@bitwarden/cli 2023.9.1 → 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 +2145 -750
  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.9.1","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
 
@@ -360,15 +360,6 @@ class PlanResponse extends BaseResponse {
360
360
  this.nameLocalizationKey = this.getResponseProperty("NameLocalizationKey");
361
361
  this.descriptionLocalizationKey = this.getResponseProperty("DescriptionLocalizationKey");
362
362
  this.canBeUsedByBusiness = this.getResponseProperty("CanBeUsedByBusiness");
363
- this.baseSeats = this.getResponseProperty("BaseSeats");
364
- this.baseStorageGb = this.getResponseProperty("BaseStorageGb");
365
- this.maxCollections = this.getResponseProperty("MaxCollections");
366
- this.maxUsers = this.getResponseProperty("MaxUsers");
367
- this.hasAdditionalSeatsOption = this.getResponseProperty("HasAdditionalSeatsOption");
368
- this.maxAdditionalSeats = this.getResponseProperty("MaxAdditionalSeats");
369
- this.hasAdditionalStorageOption = this.getResponseProperty("HasAdditionalStorageOption");
370
- this.maxAdditionalStorage = this.getResponseProperty("MaxAdditionalStorage");
371
- this.hasPremiumAccessOption = this.getResponseProperty("HasPremiumAccessOption");
372
363
  this.trialPeriodDays = this.getResponseProperty("TrialPeriodDays");
373
364
  this.hasSelfHost = this.getResponseProperty("HasSelfHost");
374
365
  this.hasPolicies = this.getResponseProperty("HasPolicies");
@@ -382,25 +373,56 @@ class PlanResponse extends BaseResponse {
382
373
  this.hasResetPassword = this.getResponseProperty("HasResetPassword");
383
374
  this.usersGetPremium = this.getResponseProperty("UsersGetPremium");
384
375
  this.upgradeSortOrder = this.getResponseProperty("UpgradeSortOrder");
385
- this.displaySortOrder = this.getResponseProperty("SortOrder");
376
+ this.displaySortOrder = this.getResponseProperty("DisplaySortOrder");
386
377
  this.legacyYear = this.getResponseProperty("LegacyYear");
387
378
  this.disabled = this.getResponseProperty("Disabled");
388
- this.stripePlanId = this.getResponseProperty("StripePlanId");
379
+ const passwordManager = this.getResponseProperty("PasswordManager");
380
+ const secretsManager = this.getResponseProperty("SecretsManager");
381
+ this.PasswordManager =
382
+ passwordManager == null ? null : new PasswordManagerPlanFeaturesResponse(passwordManager);
383
+ this.SecretsManager =
384
+ secretsManager == null ? null : new SecretsManagerPlanFeaturesResponse(secretsManager);
385
+ }
386
+ }
387
+ class SecretsManagerPlanFeaturesResponse extends BaseResponse {
388
+ constructor(response) {
389
+ super(response);
389
390
  this.stripeSeatPlanId = this.getResponseProperty("StripeSeatPlanId");
390
- this.stripeStoragePlanId = this.getResponseProperty("StripeStoragePlanId");
391
- this.stripePremiumAccessPlanId = this.getResponseProperty("StripePremiumAccessPlanId");
391
+ this.baseSeats = this.getResponseProperty("BaseSeats");
392
392
  this.basePrice = this.getResponseProperty("BasePrice");
393
393
  this.seatPrice = this.getResponseProperty("SeatPrice");
394
- this.additionalStoragePricePerGb = this.getResponseProperty("AdditionalStoragePricePerGb");
395
- this.premiumAccessOptionPrice = this.getResponseProperty("PremiumAccessOptionPrice");
396
- this.bitwardenProduct = this.getResponseProperty("BitwardenProduct");
394
+ this.hasAdditionalSeatsOption = this.getResponseProperty("HasAdditionalSeatsOption");
395
+ this.maxAdditionalSeats = this.getResponseProperty("MaxAdditionalSeats");
396
+ this.maxSeats = this.getResponseProperty("MaxSeats");
397
+ this.stripeServiceAccountPlanId = this.getResponseProperty("StripeServiceAccountPlanId");
397
398
  this.additionalPricePerServiceAccount = this.getResponseProperty("AdditionalPricePerServiceAccount");
398
399
  this.baseServiceAccount = this.getResponseProperty("BaseServiceAccount");
399
400
  this.maxServiceAccount = this.getResponseProperty("MaxServiceAccount");
400
401
  this.hasAdditionalServiceAccountOption = this.getResponseProperty("HasAdditionalServiceAccountOption");
401
- this.maxProjects = this.getResponseProperty("MaxProjects");
402
402
  this.maxAdditionalServiceAccounts = this.getResponseProperty("MaxAdditionalServiceAccounts");
403
- this.stripeServiceAccountPlanId = this.getResponseProperty("StripeServiceAccountPlanId");
403
+ this.maxProjects = this.getResponseProperty("MaxProjects");
404
+ }
405
+ }
406
+ class PasswordManagerPlanFeaturesResponse extends BaseResponse {
407
+ constructor(response) {
408
+ super(response);
409
+ this.stripePlanId = this.getResponseProperty("StripePlanId");
410
+ this.stripeSeatPlanId = this.getResponseProperty("StripeSeatPlanId");
411
+ this.stripeStoragePlanId = this.getResponseProperty("StripeStoragePlanId");
412
+ this.stripePremiumAccessPlanId = this.getResponseProperty("StripePremiumAccessPlanId");
413
+ this.basePrice = this.getResponseProperty("BasePrice");
414
+ this.seatPrice = this.getResponseProperty("SeatPrice");
415
+ this.baseSeats = this.getResponseProperty("BaseSeats");
416
+ this.maxAdditionalSeats = this.getResponseProperty("MaxAdditionalSeats");
417
+ this.premiumAccessOptionPrice = this.getResponseProperty("PremiumAccessOptionPrice");
418
+ this.maxSeats = this.getResponseProperty("MaxSeats");
419
+ this.additionalStoragePricePerGb = this.getResponseProperty("AdditionalStoragePricePerGb");
420
+ this.hasAdditionalSeatsOption = this.getResponseProperty("HasAdditionalSeatsOption");
421
+ this.baseStorageGb = this.getResponseProperty("BaseStorageGb");
422
+ this.maxCollections = this.getResponseProperty("MaxCollections");
423
+ this.hasAdditionalStorageOption = this.getResponseProperty("HasAdditionalStorageOption");
424
+ this.maxAdditionalStorage = this.getResponseProperty("MaxAdditionalStorage");
425
+ this.hasPremiumAccessOption = this.getResponseProperty("HasPremiumAccessOption");
404
426
  }
405
427
  }
406
428
 
@@ -421,9 +443,6 @@ class OrganizationResponse extends BaseResponse {
421
443
  this.billingEmail = this.getResponseProperty("BillingEmail");
422
444
  const plan = this.getResponseProperty("Plan");
423
445
  this.plan = plan == null ? null : new PlanResponse(plan);
424
- const secretsManagerPlan = this.getResponseProperty("SecretsManagerPlan");
425
- this.secretsManagerPlan =
426
- secretsManagerPlan == null ? null : new PlanResponse(secretsManagerPlan);
427
446
  this.planType = this.getResponseProperty("PlanType");
428
447
  this.seats = this.getResponseProperty("Seats");
429
448
  this.maxAutoscaleSeats = this.getResponseProperty("MaxAutoscaleSeats");
@@ -443,6 +462,7 @@ class OrganizationResponse extends BaseResponse {
443
462
  this.smServiceAccounts = this.getResponseProperty("SmServiceAccounts");
444
463
  this.maxAutoscaleSmSeats = this.getResponseProperty("MaxAutoscaleSmSeats");
445
464
  this.maxAutoscaleSmServiceAccounts = this.getResponseProperty("MaxAutoscaleSmServiceAccounts");
465
+ this.limitCollectionCreationDeletion = this.getResponseProperty("LimitCollectionCreationDeletion");
446
466
  }
447
467
  }
448
468
 
@@ -493,7 +513,6 @@ class BillingSubscriptionItemResponse extends BaseResponse {
493
513
  this.interval = this.getResponseProperty("Interval");
494
514
  this.sponsoredSubscriptionItem = this.getResponseProperty("SponsoredSubscriptionItem");
495
515
  this.addonSubscriptionItem = this.getResponseProperty("AddonSubscriptionItem");
496
- this.bitwardenProduct = this.getResponseProperty("BitwardenProduct");
497
516
  }
498
517
  }
499
518
  class BillingSubscriptionUpcomingInvoiceResponse extends BaseResponse {
@@ -507,6 +526,7 @@ class BillingSubscriptionUpcomingInvoiceResponse extends BaseResponse {
507
526
  ;// CONCATENATED MODULE: ../../libs/common/src/billing/models/response/organization-subscription.response.ts
508
527
 
509
528
 
529
+
510
530
  class OrganizationSubscriptionResponse extends OrganizationResponse {
511
531
  constructor(response) {
512
532
  super(response);
@@ -519,11 +539,26 @@ class OrganizationSubscriptionResponse extends OrganizationResponse {
519
539
  upcomingInvoice == null
520
540
  ? null
521
541
  : new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
542
+ const customerDiscount = this.getResponseProperty("CustomerDiscount");
543
+ this.customerDiscount =
544
+ customerDiscount == null ? null : new BillingCustomerDiscount(customerDiscount);
522
545
  this.expiration = this.getResponseProperty("Expiration");
523
546
  this.expirationWithoutGracePeriod = this.getResponseProperty("ExpirationWithoutGracePeriod");
524
547
  this.secretsManagerBeta = this.getResponseProperty("SecretsManagerBeta");
525
548
  }
526
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
+ }
527
562
 
528
563
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/api/permissions.api.ts
529
564
 
@@ -608,6 +643,7 @@ class ProfileOrganizationResponse extends BaseResponse {
608
643
  }
609
644
  this.familySponsorshipToDelete = this.getResponseProperty("FamilySponsorshipToDelete");
610
645
  this.accessSecretsManager = this.getResponseProperty("AccessSecretsManager");
646
+ this.limitCollectionCreationDeletion = this.getResponseProperty("LimitCollectionCreationDeletion");
611
647
  }
612
648
  }
613
649
 
@@ -977,6 +1013,14 @@ class OrganizationApiService {
977
1013
  return new ProfileOrganizationResponse(r);
978
1014
  });
979
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
+ }
980
1024
  }
981
1025
 
982
1026
  ;// CONCATENATED MODULE: external "rxjs"
@@ -1114,6 +1158,36 @@ class utils_Utils {
1114
1158
  .join("");
1115
1159
  }
1116
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
+ }
1117
1191
  static fromUrlB64ToB64(urlB64Str) {
1118
1192
  let output = urlB64Str.replace(/-/g, "+").replace(/_/g, "/");
1119
1193
  switch (output.length % 4) {
@@ -1214,7 +1288,10 @@ class utils_Utils {
1214
1288
  return null;
1215
1289
  }
1216
1290
  try {
1217
- 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
+ });
1218
1295
  if (parseResult != null && parseResult.hostname != null) {
1219
1296
  if (parseResult.hostname === "localhost" || parseResult.isIp) {
1220
1297
  return parseResult.hostname;
@@ -1530,9 +1607,9 @@ var ClientType;
1530
1607
  ClientType["Web"] = "web";
1531
1608
  ClientType["Browser"] = "browser";
1532
1609
  ClientType["Desktop"] = "desktop";
1533
- ClientType["Mobile"] = "mobile";
1610
+ // Mobile = "mobile",
1534
1611
  ClientType["Cli"] = "cli";
1535
- ClientType["DirectoryConnector"] = "connector";
1612
+ // DirectoryConnector = "connector",
1536
1613
  })(ClientType || (ClientType = {}));
1537
1614
 
1538
1615
  ;// CONCATENATED MODULE: ../../libs/common/src/enums/device-type.enum.ts
@@ -1561,6 +1638,9 @@ var DeviceType;
1561
1638
  DeviceType[DeviceType["SafariExtension"] = 20] = "SafariExtension";
1562
1639
  DeviceType[DeviceType["SDK"] = 21] = "SDK";
1563
1640
  DeviceType[DeviceType["Server"] = 22] = "Server";
1641
+ DeviceType[DeviceType["WindowsCLI"] = 23] = "WindowsCLI";
1642
+ DeviceType[DeviceType["MacOsCLI"] = 24] = "MacOsCLI";
1643
+ DeviceType[DeviceType["LinuxCLI"] = 25] = "LinuxCLI";
1564
1644
  })(DeviceType || (DeviceType = {}));
1565
1645
  const MobileDeviceTypes = new Set([
1566
1646
  DeviceType.Android,
@@ -1572,6 +1652,9 @@ const DesktopDeviceTypes = new Set([
1572
1652
  DeviceType.MacOsDesktop,
1573
1653
  DeviceType.LinuxDesktop,
1574
1654
  DeviceType.UWP,
1655
+ DeviceType.WindowsCLI,
1656
+ DeviceType.MacOsCLI,
1657
+ DeviceType.LinuxCLI,
1575
1658
  ]);
1576
1659
 
1577
1660
  ;// CONCATENATED MODULE: ../../libs/common/src/enums/encrypted-export-type.enum.ts
@@ -2188,6 +2271,7 @@ var ProductType;
2188
2271
  ProductType[ProductType["Families"] = 1] = "Families";
2189
2272
  ProductType[ProductType["Teams"] = 2] = "Teams";
2190
2273
  ProductType[ProductType["Enterprise"] = 3] = "Enterprise";
2274
+ ProductType[ProductType["TeamsStarter"] = 4] = "TeamsStarter";
2191
2275
  })(ProductType || (ProductType = {}));
2192
2276
 
2193
2277
  ;// CONCATENATED MODULE: ../../libs/common/src/enums/provider-type.enum.ts
@@ -2399,6 +2483,7 @@ class Organization {
2399
2483
  this.familySponsorshipValidUntil = obj.familySponsorshipValidUntil;
2400
2484
  this.familySponsorshipToDelete = obj.familySponsorshipToDelete;
2401
2485
  this.accessSecretsManager = obj.accessSecretsManager;
2486
+ this.limitCollectionCreationDeletion = obj.limitCollectionCreationDeletion;
2402
2487
  }
2403
2488
  get canAccess() {
2404
2489
  if (this.isOwner) {
@@ -2434,7 +2519,9 @@ class Organization {
2434
2519
  return this.isAdmin || this.permissions.accessReports;
2435
2520
  }
2436
2521
  get canCreateNewCollections() {
2437
- return this.isManager || this.permissions.createNewCollections;
2522
+ return (!this.limitCollectionCreationDeletion ||
2523
+ this.isManager ||
2524
+ this.permissions.createNewCollections);
2438
2525
  }
2439
2526
  get canEditAnyCollection() {
2440
2527
  return this.isAdmin || this.permissions.editAnyCollection;
@@ -2504,6 +2591,9 @@ class Organization {
2504
2591
  get hasProvider() {
2505
2592
  return this.providerId != null || this.providerName != null;
2506
2593
  }
2594
+ get hasReseller() {
2595
+ return this.hasProvider && this.providerType === ProviderType.Reseller;
2596
+ }
2507
2597
  get canAccessSecretsManager() {
2508
2598
  return this.useSecretsManager && this.accessSecretsManager;
2509
2599
  }
@@ -2628,6 +2718,300 @@ class organization_service_OrganizationService {
2628
2718
  }
2629
2719
  }
2630
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
+
2631
3015
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/data/policy.data.ts
2632
3016
  class PolicyData {
2633
3017
  constructor(response) {
@@ -2667,6 +3051,8 @@ var policy_api_service_awaiter = (undefined && undefined.__awaiter) || function
2667
3051
 
2668
3052
 
2669
3053
 
3054
+
3055
+
2670
3056
  class PolicyApiService {
2671
3057
  constructor(policyService, apiService, stateService) {
2672
3058
  this.policyService = policyService;
@@ -2699,18 +3085,30 @@ class PolicyApiService {
2699
3085
  return new ListResponse(r, PolicyResponse);
2700
3086
  });
2701
3087
  }
2702
- getPoliciesByInvitedUser(organizationId, userId) {
3088
+ getMasterPasswordPolicyResponseForOrgUser(organizationId) {
2703
3089
  return policy_api_service_awaiter(this, void 0, void 0, function* () {
2704
- const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/policies/invited-user?" + "userId=" + userId, null, false, true);
2705
- 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);
2706
3092
  });
2707
3093
  }
2708
- getMasterPasswordPoliciesForInvitedUsers(orgId) {
3094
+ getMasterPasswordPolicyOptsForOrgUser(orgId) {
2709
3095
  return policy_api_service_awaiter(this, void 0, void 0, function* () {
2710
- const userId = yield this.stateService.getUserId();
2711
- const response = yield this.getPoliciesByInvitedUser(orgId, userId);
2712
- const policies = yield this.policyService.mapPoliciesFromToken(response);
2713
- 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
+ }
2714
3112
  });
2715
3113
  }
2716
3114
  putPolicy(organizationId, type, request) {
@@ -3036,11 +3434,6 @@ class PolicyService {
3036
3434
  })))
3037
3435
  .subscribe();
3038
3436
  }
3039
- /**
3040
- * Returns the first policy found that applies to the active user
3041
- * @param policyType Policy type to search for
3042
- * @param policyFilter Additional filter to apply to the policy
3043
- */
3044
3437
  get$(policyType, policyFilter) {
3045
3438
  return this.policies$.pipe((0,external_rxjs_namespaceObject.concatMap)((policies) => policy_service_awaiter(this, void 0, void 0, function* () {
3046
3439
  const userId = yield this.stateService.getUserId();
@@ -3050,9 +3443,6 @@ class PolicyService {
3050
3443
  }
3051
3444
  })));
3052
3445
  }
3053
- /**
3054
- * @deprecated Do not call this, use the policies$ observable collection
3055
- */
3056
3446
  getAll(type, userId) {
3057
3447
  return policy_service_awaiter(this, void 0, void 0, function* () {
3058
3448
  let response = [];
@@ -3162,12 +3552,15 @@ class PolicyService {
3162
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;
3163
3553
  return [resetPasswordPolicyOptions, (_c = policy === null || policy === void 0 ? void 0 : policy.enabled) !== null && _c !== void 0 ? _c : false];
3164
3554
  }
3555
+ mapPolicyFromResponse(policyResponse) {
3556
+ const policyData = new PolicyData(policyResponse);
3557
+ return new Policy(policyData);
3558
+ }
3165
3559
  mapPoliciesFromToken(policiesResponse) {
3166
- if (policiesResponse == null || policiesResponse.data == null) {
3560
+ if ((policiesResponse === null || policiesResponse === void 0 ? void 0 : policiesResponse.data) == null) {
3167
3561
  return null;
3168
3562
  }
3169
- const policiesData = policiesResponse.data.map((p) => new PolicyData(p));
3170
- return policiesData.map((p) => new Policy(p));
3563
+ return policiesResponse.data.map((response) => this.mapPolicyFromResponse(response));
3171
3564
  }
3172
3565
  policyAppliesToUser(policyType, policyFilter, userId) {
3173
3566
  return policy_service_awaiter(this, void 0, void 0, function* () {
@@ -3308,6 +3701,276 @@ class ProviderService {
3308
3701
  }
3309
3702
  }
3310
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
+
3863
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/enums/authentication-status.ts
3864
+ var AuthenticationStatus;
3865
+ (function (AuthenticationStatus) {
3866
+ AuthenticationStatus[AuthenticationStatus["LoggedOut"] = 0] = "LoggedOut";
3867
+ AuthenticationStatus[AuthenticationStatus["Locked"] = 1] = "Locked";
3868
+ AuthenticationStatus[AuthenticationStatus["Unlocked"] = 2] = "Unlocked";
3869
+ })(AuthenticationStatus || (AuthenticationStatus = {}));
3870
+
3871
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/services/account.service.ts
3872
+ var account_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
3873
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3874
+ return new (P || (P = Promise))(function (resolve, reject) {
3875
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3876
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3877
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3878
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3879
+ });
3880
+ };
3881
+
3882
+
3883
+
3884
+
3885
+ function AccountsDeserializer(accounts) {
3886
+ if (accounts == null) {
3887
+ return {};
3888
+ }
3889
+ return accounts;
3890
+ }
3891
+ class AccountServiceImplementation {
3892
+ constructor(messagingService, logService, globalStateProvider) {
3893
+ this.messagingService = messagingService;
3894
+ this.logService = logService;
3895
+ this.globalStateProvider = globalStateProvider;
3896
+ this.lock = new external_rxjs_namespaceObject.Subject();
3897
+ this.logout = new external_rxjs_namespaceObject.Subject();
3898
+ this.accountLock$ = this.lock.asObservable();
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 }));
3904
+ }
3905
+ addAccount(userId, accountData) {
3906
+ this.accountsState.update((accounts) => {
3907
+ accounts || (accounts = {});
3908
+ accounts[userId] = accountData;
3909
+ return accounts;
3910
+ });
3911
+ }
3912
+ setAccountName(userId, name) {
3913
+ this.setAccountInfo(userId, { name });
3914
+ }
3915
+ setAccountEmail(userId, email) {
3916
+ this.setAccountInfo(userId, { email });
3917
+ }
3918
+ setAccountStatus(userId, status) {
3919
+ this.setAccountInfo(userId, { status });
3920
+ if (status === AuthenticationStatus.LoggedOut) {
3921
+ this.logout.next(userId);
3922
+ }
3923
+ else if (status === AuthenticationStatus.Locked) {
3924
+ this.lock.next(userId);
3925
+ }
3926
+ }
3927
+ switchAccount(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
+ });
3940
+ }
3941
+ // TODO: update to use our own account status settings. Requires inverting direction of state service accounts flow
3942
+ delete() {
3943
+ var _a;
3944
+ return account_service_awaiter(this, void 0, void 0, function* () {
3945
+ try {
3946
+ (_a = this.messagingService) === null || _a === void 0 ? void 0 : _a.send("logout");
3947
+ }
3948
+ catch (e) {
3949
+ this.logService.error(e);
3950
+ throw e;
3951
+ }
3952
+ });
3953
+ }
3954
+ setAccountInfo(userId, update) {
3955
+ function newAccountInfo(oldAccountInfo) {
3956
+ return Object.assign(Object.assign({}, oldAccountInfo), update);
3957
+ }
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
+ });
3971
+ }
3972
+ }
3973
+
3311
3974
  ;// CONCATENATED MODULE: ../../libs/common/src/platform/models/domain/symmetric-crypto-key.ts
