File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/shared ' : patch
3+ ---
4+
5+ Generate publishable keys with unpadded Base64 encoding to match backend output.
Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ import {
1515
1616describe ( 'buildPublishableKey(frontendApi)' , ( ) => {
1717 const cases = [
18- [ 'fake-clerk-test.clerk.accounts.dev' , 'pk_live_ZmFrZS1jbGVyay10ZXN0LmNsZXJrLmFjY291bnRzLmRldiQ= ' ] ,
18+ [ 'fake-clerk-test.clerk.accounts.dev' , 'pk_live_ZmFrZS1jbGVyay10ZXN0LmNsZXJrLmFjY291bnRzLmRldiQ' ] ,
1919 [ 'foo-bar-13.clerk.accounts.dev' , 'pk_test_Zm9vLWJhci0xMy5jbGVyay5hY2NvdW50cy5kZXYk' ] ,
20- [ 'clerk.boring.sawfly-91.lcl.dev' , 'pk_test_Y2xlcmsuYm9yaW5nLnNhd2ZseS05MS5sY2wuZGV2JA== ' ] ,
20+ [ 'clerk.boring.sawfly-91.lcl.dev' , 'pk_test_Y2xlcmsuYm9yaW5nLnNhd2ZseS05MS5sY2wuZGV2JA' ] ,
2121 [ 'clerk.boring.sawfly-91.lclclerk.com' , 'pk_test_Y2xlcmsuYm9yaW5nLnNhd2ZseS05MS5sY2xjbGVyay5jb20k' ] ,
2222 ] ;
2323
@@ -37,7 +37,7 @@ describe('parsePublishableKey(key)', () => {
3737 [ '' , null ] ,
3838 [ 'whatever' , null ] ,
3939 [
40- 'pk_live_ZmFrZS1jbGVyay10ZXN0LmNsZXJrLmFjY291bnRzLmRldiQ= ' ,
40+ 'pk_live_ZmFrZS1jbGVyay10ZXN0LmNsZXJrLmFjY291bnRzLmRldiQ' ,
4141 { instanceType : 'production' , frontendApi : 'fake-clerk-test.clerk.accounts.dev' } ,
4242 ] ,
4343 [
Original file line number Diff line number Diff line change @@ -30,17 +30,17 @@ const PUBLISHABLE_KEY_TEST_PREFIX = 'pk_test_';
3030const PUBLISHABLE_FRONTEND_API_DEV_REGEX = / ^ ( ( [ a - z ] + ) - ) { 2 } ( [ 0 - 9 ] { 1 , 2 } ) \. c l e r k \. a c c o u n t s ( [ a - z . ] * ) ( d e v | c o m ) $ / i;
3131
3232/**
33- * Converts a frontend API URL into a base64-encoded publishable key.
33+ * Converts a frontend API URL into an unpadded base64-encoded publishable key.
3434 *
3535 * @param frontendApi - The frontend API URL (e.g., 'clerk.example.com').
36- * @returns A base64-encoded publishable key with appropriate prefix (pk_live_ or pk_test_).
36+ * @returns An unpadded base64-encoded publishable key with appropriate prefix (pk_live_ or pk_test_).
3737 */
3838export function buildPublishableKey ( frontendApi : string ) : string {
3939 const isDevKey =
4040 PUBLISHABLE_FRONTEND_API_DEV_REGEX . test ( frontendApi ) ||
4141 ( frontendApi . startsWith ( 'clerk.' ) && LEGACY_DEV_INSTANCE_SUFFIXES . some ( s => frontendApi . endsWith ( s ) ) ) ;
4242 const keyPrefix = isDevKey ? PUBLISHABLE_KEY_TEST_PREFIX : PUBLISHABLE_KEY_LIVE_PREFIX ;
43- return `${ keyPrefix } ${ isomorphicBtoa ( `${ frontendApi } $` ) } ` ;
43+ return `${ keyPrefix } ${ isomorphicBtoa ( `${ frontendApi } $` ) . replace ( / = + $ / , '' ) } ` ;
4444}
4545
4646/**
You can’t perform that action at this time.
0 commit comments