Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/whole-paws-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/expo-passkeys': patch
'@clerk/shared': patch
---

Add docs URL to `passkey_invalid_rpID_or_domain` error
5 changes: 4 additions & 1 deletion packages/expo-passkeys/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export function mapNativeErrorToClerkWebAuthnErrorCode(
}

if (code === '1002') {
return new ClerkWebAuthnError(message, { code: 'passkey_invalid_rpID_or_domain' });
return new ClerkWebAuthnError(message, {
code: 'passkey_invalid_rpID_or_domain',
docsUrl: 'https://clerk.com/docs/deployments/overview#authentication-across-subdomains',
});
}

if (code === '1003' || code === 'CreateCredentialInterruptedException') {
Expand Down
9 changes: 6 additions & 3 deletions packages/shared/src/errors/webAuthNError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ClerkErrorParams } from './clerkError';
import { ClerkRuntimeError } from './clerkRuntimeError';

type ClerkWebAuthnErrorCode =
Expand All @@ -14,14 +15,16 @@ type ClerkWebAuthnErrorCode =
| 'passkey_registration_cancelled'
| 'passkey_registration_failed';

type ClerkWebAuthnErrorOptions = Omit<ClerkErrorParams, 'message' | 'code'> & { code: ClerkWebAuthnErrorCode };

export class ClerkWebAuthnError extends ClerkRuntimeError {
/**
* A unique code identifying the error, can be used for localization.
*/
code: ClerkWebAuthnErrorCode;

constructor(message: string, { code }: { code: ClerkWebAuthnErrorCode }) {
super(message, { code });
this.code = code;
constructor(message: string, options: ClerkWebAuthnErrorOptions) {
super(message, options);
this.code = options.code;
}
}
5 changes: 4 additions & 1 deletion packages/shared/src/internal/clerk-js/passkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ function handlePublicKeyError(error: Error): ClerkWebAuthnError | ClerkRuntimeEr
return new ClerkWebAuthnError(error.message, { code: 'passkey_operation_aborted' });
}
if (error.name === 'SecurityError') {
return new ClerkWebAuthnError(error.message, { code: 'passkey_invalid_rpID_or_domain' });
return new ClerkWebAuthnError(error.message, {
code: 'passkey_invalid_rpID_or_domain',
docsUrl: 'https://clerk.com/docs/deployments/overview#authentication-across-subdomains',
});
}
return error;
}
Expand Down
Loading