Files
sonr/pkg/nebula/global/state/credentials.templ
T

87 lines
1.6 KiB
Templ

package state
templ NavigatorCredentialsCreate() {
<script>
navigator.credentials.create({
publicKey: {
rp: {
name: "Sonr",
id: "sonr.id",
},
user: {
id: new Uint8Array(0),
name: "Sonr",
displayName: "Sonr",
},
challenge: new Uint8Array(0),
pubKeyCredParams: [{
type: "public-key",
alg: -7,
}],
timeout: 60000,
excludeCredentials: [],
authenticatorSelection: {
requireResidentKey: false,
userVerification: "discouraged",
},
},
})
.then((assertion) => {
console.log("Assertion:", assertion);
})
.catch((error) => {
console.error("Error:", error);
});
</script>
}
templ NavigatorCredentialsGet() {
<script>
navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(0),
allowCredentials: [],
timeout: 60000,
userVerification: "discouraged",
},
})
.then((assertion) => {
console.log("Assertion:", assertion);
})
.catch((error) => {
console.error("Error:", error);
});
</script>
}
templ NavigatorCredentialsGetAll() {
<script>
navigator.credentials.getAll({
publicKey: {
challenge: new Uint8Array(0),
allowCredentials: [],
timeout: 60000,
userVerification: "discouraged",
},
})
.then((assertion) => {
console.log("Assertion:", assertion);
})
.catch((error) => {
console.error("Error:", error);
});
</script>
}
templ NavigatorCredentialsHasPasskey() {
<script>
navigator.credentials.has()
.then((has) => {
console.log("Has Passkey:", has);
})
.catch((error) => {
console.error("Error:", error);
});
</script>
}