mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
move sso properties to globalstate (#583)
* move sso properties to globalstate * whitespace * npm prettier changes
This commit is contained in:
@@ -95,9 +95,6 @@ export class AccountProfile {
|
|||||||
hasPremiumPersonally?: boolean;
|
hasPremiumPersonally?: boolean;
|
||||||
lastActive?: number;
|
lastActive?: number;
|
||||||
lastSync?: string;
|
lastSync?: string;
|
||||||
ssoCodeVerifier?: string;
|
|
||||||
ssoOrganizationIdentifier?: string;
|
|
||||||
ssoState?: string;
|
|
||||||
userId?: string;
|
userId?: string;
|
||||||
usesKeyConnector?: boolean;
|
usesKeyConnector?: boolean;
|
||||||
keyHash?: string;
|
keyHash?: string;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ export class GlobalState {
|
|||||||
locale?: string;
|
locale?: string;
|
||||||
openAtLogin?: boolean;
|
openAtLogin?: boolean;
|
||||||
organizationInvitation?: any;
|
organizationInvitation?: any;
|
||||||
|
ssoCodeVerifier?: string;
|
||||||
|
ssoOrganizationIdentifier?: string;
|
||||||
|
ssoState?: string;
|
||||||
rememberedEmail?: string;
|
rememberedEmail?: string;
|
||||||
theme?: string;
|
theme?: string;
|
||||||
window?: Map<string, any> = new Map<string, any>();
|
window?: Map<string, any> = new Map<string, any>();
|
||||||
|
|||||||
@@ -1874,46 +1874,54 @@ export class StateService implements StateServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSsoCodeVerifier(options?: StorageOptions): Promise<string> {
|
async getSsoCodeVerifier(options?: StorageOptions): Promise<string> {
|
||||||
return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
|
return (
|
||||||
?.profile?.ssoCodeVerifier;
|
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskOptions()))
|
||||||
|
)?.ssoCodeVerifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSsoCodeVerifier(value: string, options?: StorageOptions): Promise<void> {
|
async setSsoCodeVerifier(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const account = await this.getAccount(
|
const globals = await this.getGlobals(
|
||||||
this.reconcileOptions(options, this.defaultInMemoryOptions)
|
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||||
|
);
|
||||||
|
globals.ssoCodeVerifier = value;
|
||||||
|
await this.saveGlobals(
|
||||||
|
globals,
|
||||||
|
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||||
);
|
);
|
||||||
account.profile.ssoCodeVerifier = value;
|
|
||||||
await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSsoOrgIdentifier(options?: StorageOptions): Promise<string> {
|
async getSsoOrgIdentifier(options?: StorageOptions): Promise<string> {
|
||||||
return (
|
return (
|
||||||
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||||
)?.profile?.ssoOrganizationIdentifier;
|
)?.ssoOrganizationIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSsoOrganizationIdentifier(value: string, options?: StorageOptions): Promise<void> {
|
async setSsoOrganizationIdentifier(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const account = await this.getAccount(
|
const globals = await this.getGlobals(
|
||||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||||
);
|
);
|
||||||
account.profile.ssoOrganizationIdentifier = value;
|
globals.ssoOrganizationIdentifier = value;
|
||||||
await this.saveAccount(
|
await this.saveGlobals(
|
||||||
account,
|
globals,
|
||||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSsoState(options?: StorageOptions): Promise<string> {
|
async getSsoState(options?: StorageOptions): Promise<string> {
|
||||||
return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
|
return (
|
||||||
?.profile?.ssoState;
|
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskOptions()))
|
||||||
|
)?.ssoState;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSsoState(value: string, options?: StorageOptions): Promise<void> {
|
async setSsoState(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const account = await this.getAccount(
|
const globals = await this.getGlobals(
|
||||||
this.reconcileOptions(options, this.defaultInMemoryOptions)
|
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||||
|
);
|
||||||
|
globals.ssoState = value;
|
||||||
|
await this.saveGlobals(
|
||||||
|
globals,
|
||||||
|
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||||
);
|
);
|
||||||
account.profile.ssoState = value;
|
|
||||||
await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTheme(options?: StorageOptions): Promise<string> {
|
async getTheme(options?: StorageOptions): Promise<string> {
|
||||||
|
|||||||
@@ -192,6 +192,15 @@ export class StateMigrationService {
|
|||||||
),
|
),
|
||||||
openAtLogin: await this.storageService.get<boolean>(v1Keys.openAtLogin, options),
|
openAtLogin: await this.storageService.get<boolean>(v1Keys.openAtLogin, options),
|
||||||
organizationInvitation: await this.storageService.get<string>("", options),
|
organizationInvitation: await this.storageService.get<string>("", options),
|
||||||
|
ssoCodeVerifier: await this.storageService.get<string>(
|
||||||
|
v1Keys.ssoCodeVerifier,
|
||||||
|
options
|
||||||
|
),
|
||||||
|
ssoOrganizationIdentifier: await this.storageService.get<string>(
|
||||||
|
v1Keys.ssoIdentifier,
|
||||||
|
options
|
||||||
|
),
|
||||||
|
ssoState: null,
|
||||||
rememberedEmail: await this.storageService.get<string>(
|
rememberedEmail: await this.storageService.get<string>(
|
||||||
v1Keys.rememberedEmail,
|
v1Keys.rememberedEmail,
|
||||||
options
|
options
|
||||||
@@ -327,15 +336,6 @@ export class StateMigrationService {
|
|||||||
keyHash: await this.storageService.get<string>(v1Keys.keyHash, options),
|
keyHash: await this.storageService.get<string>(v1Keys.keyHash, options),
|
||||||
lastActive: await this.storageService.get<number>(v1Keys.lastActive, options),
|
lastActive: await this.storageService.get<number>(v1Keys.lastActive, options),
|
||||||
lastSync: null,
|
lastSync: null,
|
||||||
ssoCodeVerifier: await this.storageService.get<string>(
|
|
||||||
v1Keys.ssoCodeVerifier,
|
|
||||||
options
|
|
||||||
),
|
|
||||||
ssoOrganizationIdentifier: await this.storageService.get<string>(
|
|
||||||
v1Keys.ssoIdentifier,
|
|
||||||
options
|
|
||||||
),
|
|
||||||
ssoState: null,
|
|
||||||
userId: userId,
|
userId: userId,
|
||||||
usesKeyConnector: null,
|
usesKeyConnector: null,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user