@mowaos/host-browser 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,12 @@ in the browser and provides what the kernel deliberately leaves out:
12
12
  - **Verification:** every step's event, facts and context are kept with its commit,
13
13
  and `exportVerificationBundle(sessionIds)` exports a case so anyone can replay its
14
14
  decisions with the open kernel.
15
+ - **Anchors** (since 0.7.0, [docs/anchoring.md](../../docs/anchoring.md)):
16
+ `importAnchors(anchors)` stores an issuer's anchors once they fit the host's records
17
+ (the session and step exist, with the same `resultHash`), and exported bundles carry
18
+ them. `MowaStorage` adapters support anchors through the optional `saveAnchor` and
19
+ `getAnchors` methods; `IndexedDbStorage` keeps them in its version 4 schema, which
20
+ existing databases upgrade to on first open.
15
21
 
16
22
  The kernel's WASM module is passed in, not bundled, so you control which verified
17
23
  build you run:
@@ -27,6 +33,22 @@ const host = new MowaBrowserHost(new WasmKernelBridge(wasm), {
27
33
  });
28
34
  ```
29
35
 
36
+ **Conformance suite** (since 0.8.0): a storage adapter written elsewhere runs the same
37
+ tests as `MemoryStorage` and `SqliteStorage`, under `node --test`:
38
+
39
+ ```js
40
+ import * as lib from "@mowaos/host-browser";
41
+ import { hostSuite } from "@mowaos/host-browser/conformance";
42
+ import { loadKernel } from "@mowaos/kernel";
43
+
44
+ hostSuite("MyStorage", {
45
+ lib,
46
+ wasmPkg: await loadKernel(),
47
+ makeStorage: () => new MyStorage(),
48
+ clearSteps: (storage) => storage.deleteAllSteps(), // imitates a host from before 0.5.0
49
+ });
50
+ ```
51
+
30
52
  What every host must guarantee is specified in the
31
53
  [host contract](../../docs/host-contract.md). Each release attaches the WASM build and its
32
54
  SHA-256 checksum. Licensed under Apache-2.0.
@@ -0,0 +1,15 @@
1
+ import type { MowaStorage } from "../dist/index.js";
2
+
3
+ export interface HostSuiteOptions {
4
+ /** The @mowaos/host-browser module the storage was built against. */
5
+ lib: typeof import("../dist/index.js");
6
+ /** The kernel's bindings: startJson, advanceJson, loadFlowJson, dedupKeyJson, kernelVersion. */
7
+ wasmPkg: unknown;
8
+ /** A new, empty storage for each test. */
9
+ makeStorage: () => MowaStorage | Promise<MowaStorage>;
10
+ /** Deletes every step record from a storage, to imitate a host from before 0.5.0. */
11
+ clearSteps: (storage: MowaStorage) => void | Promise<void>;
12
+ }
13
+
14
+ /** Registers the host conformance tests (node:test) for one storage adapter. */
15
+ export function hostSuite(name: string, options: HostSuiteOptions): void;