Last active
January 4, 2019 20:19
-
-
Save yackermann/205ef29d750f0dc686f35ead04177f9a 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 challenge = new Uint8Array(32); | |
window.crypto.getRandomValues(challenge); | |
var userID = 'Kosv9fPtkDoh4Oz7Yq/pVgWHS8HhdlCto5cR0aBoVMw=' | |
var id = Uint8Array.from(window.atob(userID), c=>c.charCodeAt(0)) | |
var publicKey = { | |
'challenge': challenge, | |
'rp': { | |
'name': 'Example Inc.' | |
}, | |
'user': { | |
'id': id, | |
'name': '[email protected]', | |
'displayName': 'Alice Liddell' | |
}, | |
'pubKeyCredParams': [ | |
{ 'type': 'public-key', 'alg': -7 }, | |
{ 'type': 'public-key', 'alg': -257 } | |
] | |
} | |
navigator.credentials.create({ 'publicKey': 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