passbolt-browser-extension 5.16.1 → 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 (337) hide show
  1. package/.pre-commit-config.yaml +6 -2
  2. package/CHANGELOG.md +210 -1
  3. package/README.md +2 -2
  4. package/RELEASE_NOTES.md +3 -4
  5. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/AppDelegate.swift +3 -3
  6. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/ViewController.swift +15 -15
  7. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/SafariWebExtensionHandler.swift +5 -5
  8. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/AbstractController.swift +5 -5
  9. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/ErrorController.swift +2 -2
  10. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/FetchController.swift +3 -3
  11. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/OpenSafariSettingsController.swift +1 -1
  12. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/SaveFileController.swift +2 -2
  13. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/WriteClipboardController.swift +3 -3
  14. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/fetch/SecureProfileSessionManager.swift +36 -30
  15. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/fetch/fetchService.swift +24 -24
  16. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/file/SaveFileService.swift +15 -15
  17. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/utils/ErrorSerializer.swift +13 -13
  18. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/utils/LocatedError.swift +3 -3
  19. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/SafariWebExtensionHandlerTests.swift +3 -3
  20. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/AbstractControllerTests.swift +2 -2
  21. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/ErrorControllerTests.swift +1 -1
  22. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/FetchControllerTests.swift +1 -1
  23. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/OpenSafariSettingsControllerTests.swift +1 -1
  24. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/SaveFileControllerTests.swift +1 -1
  25. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/WriteClipboardControllerTests.swift +1 -1
  26. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/services/fetch/FetchServiceTests.swift +1 -1
  27. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/services/fetch/SecureProfileSessionManagerTests.swift +7 -7
  28. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/utils/ErrorSerializerTests.swift +17 -17
  29. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/utils/LocatedErrorTests.swift +12 -12
  30. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager.xcodeproj/project.pbxproj +12 -14
  31. package/eslint.config.mjs +3 -35
  32. package/jest.config.json +1 -2
  33. package/package.json +45 -51
  34. package/src/all/_locales/locales.test.js +2 -0
  35. package/src/all/background_page/controller/InformMenuController/InformMenuController.test.js +45 -1
  36. package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.js +1 -2
  37. package/src/all/background_page/controller/accountRecovery/accountRecoverySaveUserSettingController.test.js +10 -8
  38. package/src/all/background_page/controller/accountRecovery/accountRecoveryValidatePublicKeyController.test.js +1 -1
  39. package/src/all/background_page/controller/accountRecovery/recoverAccountController.js +4 -0
  40. package/src/all/background_page/controller/accountRecovery/recoverAccountController.test.js +5 -1
  41. package/src/all/background_page/controller/auth/authLocalLogoutController.js +3 -14
  42. package/src/all/background_page/controller/auth/authLocalLogoutController.test.js +3 -3
  43. package/src/all/background_page/controller/auth/authLoginController.js +2 -2
  44. package/src/all/background_page/controller/auth/authOfflineLogoutController.js +4 -12
  45. package/src/all/background_page/controller/auth/authOfflineLogoutController.test.js +3 -3
  46. package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.js → findAndUpdateActiveSessionSessionStorageController.js} +6 -6
  47. package/src/all/background_page/controller/auth/{findAndUpdateActiveSessionLocalStorageController.test.js → findAndUpdateActiveSessionSessionStorageController.test.js} +30 -30
  48. package/src/all/background_page/controller/auth/getOrFindActiveSessionController.test.js +22 -20
  49. package/src/all/background_page/controller/auth/isMfaRequiredController.js +5 -4
  50. package/src/all/background_page/controller/auth/isMfaRequiredController.test.js +3 -3
  51. package/src/all/background_page/controller/crypto/getUserKeyInfoController.test.js +1 -1
  52. package/src/all/background_page/controller/crypto/getUserPrivateKeyController.test.js +1 -1
  53. package/src/all/background_page/controller/extension/onExtensionInstalledController.js +61 -30
  54. package/src/all/background_page/controller/extension/onExtensionInstalledController.test.js +131 -19
  55. package/src/all/background_page/controller/informCallToActionController/informCallToActionController.js +4 -2
  56. package/src/all/background_page/controller/informCallToActionController/informCallToActionController.test.js +50 -2
  57. package/src/all/background_page/controller/mfaPolicy/mfaGetMfaSettingsController.test.js +13 -0
  58. package/src/all/background_page/controller/mfaSetup/MfaSetupAbortWebauthnCeremonyController.js +52 -0
  59. package/src/all/background_page/controller/mfaSetup/MfaSetupAbortWebauthnCeremonyController.test.js +54 -0
  60. package/src/all/background_page/controller/mfaSetup/MfaSetupBeginWebauthnCeremonyController.js +52 -0
  61. package/src/all/background_page/controller/mfaSetup/MfaSetupBeginWebauthnCeremonyController.test.js +54 -0
  62. package/src/all/background_page/controller/mfaSetup/MfaSetupDeleteWebauthnCredentialController.js +55 -0
  63. package/src/all/background_page/controller/mfaSetup/MfaSetupDeleteWebauthnCredentialController.test.js +55 -0
  64. package/src/all/background_page/controller/mfaSetup/MfaSetupFinishWebauthnCeremonyController.js +54 -0
  65. package/src/all/background_page/controller/mfaSetup/MfaSetupFinishWebauthnCeremonyController.test.js +54 -0
  66. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnCredentialsController.js +54 -0
  67. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnCredentialsController.test.js +61 -0
  68. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnSettingsController.js +53 -0
  69. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnSettingsController.test.js +57 -0
  70. package/src/all/background_page/controller/mfaSetup/MfaSetupHandleWebauthnCeremonyResultController.js +55 -0
  71. package/src/all/background_page/controller/mfaSetup/MfaSetupHandleWebauthnCeremonyResultController.test.js +52 -0
  72. package/src/all/background_page/controller/move/moveFolderController.js +12 -12
  73. package/src/all/background_page/controller/move/moveFolderController.test.js +31 -1
  74. package/src/all/background_page/controller/move/moveResourcesController.js +18 -5
  75. package/src/all/background_page/controller/move/moveResourcesController.test.js +68 -7
  76. package/src/all/background_page/controller/recover/completeRecoverController.js +4 -0
  77. package/src/all/background_page/controller/recover/completeRecoverController.test.js +5 -1
  78. package/src/all/background_page/controller/resource/setResourcesExpiryDateController.test.js +1 -1
  79. package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.js +54 -0
  80. package/src/all/background_page/controller/sessionTimestamps/getSessionTimestampsController.test.js +91 -0
  81. package/src/all/background_page/controller/setup/completeSetupController.js +4 -0
  82. package/src/all/background_page/controller/setup/completeSetupController.test.js +5 -1
  83. package/src/all/background_page/controller/share/shareResourcesController.test.js +2 -2
  84. package/src/all/background_page/controller/sso/getQualifiedSsoLoginErrorController.test.js +1 -1
  85. package/src/all/background_page/controller/sso/hasSsoLoginErrorController.test.js +1 -1
  86. package/src/all/background_page/controller/subscription/createSubscriptionKeyController.js +3 -3
  87. package/src/all/background_page/controller/subscription/createSubscriptionKeyController.test.js +4 -4
  88. package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.js +3 -3
  89. package/src/all/background_page/controller/subscription/deleteSubscriptionKeyController.test.js +4 -4
  90. package/src/all/background_page/controller/theme/findThemesController.js +52 -0
  91. package/src/all/background_page/controller/theme/findThemesController.test.js +68 -0
  92. package/src/all/background_page/controller/theme/updateThemeController.js +55 -0
  93. package/src/all/background_page/controller/theme/updateThemeController.test.js +76 -0
  94. package/src/all/background_page/controller/user/getOrFindLoggedInUserController.test.js +2 -2
  95. package/src/{chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.js → all/background_page/error/webauthnAlreadyRunningCeremonyError.js} +7 -14
  96. package/src/all/background_page/error/webauthnAuthenticatorAlreadyRegisteredError.js +26 -0
  97. package/src/all/background_page/error/webauthnCeremonyAbortedError.js +26 -0
  98. package/src/all/background_page/error/webauthnCeremonyCancelledError.js +26 -0
  99. package/src/all/background_page/error/webauthnCeremonyError.js +26 -0
  100. package/src/all/background_page/error/webauthnCeremonyNotFoundError.js +26 -0
  101. package/src/all/background_page/error/webauthnTLSCertificateError.js +24 -0
  102. package/src/all/background_page/event/appBootstrapEvents.js +32 -0
  103. package/src/all/background_page/event/appBootstrapEvents.test.js +31 -0
  104. package/src/all/background_page/event/appEvents.js +1 -26
  105. package/src/all/background_page/event/authEvents.js +2 -2
  106. package/src/all/background_page/event/configEvents.js +0 -12
  107. package/src/all/background_page/event/folderEvents.js +5 -4
  108. package/src/all/background_page/event/informCallToActionEvents.js +3 -2
  109. package/src/all/background_page/event/informMenuEvents.js +2 -2
  110. package/src/all/background_page/event/mfaEvents.js +38 -1
  111. package/src/all/background_page/event/quickAccessEvents.js +12 -0
  112. package/src/all/background_page/event/resourceEvents.js +9 -5
  113. package/src/all/background_page/event/themeEvents.js +9 -21
  114. package/src/all/background_page/index.js +16 -0
  115. package/src/all/background_page/model/auth/authModel.js +3 -3
  116. package/src/all/background_page/model/auth/authModel.test.js +2 -2
  117. package/src/all/background_page/model/entity/export/exportResourcesFileEntity.js +2 -0
  118. package/src/all/background_page/model/entity/export/exportResourcesFileEntity.test.js +1 -0
  119. package/src/all/background_page/model/entity/folder/foldersCollection.js +13 -9
  120. package/src/all/background_page/model/entity/folder/foldersCollection.test.data.js +35 -0
  121. package/src/all/background_page/model/entity/folder/foldersCollection.test.js +60 -0
  122. package/src/all/background_page/model/entity/import/importResourcesFileEntity.test.data.js +5 -0
  123. package/src/all/background_page/model/entity/mfa/mfaEnabledProviderEntity.js +11 -0
  124. package/src/all/background_page/model/entity/mfa/mfaEnabledProviderEntity.test.js +13 -0
  125. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.js +126 -0
  126. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.test.data.js +26 -0
  127. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.test.js +105 -0
  128. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.js +52 -0
  129. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.test.data.js +22 -0
  130. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.test.js +60 -0
  131. package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.js +45 -0
  132. package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.test.data.js +17 -0
  133. package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.test.js +48 -0
  134. package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.js +235 -0
  135. package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.test.data.js +42 -0
  136. package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.test.js +152 -0
  137. package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.js +72 -0
  138. package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.test.data.js +26 -0
  139. package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.test.js +83 -0
  140. package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.js +121 -0
  141. package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.test.data.js +36 -0
  142. package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.test.js +100 -0
  143. package/src/all/background_page/model/entity/permission/change/permissionChangesCollection.js +0 -59
  144. package/src/all/background_page/model/entity/permission/change/permissionChangesCollection.test.js +0 -333
  145. package/src/all/background_page/model/entity/sso/ssoLoginUrlEntity.js +1 -1
  146. package/src/all/background_page/model/entity/theme/themeEntity.test.data.js +12 -0
  147. package/src/all/background_page/model/entity/theme/themesCollection.test.data.js +10 -1
  148. package/src/all/background_page/model/entity/userAndGroupSearchResultEntity/userAndGroupSearchResultEntity.js +1 -1
  149. package/src/all/background_page/model/entity/userAndGroupSearchResultEntity/userAndGroupSearchResultEntity.test.js +19 -1
  150. package/src/all/background_page/model/export/resources/csvRowComposer/abstractRowComposer.js +8 -0
  151. package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.js +67 -0
  152. package/src/all/background_page/model/export/resources/csvRowComposer/csvNetwrixRowComposer.test.js +37 -0
  153. package/src/all/background_page/model/export/resources/resourcesCsvExporter.js +5 -2
  154. package/src/all/background_page/model/export/resources/resourcesCsvExporter.test.js +3 -1
  155. package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.js +98 -0
  156. package/src/all/background_page/model/import/resources/csvRowParser/csvNetwrixRowParser.test.js +145 -0
  157. package/src/all/background_page/model/import/resources/resourcesCsvImportParser.js +2 -0
  158. package/src/all/background_page/model/import/resources/resourcesCsvImportParser.test.js +19 -1
  159. package/src/all/background_page/model/keyring.test.js +1 -1
  160. package/src/all/background_page/model/multiFactorAuthentication/multiFactorAuthenticationModel.test.js +1 -1
  161. package/src/all/background_page/model/user/userModel.test.js +1 -1
  162. package/src/all/background_page/model/user.js +2 -2
  163. package/src/all/background_page/model/userSettings/userSettings.js +1 -1
  164. package/src/all/background_page/pagemod/accountRecoveryBootstrapPagemod.test.js +1 -1
  165. package/src/all/background_page/pagemod/appBootstrapPagemod.js +8 -6
  166. package/src/all/background_page/pagemod/appBootstrapPagemod.test.js +15 -20
  167. package/src/all/background_page/pagemod/authBootstrapPagemod.js +2 -2
  168. package/src/all/background_page/pagemod/authBootstrapPagemod.test.js +7 -8
  169. package/src/all/background_page/pagemod/pagemod.js +3 -1
  170. package/src/all/background_page/pagemod/pagemod.test.js +1 -1
  171. package/src/all/background_page/pagemod/pagemodManager.test.js +14 -20
  172. package/src/all/background_page/pagemod/publicWebsiteSignInPagemod.test.js +1 -1
  173. package/src/all/background_page/pagemod/recoverBootstrapPagemod.test.js +1 -1
  174. package/src/all/background_page/pagemod/setupBootstrapPagemod.test.js +1 -1
  175. package/src/all/background_page/pagemod/webIntegrationPagemod.js +2 -2
  176. package/src/all/background_page/pagemod/webIntegrationPagemod.test.js +10 -10
  177. package/src/all/background_page/sdk/port/portManager.js +13 -1
  178. package/src/all/background_page/sdk/port/portManager.test.js +98 -0
  179. package/src/all/background_page/service/accountRecovery/decryptPrivateKeyPasswordDataService.js +1 -1
  180. package/src/all/background_page/service/accountRecovery/decryptResponseDataService.js +1 -1
  181. package/src/all/background_page/service/accountRecovery/parseAccountRecoveryUrlService.js +1 -1
  182. package/src/all/background_page/service/accountRecovery/validateOrganizationPublicKeyService.test.js +1 -1
  183. package/src/all/background_page/service/activeSession/{findAndUpdateActiveSessionLocalStorageService.js → findAndUpdateActiveSessionSessionStorageService.js} +27 -60
  184. package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionSessionStorageService.test.js +720 -0
  185. package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.js +8 -8
  186. package/src/all/background_page/service/activeSession/getOrFindActiveSessionService.test.js +16 -16
  187. package/src/all/background_page/service/api/accountSettings/accountSettingsService.js +0 -29
  188. package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.data.js +0 -6
  189. package/src/all/background_page/service/api/accountSettings/accountSettingsService.test.js +1 -32
  190. package/src/all/background_page/service/api/actionLog/actionLogApiService.test.js +1 -1
  191. package/src/all/background_page/service/api/comment/commentApiService.test.js +1 -1
  192. package/src/all/background_page/service/api/metadata/metadataKeysApiService.test.js +1 -1
  193. package/src/all/background_page/service/api/mfa/webauthnApiService.js +76 -0
  194. package/src/all/background_page/service/api/mfa/webauthnApiService.test.js +119 -0
  195. package/src/all/background_page/service/api/mfa/webauthnSettingsApiService.js +44 -0
  196. package/src/all/background_page/service/api/mfa/webauthnSettingsApiService.test.js +56 -0
  197. package/src/all/background_page/service/api/sessionKey/sessionKeysBundlesApiService.test.js +1 -1
  198. package/src/all/background_page/service/api/theme/themesApiService.js +57 -0
  199. package/src/all/background_page/service/api/theme/themesApiService.test.js +83 -0
  200. package/src/all/background_page/service/app/parseAppUrlService.js +18 -10
  201. package/src/all/background_page/service/app/parseAppUrlService.test.js +21 -21
  202. package/src/all/background_page/service/auth/localLogoutService.js +42 -0
  203. package/src/all/background_page/service/auth/localLogoutService.test.js +43 -0
  204. package/src/all/background_page/service/auth/offlineLogoutService.js +47 -0
  205. package/src/all/background_page/service/auth/offlineLogoutService.test.js +46 -0
  206. package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.js +2 -2
  207. package/src/all/background_page/service/auth/offlineSessionExpiryAlarmService.test.js +3 -3
  208. package/src/all/background_page/service/auth/parseAuthUrlService.js +11 -6
  209. package/src/all/background_page/service/auth/parseAuthUrlService.test.js +11 -13
  210. package/src/all/background_page/service/auth/postLoginOfflineService.js +3 -3
  211. package/src/all/background_page/service/auth/postLoginOfflineService.test.js +3 -3
  212. package/src/all/background_page/service/auth/postLoginService.js +5 -4
  213. package/src/all/background_page/service/auth/postLoginService.test.js +4 -4
  214. package/src/all/background_page/service/auth/postLogoutService.js +2 -1
  215. package/src/all/background_page/service/auth/postLogoutService.test.js +24 -1
  216. package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.js +8 -4
  217. package/src/all/background_page/service/auth/startLoopAuthSessionCheckService.test.js +36 -13
  218. package/src/all/background_page/service/authenticationStatusService.test.js +1 -1
  219. package/src/all/background_page/service/clipboard/clipboardProviderService.js +0 -7
  220. package/src/all/background_page/service/clipboard/clipboardProviderService.test.js +0 -10
  221. package/src/all/background_page/service/clipboard/copyToClipboardService.js +1 -5
  222. package/src/all/background_page/service/crypto/decryptSsoPassphraseService.js +1 -1
  223. package/src/all/background_page/service/extension/onExtensionUpdateAvailableService.test.js +2 -6
  224. package/src/all/background_page/service/extension/onStartUpService.js +2 -2
  225. package/src/all/background_page/service/extension/onStartUpService.test.js +3 -3
  226. package/src/all/background_page/service/group/groupUpdateSecretsCryptoService.js +1 -1
  227. package/src/all/background_page/service/group/groupUpdateService.js +1 -1
  228. package/src/all/background_page/service/group/groupUpdateService.test.js +3 -3
  229. package/src/all/background_page/service/localStorage/localStorageService.js +6 -2
  230. package/src/all/background_page/service/localStorage/localStorageService.test.js +31 -14
  231. package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.js +40 -0
  232. package/src/all/background_page/service/local_storage/sessionTimestampsLocalStorage.test.js +63 -0
  233. package/src/all/background_page/service/metadata/rotateMetadata/rotateMetadataKeyService.test.js +2 -2
  234. package/src/all/background_page/service/metadata/rotateMetadata/rotateResourcesMetadataKeyService.test.js +2 -2
  235. package/src/all/background_page/service/mfa/validateWebauthnCreationOptionsService.js +41 -0
  236. package/src/all/background_page/service/mfa/validateWebauthnCreationOptionsService.test.js +52 -0
  237. package/src/all/background_page/service/mfa/webauthnSetupCeremonyService.js +266 -0
  238. package/src/all/background_page/service/mfa/webauthnSetupCeremonyService.test.js +437 -0
  239. package/src/all/background_page/service/migrateMetadata/migrateMetadataResourcesService.test.js +2 -2
  240. package/src/all/background_page/service/move/deserializeConfirmedMovePermissions.js +41 -0
  241. package/src/all/background_page/service/move/deserializeConfirmedMovePermissions.test.js +80 -0
  242. package/src/all/background_page/service/move/moveOneFolderService.js +88 -135
  243. package/src/all/background_page/service/move/moveOneFolderService.test.js +774 -5237
  244. package/src/all/background_page/service/move/moveResourcesService.js +68 -40
  245. package/src/all/background_page/service/move/moveResourcesService.test.data.js +53 -0
  246. package/src/all/background_page/service/move/moveResourcesService.test.js +559 -2090
  247. package/src/all/background_page/service/offline/canUseOfflineStorageService.js +16 -1
  248. package/src/all/background_page/service/offline/canUseOfflineStorageService.test.js +14 -6
  249. package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.js +6 -2
  250. package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.test.js +33 -1
  251. package/src/all/background_page/service/offline/offlineRetentionDataFlushService.js +12 -9
  252. package/src/all/background_page/service/offline/offlineRetentionDataFlushService.test.js +35 -24
  253. package/src/all/background_page/service/permission/calculatePermissionsChangesService.js +172 -0
  254. package/src/all/background_page/service/permission/calculatePermissionsChangesService.test.js +370 -0
  255. package/src/all/background_page/service/rbac/getOrFindRbacService.js +6 -2
  256. package/src/all/background_page/service/recover/parseRecoverUrlService.js +1 -1
  257. package/src/all/background_page/service/resource/export/exportResourcesService.test.js +3 -0
  258. package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.js +30 -10
  259. package/src/all/background_page/service/resource/getOrFindOfflineResourcesService.test.js +108 -9
  260. package/src/all/background_page/service/resource/getOrFindResourcesService.js +30 -10
  261. package/src/all/background_page/service/resource/getOrFindResourcesService.test.js +99 -9
  262. package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.js +6 -2
  263. package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.test.js +29 -2
  264. package/src/all/background_page/service/secret/decryptAndParseResourceSecretService.js +1 -1
  265. package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.js +62 -0
  266. package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.test.js +60 -0
  267. package/src/all/background_page/service/sessionStorage/workersSessionStorage.js +30 -0
  268. package/src/all/background_page/service/sessionStorage/workersSessionStorage.test.js +55 -0
  269. package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.js +48 -0
  270. package/src/all/background_page/service/sessionTimestamps/getSessionTimestampsService.test.js +66 -0
  271. package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.js +102 -0
  272. package/src/all/background_page/service/sessionTimestamps/updateSessionTimestampsService.test.js +221 -0
  273. package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.js → session_storage/activeSessionSessionStorage.js} +17 -17
  274. package/src/all/background_page/service/{local_storage/activeSessionLocalStorage.test.js → session_storage/activeSessionSessionStorage.test.js} +31 -34
  275. package/src/all/background_page/service/setup/parseSetupUrlService.js +3 -2
  276. package/src/all/background_page/service/setup/parseSetupUrlService.test.js +195 -24
  277. package/src/all/background_page/service/share/shareFoldersService.js +20 -36
  278. package/src/all/background_page/service/share/shareFoldersService.test.js +240 -4
  279. package/src/all/background_page/service/share/shareResourceService.test.js +4 -4
  280. package/src/all/background_page/service/tab/tabService.js +3 -2
  281. package/src/all/background_page/service/theme/findThemesService.js +38 -0
  282. package/src/all/background_page/service/theme/findThemesService.test.js +63 -0
  283. package/src/all/background_page/service/theme/updateThemeService.js +39 -0
  284. package/src/all/background_page/service/theme/updateThemeService.test.js +65 -0
  285. package/src/all/background_page/service/toolbar/toolbarService.js +33 -15
  286. package/src/all/background_page/service/toolbar/toolbarService.test.js +82 -6
  287. package/src/all/background_page/service/ui/browserTab.service.js +6 -4
  288. package/src/all/background_page/service/ui/browserTab.service.test.js +19 -6
  289. package/src/all/background_page/service/user/getOrFindMeService.js +6 -2
  290. package/src/all/background_page/service/user/getOrFindMeService.test.js +27 -2
  291. package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.js +11 -6
  292. package/src/all/background_page/service/webIntegration/parseWebIntegrationUrlService.test.js +7 -9
  293. package/src/all/background_page/service/worker/workerService.js +42 -11
  294. package/src/all/background_page/service/worker/workerService.test.js +70 -2
  295. package/src/all/background_page/utils/format/formDataUtils.test.js +1 -1
  296. package/src/all/background_page/utils/openpgp/openpgpAssertions.js +1 -1
  297. package/src/all/contentScripts/js/app/App.js +2 -0
  298. package/src/all/contentScripts/js/controller/abortWebauthnSetupCeremonyContentScriptController.js +62 -0
  299. package/src/all/contentScripts/js/controller/abortWebauthnSetupCeremonyContentScriptController.test.js +44 -0
  300. package/src/all/contentScripts/js/controller/runWebauthnSetupCeremonyContentScriptController.js +65 -0
  301. package/src/all/contentScripts/js/controller/runWebauthnSetupCeremonyContentScriptController.test.js +70 -0
  302. package/src/all/contentScripts/js/event/webauthnSetupCeremonyEvents.js +33 -0
  303. package/src/all/contentScripts/js/service/webauthnSetupCeremonyContentScriptService.js +154 -0
  304. package/src/all/contentScripts/js/service/webauthnSetupCeremonyContentScriptService.test.js +252 -0
  305. package/src/all/locales/en-UK/common.json +0 -1
  306. package/src/all/webAccessibleResources/js/lib/port.js +106 -10
  307. package/src/all/webAccessibleResources/js/lib/port.test.js +174 -1
  308. package/src/all/webAccessibleResources/js/themes/stylesheet.js +1 -1
  309. package/src/chrome-mv3/index.js +6 -0
  310. package/src/chrome-mv3/manifest.json +3 -4
  311. package/src/chrome-mv3/serviceWorker/service/network/requestFetchOffscreenService.js +1 -1
  312. package/src/chrome-mv3/serviceWorker/service/network/responseFetchOffscreenService.js +7 -4
  313. package/src/firefox/manifest.json +2 -3
  314. package/src/safari/background_page/index.js +2 -1
  315. package/src/safari/background_page/service/cookies/cookiesService.js +9 -3
  316. package/src/safari/background_page/service/cookies/cookiesService.test.js +28 -1
  317. package/src/safari/manifest.json +2 -3
  318. package/test/matchers/toBeOpenpgpKeySignedBy.js +13 -14
  319. package/test/mocks/mockJsDomPolyfill.js +0 -2
  320. package/test/mocks/mockWebExtensionPolyfill.js +2 -4
  321. package/webpack/common-blocks.js +13 -13
  322. package/webpack/expectedBuildArtifacts.js +1 -1
  323. package/webpack/passboltEnvPlugin.js +1 -1
  324. package/webpack.common.config.js +2 -0
  325. package/webpack.config.js +4 -5
  326. package/webpack.safari-background-page.config.js +38 -31
  327. package/src/all/background_page/model/theme/themeModel.js +0 -66
  328. package/src/all/background_page/model/theme/themeModel.test.js +0 -73
  329. package/src/all/background_page/service/activeSession/findAndUpdateActiveSessionLocalStorageService.test.js +0 -776
  330. package/src/all/background_page/service/move/calculatePermissionsChangesForMoveService.js +0 -113
  331. package/src/all/background_page/service/move/calculatePermissionsChangesForMoveService.test.js +0 -158
  332. package/src/all/background_page/service/move/confirmMoveStrategyService.js +0 -42
  333. package/src/all/background_page/service/move/confirmMoveStrategyService.test.js +0 -67
  334. package/src/chrome/manifest.json +0 -52
  335. package/src/chrome/polyfill/clipboard/edgeBackgroundPageClipboardService.test.js +0 -53
  336. package/webpack.chromium-mv2.config.js +0 -40
  337. /package/src/all/background_page/service/{move/calculatePermissionsChangesForMoveService.test.data.js → permission/calculatePermissionsChangesService.test.data.js} +0 -0
