1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-19 20:51:35 +01:00

Direct download for send (#288)

* Allow for responding with time-limited download URL

* Re-verify access on download link request
This commit is contained in:
Matt Gibson 2021-03-01 15:03:04 -06:00 committed by GitHub
parent 301ef455f3
commit 1324416784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 9 deletions

View File

@ -106,6 +106,7 @@ import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse'; import { ProfileResponse } from '../models/response/profileResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse'; import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
import { SendAccessResponse } from '../models/response/sendAccessResponse'; import { SendAccessResponse } from '../models/response/sendAccessResponse';
import { SendFileDownloadDataResponse } from '../models/response/sendFileDownloadDataResponse';
import { SendResponse } from '../models/response/sendResponse'; import { SendResponse } from '../models/response/sendResponse';
import { SubscriptionResponse } from '../models/response/subscriptionResponse'; import { SubscriptionResponse } from '../models/response/subscriptionResponse';
import { SyncResponse } from '../models/response/syncResponse'; import { SyncResponse } from '../models/response/syncResponse';
@ -123,6 +124,8 @@ import {
import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse'; import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse';
import { UserKeyResponse } from '../models/response/userKeyResponse'; import { UserKeyResponse } from '../models/response/userKeyResponse';
import { SendAccessView } from '../models/view/sendAccessView';
export abstract class ApiService { export abstract class ApiService {
urlsSet: boolean; urlsSet: boolean;
apiBaseUrl: string; apiBaseUrl: string;
@ -181,6 +184,7 @@ export abstract class ApiService {
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>;
getSendFileDownloadData: (send: SendAccessView, request: SendAccessRequest) => Promise<SendFileDownloadDataResponse>;
getCipher: (id: string) => Promise<CipherResponse>; getCipher: (id: string) => Promise<CipherResponse>;
getCipherAdmin: (id: string) => Promise<CipherResponse>; getCipherAdmin: (id: string) => Promise<CipherResponse>;

View File

@ -2,7 +2,6 @@ import { BaseResponse } from '../response/baseResponse';
export class SendFileApi extends BaseResponse { export class SendFileApi extends BaseResponse {
id: string; id: string;
url: string;
fileName: string; fileName: string;
key: string; key: string;
size: string; size: string;
@ -14,7 +13,6 @@ export class SendFileApi extends BaseResponse {
return; return;
} }
this.id = this.getResponseProperty('Id'); this.id = this.getResponseProperty('Id');
this.url = this.getResponseProperty('Url');
this.fileName = this.getResponseProperty('FileName'); this.fileName = this.getResponseProperty('FileName');
this.key = this.getResponseProperty('Key'); this.key = this.getResponseProperty('Key');
this.size = this.getResponseProperty('Size'); this.size = this.getResponseProperty('Size');

View File

@ -2,7 +2,6 @@ import { SendFileApi } from '../api/sendFileApi';
export class SendFileData { export class SendFileData {
id: string; id: string;
url: string;
fileName: string; fileName: string;
key: string; key: string;
size: string; size: string;
@ -14,7 +13,6 @@ export class SendFileData {
} }
this.id = data.id; this.id = data.id;
this.url = data.url;
this.fileName = data.fileName; this.fileName = data.fileName;
this.key = data.key; this.key = data.key;
this.size = data.size; this.size = data.size;

View File

@ -8,7 +8,6 @@ import { SendFileView } from '../view/sendFileView';
export class SendFile extends Domain { export class SendFile extends Domain {
id: string; id: string;
url: string;
size: string; size: string;
sizeName: string; sizeName: string;
fileName: CipherString; fileName: CipherString;
@ -22,10 +21,9 @@ export class SendFile extends Domain {
this.size = obj.size; this.size = obj.size;
this.buildDomainModel(this, obj, { this.buildDomainModel(this, obj, {
id: null, id: null,
url: null,
sizeName: null, sizeName: null,
fileName: null, fileName: null,
}, alreadyEncrypted, ['id', 'url', 'sizeName']); }, alreadyEncrypted, ['id', 'sizeName']);
} }
async decrypt(key: SymmetricCryptoKey): Promise<SendFileView> { async decrypt(key: SymmetricCryptoKey): Promise<SendFileView> {

View File

@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class SendFileDownloadDataResponse extends BaseResponse {
id: string = null;
url: string = null;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.url = this.getResponseProperty('Url');
}
}

View File

@ -4,7 +4,6 @@ import { SendFile } from '../domain/sendFile';
export class SendFileView implements View { export class SendFileView implements View {
id: string = null; id: string = null;
url: string = null;
size: string = null; size: string = null;
sizeName: string = null; sizeName: string = null;
fileName: string = null; fileName: string = null;
@ -15,7 +14,6 @@ export class SendFileView implements View {
} }
this.id = f.id; this.id = f.id;
this.url = f.url;
this.size = f.size; this.size = f.size;
this.sizeName = f.sizeName; this.sizeName = f.sizeName;
} }

View File

@ -112,6 +112,7 @@ import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse'; import { ProfileResponse } from '../models/response/profileResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse'; import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
import { SendAccessResponse } from '../models/response/sendAccessResponse'; import { SendAccessResponse } from '../models/response/sendAccessResponse';
import { SendFileDownloadDataResponse } from '../models/response/sendFileDownloadDataResponse';
import { SendResponse } from '../models/response/sendResponse'; import { SendResponse } from '../models/response/sendResponse';
import { SubscriptionResponse } from '../models/response/subscriptionResponse'; import { SubscriptionResponse } from '../models/response/subscriptionResponse';
import { SyncResponse } from '../models/response/syncResponse'; import { SyncResponse } from '../models/response/syncResponse';
@ -129,6 +130,8 @@ import {
import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse'; import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse';
import { UserKeyResponse } from '../models/response/userKeyResponse'; import { UserKeyResponse } from '../models/response/userKeyResponse';
import { SendAccessView } from '../models/view/sendAccessView';
export class ApiService implements ApiServiceAbstraction { export class ApiService implements ApiServiceAbstraction {
urlsSet: boolean = false; urlsSet: boolean = false;
apiBaseUrl: string; apiBaseUrl: string;
@ -416,6 +419,12 @@ export class ApiService implements ApiServiceAbstraction {
return new SendAccessResponse(r); return new SendAccessResponse(r);
} }
async getSendFileDownloadData(send: SendAccessView, request: SendAccessRequest): Promise<SendFileDownloadDataResponse> {
const r = await this.send('POST', '/sends/' + send.id + '/access/file/' + send.file.id, request, false, true);
return new SendFileDownloadDataResponse(r);
}
async getSends(): Promise<ListResponse<SendResponse>> { async getSends(): Promise<ListResponse<SendResponse>> {
const r = await this.send('GET', '/sends', null, true, true); const r = await this.send('GET', '/sends', null, true, true);
return new ListResponse(r, SendResponse); return new ListResponse(r, SendResponse);