CredentialsContainer
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.
凭证管理 API 的 CredentialsContainer
接口提供了一系列方法,用于请求凭证并在登录成功或注销等事件发生时通知用户代理。该接口可通过 Navigator.credentials
访问。
实例属性
无。
实例方法
CredentialsContainer.create()
-
返回一个
Promise
,根据提供的参数兑现为一个新的Credential
实例;如果无法创建Credential
对象,则兑现为null
。在特殊情况下,该Promise
可能会被拒绝。 CredentialsContainer.get()
-
返回一个
Promise
,根据提供的参数解析为匹配的Credential
实例。 CredentialsContainer.preventSilentAccess()
-
设置一个用于指定是否允许当前源在后续访问时自动登录的标志位,随后返回一个空的
Promise
。例如,当用户从网站注销后调用此方法,可确保其在下次访问时不会自动登录。该方法的早期规范版本曾命名为requireUserMediation()
。具体支持情况请参阅浏览器兼容性。 CredentialsContainer.store()
-
将用户的一组凭证存储到指定的
Credential
实例中,并通过Promise
返回该实例。
规范
Specification |
---|
Credential Management Level 1 # credentialscontainer |