From dfbc1b539209dd67b8cbb3e3c9d4f45257fdc9ef Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Fri, 22 Sep 2023 16:05:18 +0300 Subject: [PATCH] chore(backend): Moved shared module to util/shared and drop unused --- .changeset/metal-lions-switch.md | 5 +++++ .changeset/silent-fishes-change.md | 5 +++++ packages/backend/src/redirections.ts | 2 +- packages/backend/src/tokens/interstitial.ts | 4 ++-- packages/backend/src/tokens/interstitialRule.ts | 2 +- packages/backend/src/tokens/keys.ts | 2 +- packages/backend/src/tokens/request.ts | 2 +- packages/backend/src/{shared/index.ts => util/shared.ts} | 3 --- 8 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .changeset/metal-lions-switch.md create mode 100644 .changeset/silent-fishes-change.md rename packages/backend/src/{shared/index.ts => util/shared.ts} (90%) diff --git a/.changeset/metal-lions-switch.md b/.changeset/metal-lions-switch.md new file mode 100644 index 00000000000..5cfd2b8fca3 --- /dev/null +++ b/.changeset/metal-lions-switch.md @@ -0,0 +1,5 @@ +--- +'@clerk/shared': minor +--- + +Introduce `getClerkJsMajorVersionOrTag()`, `getScriptUrl()`, `callWithRetry()` diff --git a/.changeset/silent-fishes-change.md b/.changeset/silent-fishes-change.md new file mode 100644 index 00000000000..ed10e1ea9b4 --- /dev/null +++ b/.changeset/silent-fishes-change.md @@ -0,0 +1,5 @@ +--- +'@clerk/backend': minor +--- + +Replace utilities with @clerk/shared exports diff --git a/packages/backend/src/redirections.ts b/packages/backend/src/redirections.ts index 485ef10ac71..76f96b7c12b 100644 --- a/packages/backend/src/redirections.ts +++ b/packages/backend/src/redirections.ts @@ -1,4 +1,4 @@ -import { errorThrower, parsePublishableKey } from './shared'; +import { errorThrower, parsePublishableKey } from './util/shared'; type RedirectAdapter = (url: string) => any; diff --git a/packages/backend/src/tokens/interstitial.ts b/packages/backend/src/tokens/interstitial.ts index 2d8a3e8709a..b5d434fbddb 100644 --- a/packages/backend/src/tokens/interstitial.ts +++ b/packages/backend/src/tokens/interstitial.ts @@ -4,6 +4,7 @@ import { API_VERSION, USER_AGENT } from '../constants'; // DO NOT CHANGE: Runtime needs to be imported as a default export so that we can stub its dependencies with Sinon.js // For more information refer to https://sinonjs.org/how-to/stub-dependency/ import runtime from '../runtime'; +import { joinPaths } from '../util/path'; import { addClerkPrefix, callWithRetry, @@ -11,8 +12,7 @@ import { getScriptUrl, isDevOrStagingUrl, parsePublishableKey, -} from '../shared'; -import { joinPaths } from '../util/path'; +} from '../util/shared'; import { TokenVerificationError, TokenVerificationErrorAction, TokenVerificationErrorReason } from './errors'; import type { DebugRequestSate } from './request'; diff --git a/packages/backend/src/tokens/interstitialRule.ts b/packages/backend/src/tokens/interstitialRule.ts index 9a8933dd307..19dd3795d26 100644 --- a/packages/backend/src/tokens/interstitialRule.ts +++ b/packages/backend/src/tokens/interstitialRule.ts @@ -1,5 +1,5 @@ -import { isDevelopmentFromApiKey, isProductionFromApiKey } from '../shared'; import { checkCrossOrigin } from '../util/request'; +import { isDevelopmentFromApiKey, isProductionFromApiKey } from '../util/shared'; import type { RequestState } from './authStatus'; import { AuthErrorReason, interstitial, signedIn, signedOut } from './authStatus'; import type { AuthenticateRequestOptions } from './request'; diff --git a/packages/backend/src/tokens/keys.ts b/packages/backend/src/tokens/keys.ts index f8826624913..be83ef518ca 100644 --- a/packages/backend/src/tokens/keys.ts +++ b/packages/backend/src/tokens/keys.ts @@ -2,9 +2,9 @@ import { API_URL, API_VERSION, MAX_CACHE_LAST_UPDATED_AT_SECONDS } from '../cons // DO NOT CHANGE: Runtime needs to be imported as a default export so that we can stub its dependencies with Sinon.js // For more information refer to https://sinonjs.org/how-to/stub-dependency/ import runtime from '../runtime'; -import { callWithRetry } from '../shared'; import { joinPaths } from '../util/path'; import { getErrorObjectByCode } from '../util/request'; +import { callWithRetry } from '../util/shared'; import { TokenVerificationError, TokenVerificationErrorAction, diff --git a/packages/backend/src/tokens/request.ts b/packages/backend/src/tokens/request.ts index 98ea9114ba6..991677b2700 100644 --- a/packages/backend/src/tokens/request.ts +++ b/packages/backend/src/tokens/request.ts @@ -1,7 +1,7 @@ import { API_URL, API_VERSION, constants } from '../constants'; -import { isDevelopmentFromApiKey, parsePublishableKey } from '../shared'; import { assertValidSecretKey } from '../util/assertValidSecretKey'; import { buildRequest, stripAuthorizationHeader } from '../util/IsomorphicRequest'; +import { isDevelopmentFromApiKey, parsePublishableKey } from '../util/shared'; import type { RequestState } from './authStatus'; import { AuthErrorReason, interstitial, signedOut, unknownState } from './authStatus'; import type { TokenCarrier } from './errors'; diff --git a/packages/backend/src/shared/index.ts b/packages/backend/src/util/shared.ts similarity index 90% rename from packages/backend/src/shared/index.ts rename to packages/backend/src/util/shared.ts index e45b44acb5c..0da270edba0 100644 --- a/packages/backend/src/shared/index.ts +++ b/packages/backend/src/util/shared.ts @@ -1,13 +1,10 @@ export { addClerkPrefix, - buildPublishableKey, callWithRetry, getClerkJsMajorVersionOrTag, getScriptUrl, isDevelopmentFromApiKey, isProductionFromApiKey, - isPublishableKey, - isStaging, parsePublishableKey, } from '@clerk/shared';