mirror of
https://github.com/bitwarden/browser.git
synced 2024-08-25 23:03:07 +02:00
allow original cipher to be passed during encrypt
This commit is contained in:
parent
d56c5ff4f1
commit
f16fc58d70
|
@ -14,7 +14,7 @@ export abstract class CipherService {
|
||||||
decryptedCipherCache: CipherView[];
|
decryptedCipherCache: CipherView[];
|
||||||
|
|
||||||
clearCache: () => void;
|
clearCache: () => void;
|
||||||
encrypt: (model: CipherView, key?: SymmetricCryptoKey) => Promise<Cipher>;
|
encrypt: (model: CipherView, key?: SymmetricCryptoKey, originalCipher?: Cipher) => Promise<Cipher>;
|
||||||
encryptFields: (fieldsModel: FieldView[], key: SymmetricCryptoKey) => Promise<Field[]>;
|
encryptFields: (fieldsModel: FieldView[], key: SymmetricCryptoKey) => Promise<Field[]>;
|
||||||
encryptField: (fieldModel: FieldView, key: SymmetricCryptoKey) => Promise<Field>;
|
encryptField: (fieldModel: FieldView, key: SymmetricCryptoKey) => Promise<Field>;
|
||||||
get: (id: string) => Promise<Cipher>;
|
get: (id: string) => Promise<Cipher>;
|
||||||
|
|
|
@ -80,11 +80,14 @@ export class CipherService implements CipherServiceAbstraction {
|
||||||
this.decryptedCipherCache = null;
|
this.decryptedCipherCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async encrypt(model: CipherView, key?: SymmetricCryptoKey): Promise<Cipher> {
|
async encrypt(model: CipherView, key?: SymmetricCryptoKey, originalCipher: Cipher = null): Promise<Cipher> {
|
||||||
// Adjust password history
|
// Adjust password history
|
||||||
if (model.id != null) {
|
if (model.id != null) {
|
||||||
const existingCipher = await (await this.get(model.id)).decrypt();
|
if (originalCipher == null) {
|
||||||
if (existingCipher != null) {
|
originalCipher = await this.get(model.id);
|
||||||
|
}
|
||||||
|
if (originalCipher != null) {
|
||||||
|
const existingCipher = await originalCipher.decrypt();
|
||||||
model.passwordHistory = existingCipher.passwordHistory || [];
|
model.passwordHistory = existingCipher.passwordHistory || [];
|
||||||
if (model.type === CipherType.Login && existingCipher.type === CipherType.Login) {
|
if (model.type === CipherType.Login && existingCipher.type === CipherType.Login) {
|
||||||
if (existingCipher.login.password != null && existingCipher.login.password !== '' &&
|
if (existingCipher.login.password != null && existingCipher.login.password !== '' &&
|
||||||
|
|
Loading…
Reference in New Issue
Block a user