Credential
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Credential Management API")}}{{securecontext_header}}
The **Credential** interface of the Credential Management API provides information about an entity (usually a user) normally as a prerequisite to a trust decision.
Credential objects may be of the following types:
- {{domxref("FederatedCredential")}}
- {{domxref("IdentityCredential")}}
- {{domxref("PasswordCredential")}}
- {{domxref("PublicKeyCredential")}}
- {{domxref("OTPCredential")}}
Instance properties
- {{domxref("Credential.id")}} {{ReadOnlyInline}}
- : Returns a string containing the credential's identifier. This might be any one of a GUID, username, or email address.
- {{domxref("Credential.type")}} {{ReadOnlyInline}}
- : Returns a string containing the credential's type. Valid values are
password,federated,public-key,identityandotp. (For {{domxref("PasswordCredential")}}, {{domxref("FederatedCredential")}}, {{domxref("PublicKeyCredential")}}, {{domxref("IdentityCredential")}} and {{domxref("OTPCredential")}})
Static methods
- {{domxref("Credential.isConditionalMediationAvailable_static", "Credential.isConditionalMediationAvailable()")}}
- : Returns a {{jsxref("Promise")}} which always resolves to
false. Subclasses may override this value.
Examples
js
const pwdCredential = new PasswordCredential({
id: "example-username", // Username/ID
name: "Carina Anand", // Display name
password: "correct horse battery staple", // Password
});
console.assert(pwdCredential.type === "password");Specifications
{{Specifications}}
Browser compatibility
{{Compat}}