const publicKey = {
challenge: new Uint8Array([117, 61, 252, 231, 191, 241 /* … */]),
rp: { id: "acme.com", name: "ACME Corporation" },
user: {
id: new Uint8Array([79, 252, 83, 72, 214, 7, 89, 26]),
name: "jamiedoe",
displayName: "Jamie Doe",
},
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
authenticatorSelection: {
residentKey: "preferred",
},
extensions: {
credProps: true,
minPinLength: true,
},
};Web Authentication extensions / notebook
Web Authentication extensions
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
navigator.credentials.create({ publicKey });navigator.credentials
.create({ publicKey })
.then((publicKeyCred) => {
const myClientExtResults = publicKeyCred.getClientExtensionResults();
// myClientExtResults will contain the output of processing
// the "credProps" extension
const authData = publicKeyCred.response.getAuthenticatorData();
// authData will contain authenticator data, which will include
// authenticator extension processing results, i.e., minPinLength
})
.catch((err) => {
console.error(err);
});({
extensions: {
appid: "https://accounts.example.com",
},
});({
allowCredentials: [
{
id: arrayBuffer, // needs to contain decoded binary form of id
transports: ["nfc", "usb"],
type: "public-key",
},
],
});({
extensions: {
appidExclude: "https://accounts.example.com",
},
});({
excludeCredentials: [
{
id: arrayBuffer, // needs to contain decoded binary form of id
transports: ["nfc", "usb"],
type: "public-key",
},
],
});({
extensions: {
credProps: true,
},
});({
authenticatorSelection: {
requireResidentKey: true,
},
});({
credProps: {
rk: true,
},
});({
extensions: {
credentialProtectionPolicy: "userVerificationOptional",
enforceCredentialProtectionPolicy: true,
},
});({ credProtect: 0x01 });({
extensions: {
largeBlob: {
support: "required",
},
},
});({
extensions: {
largeBlob: {
read: true,
},
},
});({
extensions: {
largeBlob: {
write: arrayBuffer,
},
},
});({
largeBlob: {
supported: true, // false if it cannot store blobs
},
});({
largeBlob: {
blob: arrayBuffer,
},
});({
largeBlob: {
written: true,
},
});({
extensions: {
minPinLength: true,
},
});({ minPinLength: uint });({
extensions: {
prf: {
eval: { first: new TextEncoder().encode("Salt for new symmetric key") },
},
},
});({
extensions: {
prf: {
eval: {
first: currentSessionKey, // salt for current session
second: nextSessionKey, // salt for next session
},
},
},
});({
extensions: {
prf: {
evalByCredential: {
"<credentialId>": { first: bufferOne, second: bufferTwo },
// …
"<credentialId2>": {
first: anotherBufferOne,
second: anotherBufferTwo,
},
},
},
},
});({
prf: {
enabled: true, // PRF can be used when creating credentials.
results: { first: outputBuffer1, second: outputBuffer2 },
},
});({
prf: {
enabled: false, // PRF cannot be used when creating credentials.
},
});({
prf: {
results: { first: outputBuffer1, second: outputBuffer2 },
},
});({
prf: {},
});