user inputs name and presses 'register'
normally, js would 'ping' the server with the username, and receive a challenge. ( also verifying that the username is available ) however, i'm hardcoding the challenge in this proof-of-concept. 01234567-89ab-cdef-0123-456789abcdef
// webauthn.io
// webauthn.guide
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto
var u8a = new Uint8Array( 16 );
crypto.getRandomValues( u8a );
console.log( u8a );
var challenge = [
98, 47, 153, 237,
143, 250, 156, 209,
26, 151, 122, 91,
66, 48, 3, 11,
];
////
var assertionRequest = await navigator.credentials.create( {
} );
navigator.credentials.create({
publicKey: {
rp: {
id: 'dirtand.rocks',
name: 'dirt and rocks',
}
user: {
// id: 327, // what is this for...
name:
displayName:
}
challenge: challenge,
pubKeyCredParams: [
{
type: 'public-key',
alg: -7,
},
// {
// type: 'public-key',
// alg:
// },
]
timeout:
excludeCredentials: [
{
type: 'public-key',
id:
transports: [ USB NFC BLE INTERNAL
]
}
]
authenticatorSelection: {
authenticatorAttachment:
residentKey:
requireResidentKey
userVerification:
}
attestation:
}
extensions: {
credProps
credentialProtectionPolicy:
enforceCredentialProtectionPolicy
minPinLength
uvm
}
});
todo: finish copying from webauthn.guide ...