-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
k
committed
Oct 22, 2024
1 parent
8aecdba
commit 3b2d5d0
Showing
1 changed file
with
38 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,44 +4,50 @@ date: 2019-11-07 | |
layout: post | ||
--- | ||
<script> | ||
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: { id: "scateu.me", name: "scateu.me" }, | ||
|
||
user: { | ||
id: idBuffer, | ||
name: "[email protected]", | ||
displayName: "Alice von Wunderland" | ||
}, | ||
|
||
attestation: 'none', | ||
|
||
pubKeyCredParams: [ | ||
{ type: 'public-key', alg: -7 }, // ES256 | ||
{ type: 'public-key', alg: -257 } // RS256 | ||
] | ||
function doFunction() { | ||
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: { id: "scateu.me", name: "scateu.me" }, | ||
|
||
user: { | ||
id: idBuffer, | ||
name: "[email protected]", | ||
displayName: "Alice von Wunderland" | ||
}, | ||
|
||
attestation: 'none', | ||
|
||
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) | ||
}) | ||
} | ||
|
||
navigator.credentials.create({ publicKey }) | ||
.then((newCredentialInfo) => { | ||
console.log('SUCCESS', newCredentialInfo) | ||
}) | ||
.catch((error) => { | ||
console.log('FAIL', error) | ||
}) | ||
|
||
</script> | ||
|
||
|
||
在此页面(一定要有https,感兴趣的同学可以访问http的此页面观察对比现象) | ||
随手打开Console,粘! | ||
|
||
或者 | ||
|
||
<input id="clickMe" type="button" value="FIDO注册" onclick="doFunction();" /> | ||
|
||
注意:里面相关ID的scateu.me字样要与域名相匹配。 | ||
|
||
|
||
|