aboutsummaryrefslogtreecommitdiff
path: root/html/payload_create.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/payload_create.js')
-rw-r--r--html/payload_create.js11
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}`] &&