Credential
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2019.
* Some parts of this feature may have varying levels of support.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Giao diện Credential của Credential Management API cung cấp thông tin về một thực thể (thường là người dùng), thường như một điều kiện tiên quyết để đưa ra quyết định về mức độ tin cậy.
Các đối tượng Credential có thể thuộc các kiểu sau:
Thuộc tính thể hiện
Credential.idRead only-
Trả về một chuỗi chứa định danh của thông tin xác thực. Đây có thể là GUID, tên người dùng hoặc địa chỉ email.
Credential.typeRead only-
Trả về một chuỗi chứa kiểu của thông tin xác thực. Các giá trị hợp lệ là
password,federated,public-key,identityvàotp. (Dành choPasswordCredential,FederatedCredential,PublicKeyCredential,IdentityCredentialvàOTPCredential)
Phương thức tĩnh
-
Trả về một
Promiseluôn được giải quyết thànhfalse. Các lớp con có thể ghi đè giá trị này.
Ví dụ
const pwdCredential = new PasswordCredential({
id: "example-username", // Tên người dùng/ID
name: "Carina Anand", // Tên hiển thị
password: "correct horse battery staple", // Mật khẩu
});
console.assert(pwdCredential.type === "password");
Thông số kỹ thuật
| Specification |
|---|
| Credential Management Level 1> # the-credential-interface> |