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.
Files changed (180) hide show
  1. package/CHANGELOG.md +105 -1
  2. package/RELEASE_NOTES.md +94 -4
  3. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/AppDelegate.swift +3 -3
  4. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager/ViewController.swift +10 -10
  5. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/SafariWebExtensionHandler.swift +5 -5
  6. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/AbstractController.swift +5 -5
  7. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/ErrorController.swift +2 -2
  8. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/FetchController.swift +3 -3
  9. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/OpenSafariSettingsController.swift +1 -1
  10. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/SaveFileController.swift +2 -2
  11. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/controllers/WriteClipboardController.swift +3 -3
  12. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/fetch/SecureProfileSessionManager.swift +36 -30
  13. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/fetch/fetchService.swift +24 -24
  14. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/services/file/SaveFileService.swift +15 -15
  15. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/utils/ErrorSerializer.swift +13 -13
  16. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Extension/utils/LocatedError.swift +3 -3
  17. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/SafariWebExtensionHandlerTests.swift +3 -3
  18. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/AbstractControllerTests.swift +2 -2
  19. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/ErrorControllerTests.swift +1 -1
  20. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/FetchControllerTests.swift +1 -1
  21. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/OpenSafariSettingsControllerTests.swift +1 -1
  22. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/SaveFileControllerTests.swift +1 -1
  23. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/controllers/WriteClipboardControllerTests.swift +1 -1
  24. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/services/fetch/FetchServiceTests.swift +1 -1
  25. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/services/fetch/SecureProfileSessionManagerTests.swift +7 -7
  26. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/utils/ErrorSerializerTests.swift +17 -17
  27. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager Tests/utils/LocatedErrorTests.swift +12 -12
  28. package/build-safari-extension/Passbolt-Safari-Extension/Passbolt - password manager.xcodeproj/project.pbxproj +2 -4
  29. package/package.json +10 -7
  30. package/src/all/background_page/controller/accountRecovery/recoverAccountController.js +4 -0
  31. package/src/all/background_page/controller/accountRecovery/recoverAccountController.test.js +5 -1
  32. package/src/all/background_page/controller/informCallToActionController/informCallToActionController.js +4 -2
  33. package/src/all/background_page/controller/informCallToActionController/informCallToActionController.test.js +4 -2
  34. package/src/all/background_page/controller/mfaPolicy/mfaGetMfaSettingsController.test.js +13 -0
  35. package/src/all/background_page/controller/mfaSetup/MfaSetupAbortWebauthnCeremonyController.js +52 -0
  36. package/src/all/background_page/controller/mfaSetup/MfaSetupAbortWebauthnCeremonyController.test.js +54 -0
  37. package/src/all/background_page/controller/mfaSetup/MfaSetupBeginWebauthnCeremonyController.js +52 -0
  38. package/src/all/background_page/controller/mfaSetup/MfaSetupBeginWebauthnCeremonyController.test.js +54 -0
  39. package/src/all/background_page/controller/mfaSetup/MfaSetupDeleteWebauthnCredentialController.js +55 -0
  40. package/src/all/background_page/controller/mfaSetup/MfaSetupDeleteWebauthnCredentialController.test.js +55 -0
  41. package/src/all/background_page/controller/mfaSetup/MfaSetupFinishWebauthnCeremonyController.js +54 -0
  42. package/src/all/background_page/controller/mfaSetup/MfaSetupFinishWebauthnCeremonyController.test.js +54 -0
  43. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnCredentialsController.js +54 -0
  44. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnCredentialsController.test.js +61 -0
  45. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnSettingsController.js +53 -0
  46. package/src/all/background_page/controller/mfaSetup/MfaSetupGetWebauthnSettingsController.test.js +57 -0
  47. package/src/all/background_page/controller/mfaSetup/MfaSetupHandleWebauthnCeremonyResultController.js +55 -0
  48. package/src/all/background_page/controller/mfaSetup/MfaSetupHandleWebauthnCeremonyResultController.test.js +52 -0
  49. package/src/all/background_page/controller/move/moveFolderController.js +12 -12
  50. package/src/all/background_page/controller/move/moveFolderController.test.js +31 -1
  51. package/src/all/background_page/controller/move/moveResourcesController.js +18 -5
  52. package/src/all/background_page/controller/move/moveResourcesController.test.js +68 -7
  53. package/src/all/background_page/controller/recover/completeRecoverController.js +4 -0
  54. package/src/all/background_page/controller/recover/completeRecoverController.test.js +5 -1
  55. package/src/all/background_page/controller/setup/completeSetupController.js +4 -0
  56. package/src/all/background_page/controller/setup/completeSetupController.test.js +5 -1
  57. package/src/all/background_page/error/webauthnAlreadyRunningCeremonyError.js +24 -0
  58. package/src/all/background_page/error/webauthnAuthenticatorAlreadyRegisteredError.js +26 -0
  59. package/src/all/background_page/error/webauthnCeremonyAbortedError.js +26 -0
  60. package/src/all/background_page/error/webauthnCeremonyCancelledError.js +26 -0
  61. package/src/all/background_page/error/webauthnCeremonyError.js +26 -0
  62. package/src/all/background_page/error/webauthnCeremonyNotFoundError.js +26 -0
  63. package/src/all/background_page/error/webauthnTLSCertificateError.js +24 -0
  64. package/src/all/background_page/event/appBootstrapEvents.js +32 -0
  65. package/src/all/background_page/event/appBootstrapEvents.test.js +31 -0
  66. package/src/all/background_page/event/folderEvents.js +5 -4
  67. package/src/all/background_page/event/informCallToActionEvents.js +3 -2
  68. package/src/all/background_page/event/mfaEvents.js +38 -1
  69. package/src/all/background_page/event/resourceEvents.js +9 -5
  70. package/src/all/background_page/index.js +16 -0
  71. package/src/all/background_page/model/entity/folder/foldersCollection.js +13 -9
  72. package/src/all/background_page/model/entity/folder/foldersCollection.test.data.js +35 -0
  73. package/src/all/background_page/model/entity/folder/foldersCollection.test.js +60 -0
  74. package/src/all/background_page/model/entity/mfa/mfaEnabledProviderEntity.js +11 -0
  75. package/src/all/background_page/model/entity/mfa/mfaEnabledProviderEntity.test.js +13 -0
  76. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.js +126 -0
  77. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.test.data.js +26 -0
  78. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialEntity.test.js +105 -0
  79. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.js +52 -0
  80. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.test.data.js +22 -0
  81. package/src/all/background_page/model/entity/mfa/mfaWebauthnCredentialsCollection.test.js +60 -0
  82. package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.js +45 -0
  83. package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.test.data.js +17 -0
  84. package/src/all/background_page/model/entity/mfa/mfaWebauthnSettingsEntity.test.js +48 -0
  85. package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.js +235 -0
  86. package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.test.data.js +42 -0
  87. package/src/all/background_page/model/entity/mfa/webauthnCredentialCreationOptionsEntity.test.js +152 -0
  88. package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.js +72 -0
  89. package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.test.data.js +26 -0
  90. package/src/all/background_page/model/entity/mfa/webauthnRegistrationResponseEntity.test.js +83 -0
  91. package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.js +121 -0
  92. package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.test.data.js +36 -0
  93. package/src/all/background_page/model/entity/mfa/webauthnSetupCeremonyEntity.test.js +100 -0
  94. package/src/all/background_page/model/entity/permission/change/permissionChangesCollection.js +0 -59
  95. package/src/all/background_page/model/entity/permission/change/permissionChangesCollection.test.js +0 -333
  96. package/src/all/background_page/model/entity/userAndGroupSearchResultEntity/userAndGroupSearchResultEntity.js +1 -1
  97. package/src/all/background_page/model/entity/userAndGroupSearchResultEntity/userAndGroupSearchResultEntity.test.js +19 -1
  98. package/src/all/background_page/pagemod/accountRecoveryBootstrapPagemod.test.js +1 -1
  99. package/src/all/background_page/pagemod/appBootstrapPagemod.js +2 -1
  100. package/src/all/background_page/pagemod/appBootstrapPagemod.test.js +8 -8
  101. package/src/all/background_page/pagemod/authBootstrapPagemod.test.js +1 -1
  102. package/src/all/background_page/pagemod/pagemod.js +3 -1
  103. package/src/all/background_page/pagemod/pagemod.test.js +1 -1
  104. package/src/all/background_page/pagemod/publicWebsiteSignInPagemod.test.js +1 -1
  105. package/src/all/background_page/pagemod/recoverBootstrapPagemod.test.js +1 -1
  106. package/src/all/background_page/pagemod/setupBootstrapPagemod.test.js +1 -1
  107. package/src/all/background_page/pagemod/webIntegrationPagemod.test.js +1 -1
  108. package/src/all/background_page/sdk/port/portManager.js +13 -1
  109. package/src/all/background_page/sdk/port/portManager.test.js +98 -0
  110. package/src/all/background_page/service/api/mfa/webauthnApiService.js +76 -0
  111. package/src/all/background_page/service/api/mfa/webauthnApiService.test.js +119 -0
  112. package/src/all/background_page/service/api/mfa/webauthnSettingsApiService.js +44 -0
  113. package/src/all/background_page/service/api/mfa/webauthnSettingsApiService.test.js +56 -0
  114. package/src/all/background_page/service/auth/postLoginService.js +2 -1
  115. package/src/all/background_page/service/auth/postLoginService.test.js +1 -1
  116. package/src/all/background_page/service/auth/postLogoutService.js +2 -1
  117. package/src/all/background_page/service/auth/postLogoutService.test.js +24 -1
  118. package/src/all/background_page/service/extension/onExtensionUpdateAvailableService.test.js +2 -6
  119. package/src/all/background_page/service/group/groupUpdateSecretsCryptoService.js +1 -1
  120. package/src/all/background_page/service/group/groupUpdateService.js +1 -1
  121. package/src/all/background_page/service/group/groupUpdateService.test.js +3 -3
  122. package/src/all/background_page/service/localStorage/localStorageService.js +2 -0
  123. package/src/all/background_page/service/localStorage/localStorageService.test.js +3 -2
  124. package/src/all/background_page/service/mfa/validateWebauthnCreationOptionsService.js +41 -0
  125. package/src/all/background_page/service/mfa/validateWebauthnCreationOptionsService.test.js +52 -0
  126. package/src/all/background_page/service/mfa/webauthnSetupCeremonyService.js +266 -0
  127. package/src/all/background_page/service/mfa/webauthnSetupCeremonyService.test.js +437 -0
  128. package/src/all/background_page/service/move/deserializeConfirmedMovePermissions.js +41 -0
  129. package/src/all/background_page/service/move/deserializeConfirmedMovePermissions.test.js +80 -0
  130. package/src/all/background_page/service/move/moveOneFolderService.js +88 -135
  131. package/src/all/background_page/service/move/moveOneFolderService.test.js +774 -5237
  132. package/src/all/background_page/service/move/moveResourcesService.js +68 -40
  133. package/src/all/background_page/service/move/moveResourcesService.test.data.js +53 -0
  134. package/src/all/background_page/service/move/moveResourcesService.test.js +559 -2090
  135. package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.js +2 -1
  136. package/src/all/background_page/service/offline/getOrFindOfflineSettingsService.test.js +23 -0
  137. package/src/all/background_page/service/permission/calculatePermissionsChangesService.js +172 -0
  138. package/src/all/background_page/service/permission/calculatePermissionsChangesService.test.js +370 -0
  139. package/src/all/background_page/service/rbac/getOrFindRbacService.js +2 -1
  140. package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.js +2 -1
  141. package/src/all/background_page/service/resourceType/getOrFindResourceTypesService.test.js +19 -0
  142. package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.js +62 -0
  143. package/src/all/background_page/service/sessionStorage/webauthnSetupCeremonySessionStorageService.test.js +60 -0
  144. package/src/all/background_page/service/sessionStorage/workersSessionStorage.js +30 -0
  145. package/src/all/background_page/service/sessionStorage/workersSessionStorage.test.js +55 -0
  146. package/src/all/background_page/service/share/shareFoldersService.js +20 -36
  147. package/src/all/background_page/service/share/shareFoldersService.test.js +236 -0
  148. package/src/all/background_page/service/tab/tabService.js +3 -2
  149. package/src/all/background_page/service/toolbar/toolbarService.js +13 -5
  150. package/src/all/background_page/service/ui/browserTab.service.js +6 -4
  151. package/src/all/background_page/service/ui/browserTab.service.test.js +19 -6
  152. package/src/all/background_page/service/user/getOrFindMeService.js +2 -1
  153. package/src/all/background_page/service/user/getOrFindMeService.test.js +17 -0
  154. package/src/all/background_page/service/worker/workerService.js +42 -11
  155. package/src/all/background_page/service/worker/workerService.test.js +70 -2
  156. package/src/all/contentScripts/js/app/App.js +2 -0
  157. package/src/all/contentScripts/js/controller/abortWebauthnSetupCeremonyContentScriptController.js +62 -0
  158. package/src/all/contentScripts/js/controller/abortWebauthnSetupCeremonyContentScriptController.test.js +44 -0
  159. package/src/all/contentScripts/js/controller/runWebauthnSetupCeremonyContentScriptController.js +65 -0
  160. package/src/all/contentScripts/js/controller/runWebauthnSetupCeremonyContentScriptController.test.js +70 -0
  161. package/src/all/contentScripts/js/event/webauthnSetupCeremonyEvents.js +33 -0
  162. package/src/all/contentScripts/js/service/webauthnSetupCeremonyContentScriptService.js +154 -0
  163. package/src/all/contentScripts/js/service/webauthnSetupCeremonyContentScriptService.test.js +252 -0
  164. package/src/all/locales/en-UK/common.json +0 -1
  165. package/src/all/webAccessibleResources/js/lib/port.js +106 -10
  166. package/src/all/webAccessibleResources/js/lib/port.test.js +174 -1
  167. package/src/chrome/manifest.json +2 -3
  168. package/src/chrome-mv3/index.js +6 -0
  169. package/src/chrome-mv3/manifest.json +3 -4
  170. package/src/firefox/manifest.json +2 -3
  171. package/src/safari/background_page/index.js +2 -1
  172. package/src/safari/background_page/service/cookies/cookiesService.js +9 -3
  173. package/src/safari/background_page/service/cookies/cookiesService.test.js +28 -1
  174. package/src/safari/manifest.json +2 -3
  175. package/test/mocks/mockWebExtensionPolyfill.js +2 -4
  176. package/src/all/background_page/service/move/calculatePermissionsChangesForMoveService.js +0 -113
  177. package/src/all/background_page/service/move/calculatePermissionsChangesForMoveService.test.js +0 -158
  178. package/src/all/background_page/service/move/confirmMoveStrategyService.js +0 -42
  179. package/src/all/background_page/service/move/confirmMoveStrategyService.test.js +0 -67
  180. /package/src/all/background_page/service/{move/calculatePermissionsChangesForMoveService.test.data.js → permission/calculatePermissionsChangesService.test.data.js} +0 -0
