From 5cc2339311e94e51ada710a33cf64c9bb49e01a0 Mon Sep 17 00:00:00 2001 From: Murph Murphy Date: Mon, 17 Nov 2025 20:02:07 -0700 Subject: [PATCH 1/2] Fix the 0.7 release Sets it back to the old release style. The thing produced by wasm-pack is a ES/nodenext module, but our shim still wraps it into a CJS module, so downstream consumers don't need to change anything. We lose our TS compile checking the validity of dependencies types (though our uses of them are still checked against their declarations). We do this on most (all?) of our other TS projects. --- Cargo.lock | 16 ++++++++-------- build.js | 20 +++++++++++++++++--- lib/Api256Shim.ts | 1 - tsconfig.json | 1 + 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be1d237..00e95c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "cc" -version = "1.2.45" +version = "1.2.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" +checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" dependencies = [ "find-msvc-tools", "shlex", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -194,15 +194,15 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", diff --git a/build.js b/build.js index bc907af..b46b56c 100755 --- a/build.js +++ b/build.js @@ -48,18 +48,32 @@ shell.cp("./recrypt_wasm_binding.d.ts", "./pkg"); //Compile our wasm-bindgen shim from TS to ES6 JS shell.exec( - "./node_modules/typescript/bin/tsc --lib es6 --target ES2015 --sourceMap false --module nodenext --moduleResolution nodenext --outDir ./pkg lib/Api256Shim.ts" + "./node_modules/typescript/bin/tsc --lib es6 --target ES2015 --sourceMap false --module esnext --skipLibCheck true --outDir ./pkg lib/Api256Shim.ts" ); //Tweak wasm-bindgen import location since we moved the file to the same directory as the wasm-bindgen produced shim +// WARNING: if the above module type changes to nodenext from esnext, this will go from an import to a require +// and will need to be updated. +const before = shell.exec(`shasum ./pkg/Api256Shim.js`, {silent: true}).stdout; shell.sed("-i", `from "../target/`, `from "./`, "./pkg/Api256Shim.js"); +const after = shell.exec(`shasum ./pkg/Api256Shim.js`, {silent: true}).stdout; +if (before === after) { + console.error("Error: failed to correct Api256Shim.js wasm import."); + process.exit(1); +} //We need to tweak the wasm-pack generated package.json file since we have our own shim that fronts wasm-bindgen const generatedPackageJson = require("./pkg/package.json"); generatedPackageJson.main = "Api256Shim.js"; -delete generatedPackageJson.module; +delete generatedPackageJson.type; delete generatedPackageJson.files; generatedPackageJson.types = "recrypt_wasm_binding.d.ts"; -fs.writeFileSync("./pkg/package.json", JSON.stringify(generatedPackageJson, null, 2)); +try { + fs.writeFileSync("./pkg/package.json", JSON.stringify(generatedPackageJson, null, 2)); + console.log("File written successfully"); +} catch (err) { + console.error("Write failed:", err); + process.exit(1); +} shell.cp("./LICENSE", "./pkg"); diff --git a/lib/Api256Shim.ts b/lib/Api256Shim.ts index d82d1c7..21fa48e 100644 --- a/lib/Api256Shim.ts +++ b/lib/Api256Shim.ts @@ -265,7 +265,6 @@ export const addPrivateKeys = (privateKeyA: Uint8Array, privateKeyB: Uint8Array) */ export const subtractPrivateKeys = (privateKeyA: Uint8Array, privateKeyB: Uint8Array): Uint8Array => Recrypt.subtractPrivateKeys(privateKeyA, privateKeyB); - /** * Export the entire EncryptedSearch struct out directly. No need to shim this at any level. */ diff --git a/tsconfig.json b/tsconfig.json index 22a4402..413b837 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "noEmitOnError": true, "noUnusedLocals": true, "declaration": false, + "skipLibCheck": true, "target": "ES2015", "module": "nodenext", "moduleResolution": "nodenext", From d5aada76b70e3271919d49d8e87503add61ed391 Mon Sep 17 00:00:00 2001 From: Murph Murphy Date: Tue, 18 Nov 2025 09:40:18 -0700 Subject: [PATCH 2/2] Fix tsconfig module type --- tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 413b837..6176568 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,8 +9,7 @@ "declaration": false, "skipLibCheck": true, "target": "ES2015", - "module": "nodenext", - "moduleResolution": "nodenext", + "module": "esnext", "lib": ["es6", "dom"] }, "exclude": ["node_modules"]