Skip to content

Commit acafd5b

Browse files
committed
chore(*): Enforce publishableKey to IsomorphicClerkOptions
1 parent cc7cfba commit acafd5b

File tree

8 files changed

+19
-16
lines changed

8 files changed

+19
-16
lines changed

integration/tests/next-build.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { appConfigs } from '../presets';
66
test.describe('next build @nextjs', () => {
77
test.describe.configure({ mode: 'parallel' });
88
let app: Application;
9-
const output = [];
109

1110
test.beforeAll(async () => {
1211
app = await appConfigs.next.appRouter

packages/expo/src/ClerkProvider.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ __internal__setErrorThrowerOptions({
1313
packageName: '@clerk/expo',
1414
});
1515

16-
export type ClerkProviderProps = ClerkReactProviderProps & {
16+
type ClerkReactProviderOptionalPK = Exclude<ClerkReactProviderProps, 'publishableKey'> &
17+
Partial<Pick<ClerkReactProviderProps, 'publishableKey'>>;
18+
19+
export type ClerkProviderProps = ClerkReactProviderOptionalPK & {
1720
tokenCache?: TokenCache;
1821
};
1922

@@ -27,6 +30,7 @@ export function ClerkProvider(props: ClerkProviderProps): JSX.Element {
2730
// See JS-598 for additional context.
2831
key={key}
2932
{...rest}
33+
publishableKey={key}
3034
Clerk={buildClerk({ key, tokenCache })}
3135
standardBrowser={!isReactNative()}
3236
>

packages/nextjs/src/pages/ClerkProvider.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export function ClerkProvider({ children, ...props }: NextClerkProviderProps): J
3939

4040
return (
4141
<ClerkNextOptionsProvider options={mergedProps}>
42-
{/*@ts-expect-error*/}
4342
<ReactClerkProvider
4443
{...mergedProps}
4544
initialState={initialState}

packages/nextjs/src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { IsomorphicClerkOptions } from '@clerk/clerk-react';
1+
import type { ClerkProviderProps } from '@clerk/clerk-react';
2+
import type { MultiDomainAndOrProxy } from '@clerk/types';
23
import type React from 'react';
34

45
export type NextClerkProviderProps = {
@@ -12,4 +13,5 @@ export type NextClerkProviderProps = {
1213
* @default true
1314
*/
1415
__unstable_invokeMiddlewareOnAuthStateChange?: boolean;
15-
} & IsomorphicClerkOptions;
16+
} & Partial<ClerkProviderProps> &
17+
MultiDomainAndOrProxy;

packages/nextjs/src/utils/mergeNextClerkPropsWithEnv.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export const mergeNextClerkPropsWithEnv = (props: Omit<NextClerkProviderProps, '
88
publishableKey: props.publishableKey || process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY || '',
99
clerkJSUrl: props.clerkJSUrl || process.env.NEXT_PUBLIC_CLERK_JS,
1010
clerkJSVersion: props.clerkJSVersion || process.env.NEXT_PUBLIC_CLERK_JS_VERSION,
11-
proxyUrl: props.proxyUrl || process.env.NEXT_PUBLIC_CLERK_PROXY_URL || '',
12-
domain: props.domain || process.env.NEXT_PUBLIC_CLERK_DOMAIN || '',
13-
isSatellite: props.isSatellite || isTruthy(process.env.NEXT_PUBLIC_CLERK_IS_SATELLITE),
11+
proxyUrl: props.proxyUrl || (process.env.NEXT_PUBLIC_CLERK_PROXY_URL as any), // added as any to cater issue with type resolution
12+
domain: props.domain || (process.env.NEXT_PUBLIC_CLERK_DOMAIN as any), // added as any to cater issue with type resolution
13+
isSatellite: props.isSatellite || (isTruthy(process.env.NEXT_PUBLIC_CLERK_IS_SATELLITE) as any), // added as any to cater issue with type resolution
1414
signInUrl: props.signInUrl || process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || '',
1515
signUpUrl: props.signUpUrl || process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || '',
1616
afterSignInUrl: props.afterSignInUrl || process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL || '',

packages/react/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type IsomorphicClerkOptions = Omit<ClerkOptions, 'isSatellite'> & {
2828
clerkJSVariant?: 'headless' | '';
2929
clerkJSVersion?: string;
3030
sdkMetadata?: SDKMetadata;
31-
publishableKey?: string;
31+
publishableKey: string;
3232
} & MultiDomainAndOrProxy;
3333

3434
export interface BrowserClerkConstructor {

packages/types/src/clerk.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { ClientResource } from './client';
1313
import type { CustomPage } from './customPages';
1414
import type { DisplayThemeJSON } from './json';
1515
import type { LocalizationResource } from './localization';
16+
import type { MultiDomainAndOrProxy } from './multiDomain';
1617
import type { OAuthProvider, OAuthScope } from './oauth';
1718
import type { OrganizationResource } from './organization';
1819
import type { MembershipRole } from './organizationMembership';
@@ -524,7 +525,7 @@ export interface ClerkOptions {
524525
* Defaults to false
525526
*/
526527
isInterstitial?: boolean;
527-
isSatellite?: boolean | ((url: URL) => boolean);
528+
isSatellite?: MultiDomainAndOrProxy['isSatellite'];
528529
}
529530

530531
export interface Resources {

packages/types/src/multiDomain.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import type { ClerkOptions } from './clerk';
2-
31
type StringOrURLFnToString = string | ((url: URL) => string);
42

53
/**
6-
* DomainOrProxyUrl supports the following cases
4+
* MultiDomainAndOrProxy supports the following cases
75
* 1) none of them are set
86
* 2) only proxyUrl is set
97
* 3) isSatellite and proxy is set
@@ -12,16 +10,16 @@ type StringOrURLFnToString = string | ((url: URL) => string);
1210
export type MultiDomainAndOrProxy =
1311
| {
1412
isSatellite?: never;
15-
proxyUrl?: never | StringOrURLFnToString;
13+
proxyUrl?: StringOrURLFnToString;
1614
domain?: never;
1715
}
1816
| {
19-
isSatellite: Exclude<ClerkOptions['isSatellite'], undefined>;
17+
isSatellite: boolean | ((url: URL) => boolean);
2018
proxyUrl?: never;
2119
domain: StringOrURLFnToString;
2220
}
2321
| {
24-
isSatellite: Exclude<ClerkOptions['isSatellite'], undefined>;
22+
isSatellite: boolean | ((url: URL) => boolean);
2523
proxyUrl: StringOrURLFnToString;
2624
domain?: never;
2725
};

0 commit comments

Comments
 (0)