Skip to content

Commit

Permalink
added correct types for authenticateRequest across the other sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobevangelista committed Dec 11, 2024
1 parent aa071c4 commit a13f69a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
8 changes: 7 additions & 1 deletion packages/backend/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export type { SignedInAuthObjectOptions, SignedInAuthObject, SignedOutAuthObject
export { makeAuthObjectSerializable, signedOutAuthObject, signedInAuthObject } from './tokens/authObjects';

export { AuthStatus } from './tokens/authStatus';
export type { RequestState, SignedInState, SignedOutState } from './tokens/authStatus';
export type {
RequestState,
SignedInState,
SignedOutState,
MachineAuthenticatedState,
MachineUnauthenticatedState,
} from './tokens/authStatus';

export { decorateObjectWithResources, stripPrivateDataFromObject } from './util/decorateObjectWithResources';

Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/tokens/__tests__/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ describe('tokens.authenticateRequest(options)', () => {
mockRequestWithHeaderAuth({ authorization: '' }),
mockOptions({ entity: 'machine' }),
);
console.log(requestState);

expect(requestState).toBeMachineUnAuthenticated({
reason: 'no machine token in header',
Expand Down
10 changes: 8 additions & 2 deletions packages/react-router/src/ssr/authenticateRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { createClerkClient } from '@clerk/backend';
import type { AuthenticateRequestOptions, SignedInState, SignedOutState } from '@clerk/backend/internal';
import type {
AuthenticateRequestOptions,
MachineAuthenticatedState,
MachineUnauthenticatedState,
SignedInState,
SignedOutState,
} from '@clerk/backend/internal';
import { AuthStatus } from '@clerk/backend/internal';

import type { LoaderFunctionArgs } from './types';
Expand All @@ -8,7 +14,7 @@ import { patchRequest } from './utils';
export async function authenticateRequest(
args: LoaderFunctionArgs,
opts: AuthenticateRequestOptions,
): Promise<SignedInState | SignedOutState> {
): Promise<SignedInState | SignedOutState | MachineAuthenticatedState | MachineUnauthenticatedState> {
const { request } = args;
const { audience, authorizedParties } = opts;

Expand Down
10 changes: 8 additions & 2 deletions packages/remix/src/ssr/authenticateRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { createClerkClient } from '@clerk/backend';
import type { AuthenticateRequestOptions, SignedInState, SignedOutState } from '@clerk/backend/internal';
import type {
AuthenticateRequestOptions,
MachineAuthenticatedState,
MachineUnauthenticatedState,
SignedInState,
SignedOutState,
} from '@clerk/backend/internal';
import { AuthStatus } from '@clerk/backend/internal';

import type { LoaderFunctionArgs } from './types';
Expand All @@ -8,7 +14,7 @@ import { patchRequest } from './utils';
export async function authenticateRequest(
args: LoaderFunctionArgs,
opts: AuthenticateRequestOptions,
): Promise<SignedInState | SignedOutState> {
): Promise<SignedInState | SignedOutState | MachineAuthenticatedState | MachineUnauthenticatedState> {
const { request } = args;
const { audience, authorizedParties } = opts;

Expand Down
10 changes: 8 additions & 2 deletions packages/tanstack-start/src/server/authenticateRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { createClerkClient } from '@clerk/backend';
import type { AuthenticateRequestOptions, SignedInState, SignedOutState } from '@clerk/backend/internal';
import type {
AuthenticateRequestOptions,
MachineAuthenticatedState,
MachineUnauthenticatedState,
SignedInState,
SignedOutState,
} from '@clerk/backend/internal';
import { AuthStatus } from '@clerk/backend/internal';

import { errorThrower } from '../utils';
Expand All @@ -8,7 +14,7 @@ import { patchRequest } from './utils';
export async function authenticateRequest(
request: Request,
opts: AuthenticateRequestOptions,
): Promise<SignedInState | SignedOutState> {
): Promise<SignedInState | SignedOutState | MachineAuthenticatedState | MachineUnauthenticatedState> {
const { audience, authorizedParties } = opts;

const { apiUrl, secretKey, jwtKey, proxyUrl, isSatellite, domain, publishableKey } = opts;
Expand Down

0 comments on commit a13f69a

Please sign in to comment.