Created
December 3, 2018 20:35
-
-
Save herrjemand/c0f31e68f312d9f9eaa7af798b39d3ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var randomChallengeBuffer = new Uint8Array(32); | |
window.crypto.getRandomValues(randomChallengeBuffer); | |
var base64id = 'MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=' | |
var idBuffer = Uint8Array.from(window.atob(base64id), c=>c.charCodeAt(0)) | |
var publicKey = { | |
challenge: randomChallengeBuffer, | |
rp: { | |
name: 'FIDO Example Corporation', | |
icon: 'https://fidoalliance.co.nz/testimages/catimage.png' | |
}, | |
user: { | |
id: idBuffer, | |
name: "alice@example.com", | |
displayName: "Alice von Wunderland", | |
icon: 'https://fidoalliance.co.nz/testimages/catimage.png' | |
}, | |
attestation: 'direct', | |
authenticatorSelection: { | |
'authenticatorAttachment': 'platform' | |
}, | |
pubKeyCredParams: [ | |
{ type: 'public-key', alg: -7 }, // ES256 | |
{ type: 'public-key', alg: -257 } // RS256 | |
] | |
} | |
navigator.credentials.create({ publicKey }) | |
.then((newCredentialInfo) => { | |
console.log('SUCCESS', newCredentialInfo) | |
}) | |
.catch((error) => { | |
console.log('FAIL', error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment