passbolt-browser-extension 5.17.0 → 5.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pre-commit-config.yaml +6 -2
- package/CHANGELOG.md +106 -1
- package/README.md +2 -2
- package/RELEASE_NOTES.md +3 -94
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/ViewController.swift +5 -5
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager.xcodeproj/project.pbxproj +10 -10
- package/eslint.config.mjs +3 -35
- package/jest.config.json +1 -2
- package/package.json +45 -54
- package/src/all/_locales/locales.test.js +2 -0
- package/src/all/background_page/controller/InformMenuController/InformMenuController.test.js +45 -1
- package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.js +1 -2
- package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.test.js +10 -8
- package/src/all/background_page/controller/accountRecovery/accountRecoveryValidatePublicKeyController.test.js +1 -1
- package/src/all/background_page/controller/auth/authLocalLogoutController.js +3 -14
- package/src/all/background_page/controller/auth/authLocalLogoutController.test.js +3 -3
- package/src/all/background_page/controller/auth/authLoginController.js +2 -2
- package/src/all/background_page/controller/auth/authOfflineLogoutController.js +4 -12
- package/src/all/background_page/controller/auth/authOfflineLogoutController.test.js +3 -3
- package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.js → findAndUpdateActiveSessionSessionStorageController.js} +6 -6
- package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.test.js → findAndUpdateActiveSessionSessionStorageController.test.js} +30 -30
- package/src/all/background_page/controller/auth/getOrFindActiveSessionController.test.js +22 -20
- package/src/all/background_page/controller/auth/isMfaRequiredController.js +5 -4
- package/src/all/background_page/controller/auth/isMfaRequiredController.test.js +3 -3
- package/src/all/background_page/controller/crypto/getUserKeyInfoController.test.js +1 -1
- package/src/all/background_page/controller/crypto/getUserPrivateKeyController.test.js +1 -1
- package/src/all/background_page/controller/extension/onExtensionInstalledController.js +61 -30
- package/src/all/background_page/controller/extension/onExtensionInstalledController.test.js +131 -19
- package/src/all/background_page/controller/informCallToActionController/informCallToActionController.test.js +46 -0
- package/src/all/background_page/controller/resource/setResourcesExpiryDateController.test.js +1 -1
- package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.js +54 -0
- package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.test.js +91 -0
- package/src/all/background_page/controller/share/shareResourcesController.test.js +2 -2
- package/src/all/background_page/controller/sso/getQualifiedSsoLoginErrorController.test.js +1 -1
- package/src/all/background_page/controller/sso/hasSsoLoginErrorController.test.js +1 -1
- package/src/all/background_page/controller/subscription/createSubscriptionKeyController.js +3 -3
- package/src/all/background_page/controller/subscription/createSubscriptionKeyController.test.js +4 -4
- package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.js +3 -3
- package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.test.js +4 -4
- package/src/all/background_page/controller/theme/findThemesController.js +52 -0
- package/src/all/background_page/controller/theme/findThemesController.test.js +68 -0
- package/src/all/background_page/controller/theme/updateThemeController.js +55 -0
- package/src/all/background_page/controller/theme/updateThemeController.test.js +76 -0
- package/src/all/background_page/controller/user/getOrFindLoggedInUserController.test.js +2 -2
- package/src/all/background_page/event/appEvents.js +1 -26
- package/src/all/background_page/event/authEvents.js +2 -2
- package/src/all/background_page/event/configEvents.js +0 -12
- package/src/all/background_page/event/informMenuEvents.js +2 -2
- package/src/all/background_page/event/quickAccessEvents.js +12 -0
- package/src/all/background_page/event/themeEvents.js +9 -21
- package/src/all/background_page/model/auth/authModel.js +3 -3
- package/src/all/background_page/model/auth/authModel.test.js +2 -2
- package/src/all/background_page/model/entity/export/exportResourcesFileEntity.js +2 -0
- package/src/all/background_page/model/entity/export/exportResourcesFileEntity.test.js +1 -0
- package/src/all/background_page/model/entity/import/importResourcesFileEntity.test.data.js +5 -0
- package/src/all/background_page/model/entity/sso/ssoLoginUrlEntity.js +1 -1
- package/src/all/background_page/model/entity/theme/themeEntity.test.data.js +12 -0
- package/src/all/background_page/model/entity/theme/themesCollection.test.data.js +10 -1
- package/src/all/background_page/model/export/resources/csvRowComposer/abstractRowComposer.js +8 -0
- package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.js +67 -0
- package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.test.js +37 -0
- package/src/all/background_page/model/export/resources/resourcesCsvExporter.js +5 -2
- package/src/all/background_page/model/export/resources/resourcesCsvExporter.test.js +3 -1
- package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.js +98 -0
- package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.test.js +145 -0
- package/src/all/background_page/model/import/resources/resourcesCsvImportParser.js +2 -0
- package/src/all/background_page/model/import/resources/resourcesCsvImportParser.test.js +19 -1
- package/src/all/background_page/model/keyring.test.js +1 -1
- package/src/all/background_page/model/multiFactorAuthentication/multiFactorAuthenticationModel.test.js +1 -1
- package/src/all/background_page/model/user/userModel.test.js +1 -1
- package/src/all/background_page/model/user.js +2 -2
- package/src/all/background_page/model/userSettings/userSettings.js +1 -1
- package/src/all/background_page/pagemod/appBootstrapPagemod.js +6 -5
- package/src/all/background_page/pagemod/appBootstrapPagemod.test.js +7 -12
- package/src/all/background_page/pagemod/authBootstrapPagemod.js +2 -2
- package/src/all/background_page/pagemod/authBootstrapPagemod.test.js +6 -7
- package/src/all/background_page/pagemod/pagemodManager.test.js +14 -20
- package/src/all/background_page/pagemod/webIntegrationPagemod.js +2 -2
- package/src/all/background_page/pagemod/webIntegrationPagemod.test.js +9 -9
- package/src/all/background_page/service/accountRecovery/decryptPrivateKeyPasswordDataService.js +1 -1
- package/src/all/background_page/service/accountRecovery/decryptResponseDataService.js +1 -1
- package/src/all/background_page/service/accountRecovery/parseAccountRecoveryUrlService.js +1 -1
- package/src/all/background_page/service/accountRecovery/validateOrganizationPublicKeyService.test.js +1 -1
- package/src/all/background_page/service/activeSession/{findAndUpdateActiveSessionLocalStorageService.js → findAndUpdateActiveSessionSessionStorageService.js} +27 -60
- package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionSessionStorageService.test.js +720 -0
- package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.js +8 -8
- package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.test.js +16 -16
- package/src/all/background_page/service/api/accountSettings/accountSettingsService.js +0 -29
- package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.data.js +0 -6
- package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.js +1 -32
- package/src/all/background_page/service/api/actionLog/actionLogApiService.test.js +1 -1
- package/src/all/background_page/service/api/comment/commentApiService.test.js +1 -1
- package/src/all/background_page/service/api/metadata/metadataKeysApiService.test.js +1 -1
- package/src/all/background_page/service/api/sessionKey/sessionKeysBundlesApiService.test.js +1 -1
- package/src/all/background_page/service/api/theme/themesApiService.js +57 -0
- package/src/all/background_page/service/api/theme/themesApiService.test.js +83 -0
- package/src/all/background_page/service/app/parseAppUrlService.js +18 -10
- package/src/all/background_page/service/app/parseAppUrlService.test.js +21 -21
- package/src/all/background_page/service/auth/localLogoutService.js +42 -0
- package/src/all/background_page/service/auth/localLogoutService.test.js +43 -0
- package/src/all/background_page/service/auth/offlineLogoutService.js +47 -0
- package/src/all/background_page/service/auth/offlineLogoutService.test.js +46 -0
- package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.js +2 -2
- package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.test.js +3 -3
- package/src/all/background_page/service/auth/parseAuthUrlService.js +11 -6
- package/src/all/background_page/service/auth/parseAuthUrlService.test.js +11 -13
- package/src/all/background_page/service/auth/postLoginOfflineService.js +3 -3
- package/src/all/background_page/service/auth/postLoginOfflineService.test.js +3 -3
- package/src/all/background_page/service/auth/postLoginService.js +3 -3
- package/src/all/background_page/service/auth/postLoginService.test.js +3 -3
- package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.js +8 -4
- package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.test.js +36 -13
- package/src/all/background_page/service/authenticationStatusService.test.js +1 -1
- package/src/all/background_page/service/clipboard/clipboardProviderService.js +0 -7
- package/src/all/background_page/service/clipboard/clipboardProviderService.test.js +0 -10
- package/src/all/background_page/service/clipboard/copyToClipboardService.js +1 -5
- package/src/all/background_page/service/crypto/decryptSsoPassphraseService.js +1 -1
- package/src/all/background_page/service/extension/onStartUpService.js +2 -2
- package/src/all/background_page/service/extension/onStartUpService.test.js +3 -3
- package/src/all/background_page/service/localStorage/localStorageService.js +4 -2
- package/src/all/background_page/service/localStorage/localStorageService.test.js +28 -12
- package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.js +40 -0
- package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.test.js +63 -0
- package/src/all/background_page/service/metadata/rotateMetadata/rotateMetadataKeyService.test.js +2 -2
- package/src/all/background_page/service/metadata/rotateMetadata/rotateResourcesMetadataKeyService.test.js +2 -2
- package/src/all/background_page/service/migrateMetadata/migrateMetadataResourcesService.test.js +2 -2
- package/src/all/background_page/service/offline/canUseOfflineStorageService.js +16 -1
- package/src/all/background_page/service/offline/canUseOfflineStorageService.test.js +14 -6
- package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.js +4 -1
- package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.test.js +10 -1
- package/src/all/background_page/service/offline/offlineRetentionDataFlushService.js +12 -9
- package/src/all/background_page/service/offline/offlineRetentionDataFlushService.test.js +35 -24
- package/src/all/background_page/service/rbac/getOrFindRbacService.js +4 -1
- package/src/all/background_page/service/recover/parseRecoverUrlService.js +1 -1
- package/src/all/background_page/service/resource/export/exportResourcesService.test.js +3 -0
- package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.js +30 -10
- package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.test.js +108 -9
- package/src/all/background_page/service/resource/getOrFindResourcesService.js +30 -10
- package/src/all/background_page/service/resource/getOrFindResourcesService.test.js +99 -9
- package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.js +4 -1
- package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.test.js +10 -2
- package/src/all/background_page/service/secret/decryptAndParseResourceSecretService.js +1 -1
- package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.js +48 -0
- package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.test.js +66 -0
- package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.js +102 -0
- package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.test.js +221 -0
- package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.js → session_storage/activeSessionSessionStorage.js} +17 -17
- package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.test.js → session_storage/activeSessionSessionStorage.test.js} +31 -34
- package/src/all/background_page/service/setup/parseSetupUrlService.js +3 -2
- package/src/all/background_page/service/setup/parseSetupUrlService.test.js +195 -24
- package/src/all/background_page/service/share/shareFoldersService.test.js +4 -4
- package/src/all/background_page/service/share/shareResourceService.test.js +4 -4
- package/src/all/background_page/service/theme/findThemesService.js +38 -0
- package/src/all/background_page/service/theme/findThemesService.test.js +63 -0
- package/src/all/background_page/service/theme/updateThemeService.js +39 -0
- package/src/all/background_page/service/theme/updateThemeService.test.js +65 -0
- package/src/all/background_page/service/toolbar/toolbarService.js +20 -10
- package/src/all/background_page/service/toolbar/toolbarService.test.js +82 -6
- package/src/all/background_page/service/user/getOrFindMeService.js +4 -1
- package/src/all/background_page/service/user/getOrFindMeService.test.js +10 -2
- package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.js +11 -6
- package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.test.js +7 -9
- package/src/all/background_page/utils/format/formDataUtils.test.js +1 -1
- package/src/all/background_page/utils/openpgp/openpgpAssertions.js +1 -1
- package/src/all/webAccessibleResources/js/themes/stylesheet.js +1 -1
- package/src/chrome-mv3/manifest.json +1 -1
- package/src/chrome-mv3/serviceWorker/service/network/requestFetchOffscreenService.js +1 -1
- package/src/chrome-mv3/serviceWorker/service/network/responseFetchOffscreenService.js +7 -4
- package/src/firefox/manifest.json +1 -1
- package/src/safari/manifest.json +1 -1
- package/test/matchers/toBeOpenpgpKeySignedBy.js +13 -14
- package/test/mocks/mockJsDomPolyfill.js +0 -2
- package/webpack/common-blocks.js +13 -13
- package/webpack/expectedBuildArtifacts.js +1 -1
- package/webpack/passboltEnvPlugin.js +1 -1
- package/webpack.common.config.js +2 -0
- package/webpack.config.js +4 -5
- package/webpack.safari-background-page.config.js +38 -31
- package/src/all/background_page/model/theme/themeModel.js +0 -66
- package/src/all/background_page/model/theme/themeModel.test.js +0 -73
- package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionLocalStorageService.test.js +0 -776
- package/src/chrome/manifest.json +0 -51
- package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.js +0 -31
- package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.test.js +0 -53
- package/webpack.chromium-mv2.config.js +0 -40
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { defaultApiClientOptions } from "passbolt-styleguide/src/shared/lib/apiClient/apiClientOptions.test.data";
|
|
16
|
+
import LocalLogoutService from "./localLogoutService";
|
|
17
|
+
import OfflineLogoutService from "./offlineLogoutService";
|
|
18
|
+
import SessionCookieFlushService from "./sessionCookieFlushService";
|
|
19
|
+
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
20
|
+
import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
jest.clearAllMocks();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("LocalLogoutService", () => {
|
|
27
|
+
const account = new AccountEntity(defaultAccountDto());
|
|
28
|
+
|
|
29
|
+
describe("LocalLogoutService::exec", () => {
|
|
30
|
+
it("removes the session cookies, then signs the user out as an offline logout does", async () => {
|
|
31
|
+
expect.assertions(1);
|
|
32
|
+
const calls = [];
|
|
33
|
+
jest
|
|
34
|
+
.spyOn(SessionCookieFlushService.prototype, "flush")
|
|
35
|
+
.mockImplementation(async () => calls.push("flushCookies"));
|
|
36
|
+
jest.spyOn(OfflineLogoutService.prototype, "exec").mockImplementation(async () => calls.push("offlineLogout"));
|
|
37
|
+
|
|
38
|
+
await new LocalLogoutService(account, defaultApiClientOptions()).exec();
|
|
39
|
+
|
|
40
|
+
expect(calls).toEqual(["flushCookies", "offlineLogout"]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import PostLogoutService from "./postLogoutService";
|
|
16
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
17
|
+
import OfflineSessionExpiryAlarmService from "./offlineSessionExpiryAlarmService";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sign out a user authenticated offline. The API is not called.
|
|
21
|
+
*/
|
|
22
|
+
class OfflineLogoutService {
|
|
23
|
+
/**
|
|
24
|
+
* @constructor
|
|
25
|
+
* @param {AccountEntity} account The user account
|
|
26
|
+
* @param {ApiClientOptions} apiClientOptions The api client options
|
|
27
|
+
*/
|
|
28
|
+
constructor(account, apiClientOptions) {
|
|
29
|
+
this.findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
|
|
30
|
+
account,
|
|
31
|
+
apiClientOptions,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Mark the active session as signed out, clear the offline session expiry alarm and run the post-logout cleanup.
|
|
37
|
+
* @return {Promise<void>}
|
|
38
|
+
*/
|
|
39
|
+
async exec() {
|
|
40
|
+
await this.findAndUpdateActiveSessionSessionStorageService.resetAuthentication();
|
|
41
|
+
// clear offline alarm if any
|
|
42
|
+
await OfflineSessionExpiryAlarmService.clearAlarm();
|
|
43
|
+
await PostLogoutService.exec();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default OfflineLogoutService;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.18.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { defaultApiClientOptions } from "passbolt-styleguide/src/shared/lib/apiClient/apiClientOptions.test.data";
|
|
16
|
+
import OfflineLogoutService from "./offlineLogoutService";
|
|
17
|
+
import PostLogoutService from "./postLogoutService";
|
|
18
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
19
|
+
import OfflineSessionExpiryAlarmService from "./offlineSessionExpiryAlarmService";
|
|
20
|
+
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
21
|
+
import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
jest.clearAllMocks();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("OfflineLogoutService", () => {
|
|
28
|
+
const account = new AccountEntity(defaultAccountDto());
|
|
29
|
+
|
|
30
|
+
describe("OfflineLogoutService::exec", () => {
|
|
31
|
+
it("marks the active session as signed out, clears the offline alarm, then runs the post-logout cleanup", async () => {
|
|
32
|
+
expect.assertions(1);
|
|
33
|
+
const calls = [];
|
|
34
|
+
jest
|
|
35
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "resetAuthentication")
|
|
36
|
+
.mockImplementation(async () => calls.push("resetAuthentication"));
|
|
37
|
+
jest
|
|
38
|
+
.spyOn(OfflineSessionExpiryAlarmService, "clearAlarm")
|
|
39
|
+
.mockImplementation(async () => calls.push("clearAlarm"));
|
|
40
|
+
jest.spyOn(PostLogoutService, "exec").mockImplementation(async () => calls.push("postLogout"));
|
|
41
|
+
|
|
42
|
+
await new OfflineLogoutService(account, defaultApiClientOptions()).exec();
|
|
43
|
+
expect(calls).toEqual(["resetAuthentication", "clearAlarm", "postLogout"]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import GetActiveAccountService from "../account/getActiveAccountService";
|
|
15
15
|
import BuildApiClientOptionsService from "../account/buildApiClientOptionsService";
|
|
16
16
|
import GetOrFindOfflineSettingsService from "../offline/getOrFindOfflineSettingsService";
|
|
17
|
-
import
|
|
17
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
18
18
|
import PostLogoutService from "./postLogoutService";
|
|
19
19
|
import { assertNumber } from "passbolt-styleguide/src/shared/utils/assertions";
|
|
20
20
|
|
|
@@ -98,7 +98,7 @@ export default class OfflineSessionExpiryAlarmService {
|
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
const apiClientOptions = BuildApiClientOptionsService.buildFromAccount(account);
|
|
101
|
-
await new
|
|
101
|
+
await new FindAndUpdateActiveSessionSessionStorageService(account, apiClientOptions).resetAuthentication();
|
|
102
102
|
await PostLogoutService.exec();
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -15,7 +15,7 @@ import OfflineSessionExpiryAlarmService from "./offlineSessionExpiryAlarmService
|
|
|
15
15
|
import GetActiveAccountService from "../account/getActiveAccountService";
|
|
16
16
|
import BuildApiClientOptionsService from "../account/buildApiClientOptionsService";
|
|
17
17
|
import GetOrFindOfflineSettingsService from "../offline/getOrFindOfflineSettingsService";
|
|
18
|
-
import
|
|
18
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
19
19
|
import PassphraseStorageService from "../session_storage/passphraseStorageService";
|
|
20
20
|
import PostLogoutService from "./postLogoutService";
|
|
21
21
|
import toolbarService from "../toolbar/toolbarService";
|
|
@@ -125,7 +125,7 @@ describe("OfflineSessionExpiryAlarmService", () => {
|
|
|
125
125
|
expect.assertions(4);
|
|
126
126
|
jest.spyOn(GetActiveAccountService, "get").mockResolvedValue(account);
|
|
127
127
|
const spyOnResetAuthentication = jest
|
|
128
|
-
.spyOn(
|
|
128
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "resetAuthentication")
|
|
129
129
|
.mockResolvedValue();
|
|
130
130
|
const spyOnSendLogout = jest.spyOn(PostLogoutService, "sendLogoutEventForWorkers").mockResolvedValue();
|
|
131
131
|
const spyOnToolbar = jest.spyOn(toolbarService, "handleUserLoggedOut").mockImplementation(() => {});
|
|
@@ -145,7 +145,7 @@ describe("OfflineSessionExpiryAlarmService", () => {
|
|
|
145
145
|
.spyOn(GetActiveAccountService, "get")
|
|
146
146
|
.mockRejectedValue(new Error("No account associated with this extension."));
|
|
147
147
|
const spyOnResetAuthentication = jest.spyOn(
|
|
148
|
-
|
|
148
|
+
FindAndUpdateActiveSessionSessionStorageService.prototype,
|
|
149
149
|
"resetAuthentication",
|
|
150
150
|
);
|
|
151
151
|
const spyOnSendLogout = jest.spyOn(PostLogoutService, "sendLogoutEventForWorkers");
|
|
@@ -11,26 +11,31 @@
|
|
|
11
11
|
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
12
|
* @since 3.10.0
|
|
13
13
|
*/
|
|
14
|
-
import
|
|
14
|
+
import { assertString, assertType } from "../../utils/assertions";
|
|
15
|
+
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
15
16
|
|
|
16
17
|
class ParseAuthUrlService {
|
|
17
18
|
/**
|
|
18
19
|
* Get regex to check URI validity
|
|
20
|
+
* @param {AccountEntity} account The user account
|
|
19
21
|
* @returns {RegExp}
|
|
20
22
|
*/
|
|
21
|
-
static
|
|
22
|
-
|
|
23
|
-
const escapedDomain =
|
|
23
|
+
static getRegex(account) {
|
|
24
|
+
assertType(account, AccountEntity);
|
|
25
|
+
const escapedDomain = account.domain.replace(/\W/g, "\\$&");
|
|
24
26
|
return new RegExp(`^${escapedDomain}/auth/login/?(#.*)?(\\?.*)?$`);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Test regex with the url.
|
|
31
|
+
* @param {AccountEntity} account The user account
|
|
29
32
|
* @param {string} url The url to test.
|
|
30
33
|
* @returns {boolean}
|
|
31
34
|
*/
|
|
32
|
-
static test(url) {
|
|
33
|
-
|
|
35
|
+
static test(account, url) {
|
|
36
|
+
assertType(account, AccountEntity);
|
|
37
|
+
assertString(url);
|
|
38
|
+
return this.getRegex(account).test(url);
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -13,14 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import ParseAuthUrlService from "./parseAuthUrlService";
|
|
16
|
-
import
|
|
16
|
+
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
17
|
+
import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
|
|
17
18
|
|
|
18
19
|
describe("ParseAuthUrlService", () => {
|
|
19
|
-
const domain = "https://passbolt.
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
Config.write("user.settings.trustedDomain", domain);
|
|
23
|
-
});
|
|
20
|
+
const domain = "https://passbolt.local";
|
|
21
|
+
const account = new AccountEntity(defaultAccountDto());
|
|
24
22
|
|
|
25
23
|
describe("ParseAuthUrlService:test", () => {
|
|
26
24
|
describe.each([
|
|
@@ -29,7 +27,7 @@ describe("ParseAuthUrlService", () => {
|
|
|
29
27
|
{ scenario: "Passbolt login page with anchors", url: `${domain}/auth/login#test` },
|
|
30
28
|
])("should parse", (_props) => {
|
|
31
29
|
it(`should match: ${_props.scenario}`, () => {
|
|
32
|
-
const parseResult = ParseAuthUrlService.
|
|
30
|
+
const parseResult = ParseAuthUrlService.test(account, _props.url);
|
|
33
31
|
expect.assertions(1);
|
|
34
32
|
expect(parseResult).toBeTruthy();
|
|
35
33
|
});
|
|
@@ -37,16 +35,16 @@ describe("ParseAuthUrlService", () => {
|
|
|
37
35
|
|
|
38
36
|
describe.each([
|
|
39
37
|
{ scenario: "No domain given", url: "https://auth/login" },
|
|
40
|
-
{ scenario: "No protocol given", url: "passbolt.
|
|
41
|
-
{ scenario: "Wrong protocol given", url: "http://passbolt.
|
|
42
|
-
{ scenario: "Domain look alike attack", url: `https://passbolt.
|
|
43
|
-
{ scenario: "Sub domain look alike attack", url: `https://attacker.passbolt.
|
|
44
|
-
{ scenario: "Regex wild mark attack", url: "https://
|
|
38
|
+
{ scenario: "No protocol given", url: "passbolt.local/auth/login" },
|
|
39
|
+
{ scenario: "Wrong protocol given", url: "http://passbolt.local/auth/login" },
|
|
40
|
+
{ scenario: "Domain look alike attack", url: `https://passbolt.local.attacker.com/auth/login` },
|
|
41
|
+
{ scenario: "Sub domain look alike attack", url: `https://attacker.passbolt.local.com/auth/login` },
|
|
42
|
+
{ scenario: "Regex wild mark attack", url: "https://passboltxlocal/auth/login" },
|
|
45
43
|
{ scenario: "Domain look alike as hash attack", url: `https://www.attacker.com#${domain}` },
|
|
46
44
|
{ scenario: "Wrong entry point", url: `${domain}/auth/login/wrong-entry-point` },
|
|
47
45
|
])("should not parse", (_props) => {
|
|
48
46
|
it(`should not match: ${_props.scenario}`, () => {
|
|
49
|
-
const parseResult = ParseAuthUrlService.
|
|
47
|
+
const parseResult = ParseAuthUrlService.test(account, _props.url);
|
|
50
48
|
expect.assertions(1);
|
|
51
49
|
expect(parseResult).toBeFalsy();
|
|
52
50
|
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import toolbarService from "../toolbar/toolbarService";
|
|
15
15
|
import PostLoginService from "./postLoginService";
|
|
16
16
|
import OfflineSessionExpiryAlarmService from "./offlineSessionExpiryAlarmService";
|
|
17
|
-
import
|
|
17
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
18
18
|
import PassphraseStorageService from "../../service/session_storage/passphraseStorageService";
|
|
19
19
|
import FindAndUpdateMetadataKeysSessionStorageFromOPFSService from "../metadata/findAndUpdateMetadataKeysSessionStorageFromOPFSService";
|
|
20
20
|
|
|
@@ -28,7 +28,7 @@ class PostLoginOfflineService {
|
|
|
28
28
|
*/
|
|
29
29
|
constructor(account, apiClientOptions) {
|
|
30
30
|
this.account = account;
|
|
31
|
-
this.
|
|
31
|
+
this.findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
|
|
32
32
|
account,
|
|
33
33
|
apiClientOptions,
|
|
34
34
|
);
|
|
@@ -44,7 +44,7 @@ class PostLoginOfflineService {
|
|
|
44
44
|
*/
|
|
45
45
|
async exec(passphrase, sessionDuration) {
|
|
46
46
|
await PassphraseStorageService.set(passphrase, sessionDuration);
|
|
47
|
-
await this.
|
|
47
|
+
await this.findAndUpdateActiveSessionSessionStorageService.authenticateOffline();
|
|
48
48
|
await this.findAndUpdateMetadataKeysSessionStorageFromOPFSService.findAndUpdateAll();
|
|
49
49
|
await OfflineSessionExpiryAlarmService.scheduleSessionExpiry(this.account, sessionDuration);
|
|
50
50
|
// Safe subset shared with the online flow (no server dependency).
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import PostLoginOfflineService from "./postLoginOfflineService";
|
|
15
15
|
import PostLoginService from "./postLoginService";
|
|
16
16
|
import OfflineSessionExpiryAlarmService from "./offlineSessionExpiryAlarmService";
|
|
17
|
-
import
|
|
17
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
18
18
|
import toolbarService from "../toolbar/toolbarService";
|
|
19
19
|
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
20
20
|
import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
|
|
@@ -34,7 +34,7 @@ describe("PostLoginOfflineService", () => {
|
|
|
34
34
|
account = new AccountEntity(defaultAccountDto());
|
|
35
35
|
apiClientOptions = defaultApiClientOptions();
|
|
36
36
|
jest.spyOn(PassphraseStorageService, "set").mockResolvedValue();
|
|
37
|
-
jest.spyOn(
|
|
37
|
+
jest.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "authenticateOffline").mockResolvedValue();
|
|
38
38
|
jest
|
|
39
39
|
.spyOn(FindAndUpdateMetadataKeysSessionStorageFromOPFSService.prototype, "findAndUpdateAll")
|
|
40
40
|
.mockResolvedValue();
|
|
@@ -51,7 +51,7 @@ describe("PostLoginOfflineService", () => {
|
|
|
51
51
|
await service.exec(passphrase, 300);
|
|
52
52
|
|
|
53
53
|
expect(PassphraseStorageService.set).toHaveBeenCalledWith(passphrase, 300);
|
|
54
|
-
expect(
|
|
54
|
+
expect(FindAndUpdateActiveSessionSessionStorageService.prototype.authenticateOffline).toHaveBeenCalledTimes(1);
|
|
55
55
|
expect(FindAndUpdateMetadataKeysSessionStorageFromOPFSService.prototype.findAndUpdateAll).toHaveBeenCalledTimes(
|
|
56
56
|
1,
|
|
57
57
|
);
|
|
@@ -17,7 +17,7 @@ import StartLoopAuthSessionCheckService from "./startLoopAuthSessionCheckService
|
|
|
17
17
|
import InformCallToActionPagemod from "../../pagemod/informCallToActionPagemod";
|
|
18
18
|
import WorkerService from "../worker/workerService";
|
|
19
19
|
import SiteSettingsRuntimeCache from "../siteSettings/siteSettingsRuntimeCache";
|
|
20
|
-
import
|
|
20
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
21
21
|
|
|
22
22
|
class PostLoginService {
|
|
23
23
|
/**
|
|
@@ -30,11 +30,11 @@ class PostLoginService {
|
|
|
30
30
|
// Clear the in-memory site settings cache so the next authenticated read refetches.
|
|
31
31
|
SiteSettingsRuntimeCache.flushAll();
|
|
32
32
|
// Record the online login transition (is_authenticated + login date) on the active session.
|
|
33
|
-
const
|
|
33
|
+
const findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
|
|
34
34
|
account,
|
|
35
35
|
apiClientOptions,
|
|
36
36
|
);
|
|
37
|
-
await
|
|
37
|
+
await findAndUpdateActiveSessionSessionStorageService.authenticateOnline();
|
|
38
38
|
// Start the session check first, so it never depends on the workers' ability to answer.
|
|
39
39
|
await StartLoopAuthSessionCheckService.exec();
|
|
40
40
|
await PostLoginService.sendLoginEventForWorkers();
|
|
@@ -27,7 +27,7 @@ import SiteSettingsRuntimeCache from "../siteSettings/siteSettingsRuntimeCache";
|
|
|
27
27
|
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
28
28
|
import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
|
|
29
29
|
import { defaultApiClientOptions } from "passbolt-styleguide/src/shared/lib/apiClient/apiClientOptions.test.data";
|
|
30
|
-
import
|
|
30
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
31
31
|
|
|
32
32
|
let account, apiClientOptions;
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ beforeEach(async () => {
|
|
|
37
37
|
account = new AccountEntity(defaultAccountDto());
|
|
38
38
|
apiClientOptions = defaultApiClientOptions();
|
|
39
39
|
jest
|
|
40
|
-
.spyOn(
|
|
40
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "authenticateOnline")
|
|
41
41
|
.mockImplementation(async () => {});
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -111,7 +111,7 @@ describe("PostLoginService", () => {
|
|
|
111
111
|
expect(StartLoopAuthSessionCheckService.exec).toHaveBeenCalledTimes(1);
|
|
112
112
|
expect(toolbarService.handleUserLoggedIn).toHaveBeenCalledTimes(1);
|
|
113
113
|
// The online login transition is recorded on the active session.
|
|
114
|
-
expect(
|
|
114
|
+
expect(FindAndUpdateActiveSessionSessionStorageService.prototype.authenticateOnline).toHaveBeenCalledTimes(1);
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
});
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
import PostLogoutService from "./postLogoutService";
|
|
15
15
|
import GetActiveAccountService from "../account/getActiveAccountService";
|
|
16
16
|
import BuildApiClientOptionsService from "../account/buildApiClientOptionsService";
|
|
17
|
-
import
|
|
17
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
18
|
+
import UpdateSessionTimestampsService from "../sessionTimestamps/updateSessionTimestampsService";
|
|
18
19
|
|
|
19
20
|
const CHECK_IS_AUTHENTICATED_INTERVAL_PERIOD = 60000;
|
|
20
21
|
const AUTH_SESSION_CHECK_ALARM = "AuthSessionCheck";
|
|
@@ -54,15 +55,18 @@ class StartLoopAuthSessionCheckService {
|
|
|
54
55
|
}
|
|
55
56
|
const account = await GetActiveAccountService.get();
|
|
56
57
|
const apiClientOptions = BuildApiClientOptionsService.buildFromAccount(account);
|
|
57
|
-
const
|
|
58
|
+
const findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
|
|
58
59
|
account,
|
|
59
60
|
apiClientOptions,
|
|
60
61
|
);
|
|
61
|
-
const activeSessionEntity =
|
|
62
|
+
const activeSessionEntity =
|
|
63
|
+
await findAndUpdateActiveSessionSessionStorageService.findAndUpdateAuthenticationStatus();
|
|
62
64
|
if (!activeSessionEntity.isAuthenticated) {
|
|
63
65
|
PostLogoutService.exec();
|
|
66
|
+
} else if (activeSessionEntity.isServerReachable) {
|
|
67
|
+
// Only an authenticated session with a reachable server counts as seen online.
|
|
68
|
+
await new UpdateSessionTimestampsService(account).updateLastSeenOnline(new Date());
|
|
64
69
|
}
|
|
65
|
-
await findAndUpdateActiveSessionLocalStorageService.updateLastSeenOnline(new Date());
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
/**
|
|
@@ -19,7 +19,8 @@ import GetActiveAccountService from "../account/getActiveAccountService";
|
|
|
19
19
|
import UserActiveSessionEntity, {
|
|
20
20
|
USER_ACTIVE_SESSION_ONLINE,
|
|
21
21
|
} from "passbolt-styleguide/src/shared/models/entity/session/userActiveSessionEntity";
|
|
22
|
-
import
|
|
22
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
23
|
+
import UpdateSessionTimestampsService from "../sessionTimestamps/updateSessionTimestampsService";
|
|
23
24
|
|
|
24
25
|
jest.useFakeTimers();
|
|
25
26
|
|
|
@@ -41,15 +42,13 @@ describe("StartLoopAuthSessionCheckService", () => {
|
|
|
41
42
|
const sessionEntity = new UserActiveSessionEntity({
|
|
42
43
|
is_authenticated: true,
|
|
43
44
|
is_mfa_required: false,
|
|
45
|
+
is_server_reachable: true,
|
|
44
46
|
type: USER_ACTIVE_SESSION_ONLINE,
|
|
45
47
|
});
|
|
46
48
|
const spyIsAuthenticated = jest
|
|
47
|
-
.spyOn(
|
|
49
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "findAndUpdateAuthenticationStatus")
|
|
48
50
|
.mockImplementation(() => Promise.resolve(sessionEntity));
|
|
49
|
-
const spyUpdateLastSeenOnline = jest.spyOn(
|
|
50
|
-
FindAndUpdateActiveSessionLocalStorageService.prototype,
|
|
51
|
-
"updateLastSeenOnline",
|
|
52
|
-
);
|
|
51
|
+
const spyUpdateLastSeenOnline = jest.spyOn(UpdateSessionTimestampsService.prototype, "updateLastSeenOnline");
|
|
53
52
|
|
|
54
53
|
//mocking top-level alarm handler
|
|
55
54
|
browser.alarms.onAlarm.addListener(
|
|
@@ -75,22 +74,20 @@ describe("StartLoopAuthSessionCheckService", () => {
|
|
|
75
74
|
expect(spyUpdateLastSeenOnline).toHaveBeenCalledTimes(2);
|
|
76
75
|
});
|
|
77
76
|
|
|
78
|
-
it("should send logout event if not authenticated anymore", async () => {
|
|
77
|
+
it("should send logout event and not update the last seen online date if not authenticated anymore", async () => {
|
|
79
78
|
expect.assertions(5);
|
|
80
79
|
// Function mocked
|
|
81
80
|
const spyClearAuthSessionCheck = jest.spyOn(StartLoopAuthSessionCheckService, "clearAlarm");
|
|
82
81
|
const sessionEntity = new UserActiveSessionEntity({
|
|
83
82
|
is_authenticated: false,
|
|
84
83
|
is_mfa_required: false,
|
|
84
|
+
is_server_reachable: true,
|
|
85
85
|
type: USER_ACTIVE_SESSION_ONLINE,
|
|
86
86
|
});
|
|
87
87
|
const spyIsAuthenticated = jest
|
|
88
|
-
.spyOn(
|
|
88
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "findAndUpdateAuthenticationStatus")
|
|
89
89
|
.mockImplementation(() => Promise.resolve(sessionEntity));
|
|
90
|
-
const spyUpdateLastSeenOnline = jest.spyOn(
|
|
91
|
-
FindAndUpdateActiveSessionLocalStorageService.prototype,
|
|
92
|
-
"updateLastSeenOnline",
|
|
93
|
-
);
|
|
90
|
+
const spyUpdateLastSeenOnline = jest.spyOn(UpdateSessionTimestampsService.prototype, "updateLastSeenOnline");
|
|
94
91
|
const spyOnPostLogout = jest.spyOn(PostLogoutService, "exec").mockImplementation(async () => {});
|
|
95
92
|
|
|
96
93
|
//mocking top-level alarm handler
|
|
@@ -109,6 +106,32 @@ describe("StartLoopAuthSessionCheckService", () => {
|
|
|
109
106
|
|
|
110
107
|
expect(spyIsAuthenticated).toHaveBeenCalledTimes(1);
|
|
111
108
|
expect(spyOnPostLogout).toHaveBeenCalledTimes(1);
|
|
112
|
-
expect(spyUpdateLastSeenOnline).
|
|
109
|
+
expect(spyUpdateLastSeenOnline).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("should not update the last seen online date if the server is not reachable", async () => {
|
|
113
|
+
expect.assertions(3);
|
|
114
|
+
// Function mocked
|
|
115
|
+
const sessionEntity = new UserActiveSessionEntity({
|
|
116
|
+
is_authenticated: true,
|
|
117
|
+
is_mfa_required: false,
|
|
118
|
+
is_server_reachable: false,
|
|
119
|
+
type: USER_ACTIVE_SESSION_ONLINE,
|
|
120
|
+
});
|
|
121
|
+
const spyIsAuthenticated = jest
|
|
122
|
+
.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "findAndUpdateAuthenticationStatus")
|
|
123
|
+
.mockImplementation(() => Promise.resolve(sessionEntity));
|
|
124
|
+
const spyUpdateLastSeenOnline = jest.spyOn(UpdateSessionTimestampsService.prototype, "updateLastSeenOnline");
|
|
125
|
+
const spyOnPostLogout = jest.spyOn(PostLogoutService, "exec").mockImplementation(async () => {});
|
|
126
|
+
|
|
127
|
+
// Process
|
|
128
|
+
await StartLoopAuthSessionCheckService.handleAuthStatusCheckAlarm({
|
|
129
|
+
name: StartLoopAuthSessionCheckService.ALARM_NAME,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Expectation
|
|
133
|
+
expect(spyIsAuthenticated).toHaveBeenCalledTimes(1);
|
|
134
|
+
expect(spyOnPostLogout).not.toHaveBeenCalled();
|
|
135
|
+
expect(spyUpdateLastSeenOnline).not.toHaveBeenCalled();
|
|
113
136
|
});
|
|
114
137
|
});
|
|
@@ -19,7 +19,7 @@ import { defaultApiClientOptions } from "passbolt-styleguide/src/shared/lib/apiC
|
|
|
19
19
|
import MfaAuthenticationRequiredError from "../error/mfaAuthenticationRequiredError";
|
|
20
20
|
import PassboltBadResponseError from "../error/passboltBadResponseError";
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
beforeEach(() => {
|
|
23
23
|
enableFetchMocks();
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
12
|
* @since 5.3.2
|
|
13
13
|
*/
|
|
14
|
-
import EdgeBackgroundPageClipboardService from "../../../../chrome/polyfill/clipboard/edgeBackgroundPageClipboardService";
|
|
15
|
-
import BrowserService from "../browser/browserService";
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* The service retrieves the appropriate clipboard provider for the current environment: Edge, Chrome, Safari or Firefox.
|
|
@@ -29,11 +27,6 @@ export default class ClipboardProviderService {
|
|
|
29
27
|
return customNavigatorClipboard;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
const isMV2 = chrome.runtime.getManifest().manifest_version === 2;
|
|
33
|
-
if (!BrowserService.isFirefox() && isMV2) {
|
|
34
|
-
//it's not firefox and it's MV2 => it's most probably Edge then
|
|
35
|
-
return EdgeBackgroundPageClipboardService;
|
|
36
|
-
}
|
|
37
30
|
//by default we provide the default clipboard
|
|
38
31
|
return navigator.clipboard;
|
|
39
32
|
}
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
import "../../../../../test/mocks/mockNavigatorClipboard";
|
|
15
15
|
import ClipboardProviderService from "./clipboardProviderService";
|
|
16
16
|
import BrowserService from "../browser/browserService";
|
|
17
|
-
import EdgeBackgroundPageClipboardService from "../../../../chrome/polyfill/clipboard/edgeBackgroundPageClipboardService";
|
|
18
17
|
|
|
19
18
|
beforeEach(() => {
|
|
20
19
|
global.customNavigatorClipboard = undefined;
|
|
@@ -31,15 +30,6 @@ describe("ClipboardProviderService", () => {
|
|
|
31
30
|
expect(ClipboardProviderService.getClipboard()).toStrictEqual(customNavigatorClipboard);
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
it("should return the EdgeBackgroundPageClipboardService if not on Firefox and is on MV2", async () => {
|
|
35
|
-
expect.assertions(1);
|
|
36
|
-
|
|
37
|
-
chrome.runtime.getManifest.mockImplementation(() => ({ manifest_version: 2 }));
|
|
38
|
-
jest.spyOn(BrowserService, "isFirefox").mockImplementation(() => false);
|
|
39
|
-
|
|
40
|
-
expect(ClipboardProviderService.getClipboard()).toStrictEqual(EdgeBackgroundPageClipboardService);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
33
|
it("should return the navigator.clipboard in every other cases: Firefox", async () => {
|
|
44
34
|
expect.assertions(1);
|
|
45
35
|
|
|
@@ -17,11 +17,7 @@ import ClipboardProviderService from "./clipboardProviderService";
|
|
|
17
17
|
|
|
18
18
|
const CLIPBOARD_TEMPORARY_CONTENT_FLUSH_DELAY_IN_SECOND = 30;
|
|
19
19
|
const CLIPBOARD_TEMPORARY_CONTENT_FLUSH_ALARM = "ClipboardTemporaryContentFlush";
|
|
20
|
-
|
|
21
|
-
* The service aims to use the clipboard capability on Edge MV2 where:
|
|
22
|
-
* - navigator.clipboard.writeText cannot be used in Edge MV2 background page due to a focus issue.
|
|
23
|
-
* - offscreen clipboard cannot be used due to offscreen API available only with MV3.
|
|
24
|
-
*/
|
|
20
|
+
|
|
25
21
|
export default class CopyToClipboardService {
|
|
26
22
|
/**
|
|
27
23
|
* @constructor
|
|
@@ -67,7 +67,7 @@ class DecryptSsoPassphraseService {
|
|
|
67
67
|
* This can happen if the local SSO kit nek and/or iv1 has changed (manually?).
|
|
68
68
|
*/
|
|
69
69
|
console.error(e);
|
|
70
|
-
throw new Error(`Unable to decrypt passphrase with the local SSO kit: ${e.message}
|
|
70
|
+
throw new Error(`Unable to decrypt passphrase with the local SSO kit: ${e.message}`, { cause: e });
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return Buffer.from(secondDecryptionBuffer).toString();
|
|
@@ -20,7 +20,7 @@ import { BrowserExtensionIconService } from "../ui/browserExtensionIcon.service"
|
|
|
20
20
|
import User from "../../model/user";
|
|
21
21
|
import GetActiveAccountService from "../account/getActiveAccountService";
|
|
22
22
|
import BuildApiClientOptionsService from "../account/buildApiClientOptionsService";
|
|
23
|
-
import
|
|
23
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
24
24
|
|
|
25
25
|
class OnStartUpService {
|
|
26
26
|
/**
|
|
@@ -48,7 +48,7 @@ class OnStartUpService {
|
|
|
48
48
|
const account = await GetActiveAccountService.get();
|
|
49
49
|
const apiClientOptions = BuildApiClientOptionsService.buildFromAccount(account);
|
|
50
50
|
// Rest authentication
|
|
51
|
-
await new
|
|
51
|
+
await new FindAndUpdateActiveSessionSessionStorageService(account, apiClientOptions).resetAuthentication();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -20,7 +20,7 @@ import { BrowserExtensionIconService } from "../ui/browserExtensionIcon.service"
|
|
|
20
20
|
import GetActiveAccountService from "../account/getActiveAccountService";
|
|
21
21
|
import AccountEntity from "../../model/entity/account/accountEntity";
|
|
22
22
|
import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
|
|
23
|
-
import
|
|
23
|
+
import FindAndUpdateActiveSessionSessionStorageService from "../activeSession/findAndUpdateActiveSessionSessionStorageService";
|
|
24
24
|
|
|
25
25
|
// Reset the modules before each test.
|
|
26
26
|
beforeEach(() => {
|
|
@@ -54,13 +54,13 @@ describe("OnStartUpService", () => {
|
|
|
54
54
|
jest.spyOn(LocalStorageService, "flush");
|
|
55
55
|
jest.spyOn(BrowserExtensionIconService, "deactivate");
|
|
56
56
|
jest.spyOn(GetActiveAccountService, "get").mockImplementation(() => new AccountEntity(defaultAccountDto()));
|
|
57
|
-
jest.spyOn(
|
|
57
|
+
jest.spyOn(FindAndUpdateActiveSessionSessionStorageService.prototype, "resetAuthentication");
|
|
58
58
|
// process
|
|
59
59
|
await OnStartUpService.exec();
|
|
60
60
|
// expectation
|
|
61
61
|
expect(LocalStorageService.flush).toHaveBeenCalledTimes(1);
|
|
62
62
|
expect(BrowserExtensionIconService.deactivate).toHaveBeenCalledTimes(1);
|
|
63
|
-
expect(
|
|
63
|
+
expect(FindAndUpdateActiveSessionSessionStorageService.prototype.resetAuthentication).toHaveBeenCalledTimes(1);
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
});
|