Skip to content

Commit aa63796

Browse files
authored
fix(shared,expo-passkeys): Add docs URL to passkey_invalid_rpID_or_domain error (#8216)
1 parent b80eafb commit aa63796

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

.changeset/whole-paws-unite.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/expo-passkeys': patch
3+
'@clerk/shared': patch
4+
---
5+
6+
Add docs URL to `passkey_invalid_rpID_or_domain` error

packages/expo-passkeys/src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ export function mapNativeErrorToClerkWebAuthnErrorCode(
9494
}
9595

9696
if (code === '1002') {
97-
return new ClerkWebAuthnError(message, { code: 'passkey_invalid_rpID_or_domain' });
97+
return new ClerkWebAuthnError(message, {
98+
code: 'passkey_invalid_rpID_or_domain',
99+
docsUrl: 'https://clerk.com/docs/deployments/overview#authentication-across-subdomains',
100+
});
98101
}
99102

100103
if (code === '1003' || code === 'CreateCredentialInterruptedException') {

packages/shared/src/errors/webAuthNError.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ClerkErrorParams } from './clerkError';
12
import { ClerkRuntimeError } from './clerkRuntimeError';
23

34
type ClerkWebAuthnErrorCode =
@@ -14,14 +15,16 @@ type ClerkWebAuthnErrorCode =
1415
| 'passkey_registration_cancelled'
1516
| 'passkey_registration_failed';
1617

18+
type ClerkWebAuthnErrorOptions = Omit<ClerkErrorParams, 'message' | 'code'> & { code: ClerkWebAuthnErrorCode };
19+
1720
export class ClerkWebAuthnError extends ClerkRuntimeError {
1821
/**
1922
* A unique code identifying the error, can be used for localization.
2023
*/
2124
code: ClerkWebAuthnErrorCode;
2225

23-
constructor(message: string, { code }: { code: ClerkWebAuthnErrorCode }) {
24-
super(message, { code });
25-
this.code = code;
26+
constructor(message: string, options: ClerkWebAuthnErrorOptions) {
27+
super(message, options);
28+
this.code = options.code;
2629
}
2730
}

packages/shared/src/internal/clerk-js/passkeys.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ function handlePublicKeyError(error: Error): ClerkWebAuthnError | ClerkRuntimeEr
118118
return new ClerkWebAuthnError(error.message, { code: 'passkey_operation_aborted' });
119119
}
120120
if (error.name === 'SecurityError') {
121-
return new ClerkWebAuthnError(error.message, { code: 'passkey_invalid_rpID_or_domain' });
121+
return new ClerkWebAuthnError(error.message, {
122+
code: 'passkey_invalid_rpID_or_domain',
123+
docsUrl: 'https://clerk.com/docs/deployments/overview#authentication-across-subdomains',
124+
});
122125
}
123126
return error;
124127
}

0 commit comments

Comments
 (0)