2020 Safari & WebPrivacy & Security
WWDC20 · 16 min · Safari & Web / Privacy & Security
Meet Face ID and Touch ID for the web
Face ID and Touch ID provide a frictionless experience when logging in — and now you can use them on your websites in Safari with the Web Authentication API. Discover how to add this convenient and secure login alternative to your website.
Watch at developer.apple.com ↗Code shown on screen · 3 snippets
Feature detection
// Feature detection
const isAvailable = await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
if (isAvailable) {
// Continue to enrollment or sign in
// ...
} Enrollment
// Enrollment
const options = {
publicKey: {
rp: { name: "example.com" },
user: {
name: "[email protected]",
id: userIdBuffer,
displayName: "John Appleseed"
},
pubKeyCredParams: [ { type: "public-key", alg: -7 } ],
challenge: challengeBuffer,
authenticatorSelection: { authenticatorAttachment: "platform" },
attestation: "direct"
}
};
const publicKeyCredential = await navigator.credentials.create(options); Sign in
// Sign in
const options = {
publicKey: {
challenge: challengeBuffer,
allowCredentials: [{
type: "public-key",
id: credentialIdBuffer,
transports: ["internal"]
}]
}
};
const publicKeyCredential = await navigator.credentials.get(options); Resources
Related sessions
-
36 min