2022-11-23 23:26:57 +01:00
|
|
|
import { Jsonify } from "type-fest";
|
|
|
|
|
2022-01-27 22:22:51 +01:00
|
|
|
import {
|
|
|
|
Account as BaseAccount,
|
|
|
|
AccountSettings as BaseAccountSettings,
|
2023-06-06 22:34:53 +02:00
|
|
|
} from "@bitwarden/common/platform/models/domain/account";
|
2022-01-27 22:22:51 +01:00
|
|
|
|
|
|
|
import { BrowserComponentState } from "./browserComponentState";
|
|
|
|
import { BrowserGroupingsComponentState } from "./browserGroupingsComponentState";
|
|
|
|
import { BrowserSendComponentState } from "./browserSendComponentState";
|
|
|
|
|
|
|
|
export class AccountSettings extends BaseAccountSettings {
|
2022-02-24 18:14:04 +01:00
|
|
|
vaultTimeout = -1; // On Restart
|
2022-11-23 23:26:57 +01:00
|
|
|
|
|
|
|
static fromJSON(json: Jsonify<AccountSettings>): AccountSettings {
|
|
|
|
if (json == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object.assign(new AccountSettings(), json, super.fromJSON(json));
|
|
|
|
}
|
2022-01-27 22:22:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Account extends BaseAccount {
|
|
|
|
settings?: AccountSettings = new AccountSettings();
|
|
|
|
groupings?: BrowserGroupingsComponentState;
|
|
|
|
send?: BrowserSendComponentState;
|
|
|
|
ciphers?: BrowserComponentState;
|
|
|
|
sendType?: BrowserComponentState;
|
|
|
|
|
|
|
|
constructor(init: Partial<Account>) {
|
|
|
|
super(init);
|
|
|
|
Object.assign(this.settings, {
|
|
|
|
...new AccountSettings(),
|
|
|
|
...this.settings,
|
|
|
|
});
|
|
|
|
this.groupings = init?.groupings ?? new BrowserGroupingsComponentState();
|
|
|
|
this.send = init?.send ?? new BrowserSendComponentState();
|
|
|
|
this.ciphers = init?.ciphers ?? new BrowserComponentState();
|
|
|
|
this.sendType = init?.sendType ?? new BrowserComponentState();
|
|
|
|
}
|
2022-11-23 23:26:57 +01:00
|
|
|
|
|
|
|
static fromJSON(json: Jsonify<Account>): Account {
|
|
|
|
if (json == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object.assign(new Account({}), json, super.fromJSON(json), {
|
|
|
|
settings: AccountSettings.fromJSON(json.settings),
|
|
|
|
groupings: BrowserGroupingsComponentState.fromJSON(json.groupings),
|
|
|
|
send: BrowserSendComponentState.fromJSON(json.send),
|
|
|
|
ciphers: BrowserComponentState.fromJSON(json.ciphers),
|
|
|
|
sendType: BrowserComponentState.fromJSON(json.sendType),
|
|
|
|
});
|
|
|
|
}
|
2022-01-27 22:22:51 +01:00
|
|
|
}
|