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 id: string;
|
||||||
private key: string;
|
private key: string;
|
||||||
private decKey: SymmetricCryptoKey;
|
private decKey: SymmetricCryptoKey;
|
||||||
|
private accessRequest: SendAccessRequest;
|
||||||
|
|
||||||
constructor(private i18nService: I18nService, private cryptoFunctionService: CryptoFunctionService,
|
constructor(private i18nService: I18nService, private cryptoFunctionService: CryptoFunctionService,
|
||||||
private apiService: ApiService, private platformUtilsService: PlatformUtilsService,
|
private apiService: ApiService, private platformUtilsService: PlatformUtilsService,
|
||||||
@ -90,8 +91,16 @@ export class AccessComponent implements OnInit {
|
|||||||
return;
|
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;
|
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) {
|
if (response.status !== 200) {
|
||||||
this.platformUtilsService.showToast('error', null, this.i18nService.t('errorOccurred'));
|
this.platformUtilsService.showToast('error', null, this.i18nService.t('errorOccurred'));
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
@ -123,17 +132,17 @@ export class AccessComponent implements OnInit {
|
|||||||
this.unavailable = false;
|
this.unavailable = false;
|
||||||
this.error = false;
|
this.error = false;
|
||||||
const keyArray = Utils.fromUrlB64ToArray(this.key);
|
const keyArray = Utils.fromUrlB64ToArray(this.key);
|
||||||
const accessRequest = new SendAccessRequest();
|
this.accessRequest = new SendAccessRequest();
|
||||||
if (this.password != null) {
|
if (this.password != null) {
|
||||||
const passwordHash = await this.cryptoFunctionService.pbkdf2(this.password, keyArray, 'sha256', 100000);
|
const passwordHash = await this.cryptoFunctionService.pbkdf2(this.password, keyArray, 'sha256', 100000);
|
||||||
accessRequest.password = Utils.fromBufferToB64(passwordHash);
|
this.accessRequest.password = Utils.fromBufferToB64(passwordHash);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let sendResponse: SendAccessResponse = null;
|
let sendResponse: SendAccessResponse = null;
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
sendResponse = await this.apiService.postSendAccess(this.id, accessRequest);
|
sendResponse = await this.apiService.postSendAccess(this.id, this.accessRequest);
|
||||||
} else {
|
} else {
|
||||||
this.formPromise = this.apiService.postSendAccess(this.id, accessRequest);
|
this.formPromise = this.apiService.postSendAccess(this.id, this.accessRequest);
|
||||||
sendResponse = await this.formPromise;
|
sendResponse = await this.formPromise;
|
||||||
}
|
}
|
||||||
this.passwordRequired = false;
|
this.passwordRequired = false;
|
||||||
|
@ -3425,6 +3425,10 @@
|
|||||||
"message": "The Send you are trying to access does not exist or is no longer available.",
|
"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."
|
"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": {
|
"noSendsInList": {
|
||||||
"message": "There are no Sends to list.",
|
"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."
|
"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