CredentialsContainer

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

Credential Management APICredentialsContainer 接口提供了请求 credentials 和通知用户代理(当成功登陆或登出事件发生时)的方法。可通过 Navigator.credentials 获得该接口。

属性

None.

事件

None.

返回一个带有处理值 Credential(若它能够使用提供的选项创建的话)的 Promise ,或返回 null(若不能创建 Credential)。在特殊情况下,返回的 Promise 对象可能 reject。

方法

CredentialsContainer.create()

Returns a Promise that resolves with a new Credential instance based on the provided options, or null of no Credential object can be created.

CredentialsContainer.get()

Returns a Promise that resolves with the Credential instance that matches the provided parameters.

CredentialsContainer.preventSilentAccess()

Sets a flag that specifies whether automatic log in is allowed for future visits to the current origin, then returns an empty Promise. For example, you might call this, after a user signs out of a website to ensure that he/she isn't automatically signed in on the next site visit. Earlier versions of the spec called this method requireUserMediation(). See Browser compatibility for support details.

CredentialsContainer.store()

Stores a set of credentials for a user, inside a provided Credential instance and returns that instance in a Promise.

示例

js
// TBD

Specifications

Specification
Credential Management Level 1
# credentialscontainer

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CredentialsContainer
create
publicKey option
attestation option
attestation.direct
attestation.enterprise
attestation.indirect
attestation.none
create() extensions
appidExclude extension
credProps extension
credProtect extension
Experimental
largeBlob extension
minPinLength extension
payment extension
publicKey_option.requireResidentKey
Experimental
publicKey_option.residentKey
get
identity option
Experimental
identity.context
Experimental
Error API
ExperimentalNon-standard
identity.providers.loginHint
Experimental
otp option
Experimental
publicKey option
get() extensions
appid extension
largeBlob extension
Experimental
preventSilentAccess
store

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
See implementation notes.
Uses a non-standard name.
Has more compatibility info.