PasswordCredential

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers .

The interface of the 证书管理 API provides information about a username/password pair. In supporting browsers an instance of this class may be passed in the credential member of the init object for global fetch .

注意: This interface is restricted to top-level contexts and cannot be used from an <iframe> .

构造函数

PasswordCredential() Secure context
创建新的 PasswordCredential 对象。

特性

Inherits properties from its ancestor, Credential .

PasswordCredential.additionalData Secure context
One of a FormData instance, a URLSearchParams instance, or null. The data in the objects will be added to the request body and sent to the remote endpoint with the credentials.
PasswordCredential.iconURL 只读 Secure context
A USVString containing a URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
PasswordCredential.idName Secure context
A USVString containing the name that will be used for the ID field when submitting the current object to a remote endpoint via fetch . This property defaults to 'username', but may be overridden to match whatever the backend service expects.
PasswordCredential.name 只读 Secure context
A USVString containing a human-readable public name for display in a credential chooser.
PasswordCredential.password 只读 Secure context
A USVString containing the password of the credential.
PasswordCredential.passwordName Secure context
A USVString representing the name that will be used for the password field when submitting the current object to a remote endpoint via fetch . This property defaults to 'password', but may be overridden to match whatever the backend service expects.

事件处理程序

None.

方法

None.

范例

var cred = new PasswordCredential({
  id: id,
  password: password,
  name: name,
  iconURL: iconUrl
});
navigator.credentials.store(cred)
 .then(function() {
 // Do something else.
});
					

规范

规范 状态 Comment
Credential Management Level 1 工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PasswordCredential
Chrome 51 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
PasswordCredential() 构造函数
非标
Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
additionalData
弃用
Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
iconURL
Chrome 52 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 6.0
idName
弃用
Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
name
Chrome 52 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 6.0
password
Chrome 60 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 60 Chrome Android 60 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 8.0
passwordName
弃用
Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0

图例

完整支持
完整支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。