diff --git a/.changeset/fast-knives-peel.md b/.changeset/fast-knives-peel.md new file mode 100644 index 0000000000..4ea6f25cce --- /dev/null +++ b/.changeset/fast-knives-peel.md @@ -0,0 +1,9 @@ +--- +"@clerk/backend": patch +--- + +Export the type `AuthObject`. You can now use it like so: + +```ts +import type { AuthObject } from "@clerk/backend" +``` diff --git a/.changeset/itchy-ravens-protect.md b/.changeset/itchy-ravens-protect.md new file mode 100644 index 0000000000..26ca2f0205 --- /dev/null +++ b/.changeset/itchy-ravens-protect.md @@ -0,0 +1,10 @@ +--- +"@clerk/clerk-sdk-node": patch +"@clerk/express": patch +"@clerk/fastify": patch +"@clerk/nextjs": patch +"@clerk/astro": patch +"@clerk/remix": patch +--- + +Internal change: Use `AuthObject` type import from `@clerk/backend`. diff --git a/packages/astro/src/server/clerk-middleware.ts b/packages/astro/src/server/clerk-middleware.ts index d15c6d1b12..0dc2b8ea5f 100644 --- a/packages/astro/src/server/clerk-middleware.ts +++ b/packages/astro/src/server/clerk-middleware.ts @@ -1,11 +1,5 @@ -import type { ClerkClient } from '@clerk/backend'; -import type { - AuthenticateRequestOptions, - AuthObject, - ClerkRequest, - RedirectFun, - RequestState, -} from '@clerk/backend/internal'; +import type { AuthObject, ClerkClient } from '@clerk/backend'; +import type { AuthenticateRequestOptions, ClerkRequest, RedirectFun, RequestState } from '@clerk/backend/internal'; import { AuthStatus, constants, createClerkRequest, createRedirect } from '@clerk/backend/internal'; import { handleValueOrFn, isDevelopmentFromSecretKey, isHttpOrHttps } from '@clerk/shared'; import { eventMethodCalled } from '@clerk/shared/telemetry'; diff --git a/packages/astro/src/server/get-auth.ts b/packages/astro/src/server/get-auth.ts index 710ebf6028..7444db0657 100644 --- a/packages/astro/src/server/get-auth.ts +++ b/packages/astro/src/server/get-auth.ts @@ -1,4 +1,5 @@ -import { type AuthObject, AuthStatus, signedInAuthObject, signedOutAuthObject } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; +import { AuthStatus, signedInAuthObject, signedOutAuthObject } from '@clerk/backend/internal'; import { decodeJwt } from '@clerk/backend/jwt'; import type { APIContext } from 'astro'; diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 00a7520fce..e74b5ba103 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -120,3 +120,8 @@ export type { WebhookEvent, WebhookEventType, } from './api/resources/Webhooks'; + +/** + * Auth objects + */ +export type { AuthObject } from './tokens/authObjects'; diff --git a/packages/backend/src/internal.ts b/packages/backend/src/internal.ts index bbe92f7858..11978dae04 100644 --- a/packages/backend/src/internal.ts +++ b/packages/backend/src/internal.ts @@ -9,12 +9,7 @@ export { debugRequestState } from './tokens/request'; export type { AuthenticateRequestOptions } from './tokens/types'; -export type { - SignedInAuthObjectOptions, - SignedInAuthObject, - SignedOutAuthObject, - AuthObject, -} from './tokens/authObjects'; +export type { SignedInAuthObjectOptions, SignedInAuthObject, SignedOutAuthObject } from './tokens/authObjects'; export { makeAuthObjectSerializable, signedOutAuthObject, signedInAuthObject } from './tokens/authObjects'; export { AuthStatus } from './tokens/authStatus'; diff --git a/packages/express/src/__tests__/helpers.ts b/packages/express/src/__tests__/helpers.ts index 45a6480b95..b2131568c1 100644 --- a/packages/express/src/__tests__/helpers.ts +++ b/packages/express/src/__tests__/helpers.ts @@ -1,4 +1,4 @@ -import type { AuthObject } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; import type { Application, Request as ExpressRequest, RequestHandler, Response as ExpressResponse } from 'express'; import express from 'express'; import supertest from 'supertest'; diff --git a/packages/express/src/getAuth.ts b/packages/express/src/getAuth.ts index 41a9b0e0c7..90652cb69e 100644 --- a/packages/express/src/getAuth.ts +++ b/packages/express/src/getAuth.ts @@ -1,4 +1,4 @@ -import type { AuthObject } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; import type { Request as ExpressRequest } from 'express'; import { middlewareRequired } from './errors'; diff --git a/packages/express/src/types.ts b/packages/express/src/types.ts index 7de7d1652a..0d4bfe75a3 100644 --- a/packages/express/src/types.ts +++ b/packages/express/src/types.ts @@ -1,6 +1,5 @@ -// eslint-disable-next-line @typescript-eslint/consistent-type-imports -import { createClerkClient } from '@clerk/backend'; -import type { AuthenticateRequestOptions, AuthObject } from '@clerk/backend/internal'; +import type { AuthObject, createClerkClient } from '@clerk/backend'; +import type { AuthenticateRequestOptions } from '@clerk/backend/internal'; import type { Request as ExpressRequest, RequestHandler } from 'express'; export type ExpressRequestWithAuth = ExpressRequest & { auth: AuthObject }; diff --git a/packages/fastify/src/getAuth.ts b/packages/fastify/src/getAuth.ts index 1b6c24138e..7acb04aefc 100644 --- a/packages/fastify/src/getAuth.ts +++ b/packages/fastify/src/getAuth.ts @@ -1,4 +1,4 @@ -import type { AuthObject } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; import type { FastifyRequest } from 'fastify'; import { pluginRegistrationRequired } from './errors'; diff --git a/packages/gatsby-plugin-clerk/src/ssr/types.ts b/packages/gatsby-plugin-clerk/src/ssr/types.ts index f823ca971b..ee1daec49c 100644 --- a/packages/gatsby-plugin-clerk/src/ssr/types.ts +++ b/packages/gatsby-plugin-clerk/src/ssr/types.ts @@ -1,5 +1,5 @@ -import type { Organization, Session, User } from '@clerk/backend'; -import type { AuthenticateRequestOptions, AuthObject } from '@clerk/backend/internal'; +import type { AuthObject, Organization, Session, User } from '@clerk/backend'; +import type { AuthenticateRequestOptions } from '@clerk/backend/internal'; import type { GetServerDataProps } from 'gatsby'; export type WithServerAuthResult = (props: GetServerDataProps) => Promise>; diff --git a/packages/nextjs/src/app-router/server/auth.ts b/packages/nextjs/src/app-router/server/auth.ts index e90f46013d..4db3d4bf2d 100644 --- a/packages/nextjs/src/app-router/server/auth.ts +++ b/packages/nextjs/src/app-router/server/auth.ts @@ -1,4 +1,5 @@ -import type { AuthObject, RedirectFun } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; +import type { RedirectFun } from '@clerk/backend/internal'; import { constants, createClerkRequest, createRedirect } from '@clerk/backend/internal'; import { notFound, redirect } from 'next/navigation'; diff --git a/packages/nextjs/src/server/authMiddleware.ts b/packages/nextjs/src/server/authMiddleware.ts index e9803a0322..c3076b6c6c 100644 --- a/packages/nextjs/src/server/authMiddleware.ts +++ b/packages/nextjs/src/server/authMiddleware.ts @@ -1,4 +1,5 @@ -import type { AuthenticateRequestOptions, AuthObject, ClerkRequest } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; +import type { AuthenticateRequestOptions, ClerkRequest } from '@clerk/backend/internal'; import { AuthStatus, constants, createClerkRequest, createRedirect } from '@clerk/backend/internal'; import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; import { eventMethodCalled } from '@clerk/shared/telemetry'; diff --git a/packages/nextjs/src/server/clerkMiddleware.ts b/packages/nextjs/src/server/clerkMiddleware.ts index 8ea02733ab..10ce52b6a3 100644 --- a/packages/nextjs/src/server/clerkMiddleware.ts +++ b/packages/nextjs/src/server/clerkMiddleware.ts @@ -1,12 +1,7 @@ import { AsyncLocalStorage } from 'node:async_hooks'; -import type { - AuthenticateRequestOptions, - AuthObject, - ClerkRequest, - RedirectFun, - RequestState, -} from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; +import type { AuthenticateRequestOptions, ClerkRequest, RedirectFun, RequestState } from '@clerk/backend/internal'; import { AuthStatus, constants, createClerkRequest, createRedirect } from '@clerk/backend/internal'; import { eventMethodCalled } from '@clerk/shared/telemetry'; import type { NextMiddleware } from 'next/server'; diff --git a/packages/nextjs/src/server/createGetAuth.ts b/packages/nextjs/src/server/createGetAuth.ts index 11b85ad03d..39b60a0d4d 100644 --- a/packages/nextjs/src/server/createGetAuth.ts +++ b/packages/nextjs/src/server/createGetAuth.ts @@ -1,4 +1,4 @@ -import type { AuthObject } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; import { AuthStatus, constants, signedInAuthObject, signedOutAuthObject } from '@clerk/backend/internal'; import { decodeJwt } from '@clerk/backend/jwt'; diff --git a/packages/nextjs/src/server/protect.ts b/packages/nextjs/src/server/protect.ts index 9499cca42d..8e6a73a5a9 100644 --- a/packages/nextjs/src/server/protect.ts +++ b/packages/nextjs/src/server/protect.ts @@ -1,4 +1,5 @@ -import type { AuthObject, RedirectFun, SignedInAuthObject } from '@clerk/backend/internal'; +import type { AuthObject } from '@clerk/backend'; +import type { RedirectFun, SignedInAuthObject } from '@clerk/backend/internal'; import { constants } from '@clerk/backend/internal'; import type { CheckAuthorizationParamsWithCustomPermissions, diff --git a/packages/remix/src/ssr/types.ts b/packages/remix/src/ssr/types.ts index 97f29e70bc..2ed18d7ecd 100644 --- a/packages/remix/src/ssr/types.ts +++ b/packages/remix/src/ssr/types.ts @@ -1,5 +1,5 @@ -import type { Organization, Session, User, VerifyTokenOptions } from '@clerk/backend'; -import type { AuthObject, RequestState } from '@clerk/backend/internal'; +import type { AuthObject, Organization, Session, User, VerifyTokenOptions } from '@clerk/backend'; +import type { RequestState } from '@clerk/backend/internal'; import type { LegacyRedirectProps, MultiDomainAndOrProxy, diff --git a/packages/sdk-node/src/types.ts b/packages/sdk-node/src/types.ts index 08e362ce0c..8f05b227a5 100644 --- a/packages/sdk-node/src/types.ts +++ b/packages/sdk-node/src/types.ts @@ -1,5 +1,5 @@ -import type { createClerkClient } from '@clerk/backend'; -import type { AuthenticateRequestOptions, AuthObject, SignedInAuthObject } from '@clerk/backend/internal'; +import type { AuthObject, createClerkClient } from '@clerk/backend'; +import type { AuthenticateRequestOptions, SignedInAuthObject } from '@clerk/backend/internal'; import type { MultiDomainAndOrProxy } from '@clerk/types'; import type { NextFunction, Request, Response } from 'express'; import type { IncomingMessage } from 'http';