安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

extensions , an optional property of the PublicKeyCredentialCreationOptions dictionary, is an object providing the client extensions and their input values.

Extensions are values requesting additional processing by the client and by the authenticator. For instance, extensions may be used for:

  • backward compatibility with the legacy FIDO JS API,
  • knowing the user verification process,
  • etc.

注意: An analogous option exists for the fetching operation ( navigators.credentials.get() ), see PublicKeyCredentialRequestOptions.extensions .

句法

extensions = publicKeyCredentialCreationOptions.extensions
					

An object with various keys and values.

Here is the current (as of March 2019) list of potential extensions which may be used during the registration operation.

Warning! As of June 2020, only appId (used during creation with PublicKeyCredentialRequestOptions.extensions ) is supported by Chrome and Edge . Firefox does not seem to support any extension . Also Chrome doesn't plan to support any other extension in future

Extension identifier 类型 描述
authnSel Array of BufferSource Authenticator selection. Restricts the list of authenticator models which may be used. If no matching authenticator is available, the credential is still generated with another available authenticator.
exts 布尔 Supported extensions. If true , the client outputs an array of strings containing the extensions which are supported by the authenticator.
uvi 布尔 User verification index. If true , the client outputs an ArrayBuffer which contains a value uniquely identifying a user verification data record. In other words, this may be used server side to check if the current operation is based on the same biometric data that the previous authentication.
loc 布尔 Location. If true , the client outputs a 坐标 object representing the geolocation of the authenticator.
uvm 布尔 User verification method. If true , the client outputs an array of arrays with 3 values containing information about how the user was verified (e.g. fingerprint, pin, pattern), how the key is protected, how the matcher (tool used for the authentication operation) is protected.
biometricPerfBounds Object with two numerical properties: FAR and FRR Biometric authenticator performance bounds. The client must not use any authenticator with false acceptance rate (FAR) and false rejection rate (FRR) below the inputs. The client outputs true if this was taken into account.

注意: Extensions are optional and different browsers may recognize different extensions. All extensions are optional for the client to process them: if a browser does not know a given extension, that will not cause any failure, the extension simply will not be processed.

范例

var publicKey = {
  extensions:{
    uvi: true,
    loc: false,
    uvm: false,
    exts: true
  },
  challenge: new Uint8Array(26) /* this actually is given from the server */,
  rp: {
    name: "Example CORP",
    id  : "login.example.com"
  },
  user: {
    id: new Uint8Array(26), /* To be changed for each user */
    name: "jdoe@example.com",
    displayName: "John Doe",
  },
  pubKeyCredParams: [ {
    type: "public-key",
    alg: -7 } ]
};
navigator.credentials.create({ publicKey })
  .then(function (newCredentialInfo) {
    // myBuffer will contain the result of any of the processing of the extensions
    var myBuffer = newCredentialInfo.getClientExtensionResults();
    // send attestation response and client extensions
    // to the server to proceed with the registration
    // of the credential
  }).catch(function (err) {
     console.error(err);
  });
					

规范

规范 状态 注释
Web Authentication: An API for accessing Public Key Credentials Level 1
The definition of 'extensions' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
extensions Chrome 67 Edge ≤79 Firefox 60 IE ? Opera ? Safari 13 WebView Android No Chrome Android 67 Firefox Android ? Opera Android ? Safari iOS 13.3 Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改: