--- title: PublicKeyCredentialCreationOptions slug: Web/API/PublicKeyCredentialCreationOptions tags: - API - Dictionary - PublicKeyCredentialCreationOptions - Reference - Web Authentication API - WebAuthn translation_of: Web/API/PublicKeyCredentialCreationOptions ---
PublicKeyCredentialCreationOptions
は Web Authentication API の辞書で、 {{domxref("CredentialsContainer.create()","navigators.credentials.create()")}} で {{domxref("PublicKeyCredential")}} を生成するために渡されるオプションを保持します。
なし。
// 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); });;
仕様書 | 状態 | 備考 |
---|---|---|
{{SpecName('WebAuthn','#dictdef-publickeycredentialcreationoptions', 'PublicKeyCredentialCreationOptions dictionary')}} | {{Spec2('WebAuthn')}} | 初回定義 |
{{Compat("api.PublicKeyCredentialCreationOptions")}}