mirror of
https://github.com/bitwarden/browser
synced 2026-02-18 10:23:52 +00:00
fix engine-settings desync error
This commit is contained in:
@@ -40,13 +40,13 @@
|
||||
</bit-card>
|
||||
<tools-password-settings
|
||||
class="tw-mt-6"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === 'password'"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === Algorithm.password"
|
||||
[account]="account$ | async"
|
||||
(onUpdated)="generate('password settings')"
|
||||
/>
|
||||
<tools-passphrase-settings
|
||||
class="tw-mt-6"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === 'passphrase'"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === Algorithm.passphrase"
|
||||
[account]="account$ | async"
|
||||
(onUpdated)="generate('passphrase settings')"
|
||||
/>
|
||||
@@ -82,7 +82,7 @@
|
||||
</bit-form-field>
|
||||
</form>
|
||||
<tools-catchall-settings
|
||||
*ngIf="(showAlgorithm$ | async)?.id === 'catchall'"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === Algorithm.catchall"
|
||||
[account]="account$ | async"
|
||||
(onUpdated)="generate('catchall settings')"
|
||||
/>
|
||||
@@ -92,12 +92,12 @@
|
||||
[forwarder]="forwarderId$ | async"
|
||||
/>
|
||||
<tools-subaddress-settings
|
||||
*ngIf="(showAlgorithm$ | async)?.id === 'subaddress'"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === Algorithm.plusAddress"
|
||||
[account]="account$ | async"
|
||||
(onUpdated)="generate('subaddress settings')"
|
||||
/>
|
||||
<tools-username-settings
|
||||
*ngIf="(showAlgorithm$ | async)?.id === 'username'"
|
||||
*ngIf="(showAlgorithm$ | async)?.id === Algorithm.username"
|
||||
[account]="account$ | async"
|
||||
(onUpdated)="generate('username settings')"
|
||||
/>
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
ReplaySubject,
|
||||
Subject,
|
||||
takeUntil,
|
||||
tap,
|
||||
withLatestFrom,
|
||||
} from "rxjs";
|
||||
|
||||
@@ -49,6 +50,7 @@ import {
|
||||
isPasswordAlgorithm,
|
||||
CredentialAlgorithm,
|
||||
AlgorithmMetadata,
|
||||
Algorithm,
|
||||
} from "@bitwarden/generator-core";
|
||||
import { GeneratorHistoryService } from "@bitwarden/generator-history";
|
||||
|
||||
@@ -79,6 +81,8 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
private ariaLive: LiveAnnouncer,
|
||||
) {}
|
||||
|
||||
protected readonly Algorithm = Algorithm;
|
||||
|
||||
/** Binds the component to a specific user's settings. When this input is not provided,
|
||||
* the form binds to the active user
|
||||
*/
|
||||
@@ -91,7 +95,7 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
* @warning this may reveal sensitive information in plaintext.
|
||||
*/
|
||||
@Input()
|
||||
debug: boolean = false;
|
||||
debug: boolean = true;
|
||||
|
||||
// this `log` initializer is overridden in `ngOnInit`
|
||||
private log: SemanticLogger = disabledSemanticLoggerProvider({});
|
||||
@@ -230,7 +234,9 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
// wire up the generator
|
||||
this.generatorService
|
||||
.generator$({
|
||||
on$: this.generate$,
|
||||
on$: this.generate$.pipe(
|
||||
tap((g) => this.log.debug(g, "generate request issued by component")),
|
||||
),
|
||||
account$: this.account$,
|
||||
})
|
||||
.pipe(
|
||||
@@ -290,7 +296,7 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
} else if (root.nav) {
|
||||
return { nav: root.nav, algorithm: JSON.parse(root.nav) };
|
||||
} else {
|
||||
this.log.panic(root, "unknown navigation value.");
|
||||
return { nav: IDENTIFIER };
|
||||
}
|
||||
}),
|
||||
takeUntil(this.destroyed),
|
||||
@@ -305,7 +311,7 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
} else if (username.nav) {
|
||||
return { nav: username.nav, algorithm: JSON.parse(username.nav) };
|
||||
} else {
|
||||
this.log.panic(username, "unknown navigation value.");
|
||||
return { nav: FORWARDER };
|
||||
}
|
||||
}),
|
||||
takeUntil(this.destroyed),
|
||||
|
||||
@@ -32,7 +32,7 @@ type MockTwoLevelPartial<T> = {
|
||||
: T[K];
|
||||
};
|
||||
|
||||
describe("CredentialGeneratorService", () => {
|
||||
describe("DefaultCredentialGeneratorService", () => {
|
||||
let service: DefaultCredentialGeneratorService;
|
||||
let providers: MockTwoLevelPartial<CredentialGeneratorProviders>;
|
||||
let system: any;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
EMPTY,
|
||||
concatMap,
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
@@ -60,12 +61,14 @@ export class DefaultCredentialGeneratorService implements CredentialGeneratorSer
|
||||
} else if (isTypeRequest(requested)) {
|
||||
return this.provide.metadata.preference$(requested.type, { account$ });
|
||||
} else {
|
||||
this.log.panic(requested, "algorithm or category required");
|
||||
this.log.warn(requested, "algorithm or category required");
|
||||
return EMPTY;
|
||||
}
|
||||
}),
|
||||
filter((algorithm): algorithm is CredentialAlgorithm => !!algorithm),
|
||||
distinctUntilChanged(),
|
||||
map((algorithm) => this.provide.metadata.metadata(algorithm)),
|
||||
distinctUntilChanged((previous, current) => previous.id === current.id),
|
||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
// load the active profile's algorithm settings
|
||||
@@ -84,9 +87,8 @@ export class DefaultCredentialGeneratorService implements CredentialGeneratorSer
|
||||
|
||||
// generation proper
|
||||
const generate$ = on$.pipe(
|
||||
withLatestReady(engine$),
|
||||
withLatestReady(settings$),
|
||||
concatMap(([[request, engine], settings]) => engine.generate(request, settings)),
|
||||
withLatestReady(settings$, engine$),
|
||||
concatMap(([request, settings, engine]) => engine.generate(request, settings)),
|
||||
takeUntil(anyComplete([settings$])),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user