mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +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,
|
||||
@@ -13,10 +11,10 @@ import {
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
import { map, ReplaySubject, skip, Subject, takeUntil, withLatestFrom } from "rxjs";
|
||||
|
||||
import { Account, AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { Account } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import {
|
||||
CredentialGeneratorService,
|
||||
Generators,
|
||||
BuiltIn,
|
||||
SubaddressGenerationOptions,
|
||||
} from "@bitwarden/generator-core";
|
||||
|
||||
@@ -28,20 +26,20 @@ import {
|
||||
})
|
||||
export class SubaddressSettingsComponent implements OnInit, OnChanges, OnDestroy {
|
||||
/** Instantiates the component
|
||||
* @param accountService queries user availability
|
||||
* @param generatorService settings and policy logic
|
||||
* @param formBuilder reactive form controls
|
||||
*/
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private generatorService: CredentialGeneratorService,
|
||||
private accountService: AccountService,
|
||||
) {}
|
||||
|
||||
/** 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);
|
||||
|
||||
@@ -54,18 +52,18 @@ export class SubaddressSettingsComponent 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<SubaddressGenerationOptions>();
|
||||
|
||||
/** The template's control bindings */
|
||||
protected settings = this.formBuilder.group({
|
||||
subaddressEmail: [Generators.subaddress.settings.initial.subaddressEmail],
|
||||
subaddressEmail: [""],
|
||||
});
|
||||
|
||||
async ngOnInit() {
|
||||
const settings = await this.generatorService.settings(Generators.subaddress, {
|
||||
const settings = await this.generatorService.settings(BuiltIn.plusAddress, {
|
||||
account$: this.account$,
|
||||
});
|
||||
|
||||
@@ -79,7 +77,7 @@ export class SubaddressSettingsComponent implements OnInit, OnChanges, OnDestroy
|
||||
this.saveSettings
|
||||
.pipe(
|
||||
withLatestFrom(this.settings.valueChanges),
|
||||
map(([, settings]) => settings),
|
||||
map(([, settings]) => settings as SubaddressGenerationOptions),
|
||||
takeUntil(this.destroyed$),
|
||||
)
|
||||
.subscribe(settings);
|
||||
|
||||
Reference in New Issue
Block a user