Skip to content

Commit a32d7bc

Browse files
committed
feat(repo): Remove deprecated props
1 parent 8cb5edc commit a32d7bc

File tree

45 files changed

+42
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+42
-603
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@clerk/nextjs": major
3+
"@clerk/clerk-react": major
4+
"@clerk/clerk-js": major
5+
"@clerk/shared": major
6+
"@clerk/ui": major
7+
"@clerk/react-router": major
8+
"@clerk/tanstack-react-start": major
9+
---
10+
11+
Remove all previously deprecated UI props across the Next.js, React and clerk-js SDKs. The legacy `afterSign(In|Up)Url`/`redirectUrl` props, `UserButton` sign-out overrides, organization `hideSlug` flags, `OrganizationSwitcher`'s `afterSwitchOrganizationUrl`, `Client.activeSessions`, `setActive({ beforeEmit })`, and the `ClerkMiddlewareAuthObject` type alias are no longer exported. Components now rely solely on the new redirect options and server-side configuration.

integration/templates/astro-node/src/components/CustomUserButton.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { UserButton } from '@clerk/astro/components';
33
---
44

5-
<UserButton afterSignOutUrl='/'>
5+
<UserButton>
66
<UserButton.MenuItems>
77
<UserButton.Action label='signOut' />
88
<UserButton.Action label='manageAccount' />

integration/templates/astro-node/src/layouts/react/Layout.astro

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ import { LanguagePicker } from '../../components/LanguagePicker';
8080
<LanguagePicker client:idle />
8181

8282
<SignedIn client:load>
83-
<UserButton
84-
client:load
85-
afterSignOutUrl='/'
86-
/>
83+
<UserButton client:load />
8784
</SignedIn>
8885

8986
<SignedOut client:load>

integration/templates/react-cra/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function App() {
1010
<SignIn />
1111
</SignedOut>
1212
<SignedIn>Signed In</SignedIn>
13-
<UserButton afterSignOutUrl={'/'} />
13+
<UserButton />
1414
</main>
1515
);
1616
}