@@ -0,0 +1,35 @@
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.16.0
13
+ */
14
+ import { defaultFolderDto } from "passbolt-styleguide/src/shared/models/entity/folder/folderEntity.test.data";
15
+ import {
16
+ ownerPermissionDto,
17
+ readPermissionDto,
18
+ } from "passbolt-styleguide/src/shared/models/entity/permission/permissionEntity.test.data";
19
+ import PermissionEntity from "passbolt-styleguide/src/shared/models/entity/permission/permissionEntity";
20
+
21
+ /**
22
+ * A folder DTO carrying an owner or read permission, for the given id and parent.
23
+ * @param {string} id The folder id.
24
+ * @param {string|null} folderParentId The parent folder id, or null for the root.
25
+ * @param {boolean} isOwner Whether the operator owns the folder.
26
+ * @returns {object}
27
+ */
28
+ export const folderWithOwnershipDto = (id, folderParentId, isOwner) =>
29
+ defaultFolderDto({
30
+ id,
31
+ folder_parent_id: folderParentId,
32
+ permission: isOwner
33
+ ? ownerPermissionDto({ aco: PermissionEntity.ACO_FOLDER, aco_foreign_key: id })
34
+ : readPermissionDto({ aco: PermissionEntity.ACO_FOLDER, aco_foreign_key: id }),
35
+ });
@@ -22,6 +22,7 @@ import {
22
22
  } from "passbolt-styleguide/src/shared/models/entity/permission/permissionEntity.test.data";
