const requestCredentialOptionsJSON = {
challenge: new Uint8Array([139, 66, 181, 87, 7, 203 /* … */]),
rpId: "acme.com",
allowCredentials: [
{
type: "public-key",
id: new Uint8Array([64, 66, 25, 78, 168, 226, 174 /* … */]),
},
],
userVerification: "required",
};PublicKeyCredential: parseRequestOptionsFromJSON() static method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
JSON.stringify(requestCredentialOptionsJSON);// Convert options to form used by get()
const publicKey = PublicKeyCredential.parseRequestOptionsFromJSON(
requestCredentialOptionsJSON, // JSON-type representation
);
navigator.credentials
.get({ publicKey })
.then((returnedCredentialInfo) => {
// Handle the returned credential information here.
})
.catch((err) => {
console.error(err);
});