1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

Merge branch 'feature/organization-domain-claiming' into feature/SG-680-create-domain-verification-comp

This commit is contained in:
Jared Snider
2022-12-12 12:02:38 -05:00
263 changed files with 12257 additions and 1061 deletions

View File

@@ -22,6 +22,7 @@ export class OrganizationData {
useScim: boolean;
useCustomPermissions: boolean;
useResetPassword: boolean;
useSecretsManager: boolean;
selfHost: boolean;
usersGetPremium: boolean;
seats: number;
@@ -63,6 +64,7 @@ export class OrganizationData {
this.useScim = response.useScim;
this.useCustomPermissions = response.useCustomPermissions;
this.useResetPassword = response.useResetPassword;
this.useSecretsManager = response.useSecretsManager;
this.selfHost = response.selfHost;
this.usersGetPremium = response.usersGetPremium;
this.seats = response.seats;

View File

@@ -24,6 +24,7 @@ export class Organization {
useScim: boolean;
useCustomPermissions: boolean;
useResetPassword: boolean;
useSecretsManager: boolean;
selfHost: boolean;
usersGetPremium: boolean;
seats: number;
@@ -69,6 +70,7 @@ export class Organization {
this.useScim = obj.useScim;
this.useCustomPermissions = obj.useCustomPermissions;
this.useResetPassword = obj.useResetPassword;
this.useSecretsManager = obj.useSecretsManager;
this.selfHost = obj.selfHost;
this.usersGetPremium = obj.usersGetPremium;
this.seats = obj.seats;
@@ -210,6 +212,10 @@ export class Organization {
return this.providerId != null || this.providerName != null;
}
get canAccessSecretsManager() {
return this.useSecretsManager;
}
static fromJSON(json: Jsonify<Organization>) {
if (json == null) {
return null;

View File

@@ -20,6 +20,7 @@ export class ProfileOrganizationResponse extends BaseResponse {
useScim: boolean;
useCustomPermissions: boolean;
useResetPassword: boolean;
useSecretsManager: boolean;
selfHost: boolean;
usersGetPremium: boolean;
seats: number;
@@ -62,6 +63,7 @@ export class ProfileOrganizationResponse extends BaseResponse {
this.useScim = this.getResponseProperty("UseScim") ?? false;
this.useCustomPermissions = this.getResponseProperty("UseCustomPermissions") ?? false;
this.useResetPassword = this.getResponseProperty("UseResetPassword");
this.useSecretsManager = this.getResponseProperty("UseSecretsManager");
this.selfHost = this.getResponseProperty("SelfHost");
this.usersGetPremium = this.getResponseProperty("UsersGetPremium");
this.seats = this.getResponseProperty("Seats");

View File

@@ -18,7 +18,7 @@ export class MemoryStorageService
}
async has(key: string): Promise<boolean> {
return this.get(key) != null;
return (await this.get(key)) != null;
}
save(key: string, obj: any): Promise<any> {

View File

@@ -79,7 +79,7 @@ export class StateService<
private hasBeenInited = false;
private isRecoveredSession = false;
private accountDiskCache = new Map<string, TAccount>();
protected accountDiskCache = new BehaviorSubject<Record<string, TAccount>>({});
// default account serializer, must be overridden by child class
protected accountDeserializer = Account.fromJSON as (json: Jsonify<TAccount>) => TAccount;
@@ -2383,7 +2383,7 @@ export class StateService<
}
if (this.useAccountCache) {
const cachedAccount = this.accountDiskCache.get(options.userId);
const cachedAccount = this.accountDiskCache.value[options.userId];
if (cachedAccount != null) {
return cachedAccount;
}
@@ -2397,9 +2397,7 @@ export class StateService<
))
: await this.storageService.get<TAccount>(options.userId, options);
if (this.useAccountCache) {
this.accountDiskCache.set(options.userId, account);
}
this.setDiskCache(options.userId, account);
return account;
}
@@ -2430,9 +2428,7 @@ export class StateService<
await storageLocation.save(`${options.userId}`, account, options);
if (this.useAccountCache) {
this.accountDiskCache.delete(options.userId);
}
this.deleteDiskCache(options.userId);
}
protected async saveAccountToMemory(account: TAccount): Promise<void> {
@@ -2643,9 +2639,7 @@ export class StateService<
userId = userId ?? state.activeUserId;
delete state.accounts[userId];
if (this.useAccountCache) {
this.accountDiskCache.delete(userId);
}
this.deleteDiskCache(userId);
return state;
});
@@ -2770,6 +2764,20 @@ export class StateService<
await this.setState(updatedState);
});
}
private setDiskCache(key: string, value: TAccount, options?: StorageOptions) {
if (this.useAccountCache) {
this.accountDiskCache.value[key] = value;
this.accountDiskCache.next(this.accountDiskCache.value);
}
}
private deleteDiskCache(key: string) {
if (this.useAccountCache) {
delete this.accountDiskCache.value[key];
this.accountDiskCache.next(this.accountDiskCache.value);
}
}
}
function withPrototypeForArrayMembers<T>(