From 8ccece38e333791125389fc7c23fafe13d97c685 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:48:47 -0500 Subject: [PATCH 01/20] [deps] Platform: Update Rust crate thiserror to v1.0.68 (#10562) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- apps/desktop/desktop_native/Cargo.lock | 8 ++++---- apps/desktop/desktop_native/core/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/desktop/desktop_native/Cargo.lock b/apps/desktop/desktop_native/Cargo.lock index afe83b3f590..720f15b5c62 100644 --- a/apps/desktop/desktop_native/Cargo.lock +++ b/apps/desktop/desktop_native/Cargo.lock @@ -1867,18 +1867,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", diff --git a/apps/desktop/desktop_native/core/Cargo.toml b/apps/desktop/desktop_native/core/Cargo.toml index 7c9c5de1554..151c2cc8bb0 100644 --- a/apps/desktop/desktop_native/core/Cargo.toml +++ b/apps/desktop/desktop_native/core/Cargo.toml @@ -38,7 +38,7 @@ rand = "=0.8.5" retry = "=2.0.0" scopeguard = "=1.2.0" sha2 = "=0.10.8" -thiserror = "=1.0.61" +thiserror = "=1.0.68" tokio = { version = "=1.41.0", features = ["io-util", "sync", "macros"] } tokio-util = "=0.7.12" typenum = "=1.17.0" From 12cf870e34c767231e3569cde32f93f25cfbf382 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:13:52 -0500 Subject: [PATCH 02/20] [deps] Platform: Update Rust crate zbus to v4.4.0 (#10581) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- apps/desktop/desktop_native/Cargo.lock | 20 ++++++++++---------- apps/desktop/desktop_native/core/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/desktop/desktop_native/Cargo.lock b/apps/desktop/desktop_native/Cargo.lock index 720f15b5c62..b10f1a0e5ed 100644 --- a/apps/desktop/desktop_native/Cargo.lock +++ b/apps/desktop/desktop_native/Cargo.lock @@ -2487,9 +2487,9 @@ dependencies = [ [[package]] name = "zbus" -version = "4.3.1" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "851238c133804e0aa888edf4a0229481c753544ca12a60fd1c3230c8a500fe40" +checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" dependencies = [ "async-broadcast", "async-executor", @@ -2525,9 +2525,9 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "4.3.1" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d5a3f12c20bd473be3194af6b49d50d7bb804ef3192dc70eddedb26b85d9da7" +checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2583,9 +2583,9 @@ dependencies = [ [[package]] name = "zvariant" -version = "4.1.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1724a2b330760dc7d2a8402d841119dc869ef120b139d29862d6980e9c75bfc9" +checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" dependencies = [ "endi", "enumflags2", @@ -2596,9 +2596,9 @@ dependencies = [ [[package]] name = "zvariant_derive" -version = "4.1.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55025a7a518ad14518fb243559c058a2e5b848b015e31f1d90414f36e3317859" +checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2609,9 +2609,9 @@ dependencies = [ [[package]] name = "zvariant_utils" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc242db087efc22bd9ade7aa7809e4ba828132edc312871584a6b4391bdf8786" +checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" dependencies = [ "proc-macro2", "quote", diff --git a/apps/desktop/desktop_native/core/Cargo.toml b/apps/desktop/desktop_native/core/Cargo.toml index 151c2cc8bb0..1eeaad8e640 100644 --- a/apps/desktop/desktop_native/core/Cargo.toml +++ b/apps/desktop/desktop_native/core/Cargo.toml @@ -68,5 +68,5 @@ security-framework-sys = { version = "=2.11.0", optional = true } [target.'cfg(target_os = "linux")'.dependencies] gio = { version = "=0.19.5", optional = true } libsecret = { version = "=0.5.0", optional = true } -zbus = { version = "=4.3.1", optional = true } +zbus = { version = "=4.4.0", optional = true } zbus_polkit = { version = "=4.0.0", optional = true } From 1e2a51a56b6f8aa3b9ff69feebd56753847b03ba Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:55:31 -0500 Subject: [PATCH 03/20] Reverse Arguments (#11870) --- libs/common/src/services/api.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common/src/services/api.service.ts b/libs/common/src/services/api.service.ts index f3bd93560b6..2d4a0522636 100644 --- a/libs/common/src/services/api.service.ts +++ b/libs/common/src/services/api.service.ts @@ -1847,8 +1847,8 @@ export class ApiService implements ApiServiceAbstraction { const [requestHeaders, requestBody] = await this.buildHeadersAndBody( authed, hasResponse, - alterHeaders, body, + alterHeaders, ); const requestInit: RequestInit = { From b5450227da9d60bf72b709001fc4ce23c7115151 Mon Sep 17 00:00:00 2001 From: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:02:51 -0500 Subject: [PATCH 04/20] PM-14424 - LoginComponents should listen for unauthUiRefresh flag changes and forcibly change the UI on browser & desktop to make for a seamless experience without having to refresh. (#11830) --- apps/browser/src/auth/popup/home.component.ts | 33 +++++++++++++++++-- .../src/auth/login/login-v1.component.ts | 30 ++++++++++++++++- .../auth/src/angular/login/login.component.ts | 31 ++++++++++++++++- 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/apps/browser/src/auth/popup/home.component.ts b/apps/browser/src/auth/popup/home.component.ts index cd9dfc3702b..4d185fcbfc6 100644 --- a/apps/browser/src/auth/popup/home.component.ts +++ b/apps/browser/src/auth/popup/home.component.ts @@ -1,10 +1,12 @@ import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core"; import { FormBuilder, Validators } from "@angular/forms"; -import { Router } from "@angular/router"; -import { Subject, firstValueFrom, switchMap, takeUntil } from "rxjs"; +import { ActivatedRoute, Router } from "@angular/router"; +import { Subject, firstValueFrom, switchMap, takeUntil, tap } from "rxjs"; import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component"; import { LoginEmailServiceAbstraction, RegisterRouteService } from "@bitwarden/auth/common"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { ToastService } from "@bitwarden/components"; @@ -38,9 +40,13 @@ export class HomeComponent implements OnInit, OnDestroy { private accountSwitcherService: AccountSwitcherService, private registerRouteService: RegisterRouteService, private toastService: ToastService, + private configService: ConfigService, + private route: ActivatedRoute, ) {} async ngOnInit(): Promise { + this.listenForUnauthUiRefreshFlagChanges(); + const email = await firstValueFrom(this.loginEmailService.loginEmail$); const rememberEmail = this.loginEmailService.getRememberEmail(); @@ -70,6 +76,29 @@ export class HomeComponent implements OnInit, OnDestroy { this.destroyed$.complete(); } + private listenForUnauthUiRefreshFlagChanges() { + this.configService + .getFeatureFlag$(FeatureFlag.UnauthenticatedExtensionUIRefresh) + .pipe( + tap(async (flag) => { + // If the flag is turned ON, we must force a reload to ensure the correct UI is shown + if (flag) { + const uniqueQueryParams = { + ...this.route.queryParams, + // adding a unique timestamp to the query params to force a reload + t: new Date().getTime().toString(), + }; + + await this.router.navigate(["/login"], { + queryParams: uniqueQueryParams, + }); + } + }), + takeUntil(this.destroyed$), + ) + .subscribe(); + } + get availableAccounts$() { return this.accountSwitcherService.availableAccounts$; } diff --git a/apps/desktop/src/auth/login/login-v1.component.ts b/apps/desktop/src/auth/login/login-v1.component.ts index 6eb069d9bcb..132b430f327 100644 --- a/apps/desktop/src/auth/login/login-v1.component.ts +++ b/apps/desktop/src/auth/login/login-v1.component.ts @@ -1,7 +1,7 @@ import { Component, NgZone, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core"; import { FormBuilder } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; -import { Subject, takeUntil } from "rxjs"; +import { Subject, takeUntil, tap } from "rxjs"; import { LoginComponentV1 as BaseLoginComponent } from "@bitwarden/angular/auth/components/login-v1.component"; import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstractions/form-validation-errors.service"; @@ -14,8 +14,10 @@ import { import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction"; import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction"; import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service"; import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -76,6 +78,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe webAuthnLoginService: WebAuthnLoginServiceAbstraction, registerRouteService: RegisterRouteService, toastService: ToastService, + private configService: ConfigService, ) { super( devicesApiService, @@ -105,6 +108,8 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe } async ngOnInit() { + this.listenForUnauthUiRefreshFlagChanges(); + await super.ngOnInit(); await this.getLoginWithDevice(this.loggedEmail); this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => { @@ -137,6 +142,29 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe this.componentDestroyed$.complete(); } + private listenForUnauthUiRefreshFlagChanges() { + this.configService + .getFeatureFlag$(FeatureFlag.UnauthenticatedExtensionUIRefresh) + .pipe( + tap(async (flag) => { + // If the flag is turned ON, we must force a reload to ensure the correct UI is shown + if (flag) { + const uniqueQueryParams = { + ...this.route.queryParams, + // adding a unique timestamp to the query params to force a reload + t: new Date().getTime().toString(), + }; + + await this.router.navigate(["/"], { + queryParams: uniqueQueryParams, + }); + } + }), + takeUntil(this.destroy$), + ) + .subscribe(); + } + async settings() { const [modal, childComponent] = await this.modalService.openViewRef( EnvironmentComponent, diff --git a/libs/auth/src/angular/login/login.component.ts b/libs/auth/src/angular/login/login.component.ts index 239383ddd00..0193e4c4035 100644 --- a/libs/auth/src/angular/login/login.component.ts +++ b/libs/auth/src/angular/login/login.component.ts @@ -2,7 +2,7 @@ import { CommonModule } from "@angular/common"; import { Component, ElementRef, Input, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core"; import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from "@angular/forms"; import { ActivatedRoute, Router, RouterModule } from "@angular/router"; -import { firstValueFrom, Subject, take, takeUntil } from "rxjs"; +import { firstValueFrom, Subject, take, takeUntil, tap } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { @@ -19,9 +19,11 @@ import { CaptchaIFrame } from "@bitwarden/common/auth/captcha-iframe"; import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result"; import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason"; import { ClientType, HttpStatusCode } from "@bitwarden/common/enums"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ErrorResponse } from "@bitwarden/common/models/response/error.response"; import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service"; import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; @@ -139,12 +141,16 @@ export class LoginComponent implements OnInit, OnDestroy { private toastService: ToastService, private logService: LogService, private validationService: ValidationService, + private configService: ConfigService, ) { this.clientType = this.platformUtilsService.getClientType(); this.loginViaAuthRequestSupported = this.loginComponentService.isLoginViaAuthRequestSupported(); } async ngOnInit(): Promise { + // TODO: remove this when the UnauthenticatedExtensionUIRefresh feature flag is removed. + this.listenForUnauthUiRefreshFlagChanges(); + await this.defaultOnInit(); if (this.clientType === ClientType.Desktop) { @@ -162,6 +168,29 @@ export class LoginComponent implements OnInit, OnDestroy { this.destroy$.complete(); } + private listenForUnauthUiRefreshFlagChanges() { + this.configService + .getFeatureFlag$(FeatureFlag.UnauthenticatedExtensionUIRefresh) + .pipe( + tap(async (flag) => { + // If the flag is turned OFF, we must force a reload to ensure the correct UI is shown + if (!flag) { + const uniqueQueryParams = { + ...this.activatedRoute.queryParams, + // adding a unique timestamp to the query params to force a reload + t: new Date().getTime().toString(), // Adding a unique timestamp as a query parameter + }; + + await this.router.navigate(["/"], { + queryParams: uniqueQueryParams, + }); + } + }), + takeUntil(this.destroy$), + ) + .subscribe(); + } + submit = async (): Promise => { if (this.clientType === ClientType.Desktop) { if (this.loginUiState !== LoginUiState.MASTER_PASSWORD_ENTRY) { From 350a85674d73d3f3c7e0187c3b843e1fd17c594d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:20:41 -0500 Subject: [PATCH 05/20] [deps] Platform: Update Rust crate napi to v2.16.13 (#11533) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- apps/desktop/desktop_native/Cargo.lock | 4 ++-- apps/desktop/desktop_native/napi/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/desktop/desktop_native/Cargo.lock b/apps/desktop/desktop_native/Cargo.lock index b10f1a0e5ed..490ea1997d0 100644 --- a/apps/desktop/desktop_native/Cargo.lock +++ b/apps/desktop/desktop_native/Cargo.lock @@ -1154,9 +1154,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.11" +version = "2.16.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53575dfa17f208dd1ce3a2da2da4659aae393b256a472f2738a8586a6c4107fd" +checksum = "214f07a80874bb96a8433b3cdfc84980d56c7b02e1a0d7ba4ba0db5cef785e2b" dependencies = [ "bitflags", "ctor", diff --git a/apps/desktop/desktop_native/napi/Cargo.toml b/apps/desktop/desktop_native/napi/Cargo.toml index 6da4fcb0153..d5376b3eaa9 100644 --- a/apps/desktop/desktop_native/napi/Cargo.toml +++ b/apps/desktop/desktop_native/napi/Cargo.toml @@ -16,7 +16,7 @@ manual_test = [] [dependencies] anyhow = "=1.0.86" desktop_core = { path = "../core" } -napi = { version = "=2.16.11", features = ["async"] } +napi = { version = "=2.16.13", features = ["async"] } napi-derive = "=2.16.12" tokio = { version = "1.38.0" } tokio-util = "0.7.11" From 52c7d21e5f13cfca13d08a8762a177835daa3d6d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:59:35 -0500 Subject: [PATCH 06/20] [deps] Platform: Update Rust crate anyhow to v1.0.93 (#11059) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- apps/desktop/desktop_native/Cargo.lock | 4 ++-- apps/desktop/desktop_native/core/Cargo.toml | 2 +- apps/desktop/desktop_native/napi/Cargo.toml | 2 +- apps/desktop/desktop_native/proxy/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/desktop/desktop_native/Cargo.lock b/apps/desktop/desktop_native/Cargo.lock index 490ea1997d0..d8a7c470eba 100644 --- a/apps/desktop/desktop_native/Cargo.lock +++ b/apps/desktop/desktop_native/Cargo.lock @@ -39,9 +39,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "arboard" diff --git a/apps/desktop/desktop_native/core/Cargo.toml b/apps/desktop/desktop_native/core/Cargo.toml index 1eeaad8e640..a56c1b57434 100644 --- a/apps/desktop/desktop_native/core/Cargo.toml +++ b/apps/desktop/desktop_native/core/Cargo.toml @@ -23,7 +23,7 @@ sys = [ [dependencies] aes = "=0.8.4" -anyhow = "=1.0.86" +anyhow = "=1.0.93" arboard = { version = "=3.4.1", default-features = false, features = [ "wayland-data-control", ] } diff --git a/apps/desktop/desktop_native/napi/Cargo.toml b/apps/desktop/desktop_native/napi/Cargo.toml index d5376b3eaa9..64ab106e576 100644 --- a/apps/desktop/desktop_native/napi/Cargo.toml +++ b/apps/desktop/desktop_native/napi/Cargo.toml @@ -14,7 +14,7 @@ default = [] manual_test = [] [dependencies] -anyhow = "=1.0.86" +anyhow = "=1.0.93" desktop_core = { path = "../core" } napi = { version = "=2.16.13", features = ["async"] } napi-derive = "=2.16.12" diff --git a/apps/desktop/desktop_native/proxy/Cargo.toml b/apps/desktop/desktop_native/proxy/Cargo.toml index 6f8005811d6..a1cefca7a3f 100644 --- a/apps/desktop/desktop_native/proxy/Cargo.toml +++ b/apps/desktop/desktop_native/proxy/Cargo.toml @@ -7,7 +7,7 @@ version = "0.0.0" publish = false [dependencies] -anyhow = "=1.0.86" +anyhow = "=1.0.93" desktop_core = { path = "../core", default-features = false } futures = "0.3.30" log = "0.4.22" From b877624ce3c12c1063ada58655b50f730b220e2a Mon Sep 17 00:00:00 2001 From: Jordan Aasen <166539328+jaasen-livefront@users.noreply.github.com> Date: Wed, 6 Nov 2024 06:47:29 -0800 Subject: [PATCH 07/20] [PM-14462] - Update "Access Intelligence" to "Risk Insights" (#11853) * rename acess intelligence to risk insights * keep branch name * replace all instances of AccessIntelligence. strip raw data + members to just the table * revert change to feature flag name --- .../organization-layout.component.html | 6 +- .../layouts/organization-layout.component.ts | 4 +- .../organization-routing.module.ts | 6 +- .../access-intelligence.module.ts | 9 -- .../password-health-members.component.html | 120 ------------------ .../all-applications.component.html | 0 .../all-applications.component.ts | 0 .../application-table.mock.ts | 0 .../critical-applications.component.html | 0 .../critical-applications.component.ts | 6 +- .../notified-members-table.component.html | 0 .../notified-members-table.component.ts | 0 ...password-health-members-uri.component.html | 0 ...sword-health-members-uri.component.spec.ts | 2 +- .../password-health-members-uri.component.ts | 2 +- .../password-health-members.component.html | 64 ++++++++++ .../password-health-members.component.ts | 2 +- .../password-health.component.html | 0 .../password-health.component.spec.ts | 2 +- .../password-health.component.ts | 2 +- .../risk-insights-routing.module.ts} | 8 +- .../risk-insights.component.html} | 2 +- .../risk-insights.component.ts} | 10 +- .../risk-insights/risk-insights.module.ts | 9 ++ apps/web/src/locales/en/messages.json | 4 +- .../index.ts | 0 .../member-cipher-details.response.ts | 0 .../services/ciphers.mock.ts | 0 .../services/index.ts | 0 .../member-cipher-details-api.service.spec.ts | 0 .../member-cipher-details-api.service.ts | 0 .../member-cipher-details-response.mock.ts | 0 .../services/password-health.service.spec.ts | 0 .../services/password-health.service.ts | 4 +- 34 files changed, 103 insertions(+), 159 deletions(-) delete mode 100644 apps/web/src/app/tools/access-intelligence/access-intelligence.module.ts delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health-members.component.html rename apps/web/src/app/tools/{access-intelligence => risk-insights}/all-applications.component.html (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/all-applications.component.ts (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/application-table.mock.ts (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/critical-applications.component.html (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/critical-applications.component.ts (93%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/notified-members-table.component.html (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/notified-members-table.component.ts (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health-members-uri.component.html (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health-members-uri.component.spec.ts (98%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health-members-uri.component.ts (99%) create mode 100644 apps/web/src/app/tools/risk-insights/password-health-members.component.html rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health-members.component.ts (99%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health.component.html (100%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health.component.spec.ts (98%) rename apps/web/src/app/tools/{access-intelligence => risk-insights}/password-health.component.ts (98%) rename apps/web/src/app/tools/{access-intelligence/access-intelligence-routing.module.ts => risk-insights/risk-insights-routing.module.ts} (70%) rename apps/web/src/app/tools/{access-intelligence/access-intelligence.component.html => risk-insights/risk-insights.component.html} (94%) rename apps/web/src/app/tools/{access-intelligence/access-intelligence.component.ts => risk-insights/risk-insights.component.ts} (88%) create mode 100644 apps/web/src/app/tools/risk-insights/risk-insights.module.ts rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/index.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/response/member-cipher-details.response.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/ciphers.mock.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/index.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/member-cipher-details-api.service.spec.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/member-cipher-details-api.service.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/member-cipher-details-response.mock.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/password-health.service.spec.ts (100%) rename bitwarden_license/bit-common/src/tools/reports/{access-intelligence => risk-insights}/services/password-health.service.ts (97%) diff --git a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html index 23e9c6df178..9cd94c5208c 100644 --- a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html +++ b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.html @@ -40,9 +40,9 @@ > ; hideNewOrgButton$: Observable; organizationIsUnmanaged$: Observable; - isAccessIntelligenceFeatureEnabled = false; + isRiskInsightsFeatureEnabled = false; private _destroy = new Subject(); @@ -71,7 +71,7 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy { async ngOnInit() { document.body.classList.remove("layout_frontend"); - this.isAccessIntelligenceFeatureEnabled = await this.configService.getFeatureFlag( + this.isRiskInsightsFeatureEnabled = await this.configService.getFeatureFlag( FeatureFlag.AccessIntelligence, ); diff --git a/apps/web/src/app/admin-console/organizations/organization-routing.module.ts b/apps/web/src/app/admin-console/organizations/organization-routing.module.ts index a36b267e2fe..1725148d477 100644 --- a/apps/web/src/app/admin-console/organizations/organization-routing.module.ts +++ b/apps/web/src/app/admin-console/organizations/organization-routing.module.ts @@ -63,10 +63,10 @@ const routes: Routes = [ ), }, { - path: "access-intelligence", + path: "risk-insights", loadChildren: () => - import("../../tools/access-intelligence/access-intelligence.module").then( - (m) => m.AccessIntelligenceModule, + import("../../tools/risk-insights/risk-insights.module").then( + (m) => m.RiskInsightsModule, ), }, { diff --git a/apps/web/src/app/tools/access-intelligence/access-intelligence.module.ts b/apps/web/src/app/tools/access-intelligence/access-intelligence.module.ts deleted file mode 100644 index 32b66935b69..00000000000 --- a/apps/web/src/app/tools/access-intelligence/access-intelligence.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NgModule } from "@angular/core"; - -import { AccessIntelligenceRoutingModule } from "./access-intelligence-routing.module"; -import { AccessIntelligenceComponent } from "./access-intelligence.component"; - -@NgModule({ - imports: [AccessIntelligenceComponent, AccessIntelligenceRoutingModule], -}) -export class AccessIntelligenceModule {} diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members.component.html b/apps/web/src/app/tools/access-intelligence/password-health-members.component.html deleted file mode 100644 index 611443c993a..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health-members.component.html +++ /dev/null @@ -1,120 +0,0 @@ -

{{ "passwordsReportDesc" | i18n }}

-
- - {{ "loading" | i18n }} -
-
-
- - - - -
-
- - -
-
-
- - - - -
-
- - -
- - - - - {{ "name" | i18n }} - {{ "weakness" | i18n }} - {{ "timesReused" | i18n }} - {{ "timesExposed" | i18n }} - {{ "totalMembers" | i18n }} - - - - - - - - - - {{ r.name }} - -
- {{ r.subTitle }} - - - - {{ passwordStrengthMap.get(r.id)[0] | i18n }} - - - - - {{ "reusedXTimes" | i18n: passwordUseMap.get(r.login.password) }} - - - - - {{ "exposedXTimes" | i18n: exposedPasswordMap.get(r.id) }} - - - - {{ totalMembersMap.get(r.id) || 0 }} - - -
-
-
-
diff --git a/apps/web/src/app/tools/access-intelligence/all-applications.component.html b/apps/web/src/app/tools/risk-insights/all-applications.component.html similarity index 100% rename from apps/web/src/app/tools/access-intelligence/all-applications.component.html rename to apps/web/src/app/tools/risk-insights/all-applications.component.html diff --git a/apps/web/src/app/tools/access-intelligence/all-applications.component.ts b/apps/web/src/app/tools/risk-insights/all-applications.component.ts similarity index 100% rename from apps/web/src/app/tools/access-intelligence/all-applications.component.ts rename to apps/web/src/app/tools/risk-insights/all-applications.component.ts diff --git a/apps/web/src/app/tools/access-intelligence/application-table.mock.ts b/apps/web/src/app/tools/risk-insights/application-table.mock.ts similarity index 100% rename from apps/web/src/app/tools/access-intelligence/application-table.mock.ts rename to apps/web/src/app/tools/risk-insights/application-table.mock.ts diff --git a/apps/web/src/app/tools/access-intelligence/critical-applications.component.html b/apps/web/src/app/tools/risk-insights/critical-applications.component.html similarity index 100% rename from apps/web/src/app/tools/access-intelligence/critical-applications.component.html rename to apps/web/src/app/tools/risk-insights/critical-applications.component.html diff --git a/apps/web/src/app/tools/access-intelligence/critical-applications.component.ts b/apps/web/src/app/tools/risk-insights/critical-applications.component.ts similarity index 93% rename from apps/web/src/app/tools/access-intelligence/critical-applications.component.ts rename to apps/web/src/app/tools/risk-insights/critical-applications.component.ts index a5df519fd80..0779b2977e5 100644 --- a/apps/web/src/app/tools/access-intelligence/critical-applications.component.ts +++ b/apps/web/src/app/tools/risk-insights/critical-applications.component.ts @@ -12,8 +12,8 @@ import { HeaderModule } from "../../layouts/header/header.module"; import { SharedModule } from "../../shared"; import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; -import { AccessIntelligenceTabType } from "./access-intelligence.component"; import { applicationTableMockData } from "./application-table.mock"; +import { RiskInsightsTabType } from "./risk-insights.component"; @Component({ standalone: true, @@ -49,8 +49,8 @@ export class CriticalApplicationsComponent implements OnInit { } goToAllAppsTab = async () => { - await this.router.navigate([`organizations/${this.organizationId}/access-intelligence`], { - queryParams: { tabIndex: AccessIntelligenceTabType.AllApps }, + await this.router.navigate([`organizations/${this.organizationId}/risk-insights`], { + queryParams: { tabIndex: RiskInsightsTabType.AllApps }, queryParamsHandling: "merge", }); }; diff --git a/apps/web/src/app/tools/access-intelligence/notified-members-table.component.html b/apps/web/src/app/tools/risk-insights/notified-members-table.component.html similarity index 100% rename from apps/web/src/app/tools/access-intelligence/notified-members-table.component.html rename to apps/web/src/app/tools/risk-insights/notified-members-table.component.html diff --git a/apps/web/src/app/tools/access-intelligence/notified-members-table.component.ts b/apps/web/src/app/tools/risk-insights/notified-members-table.component.ts similarity index 100% rename from apps/web/src/app/tools/access-intelligence/notified-members-table.component.ts rename to apps/web/src/app/tools/risk-insights/notified-members-table.component.ts diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html b/apps/web/src/app/tools/risk-insights/password-health-members-uri.component.html similarity index 100% rename from apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html rename to apps/web/src/app/tools/risk-insights/password-health-members-uri.component.html diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts b/apps/web/src/app/tools/risk-insights/password-health-members-uri.component.spec.ts similarity index 98% rename from apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts rename to apps/web/src/app/tools/risk-insights/password-health-members-uri.component.spec.ts index 376ae16e232..b34730bd328 100644 --- a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts +++ b/apps/web/src/app/tools/risk-insights/password-health-members-uri.component.spec.ts @@ -4,7 +4,7 @@ import { mock, MockProxy } from "jest-mock-extended"; import { of } from "rxjs"; // eslint-disable-next-line no-restricted-imports -import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/access-intelligence"; +import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts b/apps/web/src/app/tools/risk-insights/password-health-members-uri.component.ts similarity index 99% rename from apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts rename to apps/web/src/app/tools/risk-insights/password-health-members-uri.component.ts index 0059964f41b..c977c829537 100644 --- a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts +++ b/apps/web/src/app/tools/risk-insights/password-health-members-uri.component.ts @@ -6,7 +6,7 @@ import { map } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; // eslint-disable-next-line no-restricted-imports -import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/access-intelligence"; +import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; diff --git a/apps/web/src/app/tools/risk-insights/password-health-members.component.html b/apps/web/src/app/tools/risk-insights/password-health-members.component.html new file mode 100644 index 00000000000..7f9b37f2a82 --- /dev/null +++ b/apps/web/src/app/tools/risk-insights/password-health-members.component.html @@ -0,0 +1,64 @@ +

{{ "passwordsReportDesc" | i18n }}

+
+ + {{ "loading" | i18n }} +
+
+ + + + + {{ "name" | i18n }} + {{ "weakness" | i18n }} + {{ "timesReused" | i18n }} + {{ "timesExposed" | i18n }} + {{ "totalMembers" | i18n }} + + + + + + + + + + {{ r.name }} + +
+ {{ r.subTitle }} + + + + {{ passwordStrengthMap.get(r.id)[0] | i18n }} + + + + + {{ "reusedXTimes" | i18n: passwordUseMap.get(r.login.password) }} + + + + + {{ "exposedXTimes" | i18n: exposedPasswordMap.get(r.id) }} + + + + {{ totalMembersMap.get(r.id) || 0 }} + + +
+
+
diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members.component.ts b/apps/web/src/app/tools/risk-insights/password-health-members.component.ts similarity index 99% rename from apps/web/src/app/tools/access-intelligence/password-health-members.component.ts rename to apps/web/src/app/tools/risk-insights/password-health-members.component.ts index 9d457013e84..2581de78ed5 100644 --- a/apps/web/src/app/tools/access-intelligence/password-health-members.component.ts +++ b/apps/web/src/app/tools/risk-insights/password-health-members.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute } from "@angular/router"; import { debounceTime, map } from "rxjs"; // eslint-disable-next-line no-restricted-imports -import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/access-intelligence"; +import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; diff --git a/apps/web/src/app/tools/access-intelligence/password-health.component.html b/apps/web/src/app/tools/risk-insights/password-health.component.html similarity index 100% rename from apps/web/src/app/tools/access-intelligence/password-health.component.html rename to apps/web/src/app/tools/risk-insights/password-health.component.html diff --git a/apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts b/apps/web/src/app/tools/risk-insights/password-health.component.spec.ts similarity index 98% rename from apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts rename to apps/web/src/app/tools/risk-insights/password-health.component.spec.ts index d41807e7d2d..50295b435b2 100644 --- a/apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts +++ b/apps/web/src/app/tools/risk-insights/password-health.component.spec.ts @@ -4,7 +4,7 @@ import { mock } from "jest-mock-extended"; import { of } from "rxjs"; // eslint-disable-next-line no-restricted-imports -import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/access-intelligence"; +import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; diff --git a/apps/web/src/app/tools/access-intelligence/password-health.component.ts b/apps/web/src/app/tools/risk-insights/password-health.component.ts similarity index 98% rename from apps/web/src/app/tools/access-intelligence/password-health.component.ts rename to apps/web/src/app/tools/risk-insights/password-health.component.ts index 4b7b8e394d3..c3c1732854d 100644 --- a/apps/web/src/app/tools/access-intelligence/password-health.component.ts +++ b/apps/web/src/app/tools/risk-insights/password-health.component.ts @@ -6,7 +6,7 @@ import { map } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; // eslint-disable-next-line no-restricted-imports -import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/access-intelligence"; +import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; diff --git a/apps/web/src/app/tools/access-intelligence/access-intelligence-routing.module.ts b/apps/web/src/app/tools/risk-insights/risk-insights-routing.module.ts similarity index 70% rename from apps/web/src/app/tools/access-intelligence/access-intelligence-routing.module.ts rename to apps/web/src/app/tools/risk-insights/risk-insights-routing.module.ts index 88efb2b4832..19cc6f6832c 100644 --- a/apps/web/src/app/tools/access-intelligence/access-intelligence-routing.module.ts +++ b/apps/web/src/app/tools/risk-insights/risk-insights-routing.module.ts @@ -4,15 +4,15 @@ import { RouterModule, Routes } from "@angular/router"; import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { AccessIntelligenceComponent } from "./access-intelligence.component"; +import { RiskInsightsComponent } from "./risk-insights.component"; const routes: Routes = [ { path: "", - component: AccessIntelligenceComponent, + component: RiskInsightsComponent, canActivate: [canAccessFeature(FeatureFlag.AccessIntelligence)], data: { - titleId: "accessIntelligence", + titleId: "RiskInsights", }, }, ]; @@ -21,4 +21,4 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule], }) -export class AccessIntelligenceRoutingModule {} +export class RiskInsightsRoutingModule {} diff --git a/apps/web/src/app/tools/access-intelligence/access-intelligence.component.html b/apps/web/src/app/tools/risk-insights/risk-insights.component.html similarity index 94% rename from apps/web/src/app/tools/access-intelligence/access-intelligence.component.html rename to apps/web/src/app/tools/risk-insights/risk-insights.component.html index 0f62a434648..90d9ce696d6 100644 --- a/apps/web/src/app/tools/access-intelligence/access-intelligence.component.html +++ b/apps/web/src/app/tools/risk-insights/risk-insights.component.html @@ -1,4 +1,4 @@ -
{{ "accessIntelligence" | i18n }}
+
{{ "riskInsights" | i18n }}

{{ "passwordRisk" | i18n }}

{{ "discoverAtRiskPasswords" | i18n }}
diff --git a/apps/web/src/app/tools/access-intelligence/access-intelligence.component.ts b/apps/web/src/app/tools/risk-insights/risk-insights.component.ts similarity index 88% rename from apps/web/src/app/tools/access-intelligence/access-intelligence.component.ts rename to apps/web/src/app/tools/risk-insights/risk-insights.component.ts index 557ae73625a..43d6da70e96 100644 --- a/apps/web/src/app/tools/access-intelligence/access-intelligence.component.ts +++ b/apps/web/src/app/tools/risk-insights/risk-insights.component.ts @@ -15,7 +15,7 @@ import { PasswordHealthMembersURIComponent } from "./password-health-members-uri import { PasswordHealthMembersComponent } from "./password-health-members.component"; import { PasswordHealthComponent } from "./password-health.component"; -export enum AccessIntelligenceTabType { +export enum RiskInsightsTabType { AllApps = 0, CriticalApps = 1, NotifiedMembers = 2, @@ -23,7 +23,7 @@ export enum AccessIntelligenceTabType { @Component({ standalone: true, - templateUrl: "./access-intelligence.component.html", + templateUrl: "./risk-insights.component.html", imports: [ AllApplicationsComponent, AsyncActionsModule, @@ -39,8 +39,8 @@ export enum AccessIntelligenceTabType { TabsModule, ], }) -export class AccessIntelligenceComponent { - tabIndex: AccessIntelligenceTabType; +export class RiskInsightsComponent { + tabIndex: RiskInsightsTabType; dataLastUpdated = new Date(); apps: any[] = []; @@ -70,7 +70,7 @@ export class AccessIntelligenceComponent { private router: Router, ) { route.queryParams.pipe(takeUntilDestroyed()).subscribe(({ tabIndex }) => { - this.tabIndex = !isNaN(tabIndex) ? tabIndex : AccessIntelligenceTabType.AllApps; + this.tabIndex = !isNaN(tabIndex) ? tabIndex : RiskInsightsTabType.AllApps; }); } } diff --git a/apps/web/src/app/tools/risk-insights/risk-insights.module.ts b/apps/web/src/app/tools/risk-insights/risk-insights.module.ts new file mode 100644 index 00000000000..23d3cd8089b --- /dev/null +++ b/apps/web/src/app/tools/risk-insights/risk-insights.module.ts @@ -0,0 +1,9 @@ +import { NgModule } from "@angular/core"; + +import { RiskInsightsRoutingModule } from "./risk-insights-routing.module"; +import { RiskInsightsComponent } from "./risk-insights.component"; + +@NgModule({ + imports: [RiskInsightsComponent, RiskInsightsRoutingModule], +}) +export class RiskInsightsModule {} diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 7e441ae4ba2..05332032e0a 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -5,8 +5,8 @@ "criticalApplications": { "message": "Critical applications" }, - "accessIntelligence": { - "message": "Access Intelligence" + "riskInsights": { + "message": "Risk Insights" }, "passwordRisk": { "message": "Password Risk" diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/index.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/index.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/index.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/index.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/response/member-cipher-details.response.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/response/member-cipher-details.response.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/response/member-cipher-details.response.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/response/member-cipher-details.response.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/ciphers.mock.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/ciphers.mock.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/ciphers.mock.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/ciphers.mock.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/index.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/index.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/index.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/index.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/member-cipher-details-api.service.spec.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/member-cipher-details-api.service.spec.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/member-cipher-details-api.service.spec.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/member-cipher-details-api.service.spec.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/member-cipher-details-api.service.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/member-cipher-details-api.service.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/member-cipher-details-api.service.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/member-cipher-details-api.service.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/member-cipher-details-response.mock.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/member-cipher-details-response.mock.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/member-cipher-details-response.mock.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/member-cipher-details-response.mock.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/password-health.service.spec.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.spec.ts similarity index 100% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/password-health.service.spec.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.spec.ts diff --git a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/password-health.service.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts similarity index 97% rename from bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/password-health.service.ts rename to bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts index 0eaed89b71f..1709261922b 100644 --- a/bitwarden_license/bit-common/src/tools/reports/access-intelligence/services/password-health.service.ts +++ b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts @@ -1,9 +1,9 @@ import { Inject, Injectable } from "@angular/core"; // eslint-disable-next-line no-restricted-imports -import { mockCiphers } from "@bitwarden/bit-common/tools/reports/access-intelligence/services/ciphers.mock"; +import { mockCiphers } from "@bitwarden/bit-common/tools/reports/risk-insights/services/ciphers.mock"; // eslint-disable-next-line no-restricted-imports -import { mockMemberCipherDetailsResponse } from "@bitwarden/bit-common/tools/reports/access-intelligence/services/member-cipher-details-response.mock"; +import { mockMemberCipherDetailsResponse } from "@bitwarden/bit-common/tools/reports/risk-insights/services/member-cipher-details-response.mock"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; From f33661c31c58700bf45178ab5239c9eda3b6125e Mon Sep 17 00:00:00 2001 From: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:05:22 +0100 Subject: [PATCH 08/20] [PM-11505]Delete the feature flag PM-5864-dollar-threshold (#11436) * remove the time threshold flag * Remove the time threshold flag --- .../user-subscription.component.html | 11 +---------- .../individual/user-subscription.component.ts | 5 ----- ...nization-subscription-cloud.component.html | 5 +---- ...ganization-subscription-cloud.component.ts | 19 ------------------- libs/common/src/enums/feature-flag.enum.ts | 2 -- 5 files changed, 2 insertions(+), 40 deletions(-) diff --git a/apps/web/src/app/billing/individual/user-subscription.component.html b/apps/web/src/app/billing/individual/user-subscription.component.html index eeb64ffe77d..1c1382cd816 100644 --- a/apps/web/src/app/billing/individual/user-subscription.component.html +++ b/apps/web/src/app/billing/individual/user-subscription.component.html @@ -48,16 +48,7 @@ }}
{{ "nextCharge" | i18n }}
-
- {{ - nextInvoice - ? (nextInvoice.date | date: "mediumDate") + - ", " + - (nextInvoice.amount | currency: "$") - : "-" - }} -
-
+
{{ nextInvoice ? (sub.subscription.periodEndDate | date: "mediumDate") + diff --git a/apps/web/src/app/billing/individual/user-subscription.component.ts b/apps/web/src/app/billing/individual/user-subscription.component.ts index e04b7c8b019..942767946ba 100644 --- a/apps/web/src/app/billing/individual/user-subscription.component.ts +++ b/apps/web/src/app/billing/individual/user-subscription.component.ts @@ -38,13 +38,9 @@ export class UserSubscriptionComponent implements OnInit { sub: SubscriptionResponse; selfHosted = false; cloudWebVaultUrl: string; - enableTimeThreshold: boolean; cancelPromise: Promise; reinstatePromise: Promise; - protected enableTimeThreshold$ = this.configService.getFeatureFlag$( - FeatureFlag.EnableTimeThreshold, - ); protected deprecateStripeSourcesAPI$ = this.configService.getFeatureFlag$( FeatureFlag.AC2476_DeprecateStripeSourcesAPI, @@ -69,7 +65,6 @@ export class UserSubscriptionComponent implements OnInit { async ngOnInit() { this.cloudWebVaultUrl = await firstValueFrom(this.environmentService.cloudWebVaultUrl$); await this.load(); - this.enableTimeThreshold = await firstValueFrom(this.enableTimeThreshold$); this.firstLoaded = true; } diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html index cd95e887040..0cd21d0f688 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html @@ -48,10 +48,7 @@
{{ "subscriptionExpiration" | i18n }}
-
- {{ nextInvoice ? (nextInvoice.date | date: "mediumDate") : "-" }} -
-
+
{{ nextInvoice ? (sub.subscription.periodEndDate | date: "mediumDate") : "-" }}
diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts index 1000084df9e..d4d11d91e01 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts @@ -52,7 +52,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy loading = true; locale: string; showUpdatedSubscriptionStatusSection$: Observable; - enableTimeThreshold: boolean; preSelectedProductTier: ProductTierType = ProductTierType.Free; showSubscription = true; showSelfHost = false; @@ -65,10 +64,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy FeatureFlag.EnableConsolidatedBilling, ); - protected enableTimeThreshold$ = this.configService.getFeatureFlag$( - FeatureFlag.EnableTimeThreshold, - ); - protected enableUpgradePasswordManagerSub$ = this.configService.getFeatureFlag$( FeatureFlag.EnableUpgradePasswordManagerSub, ); @@ -117,7 +112,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy this.showUpdatedSubscriptionStatusSection$ = this.configService.getFeatureFlag$( FeatureFlag.AC1795_UpdatedSubscriptionStatusSection, ); - this.enableTimeThreshold = await firstValueFrom(this.enableTimeThreshold$); } ngOnDestroy() { @@ -298,9 +292,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy return this.i18nService.t("subscriptionUpgrade", this.sub.seats.toString()); } } else if (this.sub.maxAutoscaleSeats === this.sub.seats && this.sub.seats != null) { - if (!this.enableTimeThreshold) { - return this.i18nService.t("subscriptionMaxReached", this.sub.seats.toString()); - } const seatAdjustmentMessage = this.sub.plan.isAnnual ? "annualSubscriptionUserSeatsMessage" : "monthlySubscriptionUserSeatsMessage"; @@ -311,21 +302,11 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy } else if (this.userOrg.productTierType === ProductTierType.TeamsStarter) { return this.i18nService.t("subscriptionUserSeatsWithoutAdditionalSeatsOption", 10); } else if (this.sub.maxAutoscaleSeats == null) { - if (!this.enableTimeThreshold) { - return this.i18nService.t("subscriptionUserSeatsUnlimitedAutoscale"); - } - const seatAdjustmentMessage = this.sub.plan.isAnnual ? "annualSubscriptionUserSeatsMessage" : "monthlySubscriptionUserSeatsMessage"; return this.i18nService.t(seatAdjustmentMessage); } else { - if (!this.enableTimeThreshold) { - return this.i18nService.t( - "subscriptionUserSeatsLimitedAutoscale", - this.sub.maxAutoscaleSeats.toString(), - ); - } const seatAdjustmentMessage = this.sub.plan.isAnnual ? "annualSubscriptionUserSeatsMessage" : "monthlySubscriptionUserSeatsMessage"; diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index 84cf5ed521e..ea016e34350 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -17,7 +17,6 @@ export enum FeatureFlag { InlineMenuFieldQualification = "inline-menu-field-qualification", MemberAccessReport = "ac-2059-member-access-report", TwoFactorComponentRefactor = "two-factor-component-refactor", - EnableTimeThreshold = "PM-5864-dollar-threshold", InlineMenuPositioningImprovements = "inline-menu-positioning-improvements", ProviderClientVaultPrivacyBanner = "ac-2833-provider-client-vault-privacy-banner", VaultBulkManagementAction = "vault-bulk-management-action", @@ -63,7 +62,6 @@ export const DefaultFeatureFlagValue = { [FeatureFlag.InlineMenuFieldQualification]: FALSE, [FeatureFlag.MemberAccessReport]: FALSE, [FeatureFlag.TwoFactorComponentRefactor]: FALSE, - [FeatureFlag.EnableTimeThreshold]: FALSE, [FeatureFlag.InlineMenuPositioningImprovements]: FALSE, [FeatureFlag.ProviderClientVaultPrivacyBanner]: FALSE, [FeatureFlag.VaultBulkManagementAction]: FALSE, From d5139e0511ab9a88e555515f0bcb1297eaec1a96 Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:42:53 -0600 Subject: [PATCH 09/20] change totp code to monospace font (#11844) --- .../login-credentials/login-credentials-view.component.html | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html b/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html index 0bee6d30eb8..afc38a58d65 100644 --- a/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html +++ b/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html @@ -111,6 +111,7 @@ [value]="totpCodeCopyObj?.totpCodeFormatted || '*** ***'" aria-readonly="true" data-testid="login-totp" + class="tw-font-mono" />
Date: Wed, 6 Nov 2024 10:12:24 -0600 Subject: [PATCH 10/20] fix: refactor enabled state of org name field, refs PM-14533 (#11879) --- .../organizations/settings/account.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/admin-console/organizations/settings/account.component.ts b/apps/web/src/app/admin-console/organizations/settings/account.component.ts index ffcf0cef9cf..2d97f95e519 100644 --- a/apps/web/src/app/admin-console/organizations/settings/account.component.ts +++ b/apps/web/src/app/admin-console/organizations/settings/account.component.ts @@ -123,20 +123,22 @@ export class AccountComponent implements OnInit, OnDestroy { this.canEditSubscription = organization.canEditSubscription; this.canUseApi = organization.useApi; - // Update disabled states - reactive forms prefers not using disabled attribute // Disabling these fields for self hosted orgs is deprecated // This block can be completely removed as part of // https://bitwarden.atlassian.net/browse/PM-10863 if (!this.limitCollectionCreationDeletionSplitFeatureFlagIsEnabled) { if (!this.selfHosted) { - this.formGroup.get("orgName").enable(); this.collectionManagementFormGroup.get("limitCollectionCreationDeletion").enable(); this.collectionManagementFormGroup.get("allowAdminAccessToAllCollectionItems").enable(); } } - if (!this.selfHosted && this.canEditSubscription) { - this.formGroup.get("billingEmail").enable(); + // Update disabled states - reactive forms prefers not using disabled attribute + if (!this.selfHosted) { + this.formGroup.get("orgName").enable(); + if (this.canEditSubscription) { + this.formGroup.get("billingEmail").enable(); + } } // Org Response From 13d4de15711ae3db1fd81f1fb397f9c87acf832e Mon Sep 17 00:00:00 2001 From: Victoria League Date: Wed, 6 Nov 2024 11:15:50 -0500 Subject: [PATCH 11/20] [CL-435] Prevent Windows extension from shifting (#11851) --- apps/browser/src/popup/scss/base.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/browser/src/popup/scss/base.scss b/apps/browser/src/popup/scss/base.scss index 02ec66ec2f1..89b8816567d 100644 --- a/apps/browser/src/popup/scss/base.scss +++ b/apps/browser/src/popup/scss/base.scss @@ -6,6 +6,10 @@ margin: 0; } +html { + overflow: hidden; +} + html, body { font-family: $font-family-sans-serif; From 78764a0807827ef1beff7b7c73af210024374b7e Mon Sep 17 00:00:00 2001 From: Victoria League Date: Wed, 6 Nov 2024 11:46:40 -0500 Subject: [PATCH 12/20] [CL-503] Add notification color variables (#11802) --- libs/components/src/stories/colors.mdx | 4 ++++ libs/components/src/tw-theme.css | 6 ++++++ libs/components/tailwind.config.base.js | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/libs/components/src/stories/colors.mdx b/libs/components/src/stories/colors.mdx index 2891fe66803..22079dfcbf7 100644 --- a/libs/components/src/stories/colors.mdx +++ b/libs/components/src/stories/colors.mdx @@ -57,6 +57,10 @@ export const Table = (args) => ( {Row("info-600")} {Row("info-700")} + + {Row("notification-100")} + {Row("notification-600")} + {Row("art-primary")} {Row("art-accent")} diff --git a/libs/components/src/tw-theme.css b/libs/components/src/tw-theme.css index d2cce9a842b..0a5a66337ac 100644 --- a/libs/components/src/tw-theme.css +++ b/libs/components/src/tw-theme.css @@ -37,6 +37,9 @@ --color-success-600: 12 128 24; --color-success-700: 11 111 21; + --color-notification-100: 255 225 247; + --color-notification-600: 192 17 118; + --color-art-primary: 2 15 102; --color-art-accent: 44 221 223; @@ -92,6 +95,9 @@ --color-info-600: 121 161 233; --color-info-700: 219 229 246; + --color-notification-100: 117 37 83; + --color-notification-600: 255 143 208; + --color-art-primary: 243 246 249; --color-art-accent: 44 221 233; diff --git a/libs/components/tailwind.config.base.js b/libs/components/tailwind.config.base.js index 58409899c92..dbfb6c54272 100644 --- a/libs/components/tailwind.config.base.js +++ b/libs/components/tailwind.config.base.js @@ -58,6 +58,10 @@ module.exports = { 600: rgba("--color-info-600"), 700: rgba("--color-info-700"), }, + notification: { + 100: rgba("--color-notification-100"), + 600: rgba("--color-notification-600"), + }, art: { primary: rgba("--color-art-primary"), accent: rgba("--color-art-accent"), @@ -116,6 +120,9 @@ module.exports = { 300: rgba("--color-secondary-300"), 700: rgba("--color-secondary-700"), }, + notification: { + 600: rgba("--color-notification-600"), + }, }, ringOffsetColor: ({ theme }) => ({ DEFAULT: theme("colors.background"), From a9595b4d14579ec8b8ff979765ca3273c1219a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 6 Nov 2024 17:46:57 +0100 Subject: [PATCH 13/20] [PM-13361] Fix DDG DMG builds (#11878) --- apps/desktop/scripts/after-pack.js | 50 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/apps/desktop/scripts/after-pack.js b/apps/desktop/scripts/after-pack.js index d4cbc00c81c..fd16cd5ffbe 100644 --- a/apps/desktop/scripts/after-pack.js +++ b/apps/desktop/scripts/after-pack.js @@ -58,30 +58,46 @@ async function run(context) { id = identities[0].id; } - console.log(`Signing proxy binary before the main bundle, using identity '${id}'`); + console.log( + `Signing proxy binary before the main bundle, using identity '${id}', for build ${context.electronPlatformName}`, + ); const appName = context.packager.appInfo.productFilename; const appPath = `${context.appOutDir}/${appName}.app`; const proxyPath = path.join(appPath, "Contents", "MacOS", "desktop_proxy"); + const inheritProxyPath = path.join(appPath, "Contents", "MacOS", "desktop_proxy.inherit"); const packageId = "com.bitwarden.desktop"; - const entitlementsName = "entitlements.desktop_proxy.plist"; - const entitlementsPath = path.join(__dirname, "..", "resources", entitlementsName); - child_process.execSync( - `codesign -s '${id}' -i ${packageId} -f --timestamp --options runtime --entitlements ${entitlementsPath} ${proxyPath}`, - ); - const inheritProxyPath = path.join(appPath, "Contents", "MacOS", "desktop_proxy.inherit"); - const inheritEntitlementsName = "entitlements.desktop_proxy.inherit.plist"; - const inheritEntitlementsPath = path.join( - __dirname, - "..", - "resources", - inheritEntitlementsName, - ); - child_process.execSync( - `codesign -s '${id}' -i ${packageId} -f --timestamp --options runtime --entitlements ${inheritEntitlementsPath} ${inheritProxyPath}`, - ); + if (is_mas) { + const entitlementsName = "entitlements.desktop_proxy.plist"; + const entitlementsPath = path.join(__dirname, "..", "resources", entitlementsName); + child_process.execSync( + `codesign -s '${id}' -i ${packageId} -f --timestamp --options runtime --entitlements ${entitlementsPath} ${proxyPath}`, + ); + + const inheritEntitlementsName = "entitlements.desktop_proxy.inherit.plist"; + const inheritEntitlementsPath = path.join( + __dirname, + "..", + "resources", + inheritEntitlementsName, + ); + child_process.execSync( + `codesign -s '${id}' -i ${packageId} -f --timestamp --options runtime --entitlements ${inheritEntitlementsPath} ${inheritProxyPath}`, + ); + } else { + // For non-Appstore builds, we don't need the inherit binary as they are not sandboxed, + // but we sign and include it anyway for consistency. It should be removed once DDG supports the proxy directly. + const entitlementsName = "entitlements.mac.plist"; + const entitlementsPath = path.join(__dirname, "..", "resources", entitlementsName); + child_process.execSync( + `codesign -s '${id}' -i ${packageId} -f --timestamp --options runtime --entitlements ${entitlementsPath} ${proxyPath}`, + ); + child_process.execSync( + `codesign -s '${id}' -i ${packageId} -f --timestamp --options runtime --entitlements ${entitlementsPath} ${inheritProxyPath}`, + ); + } } } From 414bdde232bb6b184b3851bc52fa1213a5850f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=20Audrey=20=E2=9C=A8?= Date: Wed, 6 Nov 2024 11:54:29 -0500 Subject: [PATCH 14/20] [PM-13876] replace angular validation with html constraints validation (#11816) * rough-in passphrase validation failure handling * trigger valid change from settings * fix `max` constraint enforcement * add taps for generator validation monitoring/debugging * HTML constraints validation rises like a phoenix * remove min/max boundaries to fix chrome display issue * bind settings components as view children of options components * remove defunct `okSettings$` * extend validationless generator to passwords * extend validationless generator to catchall emails * extend validationless generator to forwarder emails * extend validationless generator to subaddress emails * extend validationless generator to usernames * fix observable cycle * disable generate button when no algorithm is selected * prevent duplicate algorithm emissions * add constraints that assign email address defaults --- libs/common/src/tools/state/object-key.ts | 1 + .../src/tools/state/user-state-subject.ts | 7 +- .../src/catchall-settings.component.html | 7 +- .../src/catchall-settings.component.ts | 22 ++- .../src/credential-generator.component.html | 8 + .../src/credential-generator.component.ts | 10 +- .../src/forwarder-settings.component.html | 18 +- .../src/forwarder-settings.component.ts | 53 ++---- .../components/src/generator.module.ts | 2 + .../src/passphrase-settings.component.html | 33 +++- .../src/passphrase-settings.component.ts | 42 +++-- .../src/password-generator.component.html | 4 + .../src/password-generator.component.ts | 53 +++--- .../src/password-settings.component.html | 46 ++++- .../src/password-settings.component.ts | 43 +++-- .../src/subaddress-settings.component.html | 7 +- .../src/subaddress-settings.component.ts | 34 ++-- .../src/username-generator.component.html | 6 + .../src/username-generator.component.ts | 5 +- .../src/username-settings.component.html | 14 +- .../src/username-settings.component.ts | 16 +- libs/tools/generator/components/src/util.ts | 2 +- .../generator/core/src/data/generators.ts | 175 +++++++++++------- .../core/src/policies/catchall-constraints.ts | 45 +++++ .../src/policies/subaddress-constraints.ts | 34 ++++ libs/tools/generator/core/src/rx.ts | 3 +- .../credential-generator.service.spec.ts | 45 +++++ .../services/credential-generator.service.ts | 27 ++- .../core/src/types/policy-configuration.ts | 6 +- .../send-ui/src/send-form/send-form.module.ts | 2 + 30 files changed, 552 insertions(+), 218 deletions(-) create mode 100644 libs/tools/generator/core/src/policies/catchall-constraints.ts create mode 100644 libs/tools/generator/core/src/policies/subaddress-constraints.ts diff --git a/libs/common/src/tools/state/object-key.ts b/libs/common/src/tools/state/object-key.ts index 88365d5cbd1..0593186ec43 100644 --- a/libs/common/src/tools/state/object-key.ts +++ b/libs/common/src/tools/state/object-key.ts @@ -22,6 +22,7 @@ export type ObjectKey> classifier: Classifier; format: "plain" | "classified"; options: UserKeyDefinitionOptions; + initial?: State; }; export function isObjectKey(key: any): key is ObjectKey { diff --git a/libs/common/src/tools/state/user-state-subject.ts b/libs/common/src/tools/state/user-state-subject.ts index 89f19ac3c73..845ab25c808 100644 --- a/libs/common/src/tools/state/user-state-subject.ts +++ b/libs/common/src/tools/state/user-state-subject.ts @@ -254,17 +254,18 @@ export class UserStateSubject< withConstraints, map(([loadedState, constraints]) => { // bypass nulls - if (!loadedState) { + if (!loadedState && !this.objectKey?.initial) { return { constraints: {} as Constraints, state: null, } satisfies Constrained; } + const unconstrained = loadedState ?? structuredClone(this.objectKey.initial); const calibration = isDynamic(constraints) - ? constraints.calibrate(loadedState) + ? constraints.calibrate(unconstrained) : constraints; - const adjusted = calibration.adjust(loadedState); + const adjusted = calibration.adjust(unconstrained); return { constraints: calibration.constraints, diff --git a/libs/tools/generator/components/src/catchall-settings.component.html b/libs/tools/generator/components/src/catchall-settings.component.html index 0b2a9e69ef3..61037c91a73 100644 --- a/libs/tools/generator/components/src/catchall-settings.component.html +++ b/libs/tools/generator/components/src/catchall-settings.component.html @@ -1,6 +1,11 @@
{{ "domainName" | i18n }} - +
diff --git a/libs/tools/generator/components/src/catchall-settings.component.ts b/libs/tools/generator/components/src/catchall-settings.component.ts index 55ddc1f8102..74fb37d2335 100644 --- a/libs/tools/generator/components/src/catchall-settings.component.ts +++ b/libs/tools/generator/components/src/catchall-settings.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core"; import { FormBuilder } from "@angular/forms"; -import { BehaviorSubject, skip, Subject, takeUntil } from "rxjs"; +import { BehaviorSubject, map, skip, Subject, takeUntil, withLatestFrom } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { UserId } from "@bitwarden/common/types/guid"; @@ -12,6 +12,11 @@ import { import { completeOnAccountSwitch } from "./util"; +/** Splits an email into a username, subaddress, and domain named group. + * Subaddress is optional. + */ +export const DOMAIN_PARSER = new RegExp("[^@]+@(?.+)"); + /** Options group for catchall emails */ @Component({ selector: "tools-catchall-settings", @@ -60,7 +65,19 @@ export class CatchallSettingsComponent implements OnInit, OnDestroy { // the first emission is the current value; subsequent emissions are updates settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated); - this.settings.valueChanges.pipe(takeUntil(this.destroyed$)).subscribe(settings); + // now that outputs are set up, connect inputs + this.saveSettings + .pipe( + withLatestFrom(this.settings.valueChanges), + map(([, settings]) => settings), + takeUntil(this.destroyed$), + ) + .subscribe(settings); + } + + private saveSettings = new Subject(); + save(site: string = "component api call") { + this.saveSettings.next(site); } private singleUserId$() { @@ -78,6 +95,7 @@ export class CatchallSettingsComponent implements OnInit, OnDestroy { private readonly destroyed$ = new Subject(); ngOnDestroy(): void { + this.destroyed$.next(); this.destroyed$.complete(); } } diff --git a/libs/tools/generator/components/src/credential-generator.component.html b/libs/tools/generator/components/src/credential-generator.component.html index f580b75f1ba..0182bd1c204 100644 --- a/libs/tools/generator/components/src/credential-generator.component.html +++ b/libs/tools/generator/components/src/credential-generator.component.html @@ -22,6 +22,7 @@ buttonType="main" (click)="generate('user request')" [appA11yTitle]="credentialTypeGenerateLabel$ | async" + [disabled]="!(algorithm$ | async)" > {{ credentialTypeGenerateLabel$ | async }} @@ -33,16 +34,19 @@ [appA11yTitle]="credentialTypeCopyLabel$ | async" [appCopyClick]="value$ | async" [valueLabel]="credentialTypeLabel$ | async" + [disabled]="!(algorithm$ | async)" >
(); const activeIdentifier$ = new Subject(); @@ -385,7 +384,7 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy { if (!a || a.onlyOnRequest) { this.value$.next("-"); } else { - this.generate("autogenerate"); + this.generate("autogenerate").catch((e: unknown) => this.logService.error(e)); } }); }); @@ -495,7 +494,7 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy { * @param requestor a label used to trace generation request * origin in the debugger. */ - protected generate(requestor: string) { + protected async generate(requestor: string) { this.generate$.next(requestor); } @@ -510,6 +509,7 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy { private readonly destroyed = new Subject(); ngOnDestroy() { + this.destroyed.next(); this.destroyed.complete(); // finalize subjects diff --git a/libs/tools/generator/components/src/forwarder-settings.component.html b/libs/tools/generator/components/src/forwarder-settings.component.html index 64566fa9562..0e15c2e89ac 100644 --- a/libs/tools/generator/components/src/forwarder-settings.component.html +++ b/libs/tools/generator/components/src/forwarder-settings.component.html @@ -1,16 +1,28 @@
{{ "forwarderDomainName" | i18n }} - + {{ "forwarderDomainNameHint" | i18n }} {{ "apiKey" | i18n }} - + {{ "selfHostBaseUrl" | i18n }} - +
diff --git a/libs/tools/generator/components/src/forwarder-settings.component.ts b/libs/tools/generator/components/src/forwarder-settings.component.ts index 67e93c611ee..f1caf91ade1 100644 --- a/libs/tools/generator/components/src/forwarder-settings.component.ts +++ b/libs/tools/generator/components/src/forwarder-settings.component.ts @@ -17,7 +17,6 @@ import { skip, Subject, switchAll, - switchMap, takeUntil, withLatestFrom, } from "rxjs"; @@ -33,7 +32,7 @@ import { toCredentialGeneratorConfiguration, } from "@bitwarden/generator-core"; -import { completeOnAccountSwitch, toValidators } from "./util"; +import { completeOnAccountSwitch } from "./util"; const Controls = Object.freeze({ domain: "domain", @@ -117,35 +116,17 @@ export class ForwarderSettingsComponent implements OnInit, OnChanges, OnDestroy this.settings.patchValue(settings as any, { emitEvent: false }); }); - // bind policy to the reactive form - forwarder$ - .pipe( - switchMap((forwarder) => { - const constraints$ = this.generatorService - .policy$(forwarder, { userId$: singleUserId$ }) - .pipe(map(({ constraints }) => [constraints, forwarder] as const)); - - return constraints$; - }), - takeUntil(this.destroyed$), - ) - .subscribe(([constraints, forwarder]) => { - for (const name in Controls) { - const control = this.settings.get(name); - if (forwarder.request.includes(name as any)) { - control.enable({ emitEvent: false }); - control.setValidators( - // the configuration's type erasure affects `toValidators` as well - toValidators(name, forwarder, constraints), - ); - } else { - control.disable({ emitEvent: false }); - control.clearValidators(); - } + // enable requested forwarder inputs + forwarder$.pipe(takeUntil(this.destroyed$)).subscribe((forwarder) => { + for (const name in Controls) { + const control = this.settings.get(name); + if (forwarder.request.includes(name as any)) { + control.enable({ emitEvent: false }); + } else { + control.disable({ emitEvent: false }); } - - this.settings.updateValueAndValidity({ emitEvent: false }); - }); + } + }); // the first emission is the current value; subsequent emissions are updates settings$$ @@ -157,13 +138,18 @@ export class ForwarderSettingsComponent implements OnInit, OnChanges, OnDestroy .subscribe(this.onUpdated); // now that outputs are set up, connect inputs - this.settings.valueChanges - .pipe(withLatestFrom(settings$$), takeUntil(this.destroyed$)) - .subscribe(([value, settings]) => { + this.saveSettings + .pipe(withLatestFrom(this.settings.valueChanges, settings$$), takeUntil(this.destroyed$)) + .subscribe(([, value, settings]) => { settings.next(value); }); } + private saveSettings = new Subject(); + save(site: string = "component api call") { + this.saveSettings.next(site); + } + ngOnChanges(changes: SimpleChanges): void { this.refresh$.complete(); if ("forwarder" in changes) { @@ -192,6 +178,7 @@ export class ForwarderSettingsComponent implements OnInit, OnChanges, OnDestroy private readonly destroyed$ = new Subject(); ngOnDestroy(): void { + this.destroyed$.next(); this.destroyed$.complete(); } } diff --git a/libs/tools/generator/components/src/generator.module.ts b/libs/tools/generator/components/src/generator.module.ts index 2d1cedca400..e73d687d7dd 100644 --- a/libs/tools/generator/components/src/generator.module.ts +++ b/libs/tools/generator/components/src/generator.module.ts @@ -7,6 +7,7 @@ import { safeProvider } from "@bitwarden/angular/platform/utils/safe-provider"; import { SafeInjectionToken } from "@bitwarden/angular/services/injection-tokens"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { StateProvider } from "@bitwarden/common/platform/state"; @@ -79,6 +80,7 @@ const RANDOMIZER = new SafeInjectionToken("Randomizer"); I18nService, EncryptService, KeyService, + AccountService, ], }), ], diff --git a/libs/tools/generator/components/src/passphrase-settings.component.html b/libs/tools/generator/components/src/passphrase-settings.component.html index d089de7a07b..4e073f34243 100644 --- a/libs/tools/generator/components/src/passphrase-settings.component.html +++ b/libs/tools/generator/components/src/passphrase-settings.component.html @@ -7,7 +7,13 @@ {{ "numWords" | i18n }} - + {{ numWordsBoundariesHint$ | async }} @@ -16,14 +22,33 @@ {{ "wordSeparator" | i18n }} - + - + {{ "capitalize" | i18n }} - + {{ "includeNumber" | i18n }}

{{ "generatorPolicyInEffect" | i18n }}

diff --git a/libs/tools/generator/components/src/passphrase-settings.component.ts b/libs/tools/generator/components/src/passphrase-settings.component.ts index d65e897f4e1..f2f1749cb62 100644 --- a/libs/tools/generator/components/src/passphrase-settings.component.ts +++ b/libs/tools/generator/components/src/passphrase-settings.component.ts @@ -1,7 +1,15 @@ import { coerceBooleanProperty } from "@angular/cdk/coercion"; import { OnInit, Input, Output, EventEmitter, Component, OnDestroy } from "@angular/core"; import { FormBuilder } from "@angular/forms"; -import { BehaviorSubject, skip, takeUntil, Subject, ReplaySubject } from "rxjs"; +import { + BehaviorSubject, + skip, + takeUntil, + Subject, + map, + withLatestFrom, + ReplaySubject, +} from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -12,7 +20,7 @@ import { PassphraseGenerationOptions, } from "@bitwarden/generator-core"; -import { completeOnAccountSwitch, toValidators } from "./util"; +import { completeOnAccountSwitch } from "./util"; const Controls = Object.freeze({ numWords: "numWords", @@ -81,21 +89,12 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy { // the first emission is the current value; subsequent emissions are updates settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated); - // dynamic policy enforcement + // explain policy & disable policy-overridden fields this.generatorService .policy$(Generators.passphrase, { userId$: singleUserId$ }) .pipe(takeUntil(this.destroyed$)) .subscribe(({ constraints }) => { - this.settings - .get(Controls.numWords) - .setValidators(toValidators(Controls.numWords, Generators.passphrase, constraints)); - - this.settings - .get(Controls.wordSeparator) - .setValidators(toValidators(Controls.wordSeparator, Generators.passphrase, constraints)); - - this.settings.updateValueAndValidity({ emitEvent: false }); - + this.wordSeparatorMaxLength = constraints.wordSeparator.maxLength; this.policyInEffect = constraints.policyInEffect; this.toggleEnabled(Controls.capitalize, !constraints.capitalize?.readonly); @@ -110,7 +109,21 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy { }); // now that outputs are set up, connect inputs - this.settings.valueChanges.pipe(takeUntil(this.destroyed$)).subscribe(settings); + this.saveSettings + .pipe( + withLatestFrom(this.settings.valueChanges), + map(([, settings]) => settings), + takeUntil(this.destroyed$), + ) + .subscribe(settings); + } + + /** attribute binding for wordSeparator[maxlength] */ + protected wordSeparatorMaxLength: number; + + private saveSettings = new Subject(); + save(site: string = "component api call") { + this.saveSettings.next(site); } /** display binding for enterprise policy notice */ @@ -144,6 +157,7 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy { private readonly destroyed$ = new Subject(); ngOnDestroy(): void { + this.destroyed$.next(); this.destroyed$.complete(); } } diff --git a/libs/tools/generator/components/src/password-generator.component.html b/libs/tools/generator/components/src/password-generator.component.html index 6726df30855..81e18ed02a9 100644 --- a/libs/tools/generator/components/src/password-generator.component.html +++ b/libs/tools/generator/components/src/password-generator.component.html @@ -20,6 +20,7 @@ buttonType="main" (click)="generate('user request')" [appA11yTitle]="credentialTypeGenerateLabel$ | async" + [disabled]="!(algorithm$ | async)" > {{ credentialTypeGenerateLabel$ | async }} @@ -31,10 +32,12 @@ [appA11yTitle]="credentialTypeCopyLabel$ | async" [appCopyClick]="value$ | async" [valueLabel]="credentialTypeLabel$ | async" + [disabled]="!(algorithm$ | async)" >
(null); + protected credentialType$ = new BehaviorSubject(null); /** Emits the last generated value. */ protected readonly value$ = new BehaviorSubject(""); @@ -72,14 +72,14 @@ export class PasswordGeneratorComponent implements OnInit, OnDestroy { * @param requestor a label used to trace generation request * origin in the debugger. */ - protected generate(requestor: string) { + protected async generate(requestor: string) { this.generate$.next(requestor); } /** Tracks changes to the selected credential type * @param type the new credential type */ - protected onCredentialTypeChanged(type: PasswordAlgorithm) { + protected onCredentialTypeChanged(type: CredentialAlgorithm) { // break subscription cycle if (this.credentialType$.value !== type) { this.zone.run(() => { @@ -169,29 +169,34 @@ export class PasswordGeneratorComponent implements OnInit, OnDestroy { preferences.next(preference); }); - // populate the form with the user's preferences to kick off interactivity - preferences.pipe(takeUntil(this.destroyed)).subscribe(({ password }) => { - // update navigation - this.onCredentialTypeChanged(password.algorithm); - - // load algorithm metadata - const algorithm = this.generatorService.algorithm(password.algorithm); - - // update subjects within the angular zone so that the - // template bindings refresh immediately - this.zone.run(() => { - this.algorithm$.next(algorithm); - }); - }); - - // generate on load unless the generator prohibits it - this.algorithm$ + // update active algorithm + preferences .pipe( - distinctUntilChanged((prev, next) => prev.id === next.id), - filter((a) => !a.onlyOnRequest), + map(({ password }) => this.generatorService.algorithm(password.algorithm)), + distinctUntilChanged((prev, next) => isSameAlgorithm(prev?.id, next?.id)), takeUntil(this.destroyed), ) - .subscribe(() => this.generate("autogenerate")); + .subscribe((algorithm) => { + // update navigation + this.onCredentialTypeChanged(algorithm.id); + + // update subjects within the angular zone so that the + // template bindings refresh immediately + this.zone.run(() => { + this.algorithm$.next(algorithm); + }); + }); + + // generate on load unless the generator prohibits it + this.algorithm$.pipe(takeUntil(this.destroyed)).subscribe((a) => { + this.zone.run(() => { + if (!a || a.onlyOnRequest) { + this.value$.next("-"); + } else { + this.generate("autogenerate").catch((e: unknown) => this.logService.error(e)); + } + }); + }); } private typeToGenerator$(type: CredentialAlgorithm) { diff --git a/libs/tools/generator/components/src/password-settings.component.html b/libs/tools/generator/components/src/password-settings.component.html index aa12a3247c3..9f8e00921fb 100644 --- a/libs/tools/generator/components/src/password-settings.component.html +++ b/libs/tools/generator/components/src/password-settings.component.html @@ -7,7 +7,7 @@ {{ "length" | i18n }} - + {{ lengthBoundariesHint$ | async }} @@ -21,7 +21,12 @@ attr.aria-description="{{ 'uppercaseDescription' | i18n }}" title="{{ 'uppercaseDescription' | i18n }}" > - + {{ "uppercaseLabel" | i18n }} - + {{ "lowercaseLabel" | i18n }} - + {{ "numbersLabel" | i18n }} - + {{ "specialCharactersLabel" | i18n }}
{{ "minNumbers" | i18n }} - + {{ "minSpecial" | i18n }} - +
- + {{ "avoidAmbiguous" | i18n }}

{{ "generatorPolicyInEffect" | i18n }}

diff --git a/libs/tools/generator/components/src/password-settings.component.ts b/libs/tools/generator/components/src/password-settings.component.ts index 6e9d106b71a..677a3417b97 100644 --- a/libs/tools/generator/components/src/password-settings.component.ts +++ b/libs/tools/generator/components/src/password-settings.component.ts @@ -1,7 +1,17 @@ import { coerceBooleanProperty } from "@angular/cdk/coercion"; import { OnInit, Input, Output, EventEmitter, Component, OnDestroy } from "@angular/core"; import { FormBuilder } from "@angular/forms"; -import { BehaviorSubject, takeUntil, Subject, map, filter, tap, skip, ReplaySubject } from "rxjs"; +import { + BehaviorSubject, + takeUntil, + Subject, + map, + filter, + tap, + skip, + ReplaySubject, + withLatestFrom, +} from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -12,7 +22,7 @@ import { PasswordGenerationOptions, } from "@bitwarden/generator-core"; -import { completeOnAccountSwitch, toValidators } from "./util"; +import { completeOnAccountSwitch } from "./util"; const Controls = Object.freeze({ length: "length", @@ -118,23 +128,11 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy { this.settings.patchValue(s, { emitEvent: false }); }); - // bind policy to the template + // explain policy & disable policy-overridden fields this.generatorService .policy$(Generators.password, { userId$: singleUserId$ }) .pipe(takeUntil(this.destroyed$)) .subscribe(({ constraints }) => { - this.settings - .get(Controls.length) - .setValidators(toValidators(Controls.length, Generators.password, constraints)); - - this.minNumber.setValidators( - toValidators(Controls.minNumber, Generators.password, constraints), - ); - - this.minSpecial.setValidators( - toValidators(Controls.minSpecial, Generators.password, constraints), - ); - this.policyInEffect = constraints.policyInEffect; const toggles = [ @@ -153,8 +151,8 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy { const boundariesHint = this.i18nService.t( "generatorBoundariesHint", - constraints.length.min, - constraints.length.max, + constraints.length.min?.toString(), + constraints.length.max?.toString(), ); this.lengthBoundariesHint.next(boundariesHint); }); @@ -201,9 +199,10 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy { settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated); // now that outputs are set up, connect inputs - this.settings.valueChanges + this.saveSettings .pipe( - map((settings) => { + withLatestFrom(this.settings.valueChanges), + map(([, settings]) => { // interface is "avoid" while storage is "include" const s: any = { ...settings }; s.ambiguous = s.avoidAmbiguous; @@ -215,6 +214,11 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy { .subscribe(settings); } + private saveSettings = new Subject(); + save(site: string = "component api call") { + this.saveSettings.next(site); + } + /** display binding for enterprise policy notice */ protected policyInEffect: boolean; @@ -246,6 +250,7 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy { private readonly destroyed$ = new Subject(); ngOnDestroy(): void { + this.destroyed$.next(); this.destroyed$.complete(); } } diff --git a/libs/tools/generator/components/src/subaddress-settings.component.html b/libs/tools/generator/components/src/subaddress-settings.component.html index 16f3aea28bf..1dfb5e3460d 100644 --- a/libs/tools/generator/components/src/subaddress-settings.component.html +++ b/libs/tools/generator/components/src/subaddress-settings.component.html @@ -1,6 +1,11 @@
{{ "email" | i18n }} - +
diff --git a/libs/tools/generator/components/src/subaddress-settings.component.ts b/libs/tools/generator/components/src/subaddress-settings.component.ts index bd6ca899db7..5a310c8defb 100644 --- a/libs/tools/generator/components/src/subaddress-settings.component.ts +++ b/libs/tools/generator/components/src/subaddress-settings.component.ts @@ -53,28 +53,25 @@ export class SubaddressSettingsComponent implements OnInit, OnDestroy { const singleUserId$ = this.singleUserId$(); const settings = await this.generatorService.settings(Generators.subaddress, { singleUserId$ }); - settings - .pipe( - withLatestFrom(this.accountService.activeAccount$), - map(([settings, activeAccount]) => { - // if the subaddress isn't specified, copy it from - // the user's settings - if ((settings.subaddressEmail ?? "").length < 1) { - settings.subaddressEmail = activeAccount.email; - } - - return settings; - }), - takeUntil(this.destroyed$), - ) - .subscribe((s) => { - this.settings.patchValue(s, { emitEvent: false }); - }); + settings.pipe(takeUntil(this.destroyed$)).subscribe((s) => { + this.settings.patchValue(s, { emitEvent: false }); + }); // the first emission is the current value; subsequent emissions are updates settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated); - this.settings.valueChanges.pipe(takeUntil(this.destroyed$)).subscribe(settings); + this.saveSettings + .pipe( + withLatestFrom(this.settings.valueChanges), + map(([, settings]) => settings), + takeUntil(this.destroyed$), + ) + .subscribe(settings); + } + + private saveSettings = new Subject(); + save(site: string = "component api call") { + this.saveSettings.next(site); } private singleUserId$() { @@ -92,6 +89,7 @@ export class SubaddressSettingsComponent implements OnInit, OnDestroy { private readonly destroyed$ = new Subject(); ngOnDestroy(): void { + this.destroyed$.next(); this.destroyed$.complete(); } } diff --git a/libs/tools/generator/components/src/username-generator.component.html b/libs/tools/generator/components/src/username-generator.component.html index 36aaae57ce2..f96374e063b 100644 --- a/libs/tools/generator/components/src/username-generator.component.html +++ b/libs/tools/generator/components/src/username-generator.component.html @@ -9,6 +9,7 @@ buttonType="main" (click)="generate('user request')" [appA11yTitle]="credentialTypeGenerateLabel$ | async" + [disabled]="!(algorithm$ | async)" > {{ credentialTypeGenerateLabel$ | async }} @@ -20,6 +21,7 @@ [appA11yTitle]="credentialTypeCopyLabel$ | async" [appCopyClick]="value$ | async" [valueLabel]="credentialTypeLabel$ | async" + [disabled]="!(algorithm$ | async)" > {{ credentialTypeCopyLabel$ | async }} @@ -57,21 +59,25 @@ this.logService.error(e)); } }); }); @@ -414,7 +414,7 @@ export class UsernameGeneratorComponent implements OnInit, OnDestroy { * @param requestor a label used to trace generation request * origin in the debugger. */ - protected generate(requestor: string) { + protected async generate(requestor: string) { this.generate$.next(requestor); } @@ -429,6 +429,7 @@ export class UsernameGeneratorComponent implements OnInit, OnDestroy { private readonly destroyed = new Subject(); ngOnDestroy() { + this.destroyed.next(); this.destroyed.complete(); // finalize subjects diff --git a/libs/tools/generator/components/src/username-settings.component.html b/libs/tools/generator/components/src/username-settings.component.html index 4a4f8cd9feb..649cd052e7b 100644 --- a/libs/tools/generator/components/src/username-settings.component.html +++ b/libs/tools/generator/components/src/username-settings.component.html @@ -1,10 +1,20 @@
- + {{ "capitalize" | i18n }} - + {{ "includeNumber" | i18n }}
diff --git a/libs/tools/generator/components/src/username-settings.component.ts b/libs/tools/generator/components/src/username-settings.component.ts index 8237b8674cd..05a46feaaa8 100644 --- a/libs/tools/generator/components/src/username-settings.component.ts +++ b/libs/tools/generator/components/src/username-settings.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core"; import { FormBuilder } from "@angular/forms"; -import { BehaviorSubject, skip, Subject, takeUntil } from "rxjs"; +import { BehaviorSubject, map, skip, Subject, takeUntil, withLatestFrom } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { UserId } from "@bitwarden/common/types/guid"; @@ -61,7 +61,18 @@ export class UsernameSettingsComponent implements OnInit, OnDestroy { // the first emission is the current value; subsequent emissions are updates settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated); - this.settings.valueChanges.pipe(takeUntil(this.destroyed$)).subscribe(settings); + this.saveSettings + .pipe( + withLatestFrom(this.settings.valueChanges), + map(([, settings]) => settings), + takeUntil(this.destroyed$), + ) + .subscribe(settings); + } + + private saveSettings = new Subject(); + save(site: string = "component api call") { + this.saveSettings.next(site); } private singleUserId$() { @@ -79,6 +90,7 @@ export class UsernameSettingsComponent implements OnInit, OnDestroy { private readonly destroyed$ = new Subject(); ngOnDestroy(): void { + this.destroyed$.next(); this.destroyed$.complete(); } } diff --git a/libs/tools/generator/components/src/util.ts b/libs/tools/generator/components/src/util.ts index d6cd4e6fbaf..7977f774594 100644 --- a/libs/tools/generator/components/src/util.ts +++ b/libs/tools/generator/components/src/util.ts @@ -49,7 +49,7 @@ export function toValidators( } const max = getConstraint("max", config, runtime); - if (max === undefined) { + if (max !== undefined) { validators.push(Validators.max(max)); } diff --git a/libs/tools/generator/core/src/data/generators.ts b/libs/tools/generator/core/src/data/generators.ts index 6090fe789cb..6ddea595ec7 100644 --- a/libs/tools/generator/core/src/data/generators.ts +++ b/libs/tools/generator/core/src/data/generators.ts @@ -1,7 +1,10 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { Policy } from "@bitwarden/common/admin-console/models/domain/policy"; +import { GENERATOR_DISK } from "@bitwarden/common/platform/state"; import { ApiSettings } from "@bitwarden/common/tools/integration/rpc"; +import { PublicClassifier } from "@bitwarden/common/tools/public-classifier"; import { IdentityConstraint } from "@bitwarden/common/tools/state/identity-state-constraint"; +import { ObjectKey } from "@bitwarden/common/tools/state/object-key"; import { EmailRandomizer, @@ -19,12 +22,12 @@ import { PasswordGeneratorOptionsEvaluator, passwordLeastPrivilege, } from "../policies"; +import { CatchallConstraints } from "../policies/catchall-constraints"; +import { SubaddressConstraints } from "../policies/subaddress-constraints"; import { - CATCHALL_SETTINGS, EFF_USERNAME_SETTINGS, PASSPHRASE_SETTINGS, PASSWORD_SETTINGS, - SUBADDRESS_SETTINGS, } from "../strategies/storage"; import { CatchallGenerationOptions, @@ -178,79 +181,115 @@ const USERNAME = Object.freeze({ }, } satisfies CredentialGeneratorConfiguration); -const CATCHALL = Object.freeze({ - id: "catchall", - category: "email", - nameKey: "catchallEmail", - descriptionKey: "catchallEmailDesc", - generateKey: "generateEmail", - generatedValueKey: "email", - copyKey: "copyEmail", - onlyOnRequest: false, - request: [], - engine: { - create( - dependencies: GeneratorDependencyProvider, - ): CredentialGenerator { - return new EmailRandomizer(dependencies.randomizer); +const CATCHALL: CredentialGeneratorConfiguration = + Object.freeze({ + id: "catchall", + category: "email", + nameKey: "catchallEmail", + descriptionKey: "catchallEmailDesc", + generateKey: "generateEmail", + generatedValueKey: "email", + copyKey: "copyEmail", + onlyOnRequest: false, + request: [], + engine: { + create( + dependencies: GeneratorDependencyProvider, + ): CredentialGenerator { + return new EmailRandomizer(dependencies.randomizer); + }, }, - }, - settings: { - initial: DefaultCatchallOptions, - constraints: { catchallDomain: { minLength: 1 } }, - account: CATCHALL_SETTINGS, - }, - policy: { - type: PolicyType.PasswordGenerator, - disabledValue: {}, - combine(_acc: NoPolicy, _policy: Policy) { - return {}; + settings: { + initial: DefaultCatchallOptions, + constraints: { catchallDomain: { minLength: 1 } }, + account: { + key: "catchallGeneratorSettings", + target: "object", + format: "plain", + classifier: new PublicClassifier([ + "catchallType", + "catchallDomain", + ]), + state: GENERATOR_DISK, + initial: { + catchallType: "random", + catchallDomain: "", + }, + options: { + deserializer: (value) => value, + clearOn: ["logout"], + }, + } satisfies ObjectKey, }, - createEvaluator(_policy: NoPolicy) { - return new DefaultPolicyEvaluator(); + policy: { + type: PolicyType.PasswordGenerator, + disabledValue: {}, + combine(_acc: NoPolicy, _policy: Policy) { + return {}; + }, + createEvaluator(_policy: NoPolicy) { + return new DefaultPolicyEvaluator(); + }, + toConstraints(_policy: NoPolicy, email: string) { + return new CatchallConstraints(email); + }, }, - toConstraints(_policy: NoPolicy) { - return new IdentityConstraint(); - }, - }, -} satisfies CredentialGeneratorConfiguration); + }); -const SUBADDRESS = Object.freeze({ - id: "subaddress", - category: "email", - nameKey: "plusAddressedEmail", - descriptionKey: "plusAddressedEmailDesc", - generateKey: "generateEmail", - generatedValueKey: "email", - copyKey: "copyEmail", - onlyOnRequest: false, - request: [], - engine: { - create( - dependencies: GeneratorDependencyProvider, - ): CredentialGenerator { - return new EmailRandomizer(dependencies.randomizer); +const SUBADDRESS: CredentialGeneratorConfiguration = + Object.freeze({ + id: "subaddress", + category: "email", + nameKey: "plusAddressedEmail", + descriptionKey: "plusAddressedEmailDesc", + generateKey: "generateEmail", + generatedValueKey: "email", + copyKey: "copyEmail", + onlyOnRequest: false, + request: [], + engine: { + create( + dependencies: GeneratorDependencyProvider, + ): CredentialGenerator { + return new EmailRandomizer(dependencies.randomizer); + }, }, - }, - settings: { - initial: DefaultSubaddressOptions, - constraints: {}, - account: SUBADDRESS_SETTINGS, - }, - policy: { - type: PolicyType.PasswordGenerator, - disabledValue: {}, - combine(_acc: NoPolicy, _policy: Policy) { - return {}; + settings: { + initial: DefaultSubaddressOptions, + constraints: {}, + account: { + key: "subaddressGeneratorSettings", + target: "object", + format: "plain", + classifier: new PublicClassifier([ + "subaddressType", + "subaddressEmail", + ]), + state: GENERATOR_DISK, + initial: { + subaddressType: "random", + subaddressEmail: "", + }, + options: { + deserializer: (value) => value, + clearOn: ["logout"], + }, + } satisfies ObjectKey, }, - createEvaluator(_policy: NoPolicy) { - return new DefaultPolicyEvaluator(); + policy: { + type: PolicyType.PasswordGenerator, + disabledValue: {}, + combine(_acc: NoPolicy, _policy: Policy) { + return {}; + }, + createEvaluator(_policy: NoPolicy) { + return new DefaultPolicyEvaluator(); + }, + toConstraints(_policy: NoPolicy, email: string) { + return new SubaddressConstraints(email); + }, }, - toConstraints(_policy: NoPolicy) { - return new IdentityConstraint(); - }, - }, -} satisfies CredentialGeneratorConfiguration); + }); export function toCredentialGeneratorConfiguration( configuration: ForwarderConfiguration, diff --git a/libs/tools/generator/core/src/policies/catchall-constraints.ts b/libs/tools/generator/core/src/policies/catchall-constraints.ts new file mode 100644 index 00000000000..37f62f874c6 --- /dev/null +++ b/libs/tools/generator/core/src/policies/catchall-constraints.ts @@ -0,0 +1,45 @@ +import { Constraints, StateConstraints } from "@bitwarden/common/tools/types"; + +import { CatchallGenerationOptions } from "../types"; + +/** Parses the domain part of an email address + */ +const DOMAIN_PARSER = new RegExp("[^@]+@(?.+)"); + +/** A constraint that sets the catchall domain using a fixed email address */ +export class CatchallConstraints implements StateConstraints { + /** Creates a catchall constraints + * @param email - the email address containing the domain. + */ + constructor(email: string) { + if (!email) { + this.domain = ""; + return; + } + + const parsed = DOMAIN_PARSER.exec(email); + if (parsed && parsed.groups?.domain) { + this.domain = parsed.groups.domain; + } + } + private domain: string; + + constraints: Readonly> = {}; + + adjust(state: CatchallGenerationOptions) { + const currentDomain = (state.catchallDomain ?? "").trim(); + + if (currentDomain !== "") { + return state; + } + + const options = { ...state }; + options.catchallDomain = this.domain; + + return options; + } + + fix(state: CatchallGenerationOptions) { + return state; + } +} diff --git a/libs/tools/generator/core/src/policies/subaddress-constraints.ts b/libs/tools/generator/core/src/policies/subaddress-constraints.ts new file mode 100644 index 00000000000..db05f712cf2 --- /dev/null +++ b/libs/tools/generator/core/src/policies/subaddress-constraints.ts @@ -0,0 +1,34 @@ +import { Constraints, StateConstraints } from "@bitwarden/common/tools/types"; + +import { SubaddressGenerationOptions } from "../types"; + +/** A constraint that sets the subaddress email using a fixed email address */ +export class SubaddressConstraints implements StateConstraints { + /** Creates a catchall constraints + * @param email - the email address containing the domain. + */ + constructor(readonly email: string) { + if (!email) { + this.email = ""; + } + } + + constraints: Readonly> = {}; + + adjust(state: SubaddressGenerationOptions) { + const currentDomain = (state.subaddressEmail ?? "").trim(); + + if (currentDomain !== "") { + return state; + } + + const options = { ...state }; + options.subaddressEmail = this.email; + + return options; + } + + fix(state: SubaddressGenerationOptions) { + return state; + } +} diff --git a/libs/tools/generator/core/src/rx.ts b/libs/tools/generator/core/src/rx.ts index 070d34d37d8..44d23ef1c5c 100644 --- a/libs/tools/generator/core/src/rx.ts +++ b/libs/tools/generator/core/src/rx.ts @@ -23,11 +23,12 @@ export function mapPolicyToEvaluator( */ export function mapPolicyToConstraints( configuration: PolicyConfiguration, + email: string, ) { return pipe( reduceCollection(configuration.combine, configuration.disabledValue), distinctIfShallowMatch(), - map(configuration.toConstraints), + map((policy) => configuration.toConstraints(policy, email)), ); } diff --git a/libs/tools/generator/core/src/services/credential-generator.service.spec.ts b/libs/tools/generator/core/src/services/credential-generator.service.spec.ts index 225745e5f95..bd26642157e 100644 --- a/libs/tools/generator/core/src/services/credential-generator.service.spec.ts +++ b/libs/tools/generator/core/src/services/credential-generator.service.spec.ts @@ -202,6 +202,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const generated = new ObservableTracker(generator.generate$(SomeConfiguration)); @@ -223,6 +224,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const generated = new ObservableTracker(generator.generate$(SomeConfiguration)); @@ -248,6 +250,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const generated = new ObservableTracker(generator.generate$(SomeConfiguration)); @@ -276,6 +279,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const website$ = new BehaviorSubject("some website"); const generated = new ObservableTracker(generator.generate$(SomeConfiguration, { website$ })); @@ -297,6 +301,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const website$ = new BehaviorSubject("some website"); let error = null; @@ -322,6 +327,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const website$ = new BehaviorSubject("some website"); let completed = false; @@ -348,6 +354,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(AnotherUser).asObservable(); const generated = new ObservableTracker(generator.generate$(SomeConfiguration, { userId$ })); @@ -368,6 +375,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.pipe(filter((u) => !!u)); @@ -392,6 +400,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(SomeUser); let error = null; @@ -417,6 +426,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(SomeUser); let completed = false; @@ -443,6 +453,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const on$ = new Subject(); const results: any[] = []; @@ -485,6 +496,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const on$ = new Subject(); let error: any = null; @@ -511,6 +523,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const on$ = new Subject(); let complete = false; @@ -542,6 +555,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = generator.algorithms("password"); @@ -563,6 +577,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = generator.algorithms("username"); @@ -583,6 +598,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = generator.algorithms("email"); @@ -604,6 +620,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = generator.algorithms(["username", "email"]); @@ -629,6 +646,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.algorithms$("password")); @@ -646,6 +664,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.algorithms$("username")); @@ -662,6 +681,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.algorithms$("email")); @@ -679,6 +699,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.algorithms$(["username", "email"])); @@ -701,6 +722,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.algorithms$(["password"])); @@ -726,6 +748,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const results: any = []; const sub = generator.algorithms$("password").subscribe((r) => results.push(r)); @@ -763,6 +786,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(AnotherUser).asObservable(); @@ -784,6 +808,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -814,6 +839,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -840,6 +866,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -866,6 +893,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -898,6 +926,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.settings$(SomeConfiguration)); @@ -916,6 +945,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.settings$(SomeConfiguration)); @@ -936,6 +966,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const result = await firstValueFrom(generator.settings$(SomeConfiguration)); @@ -961,6 +992,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const results: any = []; const sub = generator.settings$(SomeConfiguration).subscribe((r) => results.push(r)); @@ -986,6 +1018,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(AnotherUser).asObservable(); @@ -1007,6 +1040,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1034,6 +1068,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1060,6 +1095,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1086,6 +1122,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1118,6 +1155,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const subject = await generator.settings(SomeConfiguration, { singleUserId$ }); @@ -1139,6 +1177,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); let completed = false; @@ -1165,6 +1204,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(SomeUser).asObservable(); @@ -1182,6 +1222,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId$ = new BehaviorSubject(SomeUser).asObservable(); const policy$ = new BehaviorSubject([somePolicy]); @@ -1201,6 +1242,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1230,6 +1272,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1260,6 +1303,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); @@ -1286,6 +1330,7 @@ describe("CredentialGeneratorService", () => { i18nService, encryptService, keyService, + accountService, ); const userId = new BehaviorSubject(SomeUser); const userId$ = userId.asObservable(); diff --git a/libs/tools/generator/core/src/services/credential-generator.service.ts b/libs/tools/generator/core/src/services/credential-generator.service.ts index 04413ba2c0d..8c971b0d61b 100644 --- a/libs/tools/generator/core/src/services/credential-generator.service.ts +++ b/libs/tools/generator/core/src/services/credential-generator.service.ts @@ -23,6 +23,7 @@ import { Simplify } from "type-fest"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; import { PolicyType } from "@bitwarden/common/admin-console/enums"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { StateProvider } from "@bitwarden/common/platform/state"; @@ -98,6 +99,7 @@ export class CredentialGeneratorService { private readonly i18nService: I18nService, private readonly encryptService: EncryptService, private readonly keyService: KeyService, + private readonly accountService: AccountService, ) {} private getDependencyProvider(): GeneratorDependencyProvider { @@ -380,17 +382,30 @@ export class CredentialGeneratorService { configuration: Configuration, dependencies: Policy$Dependencies, ): Observable> { - const completion$ = dependencies.userId$.pipe(ignoreElements(), endWith(true)); + const email$ = dependencies.userId$.pipe( + distinctUntilChanged(), + withLatestFrom(this.accountService.accounts$), + filter((accounts) => !!accounts), + map(([userId, accounts]) => { + if (userId in accounts) { + return { userId, email: accounts[userId].email }; + } - const constraints$ = dependencies.userId$.pipe( - switchMap((userId) => { - // complete policy emissions otherwise `mergeMap` holds `policies$` open indefinitely + return { userId, email: null }; + }), + ); + + const constraints$ = email$.pipe( + switchMap(({ userId, email }) => { + // complete policy emissions otherwise `switchMap` holds `policies$` open indefinitely const policies$ = this.policyService .getAll$(configuration.policy.type, userId) - .pipe(takeUntil(completion$)); + .pipe( + mapPolicyToConstraints(configuration.policy, email), + takeUntil(anyComplete(email$)), + ); return policies$; }), - mapPolicyToConstraints(configuration.policy), ); return constraints$; diff --git a/libs/tools/generator/core/src/types/policy-configuration.ts b/libs/tools/generator/core/src/types/policy-configuration.ts index 2b01a04b92e..07ded886609 100644 --- a/libs/tools/generator/core/src/types/policy-configuration.ts +++ b/libs/tools/generator/core/src/types/policy-configuration.ts @@ -24,9 +24,13 @@ export type PolicyConfiguration = { createEvaluator: (policy: Policy) => PolicyEvaluator; /** Converts policy service data into actionable policy constraints. + * + * @param policy - the policy to map into policy constraints. + * @param email - the default email to extend. + * * @remarks this version includes constraints needed for the reactive forms; * it was introduced so that the constraints can be incrementally introduced * as the new UI is built. */ - toConstraints: (policy: Policy) => GeneratorConstraints; + toConstraints: (policy: Policy, email: string) => GeneratorConstraints; }; diff --git a/libs/tools/send/send-ui/src/send-form/send-form.module.ts b/libs/tools/send/send-ui/src/send-form/send-form.module.ts index 67f1f910cc8..ec51c2c0e32 100644 --- a/libs/tools/send/send-ui/src/send-form/send-form.module.ts +++ b/libs/tools/send/send-ui/src/send-form/send-form.module.ts @@ -4,6 +4,7 @@ import { safeProvider } from "@bitwarden/angular/platform/utils/safe-provider"; import { SafeInjectionToken } from "@bitwarden/angular/services/injection-tokens"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { StateProvider } from "@bitwarden/common/platform/state"; @@ -43,6 +44,7 @@ const RANDOMIZER = new SafeInjectionToken("Randomizer"); I18nService, EncryptService, KeyService, + AccountService, ], }), ], From a959620a11da826edd05bbaa348ee1e893a5e6ac Mon Sep 17 00:00:00 2001 From: Alec Rippberger <127791530+alec-livefront@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:08:29 -0600 Subject: [PATCH 15/20] [PM-14369] Hide account switcher if on login page and not logged into any accounts (#11827) * Add hasLoggedInAccount to check if there is a logged in account * Update Storybook providers * Revert "Update Storybook providers" This reverts commit 646506ab959e601bbddedb5173077362fb7c5450. * Reapply "Update Storybook providers" This reverts commit d86744a80b5b4fe910cb16a5b3b5dbf452ee845c. * Add story for HasLoggedInAccountExample * Remove unused imports --- ...tension-anon-layout-wrapper.component.html | 2 +- ...extension-anon-layout-wrapper.component.ts | 9 +++ .../extension-anon-layout-wrapper.stories.ts | 70 +++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.html b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.html index d5273fd9fb2..4a206b36fa8 100644 --- a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.html +++ b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.html @@ -9,7 +9,7 @@ - + diff --git a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.ts b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.ts index db85b28fa64..0301a76431d 100644 --- a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.ts +++ b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.component.ts @@ -15,6 +15,7 @@ import { PopOutComponent } from "../../../platform/popup/components/pop-out.comp import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-header.component"; import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component"; import { CurrentAccountComponent } from "../account-switching/current-account.component"; +import { AccountSwitcherService } from "../account-switching/services/account-switcher.service"; import { ExtensionBitwardenLogo } from "./extension-bitwarden-logo.icon"; @@ -50,6 +51,7 @@ export class ExtensionAnonLayoutWrapperComponent implements OnInit, OnDestroy { protected pageIcon: Icon; protected showReadonlyHostname: boolean; protected maxWidth: "md" | "3xl"; + protected hasLoggedInAccount: boolean = false; protected theme: string; protected logo = ExtensionBitwardenLogo; @@ -59,6 +61,7 @@ export class ExtensionAnonLayoutWrapperComponent implements OnInit, OnDestroy { private route: ActivatedRoute, private i18nService: I18nService, private extensionAnonLayoutWrapperDataService: AnonLayoutWrapperDataService, + private accountSwitcherService: AccountSwitcherService, ) {} async ngOnInit(): Promise { @@ -68,6 +71,12 @@ export class ExtensionAnonLayoutWrapperComponent implements OnInit, OnDestroy { // Listen for page changes and update the page data appropriately this.listenForPageDataChanges(); this.listenForServiceDataChanges(); + + this.accountSwitcherService.availableAccounts$ + .pipe(takeUntil(this.destroy$)) + .subscribe((accounts) => { + this.hasLoggedInAccount = accounts.some((account) => account.id !== "addAccount"); + }); } private listenForPageDataChanges() { diff --git a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.stories.ts b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.stories.ts index cc4aa2f7319..ad7e6f67361 100644 --- a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.stories.ts +++ b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper.stories.ts @@ -27,6 +27,7 @@ import { ButtonModule, I18nMockService } from "@bitwarden/components"; import { RegistrationCheckEmailIcon } from "../../../../../../libs/auth/src/angular/icons/registration-check-email.icon"; import { PopupRouterCacheService } from "../../../platform/popup/view-cache/popup-router-cache.service"; +import { AccountSwitcherService } from "../account-switching/services/account-switcher.service"; import { ExtensionAnonLayoutWrapperDataService } from "./extension-anon-layout-wrapper-data.service"; import { @@ -45,6 +46,7 @@ const decorators = (options: { applicationVersion?: string; clientType?: ClientType; hostName?: string; + accounts?: any[]; }) => { return [ componentWrapperDecorator( @@ -83,6 +85,13 @@ const decorators = (options: { }), }, }, + { + provide: AccountSwitcherService, + useValue: { + availableAccounts$: of(options.accounts || []), + SPECIAL_ADD_ACCOUNT_ID: "addAccount", + } as Partial, + }, { provide: AuthService, useValue: { @@ -300,3 +309,64 @@ export const DynamicContentExample: Story = { ], }), }; + +export const HasLoggedInAccountExample: Story = { + render: (args) => ({ + props: args, + template: "", + }), + decorators: decorators({ + components: [DefaultPrimaryOutletExampleComponent], + routes: [ + { + path: "**", + redirectTo: "has-logged-in-account", + pathMatch: "full", + }, + { + path: "", + component: ExtensionAnonLayoutWrapperComponent, + children: [ + { + path: "has-logged-in-account", + data: { + hasLoggedInAccount: true, + showAcctSwitcher: true, + }, + children: [ + { + path: "", + component: DefaultPrimaryOutletExampleComponent, + }, + { + path: "", + component: DefaultSecondaryOutletExampleComponent, + outlet: "secondary", + }, + { + path: "", + component: DefaultEnvSelectorOutletExampleComponent, + outlet: "environment-selector", + }, + ], + }, + ], + }, + ], + accounts: [ + { + name: "Test User", + email: "testuser@bitwarden.com", + id: "123e4567-e89b-12d3-a456-426614174000", + server: "bitwarden.com", + status: 2, + isActive: false, + }, + { + name: "addAccount", + id: "addAccount", + isActive: false, + }, + ], + }), +}; From 5a288b97dbfae96e7b228c42c0527760b3f78de3 Mon Sep 17 00:00:00 2001 From: Alec Rippberger <127791530+alec-livefront@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:23:38 -0600 Subject: [PATCH 16/20] [PM-14454] Add bit-menu-panel and bitmenuitem to environment selector dropdown (#11866) * Add bit-menu-panel class and bitmenuitem attribute * Add data-testids instead of class/attributes --- .../src/auth/components/environment-selector.component.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/angular/src/auth/components/environment-selector.component.html b/libs/angular/src/auth/components/environment-selector.component.html index 6a93e2a221a..786afe40371 100644 --- a/libs/angular/src/auth/components/environment-selector.component.html +++ b/libs/angular/src/auth/components/environment-selector.component.html @@ -38,18 +38,20 @@