mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-01 23:01:28 +01:00
PM-16170 remove methods using deprecated send endpoints (#12751)
This commit is contained in:
parent
f44b36bdf6
commit
8621e8aa6a
@ -22,11 +22,6 @@ export abstract class SendApiService {
|
|||||||
postSend: (request: SendRequest) => Promise<SendResponse>;
|
postSend: (request: SendRequest) => Promise<SendResponse>;
|
||||||
postFileTypeSend: (request: SendRequest) => Promise<SendFileUploadDataResponse>;
|
postFileTypeSend: (request: SendRequest) => Promise<SendFileUploadDataResponse>;
|
||||||
postSendFile: (sendId: string, fileId: string, data: FormData) => Promise<any>;
|
postSendFile: (sendId: string, fileId: string, data: FormData) => Promise<any>;
|
||||||
/**
|
|
||||||
* @deprecated Mar 25 2021: This method has been deprecated in favor of direct uploads.
|
|
||||||
* This method still exists for backward compatibility with old server versions.
|
|
||||||
*/
|
|
||||||
postSendFileLegacy: (data: FormData) => Promise<SendResponse>;
|
|
||||||
putSend: (id: string, request: SendRequest) => Promise<SendResponse>;
|
putSend: (id: string, request: SendRequest) => Promise<SendResponse>;
|
||||||
putSendRemovePassword: (id: string) => Promise<SendResponse>;
|
putSendRemovePassword: (id: string) => Promise<SendResponse>;
|
||||||
deleteSend: (id: string) => Promise<any>;
|
deleteSend: (id: string) => Promise<any>;
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
FileUploadApiMethods,
|
FileUploadApiMethods,
|
||||||
FileUploadService,
|
FileUploadService,
|
||||||
} from "../../../platform/abstractions/file-upload/file-upload.service";
|
} from "../../../platform/abstractions/file-upload/file-upload.service";
|
||||||
import { Utils } from "../../../platform/misc/utils";
|
|
||||||
import { EncArrayBuffer } from "../../../platform/models/domain/enc-array-buffer";
|
import { EncArrayBuffer } from "../../../platform/models/domain/enc-array-buffer";
|
||||||
import { SendType } from "../enums/send-type";
|
import { SendType } from "../enums/send-type";
|
||||||
import { SendData } from "../models/data/send.data";
|
import { SendData } from "../models/data/send.data";
|
||||||
@ -106,15 +105,6 @@ export class SendApiService implements SendApiServiceAbstraction {
|
|||||||
return this.apiService.send("POST", "/sends/" + sendId + "/file/" + fileId, data, true, false);
|
return this.apiService.send("POST", "/sends/" + sendId + "/file/" + fileId, data, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Mar 25 2021: This method has been deprecated in favor of direct uploads.
|
|
||||||
* This method still exists for backward compatibility with old server versions.
|
|
||||||
*/
|
|
||||||
async postSendFileLegacy(data: FormData): Promise<SendResponse> {
|
|
||||||
const r = await this.apiService.send("POST", "/sends/file", data, true, true);
|
|
||||||
return new SendResponse(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
async putSend(id: string, request: SendRequest): Promise<SendResponse> {
|
async putSend(id: string, request: SendRequest): Promise<SendResponse> {
|
||||||
const r = await this.apiService.send("PUT", "/sends/" + id, request, true, true);
|
const r = await this.apiService.send("PUT", "/sends/" + id, request, true, true);
|
||||||
return new SendResponse(r);
|
return new SendResponse(r);
|
||||||
@ -173,9 +163,7 @@ export class SendApiService implements SendApiServiceAbstraction {
|
|||||||
this.generateMethods(uploadDataResponse, response),
|
this.generateMethods(uploadDataResponse, response),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ErrorResponse && (e as ErrorResponse).statusCode === 404) {
|
if (e instanceof ErrorResponse) {
|
||||||
response = await this.legacyServerSendFileUpload(sendData, request);
|
|
||||||
} else if (e instanceof ErrorResponse) {
|
|
||||||
throw new Error((e as ErrorResponse).getSingleMessage());
|
throw new Error((e as ErrorResponse).getSingleMessage());
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
@ -219,35 +207,4 @@ export class SendApiService implements SendApiServiceAbstraction {
|
|||||||
return this.deleteSend(sendId);
|
return this.deleteSend(sendId);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Mar 25 2021: This method has been deprecated in favor of direct uploads.
|
|
||||||
* This method still exists for backward compatibility with old server versions.
|
|
||||||
*/
|
|
||||||
async legacyServerSendFileUpload(
|
|
||||||
sendData: [Send, EncArrayBuffer],
|
|
||||||
request: SendRequest,
|
|
||||||
): Promise<SendResponse> {
|
|
||||||
const fd = new FormData();
|
|
||||||
try {
|
|
||||||
const blob = new Blob([sendData[1].buffer], { type: "application/octet-stream" });
|
|
||||||
fd.append("model", JSON.stringify(request));
|
|
||||||
fd.append("data", blob, sendData[0].file.fileName.encryptedString);
|
|
||||||
} catch (e) {
|
|
||||||
if (Utils.isNode && !Utils.isBrowser) {
|
|
||||||
fd.append("model", JSON.stringify(request));
|
|
||||||
fd.append(
|
|
||||||
"data",
|
|
||||||
Buffer.from(sendData[1].buffer) as any,
|
|
||||||
{
|
|
||||||
filepath: sendData[0].file.fileName.encryptedString,
|
|
||||||
contentType: "application/octet-stream",
|
|
||||||
} as any,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await this.postSendFileLegacy(fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user