/** * Module-host capability adapters (WS6.2). * * Bridges the sdn-js browser node's services — Helia (ipfs), the record * store (storage_*), libp2p gossipsub (pubsub), and wallet key material * (wallet_sign / keyslot) — into the space-data-module-sdk BrowserHost * adapter contract, so guest WASM modules loaded through the browser module * harness can call the same host capabilities the Go node grants * (sdn-server internal/modulert/caps): * * ipfs.add {base64|content|data} -> { Hash, Size } * ipfs.cat {cid} -> bytes * storage.write {schema, data:b64} -> { cid } * storage.query {schema, limit,...} -> records * storage.delete {schema, cid} -> true * pubsub.publish {topic, data} -> true * pubsub.subscribe/unsubscribe {topic}; pubsub.list_topics {} -> { topics } * * wallet_sign / keyslot is a host-side crypto oracle, not a raw-key export: * there is no "keyslot.get" guest-facing operation (removed by B2, mirroring * the same removal in sdn-server/internal/modulert/caps/keyslot.go). The * `walletSign.get({slotId})` resolver built by this module is internal-only * — it is never invoked directly by a guest. It is consumed by * space-data-module-sdk's BrowserHost, which implements the guest-facing * ops itself and never lets the resolved key bytes leave the host: * * keyslot.sign {slotId, payload:b64, algorithm?} -> {signature:b64, algorithm} * keyslot.unwrap {slotId, ephemeralPublicKey:b64, nonce:b64, ciphertext:b64} * -> {plaintext:b64} * * Pass the result as `hostOptions.capabilityAdapters` to * createBrowserModuleHarness (see loadDecryptedModule in * ui/runtime/live-delivery.ts). */ import type { Helia } from 'helia'; import type { Libp2p } from 'libp2p'; /** Minimal record-store contract (satisfied by the FlatSQL-WASM engine record store — THE SDNNode store). */ export interface ModuleHostRecordStore { store(schema: string, data: Uint8Array, peerId: string, signature: Uint8Array): Promise; query(schema: string, filter?: { peerId?: string; limit?: number; }): Promise; delete(cid: string): Promise; } export type ModuleHostKeySlotResolver = Uint8Array | (() => Uint8Array | Promise); export interface ModuleHostAdapterOptions { /** Helia instance backing ipfs.add / ipfs.cat. */ helia?: Helia; /** libp2p node whose services.pubsub (gossipsub) backs pubsub.*. */ libp2p?: Libp2p; /** Record store backing storage.* (e.g. FlatSQLEngineRecordStore). */ storage?: ModuleHostRecordStore; /** Publisher peer id recorded on storage.write records. */ peerId?: string; /** * Named signing-key slots backing the host-side keyslot.sign / * keyslot.unwrap crypto oracle. Resolved key bytes stay host-side — they * are consumed internally by BrowserHost's keyslot.sign/keyslot.unwrap * implementations and never returned to the guest directly (there is no * "keyslot.get" hostcall). */ keySlots?: Record; /** Optional callback for messages on topics subscribed via pubsub.subscribe. */ onPubsubMessage?: (message: { topic: string; data: Uint8Array; from?: string; }) => void; } export interface ModuleHostCapabilityAdapters { ipfs?: Record) => Promise>; storage?: Record) => Promise>; pubsub?: Record) => Promise>; walletSign?: Record) => Promise>; } /** * Build BrowserHost capabilityAdapters from sdn-js node services. Only the * capabilities whose backing service was provided are included. */ export declare function createModuleHostCapabilityAdapters(options?: ModuleHostAdapterOptions): ModuleHostCapabilityAdapters; //# sourceMappingURL=module-host-adapters.d.ts.map