mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-26 22:01:32 +01:00
[bug] Also check for a never lock timeout when determining where to pull tokens (#673)
This commit is contained in:
parent
eaf387435f
commit
e3b29a40d3
@ -151,20 +151,12 @@ export class StateService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getAccessToken(options?: StorageOptions): Promise<string> {
|
async getAccessToken(options?: StorageOptions): Promise<string> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
return (await this.getAccount(options))?.tokens?.accessToken;
|
return (await this.getAccount(options))?.tokens?.accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setAccessToken(value: string, options?: StorageOptions): Promise<void> {
|
async setAccessToken(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
const account = await this.getAccount(options);
|
const account = await this.getAccount(options);
|
||||||
account.tokens.accessToken = value;
|
account.tokens.accessToken = value;
|
||||||
await this.saveAccount(account, options);
|
await this.saveAccount(account, options);
|
||||||
@ -202,40 +194,24 @@ export class StateService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getApiKeyClientId(options?: StorageOptions): Promise<string> {
|
async getApiKeyClientId(options?: StorageOptions): Promise<string> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
return (await this.getAccount(options))?.profile?.apiKeyClientId;
|
return (await this.getAccount(options))?.profile?.apiKeyClientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setApiKeyClientId(value: string, options?: StorageOptions): Promise<void> {
|
async setApiKeyClientId(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
const account = await this.getAccount(options);
|
const account = await this.getAccount(options);
|
||||||
account.profile.apiKeyClientId = value;
|
account.profile.apiKeyClientId = value;
|
||||||
await this.saveAccount(account, options);
|
await this.saveAccount(account, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getApiKeyClientSecret(options?: StorageOptions): Promise<string> {
|
async getApiKeyClientSecret(options?: StorageOptions): Promise<string> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
return (await this.getAccount(options))?.keys?.apiKeyClientSecret;
|
return (await this.getAccount(options))?.keys?.apiKeyClientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setApiKeyClientSecret(value: string, options?: StorageOptions): Promise<void> {
|
async setApiKeyClientSecret(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
const account = await this.getAccount(options);
|
const account = await this.getAccount(options);
|
||||||
account.keys.apiKeyClientSecret = value;
|
account.keys.apiKeyClientSecret = value;
|
||||||
await this.saveAccount(account, options);
|
await this.saveAccount(account, options);
|
||||||
@ -1880,20 +1856,12 @@ export class StateService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getRefreshToken(options?: StorageOptions): Promise<string> {
|
async getRefreshToken(options?: StorageOptions): Promise<string> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
return (await this.getAccount(options))?.tokens?.refreshToken;
|
return (await this.getAccount(options))?.tokens?.refreshToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setRefreshToken(value: string, options?: StorageOptions): Promise<void> {
|
async setRefreshToken(value: string, options?: StorageOptions): Promise<void> {
|
||||||
const defaultOptions =
|
options = await this.getTimeoutBasedStorageOptions(options);
|
||||||
(await this.getVaultTimeoutAction({ userId: options?.userId })) === "logOut"
|
|
||||||
? this.defaultInMemoryOptions
|
|
||||||
: await this.defaultOnDiskOptions();
|
|
||||||
options = this.reconcileOptions(options, defaultOptions);
|
|
||||||
const account = await this.getAccount(options);
|
const account = await this.getAccount(options);
|
||||||
account.tokens.refreshToken = value;
|
account.tokens.refreshToken = value;
|
||||||
await this.saveAccount(account, options);
|
await this.saveAccount(account, options);
|
||||||
@ -2272,7 +2240,7 @@ export class StateService<
|
|||||||
await this.storageService.remove(keys.tempAccountSettings);
|
await this.storageService.remove(keys.tempAccountSettings);
|
||||||
}
|
}
|
||||||
account.settings.environmentUrls = environmentUrls;
|
account.settings.environmentUrls = environmentUrls;
|
||||||
if (account.settings.vaultTimeoutAction === "logOut") {
|
if (account.settings.vaultTimeoutAction === "logOut" && account.settings.vaultTimeout != null) {
|
||||||
account.tokens.accessToken = null;
|
account.tokens.accessToken = null;
|
||||||
account.tokens.refreshToken = null;
|
account.tokens.refreshToken = null;
|
||||||
account.profile.apiKeyClientId = null;
|
account.profile.apiKeyClientId = null;
|
||||||
@ -2497,4 +2465,14 @@ export class StateService<
|
|||||||
await this.setActiveUser(null);
|
await this.setActiveUser(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getTimeoutBasedStorageOptions(options?: StorageOptions): Promise<StorageOptions> {
|
||||||
|
const timeoutAction = await this.getVaultTimeoutAction({ userId: options?.userId });
|
||||||
|
const timeout = await this.getVaultTimeout({ userId: options?.userId });
|
||||||
|
const defaultOptions =
|
||||||
|
timeoutAction === "logOut" && timeout != null
|
||||||
|
? this.defaultInMemoryOptions
|
||||||
|
: await this.defaultOnDiskOptions();
|
||||||
|
return this.reconcileOptions(options, defaultOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user