PublicKeyCredentialCreationOptions
安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。
PublicKeyCredentialCreationOptions
は Web Authentication API の辞書で、 navigators.credentials.create()
で PublicKeyCredential
を生成するために渡されるオプションを保持します。
プロパティ
PublicKeyCredentialCreationOptions.rp
(en-US)- 資格情報の生成のリクエスト元を示すオブジェクトです。
PublicKeyCredentialCreationOptions.user
(en-US)- 資格情報が生成されるユーザーアカウントを示すオブジェクトです。
PublicKeyCredentialCreationOptions.challenge
(en-US)BufferSource
型で、証明書利用者のサーバーによって生成され、暗号チャレンジとして使用されるものです。この値は認証プロバイダーによって署名され、署名はAuthenticatorAssertionResponse.signature
(en-US) の一部として送り返されます。PublicKeyCredentialCreationOptions.pubKeyCredParams
(en-US)Array
型で、資格情報に要求される機能を指定する要素の配列です。暗号化署名の操作で使用される種類とアルゴリズムを含みます。この配列は設定の降順で並べ替えられます。PublicKeyCredentialCreationOptions.timeout
(en-US) 省略可- 数値のヒントで、取得操作が完了するまで呼び出し元が待機する時間をミリ秒単位で表します。このヒントは、ブラウザーによって上書きされる場合があります。
PublicKeyCredentialCreationOptions.excludeCredentials
省略可Array
で、既存の資格情報の記述子の配列です。これは、すでに資格情報を持つ既存のユーザーが新しい公開鍵資格情報を生成することを防ぐために、認証者によって提供されます。PublicKeyCredentialCreationOptions.authenticatorSelection
省略可- 生成操作で使用可能な認証機器を絞り込む条件をプロパティに持つオブジェクトです。
PublicKeyCredentialCreationOptions.attestation
(en-US) 省略可String
で、認証結果を (認証機器の元が) 送信する方法を示します。PublicKeyCredentialCreationOptions.extensions
(en-US) 省略可- 複数のクライアント拡張機能の入力を持つオブジェクトです。これらの拡張機能は、追加の処理を要求するために使用されます (例えば、従来の FIDO API 資格情報を処理、認証端末上でのテキストの要求など)。
メソッド
なし。
例
// some examples of COSE algorithms
const cose_alg_ECDSA_w_SHA256 = -7;
const cose_alg_ECDSA_w_SHA512 = -36;
var createCredentialOptions = {
// Format of new credentials is publicKey
publicKey: {
// Relying Party
rp: {
name: "Example CORP",
id: "login.example.com",
icon: "https://login.example.com/login.ico"
},
// Cryptographic challenge from the server
challenge: new Uint8Array(26),
// User
user: {
id: new Uint8Array(16),
name: "john.p.smith@example.com",
displayName: "John P. Smith",
},
// Requested format of new keypair
pubKeyCredParams: [{
type: "public-key",
alg: cose_alg_ECDSA_w_SHA256,
}],
// Timeout after 1 minute
timeout: 60000,
// Do not send the authenticator's origin attestation
attestation: "none",
extensions: {
uvm: true,
exts: true
},
// Filter out authenticators which are bound to the device
authenticatorSelection:{
authenticatorAttachment: "cross-platform",
requireResidentKey: true,
userVerification: "preferred"
},
// Exclude already existing credentials for the user
excludeCredentials: [
{
type: "public-key",
// the id for john.doe@example.com
id : new Uint8Array(26) /* this actually is given by the server */
},
{
type: "public-key",
// the id for john-doe@example.com
id : new Uint8Array(26) /* another id */
}
]
}
};
// Create the new credential with the options above
navigator.credentials.create(createCredentialOptions)
.then(function (newCredentialInfo) {
var attestationResponse = newCredentialInfo.response;
var clientExtensionsOutputs = newCredentialInfo.getClientExtensionsResults();
// Send the response to the relying party server
// it will verify the content and integrity before
// creating a new credential
}).catch(function (err) {
// Deal with any error properly
console.error(err);
});;
仕様書
ブラウザーの互換性
No compatibility data found for api.PublicKeyCredentialCreationOptions
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.
関連情報
PublicKeyRequestOptions
: 公開鍵を受け取る操作のオプションを提供する辞書