Commit 1b90ec74 authored by Xunnamius (Luna)'s avatar Xunnamius (Luna)

publish version 0.11.0

parent 74c3491b
# The port webpack-dev-server will listen on
WEBPACK_PORT=9000
# The port the hotcrp-backend uses
HOTCRP_BACKEND_PORT=3003
# The host the hotcrp-backend uses for DNS updates
HOTCRP_BACKEND_HOST=haschk.dev
# Where your webpack-dev-server lives
DEV_ENDPOINT=127.0.0.1
......
......@@ -5,7 +5,7 @@
"type": "git",
"url": "https://git.xunn.io/closed-source/research/psd-mirrored/haschk"
},
"version": "0.10.0",
"version": "0.11.0",
"scripts": {
"dev": "npx gulp wpdevserv",
"build": "npx gulp build",
......@@ -77,13 +77,11 @@
"babel-jest": "^25.1.0",
"babel-loader": "^8.0.6",
"babel-plugin-source-map-support": "^2.1.1",
"base32-encode": "^1.1.1",
"bluebird": "^3.7.2",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "^3.4.2",
"del": "^5.1.0",
"do-wrapper": "^4.0.0-alpha.2",
"eslint": "^6.8.0",
"eslint-plugin-flowtype": "^4.6.0",
"fancy-log": "^1.3.3",
......@@ -98,8 +96,6 @@
"jest": "^25.1.0",
"jsdoc": "^3.6.3",
"jsdoc-babel": "^0.5.0",
"koa": "^2.11.0",
"koa-router": "^8.0.8",
"parse-gitignore": "^1.0.1",
"source-map": "^0.7.3",
"source-map-support": "^0.5.16",
......
......@@ -32,16 +32,6 @@ import type { EventFrame } from 'universe/events'
declare var crypto;
export default (oracle: EventFrameEmitter, chrome: Chrome, context: Object) => {
// ? These events update the context.downloadItems cache
const updateDownloadItemInContext = downloadItem => context.downloadItems[downloadItem.id] = downloadItem;
oracle.addListener('download.incoming', (e, downloadItem) => updateDownloadItemInContext(downloadItem));
oracle.addListener('download.paused', (e, downloadItem) => updateDownloadItemInContext(downloadItem));
oracle.addListener('download.resumed', (e, downloadItem) => updateDownloadItemInContext(downloadItem));
oracle.addListener('download.interrupted', (e, downloadItem) => updateDownloadItemInContext(downloadItem));
oracle.addListener('download.completed', (e, downloadItem) => updateDownloadItemInContext(downloadItem));
// ? This event fires whenever haschk decides a download is NOT safe
oracle.addListener(`judgement.${JUDGEMENT_UNSAFE}`, (e: EventFrame, downloadItem) => {
chrome.downloads.removeFile(downloadItem.id, () => {
......@@ -78,11 +68,29 @@ export default (oracle: EventFrameEmitter, chrome: Chrome, context: Object) => {
return;
}
// ? Since it's finished downloading, grab the file's data
const file = await http.get(`file://${downloadItem.filename}`, { responseType: 'arraybuffer' });
const hasFilesystemAccess = await new Promise(res => chrome.extension.isAllowedFileSchemeAccess(t => res(t)));
if(!hasFilesystemAccess)
throw new Error(`HASCHK needs file scheme access to operate. Please allow access to file URLs in settings`);
// ? Since it's finished downloading, grab the file's data, but we need
// ? to use custom XHR because fetch (and Axios) can't handle status
// ? code 0 (pathetic)
const fetchLocal = async url => {
return new Promise(function(resolve, reject) {
const xhr = new XMLHttpRequest();
xhr.onload = () => resolve(xhr.response);
xhr.onerror = () => reject(new Error('file://XMLHttpRequest request failed'));
xhr.responseType = 'arraybuffer';
xhr.open('GET', url);
xhr.send(null);
});
};
const fileData = await fetchLocal(`file://${downloadItem.filename}`);
// ? Hash file data with proper algorithm
const base32FileHash = base32Encode(await crypto.subtle.digest(HASHING_ALGORITHM, file.data), 'Crockford', {
const base32FileHash = base32Encode(await crypto.subtle.digest(HASHING_ALGORITHM, fileData), 'Crockford', {
padding: false
});
......
......@@ -16,7 +16,6 @@
"options_page": "options.html",
"permissions": [
"<all_urls>",
"file://*/",
"downloads",
"webRequest"
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment