Skip to content

Commit

Permalink
chore(expo): Fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Jul 2, 2024
1 parent 5f9e783 commit 9066440
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/expo/src/provider/ClerkProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '../polyfills';

import { ClerkProvider as ClerkReactProvider } from '@clerk/clerk-react';
import React from 'react';

import type { TokenCache } from '../caches/types';
import { isNative } from '../utils/runtime';
Expand All @@ -12,14 +11,14 @@ export type ClerkProviderProps = React.ComponentProps<typeof ClerkReactProvider>
};

export function ClerkProvider(props: ClerkProviderProps): JSX.Element {
const { children, tokenCache, publishableKey, key, ...rest } = props;
const { children, tokenCache, publishableKey, ...rest } = props;
const pk = publishableKey || process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY || process.env.CLERK_PUBLISHABLE_KEY || '';

return (
<ClerkReactProvider
// Force reset the state when the provided key changes, this ensures that the provider does not retain stale state.
// See JS-598 for additional context.
key={key}
key={pk}
{...rest}
publishableKey={pk}
Clerk={isNative() ? getClerkInstance({ publishableKey: pk, tokenCache }) : null}
Expand Down
2 changes: 2 additions & 0 deletions packages/expo/src/provider/singleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function getClerkInstance(options?: BuildClerkOptions): HeadlessBrowserCl
const saveToken = tokenCache.saveToken;
__internal_clerk = clerk = new Clerk(publishableKey);

// @ts-expect-error - This is an internal API
__internal_clerk.__unstable__onBeforeRequest(async (requestInit: FapiRequestInit) => {
// https://reactnative.dev/docs/0.61/network#known-issues-with-fetch-and-cookie-based-authentication
requestInit.credentials = 'omit';
Expand All @@ -71,6 +72,7 @@ export function getClerkInstance(options?: BuildClerkOptions): HeadlessBrowserCl
(requestInit.headers as Headers).set('authorization', jwt || '');
});

// @ts-expect-error - This is an internal API
__internal_clerk.__unstable__onAfterResponse(async (_: FapiRequestInit, response: FapiResponse<unknown>) => {
const authHeader = response.headers.get('authorization');
if (authHeader) {
Expand Down
2 changes: 1 addition & 1 deletion packages/expo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"outDir": "dist",
"baseUrl": ".",
"lib": ["es6", "dom"],
"jsx": "react",
"jsx": "react-jsx",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"importHelpers": true,
Expand Down

0 comments on commit 9066440

Please sign in to comment.