大网数据广告活动
Web 标准与前端开发

PublicKeyCredential: getClientExtensionResults() method

· 52CE 我爱测

The **`getClientExtensionResults()`** method of the PublicKeyCredential interface returns an object mapping the identifiers of extensions requested during credential creation or authentication, and their results after processing by the user agent.

Web Authentication API

The getClientExtensionResults() method of the PublicKeyCredential interface returns an object mapping the identifiers of extensions requested during credential creation or authentication, and their results after processing by the user agent.

During the creation or fetching of a PublicKeyCredential (via CredentialsContainer.create() and CredentialsContainer.get() respectively), it is possible to request "custom" processing by the client for different extensions, specified in the publicKey option's extensions property. You can find more information about requesting the different extensions in Web Authentication extensions.

[!NOTE] getClientExtensionResults() only returns the results from extensions processed by the user agent (client). The results from extensions processed by the authenticator can be found in the authenticator data available in AuthenticatorAssertionResponse.authenticatorData.

Syntax

getClientExtensionResults()

Parameters

None.

Return value

An object with each entry being an extensions' identifier string as the key, and the output from the processing of the extension by the client as the value.

Exceptions

  • SecurityError DOMException
    • : The RP domain is not valid.

Examples

const publicKey = {
  // Here are the extension "inputs"
  extensions: {
    appid: "https://accounts.example.com",
  },
  allowCredentials: {
    id: "fgrt46jfgd...",
    transports: ["usb", "nfc"],
    type: "public-key",
  },
  challenge: new Uint8Array(16) /* from the server */,
};

navigator.credentials
  .get({ publicKey })
  .then((publicKeyCred) => {
    const myResults = publicKeyCred.getClientExtensionResults();
    // myResults will contain the output of processing the "appid" extension
  })
  .catch((err) => {
    console.error(err);
  });

Specifications

Browser compatibility

[!NOTE] Extensions are optional and different browsers may recognize different extensions. Processing extensions is always optional for the client: if a browser does not recognize a given extension, it will just ignore it. For information on which extensions are supported by which browsers, see Web Authentication extensions.

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。