From a6f96f1d8d8d28a4d44742c368f8a1144fbada5b Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 8 Jul 2024 09:03:45 +0800 Subject: [PATCH] refactor(core, experience): remove `no_cache` param --- packages/core/src/oidc/utils.test.ts | 8 ++++---- packages/core/src/oidc/utils.ts | 5 ----- packages/experience/src/apis/settings.ts | 2 -- packages/experience/src/index.html | 3 +-- .../experience/src/utils/search-parameters.ts | 20 +++++++++---------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/packages/core/src/oidc/utils.test.ts b/packages/core/src/oidc/utils.test.ts index af26a4a00..7632bd6f2 100644 --- a/packages/core/src/oidc/utils.test.ts +++ b/packages/core/src/oidc/utils.test.ts @@ -134,14 +134,14 @@ describe('buildLoginPromptUrl', () => { it('should return the correct url for empty parameters', () => { expect(buildLoginPromptUrl({})).toBe('sign-in'); expect(buildLoginPromptUrl({}, 'foo')).toBe('sign-in'); - expect(buildLoginPromptUrl({}, demoAppApplicationId)).toBe('sign-in?no_cache='); + expect(buildLoginPromptUrl({}, demoAppApplicationId)).toBe('sign-in'); }); it('should return the correct url for firstScreen', () => { expect(buildLoginPromptUrl({ first_screen: FirstScreen.Register })).toBe('register'); expect(buildLoginPromptUrl({ first_screen: FirstScreen.Register }, 'foo')).toBe('register'); expect(buildLoginPromptUrl({ first_screen: FirstScreen.SignIn }, demoAppApplicationId)).toBe( - 'sign-in?no_cache=' + 'sign-in' ); // Legacy interactionMode support expect(buildLoginPromptUrl({ interaction_mode: InteractionMode.SignUp })).toBe('register'); @@ -155,7 +155,7 @@ describe('buildLoginPromptUrl', () => { 'direct/method/target?fallback=sign-in' ); expect(buildLoginPromptUrl({ direct_sign_in: 'method:target' }, demoAppApplicationId)).toBe( - 'direct/method/target?no_cache=&fallback=sign-in' + 'direct/method/target?fallback=sign-in' ); expect(buildLoginPromptUrl({ direct_sign_in: 'method' })).toBe( 'direct/method?fallback=sign-in' @@ -172,6 +172,6 @@ describe('buildLoginPromptUrl', () => { { first_screen: FirstScreen.Register, direct_sign_in: 'method:target' }, demoAppApplicationId ) - ).toBe('direct/method/target?no_cache=&fallback=register'); + ).toBe('direct/method/target?fallback=register'); }); }); diff --git a/packages/core/src/oidc/utils.ts b/packages/core/src/oidc/utils.ts index 45e07dbba..468c3483f 100644 --- a/packages/core/src/oidc/utils.ts +++ b/packages/core/src/oidc/utils.ts @@ -6,7 +6,6 @@ import { customClientMetadataGuard, GrantType, ExtraParamsKey, - demoAppApplicationId, FirstScreen, experience, } from '@logto/schemas'; @@ -91,10 +90,6 @@ export const buildLoginPromptUrl = (params: ExtraParamsObject, appId?: unknown): const searchParams = new URLSearchParams(); const getSearchParamString = () => (searchParams.size > 0 ? `?${searchParams.toString()}` : ''); - if (appId === demoAppApplicationId) { - searchParams.append('no_cache', ''); - } - if (directSignIn) { searchParams.append('fallback', firstScreen); const [method, target] = directSignIn.split(':'); diff --git a/packages/experience/src/apis/settings.ts b/packages/experience/src/apis/settings.ts index cfa001644..1ca7db41a 100644 --- a/packages/experience/src/apis/settings.ts +++ b/packages/experience/src/apis/settings.ts @@ -22,7 +22,6 @@ export const getSignInExperience = async (): return ky .get('/api/.well-known/sign-in-exp', { searchParams: buildSearchParameters({ - [searchKeys.noCache]: sessionStorage.getItem(searchKeys.noCache), [searchKeys.organizationId]: sessionStorage.getItem(searchKeys.organizationId), }), }) @@ -50,7 +49,6 @@ export const getPhrases = async ({ }) .get('/api/.well-known/phrases', { searchParams: buildSearchParameters({ - [searchKeys.noCache]: sessionStorage.getItem(searchKeys.noCache), lng: language, }), }); diff --git a/packages/experience/src/index.html b/packages/experience/src/index.html index 7cdd85d13..7909bc311 100644 --- a/packages/experience/src/index.html +++ b/packages/experience/src/index.html @@ -8,7 +8,6 @@