@bitwarden/cli 2023.10.0 → 2023.12.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 (3) hide show
  1. package/build/bw.js +1519 -725
  2. package/build/bw.js.map +1 -1
  3. package/package.json +1 -1
package/build/bw.js CHANGED
@@ -20,7 +20,7 @@ module.exports = require("url");
20
20
  /***/ 147:
21
21
  /***/ ((module) => {
22
22
 
23
- module.exports = JSON.parse('{"name":"@bitwarden/cli","description":"A secure and free password manager for all of your devices.","version":"2023.10.0","keywords":["bitwarden","password","vault","password manager","cli"],"author":"Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)","homepage":"https://bitwarden.com","repository":{"type":"git","url":"https://github.com/bitwarden/clients"},"license":"GPL-3.0-only","scripts":{"clean":"rimraf dist","build":"webpack","build:debug":"npm run build && node --inspect ./build/bw.js","build:watch":"webpack --watch","build:prod":"cross-env NODE_ENV=production webpack","build:prod:watch":"cross-env NODE_ENV=production webpack --watch","package":"npm run package:win && npm run package:mac && npm run package:lin","package:win":"pkg . --targets win-x64 --output ./dist/windows/bw.exe","package:mac":"pkg . --targets macos-x64 --output ./dist/macos/bw","package:lin":"pkg . --targets linux-x64 --output ./dist/linux/bw","debug":"node --inspect ./build/bw.js","dist":"npm run build:prod && npm run clean && npm run package","dist:win":"npm run build:prod && npm run clean && npm run package:win","dist:mac":"npm run build:prod && npm run clean && npm run package:mac","dist:lin":"npm run build:prod && npm run clean && npm run package:lin","publish:npm":"npm run build:prod && npm publish --access public","test":"jest","test:watch":"jest --watch","test:watch:all":"jest --watchAll"},"bin":{"bw":"build/bw.js"},"pkg":{"assets":["./build/**/*","../../node_modules/argon2/**/*"]},"dependencies":{"@koa/multer":"3.0.2","@koa/router":"12.0.0","argon2":"0.31.0","big-integer":"1.6.51","browser-hrtime":"1.1.8","chalk":"4.1.2","commander":"7.2.0","form-data":"4.0.0","https-proxy-agent":"5.0.1","inquirer":"8.2.6","jsdom":"22.1.0","jszip":"3.10.1","koa":"2.14.2","koa-bodyparser":"4.4.1","koa-json":"2.0.2","lowdb":"1.0.0","lunr":"2.3.9","multer":"1.4.5-lts.1","node-fetch":"2.6.12","node-forge":"1.3.1","open":"8.4.2","papaparse":"5.4.1","proper-lockfile":"4.1.2","rxjs":"7.8.1","tldts":"6.0.14","zxcvbn":"4.4.2"}}');
23
+ module.exports = JSON.parse('{"name":"@bitwarden/cli","description":"A secure and free password manager for all of your devices.","version":"2023.12.0","keywords":["bitwarden","password","vault","password manager","cli"],"author":"Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)","homepage":"https://bitwarden.com","repository":{"type":"git","url":"https://github.com/bitwarden/clients"},"license":"GPL-3.0-only","scripts":{"clean":"rimraf dist","build":"webpack","build:debug":"npm run build && node --inspect ./build/bw.js","build:watch":"webpack --watch","build:prod":"cross-env NODE_ENV=production webpack","build:prod:watch":"cross-env NODE_ENV=production webpack --watch","package":"npm run package:win && npm run package:mac && npm run package:lin","package:win":"pkg . --targets win-x64 --output ./dist/windows/bw.exe","package:mac":"pkg . --targets macos-x64 --output ./dist/macos/bw","package:lin":"pkg . --targets linux-x64 --output ./dist/linux/bw","debug":"node --inspect ./build/bw.js","dist":"npm run build:prod && npm run clean && npm run package","dist:win":"npm run build:prod && npm run clean && npm run package:win","dist:mac":"npm run build:prod && npm run clean && npm run package:mac","dist:lin":"npm run build:prod && npm run clean && npm run package:lin","publish:npm":"npm run build:prod && npm publish --access public","test":"jest","test:watch":"jest --watch","test:watch:all":"jest --watchAll"},"bin":{"bw":"build/bw.js"},"pkg":{"assets":["./build/**/*","../../node_modules/argon2/**/*"]},"dependencies":{"@koa/multer":"3.0.2","@koa/router":"12.0.0","argon2":"0.31.0","big-integer":"1.6.51","browser-hrtime":"1.1.8","chalk":"4.1.2","commander":"7.2.0","form-data":"4.0.0","https-proxy-agent":"5.0.1","inquirer":"8.2.6","jsdom":"22.1.0","jszip":"3.10.1","koa":"2.14.2","koa-bodyparser":"4.4.1","koa-json":"2.0.2","lowdb":"1.0.0","lunr":"2.3.9","multer":"1.4.5-lts.1","node-fetch":"2.6.12","node-forge":"1.3.1","open":"8.4.2","papaparse":"5.4.1","proper-lockfile":"4.1.2","rxjs":"7.8.1","tldts":"6.0.14","zxcvbn":"4.4.2"}}');
24
24
 
25
25
  /***/ })
26
26
 
@@ -373,7 +373,7 @@ class PlanResponse extends BaseResponse {
373
373
  this.hasResetPassword = this.getResponseProperty("HasResetPassword");
374
374
  this.usersGetPremium = this.getResponseProperty("UsersGetPremium");
375
375
  this.upgradeSortOrder = this.getResponseProperty("UpgradeSortOrder");
376
- this.displaySortOrder = this.getResponseProperty("SortOrder");
376
+ this.displaySortOrder = this.getResponseProperty("DisplaySortOrder");
377
377
  this.legacyYear = this.getResponseProperty("LegacyYear");
378
378
  this.disabled = this.getResponseProperty("Disabled");
379
379
  const passwordManager = this.getResponseProperty("PasswordManager");
@@ -462,6 +462,7 @@ class OrganizationResponse extends BaseResponse {
462
462
  this.smServiceAccounts = this.getResponseProperty("SmServiceAccounts");
463
463
  this.maxAutoscaleSmSeats = this.getResponseProperty("MaxAutoscaleSmSeats");
464
464
  this.maxAutoscaleSmServiceAccounts = this.getResponseProperty("MaxAutoscaleSmServiceAccounts");
465
+ this.limitCollectionCreationDeletion = this.getResponseProperty("LimitCollectionCreationDeletion");
465
466
  }
466
467
  }
467
468
 
@@ -478,13 +479,11 @@ class SubscriptionResponse extends BaseResponse {
478
479
  this.usingInAppPurchase = this.getResponseProperty("UsingInAppPurchase");
479
480
  const subscription = this.getResponseProperty("Subscription");
480
481
  const upcomingInvoice = this.getResponseProperty("UpcomingInvoice");
481
- const discount = this.getResponseProperty("Discount");
482
482
  this.subscription = subscription == null ? null : new BillingSubscriptionResponse(subscription);
483
483
  this.upcomingInvoice =
484
484
  upcomingInvoice == null
485
485
  ? null
486
486
  : new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
487
- this.discount = discount == null ? null : new BillingCustomerDiscount(discount);
488
487
  }
489
488
  }
490
489
  class BillingSubscriptionResponse extends BaseResponse {
@@ -523,17 +522,11 @@ class BillingSubscriptionUpcomingInvoiceResponse extends BaseResponse {
523
522
  this.amount = this.getResponseProperty("Amount");
524
523
  }
525
524
  }
526
- class BillingCustomerDiscount extends BaseResponse {
527
- constructor(response) {
528
- super(response);
529
- this.id = this.getResponseProperty("Id");
530
- this.active = this.getResponseProperty("Active");
531
- }
532
- }
533
525
 
534
526
  ;// CONCATENATED MODULE: ../../libs/common/src/billing/models/response/organization-subscription.response.ts
535
527
 
536
528
 
529
+
537
530
  class OrganizationSubscriptionResponse extends OrganizationResponse {
538
531
  constructor(response) {
539
532
  super(response);
@@ -546,13 +539,26 @@ class OrganizationSubscriptionResponse extends OrganizationResponse {
546
539
  upcomingInvoice == null
547
540
  ? null
548
541
  : new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
549
- const discount = this.getResponseProperty("Discount");
550
- this.discount = discount == null ? null : new BillingCustomerDiscount(discount);
542
+ const customerDiscount = this.getResponseProperty("CustomerDiscount");
543
+ this.customerDiscount =
544
+ customerDiscount == null ? null : new BillingCustomerDiscount(customerDiscount);
551
545
  this.expiration = this.getResponseProperty("Expiration");
552
546
  this.expirationWithoutGracePeriod = this.getResponseProperty("ExpirationWithoutGracePeriod");
553
547
  this.secretsManagerBeta = this.getResponseProperty("SecretsManagerBeta");
554
548
  }
555
549
  }
550
+ class BillingCustomerDiscount extends BaseResponse {
551
+ constructor(response) {
552
+ super(response);
553
+ this.discountPrice = (price) => {
554
+ const discount = this !== null && this.active ? price * (this.percentOff / 100) : 0;
555
+ return price - discount;
556
+ };
557
+ this.id = this.getResponseProperty("Id");
558
+ this.active = this.getResponseProperty("Active");
559
+ this.percentOff = this.getResponseProperty("PercentOff");
560
+ }
561
+ }
556
562
 
557
563
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/api/permissions.api.ts
558
564
 
@@ -637,6 +643,7 @@ class ProfileOrganizationResponse extends BaseResponse {
637
643
  }
638
644
  this.familySponsorshipToDelete = this.getResponseProperty("FamilySponsorshipToDelete");
639
645
  this.accessSecretsManager = this.getResponseProperty("AccessSecretsManager");
646
+ this.limitCollectionCreationDeletion = this.getResponseProperty("LimitCollectionCreationDeletion");
640
647
  }
641
648
  }
642
649
 
@@ -1006,6 +1013,14 @@ class OrganizationApiService {
1006
1013
  return new ProfileOrganizationResponse(r);
1007
1014
  });
1008
1015
  }
1016
+ updateCollectionManagement(id, request) {
1017
+ return __awaiter(this, void 0, void 0, function* () {
1018
+ const r = yield this.apiService.send("PUT", "/organizations/" + id + "/collection-management", request, true, true);
1019
+ const data = new OrganizationResponse(r);
1020
+ yield this.syncService.fullSync(true);
1021
+ return data;
1022
+ });
1023
+ }
1009
1024
  }
1010
1025
 
1011
1026
  ;// CONCATENATED MODULE: external "rxjs"
@@ -1143,6 +1158,36 @@ class utils_Utils {
1143
1158
  .join("");
1144
1159
  }
1145
1160
  }
