From 3373588fe778bfd4c343005417a2da8ec06cc3f3 Mon Sep 17 00:00:00 2001 From: martgil Date: Fri, 18 Aug 2023 17:42:13 +0800 Subject: [PATCH 01/11] add custom authentication config to local store --- extension/js/common/api/account-servers/external-service.ts | 3 +++ extension/js/common/authentication-configuration.ts | 5 +++++ extension/js/common/domain-configuration.ts | 6 ++++++ extension/js/common/platform/store/acct-store.ts | 2 ++ test/source/mock/fes/customer-url-fes-endpoints.ts | 6 ++++++ 5 files changed, 22 insertions(+) create mode 100644 extension/js/common/authentication-configuration.ts create mode 100644 extension/js/common/domain-configuration.ts diff --git a/extension/js/common/api/account-servers/external-service.ts b/extension/js/common/api/account-servers/external-service.ts index 202237f340d..a763ee4a816 100644 --- a/extension/js/common/api/account-servers/external-service.ts +++ b/extension/js/common/api/account-servers/external-service.ts @@ -13,6 +13,7 @@ import { Buf } from '../../core/buf.js'; import { ClientConfigurationError, ClientConfigurationJson } from '../../client-configuration.js'; import { InMemoryStore } from '../../platform/store/in-memory-store.js'; import { GoogleOAuth } from '../authentication/google/google-oauth.js'; +import { AuthenticationConfiguration } from '../../authentication-configuration.js'; // todo - decide which tags to use type EventTag = 'compose' | 'decrypt' | 'setup' | 'settings' | 'import-pub' | 'import-prv'; @@ -88,6 +89,8 @@ export class ExternalService extends Api { }; public fetchAndSaveClientConfiguration = async (): Promise => { + const auth = await this.request('GET', `/api/v1/client-configuration/authentication?domain=${this.domain}`); + await AcctStore.set(this.acctEmail, { authentication: auth }); const r = await this.request('GET', `/api/${this.apiVersion}/client-configuration?domain=${this.domain}`); if (r.clientConfiguration && !r.clientConfiguration.flags) { throw new ClientConfigurationError('missing_flags'); diff --git a/extension/js/common/authentication-configuration.ts b/extension/js/common/authentication-configuration.ts new file mode 100644 index 00000000000..68efad2bfce --- /dev/null +++ b/extension/js/common/authentication-configuration.ts @@ -0,0 +1,5 @@ +/* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com */ + +export type AuthenticationConfiguration = { + oauth: { clientId: string; clientSecret: string | undefined; redirectUrl: string; authCodeUrl: string; tokensUrl: string }; +}; diff --git a/extension/js/common/domain-configuration.ts b/extension/js/common/domain-configuration.ts new file mode 100644 index 00000000000..068024cf467 --- /dev/null +++ b/extension/js/common/domain-configuration.ts @@ -0,0 +1,6 @@ +/* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com */ + +import { AuthenticationConfiguration } from './authentication-configuration'; +import { ClientConfigurationJson } from './client-configuration'; + +export type DomainConfiguration = { authentication: AuthenticationConfiguration; clientConfigurationJson: ClientConfigurationJson }; diff --git a/extension/js/common/platform/store/acct-store.ts b/extension/js/common/platform/store/acct-store.ts index 3ff000f6e40..9471c48af56 100644 --- a/extension/js/common/platform/store/acct-store.ts +++ b/extension/js/common/platform/store/acct-store.ts @@ -2,6 +2,7 @@ import { GoogleOAuth } from '../../api/authentication/google/google-oauth.js'; import { ApiErr } from '../../api/shared/api-error.js'; +import { AuthenticationConfiguration } from '../../authentication-configuration.js'; import { BrowserMsg } from '../../browser/browser-msg.js'; import { storageLocalGet, storageLocalRemove, storageLocalSet } from '../../browser/chrome.js'; import { ClientConfigurationJson } from '../../client-configuration.js'; @@ -75,6 +76,7 @@ export type AcctStoreDict = { fesUrl?: string; // url where FlowCrypt External Service is deployed failedPassphraseAttempts?: number; lastUnsuccessfulPassphraseAttempt?: number; + authentication?: AuthenticationConfiguration; }; /* eslint-enable @typescript-eslint/naming-convention */ diff --git a/test/source/mock/fes/customer-url-fes-endpoints.ts b/test/source/mock/fes/customer-url-fes-endpoints.ts index bea1653490c..b9459fb8b04 100644 --- a/test/source/mock/fes/customer-url-fes-endpoints.ts +++ b/test/source/mock/fes/customer-url-fes-endpoints.ts @@ -46,6 +46,12 @@ export const getMockCustomerUrlFesEndpoints = (config: FesConfig | undefined): H } throw new HttpClientErr(`Unexpected FES domain "${req.headers.host}" and url "${req.url}"`); }, + '/api/v1/client-configuration/authentication': async ({}, req) => { + if (req.method !== 'GET') { + throw new HttpClientErr('Unsupported method'); + } + return {}; + }, '/api/v1/message/new-reply-token': async ({}, req) => { if (req.headers.host === standardFesUrl(parsePort(req)) && req.method === 'POST') { authenticate(req, 'oidc'); From 50088e27c266e152e74ab3368141a5ea63826dd8 Mon Sep 17 00:00:00 2001 From: martgil Date: Sat, 19 Aug 2023 12:22:49 +0800 Subject: [PATCH 02/11] prepare mock endpoint for test --- .../mock/fes/customer-url-fes-endpoints.ts | 5 +++++ .../mock/fes/shared-tenant-fes-endpoints.ts | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/test/source/mock/fes/customer-url-fes-endpoints.ts b/test/source/mock/fes/customer-url-fes-endpoints.ts index b9459fb8b04..bf728ba7efa 100644 --- a/test/source/mock/fes/customer-url-fes-endpoints.ts +++ b/test/source/mock/fes/customer-url-fes-endpoints.ts @@ -50,6 +50,11 @@ export const getMockCustomerUrlFesEndpoints = (config: FesConfig | undefined): H if (req.method !== 'GET') { throw new HttpClientErr('Unsupported method'); } + if (config?.authenticationConfiguration) { + return { + oauth: config.authenticationConfiguration, + }; + } return {}; }, '/api/v1/message/new-reply-token': async ({}, req) => { diff --git a/test/source/mock/fes/shared-tenant-fes-endpoints.ts b/test/source/mock/fes/shared-tenant-fes-endpoints.ts index e3e70e6eeed..dd6b68c5d91 100644 --- a/test/source/mock/fes/shared-tenant-fes-endpoints.ts +++ b/test/source/mock/fes/shared-tenant-fes-endpoints.ts @@ -52,6 +52,14 @@ export type FesClientConfiguration = { }; /* eslint-enable @typescript-eslint/naming-convention */ +export type FesAuthenticationConfiguration = { + clientId: string; + clientSecret: string; + redirectUrl: string; + authCodeUrl: string; + tokensUrl: string; +}; + export interface FesMessageReturnType { url: string; externalId: string; @@ -61,6 +69,7 @@ export interface FesConfig { returnError?: HttpClientErr; apiEndpointReturnError?: HttpClientErr; clientConfiguration?: FesClientConfiguration; + authenticationConfiguration?: FesAuthenticationConfiguration; messagePostValidator?: (body: string, fesUrl: string) => Promise; } @@ -102,6 +111,17 @@ export const getMockSharedTenantFesEndpoints = (config: FesConfig | undefined): }, }; }, + '/shared-tenant-fes/api/v1/client-configuration/authentication': async ({}, req) => { + if (req.method !== 'GET') { + throw new HttpClientErr('Unsupported method'); + } + if (config?.authenticationConfiguration) { + return { + oauth: config.authenticationConfiguration, + }; + } + return {}; + }, '/shared-tenant-fes/api/v1/log-collector/exception': async ({ body }) => { reportedErrors.push(body as ReportedError); return { saved: true }; From abee44ec1d3492ece280608bd9b594e56de29fb4 Mon Sep 17 00:00:00 2001 From: martgil Date: Sat, 19 Aug 2023 13:38:17 +0800 Subject: [PATCH 03/11] add test --- .../chrome/settings/modules/debug_api.ts | 1 + .../common/platform/store/abstract-store.ts | 3 +- .../js/common/platform/store/acct-store.ts | 3 +- test/source/tests/setup.ts | 32 ++++++++++++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/extension/chrome/settings/modules/debug_api.ts b/extension/chrome/settings/modules/debug_api.ts index d5d132d3c57..9a12602a7b6 100644 --- a/extension/chrome/settings/modules/debug_api.ts +++ b/extension/chrome/settings/modules/debug_api.ts @@ -35,6 +35,7 @@ View.run( Xss.sanitizeAppend('#content', `Unsupported which: ${Xss.escape(this.which)} (not implemented)`); } else if (this.which === 'local_store') { const storage = await AcctStore.get(this.acctEmail, [ + 'authentication', 'notification_setup_needed_dismissed', 'email_provider', 'hide_message_password', diff --git a/extension/js/common/platform/store/abstract-store.ts b/extension/js/common/platform/store/abstract-store.ts index 1f7f1d8e1b5..5422e25231d 100644 --- a/extension/js/common/platform/store/abstract-store.ts +++ b/extension/js/common/platform/store/abstract-store.ts @@ -8,11 +8,12 @@ import { ClientConfigurationJson } from '../../client-configuration.js'; import { GmailRes } from '../../api/email-provider/gmail/gmail-parser.js'; import { AcctStoreDict, AccountIndex } from './acct-store.js'; import { UnreportableError, Catch } from '../catch.js'; +import { AuthenticationConfiguration } from '../../authentication-configuration.js'; type SerializableTypes = FlatTypes | string[] | number[] | boolean[] | ClientConfigurationJson; export type StorageType = 'session' | 'local'; export type FlatTypes = null | undefined | number | string | boolean; -type Storable = FlatTypes | string[] | StoredKeyInfo[] | KeyInfoWithIdentity[] | GmailRes.OpenId | ClientConfigurationJson; +type Storable = FlatTypes | string[] | StoredKeyInfo[] | KeyInfoWithIdentity[] | GmailRes.OpenId | ClientConfigurationJson | AuthenticationConfiguration; export type Serializable = SerializableTypes | SerializableTypes[] | Dict | Dict[]; export interface RawStore { diff --git a/extension/js/common/platform/store/acct-store.ts b/extension/js/common/platform/store/acct-store.ts index 9471c48af56..052e285eb7a 100644 --- a/extension/js/common/platform/store/acct-store.ts +++ b/extension/js/common/platform/store/acct-store.ts @@ -45,7 +45,8 @@ export type AccountIndex = | 'rules' | 'fesUrl' | 'failedPassphraseAttempts' - | 'lastUnsuccessfulPassphraseAttempt'; + | 'lastUnsuccessfulPassphraseAttempt' + | 'authentication'; export type SendAsAlias = { isPrimary: boolean; diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index 0d62d7f2e9f..ee146b4a006 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -30,7 +30,7 @@ import { import { testSksKey } from '../mock/sks/sks-constants'; import { flowcryptCompatibilityAliasList, multipleEmailAliasList } from '../mock/google/google-endpoints'; import { standardSubDomainFesClientConfiguration } from '../mock/fes/customer-url-fes-endpoints'; -import { FesClientConfiguration } from '../mock/fes/shared-tenant-fes-endpoints'; +import { FesAuthenticationConfiguration, FesClientConfiguration } from '../mock/fes/shared-tenant-fes-endpoints'; import { GoogleData } from '../mock/google/google-data'; import Parse from '../util/parse'; import { MsgUtil } from '../core/crypto/pgp/msg-util'; @@ -2482,6 +2482,36 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== } if (testVariant === 'CONSUMER-MOCK') { + test( + 'setup - check custom authentication config from the local store', + testWithBrowser(async (t, browser) => { + t.context.mockApi!.configProvider = new ConfigurationProvider({ + fes: { + authenticationConfiguration: { + redirectUrl: 'https://example.com/redirect', + clientId: 'your-client-id', + clientSecret: 'your-client-secret', + authCodeUrl: 'https://example.com/auth', + tokensUrl: 'https://example.com/tokens', + }, + }, + }); + const acctEmail = 'flowcrypt.compatibility@gmail.com'; + await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); + const settingsPage = await browser.newExtensionSettingsPage(t, acctEmail); + const debugFrame = await SettingsPageRecipe.awaitNewPageFrame(settingsPage, '@action-show-local-store-contents', ['debug_api.htm']); + await debugFrame.waitForContent('@container-pre', 'authentication'); + const key = `cryptup_${emailKeyIndex(acctEmail, 'authentication')}`; + const auth = (await settingsPage.getFromLocalStorage([key]))[key]; + const authenticationConfiguration = auth as FesAuthenticationConfiguration; + expect(authenticationConfiguration.clientId).to.be.not.empty; + expect(authenticationConfiguration.clientSecret).to.be.not.empty; + expect(authenticationConfiguration.redirectUrl).to.be.not.empty; + expect(authenticationConfiguration.authCodeUrl).to.be.not.empty; + expect(authenticationConfiguration.tokensUrl).to.be.not.empty; + }) + ); + test( 'setup - imported key with multiple alias should show checkbox per alias', testWithBrowser(async (t, browser) => { From bccee7c4a96ebb97617ee49277533e21d64b4f32 Mon Sep 17 00:00:00 2001 From: martgil Date: Mon, 21 Aug 2023 15:10:10 +0800 Subject: [PATCH 04/11] fix test --- .../mock/fes/customer-url-fes-endpoints.ts | 4 +--- .../mock/fes/shared-tenant-fes-endpoints.ts | 16 ++++++------- test/source/tests/setup.ts | 24 ++++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/test/source/mock/fes/customer-url-fes-endpoints.ts b/test/source/mock/fes/customer-url-fes-endpoints.ts index bf728ba7efa..a742637a516 100644 --- a/test/source/mock/fes/customer-url-fes-endpoints.ts +++ b/test/source/mock/fes/customer-url-fes-endpoints.ts @@ -51,9 +51,7 @@ export const getMockCustomerUrlFesEndpoints = (config: FesConfig | undefined): H throw new HttpClientErr('Unsupported method'); } if (config?.authenticationConfiguration) { - return { - oauth: config.authenticationConfiguration, - }; + return config.authenticationConfiguration; } return {}; }, diff --git a/test/source/mock/fes/shared-tenant-fes-endpoints.ts b/test/source/mock/fes/shared-tenant-fes-endpoints.ts index dd6b68c5d91..e0726f6ce31 100644 --- a/test/source/mock/fes/shared-tenant-fes-endpoints.ts +++ b/test/source/mock/fes/shared-tenant-fes-endpoints.ts @@ -53,11 +53,13 @@ export type FesClientConfiguration = { /* eslint-enable @typescript-eslint/naming-convention */ export type FesAuthenticationConfiguration = { - clientId: string; - clientSecret: string; - redirectUrl: string; - authCodeUrl: string; - tokensUrl: string; + oauth: { + clientId: string; + clientSecret: string; + redirectUrl: string; + authCodeUrl: string; + tokensUrl: string; + }; }; export interface FesMessageReturnType { @@ -116,9 +118,7 @@ export const getMockSharedTenantFesEndpoints = (config: FesConfig | undefined): throw new HttpClientErr('Unsupported method'); } if (config?.authenticationConfiguration) { - return { - oauth: config.authenticationConfiguration, - }; + return config.authenticationConfiguration; } return {}; }, diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index ee146b4a006..2f20eae8465 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -2488,11 +2488,13 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== t.context.mockApi!.configProvider = new ConfigurationProvider({ fes: { authenticationConfiguration: { - redirectUrl: 'https://example.com/redirect', - clientId: 'your-client-id', - clientSecret: 'your-client-secret', - authCodeUrl: 'https://example.com/auth', - tokensUrl: 'https://example.com/tokens', + oauth: { + redirectUrl: 'https://example.com/redirect', + clientId: 'your-client-id', + clientSecret: 'your-client-secret', + authCodeUrl: 'https://example.com/auth', + tokensUrl: 'https://example.com/tokens', + }, }, }, }); @@ -2503,12 +2505,12 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== await debugFrame.waitForContent('@container-pre', 'authentication'); const key = `cryptup_${emailKeyIndex(acctEmail, 'authentication')}`; const auth = (await settingsPage.getFromLocalStorage([key]))[key]; - const authenticationConfiguration = auth as FesAuthenticationConfiguration; - expect(authenticationConfiguration.clientId).to.be.not.empty; - expect(authenticationConfiguration.clientSecret).to.be.not.empty; - expect(authenticationConfiguration.redirectUrl).to.be.not.empty; - expect(authenticationConfiguration.authCodeUrl).to.be.not.empty; - expect(authenticationConfiguration.tokensUrl).to.be.not.empty; + const { oauth } = auth as FesAuthenticationConfiguration; + expect(oauth.clientId).to.be.not.empty; + expect(oauth.clientSecret).to.be.not.empty; + expect(oauth.redirectUrl).to.be.not.empty; + expect(oauth.authCodeUrl).to.be.not.empty; + expect(oauth.tokensUrl).to.be.not.empty; }) ); From 11fd660dd4431d01861e74081bfc844b5bd8ab67 Mon Sep 17 00:00:00 2001 From: martgil Date: Mon, 21 Aug 2023 15:54:44 +0800 Subject: [PATCH 05/11] add test --- test/source/tests/setup.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index 2f20eae8465..ecc9e662536 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -2479,11 +2479,9 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== ); }) ); - } - if (testVariant === 'CONSUMER-MOCK') { test( - 'setup - check custom authentication config from the local store', + 'setup - check custom authentication config from the local store (customer url fes)', testWithBrowser(async (t, browser) => { t.context.mockApi!.configProvider = new ConfigurationProvider({ fes: { @@ -2498,8 +2496,8 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== }, }, }); - const acctEmail = 'flowcrypt.compatibility@gmail.com'; - await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); + const acctEmail = 'user@authentication-config-test.flowcrypt.test'; + await BrowserRecipe.openSettingsLoginApprove(t, browser, acctEmail); const settingsPage = await browser.newExtensionSettingsPage(t, acctEmail); const debugFrame = await SettingsPageRecipe.awaitNewPageFrame(settingsPage, '@action-show-local-store-contents', ['debug_api.htm']); await debugFrame.waitForContent('@container-pre', 'authentication'); @@ -2513,6 +2511,24 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== expect(oauth.tokensUrl).to.be.not.empty; }) ); + } + + if (testVariant === 'CONSUMER-MOCK') { + test( + 'setup - check custom authentication config from the local store (shared tenant fes)', + testWithBrowser(async (t, browser) => { + const acctEmail = 'flowcrypt.compatibility@gmail.com'; + await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); + const settingsPage = await browser.newExtensionSettingsPage(t, acctEmail); + const debugFrame = await SettingsPageRecipe.awaitNewPageFrame(settingsPage, '@action-show-local-store-contents', ['debug_api.htm']); + await debugFrame.waitForContent('@container-pre', 'authentication'); + const key = `cryptup_${emailKeyIndex(acctEmail, 'authentication')}`; + const auth = (await settingsPage.getFromLocalStorage([key]))[key]; + const authenticationConfiguration = auth as FesAuthenticationConfiguration; + console.log(authenticationConfiguration); + // expect(oauth). + }) + ); test( 'setup - imported key with multiple alias should show checkbox per alias', From 97cf6288a3f69215616987565d2105613aff7ace Mon Sep 17 00:00:00 2001 From: martgil Date: Mon, 21 Aug 2023 16:39:15 +0800 Subject: [PATCH 06/11] use the apiVersion variable --- extension/js/common/api/account-servers/external-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/js/common/api/account-servers/external-service.ts b/extension/js/common/api/account-servers/external-service.ts index a763ee4a816..5fd3df9383f 100644 --- a/extension/js/common/api/account-servers/external-service.ts +++ b/extension/js/common/api/account-servers/external-service.ts @@ -89,7 +89,7 @@ export class ExternalService extends Api { }; public fetchAndSaveClientConfiguration = async (): Promise => { - const auth = await this.request('GET', `/api/v1/client-configuration/authentication?domain=${this.domain}`); + const auth = await this.request('GET', `/api/${this.apiVersion}/client-configuration/authentication?domain=${this.domain}`); await AcctStore.set(this.acctEmail, { authentication: auth }); const r = await this.request('GET', `/api/${this.apiVersion}/client-configuration?domain=${this.domain}`); if (r.clientConfiguration && !r.clientConfiguration.flags) { From 556f257d5657a2eaa3db64e8e145a4340787e4e0 Mon Sep 17 00:00:00 2001 From: martgil Date: Tue, 22 Aug 2023 10:33:42 +0800 Subject: [PATCH 07/11] update test --- test/source/tests/setup.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index ecc9e662536..9bacb5e4710 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -2525,8 +2525,7 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== const key = `cryptup_${emailKeyIndex(acctEmail, 'authentication')}`; const auth = (await settingsPage.getFromLocalStorage([key]))[key]; const authenticationConfiguration = auth as FesAuthenticationConfiguration; - console.log(authenticationConfiguration); - // expect(oauth). + expect(authenticationConfiguration).to.be.empty; }) ); From 20c81ef9d773c5c9b434621865e65d09aadf3a6b Mon Sep 17 00:00:00 2001 From: martgil Date: Tue, 22 Aug 2023 10:40:15 +0800 Subject: [PATCH 08/11] update AuthenticationConfiguration type --- extension/js/common/authentication-configuration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/js/common/authentication-configuration.ts b/extension/js/common/authentication-configuration.ts index 68efad2bfce..4918c8cda7b 100644 --- a/extension/js/common/authentication-configuration.ts +++ b/extension/js/common/authentication-configuration.ts @@ -1,5 +1,5 @@ /* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com */ export type AuthenticationConfiguration = { - oauth: { clientId: string; clientSecret: string | undefined; redirectUrl: string; authCodeUrl: string; tokensUrl: string }; + oauth: { clientId: string; clientSecret: string; redirectUrl: string; authCodeUrl: string; tokensUrl: string }; }; From 979d1caa3ad7fa656e7768a3d2b610f9a4ccc1c1 Mon Sep 17 00:00:00 2001 From: martgil Date: Tue, 22 Aug 2023 10:49:53 +0800 Subject: [PATCH 09/11] update AuthenticationConfiguration type --- extension/js/common/authentication-configuration.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extension/js/common/authentication-configuration.ts b/extension/js/common/authentication-configuration.ts index 4918c8cda7b..fb7b0a0dc05 100644 --- a/extension/js/common/authentication-configuration.ts +++ b/extension/js/common/authentication-configuration.ts @@ -1,5 +1,11 @@ /* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com */ export type AuthenticationConfiguration = { - oauth: { clientId: string; clientSecret: string; redirectUrl: string; authCodeUrl: string; tokensUrl: string }; + oauth: { + clientId: string; + clientSecret: string; + redirectUrl: string; + authCodeUrl: string; + tokensUrl: string; + }; }; From b8fe12cd1ec10615aeba362bd020edadbca735cf Mon Sep 17 00:00:00 2001 From: martgil Date: Tue, 22 Aug 2023 18:41:57 +0800 Subject: [PATCH 10/11] improve authenticationConfiguration value checking --- test/source/tests/setup.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index 476b06e9ff2..6cbde4bdc01 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -2483,16 +2483,17 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== test( 'setup - check custom authentication config from the local store (customer url fes)', testWithBrowser(async (t, browser) => { + const oauthConfig = { + clientId: 'your-client-id', + clientSecret: 'your-client-secret', + redirectUrl: 'https://example.com/redirect', + authCodeUrl: 'https://example.com/auth', + tokensUrl: 'https://example.com/tokens', + }; t.context.mockApi!.configProvider = new ConfigurationProvider({ fes: { authenticationConfiguration: { - oauth: { - redirectUrl: 'https://example.com/redirect', - clientId: 'your-client-id', - clientSecret: 'your-client-secret', - authCodeUrl: 'https://example.com/auth', - tokensUrl: 'https://example.com/tokens', - }, + oauth: oauthConfig, }, }, }); @@ -2504,11 +2505,7 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== const key = `cryptup_${emailKeyIndex(acctEmail, 'authentication')}`; const auth = (await settingsPage.getFromLocalStorage([key]))[key]; const { oauth } = auth as FesAuthenticationConfiguration; - expect(oauth.clientId).to.be.not.empty; - expect(oauth.clientSecret).to.be.not.empty; - expect(oauth.redirectUrl).to.be.not.empty; - expect(oauth.authCodeUrl).to.be.not.empty; - expect(oauth.tokensUrl).to.be.not.empty; + expect(oauth).to.equal(oauthConfig); }) ); } From 2db675e63bc7fa0dc92bff14bdb196ef87f6f26b Mon Sep 17 00:00:00 2001 From: martgil Date: Wed, 23 Aug 2023 14:19:50 +0800 Subject: [PATCH 11/11] update ava object checking --- test/source/tests/setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index 6cbde4bdc01..1d2b3e4fe70 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -2505,7 +2505,7 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== const key = `cryptup_${emailKeyIndex(acctEmail, 'authentication')}`; const auth = (await settingsPage.getFromLocalStorage([key]))[key]; const { oauth } = auth as FesAuthenticationConfiguration; - expect(oauth).to.equal(oauthConfig); + expect(oauth).to.deep.equal(oauthConfig); }) ); }