mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
fixed merge conflict
This commit is contained in:
@@ -520,9 +520,12 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
await this.stateService.setNeverDomains(domains);
|
||||
}
|
||||
|
||||
async createWithServer(cipher: Cipher): Promise<any> {
|
||||
async createWithServer(cipher: Cipher, orgAdmin?: boolean): Promise<any> {
|
||||
let response: CipherResponse;
|
||||
if (cipher.collectionIds != null) {
|
||||
if (orgAdmin) {
|
||||
const request = new CipherCreateRequest(cipher);
|
||||
response = await this.apiService.postCipherAdmin(request);
|
||||
} else if (cipher.collectionIds != null) {
|
||||
const request = new CipherCreateRequest(cipher);
|
||||
response = await this.apiService.postCipherCreate(request);
|
||||
} else {
|
||||
@@ -535,9 +538,12 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
await this.upsert(data);
|
||||
}
|
||||
|
||||
async updateWithServer(cipher: Cipher): Promise<any> {
|
||||
async updateWithServer(cipher: Cipher, orgAdmin?: boolean, isNotClone?: boolean): Promise<any> {
|
||||
let response: CipherResponse;
|
||||
if (cipher.edit) {
|
||||
if (orgAdmin && isNotClone) {
|
||||
const request = new CipherRequest(cipher);
|
||||
response = await this.apiService.putCipherAdmin(cipher.id, request);
|
||||
} else if (cipher.edit) {
|
||||
const request = new CipherRequest(cipher);
|
||||
response = await this.apiService.putCipher(cipher.id, request);
|
||||
} else {
|
||||
@@ -638,7 +644,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
const encFileName = await this.cryptoService.encrypt(filename, key);
|
||||
|
||||
const dataEncKey = await this.cryptoService.makeEncKey(key);
|
||||
const encData = await this.cryptoService.encryptToBytes(data, dataEncKey[0]);
|
||||
const encData = await this.cryptoService.encryptToBytes(new Uint8Array(data), dataEncKey[0]);
|
||||
|
||||
const response = await this.cipherFileUploadService.upload(
|
||||
cipher,
|
||||
@@ -741,10 +747,11 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
|
||||
async deleteManyWithServer(ids: string[], asAdmin = false): Promise<any> {
|
||||
const request = new CipherBulkDeleteRequest(ids);
|
||||
if (asAdmin) {
|
||||
await this.apiService.deleteManyCiphersAdmin(new CipherBulkDeleteRequest(ids));
|
||||
await this.apiService.deleteManyCiphersAdmin(request);
|
||||
} else {
|
||||
await this.apiService.deleteManyCiphers(new CipherBulkDeleteRequest(ids));
|
||||
await this.apiService.deleteManyCiphers(request);
|
||||
}
|
||||
await this.delete(ids);
|
||||
}
|
||||
@@ -880,10 +887,11 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
|
||||
async softDeleteManyWithServer(ids: string[], asAdmin = false): Promise<any> {
|
||||
const request = new CipherBulkDeleteRequest(ids);
|
||||
if (asAdmin) {
|
||||
await this.apiService.putDeleteManyCiphersAdmin(new CipherBulkDeleteRequest(ids));
|
||||
await this.apiService.putDeleteManyCiphersAdmin(request);
|
||||
} else {
|
||||
await this.apiService.putDeleteManyCiphers(new CipherBulkDeleteRequest(ids));
|
||||
await this.apiService.putDeleteManyCiphers(request);
|
||||
}
|
||||
|
||||
await this.softDelete(ids);
|
||||
@@ -916,14 +924,30 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
|
||||
async restoreWithServer(id: string, asAdmin = false): Promise<any> {
|
||||
const response = asAdmin
|
||||
? await this.apiService.putRestoreCipherAdmin(id)
|
||||
: await this.apiService.putRestoreCipher(id);
|
||||
let response;
|
||||
if (asAdmin) {
|
||||
response = await this.apiService.putRestoreCipherAdmin(id);
|
||||
} else {
|
||||
response = await this.apiService.putRestoreCipher(id);
|
||||
}
|
||||
|
||||
await this.restore({ id: id, revisionDate: response.revisionDate });
|
||||
}
|
||||
|
||||
async restoreManyWithServer(ids: string[]): Promise<any> {
|
||||
const response = await this.apiService.putRestoreManyCiphers(new CipherBulkRestoreRequest(ids));
|
||||
async restoreManyWithServer(
|
||||
ids: string[],
|
||||
organizationId: string = null,
|
||||
asAdmin = false
|
||||
): Promise<void> {
|
||||
let response;
|
||||
if (asAdmin) {
|
||||
const request = new CipherBulkRestoreRequest(ids, organizationId);
|
||||
response = await this.apiService.putRestoreManyCiphersAdmin(request);
|
||||
} else {
|
||||
const request = new CipherBulkRestoreRequest(ids);
|
||||
response = await this.apiService.putRestoreManyCiphers(request);
|
||||
}
|
||||
|
||||
const restores: { id: string; revisionDate: string }[] = [];
|
||||
for (const cipher of response.data) {
|
||||
restores.push({ id: cipher.id, revisionDate: cipher.revisionDate });
|
||||
|
||||
Reference in New Issue
Block a user