Skip to content

Commit

Permalink
chore(clerk-js,backend): Remove deprecated __clerk_referrer_primary (
Browse files Browse the repository at this point in the history
…#1755)

* chore(clerk-js,backend): Remove deprecated internal `__clerk_referrer_primary`

This is safe to remove, as the code that was adding this query param has been removed for at least 4 releases

* chore(clerk-js): Add changeset
  • Loading branch information
panteliselef committed Sep 21, 2023
1 parent a2c7115 commit 378a903
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 49 deletions.
6 changes: 6 additions & 0 deletions .changeset/little-grapes-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': patch
'@clerk/backend': patch
---

Removing the `__clerk_referrer_primary` that was marked as deprecated. It was introduced to support the multi-domain featured, but was replaced shortly after.
18 changes: 0 additions & 18 deletions packages/backend/src/tokens/interstitialRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ type InterstitialRule = <T extends AuthenticateRequestOptions>(

const shouldRedirectToSatelliteUrl = (qp?: URLSearchParams) => !!qp?.get('__clerk_satellite_url');
const hasJustSynced = (qp?: URLSearchParams) => qp?.get('__clerk_synced') === 'true';
/**
* @deprecated This will be removed in the next minor version
*/
const isReturningFromPrimary = (qp?: URLSearchParams) => qp?.get('__clerk_referrer_primary') === 'true';

const VALID_USER_AGENTS = /^Mozilla\/|(Amazon CloudFront)/;

Expand Down Expand Up @@ -90,20 +86,6 @@ export const potentialRequestAfterSignInOrOutFromClerkHostedUiInDev: Interstitia
return undefined;
};

/**
* @deprecated This will be removed in the next minor version
*/
export const satelliteInDevReturningFromPrimary: InterstitialRule = options => {
const { apiKey, secretKey, isSatellite, searchParams } = options;

const key = secretKey || apiKey || '';

if (isSatellite && isReturningFromPrimary(searchParams) && isDevelopmentFromApiKey(key)) {
return interstitial(options, AuthErrorReason.SatelliteReturnsFromPrimary);
}
return undefined;
};

export const potentialFirstRequestOnProductionEnvironment: InterstitialRule = options => {
const { apiKey, secretKey, clientUat, cookieToken } = options;
const key = secretKey || apiKey || '';
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/tokens/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
potentialFirstRequestOnProductionEnvironment,
potentialRequestAfterSignInOrOutFromClerkHostedUiInDev,
runInterstitialRules,
satelliteInDevReturningFromPrimary,
} from './interstitialRule';
import type { VerifyTokenOptions } from './verify';

Expand Down Expand Up @@ -161,7 +160,6 @@ export async function authenticateRequest(options: AuthenticateRequestOptions):
crossOriginRequestWithoutHeader,
nonBrowserRequestInDevRule,
isSatelliteAndNeedsSyncing,
satelliteInDevReturningFromPrimary,
isPrimaryInDevAndRedirectsToSatellite,
potentialFirstRequestOnProductionEnvironment,
potentialFirstLoadInDevWhenUATMissing,
Expand Down
23 changes: 1 addition & 22 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import {
noUserExists,
pickRedirectionProp,
removeClerkQueryParam,
replaceClerkQueryParam,
requiresUserInput,
sessionExistsAndSingleSessionModeEnabled,
setDevBrowserJWTInURL,
Expand All @@ -85,7 +84,7 @@ import {
windowNavigate,
} from '../utils';
import { memoizeListenerCallback } from '../utils/memoizeStateListenerCallback';
import { CLERK_REFERRER_PRIMARY, CLERK_SATELLITE_URL, CLERK_SYNCED, ERROR_CODES } from './constants';
import { CLERK_SATELLITE_URL, CLERK_SYNCED, ERROR_CODES } from './constants';
import type { DevBrowserHandler } from './devBrowserHandler';
import createDevBrowserHandler from './devBrowserHandler';
import {
Expand Down Expand Up @@ -1141,20 +1140,6 @@ export default class Clerk implements ClerkInterface {

#hasJustSynced = () => getClerkQueryParam(CLERK_SYNCED) === 'true';
#clearJustSynced = () => removeClerkQueryParam(CLERK_SYNCED);
/**
* @deprecated This will be removed in the next minor version
*/
#isReturningFromPrimary = () => getClerkQueryParam(CLERK_REFERRER_PRIMARY) === 'true';
/**
* @deprecated This will be removed in the next minor version
*/
#replacePrimaryReferrerWithClerkSynced = () => {
if (this.#options.isInterstitial) {
replaceClerkQueryParam(CLERK_REFERRER_PRIMARY, CLERK_SYNCED, 'true');
} else {
removeClerkQueryParam(CLERK_REFERRER_PRIMARY);
}
};

#buildSyncUrlForDevelopmentInstances = (): string => {
const searchParams = new URLSearchParams({
Expand All @@ -1179,12 +1164,6 @@ export default class Clerk implements ClerkInterface {
};

#shouldSyncWithPrimary = (): boolean => {
// TODO: Remove this in the minor release
if (this.#isReturningFromPrimary()) {
this.#replacePrimaryReferrerWithClerkSynced();
return false;
}

if (this.#hasJustSynced()) {
if (!this.#options.isInterstitial) {
this.#clearJustSynced();
Expand Down
4 changes: 0 additions & 4 deletions packages/clerk-js/src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ export const DEV_BROWSER_SSO_JWT_PARAMETER = '__dev_session';
export const DEV_BROWSER_SSO_JWT_HTTP_HEADER = 'Clerk-Cookie';

export const CLERK_MODAL_STATE = '__clerk_modal_state';
/**
* @deprecated This will be removed in the next minor version
*/
export const CLERK_REFERRER_PRIMARY = '__clerk_referrer_primary';
export const CLERK_SYNCED = '__clerk_synced';
export const CLERK_SATELLITE_URL = '__clerk_satellite_url';
export const ERROR_CODES = {
Expand Down
4 changes: 1 addition & 3 deletions packages/clerk-js/src/utils/getClerkQueryParam.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CLERK_REFERRER_PRIMARY, CLERK_SATELLITE_URL, CLERK_SYNCED } from '../core/constants';
import { CLERK_SATELLITE_URL, CLERK_SYNCED } from '../core/constants';

const ClerkQueryParams = [
'__clerk_status',
Expand All @@ -8,7 +8,6 @@ const ClerkQueryParams = [
'__clerk_modal_state',
CLERK_SYNCED,
CLERK_SATELLITE_URL,
CLERK_REFERRER_PRIMARY,
] as const;

type ClerkQueryParam = (typeof ClerkQueryParams)[number];
Expand All @@ -21,7 +20,6 @@ type ClerkQueryParamsToValuesMap = {
__clerk_modal_state: string;
__clerk_synced: string;
__clerk_satellite_url: string;
__clerk_referrer_primary: string;
};

export type VerificationStatus = 'expired' | 'failed' | 'loading' | 'verified' | 'verified_switch_tab';
Expand Down

0 comments on commit 378a903

Please sign in to comment.