1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

Refactored fido2 popup to use auth guard when routing to component, added BrowserRouterService to track previous page and route using that

This commit is contained in:
gbubemismith
2023-09-04 15:29:48 -04:00
parent 43db7f6d60
commit c204c70e6b
6 changed files with 123 additions and 4 deletions

View File

@@ -524,4 +524,17 @@ export abstract class StateService<T extends Account = Account> {
value: Record<string, Record<string, boolean>>,
options?: StorageOptions
) => Promise<void>;
/**
* fetches string value of the URL stored here, usually only called after SSO flows.
* @param options Defines the storage options for the URL; Defaults to Local Storage.
* @returns route called prior to SSO routing to organizations configured IdP.
*/
getPreviousUrl: (options?: StorageOptions) => Promise<string>;
/**
* Store URL in local storage by default, but can be configured. Developed to handle
* SSO routing to organizations configured IdP.
* @param url URL of route
* @param options Defines the storage options for the URL; Defaults to Local Storage.
*/
setPreviousUrl: (url: string, options?: StorageOptions) => Promise<void>;
}

View File

@@ -37,4 +37,5 @@ export class GlobalState {
enableBrowserIntegrationFingerprint?: boolean;
enableDuckDuckGoBrowserIntegration?: boolean;
region?: string;
previousUrl?: string;
}

View File

@@ -2828,6 +2828,23 @@ export class StateService<
);
}
async getPreviousUrl(options?: StorageOptions): Promise<string> {
return (
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
)?.previousUrl;
}
async setPreviousUrl(url: string, options?: StorageOptions): Promise<void> {
const globals = await this.getGlobals(
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
);
globals.previousUrl = url;
await this.saveGlobals(
globals,
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
);
}
protected async getGlobals(options: StorageOptions): Promise<TGlobalState> {
let globals: TGlobalState;
if (this.useMemory(options.storageLocation)) {