passbolt-browser-extension 5.16.1 → 5.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -1
- package/RELEASE_NOTES.md +94 -4
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/AppDelegate.swift +3 -3
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/ViewController.swift +10 -10
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/SafariWebExtensionHandler.swift +5 -5
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/AbstractController.swift +5 -5
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/ErrorController.swift +2 -2
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/FetchController.swift +3 -3
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/OpenSafariSettingsController.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/SaveFileController.swift +2 -2
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/WriteClipboardController.swift +3 -3
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/fetch/SecureProfileSessionManager.swift +36 -30
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/fetch/fetchService.swift +24 -24
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/file/SaveFileService.swift +15 -15
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/utils/ErrorSerializer.swift +13 -13
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/utils/LocatedError.swift +3 -3
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/SafariWebExtensionHandlerTests.swift +3 -3
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/AbstractControllerTests.swift +2 -2
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/ErrorControllerTests.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/FetchControllerTests.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/OpenSafariSettingsControllerTests.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/SaveFileControllerTests.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/WriteClipboardControllerTests.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/services/fetch/FetchServiceTests.swift +1 -1
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/services/fetch/SecureProfileSessionManagerTests.swift +7 -7
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/utils/ErrorSerializerTests.swift +17 -17
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/utils/LocatedErrorTests.swift +12 -12
- package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager.xcodeproj/project.pbxproj +2 -4
- package/package.json +10 -7
- package/src/all/background_page/controller/accountRecovery/recoverAccountController.js +4 -0
- package/src/all/background_page/controller/accountRecovery/recoverAccountController.test.js +5 -1
- package/src/all/background_page/controller/informCallToActionController/informCallToActionController.js +4 -2
- package/src/all/background_page/controller/informCallToActionController/informCallToActionController.test.js +4 -2
- package/src/all/background_page/controller/mfaPolicy/mfaGetMfaSettingsController.test.js +13 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupAbortWebauthnCeremonyController.js +52 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupAbortWebauthnCeremonyController.test.js +54 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupBeginWebauthnCeremonyController.js +52 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupBeginWebauthnCeremonyController.test.js +54 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupDeleteWebauthnCredentialController.js +55 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupDeleteWebauthnCredentialController.test.js +55 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupFinishWebauthnCeremonyController.js +54 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupFinishWebauthnCeremonyController.test.js +54 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnCredentialsController.js +54 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnCredentialsController.test.js +61 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnSettingsController.js +53 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnSettingsController.test.js +57 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupHandleWebauthnCeremonyResultController.js +55 -0
- package/src/all/background_page/controller/mfaSetup/MfaSetupHandleWebauthnCeremonyResultController.test.js +52 -0
- package/src/all/background_page/controller/move/moveFolderController.js +12 -12
- package/src/all/background_page/controller/move/moveFolderController.test.js +31 -1
- package/src/all/background_page/controller/move/moveResourcesController.js +18 -5
- package/src/all/background_page/controller/move/moveResourcesController.test.js +68 -7
- package/src/all/background_page/controller/recover/completeRecoverController.js +4 -0
- package/src/all/background_page/controller/recover/completeRecoverController.test.js +5 -1
- package/src/all/background_page/controller/setup/completeSetupController.js +4 -0
- package/src/all/background_page/controller/setup/completeSetupController.test.js +5 -1
- package/src/all/background_page/error/webauthnAlreadyRunningCeremonyError.js +24 -0
- package/src/all/background_page/error/webauthnAuthenticatorAlreadyRegisteredError.js +26 -0
- package/src/all/background_page/error/webauthnCeremonyAbortedError.js +26 -0
- package/src/all/background_page/error/webauthnCeremonyCancelledError.js +26 -0
- package/src/all/background_page/error/webauthnCeremonyError.js +26 -0
- package/src/all/background_page/error/webauthnCeremonyNotFoundError.js +26 -0
- package/src/all/background_page/error/webauthnTLSCertificateError.js +24 -0
- package/src/all/background_page/event/appBootstrapEvents.js +32 -0
- package/src/all/background_page/event/appBootstrapEvents.test.js +31 -0
- package/src/all/background_page/event/folderEvents.js +5 -4
- package/src/all/background_page/event/informCallToActionEvents.js +3 -2
- package/src/all/background_page/event/mfaEvents.js +38 -1
- package/src/all/background_page/event/resourceEvents.js +9 -5
- package/src/all/background_page/index.js +16 -0
- package/src/all/background_page/model/entity/folder/foldersCollection.js +13 -9
- package/src/all/background_page/model/entity/folder/foldersCollection.test.data.js +35 -0
- package/src/all/background_page/model/entity/folder/foldersCollection.test.js +60 -0
- package/src/all/background_page/model/entity/mfa/mfaEnabledProviderEntity.js +11 -0
- package/src/all/background_page/model/entity/mfa/mfaEnabledProviderEntity.test.js +13 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.js +126 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.test.data.js +26 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.test.js +105 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.js +52 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.test.data.js +22 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.test.js +60 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.js +45 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.test.data.js +17 -0
- package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.test.js +48 -0
- package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.js +235 -0
- package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.test.data.js +42 -0
- package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.test.js +152 -0
- package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.js +72 -0
- package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.test.data.js +26 -0
- package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.test.js +83 -0
- package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.js +121 -0
- package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.test.data.js +36 -0
- package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.test.js +100 -0
- package/src/all/background_page/model/entity/permission/change/permissionChangesCollection.js +0 -59
- package/src/all/background_page/model/entity/permission/change/permissionChangesCollection.test.js +0 -333
- package/src/all/background_page/model/entity/userAndGroupSearchResultEntity/userAndGroupSearchResultEntity.js +1 -1
- package/src/all/background_page/model/entity/userAndGroupSearchResultEntity/userAndGroupSearchResultEntity.test.js +19 -1
- package/src/all/background_page/pagemod/accountRecoveryBootstrapPagemod.test.js +1 -1
- package/src/all/background_page/pagemod/appBootstrapPagemod.js +2 -1
- package/src/all/background_page/pagemod/appBootstrapPagemod.test.js +8 -8
- package/src/all/background_page/pagemod/authBootstrapPagemod.test.js +1 -1
- package/src/all/background_page/pagemod/pagemod.js +3 -1
- package/src/all/background_page/pagemod/pagemod.test.js +1 -1
- package/src/all/background_page/pagemod/publicWebsiteSignInPagemod.test.js +1 -1
- package/src/all/background_page/pagemod/recoverBootstrapPagemod.test.js +1 -1
- package/src/all/background_page/pagemod/setupBootstrapPagemod.test.js +1 -1
- package/src/all/background_page/pagemod/webIntegrationPagemod.test.js +1 -1
- package/src/all/background_page/sdk/port/portManager.js +13 -1
- package/src/all/background_page/sdk/port/portManager.test.js +98 -0
- package/src/all/background_page/service/api/mfa/webauthnApiService.js +76 -0
- package/src/all/background_page/service/api/mfa/webauthnApiService.test.js +119 -0
- package/src/all/background_page/service/api/mfa/webauthnSettingsApiService.js +44 -0
- package/src/all/background_page/service/api/mfa/webauthnSettingsApiService.test.js +56 -0
- package/src/all/background_page/service/auth/postLoginService.js +2 -1
- package/src/all/background_page/service/auth/postLoginService.test.js +1 -1
- package/src/all/background_page/service/auth/postLogoutService.js +2 -1
- package/src/all/background_page/service/auth/postLogoutService.test.js +24 -1
- package/src/all/background_page/service/extension/onExtensionUpdateAvailableService.test.js +2 -6
- package/src/all/background_page/service/group/groupUpdateSecretsCryptoService.js +1 -1
- package/src/all/background_page/service/group/groupUpdateService.js +1 -1
- package/src/all/background_page/service/group/groupUpdateService.test.js +3 -3
- package/src/all/background_page/service/localStorage/localStorageService.js +2 -0
- package/src/all/background_page/service/localStorage/localStorageService.test.js +3 -2
- package/src/all/background_page/service/mfa/validateWebauthnCreationOptionsService.js +41 -0
- package/src/all/background_page/service/mfa/validateWebauthnCreationOptionsService.test.js +52 -0
- package/src/all/background_page/service/mfa/webauthnSetupCeremonyService.js +266 -0
- package/src/all/background_page/service/mfa/webauthnSetupCeremonyService.test.js +437 -0
- package/src/all/background_page/service/move/deserializeConfirmedMovePermissions.js +41 -0
- package/src/all/background_page/service/move/deserializeConfirmedMovePermissions.test.js +80 -0
- package/src/all/background_page/service/move/moveOneFolderService.js +88 -135
- package/src/all/background_page/service/move/moveOneFolderService.test.js +774 -5237
- package/src/all/background_page/service/move/moveResourcesService.js +68 -40
- package/src/all/background_page/service/move/moveResourcesService.test.data.js +53 -0
- package/src/all/background_page/service/move/moveResourcesService.test.js +559 -2090
- package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.js +2 -1
- package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.test.js +23 -0
- package/src/all/background_page/service/permission/calculatePermissionsChangesService.js +172 -0
- package/src/all/background_page/service/permission/calculatePermissionsChangesService.test.js +370 -0
- package/src/all/background_page/service/rbac/getOrFindRbacService.js +2 -1
- package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.js +2 -1
- package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.test.js +19 -0
- package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.js +62 -0
- package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.test.js +60 -0
- package/src/all/background_page/service/sessionStorage/workersSessionStorage.js +30 -0
- package/src/all/background_page/service/sessionStorage/workersSessionStorage.test.js +55 -0
- package/src/all/background_page/service/share/shareFoldersService.js +20 -36
- package/src/all/background_page/service/share/shareFoldersService.test.js +236 -0
- package/src/all/background_page/service/tab/tabService.js +3 -2
- package/src/all/background_page/service/toolbar/toolbarService.js +13 -5
- package/src/all/background_page/service/ui/browserTab.service.js +6 -4
- package/src/all/background_page/service/ui/browserTab.service.test.js +19 -6
- package/src/all/background_page/service/user/getOrFindMeService.js +2 -1
- package/src/all/background_page/service/user/getOrFindMeService.test.js +17 -0
- package/src/all/background_page/service/worker/workerService.js +42 -11
- package/src/all/background_page/service/worker/workerService.test.js +70 -2
- package/src/all/contentScripts/js/app/App.js +2 -0
- package/src/all/contentScripts/js/controller/abortWebauthnSetupCeremonyContentScriptController.js +62 -0
- package/src/all/contentScripts/js/controller/abortWebauthnSetupCeremonyContentScriptController.test.js +44 -0
- package/src/all/contentScripts/js/controller/runWebauthnSetupCeremonyContentScriptController.js +65 -0
- package/src/all/contentScripts/js/controller/runWebauthnSetupCeremonyContentScriptController.test.js +70 -0
- package/src/all/contentScripts/js/event/webauthnSetupCeremonyEvents.js +33 -0
- package/src/all/contentScripts/js/service/webauthnSetupCeremonyContentScriptService.js +154 -0
- package/src/all/contentScripts/js/service/webauthnSetupCeremonyContentScriptService.test.js +252 -0
- package/src/all/locales/en-UK/common.json +0 -1
- package/src/all/webAccessibleResources/js/lib/port.js +106 -10
- package/src/all/webAccessibleResources/js/lib/port.test.js +174 -1
- package/src/chrome/manifest.json +2 -3
- package/src/chrome-mv3/index.js +6 -0
- package/src/chrome-mv3/manifest.json +3 -4
- package/src/firefox/manifest.json +2 -3
- package/src/safari/background_page/index.js +2 -1
- package/src/safari/background_page/service/cookies/cookiesService.js +9 -3
- package/src/safari/background_page/service/cookies/cookiesService.test.js +28 -1
- package/src/safari/manifest.json +2 -3
- package/test/mocks/mockWebExtensionPolyfill.js +2 -4
- package/src/all/background_page/service/move/calculatePermissionsChangesForMoveService.js +0 -113
- package/src/all/background_page/service/move/calculatePermissionsChangesForMoveService.test.js +0 -158
- package/src/all/background_page/service/move/confirmMoveStrategyService.js +0 -42
- package/src/all/background_page/service/move/confirmMoveStrategyService.test.js +0 -67
- /package/src/all/background_page/service/{move/calculatePermissionsChangesForMoveService.test.data.js → permission/calculatePermissionsChangesService.test.data.js} +0 -0
package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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.17.0
|
|
13
|
+
*/
|
|
14
|
+
import WebauthnSetupCeremonyEntity from "../../model/entity/mfa/webauthnSetupCeremonyEntity";
|
|
15
|
+
import { assertType } from "../../utils/assertions";
|
|
16
|
+
|
|
17
|
+
const WEBAUTHN_SETUP_CEREMONY_KEY = "webauthn-setup-ceremony";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Keeps the pending WebAuthn setup ceremony across service worker restarts.
|
|
21
|
+
*/
|
|
22
|
+
class WebauthnSetupCeremonySessionStorageService {
|
|
23
|
+
/**
|
|
24
|
+
* Get the pending ceremony.
|
|
25
|
+
* @returns {Promise<WebauthnSetupCeremonyEntity|null>}
|
|
26
|
+
*/
|
|
27
|
+
static async get() {
|
|
28
|
+
const storageData = await browser.storage.session.get(WEBAUTHN_SETUP_CEREMONY_KEY);
|
|
29
|
+
const dto = storageData?.[WEBAUTHN_SETUP_CEREMONY_KEY];
|
|
30
|
+
return dto ? new WebauthnSetupCeremonyEntity(dto) : null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Store the pending ceremony, replacing any previous one.
|
|
35
|
+
* @param {WebauthnSetupCeremonyEntity} ceremony
|
|
36
|
+
* @throws {Error} If the ceremony is not a WebauthnSetupCeremonyEntity
|
|
37
|
+
* @returns {Promise<void>}
|
|
38
|
+
*/
|
|
39
|
+
static async set(ceremony) {
|
|
40
|
+
assertType(
|
|
41
|
+
ceremony,
|
|
42
|
+
WebauthnSetupCeremonyEntity,
|
|
43
|
+
"The ceremony is not a WebauthnSetupCeremonyEntity, storage has not been set",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
await navigator.locks.request(WEBAUTHN_SETUP_CEREMONY_KEY, async () => {
|
|
47
|
+
await browser.storage.session.set({ [WEBAUTHN_SETUP_CEREMONY_KEY]: ceremony.toDto() });
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Flush the pending ceremony.
|
|
53
|
+
* @returns {Promise<void>}
|
|
54
|
+
*/
|
|
55
|
+
static async flush() {
|
|
56
|
+
await navigator.locks.request(WEBAUTHN_SETUP_CEREMONY_KEY, async () => {
|
|
57
|
+
await browser.storage.session.remove(WEBAUTHN_SETUP_CEREMONY_KEY);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default WebauthnSetupCeremonySessionStorageService;
|
|
@@ -0,0 +1,60 @@
|
|
|
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.17.0
|
|
13
|
+
*/
|
|
14
|
+
import WebauthnSetupCeremonySessionStorageService from "./webauthnSetupCeremonySessionStorageService";
|
|
15
|
+
import WebauthnSetupCeremonyEntity from "../../model/entity/mfa/webauthnSetupCeremonyEntity";
|
|
16
|
+
import { defaultWebauthnSetupCeremonyDto } from "../../model/entity/mfa/webauthnSetupCeremonyEntity.test.data";
|
|
17
|
+
|
|
18
|
+
describe("WebauthnSetupCeremonySessionStorageService", () => {
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
await browser.storage.session.clear();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("WebauthnSetupCeremonySessionStorageService::get", () => {
|
|
24
|
+
it("returns null when nothing is stored", async () => {
|
|
25
|
+
expect.assertions(1);
|
|
26
|
+
expect(await WebauthnSetupCeremonySessionStorageService.get()).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("WebauthnSetupCeremonySessionStorageService::set", () => {
|
|
31
|
+
it("stores the ceremony and keeps only the last one", async () => {
|
|
32
|
+
expect.assertions(2);
|
|
33
|
+
const ceremony1 = new WebauthnSetupCeremonyEntity(defaultWebauthnSetupCeremonyDto({ tab_id: 1 }));
|
|
34
|
+
const ceremony2 = new WebauthnSetupCeremonyEntity(defaultWebauthnSetupCeremonyDto({ tab_id: 2 }));
|
|
35
|
+
await WebauthnSetupCeremonySessionStorageService.set(ceremony1);
|
|
36
|
+
expect(await WebauthnSetupCeremonySessionStorageService.get()).toEqual(ceremony1);
|
|
37
|
+
await WebauthnSetupCeremonySessionStorageService.set(ceremony2);
|
|
38
|
+
expect(await WebauthnSetupCeremonySessionStorageService.get()).toEqual(ceremony2);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("throws if the ceremony is not a WebauthnSetupCeremonyEntity", async () => {
|
|
42
|
+
expect.assertions(2);
|
|
43
|
+
await expect(WebauthnSetupCeremonySessionStorageService.set(defaultWebauthnSetupCeremonyDto())).rejects.toThrow(
|
|
44
|
+
"The ceremony is not a WebauthnSetupCeremonyEntity, storage has not been set",
|
|
45
|
+
);
|
|
46
|
+
expect(await WebauthnSetupCeremonySessionStorageService.get()).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("WebauthnSetupCeremonySessionStorageService::flush", () => {
|
|
51
|
+
it("removes the stored ceremony", async () => {
|
|
52
|
+
expect.assertions(1);
|
|
53
|
+
await WebauthnSetupCeremonySessionStorageService.set(
|
|
54
|
+
new WebauthnSetupCeremonyEntity(defaultWebauthnSetupCeremonyDto()),
|
|
55
|
+
);
|
|
56
|
+
await WebauthnSetupCeremonySessionStorageService.flush();
|
|
57
|
+
expect(await WebauthnSetupCeremonySessionStorageService.get()).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -112,6 +112,36 @@ class WorkersSessionStorage {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Add a worker, atomically evicting any previous worker of the same name/tab/frame first. A re-injection
|
|
117
|
+
* into a frame supersedes its previous worker; doing the evict + add in a single locked transaction keeps
|
|
118
|
+
* concurrent (re-)injections from each leaving a worker behind (which would let a stale one be picked).
|
|
119
|
+
* @param {WorkerEntity} workerEntity
|
|
120
|
+
* @return {Promise<void>}
|
|
121
|
+
*/
|
|
122
|
+
async addWorkerAndEvictSameFrame(workerEntity) {
|
|
123
|
+
await lock.acquire();
|
|
124
|
+
try {
|
|
125
|
+
this.assertEntityBeforeSave(workerEntity);
|
|
126
|
+
let workers = await this.getWorkers();
|
|
127
|
+
workers = workers.filter(
|
|
128
|
+
(worker) =>
|
|
129
|
+
!(
|
|
130
|
+
worker.name === workerEntity.name &&
|
|
131
|
+
worker.tabId === workerEntity.tabId &&
|
|
132
|
+
worker.frameId === workerEntity.frameId
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
if (this.IsExceedNumberWorkersByTabId(workers, workerEntity.tabId)) {
|
|
136
|
+
throw new Error(`The extension port limit is exceeded on tab ${workerEntity.tabId}`);
|
|
137
|
+
}
|
|
138
|
+
workers.push(workerEntity.toDto());
|
|
139
|
+
await browser.storage.session.set({ workers });
|
|
140
|
+
} finally {
|
|
141
|
+
lock.release();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
115
145
|
/**
|
|
116
146
|
*
|
|
117
147
|
* @param {Object<array>} workers The workers
|
|
@@ -64,6 +64,61 @@ describe("WorkersSessionStorage", () => {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
describe("WorkersSessionStorage::addWorkerAndEvictSameFrame", () => {
|
|
68
|
+
it("Should evict a previous worker of the same name/tab/frame before adding the new one", async () => {
|
|
69
|
+
expect.assertions(2);
|
|
70
|
+
// data mocked
|
|
71
|
+
const previousWorker = new WorkerEntity(readWorker());
|
|
72
|
+
const newWorker = new WorkerEntity(
|
|
73
|
+
readWorker({ name: previousWorker.name, tabId: previousWorker.tabId, frameId: previousWorker.frameId }),
|
|
74
|
+
);
|
|
75
|
+
// process
|
|
76
|
+
await WorkersSessionStorage.addWorker(previousWorker);
|
|
77
|
+
await WorkersSessionStorage.addWorkerAndEvictSameFrame(newWorker);
|
|
78
|
+
// expectations: only the new worker remains on the frame.
|
|
79
|
+
expect(await WorkersSessionStorage.getWorkersByTabId(newWorker.tabId)).toEqual([newWorker.toDto()]);
|
|
80
|
+
expect(await WorkersSessionStorage.getWorkerById(previousWorker.id)).toBeUndefined();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("Should keep workers of a different name/tab/frame untouched", async () => {
|
|
84
|
+
expect.assertions(1);
|
|
85
|
+
// data mocked
|
|
86
|
+
const otherFrame = new WorkerEntity(readWorker({ name: "worker", frameId: 2 }));
|
|
87
|
+
const otherName = new WorkerEntity(readWorker({ name: "worker2", frameId: 0 }));
|
|
88
|
+
const otherTab = new WorkerEntity(readWorker({ name: "worker", tabId: 2, frameId: 0 }));
|
|
89
|
+
const newWorker = new WorkerEntity(readWorker({ name: "worker", tabId: 1, frameId: 0 }));
|
|
90
|
+
// process
|
|
91
|
+
await WorkersSessionStorage.addWorker(otherFrame);
|
|
92
|
+
await WorkersSessionStorage.addWorker(otherName);
|
|
93
|
+
await WorkersSessionStorage.addWorker(otherTab);
|
|
94
|
+
await WorkersSessionStorage.addWorkerAndEvictSameFrame(newWorker);
|
|
95
|
+
// expectations: none of the non-matching workers were evicted.
|
|
96
|
+
expect(await WorkersSessionStorage.getWorkers()).toEqual([
|
|
97
|
+
otherFrame.toDto(),
|
|
98
|
+
otherName.toDto(),
|
|
99
|
+
otherTab.toDto(),
|
|
100
|
+
newWorker.toDto(),
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("Should throw and not add the worker when the tab limit is exceeded", async () => {
|
|
105
|
+
expect.assertions(2);
|
|
106
|
+
// data mocked: fill the tab to the limit with same-frame workers so the evict frees exactly one slot.
|
|
107
|
+
for (let i = 0; i < 100; i++) {
|
|
108
|
+
await WorkersSessionStorage.addWorker(new WorkerEntity(readWorker({ name: `worker${i}`, frameId: i })));
|
|
109
|
+
}
|
|
110
|
+
const newWorker = new WorkerEntity(readWorker({ name: "workerNew", frameId: 500 }));
|
|
111
|
+
// process
|
|
112
|
+
try {
|
|
113
|
+
await WorkersSessionStorage.addWorkerAndEvictSameFrame(newWorker);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
// expectations
|
|
116
|
+
expect(error.message).toStrictEqual("The extension port limit is exceeded on tab 1");
|
|
117
|
+
expect(await WorkersSessionStorage.getWorkerById(newWorker.id)).toBeUndefined();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
67
122
|
describe("WorkersSessionStorage::updateWorker", () => {
|
|
68
123
|
it("Should update a worker if present", async () => {
|
|
69
124
|
expect.assertions(2);
|
|
@@ -23,8 +23,8 @@ import ShareResourceService from "./shareResourceService";
|
|
|
23
23
|
import FindAndUpdateFoldersLocalStorageService from "../folder/findAndUpdateFoldersLocalStorageService";
|
|
24
24
|
import ResourcesCollection from "../../model/entity/resource/resourcesCollection";
|
|
25
25
|
import GetOrFindFoldersService from "../folder/getOrFindFoldersService";
|
|
26
|
-
import FoldersCollection from "../../model/entity/folder/foldersCollection";
|
|
27
26
|
import GetOrFindResourcesService from "../resource/getOrFindResourcesService";
|
|
27
|
+
import CalculatePermissionsChangesService from "../permission/calculatePermissionsChangesService";
|
|
28
28
|
|
|
29
29
|
export const PROGRESS_STEPS_SHARE_FOLDERS_SHARE_ONE = 1;
|
|
30
30
|
|
|
@@ -52,8 +52,6 @@ class ShareFoldersService {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Share a folder and its descendant.
|
|
55
|
-
* Note: When implementing shareAll, note that some parts of the algorithm require access to the original permissions
|
|
56
|
-
* of the folder that was target of the share.
|
|
57
55
|
* @param {string} folderId The folder id to share
|
|
58
56
|
* @param {PermissionChangesCollection} permissionsChanges The permission changes
|
|
59
57
|
* @param {string} passphrase The user's private key passphrase
|
|
@@ -68,17 +66,18 @@ class ShareFoldersService {
|
|
|
68
66
|
);
|
|
69
67
|
assertString(passphrase, 'The parameter "passphrase" should be a string');
|
|
70
68
|
|
|
71
|
-
const
|
|
72
|
-
|
|
69
|
+
const folders = await this.getOrFindFoldersService.getOrFindAll();
|
|
70
|
+
// Each branch stops at the first folder the operator does not own, including what it holds.
|
|
71
|
+
const foldersDescendant = folders.getOwnedDescendantsStoppingAtNotOwned(folderId);
|
|
72
|
+
const foldersToShareWithPermissions = await this.findFoldersToShareWithPermissions(folderId, foldersDescendant);
|
|
73
|
+
const resourcesToShareWithPermissions = await this.findResourcesToShareWithPermissions(folderId, foldersDescendant);
|
|
73
74
|
const folderPermissionsChanges = this.calculateFoldersPermissionChanges(
|
|
74
75
|
folderId,
|
|
75
76
|
permissionsChanges,
|
|
76
77
|
foldersToShareWithPermissions,
|
|
77
78
|
);
|
|
78
79
|
const resourcesPermissionChanges = this.calculateResourcesPermissionChanges(
|
|
79
|
-
folderId,
|
|
80
80
|
permissionsChanges,
|
|
81
|
-
foldersToShareWithPermissions,
|
|
82
81
|
resourcesToShareWithPermissions,
|
|
83
82
|
);
|
|
84
83
|
await this.saveFoldersPermissionsChanges(folderPermissionsChanges);
|
|
@@ -98,15 +97,14 @@ class ShareFoldersService {
|
|
|
98
97
|
* A folder is impacted by the share if it is the folder that is shared or a folder descendant for which the user
|
|
99
98
|
* has ownership.
|
|
100
99
|
* @param {string} folderId The folder id to share
|
|
100
|
+
* @param {FoldersCollection} foldersDescendant The owned folders below, each branch stopping at the
|
|
101
|
+
* first folder the operator does not own.
|
|
101
102
|
* @returns {Promise<FoldersCollection>}
|
|
102
103
|
* @private
|
|
103
104
|
*/
|
|
104
|
-
async findFoldersToShareWithPermissions(folderId) {
|
|
105
|
+
async findFoldersToShareWithPermissions(folderId, foldersDescendant) {
|
|
105
106
|
this.progressService.finishStep(i18n.t("Retrieving folders permissions"), true);
|
|
106
|
-
const
|
|
107
|
-
const foldersDescendant = FoldersCollection.getAllChildren(folderId, folders, new FoldersCollection([]));
|
|
108
|
-
const foldersDescendantWithOwnership = foldersDescendant.filterByIsOwner();
|
|
109
|
-
const foldersIdsToRetrievePermissions = [folderId, ...foldersDescendantWithOwnership.ids];
|
|
107
|
+
const foldersIdsToRetrievePermissions = [folderId, ...foldersDescendant.ids];
|
|
110
108
|
|
|
111
109
|
return this.findFoldersService.findAllByIdsWithPermissions(foldersIdsToRetrievePermissions);
|
|
112
110
|
}
|
|
@@ -115,13 +113,13 @@ class ShareFoldersService {
|
|
|
115
113
|
* Retrieve the resources to share with their permissions.
|
|
116
114
|
* A resource is impacted by the share if it is a folder descendant for which the user has ownership.
|
|
117
115
|
* @param {string} folderId The folder id to share
|
|
116
|
+
* @param {FoldersCollection} foldersDescendant The owned folders below, each branch stopping at the
|
|
117
|
+
* first folder the operator does not own.
|
|
118
118
|
* @returns {Promise<ResourcesCollection>}
|
|
119
119
|
* @private
|
|
120
120
|
*/
|
|
121
|
-
async findResourcesToShareWithPermissions(folderId) {
|
|
121
|
+
async findResourcesToShareWithPermissions(folderId, foldersDescendant) {
|
|
122
122
|
this.progressService.finishStep(i18n.t("Retrieving resources permissions"), true);
|
|
123
|
-
const folders = await this.getOrFindFoldersService.getOrFindAll();
|
|
124
|
-
const foldersDescendant = FoldersCollection.getAllChildren(folderId, folders, new FoldersCollection([]));
|
|
125
123
|
const resourcesDescendant = await this.getOrFindResourcesService.getOrFindAll();
|
|
126
124
|
resourcesDescendant.filterByPropertyValueIn("folder_parent_id", [folderId, ...foldersDescendant.ids]);
|
|
127
125
|
const resourcesDescendantWithOwnership = resourcesDescendant.filterByIsOwner();
|
|
@@ -135,7 +133,8 @@ class ShareFoldersService {
|
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
/**
|
|
138
|
-
*
|
|
136
|
+
* The changes to apply to the folders below: each receives the change made on the shared folder.
|
|
137
|
+
* One left with no permission or no owner is skipped, the rest of the cascade still applies.
|
|
139
138
|
* @param {string} folderTargetId The folder originally target of the share.
|
|
140
139
|
* @param {PermissionChangesCollection} permissionsChanges The permission changes
|
|
141
140
|
* @param {FoldersCollection} foldersToShare The folders to share, with their permissions.
|
|
@@ -146,7 +145,6 @@ class ShareFoldersService {
|
|
|
146
145
|
this.progressService.finishStep(i18n.t("Calculating folders permissions changes"), true);
|
|
147
146
|
|
|
148
147
|
const foldersPermissionChanges = new PermissionChangesCollection([]);
|
|
149
|
-
const folderTargetOriginalPermissions = foldersToShare.getById(folderTargetId).permissions;
|
|
150
148
|
|
|
151
149
|
// Add the user requested changes to the collection of permissions changes to apply to the folders.
|
|
152
150
|
foldersPermissionChanges.merge(permissionsChanges);
|
|
@@ -157,13 +155,7 @@ class ShareFoldersService {
|
|
|
157
155
|
continue;
|
|
158
156
|
}
|
|
159
157
|
foldersPermissionChanges.merge(
|
|
160
|
-
|
|
161
|
-
folderToShare.permission.aco,
|
|
162
|
-
folderToShare.id,
|
|
163
|
-
folderToShare.permissions,
|
|
164
|
-
permissionsChanges,
|
|
165
|
-
folderTargetOriginalPermissions,
|
|
166
|
-
),
|
|
158
|
+
CalculatePermissionsChangesService.forFolderWithCascadedChange(folderToShare, permissionsChanges),
|
|
167
159
|
);
|
|
168
160
|
}
|
|
169
161
|
|
|
@@ -171,28 +163,20 @@ class ShareFoldersService {
|
|
|
171
163
|
}
|
|
172
164
|
|
|
173
165
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
166
|
+
* The changes to apply to the resources below: each receives the change made on the shared
|
|
167
|
+
* folder. One left with no permission or no owner is skipped, the rest of the cascade applies.
|
|
176
168
|
* @param {PermissionChangesCollection} permissionsChanges The permission changes
|
|
177
|
-
* @param {FoldersCollection} foldersToShare The folders to share, with their permissions.
|
|
178
169
|
* @param {ResourcesCollection} resourcesToShare The resources to share, with their permissions.
|
|
179
170
|
* @return {PermissionChangesCollection}
|
|
180
171
|
*/
|
|
181
|
-
calculateResourcesPermissionChanges(
|
|
172
|
+
calculateResourcesPermissionChanges(permissionsChanges, resourcesToShare) {
|
|
182
173
|
this.progressService.finishStep(i18n.t("Calculating resources permissions changes"), true);
|
|
183
174
|
|
|
184
175
|
const resourcesPermissionsChanges = new PermissionChangesCollection([]);
|
|
185
|
-
const folderTargetOriginalPermissions = foldersToShare.getById(folderTargetId).permissions;
|
|
186
176
|
|
|
187
177
|
for (const resourceToShare of resourcesToShare.items) {
|
|
188
178
|
resourcesPermissionsChanges.merge(
|
|
189
|
-
|
|
190
|
-
resourceToShare.permission.aco,
|
|
191
|
-
resourceToShare.id,
|
|
192
|
-
resourceToShare.permissions,
|
|
193
|
-
permissionsChanges,
|
|
194
|
-
folderTargetOriginalPermissions,
|
|
195
|
-
),
|
|
179
|
+
CalculatePermissionsChangesService.forResourceWithCascadedChange(resourceToShare, permissionsChanges),
|
|
196
180
|
);
|
|
197
181
|
}
|
|
198
182
|
|
|
@@ -252,6 +252,242 @@ describe("ShareResourceService", () => {
|
|
|
252
252
|
expect(mockedProgressService.finishStep).toHaveBeenNthCalledWith(6, "Updating folders local storage", true);
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
+
it("aligns a sub folder where the recipient already had a diverging permission", async () => {
|
|
256
|
+
expect.assertions(4);
|
|
257
|
+
const folderIdToShare = uuidv4();
|
|
258
|
+
const subFolderIdToShare = uuidv4();
|
|
259
|
+
|
|
260
|
+
// Carol is granted READ on the shared folder, while she is already OWNER of the sub folder.
|
|
261
|
+
const carolPermissionChange = minimumPermissionDto({
|
|
262
|
+
aco: "Folder",
|
|
263
|
+
aro_foreign_key: pgpKeys.carol.userId,
|
|
264
|
+
aco_foreign_key: folderIdToShare,
|
|
265
|
+
type: 1,
|
|
266
|
+
});
|
|
267
|
+
const permissionChanges = new PermissionChangesCollection([carolPermissionChange]);
|
|
268
|
+
|
|
269
|
+
const folderDto = defaultFolderDto({
|
|
270
|
+
id: folderIdToShare,
|
|
271
|
+
permission: ownerFolderPermissionDto({
|
|
272
|
+
aco_foreign_key: folderIdToShare,
|
|
273
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
274
|
+
}),
|
|
275
|
+
});
|
|
276
|
+
const subFolderDto = defaultFolderDto({
|
|
277
|
+
id: subFolderIdToShare,
|
|
278
|
+
folder_parent_id: folderIdToShare,
|
|
279
|
+
permission: ownerFolderPermissionDto({
|
|
280
|
+
aco_foreign_key: subFolderIdToShare,
|
|
281
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
282
|
+
}),
|
|
283
|
+
});
|
|
284
|
+
const carolSubFolderPermission = ownerFolderPermissionDto({
|
|
285
|
+
aco_foreign_key: subFolderIdToShare,
|
|
286
|
+
aro_foreign_key: pgpKeys.carol.userId,
|
|
287
|
+
});
|
|
288
|
+
jest
|
|
289
|
+
.spyOn(service.getOrFindFoldersService, "getOrFindAll")
|
|
290
|
+
.mockImplementation(() => new FoldersCollection([folderDto, subFolderDto]));
|
|
291
|
+
jest
|
|
292
|
+
.spyOn(service.getOrFindResourcesService, "getOrFindAll")
|
|
293
|
+
.mockImplementation(() => new ResourcesCollection([]));
|
|
294
|
+
jest
|
|
295
|
+
.spyOn(service.findFoldersService, "findAllByIdsWithPermissions")
|
|
296
|
+
.mockImplementation(
|
|
297
|
+
() =>
|
|
298
|
+
new FoldersCollection([
|
|
299
|
+
defaultFolderDto({ ...folderDto, permissions: [folderDto.permission] }),
|
|
300
|
+
defaultFolderDto({ ...subFolderDto, permissions: [subFolderDto.permission, carolSubFolderPermission] }),
|
|
301
|
+
]),
|
|
302
|
+
);
|
|
303
|
+
jest
|
|
304
|
+
.spyOn(service.findResourcesService, "findAllByIdsWithPermissions")
|
|
305
|
+
.mockImplementation(() => new ResourcesCollection([]));
|
|
306
|
+
|
|
307
|
+
let shareRequest2Data;
|
|
308
|
+
jest.spyOn(service.shareApiService, "shareFolder").mockImplementation((folderId, data) => {
|
|
309
|
+
if (folderId === subFolderIdToShare) {
|
|
310
|
+
shareRequest2Data = data;
|
|
311
|
+
}
|
|
312
|
+
return {};
|
|
313
|
+
});
|
|
314
|
+
jest.spyOn(service.findAndUpdateFoldersLocalStorageService, "findAndUpdateAll").mockImplementation(jest.fn);
|
|
315
|
+
|
|
316
|
+
await service.shareOneWithContent(folderDto.id, permissionChanges, pgpKeys.admin.passphrase);
|
|
317
|
+
|
|
318
|
+
// Carol is owner of the sub folder and drops to the read granted on the parent, she is not left as she is.
|
|
319
|
+
expect(shareRequest2Data.permissions).toHaveLength(1);
|
|
320
|
+
const subFolderChange = shareRequest2Data.permissions[0].toDto();
|
|
321
|
+
expect(subFolderChange.id).toEqual(carolSubFolderPermission.id);
|
|
322
|
+
expect(subFolderChange.aro_foreign_key).toEqual(pgpKeys.carol.userId);
|
|
323
|
+
expect(subFolderChange.type).toEqual(1);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("leaves a sub folder the cascade would strip of its last owner untouched, and aligns the rest of the branch", async () => {
|
|
327
|
+
expect.assertions(4);
|
|
328
|
+
const folderIdToShare = uuidv4();
|
|
329
|
+
const subFolderIdSkipped = uuidv4();
|
|
330
|
+
const subFolderIdAligned = uuidv4();
|
|
331
|
+
const groupId = uuidv4();
|
|
332
|
+
|
|
333
|
+
// The group is downgraded to READ on the shared folder.
|
|
334
|
+
const groupFolderPermission = ownerFolderPermissionDto({
|
|
335
|
+
aco_foreign_key: folderIdToShare,
|
|
336
|
+
aro: "Group",
|
|
337
|
+
aro_foreign_key: groupId,
|
|
338
|
+
});
|
|
339
|
+
const groupPermissionChange = defaultPermissionDto({
|
|
340
|
+
id: groupFolderPermission.id,
|
|
341
|
+
aco: "Folder",
|
|
342
|
+
aco_foreign_key: folderIdToShare,
|
|
343
|
+
aro: "Group",
|
|
344
|
+
aro_foreign_key: groupId,
|
|
345
|
+
type: 1,
|
|
346
|
+
});
|
|
347
|
+
const permissionChanges = new PermissionChangesCollection([groupPermissionChange]);
|
|
348
|
+
|
|
349
|
+
const folderDto = defaultFolderDto({
|
|
350
|
+
id: folderIdToShare,
|
|
351
|
+
permission: ownerFolderPermissionDto({
|
|
352
|
+
aco_foreign_key: folderIdToShare,
|
|
353
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
354
|
+
}),
|
|
355
|
+
});
|
|
356
|
+
// The group is the only owner of the first sub folder, so lowering it there would leave nobody
|
|
357
|
+
// as owner and it keeps what it has. The branch goes on: the folder below still gets the change.
|
|
358
|
+
const subFolderSkippedDto = defaultFolderDto({
|
|
359
|
+
id: subFolderIdSkipped,
|
|
360
|
+
folder_parent_id: folderIdToShare,
|
|
361
|
+
permission: ownerFolderPermissionDto({
|
|
362
|
+
aco_foreign_key: subFolderIdSkipped,
|
|
363
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
364
|
+
}),
|
|
365
|
+
});
|
|
366
|
+
const groupSubFolderSkippedPermission = ownerFolderPermissionDto({
|
|
367
|
+
aco_foreign_key: subFolderIdSkipped,
|
|
368
|
+
aro: "Group",
|
|
369
|
+
aro_foreign_key: groupId,
|
|
370
|
+
});
|
|
371
|
+
const subFolderAlignedDto = defaultFolderDto({
|
|
372
|
+
id: subFolderIdAligned,
|
|
373
|
+
folder_parent_id: subFolderIdSkipped,
|
|
374
|
+
permission: ownerFolderPermissionDto({
|
|
375
|
+
aco_foreign_key: subFolderIdAligned,
|
|
376
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
377
|
+
}),
|
|
378
|
+
});
|
|
379
|
+
const groupSubFolderAlignedPermission = ownerFolderPermissionDto({
|
|
380
|
+
aco_foreign_key: subFolderIdAligned,
|
|
381
|
+
aro: "Group",
|
|
382
|
+
aro_foreign_key: groupId,
|
|
383
|
+
});
|
|
384
|
+
jest
|
|
385
|
+
.spyOn(service.getOrFindFoldersService, "getOrFindAll")
|
|
386
|
+
.mockImplementation(() => new FoldersCollection([folderDto, subFolderSkippedDto, subFolderAlignedDto]));
|
|
387
|
+
jest
|
|
388
|
+
.spyOn(service.getOrFindResourcesService, "getOrFindAll")
|
|
389
|
+
.mockImplementation(() => new ResourcesCollection([]));
|
|
390
|
+
jest.spyOn(service.findFoldersService, "findAllByIdsWithPermissions").mockImplementation(
|
|
391
|
+
() =>
|
|
392
|
+
new FoldersCollection([
|
|
393
|
+
defaultFolderDto({ ...folderDto, permissions: [folderDto.permission, groupFolderPermission] }),
|
|
394
|
+
defaultFolderDto({ ...subFolderSkippedDto, permissions: [groupSubFolderSkippedPermission] }),
|
|
395
|
+
defaultFolderDto({
|
|
396
|
+
...subFolderAlignedDto,
|
|
397
|
+
permissions: [subFolderAlignedDto.permission, groupSubFolderAlignedPermission],
|
|
398
|
+
}),
|
|
399
|
+
]),
|
|
400
|
+
);
|
|
401
|
+
jest
|
|
402
|
+
.spyOn(service.findResourcesService, "findAllByIdsWithPermissions")
|
|
403
|
+
.mockImplementation(() => new ResourcesCollection([]));
|
|
404
|
+
|
|
405
|
+
const shareRequests = new Map();
|
|
406
|
+
jest.spyOn(service.shareApiService, "shareFolder").mockImplementation((folderId, data) => {
|
|
407
|
+
shareRequests.set(folderId, data);
|
|
408
|
+
return {};
|
|
409
|
+
});
|
|
410
|
+
jest.spyOn(service.findAndUpdateFoldersLocalStorageService, "findAndUpdateAll").mockImplementation(jest.fn);
|
|
411
|
+
|
|
412
|
+
await service.shareOneWithContent(folderDto.id, permissionChanges, pgpKeys.admin.passphrase);
|
|
413
|
+
|
|
414
|
+
expect([...shareRequests.keys()]).toEqual([folderIdToShare, subFolderIdAligned]);
|
|
415
|
+
const alignedPermissions = shareRequests.get(subFolderIdAligned).permissions;
|
|
416
|
+
expect(alignedPermissions).toHaveLength(1);
|
|
417
|
+
const alignedChange = alignedPermissions[0].toDto();
|
|
418
|
+
expect(alignedChange.aro_foreign_key).toEqual(groupId);
|
|
419
|
+
expect(alignedChange.type).toEqual(1);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it("stops the cascade at a sub folder the operator does not own", async () => {
|
|
423
|
+
expect.assertions(2);
|
|
424
|
+
const folderIdToShare = uuidv4();
|
|
425
|
+
const notOwnedSubFolderId = uuidv4();
|
|
426
|
+
const nestedFolderId = uuidv4();
|
|
427
|
+
|
|
428
|
+
const carolPermissionChange = minimumPermissionDto({
|
|
429
|
+
aco: "Folder",
|
|
430
|
+
aro_foreign_key: pgpKeys.carol.userId,
|
|
431
|
+
aco_foreign_key: folderIdToShare,
|
|
432
|
+
type: 1,
|
|
433
|
+
});
|
|
434
|
+
const permissionChanges = new PermissionChangesCollection([carolPermissionChange]);
|
|
435
|
+
|
|
436
|
+
const folderDto = defaultFolderDto({
|
|
437
|
+
id: folderIdToShare,
|
|
438
|
+
permission: ownerFolderPermissionDto({
|
|
439
|
+
aco_foreign_key: folderIdToShare,
|
|
440
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
441
|
+
}),
|
|
442
|
+
});
|
|
443
|
+
// The operator only has update here, so the branch stops and the folder it holds is left alone.
|
|
444
|
+
const notOwnedSubFolderDto = defaultFolderDto({
|
|
445
|
+
id: notOwnedSubFolderId,
|
|
446
|
+
folder_parent_id: folderIdToShare,
|
|
447
|
+
permission: defaultPermissionDto({
|
|
448
|
+
aco: "Folder",
|
|
449
|
+
aco_foreign_key: notOwnedSubFolderId,
|
|
450
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
451
|
+
type: 7,
|
|
452
|
+
}),
|
|
453
|
+
});
|
|
454
|
+
const nestedFolderDto = defaultFolderDto({
|
|
455
|
+
id: nestedFolderId,
|
|
456
|
+
folder_parent_id: notOwnedSubFolderId,
|
|
457
|
+
permission: ownerFolderPermissionDto({
|
|
458
|
+
aco_foreign_key: nestedFolderId,
|
|
459
|
+
aro_foreign_key: pgpKeys.admin.userId,
|
|
460
|
+
}),
|
|
461
|
+
});
|
|
462
|
+
jest
|
|
463
|
+
.spyOn(service.getOrFindFoldersService, "getOrFindAll")
|
|
464
|
+
.mockImplementation(() => new FoldersCollection([folderDto, notOwnedSubFolderDto, nestedFolderDto]));
|
|
465
|
+
jest
|
|
466
|
+
.spyOn(service.getOrFindResourcesService, "getOrFindAll")
|
|
467
|
+
.mockImplementation(() => new ResourcesCollection([]));
|
|
468
|
+
const findAllByIdsWithPermissions = jest
|
|
469
|
+
.spyOn(service.findFoldersService, "findAllByIdsWithPermissions")
|
|
470
|
+
.mockImplementation(
|
|
471
|
+
() => new FoldersCollection([defaultFolderDto({ ...folderDto, permissions: [folderDto.permission] })]),
|
|
472
|
+
);
|
|
473
|
+
jest
|
|
474
|
+
.spyOn(service.findResourcesService, "findAllByIdsWithPermissions")
|
|
475
|
+
.mockImplementation(() => new ResourcesCollection([]));
|
|
476
|
+
|
|
477
|
+
const sharedFolderIds = [];
|
|
478
|
+
jest.spyOn(service.shareApiService, "shareFolder").mockImplementation((folderId) => {
|
|
479
|
+
sharedFolderIds.push(folderId);
|
|
480
|
+
return {};
|
|
481
|
+
});
|
|
482
|
+
jest.spyOn(service.findAndUpdateFoldersLocalStorageService, "findAndUpdateAll").mockImplementation(jest.fn);
|
|
483
|
+
|
|
484
|
+
await service.shareOneWithContent(folderDto.id, permissionChanges, pgpKeys.admin.passphrase);
|
|
485
|
+
|
|
486
|
+
// The owned folder sitting under the not-owned one is never even retrieved.
|
|
487
|
+
expect(findAllByIdsWithPermissions).toHaveBeenCalledWith([folderIdToShare]);
|
|
488
|
+
expect(sharedFolderIds).toEqual([folderIdToShare]);
|
|
489
|
+
});
|
|
490
|
+
|
|
255
491
|
it("shares a folder, its sub folder and any resources the users has owner right on", async () => {
|
|
256
492
|
expect.assertions(7);
|
|
257
493
|
const folderIdToShare = uuidv4();
|
|
@@ -48,8 +48,9 @@ class TabService {
|
|
|
48
48
|
if (!(tab?.url?.startsWith("http://") || tab?.url?.startsWith("https://"))) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
await navigator.locks.request(tab.url, async () => {
|
|
52
|
+
await TabService.handleNavigation(tabId, tab.url);
|
|
53
|
+
});
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
/**
|
|
@@ -23,6 +23,9 @@ import GetOrFindOfflineResourcesService from "../resource/getOrFindOfflineResour
|
|
|
23
23
|
|
|
24
24
|
export const QUICKACCESS_POPUP_URL = "webAccessibleResources/quickaccess.html?passbolt=quickaccess";
|
|
25
25
|
|
|
26
|
+
// picking the right API between browser.browserAction (MV2 only) and browser.action (MV3 only)
|
|
27
|
+
const browserAction = browser.browserAction ?? browser.action;
|
|
28
|
+
|
|
26
29
|
class ToolbarService {
|
|
27
30
|
constructor() {
|
|
28
31
|
this.bindCallbacks();
|
|
@@ -124,8 +127,6 @@ class ToolbarService {
|
|
|
124
127
|
/**
|
|
125
128
|
* Handles click on the icon in the toolbar.
|
|
126
129
|
* The event is called by the browser only if no quickaccess popup URL is set (neither from the manifest nor in script).
|
|
127
|
-
* The popup is set when clicking the first and if an account is configured, otherwise this handler always triggers a tab open.
|
|
128
|
-
* note: Only used for Safari right now
|
|
129
130
|
*/
|
|
130
131
|
async handleIconToolbarClicked() {
|
|
131
132
|
const user = User.getInstance();
|
|
@@ -135,9 +136,16 @@ class ToolbarService {
|
|
|
135
136
|
return;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
// if the user account is set, sets the popup to the expected URL and open it.
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
// if the user account is set, sets the QA popup to the expected URL and open it.
|
|
140
|
+
this.setQuickaccessPopup();
|
|
141
|
+
browserAction?.openPopup(); // 'openPopup' is not available in Edge
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Sets the Quickaccess popup with the default popup URL to open to.
|
|
146
|
+
*/
|
|
147
|
+
setQuickaccessPopup() {
|
|
148
|
+
browserAction.setPopup({ popup: QUICKACCESS_POPUP_URL });
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
/**
|