Skip to content

Instantly share code, notes, and snippets.

@MeiyappanKannappa
Last active March 15, 2024 03:13
Show Gist options
  • Select an option

  • Save MeiyappanKannappa/942642e3ff02b0e0ff7525f29b97247a to your computer and use it in GitHub Desktop.

Select an option

Save MeiyappanKannappa/942642e3ff02b0e0ff7525f29b97247a to your computer and use it in GitHub Desktop.
// Simulate the server response with registration options
const registrationOptions = {
challenge: new Uint8Array(32),
rp: { name: 'Example Corp', domain:'example.com' },
user: {
id: new TextEncoder().encode(username),
name: username,
displayName: username
},
pubKeyCredParams: [
{ type: 'public-key', alg: -7 }
]
};
// Use the WebAuthn API to create a new credential
const credential = await navigator.credentials.create({ publicKey: registrationOptions });
// Simulate sending the new credential to the server for verification and storage
console.log('Credential:', credential);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment