space-data-module-sdk 0.9.3 → 0.9.4

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.
@@ -159,6 +159,7 @@
159
159
  <li><code>expect</code> (<code>&quot;ok&quot; | &quot;guest-error&quot; | &quot;trap&quot;</code>) is optional; without it the case only requires the class to be IDENTICAL across lanes (malformed-input fixtures compare error/trap classes this way).</li>
160
160
  <li>Payloads: <code>payloadFile</code> (relative to the fixture), <code>payloadBase64</code>, <code>payloadHex</code>, <code>payloadUtf8</code>.</li>
161
161
  <li>Committed payload binaries are regenerated deterministically by <code>node fixtures/parity/generate-fixtures.mjs</code>.</li>
162
+ <li><code>config</code> (an object, on the fixture or a case; the case's replaces the fixture's, <code>{}</code> by default) is what a module's <code>plugin.getConfig</code> hostcall answers. Every lane serves the typed hostcall bridge (<code>space_data_module_host.call</code> / <code>response_len</code> / <code>read_response</code>): <code>plugin.getConfig</code> answers the case's config as one <code>ModuleConfig</code> on raw <code>config</code> (the answer the SDK JS hosts give), and every other operation a STATUS FAILED <code>unsupported</code> $PIV answer. The WasmEdge CLI provides no host imports, so the wasmedge lanes run an artifact that imports the bridge on the SDK runner (single-thread or not), which replays answers the orchestrator encodes with the SDK's own encoder.</li>
162
163
  </ul>
163
164
  <h2 id="scope-and-current-limits-v1"><a class="anchor" href="#scope-and-current-limits-v1" aria-hidden="true">#</a>Scope and current limits (v1)</h2>
164
165
  <ul>
@@ -113,6 +113,16 @@ Every lane receives EXACTLY the same guest-observable inputs:
113
113
  `payloadHex`, `payloadUtf8`.
114
114
  - Committed payload binaries are regenerated deterministically by
115
115
  `node fixtures/parity/generate-fixtures.mjs`.
116
+ - `config` (an object, on the fixture or a case; the case's replaces the
117
+ fixture's, `{}` by default) is what a module's `plugin.getConfig` hostcall
118
+ answers. Every lane serves the typed hostcall bridge
119
+ (`space_data_module_host.call` / `response_len` / `read_response`):
120
+ `plugin.getConfig` answers the case's config as one `ModuleConfig` on raw
121
+ `config` (the answer the SDK JS hosts give), and every other operation a
122
+ STATUS FAILED `unsupported` $PIV answer. The WasmEdge CLI provides no host
123
+ imports, so the wasmedge lanes run an artifact that imports the bridge on the
124
+ SDK runner (single-thread or not), which replays answers the orchestrator
125
+ encodes with the SDK's own encoder.
116
126
 
117
127
  ## Scope and current limits (v1)
118
128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "space-data-module-sdk",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
6
6
  "type": "module",
@@ -40,6 +40,16 @@ export const ADAPTER_OPERATIONS = Object.freeze({
40
40
  "node_activity_read.activity": { capability: "node_activity_read", adapter: "node", method: "activity" },
41
41
  });
42
42
 
43
+ /**
44
+ * The Go node's other ipfs operations, served by the host's ipfs adapter (options.ipfs / capabilityAdapters.ipfs) as
45
+ * adapter.<method>(params) or adapter.invoke(method, params): the IpfsParams record's set fields as lower-case keys
46
+ * ({cid, name, type, lifetime, ttl}), answered the way Kubo answers ({Objects: [{Links}]}, {Pins}, {Keys}, {ID, ...}).
47
+ */
48
+ export const IPFS_ADAPTER_OPERATIONS = Object.freeze([
49
+ "ipfs.ls", "ipfs.pin_add", "ipfs.pin_rm", "ipfs.pin_ls", "ipfs.dag_get", "ipfs.id", "ipfs.swarm_peers",
50
+ "ipfs.name_resolve", "ipfs.name_publish", "ipfs.pubsub_publish",
51
+ ]);
52
+
43
53
  /** The capabilities those operations need. */
44
54
  export const ADAPTER_CAPABILITIES = Object.freeze(
45
55
  [...new Set(Object.values(ADAPTER_OPERATIONS).map((o) => o.capability).filter(Boolean))],
@@ -22,6 +22,7 @@ import { createBrowserEdgeShims } from "./browserEdgeShims.js";
22
22
  import {
23
23
  ADAPTER_CAPABILITIES,
24
24
  ADAPTER_OPERATIONS,
25
+ IPFS_ADAPTER_OPERATIONS,
25
26
  callServiceAdapter,
26
27
  normalizePluginConfig,
27
28
  resolveServiceAdapters,
@@ -87,6 +88,7 @@ export const BrowserHostSupportedOperations = Object.freeze([
87
88
  "ipfs.invoke",
88
89
  "ipfs.add",
89
90
  "ipfs.cat",
91
+ ...IPFS_ADAPTER_OPERATIONS,
90
92
  "protocol_handle.register",
91
93
  "protocol_handle.unregister",
92
94
  "protocol_dial.dial",
@@ -640,6 +642,11 @@ export class BrowserHost {
640
642
  this.#assertCapability("ipfs", "ipfs.cat");
641
643
  return invokeAdapterMethod(ipfsAdapter, "cat", params, "ipfs");
642
644
  },
645
+ // ls, pin_add, pin_rm, pin_ls, dag_get, id, swarm_peers, name_resolve, name_publish, pubsub_publish
646
+ ...Object.fromEntries(IPFS_ADAPTER_OPERATIONS.map((operation) => [operation.slice(5), async (params = {}) => {
647
+ this.#assertCapability("ipfs", operation);
648
+ return invokeAdapterMethod(ipfsAdapter, operation.slice(5), params, "ipfs");
649
+ }])),
643
650
  });
644
651
 
645
652
  this.protocolHandle = Object.freeze({
@@ -1226,6 +1233,9 @@ export class BrowserHost {
1226
1233
  if (ADAPTER_OPERATIONS[normalized]) {
1227
1234
  return this.serveAdapterOperation(normalized, params);
1228
1235
  }
1236
+ if (IPFS_ADAPTER_OPERATIONS.includes(normalized)) {
1237
+ return this.ipfs[normalized.slice(5)](params);
1238
+ }
1229
1239
  throw new Error(`Unknown browser host operation "${normalized}".`);
1230
1240
  }
1231
1241
  }