Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/componentize-js-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
curl -fsSLO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-30/wasi-sdk-30.0-${{ matrix.wasi-sdk }}.tar.gz
tar -C "$RUNNER_TEMP" -xf wasi-sdk-30.0-${{ matrix.wasi-sdk }}.tar.gz
export WASI_SDK_PATH="$RUNNER_TEMP/wasi-sdk-30.0-${{ matrix.wasi-sdk }}"
git clone https://github.com/dicej/componentize-js "$RUNNER_TEMP/componentize-js"
git clone https://github.com/lann/componentize-js "$RUNNER_TEMP/componentize-js"
git -C "$RUNNER_TEMP/componentize-js" checkout "${{ steps.id.outputs.rev }}"
# componentize-js's build.rs builds its wasm runtime by spawning a
# nested `cargo build --target=wasm32-wasip2` after removing every
Expand Down
2 changes: 1 addition & 1 deletion examples/componentize-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end to end: HMAC-SHA-256 known answers (RFC 4231), AES-256-GCM known answers
(NIST GCM test case 16), round trips including the empty plaintext, and the
key-capability surface (usages, extractability, malformed-input rejection).

[componentize-js]: https://github.com/dicej/componentize-js
[componentize-js]: https://github.com/lann/componentize-js

The guest exports the same `demo:webcrypto-demo/demo@0.1.0` entry point as
the Rust `crypto-demo` guest, so the existing `crypto-demo-driver` drives it
Expand Down
16 changes: 9 additions & 7 deletions js/componentize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ the `polymorph:webcrypto` interfaces. This is the JS-guest counterpart of the Ru
ergonomic Rust newtypes, `webcrypto.js` wraps them in the API JS code already
knows — `crypto.subtle`.

[componentize-js]: https://github.com/dicej/componentize-js
[componentize-js]: https://github.com/lann/componentize-js

## Surface

Expand Down Expand Up @@ -96,16 +96,18 @@ To use a build of your own instead — a platform with no published asset, or
a revision you are evaluating — put it on `COMPONENTIZE_JS`:

```sh
git clone https://github.com/dicej/componentize-js
git clone https://github.com/lann/componentize-js
cd componentize-js
git checkout "$(cat path/to/js/componentize/componentize-js.rev)"
# Needs WASI-SDK 30 on WASI_SDK_PATH; see that repository's README.
cargo install --path .
export COMPONENTIZE_JS="$(command -v componentize-js)"
```

One further upstream quirk needs no action: an async import that completes
*without* suspending resolves with the raw canonical `result` wrapper
(`{ tag, val }`) instead of the unwrapped value. The library normalizes both
settlement shapes internally (see `callImport` in `webcrypto.js`), so it
works unchanged whether or not that is fixed upstream.
The pin also includes the eager-settlement fix,
[lann/componentize-js#1](https://github.com/lann/componentize-js/pull/1):
revisions before it resolve an async import that completes *without*
suspending with the raw canonical `result` wrapper (`{ tag, val }`) instead
of the unwrapped value. The library normalizes both settlement shapes
internally (see `callImport` in `webcrypto.js`), so it runs unchanged on
revisions either side of that fix.
2 changes: 1 addition & 1 deletion js/componentize/componentize-js.rev
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bdd7c3d50e064d9c820218dbeb98be8bcae96875
f417fa6d5f747a6fe8a956fcb7f18806bfa508fd
4 changes: 2 additions & 2 deletions js/componentize/componentize-js.sha256
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# Regenerate with `just componentize::update-toolchain-digest` when the revision changes:
# it verifies the attestation before recording, so adding a line here is the
# deliberate, reviewable act of trusting a new binary.
linux-aarch64 043b3695a82fef4114454fa3e7195d8bfcaf704ac8e3880ba53e27526d2620ee e64592d1009bf7eed52d2d3efe33420c5c4c8d323bd9c3062db4fffe75cb713c
linux-x86_64 9a38c0a6b82f0bab9ac63cfc65d3a4218f65c96c68fe43998e0053762d1697cd 69b9b79f422abf26b0836a5ddd653ce751c433adf944d465b71f89cca31ff927
linux-aarch64 f18dc2a472946fb531d6a6a64ca8e29d14c48027c6d719ccb5120c57e2d9eeb3 b5a7663d4893a239281408772c343f37e324ac778fbf9fc9b09368f52222580f
linux-x86_64 be573cd7631ccc10d3daa2c5b8b1ae99c3026e69e5fade0286287bcaed843963 ba88d9a02a04f15a0744eb6753944e7cf3b39a84eae4085f4654351c4687846c
18 changes: 10 additions & 8 deletions js/componentize/webcrypto.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
// A WebCrypto-subset library for JS guests componentized with
// componentize-js (https://github.com/dicej/componentize-js, the wit-dylib
// componentize-js (https://github.com/lann/componentize-js, the wit-dylib
// reboot of ComponentizeJS), backed by the `polymorph:webcrypto` interfaces.
//
// The surface mirrors `crypto.subtle` for the supported algorithms:
Expand Down Expand Up @@ -326,13 +326,15 @@ async function verdict(operation) {
/**
* Await an async `polymorph:webcrypto` import and normalize its settlement.
*
* componentize-js (as of the revision pinned in componentize-js.rev)
* settles async imports through two paths: an import that suspends resolves
* with the `ok` value unwrapped and rejects an `err` as a `ComponentError`,
* but an import that completes without blocking resolves with the raw
* canonical `result` wrapper (`{ tag: "ok" | "err", val }`). Detecting the
* wrapper is unambiguous for this surface: every `ok` payload is a
* resource, typed array, or `undefined` — never a plain `{ tag }` object.
* componentize-js settles a suspending import with the `ok` value unwrapped
* and rejects an `err` as a `ComponentError`; revisions before the
* eager-settlement fix (lann/componentize-js#1, included in the pinned
* revision) settle an import that completes without blocking with the raw
* canonical `result` wrapper (`{ tag: "ok" | "err", val }`) instead. Both
* shapes are normalized here, so the library runs on revisions either side
* of that fix. Detecting the wrapper is unambiguous for this surface: every
* `ok` payload is a resource, typed array, or `undefined` — never a plain
* `{ tag }` object.
* @param {unknown} promise
* @returns {Promise<any>}
*/
Expand Down
Loading