providers/webauthn
WebAuthnConfig
すべての ProviderType で共有
拡張
プロパティ
authenticationOptions?
optional authenticationOptions: Partial<ConfigurableAuthenticationOptions>;
に渡される認証オプション
Simplewebauthn
認証中。
enableConditionalUI
enableConditionalUI: boolean;
条件付きUIを有効にします。
注:このオプションを有効にできるプロバイダーは一度に1つだけです。デフォルトは true
です。
formFields
formFields: Record<string, CredentialInput>;
デフォルトのパスキーサインイン/サインアップフォームに表示されるフォームフィールド。これらは、デフォルトのAuth.js認証ページ以外では検証または強制されません。
デフォルトでは、メールフィールドが表示されます。
getRelayingParty()
getRelayingParty: (options, request) => RelayingParty;
現在のリクエストのリレーイングパーティを返す関数。
パラメーター
パラメーター | 型 |
---|---|
options | InternalOptions <"webauthn" > |
request | RequestInternal |
戻り値
getUserInfo
getUserInfo: GetUserInfo;
認証器が登録と認証中に使用するユーザー情報を返す関数。
- プロバイダーオプション、リクエストオブジェクトを受け取り、ユーザー情報を返します。
- リクエストに既存のユーザーデータ(例:メールアドレス)が含まれている場合、関数は既存のユーザーを返し、
exists
はtrue
である必要があります。 - リクエストに新しいユーザーを作成するのに十分な情報が含まれている場合、関数は新しいユーザー情報を返し、
exists
はfalse
である必要があります。 - リクエストに新しいユーザーを作成するのに十分な情報が含まれていない場合、関数は
null
を返す必要があります。
副作用があってはなりません(つまり、データベースを変更してはなりません)。
パスキー作成中
- パスキーのユーザーIDはランダムな文字列になります。
- パスキーのユーザー名は user.email になります
- パスキーのユーザー表示名は、user.name が存在する場合は user.name、それ以外の場合は user.email になります
デフォルトでは、「email」リクエストパラメーターを検索して使用し、データベース内のユーザーを検索します。
id
id: string;
AuthConfig.providers でプロバイダーを一意に識別します。URLの一部でもあります
継承元
name
name: string;
デフォルトのサインインページのサインインボタンで使用されるプロバイダー名。たとえば、「Google」の場合、対応するボタンには「Googleでサインイン」と表示されます。
継承元
registrationOptions
registrationOptions: Partial<ConfigurableRegistrationOptions>;
に渡される登録オプション
Simplewebauthn
登録中。
relayingParty?
optional relayingParty: Partial<RelayingPartyArray>;
リレーイングパーティ(RP)構成
提供されない場合、リクエストURLが使用されます。
simpleWebAuthn
simpleWebAuthn: {
generateAuthenticationOptions: (options?) => Promise<PublicKeyCredentialRequestOptionsJSON>;
generateRegistrationOptions: (options) => Promise<PublicKeyCredentialCreationOptionsJSON>;
verifyAuthenticationResponse: (options) => Promise<VerifiedAuthenticationResponse>;
verifyRegistrationResponse: (options) => Promise<VerifiedRegistrationResponse>;
};
登録と認証に使用するSimpleWebAuthnインスタンス。
generateAuthenticationOptions()
generateAuthenticationOptions: (options?) => Promise<PublicKeyCredentialRequestOptionsJSON>;
認証器の「ログイン」のために、navigator.credentials.get(…) に渡す値を準備します
パラメーター
パラメーター | 型 |
---|---|
options ? | GenerateAuthenticationOptionsOpts |
戻り値
Promise
<PublicKeyCredentialRequestOptionsJSON
>
generateRegistrationOptions()
generateRegistrationOptions: (options) => Promise<PublicKeyCredentialCreationOptionsJSON>;
認証器の「登録」のために、navigator.credentials.create(…)に渡す値を準備します。
オプション
パラメータ
パラメーター | 型 |
---|---|
options | GenerateRegistrationOptionsOpts |
戻り値
Promise
<PublicKeyCredentialCreationOptionsJSON
>
verifyAuthenticationResponse()
verifyAuthenticationResponse: (options) => Promise<VerifiedAuthenticationResponse>;
ユーザーが正当にログインプロセスを完了したことを検証します
オプション
パラメータ
パラメーター | 型 |
---|---|
options | VerifyAuthenticationResponseOpts |
戻り値
Promise
<VerifiedAuthenticationResponse
>
verifyRegistrationResponse()
verifyRegistrationResponse: (options) => Promise<VerifiedRegistrationResponse>;
ユーザーが正当に登録プロセスを完了したことを検証します
オプション
パラメータ
パラメーター | 型 |
---|---|
options | VerifyRegistrationResponseOpts |
戻り値
Promise
<VerifiedRegistrationResponse
>
simpleWebAuthnBrowserVersion
simpleWebAuthnBrowserVersion: false | SemverString;
サインインページにロードするSimpleWebAuthnブラウザスクリプトのバージョン。
これは、プロバイダーで条件付きUIが有効になっている場合にのみロードされます。falseに設定した場合、スクリプトはロードされません。デフォルトはv9.0.0
です。
type
type: "webauthn";
ProviderTypeを参照してください。
オーバーライド
verifyAuthenticationOptions?
optional verifyAuthenticationOptions: Partial<ConfigurableVerifyAuthenticationOptions>;
に渡される認証オプションを検証します
Simplewebauthn
認証中。
verifyRegistrationOptions?
optional verifyRegistrationOptions: Partial<ConfigurableVerifyRegistrationOptions>;
に渡される登録オプションを検証します
Simplewebauthn
登録中。
GetUserInfo()
type GetUserInfo: (options, request) => Promise<{
exists: true;
user: User;
} | {
exists: false;
user: Omit<User, "id">;
} | null>;
パラメータ
パラメーター | 型 |
---|---|
options | InternalOptions <WebAuthnProviderType > |
request | RequestInternal |
戻り値
Promise
<{ exists
: true
; user
: User
; } | { exists
: false
; user
: Omit
<User
, "id"
>; } | null
>
RelayingParty
type RelayingParty: {
id: string;
name: string;
origin: string;
};
型宣言
id
id: string;
リライングパーティID。ウェブサイトのドメイン名を使用します。
name
name: string;
リライングパーティ名。ウェブサイトの名前を使用します。
origin
origin: string;
リライングパーティのオリジン。ウェブサイトのオリジンを使用します。
WebAuthnProviderType
type WebAuthnProviderType: "webauthn";
DEFAULT_SIMPLEWEBAUTHN_BROWSER_VERSION
const DEFAULT_SIMPLEWEBAUTHN_BROWSER_VERSION: SemverString = "v9.0.1";
DEFAULT_WEBAUTHN_TIMEOUT
const DEFAULT_WEBAUTHN_TIMEOUT: number;
default()
default(config): WebAuthnConfig
WebAuthnログインをページに追加します。
セットアップ
構成
import { Auth } from "@auth/core"
import WebAuthn from "@auth/core/providers/webauthn"
const request = new Request(origin)
const response = await Auth(request, {
providers: [WebAuthn],
})
リソース
WebAuthnプロバイダーには、デフォルト設定が付属しています。ユースケースに合わせてデフォルトをオーバーライドするには、組み込みのWebAuthnプロバイダーのカスタマイズをご覧ください。
パラメータ
パラメーター | 型 |
---|---|
config | Partial <WebAuthnConfig > |