mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
[PM-16793] port credential generator service to providers (#14071)
* introduce extension service * deprecate legacy forwarder types * eliminate repeat algorithm emissions * extend logging to preference management * align forwarder ids with vendor ids * fix duplicate policy emissions; debugging required logger enhancements ----- Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
@@ -17,7 +15,7 @@ import { Account } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import {
|
||||
CredentialGeneratorService,
|
||||
EffUsernameGenerationOptions,
|
||||
Generators,
|
||||
BuiltIn,
|
||||
} from "@bitwarden/generator-core";
|
||||
|
||||
/** Options group for usernames */
|
||||
@@ -28,7 +26,6 @@ import {
|
||||
})
|
||||
export class UsernameSettingsComponent implements OnInit, OnChanges, OnDestroy {
|
||||
/** Instantiates the component
|
||||
* @param accountService queries user availability
|
||||
* @param generatorService settings and policy logic
|
||||
* @param formBuilder reactive form controls
|
||||
*/
|
||||
@@ -38,9 +35,11 @@ export class UsernameSettingsComponent implements OnInit, OnChanges, OnDestroy {
|
||||
) {}
|
||||
|
||||
/** Binds the component to a specific user's settings.
|
||||
* @remarks this is initialized to null but since it's a required input it'll
|
||||
* never have that value in practice.
|
||||
*/
|
||||
@Input({ required: true })
|
||||
account: Account;
|
||||
account: Account = null!;
|
||||
|
||||
protected account$ = new ReplaySubject<Account>(1);
|
||||
|
||||
@@ -53,19 +52,19 @@ export class UsernameSettingsComponent implements OnInit, OnChanges, OnDestroy {
|
||||
/** Emits settings updates and completes if the settings become unavailable.
|
||||
* @remarks this does not emit the initial settings. If you would like
|
||||
* to receive live settings updates including the initial update,
|
||||
* use `CredentialGeneratorService.settings$(...)` instead.
|
||||
* use `CredentialGeneratorService.settings(...)` instead.
|
||||
*/
|
||||
@Output()
|
||||
readonly onUpdated = new EventEmitter<EffUsernameGenerationOptions>();
|
||||
|
||||
/** The template's control bindings */
|
||||
protected settings = this.formBuilder.group({
|
||||
wordCapitalize: [Generators.username.settings.initial.wordCapitalize],
|
||||
wordIncludeNumber: [Generators.username.settings.initial.wordIncludeNumber],
|
||||
wordCapitalize: [false],
|
||||
wordIncludeNumber: [false],
|
||||
});
|
||||
|
||||
async ngOnInit() {
|
||||
const settings = await this.generatorService.settings(Generators.username, {
|
||||
const settings = await this.generatorService.settings(BuiltIn.effWordList, {
|
||||
account$: this.account$,
|
||||
});
|
||||
|
||||
@@ -79,7 +78,7 @@ export class UsernameSettingsComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.saveSettings
|
||||
.pipe(
|
||||
withLatestFrom(this.settings.valueChanges),
|
||||
map(([, settings]) => settings),
|
||||
map(([, settings]) => settings as EffUsernameGenerationOptions),
|
||||
takeUntil(this.destroyed$),
|
||||
)
|
||||
.subscribe(settings);
|
||||
|
||||
Reference in New Issue
Block a user