mirror of
https://github.com/bitwarden/browser
synced 2026-02-19 10:54:00 +00:00
Tools/pm 29918/implement send auth flows (#18270)
* [PM-29918] Implement new Send auth flows * [PM-29918] Fix types * Trigger Claude code review * [PM-29918] Address PR review comments * [PM-29918] Remove duplicate AuthType const
This commit is contained in:
committed by
jaasen-livefront
parent
0f6e477b36
commit
9085ae20d5
@@ -1,3 +1,5 @@
|
||||
import { SendAccessToken } from "@bitwarden/common/auth/send-access";
|
||||
|
||||
import { ListResponse } from "../../../models/response/list.response";
|
||||
import { EncArrayBuffer } from "../../../platform/models/domain/enc-array-buffer";
|
||||
import { Send } from "../models/domain/send";
|
||||
@@ -16,6 +18,10 @@ export abstract class SendApiService {
|
||||
request: SendAccessRequest,
|
||||
apiUrl?: string,
|
||||
): Promise<SendAccessResponse>;
|
||||
abstract postSendAccessV2(
|
||||
accessToken: SendAccessToken,
|
||||
apiUrl?: string,
|
||||
): Promise<SendAccessResponse>;
|
||||
abstract getSends(): Promise<ListResponse<SendResponse>>;
|
||||
abstract postSend(request: SendRequest): Promise<SendResponse>;
|
||||
abstract postFileTypeSend(request: SendRequest): Promise<SendFileUploadDataResponse>;
|
||||
@@ -28,6 +34,11 @@ export abstract class SendApiService {
|
||||
request: SendAccessRequest,
|
||||
apiUrl?: string,
|
||||
): Promise<SendFileDownloadDataResponse>;
|
||||
abstract getSendFileDownloadDataV2(
|
||||
send: SendAccessView,
|
||||
accessToken: SendAccessToken,
|
||||
apiUrl?: string,
|
||||
): Promise<SendFileDownloadDataResponse>;
|
||||
abstract renewSendFileUploadUrl(
|
||||
sendId: string,
|
||||
fileId: string,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { SendAccessToken } from "@bitwarden/common/auth/send-access";
|
||||
|
||||
import { ApiService } from "../../../abstractions/api.service";
|
||||
import { ErrorResponse } from "../../../models/response/error.response";
|
||||
import { ListResponse } from "../../../models/response/list.response";
|
||||
@@ -52,6 +54,25 @@ export class SendApiService implements SendApiServiceAbstraction {
|
||||
return new SendAccessResponse(r);
|
||||
}
|
||||
|
||||
async postSendAccessV2(
|
||||
accessToken: SendAccessToken,
|
||||
apiUrl?: string,
|
||||
): Promise<SendAccessResponse> {
|
||||
const setAuthTokenHeader = (headers: Headers) => {
|
||||
headers.set("Authorization", "Bearer " + accessToken.token);
|
||||
};
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/sends/access",
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
apiUrl,
|
||||
setAuthTokenHeader,
|
||||
);
|
||||
return new SendAccessResponse(r);
|
||||
}
|
||||
|
||||
async getSendFileDownloadData(
|
||||
send: SendAccessView,
|
||||
request: SendAccessRequest,
|
||||
@@ -72,6 +93,26 @@ export class SendApiService implements SendApiServiceAbstraction {
|
||||
return new SendFileDownloadDataResponse(r);
|
||||
}
|
||||
|
||||
async getSendFileDownloadDataV2(
|
||||
send: SendAccessView,
|
||||
accessToken: SendAccessToken,
|
||||
apiUrl?: string,
|
||||
): Promise<SendFileDownloadDataResponse> {
|
||||
const setAuthTokenHeader = (headers: Headers) => {
|
||||
headers.set("Authorization", "Bearer " + accessToken.token);
|
||||
};
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/sends/access/file/" + send.file.id,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
apiUrl,
|
||||
setAuthTokenHeader,
|
||||
);
|
||||
return new SendFileDownloadDataResponse(r);
|
||||
}
|
||||
|
||||
async getSends(): Promise<ListResponse<SendResponse>> {
|
||||
const r = await this.apiService.send("GET", "/sends", null, true, true);
|
||||
return new ListResponse(r, SendResponse);
|
||||
|
||||
Reference in New Issue
Block a user