@@ -0,0 +1,83 @@
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
+ import { enableFetchMocks } from "jest-fetch-mock";
15
+ import { mockApiResponse, mockApiResponseError } from "../../../../../../test/mocks/mockApiResponse";
16
+ import { defaultApiClientOptions } from "passbolt-styleguide/src/shared/lib/apiClient/apiClientOptions.test.data";
17
+ import PassboltApiFetchError from "passbolt-styleguide/src/shared/lib/Error/PassboltApiFetchError";
18
+ import ThemesApiService from "./themesApiService";
19
+ import ChangeThemeEntity from "../../../model/entity/theme/change/ChangeThemeEntity";
20
+ import { defaultThemeCollectionDtos } from "../../../model/entity/theme/themesCollection.test.data";
21
+ import { accountSettingsService_midgarThemeDto } from "../accountSettings/accountSettingsService.test.data";
22
+
23
+ beforeEach(() => {
24
+ enableFetchMocks();
25
+ jest.clearAllMocks();
26
+ });
27
+
28
+ describe("ThemesApiService", () => {
29
+ let service;
30
+
31
+ beforeEach(() => {
32
+ service = new ThemesApiService(defaultApiClientOptions());
33
+ });
34
+
35
+ it("has the correct resource name", () => {
36
+ expect.assertions(1);
37
+ expect(ThemesApiService.RESOURCE_NAME).toEqual("account/settings/themes");
38
+ });
39
+
40
+ describe("ThemesApiService::findAll", () => {
41
+ it("gets the themes and returns the body", async () => {
42
+ expect.assertions(2);
43
+ const dtos = defaultThemeCollectionDtos();
44
+ fetch.doMockOnceIf(/account\/settings\/themes\.json/, async (req) => {
45
+ expect(req.method).toEqual("GET");
46
+ return mockApiResponse(dtos);
47
+ });
48
+ const body = await service.findAll();
49
+ expect(body).toEqual(dtos);
50
+ });
51
+
52
+ it("throws on API error", async () => {
53
+ expect.assertions(1);
54
+ fetch.doMockOnceIf(/account\/settings\/themes\.json/, () => mockApiResponseError(500, "Something went wrong"));
55
+ await expect(service.findAll()).rejects.toThrow(PassboltApiFetchError);
56
+ });
57
+ });
58
+
59
+ describe("ThemesApiService::update", () => {
60
+ it("posts the theme name and returns the body", async () => {
61
+ expect.assertions(3);
62
+ const dto = accountSettingsService_midgarThemeDto();
63
+ fetch.doMockOnceIf(/account\/settings\/themes\.json/, async (req) => {
64
+ expect(req.method).toEqual("POST");
65
+ expect(await req.json()).toEqual({ value: "midgar" });
66
+ return mockApiResponse(dto);
67
+ });
68
+ const body = await service.update(new ChangeThemeEntity({ name: "midgar" }));
69
+ expect(body).toEqual(dto);
70
+ });
71
+
72
+ it("throws if the parameter is not a ChangeThemeEntity", async () => {
73
+ expect.assertions(1);
74
+ await expect(service.update({ name: "midgar" })).rejects.toThrow(TypeError);
75
+ });
76
+
77
+ it("throws on API error", async () => {
78
+ expect.assertions(1);
79
+ fetch.doMockOnceIf(/account\/settings\/themes\.json/, () => mockApiResponseError(500, "Something went wrong"));
80
+ await expect(service.update(new ChangeThemeEntity({ name: "midgar" }))).rejects.toThrow(PassboltApiFetchError);
81
+ });
82
+ });
83
+ });
@@ -1,3 +1,6 @@
1
+ import { assertString, assertType } from "../../utils/assertions";
2
+ import AccountEntity from "../../model/entity/account/accountEntity";
3
+
1
4
  /**
2
5
  * Passbolt ~ Open source password manager for teams
3
6
  * Copyright (c) 2022 Passbolt SA (https://www.passbolt.com)
@@ -11,27 +14,29 @@
11
14
  * @link https://www.passbolt.com Passbolt(tm)
12
15
  * @since 3.6.0
13
16
  */