integration/templates/react-vite/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ClientId } from './client-id';
66
function App() {
77
return (
88
<main>
9-
<UserButton afterSignOutUrl={'/'} />
9+
<UserButton />
1010
<OrganizationSwitcher fallback={<>Loading organization switcher</>} />
1111
<ClientId />
1212
<SignedOut>SignedOut</SignedOut>

packages/astro/src/stores/external.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const $organizationStore = computed([$authStore], auth => auth.organizati
7070
* It is a nanostore, for instructions on how to use nanostores please review the [documentation](https://github.com/nanostores/nanostores)
7171
*
7272
* @example
73-
* $clientStore.subscribe((client) => console.log(client.activeSessions))
73+
* $clientStore.subscribe((client) => console.log(client?.signedInSessions?.length))
7474
*/
7575
export const $clientStore = computed([$csrState], csr => csr.client);
7676

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

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -246,100 +246,6 @@ describe('Clerk singleton', () => {
246246
await sut.setActive({ session: mockSession as any as ActiveSessionResource });
247247
});
248248

249-
it('calls __unstable__onAfterSetActive after beforeEmit and session.touch', async () => {
250-
const beforeEmitMock = vi.fn();
251-
mockSession.touch.mockReturnValueOnce(Promise.resolve());
252-
mockClientFetch.mockReturnValue(Promise.resolve({ signedInSessions: [mockSession] }));
253-
254-
(window as any).__unstable__onAfterSetActive = () => {
255-
expect(mockSession.touch).toHaveBeenCalled();
256-
expect(beforeEmitMock).toHaveBeenCalled();
257-
};
258-
259-
const sut = new Clerk(productionPublishableKey);
260-
await sut.load();
261-
await sut.setActive({ session: mockSession as any as ActiveSessionResource, beforeEmit: beforeEmitMock });
262-
});
263-
264-
// TODO: @dimkl include set transitive state
265-
it('calls session.touch -> set cookie -> before emit with touched session on session switch', async () => {
266-
const mockSession2 = {
267-
id: '2',
268-
remove: vi.fn(),
269-
status: 'active',
270-
user: {},
271-
touch: vi.fn(),
272-
getToken: vi.fn(),
273-
};
274-
mockClientFetch.mockReturnValue(
275-
Promise.resolve({
276-
signedInSessions: [mockSession, mockSession2],
277-
}),
278-
);
279-
280-
const sut = new Clerk(productionPublishableKey);
281-
await sut.load();
282-
283-
const executionOrder: string[] = [];
284-
mockSession2.touch.mockImplementationOnce(() => {
285-
sut.session = mockSession2 as any;
286-
executionOrder.push('session.touch');
287-
return Promise.resolve();
288-
});
289-
mockSession2.getToken.mockImplementation(() => {
290-
executionOrder.push('set cookie');
291-
return 'mocked-token-2';
292-
});
293-
const beforeEmitMock = vi.fn().mockImplementationOnce(() => {
294-
executionOrder.push('before emit');
295-
return Promise.resolve();
296-
});
297-
298-
await sut.setActive({ session: mockSession2 as any as ActiveSessionResource, beforeEmit: beforeEmitMock });
299-
300-
await waitFor(() => {
301-
expect(executionOrder).toEqual(['session.touch', 'set cookie', 'before emit']);
302-
expect(mockSession2.touch).toHaveBeenCalled();
303-
expect(mockSession2.getToken).toHaveBeenCalled();
304-
expect(beforeEmitMock).toHaveBeenCalledWith(mockSession2);
305-
expect(sut.session).toMatchObject(mockSession2);
306-
});
307-
});
308-
309-
// TODO: @dimkl include set transitive state
310-
it('calls with lastActiveOrganizationId session.touch -> set cookie -> before emit -> set accessors with touched session on organization switch', async () => {
311-
mockClientFetch.mockReturnValue(Promise.resolve({ signedInSessions: [mockSession] }));
312-
const sut = new Clerk(productionPublishableKey);
313-
await sut.load();
314-
315-
const executionOrder: string[] = [];
316-
mockSession.touch.mockImplementationOnce(() => {
317-
sut.session = mockSession as any;
318-
executionOrder.push('session.touch');
319-
return Promise.resolve();
320-
});
321-
mockSession.getToken.mockImplementation(() => {
322-
executionOrder.push('set cookie');
323-
return 'mocked-token';
324-
});
325-
326-
const beforeEmitMock = vi.fn().mockImplementationOnce(() => {
327-
executionOrder.push('before emit');
328-
return Promise.resolve();
329-
});
330-
331-
await sut.setActive({ organization: { id: 'org_id' } as Organization, beforeEmit: beforeEmitMock });
332-
333-
await waitFor(() => {
334-
expect(executionOrder).toEqual(['session.touch', 'set cookie', 'before emit']);
335-
expect(mockSession.touch).toHaveBeenCalled();
336-
expect(mockSession.getToken).toHaveBeenCalled();
337-
expect((mockSession as any as ActiveSessionResource)?.lastActiveOrganizationId).toEqual('org_id');
338-
expect(beforeEmitMock).toHaveBeenCalledWith(mockSession);
339-
expect(sut.session).toMatchObject(mockSession);
340-
});
341-
});
342-
343249
it('sets active organization by slug', async () => {
344250
const mockSession2 = {
345251
id: '1',
@@ -465,24 +371,16 @@ describe('Clerk singleton', () => {
465371
const sut = new Clerk(productionPublishableKey);
466372
await sut.load({ standardBrowser: false });
467373

468-
const executionOrder: string[] = [];
469374
mockSession.touch.mockImplementationOnce(() => {
470375
sut.session = mockSession as any;
471-
executionOrder.push('session.touch');
472-
return Promise.resolve();
473-
});
474-
const beforeEmitMock = vi.fn().mockImplementationOnce(() => {
475-
executionOrder.push('before emit');
476376
return Promise.resolve();
477377
});
478378

479-
await sut.setActive({ organization: { id: 'org_id' } as Organization, beforeEmit: beforeEmitMock });
379+
await sut.setActive({ organization: { id: 'org_id' } as Organization });
480380

481-
expect(executionOrder).toEqual(['session.touch', 'before emit']);
482381
expect(mockSession.touch).toHaveBeenCalled();
483382
expect((mockSession as any as ActiveSessionResource)?.lastActiveOrganizationId).toEqual('org_id');
484383
expect(mockSession.getToken).toHaveBeenCalled();
485-
expect(beforeEmitMock).toHaveBeenCalledWith(mockSession);
486384
expect(sut.session).toMatchObject(mockSession);
487385
});
488386
});

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { inBrowser as inClientSide, isValidBrowserOnline } from '@clerk/shared/browser';
22
import { clerkEvents, createClerkEventBus } from '@clerk/shared/clerkEventBus';
3-
import { deprecated } from '@clerk/shared/deprecated';
43
import {
54
ClerkRuntimeError,
65
EmailLinkError,
@@ -9,7 +8,6 @@ import {
98
isClerkAPIResponseError,
109
isClerkRuntimeError,
1110
} from '@clerk/shared/error';
12-
import { assertNoLegacyProp } from '@clerk/shared/internal/clerk-js/assertNoLegacyProp';
1311
import {
1412
disabledAllAPIKeysFeatures,
1513
disabledAllBillingFeatures,
@@ -496,8 +494,6 @@ export class Clerk implements ClerkInterface {
496494
this.#emit();
497495
});
498496

499-
assertNoLegacyProp(this.#options);
500-
501497
if (this.#options.sdkMetadata) {
502498
Clerk.sdkMetadata = this.#options.sdkMetadata;
503499
}
@@ -1300,7 +1296,7 @@ export class Clerk implements ClerkInterface {
13001296
* `setActive` can be used to set the active session and/or organization.
13011297
*/
13021298
public setActive = async (params: SetActiveParams): Promise<void> => {
1303-
const { organization, beforeEmit, redirectUrl, navigate: setActiveNavigate } = params;
1299+
const { organization, redirectUrl, navigate: setActiveNavigate } = params;
13041300
let { session } = params;
13051301
this.__internal_setActiveInProgress = true;
13061302
debugLogger.debug(
@@ -1405,29 +1401,18 @@ export class Clerk implements ClerkInterface {
14051401
eventBus.emit(events.TokenUpdate, { token: null });
14061402
}
14071403

1408-
//2. If there's a beforeEmit, typically we're navigating. Emit the session as
1409-
// undefined, then wait for beforeEmit to complete before emitting the new session.
1404+
//2. When navigation is required we emit the session as undefined,
1405+
// then wait for navigation to finish before emitting the new session.
14101406
// When undefined, neither SignedIn nor SignedOut renders, which avoids flickers or
14111407
// automatic reloading when reloading shouldn't be happening.
14121408
const tracker = createBeforeUnloadTracker(this.#options.standardBrowser);
14131409

1414-
if (beforeEmit) {
1415-
deprecated(
1416-
'Clerk.setActive({beforeEmit})',
1417-
'Use the `redirectUrl` property instead. Example `Clerk.setActive({redirectUrl:"/"})`',
1418-
);
1419-
await tracker.track(async () => {
1420-
this.#setTransitiveState();
1421-
await beforeEmit(newSession);
1422-
});
1423-
}
1424-
14251410
const taskUrl =
14261411
newSession?.status === 'pending' &&
14271412
newSession?.currentTask &&
14281413
this.#options.taskUrls?.[newSession?.currentTask.key];
14291414

1430-
if (!beforeEmit && (redirectUrl || taskUrl || setActiveNavigate)) {
1415+
if (redirectUrl || taskUrl || setActiveNavigate) {
14311416
await tracker.track(async () => {
14321417
if (!this.client) {
14331418
// Typescript is not happy because since thinks this.client might have changed to undefined because the function is asynchronous.

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type {
2-
ActiveSessionResource,
32
ClientJSON,
43
ClientJSONSnapshot,
54
ClientResource,
@@ -57,13 +56,6 @@ export class Client extends BaseResource implements ClientResource {
5756
return this.signIn;
5857
}
5958

60-
/**
61-
* @deprecated Use `signedInSessions()` instead.
62-
*/
63-
get activeSessions(): ActiveSessionResource[] {
64-
return this.sessions.filter(s => s.status === 'active') as ActiveSessionResource[];
65-
}
66-
6759
get signedInSessions(): SignedInSessionResource[] {
6860
return this.sessions.filter(s => s.status === 'active' || s.status === 'pending') as SignedInSessionResource[];
6961
}

packages/localizations/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ We're open to all community contributions! If you'd like to contribute in any wa
6666
1. Open the [`localizations/src/en-US.ts`](https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts) file and add your new key to the object. `en-US` is the default language. If you feel comfortable adding your message in another language than English, feel free to also edit other files.
6767

6868
1. Use the new localization key inside the component. There are two ways:
69+
6970
- The string is inside a component like `<Text>`:
7071

7172
```diff

0 commit comments

Comments
 (0)