安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
clientDataJSON
特性为
AuthenticatorResponse
interface stores a
JSON
string in an
ArrayBuffer
, representing the client data that was passed to
CredentialsContainer.create()
or
CredentialsContainer.get()
. This property is only accessed on one of the child objects of
AuthenticatorResponse
, specifically
AuthenticatorAttestationResponse
or
AuthenticatorAssertionResponse
.
var arrayBuffer = AuthenticatorAttestationResponse.clientDataJSON; var arrayBuffer = AuthenticatorAssertionResponse.clientDataJSON;
之后
clientDataJSON
object is converted from an
ArrayBuffer
to a JavaScript object, it will have the following properties:
type
"webauthn.get"
when an existing credential is retrieved or
"webauthn.create"
when a new credential is created.
challenge
PublicKeyCredentialRequestOptions.challenge
or
PublicKeyCredentialCreationOptions.challenge
.
origin
tokenBindingId
可选
An object describing the state of the token binding protocol for the communication with the relying party. It has two properties:
status
: A string which is either
"supported"
which indicates the client support token binding but did not negotiate with the relying party or
"present"
when token binding was used already
id
: A
DOMString
which is the
base64url
encoding of the token binding ID which was used for the communication.
Should this property be absent, it would indicate that the client does not support token binding.
function arrayBufferToStr(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
// pk is a PublicKeyCredential that is the result of a create() or get() Promise
var clientDataStr = arrayBufferToStr(pk.clientDataJSON);
var clientDataObj = JSON.parse(clientDataStr);
console.log(clientDataObj.type); // "webauthn.create" or "webauthn.get"
console.log(clientDataObj.challenge); // base64 encoded String containing the original challenge
console.log(clientDataObj.origin); // the window.origin
| 规范 | 状态 | 注释 |
|---|---|---|
|
Web Authentication: An API for accessing Public Key Credentials Level 1
The definition of 'clientDataJSON' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
clientDataJSON
|
Chrome
67
|
Edge 18 |
Firefox
60
|
IE No | Opera No | Safari 13 | WebView Android 70 | Chrome Android 70 |
Firefox Android
60
|
Opera Android No | Safari iOS 13.3 | Samsung Internet Android No |
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
AuthenticatorResponse
clientDataJSON