22 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
5- import { IsArray , IsBoolean , IsNumber , IsString } from 'class-validator' ;
5+ import {
6+ IsArray ,
7+ IsBoolean ,
8+ IsIn ,
9+ IsNumber ,
10+ IsOptional ,
11+ IsString ,
12+ } from 'class-validator' ;
13+ import type {
14+ AuthenticatorAttachment ,
15+ ResidentKeyRequirement ,
16+ UserVerificationRequirement ,
17+ } from '@simplewebauthn/server' ;
618
719/**
820 * Configuration for passkey (WebAuthn) functionality.
@@ -59,8 +71,9 @@ export class PasskeyConfig {
5971 * - 'discouraged': User verification should not occur
6072 * @example 'required'
6173 */
62- @IsString ( )
63- public userVerification ?: 'required' | 'preferred' | 'discouraged' ;
74+ @IsOptional ( )
75+ @IsIn ( [ 'required' , 'preferred' , 'discouraged' ] )
76+ public userVerification ?: UserVerificationRequirement ;
6477
6578 /**
6679 * Resident key (discoverable credential) requirement.
@@ -72,15 +85,17 @@ export class PasskeyConfig {
7285 * - 'discouraged': Non-discoverable credential preferred
7386 * @example 'required'
7487 */
75- @IsString ( )
76- public residentKey ?: 'required' | 'preferred' | 'discouraged' ;
88+ @IsOptional ( )
89+ @IsIn ( [ 'required' , 'preferred' , 'discouraged' ] )
90+ public residentKey ?: ResidentKeyRequirement ;
7791
7892 /**
7993 * Authenticator attachment preference.
8094 * - 'platform': Platform authenticators (built into device, like Touch ID)
8195 * - 'cross-platform': Roaming authenticators (USB security keys)
8296 * - undefined: No preference (allow any)
8397 */
84- @IsString ( )
85- public authenticatorAttachment ?: string ;
98+ @IsOptional ( )
99+ @IsIn ( [ 'platform' , 'cross-platform' ] )
100+ public authenticatorAttachment ?: AuthenticatorAttachment ;
86101}
0 commit comments