3312
3975
 
3313
3976
 
@@ -3431,107 +4094,16 @@ class PreloginRequest {
3431
4094
  }
3432
4095
  }
3433
4096
 
3434
- ;// CONCATENATED MODULE: ../../libs/common/src/models/response/error.response.ts
3435
-
3436
-
3437
- class ErrorResponse extends BaseResponse {
3438
- constructor(response, status, identityResponse) {
3439
- var _a, _b;
3440
- super(response);
3441
- let errorModel = null;
3442
- if (response != null) {
3443
- const responseErrorModel = this.getResponseProperty("ErrorModel");
3444
- if (responseErrorModel && identityResponse) {
3445
- errorModel = responseErrorModel;
3446
- }
3447
- else {
3448
- errorModel = response;
3449
- }
3450
- }
3451
- if (status === 429) {
3452
- this.message = "Rate limit exceeded. Try again later.";
3453
- }
3454
- else if (errorModel) {
3455
- this.message = this.getResponseProperty("Message", errorModel);
3456
- this.validationErrors = this.getResponseProperty("ValidationErrors", errorModel);
3457
- this.captchaSiteKey = (_b = (_a = this.validationErrors) === null || _a === void 0 ? void 0 : _a.HCaptcha_SiteKey) === null || _b === void 0 ? void 0 : _b[0];
3458
- this.captchaRequired = !utils_Utils.isNullOrWhitespace(this.captchaSiteKey);
3459
- }
3460
- this.statusCode = status;
3461
- }
3462
- getSingleMessage() {
3463
- if (this.validationErrors == null) {
3464
- return this.message;
3465
- }
3466
- for (const key in this.validationErrors) {
3467
- // eslint-disable-next-line
3468
- if (!this.validationErrors.hasOwnProperty(key)) {
3469
- continue;
3470
- }
3471
- if (this.validationErrors[key].length) {
3472
- return this.validationErrors[key][0];
3473
- }
3474
- }
3475
- return this.message;
3476
- }
3477
- getAllMessages() {
3478
- const messages = [];
3479
- if (this.validationErrors == null) {
3480
- return messages;
3481
- }
3482
- for (const key in this.validationErrors) {
3483
- // eslint-disable-next-line
3484
- if (!this.validationErrors.hasOwnProperty(key)) {
3485
- continue;
3486
- }
3487
- this.validationErrors[key].forEach((item) => {
3488
- let prefix = "";
3489
- if (key.indexOf("[") > -1 && key.indexOf("]") > -1) {
3490
- const lastSep = key.lastIndexOf(".");
3491
- prefix = key.substr(0, lastSep > -1 ? lastSep : key.length) + ": ";
3492
- }
3493
- messages.push(prefix + item);
3494
- });
3495
- }
3496
- return messages;
3497
- }
3498
- }
3499
-
3500
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/enums/authentication-status.ts
3501
- var AuthenticationStatus;
3502
- (function (AuthenticationStatus) {
3503
- AuthenticationStatus[AuthenticationStatus["LoggedOut"] = 0] = "LoggedOut";
3504
- AuthenticationStatus[AuthenticationStatus["Locked"] = 1] = "Locked";
3505
- AuthenticationStatus[AuthenticationStatus["Unlocked"] = 2] = "Unlocked";
3506
- })(AuthenticationStatus || (AuthenticationStatus = {}));
3507
-
3508
4097
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/enums/authentication-type.ts
3509
4098
  var authentication_type_AuthenticationType;
3510
4099
  (function (AuthenticationType) {
3511
4100
  AuthenticationType[AuthenticationType["Password"] = 0] = "Password";
3512
4101
  AuthenticationType[AuthenticationType["Sso"] = 1] = "Sso";
3513
4102
  AuthenticationType[AuthenticationType["UserApi"] = 2] = "UserApi";
3514
- AuthenticationType[AuthenticationType["Passwordless"] = 3] = "Passwordless";
4103
+ AuthenticationType[AuthenticationType["AuthRequest"] = 3] = "AuthRequest";
4104
+ AuthenticationType[AuthenticationType["WebAuthn"] = 4] = "WebAuthn";
3515
4105
  })(authentication_type_AuthenticationType || (authentication_type_AuthenticationType = {}));
3516
4106
 
