From acafd5bdc8ead02ccd468993c06ba609600c4374 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Thu, 16 Nov 2023 01:49:00 +0200 Subject: [PATCH] chore(*): Enforce publishableKey to IsomorphicClerkOptions --- integration/tests/next-build.test.ts | 1 - packages/expo/src/ClerkProvider.tsx | 6 +++++- packages/nextjs/src/pages/ClerkProvider.tsx | 1 - packages/nextjs/src/types.ts | 6 ++++-- .../nextjs/src/utils/mergeNextClerkPropsWithEnv.ts | 6 +++--- packages/react/src/types.ts | 2 +- packages/types/src/clerk.ts | 3 ++- packages/types/src/multiDomain.ts | 10 ++++------ 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/integration/tests/next-build.test.ts b/integration/tests/next-build.test.ts index 7f5cf9394e0..4e03db4f80c 100644 --- a/integration/tests/next-build.test.ts +++ b/integration/tests/next-build.test.ts @@ -6,7 +6,6 @@ import { appConfigs } from '../presets'; test.describe('next build @nextjs', () => { test.describe.configure({ mode: 'parallel' }); let app: Application; - const output = []; test.beforeAll(async () => { app = await appConfigs.next.appRouter diff --git a/packages/expo/src/ClerkProvider.tsx b/packages/expo/src/ClerkProvider.tsx index d2a5adfe6e3..13dd3740712 100644 --- a/packages/expo/src/ClerkProvider.tsx +++ b/packages/expo/src/ClerkProvider.tsx @@ -13,7 +13,10 @@ __internal__setErrorThrowerOptions({ packageName: '@clerk/expo', }); -export type ClerkProviderProps = ClerkReactProviderProps & { +type ClerkReactProviderOptionalPK = Exclude & + Partial>; + +export type ClerkProviderProps = ClerkReactProviderOptionalPK & { tokenCache?: TokenCache; }; @@ -27,6 +30,7 @@ export function ClerkProvider(props: ClerkProviderProps): JSX.Element { // See JS-598 for additional context. key={key} {...rest} + publishableKey={key} Clerk={buildClerk({ key, tokenCache })} standardBrowser={!isReactNative()} > diff --git a/packages/nextjs/src/pages/ClerkProvider.tsx b/packages/nextjs/src/pages/ClerkProvider.tsx index 2aa571720c1..c1f093729d7 100644 --- a/packages/nextjs/src/pages/ClerkProvider.tsx +++ b/packages/nextjs/src/pages/ClerkProvider.tsx @@ -39,7 +39,6 @@ export function ClerkProvider({ children, ...props }: NextClerkProviderProps): J return ( - {/*@ts-expect-error*/} & + MultiDomainAndOrProxy; diff --git a/packages/nextjs/src/utils/mergeNextClerkPropsWithEnv.ts b/packages/nextjs/src/utils/mergeNextClerkPropsWithEnv.ts index 0cdd5894515..e5d14273910 100644 --- a/packages/nextjs/src/utils/mergeNextClerkPropsWithEnv.ts +++ b/packages/nextjs/src/utils/mergeNextClerkPropsWithEnv.ts @@ -8,9 +8,9 @@ export const mergeNextClerkPropsWithEnv = (props: Omit & { clerkJSVariant?: 'headless' | ''; clerkJSVersion?: string; sdkMetadata?: SDKMetadata; - publishableKey?: string; + publishableKey: string; } & MultiDomainAndOrProxy; export interface BrowserClerkConstructor { diff --git a/packages/types/src/clerk.ts b/packages/types/src/clerk.ts index 2d8fb3f691e..6ebd73a374d 100644 --- a/packages/types/src/clerk.ts +++ b/packages/types/src/clerk.ts @@ -13,6 +13,7 @@ import type { ClientResource } from './client'; import type { CustomPage } from './customPages'; import type { DisplayThemeJSON } from './json'; import type { LocalizationResource } from './localization'; +import type { MultiDomainAndOrProxy } from './multiDomain'; import type { OAuthProvider, OAuthScope } from './oauth'; import type { OrganizationResource } from './organization'; import type { MembershipRole } from './organizationMembership'; @@ -524,7 +525,7 @@ export interface ClerkOptions { * Defaults to false */ isInterstitial?: boolean; - isSatellite?: boolean | ((url: URL) => boolean); + isSatellite?: MultiDomainAndOrProxy['isSatellite']; } export interface Resources { diff --git a/packages/types/src/multiDomain.ts b/packages/types/src/multiDomain.ts index a03685d9bbe..6a5823c33f5 100644 --- a/packages/types/src/multiDomain.ts +++ b/packages/types/src/multiDomain.ts @@ -1,9 +1,7 @@ -import type { ClerkOptions } from './clerk'; - type StringOrURLFnToString = string | ((url: URL) => string); /** - * DomainOrProxyUrl supports the following cases + * MultiDomainAndOrProxy supports the following cases * 1) none of them are set * 2) only proxyUrl is set * 3) isSatellite and proxy is set @@ -12,16 +10,16 @@ type StringOrURLFnToString = string | ((url: URL) => string); export type MultiDomainAndOrProxy = | { isSatellite?: never; - proxyUrl?: never | StringOrURLFnToString; + proxyUrl?: StringOrURLFnToString; domain?: never; } | { - isSatellite: Exclude; + isSatellite: boolean | ((url: URL) => boolean); proxyUrl?: never; domain: StringOrURLFnToString; } | { - isSatellite: Exclude; + isSatellite: boolean | ((url: URL) => boolean); proxyUrl: StringOrURLFnToString; domain?: never; };