mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
[PM-27500] update cipher.service to align with sdk types (#17147)
This commit is contained in:
@@ -91,7 +91,7 @@ import { CipherShareRequest } from "../vault/models/request/cipher-share.request
|
|||||||
import { CipherRequest } from "../vault/models/request/cipher.request";
|
import { CipherRequest } from "../vault/models/request/cipher.request";
|
||||||
import { AttachmentUploadDataResponse } from "../vault/models/response/attachment-upload-data.response";
|
import { AttachmentUploadDataResponse } from "../vault/models/response/attachment-upload-data.response";
|
||||||
import { AttachmentResponse } from "../vault/models/response/attachment.response";
|
import { AttachmentResponse } from "../vault/models/response/attachment.response";
|
||||||
import { CipherResponse } from "../vault/models/response/cipher.response";
|
import { CipherMiniResponse, CipherResponse } from "../vault/models/response/cipher.response";
|
||||||
import { OptionalCipherResponse } from "../vault/models/response/optional-cipher.response";
|
import { OptionalCipherResponse } from "../vault/models/response/optional-cipher.response";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,7 +215,10 @@ export abstract class ApiService {
|
|||||||
id: string,
|
id: string,
|
||||||
request: CipherCollectionsRequest,
|
request: CipherCollectionsRequest,
|
||||||
): Promise<OptionalCipherResponse>;
|
): Promise<OptionalCipherResponse>;
|
||||||
abstract putCipherCollectionsAdmin(id: string, request: CipherCollectionsRequest): Promise<any>;
|
abstract putCipherCollectionsAdmin(
|
||||||
|
id: string,
|
||||||
|
request: CipherCollectionsRequest,
|
||||||
|
): Promise<CipherMiniResponse>;
|
||||||
abstract postPurgeCiphers(
|
abstract postPurgeCiphers(
|
||||||
request: SecretVerificationRequest,
|
request: SecretVerificationRequest,
|
||||||
organizationId?: string,
|
organizationId?: string,
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ import { SshKeyApi } from "../api/ssh-key.api";
|
|||||||
import { AttachmentResponse } from "./attachment.response";
|
import { AttachmentResponse } from "./attachment.response";
|
||||||
import { PasswordHistoryResponse } from "./password-history.response";
|
import { PasswordHistoryResponse } from "./password-history.response";
|
||||||
|
|
||||||
|
export type CipherMiniResponse = Omit<
|
||||||
|
CipherResponse,
|
||||||
|
"edit" | "viewPassword" | "folderId" | "favorite" | "permissions"
|
||||||
|
>;
|
||||||
|
|
||||||
export class CipherResponse extends BaseResponse {
|
export class CipherResponse extends BaseResponse {
|
||||||
id: string;
|
id: string;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
|
|||||||
@@ -1117,7 +1117,13 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
async saveCollectionsWithServerAdmin(cipher: Cipher): Promise<Cipher> {
|
async saveCollectionsWithServerAdmin(cipher: Cipher): Promise<Cipher> {
|
||||||
const request = new CipherCollectionsRequest(cipher.collectionIds);
|
const request = new CipherCollectionsRequest(cipher.collectionIds);
|
||||||
const response = await this.apiService.putCipherCollectionsAdmin(cipher.id, request);
|
const response = await this.apiService.putCipherCollectionsAdmin(cipher.id, request);
|
||||||
const data = new CipherData(response);
|
// The response will be incomplete with several properties missing values
|
||||||
|
// We will assign those properties values so the SDK decryption can complete
|
||||||
|
const completedResponse = new CipherResponse(response);
|
||||||
|
completedResponse.edit = true;
|
||||||
|
completedResponse.viewPassword = true;
|
||||||
|
completedResponse.favorite = false;
|
||||||
|
const data = new CipherData(completedResponse);
|
||||||
return new Cipher(data);
|
return new Cipher(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user