1161
+ /**
1162
+ * Converts a hex string to an ArrayBuffer.
1163
+ * Note: this doesn't need any Node specific code as parseInt() / ArrayBuffer / Uint8Array
1164
+ * work the same in Node and the browser.
1165
+ * @param {string} hexString - A string of hexadecimal characters.
1166
+ * @returns {ArrayBuffer} The ArrayBuffer representation of the hex string.
1167
+ */
1168
+ static hexStringToArrayBuffer(hexString) {
1169
+ // Check if the hexString has an even length, as each hex digit represents half a byte (4 bits),
1170
+ // and it takes two hex digits to represent a full byte (8 bits).
1171
+ if (hexString.length % 2 !== 0) {
1172
+ throw "HexString has to be an even length";
1173
+ }
1174
+ // Create an ArrayBuffer with a length that is half the length of the hex string,
1175
+ // because each pair of hex digits will become a single byte.
1176
+ const arrayBuffer = new ArrayBuffer(hexString.length / 2);
1177
+ // Create a Uint8Array view on top of the ArrayBuffer (each position represents a byte)
1178
+ // as ArrayBuffers cannot be edited directly.
1179
+ const uint8Array = new Uint8Array(arrayBuffer);
1180
+ // Loop through the bytes
1181
+ for (let i = 0; i < uint8Array.length; i++) {
1182
+ // Extract two hex characters (1 byte)
1183
+ const hexByte = hexString.substr(i * 2, 2);
1184
+ // Convert hexByte into a decimal value from base 16. (ex: ff --> 255)
1185
+ const byteValue = parseInt(hexByte, 16);
1186
+ // Place the byte value into the uint8Array
1187
+ uint8Array[i] = byteValue;
1188
+ }
1189
+ return arrayBuffer;
1190
+ }
1146
1191
  static fromUrlB64ToB64(urlB64Str) {
1147
1192
  let output = urlB64Str.replace(/-/g, "+").replace(/_/g, "/");
1148
1193
  switch (output.length % 4) {
@@ -1243,7 +1288,10 @@ class utils_Utils {
1243
1288
  return null;
1244
1289
  }
1245
1290
  try {
1246
- const parseResult = (0,external_tldts_namespaceObject.parse)(uriString, { validHosts: this.validHosts });
1291
+ const parseResult = (0,external_tldts_namespaceObject.parse)(uriString, {
1292
+ validHosts: this.validHosts,
1293
+ allowPrivateDomains: true,
1294
+ });
1247
1295
  if (parseResult != null && parseResult.hostname != null) {
1248
1296
  if (parseResult.hostname === "localhost" || parseResult.isIp) {
1249
1297
  return parseResult.hostname;
@@ -1590,6 +1638,9 @@ var DeviceType;
1590
1638
  DeviceType[DeviceType["SafariExtension"] = 20] = "SafariExtension";
1591
1639
  DeviceType[DeviceType["SDK"] = 21] = "SDK";
1592
1640
  DeviceType[DeviceType["Server"] = 22] = "Server";
1641
+ DeviceType[DeviceType["WindowsCLI"] = 23] = "WindowsCLI";
1642
+ DeviceType[DeviceType["MacOsCLI"] = 24] = "MacOsCLI";
1643
+ DeviceType[DeviceType["LinuxCLI"] = 25] = "LinuxCLI";
1593
1644
  })(DeviceType || (DeviceType = {}));
1594
1645
  const MobileDeviceTypes = new Set([
1595
1646
  DeviceType.Android,
@@ -1601,6 +1652,9 @@ const DesktopDeviceTypes = new Set([
1601
1652
  DeviceType.MacOsDesktop,
1602
1653
  DeviceType.LinuxDesktop,
1603
1654
  DeviceType.UWP,
1655
+ DeviceType.WindowsCLI,
1656
+ DeviceType.MacOsCLI,
1657
+ DeviceType.LinuxCLI,
1604
1658
  ]);
1605
1659
 
1606
1660
  ;// CONCATENATED MODULE: ../../libs/common/src/enums/encrypted-export-type.enum.ts
@@ -2217,6 +2271,7 @@ var ProductType;
2217
2271
  ProductType[ProductType["Families"] = 1] = "Families";
2218
2272
  ProductType[ProductType["Teams"] = 2] = "Teams";
2219
2273
  ProductType[ProductType["Enterprise"] = 3] = "Enterprise";
2274
+ ProductType[ProductType["TeamsStarter"] = 4] = "TeamsStarter";
2220
2275
  })(ProductType || (ProductType = {}));
2221
2276
 
2222
2277
  ;// CONCATENATED MODULE: ../../libs/common/src/enums/provider-type.enum.ts
@@ -2428,6 +2483,7 @@ class Organization {
2428
2483
  this.familySponsorshipValidUntil = obj.familySponsorshipValidUntil;
2429
2484
  this.familySponsorshipToDelete = obj.familySponsorshipToDelete;
2430
2485
  this.accessSecretsManager = obj.accessSecretsManager;
2486
+ this.limitCollectionCreationDeletion = obj.limitCollectionCreationDeletion;
2431
2487
  }
2432
2488
  get canAccess() {
2433
2489
  if (this.isOwner) {
@@ -2463,7 +2519,9 @@ class Organization {
2463
2519
  return this.isAdmin || this.permissions.accessReports;
2464
2520
  }
2465
2521
  get canCreateNewCollections() {
2466
- return this.isManager || this.permissions.createNewCollections;
2522
+ return (!this.limitCollectionCreationDeletion ||
2523
+ this.isManager ||
2524
+ this.permissions.createNewCollections);
2467
2525
  }
2468
2526
  get canEditAnyCollection() {
2469
2527
  return this.isAdmin || this.permissions.editAnyCollection;
@@ -2533,6 +2591,9 @@ class Organization {
2533
2591
  get hasProvider() {
2534
2592
  return this.providerId != null || this.providerName != null;
2535
2593
  }
2594
+ get hasReseller() {
2595
+ return this.hasProvider && this.providerType === ProviderType.Reseller;
2596
+ }
2536
2597
  get canAccessSecretsManager() {
2537
2598
  return this.useSecretsManager && this.accessSecretsManager;
2538
2599
  }
@@ -2657,6 +2718,300 @@ class organization_service_OrganizationService {
2657
2718
  }
2658
2719
  }
2659
2720
 
2721
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/response/selection-read-only.response.ts
2722
+
2723
+ class SelectionReadOnlyResponse extends BaseResponse {
2724
+ constructor(response) {
2725
+ super(response);
2726
+ this.id = this.getResponseProperty("Id");
2727
+ this.readOnly = this.getResponseProperty("ReadOnly");
2728
+ this.hidePasswords = this.getResponseProperty("HidePasswords");
2729
+ this.manage = this.getResponseProperty("Manage");
2730
+ }
2731
+ }
2732
+
2733
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/abstractions/organization-user/responses/organization-user.response.ts
2734
+
2735
+
2736
+
2737
+ class OrganizationUserResponse extends BaseResponse {
2738
+ constructor(response) {
2739
+ super(response);
2740
+ this.collections = [];
2741
+ this.groups = [];
2742
+ this.id = this.getResponseProperty("Id");
2743
+ this.userId = this.getResponseProperty("UserId");
2744
+ this.type = this.getResponseProperty("Type");
2745
+ this.status = this.getResponseProperty("Status");
2746
+ this.permissions = new PermissionsApi(this.getResponseProperty("Permissions"));
2747
+ this.externalId = this.getResponseProperty("ExternalId");
2748
+ this.accessAll = this.getResponseProperty("AccessAll");
2749
+ this.accessSecretsManager = this.getResponseProperty("AccessSecretsManager");
2750
+ this.resetPasswordEnrolled = this.getResponseProperty("ResetPasswordEnrolled");
2751
+ this.hasMasterPassword = this.getResponseProperty("HasMasterPassword");
2752
+ const collections = this.getResponseProperty("Collections");
2753
+ if (collections != null) {
2754
+ this.collections = collections.map((c) => new SelectionReadOnlyResponse(c));
2755
+ }
2756
+ const groups = this.getResponseProperty("Groups");
2757
+ if (groups != null) {
2758
+ this.groups = groups;
2759
+ }
2760
+ }
2761
+ }
2762
+ class OrganizationUserUserDetailsResponse extends OrganizationUserResponse {
2763
+ constructor(response) {
2764
+ var _a;
2765
+ super(response);
2766
+ this.name = this.getResponseProperty("Name");
2767
+ this.email = this.getResponseProperty("Email");
2768
+ this.avatarColor = this.getResponseProperty("AvatarColor");
2769
+ this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
2770
+ this.usesKeyConnector = (_a = this.getResponseProperty("UsesKeyConnector")) !== null && _a !== void 0 ? _a : false;
2771
+ }
2772
+ }
2773
+ class OrganizationUserDetailsResponse extends OrganizationUserResponse {
2774
+ constructor(response) {
2775
+ super(response);
2776
+ }
2777
+ }
2778
+ class OrganizationUserResetPasswordDetailsResponse extends BaseResponse {
2779
+ constructor(response) {
2780
+ super(response);
2781
+ this.kdf = this.getResponseProperty("Kdf");
2782
+ this.kdfIterations = this.getResponseProperty("KdfIterations");
2783
+ this.kdfMemory = this.getResponseProperty("KdfMemory");
2784
+ this.kdfParallelism = this.getResponseProperty("KdfParallelism");
2785
+ this.resetPasswordKey = this.getResponseProperty("ResetPasswordKey");
2786
+ this.encryptedPrivateKey = this.getResponseProperty("EncryptedPrivateKey");
2787
+ }
2788
+ }
2789
+
2790
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/abstractions/organization-user/responses/organization-user-bulk.response.ts
2791
+
2792
+ class OrganizationUserBulkResponse extends BaseResponse {
2793
+ constructor(response) {
2794
+ super(response);
2795
+ this.id = this.getResponseProperty("Id");
2796
+ this.error = this.getResponseProperty("Error");
2797
+ }
2798
+ }
2799
+
2800
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/abstractions/organization-user/responses/organization-user-bulk-public-key.response.ts
2801
+
2802
+ class OrganizationUserBulkPublicKeyResponse extends BaseResponse {
2803
+ constructor(response) {
2804
+ super(response);
2805
+ this.id = this.getResponseProperty("Id");
2806
+ this.userId = this.getResponseProperty("UserId");
2807
+ this.key = this.getResponseProperty("Key");
2808
+ }
2809
+ }
2810
+
2811
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/services/organization-user/requests/organization-user-bulk.request.ts
2812
+ class OrganizationUserBulkRequest {
2813
+ constructor(ids) {
2814
+ this.ids = ids == null ? [] : ids;
2815
+ }
2816
+ }
2817
+
2818
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/services/organization-user/organization-user.service.implementation.ts
2819
+ var organization_user_service_implementation_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2820
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2821
+ return new (P || (P = Promise))(function (resolve, reject) {
2822
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2823
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2824
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2825
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2826
+ });
2827
+ };
2828
+
2829
+
2830
+
2831
+ class OrganizationUserServiceImplementation {
2832
+ constructor(apiService) {
2833
+ this.apiService = apiService;
2834
+ }
2835
+ getOrganizationUser(organizationId, id, options) {
2836
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2837
+ const params = new URLSearchParams();
2838
+ if (options === null || options === void 0 ? void 0 : options.includeGroups) {
2839
+ params.set("includeGroups", "true");
2840
+ }
2841
+ const r = yield this.apiService.send("GET", `/organizations/${organizationId}/users/${id}?${params.toString()}`, null, true, true);
2842
+ return new OrganizationUserDetailsResponse(r);
2843
+ });
2844
+ }
2845
+ getOrganizationUserGroups(organizationId, id) {
2846
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2847
+ const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/users/" + id + "/groups", null, true, true);
2848
+ return r;
2849
+ });
2850
+ }
2851
+ getAllUsers(organizationId, options) {
2852
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2853
+ const params = new URLSearchParams();
2854
+ if (options === null || options === void 0 ? void 0 : options.includeCollections) {
2855
+ params.set("includeCollections", "true");
2856
+ }
2857
+ if (options === null || options === void 0 ? void 0 : options.includeGroups) {
2858
+ params.set("includeGroups", "true");
2859
+ }
2860
+ const r = yield this.apiService.send("GET", `/organizations/${organizationId}/users?${params.toString()}`, null, true, true);
2861
+ return new ListResponse(r, OrganizationUserUserDetailsResponse);
2862
+ });
2863
+ }
2864
+ getOrganizationUserResetPasswordDetails(organizationId, id) {
2865
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2866
+ const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/users/" + id + "/reset-password-details", null, true, true);
2867
+ return new OrganizationUserResetPasswordDetailsResponse(r);
2868
+ });
2869
+ }
2870
+ postOrganizationUserInvite(organizationId, request) {
2871
+ return this.apiService.send("POST", "/organizations/" + organizationId + "/users/invite", request, true, false);
2872
+ }
2873
+ postOrganizationUserReinvite(organizationId, id) {
2874
+ return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/reinvite", null, true, false);
2875
+ }
2876
+ postManyOrganizationUserReinvite(organizationId, ids) {
2877
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2878
+ const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/reinvite", new OrganizationUserBulkRequest(ids), true, true);
2879
+ return new ListResponse(r, OrganizationUserBulkResponse);
2880
+ });
2881
+ }
2882
+ postOrganizationUserAcceptInit(organizationId, id, request) {
2883
+ return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/accept-init", request, true, false);
2884
+ }
2885
+ postOrganizationUserAccept(organizationId, id, request) {
2886
+ return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/accept", request, true, false);
2887
+ }
2888
+ postOrganizationUserConfirm(organizationId, id, request) {
2889
+ return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/confirm", request, true, false);
2890
+ }
2891
+ postOrganizationUsersPublicKey(organizationId, ids) {
2892
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2893
+ const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/public-keys", new OrganizationUserBulkRequest(ids), true, true);
2894
+ return new ListResponse(r, OrganizationUserBulkPublicKeyResponse);
2895
+ });
2896
+ }
2897
+ postOrganizationUserBulkConfirm(organizationId, request) {
2898
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2899
+ const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/confirm", request, true, true);
2900
+ return new ListResponse(r, OrganizationUserBulkResponse);
2901
+ });
2902
+ }
2903
+ putOrganizationUserBulkEnableSecretsManager(organizationId, ids) {
2904
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2905
+ yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/enable-secrets-manager", new OrganizationUserBulkRequest(ids), true, false);
2906
+ });
2907
+ }
2908
+ putOrganizationUser(organizationId, id, request) {
2909
+ return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id, request, true, false);
2910
+ }
2911
+ putOrganizationUserGroups(organizationId, id, request) {
2912
+ return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/groups", request, true, false);
2913
+ }
2914
+ putOrganizationUserResetPasswordEnrollment(organizationId, userId, request) {
2915
+ return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment", request, true, false);
2916
+ }
2917
+ putOrganizationUserResetPassword(organizationId, id, request) {
2918
+ return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/reset-password", request, true, false);
2919
+ }
2920
+ deleteOrganizationUser(organizationId, id) {
2921
+ return this.apiService.send("DELETE", "/organizations/" + organizationId + "/users/" + id, null, true, false);
2922
+ }
2923
+ deleteManyOrganizationUsers(organizationId, ids) {
2924
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2925
+ const r = yield this.apiService.send("DELETE", "/organizations/" + organizationId + "/users", new OrganizationUserBulkRequest(ids), true, true);
2926
+ return new ListResponse(r, OrganizationUserBulkResponse);
2927
+ });
2928
+ }
2929
+ revokeOrganizationUser(organizationId, id) {
2930
+ return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/revoke", null, true, false);
2931
+ }
2932
+ revokeManyOrganizationUsers(organizationId, ids) {
2933
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2934
+ const r = yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/revoke", new OrganizationUserBulkRequest(ids), true, true);
2935
+ return new ListResponse(r, OrganizationUserBulkResponse);
2936
+ });
2937
+ }
2938
+ restoreOrganizationUser(organizationId, id) {
2939
+ return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/restore", null, true, false);
2940
+ }
2941
+ restoreManyOrganizationUsers(organizationId, ids) {
2942
+ return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
2943
+ const r = yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/restore", new OrganizationUserBulkRequest(ids), true, true);
2944
+ return new ListResponse(r, OrganizationUserBulkResponse);
2945
+ });
2946
+ }
2947
+ }
2948
+
2949
+ ;// CONCATENATED MODULE: ../../libs/common/src/models/response/error.response.ts
2950
+
2951
+
2952
+ class ErrorResponse extends BaseResponse {
2953
+ constructor(response, status, identityResponse) {
2954
+ var _a, _b;
2955
+ super(response);
2956
+ let errorModel = null;
2957
+ if (response != null) {
2958
+ const responseErrorModel = this.getResponseProperty("ErrorModel");
2959
+ if (responseErrorModel && identityResponse) {
2960
+ errorModel = responseErrorModel;
2961
+ }
2962
+ else {
2963
+ errorModel = response;
2964
+ }
2965
+ }
2966
+ if (status === 429) {
2967
+ this.message = "Rate limit exceeded. Try again later.";
2968
+ }
2969
+ else if (errorModel) {
2970
+ this.message = this.getResponseProperty("Message", errorModel);
2971
+ this.validationErrors = this.getResponseProperty("ValidationErrors", errorModel);
2972
+ this.captchaSiteKey = (_b = (_a = this.validationErrors) === null || _a === void 0 ? void 0 : _a.HCaptcha_SiteKey) === null || _b === void 0 ? void 0 : _b[0];
2973
+ this.captchaRequired = !utils_Utils.isNullOrWhitespace(this.captchaSiteKey);
2974
+ }
2975
+ this.statusCode = status;
2976
+ }
2977
+ getSingleMessage() {
2978
+ if (this.validationErrors == null) {
2979
+ return this.message;
2980
+ }
2981
+ for (const key in this.validationErrors) {
2982
+ // eslint-disable-next-line
2983
+ if (!this.validationErrors.hasOwnProperty(key)) {
2984
+ continue;
2985
+ }
2986
+ if (this.validationErrors[key].length) {
2987
+ return this.validationErrors[key][0];
2988
+ }
2989
+ }
2990
+ return this.message;
2991
+ }
2992
+ getAllMessages() {
2993
+ const messages = [];
2994
+ if (this.validationErrors == null) {
2995
+ return messages;
2996
+ }
2997
+ for (const key in this.validationErrors) {
2998
+ // eslint-disable-next-line
2999
+ if (!this.validationErrors.hasOwnProperty(key)) {
3000
+ continue;
3001
+ }
3002
+ this.validationErrors[key].forEach((item) => {
3003
+ let prefix = "";
3004
+ if (key.indexOf("[") > -1 && key.indexOf("]") > -1) {
3005
+ const lastSep = key.lastIndexOf(".");
3006
+ prefix = key.substr(0, lastSep > -1 ? lastSep : key.length) + ": ";
3007
+ }
3008
+ messages.push(prefix + item);
3009
+ });
3010
+ }
3011
+ return messages;
3012
+ }
3013
+ }
3014
+
2660
3015
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/data/policy.data.ts
2661
3016
  class PolicyData {
2662
3017
  constructor(response) {
@@ -2696,6 +3051,8 @@ var policy_api_service_awaiter = (undefined && undefined.__awaiter) || function
2696
3051
 
2697
3052
 
2698
3053
 
3054
+
3055
+
2699
3056
  class PolicyApiService {
2700
3057
  constructor(policyService, apiService, stateService) {
2701
3058
  this.policyService = policyService;
@@ -2728,18 +3085,30 @@ class PolicyApiService {
2728
3085
  return new ListResponse(r, PolicyResponse);
2729
3086
  });
2730
3087
  }
2731
- getPoliciesByInvitedUser(organizationId, userId) {
3088
+ getMasterPasswordPolicyResponseForOrgUser(organizationId) {
2732
3089
  return policy_api_service_awaiter(this, void 0, void 0, function* () {
2733
- const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/policies/invited-user?" + "userId=" + userId, null, false, true);
2734
- return new ListResponse(r, PolicyResponse);
3090
+ const response = yield this.apiService.send("GET", "/organizations/" + organizationId + "/policies/master-password", null, true, true);
3091
+ return new PolicyResponse(response);
2735
3092
  });
2736
3093
  }
2737
- getMasterPasswordPoliciesForInvitedUsers(orgId) {
3094
+ getMasterPasswordPolicyOptsForOrgUser(orgId) {
2738
3095
  return policy_api_service_awaiter(this, void 0, void 0, function* () {
2739
- const userId = yield this.stateService.getUserId();
2740
- const response = yield this.getPoliciesByInvitedUser(orgId, userId);
2741
- const policies = yield this.policyService.mapPoliciesFromToken(response);
2742
- return yield (0,external_rxjs_namespaceObject.firstValueFrom)(this.policyService.masterPasswordPolicyOptions$(policies));
3096
+ try {
3097
+ const masterPasswordPolicyResponse = yield this.getMasterPasswordPolicyResponseForOrgUser(orgId);
3098
+ const masterPasswordPolicy = this.policyService.mapPolicyFromResponse(masterPasswordPolicyResponse);
3099
+ if (!masterPasswordPolicy) {
3100
+ return null;
3101
+ }
3102
+ return yield (0,external_rxjs_namespaceObject.firstValueFrom)(this.policyService.masterPasswordPolicyOptions$([masterPasswordPolicy]));
3103
+ }
3104
+ catch (error) {
3105
+ // If policy not found, return null
3106
+ if (error instanceof ErrorResponse && error.statusCode === HttpStatusCode.NotFound) {
3107
+ return null;
3108
+ }
3109
+ // otherwise rethrow error
3110
+ throw error;
3111
+ }
2743
3112
  });
2744
3113
  }
2745
3114
  putPolicy(organizationId, type, request) {
@@ -3065,11 +3434,6 @@ class PolicyService {
3065
3434
  })))
3066
3435
  .subscribe();
3067
3436
  }
3068
- /**
3069
- * Returns the first policy found that applies to the active user
3070
- * @param policyType Policy type to search for
3071
- * @param policyFilter Additional filter to apply to the policy
3072
- */
3073
3437
  get$(policyType, policyFilter) {
3074
3438
  return this.policies$.pipe((0,external_rxjs_namespaceObject.concatMap)((policies) => policy_service_awaiter(this, void 0, void 0, function* () {
3075
3439
  const userId = yield this.stateService.getUserId();
@@ -3079,9 +3443,6 @@ class PolicyService {
3079
3443
  }
3080
3444
  })));
3081
3445
  }
3082
- /**
3083
- * @deprecated Do not call this, use the policies$ observable collection
3084
- */
3085
3446
  getAll(type, userId) {
3086
3447
  return policy_service_awaiter(this, void 0, void 0, function* () {
3087
3448
  let response = [];
@@ -3191,12 +3552,15 @@ class PolicyService {
3191
3552
  resetPasswordPolicyOptions.autoEnrollEnabled = (_b = (_a = policy === null || policy === void 0 ? void 0 : policy.data) === null || _a === void 0 ? void 0 : _a.autoEnrollEnabled) !== null && _b !== void 0 ? _b : false;
3192
3553
  return [resetPasswordPolicyOptions, (_c = policy === null || policy === void 0 ? void 0 : policy.enabled) !== null && _c !== void 0 ? _c : false];
3193
3554
  }
3555
+ mapPolicyFromResponse(policyResponse) {
3556
+ const policyData = new PolicyData(policyResponse);
3557
+ return new Policy(policyData);
3558
+ }
3194
3559
  mapPoliciesFromToken(policiesResponse) {
3195
- if (policiesResponse == null || policiesResponse.data == null) {
3560
+ if ((policiesResponse === null || policiesResponse === void 0 ? void 0 : policiesResponse.data) == null) {
3196
3561
  return null;
3197
3562
  }
3198
- const policiesData = policiesResponse.data.map((p) => new PolicyData(p));
3199
- return policiesData.map((p) => new Policy(p));
3563
+ return policiesResponse.data.map((response) => this.mapPolicyFromResponse(response));
3200
3564
  }
3201
3565
  policyAppliesToUser(policyType, policyFilter, userId) {
3202
3566
  return policy_service_awaiter(this, void 0, void 0, function* () {
@@ -3337,6 +3701,165 @@ class ProviderService {
3337
3701
  }
3338
3702
  }
3339
3703
 
3704
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/abstractions/account.service.ts
3705
+ function accountInfoEqual(a, b) {
3706
+ return a.status == b.status && a.email == b.email && a.name == b.name;
3707
+ }
3708
+ class AccountService {
3709
+ }
3710
+ class InternalAccountService extends (/* unused pure expression or super */ null && (AccountService)) {
3711
+ }
3712
+
3713
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/key-definition.ts
3714
+
3715
+ /**
3716
+ * KeyDefinitions describe the precise location to store data for a given piece of state.
3717
+ * The StateDefinition is used to describe the domain of the state, and the KeyDefinition
3718
+ * sub-divides that domain into specific keys.
3719
+ */
3720
+ class KeyDefinition {
3721
+ /**
3722
+ * Creates a new instance of a KeyDefinition
3723
+ * @param stateDefinition The state definition for which this key belongs to.
3724
+ * @param key The name of the key, this should be unique per domain.
3725
+ * @param options A set of options to customize the behavior of {@link KeyDefinition}. All options are required.
3726
+ * @param options.deserializer A function to use to safely convert your type from json to your expected type.
3727
+ * Your data may be serialized/deserialized at any time and this needs callback needs to be able to faithfully re-initialize
3728
+ * from the JSON object representation of your type.
3729
+ */
3730
+ constructor(stateDefinition, key, options) {
3731
+ this.stateDefinition = stateDefinition;
3732
+ this.key = key;
3733
+ this.options = options;
3734
+ if (options.deserializer == null) {
3735
+ throw new Error(`'deserializer' is a required property on key ${stateDefinition.name} > ${key}`);
3736
+ }
3737
+ }
3738
+ /**
3739
+ * Gets the deserializer configured for this {@link KeyDefinition}
3740
+ */
3741
+ get deserializer() {
3742
+ return this.options.deserializer;
3743
+ }
3744
+ /**
3745
+ * Creates a {@link KeyDefinition} for state that is an array.
3746
+ * @param stateDefinition The state definition to be added to the KeyDefinition
3747
+ * @param key The key to be added to the KeyDefinition
3748
+ * @param options The options to customize the final {@link KeyDefinition}.
3749
+ * @returns A {@link KeyDefinition} initialized for arrays, the options run
3750
+ * the deserializer on the provided options for each element of an array
3751
+ * **unless that array is null, in which case it will return an empty list.**
3752
+ *
3753
+ * @example
3754
+ * ```typescript
3755
+ * const MY_KEY = KeyDefinition.array<MyArrayElement>(MY_STATE, "key", {
3756
+ * deserializer: (myJsonElement) => convertToElement(myJsonElement),
3757
+ * });
3758
+ * ```
3759
+ */
3760
+ static array(stateDefinition, key,
3761
+ // We have them provide options for the element of the array, depending on future options we add, this could get a little weird.
3762
+ options // The array helper forces an initialValue of an empty array
3763
+ ) {
3764
+ return new KeyDefinition(stateDefinition, key, Object.assign(Object.assign({}, options), { deserializer: (jsonValue) => {
3765
+ if (jsonValue == null) {
3766
+ return null;
3767
+ }
3768
+ return jsonValue.map((v) => options.deserializer(v));
3769
+ } }));
3770
+ }
3771
+ /**
3772
+ * Creates a {@link KeyDefinition} for state that is a record.
3773
+ * @param stateDefinition The state definition to be added to the KeyDefinition
3774
+ * @param key The key to be added to the KeyDefinition
3775
+ * @param options The options to customize the final {@link KeyDefinition}.
3776
+ * @returns A {@link KeyDefinition} that contains a serializer that will run the provided deserializer for each
3777
+ * value in a record and returns every key as a string **unless that record is null, in which case it will return an record.**
3778
+ *
3779
+ * @example
3780
+ * ```typescript
3781
+ * const MY_KEY = KeyDefinition.record<MyRecordValue>(MY_STATE, "key", {
3782
+ * deserializer: (myJsonValue) => convertToValue(myJsonValue),
3783
+ * });
3784
+ * ```
3785
+ */
3786
+ static record(stateDefinition, key,
3787
+ // We have them provide options for the value of the record, depending on future options we add, this could get a little weird.
3788
+ options // The array helper forces an initialValue of an empty record
3789
+ ) {
3790
+ return new KeyDefinition(stateDefinition, key, Object.assign(Object.assign({}, options), { deserializer: (jsonValue) => {
3791
+ if (jsonValue == null) {
3792
+ return null;
3793
+ }
3794
+ const output = {};
3795
+ for (const key in jsonValue) {
3796
+ output[key] = options.deserializer(jsonValue[key]);
3797
+ }
3798
+ return output;
3799
+ } }));
3800
+ }
3801
+ /**
3802
+ * Create a string that should be unique across the entire application.
3803
+ * @returns A string that can be used to cache instances created via this key.
3804
+ */
3805
+ buildCacheKey() {
3806
+ return `${this.stateDefinition.storageLocation}_${this.stateDefinition.name}_${this.key}`;
3807
+ }
3808
+ }
3809
+ /**
3810
+ * Creates a {@link StorageKey} that points to the data at the given key definition for the specified user.
3811
+ * @param userId The userId of the user you want the key to be for.
3812
+ * @param keyDefinition The key definition of which data the key should point to.
3813
+ * @returns A key that is ready to be used in a storage service to get data.
3814
+ */
3815
+ function userKeyBuilder(userId, keyDefinition) {
3816
+ if (!Utils.isGuid(userId)) {
3817
+ throw new Error("You cannot build a user key without a valid UserId");
3818
+ }
3819
+ return `user_${userId}_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
3820
+ }
3821
+ /**
3822
+ * Creates a {@link StorageKey}
3823
+ * @param keyDefinition The key definition of which data the key should point to.
3824
+ * @returns A key that is ready to be used in a storage service to get data.
3825
+ */
3826
+ function globalKeyBuilder(keyDefinition) {
3827
+ return `global_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
3828
+ }
3829
+
3830
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/state-definition.ts
3831
+ /**
3832
+ * Defines the base location and instruction of where this state is expected to be located.
3833
+ */
3834
+ class StateDefinition {
3835
+ /**
3836
+ * Creates a new instance of {@link StateDefinition}, the creation of which is owned by the platform team.
3837
+ * @param name The name of the state, this needs to be unique from all other {@link StateDefinition}'s.
3838
+ * @param storageLocation The location of where this state should be stored.
3839
+ */
3840
+ constructor(name, storageLocation) {
3841
+ this.name = name;
3842
+ this.storageLocation = storageLocation;
3843
+ }
3844
+ }
3845
+
3846
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/key-definitions.ts
3847
+
3848
+
3849
+
3850
+ const ACCOUNT_MEMORY = new StateDefinition("account", "memory");
3851
+ const ACCOUNT_ACCOUNTS = new KeyDefinition(ACCOUNT_MEMORY, "accounts", {
3852
+ deserializer: (obj) => AccountsDeserializer(obj),
3853
+ });
3854
+ const ACCOUNT_ACTIVE_ACCOUNT_ID = new KeyDefinition(ACCOUNT_MEMORY, "activeAccountId", {
3855
+ deserializer: (id) => id,
3856
+ });
3857
+
3858
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/index.ts
3859
+
3860
+
3861
+
3862
+
3340
3863
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/enums/authentication-status.ts
3341
3864
  var AuthenticationStatus;
3342
3865
  (function (AuthenticationStatus) {
@@ -3357,31 +3880,43 @@ var account_service_awaiter = (undefined && undefined.__awaiter) || function (th
3357
3880
  };
3358
3881
 
3359
3882
 
3883
+
3884
+
3885
+ function AccountsDeserializer(accounts) {
3886
+ if (accounts == null) {
3887
+ return {};
3888
+ }
3889
+ return accounts;
3890
+ }
3360
3891
  class AccountServiceImplementation {
3361
- constructor(messagingService, logService) {
3892
+ constructor(messagingService, logService, globalStateProvider) {
3362
3893
  this.messagingService = messagingService;
3363
3894
  this.logService = logService;
3364
- this.accounts = new external_rxjs_namespaceObject.BehaviorSubject({});
3365
- this.activeAccountId = new external_rxjs_namespaceObject.BehaviorSubject(undefined);
3895
+ this.globalStateProvider = globalStateProvider;
3366
3896
  this.lock = new external_rxjs_namespaceObject.Subject();
3367
3897
  this.logout = new external_rxjs_namespaceObject.Subject();
3368
- this.accounts$ = this.accounts.asObservable();
3369
- this.activeAccount$ = this.activeAccountId.pipe((0,external_rxjs_namespaceObject.combineLatestWith)(this.accounts$), (0,external_rxjs_namespaceObject.map)(([id, accounts]) => (id ? Object.assign({ id }, accounts[id]) : undefined)), (0,external_rxjs_namespaceObject.distinctUntilChanged)(), (0,external_rxjs_namespaceObject.shareReplay)({ bufferSize: 1, refCount: false }));
3370
3898
  this.accountLock$ = this.lock.asObservable();
3371
3899
  this.accountLogout$ = this.logout.asObservable();
3900
+ this.accountsState = this.globalStateProvider.get(ACCOUNT_ACCOUNTS);
3901
+ this.activeAccountIdState = this.globalStateProvider.get(ACCOUNT_ACTIVE_ACCOUNT_ID);
3902
+ this.accounts$ = this.accountsState.state$.pipe((0,external_rxjs_namespaceObject.map)((accounts) => (accounts == null ? {} : accounts)));
3903
+ this.activeAccount$ = this.activeAccountIdState.state$.pipe((0,external_rxjs_namespaceObject.combineLatestWith)(this.accounts$), (0,external_rxjs_namespaceObject.map)(([id, accounts]) => (id ? Object.assign({ id }, accounts[id]) : undefined)), (0,external_rxjs_namespaceObject.distinctUntilChanged)(), (0,external_rxjs_namespaceObject.shareReplay)({ bufferSize: 1, refCount: false }));
3372
3904
  }
3373
3905
  addAccount(userId, accountData) {
3374
- this.accounts.value[userId] = accountData;
3375
- this.accounts.next(this.accounts.value);
3906
+ this.accountsState.update((accounts) => {
3907
+ accounts || (accounts = {});
3908
+ accounts[userId] = accountData;
3909
+ return accounts;
3910
+ });
3376
3911
  }
3377
3912
  setAccountName(userId, name) {
3378
- this.setAccountInfo(userId, Object.assign(Object.assign({}, this.accounts.value[userId]), { name }));
3913
+ this.setAccountInfo(userId, { name });
3379
3914
  }
3380
3915
  setAccountEmail(userId, email) {
3381
- this.setAccountInfo(userId, Object.assign(Object.assign({}, this.accounts.value[userId]), { email }));
3916
+ this.setAccountInfo(userId, { email });
3382
3917
  }
3383
3918
  setAccountStatus(userId, status) {
3384
- this.setAccountInfo(userId, Object.assign(Object.assign({}, this.accounts.value[userId]), { status }));
3919
+ this.setAccountInfo(userId, { status });
3385
3920
  if (status === AuthenticationStatus.LoggedOut) {
3386
3921
  this.logout.next(userId);
3387
3922
  }
@@ -3390,15 +3925,18 @@ class AccountServiceImplementation {
3390
3925
  }
3391
3926
  }
3392
3927
  switchAccount(userId) {
3393
- if (userId == null) {
3394
- // indicates no account is active
3395
- this.activeAccountId.next(undefined);
3396
- return;
3397
- }
3398
- if (this.accounts.value[userId] == null) {
3399
- throw new Error("Account does not exist");
3400
- }
3401
- this.activeAccountId.next(userId);
3928
+ this.activeAccountIdState.update((_, accounts) => {
3929
+ if (userId == null) {
3930
+ // indicates no account is active
3931
+ return undefined;
3932
+ }
3933
+ if ((accounts === null || accounts === void 0 ? void 0 : accounts[userId]) == null) {
3934
+ throw new Error("Account does not exist");
3935
+ }
3936
+ return userId;
3937
+ }, {
3938
+ combineLatestWith: this.accounts$,
3939
+ });
3402
3940
  }
3403
3941
  // TODO: update to use our own account status settings. Requires inverting direction of state service accounts flow
3404
3942
  delete() {
@@ -3413,17 +3951,23 @@ class AccountServiceImplementation {
3413
3951
  }
3414
3952
  });
3415
3953
  }
3416
- setAccountInfo(userId, accountInfo) {
3417
- if (this.accounts.value[userId] == null) {
3418
- throw new Error("Account does not exist");
3954
+ setAccountInfo(userId, update) {
3955
+ function newAccountInfo(oldAccountInfo) {
3956
+ return Object.assign(Object.assign({}, oldAccountInfo), update);
3419
3957
  }
3420
- // Avoid unnecessary updates
3421
- // TODO: Faster comparison, maybe include a hash on the objects?
3422
- if (JSON.stringify(this.accounts.value[userId]) === JSON.stringify(accountInfo)) {
3423
- return;
3424
- }
3425
- this.accounts.value[userId] = accountInfo;
3426
- this.accounts.next(this.accounts.value);
3958
+ this.accountsState.update((accounts) => {
3959
+ accounts[userId] = newAccountInfo(accounts[userId]);
3960
+ return accounts;
3961
+ }, {
3962
+ // Avoid unnecessary updates
3963
+ // TODO: Faster comparison, maybe include a hash on the objects?
3964
+ shouldUpdate: (accounts) => {
3965
+ if ((accounts === null || accounts === void 0 ? void 0 : accounts[userId]) == null) {
3966
+ throw new Error("Account does not exist");
3967
+ }
3968
+ return !accountInfoEqual(accounts[userId], newAccountInfo(accounts[userId]));
3969
+ },
3970
+ });
3427
3971
  }
3428
3972
  }
3429
3973
 
@@ -3550,105 +4094,16 @@ class PreloginRequest {
3550
4094
  }
3551
4095
  }
3552
4096
 
3553
- ;// CONCATENATED MODULE: ../../libs/common/src/models/response/error.response.ts
3554
-
3555
-
3556
- class ErrorResponse extends BaseResponse {
3557
- constructor(response, status, identityResponse) {
3558
- var _a, _b;
3559
- super(response);
3560
- let errorModel = null;
3561
- if (response != null) {
3562
- const responseErrorModel = this.getResponseProperty("ErrorModel");
3563
- if (responseErrorModel && identityResponse) {
3564
- errorModel = responseErrorModel;
3565
- }
3566
- else {
3567
- errorModel = response;
3568
- }
3569
- }
3570
- if (status === 429) {
3571
- this.message = "Rate limit exceeded. Try again later.";
3572
- }
3573
- else if (errorModel) {
3574
- this.message = this.getResponseProperty("Message", errorModel);
3575
- this.validationErrors = this.getResponseProperty("ValidationErrors", errorModel);
3576
- this.captchaSiteKey = (_b = (_a = this.validationErrors) === null || _a === void 0 ? void 0 : _a.HCaptcha_SiteKey) === null || _b === void 0 ? void 0 : _b[0];
3577
- this.captchaRequired = !utils_Utils.isNullOrWhitespace(this.captchaSiteKey);
3578
- }
3579
- this.statusCode = status;
3580
- }
3581
- getSingleMessage() {
3582
- if (this.validationErrors == null) {
3583
- return this.message;
3584
- }
3585
- for (const key in this.validationErrors) {
3586
- // eslint-disable-next-line
3587
- if (!this.validationErrors.hasOwnProperty(key)) {
3588
- continue;
3589
- }
3590
- if (this.validationErrors[key].length) {
3591
- return this.validationErrors[key][0];
3592
- }
3593
- }
3594
- return this.message;
3595
- }
3596
- getAllMessages() {
3597
- const messages = [];
3598
- if (this.validationErrors == null) {
3599
- return messages;
3600
- }
3601
- for (const key in this.validationErrors) {
3602
- // eslint-disable-next-line
3603
- if (!this.validationErrors.hasOwnProperty(key)) {
3604
- continue;
3605
- }
3606
- this.validationErrors[key].forEach((item) => {
3607
- let prefix = "";
3608
- if (key.indexOf("[") > -1 && key.indexOf("]") > -1) {
3609
- const lastSep = key.lastIndexOf(".");
3610
- prefix = key.substr(0, lastSep > -1 ? lastSep : key.length) + ": ";
3611
- }
3612
- messages.push(prefix + item);
3613
- });
3614
- }
3615
- return messages;
3616
- }
3617
- }
3618
-
3619
4097
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/enums/authentication-type.ts
3620
4098
  var authentication_type_AuthenticationType;
3621
4099
  (function (AuthenticationType) {
3622
4100
  AuthenticationType[AuthenticationType["Password"] = 0] = "Password";
3623
4101
  AuthenticationType[AuthenticationType["Sso"] = 1] = "Sso";
3624
4102
  AuthenticationType[AuthenticationType["UserApi"] = 2] = "UserApi";
3625
- AuthenticationType[AuthenticationType["Passwordless"] = 3] = "Passwordless";
4103
+ AuthenticationType[AuthenticationType["AuthRequest"] = 3] = "AuthRequest";
4104
+ AuthenticationType[AuthenticationType["WebAuthn"] = 4] = "WebAuthn";
3626
4105
  })(authentication_type_AuthenticationType || (authentication_type_AuthenticationType = {}));
3627
4106
 
3628
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/force-reset-password-reason.ts
3629
- /*
3630
- * This enum is used to determine if a user should be forced to reset their password
3631
- * on login (server flag) or unlock via MP (client evaluation).
3632
- */
3633
- var ForceResetPasswordReason;
3634
- (function (ForceResetPasswordReason) {
3635
- /**
3636
- * A password reset should not be forced.
3637
- */
3638
- ForceResetPasswordReason[ForceResetPasswordReason["None"] = 0] = "None";
3639
- /**
3640
- * Occurs when an organization admin forces a user to reset their password.
3641
- * Communicated via server flag.
3642
- */
3643
- ForceResetPasswordReason[ForceResetPasswordReason["AdminForcePasswordReset"] = 1] = "AdminForcePasswordReset";
3644
- /**
3645
- * Occurs when a user logs in / unlocks their vault with a master password that does not meet an organization's
3646
- * master password policy that is enforced on login/unlock.
3647
- * Only set client side b/c server can't evaluate MP.
3648
- */
3649
- ForceResetPasswordReason[ForceResetPasswordReason["WeakMasterPassword"] = 2] = "WeakMasterPassword";
3650
- })(ForceResetPasswordReason || (ForceResetPasswordReason = {}));
3651
-
3652
4107
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/identity-token/token.request.ts
3653
4108
  class TokenRequest {
3654
4109
  constructor(twoFactor, device) {
@@ -3662,8 +4117,8 @@ class TokenRequest {
3662
4117
  setTwoFactor(twoFactor) {
3663
4118
  this.twoFactor = twoFactor;
3664
4119
  }
3665
- setPasswordlessAccessCode(accessCode) {
3666
- this.passwordlessAuthRequest = accessCode;
4120
+ setAuthRequestAccessCode(accessCode) {
4121
+ this.authRequest = accessCode;
3667
4122
  }
3668
4123
  toIdentityToken(clientId) {
3669
4124
  const obj = {
@@ -3678,8 +4133,8 @@ class TokenRequest {
3678
4133
  // obj.devicePushToken = this.device.pushToken;
3679
4134
  }
3680
4135
  //passswordless login
3681
- if (this.passwordlessAuthRequest) {
3682
- obj.authRequest = this.passwordlessAuthRequest;
4136
+ if (this.authRequest) {
4137
+ obj.authRequest = this.authRequest;
3683
4138
  }
3684
4139
  if (this.twoFactor) {
3685
4140
  if (this.twoFactor.token && this.twoFactor.provider != null) {
@@ -3718,15 +4173,6 @@ class PasswordTokenRequest extends TokenRequest {
3718
4173
  }
3719
4174
  }
3720
4175
 
3721
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/identity-captcha.response.ts
3722
-
3723
- class IdentityCaptchaResponse extends BaseResponse {
3724
- constructor(response) {
3725
- super(response);
3726
- this.siteKey = this.getResponseProperty("HCaptcha_SiteKey");
3727
- }
3728
- }
3729
-
3730
4176
  ;// CONCATENATED MODULE: ../../libs/common/src/models/request/keys.request.ts
3731
4177
  class KeysRequest {
3732
4178
  constructor(publicKey, encryptedPrivateKey) {
@@ -3910,8 +4356,11 @@ class AccountKeys {
3910
4356
  this.cryptoSymmetricKey = new EncryptionPair();
3911
4357
  }
3912
4358
  toJSON() {
4359
+ // If you pass undefined into fromBufferToByteString, you will get an empty string back
4360
+ // which will cause all sorts of headaches down the line when you try to getPublicKey
4361
+ // and expect a Uint8Array and get an empty string instead.
3913
4362
  return utils_Utils.merge(this, {
3914
- publicKey: utils_Utils.fromBufferToByteString(this.publicKey),
4363
+ publicKey: this.publicKey ? utils_Utils.fromBufferToByteString(this.publicKey) : undefined,
3915
4364
  });
3916
4365
  }
3917
4366
  static fromJSON(obj) {
@@ -4101,6 +4550,35 @@ var TwoFactorProviderType;
4101
4550
  TwoFactorProviderType[TwoFactorProviderType["WebAuthn"] = 7] = "WebAuthn";
4102
4551
  })(TwoFactorProviderType || (TwoFactorProviderType = {}));
4103
4552
 
4553
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/force-set-password-reason.ts
4554
+ /*
4555
+ * This enum is used to determine if a user should be forced to initially set or reset their password
4556
+ * on login (server flag) or unlock via MP (client evaluation).
4557
+ */
4558
+ var ForceSetPasswordReason;
4559
+ (function (ForceSetPasswordReason) {
4560
+ /**
4561
+ * A password reset should not be forced.
4562
+ */
4563
+ ForceSetPasswordReason[ForceSetPasswordReason["None"] = 0] = "None";
4564
+ /**
4565
+ * Occurs when an organization admin forces a user to reset their password.
4566
+ * Communicated via server flag.
4567
+ */
4568
+ ForceSetPasswordReason[ForceSetPasswordReason["AdminForcePasswordReset"] = 1] = "AdminForcePasswordReset";
4569
+ /**
4570
+ * Occurs when a user logs in / unlocks their vault with a master password that does not meet an organization's
4571
+ * master password policy that is enforced on login/unlock.
4572
+ * Only set client side b/c server can't evaluate MP.
4573
+ */
4574
+ ForceSetPasswordReason[ForceSetPasswordReason["WeakMasterPassword"] = 2] = "WeakMasterPassword";
4575
+ /**
4576
+ * Occurs when a TDE user without a password obtains the password reset permission.
4577
+ * Set post login & decryption client side and by server in sync (to catch logged in users).
4578
+ */
4579
+ ForceSetPasswordReason[ForceSetPasswordReason["TdeUserWithoutPasswordHasPasswordResetPermission"] = 3] = "TdeUserWithoutPasswordHasPasswordResetPermission";
4580
+ })(ForceSetPasswordReason || (ForceSetPasswordReason = {}));
4581
+
4104
4582
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/auth-result.ts
4105
4583
 
4106
4584
 
@@ -4114,7 +4592,7 @@ class AuthResult {
4114
4592
  * not have a master password and is not using Key Connector.
4115
4593
  * */
4116
4594
  this.resetMasterPassword = false;
4117
- this.forcePasswordReset = ForceResetPasswordReason.None;
4595
+ this.forcePasswordReset = ForceSetPasswordReason.None;
4118
4596
  this.twoFactorProviders = null;
4119
4597
  }
4120
4598
  get requiresCaptcha() {
@@ -4144,6 +4622,15 @@ class TokenTwoFactorRequest {
4144
4622
  }
4145
4623
  }
4146
4624
 
4625
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/identity-captcha.response.ts
4626
+
4627
+ class IdentityCaptchaResponse extends BaseResponse {
4628
+ constructor(response) {
4629
+ super(response);
4630
+ this.siteKey = this.getResponseProperty("HCaptcha_SiteKey");
4631
+ }
4632
+ }
4633
+
4147
4634
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/master-password-policy.response.ts
4148
4635
 
4149
4636
  class MasterPasswordPolicyResponse extends BaseResponse {
@@ -4186,10 +4673,26 @@ class TrustedDeviceUserDecryptionOptionResponse extends BaseResponse {
4186
4673
  }
4187
4674
  }
4188
4675
 
4676
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/user-decryption-options/webauthn-prf-decryption-option.response.ts
4677
+
4678
+
4679
+ class WebAuthnPrfDecryptionOptionResponse extends BaseResponse {
4680
+ constructor(response) {
4681
+ super(response);
4682
+ if (response.EncryptedPrivateKey) {
4683
+ this.encryptedPrivateKey = new EncString(this.getResponseProperty("EncryptedPrivateKey"));
4684
+ }
4685
+ if (response.EncryptedUserKey) {
4686
+ this.encryptedUserKey = new EncString(this.getResponseProperty("EncryptedUserKey"));
4687
+ }
4688
+ }
4689
+ }
4690
+
4189
4691
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/user-decryption-options/user-decryption-options.response.ts
4190
4692
 
4191
4693
 
4192
4694
 
4695
+
4193
4696
  class UserDecryptionOptionsResponse extends BaseResponse {
4194
4697
  constructor(response) {
4195
4698
  super(response);
@@ -4200,6 +4703,9 @@ class UserDecryptionOptionsResponse extends BaseResponse {
4200
4703
  if (response.KeyConnectorOption) {
4201
4704
  this.keyConnectorOption = new KeyConnectorUserDecryptionOptionResponse(this.getResponseProperty("KeyConnectorOption"));
4202
4705
  }
4706
+ if (response.WebAuthnPrfOption) {
4707
+ this.webAuthnPrfOption = new WebAuthnPrfDecryptionOptionResponse(this.getResponseProperty("WebAuthnPrfOption"));
4708
+ }
4203
4709
  }
4204
4710
  }
4205
4711
 
@@ -4277,7 +4783,7 @@ var login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thi
4277
4783
 
4278
4784
 
4279
4785
 
4280
- class LogInStrategy {
4786
+ class LoginStrategy {
4281
4787
  constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService) {
4282
4788
  this.cryptoService = cryptoService;
4283
4789
  this.apiService = apiService;
@@ -4381,7 +4887,7 @@ class LogInStrategy {
4381
4887
  result.resetMasterPassword = response.resetMasterPassword;
4382
4888
  // Convert boolean to enum
4383
4889
  if (response.forcePasswordReset) {
4384
- result.forcePasswordReset = ForceResetPasswordReason.AdminForcePasswordReset;
4890
+ result.forcePasswordReset = ForceSetPasswordReason.AdminForcePasswordReset;
4385
4891
  }
4386
4892
  // Must come before setting keys, user key needs email to update additional keys
4387
4893
  yield this.saveAccountInformation(response);
@@ -4433,6 +4939,93 @@ class LogInStrategy {
4433
4939
  }
4434
4940
  }
4435
4941
 
4942
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/login-strategies/auth-request-login.strategy.ts
4943
+ var auth_request_login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4944
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4945
+ return new (P || (P = Promise))(function (resolve, reject) {
4946
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4947
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4948
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4949
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4950
+ });
4951
+ };
4952
+
4953
+
4954
+ class AuthRequestLoginStrategy extends LoginStrategy {
4955
+ get email() {
4956
+ return this.tokenRequest.email;
4957
+ }
4958
+ get accessCode() {
4959
+ return this.authRequestCredentials.accessCode;
4960
+ }
4961
+ get authRequestId() {
4962
+ return this.authRequestCredentials.authRequestId;
4963
+ }
4964
+ constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, deviceTrustCryptoService) {
4965
+ super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4966
+ this.deviceTrustCryptoService = deviceTrustCryptoService;
4967
+ }
4968
+ logIn(credentials) {
4969
+ return auth_request_login_strategy_awaiter(this, void 0, void 0, function* () {
4970
+ // NOTE: To avoid DeadObject references on Firefox, do not set the credentials object directly
4971
+ // Use deep copy in future if objects are added that were created in popup
4972
+ this.authRequestCredentials = Object.assign({}, credentials);
4973
+ this.tokenRequest = new PasswordTokenRequest(credentials.email, credentials.accessCode, null, yield this.buildTwoFactor(credentials.twoFactor), yield this.buildDeviceRequest());
4974
+ this.tokenRequest.setAuthRequestAccessCode(credentials.authRequestId);
4975
+ const [authResult] = yield this.startLogIn();
4976
+ return authResult;
4977
+ });
4978
+ }
4979
+ logInTwoFactor(twoFactor, captchaResponse) {
4980
+ const _super = Object.create(null, {
4981
+ logInTwoFactor: { get: () => super.logInTwoFactor }
4982
+ });
4983
+ return auth_request_login_strategy_awaiter(this, void 0, void 0, function* () {
4984
+ this.tokenRequest.captchaResponse = captchaResponse !== null && captchaResponse !== void 0 ? captchaResponse : this.captchaBypassToken;
4985
+ return _super.logInTwoFactor.call(this, twoFactor);
4986
+ });
4987
+ }
4988
+ setMasterKey(response) {
4989
+ return auth_request_login_strategy_awaiter(this, void 0, void 0, function* () {
4990
+ if (this.authRequestCredentials.decryptedMasterKey &&
4991
+ this.authRequestCredentials.decryptedMasterKeyHash) {
4992
+ yield this.cryptoService.setMasterKey(this.authRequestCredentials.decryptedMasterKey);
4993
+ yield this.cryptoService.setMasterKeyHash(this.authRequestCredentials.decryptedMasterKeyHash);
4994
+ }
4995
+ });
4996
+ }
4997
+ setUserKey(response) {
4998
+ return auth_request_login_strategy_awaiter(this, void 0, void 0, function* () {
4999
+ // User now may or may not have a master password
5000
+ // but set the master key encrypted user key if it exists regardless
5001
+ yield this.cryptoService.setMasterKeyEncryptedUserKey(response.key);
5002
+ if (this.authRequestCredentials.decryptedUserKey) {
5003
+ yield this.cryptoService.setUserKey(this.authRequestCredentials.decryptedUserKey);
5004
+ }
5005
+ else {
5006
+ yield this.trySetUserKeyWithMasterKey();
5007
+ // Establish trust if required after setting user key
5008
+ yield this.deviceTrustCryptoService.trustDeviceIfRequired();
5009
+ }
5010
+ });
5011
+ }
5012
+ trySetUserKeyWithMasterKey() {
5013
+ return auth_request_login_strategy_awaiter(this, void 0, void 0, function* () {
5014
+ const masterKey = yield this.cryptoService.getMasterKey();
5015
+ if (masterKey) {
5016
+ const userKey = yield this.cryptoService.decryptUserKeyWithMasterKey(masterKey);
5017
+ yield this.cryptoService.setUserKey(userKey);
5018
+ }
5019
+ });
5020
+ }
5021
+ setPrivateKey(response) {
5022
+ var _a;
5023
+ return auth_request_login_strategy_awaiter(this, void 0, void 0, function* () {
5024
+ yield this.cryptoService.setPrivateKey((_a = response.privateKey) !== null && _a !== void 0 ? _a : (yield this.createKeyPairForOldAccount()));
5025
+ });
5026
+ }
5027
+ }
5028
+
4436
5029
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/login-strategies/password-login.strategy.ts
4437
5030
  var password_login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4438
5031
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -4449,7 +5042,7 @@ var password_login_strategy_awaiter = (undefined && undefined.__awaiter) || func
4449
5042
 
4450
5043
 
4451
5044
 
4452
- class PasswordLogInStrategy extends LogInStrategy {
5045
+ class PasswordLoginStrategy extends LoginStrategy {
4453
5046
  get email() {
4454
5047
  return this.tokenRequest.email;
4455
5048
  }
@@ -4466,7 +5059,7 @@ class PasswordLogInStrategy extends LogInStrategy {
4466
5059
  * Options to track if the user needs to update their password due to a password that does not meet an organization's
4467
5060
  * master password policy.
4468
5061
  */
4469
- this.forcePasswordResetReason = ForceResetPasswordReason.None;
5062
+ this.forcePasswordResetReason = ForceSetPasswordReason.None;
4470
5063
  }
4471
5064
  logInTwoFactor(twoFactor, captchaResponse) {
4472
5065
  const _super = Object.create(null, {
@@ -4478,8 +5071,8 @@ class PasswordLogInStrategy extends LogInStrategy {
4478
5071
  // 2FA was successful, save the force update password options with the state service if defined
4479
5072
  if (!result.requiresTwoFactor &&
4480
5073
  !result.requiresCaptcha &&
4481
- this.forcePasswordResetReason != ForceResetPasswordReason.None) {
4482
- yield this.stateService.setForcePasswordResetReason(this.forcePasswordResetReason);
5074
+ this.forcePasswordResetReason != ForceSetPasswordReason.None) {
5075
+ yield this.stateService.setForceSetPasswordReason(this.forcePasswordResetReason);
4483
5076
  result.forcePasswordReset = this.forcePasswordResetReason;
4484
5077
  }
4485
5078
  return result;
@@ -4502,12 +5095,12 @@ class PasswordLogInStrategy extends LogInStrategy {
4502
5095
  if (!meetsRequirements) {
4503
5096
  if (authResult.requiresCaptcha || authResult.requiresTwoFactor) {
4504
5097
  // Save the flag to this strategy for later use as the master password is about to pass out of scope
4505
- this.forcePasswordResetReason = ForceResetPasswordReason.WeakMasterPassword;
5098
+ this.forcePasswordResetReason = ForceSetPasswordReason.WeakMasterPassword;
4506
5099
  }
4507
5100
  else {
4508
5101
  // Authentication was successful, save the force update password options with the state service
4509
- yield this.stateService.setForcePasswordResetReason(ForceResetPasswordReason.WeakMasterPassword);
4510
- authResult.forcePasswordReset = ForceResetPasswordReason.WeakMasterPassword;
5102
+ yield this.stateService.setForceSetPasswordReason(ForceSetPasswordReason.WeakMasterPassword);
5103
+ authResult.forcePasswordReset = ForceSetPasswordReason.WeakMasterPassword;
4511
5104
  }
4512
5105
  }
4513
5106
  }
@@ -4556,91 +5149,6 @@ class PasswordLogInStrategy extends LogInStrategy {
4556
5149
  }
4557
5150
  }
4558
5151
 
4559
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/login-strategies/passwordless-login.strategy.ts
4560
- var passwordless_login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4561
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4562
- return new (P || (P = Promise))(function (resolve, reject) {
4563
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4564
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4565
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4566
- step((generator = generator.apply(thisArg, _arguments || [])).next());
4567
- });
4568
- };
4569
-
4570
-
4571
- class PasswordlessLogInStrategy extends LogInStrategy {
4572
- get email() {
4573
- return this.tokenRequest.email;
4574
- }
4575
- get accessCode() {
4576
- return this.passwordlessCredentials.accessCode;
4577
- }
4578
- get authRequestId() {
4579
- return this.passwordlessCredentials.authRequestId;
4580
- }
4581
- constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, deviceTrustCryptoService) {
4582
- super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4583
- this.deviceTrustCryptoService = deviceTrustCryptoService;
4584
- }
4585
- logIn(credentials) {
4586
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4587
- this.passwordlessCredentials = credentials;
4588
- this.tokenRequest = new PasswordTokenRequest(credentials.email, credentials.accessCode, null, yield this.buildTwoFactor(credentials.twoFactor), yield this.buildDeviceRequest());
4589
- this.tokenRequest.setPasswordlessAccessCode(credentials.authRequestId);
4590
- const [authResult] = yield this.startLogIn();
4591
- return authResult;
4592
- });
4593
- }
4594
- logInTwoFactor(twoFactor, captchaResponse) {
4595
- const _super = Object.create(null, {
4596
- logInTwoFactor: { get: () => super.logInTwoFactor }
4597
- });
4598
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4599
- this.tokenRequest.captchaResponse = captchaResponse !== null && captchaResponse !== void 0 ? captchaResponse : this.captchaBypassToken;
4600
- return _super.logInTwoFactor.call(this, twoFactor);
4601
- });
4602
- }
4603
- setMasterKey(response) {
4604
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4605
- if (this.passwordlessCredentials.decryptedMasterKey &&
4606
- this.passwordlessCredentials.decryptedMasterKeyHash) {
4607
- yield this.cryptoService.setMasterKey(this.passwordlessCredentials.decryptedMasterKey);
4608
- yield this.cryptoService.setMasterKeyHash(this.passwordlessCredentials.decryptedMasterKeyHash);
4609
- }
4610
- });
4611
- }
4612
- setUserKey(response) {
4613
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4614
- // User now may or may not have a master password
4615
- // but set the master key encrypted user key if it exists regardless
4616
- yield this.cryptoService.setMasterKeyEncryptedUserKey(response.key);
4617
- if (this.passwordlessCredentials.decryptedUserKey) {
4618
- yield this.cryptoService.setUserKey(this.passwordlessCredentials.decryptedUserKey);
4619
- }
4620
- else {
4621
- yield this.trySetUserKeyWithMasterKey();
4622
- // Establish trust if required after setting user key
4623
- yield this.deviceTrustCryptoService.trustDeviceIfRequired();
4624
- }
4625
- });
4626
- }
4627
- trySetUserKeyWithMasterKey() {
4628
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4629
- const masterKey = yield this.cryptoService.getMasterKey();
4630
- if (masterKey) {
4631
- const userKey = yield this.cryptoService.decryptUserKeyWithMasterKey(masterKey);
4632
- yield this.cryptoService.setUserKey(userKey);
4633
- }
4634
- });
4635
- }
4636
- setPrivateKey(response) {
4637
- var _a;
4638
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4639
- yield this.cryptoService.setPrivateKey((_a = response.privateKey) !== null && _a !== void 0 ? _a : (yield this.createKeyPairForOldAccount()));
4640
- });
4641
- }
4642
- }
4643
-
4644
5152
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/identity-token/sso-token.request.ts
4645
5153
 
4646
5154
  class SsoTokenRequest extends TokenRequest {
@@ -4676,7 +5184,7 @@ var sso_login_strategy_awaiter = (undefined && undefined.__awaiter) || function
4676
5184
 
4677
5185
 
4678
5186
 
4679
- class SsoLogInStrategy extends LogInStrategy {
5187
+ class SsoLoginStrategy extends LoginStrategy {
4680
5188
  constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, keyConnectorService, deviceTrustCryptoService, authReqCryptoService, i18nService) {
4681
5189
  super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4682
5190
  this.keyConnectorService = keyConnectorService;
@@ -4692,8 +5200,8 @@ class SsoLogInStrategy extends LogInStrategy {
4692
5200
  this.email = ssoAuthResult.email;
4693
5201
  this.ssoEmail2FaSessionToken = ssoAuthResult.ssoEmail2FaSessionToken;
4694
5202
  // Auth guard currently handles redirects for this.
4695
- if (ssoAuthResult.forcePasswordReset == ForceResetPasswordReason.AdminForcePasswordReset) {
4696
- yield this.stateService.setForcePasswordResetReason(ssoAuthResult.forcePasswordReset);
5203
+ if (ssoAuthResult.forcePasswordReset == ForceSetPasswordReason.AdminForcePasswordReset) {
5204
+ yield this.stateService.setForceSetPasswordReason(ssoAuthResult.forcePasswordReset);
4697
5205
  }
4698
5206
  return ssoAuthResult;
4699
5207
  });
@@ -4892,7 +5400,7 @@ var user_api_login_strategy_awaiter = (undefined && undefined.__awaiter) || func
4892
5400
  };
4893
5401
 
4894
5402
 
4895
- class UserApiLogInStrategy extends LogInStrategy {
5403
+ class UserApiLoginStrategy extends LoginStrategy {
4896
5404
  constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, environmentService, keyConnectorService) {
4897
5405
  super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4898
5406
  this.environmentService = environmentService;
@@ -4943,6 +5451,86 @@ class UserApiLogInStrategy extends LogInStrategy {
4943
5451
  }
4944
5452
  }
4945
5453
 
5454
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/identity-token/webauthn-login-token.request.ts
5455
+
5456
+ class WebAuthnLoginTokenRequest extends TokenRequest {
5457
+ constructor(token, deviceResponse, device) {
5458
+ super(undefined, device);
5459
+ this.token = token;
5460
+ this.deviceResponse = deviceResponse;
5461
+ }
5462
+ toIdentityToken(clientId) {
5463
+ const obj = super.toIdentityToken(clientId);
5464
+ obj.grant_type = "webauthn";
5465
+ obj.token = this.token;
5466
+ // must be a string b/c sending as form encoded data
5467
+ obj.deviceResponse = JSON.stringify(this.deviceResponse);
5468
+ return obj;
5469
+ }
5470
+ }
5471
+
5472
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/login-strategies/webauthn-login.strategy.ts
5473
+ var webauthn_login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
5474
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5475
+ return new (P || (P = Promise))(function (resolve, reject) {
5476
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5477
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5478
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5479
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
5480
+ });
5481
+ };
5482
+
5483
+
5484
+
5485
+ class WebAuthnLoginStrategy extends LoginStrategy {
5486
+ setMasterKey() {
5487
+ return webauthn_login_strategy_awaiter(this, void 0, void 0, function* () {
5488
+ return Promise.resolve();
5489
+ });
5490
+ }
5491
+ setUserKey(idTokenResponse) {
5492
+ var _a;
5493
+ return webauthn_login_strategy_awaiter(this, void 0, void 0, function* () {
5494
+ const userDecryptionOptions = idTokenResponse === null || idTokenResponse === void 0 ? void 0 : idTokenResponse.userDecryptionOptions;
5495
+ if (userDecryptionOptions === null || userDecryptionOptions === void 0 ? void 0 : userDecryptionOptions.webAuthnPrfOption) {
5496
+ const webAuthnPrfOption = (_a = idTokenResponse.userDecryptionOptions) === null || _a === void 0 ? void 0 : _a.webAuthnPrfOption;
5497
+ // confirm we still have the prf key
5498
+ if (!this.credentials.prfKey) {
5499
+ return;
5500
+ }
5501
+ // decrypt prf encrypted private key
5502
+ const privateKey = yield this.cryptoService.decryptToBytes(webAuthnPrfOption.encryptedPrivateKey, this.credentials.prfKey);
5503
+ // decrypt user key with private key
5504
+ const userKey = yield this.cryptoService.rsaDecrypt(webAuthnPrfOption.encryptedUserKey.encryptedString, privateKey);
5505
+ if (userKey) {
5506
+ yield this.cryptoService.setUserKey(new SymmetricCryptoKey(userKey));
5507
+ }
5508
+ }
5509
+ });
5510
+ }
5511
+ setPrivateKey(response) {
5512
+ var _a;
5513
+ return webauthn_login_strategy_awaiter(this, void 0, void 0, function* () {
5514
+ yield this.cryptoService.setPrivateKey((_a = response.privateKey) !== null && _a !== void 0 ? _a : (yield this.createKeyPairForOldAccount()));
5515
+ });
5516
+ }
5517
+ logInTwoFactor() {
5518
+ return webauthn_login_strategy_awaiter(this, void 0, void 0, function* () {
5519
+ throw new Error("2FA not supported yet for WebAuthn Login.");
5520
+ });
5521
+ }
5522
+ logIn(credentials) {
5523
+ return webauthn_login_strategy_awaiter(this, void 0, void 0, function* () {
5524
+ // NOTE: To avoid DeadObject references on Firefox, do not set the credentials object directly
5525
+ // Use deep copy in future if objects are added that were created in popup
5526
+ this.credentials = Object.assign({}, credentials);
5527
+ this.tokenRequest = new WebAuthnLoginTokenRequest(credentials.token, credentials.deviceResponse, yield this.buildDeviceRequest());
5528
+ const [authResult] = yield this.startLogIn();
5529
+ return authResult;
5530
+ });
5531
+ }
5532
+ }
5533
+
4946
5534
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/passwordless-auth.request.ts
4947
5535
  class PasswordlessAuthRequest {
4948
5536
  constructor(key, masterPasswordHash, deviceIdentifier, requestApproved) {
@@ -4976,33 +5564,34 @@ var auth_service_awaiter = (undefined && undefined.__awaiter) || function (thisA
4976
5564
 
4977
5565
 
4978
5566
 
5567
+
4979
5568
  const sessionTimeoutLength = 2 * 60 * 1000; // 2 minutes
4980
5569
  class AuthService {
4981
5570
  get email() {
4982
- if (this.logInStrategy instanceof PasswordLogInStrategy ||
4983
- this.logInStrategy instanceof PasswordlessLogInStrategy ||
4984
- this.logInStrategy instanceof SsoLogInStrategy) {
5571
+ if (this.logInStrategy instanceof PasswordLoginStrategy ||
5572
+ this.logInStrategy instanceof AuthRequestLoginStrategy ||
5573
+ this.logInStrategy instanceof SsoLoginStrategy) {
4985
5574
  return this.logInStrategy.email;
4986
5575
  }
4987
5576
  return null;
4988
5577
  }
4989
5578
  get masterPasswordHash() {
4990
- return this.logInStrategy instanceof PasswordLogInStrategy
5579
+ return this.logInStrategy instanceof PasswordLoginStrategy
4991
5580
  ? this.logInStrategy.masterPasswordHash
4992
5581
  : null;
4993
5582
  }
4994
5583
  get accessCode() {
4995
- return this.logInStrategy instanceof PasswordlessLogInStrategy
5584
+ return this.logInStrategy instanceof AuthRequestLoginStrategy
4996
5585
  ? this.logInStrategy.accessCode
4997
5586
  : null;
4998
5587
  }
4999
5588
  get authRequestId() {
5000
- return this.logInStrategy instanceof PasswordlessLogInStrategy
5589
+ return this.logInStrategy instanceof AuthRequestLoginStrategy
5001
5590
  ? this.logInStrategy.authRequestId
5002
5591
  : null;
5003
5592
  }
5004
5593
  get ssoEmail2FaSessionToken() {
5005
- return this.logInStrategy instanceof SsoLogInStrategy
5594
+ return this.logInStrategy instanceof SsoLoginStrategy
5006
5595
  ? this.logInStrategy.ssoEmail2FaSessionToken
5007
5596
  : null;
5008
5597
  }
@@ -5032,18 +5621,23 @@ class AuthService {
5032
5621
  let strategy;
5033
5622
  switch (credentials.type) {
5034
5623
  case authentication_type_AuthenticationType.Password:
5035
- strategy = new PasswordLogInStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.passwordStrengthService, this.policyService, this);
5624
+ strategy = new PasswordLoginStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.passwordStrengthService, this.policyService, this);
5036
5625
  break;
5037
5626
  case authentication_type_AuthenticationType.Sso:
5038
- strategy = new SsoLogInStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.keyConnectorService, this.deviceTrustCryptoService, this.authReqCryptoService, this.i18nService);
5627
+ strategy = new SsoLoginStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.keyConnectorService, this.deviceTrustCryptoService, this.authReqCryptoService, this.i18nService);
5039
5628
  break;
5040
5629
  case authentication_type_AuthenticationType.UserApi:
5041
- strategy = new UserApiLogInStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.environmentService, this.keyConnectorService);
5630
+ strategy = new UserApiLoginStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.environmentService, this.keyConnectorService);
5042
5631
  break;
5043
- case authentication_type_AuthenticationType.Passwordless:
5044
- strategy = new PasswordlessLogInStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.deviceTrustCryptoService);
5632
+ case authentication_type_AuthenticationType.AuthRequest:
5633
+ strategy = new AuthRequestLoginStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.deviceTrustCryptoService);
5634
+ break;
5635
+ case authentication_type_AuthenticationType.WebAuthn:
5636
+ strategy = new WebAuthnLoginStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService);
5045
5637
  break;
5046
5638
  }
5639
+ // Note: Do not set the credentials object directly on the strategy. They are
5640
+ // created in the popup and can cause DeadObject references on Firefox.
5047
5641
  const result = yield strategy.logIn(credentials);
5048
5642
  if (result === null || result === void 0 ? void 0 : result.requiresTwoFactor) {
5049
5643
  this.saveState(strategy);
@@ -5078,16 +5672,16 @@ class AuthService {
5078
5672
  this.messagingService.send("loggedOut");
5079
5673
  }
5080
5674
  authingWithUserApiKey() {
5081
- return this.logInStrategy instanceof UserApiLogInStrategy;
5675
+ return this.logInStrategy instanceof UserApiLoginStrategy;
5082
5676
  }
5083
5677
  authingWithSso() {
5084
- return this.logInStrategy instanceof SsoLogInStrategy;
5678
+ return this.logInStrategy instanceof SsoLoginStrategy;
5085
5679
  }
5086
5680
  authingWithPassword() {
5087
- return this.logInStrategy instanceof PasswordLogInStrategy;
5681
+ return this.logInStrategy instanceof PasswordLoginStrategy;
5088
5682
  }
5089
5683
  authingWithPasswordless() {
5090
- return this.logInStrategy instanceof PasswordlessLogInStrategy;
5684
+ return this.logInStrategy instanceof AuthRequestLoginStrategy;
5091
5685
  }
5092
5686
  getAuthStatus(userId) {
5093
5687
  return auth_service_awaiter(this, void 0, void 0, function* () {
@@ -15485,6 +16079,7 @@ var environment_service_awaiter = (undefined && undefined.__awaiter) || function
15485
16079
 
15486
16080
 
15487
16081
 
16082
+
15488
16083
  class environment_service_EnvironmentService {
15489
16084
  constructor(stateService) {
15490
16085
  this.stateService = stateService;
@@ -15710,6 +16305,27 @@ class environment_service_EnvironmentService {
15710
16305
  this.notificationsUrl == null &&
15711
16306
  this.eventsUrl == null);
15712
16307
  }
16308
+ getHost(userId) {
16309
+ return environment_service_awaiter(this, void 0, void 0, function* () {
16310
+ const region = yield this.getRegion(userId ? userId : null);
16311
+ switch (region) {
16312
+ case Region.US:
16313
+ return RegionDomain.US;
16314
+ case Region.EU:
16315
+ return RegionDomain.EU;
16316
+ default: {
16317
+ // Environment is self-hosted
16318
+ const envUrls = yield this.stateService.getEnvironmentUrls(userId ? { userId: userId } : null);
16319
+ return utils_Utils.getHost(envUrls.webVault || envUrls.base);
16320
+ }
16321
+ }
16322
+ });
16323
+ }
16324
+ getRegion(userId) {
16325
+ return environment_service_awaiter(this, void 0, void 0, function* () {
16326
+ return this.stateService.getRegion(userId ? { userId: userId } : null);
16327
+ });
16328
+ }
15713
16329
  setRegion(region) {
15714
16330
  return environment_service_awaiter(this, void 0, void 0, function* () {
15715
16331
  this.selectedRegion = region;
@@ -16068,10 +16684,18 @@ var memory_storage_service_awaiter = (undefined && undefined.__awaiter) || funct
16068
16684
  });
16069
16685
  };
16070
16686
 
16687
+
16071
16688
  class MemoryStorageService extends AbstractMemoryStorageService {
16072
16689
  constructor() {
16073
16690
  super(...arguments);
16074
16691
  this.store = new Map();
16692
+ this.updatesSubject = new external_rxjs_namespaceObject.Subject();
16693
+ }
16694
+ get valuesRequireDeserialization() {
16695
+ return false;
16696
+ }
16697
+ get updates$() {
16698
+ return this.updatesSubject.asObservable();
16075
16699
  }
16076
16700
  get(key) {
16077
16701
  if (this.store.has(key)) {
@@ -16090,10 +16714,12 @@ class MemoryStorageService extends AbstractMemoryStorageService {
16090
16714
  return this.remove(key);
16091
16715
  }
16092
16716
  this.store.set(key, obj);
16717
+ this.updatesSubject.next({ key, updateType: "save" });
16093
16718
  return Promise.resolve();
16094
16719
  }
16095
16720
  remove(key) {
16096
16721
  this.store.delete(key);
16722
+ this.updatesSubject.next({ key, updateType: "remove" });
16097
16723
  return Promise.resolve();
16098
16724
  }
16099
16725
  getBypassCache(key) {
@@ -16108,6 +16734,27 @@ class NoopMessagingService {
16108
16734
  }
16109
16735
  }
16110
16736
 
16737
+ ;// CONCATENATED MODULE: ../browser/src/autofill/utils/autofill-overlay.enum.ts
16738
+ const AutofillOverlayElement = {
16739
+ Button: "autofill-overlay-button",
16740
+ List: "autofill-overlay-list",
16741
+ };
16742
+ const AutofillOverlayPort = {
16743
+ Button: "autofill-overlay-button-port",
16744
+ List: "autofill-overlay-list-port",
16745
+ };
16746
+ const RedirectFocusDirection = {
16747
+ Current: "current",
16748
+ Previous: "previous",
16749
+ Next: "next",
16750
+ };
16751
+ const AutofillOverlayVisibility = {
16752
+ Off: 0,
16753
+ OnButtonClick: 1,
16754
+ OnFieldFocus: 2,
16755
+ };
16756
+
16757
+
16111
16758
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/data/provider.data.ts
16112
16759
  class ProviderData {
16113
16760
  constructor(response) {
@@ -16198,7 +16845,7 @@ class MigrationBuilder {
16198
16845
  helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) should migrate: ${shouldMigrate} - ${direction}`);
16199
16846
  if (shouldMigrate) {
16200
16847
  const method = direction === "up" ? migrator.migrate : migrator.rollback;
16201
- yield method(helper);
16848
+ yield method.bind(migrator)(helper);
16202
16849
  helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) migrated - ${direction}`);
16203
16850
  yield migrator.updateVersion(helper, direction);
16204
16851
  helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) updated version - ${direction}`);
@@ -16597,6 +17244,70 @@ class MoveStateVersionMigrator extends Migrator {
16597
17244
  }
16598
17245
  }
16599
17246
 
17247
+ ;// CONCATENATED MODULE: ../../libs/common/src/state-migrations/migrations/9-move-browser-settings-to-global.ts
17248
+ var _9_move_browser_settings_to_global_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
17249
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17250
+ return new (P || (P = Promise))(function (resolve, reject) {
17251
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17252
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17253
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17254
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17255
+ });
17256
+ };
17257
+
17258
+ class MoveBrowserSettingsToGlobal extends Migrator {
17259
+ // Will first check if any of the accounts have a value from the given accountSelector
17260
+ // if they do have a value it will set that value into global state but if multiple
17261
+ // users have differing values it will prefer the false setting,
17262
+ // if all users have true then it will take true.
17263
+ tryAddSetting(accounts, accountSelector, globalSetter) {
17264
+ const hasValue = accounts.some(({ account }) => {
17265
+ return accountSelector(account) !== undefined;
17266
+ });
17267
+ if (hasValue) {
17268
+ const value = !accounts.some(({ account }) => {
17269
+ var _a;
17270
+ return ((_a = accountSelector(account)) !== null && _a !== void 0 ? _a : false) === false;
17271
+ });
17272
+ globalSetter(value);
17273
+ }
17274
+ }
17275
+ migrate(helper) {
17276
+ return _9_move_browser_settings_to_global_awaiter(this, void 0, void 0, function* () {
17277
+ const global = yield helper.get("global");
17278
+ const accounts = yield helper.getAccounts();
17279
+ const globalNeverDomainsValue = accounts.reduce((accumulator, { account }) => {
17280
+ var _a, _b;
17281
+ const normalizedNeverDomains = (_b = (_a = account.settings) === null || _a === void 0 ? void 0 : _a.neverDomains) !== null && _b !== void 0 ? _b : {};
17282
+ for (const [id, value] of Object.entries(normalizedNeverDomains)) {
17283
+ accumulator !== null && accumulator !== void 0 ? accumulator : (accumulator = {});
17284
+ accumulator[id] = value;
17285
+ }
17286
+ return accumulator;
17287
+ }, undefined);
17288
+ const targetGlobalState = {};
17289
+ if (globalNeverDomainsValue != null) {
17290
+ targetGlobalState.neverDomains = globalNeverDomainsValue;
17291
+ }
17292
+ this.tryAddSetting(accounts, (a) => { var _a; return (_a = a.settings) === null || _a === void 0 ? void 0 : _a.disableAddLoginNotification; }, (v) => (targetGlobalState.disableAddLoginNotification = v));
17293
+ this.tryAddSetting(accounts, (a) => { var _a; return (_a = a.settings) === null || _a === void 0 ? void 0 : _a.disableChangedPasswordNotification; }, (v) => (targetGlobalState.disableChangedPasswordNotification = v));
17294
+ this.tryAddSetting(accounts, (a) => { var _a; return (_a = a.settings) === null || _a === void 0 ? void 0 : _a.disableContextMenuItem; }, (v) => (targetGlobalState.disableContextMenuItem = v));
17295
+ yield helper.set("global", Object.assign(Object.assign({}, global), targetGlobalState));
17296
+ yield Promise.all(accounts.map(({ userId, account }) => _9_move_browser_settings_to_global_awaiter(this, void 0, void 0, function* () {
17297
+ var _a, _b, _c, _d;
17298
+ (_a = account.settings) === null || _a === void 0 ? true : delete _a.disableAddLoginNotification;
17299
+ (_b = account.settings) === null || _b === void 0 ? true : delete _b.disableChangedPasswordNotification;
17300
+ (_c = account.settings) === null || _c === void 0 ? true : delete _c.disableContextMenuItem;
17301
+ (_d = account.settings) === null || _d === void 0 ? true : delete _d.neverDomains;
17302
+ yield helper.set(userId, account);
17303
+ })));
17304
+ });
17305
+ }
17306
+ rollback(helper) {
17307
+ throw new Error("Method not implemented.");
17308
+ }
17309
+ }
17310
+
16600
17311
  ;// CONCATENATED MODULE: ../../libs/common/src/state-migrations/migrations/min-version.ts
16601
17312
  var min_version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
16602
17313
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -16653,8 +17364,9 @@ var migrate_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
16653
17364
 
16654
17365
 
16655
17366
 
17367
+
16656
17368
  const MIN_VERSION = 2;
16657
- const CURRENT_VERSION = 8;
17369
+ const CURRENT_VERSION = 9;
16658
17370
  function migrate(storageService, logService) {
16659
17371
  return migrate_awaiter(this, void 0, void 0, function* () {
16660
17372
  const migrationHelper = new MigrationHelper(yield currentVersion(storageService, logService), storageService, logService);
@@ -16670,7 +17382,8 @@ function migrate(storageService, logService) {
16670
17382
  .with(AddKeyTypeToOrgKeysMigrator, 4, 5)
16671
17383
  .with(RemoveLegacyEtmKeyMigrator, 5, 6)
16672
17384
  .with(MoveBiometricAutoPromptToAccount, 6, 7)
16673
- .with(MoveStateVersionMigrator, 7, CURRENT_VERSION)
17385
+ .with(MoveStateVersionMigrator, 7, 8)
17386
+ .with(MoveBrowserSettingsToGlobal, 8, CURRENT_VERSION)
16674
17387
  .migrate(migrationHelper);
16675
17388
  });
16676
17389
  }
@@ -17518,6 +18231,7 @@ class Fido2CredentialData {
17518
18231
  this.keyValue = data.keyValue;
17519
18232
  this.rpId = data.rpId;
17520
18233
  this.userHandle = data.userHandle;
18234
+ this.userName = data.userName;
17521
18235
  this.counter = data.counter;
17522
18236
  this.rpName = data.rpName;
17523
18237
  this.userDisplayName = data.userDisplayName;
@@ -17648,6 +18362,7 @@ class CollectionData {
17648
18362
  this.name = response.name;
17649
18363
  this.externalId = response.externalId;
17650
18364
  this.readOnly = response.readOnly;
18365
+ this.manage = response.manage;
17651
18366
  this.hidePasswords = response.hidePasswords;
17652
18367
  }
17653
18368
  }
@@ -18135,8 +18850,7 @@ class Fido2CredentialView extends ItemView {
18135
18850
  }
18136
18851
  }
18137
18852
 
18138
- ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/view/login-uri.view.ts
18139
-
18853
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/misc/safe-urls.ts
18140
18854
 
18141
18855
  const CanLaunchWhitelist = [
18142
18856
  "https://",
@@ -18153,6 +18867,24 @@ const CanLaunchWhitelist = [
18153
18867
  "iosapp://",
18154
18868
  "androidapp://",
18155
18869
  ];
18870
+ class SafeUrls {
18871
+ static canLaunch(uri) {
18872
+ if (utils_Utils.isNullOrWhitespace(uri)) {
18873
+ return false;
18874
+ }
18875
+ for (let i = 0; i < CanLaunchWhitelist.length; i++) {
18876
+ if (uri.indexOf(CanLaunchWhitelist[i]) === 0) {
18877
+ return true;
18878
+ }
18879
+ }
18880
+ return false;
18881
+ }
18882
+ }
18883
+
18884
+ ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/view/login-uri.view.ts
18885
+
18886
+
18887
+
18156
18888
  class LoginUriView {
18157
18889
  constructor(u) {
18158
18890
  this.match = null;
@@ -18224,15 +18956,11 @@ class LoginUriView {
18224
18956
  return this._canLaunch;
18225
18957
  }
18226
18958
  if (this.uri != null && this.match !== UriMatchType.RegularExpression) {
18227
- const uri = this.launchUri;
18228
- for (let i = 0; i < CanLaunchWhitelist.length; i++) {
18229
- if (uri.indexOf(CanLaunchWhitelist[i]) === 0) {
18230
- this._canLaunch = true;
18231
- return this._canLaunch;
18232
- }
18233
- }
18959
+ this._canLaunch = SafeUrls.canLaunch(this.launchUri);
18960
+ }
18961
+ else {
18962
+ this._canLaunch = false;
18234
18963
  }
18235
- this._canLaunch = false;
18236
18964
  return this._canLaunch;
18237
18965
  }
18238
18966
  get launchUri() {
@@ -18489,7 +19217,8 @@ class CipherView {
18489
19217
  return null;
18490
19218
  }
18491
19219
  get subTitle() {
18492
- return this.item.subTitle;
19220
+ var _a;
19221
+ return (_a = this.item) === null || _a === void 0 ? void 0 : _a.subTitle;
18493
19222
  }
18494
19223
  get hasPasswordHistory() {
18495
19224
  return this.passwordHistory && this.passwordHistory.length > 0;
@@ -18523,7 +19252,8 @@ class CipherView {
18523
19252
  return this.deletedDate != null;
18524
19253
  }
18525
19254
  get linkedFieldOptions() {
18526
- return this.item.linkedFieldOptions;
19255
+ var _a;
19256
+ return (_a = this.item) === null || _a === void 0 ? void 0 : _a.linkedFieldOptions;
18527
19257
  }
18528
19258
  linkedFieldValue(id) {
18529
19259
  var _a;
@@ -18589,7 +19319,8 @@ class Collection extends Domain {
18589
19319
  externalId: null,
18590
19320
  readOnly: null,
18591
19321
  hidePasswords: null,
18592
- }, ["id", "organizationId", "externalId", "readOnly", "hidePasswords"]);
19322
+ manage: null,
19323
+ }, ["id", "organizationId", "externalId", "readOnly", "hidePasswords", "manage"]);
18593
19324
  }
18594
19325
  decrypt() {
18595
19326
  return this.decryptObj(new CollectionView(this), {
@@ -18610,6 +19341,7 @@ class CollectionView {
18610
19341
  // readOnly applies to the items within a collection
18611
19342
  this.readOnly = null;
18612
19343
  this.hidePasswords = null;
19344
+ this.manage = null;
18613
19345
  if (!c) {
18614
19346
  return;
18615
19347
  }
@@ -18619,6 +19351,7 @@ class CollectionView {
18619
19351
  if (c instanceof Collection) {
18620
19352
  this.readOnly = c.readOnly;
18621
19353
  this.hidePasswords = c.hidePasswords;
19354
+ this.manage = c.manage;
18622
19355
  }
18623
19356
  }
18624
19357
  // For editing collection details, not the items within it.
@@ -18629,11 +19362,16 @@ class CollectionView {
18629
19362
  return (org === null || org === void 0 ? void 0 : org.canEditAnyCollection) || (org === null || org === void 0 ? void 0 : org.canEditAssignedCollections);
18630
19363
  }
18631
19364
  // For deleting a collection, not the items within it.
18632
- canDelete(org) {
19365
+ canDelete(org, flexibleCollectionsEnabled) {
18633
19366
  if (org.id !== this.organizationId) {
18634
19367
  throw new Error("Id of the organization provided does not match the org id of the collection.");
18635
19368
  }
18636
- return (org === null || org === void 0 ? void 0 : org.canDeleteAnyCollection) || (org === null || org === void 0 ? void 0 : org.canDeleteAssignedCollections);
19369
+ if (flexibleCollectionsEnabled) {
19370
+ return (org === null || org === void 0 ? void 0 : org.canDeleteAnyCollection) || (!(org === null || org === void 0 ? void 0 : org.limitCollectionCreationDeletion) && this.manage);
19371
+ }
19372
+ else {
19373
+ return (org === null || org === void 0 ? void 0 : org.canDeleteAnyCollection) || (org === null || org === void 0 ? void 0 : org.canDeleteAssignedCollections);
19374
+ }
18637
19375
  }
18638
19376
  }
18639
19377
 
@@ -18710,6 +19448,7 @@ var state_service_awaiter = (undefined && undefined.__awaiter) || function (this
18710
19448
 
18711
19449
 
18712
19450
 
19451
+
18713
19452
 
18714
19453
 
18715
19454
  const keys = {
@@ -19552,16 +20291,16 @@ class StateService {
19552
20291
  });
19553
20292
  }
19554
20293
  getDisableAddLoginNotification(options) {
19555
- var _a, _b, _c;
20294
+ var _a, _b;
19556
20295
  return state_service_awaiter(this, void 0, void 0, function* () {
19557
- return ((_c = (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.disableAddLoginNotification) !== null && _c !== void 0 ? _c : false);
20296
+ return ((_b = (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.disableAddLoginNotification) !== null && _b !== void 0 ? _b : false);
19558
20297
  });
19559
20298
  }
19560
20299
  setDisableAddLoginNotification(value, options) {
19561
20300
  return state_service_awaiter(this, void 0, void 0, function* () {
19562
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19563
- account.settings.disableAddLoginNotification = value;
19564
- yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20301
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20302
+ globals.disableAddLoginNotification = value;
20303
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19565
20304
  });
19566
20305
  }
19567
20306
  getDisableAutoBiometricsPrompt(options) {
@@ -19604,29 +20343,42 @@ class StateService {
19604
20343
  });
19605
20344
  }
19606
20345
  getDisableChangedPasswordNotification(options) {
19607
- var _a, _b, _c;
20346
+ var _a, _b;
19608
20347
  return state_service_awaiter(this, void 0, void 0, function* () {
19609
- return ((_c = (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.disableChangedPasswordNotification) !== null && _c !== void 0 ? _c : false);
20348
+ return ((_b = (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.disableChangedPasswordNotification) !== null && _b !== void 0 ? _b : false);
19610
20349
  });
19611
20350
  }
19612
20351
  setDisableChangedPasswordNotification(value, options) {
19613
20352
  return state_service_awaiter(this, void 0, void 0, function* () {
19614
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19615
- account.settings.disableChangedPasswordNotification = value;
19616
- yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20353
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20354
+ globals.disableChangedPasswordNotification = value;
20355
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20356
+ });
20357
+ }
20358
+ getEnablePasskeys(options) {
20359
+ var _a, _b;
20360
+ return state_service_awaiter(this, void 0, void 0, function* () {
20361
+ return ((_b = (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.enablePasskeys) !== null && _b !== void 0 ? _b : true);
20362
+ });
20363
+ }
20364
+ setEnablePasskeys(value, options) {
20365
+ return state_service_awaiter(this, void 0, void 0, function* () {
20366
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20367
+ globals.enablePasskeys = value;
20368
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19617
20369
  });
19618
20370
  }
19619
20371
  getDisableContextMenuItem(options) {
19620
- var _a, _b, _c;
20372
+ var _a, _b;
19621
20373
  return state_service_awaiter(this, void 0, void 0, function* () {
19622
- return ((_c = (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.disableContextMenuItem) !== null && _c !== void 0 ? _c : false);
20374
+ return ((_b = (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.disableContextMenuItem) !== null && _b !== void 0 ? _b : false);
19623
20375
  });
19624
20376
  }
19625
20377
  setDisableContextMenuItem(value, options) {
19626
20378
  return state_service_awaiter(this, void 0, void 0, function* () {
19627
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19628
- account.settings.disableContextMenuItem = value;
19629
- yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20379
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20380
+ globals.disableContextMenuItem = value;
20381
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19630
20382
  });
19631
20383
  }
19632
20384
  getDisableFavicon(options) {
@@ -19854,6 +20606,19 @@ class StateService {
19854
20606
  yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19855
20607
  });
19856
20608
  }
20609
+ getAutoFillOverlayVisibility(options) {
20610
+ var _a, _b;
20611
+ return state_service_awaiter(this, void 0, void 0, function* () {
20612
+ return ((_b = (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskLocalOptions())))) === null || _a === void 0 ? void 0 : _a.autoFillOverlayVisibility) !== null && _b !== void 0 ? _b : AutofillOverlayVisibility.OnFieldFocus);
20613
+ });
20614
+ }
20615
+ setAutoFillOverlayVisibility(value, options) {
20616
+ return state_service_awaiter(this, void 0, void 0, function* () {
20617
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskLocalOptions()));
20618
+ globals.autoFillOverlayVisibility = value;
20619
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskLocalOptions()));
20620
+ });
20621
+ }
19857
20622
  getEnableAutoFillOnPageLoad(options) {
19858
20623
  var _a, _b, _c;
19859
20624
  return state_service_awaiter(this, void 0, void 0, function* () {
@@ -20238,16 +21003,16 @@ class StateService {
20238
21003
  yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
20239
21004
  });
20240
21005
  }
20241
- getForcePasswordResetReason(options) {
21006
+ getForceSetPasswordReason(options) {
20242
21007
  var _a, _b, _c;
20243
21008
  return state_service_awaiter(this, void 0, void 0, function* () {
20244
- return ((_c = (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskMemoryOptions())))) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.forcePasswordResetReason) !== null && _c !== void 0 ? _c : ForceResetPasswordReason.None);
21009
+ return ((_c = (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskMemoryOptions())))) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.forceSetPasswordReason) !== null && _c !== void 0 ? _c : ForceSetPasswordReason.None);
20245
21010
  });
20246
21011
  }
20247
- setForcePasswordResetReason(value, options) {
21012
+ setForceSetPasswordReason(value, options) {
20248
21013
  return state_service_awaiter(this, void 0, void 0, function* () {
20249
21014
  const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskMemoryOptions()));
20250
- account.profile.forcePasswordResetReason = value;
21015
+ account.profile.forceSetPasswordReason = value;
20251
21016
  yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskMemoryOptions()));
20252
21017
  });
20253
21018
  }
@@ -20401,16 +21166,16 @@ class StateService {
20401
21166
  });
20402
21167
  }
20403
21168
  getNeverDomains(options) {
20404
- var _a, _b;
21169
+ var _a;
20405
21170
  return state_service_awaiter(this, void 0, void 0, function* () {
20406
- return (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.neverDomains;
21171
+ return (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.neverDomains;
20407
21172
  });
20408
21173
  }
20409
21174
  setNeverDomains(value, options) {
20410
21175
  return state_service_awaiter(this, void 0, void 0, function* () {
20411
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20412
- account.settings.neverDomains = value;
20413
- yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
21176
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
21177
+ globals.neverDomains = value;
21178
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20414
21179
  });
20415
21180
  }
20416
21181
  getNoAutoPromptBiometricsText(options) {
@@ -20452,19 +21217,6 @@ class StateService {
20452
21217
  yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
20453
21218
  });
20454
21219
  }
20455
- getEmergencyAccessInvitation(options) {
20456
- var _a;
20457
- return state_service_awaiter(this, void 0, void 0, function* () {
20458
- return (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.emergencyAccessInvitation;
20459
- });
20460
- }
20461
- setEmergencyAccessInvitation(value, options) {
20462
- return state_service_awaiter(this, void 0, void 0, function* () {
20463
- const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20464
- globals.emergencyAccessInvitation = value;
20465
- yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20466
- });
20467
- }
20468
21220
  /**
20469
21221
  * @deprecated Do not call this directly, use OrganizationService
20470
21222
  */
@@ -20824,6 +21576,19 @@ class StateService {
20824
21576
  return yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskLocalOptions()));
20825
21577
  });
20826
21578
  }
21579
+ getDeepLinkRedirectUrl(options) {
21580
+ var _a;
21581
+ return state_service_awaiter(this, void 0, void 0, function* () {
21582
+ return (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.deepLinkRedirectUrl;
21583
+ });
21584
+ }
21585
+ setDeepLinkRedirectUrl(url, options) {
21586
+ return state_service_awaiter(this, void 0, void 0, function* () {
21587
+ const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
21588
+ globals.deepLinkRedirectUrl = url;
21589
+ yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
21590
+ });
21591
+ }
20827
21592
  getGlobals(options) {
20828
21593
  return state_service_awaiter(this, void 0, void 0, function* () {
20829
21594
  let globals;
@@ -21437,6 +22202,139 @@ function withPrototypeForObjectValues(valuesConstructor, valuesConverter = (i) =
21437
22202
  };
21438
22203
  }
21439
22204
 
22205
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/state-update-options.ts
22206
+ const DEFAULT_OPTIONS = {
22207
+ shouldUpdate: () => true,
22208
+ combineLatestWith: null,
22209
+ msTimeout: 1000,
22210
+ };
22211
+ function populateOptionsWithDefault(options) {
22212
+ return Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
22213
+ }
22214
+
22215
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/implementations/util.ts
22216
+ var util_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22217
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22218
+ return new (P || (P = Promise))(function (resolve, reject) {
22219
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22220
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22221
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22222
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22223
+ });
22224
+ };
22225
+ function getStoredValue(key, storage, deserializer) {
22226
+ return util_awaiter(this, void 0, void 0, function* () {
22227
+ if (storage.valuesRequireDeserialization) {
22228
+ const jsonValue = yield storage.get(key);
22229
+ const value = deserializer(jsonValue);
22230
+ return value;
22231
+ }
22232
+ else {
22233
+ const value = yield storage.get(key);
22234
+ return value !== null && value !== void 0 ? value : null;
22235
+ }
22236
+ });
22237
+ }
22238
+
22239
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/implementations/default-global-state.ts
22240
+ var default_global_state_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22241
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22242
+ return new (P || (P = Promise))(function (resolve, reject) {
22243
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22244
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22245
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22246
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22247
+ });
22248
+ };
22249
+
22250
+
22251
+
22252
+
22253
+ const FAKE_DEFAULT = Symbol("fakeDefault");
22254
+ class DefaultGlobalState {
22255
+ constructor(keyDefinition, chosenLocation) {
22256
+ this.keyDefinition = keyDefinition;
22257
+ this.chosenLocation = chosenLocation;
22258
+ this.stateSubject = new external_rxjs_namespaceObject.BehaviorSubject(FAKE_DEFAULT);
22259
+ this.storageKey = globalKeyBuilder(this.keyDefinition);
22260
+ const storageUpdates$ = this.chosenLocation.updates$.pipe((0,external_rxjs_namespaceObject.filter)((update) => update.key === this.storageKey), (0,external_rxjs_namespaceObject.switchMap)((update) => default_global_state_awaiter(this, void 0, void 0, function* () {
22261
+ if (update.updateType === "remove") {
22262
+ return null;
22263
+ }
22264
+ return yield getStoredValue(this.storageKey, this.chosenLocation, this.keyDefinition.deserializer);
22265
+ })), (0,external_rxjs_namespaceObject.shareReplay)({ bufferSize: 1, refCount: false }));
22266
+ this.state$ = (0,external_rxjs_namespaceObject.defer)(() => {
22267
+ const storageUpdateSubscription = storageUpdates$.subscribe((value) => {
22268
+ this.stateSubject.next(value);
22269
+ });
22270
+ this.getFromState().then((s) => {
22271
+ this.stateSubject.next(s);
22272
+ });
22273
+ return this.stateSubject.pipe((0,external_rxjs_namespaceObject.tap)({
22274
+ complete: () => {
22275
+ storageUpdateSubscription.unsubscribe();
22276
+ },
22277
+ }));
22278
+ }).pipe((0,external_rxjs_namespaceObject.shareReplay)({ refCount: false, bufferSize: 1 }), (0,external_rxjs_namespaceObject.filter)((i) => i != FAKE_DEFAULT));
22279
+ }
22280
+ update(configureState, options = {}) {
22281
+ return default_global_state_awaiter(this, void 0, void 0, function* () {
22282
+ options = populateOptionsWithDefault(options);
22283
+ const currentState = yield this.getGuaranteedState();
22284
+ const combinedDependencies = options.combineLatestWith != null
22285
+ ? yield (0,external_rxjs_namespaceObject.firstValueFrom)(options.combineLatestWith.pipe((0,external_rxjs_namespaceObject.timeout)(options.msTimeout)))
22286
+ : null;
22287
+ if (!options.shouldUpdate(currentState, combinedDependencies)) {
22288
+ return;
22289
+ }
22290
+ const newState = configureState(currentState, combinedDependencies);
22291
+ yield this.chosenLocation.save(this.storageKey, newState);
22292
+ return newState;
22293
+ });
22294
+ }
22295
+ getGuaranteedState() {
22296
+ return default_global_state_awaiter(this, void 0, void 0, function* () {
22297
+ const currentValue = this.stateSubject.getValue();
22298
+ return currentValue === FAKE_DEFAULT ? yield this.getFromState() : currentValue;
22299
+ });
22300
+ }
22301
+ getFromState() {
22302
+ return default_global_state_awaiter(this, void 0, void 0, function* () {
22303
+ return yield getStoredValue(this.storageKey, this.chosenLocation, this.keyDefinition.deserializer);
22304
+ });
22305
+ }
22306
+ }
22307
+
22308
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/state/implementations/default-global-state.provider.ts
22309
+
22310
+ class DefaultGlobalStateProvider {
22311
+ constructor(memoryStorage, diskStorage) {
22312
+ this.memoryStorage = memoryStorage;
22313
+ this.diskStorage = diskStorage;
22314
+ this.globalStateCache = {};
22315
+ }
22316
+ get(keyDefinition) {
22317
+ const cacheKey = keyDefinition.buildCacheKey();
22318
+ const existingGlobalState = this.globalStateCache[cacheKey];
22319
+ if (existingGlobalState != null) {
22320
+ // The cast into the actual generic is safe because of rules around key definitions
22321
+ // being unique.
22322
+ return existingGlobalState;
22323
+ }
22324
+ const newGlobalState = new DefaultGlobalState(keyDefinition, this.getLocation(keyDefinition.stateDefinition.storageLocation));
22325
+ this.globalStateCache[cacheKey] = newGlobalState;
22326
+ return newGlobalState;
22327
+ }
22328
+ getLocation(location) {
22329
+ switch (location) {
22330
+ case "disk":
22331
+ return this.diskStorage;
22332
+ case "memory":
22333
+ return this.memoryStorage;
22334
+ }
22335
+ }
22336
+ }
22337
+
21440
22338
  ;// CONCATENATED MODULE: ../../libs/common/src/platform/misc/throttle.ts
21441
22339
  /**
21442
22340
  * Use as a Decorator on async functions, it will limit how many times the function can be
@@ -21565,104 +22463,73 @@ audit_service_decorate([
21565
22463
  audit_service_metadata("design:returntype", Promise)
21566
22464
  ], AuditService.prototype, "passwordLeaked", null);
21567
22465
 
21568
- ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/response/selection-read-only.response.ts
21569
-
21570
- class SelectionReadOnlyResponse extends BaseResponse {
21571
- constructor(response) {
21572
- super(response);
21573
- this.id = this.getResponseProperty("Id");
21574
- this.readOnly = this.getResponseProperty("ReadOnly");
21575
- this.hidePasswords = this.getResponseProperty("HidePasswords");
21576
- }
21577
- }
21578
-
21579
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/responses/organization-user.response.ts
21580
-
21581
-
21582
-
21583
- class OrganizationUserResponse extends BaseResponse {
21584
- constructor(response) {
21585
- super(response);
21586
- this.collections = [];
21587
- this.groups = [];
21588
- this.id = this.getResponseProperty("Id");
21589
- this.userId = this.getResponseProperty("UserId");
21590
- this.type = this.getResponseProperty("Type");
21591
- this.status = this.getResponseProperty("Status");
21592
- this.permissions = new PermissionsApi(this.getResponseProperty("Permissions"));
21593
- this.externalId = this.getResponseProperty("ExternalId");
21594
- this.accessAll = this.getResponseProperty("AccessAll");
21595
- this.accessSecretsManager = this.getResponseProperty("AccessSecretsManager");
21596
- this.resetPasswordEnrolled = this.getResponseProperty("ResetPasswordEnrolled");
21597
- this.hasMasterPassword = this.getResponseProperty("HasMasterPassword");
21598
- const collections = this.getResponseProperty("Collections");
21599
- if (collections != null) {
21600
- this.collections = collections.map((c) => new SelectionReadOnlyResponse(c));
21601
- }
21602
- const groups = this.getResponseProperty("Groups");
21603
- if (groups != null) {
21604
- this.groups = groups;
21605
- }
21606
- }
21607
- }
21608
- class OrganizationUserUserDetailsResponse extends OrganizationUserResponse {
21609
- constructor(response) {
21610
- var _a;
21611
- super(response);
21612
- this.name = this.getResponseProperty("Name");
21613
- this.email = this.getResponseProperty("Email");
21614
- this.avatarColor = this.getResponseProperty("AvatarColor");
21615
- this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
21616
- this.usesKeyConnector = (_a = this.getResponseProperty("UsesKeyConnector")) !== null && _a !== void 0 ? _a : false;
21617
- }
21618
- }
21619
- class OrganizationUserDetailsResponse extends OrganizationUserResponse {
21620
- constructor(response) {
21621
- super(response);
21622
- }
21623
- }
21624
- class OrganizationUserResetPasswordDetailsResponse extends BaseResponse {
21625
- constructor(response) {
21626
- super(response);
21627
- this.kdf = this.getResponseProperty("Kdf");
21628
- this.kdfIterations = this.getResponseProperty("KdfIterations");
21629
- this.kdfMemory = this.getResponseProperty("KdfMemory");
21630
- this.kdfParallelism = this.getResponseProperty("KdfParallelism");
21631
- this.resetPasswordKey = this.getResponseProperty("ResetPasswordKey");
21632
- this.encryptedPrivateKey = this.getResponseProperty("EncryptedPrivateKey");
21633
- }
21634
- }
21635
-
21636
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/responses/organization-user-bulk.response.ts
22466
+ ;// CONCATENATED MODULE: ../../libs/common/src/services/event/event-collection.service.ts
22467
+ var event_collection_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22468
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22469
+ return new (P || (P = Promise))(function (resolve, reject) {
22470
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22471
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22472
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22473
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22474
+ });
22475
+ };
21637
22476
 
21638
- class OrganizationUserBulkResponse extends BaseResponse {
21639
- constructor(response) {
21640
- super(response);
21641
- this.id = this.getResponseProperty("Id");
21642
- this.error = this.getResponseProperty("Error");
22477
+ class EventCollectionService {
22478
+ constructor(cipherService, stateService, organizationService, eventUploadService) {
22479
+ this.cipherService = cipherService;
22480
+ this.stateService = stateService;
22481
+ this.organizationService = organizationService;
22482
+ this.eventUploadService = eventUploadService;
21643
22483
  }
21644
- }
21645
-
21646
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/responses/organization-user-bulk-public-key.response.ts
21647
-
21648
- class OrganizationUserBulkPublicKeyResponse extends BaseResponse {
21649
- constructor(response) {
21650
- super(response);
21651
- this.id = this.getResponseProperty("Id");
21652
- this.userId = this.getResponseProperty("UserId");
21653
- this.key = this.getResponseProperty("Key");
22484
+ collect(eventType, cipherId = null, uploadImmediately = false, organizationId = null) {
22485
+ return event_collection_service_awaiter(this, void 0, void 0, function* () {
22486
+ const authed = yield this.stateService.getIsAuthenticated();
22487
+ if (!authed) {
22488
+ return;
22489
+ }
22490
+ const organizations = yield this.organizationService.getAll();
22491
+ if (organizations == null) {
22492
+ return;
22493
+ }
22494
+ const orgIds = new Set(organizations.filter((o) => o.useEvents).map((o) => o.id));
22495
+ if (orgIds.size === 0) {
22496
+ return;
22497
+ }
22498
+ if (cipherId != null) {
22499
+ const cipher = yield this.cipherService.get(cipherId);
22500
+ if (cipher == null || cipher.organizationId == null || !orgIds.has(cipher.organizationId)) {
22501
+ return;
22502
+ }
22503
+ }
22504
+ if (organizationId != null) {
22505
+ if (!orgIds.has(organizationId)) {
22506
+ return;
22507
+ }
22508
+ }
22509
+ let eventCollection = yield this.stateService.getEventCollection();
22510
+ if (eventCollection == null) {
22511
+ eventCollection = [];
22512
+ }
22513
+ const event = new EventData();
22514
+ event.type = eventType;
22515
+ event.cipherId = cipherId;
22516
+ event.date = new Date().toISOString();
22517
+ event.organizationId = organizationId;
22518
+ eventCollection.push(event);
22519
+ yield this.stateService.setEventCollection(eventCollection);
22520
+ if (uploadImmediately) {
22521
+ yield this.eventUploadService.uploadEvents();
22522
+ }
22523
+ });
21654
22524
  }
21655
22525
  }
21656
22526
 
21657
- ;// CONCATENATED MODULE: ../../libs/common/src/services/organization-user/requests/organization-user-bulk.request.ts
21658
- class OrganizationUserBulkRequest {
21659
- constructor(ids) {
21660
- this.ids = ids == null ? [] : ids;
21661
- }
22527
+ ;// CONCATENATED MODULE: ../../libs/common/src/models/request/event.request.ts
22528
+ class EventRequest {
21662
22529
  }
21663
22530
 
21664
- ;// CONCATENATED MODULE: ../../libs/common/src/services/organization-user/organization-user.service.implementation.ts
21665
- var organization_user_service_implementation_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22531
+ ;// CONCATENATED MODULE: ../../libs/common/src/services/event/event-upload.service.ts
22532
+ var event_upload_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
21666
22533
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21667
22534
  return new (P || (P = Promise))(function (resolve, reject) {
21668
22535
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -21672,122 +22539,53 @@ var organization_user_service_implementation_awaiter = (undefined && undefined._
21672
22539
  });
21673
22540
  };
21674
22541
 
21675
-
21676
-
21677
- class OrganizationUserServiceImplementation {
21678
- constructor(apiService) {
22542
+ class EventUploadService {
22543
+ constructor(apiService, stateService, logService) {
21679
22544
  this.apiService = apiService;
22545
+ this.stateService = stateService;
22546
+ this.logService = logService;
22547
+ this.inited = false;
21680
22548
  }
21681
- getOrganizationUser(organizationId, id, options) {
21682
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21683
- const params = new URLSearchParams();
21684
- if (options === null || options === void 0 ? void 0 : options.includeGroups) {
21685
- params.set("includeGroups", "true");
21686
- }
21687
- const r = yield this.apiService.send("GET", `/organizations/${organizationId}/users/${id}?${params.toString()}`, null, true, true);
21688
- return new OrganizationUserDetailsResponse(r);
21689
- });
21690
- }
21691
- getOrganizationUserGroups(organizationId, id) {
21692
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21693
- const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/users/" + id + "/groups", null, true, true);
21694
- return r;
21695
- });
22549
+ init(checkOnInterval) {
22550
+ if (this.inited) {
22551
+ return;
22552
+ }
22553
+ this.inited = true;
22554
+ if (checkOnInterval) {
22555
+ this.uploadEvents();
22556
+ setInterval(() => this.uploadEvents(), 60 * 1000); // check every 60 seconds
22557
+ }
21696
22558
  }
21697
- getAllUsers(organizationId, options) {
21698
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21699
- const params = new URLSearchParams();
21700
- if (options === null || options === void 0 ? void 0 : options.includeCollections) {
21701
- params.set("includeCollections", "true");
22559
+ uploadEvents(userId) {
22560
+ return event_upload_service_awaiter(this, void 0, void 0, function* () {
22561
+ const authed = yield this.stateService.getIsAuthenticated({ userId: userId });
22562
+ if (!authed) {
22563
+ return;
21702
22564
  }
21703
- if (options === null || options === void 0 ? void 0 : options.includeGroups) {
21704
- params.set("includeGroups", "true");
22565
+ const eventCollection = yield this.stateService.getEventCollection({ userId: userId });
22566
+ if (eventCollection == null || eventCollection.length === 0) {
22567
+ return;
22568
+ }
22569
+ const request = eventCollection.map((e) => {
22570
+ const req = new EventRequest();
22571
+ req.type = e.type;
22572
+ req.cipherId = e.cipherId;
22573
+ req.date = e.date;
22574
+ req.organizationId = e.organizationId;
22575
+ return req;
22576
+ });
22577
+ try {
22578
+ yield this.apiService.postEventsCollect(request);
22579
+ this.clearEvents(userId);
22580
+ }
22581
+ catch (e) {
22582
+ this.logService.error(e);
21705
22583
  }
21706
- const r = yield this.apiService.send("GET", `/organizations/${organizationId}/users?${params.toString()}`, null, true, true);
21707
- return new ListResponse(r, OrganizationUserUserDetailsResponse);
21708
- });
21709
- }
21710
- getOrganizationUserResetPasswordDetails(organizationId, id) {
21711
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21712
- const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/users/" + id + "/reset-password-details", null, true, true);
21713
- return new OrganizationUserResetPasswordDetailsResponse(r);
21714
- });
21715
- }
21716
- postOrganizationUserInvite(organizationId, request) {
21717
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/invite", request, true, false);
21718
- }
21719
- postOrganizationUserReinvite(organizationId, id) {
21720
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/reinvite", null, true, false);
21721
- }
21722
- postManyOrganizationUserReinvite(organizationId, ids) {
21723
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21724
- const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/reinvite", new OrganizationUserBulkRequest(ids), true, true);
21725
- return new ListResponse(r, OrganizationUserBulkResponse);
21726
- });
21727
- }
21728
- postOrganizationUserAcceptInit(organizationId, id, request) {
21729
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/accept-init", request, true, false);
21730
- }
21731
- postOrganizationUserAccept(organizationId, id, request) {
21732
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/accept", request, true, false);
21733
- }
21734
- postOrganizationUserConfirm(organizationId, id, request) {
21735
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/confirm", request, true, false);
21736
- }
21737
- postOrganizationUsersPublicKey(organizationId, ids) {
21738
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21739
- const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/public-keys", new OrganizationUserBulkRequest(ids), true, true);
21740
- return new ListResponse(r, OrganizationUserBulkPublicKeyResponse);
21741
- });
21742
- }
21743
- postOrganizationUserBulkConfirm(organizationId, request) {
21744
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21745
- const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/confirm", request, true, true);
21746
- return new ListResponse(r, OrganizationUserBulkResponse);
21747
- });
21748
- }
21749
- putOrganizationUserBulkEnableSecretsManager(organizationId, ids) {
21750
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21751
- yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/enable-secrets-manager", new OrganizationUserBulkRequest(ids), true, false);
21752
- });
21753
- }
21754
- putOrganizationUser(organizationId, id, request) {
21755
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id, request, true, false);
21756
- }
21757
- putOrganizationUserGroups(organizationId, id, request) {
21758
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/groups", request, true, false);
21759
- }
21760
- putOrganizationUserResetPasswordEnrollment(organizationId, userId, request) {
21761
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment", request, true, false);
21762
- }
21763
- putOrganizationUserResetPassword(organizationId, id, request) {
21764
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/reset-password", request, true, false);
21765
- }
21766
- deleteOrganizationUser(organizationId, id) {
21767
- return this.apiService.send("DELETE", "/organizations/" + organizationId + "/users/" + id, null, true, false);
21768
- }
21769
- deleteManyOrganizationUsers(organizationId, ids) {
21770
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21771
- const r = yield this.apiService.send("DELETE", "/organizations/" + organizationId + "/users", new OrganizationUserBulkRequest(ids), true, true);
21772
- return new ListResponse(r, OrganizationUserBulkResponse);
21773
- });
21774
- }
21775
- revokeOrganizationUser(organizationId, id) {
21776
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/revoke", null, true, false);
21777
- }
21778
- revokeManyOrganizationUsers(organizationId, ids) {
21779
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21780
- const r = yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/revoke", new OrganizationUserBulkRequest(ids), true, true);
21781
- return new ListResponse(r, OrganizationUserBulkResponse);
21782
22584
  });
21783
22585
  }
21784
- restoreOrganizationUser(organizationId, id) {
21785
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/restore", null, true, false);
21786
- }
21787
- restoreManyOrganizationUsers(organizationId, ids) {
21788
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21789
- const r = yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/restore", new OrganizationUserBulkRequest(ids), true, true);
21790
- return new ListResponse(r, OrganizationUserBulkResponse);
22586
+ clearEvents(userId) {
22587
+ return event_upload_service_awaiter(this, void 0, void 0, function* () {
22588
+ yield this.stateService.setEventCollection(null, { userId: userId });
21791
22589
  });
21792
22590
  }
21793
22591
  }
@@ -22162,6 +22960,16 @@ class SettingsService {
22162
22960
  getDisableFavicon() {
22163
22961
  return this._disableFavicon.getValue();
22164
22962
  }
22963
+ setAutoFillOverlayVisibility(value) {
22964
+ return settings_service_awaiter(this, void 0, void 0, function* () {
22965
+ return yield this.stateService.setAutoFillOverlayVisibility(value);
22966
+ });
22967
+ }
22968
+ getAutoFillOverlayVisibility() {
22969
+ return settings_service_awaiter(this, void 0, void 0, function* () {
22970
+ return yield this.stateService.getAutoFillOverlayVisibility();
22971
+ });
22972
+ }
22165
22973
  clear(userId) {
22166
22974
  return settings_service_awaiter(this, void 0, void 0, function* () {
22167
22975
  if (userId == null || userId == (yield this.stateService.getUserId())) {
@@ -22357,13 +23165,13 @@ class VaultTimeoutSettingsService {
22357
23165
  }
22358
23166
  setVaultTimeoutOptions(timeout, action) {
22359
23167
  return vault_timeout_settings_service_awaiter(this, void 0, void 0, function* () {
22360
- yield this.stateService.setVaultTimeout(timeout);
22361
23168
  // We swap these tokens from being on disk for lock actions, and in memory for logout actions
22362
23169
  // Get them here to set them to their new location after changing the timeout action and clearing if needed
22363
23170
  const token = yield this.tokenService.getToken();
22364
23171
  const refreshToken = yield this.tokenService.getRefreshToken();
22365
23172
  const clientId = yield this.tokenService.getClientId();
22366
23173
  const clientSecret = yield this.tokenService.getClientSecret();
23174
+ yield this.stateService.setVaultTimeout(timeout);
22367
23175
  const currentAction = yield this.stateService.getVaultTimeoutAction();
22368
23176
  if ((timeout != null || timeout === 0) &&
22369
23177
  action === VaultTimeoutAction.LogOut &&
@@ -23475,7 +24283,7 @@ function devFlagEnabled(flag) {
23475
24283
  return false;
23476
24284
  }
23477
24285
  const devFlags = getFlags(process.env.DEV_FLAGS);
23478
- return devFlags[flag] == null || !!devFlags[flag];
24286
+ return (devFlags === null || devFlags === void 0 ? void 0 : devFlags[flag]) == null ? false : !!devFlags[flag];
23479
24287
  }
23480
24288
  /**
23481
24289
  * Gets the value of a dev flag from environment.
@@ -23844,6 +24652,7 @@ class Fido2Credential extends Domain {
23844
24652
  keyValue: null,
23845
24653
  rpId: null,
23846
24654
  userHandle: null,
24655
+ userName: null,
23847
24656
  counter: null,
23848
24657
  rpName: null,
23849
24658
  userDisplayName: null,
@@ -23861,6 +24670,7 @@ class Fido2Credential extends Domain {
23861
24670
  keyValue: null,
23862
24671
  rpId: null,
23863
24672
  userHandle: null,
24673
+ userName: null,
23864
24674
  rpName: null,
23865
24675
  userDisplayName: null,
23866
24676
  discoverable: null,
@@ -23889,6 +24699,7 @@ class Fido2Credential extends Domain {
23889
24699
  keyValue: null,
23890
24700
  rpId: null,
23891
24701
  userHandle: null,
24702
+ userName: null,
23892
24703
  counter: null,
23893
24704
  rpName: null,
23894
24705
  userDisplayName: null,
@@ -23907,6 +24718,7 @@ class Fido2Credential extends Domain {
23907
24718
  const keyValue = EncString.fromJSON(obj.keyValue);
23908
24719
  const rpId = EncString.fromJSON(obj.rpId);
23909
24720
  const userHandle = EncString.fromJSON(obj.userHandle);
24721
+ const userName = EncString.fromJSON(obj.userName);
23910
24722
  const counter = EncString.fromJSON(obj.counter);
23911
24723
  const rpName = EncString.fromJSON(obj.rpName);
23912
24724
  const userDisplayName = EncString.fromJSON(obj.userDisplayName);
@@ -23920,6 +24732,7 @@ class Fido2Credential extends Domain {
23920
24732
  keyValue,
23921
24733
  rpId,
23922
24734
  userHandle,
24735
+ userName,
23923
24736
  counter,
23924
24737
  rpName,
23925
24738
  userDisplayName,
@@ -24581,6 +25394,7 @@ class Fido2CredentialApi extends BaseResponse {
24581
25394
  this.keyValue = this.getResponseProperty("keyValue");
24582
25395
  this.rpId = this.getResponseProperty("RpId");
24583
25396
  this.userHandle = this.getResponseProperty("UserHandle");
25397
+ this.userName = this.getResponseProperty("UserName");
24584
25398
  this.counter = this.getResponseProperty("Counter");
24585
25399
  this.rpName = this.getResponseProperty("RpName");
24586
25400
  this.userDisplayName = this.getResponseProperty("UserDisplayName");
@@ -24689,6 +25503,7 @@ class CipherRequest {
24689
25503
  keyApi.rpName = key.rpName != null ? key.rpName.encryptedString : null;
24690
25504
  keyApi.counter = key.counter != null ? key.counter.encryptedString : null;
24691
25505
  keyApi.userHandle = key.userHandle != null ? key.userHandle.encryptedString : null;
25506
+ keyApi.userName = key.userName != null ? key.userName.encryptedString : null;
24692
25507
  keyApi.userDisplayName =
24693
25508
  key.userDisplayName != null ? key.userDisplayName.encryptedString : null;
24694
25509
  keyApi.discoverable =
@@ -25103,6 +25918,10 @@ class CipherService {
25103
25918
  const ciphers = yield this.getAll();
25104
25919
  const orgKeys = yield this.cryptoService.getOrgKeys();
25105
25920
  const userKey = yield this.cryptoService.getUserKeyWithLegacySupport();
25921
+ if ((orgKeys === null || orgKeys === void 0 ? void 0 : orgKeys.size) === 0 && userKey == null) {
25922
+ // return early if there are no keys to decrypt with
25923
+ return;
25924
+ }
25106
25925
  // Group ciphers by orgId or under 'null' for the user's ciphers
25107
25926
  const grouped = ciphers.reduce((agg, c) => {
25108
25927
  var _a;
@@ -25846,6 +26665,7 @@ class CipherService {
25846
26665
  rpId: null,
25847
26666
  rpName: null,
25848
26667
  userHandle: null,
26668
+ userName: null,
25849
26669
  userDisplayName: null,
25850
26670
  origin: null,
25851
26671
  }, key);
@@ -26758,6 +27578,7 @@ class OrganizationData {
26758
27578
  this.familySponsorshipValidUntil = response.familySponsorshipValidUntil;
26759
27579
  this.familySponsorshipToDelete = response.familySponsorshipToDelete;
26760
27580
  this.accessSecretsManager = response.accessSecretsManager;
27581
+ this.limitCollectionCreationDeletion = response.limitCollectionCreationDeletion;
26761
27582
  this.isMember = options.isMember;
26762
27583
  this.isProviderUser = options.isProviderUser;
26763
27584
  }
@@ -26791,6 +27612,7 @@ var sync_service_awaiter = (undefined && undefined.__awaiter) || function (thisA
26791
27612
 
26792
27613
 
26793
27614
 
27615
+
26794
27616
  class SyncService {
26795
27617
  constructor(apiService, settingsService, folderService, cipherService, cryptoService, collectionService, messagingService, policyService, sendService, logService, keyConnectorService, stateService, providerService, folderApiService, organizationService, sendApiService, logoutCallback) {
26796
27618
  this.apiService = apiService;
@@ -27060,10 +27882,7 @@ class SyncService {
27060
27882
  yield this.stateService.setHasPremiumPersonally(response.premiumPersonally);
27061
27883
  yield this.stateService.setHasPremiumFromOrganization(response.premiumFromOrganization);
27062
27884
  yield this.keyConnectorService.setUsesKeyConnector(response.usesKeyConnector);
27063
- // The `forcePasswordReset` flag indicates an admin has reset the user's password and must be updated
27064
- if (response.forcePasswordReset) {
27065
- yield this.stateService.setForcePasswordResetReason(ForceResetPasswordReason.AdminForcePasswordReset);
27066
- }
27885
+ yield this.setForceSetPasswordReasonIfNeeded(response);
27067
27886
  yield this.syncProfileOrganizations(response);
27068
27887
  const providers = {};
27069
27888
  response.providers.forEach((p) => {
@@ -27079,6 +27898,35 @@ class SyncService {
27079
27898
  }
27080
27899
  });
27081
27900
  }
27901
+ setForceSetPasswordReasonIfNeeded(profileResponse) {
27902
+ return sync_service_awaiter(this, void 0, void 0, function* () {
27903
+ // The `forcePasswordReset` flag indicates an admin has reset the user's password and must be updated
27904
+ if (profileResponse.forcePasswordReset) {
27905
+ yield this.stateService.setForceSetPasswordReason(ForceSetPasswordReason.AdminForcePasswordReset);
27906
+ }
27907
+ const acctDecryptionOpts = yield this.stateService.getAccountDecryptionOptions();
27908
+ // Even though TDE users should only be in a single org (per single org policy), check
27909
+ // through all orgs for the manageResetPassword permission. If they have it in any org,
27910
+ // they should be forced to set a password.
27911
+ let hasManageResetPasswordPermission = false;
27912
+ for (const org of profileResponse.organizations) {
27913
+ const isAdmin = org.type === OrganizationUserType.Admin;
27914
+ const isOwner = org.type === OrganizationUserType.Owner;
27915
+ // Note: apparently permissions only come down populated for custom roles.
27916
+ if (isAdmin || isOwner || (org.permissions && org.permissions.manageResetPassword)) {
27917
+ hasManageResetPasswordPermission = true;
27918
+ break;
27919
+ }
27920
+ }
27921
+ if (acctDecryptionOpts.trustedDeviceOption !== undefined &&
27922
+ !acctDecryptionOpts.hasMasterPassword &&
27923
+ hasManageResetPasswordPermission) {
27924
+ // TDE user w/out MP went from having no password reset permission to having it.
27925
+ // Must set the force password reset reason so the auth guard will redirect to the set password page.
27926
+ yield this.stateService.setForceSetPasswordReason(ForceSetPasswordReason.TdeUserWithoutPasswordHasPasswordResetPermission);
27927
+ }
27928
+ });
27929
+ }
27082
27930
  syncProfileOrganizations(response) {
27083
27931
  return sync_service_awaiter(this, void 0, void 0, function* () {
27084
27932
  const organizations = {};
@@ -27420,6 +28268,7 @@ class Fido2CredentialExport {
27420
28268
  req.keyValue = "keyValue";
27421
28269
  req.rpId = "rpId";
27422
28270
  req.userHandle = "userHandle";
28271
+ req.userName = "userName";
27423
28272
  req.counter = "counter";
27424
28273
  req.rpName = "rpName";
27425
28274
  req.userDisplayName = "userDisplayName";
@@ -27441,6 +28290,7 @@ class Fido2CredentialExport {
27441
28290
  view.keyValue = req.keyValue;
27442
28291
  view.rpId = req.rpId;
27443
28292
  view.userHandle = req.userHandle;
28293
+ view.userName = req.userName;
27444
28294
  view.counter = parseInt(req.counter);
27445
28295
  view.rpName = req.rpName;
27446
28296
  view.userDisplayName = req.userDisplayName;
@@ -27462,6 +28312,7 @@ class Fido2CredentialExport {
27462
28312
  domain.keyValue = req.keyValue != null ? new EncString(req.keyValue) : null;
27463
28313
  domain.rpId = req.rpId != null ? new EncString(req.rpId) : null;
27464
28314
  domain.userHandle = req.userHandle != null ? new EncString(req.userHandle) : null;
28315
+ domain.userName = req.userName != null ? new EncString(req.userName) : null;
27465
28316
  domain.counter = req.counter != null ? new EncString(req.counter) : null;
27466
28317
  domain.rpName = req.rpName != null ? new EncString(req.rpName) : null;
27467
28318
  domain.userDisplayName =
@@ -27476,7 +28327,7 @@ class Fido2CredentialExport {
27476
28327
  * @param o - The credential storing the data being exported. When not provided, an empty export is created instead.
27477
28328
  */
27478
28329
  constructor(o) {
27479
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
28330
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
27480
28331
  if (o == null) {
27481
28332
  return;
27482
28333
  }
@@ -27488,6 +28339,7 @@ class Fido2CredentialExport {
27488
28339
  this.keyValue = o.keyValue;
27489
28340
  this.rpId = o.rpId;
27490
28341
  this.userHandle = o.userHandle;
28342
+ this.userName = o.userName;
27491
28343
  this.counter = String(o.counter);
27492
28344
  this.rpName = o.rpName;
27493
28345
  this.userDisplayName = o.userDisplayName;
@@ -27501,10 +28353,11 @@ class Fido2CredentialExport {
27501
28353
  this.keyValue = (_e = o.keyValue) === null || _e === void 0 ? void 0 : _e.encryptedString;
27502
28354
  this.rpId = (_f = o.rpId) === null || _f === void 0 ? void 0 : _f.encryptedString;
27503
28355
  this.userHandle = (_g = o.userHandle) === null || _g === void 0 ? void 0 : _g.encryptedString;
27504
- this.counter = (_h = o.counter) === null || _h === void 0 ? void 0 : _h.encryptedString;
27505
- this.rpName = (_j = o.rpName) === null || _j === void 0 ? void 0 : _j.encryptedString;
27506
- this.userDisplayName = (_k = o.userDisplayName) === null || _k === void 0 ? void 0 : _k.encryptedString;
27507
- this.discoverable = (_l = o.discoverable) === null || _l === void 0 ? void 0 : _l.encryptedString;
28356
+ this.userName = (_h = o.userName) === null || _h === void 0 ? void 0 : _h.encryptedString;
28357
+ this.counter = (_j = o.counter) === null || _j === void 0 ? void 0 : _j.encryptedString;
28358
+ this.rpName = (_k = o.rpName) === null || _k === void 0 ? void 0 : _k.encryptedString;
28359
+ this.userDisplayName = (_l = o.userDisplayName) === null || _l === void 0 ? void 0 : _l.encryptedString;
28360
+ this.discoverable = (_m = o.discoverable) === null || _m === void 0 ? void 0 : _m.encryptedString;
27508
28361
  }
27509
28362
  this.creationDate = o.creationDate;
27510
28363
  }
@@ -33406,17 +34259,15 @@ class ProtonPassJsonImporter extends base_importer_BaseImporter {
33406
34259
  }
33407
34260
  this.processFolder(result, vault.name);
33408
34261
  const cipher = this.initLoginCipher();
33409
- cipher.name = item.data.metadata.name;
33410
- cipher.notes = item.data.metadata.note;
34262
+ cipher.name = this.getValueOrDefault(item.data.metadata.name, "--");
34263
+ cipher.notes = this.getValueOrDefault(item.data.metadata.note);
33411
34264
  switch (item.data.type) {
33412
34265
  case "login": {
33413
34266
  const loginContent = item.data.content;
33414
34267
  cipher.login.uris = this.makeUriArray(loginContent.urls);
33415
- cipher.login.username = loginContent.username;
33416
- cipher.login.password = loginContent.password;
33417
- if (loginContent.totpUri != "") {
33418
- cipher.login.totp = new URL(loginContent.totpUri).searchParams.get("secret");
33419
- }
34268
+ cipher.login.username = this.getValueOrDefault(loginContent.username);
34269
+ cipher.login.password = this.getValueOrDefault(loginContent.password);
34270
+ cipher.login.totp = this.getValueOrDefault(loginContent.totpUri);
33420
34271
  for (const extraField of item.data.extraFields) {
33421
34272
  this.processKvp(cipher, extraField.fieldName, extraField.type == "totp" ? extraField.data.totpUri : extraField.data.content, extraField.type == "text" ? FieldType.Text : FieldType.Hidden);
33422
34273
  }
@@ -33431,10 +34282,10 @@ class ProtonPassJsonImporter extends base_importer_BaseImporter {
33431
34282
  const creditCardContent = item.data.content;
33432
34283
  cipher.type = CipherType.Card;
33433
34284
  cipher.card = new CardView();
33434
- cipher.card.cardholderName = creditCardContent.cardholderName;
33435
- cipher.card.number = creditCardContent.number;
34285
+ cipher.card.cardholderName = this.getValueOrDefault(creditCardContent.cardholderName);
34286
+ cipher.card.number = this.getValueOrDefault(creditCardContent.number);
33436
34287
  cipher.card.brand = CardView.getCardBrandByPatterns(creditCardContent.number);
33437
- cipher.card.code = creditCardContent.verificationNumber;
34288
+ cipher.card.code = this.getValueOrDefault(creditCardContent.verificationNumber);
33438
34289
  if (!this.isNullOrWhitespace(creditCardContent.expirationDate)) {
33439
34290
  cipher.card.expMonth = creditCardContent.expirationDate.substring(0, 2);
33440
34291
  cipher.card.expMonth = cipher.card.expMonth.replace(/^0+/, "");
@@ -33984,11 +34835,13 @@ class SecureSafeCsvImporter extends base_importer_BaseImporter {
33984
34835
  result.success = false;
33985
34836
  return Promise.resolve(result);
33986
34837
  }
34838
+ // The url field can be in different case formats.
34839
+ const urlField = Object.keys(results[0]).find((k) => /url/i.test(k));
33987
34840
  results.forEach((value) => {
33988
34841
  const cipher = this.initLoginCipher();
33989
34842
  cipher.name = this.getValueOrDefault(value.Title);
33990
34843
  cipher.notes = this.getValueOrDefault(value.Comment);
33991
- cipher.login.uris = this.makeUriArray(value.Url);
34844
+ cipher.login.uris = this.makeUriArray(value[urlField]);
33992
34845
  cipher.login.password = this.getValueOrDefault(value.Password);
33993
34846
  cipher.login.username = this.getValueOrDefault(value.Username);
33994
34847
  this.cleanupCipher(cipher);
@@ -34479,7 +35332,7 @@ class ImportService {
34479
35332
  getImportOptions() {
34480
35333
  return this.featuredImportOptions.concat(this.regularImportOptions);
34481
35334
  }
34482
- import(importer, fileContents, organizationId = null, selectedImportTarget = null, isUserAdmin) {
35335
+ import(importer, fileContents, organizationId = null, selectedImportTarget = null, canAccessImportExport) {
34483
35336
  return import_service_awaiter(this, void 0, void 0, function* () {
34484
35337
  let importResult;
34485
35338
  try {
@@ -34509,7 +35362,9 @@ class ImportService {
34509
35362
  throw new Error(this.i18nService.t("importFormatError"));
34510
35363
  }
34511
35364
  }
34512
- if (organizationId && utils_Utils.isNullOrWhitespace(selectedImportTarget) && !isUserAdmin) {
35365
+ if (organizationId &&
35366
+ utils_Utils.isNullOrWhitespace(selectedImportTarget) &&
35367
+ !canAccessImportExport) {
34513
35368
  const hasUnassignedCollections = importResult.ciphers.some((c) => !Array.isArray(c.collectionIds) || c.collectionIds.length == 0);
34514
35369
  if (hasUnassignedCollections) {
34515
35370
  throw new Error(this.i18nService.t("importUnassignedItemsError"));
@@ -35266,14 +36121,14 @@ class CliPlatformUtilsService {
35266
36121
  if (!this.deviceCache) {
35267
36122
  switch (process.platform) {
35268
36123
  case "win32":
35269
- this.deviceCache = DeviceType.WindowsDesktop;
36124
+ this.deviceCache = DeviceType.WindowsCLI;
35270
36125
  break;
35271
36126
  case "darwin":
35272
- this.deviceCache = DeviceType.MacOsDesktop;
36127
+ this.deviceCache = DeviceType.MacOsCLI;
35273
36128
  break;
35274
36129
  case "linux":
35275
36130
  default:
35276
- this.deviceCache = DeviceType.LinuxDesktop;
36131
+ this.deviceCache = DeviceType.LinuxCLI;
35277
36132
  break;
35278
36133
  }
35279
36134
  }
@@ -35281,7 +36136,7 @@ class CliPlatformUtilsService {
35281
36136
  }
35282
36137
  getDeviceString() {
35283
36138
  const device = DeviceType[this.getDevice()].toLowerCase();
35284
- return device.replace("desktop", "");
36139
+ return device.replace("cli", "");
35285
36140
  }
35286
36141
  getClientType() {
35287
36142
  return this.clientType;
@@ -35661,6 +36516,7 @@ var lowdb_storage_service_awaiter = (undefined && undefined.__awaiter) || functi
35661
36516
 
35662
36517
 
35663
36518
 
36519
+
35664
36520
  const retries = {
35665
36521
  retries: 50,
35666
36522
  minTimeout: 100,
@@ -35674,7 +36530,9 @@ class LowdbStorageService {
35674
36530
  this.allowCache = allowCache;
35675
36531
  this.requireLock = requireLock;
35676
36532
  this.ready = false;
36533
+ this.updatesSubject = new external_rxjs_namespaceObject.Subject();
35677
36534
  this.defaults = defaults;
36535
+ this.updates$ = this.updatesSubject.asObservable();
35678
36536
  }
35679
36537
  init() {
35680
36538
  return lowdb_storage_service_awaiter(this, void 0, void 0, function* () {
@@ -35737,6 +36595,9 @@ class LowdbStorageService {
35737
36595
  this.ready = true;
35738
36596
  });
35739
36597
  }
36598
+ get valuesRequireDeserialization() {
36599
+ return true;
36600
+ }
35740
36601
  get(key) {
35741
36602
  return lowdb_storage_service_awaiter(this, void 0, void 0, function* () {
35742
36603
  yield this.waitForReady();
@@ -35760,6 +36621,7 @@ class LowdbStorageService {
35760
36621
  return this.lockDbFile(() => {
35761
36622
  this.readForNoCache();
35762
36623
  this.db.set(key, obj).write();
36624
+ this.updatesSubject.next({ key, updateType: "save" });
35763
36625
  this.logService.debug(`Successfully wrote ${key} to db`);
35764
36626
  return;
35765
36627
  });
@@ -35771,6 +36633,7 @@ class LowdbStorageService {
35771
36633
  return this.lockDbFile(() => {
35772
36634
  this.readForNoCache();
35773
36635
  this.db.unset(key).write();
36636
+ this.updatesSubject.next({ key, updateType: "remove" });
35774
36637
  this.logService.debug(`Successfully removed ${key} from db`);
35775
36638
  return;
35776
36639
  });
@@ -35940,6 +36803,7 @@ class CollectionDetailsResponse extends CollectionResponse {
35940
36803
  constructor(response) {
35941
36804
  super(response);
35942
36805
  this.readOnly = this.getResponseProperty("ReadOnly") || false;
36806
+ this.manage = this.getResponseProperty("Manage") || false;
35943
36807
  this.hidePasswords = this.getResponseProperty("HidePasswords") || false;
35944
36808
  }
35945
36809
  }
@@ -36096,59 +36960,6 @@ class DeviceVerificationResponse extends BaseResponse {
36096
36960
  }
36097
36961
  }
36098
36962
 
36099
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/emergency-access.response.ts
36100
-
36101
-
36102
- class EmergencyAccessGranteeDetailsResponse extends BaseResponse {
36103
- constructor(response) {
36104
- super(response);
36105
- this.id = this.getResponseProperty("Id");
36106
- this.granteeId = this.getResponseProperty("GranteeId");
36107
- this.name = this.getResponseProperty("Name");
36108
- this.email = this.getResponseProperty("Email");
36109
- this.type = this.getResponseProperty("Type");
36110
- this.status = this.getResponseProperty("Status");
36111
- this.waitTimeDays = this.getResponseProperty("WaitTimeDays");
36112
- this.creationDate = this.getResponseProperty("CreationDate");
36113
- this.avatarColor = this.getResponseProperty("AvatarColor");
36114
- }
36115
- }
36116
- class EmergencyAccessGrantorDetailsResponse extends BaseResponse {
36117
- constructor(response) {
36118
- super(response);
36119
- this.id = this.getResponseProperty("Id");
36120
- this.grantorId = this.getResponseProperty("GrantorId");
36121
- this.name = this.getResponseProperty("Name");
36122
- this.email = this.getResponseProperty("Email");
36123
- this.type = this.getResponseProperty("Type");
36124
- this.status = this.getResponseProperty("Status");
36125
- this.waitTimeDays = this.getResponseProperty("WaitTimeDays");
36126
- this.creationDate = this.getResponseProperty("CreationDate");
36127
- this.avatarColor = this.getResponseProperty("AvatarColor");
36128
- }
36129
- }
36130
- class EmergencyAccessTakeoverResponse extends BaseResponse {
36131
- constructor(response) {
36132
- super(response);
36133
- this.keyEncrypted = this.getResponseProperty("KeyEncrypted");
36134
- this.kdf = this.getResponseProperty("Kdf");
36135
- this.kdfIterations = this.getResponseProperty("KdfIterations");
36136
- this.kdfMemory = this.getResponseProperty("KdfMemory");
36137
- this.kdfParallelism = this.getResponseProperty("KdfParallelism");
36138
- }
36139
- }
36140
- class EmergencyAccessViewResponse extends BaseResponse {
36141
- constructor(response) {
36142
- super(response);
36143
- this.ciphers = [];
36144
- this.keyEncrypted = this.getResponseProperty("KeyEncrypted");
36145
- const ciphers = this.getResponseProperty("Ciphers");
36146
- if (ciphers != null) {
36147
- this.ciphers = ciphers.map((c) => new CipherResponse(c));
36148
- }
36149
- }
36150
- }
36151
-
36152
36963
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/key-connector-user-key.response.ts
36153
36964
 
36154
36965
  class KeyConnectorUserKeyResponse extends BaseResponse {
@@ -36340,6 +37151,13 @@ class TaxRateResponse extends BaseResponse {
36340
37151
  }
36341
37152
  }
36342
37153
 
37154
+ ;// CONCATENATED MODULE: ../../libs/common/src/models/request/collection-bulk-delete.request.ts
37155
+ class CollectionBulkDeleteRequest {
37156
+ constructor(ids) {
37157
+ this.ids = ids == null ? [] : ids;
37158
+ }
37159
+ }
37160
+
36343
37161
  ;// CONCATENATED MODULE: ../../libs/common/src/models/response/breach-account.response.ts
36344
37162
 
36345
37163
  class BreachAccountResponse extends BaseResponse {
@@ -36552,7 +37370,6 @@ var api_service_awaiter = (undefined && undefined.__awaiter) || function (thisAr
36552
37370
 
36553
37371
 
36554
37372
 
36555
-
36556
37373
 
36557
37374
 
36558
37375
  /**
@@ -36584,7 +37401,10 @@ class ApiService {
36584
37401
  this.isDesktopClient =
36585
37402
  this.device === DeviceType.WindowsDesktop ||
36586
37403
  this.device === DeviceType.MacOsDesktop ||
36587
- this.device === DeviceType.LinuxDesktop;
37404
+ this.device === DeviceType.LinuxDesktop ||
37405
+ this.device === DeviceType.WindowsCLI ||
37406
+ this.device === DeviceType.MacOsCLI ||
37407
+ this.device === DeviceType.LinuxCLI;
36588
37408
  }
36589
37409
  // Auth APIs
36590
37410
  postIdentityToken(request) {
@@ -37097,8 +37917,8 @@ class ApiService {
37097
37917
  deleteCollection(organizationId, id) {
37098
37918
  return this.send("DELETE", "/organizations/" + organizationId + "/collections/" + id, null, true, false);
37099
37919
  }
37100
- deleteManyCollections(request) {
37101
- return this.send("DELETE", "/organizations/" + request.organizationId + "/collections", request, true, false);
37920
+ deleteManyCollections(organizationId, collectionIds) {
37921
+ return this.send("DELETE", "/organizations/" + organizationId + "/collections", new CollectionBulkDeleteRequest(collectionIds), true, false);
37102
37922
  }
37103
37923
  deleteCollectionUser(organizationId, id, organizationUserId) {
37104
37924
  return this.send("DELETE", "/organizations/" + organizationId + "/collections/" + id + "/user/" + organizationUserId, null, true, false);
@@ -37305,75 +38125,6 @@ class ApiService {
37305
38125
  return new DeviceVerificationResponse(r);
37306
38126
  });
37307
38127
  }
37308
- // Emergency Access APIs
37309
- getEmergencyAccessTrusted() {
37310
- return api_service_awaiter(this, void 0, void 0, function* () {
37311
- const r = yield this.send("GET", "/emergency-access/trusted", null, true, true);
37312
- return new ListResponse(r, EmergencyAccessGranteeDetailsResponse);
37313
- });
37314
- }
37315
- getEmergencyAccessGranted() {
37316
- return api_service_awaiter(this, void 0, void 0, function* () {
37317
- const r = yield this.send("GET", "/emergency-access/granted", null, true, true);
37318
- return new ListResponse(r, EmergencyAccessGrantorDetailsResponse);
37319
- });
37320
- }
37321
- getEmergencyAccess(id) {
37322
- return api_service_awaiter(this, void 0, void 0, function* () {
37323
- const r = yield this.send("GET", "/emergency-access/" + id, null, true, true);
37324
- return new EmergencyAccessGranteeDetailsResponse(r);
37325
- });
37326
- }
37327
- getEmergencyGrantorPolicies(id) {
37328
- return api_service_awaiter(this, void 0, void 0, function* () {
37329
- const r = yield this.send("GET", "/emergency-access/" + id + "/policies", null, true, true);
37330
- return new ListResponse(r, PolicyResponse);
37331
- });
37332
- }
37333
- putEmergencyAccess(id, request) {
37334
- return this.send("PUT", "/emergency-access/" + id, request, true, false);
37335
- }
37336
- deleteEmergencyAccess(id) {
37337
- return this.send("DELETE", "/emergency-access/" + id, null, true, false);
37338
- }
37339
- postEmergencyAccessInvite(request) {
37340
- return this.send("POST", "/emergency-access/invite", request, true, false);
37341
- }
37342
- postEmergencyAccessReinvite(id) {
37343
- return this.send("POST", "/emergency-access/" + id + "/reinvite", null, true, false);
37344
- }
37345
- postEmergencyAccessAccept(id, request) {
37346
- return this.send("POST", "/emergency-access/" + id + "/accept", request, true, false);
37347
- }
37348
- postEmergencyAccessConfirm(id, request) {
37349
- return this.send("POST", "/emergency-access/" + id + "/confirm", request, true, false);
37350
- }
37351
- postEmergencyAccessInitiate(id) {
37352
- return this.send("POST", "/emergency-access/" + id + "/initiate", null, true, false);
37353
- }
37354
- postEmergencyAccessApprove(id) {
37355
- return this.send("POST", "/emergency-access/" + id + "/approve", null, true, false);
37356
- }
37357
- postEmergencyAccessReject(id) {
37358
- return this.send("POST", "/emergency-access/" + id + "/reject", null, true, false);
37359
- }
37360
- postEmergencyAccessTakeover(id) {
37361
- return api_service_awaiter(this, void 0, void 0, function* () {
37362
- const r = yield this.send("POST", "/emergency-access/" + id + "/takeover", null, true, true);
37363
- return new EmergencyAccessTakeoverResponse(r);
37364
- });
37365
- }
37366
- postEmergencyAccessPassword(id, request) {
37367
- return api_service_awaiter(this, void 0, void 0, function* () {
37368
- yield this.send("POST", "/emergency-access/" + id + "/password", request, true, true);
37369
- });
37370
- }
37371
- postEmergencyAccessView(id) {
37372
- return api_service_awaiter(this, void 0, void 0, function* () {
37373
- const r = yield this.send("POST", "/emergency-access/" + id + "/view", null, true, true);
37374
- return new EmergencyAccessViewResponse(r);
37375
- });
37376
- }
37377
38128
  // Organization APIs
37378
38129
  getCloudCommunicationsEnabled() {
37379
38130
  return api_service_awaiter(this, void 0, void 0, function* () {
@@ -37958,12 +38709,19 @@ var node_env_secure_storage_service_awaiter = (undefined && undefined.__awaiter)
37958
38709
 
37959
38710
 
37960
38711
 
38712
+
37961
38713
  class NodeEnvSecureStorageService {
37962
38714
  constructor(storageService, logService, cryptoService) {
37963
38715
  this.storageService = storageService;
37964
38716
  this.logService = logService;
37965
38717
  this.cryptoService = cryptoService;
37966
38718
  }
38719
+ get valuesRequireDeserialization() {
38720
+ return true;
38721
+ }
38722
+ get updates$() {
38723
+ return (0,external_rxjs_namespaceObject.throwError)(() => new Error("Secure storage implementations cannot have their updates subscribed to."));
38724
+ }
37967
38725
  get(key) {
37968
38726
  return node_env_secure_storage_service_awaiter(this, void 0, void 0, function* () {
37969
38727
  const value = yield this.storageService.get(this.makeProtectedStorageKey(key));
@@ -37992,7 +38750,10 @@ class NodeEnvSecureStorageService {
37992
38750
  });
37993
38751
  }
37994
38752
  remove(key) {
37995
- return this.storageService.remove(this.makeProtectedStorageKey(key));
38753
+ return node_env_secure_storage_service_awaiter(this, void 0, void 0, function* () {
38754
+ yield this.storageService.remove(this.makeProtectedStorageKey(key));
38755
+ return;
38756
+ });
37996
38757
  }
37997
38758
  encrypt(plainValue) {
37998
38759
  return node_env_secure_storage_service_awaiter(this, void 0, void 0, function* () {
@@ -38133,9 +38894,9 @@ class LockCommand {
38133
38894
  const external_http_namespaceObject = require("http");
38134
38895
  ;// CONCATENATED MODULE: external "inquirer"
38135
38896
  const external_inquirer_namespaceObject = require("inquirer");
38136
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/log-in-credentials.ts
38897
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/login-credentials.ts
38137
38898
 
38138
- class PasswordLogInCredentials {
38899
+ class PasswordLoginCredentials {
38139
38900
  constructor(email, masterPassword, captchaToken, twoFactor) {
38140
38901
  this.email = email;
38141
38902
  this.masterPassword = masterPassword;
@@ -38144,7 +38905,7 @@ class PasswordLogInCredentials {
38144
38905
  this.type = authentication_type_AuthenticationType.Password;
38145
38906
  }
38146
38907
  }
38147
- class SsoLogInCredentials {
38908
+ class SsoLoginCredentials {
38148
38909
  constructor(code, codeVerifier, redirectUrl, orgId, twoFactor) {
38149
38910
  this.code = code;
38150
38911
  this.codeVerifier = codeVerifier;
@@ -38154,14 +38915,14 @@ class SsoLogInCredentials {
38154
38915
  this.type = authentication_type_AuthenticationType.Sso;
38155
38916
  }
38156
38917
  }
38157
- class UserApiLogInCredentials {
38918
+ class UserApiLoginCredentials {
38158
38919
  constructor(clientId, clientSecret) {
38159
38920
  this.clientId = clientId;
38160
38921
  this.clientSecret = clientSecret;
38161
38922
  this.type = authentication_type_AuthenticationType.UserApi;
38162
38923
  }
38163
38924
  }
38164
- class PasswordlessLogInCredentials {
38925
+ class AuthRequestLoginCredentials {
38165
38926
  constructor(email, accessCode, authRequestId, decryptedUserKey, decryptedMasterKey, decryptedMasterKeyHash, twoFactor) {
38166
38927
  this.email = email;
38167
38928
  this.accessCode = accessCode;
@@ -38170,7 +38931,15 @@ class PasswordlessLogInCredentials {
38170
38931
  this.decryptedMasterKey = decryptedMasterKey;
38171
38932
  this.decryptedMasterKeyHash = decryptedMasterKeyHash;
38172
38933
  this.twoFactor = twoFactor;
38173
- this.type = AuthenticationType.Passwordless;
38934
+ this.type = AuthenticationType.AuthRequest;
38935
+ }
38936
+ }
38937
+ class WebAuthnLoginCredentials {
38938
+ constructor(token, deviceResponse, prfKey) {
38939
+ this.token = token;
38940
+ this.deviceResponse = deviceResponse;
38941
+ this.prfKey = prfKey;
38942
+ this.type = AuthenticationType.WebAuthn;
38174
38943
  }
38175
38944
  }
38176
38945
 
@@ -38184,7 +38953,7 @@ class PasswordRequest extends SecretVerificationRequest {
38184
38953
  class TwoFactorEmailRequest extends SecretVerificationRequest {
38185
38954
  }
38186
38955
 
38187
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/requests/organization-user-reset-password.request.ts
38956
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/abstractions/organization-user/requests/organization-user-reset-password.request.ts
38188
38957
  class OrganizationUserResetPasswordRequest {
38189
38958
  }
38190
38959
 
@@ -38344,7 +39113,7 @@ class LoginCommand {
38344
39113
  return Response.error("Invalid API Key; Organization API Key currently not supported");
38345
39114
  }
38346
39115
  try {
38347
- response = yield this.authService.logIn(new UserApiLogInCredentials(clientId, clientSecret));
39116
+ response = yield this.authService.logIn(new UserApiLoginCredentials(clientId, clientSecret));
38348
39117
  }
38349
39118
  catch (e) {
38350
39119
  // handle API key login failures
@@ -38359,16 +39128,16 @@ class LoginCommand {
38359
39128
  }
38360
39129
  }
38361
39130
  else if (ssoCode != null && ssoCodeVerifier != null) {
38362
- response = yield this.authService.logIn(new SsoLogInCredentials(ssoCode, ssoCodeVerifier, this.ssoRedirectUri, orgIdentifier, twoFactor));
39131
+ response = yield this.authService.logIn(new SsoLoginCredentials(ssoCode, ssoCodeVerifier, this.ssoRedirectUri, orgIdentifier, twoFactor));
38363
39132
  }
38364
39133
  else {
38365
- response = yield this.authService.logIn(new PasswordLogInCredentials(email, password, null, twoFactor));
39134
+ response = yield this.authService.logIn(new PasswordLoginCredentials(email, password, null, twoFactor));
38366
39135
  }
38367
39136
  if (response.requiresEncryptionKeyMigration) {
38368
39137
  return Response.error("Encryption key migration required. Please login through the web vault to update your encryption key.");
38369
39138
  }
38370
39139
  if (response.captchaSiteKey) {
38371
- const credentials = new PasswordLogInCredentials(email, password);
39140
+ const credentials = new PasswordLoginCredentials(email, password);
38372
39141
  const handledResponse = yield this.handleCaptchaRequired(twoFactor, credentials);
38373
39142
  // Error Response
38374
39143
  if (handledResponse instanceof Response) {
@@ -38463,13 +39232,13 @@ class LoginCommand {
38463
39232
  // Run full sync before handling success response or password reset flows (to get Master Password Policies)
38464
39233
  yield this.syncService.fullSync(true);
38465
39234
  // Handle updating passwords if NOT using an API Key for authentication
38466
- if (response.forcePasswordReset != ForceResetPasswordReason.None &&
39235
+ if (response.forcePasswordReset != ForceSetPasswordReason.None &&
38467
39236
  clientId == null &&
38468
39237
  clientSecret == null) {
38469
- if (response.forcePasswordReset === ForceResetPasswordReason.AdminForcePasswordReset) {
39238
+ if (response.forcePasswordReset === ForceSetPasswordReason.AdminForcePasswordReset) {
38470
39239
  return yield this.updateTempPassword();
38471
39240
  }
38472
- else if (response.forcePasswordReset === ForceResetPasswordReason.WeakMasterPassword) {
39241
+ else if (response.forcePasswordReset === ForceSetPasswordReason.WeakMasterPassword) {
38473
39242
  return yield this.updateWeakPassword(password);
38474
39243
  }
38475
39244
  }
@@ -39504,7 +40273,7 @@ const external_koa_namespaceObject = require("koa");
39504
40273
  const external_koa_bodyparser_namespaceObject = require("koa-bodyparser");
39505
40274
  ;// CONCATENATED MODULE: external "koa-json"
39506
40275
  const external_koa_json_namespaceObject = require("koa-json");
39507
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/requests/organization-user-confirm.request.ts
40276
+ ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/abstractions/organization-user/requests/organization-user-confirm.request.ts
39508
40277
  class OrganizationUserConfirmRequest {
39509
40278
  }
39510
40279
 
@@ -40678,10 +41447,11 @@ class SendRemovePasswordCommand {
40678
41447
 
40679
41448
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/request/selection-read-only.request.ts
40680
41449
  class SelectionReadOnlyRequest {
40681
- constructor(id, readOnly, hidePasswords) {
41450
+ constructor(id, readOnly, hidePasswords, manage) {
40682
41451
  this.id = id;
40683
41452
  this.readOnly = readOnly;
40684
41453
  this.hidePasswords = hidePasswords;
41454
+ this.manage = manage;
40685
41455
  }
40686
41456
  }
40687
41457
 
@@ -40885,7 +41655,7 @@ class CreateCommand {
40885
41655
  }
40886
41656
  const groups = req.groups == null
40887
41657
  ? null
40888
- : req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords));
41658
+ : req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords, g.manage));
40889
41659
  const request = new CollectionRequest();
40890
41660
  request.name = (yield this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
40891
41661
  request.externalId = req.externalId;
@@ -41249,7 +42019,7 @@ class EditCommand {
41249
42019
  }
41250
42020
  const groups = req.groups == null
41251
42021
  ? null
41252
- : req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords));
42022
+ : req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords, g.manage));
41253
42023
  const request = new CollectionRequest();
41254
42024
  request.name = (yield this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
41255
42025
  request.externalId = req.externalId;
@@ -41275,12 +42045,13 @@ class commands_edit_command_Options {
41275
42045
  ;// CONCATENATED MODULE: ./src/admin-console/models/selection-read-only.ts
41276
42046
  class SelectionReadOnly {
41277
42047
  static template() {
41278
- return new SelectionReadOnly("00000000-0000-0000-0000-000000000000", false, false);
42048
+ return new SelectionReadOnly("00000000-0000-0000-0000-000000000000", false, false, false);
41279
42049
  }
41280
- constructor(id, readOnly, hidePasswords) {
42050
+ constructor(id, readOnly, hidePasswords, manage) {
41281
42051
  this.id = id;
41282
42052
  this.readOnly = readOnly;
41283
42053
  this.hidePasswords = hidePasswords || false;
42054
+ this.manage = manage;
41284
42055
  }
41285
42056
  }
41286
42057
 
@@ -41354,10 +42125,11 @@ var commands_get_command_awaiter = (undefined && undefined.__awaiter) || functio
41354
42125
 
41355
42126
 
41356
42127
 
42128
+
41357
42129
 
41358
42130
 
41359
42131
  class GetCommand extends DownloadCommand {
41360
- constructor(cipherService, folderService, collectionService, totpService, auditService, cryptoService, stateService, searchService, apiService, organizationService) {
42132
+ constructor(cipherService, folderService, collectionService, totpService, auditService, cryptoService, stateService, searchService, apiService, organizationService, eventCollectionService) {
41361
42133
  super(cryptoService);
41362
42134
  this.cipherService = cipherService;
41363
42135
  this.folderService = folderService;
@@ -41368,6 +42140,7 @@ class GetCommand extends DownloadCommand {
41368
42140
  this.searchService = searchService;
41369
42141
  this.apiService = apiService;
41370
42142
  this.organizationService = organizationService;
42143
+ this.eventCollectionService = eventCollectionService;
41371
42144
  }
41372
42145
  run(object, id, cmdOptions) {
41373
42146
  return commands_get_command_awaiter(this, void 0, void 0, function* () {
@@ -41448,6 +42221,7 @@ class GetCommand extends DownloadCommand {
41448
42221
  return Response.multipleResults(decCipher.map((c) => c.id));
41449
42222
  }
41450
42223
  }
42224
+ this.eventCollectionService.collect(EventType.Cipher_ClientViewed, id, true, decCipher.organizationId);
41451
42225
  const res = new cipher_response_CipherResponse(decCipher);
41452
42226
  return Response.success(res);
41453
42227
  });
@@ -41693,7 +42467,7 @@ class GetCommand extends DownloadCommand {
41693
42467
  decCollection.name = yield this.cryptoService.decryptToUtf8(new EncString(response.name), orgKey);
41694
42468
  const groups = response.groups == null
41695
42469
  ? null
41696
- : response.groups.map((g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords));
42470
+ : response.groups.map((g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords, g.manage));
41697
42471
  const res = new OrganizationCollectionResponse(decCollection, groups);
41698
42472
  return Response.success(res);
41699
42473
  }
@@ -41835,8 +42609,9 @@ var commands_list_command_awaiter = (undefined && undefined.__awaiter) || functi
41835
42609
 
41836
42610
 
41837
42611
 
42612
+
41838
42613
  class ListCommand {
41839
- constructor(cipherService, folderService, collectionService, organizationService, searchService, organizationUserService, apiService) {
42614
+ constructor(cipherService, folderService, collectionService, organizationService, searchService, organizationUserService, apiService, eventCollectionService) {
41840
42615
  this.cipherService = cipherService;
41841
42616
  this.folderService = folderService;
41842
42617
  this.collectionService = collectionService;
@@ -41844,6 +42619,7 @@ class ListCommand {
41844
42619
  this.searchService = searchService;
41845
42620
  this.organizationUserService = organizationUserService;
41846
42621
  this.apiService = apiService;
42622
+ this.eventCollectionService = eventCollectionService;
41847
42623
  }
41848
42624
  run(object, cmdOptions) {
41849
42625
  return commands_list_command_awaiter(this, void 0, void 0, function* () {
@@ -41926,6 +42702,11 @@ class ListCommand {
41926
42702
  if (options.search != null && options.search.trim() !== "") {
41927
42703
  ciphers = this.searchService.searchCiphersBasic(ciphers, options.search, options.trash);
41928
42704
  }
42705
+ ciphers.forEach((c, index) => {
42706
+ // Set upload immediately on the last item in the ciphers collection to avoid the event collection
42707
+ // service from uploading each time.
42708
+ this.eventCollectionService.collect(EventType.Cipher_ClientViewed, c.id, index === ciphers.length - 1, c.organizationId);
42709
+ });
41929
42710
  const res = new list_response_ListResponse(ciphers.map((o) => new cipher_response_CipherResponse(o)));
41930
42711
  return Response.success(res);
41931
42712
  });
@@ -42189,8 +42970,8 @@ var serve_command_awaiter = (undefined && undefined.__awaiter) || function (this
42189
42970
  class ServeCommand {
42190
42971
  constructor(main) {
42191
42972
  this.main = main;
42192
- this.getCommand = new GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.stateService, this.main.searchService, this.main.apiService, this.main.organizationService);
42193
- this.listCommand = new ListCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.organizationService, this.main.searchService, this.main.organizationUserService, this.main.apiService);
42973
+ this.getCommand = new GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.stateService, this.main.searchService, this.main.apiService, this.main.organizationService, this.main.eventCollectionService);
42974
+ this.listCommand = new ListCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.organizationService, this.main.searchService, this.main.organizationUserService, this.main.apiService, this.main.eventCollectionService);
42194
42975
  this.createCommand = new CreateCommand(this.main.cipherService, this.main.folderService, this.main.stateService, this.main.cryptoService, this.main.apiService, this.main.folderApiService);
42195
42976
  this.editCommand = new EditCommand(this.main.cipherService, this.main.folderService, this.main.cryptoService, this.main.apiService, this.main.folderApiService);
42196
42977
  this.generateCommand = new GenerateCommand(this.main.passwordGenerationService, this.main.stateService);
@@ -43168,7 +43949,7 @@ class SendProgram extends Program {
43168
43949
  object: "Valid objects are: send.text, send.file",
43169
43950
  })
43170
43951
  .action((object) => send_program_awaiter(this, void 0, void 0, function* () {
43171
- const cmd = new GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.stateService, this.main.searchService, this.main.apiService, this.main.organizationService);
43952
+ const cmd = new GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.stateService, this.main.searchService, this.main.apiService, this.main.organizationService, this.main.eventCollectionService);
43172
43953
  const response = yield cmd.run("template", object, null);
43173
43954
  this.processResponse(response);
43174
43955
  }));
@@ -43330,10 +44111,12 @@ var export_command_awaiter = (undefined && undefined.__awaiter) || function (thi
43330
44111
 
43331
44112
 
43332
44113
 
44114
+
43333
44115
  class ExportCommand {
43334
- constructor(exportService, policyService) {
44116
+ constructor(exportService, policyService, eventCollectionService) {
43335
44117
  this.exportService = exportService;
43336
44118
  this.policyService = policyService;
44119
+ this.eventCollectionService = eventCollectionService;
43337
44120
  }
43338
44121
  run(options) {
43339
44122
  var _a;
@@ -43355,6 +44138,10 @@ class ExportCommand {
43355
44138
  format === "encrypted_json"
43356
44139
  ? yield this.getProtectedExport(options.password, options.organizationid)
43357
44140
  : yield this.getUnprotectedExport(format, options.organizationid);
44141
+ const eventType = options.organizationid
44142
+ ? EventType.Organization_ClientExportedVault
44143
+ : EventType.User_ClientExportedVault;
44144
+ this.eventCollectionService.collect(eventType, null, true, options.organizationid);
43358
44145
  }
43359
44146
  catch (e) {
43360
44147
  return Response.error(e);
@@ -43638,7 +44425,7 @@ class VaultProgram extends Program {
43638
44425
  return;
43639
44426
  }
43640
44427
  yield this.exitIfLocked();
43641
- const command = new ListCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.organizationService, this.main.searchService, this.main.organizationUserService, this.main.apiService);
44428
+ const command = new ListCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.organizationService, this.main.searchService, this.main.organizationUserService, this.main.apiService, this.main.eventCollectionService);
43642
44429
  const response = yield command.run(object, cmd);
43643
44430
  this.processResponse(response);
43644
44431
  }));
@@ -43693,7 +44480,7 @@ class VaultProgram extends Program {
43693
44480
  return;
43694
44481
  }
43695
44482
  yield this.exitIfLocked();
43696
- const command = new GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.stateService, this.main.searchService, this.main.apiService, this.main.organizationService);
44483
+ const command = new GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.stateService, this.main.searchService, this.main.apiService, this.main.organizationService, this.main.eventCollectionService);
43697
44484
  const response = yield command.run(object, id, cmd);
43698
44485
  this.processResponse(response);
43699
44486
  }));
@@ -43922,7 +44709,7 @@ class VaultProgram extends Program {
43922
44709
  })
43923
44710
  .action((options) => vault_program_awaiter(this, void 0, void 0, function* () {
43924
44711
  yield this.exitIfLocked();
43925
- const command = new ExportCommand(this.main.exportService, this.main.policyService);
44712
+ const command = new ExportCommand(this.main.exportService, this.main.policyService, this.main.eventCollectionService);
43926
44713
  const response = yield command.run(options);
43927
44714
  this.processResponse(response);
43928
44715
  }));
@@ -43974,6 +44761,10 @@ var bw_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argum
43974
44761
 
43975
44762
 
43976
44763
 
44764
+ // eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
44765
+
44766
+
44767
+
43977
44768
 
43978
44769
 
43979
44770
 
@@ -44038,12 +44829,13 @@ class Main {
44038
44829
  this.storageService = new LowdbStorageService(this.logService, null, p, false, true);
44039
44830
  this.secureStorageService = new NodeEnvSecureStorageService(this.storageService, this.logService, () => this.cryptoService);
44040
44831
  this.memoryStorageService = new MemoryStorageService();
44041
- this.accountService = new AccountServiceImplementation(null, this.logService);
44832
+ this.globalStateProvider = new DefaultGlobalStateProvider(this.memoryStorageService, this.storageService);
44833
+ this.messagingService = new NoopMessagingService();
44834
+ this.accountService = new AccountServiceImplementation(this.messagingService, this.logService, this.globalStateProvider);
44042
44835
  this.stateService = new StateService(this.storageService, this.secureStorageService, this.memoryStorageService, this.logService, new StateFactory(GlobalState, Account), this.accountService);
44043
44836
  this.cryptoService = new CryptoService(this.cryptoFunctionService, this.encryptService, this.platformUtilsService, this.logService, this.stateService);
44044
44837
  this.appIdService = new AppIdService(this.storageService);
44045
44838
  this.tokenService = new TokenService(this.stateService);
44046
- this.messagingService = new NoopMessagingService();
44047
44839
  this.environmentService = new environment_service_EnvironmentService(this.stateService);
44048
44840
  const customUserAgent = "Bitwarden_CLI/" +
44049
44841
  this.platformUtilsService.getApplicationVersionSync() +
@@ -44094,6 +44886,8 @@ class Main {
44094
44886
  this.vaultProgram = new VaultProgram(this);
44095
44887
  this.sendProgram = new SendProgram(this);
44096
44888
  this.userVerificationApiService = new UserVerificationApiService(this.apiService);
44889
+ this.eventUploadService = new EventUploadService(this.apiService, this.stateService, this.logService);
44890
+ this.eventCollectionService = new EventCollectionService(this.cipherService, this.stateService, this.organizationService, this.eventUploadService);
44097
44891
  }
44098
44892
  run() {
44099
44893
  return bw_awaiter(this, void 0, void 0, function* () {