Skip to content

Commit b7f67a6

Browse files
Merge pull request #20101 from mozilla/FXA-13056
feat(passkey): create server side helper functions
2 parents adf1f60 + 7493ca0 commit b7f67a6

7 files changed

Lines changed: 882 additions & 9 deletions

File tree

libs/accounts/passkey/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ This library follows the layered architecture pattern used across `libs/accounts
5454
- Validated with class-validator decorators
5555
- Loaded from Convict config in consuming applications
5656

57+
6. **WebAuthn Adapter** (`webauthn-adapter.ts`)
58+
- Thin wrapper around `@simplewebauthn/server` v13.
59+
- Transforms between repository data structures and library format
60+
5761
### Pattern: No Module Export
5862

5963
Unlike `libs/shared/nestjs/*`, this library **does not export a NestJS module**. This is intentional:

libs/accounts/passkey/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export * from './lib/passkey.manager';
2525
export * from './lib/passkey.repository';
2626
export * from './lib/passkey.errors';
2727
export * from './lib/passkey.config';
28+
export * from './lib/webauthn-adapter';

libs/accounts/passkey/src/lib/passkey.config.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
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

Comments
 (0)