3517
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/force-reset-password-reason.ts
3518
- var ForceResetPasswordReason;
3519
- (function (ForceResetPasswordReason) {
3520
- /**
3521
- * A password reset should not be forced.
3522
- */
3523
- ForceResetPasswordReason[ForceResetPasswordReason["None"] = 0] = "None";
3524
- /**
3525
- * Occurs when an organization admin forces a user to reset their password.
3526
- */
3527
- ForceResetPasswordReason[ForceResetPasswordReason["AdminForcePasswordReset"] = 1] = "AdminForcePasswordReset";
3528
- /**
3529
- * Occurs when a user logs in / unlocks their vault with a master password that does not meet an organization's
3530
- * master password policy that is enforced on login/unlock.
3531
- */
3532
- ForceResetPasswordReason[ForceResetPasswordReason["WeakMasterPassword"] = 2] = "WeakMasterPassword";
3533
- })(ForceResetPasswordReason || (ForceResetPasswordReason = {}));
3534
-
3535
4107
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/identity-token/token.request.ts
3536
4108
  class TokenRequest {
3537
4109
  constructor(twoFactor, device) {
@@ -3545,8 +4117,8 @@ class TokenRequest {
3545
4117
  setTwoFactor(twoFactor) {
3546
4118
  this.twoFactor = twoFactor;
3547
4119
  }
3548
- setPasswordlessAccessCode(accessCode) {
3549
- this.passwordlessAuthRequest = accessCode;
4120
+ setAuthRequestAccessCode(accessCode) {
4121
+ this.authRequest = accessCode;
3550
4122
  }
3551
4123
  toIdentityToken(clientId) {
3552
4124
  const obj = {
@@ -3561,8 +4133,8 @@ class TokenRequest {
3561
4133
  // obj.devicePushToken = this.device.pushToken;
3562
4134
  }
3563
4135
  //passswordless login
3564
- if (this.passwordlessAuthRequest) {
3565
- obj.authRequest = this.passwordlessAuthRequest;
4136
+ if (this.authRequest) {
4137
+ obj.authRequest = this.authRequest;
3566
4138
  }
3567
4139
  if (this.twoFactor) {
3568
4140
  if (this.twoFactor.token && this.twoFactor.provider != null) {
@@ -3601,15 +4173,6 @@ class PasswordTokenRequest extends TokenRequest {
3601
4173
  }
3602
4174
  }
3603
4175
 
3604
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/identity-captcha.response.ts
3605
-
3606
- class IdentityCaptchaResponse extends BaseResponse {
3607
- constructor(response) {
3608
- super(response);
3609
- this.siteKey = this.getResponseProperty("HCaptcha_SiteKey");
3610
- }
3611
- }
3612
-
3613
4176
  ;// CONCATENATED MODULE: ../../libs/common/src/models/request/keys.request.ts
3614
4177
  class KeysRequest {
3615
4178
  constructor(publicKey, encryptedPrivateKey) {
@@ -3793,8 +4356,11 @@ class AccountKeys {
3793
4356
  this.cryptoSymmetricKey = new EncryptionPair();
3794
4357
  }
3795
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.
3796
4362
  return utils_Utils.merge(this, {
3797
- publicKey: utils_Utils.fromBufferToByteString(this.publicKey),
4363
+ publicKey: this.publicKey ? utils_Utils.fromBufferToByteString(this.publicKey) : undefined,
3798
4364
  });
3799
4365
  }
3800
4366
  static fromJSON(obj) {
@@ -3984,6 +4550,35 @@ var TwoFactorProviderType;
3984
4550
  TwoFactorProviderType[TwoFactorProviderType["WebAuthn"] = 7] = "WebAuthn";
3985
4551
  })(TwoFactorProviderType || (TwoFactorProviderType = {}));
3986
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
+
3987
4582
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/auth-result.ts
3988
4583
 
3989
4584
 
@@ -3997,7 +4592,7 @@ class AuthResult {
3997
4592
  * not have a master password and is not using Key Connector.
3998
4593
  * */
3999
4594
  this.resetMasterPassword = false;
4000
- this.forcePasswordReset = ForceResetPasswordReason.None;
4595
+ this.forcePasswordReset = ForceSetPasswordReason.None;
4001
4596
  this.twoFactorProviders = null;
4002
4597
  }
4003
4598
  get requiresCaptcha() {
@@ -4027,6 +4622,15 @@ class TokenTwoFactorRequest {
4027
4622
  }
4028
4623
  }
4029
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
+
4030
4634
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/master-password-policy.response.ts
4031
4635
 
4032
4636
  class MasterPasswordPolicyResponse extends BaseResponse {
@@ -4069,10 +4673,26 @@ class TrustedDeviceUserDecryptionOptionResponse extends BaseResponse {
4069
4673
  }
4070
4674
  }
4071
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
+
4072
4691
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/user-decryption-options/user-decryption-options.response.ts
4073
4692
 
4074
4693
 
4075
4694
 
4695
+
4076
4696
  class UserDecryptionOptionsResponse extends BaseResponse {
4077
4697
  constructor(response) {
4078
4698
  super(response);
@@ -4083,6 +4703,9 @@ class UserDecryptionOptionsResponse extends BaseResponse {
4083
4703
  if (response.KeyConnectorOption) {
4084
4704
  this.keyConnectorOption = new KeyConnectorUserDecryptionOptionResponse(this.getResponseProperty("KeyConnectorOption"));
4085
4705
  }
4706
+ if (response.WebAuthnPrfOption) {
4707
+ this.webAuthnPrfOption = new WebAuthnPrfDecryptionOptionResponse(this.getResponseProperty("WebAuthnPrfOption"));
4708
+ }
4086
4709
  }
4087
4710
  }
4088
4711
 
@@ -4159,7 +4782,8 @@ var login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thi
4159
4782
 
4160
4783
 
4161
4784
 
4162
- class LogInStrategy {
4785
+
4786
+ class LoginStrategy {
4163
4787
  constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService) {
4164
4788
  this.cryptoService = cryptoService;
4165
4789
  this.apiService = apiService;
@@ -4252,9 +4876,18 @@ class LogInStrategy {
4252
4876
  processTokenResponse(response) {
4253
4877
  return login_strategy_awaiter(this, void 0, void 0, function* () {
4254
4878
  const result = new AuthResult();
4879
+ // Old encryption keys must be migrated, but is currently only available on web.
4880
+ // Other clients shouldn't continue the login process.
4881
+ if (this.encryptionKeyMigrationRequired(response)) {
4882
+ result.requiresEncryptionKeyMigration = true;
4883
+ if (this.platformUtilsService.getClientType() !== ClientType.Web) {
4884
+ return result;
4885
+ }
4886
+ }
4255
4887
  result.resetMasterPassword = response.resetMasterPassword;
4888
+ // Convert boolean to enum
4256
4889
  if (response.forcePasswordReset) {
4257
- result.forcePasswordReset = ForceResetPasswordReason.AdminForcePasswordReset;
4890
+ result.forcePasswordReset = ForceSetPasswordReason.AdminForcePasswordReset;
4258
4891
  }
4259
4892
  // Must come before setting keys, user key needs email to update additional keys
4260
4893
  yield this.saveAccountInformation(response);
@@ -4268,6 +4901,11 @@ class LogInStrategy {
4268
4901
  return result;
4269
4902
  });
4270
4903
  }
4904
+ // Old accounts used master key for encryption. We are forcing migrations but only need to
4905
+ // check on password logins
4906
+ encryptionKeyMigrationRequired(response) {
4907
+ return false;
4908
+ }
4271
4909
  createKeyPairForOldAccount() {
4272
4910
  return login_strategy_awaiter(this, void 0, void 0, function* () {
4273
4911
  try {
@@ -4301,6 +4939,93 @@ class LogInStrategy {
4301
4939
  }
4302
4940
  }
4303
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
+
4304
5029
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/login-strategies/password-login.strategy.ts
4305
5030
  var password_login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4306
5031
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -4317,7 +5042,7 @@ var password_login_strategy_awaiter = (undefined && undefined.__awaiter) || func
4317
5042
 
4318
5043
 
4319
5044
 
4320
- class PasswordLogInStrategy extends LogInStrategy {
5045
+ class PasswordLoginStrategy extends LoginStrategy {
4321
5046
  get email() {
4322
5047
  return this.tokenRequest.email;
4323
5048
  }
@@ -4334,7 +5059,7 @@ class PasswordLogInStrategy extends LogInStrategy {
4334
5059
  * Options to track if the user needs to update their password due to a password that does not meet an organization's
4335
5060
  * master password policy.
4336
5061
  */
4337
- this.forcePasswordResetReason = ForceResetPasswordReason.None;
5062
+ this.forcePasswordResetReason = ForceSetPasswordReason.None;
4338
5063
  }
4339
5064
  logInTwoFactor(twoFactor, captchaResponse) {
4340
5065
  const _super = Object.create(null, {
@@ -4346,8 +5071,8 @@ class PasswordLogInStrategy extends LogInStrategy {
4346
5071
  // 2FA was successful, save the force update password options with the state service if defined
4347
5072
  if (!result.requiresTwoFactor &&
4348
5073
  !result.requiresCaptcha &&
4349
- this.forcePasswordResetReason != ForceResetPasswordReason.None) {
4350
- yield this.stateService.setForcePasswordResetReason(this.forcePasswordResetReason);
5074
+ this.forcePasswordResetReason != ForceSetPasswordReason.None) {
5075
+ yield this.stateService.setForceSetPasswordReason(this.forcePasswordResetReason);
4351
5076
  result.forcePasswordReset = this.forcePasswordResetReason;
4352
5077
  }
4353
5078
  return result;
@@ -4370,12 +5095,12 @@ class PasswordLogInStrategy extends LogInStrategy {
4370
5095
  if (!meetsRequirements) {
4371
5096
  if (authResult.requiresCaptcha || authResult.requiresTwoFactor) {
4372
5097
  // Save the flag to this strategy for later use as the master password is about to pass out of scope
4373
- this.forcePasswordResetReason = ForceResetPasswordReason.WeakMasterPassword;
5098
+ this.forcePasswordResetReason = ForceSetPasswordReason.WeakMasterPassword;
4374
5099
  }
4375
5100
  else {
4376
5101
  // Authentication was successful, save the force update password options with the state service
4377
- yield this.stateService.setForcePasswordResetReason(ForceResetPasswordReason.WeakMasterPassword);
4378
- authResult.forcePasswordReset = ForceResetPasswordReason.WeakMasterPassword;
5102
+ yield this.stateService.setForceSetPasswordReason(ForceSetPasswordReason.WeakMasterPassword);
5103
+ authResult.forcePasswordReset = ForceSetPasswordReason.WeakMasterPassword;
4379
5104
  }
4380
5105
  }
4381
5106
  }
@@ -4390,6 +5115,10 @@ class PasswordLogInStrategy extends LogInStrategy {
4390
5115
  }
4391
5116
  setUserKey(response) {
4392
5117
  return password_login_strategy_awaiter(this, void 0, void 0, function* () {
5118
+ // If migration is required, we won't have a user key to set yet.
5119
+ if (this.encryptionKeyMigrationRequired(response)) {
5120
+ return;
5121
+ }
4393
5122
  yield this.cryptoService.setMasterKeyEncryptedUserKey(response.key);
4394
5123
  const masterKey = yield this.cryptoService.getMasterKey();
4395
5124
  if (masterKey) {
@@ -4404,6 +5133,9 @@ class PasswordLogInStrategy extends LogInStrategy {
4404
5133
  yield this.cryptoService.setPrivateKey((_a = response.privateKey) !== null && _a !== void 0 ? _a : (yield this.createKeyPairForOldAccount()));
4405
5134
  });
4406
5135
  }
5136
+ encryptionKeyMigrationRequired(response) {
5137
+ return !response.key;
5138
+ }
4407
5139
  getMasterPasswordPolicyOptionsFromResponse(response) {
4408
5140
  if (response == null || response instanceof IdentityCaptchaResponse) {
4409
5141
  return null;
@@ -4417,91 +5149,6 @@ class PasswordLogInStrategy extends LogInStrategy {
4417
5149
  }
4418
5150
  }
4419
5151
 
4420
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/login-strategies/passwordless-login.strategy.ts
4421
- var passwordless_login_strategy_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4422
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4423
- return new (P || (P = Promise))(function (resolve, reject) {
4424
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4425
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4426
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4427
- step((generator = generator.apply(thisArg, _arguments || [])).next());
4428
- });
4429
- };
4430
-
4431
-
4432
- class PasswordlessLogInStrategy extends LogInStrategy {
4433
- get email() {
4434
- return this.tokenRequest.email;
4435
- }
4436
- get accessCode() {
4437
- return this.passwordlessCredentials.accessCode;
4438
- }
4439
- get authRequestId() {
4440
- return this.passwordlessCredentials.authRequestId;
4441
- }
4442
- constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, deviceTrustCryptoService) {
4443
- super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4444
- this.deviceTrustCryptoService = deviceTrustCryptoService;
4445
- }
4446
- logIn(credentials) {
4447
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4448
- this.passwordlessCredentials = credentials;
4449
- this.tokenRequest = new PasswordTokenRequest(credentials.email, credentials.accessCode, null, yield this.buildTwoFactor(credentials.twoFactor), yield this.buildDeviceRequest());
4450
- this.tokenRequest.setPasswordlessAccessCode(credentials.authRequestId);
4451
- const [authResult] = yield this.startLogIn();
4452
- return authResult;
4453
- });
4454
- }
4455
- logInTwoFactor(twoFactor, captchaResponse) {
4456
- const _super = Object.create(null, {
4457
- logInTwoFactor: { get: () => super.logInTwoFactor }
4458
- });
4459
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4460
- this.tokenRequest.captchaResponse = captchaResponse !== null && captchaResponse !== void 0 ? captchaResponse : this.captchaBypassToken;
4461
- return _super.logInTwoFactor.call(this, twoFactor);
4462
- });
4463
- }
4464
- setMasterKey(response) {
4465
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4466
- if (this.passwordlessCredentials.decryptedMasterKey &&
4467
- this.passwordlessCredentials.decryptedMasterKeyHash) {
4468
- yield this.cryptoService.setMasterKey(this.passwordlessCredentials.decryptedMasterKey);
4469
- yield this.cryptoService.setMasterKeyHash(this.passwordlessCredentials.decryptedMasterKeyHash);
4470
- }
4471
- });
4472
- }
4473
- setUserKey(response) {
4474
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4475
- // User now may or may not have a master password
4476
- // but set the master key encrypted user key if it exists regardless
4477
- yield this.cryptoService.setMasterKeyEncryptedUserKey(response.key);
4478
- if (this.passwordlessCredentials.decryptedUserKey) {
4479
- yield this.cryptoService.setUserKey(this.passwordlessCredentials.decryptedUserKey);
4480
- }
4481
- else {
4482
- yield this.trySetUserKeyWithMasterKey();
4483
- // Establish trust if required after setting user key
4484
- yield this.deviceTrustCryptoService.trustDeviceIfRequired();
4485
- }
4486
- });
4487
- }
4488
- trySetUserKeyWithMasterKey() {
4489
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4490
- const masterKey = yield this.cryptoService.getMasterKey();
4491
- if (masterKey) {
4492
- const userKey = yield this.cryptoService.decryptUserKeyWithMasterKey(masterKey);
4493
- yield this.cryptoService.setUserKey(userKey);
4494
- }
4495
- });
4496
- }
4497
- setPrivateKey(response) {
4498
- var _a;
4499
- return passwordless_login_strategy_awaiter(this, void 0, void 0, function* () {
4500
- yield this.cryptoService.setPrivateKey((_a = response.privateKey) !== null && _a !== void 0 ? _a : (yield this.createKeyPairForOldAccount()));
4501
- });
4502
- }
4503
- }
4504
-
4505
5152
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/identity-token/sso-token.request.ts
4506
5153
 
4507
5154
  class SsoTokenRequest extends TokenRequest {
@@ -4536,7 +5183,8 @@ var sso_login_strategy_awaiter = (undefined && undefined.__awaiter) || function
4536
5183
 
4537
5184
 
4538
5185
 
4539
- class SsoLogInStrategy extends LogInStrategy {
5186
+
5187
+ class SsoLoginStrategy extends LoginStrategy {
4540
5188
  constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, keyConnectorService, deviceTrustCryptoService, authReqCryptoService, i18nService) {
4541
5189
  super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4542
5190
  this.keyConnectorService = keyConnectorService;
@@ -4551,6 +5199,10 @@ class SsoLogInStrategy extends LogInStrategy {
4551
5199
  const [ssoAuthResult] = yield this.startLogIn();
4552
5200
  this.email = ssoAuthResult.email;
4553
5201
  this.ssoEmail2FaSessionToken = ssoAuthResult.ssoEmail2FaSessionToken;
5202
+ // Auth guard currently handles redirects for this.
5203
+ if (ssoAuthResult.forcePasswordReset == ForceSetPasswordReason.AdminForcePasswordReset) {
5204
+ yield this.stateService.setForceSetPasswordReason(ssoAuthResult.forcePasswordReset);
5205
+ }
4554
5206
  return ssoAuthResult;
4555
5207
  });
4556
5208
  }
@@ -4748,7 +5400,7 @@ var user_api_login_strategy_awaiter = (undefined && undefined.__awaiter) || func
4748
5400
  };
4749
5401
 
4750
5402
 
4751
- class UserApiLogInStrategy extends LogInStrategy {
5403
+ class UserApiLoginStrategy extends LoginStrategy {
4752
5404
  constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService, environmentService, keyConnectorService) {
4753
5405
  super(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService);
4754
5406
  this.environmentService = environmentService;
@@ -4799,6 +5451,86 @@ class UserApiLogInStrategy extends LogInStrategy {
4799
5451
  }
4800
5452
  }
4801
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
+
4802
5534
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/request/passwordless-auth.request.ts
4803
5535
  class PasswordlessAuthRequest {
4804
5536
  constructor(key, masterPasswordHash, deviceIdentifier, requestApproved) {
@@ -4832,33 +5564,34 @@ var auth_service_awaiter = (undefined && undefined.__awaiter) || function (thisA
4832
5564
 
4833
5565
 
4834
5566
 
5567
+
4835
5568
  const sessionTimeoutLength = 2 * 60 * 1000; // 2 minutes
4836
5569
  class AuthService {
4837
5570
  get email() {
4838
- if (this.logInStrategy instanceof PasswordLogInStrategy ||
4839
- this.logInStrategy instanceof PasswordlessLogInStrategy ||
4840
- this.logInStrategy instanceof SsoLogInStrategy) {
5571
+ if (this.logInStrategy instanceof PasswordLoginStrategy ||
5572
+ this.logInStrategy instanceof AuthRequestLoginStrategy ||
5573
+ this.logInStrategy instanceof SsoLoginStrategy) {
4841
5574
  return this.logInStrategy.email;
4842
5575
  }
4843
5576
  return null;
4844
5577
  }
4845
5578
  get masterPasswordHash() {
4846
- return this.logInStrategy instanceof PasswordLogInStrategy
5579
+ return this.logInStrategy instanceof PasswordLoginStrategy
4847
5580
  ? this.logInStrategy.masterPasswordHash
4848
5581
  : null;
4849
5582
  }
4850
5583
  get accessCode() {
4851
- return this.logInStrategy instanceof PasswordlessLogInStrategy
5584
+ return this.logInStrategy instanceof AuthRequestLoginStrategy
4852
5585
  ? this.logInStrategy.accessCode
4853
5586
  : null;
4854
5587
  }
4855
5588
  get authRequestId() {
4856
- return this.logInStrategy instanceof PasswordlessLogInStrategy
5589
+ return this.logInStrategy instanceof AuthRequestLoginStrategy
4857
5590
  ? this.logInStrategy.authRequestId
4858
5591
  : null;
4859
5592
  }
4860
5593
  get ssoEmail2FaSessionToken() {
4861
- return this.logInStrategy instanceof SsoLogInStrategy
5594
+ return this.logInStrategy instanceof SsoLoginStrategy
4862
5595
  ? this.logInStrategy.ssoEmail2FaSessionToken
4863
5596
  : null;
4864
5597
  }
@@ -4888,18 +5621,23 @@ class AuthService {
4888
5621
  let strategy;
4889
5622
  switch (credentials.type) {
4890
5623
  case authentication_type_AuthenticationType.Password:
4891
- 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);
4892
5625
  break;
4893
5626
  case authentication_type_AuthenticationType.Sso:
4894
- 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);
4895
5628
  break;
4896
5629
  case authentication_type_AuthenticationType.UserApi:
4897
- 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);
5631
+ break;
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);
4898
5634
  break;
4899
- case authentication_type_AuthenticationType.Passwordless:
4900
- strategy = new PasswordlessLogInStrategy(this.cryptoService, this.apiService, this.tokenService, this.appIdService, this.platformUtilsService, this.messagingService, this.logService, this.stateService, this.twoFactorService, this.deviceTrustCryptoService);
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);
4901
5637
  break;
4902
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.
4903
5641
  const result = yield strategy.logIn(credentials);
4904
5642
  if (result === null || result === void 0 ? void 0 : result.requiresTwoFactor) {
4905
5643
  this.saveState(strategy);
@@ -4934,16 +5672,16 @@ class AuthService {
4934
5672
  this.messagingService.send("loggedOut");
4935
5673
  }
4936
5674
  authingWithUserApiKey() {
4937
- return this.logInStrategy instanceof UserApiLogInStrategy;
5675
+ return this.logInStrategy instanceof UserApiLoginStrategy;
4938
5676
  }
4939
5677
  authingWithSso() {
4940
- return this.logInStrategy instanceof SsoLogInStrategy;
5678
+ return this.logInStrategy instanceof SsoLoginStrategy;
4941
5679
  }
4942
5680
  authingWithPassword() {
4943
- return this.logInStrategy instanceof PasswordLogInStrategy;
5681
+ return this.logInStrategy instanceof PasswordLoginStrategy;
4944
5682
  }
4945
5683
  authingWithPasswordless() {
4946
- return this.logInStrategy instanceof PasswordlessLogInStrategy;
5684
+ return this.logInStrategy instanceof AuthRequestLoginStrategy;
4947
5685
  }
4948
5686
  getAuthStatus(userId) {
4949
5687
  return auth_service_awaiter(this, void 0, void 0, function* () {
@@ -5214,7 +5952,7 @@ class DeviceTrustCryptoService {
5214
5952
  }
5215
5953
  }
5216
5954
 
5217
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/devices/responses/device.response.ts
5955
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/abstractions/devices/responses/device.response.ts
5218
5956
 
5219
5957
  class DeviceResponse extends BaseResponse {
5220
5958
  constructor(response) {
@@ -5229,15 +5967,6 @@ class DeviceResponse extends BaseResponse {
5229
5967
  }
5230
5968
  }
5231
5969
 
5232
- ;// CONCATENATED MODULE: ../../libs/common/src/services/devices/requests/trusted-device-keys.request.ts
5233
- class TrustedDeviceKeysRequest {
5234
- constructor(encryptedUserKey, encryptedPublicKey, encryptedPrivateKey) {
5235
- this.encryptedUserKey = encryptedUserKey;
5236
- this.encryptedPublicKey = encryptedPublicKey;
5237
- this.encryptedPrivateKey = encryptedPrivateKey;
5238
- }
5239
- }
5240
-
5241
5970
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/protected-device.response.ts
5242
5971
 
5243
5972
 
@@ -5258,6 +5987,15 @@ class ProtectedDeviceResponse extends BaseResponse {
5258
5987
  }
5259
5988
  }
5260
5989
 
5990
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/services/devices/requests/trusted-device-keys.request.ts
5991
+ class TrustedDeviceKeysRequest {
5992
+ constructor(encryptedUserKey, encryptedPublicKey, encryptedPrivateKey) {
5993
+ this.encryptedUserKey = encryptedUserKey;
5994
+ this.encryptedPublicKey = encryptedPublicKey;
5995
+ this.encryptedPrivateKey = encryptedPrivateKey;
5996
+ }
5997
+ }
5998
+
5261
5999
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/services/devices-api.service.implementation.ts
5262
6000
  var devices_api_service_implementation_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
5263
6001
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -14159,6 +14897,11 @@ class CryptoService {
14159
14897
  }
14160
14898
  });
14161
14899
  }
14900
+ isLegacyUser(masterKey, userId) {
14901
+ return crypto_service_awaiter(this, void 0, void 0, function* () {
14902
+ return yield this.validateUserKey((masterKey !== null && masterKey !== void 0 ? masterKey : (yield this.getMasterKey(userId))));
14903
+ });
14904
+ }
14162
14905
  getUserKeyWithLegacySupport(userId) {
14163
14906
  return crypto_service_awaiter(this, void 0, void 0, function* () {
14164
14907
  const userKey = yield this.getUserKey(userId);
@@ -14546,7 +15289,8 @@ class CryptoService {
14546
15289
  }
14547
15290
  makeKeyPair(key) {
14548
15291
  return crypto_service_awaiter(this, void 0, void 0, function* () {
14549
- key || (key = yield this.getUserKey());
15292
+ // Default to user key
15293
+ key || (key = yield this.getUserKeyWithLegacySupport());
14550
15294
  const keyPair = yield this.cryptoFunctionService.rsaGenerateKeyPair(2048);
14551
15295
  const publicB64 = utils_Utils.fromBufferToB64(keyPair[0]);
14552
15296
  const privateEnc = yield this.encryptService.encrypt(keyPair[1], key);
@@ -14949,19 +15693,26 @@ class CryptoService {
14949
15693
  migrateAutoKeyIfNeeded(userId) {
14950
15694
  return crypto_service_awaiter(this, void 0, void 0, function* () {
14951
15695
  const oldAutoKey = yield this.stateService.getCryptoMasterKeyAuto({ userId: userId });
14952
- if (oldAutoKey) {
14953
- // decrypt
14954
- const masterKey = new SymmetricCryptoKey(utils_Utils.fromB64ToArray(oldAutoKey));
14955
- const encryptedUserKey = yield this.stateService.getEncryptedCryptoSymmetricKey({
14956
- userId: userId,
14957
- });
14958
- const userKey = yield this.decryptUserKeyWithMasterKey(masterKey, new EncString(encryptedUserKey), userId);
14959
- // migrate
14960
- yield this.stateService.setUserKeyAutoUnlock(userKey.keyB64, { userId: userId });
14961
- yield this.stateService.setCryptoMasterKeyAuto(null, { userId: userId });
14962
- // set encrypted user key in case user immediately locks without syncing
14963
- yield this.setMasterKeyEncryptedUserKey(encryptedUserKey);
15696
+ if (!oldAutoKey) {
15697
+ return;
15698
+ }
15699
+ // Decrypt
15700
+ const masterKey = new SymmetricCryptoKey(utils_Utils.fromB64ToArray(oldAutoKey));
15701
+ if (yield this.isLegacyUser(masterKey, userId)) {
15702
+ // Legacy users don't have a user key, so no need to migrate.
15703
+ // Instead, set the master key for additional isLegacyUser checks that will log the user out.
15704
+ yield this.setMasterKey(masterKey, userId);
15705
+ return;
14964
15706
  }
15707
+ const encryptedUserKey = yield this.stateService.getEncryptedCryptoSymmetricKey({
15708
+ userId: userId,
15709
+ });
15710
+ const userKey = yield this.decryptUserKeyWithMasterKey(masterKey, new EncString(encryptedUserKey), userId);
15711
+ // Migrate
15712
+ yield this.stateService.setUserKeyAutoUnlock(userKey.keyB64, { userId: userId });
15713
+ yield this.stateService.setCryptoMasterKeyAuto(null, { userId: userId });
15714
+ // Set encrypted user key in case user immediately locks without syncing
15715
+ yield this.setMasterKeyEncryptedUserKey(encryptedUserKey);
14965
15716
  });
14966
15717
  }
14967
15718
  decryptAndMigrateOldPinKey(masterPasswordOnRestart, pin, email, kdf, kdfConfig, oldPinKey) {
@@ -15219,7 +15970,7 @@ class EncryptServiceImplementation {
15219
15970
  return null;
15220
15971
  }
15221
15972
  }
15222
- return yield this.cryptoFunctionService.aesDecryptFast(fastParams);
15973
+ return yield this.cryptoFunctionService.aesDecryptFast(fastParams, "cbc");
15223
15974
  });
15224
15975
  }
15225
15976
  decryptToBytes(encThing, key) {
@@ -15251,7 +16002,7 @@ class EncryptServiceImplementation {
15251
16002
  return null;
15252
16003
  }
15253
16004
  }
15254
- const result = yield this.cryptoFunctionService.aesDecrypt(encThing.dataBytes, encThing.ivBytes, key.encKey);
16005
+ const result = yield this.cryptoFunctionService.aesDecrypt(encThing.dataBytes, encThing.ivBytes, key.encKey, "cbc");
15255
16006
  return result !== null && result !== void 0 ? result : null;
15256
16007
  });
15257
16008
  }
@@ -15328,6 +16079,7 @@ var environment_service_awaiter = (undefined && undefined.__awaiter) || function
15328
16079
 
15329
16080
 
15330
16081
 
16082
+
15331
16083
  class environment_service_EnvironmentService {
15332
16084
  constructor(stateService) {
15333
16085
  this.stateService = stateService;
@@ -15553,6 +16305,27 @@ class environment_service_EnvironmentService {
15553
16305
  this.notificationsUrl == null &&
15554
16306
  this.eventsUrl == null);
15555
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
+ }
15556
16329
  setRegion(region) {
15557
16330
  return environment_service_awaiter(this, void 0, void 0, function* () {
15558
16331
  this.selectedRegion = region;
@@ -15911,10 +16684,18 @@ var memory_storage_service_awaiter = (undefined && undefined.__awaiter) || funct
15911
16684
  });
15912
16685
  };
15913
16686
 
16687
+
15914
16688
  class MemoryStorageService extends AbstractMemoryStorageService {
15915
16689
  constructor() {
15916
16690
  super(...arguments);
15917
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();
15918
16699
  }
15919
16700
  get(key) {
15920
16701
  if (this.store.has(key)) {
@@ -15933,10 +16714,12 @@ class MemoryStorageService extends AbstractMemoryStorageService {
15933
16714
  return this.remove(key);
15934
16715
  }
15935
16716
  this.store.set(key, obj);
16717
+ this.updatesSubject.next({ key, updateType: "save" });
15936
16718
  return Promise.resolve();
15937
16719
  }
15938
16720
  remove(key) {
15939
16721
  this.store.delete(key);
16722
+ this.updatesSubject.next({ key, updateType: "remove" });
15940
16723
  return Promise.resolve();
15941
16724
  }
15942
16725
  getBypassCache(key) {
@@ -15951,6 +16734,27 @@ class NoopMessagingService {
15951
16734
  }
15952
16735
  }
15953
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
+
15954
16758
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/data/provider.data.ts
15955
16759
  class ProviderData {
15956
16760
  constructor(response) {
@@ -16041,7 +16845,7 @@ class MigrationBuilder {
16041
16845
  helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) should migrate: ${shouldMigrate} - ${direction}`);
16042
16846
  if (shouldMigrate) {
16043
16847
  const method = direction === "up" ? migrator.migrate : migrator.rollback;
16044
- yield method(helper);
16848
+ yield method.bind(migrator)(helper);
16045
16849
  helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) migrated - ${direction}`);
16046
16850
  yield migrator.updateVersion(helper, direction);
16047
16851
  helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) updated version - ${direction}`);
@@ -16440,6 +17244,70 @@ class MoveStateVersionMigrator extends Migrator {
16440
17244
  }
16441
17245
  }
16442
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
+
16443
17311
  ;// CONCATENATED MODULE: ../../libs/common/src/state-migrations/migrations/min-version.ts
16444
17312
  var min_version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
16445
17313
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -16496,8 +17364,9 @@ var migrate_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
16496
17364
 
16497
17365
 
16498
17366
 
17367
+
16499
17368
  const MIN_VERSION = 2;
16500
- const CURRENT_VERSION = 8;
17369
+ const CURRENT_VERSION = 9;
16501
17370
  function migrate(storageService, logService) {
16502
17371
  return migrate_awaiter(this, void 0, void 0, function* () {
16503
17372
  const migrationHelper = new MigrationHelper(yield currentVersion(storageService, logService), storageService, logService);
@@ -16513,7 +17382,8 @@ function migrate(storageService, logService) {
16513
17382
  .with(AddKeyTypeToOrgKeysMigrator, 4, 5)
16514
17383
  .with(RemoveLegacyEtmKeyMigrator, 5, 6)
16515
17384
  .with(MoveBiometricAutoPromptToAccount, 6, 7)
16516
- .with(MoveStateVersionMigrator, 7, CURRENT_VERSION)
17385
+ .with(MoveStateVersionMigrator, 7, 8)
17386
+ .with(MoveBrowserSettingsToGlobal, 8, CURRENT_VERSION)
16517
17387
  .migrate(migrationHelper);
16518
17388
  });
16519
17389
  }
@@ -17348,6 +18218,28 @@ class IdentityData {
17348
18218
  }
17349
18219
  }
17350
18220
 
18221
+ ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/data/fido2-credential.data.ts
18222
+ class Fido2CredentialData {
18223
+ constructor(data) {
18224
+ if (data == null) {
18225
+ return;
18226
+ }
18227
+ this.credentialId = data.credentialId;
18228
+ this.keyType = data.keyType;
18229
+ this.keyAlgorithm = data.keyAlgorithm;
18230
+ this.keyCurve = data.keyCurve;
18231
+ this.keyValue = data.keyValue;
18232
+ this.rpId = data.rpId;
18233
+ this.userHandle = data.userHandle;
18234
+ this.userName = data.userName;
18235
+ this.counter = data.counter;
18236
+ this.rpName = data.rpName;
18237
+ this.userDisplayName = data.userDisplayName;
18238
+ this.discoverable = data.discoverable;
18239
+ this.creationDate = data.creationDate;
18240
+ }
18241
+ }
18242
+
17351
18243
  ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/data/login-uri.data.ts
17352
18244
  class LoginUriData {
17353
18245
  constructor(data) {
@@ -17362,8 +18254,10 @@ class LoginUriData {
17362
18254
 
17363
18255
  ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/data/login.data.ts
17364
18256
 
18257
+
17365
18258
  class LoginData {
17366
18259
  constructor(data) {
18260
+ var _a;
17367
18261
  if (data == null) {
17368
18262
  return;
17369
18263
  }
@@ -17375,6 +18269,9 @@ class LoginData {
17375
18269
  if (data.uris) {
17376
18270
  this.uris = data.uris.map((u) => new LoginUriData(u));
17377
18271
  }
18272
+ if (data.fido2Credentials) {
18273
+ this.fido2Credentials = (_a = data.fido2Credentials) === null || _a === void 0 ? void 0 : _a.map((key) => new Fido2CredentialData(key));
18274
+ }
17378
18275
  }
17379
18276
  }
17380
18277
 
@@ -17465,6 +18362,8 @@ class CollectionData {
17465
18362
  this.name = response.name;
17466
18363
  this.externalId = response.externalId;
17467
18364
  this.readOnly = response.readOnly;
18365
+ this.manage = response.manage;
18366
+ this.hidePasswords = response.hidePasswords;
17468
18367
  }
17469
18368
  }
17470
18369
 
@@ -17933,8 +18832,25 @@ identity_view_decorate([
17933
18832
  identity_view_metadata("design:paramtypes", [])
17934
18833
  ], IdentityView.prototype, "fullName", null);
17935
18834
 
17936
- ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/view/login-uri.view.ts
18835
+ ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/view/fido2-credential.view.ts
17937
18836
 
18837
+ class Fido2CredentialView extends ItemView {
18838
+ constructor() {
18839
+ super(...arguments);
18840
+ this.creationDate = null;
18841
+ }
18842
+ get subTitle() {
18843
+ return this.userDisplayName;
18844
+ }
18845
+ static fromJSON(obj) {
18846
+ const creationDate = obj.creationDate != null ? new Date(obj.creationDate) : null;
18847
+ return Object.assign(new Fido2CredentialView(), obj, {
18848
+ creationDate,
18849
+ });
18850
+ }
18851
+ }
18852
+
18853
+ ;// CONCATENATED MODULE: ../../libs/common/src/platform/misc/safe-urls.ts
17938
18854
 
17939
18855
  const CanLaunchWhitelist = [
17940
18856
  "https://",
@@ -17951,6 +18867,24 @@ const CanLaunchWhitelist = [
17951
18867
  "iosapp://",
17952
18868
  "androidapp://",
17953
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
+
17954
18888
  class LoginUriView {
17955
18889
  constructor(u) {
17956
18890
  this.match = null;
@@ -18022,15 +18956,11 @@ class LoginUriView {
18022
18956
  return this._canLaunch;
18023
18957
  }
18024
18958
  if (this.uri != null && this.match !== UriMatchType.RegularExpression) {
18025
- const uri = this.launchUri;
18026
- for (let i = 0; i < CanLaunchWhitelist.length; i++) {
18027
- if (uri.indexOf(CanLaunchWhitelist[i]) === 0) {
18028
- this._canLaunch = true;
18029
- return this._canLaunch;
18030
- }
18031
- }
18959
+ this._canLaunch = SafeUrls.canLaunch(this.launchUri);
18960
+ }
18961
+ else {
18962
+ this._canLaunch = false;
18032
18963
  }
18033
- this._canLaunch = false;
18034
18964
  return this._canLaunch;
18035
18965
  }
18036
18966
  get launchUri() {
@@ -18104,6 +19034,7 @@ var login_view_metadata = (undefined && undefined.__metadata) || function (k, v)
18104
19034
 
18105
19035
 
18106
19036
 
19037
+
18107
19038
  class LoginView extends ItemView {
18108
19039
  constructor(l) {
18109
19040
  super();
@@ -18113,6 +19044,7 @@ class LoginView extends ItemView {
18113
19044
  this.totp = null;
18114
19045
  this.uris = null;
18115
19046
  this.autofillOnPageLoad = null;
19047
+ this.fido2Credentials = null;
18116
19048
  if (!l) {
18117
19049
  return;
18118
19050
  }
@@ -18146,6 +19078,9 @@ class LoginView extends ItemView {
18146
19078
  get hasUris() {
18147
19079
  return this.uris != null && this.uris.length > 0;
18148
19080
  }
19081
+ get hasFido2Credentials() {
19082
+ return this.fido2Credentials != null && this.fido2Credentials.length > 0;
19083
+ }
18149
19084
  matchesUri(targetUri, equivalentDomains, defaultUriMatch = null) {
18150
19085
  if (this.uris == null) {
18151
19086
  return false;
@@ -18153,12 +19088,14 @@ class LoginView extends ItemView {
18153
19088
  return this.uris.some((uri) => uri.matchesUri(targetUri, equivalentDomains, defaultUriMatch));
18154
19089
  }
18155
19090
  static fromJSON(obj) {
18156
- var _a;
19091
+ var _a, _b;
18157
19092
  const passwordRevisionDate = obj.passwordRevisionDate == null ? null : new Date(obj.passwordRevisionDate);
18158
19093
  const uris = (_a = obj.uris) === null || _a === void 0 ? void 0 : _a.map((uri) => LoginUriView.fromJSON(uri));
19094
+ const fido2Credentials = (_b = obj.fido2Credentials) === null || _b === void 0 ? void 0 : _b.map((key) => Fido2CredentialView.fromJSON(key));
18159
19095
  return Object.assign(new LoginView(), obj, {
18160
- passwordRevisionDate: passwordRevisionDate,
18161
- uris: uris,
19096
+ passwordRevisionDate,
19097
+ uris,
19098
+ fido2Credentials,
18162
19099
  });
18163
19100
  }
18164
19101
  }
@@ -18280,7 +19217,8 @@ class CipherView {
18280
19217
  return null;
18281
19218
  }
18282
19219
  get subTitle() {
18283
- return this.item.subTitle;
19220
+ var _a;
19221
+ return (_a = this.item) === null || _a === void 0 ? void 0 : _a.subTitle;
18284
19222
  }
18285
19223
  get hasPasswordHistory() {
18286
19224
  return this.passwordHistory && this.passwordHistory.length > 0;
@@ -18314,7 +19252,8 @@ class CipherView {
18314
19252
  return this.deletedDate != null;
18315
19253
  }
18316
19254
  get linkedFieldOptions() {
18317
- return this.item.linkedFieldOptions;
19255
+ var _a;
19256
+ return (_a = this.item) === null || _a === void 0 ? void 0 : _a.linkedFieldOptions;
18318
19257
  }
18319
19258
  linkedFieldValue(id) {
18320
19259
  var _a;
@@ -18380,7 +19319,8 @@ class Collection extends Domain {
18380
19319
  externalId: null,
18381
19320
  readOnly: null,
18382
19321
  hidePasswords: null,
18383
- }, ["id", "organizationId", "externalId", "readOnly", "hidePasswords"]);
19322
+ manage: null,
19323
+ }, ["id", "organizationId", "externalId", "readOnly", "hidePasswords", "manage"]);
18384
19324
  }
18385
19325
  decrypt() {
18386
19326
  return this.decryptObj(new CollectionView(this), {
@@ -18398,8 +19338,10 @@ class CollectionView {
18398
19338
  this.organizationId = null;
18399
19339
  this.name = null;
18400
19340
  this.externalId = null;
19341
+ // readOnly applies to the items within a collection
18401
19342
  this.readOnly = null;
18402
19343
  this.hidePasswords = null;
19344
+ this.manage = null;
18403
19345
  if (!c) {
18404
19346
  return;
18405
19347
  }
@@ -18409,6 +19351,26 @@ class CollectionView {
18409
19351
  if (c instanceof Collection) {
18410
19352
  this.readOnly = c.readOnly;
18411
19353
  this.hidePasswords = c.hidePasswords;
19354
+ this.manage = c.manage;
19355
+ }
19356
+ }
19357
+ // For editing collection details, not the items within it.
19358
+ canEdit(org) {
19359
+ if (org.id !== this.organizationId) {
19360
+ throw new Error("Id of the organization provided does not match the org id of the collection.");
19361
+ }
19362
+ return (org === null || org === void 0 ? void 0 : org.canEditAnyCollection) || (org === null || org === void 0 ? void 0 : org.canEditAssignedCollections);
19363
+ }
19364
+ // For deleting a collection, not the items within it.
19365
+ canDelete(org, flexibleCollectionsEnabled) {
19366
+ if (org.id !== this.organizationId) {
19367
+ throw new Error("Id of the organization provided does not match the org id of the collection.");
19368
+ }
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);
18412
19374
  }
18413
19375
  }
18414
19376
  }
@@ -18484,6 +19446,8 @@ var state_service_awaiter = (undefined && undefined.__awaiter) || function (this
18484
19446
 
18485
19447
 
18486
19448
 
19449
+
19450
+
18487
19451
 
18488
19452
 
18489
19453
 
@@ -18505,12 +19469,13 @@ const partialKeys = {
18505
19469
  };
18506
19470
  const DDG_SHARED_KEY = "DuckDuckGoSharedKey";
18507
19471
  class StateService {
18508
- constructor(storageService, secureStorageService, memoryStorageService, logService, stateFactory, useAccountCache = true) {
19472
+ constructor(storageService, secureStorageService, memoryStorageService, logService, stateFactory, accountService, useAccountCache = true) {
18509
19473
  this.storageService = storageService;
18510
19474
  this.secureStorageService = secureStorageService;
18511
19475
  this.memoryStorageService = memoryStorageService;
18512
19476
  this.logService = logService;
18513
19477
  this.stateFactory = stateFactory;
19478
+ this.accountService = accountService;
18514
19479
  this.useAccountCache = useAccountCache;
18515
19480
  this.accountsSubject = new external_rxjs_namespaceObject.BehaviorSubject({});
18516
19481
  this.accounts$ = this.accountsSubject.asObservable();
@@ -18577,6 +19542,19 @@ class StateService {
18577
19542
  }
18578
19543
  yield this.pushAccounts();
18579
19544
  this.activeAccountSubject.next(state.activeUserId);
19545
+ // TODO: Temporary update to avoid routing all account status changes through account service for now.
19546
+ // account service tracks logged out accounts, but State service does not, so we need to add the active account
19547
+ // if it's not in the accounts list.
19548
+ if (state.activeUserId != null && this.accountsSubject.value[state.activeUserId] == null) {
19549
+ const activeDiskAccount = yield this.getAccountFromDisk({ userId: state.activeUserId });
19550
+ this.accountService.addAccount(state.activeUserId, {
19551
+ name: activeDiskAccount.profile.name,
19552
+ email: activeDiskAccount.profile.email,
19553
+ status: AuthenticationStatus.LoggedOut,
19554
+ });
19555
+ }
19556
+ this.accountService.switchAccount(state.activeUserId);
19557
+ // End TODO
18580
19558
  return state;
18581
19559
  }));
18582
19560
  });
@@ -18593,6 +19571,12 @@ class StateService {
18593
19571
  state.accounts[userId] = this.createAccount();
18594
19572
  const diskAccount = yield this.getAccountFromDisk({ userId: userId });
18595
19573
  state.accounts[userId].profile = diskAccount.profile;
19574
+ // TODO: Temporary update to avoid routing all account status changes through account service for now.
19575
+ this.accountService.addAccount(userId, {
19576
+ status: AuthenticationStatus.Locked,
19577
+ name: diskAccount.profile.name,
19578
+ email: diskAccount.profile.email,
19579
+ });
18596
19580
  return state;
18597
19581
  }));
18598
19582
  });
@@ -18608,6 +19592,12 @@ class StateService {
18608
19592
  }));
18609
19593
  yield this.scaffoldNewAccountStorage(account);
18610
19594
  yield this.setLastActive(new Date().getTime(), { userId: account.profile.userId });
19595
+ // TODO: Temporary update to avoid routing all account status changes through account service for now.
19596
+ this.accountService.addAccount(account.profile.userId, {
19597
+ status: AuthenticationStatus.Locked,
19598
+ name: account.profile.name,
19599
+ email: account.profile.email,
19600
+ });
18611
19601
  yield this.setActiveUser(account.profile.userId);
18612
19602
  this.activeAccountSubject.next(account.profile.userId);
18613
19603
  });
@@ -18619,6 +19609,8 @@ class StateService {
18619
19609
  state.activeUserId = userId;
18620
19610
  yield this.storageService.save(keys.activeUserId, userId);
18621
19611
  this.activeAccountSubject.next(state.activeUserId);
19612
+ // TODO: temporary update to avoid routing all account status changes through account service for now.
19613
+ this.accountService.switchAccount(userId);
18622
19614
  return state;
18623
19615
  }));
18624
19616
  yield this.pushAccounts();
@@ -18895,6 +19887,8 @@ class StateService {
18895
19887
  const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
18896
19888
  account.keys.cryptoMasterKey = value;
18897
19889
  yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
19890
+ const nextStatus = value != null ? AuthenticationStatus.Unlocked : AuthenticationStatus.Locked;
19891
+ this.accountService.setAccountStatus(options.userId, nextStatus);
18898
19892
  if (options.userId == this.activeAccountSubject.getValue()) {
18899
19893
  const nextValue = value != null;
18900
19894
  // Avoid emitting if we are already unlocked
@@ -18922,6 +19916,8 @@ class StateService {
18922
19916
  const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
18923
19917
  account.keys.userKey = value;
18924
19918
  yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
19919
+ const nextStatus = value != null ? AuthenticationStatus.Unlocked : AuthenticationStatus.Locked;
19920
+ this.accountService.setAccountStatus(options.userId, nextStatus);
18925
19921
  if ((options === null || options === void 0 ? void 0 : options.userId) == this.activeAccountSubject.getValue()) {
18926
19922
  const nextValue = value != null;
18927
19923
  // Avoid emitting if we are already unlocked
@@ -19295,16 +20291,16 @@ class StateService {
19295
20291
  });
19296
20292
  }
19297
20293
  getDisableAddLoginNotification(options) {
19298
- var _a, _b, _c;
20294
+ var _a, _b;
19299
20295
  return state_service_awaiter(this, void 0, void 0, function* () {
19300
- 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);
19301
20297
  });
19302
20298
  }
19303
20299
  setDisableAddLoginNotification(value, options) {
19304
20300
  return state_service_awaiter(this, void 0, void 0, function* () {
19305
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19306
- account.settings.disableAddLoginNotification = value;
19307
- 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()));
19308
20304
  });
19309
20305
  }
19310
20306
  getDisableAutoBiometricsPrompt(options) {
@@ -19347,29 +20343,42 @@ class StateService {
19347
20343
  });
19348
20344
  }
19349
20345
  getDisableChangedPasswordNotification(options) {
19350
- var _a, _b, _c;
20346
+ var _a, _b;
19351
20347
  return state_service_awaiter(this, void 0, void 0, function* () {
19352
- 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);
19353
20349
  });
19354
20350
  }
19355
20351
  setDisableChangedPasswordNotification(value, options) {
19356
20352
  return state_service_awaiter(this, void 0, void 0, function* () {
19357
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19358
- account.settings.disableChangedPasswordNotification = value;
19359
- 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()));
19360
20369
  });
19361
20370
  }
19362
20371
  getDisableContextMenuItem(options) {
19363
- var _a, _b, _c;
20372
+ var _a, _b;
19364
20373
  return state_service_awaiter(this, void 0, void 0, function* () {
19365
- 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);
19366
20375
  });
19367
20376
  }
19368
20377
  setDisableContextMenuItem(value, options) {
19369
20378
  return state_service_awaiter(this, void 0, void 0, function* () {
19370
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19371
- account.settings.disableContextMenuItem = value;
19372
- 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()));
19373
20382
  });
19374
20383
  }
19375
20384
  getDisableFavicon(options) {
@@ -19597,6 +20606,19 @@ class StateService {
19597
20606
  yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
19598
20607
  });
19599
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
+ }
19600
20622
  getEnableAutoFillOnPageLoad(options) {
19601
20623
  var _a, _b, _c;
19602
20624
  return state_service_awaiter(this, void 0, void 0, function* () {
@@ -19981,16 +21003,16 @@ class StateService {
19981
21003
  yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
19982
21004
  });
19983
21005
  }
19984
- getForcePasswordResetReason(options) {
21006
+ getForceSetPasswordReason(options) {
19985
21007
  var _a, _b, _c;
19986
21008
  return state_service_awaiter(this, void 0, void 0, function* () {
19987
- 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);
19988
21010
  });
19989
21011
  }
19990
- setForcePasswordResetReason(value, options) {
21012
+ setForceSetPasswordReason(value, options) {
19991
21013
  return state_service_awaiter(this, void 0, void 0, function* () {
19992
21014
  const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskMemoryOptions()));
19993
- account.profile.forcePasswordResetReason = value;
21015
+ account.profile.forceSetPasswordReason = value;
19994
21016
  yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskMemoryOptions()));
19995
21017
  });
19996
21018
  }
@@ -20144,16 +21166,16 @@ class StateService {
20144
21166
  });
20145
21167
  }
20146
21168
  getNeverDomains(options) {
20147
- var _a, _b;
21169
+ var _a;
20148
21170
  return state_service_awaiter(this, void 0, void 0, function* () {
20149
- 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;
20150
21172
  });
20151
21173
  }
20152
21174
  setNeverDomains(value, options) {
20153
21175
  return state_service_awaiter(this, void 0, void 0, function* () {
20154
- const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20155
- account.settings.neverDomains = value;
20156
- 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()));
20157
21179
  });
20158
21180
  }
20159
21181
  getNoAutoPromptBiometricsText(options) {
@@ -20195,19 +21217,6 @@ class StateService {
20195
21217
  yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultInMemoryOptions()));
20196
21218
  });
20197
21219
  }
20198
- getEmergencyAccessInvitation(options) {
20199
- var _a;
20200
- return state_service_awaiter(this, void 0, void 0, function* () {
20201
- return (_a = (yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.emergencyAccessInvitation;
20202
- });
20203
- }
20204
- setEmergencyAccessInvitation(value, options) {
20205
- return state_service_awaiter(this, void 0, void 0, function* () {
20206
- const globals = yield this.getGlobals(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20207
- globals.emergencyAccessInvitation = value;
20208
- yield this.saveGlobals(globals, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
20209
- });
20210
- }
20211
21220
  /**
20212
21221
  * @deprecated Do not call this directly, use OrganizationService
20213
21222
  */
@@ -20567,6 +21576,19 @@ class StateService {
20567
21576
  return yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskLocalOptions()));
20568
21577
  });
20569
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
+ }
20570
21592
  getGlobals(options) {
20571
21593
  return state_service_awaiter(this, void 0, void 0, function* () {
20572
21594
  let globals;
@@ -20771,7 +21793,6 @@ class StateService {
20771
21793
  yield this.saveAccount(account, this.reconcileOptions({ userId: account.profile.userId }, yield this.defaultOnDiskOptions()));
20772
21794
  });
20773
21795
  }
20774
- //
20775
21796
  pushAccounts() {
20776
21797
  return state_service_awaiter(this, void 0, void 0, function* () {
20777
21798
  yield this.pruneInMemoryAccounts();
@@ -20890,6 +21911,8 @@ class StateService {
20890
21911
  this.deleteDiskCache(userId);
20891
21912
  return state;
20892
21913
  }));
21914
+ // TODO: Invert this logic, we should remove accounts based on logged out emit
21915
+ this.accountService.setAccountStatus(userId, AuthenticationStatus.LoggedOut);
20893
21916
  });
20894
21917
  }
20895
21918
  pruneInMemoryAccounts() {
@@ -21179,6 +22202,139 @@ function withPrototypeForObjectValues(valuesConstructor, valuesConverter = (i) =
21179
22202
  };
21180
22203
  }
21181
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
+
21182
22338
  ;// CONCATENATED MODULE: ../../libs/common/src/platform/misc/throttle.ts
21183
22339
  /**
21184
22340
  * Use as a Decorator on async functions, it will limit how many times the function can be
@@ -21307,104 +22463,73 @@ audit_service_decorate([
21307
22463
  audit_service_metadata("design:returntype", Promise)
21308
22464
  ], AuditService.prototype, "passwordLeaked", null);
21309
22465
 
21310
- ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/response/selection-read-only.response.ts
21311
-
21312
- class SelectionReadOnlyResponse extends BaseResponse {
21313
- constructor(response) {
21314
- super(response);
21315
- this.id = this.getResponseProperty("Id");
21316
- this.readOnly = this.getResponseProperty("ReadOnly");
21317
- this.hidePasswords = this.getResponseProperty("HidePasswords");
21318
- }
21319
- }
21320
-
21321
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/responses/organization-user.response.ts
21322
-
21323
-
21324
-
21325
- class OrganizationUserResponse extends BaseResponse {
21326
- constructor(response) {
21327
- super(response);
21328
- this.collections = [];
21329
- this.groups = [];
21330
- this.id = this.getResponseProperty("Id");
21331
- this.userId = this.getResponseProperty("UserId");
21332
- this.type = this.getResponseProperty("Type");
21333
- this.status = this.getResponseProperty("Status");
21334
- this.permissions = new PermissionsApi(this.getResponseProperty("Permissions"));
21335
- this.externalId = this.getResponseProperty("ExternalId");
21336
- this.accessAll = this.getResponseProperty("AccessAll");
21337
- this.accessSecretsManager = this.getResponseProperty("AccessSecretsManager");
21338
- this.resetPasswordEnrolled = this.getResponseProperty("ResetPasswordEnrolled");
21339
- this.hasMasterPassword = this.getResponseProperty("HasMasterPassword");
21340
- const collections = this.getResponseProperty("Collections");
21341
- if (collections != null) {
21342
- this.collections = collections.map((c) => new SelectionReadOnlyResponse(c));
21343
- }
21344
- const groups = this.getResponseProperty("Groups");
21345
- if (groups != null) {
21346
- this.groups = groups;
21347
- }
21348
- }
21349
- }
21350
- class OrganizationUserUserDetailsResponse extends OrganizationUserResponse {
21351
- constructor(response) {
21352
- var _a;
21353
- super(response);
21354
- this.name = this.getResponseProperty("Name");
21355
- this.email = this.getResponseProperty("Email");
21356
- this.avatarColor = this.getResponseProperty("AvatarColor");
21357
- this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
21358
- this.usesKeyConnector = (_a = this.getResponseProperty("UsesKeyConnector")) !== null && _a !== void 0 ? _a : false;
21359
- }
21360
- }
21361
- class OrganizationUserDetailsResponse extends OrganizationUserResponse {
21362
- constructor(response) {
21363
- super(response);
21364
- }
21365
- }
21366
- class OrganizationUserResetPasswordDetailsResponse extends BaseResponse {
21367
- constructor(response) {
21368
- super(response);
21369
- this.kdf = this.getResponseProperty("Kdf");
21370
- this.kdfIterations = this.getResponseProperty("KdfIterations");
21371
- this.kdfMemory = this.getResponseProperty("KdfMemory");
21372
- this.kdfParallelism = this.getResponseProperty("KdfParallelism");
21373
- this.resetPasswordKey = this.getResponseProperty("ResetPasswordKey");
21374
- this.encryptedPrivateKey = this.getResponseProperty("EncryptedPrivateKey");
21375
- }
21376
- }
21377
-
21378
- ;// 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
+ };
21379
22476
 
21380
- class OrganizationUserBulkResponse extends BaseResponse {
21381
- constructor(response) {
21382
- super(response);
21383
- this.id = this.getResponseProperty("Id");
21384
- 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;
21385
22483
  }
21386
- }
21387
-
21388
- ;// CONCATENATED MODULE: ../../libs/common/src/abstractions/organization-user/responses/organization-user-bulk-public-key.response.ts
21389
-
21390
- class OrganizationUserBulkPublicKeyResponse extends BaseResponse {
21391
- constructor(response) {
21392
- super(response);
21393
- this.id = this.getResponseProperty("Id");
21394
- this.userId = this.getResponseProperty("UserId");
21395
- 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
+ });
21396
22524
  }
21397
22525
  }
21398
22526
 
21399
- ;// CONCATENATED MODULE: ../../libs/common/src/services/organization-user/requests/organization-user-bulk.request.ts
21400
- class OrganizationUserBulkRequest {
21401
- constructor(ids) {
21402
- this.ids = ids == null ? [] : ids;
21403
- }
22527
+ ;// CONCATENATED MODULE: ../../libs/common/src/models/request/event.request.ts
22528
+ class EventRequest {
21404
22529
  }
21405
22530
 
21406
- ;// CONCATENATED MODULE: ../../libs/common/src/services/organization-user/organization-user.service.implementation.ts
21407
- 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) {
21408
22533
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21409
22534
  return new (P || (P = Promise))(function (resolve, reject) {
21410
22535
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -21414,122 +22539,53 @@ var organization_user_service_implementation_awaiter = (undefined && undefined._
21414
22539
  });
21415
22540
  };
21416
22541
 
21417
-
21418
-
21419
- class OrganizationUserServiceImplementation {
21420
- constructor(apiService) {
22542
+ class EventUploadService {
22543
+ constructor(apiService, stateService, logService) {
21421
22544
  this.apiService = apiService;
22545
+ this.stateService = stateService;
22546
+ this.logService = logService;
22547
+ this.inited = false;
21422
22548
  }
21423
- getOrganizationUser(organizationId, id, options) {
21424
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21425
- const params = new URLSearchParams();
21426
- if (options === null || options === void 0 ? void 0 : options.includeGroups) {
21427
- params.set("includeGroups", "true");
21428
- }
21429
- const r = yield this.apiService.send("GET", `/organizations/${organizationId}/users/${id}?${params.toString()}`, null, true, true);
21430
- return new OrganizationUserDetailsResponse(r);
21431
- });
21432
- }
21433
- getOrganizationUserGroups(organizationId, id) {
21434
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21435
- const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/users/" + id + "/groups", null, true, true);
21436
- return r;
21437
- });
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
+ }
21438
22558
  }
21439
- getAllUsers(organizationId, options) {
21440
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21441
- const params = new URLSearchParams();
21442
- if (options === null || options === void 0 ? void 0 : options.includeCollections) {
21443
- 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;
21444
22564
  }
21445
- if (options === null || options === void 0 ? void 0 : options.includeGroups) {
21446
- 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);
21447
22583
  }
21448
- const r = yield this.apiService.send("GET", `/organizations/${organizationId}/users?${params.toString()}`, null, true, true);
21449
- return new ListResponse(r, OrganizationUserUserDetailsResponse);
21450
- });
21451
- }
21452
- getOrganizationUserResetPasswordDetails(organizationId, id) {
21453
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21454
- const r = yield this.apiService.send("GET", "/organizations/" + organizationId + "/users/" + id + "/reset-password-details", null, true, true);
21455
- return new OrganizationUserResetPasswordDetailsResponse(r);
21456
- });
21457
- }
21458
- postOrganizationUserInvite(organizationId, request) {
21459
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/invite", request, true, false);
21460
- }
21461
- postOrganizationUserReinvite(organizationId, id) {
21462
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/reinvite", null, true, false);
21463
- }
21464
- postManyOrganizationUserReinvite(organizationId, ids) {
21465
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21466
- const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/reinvite", new OrganizationUserBulkRequest(ids), true, true);
21467
- return new ListResponse(r, OrganizationUserBulkResponse);
21468
- });
21469
- }
21470
- postOrganizationUserAcceptInit(organizationId, id, request) {
21471
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/accept-init", request, true, false);
21472
- }
21473
- postOrganizationUserAccept(organizationId, id, request) {
21474
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/accept", request, true, false);
21475
- }
21476
- postOrganizationUserConfirm(organizationId, id, request) {
21477
- return this.apiService.send("POST", "/organizations/" + organizationId + "/users/" + id + "/confirm", request, true, false);
21478
- }
21479
- postOrganizationUsersPublicKey(organizationId, ids) {
21480
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21481
- const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/public-keys", new OrganizationUserBulkRequest(ids), true, true);
21482
- return new ListResponse(r, OrganizationUserBulkPublicKeyResponse);
21483
- });
21484
- }
21485
- postOrganizationUserBulkConfirm(organizationId, request) {
21486
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21487
- const r = yield this.apiService.send("POST", "/organizations/" + organizationId + "/users/confirm", request, true, true);
21488
- return new ListResponse(r, OrganizationUserBulkResponse);
21489
- });
21490
- }
21491
- putOrganizationUserBulkEnableSecretsManager(organizationId, ids) {
21492
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21493
- yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/enable-secrets-manager", new OrganizationUserBulkRequest(ids), true, false);
21494
- });
21495
- }
21496
- putOrganizationUser(organizationId, id, request) {
21497
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id, request, true, false);
21498
- }
21499
- putOrganizationUserGroups(organizationId, id, request) {
21500
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/groups", request, true, false);
21501
- }
21502
- putOrganizationUserResetPasswordEnrollment(organizationId, userId, request) {
21503
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment", request, true, false);
21504
- }
21505
- putOrganizationUserResetPassword(organizationId, id, request) {
21506
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/reset-password", request, true, false);
21507
- }
21508
- deleteOrganizationUser(organizationId, id) {
21509
- return this.apiService.send("DELETE", "/organizations/" + organizationId + "/users/" + id, null, true, false);
21510
- }
21511
- deleteManyOrganizationUsers(organizationId, ids) {
21512
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21513
- const r = yield this.apiService.send("DELETE", "/organizations/" + organizationId + "/users", new OrganizationUserBulkRequest(ids), true, true);
21514
- return new ListResponse(r, OrganizationUserBulkResponse);
21515
22584
  });
21516
22585
  }
21517
- revokeOrganizationUser(organizationId, id) {
21518
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/revoke", null, true, false);
21519
- }
21520
- revokeManyOrganizationUsers(organizationId, ids) {
21521
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21522
- const r = yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/revoke", new OrganizationUserBulkRequest(ids), true, true);
21523
- return new ListResponse(r, OrganizationUserBulkResponse);
21524
- });
21525
- }
21526
- restoreOrganizationUser(organizationId, id) {
21527
- return this.apiService.send("PUT", "/organizations/" + organizationId + "/users/" + id + "/restore", null, true, false);
21528
- }
21529
- restoreManyOrganizationUsers(organizationId, ids) {
21530
- return organization_user_service_implementation_awaiter(this, void 0, void 0, function* () {
21531
- const r = yield this.apiService.send("PUT", "/organizations/" + organizationId + "/users/restore", new OrganizationUserBulkRequest(ids), true, true);
21532
- 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 });
21533
22589
  });
21534
22590
  }
21535
22591
  }
@@ -21904,6 +22960,16 @@ class SettingsService {
21904
22960
  getDisableFavicon() {
21905
22961
  return this._disableFavicon.getValue();
21906
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
+ }
21907
22973
  clear(userId) {
21908
22974
  return settings_service_awaiter(this, void 0, void 0, function* () {
21909
22975
  if (userId == null || userId == (yield this.stateService.getUserId())) {
@@ -22099,13 +23165,13 @@ class VaultTimeoutSettingsService {
22099
23165
  }
22100
23166
  setVaultTimeoutOptions(timeout, action) {
22101
23167
  return vault_timeout_settings_service_awaiter(this, void 0, void 0, function* () {
22102
- yield this.stateService.setVaultTimeout(timeout);
22103
23168
  // We swap these tokens from being on disk for lock actions, and in memory for logout actions
22104
23169
  // Get them here to set them to their new location after changing the timeout action and clearing if needed
22105
23170
  const token = yield this.tokenService.getToken();
22106
23171
  const refreshToken = yield this.tokenService.getRefreshToken();
22107
23172
  const clientId = yield this.tokenService.getClientId();
22108
23173
  const clientSecret = yield this.tokenService.getClientSecret();
23174
+ yield this.stateService.setVaultTimeout(timeout);
22109
23175
  const currentAction = yield this.stateService.getVaultTimeoutAction();
22110
23176
  if ((timeout != null || timeout === 0) &&
22111
23177
  action === VaultTimeoutAction.LogOut &&
@@ -22236,6 +23302,7 @@ var vault_timeout_service_awaiter = (undefined && undefined.__awaiter) || functi
22236
23302
 
22237
23303
 
22238
23304
 
23305
+
22239
23306
  class VaultTimeoutService {
22240
23307
  constructor(cipherService, folderService, collectionService, cryptoService, platformUtilsService, messagingService, searchService, stateService, authService, vaultTimeoutSettingsService, lockedCallback = null, loggedOutCallback = null) {
22241
23308
  this.cipherService = cipherService;
@@ -22349,10 +23416,18 @@ class VaultTimeoutService {
22349
23416
  }
22350
23417
  migrateKeyForNeverLockIfNeeded() {
22351
23418
  return vault_timeout_service_awaiter(this, void 0, void 0, function* () {
23419
+ // Web can't set vault timeout to never
23420
+ if (this.platformUtilsService.getClientType() == ClientType.Web) {
23421
+ return;
23422
+ }
22352
23423
  const accounts = yield (0,external_rxjs_namespaceObject.firstValueFrom)(this.stateService.accounts$);
22353
23424
  for (const userId in accounts) {
22354
23425
  if (userId != null) {
22355
23426
  yield this.cryptoService.migrateAutoKeyIfNeeded(userId);
23427
+ // Legacy users should be logged out since we're not on the web vault and can't migrate.
23428
+ if (yield this.cryptoService.isLegacyUser(null, userId)) {
23429
+ yield this.logOut(userId);
23430
+ }
22356
23431
  }
22357
23432
  }
22358
23433
  });
@@ -23208,7 +24283,7 @@ function devFlagEnabled(flag) {
23208
24283
  return false;
23209
24284
  }
23210
24285
  const devFlags = getFlags(process.env.DEV_FLAGS);
23211
- return devFlags[flag] == null || !!devFlags[flag];
24286
+ return (devFlags === null || devFlags === void 0 ? void 0 : devFlags[flag]) == null ? false : !!devFlags[flag];
23212
24287
  }
23213
24288
  /**
23214
24289
  * Gets the value of a dev flag from environment.
@@ -23548,6 +24623,125 @@ class Identity extends Domain {
23548
24623
  }
23549
24624
  }
23550
24625
 
24626
+ ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/domain/fido2-credential.ts
24627
+ var fido2_credential_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24628
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24629
+ return new (P || (P = Promise))(function (resolve, reject) {
24630
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24631
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24632
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24633
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24634
+ });
24635
+ };
24636
+
24637
+
24638
+
24639
+
24640
+ class Fido2Credential extends Domain {
24641
+ constructor(obj) {
24642
+ super();
24643
+ this.credentialId = null;
24644
+ if (obj == null) {
24645
+ return;
24646
+ }
24647
+ this.buildDomainModel(this, obj, {
24648
+ credentialId: null,
24649
+ keyType: null,
24650
+ keyAlgorithm: null,
24651
+ keyCurve: null,
24652
+ keyValue: null,
24653
+ rpId: null,
24654
+ userHandle: null,
24655
+ userName: null,
24656
+ counter: null,
24657
+ rpName: null,
24658
+ userDisplayName: null,
24659
+ discoverable: null,
24660
+ }, []);
24661
+ this.creationDate = obj.creationDate != null ? new Date(obj.creationDate) : null;
24662
+ }
24663
+ decrypt(orgId, encKey) {
24664
+ return fido2_credential_awaiter(this, void 0, void 0, function* () {
24665
+ const view = yield this.decryptObj(new Fido2CredentialView(), {
24666
+ credentialId: null,
24667
+ keyType: null,
24668
+ keyAlgorithm: null,
24669
+ keyCurve: null,
24670
+ keyValue: null,
24671
+ rpId: null,
24672
+ userHandle: null,
24673
+ userName: null,
24674
+ rpName: null,
24675
+ userDisplayName: null,
24676
+ discoverable: null,
24677
+ }, orgId, encKey);
24678
+ const { counter } = yield this.decryptObj({ counter: "" }, {
24679
+ counter: null,
24680
+ }, orgId, encKey);
24681
+ // Counter will end up as NaN if this fails
24682
+ view.counter = parseInt(counter);
24683
+ const { discoverable } = yield this.decryptObj({ discoverable: "" }, {
24684
+ discoverable: null,
24685
+ }, orgId, encKey);
24686
+ view.discoverable = discoverable === "true";
24687
+ view.creationDate = this.creationDate;
24688
+ return view;
24689
+ });
24690
+ }
24691
+ toFido2CredentialData() {
24692
+ const i = new Fido2CredentialData();
24693
+ i.creationDate = this.creationDate.toISOString();
24694
+ this.buildDataModel(this, i, {
24695
+ credentialId: null,
24696
+ keyType: null,
24697
+ keyAlgorithm: null,
24698
+ keyCurve: null,
24699
+ keyValue: null,
24700
+ rpId: null,
24701
+ userHandle: null,
24702
+ userName: null,
24703
+ counter: null,
24704
+ rpName: null,
24705
+ userDisplayName: null,
24706
+ discoverable: null,
24707
+ });
24708
+ return i;
24709
+ }
24710
+ static fromJSON(obj) {
24711
+ if (obj == null) {
24712
+ return null;
24713
+ }
24714
+ const credentialId = EncString.fromJSON(obj.credentialId);
24715
+ const keyType = EncString.fromJSON(obj.keyType);
24716
+ const keyAlgorithm = EncString.fromJSON(obj.keyAlgorithm);
24717
+ const keyCurve = EncString.fromJSON(obj.keyCurve);
24718
+ const keyValue = EncString.fromJSON(obj.keyValue);
24719
+ const rpId = EncString.fromJSON(obj.rpId);
24720
+ const userHandle = EncString.fromJSON(obj.userHandle);
24721
+ const userName = EncString.fromJSON(obj.userName);
24722
+ const counter = EncString.fromJSON(obj.counter);
24723
+ const rpName = EncString.fromJSON(obj.rpName);
24724
+ const userDisplayName = EncString.fromJSON(obj.userDisplayName);
24725
+ const discoverable = EncString.fromJSON(obj.discoverable);
24726
+ const creationDate = obj.creationDate != null ? new Date(obj.creationDate) : null;
24727
+ return Object.assign(new Fido2Credential(), obj, {
24728
+ credentialId,
24729
+ keyType,
24730
+ keyAlgorithm,
24731
+ keyCurve,
24732
+ keyValue,
24733
+ rpId,
24734
+ userHandle,
24735
+ userName,
24736
+ counter,
24737
+ rpName,
24738
+ userDisplayName,
24739
+ discoverable,
24740
+ creationDate,
24741
+ });
24742
+ }
24743
+ }
24744
+
23551
24745
  ;// CONCATENATED MODULE: ../../libs/common/src/vault/models/domain/login-uri.ts
23552
24746
 
23553
24747
 
@@ -23603,6 +24797,7 @@ var login_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _ar
23603
24797
 
23604
24798
 
23605
24799
 
24800
+
23606
24801
  class Login extends Domain {
23607
24802
  constructor(obj) {
23608
24803
  super();
@@ -23623,6 +24818,9 @@ class Login extends Domain {
23623
24818
  this.uris.push(new LoginUri(u));
23624
24819
  });
23625
24820
  }
24821
+ if (obj.fido2Credentials) {
24822
+ this.fido2Credentials = obj.fido2Credentials.map((key) => new Fido2Credential(key));
24823
+ }
23626
24824
  }
23627
24825
  decrypt(orgId, encKey) {
23628
24826
  return login_awaiter(this, void 0, void 0, function* () {
@@ -23638,6 +24836,9 @@ class Login extends Domain {
23638
24836
  view.uris.push(uri);
23639
24837
  }
23640
24838
  }
24839
+ if (this.fido2Credentials != null) {
24840
+ view.fido2Credentials = yield Promise.all(this.fido2Credentials.map((key) => key.decrypt(orgId, encKey)));
24841
+ }
23641
24842
  return view;
23642
24843
  });
23643
24844
  }
@@ -23657,10 +24858,13 @@ class Login extends Domain {
23657
24858
  l.uris.push(u.toLoginUriData());
23658
24859
  });
23659
24860
  }
24861
+ if (this.fido2Credentials != null && this.fido2Credentials.length > 0) {
24862
+ l.fido2Credentials = this.fido2Credentials.map((key) => key.toFido2CredentialData());
24863
+ }
23660
24864
  return l;
23661
24865
  }
23662
24866
  static fromJSON(obj) {
23663
- var _a;
24867
+ var _a, _b, _c;
23664
24868
  if (obj == null) {
23665
24869
  return null;
23666
24870
  }
@@ -23669,12 +24873,14 @@ class Login extends Domain {
23669
24873
  const totp = EncString.fromJSON(obj.totp);
23670
24874
  const passwordRevisionDate = obj.passwordRevisionDate == null ? null : new Date(obj.passwordRevisionDate);
23671
24875
  const uris = (_a = obj.uris) === null || _a === void 0 ? void 0 : _a.map((uri) => LoginUri.fromJSON(uri));
24876
+ const fido2Credentials = (_c = (_b = obj.fido2Credentials) === null || _b === void 0 ? void 0 : _b.map((key) => Fido2Credential.fromJSON(key))) !== null && _c !== void 0 ? _c : [];
23672
24877
  return Object.assign(new Login(), obj, {
23673
24878
  username,
23674
24879
  password,
23675
24880
  totp,
23676
- passwordRevisionDate: passwordRevisionDate,
23677
- uris: uris,
24881
+ passwordRevisionDate,
24882
+ uris,
24883
+ fido2Credentials,
23678
24884
  });
23679
24885
  }
23680
24886
  }
@@ -24173,9 +25379,34 @@ class LoginUriApi extends BaseResponse {
24173
25379
  }
24174
25380
  }
24175
25381
 
25382
+ ;// CONCATENATED MODULE: ../../libs/common/src/vault/api/fido2-credential.api.ts
25383
+
25384
+ class Fido2CredentialApi extends BaseResponse {
25385
+ constructor(data = null) {
25386
+ super(data);
25387
+ if (data == null) {
25388
+ return;
25389
+ }
25390
+ this.credentialId = this.getResponseProperty("CredentialId");
25391
+ this.keyType = this.getResponseProperty("KeyType");
25392
+ this.keyAlgorithm = this.getResponseProperty("KeyAlgorithm");
25393
+ this.keyCurve = this.getResponseProperty("KeyCurve");
25394
+ this.keyValue = this.getResponseProperty("keyValue");
25395
+ this.rpId = this.getResponseProperty("RpId");
25396
+ this.userHandle = this.getResponseProperty("UserHandle");
25397
+ this.userName = this.getResponseProperty("UserName");
25398
+ this.counter = this.getResponseProperty("Counter");
25399
+ this.rpName = this.getResponseProperty("RpName");
25400
+ this.userDisplayName = this.getResponseProperty("UserDisplayName");
25401
+ this.discoverable = this.getResponseProperty("Discoverable");
25402
+ this.creationDate = this.getResponseProperty("CreationDate");
25403
+ }
25404
+ }
25405
+
24176
25406
  ;// CONCATENATED MODULE: ../../libs/common/src/models/api/login.api.ts
24177
25407
 
24178
25408
 
25409
+
24179
25410
  class LoginApi extends BaseResponse {
24180
25411
  constructor(data = null) {
24181
25412
  super(data);
@@ -24191,6 +25422,10 @@ class LoginApi extends BaseResponse {
24191
25422
  if (uris != null) {
24192
25423
  this.uris = uris.map((u) => new LoginUriApi(u));
24193
25424
  }
25425
+ const fido2Credentials = this.getResponseProperty("Fido2Credentials");
25426
+ if (fido2Credentials != null) {
25427
+ this.fido2Credentials = fido2Credentials.map((key) => new Fido2CredentialApi(key));
25428
+ }
24194
25429
  }
24195
25430
  }
24196
25431
 
@@ -24219,6 +25454,7 @@ class AttachmentRequest {
24219
25454
 
24220
25455
 
24221
25456
 
25457
+
24222
25458
  class CipherRequest {
24223
25459
  constructor(cipher) {
24224
25460
  var _a;
@@ -24251,6 +25487,31 @@ class CipherRequest {
24251
25487
  return uri;
24252
25488
  });
24253
25489
  }
25490
+ if (cipher.login.fido2Credentials != null) {
25491
+ this.login.fido2Credentials = cipher.login.fido2Credentials.map((key) => {
25492
+ const keyApi = new Fido2CredentialApi();
25493
+ keyApi.credentialId =
25494
+ key.credentialId != null ? key.credentialId.encryptedString : null;
25495
+ keyApi.keyType =
25496
+ key.keyType != null ? key.keyType.encryptedString : null;
25497
+ keyApi.keyAlgorithm =
25498
+ key.keyAlgorithm != null ? key.keyAlgorithm.encryptedString : null;
25499
+ keyApi.keyCurve =
25500
+ key.keyCurve != null ? key.keyCurve.encryptedString : null;
25501
+ keyApi.keyValue = key.keyValue != null ? key.keyValue.encryptedString : null;
25502
+ keyApi.rpId = key.rpId != null ? key.rpId.encryptedString : null;
25503
+ keyApi.rpName = key.rpName != null ? key.rpName.encryptedString : null;
25504
+ keyApi.counter = key.counter != null ? key.counter.encryptedString : null;
25505
+ keyApi.userHandle = key.userHandle != null ? key.userHandle.encryptedString : null;
25506
+ keyApi.userName = key.userName != null ? key.userName.encryptedString : null;
25507
+ keyApi.userDisplayName =
25508
+ key.userDisplayName != null ? key.userDisplayName.encryptedString : null;
25509
+ keyApi.discoverable =
25510
+ key.discoverable != null ? key.discoverable.encryptedString : null;
25511
+ keyApi.creationDate = key.creationDate != null ? key.creationDate.toISOString() : null;
25512
+ return keyApi;
25513
+ });
25514
+ }
24254
25515
  break;
24255
25516
  case CipherType.SecureNote:
24256
25517
  this.secureNote = new SecureNoteApi();
@@ -24453,6 +25714,7 @@ var cipher_service_awaiter = (undefined && undefined.__awaiter) || function (thi
24453
25714
 
24454
25715
 
24455
25716
 
25717
+
24456
25718
 
24457
25719
 
24458
25720
  const CIPHER_KEY_ENC_MIN_SERVER_VER = new external_semver_namespaceObject.SemVer("2023.9.1");
@@ -24653,13 +25915,13 @@ class CipherService {
24653
25915
  yield this.reindexCiphers();
24654
25916
  return yield this.getDecryptedCipherCache();
24655
25917
  }
24656
- const hasKey = yield this.cryptoService.hasUserKey();
24657
- if (!hasKey) {
24658
- throw new Error("No user key found.");
24659
- }
24660
25918
  const ciphers = yield this.getAll();
24661
25919
  const orgKeys = yield this.cryptoService.getOrgKeys();
24662
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
+ }
24663
25925
  // Group ciphers by orgId or under 'null' for the user's ciphers
24664
25926
  const grouped = ciphers.reduce((agg, c) => {
24665
25927
  var _a;
@@ -24713,13 +25975,16 @@ class CipherService {
24713
25975
  const ciphers = yield this.getAllDecrypted();
24714
25976
  defaultMatch !== null && defaultMatch !== void 0 ? defaultMatch : (defaultMatch = yield this.stateService.getDefaultUriMatch());
24715
25977
  return ciphers.filter((cipher) => {
24716
- if (cipher.deletedDate != null) {
25978
+ const cipherIsLogin = cipher.type === CipherType.Login && cipher.login !== null;
25979
+ if (cipher.deletedDate !== null) {
24717
25980
  return false;
24718
25981
  }
24719
- if (includeOtherTypes != null && includeOtherTypes.indexOf(cipher.type) > -1) {
25982
+ if (Array.isArray(includeOtherTypes) &&
25983
+ includeOtherTypes.includes(cipher.type) &&
25984
+ !cipherIsLogin) {
24720
25985
  return true;
24721
25986
  }
24722
- if (cipher.type === CipherType.Login && cipher.login !== null) {
25987
+ if (cipherIsLogin) {
24723
25988
  return cipher.login.matchesUri(url, equivalentDomains, defaultMatch);
24724
25989
  }
24725
25990
  return false;
@@ -25388,6 +26653,28 @@ class CipherService {
25388
26653
  cipher.login.uris.push(loginUri);
25389
26654
  }
25390
26655
  }
26656
+ if (model.login.fido2Credentials != null) {
26657
+ cipher.login.fido2Credentials = yield Promise.all(model.login.fido2Credentials.map((viewKey) => cipher_service_awaiter(this, void 0, void 0, function* () {
26658
+ const domainKey = new Fido2Credential();
26659
+ yield this.encryptObjProperty(viewKey, domainKey, {
26660
+ credentialId: null,
26661
+ keyType: null,
26662
+ keyAlgorithm: null,
26663
+ keyCurve: null,
26664
+ keyValue: null,
26665
+ rpId: null,
26666
+ rpName: null,
26667
+ userHandle: null,
26668
+ userName: null,
26669
+ userDisplayName: null,
26670
+ origin: null,
26671
+ }, key);
26672
+ domainKey.counter = yield this.cryptoService.encrypt(String(viewKey.counter), key);
26673
+ domainKey.discoverable = yield this.cryptoService.encrypt(String(viewKey.discoverable), key);
26674
+ domainKey.creationDate = viewKey.creationDate;
26675
+ return domainKey;
26676
+ })));
26677
+ }
25391
26678
  return;
25392
26679
  case CipherType.SecureNote:
25393
26680
  cipher.secureNote = new SecureNote();
@@ -26291,6 +27578,7 @@ class OrganizationData {
26291
27578
  this.familySponsorshipValidUntil = response.familySponsorshipValidUntil;
26292
27579
  this.familySponsorshipToDelete = response.familySponsorshipToDelete;
26293
27580
  this.accessSecretsManager = response.accessSecretsManager;
27581
+ this.limitCollectionCreationDeletion = response.limitCollectionCreationDeletion;
26294
27582
  this.isMember = options.isMember;
26295
27583
  this.isProviderUser = options.isProviderUser;
26296
27584
  }
@@ -26324,6 +27612,7 @@ var sync_service_awaiter = (undefined && undefined.__awaiter) || function (thisA
26324
27612
 
26325
27613
 
26326
27614
 
27615
+
26327
27616
  class SyncService {
26328
27617
  constructor(apiService, settingsService, folderService, cipherService, cryptoService, collectionService, messagingService, policyService, sendService, logService, keyConnectorService, stateService, providerService, folderApiService, organizationService, sendApiService, logoutCallback) {
26329
27618
  this.apiService = apiService;
@@ -26593,10 +27882,7 @@ class SyncService {
26593
27882
  yield this.stateService.setHasPremiumPersonally(response.premiumPersonally);
26594
27883
  yield this.stateService.setHasPremiumFromOrganization(response.premiumFromOrganization);
26595
27884
  yield this.keyConnectorService.setUsesKeyConnector(response.usesKeyConnector);
26596
- // The `forcePasswordReset` flag indicates an admin has reset the user's password and must be updated
26597
- if (response.forcePasswordReset) {
26598
- yield this.stateService.setForcePasswordResetReason(ForceResetPasswordReason.AdminForcePasswordReset);
26599
- }
27885
+ yield this.setForceSetPasswordReasonIfNeeded(response);
26600
27886
  yield this.syncProfileOrganizations(response);
26601
27887
  const providers = {};
26602
27888
  response.providers.forEach((p) => {
@@ -26612,6 +27898,35 @@ class SyncService {
26612
27898
  }
26613
27899
  });
26614
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
+ }
26615
27930
  syncProfileOrganizations(response) {
26616
27931
  return sync_service_awaiter(this, void 0, void 0, function* () {
26617
27932
  const organizations = {};
@@ -26932,6 +28247,122 @@ class IdentityExport {
26932
28247
  }
26933
28248
  }
26934
28249
 
28250
+ ;// CONCATENATED MODULE: ../../libs/common/src/models/export/fido2-credential.export.ts
28251
+
28252
+
28253
+
28254
+ /**
28255
+ * Represents format of Fido2 Credentials in JSON exports.
28256
+ */
28257
+ class Fido2CredentialExport {
28258
+ /**
28259
+ * Generates a template for Fido2CredentialExport
28260
+ * @returns Instance of Fido2CredentialExport with predefined values.
28261
+ */
28262
+ static template() {
28263
+ const req = new Fido2CredentialExport();
28264
+ req.credentialId = "keyId";
28265
+ req.keyType = "keyType";
28266
+ req.keyAlgorithm = "keyAlgorithm";
28267
+ req.keyCurve = "keyCurve";
28268
+ req.keyValue = "keyValue";
28269
+ req.rpId = "rpId";
28270
+ req.userHandle = "userHandle";
28271
+ req.userName = "userName";
28272
+ req.counter = "counter";
28273
+ req.rpName = "rpName";
28274
+ req.userDisplayName = "userDisplayName";
28275
+ req.discoverable = "false";
28276
+ req.creationDate = null;
28277
+ return req;
28278
+ }
28279
+ /**
28280
+ * Converts a Fido2CredentialExport object to its view representation.
28281
+ * @param req - The Fido2CredentialExport object to be converted.
28282
+ * @param view - (Optional) The Fido2CredentialView object to popualte with Fido2CredentialExport data
28283
+ * @returns Fido2CredentialView - The populated view, or a new instance if none was provided.
28284
+ */
28285
+ static toView(req, view = new Fido2CredentialView()) {
28286
+ view.credentialId = req.credentialId;
28287
+ view.keyType = req.keyType;
28288
+ view.keyAlgorithm = req.keyAlgorithm;
28289
+ view.keyCurve = req.keyCurve;
28290
+ view.keyValue = req.keyValue;
28291
+ view.rpId = req.rpId;
28292
+ view.userHandle = req.userHandle;
28293
+ view.userName = req.userName;
28294
+ view.counter = parseInt(req.counter);
28295
+ view.rpName = req.rpName;
28296
+ view.userDisplayName = req.userDisplayName;
28297
+ view.discoverable = req.discoverable === "true";
28298
+ view.creationDate = new Date(req.creationDate);
28299
+ return view;
28300
+ }
28301
+ /**
28302
+ * Converts a Fido2CredentialExport object to its domain representation.
28303
+ * @param req - The Fido2CredentialExport object to be converted.
28304
+ * @param domain - (Optional) The Fido2Credential object to popualte with Fido2CredentialExport data
28305
+ * @returns Fido2Credential - The populated domain, or a new instance if none was provided.
28306
+ */
28307
+ static toDomain(req, domain = new Fido2Credential()) {
28308
+ domain.credentialId = req.credentialId != null ? new EncString(req.credentialId) : null;
28309
+ domain.keyType = req.keyType != null ? new EncString(req.keyType) : null;
28310
+ domain.keyAlgorithm = req.keyAlgorithm != null ? new EncString(req.keyAlgorithm) : null;
28311
+ domain.keyCurve = req.keyCurve != null ? new EncString(req.keyCurve) : null;
28312
+ domain.keyValue = req.keyValue != null ? new EncString(req.keyValue) : null;
28313
+ domain.rpId = req.rpId != null ? new EncString(req.rpId) : null;
28314
+ domain.userHandle = req.userHandle != null ? new EncString(req.userHandle) : null;
28315
+ domain.userName = req.userName != null ? new EncString(req.userName) : null;
28316
+ domain.counter = req.counter != null ? new EncString(req.counter) : null;
28317
+ domain.rpName = req.rpName != null ? new EncString(req.rpName) : null;
28318
+ domain.userDisplayName =
28319
+ req.userDisplayName != null ? new EncString(req.userDisplayName) : null;
28320
+ domain.discoverable = req.discoverable != null ? new EncString(req.discoverable) : null;
28321
+ domain.creationDate = req.creationDate;
28322
+ return domain;
28323
+ }
28324
+ /**
28325
+ * Constructs a new Fid2CredentialExport instance.
28326
+ *
28327
+ * @param o - The credential storing the data being exported. When not provided, an empty export is created instead.
28328
+ */
28329
+ constructor(o) {
28330
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
28331
+ if (o == null) {
28332
+ return;
28333
+ }
28334
+ if (o instanceof Fido2CredentialView) {
28335
+ this.credentialId = o.credentialId;
28336
+ this.keyType = o.keyType;
28337
+ this.keyAlgorithm = o.keyAlgorithm;
28338
+ this.keyCurve = o.keyCurve;
28339
+ this.keyValue = o.keyValue;
28340
+ this.rpId = o.rpId;
28341
+ this.userHandle = o.userHandle;
28342
+ this.userName = o.userName;
28343
+ this.counter = String(o.counter);
28344
+ this.rpName = o.rpName;
28345
+ this.userDisplayName = o.userDisplayName;
28346
+ this.discoverable = String(o.discoverable);
28347
+ }
28348
+ else {
28349
+ this.credentialId = (_a = o.credentialId) === null || _a === void 0 ? void 0 : _a.encryptedString;
28350
+ this.keyType = (_b = o.keyType) === null || _b === void 0 ? void 0 : _b.encryptedString;
28351
+ this.keyAlgorithm = (_c = o.keyAlgorithm) === null || _c === void 0 ? void 0 : _c.encryptedString;
28352
+ this.keyCurve = (_d = o.keyCurve) === null || _d === void 0 ? void 0 : _d.encryptedString;
28353
+ this.keyValue = (_e = o.keyValue) === null || _e === void 0 ? void 0 : _e.encryptedString;
28354
+ this.rpId = (_f = o.rpId) === null || _f === void 0 ? void 0 : _f.encryptedString;
28355
+ this.userHandle = (_g = o.userHandle) === null || _g === void 0 ? void 0 : _g.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;
28361
+ }
28362
+ this.creationDate = o.creationDate;
28363
+ }
28364
+ }
28365
+
26935
28366
  ;// CONCATENATED MODULE: ../../libs/common/src/models/export/login-uri.export.ts
26936
28367
 
26937
28368
 
@@ -26974,6 +28405,7 @@ class LoginUriExport {
26974
28405
 
26975
28406
 
26976
28407
 
28408
+
26977
28409
  class LoginExport {
26978
28410
  static template() {
26979
28411
  const req = new LoginExport();
@@ -26981,6 +28413,7 @@ class LoginExport {
26981
28413
  req.username = "jdoe";
26982
28414
  req.password = "myp@ssword123";
26983
28415
  req.totp = "JBSWY3DPEHPK3PXP";
28416
+ req.fido2Credentials = [Fido2CredentialExport.template()];
26984
28417
  return req;
26985
28418
  }
26986
28419
  static toView(req, view = new LoginView()) {
@@ -26990,6 +28423,9 @@ class LoginExport {
26990
28423
  view.username = req.username;
26991
28424
  view.password = req.password;
26992
28425
  view.totp = req.totp;
28426
+ if (req.fido2Credentials != null) {
28427
+ view.fido2Credentials = req.fido2Credentials.map((key) => Fido2CredentialExport.toView(key));
28428
+ }
26993
28429
  return view;
26994
28430
  }
26995
28431
  static toDomain(req, domain = new Login()) {
@@ -26999,10 +28435,12 @@ class LoginExport {
26999
28435
  domain.username = req.username != null ? new EncString(req.username) : null;
27000
28436
  domain.password = req.password != null ? new EncString(req.password) : null;
27001
28437
  domain.totp = req.totp != null ? new EncString(req.totp) : null;
28438
+ // Fido2credentials are currently not supported for exports.
27002
28439
  return domain;
27003
28440
  }
27004
28441
  constructor(o) {
27005
28442
  var _a, _b, _c;
28443
+ this.fido2Credentials = [];
27006
28444
  if (o == null) {
27007
28445
  return;
27008
28446
  }
@@ -27014,6 +28452,9 @@ class LoginExport {
27014
28452
  this.uris = o.uris.map((u) => new LoginUriExport(u));
27015
28453
  }
27016
28454
  }
28455
+ if (o.fido2Credentials != null) {
28456
+ this.fido2Credentials = o.fido2Credentials.map((key) => new Fido2CredentialExport(key));
28457
+ }
27017
28458
  if (o instanceof LoginView) {
27018
28459
  this.username = o.username;
27019
28460
  this.password = o.password;
@@ -27395,6 +28836,7 @@ class FolderWithIdExport extends FolderExport {
27395
28836
 
27396
28837
 
27397
28838
 
28839
+
27398
28840
 
27399
28841
  ;// CONCATENATED MODULE: ../../libs/exporter/src/export-helper.ts
27400
28842
  class ExportHelper {
@@ -32817,17 +34259,15 @@ class ProtonPassJsonImporter extends base_importer_BaseImporter {
32817
34259
  }
32818
34260
  this.processFolder(result, vault.name);
32819
34261
  const cipher = this.initLoginCipher();
32820
- cipher.name = item.data.metadata.name;
32821
- cipher.notes = item.data.metadata.note;
34262
+ cipher.name = this.getValueOrDefault(item.data.metadata.name, "--");
34263
+ cipher.notes = this.getValueOrDefault(item.data.metadata.note);
32822
34264
  switch (item.data.type) {
32823
34265
  case "login": {
32824
34266
  const loginContent = item.data.content;
32825
34267
  cipher.login.uris = this.makeUriArray(loginContent.urls);
32826
- cipher.login.username = loginContent.username;
32827
- cipher.login.password = loginContent.password;
32828
- if (loginContent.totpUri != "") {
32829
- cipher.login.totp = new URL(loginContent.totpUri).searchParams.get("secret");
32830
- }
34268
+ cipher.login.username = this.getValueOrDefault(loginContent.username);
34269
+ cipher.login.password = this.getValueOrDefault(loginContent.password);
34270
+ cipher.login.totp = this.getValueOrDefault(loginContent.totpUri);
32831
34271
  for (const extraField of item.data.extraFields) {
32832
34272
  this.processKvp(cipher, extraField.fieldName, extraField.type == "totp" ? extraField.data.totpUri : extraField.data.content, extraField.type == "text" ? FieldType.Text : FieldType.Hidden);
32833
34273
  }
@@ -32842,10 +34282,10 @@ class ProtonPassJsonImporter extends base_importer_BaseImporter {
32842
34282
  const creditCardContent = item.data.content;
32843
34283
  cipher.type = CipherType.Card;
32844
34284
  cipher.card = new CardView();
32845
- cipher.card.cardholderName = creditCardContent.cardholderName;
32846
- cipher.card.number = creditCardContent.number;
34285
+ cipher.card.cardholderName = this.getValueOrDefault(creditCardContent.cardholderName);
34286
+ cipher.card.number = this.getValueOrDefault(creditCardContent.number);
32847
34287
  cipher.card.brand = CardView.getCardBrandByPatterns(creditCardContent.number);
32848
- cipher.card.code = creditCardContent.verificationNumber;
34288
+ cipher.card.code = this.getValueOrDefault(creditCardContent.verificationNumber);
32849
34289
  if (!this.isNullOrWhitespace(creditCardContent.expirationDate)) {
32850
34290
  cipher.card.expMonth = creditCardContent.expirationDate.substring(0, 2);
32851
34291
  cipher.card.expMonth = cipher.card.expMonth.replace(/^0+/, "");
@@ -33395,11 +34835,13 @@ class SecureSafeCsvImporter extends base_importer_BaseImporter {
33395
34835
  result.success = false;
33396
34836
  return Promise.resolve(result);
33397
34837
  }
34838
+ // The url field can be in different case formats.
34839
+ const urlField = Object.keys(results[0]).find((k) => /url/i.test(k));
33398
34840
  results.forEach((value) => {
33399
34841
  const cipher = this.initLoginCipher();
33400
34842
  cipher.name = this.getValueOrDefault(value.Title);
33401
34843
  cipher.notes = this.getValueOrDefault(value.Comment);
33402
- cipher.login.uris = this.makeUriArray(value.Url);
34844
+ cipher.login.uris = this.makeUriArray(value[urlField]);
33403
34845
  cipher.login.password = this.getValueOrDefault(value.Password);
33404
34846
  cipher.login.username = this.getValueOrDefault(value.Username);
33405
34847
  this.cleanupCipher(cipher);
@@ -33792,9 +35234,9 @@ const featuredImportOptions = [
33792
35234
  { id: "dashlanecsv", name: "Dashlane (csv)" },
33793
35235
  { id: "firefoxcsv", name: "Firefox (csv)" },
33794
35236
  { id: "keepass2xml", name: "KeePass 2 (xml)" },
33795
- { id: "lastpasscsv", name: "LastPass (csv)" },
35237
+ { id: "lastpasscsv", name: "LastPass" },
33796
35238
  { id: "safaricsv", name: "Safari and macOS (csv)" },
33797
- { id: "1password1pux", name: "1Password (1pux)" },
35239
+ { id: "1password1pux", name: "1Password (1pux/json)" },
33798
35240
  ];
33799
35241
  const regularImportOptions = [
33800
35242
  { id: "keepassxcsv", name: "KeePassX (csv)" },
@@ -33890,7 +35332,7 @@ class ImportService {
33890
35332
  getImportOptions() {
33891
35333
  return this.featuredImportOptions.concat(this.regularImportOptions);
33892
35334
  }
33893
- import(importer, fileContents, organizationId = null, selectedImportTarget = null, isUserAdmin) {
35335
+ import(importer, fileContents, organizationId = null, selectedImportTarget = null, canAccessImportExport) {
33894
35336
  return import_service_awaiter(this, void 0, void 0, function* () {
33895
35337
  let importResult;
33896
35338
  try {
@@ -33920,7 +35362,9 @@ class ImportService {
33920
35362
  throw new Error(this.i18nService.t("importFormatError"));
33921
35363
  }
33922
35364
  }
33923
- if (organizationId && utils_Utils.isNullOrWhitespace(selectedImportTarget) && !isUserAdmin) {
35365
+ if (organizationId &&
35366
+ utils_Utils.isNullOrWhitespace(selectedImportTarget) &&
35367
+ !canAccessImportExport) {
33924
35368
  const hasUnassignedCollections = importResult.ciphers.some((c) => !Array.isArray(c.collectionIds) || c.collectionIds.length == 0);
33925
35369
  if (hasUnassignedCollections) {
33926
35370
  throw new Error(this.i18nService.t("importUnassignedItemsError"));
@@ -34220,10 +35664,13 @@ class ImportService {
34220
35664
  }
34221
35665
  }
34222
35666
 
34223
- ;// CONCATENATED MODULE: ../../libs/importer/src/index.ts
35667
+ ;// CONCATENATED MODULE: ../../libs/importer/src/services/index.ts
35668
+
34224
35669
 
34225
35670
 
34226
35671
 
35672
+
35673
+ ;// CONCATENATED MODULE: ../../libs/importer/src/index.ts
34227
35674
 
34228
35675
 
34229
35676
 
@@ -34386,17 +35833,17 @@ class NodeCryptoFunctionService {
34386
35833
  }
34387
35834
  return p;
34388
35835
  }
34389
- aesDecryptFast(parameters) {
35836
+ aesDecryptFast(parameters, mode) {
34390
35837
  return node_crypto_function_service_awaiter(this, void 0, void 0, function* () {
34391
- const decBuf = yield this.aesDecrypt(parameters.data, parameters.iv, parameters.encKey);
35838
+ const decBuf = yield this.aesDecrypt(parameters.data, parameters.iv, parameters.encKey, mode);
34392
35839
  return utils_Utils.fromBufferToUtf8(decBuf);
34393
35840
  });
34394
35841
  }
34395
- aesDecrypt(data, iv, key) {
35842
+ aesDecrypt(data, iv, key, mode) {
34396
35843
  const nodeData = this.toNodeBuffer(data);
34397
- const nodeIv = this.toNodeBuffer(iv);
35844
+ const nodeIv = mode === "ecb" ? null : this.toNodeBuffer(iv);
34398
35845
  const nodeKey = this.toNodeBuffer(key);
34399
- const decipher = external_crypto_namespaceObject.createDecipheriv("aes-256-cbc", nodeKey, nodeIv);
35846
+ const decipher = external_crypto_namespaceObject.createDecipheriv(this.toNodeCryptoAesMode(mode), nodeKey, nodeIv);
34400
35847
  const decBuf = Buffer.concat([decipher.update(nodeData), decipher.final()]);
34401
35848
  return Promise.resolve(this.toUint8Buffer(decBuf));
34402
35849
  }
@@ -34502,6 +35949,9 @@ class NodeCryptoFunctionService {
34502
35949
  const publicKey = external_node_forge_namespaceObject.pki.publicKeyFromAsn1(asn1);
34503
35950
  return external_node_forge_namespaceObject.pki.publicKeyToPem(publicKey);
34504
35951
  }
35952
+ toNodeCryptoAesMode(mode) {
35953
+ return mode === "cbc" ? "aes-256-cbc" : "aes-256-ecb";
35954
+ }
34505
35955
  }
34506
35956
 
34507
35957
  ;// CONCATENATED MODULE: ../../libs/common/src/platform/abstractions/config/server-config.ts
@@ -34671,14 +36121,14 @@ class CliPlatformUtilsService {
34671
36121
  if (!this.deviceCache) {
34672
36122
  switch (process.platform) {
34673
36123
  case "win32":
34674
- this.deviceCache = DeviceType.WindowsDesktop;
36124
+ this.deviceCache = DeviceType.WindowsCLI;
34675
36125
  break;
34676
36126
  case "darwin":
34677
- this.deviceCache = DeviceType.MacOsDesktop;
36127
+ this.deviceCache = DeviceType.MacOsCLI;
34678
36128
  break;
34679
36129
  case "linux":
34680
36130
  default:
34681
- this.deviceCache = DeviceType.LinuxDesktop;
36131
+ this.deviceCache = DeviceType.LinuxCLI;
34682
36132
  break;
34683
36133
  }
34684
36134
  }
@@ -34686,7 +36136,7 @@ class CliPlatformUtilsService {
34686
36136
  }
34687
36137
  getDeviceString() {
34688
36138
  const device = DeviceType[this.getDevice()].toLowerCase();
34689
- return device.replace("desktop", "");
36139
+ return device.replace("cli", "");
34690
36140
  }
34691
36141
  getClientType() {
34692
36142
  return this.clientType;
@@ -35066,6 +36516,7 @@ var lowdb_storage_service_awaiter = (undefined && undefined.__awaiter) || functi
35066
36516
 
35067
36517
 
35068
36518
 
36519
+
35069
36520
  const retries = {
35070
36521
  retries: 50,
35071
36522
  minTimeout: 100,
@@ -35079,7 +36530,9 @@ class LowdbStorageService {
35079
36530
  this.allowCache = allowCache;
35080
36531
  this.requireLock = requireLock;
35081
36532
  this.ready = false;
36533
+ this.updatesSubject = new external_rxjs_namespaceObject.Subject();
35082
36534
  this.defaults = defaults;
36535
+ this.updates$ = this.updatesSubject.asObservable();
35083
36536
  }
35084
36537
  init() {
35085
36538
  return lowdb_storage_service_awaiter(this, void 0, void 0, function* () {
@@ -35142,6 +36595,9 @@ class LowdbStorageService {
35142
36595
  this.ready = true;
35143
36596
  });
35144
36597
  }
36598
+ get valuesRequireDeserialization() {
36599
+ return true;
36600
+ }
35145
36601
  get(key) {
35146
36602
  return lowdb_storage_service_awaiter(this, void 0, void 0, function* () {
35147
36603
  yield this.waitForReady();
@@ -35165,6 +36621,7 @@ class LowdbStorageService {
35165
36621
  return this.lockDbFile(() => {
35166
36622
  this.readForNoCache();
35167
36623
  this.db.set(key, obj).write();
36624
+ this.updatesSubject.next({ key, updateType: "save" });
35168
36625
  this.logService.debug(`Successfully wrote ${key} to db`);
35169
36626
  return;
35170
36627
  });
@@ -35176,6 +36633,7 @@ class LowdbStorageService {
35176
36633
  return this.lockDbFile(() => {
35177
36634
  this.readForNoCache();
35178
36635
  this.db.unset(key).write();
36636
+ this.updatesSubject.next({ key, updateType: "remove" });
35179
36637
  this.logService.debug(`Successfully removed ${key} from db`);
35180
36638
  return;
35181
36639
  });
@@ -35345,6 +36803,8 @@ class CollectionDetailsResponse extends CollectionResponse {
35345
36803
  constructor(response) {
35346
36804
  super(response);
35347
36805
  this.readOnly = this.getResponseProperty("ReadOnly") || false;
36806
+ this.manage = this.getResponseProperty("Manage") || false;
36807
+ this.hidePasswords = this.getResponseProperty("HidePasswords") || false;
35348
36808
  }
35349
36809
  }
35350
36810
  class CollectionAccessDetailsResponse extends CollectionResponse {
@@ -35500,59 +36960,6 @@ class DeviceVerificationResponse extends BaseResponse {
35500
36960
  }
35501
36961
  }
35502
36962
 
35503
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/emergency-access.response.ts
35504
-
35505
-
35506
- class EmergencyAccessGranteeDetailsResponse extends BaseResponse {
35507
- constructor(response) {
35508
- super(response);
35509
- this.id = this.getResponseProperty("Id");
35510
- this.granteeId = this.getResponseProperty("GranteeId");
35511
- this.name = this.getResponseProperty("Name");
35512
- this.email = this.getResponseProperty("Email");
35513
- this.type = this.getResponseProperty("Type");
35514
- this.status = this.getResponseProperty("Status");
35515
- this.waitTimeDays = this.getResponseProperty("WaitTimeDays");
35516
- this.creationDate = this.getResponseProperty("CreationDate");
35517
- this.avatarColor = this.getResponseProperty("AvatarColor");
35518
- }
35519
- }
35520
- class EmergencyAccessGrantorDetailsResponse extends BaseResponse {
35521
- constructor(response) {
35522
- super(response);
35523
- this.id = this.getResponseProperty("Id");
35524
- this.grantorId = this.getResponseProperty("GrantorId");
35525
- this.name = this.getResponseProperty("Name");
35526
- this.email = this.getResponseProperty("Email");
35527
- this.type = this.getResponseProperty("Type");
35528
- this.status = this.getResponseProperty("Status");
35529
- this.waitTimeDays = this.getResponseProperty("WaitTimeDays");
35530
- this.creationDate = this.getResponseProperty("CreationDate");
35531
- this.avatarColor = this.getResponseProperty("AvatarColor");
35532
- }
35533
- }
35534
- class EmergencyAccessTakeoverResponse extends BaseResponse {
35535
- constructor(response) {
35536
- super(response);
35537
- this.keyEncrypted = this.getResponseProperty("KeyEncrypted");
35538
- this.kdf = this.getResponseProperty("Kdf");
35539
- this.kdfIterations = this.getResponseProperty("KdfIterations");
35540
- this.kdfMemory = this.getResponseProperty("KdfMemory");
35541
- this.kdfParallelism = this.getResponseProperty("KdfParallelism");
35542
- }
35543
- }
35544
- class EmergencyAccessViewResponse extends BaseResponse {
35545
- constructor(response) {
35546
- super(response);
35547
- this.ciphers = [];
35548
- this.keyEncrypted = this.getResponseProperty("KeyEncrypted");
35549
- const ciphers = this.getResponseProperty("Ciphers");
35550
- if (ciphers != null) {
35551
- this.ciphers = ciphers.map((c) => new CipherResponse(c));
35552
- }
35553
- }
35554
- }
35555
-
35556
36963
  ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/response/key-connector-user-key.response.ts
35557
36964
 
35558
36965
  class KeyConnectorUserKeyResponse extends BaseResponse {
@@ -35744,6 +37151,13 @@ class TaxRateResponse extends BaseResponse {
35744
37151
  }
35745
37152
  }
35746
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
+
35747
37161
  ;// CONCATENATED MODULE: ../../libs/common/src/models/response/breach-account.response.ts
35748
37162
 
35749
37163
  class BreachAccountResponse extends BaseResponse {
@@ -35956,7 +37370,6 @@ var api_service_awaiter = (undefined && undefined.__awaiter) || function (thisAr
35956
37370
 
35957
37371
 
35958
37372
 
35959
-
35960
37373
 
35961
37374
 
35962
37375
  /**
@@ -35988,7 +37401,10 @@ class ApiService {
35988
37401
  this.isDesktopClient =
35989
37402
  this.device === DeviceType.WindowsDesktop ||
35990
37403
  this.device === DeviceType.MacOsDesktop ||
35991
- this.device === DeviceType.LinuxDesktop;
37404
+ this.device === DeviceType.LinuxDesktop ||
37405
+ this.device === DeviceType.WindowsCLI ||
37406
+ this.device === DeviceType.MacOsCLI ||
37407
+ this.device === DeviceType.LinuxCLI;
35992
37408
  }
35993
37409
  // Auth APIs
35994
37410
  postIdentityToken(request) {
@@ -36501,8 +37917,8 @@ class ApiService {
36501
37917
  deleteCollection(organizationId, id) {
36502
37918
  return this.send("DELETE", "/organizations/" + organizationId + "/collections/" + id, null, true, false);
36503
37919
  }
36504
- deleteManyCollections(request) {
36505
- 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);
36506
37922
  }
36507
37923
  deleteCollectionUser(organizationId, id, organizationUserId) {
36508
37924
  return this.send("DELETE", "/organizations/" + organizationId + "/collections/" + id + "/user/" + organizationUserId, null, true, false);
@@ -36525,7 +37941,7 @@ class ApiService {
36525
37941
  // Plan APIs
36526
37942
  getPlans() {
36527
37943
  return api_service_awaiter(this, void 0, void 0, function* () {
36528
- const r = yield this.send("GET", "/plans/all", null, false, true);
37944
+ const r = yield this.send("GET", "/plans", null, false, true);
36529
37945
  return new ListResponse(r, PlanResponse);
36530
37946
  });
36531
37947
  }
@@ -36709,75 +38125,6 @@ class ApiService {
36709
38125
  return new DeviceVerificationResponse(r);
36710
38126
  });
36711
38127
  }
36712
- // Emergency Access APIs
36713
- getEmergencyAccessTrusted() {
36714
- return api_service_awaiter(this, void 0, void 0, function* () {
36715
- const r = yield this.send("GET", "/emergency-access/trusted", null, true, true);
36716
- return new ListResponse(r, EmergencyAccessGranteeDetailsResponse);
36717
- });
36718
- }
36719
- getEmergencyAccessGranted() {
36720
- return api_service_awaiter(this, void 0, void 0, function* () {
36721
- const r = yield this.send("GET", "/emergency-access/granted", null, true, true);
36722
- return new ListResponse(r, EmergencyAccessGrantorDetailsResponse);
36723
- });
36724
- }
36725
- getEmergencyAccess(id) {
36726
- return api_service_awaiter(this, void 0, void 0, function* () {
36727
- const r = yield this.send("GET", "/emergency-access/" + id, null, true, true);
36728
- return new EmergencyAccessGranteeDetailsResponse(r);
36729
- });
36730
- }
36731
- getEmergencyGrantorPolicies(id) {
36732
- return api_service_awaiter(this, void 0, void 0, function* () {
36733
- const r = yield this.send("GET", "/emergency-access/" + id + "/policies", null, true, true);
36734
- return new ListResponse(r, PolicyResponse);
36735
- });
36736
- }
36737
- putEmergencyAccess(id, request) {
36738
- return this.send("PUT", "/emergency-access/" + id, request, true, false);
36739
- }
36740
- deleteEmergencyAccess(id) {
36741
- return this.send("DELETE", "/emergency-access/" + id, null, true, false);
36742
- }
36743
- postEmergencyAccessInvite(request) {
36744
- return this.send("POST", "/emergency-access/invite", request, true, false);
36745
- }
36746
- postEmergencyAccessReinvite(id) {
36747
- return this.send("POST", "/emergency-access/" + id + "/reinvite", null, true, false);
36748
- }
36749
- postEmergencyAccessAccept(id, request) {
36750
- return this.send("POST", "/emergency-access/" + id + "/accept", request, true, false);
36751
- }
36752
- postEmergencyAccessConfirm(id, request) {
36753
- return this.send("POST", "/emergency-access/" + id + "/confirm", request, true, false);
36754
- }
36755
- postEmergencyAccessInitiate(id) {
36756
- return this.send("POST", "/emergency-access/" + id + "/initiate", null, true, false);
36757
- }
36758
- postEmergencyAccessApprove(id) {
36759
- return this.send("POST", "/emergency-access/" + id + "/approve", null, true, false);
36760
- }
36761
- postEmergencyAccessReject(id) {
36762
- return this.send("POST", "/emergency-access/" + id + "/reject", null, true, false);
36763
- }
36764
- postEmergencyAccessTakeover(id) {
36765
- return api_service_awaiter(this, void 0, void 0, function* () {
36766
- const r = yield this.send("POST", "/emergency-access/" + id + "/takeover", null, true, true);
36767
- return new EmergencyAccessTakeoverResponse(r);
36768
- });
36769
- }
36770
- postEmergencyAccessPassword(id, request) {
36771
- return api_service_awaiter(this, void 0, void 0, function* () {
36772
- yield this.send("POST", "/emergency-access/" + id + "/password", request, true, true);
36773
- });
36774
- }
36775
- postEmergencyAccessView(id) {
36776
- return api_service_awaiter(this, void 0, void 0, function* () {
36777
- const r = yield this.send("POST", "/emergency-access/" + id + "/view", null, true, true);
36778
- return new EmergencyAccessViewResponse(r);
36779
- });
36780
- }
36781
38128
  // Organization APIs
36782
38129
  getCloudCommunicationsEnabled() {
36783
38130
  return api_service_awaiter(this, void 0, void 0, function* () {
@@ -37362,12 +38709,19 @@ var node_env_secure_storage_service_awaiter = (undefined && undefined.__awaiter)
37362
38709
 
37363
38710
 
37364
38711
 
38712
+
37365
38713
  class NodeEnvSecureStorageService {
37366
38714
  constructor(storageService, logService, cryptoService) {
37367
38715
  this.storageService = storageService;
37368
38716
  this.logService = logService;
37369
38717
  this.cryptoService = cryptoService;
37370
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
+ }
37371
38725
  get(key) {
37372
38726
  return node_env_secure_storage_service_awaiter(this, void 0, void 0, function* () {
37373
38727
  const value = yield this.storageService.get(this.makeProtectedStorageKey(key));
@@ -37396,7 +38750,10 @@ class NodeEnvSecureStorageService {
37396
38750
  });
37397
38751
  }
37398
38752
  remove(key) {
37399
- 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
+ });
37400
38757
  }
37401
38758
  encrypt(plainValue) {
37402
38759
  return node_env_secure_storage_service_awaiter(this, void 0, void 0, function* () {
@@ -37537,9 +38894,9 @@ class LockCommand {
37537
38894
  const external_http_namespaceObject = require("http");
37538
38895
  ;// CONCATENATED MODULE: external "inquirer"
37539
38896
  const external_inquirer_namespaceObject = require("inquirer");
37540
- ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/log-in-credentials.ts
38897
+ ;// CONCATENATED MODULE: ../../libs/common/src/auth/models/domain/login-credentials.ts
37541
38898
 
37542
- class PasswordLogInCredentials {
38899
+ class PasswordLoginCredentials {
37543
38900
  constructor(email, masterPassword, captchaToken, twoFactor) {
37544
38901
  this.email = email;
37545
38902
  this.masterPassword = masterPassword;
@@ -37548,7 +38905,7 @@ class PasswordLogInCredentials {
37548
38905
  this.type = authentication_type_AuthenticationType.Password;
37549
38906
  }
37550
38907
  }
37551
- class SsoLogInCredentials {
38908
+ class SsoLoginCredentials {
37552
38909
  constructor(code, codeVerifier, redirectUrl, orgId, twoFactor) {
37553
38910
  this.code = code;
37554
38911
  this.codeVerifier = codeVerifier;
@@ -37558,14 +38915,14 @@ class SsoLogInCredentials {
37558
38915
  this.type = authentication_type_AuthenticationType.Sso;
37559
38916
  }
37560
38917
  }
37561
- class UserApiLogInCredentials {
38918
+ class UserApiLoginCredentials {
37562
38919
  constructor(clientId, clientSecret) {
37563
38920
  this.clientId = clientId;
37564
38921
  this.clientSecret = clientSecret;
37565
38922
  this.type = authentication_type_AuthenticationType.UserApi;
37566
38923
  }
37567
38924
  }
37568
- class PasswordlessLogInCredentials {
38925
+ class AuthRequestLoginCredentials {
37569
38926
  constructor(email, accessCode, authRequestId, decryptedUserKey, decryptedMasterKey, decryptedMasterKeyHash, twoFactor) {
37570
38927
  this.email = email;
37571
38928
  this.accessCode = accessCode;
@@ -37574,7 +38931,15 @@ class PasswordlessLogInCredentials {
37574
38931
  this.decryptedMasterKey = decryptedMasterKey;
37575
38932
  this.decryptedMasterKeyHash = decryptedMasterKeyHash;
37576
38933
  this.twoFactor = twoFactor;
37577
- 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;
37578
38943
  }
37579
38944
  }
37580
38945
 
@@ -37588,7 +38953,7 @@ class PasswordRequest extends SecretVerificationRequest {
37588
38953
  class TwoFactorEmailRequest extends SecretVerificationRequest {
37589
38954
  }
37590
38955
 
37591
- ;// 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
37592
38957
  class OrganizationUserResetPasswordRequest {
37593
38958
  }
37594
38959
 
@@ -37748,7 +39113,7 @@ class LoginCommand {
37748
39113
  return Response.error("Invalid API Key; Organization API Key currently not supported");
37749
39114
  }
37750
39115
  try {
37751
- response = yield this.authService.logIn(new UserApiLogInCredentials(clientId, clientSecret));
39116
+ response = yield this.authService.logIn(new UserApiLoginCredentials(clientId, clientSecret));
37752
39117
  }
37753
39118
  catch (e) {
37754
39119
  // handle API key login failures
@@ -37763,13 +39128,16 @@ class LoginCommand {
37763
39128
  }
37764
39129
  }
37765
39130
  else if (ssoCode != null && ssoCodeVerifier != null) {
37766
- 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));
37767
39132
  }
37768
39133
  else {
37769
- response = yield this.authService.logIn(new PasswordLogInCredentials(email, password, null, twoFactor));
39134
+ response = yield this.authService.logIn(new PasswordLoginCredentials(email, password, null, twoFactor));
39135
+ }
39136
+ if (response.requiresEncryptionKeyMigration) {
39137
+ return Response.error("Encryption key migration required. Please login through the web vault to update your encryption key.");
37770
39138
  }
37771
39139
  if (response.captchaSiteKey) {
37772
- const credentials = new PasswordLogInCredentials(email, password);
39140
+ const credentials = new PasswordLoginCredentials(email, password);
37773
39141
  const handledResponse = yield this.handleCaptchaRequired(twoFactor, credentials);
37774
39142
  // Error Response
37775
39143
  if (handledResponse instanceof Response) {
@@ -37864,13 +39232,13 @@ class LoginCommand {
37864
39232
  // Run full sync before handling success response or password reset flows (to get Master Password Policies)
37865
39233
  yield this.syncService.fullSync(true);
37866
39234
  // Handle updating passwords if NOT using an API Key for authentication
37867
- if (response.forcePasswordReset != ForceResetPasswordReason.None &&
39235
+ if (response.forcePasswordReset != ForceSetPasswordReason.None &&
37868
39236
  clientId == null &&
37869
39237
  clientSecret == null) {
37870
- if (response.forcePasswordReset === ForceResetPasswordReason.AdminForcePasswordReset) {
39238
+ if (response.forcePasswordReset === ForceSetPasswordReason.AdminForcePasswordReset) {
37871
39239
  return yield this.updateTempPassword();
37872
39240
  }
37873
- else if (response.forcePasswordReset === ForceResetPasswordReason.WeakMasterPassword) {
39241
+ else if (response.forcePasswordReset === ForceSetPasswordReason.WeakMasterPassword) {
37874
39242
  return yield this.updateWeakPassword(password);
37875
39243
  }
37876
39244
  }
@@ -38905,7 +40273,7 @@ const external_koa_namespaceObject = require("koa");
38905
40273
  const external_koa_bodyparser_namespaceObject = require("koa-bodyparser");
38906
40274
  ;// CONCATENATED MODULE: external "koa-json"
38907
40275
  const external_koa_json_namespaceObject = require("koa-json");
38908
- ;// 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
38909
40277
  class OrganizationUserConfirmRequest {
38910
40278
  }
38911
40279
 
@@ -40079,10 +41447,11 @@ class SendRemovePasswordCommand {
40079
41447
 
40080
41448
  ;// CONCATENATED MODULE: ../../libs/common/src/admin-console/models/request/selection-read-only.request.ts
40081
41449
  class SelectionReadOnlyRequest {
40082
- constructor(id, readOnly, hidePasswords) {
41450
+ constructor(id, readOnly, hidePasswords, manage) {
40083
41451
  this.id = id;
40084
41452
  this.readOnly = readOnly;
40085
41453
  this.hidePasswords = hidePasswords;
41454
+ this.manage = manage;
40086
41455
  }
40087
41456
  }
40088
41457
 
@@ -40286,7 +41655,7 @@ class CreateCommand {
40286
41655
  }
40287
41656
  const groups = req.groups == null
40288
41657
  ? null
40289
- : 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));
40290
41659
  const request = new CollectionRequest();
40291
41660
  request.name = (yield this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
40292
41661
  request.externalId = req.externalId;
@@ -40650,7 +42019,7 @@ class EditCommand {
40650
42019
  }
40651
42020
  const groups = req.groups == null
40652
42021
  ? null
40653
- : 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));
40654
42023
  const request = new CollectionRequest();
40655
42024
  request.name = (yield this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
40656
42025
  request.externalId = req.externalId;
@@ -40676,12 +42045,13 @@ class commands_edit_command_Options {
40676
42045
  ;// CONCATENATED MODULE: ./src/admin-console/models/selection-read-only.ts
40677
42046
  class SelectionReadOnly {
40678
42047
  static template() {
40679
- return new SelectionReadOnly("00000000-0000-0000-0000-000000000000", false, false);
42048
+ return new SelectionReadOnly("00000000-0000-0000-0000-000000000000", false, false, false);
40680
42049
  }
40681
- constructor(id, readOnly, hidePasswords) {
42050
+ constructor(id, readOnly, hidePasswords, manage) {
40682
42051
  this.id = id;
40683
42052
  this.readOnly = readOnly;
40684
42053
  this.hidePasswords = hidePasswords || false;
42054
+ this.manage = manage;
40685
42055
  }
40686
42056
  }
40687
42057
 
@@ -40755,10 +42125,11 @@ var commands_get_command_awaiter = (undefined && undefined.__awaiter) || functio
40755
42125
 
40756
42126
 
40757
42127
 
42128
+
40758
42129
 
40759
42130
 
40760
42131
  class GetCommand extends DownloadCommand {
40761
- constructor(cipherService, folderService, collectionService, totpService, auditService, cryptoService, stateService, searchService, apiService, organizationService) {
42132
+ constructor(cipherService, folderService, collectionService, totpService, auditService, cryptoService, stateService, searchService, apiService, organizationService, eventCollectionService) {
40762
42133
  super(cryptoService);
40763
42134
  this.cipherService = cipherService;
40764
42135
  this.folderService = folderService;
@@ -40769,6 +42140,7 @@ class GetCommand extends DownloadCommand {
40769
42140
  this.searchService = searchService;
40770
42141
  this.apiService = apiService;
40771
42142
  this.organizationService = organizationService;
42143
+ this.eventCollectionService = eventCollectionService;
40772
42144
  }
40773
42145
  run(object, id, cmdOptions) {
40774
42146
  return commands_get_command_awaiter(this, void 0, void 0, function* () {
@@ -40849,6 +42221,7 @@ class GetCommand extends DownloadCommand {
40849
42221
  return Response.multipleResults(decCipher.map((c) => c.id));
40850
42222
  }
40851
42223
  }
42224
+ this.eventCollectionService.collect(EventType.Cipher_ClientViewed, id, true, decCipher.organizationId);
40852
42225
  const res = new cipher_response_CipherResponse(decCipher);
40853
42226
  return Response.success(res);
40854
42227
  });
@@ -41094,7 +42467,7 @@ class GetCommand extends DownloadCommand {
41094
42467
  decCollection.name = yield this.cryptoService.decryptToUtf8(new EncString(response.name), orgKey);
41095
42468
  const groups = response.groups == null
41096
42469
  ? null
41097
- : 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));
41098
42471
  const res = new OrganizationCollectionResponse(decCollection, groups);
41099
42472
  return Response.success(res);
41100
42473
  }
@@ -41236,8 +42609,9 @@ var commands_list_command_awaiter = (undefined && undefined.__awaiter) || functi
41236
42609
 
41237
42610
 
41238
42611
 
42612
+
41239
42613
  class ListCommand {
41240
- constructor(cipherService, folderService, collectionService, organizationService, searchService, organizationUserService, apiService) {
42614
+ constructor(cipherService, folderService, collectionService, organizationService, searchService, organizationUserService, apiService, eventCollectionService) {
41241
42615
  this.cipherService = cipherService;
41242
42616
  this.folderService = folderService;
41243
42617
  this.collectionService = collectionService;
@@ -41245,6 +42619,7 @@ class ListCommand {
41245
42619
  this.searchService = searchService;
41246
42620
  this.organizationUserService = organizationUserService;
41247
42621
  this.apiService = apiService;
42622
+ this.eventCollectionService = eventCollectionService;
41248
42623
  }
41249
42624
  run(object, cmdOptions) {
41250
42625
  return commands_list_command_awaiter(this, void 0, void 0, function* () {
@@ -41327,6 +42702,11 @@ class ListCommand {
41327
42702
  if (options.search != null && options.search.trim() !== "") {
41328
42703
  ciphers = this.searchService.searchCiphersBasic(ciphers, options.search, options.trash);
41329
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
+ });
41330
42710
  const res = new list_response_ListResponse(ciphers.map((o) => new cipher_response_CipherResponse(o)));
41331
42711
  return Response.success(res);
41332
42712
  });
@@ -41590,8 +42970,8 @@ var serve_command_awaiter = (undefined && undefined.__awaiter) || function (this
41590
42970
  class ServeCommand {
41591
42971
  constructor(main) {
41592
42972
  this.main = main;
41593
- 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);
41594
- 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);
41595
42975
  this.createCommand = new CreateCommand(this.main.cipherService, this.main.folderService, this.main.stateService, this.main.cryptoService, this.main.apiService, this.main.folderApiService);
41596
42976
  this.editCommand = new EditCommand(this.main.cipherService, this.main.folderService, this.main.cryptoService, this.main.apiService, this.main.folderApiService);
41597
42977
  this.generateCommand = new GenerateCommand(this.main.passwordGenerationService, this.main.stateService);
@@ -42569,7 +43949,7 @@ class SendProgram extends Program {
42569
43949
  object: "Valid objects are: send.text, send.file",
42570
43950
  })
42571
43951
  .action((object) => send_program_awaiter(this, void 0, void 0, function* () {
42572
- 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);
42573
43953
  const response = yield cmd.run("template", object, null);
42574
43954
  this.processResponse(response);
42575
43955
  }));
@@ -42731,10 +44111,12 @@ var export_command_awaiter = (undefined && undefined.__awaiter) || function (thi
42731
44111
 
42732
44112
 
42733
44113
 
44114
+
42734
44115
  class ExportCommand {
42735
- constructor(exportService, policyService) {
44116
+ constructor(exportService, policyService, eventCollectionService) {
42736
44117
  this.exportService = exportService;
42737
44118
  this.policyService = policyService;
44119
+ this.eventCollectionService = eventCollectionService;
42738
44120
  }
42739
44121
  run(options) {
42740
44122
  var _a;
@@ -42756,6 +44138,10 @@ class ExportCommand {
42756
44138
  format === "encrypted_json"
42757
44139
  ? yield this.getProtectedExport(options.password, options.organizationid)
42758
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);
42759
44145
  }
42760
44146
  catch (e) {
42761
44147
  return Response.error(e);
@@ -42882,7 +44268,7 @@ class ImportCommand {
42882
44268
  }
42883
44269
  try {
42884
44270
  let contents;
42885
- if (format === "1password1pux") {
44271
+ if (format === "1password1pux" && filepath.endsWith(".1pux")) {
42886
44272
  contents = yield CliUtils.extractZipContent(filepath, "export.data");
42887
44273
  }
42888
44274
  else if (format === "protonpass" && filepath.endsWith(".zip")) {
@@ -43039,7 +44425,7 @@ class VaultProgram extends Program {
43039
44425
  return;
43040
44426
  }
43041
44427
  yield this.exitIfLocked();
43042
- 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);
43043
44429
  const response = yield command.run(object, cmd);
43044
44430
  this.processResponse(response);
43045
44431
  }));
@@ -43094,7 +44480,7 @@ class VaultProgram extends Program {
43094
44480
  return;
43095
44481
  }
43096
44482
  yield this.exitIfLocked();
43097
- 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);
43098
44484
  const response = yield command.run(object, id, cmd);
43099
44485
  this.processResponse(response);
43100
44486
  }));
@@ -43323,7 +44709,7 @@ class VaultProgram extends Program {
43323
44709
  })
43324
44710
  .action((options) => vault_program_awaiter(this, void 0, void 0, function* () {
43325
44711
  yield this.exitIfLocked();
43326
- const command = new ExportCommand(this.main.exportService, this.main.policyService);
44712
+ const command = new ExportCommand(this.main.exportService, this.main.policyService, this.main.eventCollectionService);
43327
44713
  const response = yield command.run(options);
43328
44714
  this.processResponse(response);
43329
44715
  }));
@@ -43375,6 +44761,11 @@ var bw_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argum
43375
44761
 
43376
44762
 
43377
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
+
44768
+
43378
44769
 
43379
44770
 
43380
44771
 
@@ -43438,11 +44829,13 @@ class Main {
43438
44829
  this.storageService = new LowdbStorageService(this.logService, null, p, false, true);
43439
44830
  this.secureStorageService = new NodeEnvSecureStorageService(this.storageService, this.logService, () => this.cryptoService);
43440
44831
  this.memoryStorageService = new MemoryStorageService();
43441
- this.stateService = new StateService(this.storageService, this.secureStorageService, this.memoryStorageService, this.logService, new StateFactory(GlobalState, Account));
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);
44835
+ this.stateService = new StateService(this.storageService, this.secureStorageService, this.memoryStorageService, this.logService, new StateFactory(GlobalState, Account), this.accountService);
43442
44836
  this.cryptoService = new CryptoService(this.cryptoFunctionService, this.encryptService, this.platformUtilsService, this.logService, this.stateService);
43443
44837
  this.appIdService = new AppIdService(this.storageService);
43444
44838
  this.tokenService = new TokenService(this.stateService);
43445
- this.messagingService = new NoopMessagingService();
43446
44839
  this.environmentService = new environment_service_EnvironmentService(this.stateService);
43447
44840
  const customUserAgent = "Bitwarden_CLI/" +
43448
44841
  this.platformUtilsService.getApplicationVersionSync() +
@@ -43493,6 +44886,8 @@ class Main {
43493
44886
  this.vaultProgram = new VaultProgram(this);
43494
44887
  this.sendProgram = new SendProgram(this);
43495
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);
43496
44891
  }
43497
44892
  run() {
43498
44893
  return bw_awaiter(this, void 0, void 0, function* () {