23
23
  import { v4 as uuidv4 } from "uuid";
24
24
  import PermissionEntity from "passbolt-styleguide/src/shared/models/entity/permission/permissionEntity";
25
+ import { folderWithOwnershipDto } from "./foldersCollection.test.data";
25
26
 
26
27
  describe("Folders collection entity", () => {
27
28
  it("schema must validate", () => {
@@ -404,4 +405,63 @@ describe("Folders collection entity", () => {
404
405
  expect(filteredResources.ids).toEqual([folder1Id, folder4Id]);
405
406
  });
406
407
  });
408
+
409
+ describe("::getOwnedDescendantsStoppingAtNotOwned", () => {
410
+ it("collects every descendant when the whole branch is owned", () => {
411
+ expect.assertions(2);
412
+
413
+ const rootId = uuidv4();
414
+ const childId = uuidv4();
415
+ const grandchildId = uuidv4();
416
+ const folders = new FoldersCollection([
417
+ folderWithOwnershipDto(rootId, null, true),
418
+ folderWithOwnershipDto(childId, rootId, true),
419
+ folderWithOwnershipDto(grandchildId, childId, true),
420
+ ]);
421
+
422
+ const result = folders.getOwnedDescendantsStoppingAtNotOwned(rootId);
423
+
424
+ expect(result).toHaveLength(2);
425
+ expect(result.ids.sort()).toEqual([childId, grandchildId].sort());
426
+ });
427
+
428
+ it("excludes a not-owned folder and everything nested beneath it, even folders the operator owns", () => {
429
+ expect.assertions(2);
430
+
431
+ const rootId = uuidv4();
432
+ const notOwnedChildId = uuidv4();
433
+ const ownedGrandchildId = uuidv4();
434
+ const folders = new FoldersCollection([
435
+ folderWithOwnershipDto(rootId, null, true),
436
+ folderWithOwnershipDto(notOwnedChildId, rootId, false),
437
+ // Owned, but sitting under a folder the operator does not own. The branch already stopped there.
438
+ folderWithOwnershipDto(ownedGrandchildId, notOwnedChildId, true),
439
+ ]);
440
+
441
+ const result = folders.getOwnedDescendantsStoppingAtNotOwned(rootId);
442
+
443
+ expect(result).toHaveLength(0);
444
+ expect(result.ids).not.toContain(ownedGrandchildId);
445
+ });
446
+
447
+ it("gates per branch: a not-owned branch does not affect a sibling owned branch", () => {
448
+ expect.assertions(2);
449
+
450
+ const rootId = uuidv4();
451
+ const notOwnedBranchId = uuidv4();
452
+ const ownedBranchId = uuidv4();
453
+ const ownedBranchChildId = uuidv4();
454
+ const folders = new FoldersCollection([
455
+ folderWithOwnershipDto(rootId, null, true),
456
+ folderWithOwnershipDto(notOwnedBranchId, rootId, false),
457
+ folderWithOwnershipDto(ownedBranchId, rootId, true),
458
+ folderWithOwnershipDto(ownedBranchChildId, ownedBranchId, true),
459
+ ]);
460
+
461
+ const result = folders.getOwnedDescendantsStoppingAtNotOwned(rootId);
462
+
463
+ expect(result.ids.sort()).toEqual([ownedBranchId, ownedBranchChildId].sort());
464
+ expect(result.ids).not.toContain(notOwnedBranchId);
465
+ });
466
+ });
407
467
  });
