File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed
Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/shared ' : patch
3+ ---
4+
5+ Catching ATOB errors in isPublishableKey
Original file line number Diff line number Diff line change @@ -69,14 +69,22 @@ export function parsePublishableKey(
6969 } ;
7070}
7171
72- export function isPublishableKey ( key : string ) {
73- key = key || '' ;
74-
75- const hasValidPrefix = key . startsWith ( PUBLISHABLE_KEY_LIVE_PREFIX ) || key . startsWith ( PUBLISHABLE_KEY_TEST_PREFIX ) ;
76-
77- const hasValidFrontendApiPostfix = isomorphicAtob ( key . split ( '_' ) [ 2 ] || '' ) . endsWith ( '$' ) ;
78-
79- return hasValidPrefix && hasValidFrontendApiPostfix ;
72+ /**
73+ * Checks if the provided key is a valid publishable key.
74+ *
75+ * @param key - The key to be checked. Defaults to an empty string if not provided.
76+ * @returns `true` if 'key' is a valid publishable key, `false` otherwise.
77+ */
78+ export function isPublishableKey ( key : string = '' ) {
79+ try {
80+ const hasValidPrefix = key . startsWith ( PUBLISHABLE_KEY_LIVE_PREFIX ) || key . startsWith ( PUBLISHABLE_KEY_TEST_PREFIX ) ;
81+
82+ const hasValidFrontendApiPostfix = isomorphicAtob ( key . split ( '_' ) [ 2 ] || '' ) . endsWith ( '$' ) ;
83+
84+ return hasValidPrefix && hasValidFrontendApiPostfix ;
85+ } catch {
86+ return false ;
87+ }
8088}
8189
8290export function createDevOrStagingUrlCache ( ) {
You can’t perform that action at this time.
0 commit comments