From 3821d39bf120bc06a3d7d395ab3ffb3bbcb872f4 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Thu, 14 Dec 2023 20:06:09 +0200 Subject: [PATCH] chore(backend): Expose /internal subpath export --- .changeset/red-suns-perform.md | 34 +++++++++++++++++++ packages/backend/package.json | 10 ++++++ .../backend/src/__tests__/exports.test.ts | 33 +++++++++++------- packages/backend/src/constants.ts | 3 ++ packages/backend/src/index.ts | 10 ++---- packages/backend/src/internal.ts | 28 +++++++++++++++ packages/backend/src/redirections.ts | 3 ++ packages/backend/src/tokens/authObjects.ts | 25 ++++++++++++++ packages/backend/src/tokens/authStatus.ts | 6 ++++ packages/backend/src/tokens/factory.ts | 6 ++++ packages/backend/src/tokens/index.ts | 6 ---- packages/backend/src/tokens/request.ts | 9 +++++ .../backend/src/util/IsomorphicRequest.ts | 3 ++ packages/backend/src/utils.ts | 6 ++++ packages/backend/tsup.config.ts | 2 +- packages/fastify/src/constants.ts | 2 +- packages/fastify/src/getAuth.ts | 2 +- packages/fastify/src/withClerkMiddleware.ts | 2 +- packages/gatsby-plugin-clerk/src/ssr/types.ts | 3 +- packages/gatsby-plugin-clerk/src/ssr/utils.ts | 5 ++- .../src/ssr/withServerAuth.ts | 2 +- packages/nextjs/src/app-router/server/auth.ts | 2 +- .../nextjs/src/server/authMiddleware.test.ts | 2 +- packages/nextjs/src/server/authMiddleware.ts | 4 +-- packages/nextjs/src/server/getAuth.ts | 7 ++-- packages/nextjs/src/server/redirect.ts | 2 +- packages/nextjs/src/server/types.ts | 2 +- packages/nextjs/src/server/utils.ts | 4 +-- packages/remix/src/ssr/authenticateRequest.ts | 5 +-- packages/remix/src/ssr/getAuth.ts | 2 +- packages/remix/src/ssr/rootAuthLoader.ts | 2 +- packages/remix/src/ssr/types.ts | 3 +- packages/remix/src/ssr/utils.ts | 4 +-- .../__snapshots__/exports.test.ts.snap | 12 ------- .../src/__tests__/authenticateRequest.test.ts | 2 +- .../sdk-node/src/__tests__/middleware.test.ts | 2 +- packages/sdk-node/src/authenticateRequest.ts | 4 +-- .../sdk-node/src/clerkExpressRequireAuth.ts | 2 +- packages/sdk-node/src/clerkExpressWithAuth.ts | 2 +- packages/sdk-node/src/types.ts | 3 +- 40 files changed, 194 insertions(+), 72 deletions(-) create mode 100644 .changeset/red-suns-perform.md create mode 100644 packages/backend/src/internal.ts delete mode 100644 packages/backend/src/tokens/index.ts diff --git a/.changeset/red-suns-perform.md b/.changeset/red-suns-perform.md new file mode 100644 index 0000000000..37ab808fb5 --- /dev/null +++ b/.changeset/red-suns-perform.md @@ -0,0 +1,34 @@ +--- +'gatsby-plugin-clerk': major +'@clerk/clerk-sdk-node': major +'@clerk/backend': major +'@clerk/fastify': major +'@clerk/nextjs': major +'@clerk/remix': major +--- + +Changes in exports of `@clerk/backend`: +- Expose the following helpers and enums from `@clerk/backend/internal`: + ```typescript + import { + AuthStatus, + buildRequestUrl, + constants, + createAuthenticateRequest, + createIsomorphicRequest, + debugRequestState, + makeAuthObjectSerializable, + prunePrivateMetadata, + redirect, + sanitizeAuthObject, + signedInAuthObject, + signedOutAuthObject } from '@clerk/backend/internal'; + ``` +- Drop the above exports from the top-level api: + ```typescript + // Before + import { AuthStatus, ... } from '@clerk/backend'; + // After + import { AuthStatus, ... } from '@clerk/backend/internal'; + ``` + Dropping those exports results in also dropping the exports from `gatsby-plugin-clerk`, `@clerk/clerk-sdk-node`, `@clerk/backend`, `@clerk/fastify`, `@clerk/nextjs`, `@clerk/remix` packages. \ No newline at end of file diff --git a/packages/backend/package.json b/packages/backend/package.json index 78639b3552..3d14a27ae8 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -45,6 +45,16 @@ "default": "./dist/errors.js" } }, + "./internal": { + "import": { + "types": "./dist/internal.d.ts", + "default": "./dist/internal.mjs" + }, + "require": { + "types": "./dist/internal.d.ts", + "default": "./dist/internal.js" + } + }, "./package.json": "./package.json" }, "main": "./dist/index.js", diff --git a/packages/backend/src/__tests__/exports.test.ts b/packages/backend/src/__tests__/exports.test.ts index b1e16ba037..3b21dc4e0c 100644 --- a/packages/backend/src/__tests__/exports.test.ts +++ b/packages/backend/src/__tests__/exports.test.ts @@ -2,6 +2,7 @@ import type QUnit from 'qunit'; import * as errorExports from '../errors'; import * as publicExports from '../index'; +import * as internalExports from '../internal'; export default (QUnit: QUnit) => { const { module, test } = QUnit; @@ -10,7 +11,6 @@ export default (QUnit: QUnit) => { test('should not include a breaking change', assert => { const exportedApiKeys = [ 'AllowlistIdentifier', - 'AuthStatus', 'Client', 'DeletedObject', 'Email', @@ -32,21 +32,10 @@ export default (QUnit: QUnit) => { 'Token', 'User', 'Verification', - 'buildRequestUrl', - 'constants', - 'createAuthenticateRequest', 'createClerkClient', - 'createIsomorphicRequest', - 'debugRequestState', 'decodeJwt', 'hasValidSignature', - 'makeAuthObjectSerializable', - 'prunePrivateMetadata', - 'redirect', - 'sanitizeAuthObject', 'signJwt', - 'signedInAuthObject', - 'signedOutAuthObject', 'verifyJwt', 'verifyToken', ]; @@ -65,4 +54,24 @@ export default (QUnit: QUnit) => { assert.deepEqual(Object.keys(errorExports).sort(), exportedApiKeys); }); }); + + module('subpath /internal exports', () => { + test('should not include a breaking change', assert => { + const exportedApiKeys = [ + 'AuthStatus', + 'buildRequestUrl', + 'constants', + 'createAuthenticateRequest', + 'createIsomorphicRequest', + 'debugRequestState', + 'makeAuthObjectSerializable', + 'prunePrivateMetadata', + 'redirect', + 'sanitizeAuthObject', + 'signedInAuthObject', + 'signedOutAuthObject', + ]; + assert.deepEqual(Object.keys(internalExports).sort(), exportedApiKeys); + }); + }); }; diff --git a/packages/backend/src/constants.ts b/packages/backend/src/constants.ts index 0f12987740..9361864da5 100644 --- a/packages/backend/src/constants.ts +++ b/packages/backend/src/constants.ts @@ -47,6 +47,9 @@ const ContentTypes = { Json: 'application/json', } as const; +/** + * @internal + */ export const constants = { Attributes, Cookies, diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index e6273107ed..d9bf992bc8 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -4,18 +4,12 @@ import type { SDKMetadata } from '@clerk/types'; import type { ApiClient, CreateBackendApiOptions } from './api'; import { createBackendApiClient } from './api'; -import type { CreateAuthenticateRequestOptions } from './tokens'; -import { createAuthenticateRequest } from './tokens'; - -export { createIsomorphicRequest } from './util/IsomorphicRequest'; +import type { CreateAuthenticateRequestOptions } from './tokens/factory'; +import { createAuthenticateRequest } from './tokens/factory'; export * from './api/resources'; -export * from './tokens'; export * from './tokens/jwt'; export * from './tokens/verify'; -export { constants } from './constants'; -export { redirect } from './redirections'; -export { buildRequestUrl } from './utils'; export type ClerkOptions = CreateBackendApiOptions & Partial< diff --git a/packages/backend/src/internal.ts b/packages/backend/src/internal.ts new file mode 100644 index 0000000000..7327bfe5a2 --- /dev/null +++ b/packages/backend/src/internal.ts @@ -0,0 +1,28 @@ +export { constants } from './constants'; +export { redirect } from './redirections'; +export { buildRequestUrl } from './utils'; + +export type { CreateAuthenticateRequestOptions } from './tokens/factory'; +export { createAuthenticateRequest } from './tokens/factory'; + +export { debugRequestState } from './tokens/request'; + +export type { AuthenticateRequestOptions, OptionalVerifyTokenOptions } from './tokens/request'; + +export type { + SignedInAuthObjectOptions, + SignedInAuthObject, + SignedOutAuthObject, + AuthObject, +} from './tokens/authObjects'; +export { + makeAuthObjectSerializable, + sanitizeAuthObject, + prunePrivateMetadata, + signedOutAuthObject, + signedInAuthObject, +} from './tokens/authObjects'; +export { createIsomorphicRequest } from './util/IsomorphicRequest'; + +export { AuthStatus } from './tokens/authStatus'; +export type { RequestState } from './tokens/authStatus'; diff --git a/packages/backend/src/redirections.ts b/packages/backend/src/redirections.ts index 9629776b15..44621c9dcc 100644 --- a/packages/backend/src/redirections.ts +++ b/packages/backend/src/redirections.ts @@ -32,6 +32,9 @@ type RedirectParams = { publishableKey?: string; }; +/** + * @internal + */ export function redirect({ redirectAdapter, signUpUrl, signInUrl, publishableKey }: RedirectParams) { const frontendApi = parsePublishableKey(publishableKey)?.frontendApi; const accountsBaseUrl = buildAccountsBaseUrl(frontendApi); diff --git a/packages/backend/src/tokens/authObjects.ts b/packages/backend/src/tokens/authObjects.ts index 13aa72582b..92b76d1244 100644 --- a/packages/backend/src/tokens/authObjects.ts +++ b/packages/backend/src/tokens/authObjects.ts @@ -15,6 +15,9 @@ type AuthObjectDebugData = Record; type CreateAuthObjectDebug = (data?: AuthObjectDebugData) => AuthObjectDebug; type AuthObjectDebug = () => AuthObjectDebugData; +/** + * @internal + */ export type SignedInAuthObjectOptions = CreateBackendApiOptions & { token: string; session?: Session; @@ -22,6 +25,9 @@ export type SignedInAuthObjectOptions = CreateBackendApiOptions & { organization?: Organization; }; +/** + * @internal + */ export type SignedInAuthObject = { sessionClaims: JwtPayload; sessionId: string; @@ -39,6 +45,9 @@ export type SignedInAuthObject = { debug: AuthObjectDebug; }; +/** + * @internal + */ export type SignedOutAuthObject = { sessionClaims: null; sessionId: null; @@ -56,6 +65,9 @@ export type SignedOutAuthObject = { debug: AuthObjectDebug; }; +/** + * @internal + */ export type AuthObject = SignedInAuthObject | SignedOutAuthObject; const createDebug: CreateAuthObjectDebug = data => { @@ -67,6 +79,9 @@ const createDebug: CreateAuthObjectDebug = data => { }; }; +/** + * @internal + */ export function signedInAuthObject( sessionClaims: JwtPayload, options: SignedInAuthObjectOptions, @@ -112,6 +127,9 @@ export function signedInAuthObject( }; } +/** + * @internal + */ export function signedOutAuthObject(debugData?: AuthObjectDebugData): SignedOutAuthObject { return { sessionClaims: null, @@ -131,6 +149,9 @@ export function signedOutAuthObject(debugData?: AuthObjectDebugData): SignedOutA }; } +/** + * @internal + */ export function prunePrivateMetadata( resource?: | { @@ -152,6 +173,9 @@ export function prunePrivateMetadata( return resource; } +/** + * @internal + */ export function sanitizeAuthObject>(authObject: T): T { const user = authObject.user ? { ...authObject.user } : authObject.user; const organization = authObject.organization ? { ...authObject.organization } : authObject.organization; @@ -168,6 +192,7 @@ export function sanitizeAuthObject>(authObject: T): T * Some frameworks like Remix or Next (/pages dir only) handle this serialization by simply * ignoring any non-serializable keys, however Nextjs /app directory is stricter and * throws an error if a non-serializable value is found. + * @internal */ export const makeAuthObjectSerializable = >(obj: T): T => { // remove any non-serializable props from the returned object diff --git a/packages/backend/src/tokens/authStatus.ts b/packages/backend/src/tokens/authStatus.ts index 37552107b3..bb29b9cddb 100644 --- a/packages/backend/src/tokens/authStatus.ts +++ b/packages/backend/src/tokens/authStatus.ts @@ -5,6 +5,9 @@ import type { TokenVerificationErrorReason } from '../errors'; import type { SignedInAuthObject, SignedInAuthObjectOptions, SignedOutAuthObject } from './authObjects'; import { signedInAuthObject, signedOutAuthObject } from './authObjects'; +/** + * @internal + */ export enum AuthStatus { SignedIn = 'signed-in', SignedOut = 'signed-out', @@ -66,6 +69,9 @@ export enum AuthErrorReason { export type AuthReason = AuthErrorReason | TokenVerificationErrorReason; +/** + * @internal + */ export type RequestState = SignedInState | SignedOutState | HandshakeState; type LoadResourcesOptions = { diff --git a/packages/backend/src/tokens/factory.ts b/packages/backend/src/tokens/factory.ts index a59681e7d9..ed521cfdfb 100644 --- a/packages/backend/src/tokens/factory.ts +++ b/packages/backend/src/tokens/factory.ts @@ -32,11 +32,17 @@ const defaultOptions = { audience: '', } satisfies BuildTimeOptions; +/** + * @internal + */ export type CreateAuthenticateRequestOptions = { options: BuildTimeOptions; apiClient: ApiClient; }; +/** + * @internal + */ export function createAuthenticateRequest(params: CreateAuthenticateRequestOptions) { const buildTimeOptions = mergePreDefinedOptions(defaultOptions, params.options); diff --git a/packages/backend/src/tokens/index.ts b/packages/backend/src/tokens/index.ts deleted file mode 100644 index 511068c5d8..0000000000 --- a/packages/backend/src/tokens/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './authObjects'; -export { AuthStatus } from './authStatus'; -export type { RequestState } from './authStatus'; -export * from './factory'; -export { debugRequestState } from './request'; -export type { AuthenticateRequestOptions, OptionalVerifyTokenOptions } from './request'; diff --git a/packages/backend/src/tokens/request.ts b/packages/backend/src/tokens/request.ts index aa5fc506b2..a659698613 100644 --- a/packages/backend/src/tokens/request.ts +++ b/packages/backend/src/tokens/request.ts @@ -13,6 +13,9 @@ import { verifyHandshakeToken } from './handshake'; import { decodeJwt } from './jwt'; import { verifyToken, type VerifyTokenOptions } from './verify'; +/** + * @internal + */ export type OptionalVerifyTokenOptions = Partial< Pick< VerifyTokenOptions, @@ -20,6 +23,9 @@ export type OptionalVerifyTokenOptions = Partial< > >; +/** + * @internal + */ export type AuthenticateRequestOptions = AuthStatusOptionsType & OptionalVerifyTokenOptions; function assertSignInUrlExists(signInUrl: string | undefined, key: string): asserts signInUrl is string { @@ -303,6 +309,9 @@ ${err.getFullMessage()}`, return authenticateRequestWithTokenInCookie(); } +/** + * @internal + */ export const debugRequestState = (params: RequestState) => { const { isSignedIn, proxyUrl, reason, message, publishableKey, isSatellite, domain } = params; return { isSignedIn, proxyUrl, reason, message, publishableKey, isSatellite, domain }; diff --git a/packages/backend/src/util/IsomorphicRequest.ts b/packages/backend/src/util/IsomorphicRequest.ts index 7ac783560c..3a2b8fdee6 100644 --- a/packages/backend/src/util/IsomorphicRequest.ts +++ b/packages/backend/src/util/IsomorphicRequest.ts @@ -4,6 +4,9 @@ import runtime from '../runtime'; import { buildRequestUrl } from '../utils'; type IsomorphicRequestOptions = (Request: typeof runtime.Request, Headers: typeof runtime.Headers) => Request; +/** + * @internal + */ export const createIsomorphicRequest = (cb: IsomorphicRequestOptions): Request => { const req = cb(runtime.Request, runtime.Headers); // Used to fix request.url using the x-forwarded-* headers diff --git a/packages/backend/src/utils.ts b/packages/backend/src/utils.ts index 62857cc5b9..9482519394 100644 --- a/packages/backend/src/utils.ts +++ b/packages/backend/src/utils.ts @@ -4,6 +4,9 @@ const getHeader = (req: Request, key: string) => req.headers.get(key); const getFirstValueFromHeader = (value?: string | null) => value?.split(',')[0]; type BuildRequestUrl = (request: Request) => URL; +/** + * @internal + */ export const buildRequestUrl: BuildRequestUrl = request => { const initialUrl = new URL(request.url); @@ -25,6 +28,9 @@ type BuildOriginParams = { host?: string | null; }; type BuildOrigin = (params: BuildOriginParams) => string; +/** + * @internal + */ export const buildOrigin: BuildOrigin = ({ protocol, forwardedProto, forwardedHost, host }) => { const resolvedHost = getFirstValueFromHeader(forwardedHost) ?? host; const resolvedProtocol = getFirstValueFromHeader(forwardedProto) ?? protocol?.replace(/[:/]/, ''); diff --git a/packages/backend/tsup.config.ts b/packages/backend/tsup.config.ts index 458fd27d4f..c01a478fc8 100644 --- a/packages/backend/tsup.config.ts +++ b/packages/backend/tsup.config.ts @@ -10,7 +10,7 @@ export default defineConfig(overrideOptions => { const shouldPublish = !!overrideOptions.env?.publish; const common: Options = { - entry: ['src/index.ts', 'src/errors.ts'], + entry: ['src/index.ts', 'src/errors.ts', 'src/internal.ts'], onSuccess: `cpy 'src/runtime/**/*.{mjs,js,cjs}' dist/runtime`, sourcemap: true, define: { diff --git a/packages/fastify/src/constants.ts b/packages/fastify/src/constants.ts index 725f748d28..1f0b27991a 100644 --- a/packages/fastify/src/constants.ts +++ b/packages/fastify/src/constants.ts @@ -1,4 +1,4 @@ -import { constants } from '@clerk/backend'; +import { constants } from '@clerk/backend/internal'; import { apiUrlFromPublishableKey } from '@clerk/shared/apiUrlFromPublishableKey'; export const API_VERSION = process.env.CLERK_API_VERSION || 'v1'; diff --git a/packages/fastify/src/getAuth.ts b/packages/fastify/src/getAuth.ts index 7acb04aefc..1b6c24138e 100644 --- a/packages/fastify/src/getAuth.ts +++ b/packages/fastify/src/getAuth.ts @@ -1,4 +1,4 @@ -import type { AuthObject } from '@clerk/backend'; +import type { AuthObject } from '@clerk/backend/internal'; import type { FastifyRequest } from 'fastify'; import { pluginRegistrationRequired } from './errors'; diff --git a/packages/fastify/src/withClerkMiddleware.ts b/packages/fastify/src/withClerkMiddleware.ts index c3fe1c1ade..0a2c94a2ea 100644 --- a/packages/fastify/src/withClerkMiddleware.ts +++ b/packages/fastify/src/withClerkMiddleware.ts @@ -1,4 +1,4 @@ -import { AuthStatus } from '@clerk/backend'; +import { AuthStatus } from '@clerk/backend/internal'; import type { FastifyRequest } from 'fastify'; import { clerkClient } from './clerkClient'; diff --git a/packages/gatsby-plugin-clerk/src/ssr/types.ts b/packages/gatsby-plugin-clerk/src/ssr/types.ts index aad0a2f6d5..f823ca971b 100644 --- a/packages/gatsby-plugin-clerk/src/ssr/types.ts +++ b/packages/gatsby-plugin-clerk/src/ssr/types.ts @@ -1,4 +1,5 @@ -import type { AuthenticateRequestOptions, AuthObject, Organization, Session, User } from '@clerk/backend'; +import type { Organization, Session, User } from '@clerk/backend'; +import type { AuthenticateRequestOptions, AuthObject } from '@clerk/backend/internal'; import type { GetServerDataProps } from 'gatsby'; export type WithServerAuthResult = (props: GetServerDataProps) => Promise>; diff --git a/packages/gatsby-plugin-clerk/src/ssr/utils.ts b/packages/gatsby-plugin-clerk/src/ssr/utils.ts index fed608ad9f..575cbc82c9 100644 --- a/packages/gatsby-plugin-clerk/src/ssr/utils.ts +++ b/packages/gatsby-plugin-clerk/src/ssr/utils.ts @@ -1,10 +1,9 @@ -import type { AuthObject } from '@clerk/backend'; -import { prunePrivateMetadata } from '@clerk/backend'; +import type { AuthObject } from '@clerk/backend/internal'; +import { constants, prunePrivateMetadata } from '@clerk/backend/internal'; import cookie from 'cookie'; import type { GetServerDataProps } from 'gatsby'; import { SECRET_KEY } from '../constants'; -import { constants } from './clerkClient'; /** * @internal diff --git a/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts b/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts index f69e290ddd..eb5e5948ce 100644 --- a/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts +++ b/packages/gatsby-plugin-clerk/src/ssr/withServerAuth.ts @@ -1,4 +1,4 @@ -import { AuthStatus } from '@clerk/backend'; +import { AuthStatus } from '@clerk/backend/internal'; import type { GetServerDataProps, GetServerDataReturn } from 'gatsby'; import { PUBLISHABLE_KEY, SECRET_KEY } from '../constants'; diff --git a/packages/nextjs/src/app-router/server/auth.ts b/packages/nextjs/src/app-router/server/auth.ts index d3f3f21579..6d0d4df10a 100644 --- a/packages/nextjs/src/app-router/server/auth.ts +++ b/packages/nextjs/src/app-router/server/auth.ts @@ -1,4 +1,4 @@ -import type { SignedInAuthObject, SignedOutAuthObject } from '@clerk/backend'; +import type { SignedInAuthObject, SignedOutAuthObject } from '@clerk/backend/internal'; import type { CheckAuthorizationParamsWithCustomPermissions, CheckAuthorizationWithCustomPermissions, diff --git a/packages/nextjs/src/server/authMiddleware.test.ts b/packages/nextjs/src/server/authMiddleware.test.ts index ee6f08de28..1e6559c654 100644 --- a/packages/nextjs/src/server/authMiddleware.test.ts +++ b/packages/nextjs/src/server/authMiddleware.test.ts @@ -1,6 +1,6 @@ // There is no need to execute the complete authenticateRequest to test authMiddleware // This mock SHOULD exist before the import of authenticateRequest -import { AuthStatus } from '@clerk/backend'; +import { AuthStatus } from '@clerk/backend/internal'; import { expectTypeOf } from 'expect-type'; import { NextURL } from 'next/dist/server/web/next-url'; import type { NextFetchEvent, NextRequest } from 'next/server'; diff --git a/packages/nextjs/src/server/authMiddleware.ts b/packages/nextjs/src/server/authMiddleware.ts index 77f0d306b8..a390dbb01d 100644 --- a/packages/nextjs/src/server/authMiddleware.ts +++ b/packages/nextjs/src/server/authMiddleware.ts @@ -1,5 +1,5 @@ -import type { AuthenticateRequestOptions, AuthObject } from '@clerk/backend'; -import { AuthStatus, buildRequestUrl, constants } from '@clerk/backend'; +import type { AuthenticateRequestOptions, AuthObject } from '@clerk/backend/internal'; +import { AuthStatus, buildRequestUrl, constants } from '@clerk/backend/internal'; import { DEV_BROWSER_JWT_MARKER, setDevBrowserJWTInURL } from '@clerk/shared/devBrowser'; import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; import { eventMethodCalled } from '@clerk/shared/telemetry'; diff --git a/packages/nextjs/src/server/getAuth.ts b/packages/nextjs/src/server/getAuth.ts index f6deeeee0d..63b7d351da 100644 --- a/packages/nextjs/src/server/getAuth.ts +++ b/packages/nextjs/src/server/getAuth.ts @@ -1,13 +1,14 @@ -import type { Organization, Session, SignedInAuthObject, SignedOutAuthObject, User } from '@clerk/backend'; +import type { Organization, Session, User } from '@clerk/backend'; +import { decodeJwt } from '@clerk/backend'; +import type { SignedInAuthObject, SignedOutAuthObject } from '@clerk/backend/internal'; import { AuthStatus, constants, - decodeJwt, makeAuthObjectSerializable, sanitizeAuthObject, signedInAuthObject, signedOutAuthObject, -} from '@clerk/backend'; +} from '@clerk/backend/internal'; import { withLogger } from '../utils/debugLogger'; import { API_URL, API_VERSION, SECRET_KEY } from './constants'; diff --git a/packages/nextjs/src/server/redirect.ts b/packages/nextjs/src/server/redirect.ts index cc955aa5d3..46d76740d4 100644 --- a/packages/nextjs/src/server/redirect.ts +++ b/packages/nextjs/src/server/redirect.ts @@ -1,4 +1,4 @@ -import { constants, redirect } from '@clerk/backend'; +import { constants, redirect } from '@clerk/backend/internal'; import { NextResponse } from 'next/server'; import { setHeader } from '../utils'; diff --git a/packages/nextjs/src/server/types.ts b/packages/nextjs/src/server/types.ts index b960002590..767e0ac73d 100644 --- a/packages/nextjs/src/server/types.ts +++ b/packages/nextjs/src/server/types.ts @@ -1,4 +1,4 @@ -import type { AuthObject, OptionalVerifyTokenOptions } from '@clerk/backend'; +import type { AuthObject, OptionalVerifyTokenOptions } from '@clerk/backend/internal'; import type { MultiDomainAndOrProxy } from '@clerk/types'; import type { IncomingMessage } from 'http'; import type { NextApiRequest } from 'next'; diff --git a/packages/nextjs/src/server/utils.ts b/packages/nextjs/src/server/utils.ts index 42ef545f13..635c9f435a 100644 --- a/packages/nextjs/src/server/utils.ts +++ b/packages/nextjs/src/server/utils.ts @@ -1,5 +1,5 @@ -import type { AuthenticateRequestOptions, RequestState } from '@clerk/backend'; -import { buildRequestUrl, constants } from '@clerk/backend'; +import type { AuthenticateRequestOptions, RequestState } from '@clerk/backend/internal'; +import { buildRequestUrl, constants } from '@clerk/backend/internal'; import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; import { isHttpOrHttps } from '@clerk/shared/proxy'; diff --git a/packages/remix/src/ssr/authenticateRequest.ts b/packages/remix/src/ssr/authenticateRequest.ts index 51d203da2e..1bf35a9624 100644 --- a/packages/remix/src/ssr/authenticateRequest.ts +++ b/packages/remix/src/ssr/authenticateRequest.ts @@ -1,5 +1,6 @@ -import type { RequestState } from '@clerk/backend'; -import { buildRequestUrl, createClerkClient } from '@clerk/backend'; +import { createClerkClient } from '@clerk/backend'; +import type { RequestState } from '@clerk/backend/internal'; +import { buildRequestUrl } from '@clerk/backend/internal'; import { apiUrlFromPublishableKey } from '@clerk/shared/apiUrlFromPublishableKey'; import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; diff --git a/packages/remix/src/ssr/getAuth.ts b/packages/remix/src/ssr/getAuth.ts index 8871a5cb1f..c13836b8c3 100644 --- a/packages/remix/src/ssr/getAuth.ts +++ b/packages/remix/src/ssr/getAuth.ts @@ -1,4 +1,4 @@ -import { AuthStatus, sanitizeAuthObject } from '@clerk/backend'; +import { AuthStatus, sanitizeAuthObject } from '@clerk/backend/internal'; import { redirect } from '@remix-run/server-runtime'; import { noLoaderArgsPassedInGetAuth } from '../errors'; diff --git a/packages/remix/src/ssr/rootAuthLoader.ts b/packages/remix/src/ssr/rootAuthLoader.ts index f91094893a..0e2753a2e0 100644 --- a/packages/remix/src/ssr/rootAuthLoader.ts +++ b/packages/remix/src/ssr/rootAuthLoader.ts @@ -1,4 +1,4 @@ -import { AuthStatus, sanitizeAuthObject } from '@clerk/backend'; +import { AuthStatus, sanitizeAuthObject } from '@clerk/backend/internal'; import type { defer } from '@remix-run/server-runtime'; import { redirect } from '@remix-run/server-runtime'; import { isDeferredData } from '@remix-run/server-runtime/dist/responses'; diff --git a/packages/remix/src/ssr/types.ts b/packages/remix/src/ssr/types.ts index ec2fd551ab..dc7b6c2f0a 100644 --- a/packages/remix/src/ssr/types.ts +++ b/packages/remix/src/ssr/types.ts @@ -1,4 +1,5 @@ -import type { AuthObject, Organization, Session, User, VerifyTokenOptions } from '@clerk/backend'; +import type { Organization, Session, User, VerifyTokenOptions } from '@clerk/backend'; +import type { AuthObject } from '@clerk/backend/internal'; import type { MultiDomainAndOrProxy } from '@clerk/types'; import type { DataFunctionArgs, LoaderFunction } from '@remix-run/server-runtime'; diff --git a/packages/remix/src/ssr/utils.ts b/packages/remix/src/ssr/utils.ts index dd48b5c3d8..4273b42b80 100644 --- a/packages/remix/src/ssr/utils.ts +++ b/packages/remix/src/ssr/utils.ts @@ -1,5 +1,5 @@ -import type { AuthObject, RequestState } from '@clerk/backend'; -import { constants, debugRequestState } from '@clerk/backend'; +import type { AuthObject, RequestState } from '@clerk/backend/internal'; +import { constants, debugRequestState } from '@clerk/backend/internal'; import { isTruthy } from '@clerk/shared/underscore'; import type { AppLoadContext, defer } from '@remix-run/server-runtime'; import { json } from '@remix-run/server-runtime'; diff --git a/packages/sdk-node/src/__tests__/__snapshots__/exports.test.ts.snap b/packages/sdk-node/src/__tests__/__snapshots__/exports.test.ts.snap index 3f04f9e024..5a12311087 100644 --- a/packages/sdk-node/src/__tests__/__snapshots__/exports.test.ts.snap +++ b/packages/sdk-node/src/__tests__/__snapshots__/exports.test.ts.snap @@ -3,7 +3,6 @@ exports[`module exports should not change unless explicitly set 1`] = ` [ "AllowlistIdentifier", - "AuthStatus", "ClerkExpressRequireAuth", "ClerkExpressWithAuth", "Client", @@ -27,25 +26,14 @@ exports[`module exports should not change unless explicitly set 1`] = ` "Token", "User", "Verification", - "buildRequestUrl", "clerkClient", - "constants", - "createAuthenticateRequest", "createClerkClient", "createClerkExpressRequireAuth", "createClerkExpressWithAuth", - "createIsomorphicRequest", - "debugRequestState", "decodeJwt", "hasValidSignature", - "makeAuthObjectSerializable", - "prunePrivateMetadata", - "redirect", "requireAuth", - "sanitizeAuthObject", "signJwt", - "signedInAuthObject", - "signedOutAuthObject", "verifyJwt", "verifyToken", "withAuth", diff --git a/packages/sdk-node/src/__tests__/authenticateRequest.test.ts b/packages/sdk-node/src/__tests__/authenticateRequest.test.ts index 44b602357b..1d1751d43e 100644 --- a/packages/sdk-node/src/__tests__/authenticateRequest.test.ts +++ b/packages/sdk-node/src/__tests__/authenticateRequest.test.ts @@ -1,4 +1,4 @@ -import { constants } from '@clerk/backend'; +import { constants } from '@clerk/backend/internal'; import { Request } from 'express'; import { authenticateRequest } from '../authenticateRequest'; diff --git a/packages/sdk-node/src/__tests__/middleware.test.ts b/packages/sdk-node/src/__tests__/middleware.test.ts index 417148b7a2..74d7f7ca6c 100644 --- a/packages/sdk-node/src/__tests__/middleware.test.ts +++ b/packages/sdk-node/src/__tests__/middleware.test.ts @@ -1,4 +1,4 @@ -import type { RequestState } from '@clerk/backend'; +import type { RequestState } from '@clerk/backend/internal'; import type { NextFunction, Request, Response } from 'express'; import { createClerkExpressRequireAuth } from '../clerkExpressRequireAuth'; diff --git a/packages/sdk-node/src/authenticateRequest.ts b/packages/sdk-node/src/authenticateRequest.ts index 17db4085c2..cc04de1097 100644 --- a/packages/sdk-node/src/authenticateRequest.ts +++ b/packages/sdk-node/src/authenticateRequest.ts @@ -1,5 +1,5 @@ -import type { RequestState } from '@clerk/backend'; -import { buildRequestUrl, constants } from '@clerk/backend'; +import type { RequestState } from '@clerk/backend/internal'; +import { buildRequestUrl, constants } from '@clerk/backend/internal'; import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; import { isHttpOrHttps, isProxyUrlRelative, isValidProxyUrl } from '@clerk/shared/proxy'; diff --git a/packages/sdk-node/src/clerkExpressRequireAuth.ts b/packages/sdk-node/src/clerkExpressRequireAuth.ts index 47f3eef081..fa9880ab19 100644 --- a/packages/sdk-node/src/clerkExpressRequireAuth.ts +++ b/packages/sdk-node/src/clerkExpressRequireAuth.ts @@ -1,5 +1,5 @@ import type { createClerkClient } from '@clerk/backend'; -import { AuthStatus } from '@clerk/backend'; +import { AuthStatus } from '@clerk/backend/internal'; import { authenticateRequest, decorateResponseWithObservabilityHeaders } from './authenticateRequest'; import type { ClerkMiddlewareOptions, MiddlewareRequireAuthProp, RequireAuthProp } from './types'; diff --git a/packages/sdk-node/src/clerkExpressWithAuth.ts b/packages/sdk-node/src/clerkExpressWithAuth.ts index aba87f14eb..bf3ce796e9 100644 --- a/packages/sdk-node/src/clerkExpressWithAuth.ts +++ b/packages/sdk-node/src/clerkExpressWithAuth.ts @@ -1,4 +1,4 @@ -import { AuthStatus } from '@clerk/backend'; +import { AuthStatus } from '@clerk/backend/internal'; import { authenticateRequest, decorateResponseWithObservabilityHeaders } from './authenticateRequest'; import type { CreateClerkExpressMiddlewareOptions } from './clerkExpressRequireAuth'; diff --git a/packages/sdk-node/src/types.ts b/packages/sdk-node/src/types.ts index a4e45e80ad..63bf6b209f 100644 --- a/packages/sdk-node/src/types.ts +++ b/packages/sdk-node/src/types.ts @@ -1,4 +1,5 @@ -import type { AuthenticateRequestOptions, AuthObject, createClerkClient, SignedInAuthObject } from '@clerk/backend'; +import type { createClerkClient } from '@clerk/backend'; +import type { AuthenticateRequestOptions, AuthObject, SignedInAuthObject } from '@clerk/backend/internal'; import type { MultiDomainAndOrProxy } from '@clerk/types'; import type { NextFunction, Request, Response } from 'express'; import type { IncomingMessage } from 'http';