mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-18 20:41:31 +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:
parent
301ef455f3
commit
1324416784
@ -106,6 +106,7 @@ import { PreloginResponse } from '../models/response/preloginResponse';
|
||||
import { ProfileResponse } from '../models/response/profileResponse';
|
||||
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
|
||||
import { SendAccessResponse } from '../models/response/sendAccessResponse';
|
||||
import { SendFileDownloadDataResponse } from '../models/response/sendFileDownloadDataResponse';
|
||||
import { SendResponse } from '../models/response/sendResponse';
|
||||
import { SubscriptionResponse } from '../models/response/subscriptionResponse';
|
||||
import { SyncResponse } from '../models/response/syncResponse';
|
||||
@ -123,6 +124,8 @@ import {
|
||||
import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse';
|
||||
import { UserKeyResponse } from '../models/response/userKeyResponse';
|
||||
|
||||
import { SendAccessView } from '../models/view/sendAccessView';
|
||||
|
||||
export abstract class ApiService {
|
||||
urlsSet: boolean;
|
||||
apiBaseUrl: string;
|
||||
@ -181,6 +184,7 @@ export abstract class ApiService {
|
||||
putSend: (id: string, request: SendRequest) => Promise<SendResponse>;
|
||||
putSendRemovePassword: (id: string) => Promise<SendResponse>;
|
||||
deleteSend: (id: string) => Promise<any>;
|
||||
getSendFileDownloadData: (send: SendAccessView, request: SendAccessRequest) => Promise<SendFileDownloadDataResponse>;
|
||||
|
||||
getCipher: (id: string) => Promise<CipherResponse>;
|
||||
getCipherAdmin: (id: string) => Promise<CipherResponse>;
|
||||
|
@ -2,7 +2,6 @@ import { BaseResponse } from '../response/baseResponse';
|
||||
|
||||
export class SendFileApi extends BaseResponse {
|
||||
id: string;
|
||||
url: string;
|
||||
fileName: string;
|
||||
key: string;
|
||||
size: string;
|
||||
@ -14,7 +13,6 @@ export class SendFileApi extends BaseResponse {
|
||||
return;
|
||||
}
|
||||
this.id = this.getResponseProperty('Id');
|
||||
this.url = this.getResponseProperty('Url');
|
||||
this.fileName = this.getResponseProperty('FileName');
|
||||
this.key = this.getResponseProperty('Key');
|
||||
this.size = this.getResponseProperty('Size');
|
||||
|
@ -2,7 +2,6 @@ import { SendFileApi } from '../api/sendFileApi';
|
||||
|
||||
export class SendFileData {
|
||||
id: string;
|
||||
url: string;
|
||||
fileName: string;
|
||||
key: string;
|
||||
size: string;
|
||||
@ -14,7 +13,6 @@ export class SendFileData {
|
||||
}
|
||||
|
||||
this.id = data.id;
|
||||
this.url = data.url;
|
||||
this.fileName = data.fileName;
|
||||
this.key = data.key;
|
||||
this.size = data.size;
|
||||
|
@ -8,7 +8,6 @@ import { SendFileView } from '../view/sendFileView';
|
||||
|
||||
export class SendFile extends Domain {
|
||||
id: string;
|
||||
url: string;
|
||||
size: string;
|
||||
sizeName: string;
|
||||
fileName: CipherString;
|
||||
@ -22,10 +21,9 @@ export class SendFile extends Domain {
|
||||
this.size = obj.size;
|
||||
this.buildDomainModel(this, obj, {
|
||||
id: null,
|
||||
url: null,
|
||||
sizeName: null,
|
||||
fileName: null,
|
||||
}, alreadyEncrypted, ['id', 'url', 'sizeName']);
|
||||
}, alreadyEncrypted, ['id', 'sizeName']);
|
||||
}
|
||||
|
||||
async decrypt(key: SymmetricCryptoKey): Promise<SendFileView> {
|
||||
|
12
src/models/response/sendFileDownloadDataResponse.ts
Normal file
12
src/models/response/sendFileDownloadDataResponse.ts
Normal 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');
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import { SendFile } from '../domain/sendFile';
|
||||
|
||||
export class SendFileView implements View {
|
||||
id: string = null;
|
||||
url: string = null;
|
||||
size: string = null;
|
||||
sizeName: string = null;
|
||||
fileName: string = null;
|
||||
@ -15,7 +14,6 @@ export class SendFileView implements View {
|
||||
}
|
||||
|
||||
this.id = f.id;
|
||||
this.url = f.url;
|
||||
this.size = f.size;
|
||||
this.sizeName = f.sizeName;
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ import { PreloginResponse } from '../models/response/preloginResponse';
|
||||
import { ProfileResponse } from '../models/response/profileResponse';
|
||||
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
|
||||
import { SendAccessResponse } from '../models/response/sendAccessResponse';
|
||||
import { SendFileDownloadDataResponse } from '../models/response/sendFileDownloadDataResponse';
|
||||
import { SendResponse } from '../models/response/sendResponse';
|
||||
import { SubscriptionResponse } from '../models/response/subscriptionResponse';
|
||||
import { SyncResponse } from '../models/response/syncResponse';
|
||||
@ -129,6 +130,8 @@ import {
|
||||
import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse';
|
||||
import { UserKeyResponse } from '../models/response/userKeyResponse';
|
||||
|
||||
import { SendAccessView } from '../models/view/sendAccessView';
|
||||
|
||||
export class ApiService implements ApiServiceAbstraction {
|
||||
urlsSet: boolean = false;
|
||||
apiBaseUrl: string;
|
||||
@ -416,6 +419,12 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
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>> {
|
||||
const r = await this.send('GET', '/sends', null, true, true);
|
||||
return new ListResponse(r, SendResponse);
|
||||
|
Loading…
Reference in New Issue
Block a user