diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-02-09 17:09:13 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-02-09 18:00:16 +0100 |
commit | 1c65dd5ca24052ccf9a92939eecd0966c9635c50 (patch) | |
tree | 7575157ccd729b4ad79f6c04501023ccb0532a63 /html/payload_create.js | |
parent | 830d22d8931a4e5f0606d401f24d7cd937f8697e (diff) | |
download | browser-extension-1c65dd5ca24052ccf9a92939eecd0966c9635c50.tar.gz browser-extension-1c65dd5ca24052ccf9a92939eecd0966c9635c50.zip |
adapt to changes in file path format
From now on we assume Hydrilla serves file contents at 'file/sha256/<hash>' instead of 'file/sha256-<hash>'.
With this commit we also stop using the "hash_key" property internally.
Diffstat (limited to 'html/payload_create.js')
-rw-r--r-- | html/payload_create.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/html/payload_create.js b/html/payload_create.js index 8828809..7782299 100644 --- a/html/payload_create.js +++ b/html/payload_create.js @@ -45,7 +45,7 @@ #IMPORT common/indexeddb.js AS haketilodb #FROM html/DOM_helpers.js IMPORT clone_template -#FROM common/sha256.js IMPORT sha256 +#FROM common/sha256.js IMPORT sha256 AS compute_sha256 #FROM common/patterns.js IMPORT validate_normalize_url_pattern, \ patterns_doc_url @@ -94,7 +94,7 @@ function collect_form_data(form_ctx) const script = form_ctx.script.value; if (!script) throw "The 'script' field is required!"; - const hash_key = `sha256-${sha256(script)}`; + const sha256 = compute_sha256(script); const resource = { source_name: identifier, @@ -106,7 +106,7 @@ function collect_form_data(form_ctx) version: [1], description, dependencies: [], - scripts: [{file: "payload.js", hash_key}] + scripts: [{file: "payload.js", sha256}] }; const mapping = { @@ -121,7 +121,7 @@ function collect_form_data(form_ctx) payloads }; - return {identifier, resource, mapping, files: {[hash_key]: script}}; + return {identifier, resource, mapping, files_by_sha256: {[sha256]: script}}; } function clear_form(form_ctx) @@ -137,7 +137,8 @@ async function save_payload(saving) { const db = await haketilodb.get(); const tx_starter = haketilodb.start_items_transaction; - const tx_ctx = await tx_starter(["resource", "mapping"], saving.files); + const files = {sha256: saving.files_by_sha256}; + const tx_ctx = await tx_starter(["resource", "mapping"], files); for (const type of ["resource", "mapping"]) { if (!saving[`override_${type}`] && |