From 7f833da9ebc1b2ec9c65513628c377d0584e5d72 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Fri, 10 Nov 2023 12:05:18 +0200 Subject: [PATCH] chore(clerk-js): Drop deprecations (#2082) * chore(clerk-react): Drop `frontendApi` * chore(clerk-react,chrome-extension): Drop `*MagicLink*` related exports * chore(clerk-js): Drop `*MagicLink*` related exports * chore(types): Drop `*MagicLink*` related exports * chore(clerk-js): Drop `orgs` claim * chore(clerk-js,types): Drop `afterSwitchOrganizationUrl` claim * chore(clerk-js): Drop support for `frontendApi` as parameter * chore(clerk-js,types): Drop image related properties - `ExternalAccount.avatarUrl` - `ExternalAccountJSON.avatar_url` - `Organization.logoUrl` - `OrganizationJSON.logo_url` - `User.profileImageUrl` - `UserJSON.profile_image_url` - `OrganizationMembershipPublicUserData.profileImageUrl` - `OrganizationMembershipPublicUserDataJSON.profile_image_url` * chore(clerk-js,types): Drop `*captcha` related methods from Clerk * chore(clerk-js,types): Drop `Organization` related deprecations * chore(*): Drop `useOrganizations` * chore(clerk-js,types): Drop `appearance.userProfile` * chore(clerk-js,clerk-react): Drop `membershipList` and `invitationList` params deprecations * chore(clerk-js,types): Drop `Clerk.setSession` * chore(clerk-js,types): Drop `redirect_url` deprecations * chore(clerk-js,types): Drop `GetMembershipsParams` * chore(clerk-js): Drop `generateSignature` * chore(clerk-js,types): Drop `password` * chore(clerk-js,types): Drop deprecated `addListener/removeListener` from matchMedia return * chore(repo): Add word spelling in vscode workspace + fix typos * chore(clerk-js,types): Use paginated responses in get memberships endpoints * chore(repo): Add changeset * chore(clerk-js,types): Address PR comments --- .changeset/fast-games-hide.md | 39 ++ .vscode/settings.json | 21 +- .../src/__snapshots__/exports.test.ts.snap | 1 - packages/clerk-js/README.md | 11 +- packages/clerk-js/jest.setup.ts | 3 - .../clerk-js/src/core/clerk.redirects.test.ts | 20 +- packages/clerk-js/src/core/clerk.test.ts | 406 ++++-------------- packages/clerk-js/src/core/clerk.ts | 209 ++------- packages/clerk-js/src/core/fapiClient.test.ts | 14 +- .../src/core/resources/DisplayConfig.ts | 14 - .../src/core/resources/EmailAddress.ts | 37 -- packages/clerk-js/src/core/resources/Error.ts | 3 - .../src/core/resources/ExternalAccount.ts | 9 +- .../src/core/resources/Organization.test.ts | 4 +- .../src/core/resources/Organization.ts | 103 +---- .../core/resources/OrganizationInvitation.ts | 11 +- .../resources/OrganizationMembership.test.ts | 8 +- .../core/resources/OrganizationMembership.ts | 68 +-- .../OrganizationMembershipRequest.test.ts | 1 - .../src/core/resources/PublicUserData.ts | 11 +- .../clerk-js/src/core/resources/SignIn.ts | 44 +- .../clerk-js/src/core/resources/SignUp.ts | 66 +-- packages/clerk-js/src/core/resources/User.ts | 21 +- .../clerk-js/src/core/resources/UserData.ts | 11 +- .../clerk-js/src/core/resources/Web3Wallet.ts | 42 +- .../__snapshots__/Organization.test.ts.snap | 3 +- .../OrganizationMembership.test.ts.snap | 5 +- packages/clerk-js/src/core/test/fixtures.ts | 9 +- packages/clerk-js/src/index.browser.ts | 7 +- .../clerk-js/src/index.headless.browser.ts | 7 +- packages/clerk-js/src/ui/common/constants.ts | 11 - .../__tests__/CreateOrganization.test.tsx | 3 - .../OrganizationProfile/__tests__/utils.ts | 3 - .../UserButton/useMultisessionActions.tsx | 17 +- .../ui/components/UserProfile/EmailPage.tsx | 4 +- .../__tests__/ProfilePage.test.tsx | 4 +- .../src/ui/components/UserProfile/utils.ts | 2 +- .../ui/contexts/ClerkUIComponentsContext.tsx | 8 +- .../ui/contexts/CoreClerkContextWrapper.tsx | 6 +- .../ui/contexts/CoreOrganizationContext.tsx | 3 +- .../clerk-js/src/ui/elements/UserAvatar.tsx | 1 - .../__tests__/useCoreOrganization.test.tsx | 6 - .../hooks/__tests__/useSupportEmail.test.tsx | 2 +- .../src/ui/utils/test/createFixtures.tsx | 4 +- .../src/ui/utils/test/fixtureHelpers.ts | 1 - .../clerk-js/src/ui/utils/test/fixtures.ts | 9 +- packages/clerk-js/src/utils/jwt.ts | 8 - .../src/utils/memoizeStateListenerCallback.ts | 5 - packages/expo/src/index.ts | 1 - packages/nextjs/src/client-boundary/hooks.ts | 1 - packages/nextjs/src/index.ts | 1 - .../src/contexts/ClerkContextProvider.tsx | 20 +- packages/react/src/hooks/index.ts | 1 - packages/react/src/hooks/useOrganizations.ts | 1 - packages/react/src/isomorphicClerk.ts | 9 - packages/react/src/utils/deriveState.ts | 17 +- packages/remix/src/ssr/authenticateRequest.ts | 2 +- packages/shared/src/error.ts | 7 - packages/shared/src/keys.ts | 2 +- packages/shared/src/react/contexts.tsx | 21 +- packages/shared/src/react/hooks/index.ts | 1 - .../src/react/hooks/useOrganization.tsx | 115 +---- .../src/react/hooks/useOrganizationList.tsx | 7 +- .../src/react/hooks/useOrganizations.tsx | 72 ---- packages/types/src/clerk.ts | 75 +--- packages/types/src/displayConfig.ts | 6 - packages/types/src/emailAddress.ts | 6 - packages/types/src/externalAccount.ts | 4 - packages/types/src/json.ts | 20 - packages/types/src/jwt.ts | 9 +- packages/types/src/organization.ts | 33 +- packages/types/src/session.ts | 4 - packages/types/src/signIn.ts | 19 - packages/types/src/signUp.ts | 11 +- packages/types/src/user.ts | 34 +- packages/types/src/verification.ts | 15 - packages/types/src/web3Wallet.ts | 4 +- 77 files changed, 285 insertions(+), 1538 deletions(-) create mode 100644 .changeset/fast-games-hide.md delete mode 100644 packages/react/src/hooks/useOrganizations.ts delete mode 100644 packages/shared/src/react/hooks/useOrganizations.tsx diff --git a/.changeset/fast-games-hide.md b/.changeset/fast-games-hide.md new file mode 100644 index 0000000000..e4c04b3602 --- /dev/null +++ b/.changeset/fast-games-hide.md @@ -0,0 +1,39 @@ +--- +'@clerk/chrome-extension': major +'@clerk/clerk-js': major +'@clerk/nextjs': major +'@clerk/shared': major +'@clerk/clerk-react': major +'@clerk/types': major +'@clerk/clerk-expo': major +--- + +Drop deprecations. Migration steps: +- use `publishableKey` instead of `frontendApi` +- use `Clerk.handleEmailLinkVerification()` instead of `Clerk.handleMagicLinkVerification()` +- use `isEmailLinkError` instead of `isMagicLinkError` +- use `EmailLinkErrorCode` instead of `MagicLinkErrorCode` +- use `useEmailLink` instead of `useMagicLink` +- drop `orgs` jwt claim from session token +- use `ExternalAccount.imageUrl` instead of `ExternalAccount.avatarUrl` +- use `Organization.imageUrl` instead of `Organization.logoUrl` +- use `User.imageUrl` instead of `User.profileImageUrl` +- use `OrganizationMembershipPublicUserData.imageUrl` instead of `OrganizationMembershipPublicUserData.profileImageUrl` +- use `useOrganizationList` instead of `useOrganizations` +- use `userProfileProps` instead of `userProfile` in `Appearance` +- use `Clerk.setActive()` instead of `Clerk.setSession()` +- drop `password` param in `User.update()` +- use `afterSelectOrganizationUrl` instead of `afterSwitchOrganizationUrl` in `OrganizationSwitcher` +- drop `Clerk.experimental_canUseCaptcha` / `Clerk.Clerk.experimental_captchaSiteKey` / `Clerk.experimental_captchaURL` (were meant for internal use) +- use `User.getOrganizationMemberships()` instead of `Clerk.getOrganizationMemberships()` +- drop `lastOrganizationInvitation` / `lastOrganizationMember` from Clerk emitted events +- drop `Clerk.__unstable__invitationUpdate` / `Clerk.__unstable__membershipUpdate` +- drop support for string param in `Organization.create()` +- use `Organization.getInvitations()` instead of `Organization.getPendingInvitations()` +- use `pageSize` instead of `limit` in `OrganizationMembership.retrieve()` +- use `initialPage` instead of `offset` in `OrganizationMembership.retrieve()` +- drop `lastOrganizationInvitation` / `lastOrganizationMember` from ClerkProvider +- use `invitations` instead of `invitationList` in `useOrganization` +- use `memberships` instead of `membershipList` in `useOrganization` +- use `redirectUrl` instead of `redirect_url` in `User.createExternalAccount()` +- use `signature` instead of `generatedSignature` in `Signup.attemptWeb3WalletVerification()` diff --git a/.vscode/settings.json b/.vscode/settings.json index ca332e07ee..87589341d8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,24 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true, }, - "eslint.workingDirectories": [{ "mode": "auto" }], + "eslint.workingDirectories": [ + { + "mode": "auto" + } + ], + "cSpell.words": [ + "accountsstage", + "adduser", + "arethetypeswrong", + "attw", + "BAPI", + "citty", + "execa", + "FAPI", + "jwks", + "lclclerk", + "lclstage", + "nextjs", + "publint" + ], } diff --git a/packages/chrome-extension/src/__snapshots__/exports.test.ts.snap b/packages/chrome-extension/src/__snapshots__/exports.test.ts.snap index 5a4bbc8806..5850b5cf88 100644 --- a/packages/chrome-extension/src/__snapshots__/exports.test.ts.snap +++ b/packages/chrome-extension/src/__snapshots__/exports.test.ts.snap @@ -41,7 +41,6 @@ exports[`public exports should not include a breaking change 1`] = ` "useEmailLink", "useOrganization", "useOrganizationList", - "useOrganizations", "useSession", "useSessionList", "useSignIn", diff --git a/packages/clerk-js/README.md b/packages/clerk-js/README.md index 8bdf9b8a95..d0a3a3d6bb 100644 --- a/packages/clerk-js/README.md +++ b/packages/clerk-js/README.md @@ -44,13 +44,13 @@ There are two ways you can include ClerkJS in your project. You can either [impo npm install @clerk/clerk-js ``` -Once you have installed the package, you will need to import the ClerkJS object constructor into your code and pass it your [Frontend API](https://dashboard.clerk.com/last-active?path=api-keys) as a parameter. +Once you have installed the package, you will need to import the ClerkJS object constructor into your code and pass it your [Publishable Key](https://dashboard.clerk.com/last-active?path=api-keys) as a parameter. ```js import Clerk from '@clerk/clerk-js'; -const clerkFrontendApi = 'pk_[publishable_key]'; -const clerk = new Clerk(clerkFrontendApi); +const clerkPublishableKey = 'pk_[publishable_key]'; +const clerk = new Clerk(clerkPublishableKey); await clerk.load({ // Set load options here... }); @@ -65,14 +65,13 @@ Add the following script to your site's `` element: ```html