Commit 4ac2aed
committed
feat: add binary type support for host functions
Adds Uint8Array/Buffer support for host function arguments and returns.
Architecture:
- New hyperlight-js-common crate: shared wire-format constants, binary
sidecar encode/decode, FnReturn enum, DecodeError type
- Guest extracts Uint8Array from QuickJS VM into binary sidecar
- Host dispatches via register() (typed serde) or register_js() (JS bridge)
- NAPI layer creates native Node.js Buffers via C API (no base64)
- Tagged return format (0x00=JSON, 0x01=binary) for return path
Key changes:
- Single CallHostJsFunction entry point (removed legacy JSON-only path)
- Native Buffer marshalling in NAPI (JsArg/JsReturn types)
- Depth limits on all recursive JSON tree traversals (MAX_JSON_DEPTH=64)
- Trailing data rejection in sidecar decoder
- Typed register() rejects binary args with clear error message
- Comprehensive test coverage (Rust unit + integration + JS vitest)
- Updated README with Binary Data section and wire protocol docs
- Updated CI publish order for new common crate
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>1 parent a892a0a commit 4ac2aed
File tree
20 files changed
+3012
-486
lines changed- .github/workflows
- docs
- src
- hyperlight-js-common
- src
- hyperlight-js-runtime
- src
- main
- hyperlight-js
- src
- sandbox
- tests
- js-host-api
- src
- tests
20 files changed
+3012
-486
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
0 commit comments