The PublicKeyCredential interface provides information about a public key / private key pair, which is a credential for logging in to a service using an un-phishable and data-breach resistant asymmetric key pair instead of a password. It inherits from Credential, and was created by the Web Authentication API extension to the Credential Management API. Other interfaces that inherit from Credential are PasswordCredential and FederatedCredential.
Note: This API is restricted to top-level contexts. Use from within an <iframe> element will not have any effect.
Instance properties
PublicKeyCredential.typeRead only Secure context
Inherited from Credential. Always set to public-key for PublicKeyCredential instances.
An ArrayBuffer that holds the globally unique identifier for this PublicKeyCredential. This identifier can be used to look up credentials for future calls to CredentialsContainer.get.
const options ={challenge:newUint8Array([/* bytes sent from the server */]),};
navigator.credentials
.get({publicKey: options }).then((credentialInfoAssertion)=>{// send assertion response back to the server// to proceed with the control of the credential}).catch((err)=>{
console.error(err);});