Initial commit - version 1.0.0
This commit is contained in:
41
src/utils/webauthn/createCredentials.ts
Normal file
41
src/utils/webauthn/createCredentials.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import base64url from 'base64url';
|
||||
|
||||
interface Credentials {
|
||||
challenge: string;
|
||||
user: {
|
||||
displayName: string;
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const createCredentials = ({ challenge, user: { id, name, displayName } }: Credentials) =>
|
||||
// https://chromium.googlesource.com/chromium/src/+/master/content/browser/webauth/uv_preferred.md
|
||||
navigator.credentials.create({
|
||||
publicKey: {
|
||||
rp: {
|
||||
name: 'Todos',
|
||||
},
|
||||
user: {
|
||||
id: base64url.toBuffer(id),
|
||||
name,
|
||||
displayName,
|
||||
},
|
||||
challenge: base64url.toBuffer(challenge),
|
||||
pubKeyCredParams: [
|
||||
{
|
||||
type: 'public-key',
|
||||
alg: -7, // "ES256" IANA COSE Algorithms registry
|
||||
}
|
||||
],
|
||||
//attestation: 'none',
|
||||
authenticatorSelection: {
|
||||
userVerification: 'discouraged',
|
||||
//authenticatorAttachment: "platform",
|
||||
residentKey: 'required',
|
||||
},
|
||||
//extensions: {
|
||||
// credProps: true
|
||||
//}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user