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.
Files changed (185) hide show
  1. package/.pre-commit-config.yaml +6 -2
  2. package/CHANGELOG.md +106 -1
  3. package/README.md +2 -2
  4. package/RELEASE_NOTES.md +3 -94
  5. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/ViewController.swift +5 -5
  6. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager.xcodeproj/project.pbxproj +10 -10
  7. package/eslint.config.mjs +3 -35
  8. package/jest.config.json +1 -2
  9. package/package.json +45 -54
  10. package/src/all/_locales/locales.test.js +2 -0
  11. package/src/all/background_page/controller/InformMenuController/InformMenuController.test.js +45 -1
  12. package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.js +1 -2
  13. package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.test.js +10 -8
  14. package/src/all/background_page/controller/accountRecovery/accountRecoveryValidatePublicKeyController.test.js +1 -1
  15. package/src/all/background_page/controller/auth/authLocalLogoutController.js +3 -14
  16. package/src/all/background_page/controller/auth/authLocalLogoutController.test.js +3 -3
  17. package/src/all/background_page/controller/auth/authLoginController.js +2 -2
  18. package/src/all/background_page/controller/auth/authOfflineLogoutController.js +4 -12
  19. package/src/all/background_page/controller/auth/authOfflineLogoutController.test.js +3 -3
  20. package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.js → findAndUpdateActiveSessionSessionStorageController.js} +6 -6
  21. package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.test.js → findAndUpdateActiveSessionSessionStorageController.test.js} +30 -30
  22. package/src/all/background_page/controller/auth/getOrFindActiveSessionController.test.js +22 -20
  23. package/src/all/background_page/controller/auth/isMfaRequiredController.js +5 -4
  24. package/src/all/background_page/controller/auth/isMfaRequiredController.test.js +3 -3
  25. package/src/all/background_page/controller/crypto/getUserKeyInfoController.test.js +1 -1
  26. package/src/all/background_page/controller/crypto/getUserPrivateKeyController.test.js +1 -1
  27. package/src/all/background_page/controller/extension/onExtensionInstalledController.js +61 -30
  28. package/src/all/background_page/controller/extension/onExtensionInstalledController.test.js +131 -19
  29. package/src/all/background_page/controller/informCallToActionController/informCallToActionController.test.js +46 -0
  30. package/src/all/background_page/controller/resource/setResourcesExpiryDateController.test.js +1 -1
  31. package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.js +54 -0
  32. package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.test.js +91 -0
  33. package/src/all/background_page/controller/share/shareResourcesController.test.js +2 -2
  34. package/src/all/background_page/controller/sso/getQualifiedSsoLoginErrorController.test.js +1 -1
  35. package/src/all/background_page/controller/sso/hasSsoLoginErrorController.test.js +1 -1
  36. package/src/all/background_page/controller/subscription/createSubscriptionKeyController.js +3 -3
  37. package/src/all/background_page/controller/subscription/createSubscriptionKeyController.test.js +4 -4
  38. package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.js +3 -3
  39. package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.test.js +4 -4
  40. package/src/all/background_page/controller/theme/findThemesController.js +52 -0
  41. package/src/all/background_page/controller/theme/findThemesController.test.js +68 -0
  42. package/src/all/background_page/controller/theme/updateThemeController.js +55 -0
  43. package/src/all/background_page/controller/theme/updateThemeController.test.js +76 -0
  44. package/src/all/background_page/controller/user/getOrFindLoggedInUserController.test.js +2 -2
  45. package/src/all/background_page/event/appEvents.js +1 -26
  46. package/src/all/background_page/event/authEvents.js +2 -2
  47. package/src/all/background_page/event/configEvents.js +0 -12
  48. package/src/all/background_page/event/informMenuEvents.js +2 -2
  49. package/src/all/background_page/event/quickAccessEvents.js +12 -0
  50. package/src/all/background_page/event/themeEvents.js +9 -21
  51. package/src/all/background_page/model/auth/authModel.js +3 -3
  52. package/src/all/background_page/model/auth/authModel.test.js +2 -2
  53. package/src/all/background_page/model/entity/export/exportResourcesFileEntity.js +2 -0
  54. package/src/all/background_page/model/entity/export/exportResourcesFileEntity.test.js +1 -0
  55. package/src/all/background_page/model/entity/import/importResourcesFileEntity.test.data.js +5 -0
  56. package/src/all/background_page/model/entity/sso/ssoLoginUrlEntity.js +1 -1
  57. package/src/all/background_page/model/entity/theme/themeEntity.test.data.js +12 -0
  58. package/src/all/background_page/model/entity/theme/themesCollection.test.data.js +10 -1
  59. package/src/all/background_page/model/export/resources/csvRowComposer/abstractRowComposer.js +8 -0
  60. package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.js +67 -0
  61. package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.test.js +37 -0
  62. package/src/all/background_page/model/export/resources/resourcesCsvExporter.js +5 -2
  63. package/src/all/background_page/model/export/resources/resourcesCsvExporter.test.js +3 -1
  64. package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.js +98 -0
  65. package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.test.js +145 -0
  66. package/src/all/background_page/model/import/resources/resourcesCsvImportParser.js +2 -0
  67. package/src/all/background_page/model/import/resources/resourcesCsvImportParser.test.js +19 -1
  68. package/src/all/background_page/model/keyring.test.js +1 -1
  69. package/src/all/background_page/model/multiFactorAuthentication/multiFactorAuthenticationModel.test.js +1 -1
  70. package/src/all/background_page/model/user/userModel.test.js +1 -1
  71. package/src/all/background_page/model/user.js +2 -2
  72. package/src/all/background_page/model/userSettings/userSettings.js +1 -1
  73. package/src/all/background_page/pagemod/appBootstrapPagemod.js +6 -5
  74. package/src/all/background_page/pagemod/appBootstrapPagemod.test.js +7 -12
  75. package/src/all/background_page/pagemod/authBootstrapPagemod.js +2 -2
  76. package/src/all/background_page/pagemod/authBootstrapPagemod.test.js +6 -7
  77. package/src/all/background_page/pagemod/pagemodManager.test.js +14 -20
  78. package/src/all/background_page/pagemod/webIntegrationPagemod.js +2 -2
  79. package/src/all/background_page/pagemod/webIntegrationPagemod.test.js +9 -9
  80. package/src/all/background_page/service/accountRecovery/decryptPrivateKeyPasswordDataService.js +1 -1
  81. package/src/all/background_page/service/accountRecovery/decryptResponseDataService.js +1 -1
  82. package/src/all/background_page/service/accountRecovery/parseAccountRecoveryUrlService.js +1 -1
  83. package/src/all/background_page/service/accountRecovery/validateOrganizationPublicKeyService.test.js +1 -1
  84. package/src/all/background_page/service/activeSession/{findAndUpdateActiveSessionLocalStorageService.js → findAndUpdateActiveSessionSessionStorageService.js} +27 -60
  85. package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionSessionStorageService.test.js +720 -0
  86. package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.js +8 -8
  87. package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.test.js +16 -16
  88. package/src/all/background_page/service/api/accountSettings/accountSettingsService.js +0 -29
  89. package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.data.js +0 -6
  90. package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.js +1 -32
  91. package/src/all/background_page/service/api/actionLog/actionLogApiService.test.js +1 -1
  92. package/src/all/background_page/service/api/comment/commentApiService.test.js +1 -1
  93. package/src/all/background_page/service/api/metadata/metadataKeysApiService.test.js +1 -1
  94. package/src/all/background_page/service/api/sessionKey/sessionKeysBundlesApiService.test.js +1 -1
  95. package/src/all/background_page/service/api/theme/themesApiService.js +57 -0
  96. package/src/all/background_page/service/api/theme/themesApiService.test.js +83 -0
  97. package/src/all/background_page/service/app/parseAppUrlService.js +18 -10
  98. package/src/all/background_page/service/app/parseAppUrlService.test.js +21 -21
  99. package/src/all/background_page/service/auth/localLogoutService.js +42 -0
  100. package/src/all/background_page/service/auth/localLogoutService.test.js +43 -0
  101. package/src/all/background_page/service/auth/offlineLogoutService.js +47 -0
  102. package/src/all/background_page/service/auth/offlineLogoutService.test.js +46 -0
  103. package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.js +2 -2
  104. package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.test.js +3 -3
  105. package/src/all/background_page/service/auth/parseAuthUrlService.js +11 -6
  106. package/src/all/background_page/service/auth/parseAuthUrlService.test.js +11 -13
  107. package/src/all/background_page/service/auth/postLoginOfflineService.js +3 -3
  108. package/src/all/background_page/service/auth/postLoginOfflineService.test.js +3 -3
  109. package/src/all/background_page/service/auth/postLoginService.js +3 -3
  110. package/src/all/background_page/service/auth/postLoginService.test.js +3 -3
  111. package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.js +8 -4
  112. package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.test.js +36 -13
  113. package/src/all/background_page/service/authenticationStatusService.test.js +1 -1
  114. package/src/all/background_page/service/clipboard/clipboardProviderService.js +0 -7
  115. package/src/all/background_page/service/clipboard/clipboardProviderService.test.js +0 -10
  116. package/src/all/background_page/service/clipboard/copyToClipboardService.js +1 -5
  117. package/src/all/background_page/service/crypto/decryptSsoPassphraseService.js +1 -1
  118. package/src/all/background_page/service/extension/onStartUpService.js +2 -2
  119. package/src/all/background_page/service/extension/onStartUpService.test.js +3 -3
  120. package/src/all/background_page/service/localStorage/localStorageService.js +4 -2
  121. package/src/all/background_page/service/localStorage/localStorageService.test.js +28 -12
  122. package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.js +40 -0
  123. package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.test.js +63 -0
  124. package/src/all/background_page/service/metadata/rotateMetadata/rotateMetadataKeyService.test.js +2 -2
  125. package/src/all/background_page/service/metadata/rotateMetadata/rotateResourcesMetadataKeyService.test.js +2 -2
  126. package/src/all/background_page/service/migrateMetadata/migrateMetadataResourcesService.test.js +2 -2
  127. package/src/all/background_page/service/offline/canUseOfflineStorageService.js +16 -1
  128. package/src/all/background_page/service/offline/canUseOfflineStorageService.test.js +14 -6
  129. package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.js +4 -1
  130. package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.test.js +10 -1
  131. package/src/all/background_page/service/offline/offlineRetentionDataFlushService.js +12 -9
  132. package/src/all/background_page/service/offline/offlineRetentionDataFlushService.test.js +35 -24
  133. package/src/all/background_page/service/rbac/getOrFindRbacService.js +4 -1
  134. package/src/all/background_page/service/recover/parseRecoverUrlService.js +1 -1
  135. package/src/all/background_page/service/resource/export/exportResourcesService.test.js +3 -0
  136. package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.js +30 -10
  137. package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.test.js +108 -9
  138. package/src/all/background_page/service/resource/getOrFindResourcesService.js +30 -10
  139. package/src/all/background_page/service/resource/getOrFindResourcesService.test.js +99 -9
  140. package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.js +4 -1
  141. package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.test.js +10 -2
  142. package/src/all/background_page/service/secret/decryptAndParseResourceSecretService.js +1 -1
  143. package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.js +48 -0
  144. package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.test.js +66 -0
  145. package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.js +102 -0
  146. package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.test.js +221 -0
  147. package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.js → session_storage/activeSessionSessionStorage.js} +17 -17
  148. package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.test.js → session_storage/activeSessionSessionStorage.test.js} +31 -34
  149. package/src/all/background_page/service/setup/parseSetupUrlService.js +3 -2
  150. package/src/all/background_page/service/setup/parseSetupUrlService.test.js +195 -24
  151. package/src/all/background_page/service/share/shareFoldersService.test.js +4 -4
  152. package/src/all/background_page/service/share/shareResourceService.test.js +4 -4
  153. package/src/all/background_page/service/theme/findThemesService.js +38 -0
  154. package/src/all/background_page/service/theme/findThemesService.test.js +63 -0
  155. package/src/all/background_page/service/theme/updateThemeService.js +39 -0
  156. package/src/all/background_page/service/theme/updateThemeService.test.js +65 -0
  157. package/src/all/background_page/service/toolbar/toolbarService.js +20 -10
  158. package/src/all/background_page/service/toolbar/toolbarService.test.js +82 -6
  159. package/src/all/background_page/service/user/getOrFindMeService.js +4 -1
  160. package/src/all/background_page/service/user/getOrFindMeService.test.js +10 -2
  161. package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.js +11 -6
  162. package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.test.js +7 -9
  163. package/src/all/background_page/utils/format/formDataUtils.test.js +1 -1
  164. package/src/all/background_page/utils/openpgp/openpgpAssertions.js +1 -1
  165. package/src/all/webAccessibleResources/js/themes/stylesheet.js +1 -1
  166. package/src/chrome-mv3/manifest.json +1 -1
  167. package/src/chrome-mv3/serviceWorker/service/network/requestFetchOffscreenService.js +1 -1
  168. package/src/chrome-mv3/serviceWorker/service/network/responseFetchOffscreenService.js +7 -4
  169. package/src/firefox/manifest.json +1 -1
  170. package/src/safari/manifest.json +1 -1
  171. package/test/matchers/toBeOpenpgpKeySignedBy.js +13 -14
  172. package/test/mocks/mockJsDomPolyfill.js +0 -2
  173. package/webpack/common-blocks.js +13 -13
  174. package/webpack/expectedBuildArtifacts.js +1 -1
  175. package/webpack/passboltEnvPlugin.js +1 -1
  176. package/webpack.common.config.js +2 -0
  177. package/webpack.config.js +4 -5
  178. package/webpack.safari-background-page.config.js +38 -31
  179. package/src/all/background_page/model/theme/themeModel.js +0 -66
  180. package/src/all/background_page/model/theme/themeModel.test.js +0 -73
  181. package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionLocalStorageService.test.js +0 -776
  182. package/src/chrome/manifest.json +0 -51
  183. package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.js +0 -31
  184. package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.test.js +0 -53
  185. 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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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 FindAndUpdateActiveSessionLocalStorageService(account, apiClientOptions).resetAuthentication();
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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(FindAndUpdateActiveSessionLocalStorageService.prototype, "resetAuthentication")
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
- FindAndUpdateActiveSessionLocalStorageService.prototype,
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 User from "../../model/user";
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 get regex() {
22
- const user = User.getInstance();
23
- const escapedDomain = user.settings.getDomain().replace(/\W/g, "\\$&");
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
- return this.regex.test(url);
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 { Config } from "../../model/config";
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.dev";
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.regex.test(_props.url);
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.dev/auth/login" },
41
- { scenario: "Wrong protocol given", url: "http://passbolt.dev/auth/login" },
42
- { scenario: "Domain look alike attack", url: `https://passbolt.dev.attacker.com/auth/login` },
43
- { scenario: "Sub domain look alike attack", url: `https://attacker.passbolt.dev.com/auth/login` },
44
- { scenario: "Regex wild mark attack", url: "https://passboltxdev/auth/login" },
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.regex.test(_props.url);
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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.findAndUpdateActiveSessionLocalStorageService = new FindAndUpdateActiveSessionLocalStorageService(
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.findAndUpdateActiveSessionLocalStorageService.authenticateOffline();
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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(FindAndUpdateActiveSessionLocalStorageService.prototype, "authenticateOffline").mockResolvedValue();
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(FindAndUpdateActiveSessionLocalStorageService.prototype.authenticateOffline).toHaveBeenCalledTimes(1);
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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 findAndUpdateActiveSessionLocalStorageService = new FindAndUpdateActiveSessionLocalStorageService(
33
+ const findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
34
34
  account,
35
35
  apiClientOptions,
36
36
  );
37
- await findAndUpdateActiveSessionLocalStorageService.authenticateOnline();
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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(FindAndUpdateActiveSessionLocalStorageService.prototype, "authenticateOnline")
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(FindAndUpdateActiveSessionLocalStorageService.prototype.authenticateOnline).toHaveBeenCalledTimes(1);
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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 findAndUpdateActiveSessionLocalStorageService = new FindAndUpdateActiveSessionLocalStorageService(
58
+ const findAndUpdateActiveSessionSessionStorageService = new FindAndUpdateActiveSessionSessionStorageService(
58
59
  account,
59
60
  apiClientOptions,
60
61
  );
61
- const activeSessionEntity = await findAndUpdateActiveSessionLocalStorageService.findAndUpdateAuthenticationStatus();
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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(FindAndUpdateActiveSessionLocalStorageService.prototype, "findAndUpdateAuthenticationStatus")
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(FindAndUpdateActiveSessionLocalStorageService.prototype, "findAndUpdateAuthenticationStatus")
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).toHaveBeenCalledTimes(1);
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
- beforeAll(() => {
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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 FindAndUpdateActiveSessionLocalStorageService(account, apiClientOptions).resetAuthentication();
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 FindAndUpdateActiveSessionLocalStorageService from "../activeSession/findAndUpdateActiveSessionLocalStorageService";
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(FindAndUpdateActiveSessionLocalStorageService.prototype, "resetAuthentication");
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(FindAndUpdateActiveSessionLocalStorageService.prototype.resetAuthentication).toHaveBeenCalledTimes(1);
63
+ expect(FindAndUpdateActiveSessionSessionStorageService.prototype.resetAuthentication).toHaveBeenCalledTimes(1);
64
64
  });
65
65
  });
66
66
  });