@mindees/updates 0.8.0 โ†’ 0.10.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/dist/errors.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * @module
10
10
  */
11
11
  /** Stable code identifying why an OTA update operation failed. */
12
- type UpdateErrorCode = /** The manifest JSON is missing required fields or has the wrong shape. */'MANIFEST_MALFORMED' /** Fewer than `threshold` valid signatures from distinct trusted keys. */ | 'SIGNATURE_INVALID' /** A downloaded asset's SHA-256 does not match the manifest. */ | 'HASH_MISMATCH' /** A differential delta is malformed or out of bounds (see `delta.ts`). */ | 'DELTA_INVALID' /** `manifest.expires` is in the past (stale / freeze-attack protection). */ | 'MANIFEST_EXPIRED' /** The manifest's `runtimeVersion` does not match the app (native-incompatibility gate). */ | 'RUNTIME_MISMATCH' /** The manifest/generation is not strictly newer than what is applied (anti-downgrade). */ | 'VERSION_NOT_NEWER' /** An asset a generation needs is not present in the store. */ | 'ASSET_MISSING' /** `apply()`/`rollback()` referenced a generation id that does not exist. */ | 'GENERATION_UNKNOWN' /** `apply()` referenced a generation previously marked failed (cannot be re-activated). */ | 'GENERATION_FAILED';
12
+ type UpdateErrorCode = /** The manifest JSON is missing required fields or has the wrong shape. */'MANIFEST_MALFORMED' /** Fewer than `threshold` valid signatures from distinct trusted keys. */ | 'SIGNATURE_INVALID' /** A downloaded asset's SHA-256 does not match the manifest. */ | 'HASH_MISMATCH' /** A differential delta is malformed or out of bounds (see `delta.ts`). */ | 'DELTA_INVALID' /** `manifest.expires` is in the past (stale / freeze-attack protection). */ | 'MANIFEST_EXPIRED' /** The manifest's `runtimeVersion` does not match the app (native-incompatibility gate). */ | 'RUNTIME_MISMATCH' /** The manifest/generation is not strictly newer than what is applied (anti-downgrade). */ | 'VERSION_NOT_NEWER' /** An asset a generation needs is not present in the store. */ | 'ASSET_MISSING' /** `apply()`/`rollback()` referenced a generation id that does not exist. */ | 'GENERATION_UNKNOWN' /** `apply()` referenced a generation previously marked failed (cannot be re-activated). */ | 'GENERATION_FAILED' /** A WASM feature module is malformed, too large, or missing a required capability import. */ | 'MODULE_INVALID';
13
13
  /** An OTA update error carrying a stable {@link UpdateErrorCode}. */
14
14
  declare class UpdateError extends Error {
15
15
  /** Stable, machine-readable cause. */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;AAWA;;;;AAA2B;AAuB3B;;;;KAvBY,eAAA;;cAuBC,WAAA,SAAoB,KAAA;;WAEtB,IAAA,EAAM,eAAA;cAEH,IAAA,EAAM,eAAA,EAAiB,OAAA;AAAA"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;AAWA;;;;AAA2B;AAyB3B;;;;KAzBY,eAAA;;cAyBC,WAAA,SAAoB,KAAA;;WAEtB,IAAA,EAAM,eAAA;cAEH,IAAA,EAAM,eAAA,EAAiB,OAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Errors for `@mindees/updates` (Pulse).\n *\n * Every failure carries a stable {@link UpdateErrorCode} so callers can branch on\n * the cause (e.g. distinguish a tampered bundle from a stale manifest) without\n * string-matching messages.\n *\n * @module\n */\n\n/** Stable code identifying why an OTA update operation failed. */\nexport type UpdateErrorCode =\n /** The manifest JSON is missing required fields or has the wrong shape. */\n | 'MANIFEST_MALFORMED'\n /** Fewer than `threshold` valid signatures from distinct trusted keys. */\n | 'SIGNATURE_INVALID'\n /** A downloaded asset's SHA-256 does not match the manifest. */\n | 'HASH_MISMATCH'\n /** A differential delta is malformed or out of bounds (see `delta.ts`). */\n | 'DELTA_INVALID'\n /** `manifest.expires` is in the past (stale / freeze-attack protection). */\n | 'MANIFEST_EXPIRED'\n /** The manifest's `runtimeVersion` does not match the app (native-incompatibility gate). */\n | 'RUNTIME_MISMATCH'\n /** The manifest/generation is not strictly newer than what is applied (anti-downgrade). */\n | 'VERSION_NOT_NEWER'\n /** An asset a generation needs is not present in the store. */\n | 'ASSET_MISSING'\n /** `apply()`/`rollback()` referenced a generation id that does not exist. */\n | 'GENERATION_UNKNOWN'\n /** `apply()` referenced a generation previously marked failed (cannot be re-activated). */\n | 'GENERATION_FAILED'\n\n/** An OTA update error carrying a stable {@link UpdateErrorCode}. */\nexport class UpdateError extends Error {\n /** Stable, machine-readable cause. */\n readonly code: UpdateErrorCode\n\n constructor(code: UpdateErrorCode, message: string) {\n super(message)\n this.name = 'UpdateError'\n this.code = code\n }\n}\n"],"mappings":";;AAkCA,IAAa,cAAb,cAAiC,MAAM;;CAErC;CAEA,YAAY,MAAuB,SAAiB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Errors for `@mindees/updates` (Pulse).\n *\n * Every failure carries a stable {@link UpdateErrorCode} so callers can branch on\n * the cause (e.g. distinguish a tampered bundle from a stale manifest) without\n * string-matching messages.\n *\n * @module\n */\n\n/** Stable code identifying why an OTA update operation failed. */\nexport type UpdateErrorCode =\n /** The manifest JSON is missing required fields or has the wrong shape. */\n | 'MANIFEST_MALFORMED'\n /** Fewer than `threshold` valid signatures from distinct trusted keys. */\n | 'SIGNATURE_INVALID'\n /** A downloaded asset's SHA-256 does not match the manifest. */\n | 'HASH_MISMATCH'\n /** A differential delta is malformed or out of bounds (see `delta.ts`). */\n | 'DELTA_INVALID'\n /** `manifest.expires` is in the past (stale / freeze-attack protection). */\n | 'MANIFEST_EXPIRED'\n /** The manifest's `runtimeVersion` does not match the app (native-incompatibility gate). */\n | 'RUNTIME_MISMATCH'\n /** The manifest/generation is not strictly newer than what is applied (anti-downgrade). */\n | 'VERSION_NOT_NEWER'\n /** An asset a generation needs is not present in the store. */\n | 'ASSET_MISSING'\n /** `apply()`/`rollback()` referenced a generation id that does not exist. */\n | 'GENERATION_UNKNOWN'\n /** `apply()` referenced a generation previously marked failed (cannot be re-activated). */\n | 'GENERATION_FAILED'\n /** A WASM feature module is malformed, too large, or missing a required capability import. */\n | 'MODULE_INVALID'\n\n/** An OTA update error carrying a stable {@link UpdateErrorCode}. */\nexport class UpdateError extends Error {\n /** Stable, machine-readable cause. */\n readonly code: UpdateErrorCode\n\n constructor(code: UpdateErrorCode, message: string) {\n super(message)\n this.name = 'UpdateError'\n this.code = code\n }\n}\n"],"mappings":";;AAoCA,IAAa,cAAb,cAAiC,MAAM;;CAErC;CAEA,YAAY,MAAuB,SAAiB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF"}
