Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/tender-bears-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': patch
---

isPublishableKey(key) catches atob error
12 changes: 8 additions & 4 deletions packages/shared/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ export function parsePublishableKey(
}

export function isPublishableKey(key: string) {
key = key || '';
try {
key = key || '';

const hasValidPrefix = key.startsWith(PUBLISHABLE_KEY_LIVE_PREFIX) || key.startsWith(PUBLISHABLE_KEY_TEST_PREFIX);
const hasValidPrefix = key.startsWith(PUBLISHABLE_KEY_LIVE_PREFIX) || key.startsWith(PUBLISHABLE_KEY_TEST_PREFIX);

const hasValidFrontendApiPostfix = isomorphicAtob(key.split('_')[2] || '').endsWith('$');
const hasValidFrontendApiPostfix = isomorphicAtob(key.split('_')[2] || '').endsWith('$');

return hasValidPrefix && hasValidFrontendApiPostfix;
return hasValidPrefix && hasValidFrontendApiPostfix;
} catch {
return false;
}
}

export function createDevOrStagingUrlCache() {
Expand Down
Loading