From c78844c9d40659215a7f35c0c048179b79091355 Mon Sep 17 00:00:00 2001 From: coinshot <93342644+coinshot@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:51:40 +0200 Subject: [PATCH] Add subresource integrity --- build_wasm_module.sh | 3 +++ src/CMakeLists.txt | 2 +- src/package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build_wasm_module.sh b/build_wasm_module.sh index 28f7df9..a1a2d69 100755 --- a/build_wasm_module.sh +++ b/build_wasm_module.sh @@ -11,3 +11,6 @@ cmake /src \ emmake make +# Add subresource integrity +SRI_HASH=$(cat arrow_wasm.wasm | openssl dgst -sha384 -binary | openssl base64 -A) +sed -i "s/\(fetch([a-zA-Z]\+, { credentials: 'same-origin'\)/\1, integrity: 'sha384-${SRI_HASH}'/g" arrow_wasm.js diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cfd690..3065409 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,5 +74,5 @@ set(ASYNCIFY_CALL_STACK " ") string(REGEX REPLACE "\n" "" ASYNCIFY_CALL_STACK "${ASYNCIFY_CALL_STACK}") -set_target_properties(arrow_wasm PROPERTIES LINK_FLAGS "--bind -g -Oz -s ENVIRONMENT='web' -s WASM=1 -s INITIAL_MEMORY=32MB -s ALLOW_MEMORY_GROWTH=1 -s ASYNCIFY=1 -s ASYNCIFY_STACK_SIZE=4096 -s ASYNCIFY_ADVISE=0 -s ASYNCIFY_IGNORE_INDIRECT=0 -s ASYNCIFY_ADD=\"[${ASYNCIFY_CALL_STACK}]\" -s FETCH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ASSERTIONS=1 -s NO_EXIT_RUNTIME=1 -s FORCE_FILESYSTEM=1 -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 -s MODULARIZE=1 -s EXPORT_NAME='Arrow' -s EXPORTED_RUNTIME_METHODS=\"['FS']\"") +set_target_properties(arrow_wasm PROPERTIES LINK_FLAGS "--bind -g -Oz -s ENVIRONMENT='web' -s WASM=1 -s INITIAL_MEMORY=32MB -s ALLOW_MEMORY_GROWTH=1 -s NO_DYNAMIC_EXECUTION=1 -s ASYNCIFY=1 -s ASYNCIFY_STACK_SIZE=4096 -s ASYNCIFY_ADVISE=0 -s ASYNCIFY_IGNORE_INDIRECT=0 -s ASYNCIFY_ADD=\"[${ASYNCIFY_CALL_STACK}]\" -s FETCH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ASSERTIONS=1 -s NO_EXIT_RUNTIME=1 -s FORCE_FILESYSTEM=1 -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 -s MODULARIZE=1 -s EXPORT_NAME='Arrow' -s EXPORTED_RUNTIME_METHODS=\"['FS']\"") diff --git a/src/package.json b/src/package.json index c349e59..e831702 100644 --- a/src/package.json +++ b/src/package.json @@ -7,7 +7,7 @@ "collaborators": [ "PixelCities" ], - "version": "0.1.4", + "version": "0.1.5", "files": [ "arrow_wasm.wasm", "arrow_wasm.js",