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

getTransports() is a method of the AuthenticatorAttestationResponse interface that returns an 数组 containing strings describing the different transports which may be used by the authenticator.

Such transports may be USB, NFC, BLE or internal (applicable when the authenticator is not removable from the device).

注意: An AuthenticatorAttestationResponse instance is available on PublicKeyCredential.response after calling navigator.credentials.create() .

注意: This method may only be used in top-level contexts and will not be available in an <iframe> 例如。

Syntaxe

arrTransports = authenticatorAttestationResponse.getTransports()
					

参数

None.

返回值

数组 containing the different transports supported by the authenticator or nothing if this information is not available.of the processing of the different extensions by the client. The elements of this array are supposed to be in lexicographical order. Their values may be :

  • "usb" : the authenticator can be contacted via a removable USB link
  • "nfc" : the authenticator may be used over NFC (Near Field Communication)
  • "ble" : the authenticator may be used over BLE (Bluetooth Low Energy)
  • "internal" : the authenticator is specifically bound to the client device (cannot be removed).

范例

var publicKey = {
  challenge: /* from the server */,
  rp: {
    name: "Example CORP",
    id  : "login.example.com"
  },
  user: {
    id: new Uint8Array(16),
    name: "jdoe@example.com",
    displayName: "John Doe"
  },
  pubKeyCredParams: [
    {
      type: "public-key",
      alg: -7
    }
  ]
};
navigator.credentials.create({ publicKey })
  .then(function (newCredentialInfo) {
    var transports = newCredentialInfo.response.getTransports();
    console.table(transports); // may be something like ["internal", "nfc", "usb"]
  }).catch(function (err) {
     console.error(err);
  });
					

规范

规范 状态 注释
Web Authentication: An API for accessing Public Key Credentials Level 1
The definition of 'getTransports()' 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
getTransports Chrome No Edge No Firefox No IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No

图例

不支持

不支持

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

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

元数据

  • 最后修改: