mirror of
https://gitlab.com/timvisee/send.git
synced 2024-11-09 20:52:39 +01:00
added hmac auth to report route
Co-authored-by: timvisee <tim@visee.me>
This commit is contained in:
parent
bc0ccc8e5d
commit
f64e772145
@ -61,7 +61,10 @@ async function fetchWithAuth(url, params, keychain) {
|
|||||||
const result = {};
|
const result = {};
|
||||||
params = params || {};
|
params = params || {};
|
||||||
const h = await keychain.authHeader();
|
const h = await keychain.authHeader();
|
||||||
params.headers = new Headers({ Authorization: h });
|
params.headers = new Headers({
|
||||||
|
Authorization: h,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
});
|
||||||
const response = await fetch(url, params);
|
const response = await fetch(url, params);
|
||||||
result.response = response;
|
result.response = response;
|
||||||
result.ok = response.ok;
|
result.ok = response.ok;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Nanobus from 'nanobus';
|
import Nanobus from 'nanobus';
|
||||||
import Keychain from './keychain';
|
import Keychain from './keychain';
|
||||||
import { delay, bytes, streamToArrayBuffer } from './utils';
|
import { delay, bytes, streamToArrayBuffer } from './utils';
|
||||||
import { downloadFile, metadata, getApiUrl } from './api';
|
import { downloadFile, metadata, getApiUrl, reportLink } from './api';
|
||||||
import { blobStream } from './streams';
|
import { blobStream } from './streams';
|
||||||
import Zip from './zip';
|
import Zip from './zip';
|
||||||
|
|
||||||
@ -53,6 +53,10 @@ export default class FileReceiver extends Nanobus {
|
|||||||
this.state = 'ready';
|
this.state = 'ready';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reportLink(reason) {
|
||||||
|
await reportLink(this.fileInfo.id, this.keychain, reason);
|
||||||
|
}
|
||||||
|
|
||||||
sendMessageToSw(msg) {
|
sendMessageToSw(msg) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const channel = new MessageChannel();
|
const channel = new MessageChannel();
|
||||||
|
@ -9,7 +9,7 @@ import contentDisposition from 'content-disposition';
|
|||||||
let noSave = false;
|
let noSave = false;
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
const IMAGES = /.*\.(png|svg|jpg)$/;
|
const IMAGES = /.*\.(png|svg|jpg)$/;
|
||||||
const VERSIONED_ASSET = /\.[A-Fa-f0-9]{8}\.(js|css|png|svg|jpg)$/;
|
const VERSIONED_ASSET = /\.[A-Fa-f0-9]{8}\.(js|css|png|svg|jpg)(#\w+)?$/;
|
||||||
const DOWNLOAD_URL = /\/api\/download\/([A-Fa-f0-9]{4,})/;
|
const DOWNLOAD_URL = /\/api\/download\/([A-Fa-f0-9]{4,})/;
|
||||||
const FONT = /\.woff2?$/;
|
const FONT = /\.woff2?$/;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user