mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-09 09:51:02 +01:00
Add Send-Id header for access requests (#400)
* Add Send-Id header to postSendAccess request * Add Send Id header to file access requests * fix linting
This commit is contained in:
parent
ff387622e0
commit
2e16aef6a2
@ -428,13 +428,19 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async postSendAccess(id: string, request: SendAccessRequest, apiUrl?: string): Promise<SendAccessResponse> {
|
async postSendAccess(id: string, request: SendAccessRequest, apiUrl?: string): Promise<SendAccessResponse> {
|
||||||
const r = await this.send('POST', '/sends/access/' + id, request, false, true, apiUrl);
|
const addSendIdHeader = (headers: Headers) => {
|
||||||
|
headers.set('Send-Id', id);
|
||||||
|
};
|
||||||
|
const r = await this.send('POST', '/sends/access/' + id, request, false, true, apiUrl, addSendIdHeader);
|
||||||
return new SendAccessResponse(r);
|
return new SendAccessResponse(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async getSendFileDownloadData(send: SendAccessView, request: SendAccessRequest, apiUrl?: string): Promise<SendFileDownloadDataResponse> {
|
async getSendFileDownloadData(send: SendAccessView, request: SendAccessRequest, apiUrl?: string): Promise<SendFileDownloadDataResponse> {
|
||||||
const r = await this.send('POST', '/sends/' + send.id + '/access/file/' + send.file.id, request, false, true, apiUrl);
|
const addSendIdHeader = (headers: Headers) => {
|
||||||
|
headers.set('Send-Id', send.id);
|
||||||
|
};
|
||||||
|
const r = await this.send('POST', '/sends/' + send.id + '/access/file/' + send.file.id, request, false, true,
|
||||||
|
apiUrl, addSendIdHeader);
|
||||||
return new SendFileDownloadDataResponse(r);
|
return new SendFileDownloadDataResponse(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1353,7 +1359,8 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async send(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, body: any,
|
private async send(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, body: any,
|
||||||
authed: boolean, hasResponse: boolean, apiUrl?: string): Promise<any> {
|
authed: boolean, hasResponse: boolean, apiUrl?: string,
|
||||||
|
alterHeaders?: (headers: Headers) => void): Promise<any> {
|
||||||
apiUrl = Utils.isNullOrWhitespace(apiUrl) ? this.apiBaseUrl : apiUrl;
|
apiUrl = Utils.isNullOrWhitespace(apiUrl) ? this.apiBaseUrl : apiUrl;
|
||||||
const headers = new Headers({
|
const headers = new Headers({
|
||||||
'Device-Type': this.deviceType,
|
'Device-Type': this.deviceType,
|
||||||
@ -1388,6 +1395,9 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
if (hasResponse) {
|
if (hasResponse) {
|
||||||
headers.set('Accept', 'application/json');
|
headers.set('Accept', 'application/json');
|
||||||
}
|
}
|
||||||
|
if (alterHeaders != null) {
|
||||||
|
alterHeaders(headers);
|
||||||
|
}
|
||||||
|
|
||||||
requestInit.headers = headers;
|
requestInit.headers = headers;
|
||||||
const response = await this.fetch(new Request(apiUrl + path, requestInit));
|
const response = await this.fetch(new Request(apiUrl + path, requestInit));
|
||||||
|
Loading…
Reference in New Issue
Block a user