Skip to content

feat: introduce standalone JavaScript SDK - #41

Open
m4sh-wacker wants to merge 6 commits into
mainfrom
feat/javascript-sdk
Open

m4sh-wacker wants to merge 6 commits into
mainfrom
feat/javascript-sdk

Conversation

@m4sh-wacker

@m4sh-wacker m4sh-wacker commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes

Applications can run DecodeBox operations, recipes and multilayer analysis locally in modern browsers and Java-enabled GraalJS. The SDK wraps the workbench’s operation registry and processing engine. The public API remains at v1.0.0, with an independently versioned engine and generated TypeScript declarations.

  • Move the React entry points to src/app and group the existing engine regression tests under src/engine/tests. Runtime adapters live under src/engine/runtime, with the public contract under src/sdk.
  • Build five classic paths, three ESM paths and two declaration paths. These include /api, /api.js, stable SDK aliases and immutable /sdk/v1/{engineVersion}/ artifacts. Hash the published bytes, retain older releases and reject a version collision before publishing. Release Please retains ownership of the project version.
  • Mark classic bundles as UTF-8 so hosts serving an extensionless file without a charset work in legacy-encoded documents. The build carries project and dependency notices in the bundles.
  • Add an SDK quick start, API reference and browser, TypeScript, GraalJS, ZAP and offline integration guidance. The existing distribution remains available. The proposed official paths all returned HTTP 404 at review time.
  • Keep input validation, size and decompression checks, CSP and offline processing. The Java provider uses JCA and SecureRandom. The host controls Java permissions. Synchronous regex and crypto work require worker or process isolation for hard time limits.

Related issue

The integration addresses the external SDK request.

Fixes #38

How it was tested

  • Official baseline: 1,241 unit tests. Integrated build: 1,246/1,246 tests in 74 files. Real Node 22.23.5 and Node 24.18.0 both passed clean install, ESLint, typecheck, the 1,246 tests, website and standalone builds, and SDK distribution validation. The ten SDK files and SHA-256 manifest were byte-identical across the two toolchains. CI retains both build contexts required by the official main ruleset. Node 24 remains the default for distribution.
  • Chromium 158.0.8127.88: 504/504 operation fixtures and 13/13 contract checks, including no processing requests. All eight JavaScript URLs executed in a document without a declared charset. The site and offline HTML completed a recipe. The deployed-format worker produced the expected SHA-256 for 74,800 input bytes.
  • GraalJS 25.0.1 / Java 24.0.2: 504/504 and 12/12 contract checks. ZAP 2.17.0 / GraalJS add-on 0.12.0: 504/504 and 12/12. Final JVM suites ran serially with the original time limits. Coverage includes binary and Unicode PBKDF2, scrypt, SHA-256, Bombe, London DST, compression, random output, recipe execution and detection.
  • All ten local HTTP paths returned the exact files. Chromium’s Fetch API confirmed the raw BOM and digest; the DevTools script-text view strips that signature. The browser quick start also ran from disk with networking disabled. Matching and changed SHA-256 pins were accepted and rejected respectively by the native ZAP add-on. Its bridge initialized API 1.0.0 in ZAP, discovered the catalogue and performed a Base64 operation. The documentation’s ZAP example ran in the same host.
  • Classic SHA-256: 9932e7ed296e8245fe06f192de7c96cf657379cfcef59f18aee2ad7518c7f1f6. Independent installs reproduced the release artifacts. Missing, empty, changed and mismatched artifacts fail validation. A deployment fixture confirmed that older versions survive and a collision fails.
  • All discovery metadata and generated declarations matched the source SDK. TypeScript usage compiled and ran. Markdown lint and internal documentation links passed. The runtime dependency audit reported zero advisories. The full audit reported nine moderate development-tool findings, zero high and zero critical.
  • Official production still requires independent verification after merge and deployment. GitHub Pages controls the MIME type of /api. Strict MIME consumers can use /api.js. Local validation does not establish the headers of a future official deployment.

Checklist

  • Lint, typecheck, tests and build pass locally.
  • Added SDK contract tests and a regression check for a consumer document without a charset declaration.
  • No new explicit any in application code or dynamic code evaluation in the SDK.
  • Maintainer review of new runtime dependencies: @exodus/bytes for encoding, whatwg-url for URL handling and @noble/curves for EC key conversion in GraalJS. The versions are exact and covered by the lockfile.
  • Malformed inputs, oversized requests, bounded decompression and execution errors are covered.

The UI layout, translations, keyboard interactions and operation definitions retain their existing interfaces. No operation was added. The full compatibility harnesses and generated reports were kept outside the production repository.

Port the public v1 API and runtime changes from m4sh-wacker/DecodeBox-SDK at 74b2b392. Build classic, module and declaration artifacts from the registry and verify their release checksums.
Sign classic output with a UTF-8 BOM before aliasing and hashing. Preserve resolver paths so clean and linked installs emit identical release bytes. Exercise an undeclared consumer charset and report script errors.
Comment thread scripts/check-sdk-dist.mjs Fixed
Pin a declaration generator compatible with both runtimes and keep internal types private. Import the trusted project version directly when constructing distribution paths.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a standalone JavaScript SDK for external integrations

2 participants