blob: f162d6fa04835d5e7cfb428caf9d6d5a768385e4 [file] [log] [blame]
<input type="text" id="input">
<script>
const testCredentialIdHex = "48C4971E7805EE110EB04940EF70B7458FBC6D1E";
function hexStringToUint8Array(hexString)
{
if (hexString.length % 2 != 0)
throw "Invalid hexString";
var arrayBuffer = new Uint8Array(hexString.length / 2);
for (var i = 0; i < hexString.length; i += 2) {
var byteValue = parseInt(hexString.substr(i, 2), 16);
if (byteValue == NaN)
throw "Invalid hexString";
arrayBuffer[i/2] = byteValue;
}
return arrayBuffer;
}
if (window.internals) {
internals.setMockWebAuthenticationConfiguration({ local: { userVerification: "no", acceptAttestation: false } });
internals.withUserGesture(() => { input.focus(); });
}
const options = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: "John Appleseed",
id: new Uint8Array(16),
displayName: "Appleseed",
},
challenge: new Uint8Array(16),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
excludeCredentials: [{ type: "public-key", id: hexStringToUint8Array(testCredentialIdHex) }],
timeout: 100,
}
};
navigator.credentials.create(options);
</script>