14
- import User from "../../model/user";
15
-
16
17
  class ParseAppUrlService {
17
18
  /**
18
19
  * Get regex to check URI validity
20
+ * @param {AccountEntity} account The account
19
21
  * @returns {string}
20
22
  */
21
- static getRegex() {
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 `^${escapedDomain}/?(/app.*)?(#.*)?$`;
25
27
  }
26
28
 
27
29
  /**
28
30
  * Parse url to match .
31
+ * @param {AccountEntity} account The account
29
32
  * @param {string} url The url to parse.
30
33
  * @returns {{domain: string}}
31
34
  * @throw {Error} If the setup url cannot be parsed.
32
35
  */
33
- static parse(url) {
34
- const regex = new RegExp(this.getRegex());
36
+ static parse(account, url) {
37
+ assertType(account, AccountEntity);
38
+ assertString(url);
39
+ const regex = new RegExp(this.getRegex(account));
35
40
 
36
41
  if (!regex.test(url)) {
37
42
  throw new Error("Cannot parse application url. The url does not match the pattern.");
@@ -43,18 +48,21 @@ class ParseAppUrlService {
43
48
  new URL(url);
44
49
  } catch (error) {
45
50
  console.error(error);
46
- throw new Error("Cannot parse application url. The domain is not valid.");
51
+ throw new Error("Cannot parse application url. The domain is not valid.", { cause: error });
47
52
  }
48
53
  }
49
54
 
50
55
  /**
51
56
  * Test the url against the regex.
57
+ * @param {AccountEntity} account The account
52
58
  * @param {string} url The url to test
53
59
  * @returns {boolean}
54
60
  */
55
- static test(url) {
61
+ static test(account, url) {
56
62
  try {
57
- this.parse(url);
63
+ assertType(account, AccountEntity);
64
+ assertString(url);
65
+ this.parse(account, url);
58
66
  return true;
59
67
  } catch {
60
68
  return false;
@@ -12,29 +12,26 @@
12
12
  * @since 3.6.0
13
13
  */
14
14
 
15
- import { Config } from "../../model/config";
16
15
  import ParseAppUrlService from "./parseAppUrlService";
16
+ import AccountEntity from "../../model/entity/account/accountEntity";
17
+ import { defaultAccountDto } from "../../model/entity/account/accountEntity.test.data";
17
18
 
18
19
  const errorMatchPattern = "Cannot parse application url. The url does not match the pattern.";
19
20
  const errorDomainInvalid = "Cannot parse application url. The domain is not valid.";
20
21
 
21
- const domain = "https://passbolt.dev";
22
-
23
- beforeEach(() => {
24
- Config.write("user.settings.trustedDomain", "https://passbolt.dev");
25
- });
22
+ const domain = "https://passbolt.local";
26
23
 
27
24
  describe("ParseAppUrlService", () => {
28
25
  describe("ParseAppUrlService:parse", () => {
29
26
  describe.each([
30
27
  {
31
28
  scenario: "TLD",
32
- url: "https://passbolt.dev/app/folders/view/5452ecb2-0625-50d1-b1ef-d2038f5830b6",
29
+ url: "https://passbolt.local/app/folders/view/5452ecb2-0625-50d1-b1ef-d2038f5830b6",
33
30
  domain: domain,
34
31
  },
35
32
  {
36
33
  scenario: "TLD with Port",
37
- url: "https://passbolt.dev:4443/app/passwords",
34
+ url: "https://passbolt.local:4443/app/passwords",
38
35
  domain: `${domain}:4443`,
39
36
  },
40
37
  {
@@ -64,7 +61,7 @@ describe("ParseAppUrlService", () => {
64
61
  },
65
62
  {
66
63
  scenario: "Trailing /",
67
- url: "https://passbolt.dev/app/administration/account-recovery//",
64
+ url: "https://passbolt.local/app/administration/account-recovery//",
68
65
  domain: `${domain}/app/administration/account-recovery/`,
69
66
  },
70
67
  {
@@ -78,13 +75,14 @@ describe("ParseAppUrlService", () => {
78
75
  domain: `https://demo.passbolt.com`,
79
76
  },
80
77
  ])("should parse", (_props) => {
78
+ let account;
81
79
  beforeEach(() => {
82
- Config.write("user.settings.trustedDomain", _props.domain);
80
+ account = new AccountEntity(defaultAccountDto({ domain: _props.domain }));
83
81
  });
84
82
  it(`should parse: ${_props.scenario}`, () => {
85
83
  expect.assertions(2);
86
- expect(() => ParseAppUrlService.parse(_props.url)).not.toThrow(errorMatchPattern);
87
- expect(() => ParseAppUrlService.parse(_props.url)).not.toThrow(errorDomainInvalid);
84
+ expect(() => ParseAppUrlService.parse(account, _props.url)).not.toThrow(errorMatchPattern);
85
+ expect(() => ParseAppUrlService.parse(account, _props.url)).not.toThrow(errorDomainInvalid);
88
86
  });
89
87
  });
90
88
 
@@ -95,7 +93,7 @@ describe("ParseAppUrlService", () => {
95
93
  },
96
94
  {
97
95
  scenario: "Wrong protocol",
98
- url: "http://passbolt.dev",
96
+ url: "http://passbolt.local",
99
97
  },
100
98
  {
101
99
  scenario: "Not a domain allowed",
@@ -103,40 +101,42 @@ describe("ParseAppUrlService", () => {
103
101
  },
104
102
  {
105
103
  scenario: "Original domain as subdomain attack",
106
- url: "https://passbolt.dev.attacker.com",
104
+ url: "https://passbolt.local.attacker.com",
107
105
  },
108
106
  {
109
107
  scenario: "Subdomain attack",
110
- url: "https://attack.passbolt.dev",
108
+ url: "https://attack.passbolt.local",
111
109
  },
112
110
  {
113
111
  scenario: "Regex wild mark attack",
114
- url: "https://passboltxdev",
112
+ url: "https://passboltxlocal",
115
113
  },
116
114
  {
117
115
  scenario: "Non application entry point",
118
- url: "https://passbolt.dev/auth/login",
116
+ url: "https://passbolt.local/auth/login",
119
117
  },
120
118
  {
121
119
  scenario: "Domain look alike as hash attack",
122
120
  url: `https://www.attacker.com#${domain}`,
123
121
  },
124
122
  ])("should not parse", (_props) => {
123
+ const account = new AccountEntity(defaultAccountDto());
125
124
  it(`should not parse: ${_props.scenario}`, () => {
126
125
  expect.assertions(1);
127
- expect(() => ParseAppUrlService.parse(_props.url)).toThrow(errorMatchPattern);
126
+ expect(() => ParseAppUrlService.parse(account, _props.url)).toThrow(errorMatchPattern);
128
127
  });
129
128
  });
130
129
  });
131
130
  describe("ParseAppUrlService:getContext", () => {
132
131
  it(`should return regex based on trusted domain`, () => {
133
132
  expect.assertions(1);
134
- expect(ParseAppUrlService.getRegex()).toBe("^https\\:\\/\\/passbolt\\.dev/?(/app.*)?(#.*)?$");
133
+ const account = new AccountEntity(defaultAccountDto());
134
+ expect(ParseAppUrlService.getRegex(account)).toBe("^https\\:\\/\\/passbolt\\.local/?(/app.*)?(#.*)?$");
135
135
  });
136
136
  it(`should escaped characters from domain`, () => {
137
- Config.write("user.settings.trustedDomain", "https://passbolt.dev/#/");
137
+ const account = new AccountEntity(defaultAccountDto({ domain: "https://passbolt.local/#/" }));
138
138
  expect.assertions(1);
139
- expect(ParseAppUrlService.getRegex()).toBe("^https\\:\\/\\/passbolt\\.dev\\/\\#\\//?(/app.*)?(#.*)?$");
139
+ expect(ParseAppUrlService.getRegex(account)).toBe("^https\\:\\/\\/passbolt\\.local\\/\\#\\//?(/app.*)?(#.*)?$");
140
140
  });
141
141
  });
142
142
  });
@@ -0,0 +1,42 @@
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 SessionCookieFlushService from "./sessionCookieFlushService";
16
+ import OfflineLogoutService from "./offlineLogoutService";
17
+
18
+ /**
19
+ * Sign out a user authenticated online when the API is unavailable. The API is not called.
20
+ */
21
+ class LocalLogoutService {
22
+ /**
23
+ * @constructor
24
+ * @param {AccountEntity} account The user account
25
+ * @param {ApiClientOptions} apiClientOptions The api client options
26
+ */
27
+ constructor(account, apiClientOptions) {
28
+ this.sessionCookieFlushService = new SessionCookieFlushService(account);
29
+ this.offlineLogoutService = new OfflineLogoutService(account, apiClientOptions);
30
+ }
31
+
32
+ /**
33
+ * Remove the session cookies, then sign the user out as an offline logout does.
34
+ * @return {Promise<void>}
35
+ */
36
+ async exec() {
37
+ await this.sessionCookieFlushService.flush();
38
+ await this.offlineLogoutService.exec();
39
+ }
40
+ }
41
+
42
+ export default LocalLogoutService;
@@ -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
  );