From 102b70a671cc9ef4d934e629206c8ad59f58b9b6 Mon Sep 17 00:00:00 2001 From: digitalSloth Date: Wed, 2 Sep 2026 06:59:55 +0100 Subject: [PATCH 1/4] feat: make the browser build tree-shakeable, drop UMD - src/crypto/crypto.ts: replace crypto/ed25519-hd-key with a SLIP-0010 derivation over @noble/hashes; move the ed25519 sha512Sync assignment out of a top-level statement so sideEffects:false can't drop it. - src/wallet/encryptor.ts: replace the Node crypto/crypto-browserify driver pair with @noble/ciphers/aes gcm, keeping encrypt/decrypt sync and the cipherHex||authTagHex wire format. - src/wallet/keyFile.ts: browser branch now imports the argon2-browser bundled subpath lazily instead of the package root; native branch specifier held in a const per the esbuild escalation rule. - src/types/argon2-bundled.d.ts: new ambient declaration for the bundled subpath. - package.json: exports map -> {types, default}; browser field and build:browser script removed; sideEffects:false added; add @noble/ciphers, remove ed25519-hd-key/crypto-browserify and the webpack-browser-only devDependencies. - webpack.browser.config.cjs: deleted (UMD and ESM browser bundles both dropped). - tsconfig.json: add ts-node.files:true so the mocha/ts-node loader picks up the new ambient .d.ts (tsc/build were unaffected either way). - README.md, AGENTS.md, docs/examples.md, test/zenon.spec.ts: repoint PoW paths from dist/browser to lib, drop the now-false UMD claims, rewrite the Browser Builds section. - test/crypto/crypto.spec.ts, test/wallet/keyFile.spec.ts: cover deriveKey's path validation and the browser/native Argon2 driver parity. --- AGENTS.md | 18 +- README.md | 25 +- docs/examples.md | 2 +- package-lock.json | 1641 +-------------------------------- package.json | 30 +- src/crypto/crypto.ts | 50 +- src/types/argon2-bundled.d.ts | 5 + src/wallet/encryptor.ts | 46 +- src/wallet/keyFile.ts | 13 +- test/crypto/crypto.spec.ts | 16 + test/wallet/keyFile.spec.ts | 54 ++ test/zenon.spec.ts | 8 +- tsconfig.json | 5 +- webpack.browser.config.cjs | 107 --- 14 files changed, 182 insertions(+), 1838 deletions(-) create mode 100644 src/types/argon2-bundled.d.ts create mode 100644 test/crypto/crypto.spec.ts delete mode 100644 webpack.browser.config.cjs diff --git a/AGENTS.md b/AGENTS.md index c8b8b3b..5e3bc59 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,7 @@ This file provides guidance for AI agents and automated tools working on this co ## Project Overview -**znn-typescript-sdk** is a TypeScript/JavaScript SDK for interacting with the Zenon Network of Momentum (NoM). It supports Node.js (ESM) and browsers (ESM + UMD), includes a CLI, and ships a pre-built WebAssembly PoW module. +**znn-typescript-sdk** is a TypeScript/JavaScript SDK for interacting with the Zenon Network of Momentum (NoM). It supports Node.js and browsers (ESM), includes a CLI, and ships a pre-built WebAssembly PoW module. - **Package name:** `znn-typescript-sdk` - **License:** MIT @@ -41,10 +41,9 @@ dist/ # Build output (gitignored) ```bash npm install # Install dependencies -npm run build # Full build: lint + ESM + CLI + browser bundles +npm run build # Full build: lint + ESM + CLI npm run build:esm # TypeScript → dist/ (ESM) npm run build:cli # Webpack CLI bundle → dist/cli/cli.cjs -npm run build:browser # Webpack browser bundle → dist/browser/ npm run build:wasm # Rebuild PoW WASM (requires Emscripten) npm run lint # ESLint (src, cli, test) npm run lint:fix # ESLint with auto-fix @@ -54,7 +53,7 @@ npm run cli:dev # Build CLI and run it locally npm run clean # Remove dist/, coverage/, .nyc_output/ ``` -The full `npm run build` pipeline runs: `clean → lint → build:esm → build:cli → build:browser`. +The full `npm run build` pipeline runs: `clean → lint → build:esm → build:cli`. --- @@ -164,17 +163,6 @@ The SDK includes a WebAssembly PoW module (`lib/pow.js` + `lib/pow.wasm`). --- -## Browser Bundles - -| Bundle | Path | Usage | -|---|---|---| -| ESM | `dist/browser/bundle.browser.mjs` | Vite / Rollup / Webpack | -| UMD | `dist/browser/bundle.browser.js` | `