mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-28 17:27:50 +01:00
Use download link requests (#859)
* Use download link requests * Update jslib * Update jslib
This commit is contained in:
parent
2e4a3501a2
commit
227f457409
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 301ef455f3df59be9ca26ab98d8686b93c09ef4a
|
||||
Subproject commit 3942868cf488ed8c1983ffadab2c8900b8c78410
|
@ -43,6 +43,7 @@ export class AccessComponent implements OnInit {
|
||||
private id: string;
|
||||
private key: string;
|
||||
private decKey: SymmetricCryptoKey;
|
||||
private accessRequest: SendAccessRequest;
|
||||
|
||||
constructor(private i18nService: I18nService, private cryptoFunctionService: CryptoFunctionService,
|
||||
private apiService: ApiService, private platformUtilsService: PlatformUtilsService,
|
||||
@ -90,8 +91,16 @@ export class AccessComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const downloadData = await this.apiService.getSendFileDownloadData(this.send, this.accessRequest);
|
||||
|
||||
if (Utils.isNullOrWhitespace(downloadData.url)) {
|
||||
this.platformUtilsService.showToast('error', null, this.i18nService.t('missingSendFile'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.downloading = true;
|
||||
const response = await fetch(new Request(this.send.file.url, { cache: 'no-store' }));
|
||||
const response = await fetch(new Request(downloadData.url, { cache: 'no-store' }));
|
||||
if (response.status !== 200) {
|
||||
this.platformUtilsService.showToast('error', null, this.i18nService.t('errorOccurred'));
|
||||
this.downloading = false;
|
||||
@ -123,17 +132,17 @@ export class AccessComponent implements OnInit {
|
||||
this.unavailable = false;
|
||||
this.error = false;
|
||||
const keyArray = Utils.fromUrlB64ToArray(this.key);
|
||||
const accessRequest = new SendAccessRequest();
|
||||
this.accessRequest = new SendAccessRequest();
|
||||
if (this.password != null) {
|
||||
const passwordHash = await this.cryptoFunctionService.pbkdf2(this.password, keyArray, 'sha256', 100000);
|
||||
accessRequest.password = Utils.fromBufferToB64(passwordHash);
|
||||
this.accessRequest.password = Utils.fromBufferToB64(passwordHash);
|
||||
}
|
||||
try {
|
||||
let sendResponse: SendAccessResponse = null;
|
||||
if (this.loading) {
|
||||
sendResponse = await this.apiService.postSendAccess(this.id, accessRequest);
|
||||
sendResponse = await this.apiService.postSendAccess(this.id, this.accessRequest);
|
||||
} else {
|
||||
this.formPromise = this.apiService.postSendAccess(this.id, accessRequest);
|
||||
this.formPromise = this.apiService.postSendAccess(this.id, this.accessRequest);
|
||||
sendResponse = await this.formPromise;
|
||||
}
|
||||
this.passwordRequired = false;
|
||||
|
@ -3425,6 +3425,10 @@
|
||||
"message": "The Send you are trying to access does not exist or is no longer available.",
|
||||
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
|
||||
},
|
||||
"missingSendFile": {
|
||||
"message": "The file associated with this Send could not be found.",
|
||||
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
|
||||
},
|
||||
"noSendsInList": {
|
||||
"message": "There are no Sends to list.",
|
||||
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
|
||||
|
Loading…
Reference in New Issue
Block a user