Skip to content

Commit 4ce4abe

Browse files
authored
Merge pull request #20226 from mozilla/FXA-13303
task(passkeys): Use AppErrors instead of passkey.errors.ts
2 parents 9e880f4 + 7e47a96 commit 4ce4abe

8 files changed

Lines changed: 71 additions & 364 deletions

File tree

libs/accounts/errors/src/app-error.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,13 +1741,18 @@ export class AppError extends Error {
17411741
});
17421742
}
17431743

1744-
static passkeyLimitReached() {
1745-
return new AppError({
1746-
code: 400,
1747-
error: 'Bad Request',
1748-
errno: ERRNO.PASSKEY_LIMIT_REACHED,
1749-
message: 'Maximum number of passkeys reached',
1750-
});
1744+
static passkeyLimitReached(limit: number) {
1745+
return new AppError(
1746+
{
1747+
code: 400,
1748+
error: 'Bad Request',
1749+
errno: ERRNO.PASSKEY_LIMIT_REACHED,
1750+
message: 'Maximum number of passkeys reached',
1751+
},
1752+
{
1753+
limit,
1754+
}
1755+
);
17511756
}
17521757

17531758
static passkeyAuthenticationFailed() {
@@ -1777,6 +1782,15 @@ export class AppError extends Error {
17771782
});
17781783
}
17791784

1785+
static passkeyChallengeNotFound() {
1786+
return new AppError({
1787+
code: 404,
1788+
error: 'Not Found',
1789+
errno: ERRNO.PASSKEY_CHALLENGE_NOT_FOUND,
1790+
message: 'Passkey challenge not found',
1791+
});
1792+
}
1793+
17801794
private static decorateErrorWithRequest(error: AppError, request?: Request) {
17811795
if (request) {
17821796
error.output.payload.request = {

libs/accounts/errors/src/index.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ describe('AppErrors', () => {
369369
});
370370

371371
it('creates passkeyLimitReached', () => {
372-
const result = AppError.passkeyLimitReached();
372+
const result = AppError.passkeyLimitReached(3);
373373
expect(result).toBeInstanceOf(AppError);
374374
expect(result).toMatchObject({
375375
errno: 226,
@@ -379,6 +379,7 @@ describe('AppErrors', () => {
379379
payload: {
380380
error: 'Bad Request',
381381
errno: 226,
382+
limit: 3,
382383
},
383384
},
384385
});

libs/accounts/passkey/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
* - PasskeyService: High-level business logic for passkey operations
1111
* - PasskeyManager: Database access layer for passkey storage
1212
* - Repository functions: Pure data access functions (findPasskeysByUid, etc.)
13-
* - PasskeyError: Base error class for passkey-specific errors
1413
* - PasskeyConfig: Configuration class
1514
*
1615
* Types (import directly from shared):
@@ -23,7 +22,6 @@
2322
export * from './lib/passkey.service';
2423
export * from './lib/passkey.manager';
2524
export * from './lib/passkey.repository';
26-
export * from './lib/passkey.errors';
2725
export * from './lib/passkey.config';
2826
export * from './lib/passkey.provider';
2927
export * from './lib/passkey.challenge.manager';

libs/accounts/passkey/src/lib/passkey.errors.spec.ts

Lines changed: 0 additions & 147 deletions
This file was deleted.

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

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)