Skip to content

Commit 8be8c52

Browse files
committed
do not expose internals
1 parent b7dedb4 commit 8be8c52

File tree

3 files changed

+3
-65
lines changed

3 files changed

+3
-65
lines changed

integration/tests/session-token-cache/multi-session.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
8080
expect(page2User1SessionInfo.userId).toBe(user1SessionInfo.userId);
8181
expect(page2User1SessionInfo.sessionId).toBe(user1SessionInfo.sessionId);
8282

83-
const page2HasUser1Token = await page2.evaluate(() => {
84-
const clerk = (window as any).Clerk;
85-
return clerk?._sessionTokenCache?.size?.() > 0;
86-
});
87-
expect(page2HasUser1Token).toBe(true);
88-
8983
// Use clerk.client.signIn.create() instead of navigating to /sign-in
9084
// because navigating replaces the session by default (transferable: true)
9185
const signInResult = await page2.evaluate(
@@ -159,20 +153,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
159153
expect(page2MultiSessionInfo.allSessionIds).toContain(user2SessionInfo.sessionId);
160154
expect(page2MultiSessionInfo.activeSessionId).toBe(user2SessionInfo.sessionId);
161155

162-
const tab2CacheInfo = await page2.evaluate(() => {
163-
const clerk = (window as any).Clerk;
164-
const cache = clerk?._sessionTokenCache;
165-
const cacheSize = cache?.size?.() || 0;
166-
167-
return {
168-
cacheSize,
169-
currentSessionId: clerk?.session?.id,
170-
};
171-
});
172-
173-
expect(tab2CacheInfo.currentSessionId).toBe(user2SessionInfo.sessionId);
174-
expect(tab2CacheInfo.cacheSize).toBeGreaterThan(0);
175-
176156
const tokenFetchRequests: Array<{ sessionId: string; url: string }> = [];
177157
await context.route('**/v1/client/sessions/*/tokens*', async route => {
178158
const url = route.request().url();
@@ -213,15 +193,13 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
213193
const clerk = (window as any).Clerk;
214194
return {
215195
activeSessionId: clerk?.session?.id,
216-
cacheSize: clerk?._sessionTokenCache?.size?.() || 0,
217196
userId: clerk?.user?.id,
218197
};
219198
});
220199

221200
// Tab1 should STILL have user1 as the active session (independent per tab)
222201
expect(tab1FinalInfo.userId).toBe(user1SessionInfo.userId);
223202
expect(tab1FinalInfo.activeSessionId).toBe(user1SessionInfo.sessionId);
224-
expect(tab1FinalInfo.cacheSize).toBeGreaterThan(0);
225203
});
226204
},
227205
);

integration/tests/session-token-cache/single-session.test.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })(
5252
const u2 = createTestUtils({ app, page: page2 });
5353
await u2.po.expect.toBeSignedIn();
5454

55-
const clerkInfo1 = await page1.evaluate(() => {
56-
const clerk = (window as any).Clerk;
57-
return {
58-
hasBroadcastChannel: !!clerk?._broadcastChannel,
59-
loaded: clerk?.loaded,
60-
};
61-
});
62-
63-
const clerkInfo2 = await page2.evaluate(() => {
64-
const clerk = (window as any).Clerk;
65-
return {
66-
hasBroadcastChannel: !!clerk?._broadcastChannel,
67-
loaded: clerk?.loaded,
68-
};
69-
});
70-
71-
expect(clerkInfo1.loaded).toBe(true);
72-
expect(clerkInfo2.loaded).toBe(true);
73-
74-
expect(clerkInfo1.hasBroadcastChannel).toBe(true);
75-
expect(clerkInfo2.hasBroadcastChannel).toBe(true);
76-
7755
const page1SessionInfo = await page1.evaluate(() => {
7856
const clerk = (window as any).Clerk;
7957
return {
@@ -104,14 +82,9 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })(
10482

10583
expect(page1Token).toBeTruthy();
10684

107-
// Wait for page2 to receive the broadcast and update its cache
108-
await page2.waitForFunction(
109-
() => {
110-
const clerk = (window as any).Clerk;
111-
return clerk?._sessionTokenCache?.size?.() > 0;
112-
},
113-
{ timeout: 10000 },
114-
);
85+
// Wait for broadcast to propagate between tabs (broadcast is nearly instant, but we add buffer)
86+
// eslint-disable-next-line playwright/no-wait-for-timeout
87+
await page2.waitForTimeout(2000);
11588

11689
const page2Result = await page2.evaluate(async () => {
11790
const clerk = (window as any).Clerk;

packages/clerk-js/src/core/clerk.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ import { createCheckoutInstance } from './modules/checkout/instance';
159159
import { BaseResource, Client, Environment, Organization, Waitlist } from './resources/internal';
160160
import { getTaskEndpoint, navigateIfTaskExists, warnMissingPendingTaskHandlers } from './sessionTasks';
161161
import { State } from './state';
162-
import { SessionTokenCache, type TokenCache } from './tokenCache';
163162
import { warnings } from './warnings';
164163

165164
type SetActiveHook = (intent?: 'sign-out') => void | Promise<void>;
@@ -266,18 +265,6 @@ export class Clerk implements ClerkInterface {
266265
return this.#publishableKey;
267266
}
268267

269-
get _broadcastChannel(): BroadcastChannel | null {
270-
return this.#broadcastChannel;
271-
}
272-
273-
get _sessionTokenCache(): TokenCache {
274-
return SessionTokenCache;
275-
}
276-
277-
get _options(): ClerkOptions {
278-
return this.#options;
279-
}
280-
281268
get version(): string {
282269
return Clerk.version;
283270
}

0 commit comments

Comments
 (0)