mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
* Implement a lazy value class This will be used as a source for composing key-protected storage from a single key source. * Simplify local-backed-session-storage The new implementation stores each value to a unique location, prefixed with `session_` to help indicate the purpose. I've also removed the complexity around session keys, favoring passing in a pre-defined value that is determined lazily once for the service worker. This is more in line with how I expect a key-protected storage would work. * Remove decrypted session flag This has been nothing but an annoyance. If it's ever added back, it needs to have some way to determine if the session key matches the one it was written with * Remove unnecessary string interpolation * Remove sync Lazy This is better done as a separate class. * Handle async through type * prefer two factory calls to incorrect value on races. * Fix type * Remove log * Update libs/common/src/platform/misc/lazy.ts Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import {
|
|
flagEnabled as baseFlagEnabled,
|
|
devFlagEnabled as baseDevFlagEnabled,
|
|
devFlagValue as baseDevFlagValue,
|
|
SharedFlags,
|
|
SharedDevFlags,
|
|
} from "@bitwarden/common/platform/misc/flags";
|
|
|
|
import { GroupPolicyEnvironment } from "../admin-console/types/group-policy-environment";
|
|
|
|
import { BrowserApi } from "./browser/browser-api";
|
|
|
|
// required to avoid linting errors when there are no flags
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
export type Flags = {
|
|
accountSwitching?: boolean;
|
|
} & SharedFlags;
|
|
|
|
// required to avoid linting errors when there are no flags
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
export type DevFlags = {
|
|
managedEnvironment?: GroupPolicyEnvironment;
|
|
} & SharedDevFlags;
|
|
|
|
export function flagEnabled(flag: keyof Flags): boolean {
|
|
return baseFlagEnabled<Flags>(flag);
|
|
}
|
|
|
|
export function devFlagEnabled(flag: keyof DevFlags) {
|
|
return baseDevFlagEnabled<DevFlags>(flag);
|
|
}
|
|
|
|
export function devFlagValue(flag: keyof DevFlags) {
|
|
return baseDevFlagValue(flag);
|
|
}
|
|
|
|
/** Helper method to sync flag specifically for account switching, which as platform-based values.
|
|
* If this pattern needs to be repeated, it's better handled by increasing complexity of webpack configurations
|
|
* Not by expanding these flag getters.
|
|
*/
|
|
export function enableAccountSwitching(): boolean {
|
|
if (BrowserApi.isSafariApi) {
|
|
return false;
|
|
}
|
|
return flagEnabled("accountSwitching");
|
|
}
|