Skip to content

Commit 58c0c97

Browse files
committed
chore: address conflicts
1 parent b8eb01f commit 58c0c97

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

packages/backend/src/tokens/__tests__/request.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import type { AuthReason } from '../authStatus';
1616
import { AuthErrorReason, AuthStatus } from '../authStatus';
1717
import { OrganizationMatcher } from '../organizationMatcher';
1818
import { authenticateRequest, RefreshTokenErrorReason } from '../request';
19-
import type { AuthenticateRequestOptions, MachineTokenType } from '../types';
19+
import type { MachineTokenType } from '../tokenTypes';
20+
import type { AuthenticateRequestOptions } from '../types';
2021

2122
const PK_TEST = 'pk_test_Y2xlcmsuaW5zcGlyZWQucHVtYS03NC5sY2wuZGV2JA';
2223
const PK_LIVE = 'pk_live_Y2xlcmsuaW5zcGlyZWQucHVtYS03NC5sY2wuZGV2JA';

packages/backend/src/tokens/authObjects.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import type {
1111
import type { APIKey, CreateBackendApiOptions, MachineToken } from '../api';
1212
import { createBackendApiClient } from '../api';
1313
import type { AuthenticateContext } from './authenticateContext';
14-
import type { MachineTokenType, SessionTokenType } from './tokenTypes';
14+
import type { MachineAuthType, MachineTokenType, SessionTokenType } from './tokenTypes';
1515
import { TokenType } from './tokenTypes';
16-
import type { MachineAuthType } from './types';
1716

1817
type AuthObjectDebugData = Record<string, any>;
1918
type AuthObjectDebug = () => AuthObjectDebugData;

packages/backend/src/tokens/authStatus.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import {
1515
signedOutAuthObject,
1616
unauthenticatedMachineObject,
1717
} from './authObjects';
18-
import type { MachineTokenType, SessionTokenType } from './tokenTypes';
18+
import type { MachineAuthType, MachineTokenType, SessionTokenType } from './tokenTypes';
1919
import { TokenType } from './tokenTypes';
20-
import type { MachineAuthType } from './types';
2120

2221
export const AuthStatus = {
2322
SignedIn: 'signed-in',

packages/backend/src/tokens/handshake.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AuthErrorReason, signedIn, signedOut } from './authStatus';
99
import { getCookieName, getCookieValue } from './cookie';
1010
import { loadClerkJWKFromLocal, loadClerkJWKFromRemote } from './keys';
1111
import type { OrganizationMatcher } from './organizationMatcher';
12+
import { TokenType } from './tokenTypes';
1213
import type { OrganizationSyncOptions, OrganizationSyncTarget } from './types';
1314
import type { VerifyTokenOptions } from './verify';
1415
import { verifyToken } from './verify';
@@ -202,12 +203,24 @@ export class HandshakeService {
202203
}
203204

204205
if (sessionToken === '') {
205-
return signedOut(this.authenticateContext, AuthErrorReason.SessionTokenMissing, '', headers);
206+
return signedOut({
207+
tokenType: TokenType.SessionToken,
208+
authenticateContext: this.authenticateContext,
209+
reason: AuthErrorReason.SessionTokenMissing,
210+
message: '',
211+
headers,
212+
});
206213
}
207214

208215
const { data, errors: [error] = [] } = await verifyToken(sessionToken, this.authenticateContext);
209216
if (data) {
210-
return signedIn(this.authenticateContext, data, headers, sessionToken);
217+
return signedIn({
218+
tokenType: TokenType.SessionToken,
219+
authenticateContext: this.authenticateContext,
220+
sessionClaims: data,
221+
headers,
222+
token: sessionToken,
223+
});
211224
}
212225

213226
if (
@@ -240,7 +253,13 @@ ${developmentError.getFullMessage()}`,
240253
clockSkewInMs: 86_400_000,
241254
});
242255
if (retryResult) {
243-
return signedIn(this.authenticateContext, retryResult, headers, sessionToken);
256+
return signedIn({
257+
tokenType: TokenType.SessionToken,
258+
authenticateContext: this.authenticateContext,
259+
sessionClaims: retryResult,
260+
headers,
261+
token: sessionToken,
262+
});
244263
}
245264

246265
throw new Error(retryError?.message || 'Clerk: Handshake retry failed.');

packages/backend/src/tokens/tokenTypes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { APIKey, IdPOAuthAccessToken, MachineToken } from '../api';
2+
13
export const TokenType = {
24
SessionToken: 'session_token',
35
ApiKey: 'api_key',
@@ -9,3 +11,4 @@ export type TokenType = (typeof TokenType)[keyof typeof TokenType];
911

1012
export type SessionTokenType = typeof TokenType.SessionToken;
1113
export type MachineTokenType = Exclude<TokenType, SessionTokenType>;
14+
export type MachineAuthType = MachineToken | APIKey | IdPOAuthAccessToken;

0 commit comments

Comments
 (0)