package/dist/index.d.ts CHANGED
@@ -5,13 +5,15 @@ import { BootResult, UpdateCheck, UpdateClient, UpdateClientOptions, createUpdat
5
5
  import { Keypair, fromHex, generateKeypair, getPublicKey, sha256Hex, sign, toHex, utf8, verify } from "./crypto.js";
6
6
  import { ApplyDeltaOptions, applyDelta, diff } from "./delta.js";
7
7
  import { UpdateError, UpdateErrorCode } from "./errors.js";
8
+ import { JsonPatchOp, SduiActionHandler, SduiActionRef, SduiBindRef, SduiError, SduiErrorCode, SduiJson, SduiLimits, SduiNode, SduiPropValue, SduiRegistry, applyJsonPatch, applyMergePatch, compileSdui } from "./sdui.js";
9
+ import { Capabilities, WasmModuleInstance, WasmModuleRuntime, WasmModuleRuntimeOptions, createWasmModuleRuntime } from "./wasm.js";
8
10
  import { Maturity, NotImplementedError, PackageInfo, notImplemented } from "@mindees/core";
9
11
 
10
12
  //#region src/index.d.ts
11
13
  /** The npm package name. */
12
14
  declare const name = "@mindees/updates";
13
15
  /** The package version. All `@mindees/*` packages share one locked version line. */
14
- declare const VERSION = "0.8.0";
16
+ declare const VERSION = "0.10.0";
15
17
  /** Current maturity. See the repository `STATUS.md`. */
16
18
  declare const maturity: Maturity;
17
19
  /**
@@ -20,15 +22,6 @@ declare const maturity: Maturity;
20
22
  * matching the `readonly` fields of {@link PackageInfo}.
21
23
  */
22
24
  declare const info: PackageInfo;
23
- /**
24
- * ๐Ÿ”ฌ Research track โ€” not implemented. A sandboxed WASM module runtime for shipping
25
- * signed, capability-secure feature modules at runtime. Throws
26
- * {@link NotImplementedError}; the working path today is signed JS/asset updates
27
- * (above).
28
- *
29
- * @experimental
30
- */
31
- declare function createWasmModuleRuntime(): never;
32
25
  //#endregion
33
- export { type ApplyDeltaOptions, type AssetEntry, type BootResult, type GenerationMeta, type GenerationStatus, type Keypair, type Maturity, NotImplementedError, type PackageInfo, type PatchDescriptor, type SignatureEntry, type SignedManifest, type Signer, type TrustedKey, type UpdateCheck, type UpdateClient, type UpdateClientOptions, UpdateError, type UpdateErrorCode, type UpdateManifest, type UpdateState, type UpdateStorage, VERSION, type VerifiedManifest, allAssets, applyDelta, canonicalManifestJson, createMemoryStorage, createUpdateClient, createWasmModuleRuntime, diff, fromHex, generateKeypair, getPublicKey, info, initialState, maturity, name, notImplemented, parseManifest, sha256Hex, sign, signManifest, toHex, utf8, verify, verifySignedManifest };
26
+ export { type ApplyDeltaOptions, type AssetEntry, type BootResult, type Capabilities, type GenerationMeta, type GenerationStatus, type JsonPatchOp, type Keypair, type Maturity, NotImplementedError, type PackageInfo, type PatchDescriptor, type SduiActionHandler, type SduiActionRef, type SduiBindRef, SduiError, type SduiErrorCode, type SduiJson, type SduiLimits, type SduiNode, type SduiPropValue, type SduiRegistry, type SignatureEntry, type SignedManifest, type Signer, type TrustedKey, type UpdateCheck, type UpdateClient, type UpdateClientOptions, UpdateError, type UpdateErrorCode, type UpdateManifest, type UpdateState, type UpdateStorage, VERSION, type VerifiedManifest, type WasmModuleInstance, type WasmModuleRuntime, type WasmModuleRuntimeOptions, allAssets, applyDelta, applyJsonPatch, applyMergePatch, canonicalManifestJson, compileSdui, createMemoryStorage, createUpdateClient, createWasmModuleRuntime, diff, fromHex, generateKeypair, getPublicKey, info, initialState, maturity, name, notImplemented, parseManifest, sha256Hex, sign, signManifest, toHex, utf8, verify, verifySignedManifest };
34
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;cAgBa,IAAA;AAGb;AAAA,cAAa,OAAA;;cAGA,QAAA,EAAU,QAAyB;AAH5B;AAGpB;;;;AAHoB,cAUP,IAAA,EAAM,WAAiE;;;AAwD7C;;;;;;iBAAvB,uBAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;cAgBa,IAAA;;cAGA,OAAA;AAAb;AAAA,cAGa,QAAA,EAAU,QAAyB;;;AAH5B;AAGpB;;cAOa,IAAA,EAAM,WAAiE"}
package/dist/index.js CHANGED
@@ -5,12 +5,14 @@ import { allAssets, canonicalManifestJson, parseManifest } from "./manifest.js";
5
5
  import { signManifest, verifySignedManifest } from "./signing.js";
6
6
  import { createMemoryStorage, initialState } from "./store.js";
7
7
  import { createUpdateClient } from "./client.js";
8
+ import { SduiError, applyJsonPatch, applyMergePatch, compileSdui } from "./sdui.js";
9
+ import { createWasmModuleRuntime } from "./wasm.js";
8
10
  import { NotImplementedError, notImplemented } from "@mindees/core";
9
11
  //#region src/index.ts
10
12
  /** The npm package name. */
11
13
  const name = "@mindees/updates";
12
14
  /** The package version. All `@mindees/*` packages share one locked version line. */
13
- const VERSION = "0.8.0";
15
+ const VERSION = "0.10.0";
14
16
  /** Current maturity. See the repository `STATUS.md`. */
15
17
  const maturity = "experimental";
16
18
  /**
@@ -23,18 +25,7 @@ const info = Object.freeze({
23
25
  version: VERSION,
24
26
  maturity
25
27
  });
26
- /**
27
- * ๐Ÿ”ฌ Research track โ€” not implemented. A sandboxed WASM module runtime for shipping
28
- * signed, capability-secure feature modules at runtime. Throws
29
- * {@link NotImplementedError}; the working path today is signed JS/asset updates
30
- * (above).
31
- *
32
- * @experimental
33
- */
34
- function createWasmModuleRuntime() {
35
- throw new NotImplementedError("WASM Component-Model module runtime for OTA updates");
36
- }
37
28
  //#endregion
38
- export { NotImplementedError, UpdateError, VERSION, allAssets, applyDelta, canonicalManifestJson, createMemoryStorage, createUpdateClient, createWasmModuleRuntime, diff, fromHex, generateKeypair, getPublicKey, info, initialState, maturity, name, notImplemented, parseManifest, sha256Hex, sign, signManifest, toHex, utf8, verify, verifySignedManifest };
29
+ export { NotImplementedError, SduiError, UpdateError, VERSION, allAssets, applyDelta, applyJsonPatch, applyMergePatch, canonicalManifestJson, compileSdui, createMemoryStorage, createUpdateClient, createWasmModuleRuntime, diff, fromHex, generateKeypair, getPublicKey, info, initialState, maturity, name, notImplemented, parseManifest, sha256Hex, sign, signManifest, toHex, utf8, verify, verifySignedManifest };
39
30
 
40
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@mindees/updates` (Pulse) โ€” signed OTA updates.\n *\n * Pulse ships a versioned, hash-addressed {@link UpdateManifest}, Ed25519\n * {@link signManifest signing}/{@link verifySignedManifest verification} (threshold +\n * key rotation), a content-addressed {@link UpdateStorage store}, an\n * {@link createUpdateClient update client} with atomic generations + crash-loop\n * rollback, differential bundle diffing, a reference update server, and SDUI.\n *\n * @module\n */\n\nimport type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** The npm package name. */\nexport const name = '@mindees/updates'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.8.0'\n\n/** Current maturity. See the repository `STATUS.md`. */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n\nexport {\n type BootResult,\n createUpdateClient,\n type UpdateCheck,\n type UpdateClient,\n type UpdateClientOptions,\n} from './client'\nexport {\n fromHex,\n generateKeypair,\n getPublicKey,\n type Keypair,\n sha256Hex,\n sign,\n toHex,\n utf8,\n verify,\n} from './crypto'\nexport { type ApplyDeltaOptions, applyDelta, diff } from './delta'\nexport { UpdateError, type UpdateErrorCode } from './errors'\nexport {\n type AssetEntry,\n allAssets,\n canonicalManifestJson,\n type PatchDescriptor,\n parseManifest,\n type UpdateManifest,\n} from './manifest'\nexport {\n type SignatureEntry,\n type SignedManifest,\n type Signer,\n signManifest,\n type TrustedKey,\n type VerifiedManifest,\n verifySignedManifest,\n} from './signing'\nexport {\n createMemoryStorage,\n type GenerationMeta,\n type GenerationStatus,\n initialState,\n type UpdateState,\n type UpdateStorage,\n} from './store'\n\n/**\n * ๐Ÿ”ฌ Research track โ€” not implemented. A sandboxed WASM module runtime for shipping\n * signed, capability-secure feature modules at runtime. Throws\n * {@link NotImplementedError}; the working path today is signed JS/asset updates\n * (above).\n *\n * @experimental\n */\nexport function createWasmModuleRuntime(): never {\n throw new NotImplementedError('WASM Component-Model module runtime for OTA updates')\n}\n\nexport type { Maturity, PackageInfo }\nexport { NotImplementedError, notImplemented }\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;AAGvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC;;;;;;;;;AAwDnF,SAAgB,0BAAiC;CAC/C,MAAM,IAAI,oBAAoB,qDAAqD;AACrF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@mindees/updates` (Pulse) โ€” signed OTA updates.\n *\n * Pulse ships a versioned, hash-addressed {@link UpdateManifest}, Ed25519\n * {@link signManifest signing}/{@link verifySignedManifest verification} (threshold +\n * key rotation), a content-addressed {@link UpdateStorage store}, an\n * {@link createUpdateClient update client} with atomic generations + crash-loop\n * rollback, differential bundle diffing, a reference update server, and SDUI.\n *\n * @module\n */\n\nimport type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** The npm package name. */\nexport const name = '@mindees/updates'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.10.0'\n\n/** Current maturity. See the repository `STATUS.md`. */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n\nexport {\n type BootResult,\n createUpdateClient,\n type UpdateCheck,\n type UpdateClient,\n type UpdateClientOptions,\n} from './client'\nexport {\n fromHex,\n generateKeypair,\n getPublicKey,\n type Keypair,\n sha256Hex,\n sign,\n toHex,\n utf8,\n verify,\n} from './crypto'\nexport { type ApplyDeltaOptions, applyDelta, diff } from './delta'\nexport { UpdateError, type UpdateErrorCode } from './errors'\nexport {\n type AssetEntry,\n allAssets,\n canonicalManifestJson,\n type PatchDescriptor,\n parseManifest,\n type UpdateManifest,\n} from './manifest'\n/**\n * Server-Driven UI (Pulse ยง10): compile an allowlisted, schema-versioned JSON tree into a live\n * MindeesNode tree, and apply incremental updates with JSON Merge Patch (RFC 7396) / JSON Patch\n * (RFC 6902). No `eval` โ€” components + actions are pre-registered.\n */\nexport {\n applyJsonPatch,\n applyMergePatch,\n compileSdui,\n type JsonPatchOp,\n type SduiActionHandler,\n type SduiActionRef,\n type SduiBindRef,\n SduiError,\n type SduiErrorCode,\n type SduiJson,\n type SduiLimits,\n type SduiNode,\n type SduiPropValue,\n type SduiRegistry,\n} from './sdui'\nexport {\n type SignatureEntry,\n type SignedManifest,\n type Signer,\n signManifest,\n type TrustedKey,\n type VerifiedManifest,\n verifySignedManifest,\n} from './signing'\nexport {\n createMemoryStorage,\n type GenerationMeta,\n type GenerationStatus,\n initialState,\n type UpdateState,\n type UpdateStorage,\n} from './store'\n\n/**\n * Pulse sandboxed WASM module runtime (spec ยง10) โ€” ship signed, capability-secure feature modules\n * that run at runtime in their own linear memory, reachable only through the capabilities you grant.\n * Core WebAssembly today; the full Component Model (WASI 0.2/0.3) is a follow-up behind the same seam.\n */\nexport {\n type Capabilities,\n createWasmModuleRuntime,\n type WasmModuleInstance,\n type WasmModuleRuntime,\n type WasmModuleRuntimeOptions,\n} from './wasm'\n\nexport type { Maturity, PackageInfo }\nexport { NotImplementedError, notImplemented }\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;AAGvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
package/dist/wasm.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ //#region src/wasm.d.ts
2
+ /**
3
+ * **Pulse sandboxed WASM modules** (spec ยง10) โ€” ship signed, capability-secure feature modules that
4
+ * run at runtime, isolated in their own linear memory. A module gets ONLY the host capabilities you
5
+ * pass it (the import object); it has no ambient access to the JS realm, the network, or the DOM โ€” a
6
+ * true capability sandbox. This is core WebAssembly (works on Hermes/RN, Node, and the web today);
7
+ * the full WASM **Component Model** (WASI 0.2/0.3 typed interfaces) is a labeled follow-up that slots
8
+ * in behind the same `instantiate` seam.
9
+ *
10
+ * @module
11
+ */
12
+ type WasmBytes = ArrayBuffer | ArrayBufferView;
13
+ /** A module's exported linear memory. */
14
+ interface WasmMemory {
15
+ readonly buffer: ArrayBuffer;
16
+ }
17
+ /** A host capability surface handed to a module: `{ "module": { "fn": (...) => ... } }`. */
18
+ type Capabilities = Record<string, Record<string, (...args: never[]) => unknown>>;
19
+ /** A live, sandboxed module instance. */
20
+ interface WasmModuleInstance {
21
+ /** The module's exports (functions, memory, globals). */
22
+ readonly exports: Readonly<Record<string, unknown>>;
23
+ /** Call an exported function by name (throws `MODULE_INVALID` if it isn't an exported function). */
24
+ call<R = unknown>(name: string, ...args: number[]): R;
25
+ /** The module's exported linear memory, if any. */
26
+ readonly memory?: WasmMemory;
27
+ }
28
+ /** Options for {@link createWasmModuleRuntime}. */
29
+ interface WasmModuleRuntimeOptions {
30
+ /** Reject modules larger than this many bytes (anti-bloat / anti-DoS). Default: 16 MiB. */
31
+ readonly maxBytes?: number;
32
+ }
33
+ /** The runtime that instantiates sandboxed WASM feature modules. */
34
+ interface WasmModuleRuntime {
35
+ /**
36
+ * Instantiate `bytes` with EXACTLY the given `capabilities` as imports (nothing else is reachable).
37
+ * Rejects (`MODULE_INVALID`) on a malformed/oversized module or a missing required import.
38
+ */
39
+ instantiate(bytes: WasmBytes, capabilities?: Capabilities): Promise<WasmModuleInstance>;
40
+ }
41
+ /**
42
+ * Create a sandboxed WASM module runtime. A module sees only the `capabilities` you pass to
43
+ * `instantiate` โ€” capability-secure by construction.
44
+ */
45
+ declare function createWasmModuleRuntime(options?: WasmModuleRuntimeOptions): WasmModuleRuntime;
46
+ //#endregion
47
+ export { Capabilities, WasmModuleInstance, WasmModuleRuntime, WasmModuleRuntimeOptions, createWasmModuleRuntime };
48
+ //# sourceMappingURL=wasm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm.d.ts","names":[],"sources":["../src/wasm.ts"],"mappings":";;;;;;AAgB8C;AAE9C;;;;KAFK,SAAA,GAAY,WAAA,GAAc,eAAe;AAmB9C;AAAA,UAjBiB,UAAA;EAAA,SACN,MAAA,EAAQ,WAAW;AAAA;;KAgBlB,YAAA,GAAe,MAAM,SAAS,MAAA,aAAmB,IAAA;;UAG5C,kBAAA;EAHgD;EAAA,SAKtD,OAAA,EAAS,QAAA,CAAS,MAAA;EAFM;EAIjC,IAAA,cAAkB,IAAA,aAAiB,IAAA,aAAiB,CAAA;EAFzB;EAAA,SAIlB,MAAA,GAAS,UAAA;AAAA;;UAIH,wBAAA;EAJa;EAAA,SAMnB,QAAQ;AAAA;;UAIF,iBAAA;EAZV;;;;EAiBL,WAAA,CAAY,KAAA,EAAO,SAAA,EAAW,YAAA,GAAe,YAAA,GAAe,OAAA,CAAQ,kBAAA;AAAA;;AAfxC;AAI9B;;iBAoBgB,uBAAA,CAAwB,OAAA,GAAS,wBAAA,GAAgC,iBAAiB"}
package/dist/wasm.js ADDED
@@ -0,0 +1,46 @@
1
+ import { UpdateError } from "./errors.js";
2
+ //#region src/wasm.ts
3
+ /**
4
+ * **Pulse sandboxed WASM modules** (spec ยง10) โ€” ship signed, capability-secure feature modules that
5
+ * run at runtime, isolated in their own linear memory. A module gets ONLY the host capabilities you
6
+ * pass it (the import object); it has no ambient access to the JS realm, the network, or the DOM โ€” a
7
+ * true capability sandbox. This is core WebAssembly (works on Hermes/RN, Node, and the web today);
8
+ * the full WASM **Component Model** (WASI 0.2/0.3 typed interfaces) is a labeled follow-up that slots
9
+ * in behind the same `instantiate` seam.
10
+ *
11
+ * @module
12
+ */
13
+ const DEFAULT_MAX_BYTES = 16 * 1024 * 1024;
14
+ /**
15
+ * Create a sandboxed WASM module runtime. A module sees only the `capabilities` you pass to
16
+ * `instantiate` โ€” capability-secure by construction.
17
+ */
18
+ function createWasmModuleRuntime(options = {}) {
19
+ const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
20
+ return { async instantiate(bytes, capabilities = {}) {
21
+ const size = bytes.byteLength;
22
+ if (size > maxBytes) throw new UpdateError("MODULE_INVALID", `WASM module is ${size} B, over the ${maxBytes} B limit`);
23
+ if (!WebAssembly.validate(bytes)) throw new UpdateError("MODULE_INVALID", "WASM module failed validation (malformed bytecode)");
24
+ let instance;
25
+ try {
26
+ instance = (await WebAssembly.instantiate(bytes, capabilities)).instance;
27
+ } catch (error) {
28
+ throw new UpdateError("MODULE_INVALID", `WASM module could not be instantiated: ${error instanceof Error ? error.message : String(error)}`);
29
+ }
30
+ const exports = instance.exports;
31
+ const memory = exports.memory instanceof WebAssembly.Memory ? exports.memory : void 0;
32
+ return {
33
+ exports,
34
+ call(name, ...args) {
35
+ const fn = exports[name];
36
+ if (typeof fn !== "function") throw new UpdateError("MODULE_INVALID", `WASM module has no exported function "${name}"`);
37
+ return fn(...args);
38
+ },
39
+ ...memory ? { memory } : {}
40
+ };
41
+ } };
42
+ }
43
+ //#endregion
44
+ export { createWasmModuleRuntime };
45
+
46
+ //# sourceMappingURL=wasm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm.js","names":[],"sources":["../src/wasm.ts"],"sourcesContent":["/**\n * **Pulse sandboxed WASM modules** (spec ยง10) โ€” ship signed, capability-secure feature modules that\n * run at runtime, isolated in their own linear memory. A module gets ONLY the host capabilities you\n * pass it (the import object); it has no ambient access to the JS realm, the network, or the DOM โ€” a\n * true capability sandbox. This is core WebAssembly (works on Hermes/RN, Node, and the web today);\n * the full WASM **Component Model** (WASI 0.2/0.3 typed interfaces) is a labeled follow-up that slots\n * in behind the same `instantiate` seam.\n *\n * @module\n */\n\nimport { UpdateError } from './errors'\n\n// Self-contained typing for the JS-standard `WebAssembly` global. This package targets a neutral\n// runtime (Hermes/RN, Node, web) WITHOUT the DOM lib, so we declare exactly the surface we use rather\n// than pulling in `lib.dom`/`lib.webworker` (which would also leak `document`, `fetch`, etc.).\ntype WasmBytes = ArrayBuffer | ArrayBufferView\n/** A module's exported linear memory. */\nexport interface WasmMemory {\n readonly buffer: ArrayBuffer\n}\ninterface WasmInstance {\n readonly exports: Record<string, unknown>\n}\ninterface WasmEngine {\n validate(bytes: WasmBytes): boolean\n instantiate(\n bytes: WasmBytes,\n imports?: Record<string, Record<string, unknown>>,\n ): Promise<{ instance: WasmInstance }>\n readonly Memory: new (descriptor: { initial: number }) => WasmMemory\n}\ndeclare const WebAssembly: WasmEngine\n\n/** A host capability surface handed to a module: `{ \"module\": { \"fn\": (...) => ... } }`. */\nexport type Capabilities = Record<string, Record<string, (...args: never[]) => unknown>>\n\n/** A live, sandboxed module instance. */\nexport interface WasmModuleInstance {\n /** The module's exports (functions, memory, globals). */\n readonly exports: Readonly<Record<string, unknown>>\n /** Call an exported function by name (throws `MODULE_INVALID` if it isn't an exported function). */\n call<R = unknown>(name: string, ...args: number[]): R\n /** The module's exported linear memory, if any. */\n readonly memory?: WasmMemory\n}\n\n/** Options for {@link createWasmModuleRuntime}. */\nexport interface WasmModuleRuntimeOptions {\n /** Reject modules larger than this many bytes (anti-bloat / anti-DoS). Default: 16 MiB. */\n readonly maxBytes?: number\n}\n\n/** The runtime that instantiates sandboxed WASM feature modules. */\nexport interface WasmModuleRuntime {\n /**\n * Instantiate `bytes` with EXACTLY the given `capabilities` as imports (nothing else is reachable).\n * Rejects (`MODULE_INVALID`) on a malformed/oversized module or a missing required import.\n */\n instantiate(bytes: WasmBytes, capabilities?: Capabilities): Promise<WasmModuleInstance>\n}\n\nconst DEFAULT_MAX_BYTES = 16 * 1024 * 1024\n\n/**\n * Create a sandboxed WASM module runtime. A module sees only the `capabilities` you pass to\n * `instantiate` โ€” capability-secure by construction.\n */\nexport function createWasmModuleRuntime(options: WasmModuleRuntimeOptions = {}): WasmModuleRuntime {\n const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES\n return {\n async instantiate(bytes, capabilities = {}) {\n const size = bytes.byteLength\n if (size > maxBytes) {\n throw new UpdateError(\n 'MODULE_INVALID',\n `WASM module is ${size} B, over the ${maxBytes} B limit`,\n )\n }\n if (!WebAssembly.validate(bytes)) {\n throw new UpdateError(\n 'MODULE_INVALID',\n 'WASM module failed validation (malformed bytecode)',\n )\n }\n let instance: WasmInstance\n try {\n // The import object IS the sandbox: only `capabilities` is reachable from inside the module.\n const result = await WebAssembly.instantiate(bytes, capabilities)\n instance = result.instance\n } catch (error) {\n // A missing/typed-wrong import (LinkError) or a compile error โ†’ the module asked for a\n // capability it wasn't granted; refuse it deterministically.\n throw new UpdateError(\n 'MODULE_INVALID',\n `WASM module could not be instantiated: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n const exports = instance.exports as Record<string, unknown>\n const memory = exports.memory instanceof WebAssembly.Memory ? exports.memory : undefined\n const handle: WasmModuleInstance = {\n exports,\n call<R = unknown>(name: string, ...args: number[]): R {\n const fn = exports[name]\n if (typeof fn !== 'function') {\n throw new UpdateError(\n 'MODULE_INVALID',\n `WASM module has no exported function \"${name}\"`,\n )\n }\n return (fn as (...a: number[]) => R)(...args)\n },\n // Only present when the module exports memory (exactOptionalPropertyTypes).\n ...(memory ? { memory } : {}),\n }\n return handle\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8DA,MAAM,oBAAoB,KAAK,OAAO;;;;;AAMtC,SAAgB,wBAAwB,UAAoC,CAAC,GAAsB;CACjG,MAAM,WAAW,QAAQ,YAAY;CACrC,OAAO,EACL,MAAM,YAAY,OAAO,eAAe,CAAC,GAAG;EAC1C,MAAM,OAAO,MAAM;EACnB,IAAI,OAAO,UACT,MAAM,IAAI,YACR,kBACA,kBAAkB,KAAK,eAAe,SAAS,SACjD;EAEF,IAAI,CAAC,YAAY,SAAS,KAAK,GAC7B,MAAM,IAAI,YACR,kBACA,oDACF;EAEF,IAAI;EACJ,IAAI;GAGF,YAAW,MADU,YAAY,YAAY,OAAO,YAAY,GAC9C;EACpB,SAAS,OAAO;GAGd,MAAM,IAAI,YACR,kBACA,0CAA0C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACjG;EACF;EACA,MAAM,UAAU,SAAS;EACzB,MAAM,SAAS,QAAQ,kBAAkB,YAAY,SAAS,QAAQ,SAAS,KAAA;EAgB/E,OAAO;GAdL;GACA,KAAkB,MAAc,GAAG,MAAmB;IACpD,MAAM,KAAK,QAAQ;IACnB,IAAI,OAAO,OAAO,YAChB,MAAM,IAAI,YACR,kBACA,yCAAyC,KAAK,EAChD;IAEF,OAAQ,GAA6B,GAAG,IAAI;GAC9C;GAEA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAEjB;CACd,EACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindees/updates",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "MindeesNative Pulse - signed over-the-air (OTA) updates: hash-addressed manifests, Ed25519 signing, content-addressed storage, atomic generations with crash-loop rollback.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@noble/curves": "2.2.0",
35
35
  "@noble/hashes": "2.2.0",
36
- "@mindees/core": "0.8.0"
36
+ "@mindees/core": "0.10.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "fast-check": "4.8.0"