@@ -46,6 +46,9 @@ class MfaEnabledProviderEntity extends Entity {
46
46
  duo: {
47
47
  type: "boolean",
48
48
  },
49
+ webauthn: {
50
+ type: "boolean",
51
+ },
49
52
  },
50
53
  };
51
54
  }
@@ -80,6 +83,14 @@ class MfaEnabledProviderEntity extends Entity {
80
83
  return this._props.duo;
81
84
  }
82
85
 
86
+ /**
87
+ * get the webauthn prop
88
+ * @returns {boolean|undefined}
89
+ */
90
+ get webauthn() {
91
+ return this._props.webauthn;
92
+ }
93
+
83
94
  /*
84
95
  * ==================================================
85
96
  * Static properties getters
@@ -31,6 +31,19 @@ describe("MfaEnabledProvider entity", () => {
31
31
  expect(entity.duo).toEqual(dto.duo);
32
32
  });
33
33
 
34
+ it("constructor keeps the webauthn flag when provided", () => {
35
+ const dto = createMfaCombinedEnabledProviders({ webauthn: true });
36
+ const entity = new MfaEnabledProviderEntity(dto);
37
+
38
+ expect(entity.webauthn).toBe(true);
39
+ });
40
+
41
+ it("constructor works without the webauthn flag", () => {
42
+ const entity = new MfaEnabledProviderEntity(createMfaCombinedEnabledProviders());
43
+
44
+ expect(entity.webauthn).toBeUndefined();
45
+ });
46
+
34
47
  it("constructor returns validation error if dto required fields are missing", () => {
35
48
  try {
36
49
  new MfaEnabledProviderEntity({});
@@ -0,0 +1,126 @@
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 EntityV2 from "passbolt-styleguide/src/shared/models/entity/abstract/entityV2";
15
+ import { AAGUID_PATTERN } from "./webauthnSetupCeremonyEntity";
16
+
17
+ /**
18
+ * A WebAuthn credential registered by the user as MFA provider.
19
+ */
20
+ class MfaWebauthnCredentialEntity extends EntityV2 {
21
+ /**
22
+ * Get the entity schema
23
+ * @returns {Object} schema
24
+ */
25
+ static getSchema() {
26
+ return {
27
+ type: "object",
28
+ required: ["id", "credential_id", "aaguid", "name", "sign_count", "created", "modified"],
29
+ properties: {
30
+ id: {
31
+ type: "string",
32
+ format: "uuid",
33
+ },
34
+ credential_id: {
35
+ type: "string",
36
+ minLength: 1,
37
+ },
38
+ aaguid: {
39
+ type: "string",
40
+ pattern: AAGUID_PATTERN,
41
+ nullable: true,
42
+ },
43
+ name: {
44
+ type: "string",
45
+ maxLength: 255,
46
+ nullable: true,
47
+ },
48
+ sign_count: {
49
+ type: "integer",
50
+ minimum: 0,
51
+ },
52
+ last_used: {
53
+ type: "string",
54
+ format: "date-time",
55
+ nullable: true,
56
+ },
57
+ created: {
58
+ type: "string",
59
+ format: "date-time",
60
+ },
61
+ modified: {
62
+ type: "string",
63
+ format: "date-time",
64
+ },
65
+ },
66
+ };
67
+ }
68
+
69
+ /**
70
+ * @returns {string}
71
+ */
72
+ get id() {
73
+ return this._props.id;
74
+ }
75
+
76
+ /**
77
+ * @returns {string}
78
+ */
79
+ get credentialId() {
80
+ return this._props.credential_id;
81
+ }
82
+
83
+ /**
84
+ * @returns {string|null}
85
+ */
86
+ get aaguid() {
87
+ return this._props.aaguid || null;
88
+ }
89
+
90
+ /**
91
+ * @returns {string|null}
92
+ */
93
+ get name() {
94
+ return this._props.name || null;
95
+ }
96
+
97
+ /**
98
+ * @returns {number}
99
+ */
100
+ get signCount() {
101
+ return this._props.sign_count;
102
+ }
103
+
104
+ /**
105
+ * @returns {string|null}
106
+ */
107
+ get lastUsed() {
108
+ return this._props.last_used || null;
109
+ }
110
+
111
+ /**
112
+ * @returns {string}
113
+ */
114
+ get created() {
115
+ return this._props.created;
116
+ }
117
+
118
+ /**
119
+ * @returns {string}
120
+ */
121
+ get modified() {
122
+ return this._props.modified;
123
+ }
124
+ }
125
+
126
+ export default MfaWebauthnCredentialEntity;
@@ -0,0 +1,26 @@
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 { v4 as uuidv4 } from "uuid";
15
+
16
+ export const defaultMfaWebauthnCredentialDto = (data = {}) => ({
17
+ id: uuidv4(),
18
+ credential_id: "AZv1kKjbTxOX8BRWmQE1bPQmnPX5Gm0ARgqVGaM_UZo",
19
+ aaguid: "adce0002-35bc-c60a-648b-0b25f1f05503",
20
+ name: "My passkey",
21
+ sign_count: 3,
22
+ last_used: "2026-09-10T10:00:00+00:00",
23
+ created: "2026-09-01T10:00:00+00:00",
24
+ modified: "2026-09-10T10:00:00+00:00",
25
+ ...data,
26
+ });
@@ -0,0 +1,105 @@
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 EntitySchema from "passbolt-styleguide/src/shared/models/entity/abstract/entitySchema";
15
+ import * as assertEntityProperty from "passbolt-styleguide/test/assert/assertEntityProperty";
16
+ import MfaWebauthnCredentialEntity from "./mfaWebauthnCredentialEntity";
17
+ import { defaultMfaWebauthnCredentialDto } from "./mfaWebauthnCredentialEntity.test.data";
18
+
19
+ describe("MfaWebauthnCredentialEntity", () => {
20
+ describe("MfaWebauthnCredentialEntity::getSchema", () => {
21
+ it("schema must validate", () => {
22
+ EntitySchema.validateSchema(MfaWebauthnCredentialEntity.name, MfaWebauthnCredentialEntity.getSchema());
23
+ });
24
+
25
+ it("validates id property", () => {
26
+ assertEntityProperty.uuid(MfaWebauthnCredentialEntity, "id");
27
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "id");
28
+ });
29
+
30
+ it("validates credential_id property", () => {
31
+ assertEntityProperty.string(MfaWebauthnCredentialEntity, "credential_id");
32
+ assertEntityProperty.minLength(MfaWebauthnCredentialEntity, "credential_id", 1);
33
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "credential_id");
34
+ });
35
+
36
+ it("validates aaguid property", () => {
37
+ const successScenarios = [
38
+ assertEntityProperty.SCENARIO_UUID,
39
+ { scenario: "a non RFC 4122 aaguid", value: "adce0002-35bc-c60a-648b-0b25f1f05503" },
40
+ ];
41
+ const failScenarios = [
42
+ assertEntityProperty.SCENARIO_STRING,
43
+ { scenario: "upper case hex", value: "ADCE0002-35BC-C60A-648B-0B25F1F05503" },
44
+ ];
45
+ assertEntityProperty.assert(MfaWebauthnCredentialEntity, "aaguid", successScenarios, failScenarios, "pattern");
46
+ assertEntityProperty.nullable(MfaWebauthnCredentialEntity, "aaguid");
47
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "aaguid");
48
+ });
49
+
50
+ it("validates name property", () => {
51
+ assertEntityProperty.string(MfaWebauthnCredentialEntity, "name");
52
+ assertEntityProperty.maxLength(MfaWebauthnCredentialEntity, "name", 255);
53
+ assertEntityProperty.nullable(MfaWebauthnCredentialEntity, "name");
54
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "name");
55
+ });
56
+
57
+ it("validates sign_count property", () => {
58
+ assertEntityProperty.integer(MfaWebauthnCredentialEntity, "sign_count");
59
+ assertEntityProperty.minimum(MfaWebauthnCredentialEntity, "sign_count", 0);
60
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "sign_count");
61
+ });
62
+
63
+ it("validates last_used property", () => {
64
+ assertEntityProperty.dateTime(MfaWebauthnCredentialEntity, "last_used");
65
+ assertEntityProperty.nullable(MfaWebauthnCredentialEntity, "last_used");
66
+ assertEntityProperty.notRequired(MfaWebauthnCredentialEntity, "last_used");
67
+ });
68
+
69
+ it("validates created property", () => {
70
+ assertEntityProperty.dateTime(MfaWebauthnCredentialEntity, "created");
71
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "created");
72
+ });
73
+
74
+ it("validates modified property", () => {
75
+ assertEntityProperty.dateTime(MfaWebauthnCredentialEntity, "modified");
76
+ assertEntityProperty.required(MfaWebauthnCredentialEntity, "modified");
77
+ });
78
+ });
79
+
80
+ describe("MfaWebauthnCredentialEntity::constructor", () => {
81
+ it("works if valid DTO is provided", () => {
82
+ expect.assertions(9);
83
+ const dto = defaultMfaWebauthnCredentialDto();
84
+ const entity = new MfaWebauthnCredentialEntity(dto);
85
+ expect(entity.toDto()).toEqual(dto);
86
+ expect(entity.id).toEqual(dto.id);
87
+ expect(entity.credentialId).toEqual(dto.credential_id);
88
+ expect(entity.aaguid).toEqual(dto.aaguid);
89
+ expect(entity.name).toEqual(dto.name);
90
+ expect(entity.signCount).toEqual(dto.sign_count);
91
+ expect(entity.lastUsed).toEqual(dto.last_used);
92
+ expect(entity.created).toEqual(dto.created);
93
+ expect(entity.modified).toEqual(dto.modified);
94
+ });
95
+
96
+ it("exposes null for a never used, unnamed credential of an unknown authenticator", () => {
97
+ expect.assertions(3);
98
+ const dto = defaultMfaWebauthnCredentialDto({ aaguid: null, name: null, last_used: null });
99
+ const entity = new MfaWebauthnCredentialEntity(dto);
100
+ expect(entity.aaguid).toBeNull();
101
+ expect(entity.name).toBeNull();
102
+ expect(entity.lastUsed).toBeNull();
103
+ });
104
+ });
105
+ });
@@ -0,0 +1,52 @@
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 EntityV2Collection from "passbolt-styleguide/src/shared/models/entity/abstract/entityV2Collection";
15
+ import MfaWebauthnCredentialEntity from "./mfaWebauthnCredentialEntity";
16
+
17
+ class MfaWebauthnCredentialsCollection extends EntityV2Collection {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ get entityClass() {
22
+ return MfaWebauthnCredentialEntity;
23
+ }
24
+
25
+ /**
26
+ * Get the collection schema
27
+ * @returns {Object} schema
28
+ */
29
+ static getSchema() {
30
+ return {
31
+ type: "array",
32
+ items: MfaWebauthnCredentialEntity.getSchema(),
33
+ };
34
+ }
35
+
36
+ /**
37
+ * @inheritDoc
38
+ * @throws {EntityValidationError} If a credential already exists with the same id.
39
+ */
40
+ validateBuildRules(item) {
41
+ this.assertNotExist("id", item._props.id);
42
+ }
43
+
44
+ /**
45
+ * @returns {Array<MfaWebauthnCredentialEntity>}
46
+ */
47
+ get credentials() {
48
+ return this._items;
49
+ }
50
+ }
51
+
52
+ export default MfaWebauthnCredentialsCollection;
@@ -0,0 +1,22 @@
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 { defaultMfaWebauthnCredentialDto } from "./mfaWebauthnCredentialEntity.test.data";
15
+
16
+ export const defaultMfaWebauthnCredentialsDtos = (count = 3, data = {}) => {
17
+ const dtos = [];
18
+ for (let i = 0; i < count; i++) {
19
+ dtos.push(defaultMfaWebauthnCredentialDto({ name: `Passkey ${i + 1}`, ...data }));
20
+ }
21
+ return dtos;
22
+ };
@@ -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 EntitySchema from "passbolt-styleguide/src/shared/models/entity/abstract/entitySchema";
15
+ import MfaWebauthnCredentialEntity from "./mfaWebauthnCredentialEntity";
16
+ import MfaWebauthnCredentialsCollection from "./mfaWebauthnCredentialsCollection";
17
+ import { defaultMfaWebauthnCredentialDto } from "./mfaWebauthnCredentialEntity.test.data";
18
+ import { defaultMfaWebauthnCredentialsDtos } from "./mfaWebauthnCredentialsCollection.test.data";
19
+
20
+ describe("MfaWebauthnCredentialsCollection", () => {
21
+ describe("MfaWebauthnCredentialsCollection::constructor", () => {
22
+ it("schema must validate", () => {
23
+ EntitySchema.validateSchema(MfaWebauthnCredentialsCollection.name, MfaWebauthnCredentialsCollection.getSchema());
24
+ });
25
+
26
+ it("works if valid DTOs are provided", () => {
27
+ expect.assertions(5);
28
+ const dtos = defaultMfaWebauthnCredentialsDtos(2);
29
+ const collection = new MfaWebauthnCredentialsCollection(dtos);
30
+ expect(collection).toHaveLength(2);
31
+ expect(collection.toDto()).toEqual(dtos);
32
+ expect(collection.credentials[0]).toBeInstanceOf(MfaWebauthnCredentialEntity);
33
+ expect(collection.credentials[0].id).toEqual(dtos[0].id);
34
+ expect(collection.credentials[1].id).toEqual(dtos[1].id);
35
+ });
36
+
37
+ it("works with an empty array", () => {
38
+ expect.assertions(1);
39
+ expect(new MfaWebauthnCredentialsCollection([])).toHaveLength(0);
40
+ });
41
+
42
+ it("should throw if the collection schema does not validate", () => {
43
+ expect.assertions(1);
44
+ expect(() => new MfaWebauthnCredentialsCollection({})).toThrowEntityValidationError("items");
45
+ });
46
+
47
+ it("should throw if one of data item does not validate the entity schema", () => {
48
+ expect.assertions(1);
49
+ const dtos = [defaultMfaWebauthnCredentialDto(), defaultMfaWebauthnCredentialDto({ sign_count: "3" })];
50
+ expect(() => new MfaWebauthnCredentialsCollection(dtos)).toThrowCollectionValidationError("1.sign_count.type");
51
+ });
52
+
53
+ it("should throw if one of data item does not validate the unique id build rule", () => {
54
+ expect.assertions(1);
55
+ const dto1 = defaultMfaWebauthnCredentialDto();
56
+ const dto2 = defaultMfaWebauthnCredentialDto({ id: dto1.id });
57
+ expect(() => new MfaWebauthnCredentialsCollection([dto1, dto2])).toThrowCollectionValidationError("1.id.unique");
58
+ });
59
+ });
60
+ });
@@ -0,0 +1,45 @@
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 EntityV2 from "passbolt-styleguide/src/shared/models/entity/abstract/entityV2";
15
+
16
+ /**
17
+ * The organisation WebAuthn MFA settings relevant to the user; the API returns more fields than modelled here.
18
+ */
19
+ class MfaWebauthnSettingsEntity extends EntityV2 {
20
+ /**
21
+ * Get the entity schema
22
+ * @returns {Object} schema
23
+ */
24
+ static getSchema() {
25
+ return {
26
+ type: "object",
27
+ required: ["max_credentials_per_user"],
28
+ properties: {
29
+ max_credentials_per_user: {
30
+ type: "integer",
31
+ minimum: 1,
32
+ },
33
+ },
34
+ };
35
+ }
36
+
37
+ /**
38
+ * @returns {number}
39
+ */
40
+ get maxCredentialsPerUser() {
41
+ return this._props.max_credentials_per_user;
42
+ }
43
+ }
44
+
45
+ export default MfaWebauthnSettingsEntity;
@@ -0,0 +1,17 @@
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
+ export const defaultMfaWebauthnSettingsDto = (data = {}) => ({
15
+ max_credentials_per_user: 10,
16
+ ...data,
17
+ });
@@ -0,0 +1,48 @@
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 EntitySchema from "passbolt-styleguide/src/shared/models/entity/abstract/entitySchema";
15
+ import * as assertEntityProperty from "passbolt-styleguide/test/assert/assertEntityProperty";
16
+ import MfaWebauthnSettingsEntity from "./mfaWebauthnSettingsEntity";
17
+ import { defaultMfaWebauthnSettingsDto } from "./mfaWebauthnSettingsEntity.test.data";
18
+
19
+ describe("MfaWebauthnSettingsEntity", () => {
20
+ describe("MfaWebauthnSettingsEntity::getSchema", () => {
21
+ it("schema must validate", () => {
22
+ EntitySchema.validateSchema(MfaWebauthnSettingsEntity.name, MfaWebauthnSettingsEntity.getSchema());
23
+ });
24
+
25
+ it("validates max_credentials_per_user property", () => {
26
+ assertEntityProperty.integer(MfaWebauthnSettingsEntity, "max_credentials_per_user");
27
+ assertEntityProperty.minimum(MfaWebauthnSettingsEntity, "max_credentials_per_user", 1);
28
+ assertEntityProperty.required(MfaWebauthnSettingsEntity, "max_credentials_per_user");
29
+ });
30
+ });
31
+
32
+ describe("MfaWebauthnSettingsEntity::constructor", () => {
33
+ it("works if valid DTO is provided", () => {
34
+ expect.assertions(2);
35
+ const dto = defaultMfaWebauthnSettingsDto();
36
+ const entity = new MfaWebauthnSettingsEntity(dto);
37
+ expect(entity.toDto()).toEqual(dto);
38
+ expect(entity.maxCredentialsPerUser).toEqual(10);
39
+ });
40
+
41
+ it("drops the API fields that are not modelled", () => {
42
+ expect.assertions(1);
43
+ const dto = defaultMfaWebauthnSettingsDto({ timeout_ms: 60000, attestation: "none" });
44
+ const entity = new MfaWebauthnSettingsEntity(dto);
45
+ expect(entity.toDto()).toEqual(defaultMfaWebauthnSettingsDto());
46
+ });
47
+ });
48
+ });