@storagehub-sdk/core 0.0.1

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 ADDED
@@ -0,0 +1,85 @@
1
+ ## StorageHub SDK — Core
2
+
3
+ Foundational, backend-agnostic building blocks for StorageHub. This package contains StorageHub-specific logic that does not depend on the MSP backend implementation: wallet utilities, blockchain interaction helpers, precompile bindings, Merkle tooling, cryptography/WASM helpers, low-level HTTP utilities, and shared types. Its goal is to let developers integrate StorageHub without needing to understand network implementation details (nodes, pallets, EVM precompiles), by exposing stable, typed primitives and adapters.
4
+
5
+ ### What this package is
6
+ - **Wallet and signing**: Local wallet utilities and EIP-1193 adapter for injected wallets.
7
+ - **Blockchain interaction**: Helpers for StorageHub chain types/encodings with EVM account types.
8
+ - **Precompile helpers**: Bridge Substrate and EVM via precompiles to enable smart‑contract flows (issue storage requests, create buckets, etc.).
9
+ - **Merkle utilities**: Build/verify trees and proofs used by StorageHub.
10
+ - **Crypto/WASM helpers**: Performance-critical primitives via WASM (e.g., FileManager's Merkle/trie and hashing).
11
+ - **HTTP utilities**: Minimal `HttpClient` and types for consistent networking.
12
+ - **Shared types/constants**: Common shapes used across SDK packages.
13
+
14
+ ### What this package is not
15
+ - **Not an MSP client**: No MSP auth, upload/download, or REST contracts. See `@storagehub-sdk/msp-client`.
16
+ - **Not app-specific**: No UI/product code; only reusable SDK primitives.
17
+
18
+ ### Install
19
+ ```bash
20
+ pnpm add @storagehub-sdk/core
21
+ # or
22
+ npm i @storagehub-sdk/core
23
+ # or
24
+ yarn add @storagehub-sdk/core
25
+ ```
26
+
27
+ ### Quick start
28
+ ```ts
29
+ import { HttpClient, type HttpClientConfig } from '@storagehub-sdk/core';
30
+
31
+ const http = new HttpClient({
32
+ baseUrl: 'https://example.invalid',
33
+ } satisfies HttpClientConfig);
34
+
35
+ ```
36
+
37
+ ### Local wallet
38
+ ```ts
39
+ import { LocalWallet } from '@storagehub-sdk/core';
40
+
41
+ const wallet = LocalWallet.fromPrivateKey('0xYourPrivateKey');
42
+ const address = await wallet.getAddress();
43
+ const signature = await wallet.signMessage('hello');
44
+ ```
45
+
46
+ ### EIP-1193 wallet (browser)
47
+ ```ts
48
+ import { Eip1193Wallet } from '@storagehub-sdk/core';
49
+
50
+ const wallet = await Eip1193Wallet.connect(); // prompts injected wallet (e.g., MetaMask)
51
+ const address = await wallet.getAddress();
52
+ const signature = await wallet.signMessage('hello');
53
+ ```
54
+
55
+ ### FileManager (WASM-backed)
56
+ ```ts
57
+ import { FileManager } from '@storagehub-sdk/core';
58
+ import { createReadStream, statSync } from 'node:fs';
59
+ import { Readable } from 'node:stream';
60
+
61
+ const path = './path/to/file.bin';
62
+ const size = statSync(path).size;
63
+ const webStream = Readable.toWeb(createReadStream(path)) as unknown as ReadableStream<Uint8Array>;
64
+
65
+ const fm = new FileManager({ size, stream: () => webStream });
66
+ const fingerprint = await fm.getFingerprint(); // H256
67
+ ```
68
+
69
+ ### Design principles
70
+ - **Backend-agnostic**: No MSP-specific behavior here.
71
+ - **Composable and typed**: Small utilities, strong types, clear errors.
72
+ - **Runtime-friendly**: Browser and Node support; `fetch` is properly bound in browsers.
73
+ - **Separation of concerns**: Core primitives live here; MSP flows live in `msp-client`.
74
+
75
+ ### Roadmap
76
+ - **Typed precompile interfaces**: Strongly-typed bindings and ABI-like helpers.
77
+ - **Proof tooling**: End-to-end generation/verification for storage proofs.
78
+ - **Chunking/commitment utilities**: Streaming chunker and deterministic trees.
79
+
80
+ ### When to use `core` vs `msp-client`
81
+ - Use **`@storagehub-sdk/core`** for primitives that must work without any backend (wallets, Merkle, precompiles, chain helpers, low-level HTTP).
82
+ - Use **`@storagehub-sdk/msp-client`** for MSP endpoints, auth/nonce/sign/verify flows, and file transfer APIs.
83
+
84
+ ### Environments
85
+ Supported environments: web browsers and Node.js.
@@ -0,0 +1 @@
1
+ export declare const CHUNK_SIZE = 1024;
@@ -0,0 +1,24 @@
1
+ import type { AccountId, H256 } from '@polkadot/types/interfaces';
2
+ export declare class FileManager {
3
+ private readonly file;
4
+ constructor(file: {
5
+ size: number;
6
+ stream: () => ReadableStream<Uint8Array>;
7
+ });
8
+ private fingerprint?;
9
+ private fileKey?;
10
+ /**
11
+ * Stream the file's contents, feed every 1 kB chunk into a new FileTrie, and
12
+ * return the resulting Merkle root.
13
+ */
14
+ getFingerprint(): Promise<H256>;
15
+ /**
16
+ * Compute the FileKey for this file.
17
+ *
18
+ * The caller must provide:
19
+ * • owner – 32-byte AccountId (Uint8Array or 0x-prefixed hex string)
20
+ * • bucketId – 32-byte BucketId (Uint8Array or 0x-prefixed hex string)
21
+ * • location – path string (encoded to bytes as-is)
22
+ */
23
+ computeFileKey(owner: AccountId, bucketId: H256, location: string): Promise<H256>;
24
+ }
@@ -0,0 +1,40 @@
1
+ export type HttpClientConfig = {
2
+ baseUrl: string;
3
+ timeoutMs?: number;
4
+ defaultHeaders?: Record<string, string>;
5
+ fetchImpl?: typeof fetch;
6
+ };
7
+ export type RequestOptions = {
8
+ headers?: Record<string, string>;
9
+ signal?: AbortSignal;
10
+ query?: Record<string, string | number | boolean>;
11
+ /**
12
+ * Optional request body. If a non-BodyInit object is provided and no
13
+ * explicit Content-Type header is set, it will be JSON-encoded with
14
+ * 'application/json'.
15
+ */
16
+ body?: BodyInit | unknown;
17
+ /**
18
+ * If true, returns the raw Response without consuming the body.
19
+ * Useful for streaming downloads.
20
+ */
21
+ raw?: boolean;
22
+ };
23
+ export declare class HttpClient {
24
+ private readonly baseUrl;
25
+ private readonly timeoutMs;
26
+ private readonly defaultHeaders;
27
+ private readonly fetchImpl;
28
+ constructor(options: HttpClientConfig);
29
+ request<T>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, options?: RequestOptions): Promise<T | Response>;
30
+ get<T>(path: string, options?: RequestOptions): Promise<T>;
31
+ post<T>(path: string, options?: RequestOptions): Promise<T>;
32
+ put<T>(path: string, options?: RequestOptions): Promise<T>;
33
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
34
+ getRaw(path: string, options?: RequestOptions): Promise<Response>;
35
+ private buildUrl;
36
+ private parseJsonSafely;
37
+ private isBodyInit;
38
+ private isAbortError;
39
+ private getErrorMessage;
40
+ }
@@ -0,0 +1,11 @@
1
+ export declare class HttpError extends Error {
2
+ readonly status: number;
3
+ readonly body?: unknown;
4
+ constructor(message: string, status: number, body?: unknown);
5
+ }
6
+ export declare class NetworkError extends Error {
7
+ constructor(message: string);
8
+ }
9
+ export declare class TimeoutError extends Error {
10
+ constructor(message: string);
11
+ }
@@ -0,0 +1,7 @@
1
+ export { FileManager } from './file-manager.js';
2
+ export { HttpClient, type HttpClientConfig, type RequestOptions } from './http/HttpClient.js';
3
+ export { initWasm } from './init.js';
4
+ export { WalletBase } from './wallet/base.js';
5
+ export { Eip1193Wallet } from './wallet/eip1193.js';
6
+ export { WalletError, type WalletErrorCode } from './wallet/errors.js';
7
+ export { LocalWallet } from './wallet/local.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ var Z=Object.defineProperty;var V=(n,e)=>()=>(n&&(e=n(n=0)),e);var Q=(n,e)=>{for(var t in e)Z(n,t,{get:e[t],enumerable:!0})};var N={};Q(N,{FileMetadata:()=>b,FileTrie:()=>h,default:()=>te,initSync:()=>ee});function W(){return(_===null||_.byteLength===0)&&(_=new Uint8Array(i.memory.buffer)),_}function O(n,e){return n=n>>>0,B.decode(W().subarray(n,n+e))}function T(n,e){let t=e(n.length*1,1)>>>0;return W().set(n,t/1),m=n.length,t}function K(n,e){return n=n>>>0,W().subarray(n/1,n/1+e)}function X(n){let e=i.__wbindgen_export_0.get(n);return i.__externref_table_dealloc(n),e}async function Y(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(r){if(n.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let t=await n.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(n,e);return t instanceof WebAssembly.Instance?{instance:t,module:n}:t}}function j(){let n={};return n.wbg={},n.wbg.__wbindgen_init_externref_table=function(){let e=i.__wbindgen_export_0,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)},n.wbg.__wbindgen_string_new=function(e,t){return O(e,t)},n.wbg.__wbindgen_throw=function(e,t){throw new Error(O(e,t))},n}function D(n,e){return i=n.exports,z.__wbindgen_wasm_module=e,_=null,i.__wbindgen_start(),i}function ee(n){if(i!==void 0)return i;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=j();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let t=new WebAssembly.Instance(n,e);return D(t,n)}async function z(n){if(i!==void 0)return i;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof n>"u"&&(n=new URL("storagehub_wasm_bg.wasm",import.meta.url));let e=j();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:r}=await Y(await n,e);return D(t,r)}var i,B,_,m,L,b,C,h,te,U=V(()=>{"use strict";B=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&B.decode();_=null;m=0;L=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_filemetadata_free(n>>>0,1)),b=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,L.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_filemetadata_free(e,0)}constructor(e,t,r,s,o){let a=T(e,i.__wbindgen_malloc),p=m,d=T(t,i.__wbindgen_malloc),l=m,c=T(r,i.__wbindgen_malloc),f=m,g=T(o,i.__wbindgen_malloc),v=m,u=i.filemetadata_new(a,p,d,l,c,f,s,g,v);if(u[2])throw X(u[1]);return this.__wbg_ptr=u[0]>>>0,L.register(this,this.__wbg_ptr,this),this}getFileKey(){let e=i.filemetadata_getFileKey(this.__wbg_ptr);var t=K(e[0],e[1]).slice();return i.__wbindgen_free(e[0],e[1]*1,1),t}},C=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_filetrie_free(n>>>0,1)),h=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,C.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_filetrie_free(e,0)}constructor(){let e=i.filetrie_new();return this.__wbg_ptr=e>>>0,C.register(this,this.__wbg_ptr,this),this}push_chunk(e){let t=T(e,i.__wbindgen_malloc),r=m;i.filetrie_push_chunk(this.__wbg_ptr,t,r)}get_root(){let e=i.filetrie_get_root(this.__wbg_ptr);var t=K(e[0],e[1]).slice();return i.__wbindgen_free(e[0],e[1]*1,1),t}};te=z});U();import{TypeRegistry as $}from"@polkadot/types";var q=class{constructor(e){this.file=e}fingerprint;fileKey;async getFingerprint(){if(this.fingerprint)return this.fingerprint;let e=new $,t=new h,s=this.file.stream().getReader(),o=new Uint8Array,a=0;try{for(;;){let{done:l,value:c}=await s.read();if(l)break;if(c&&c.length){let f=o.subarray(a),g=new Uint8Array(f.length+c.length);for(g.set(f,0),g.set(c,f.length),o=g,a=0;o.length-a>=1024;){let v=o.subarray(a,a+1024);t.push_chunk(v),a+=1024}}}o.length-a>0&&t.push_chunk(o.subarray(a))}finally{s.releaseLock()}let p=t.get_root(),d=e.createType("H256",p);return this.fingerprint=d,d}async computeFileKey(e,t,r){if(this.fileKey)return this.fileKey;let s=await this.getFingerprint(),a=new b(e.toU8a(),t.toU8a(),new TextEncoder().encode(r),BigInt(this.file.size),s.toU8a()).getFileKey(),p=new $;return this.fileKey=p.createType("H256",a),this.fileKey}};var P=class extends Error{status;body;constructor(e,t,r){super(e),this.name="HttpError",this.status=t,this.body=r}},R=class extends Error{constructor(e){super(e),this.name="NetworkError"}},x=class extends Error{constructor(e){super(e),this.name="TimeoutError"}};var ne=3e4,M=class{baseUrl;timeoutMs;defaultHeaders;fetchImpl;constructor(e){if(!e.baseUrl)throw new Error("HttpClient: baseUrl is required");this.baseUrl=e.baseUrl.replace(/\/$/,""),this.timeoutMs=e.timeoutMs??ne,this.defaultHeaders={Accept:"application/json",...e.defaultHeaders??{}},this.fetchImpl=e.fetchImpl??fetch}async request(e,t,r={}){let s=this.buildUrl(t,r.query),o={...this.defaultHeaders,...r.headers??{}},a=!r.signal&&this.timeoutMs>0?new AbortController:void 0,p=r.signal??a?.signal,d=a?setTimeout(()=>a.abort(),this.timeoutMs):void 0;try{let l=Object.keys(o).some(E=>E.toLowerCase()==="content-type"),c=r.body,f=null;c!=null&&(this.isBodyInit(c)?f=c:(l||(o["Content-Type"]="application/json"),f=JSON.stringify(c)));let g={method:e,headers:o,...p?{signal:p}:{},...f!==null?{body:f}:{}},u=await(typeof globalThis<"u"&&this.fetchImpl===globalThis.fetch?globalThis.fetch.bind(globalThis):this.fetchImpl)(s,g);if(!u.ok){let E=await u.text(),G=this.parseJsonSafely(E);throw new P(`HTTP ${u.status} for ${e} ${s}`,u.status,G??E)}if(r.raw)return u;let S=await u.text();return this.parseJsonSafely(S)??S}catch(l){if(this.isAbortError(l))throw new x(`Request timed out for ${e} ${t}`);if(l instanceof P)throw l;let c=this.getErrorMessage(l);throw new R(c??`Network error for ${e} ${t}`)}finally{d&&clearTimeout(d)}}get(e,t){return this.request("GET",e,t)}post(e,t){return this.request("POST",e,t??{})}put(e,t){return this.request("PUT",e,t??{})}delete(e,t){return this.request("DELETE",e,t??{})}getRaw(e,t){return this.request("GET",e,{...t,raw:!0})}buildUrl(e,t){let r=e.startsWith("/")?e:`/${e}`,s=new URL(this.baseUrl+r);if(t)for(let[o,a]of Object.entries(t))s.searchParams.set(o,String(a));return s.toString()}parseJsonSafely(e){if(e)try{return JSON.parse(e)}catch{return}}isBodyInit(e){return typeof e=="string"||e instanceof Uint8Array||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof Blob<"u"&&e instanceof Blob||typeof FormData<"u"&&e instanceof FormData||typeof ReadableStream<"u"&&e instanceof ReadableStream}isAbortError(e){return typeof e=="object"&&e!==null&&"name"in e&&typeof e.name=="string"&&e.name==="AbortError"}getErrorMessage(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null&&"message"in e){let t=e.message;if(typeof t=="string")return t}}};var A=null;async function re(){return A||(A=(async()=>{let n=(await Promise.resolve().then(()=>(U(),N))).default,e=new URL("../wasm/pkg/storagehub_wasm_bg.wasm",import.meta.url);if(typeof window>"u"){let t="node:fs/promises",{readFile:r}=await import(t),s=await r(e);await n(s)}else await n(e.href)})(),A)}var w=class{};import{BrowserProvider as J}from"ethers";var H=class n extends w{constructor(t){super();this.provider=t}static fromProvider(t){return new n(new J(t))}static async connect(){if(typeof window.ethereum>"u")throw new Error("EIP-1193 provider not found. Please install a compatible wallet.");let t=new J(window.ethereum);return await t.send("eth_requestAccounts",[]),new n(t)}async getAddress(){return(await this.provider.getSigner()).getAddress()}async sendTransaction(t){let r=await this.provider.getSigner(),s={};return t.to&&(s.to=t.to),t.data&&t.data!=="0x"&&(s.data=t.data),t.value&&t.value!==0n&&(s.value=t.value),t.gasLimit&&t.gasLimit!==0n&&(s.gasLimit=t.gasLimit),(await r.sendTransaction(s)).hash}async signMessage(t){return(await this.provider.getSigner()).signMessage(t)}};var y=class extends Error{name="WalletError";code;constructor(e,t){super(t??e),this.code=e}};import{hexlify as se,Transaction as ie,Wallet as I}from"ethers";var F=class n extends w{constructor(t,r){super();this.wallet=t;this.provider=r}static fromPrivateKey(t,r){if(!/^0x[0-9a-fA-F]{64}$/.test(t))throw new y("InvalidPrivateKey");try{return new n(new I(t,r),r)}catch{throw new y("InvalidPrivateKey")}}static fromMnemonic(t,r){try{let s=I.fromPhrase(t),o=r?s.connect(r):s;return new n(o,r)}catch{throw new y("InvalidMnemonic")}}static createRandom(t){let r=I.createRandom(),s=t?r.connect(t):r;return new n(s,t)}getAddress(){return Promise.resolve(this.wallet.address)}signTransaction(t){let r=se(t);return this.wallet.signTransaction(ie.from(r))}async sendTransaction(t){if(!this.provider)throw new Error("No provider configured for LocalWallet; cannot send transaction");return(await this.wallet.connect(this.provider).sendTransaction(t)).hash}signMessage(t){return this.wallet.signMessage(t)}};export{H as Eip1193Wallet,q as FileManager,M as HttpClient,F as LocalWallet,w as WalletBase,y as WalletError,re as initWasm};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../wasm/pkg/storagehub_wasm.js", "../src/wasm.ts", "../src/file-manager.ts", "../src/http/errors.ts", "../src/http/HttpClient.ts", "../src/init.ts", "../src/wallet/base.ts", "../src/wallet/eip1193.ts", "../src/wallet/errors.ts", "../src/wallet/local.ts"],
4
+ "sourcesContent": ["let wasm;\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_export_0.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nconst FileMetadataFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_filemetadata_free(ptr >>> 0, 1));\n\nexport class FileMetadata {\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n FileMetadataFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_filemetadata_free(ptr, 0);\n }\n /**\n * Constructs a new `FileMetadata`.\n * * `owner`, `bucket_id`, `fingerprint` \u2013 32-byte arrays (passed as slices)\n * * `location` \u2013 arbitrary byte string (file path)\n * * `size` \u2013 file size in bytes\n * @param {Uint8Array} owner\n * @param {Uint8Array} bucket_id\n * @param {Uint8Array} location\n * @param {bigint} size\n * @param {Uint8Array} fingerprint\n */\n constructor(owner, bucket_id, location, size, fingerprint) {\n const ptr0 = passArray8ToWasm0(owner, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(bucket_id, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(location, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(fingerprint, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.filemetadata_new(ptr0, len0, ptr1, len1, ptr2, len2, size, ptr3, len3);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n this.__wbg_ptr = ret[0] >>> 0;\n FileMetadataFinalization.register(this, this.__wbg_ptr, this);\n return this;\n }\n /**\n * Returns the FileKey (blake2_256 hash of SCALE-encoded metadata) as a\n * 32-byte `Uint8Array`.\n * @returns {Uint8Array}\n */\n getFileKey() {\n const ret = wasm.filemetadata_getFileKey(this.__wbg_ptr);\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n }\n}\n\nconst FileTrieFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_filetrie_free(ptr >>> 0, 1));\n\nexport class FileTrie {\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n FileTrieFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_filetrie_free(ptr, 0);\n }\n constructor() {\n const ret = wasm.filetrie_new();\n this.__wbg_ptr = ret >>> 0;\n FileTrieFinalization.register(this, this.__wbg_ptr, this);\n return this;\n }\n /**\n * @param {Uint8Array} bytes\n */\n push_chunk(bytes) {\n const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.filetrie_push_chunk(this.__wbg_ptr, ptr0, len0);\n }\n /**\n * Current Merkle root as a hex string.\n * @returns {Uint8Array}\n */\n get_root() {\n const ret = wasm.filetrie_get_root(this.__wbg_ptr);\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n }\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbindgen_init_externref_table = function() {\n const table = wasm.__wbindgen_export_0;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n ;\n };\n imports.wbg.__wbindgen_string_new = function(arg0, arg1) {\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n };\n imports.wbg.__wbindgen_throw = function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n };\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedUint8ArrayMemory0 = null;\n\n\n wasm.__wbindgen_start();\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('storagehub_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\n", "export { FileMetadata, FileTrie } from '../wasm/pkg/storagehub_wasm.js';\n", "import { CHUNK_SIZE } from './constants';\nimport { FileMetadata, FileTrie } from './wasm.js';\nimport { TypeRegistry } from '@polkadot/types';\nimport type { AccountId, H256 } from '@polkadot/types/interfaces';\n\nexport class FileManager {\n constructor(private readonly file: { size: number; stream: () => ReadableStream<Uint8Array> }) {}\n\n private fingerprint?: H256;\n private fileKey?: H256;\n\n /**\n * Stream the file's contents, feed every 1 kB chunk into a new FileTrie, and\n * return the resulting Merkle root.\n */\n async getFingerprint(): Promise<H256> {\n if (this.fingerprint) {\n return this.fingerprint;\n }\n\n const registry = new TypeRegistry();\n const trie = new FileTrie();\n\n const stream = this.file.stream();\n // ---\n // Streaming fingerprint algorithm\n // We want to feed the MerkleTrie with **fixed-size** `${CHUNK_SIZE}`-byte chunks\n // but a `ReadableStream` gives us arbitrarily-sized `Uint8Array`s (default \u224864 KiB).\n //\n // Strategy\n // 1. Keep an in-memory sliding buffer (`buffer`).\n // 2. `bufferOffset` marks how much of that buffer has already been\n // consumed (pushed to the trie).\n // 3. On each `reader.read()` we append the newly-read bytes after the\n // unconsumed tail. Then, while we still have \u2265 CHUNK_SIZE bytes\n // available, cut a `${CHUNK_SIZE}`-byte window and push it into the trie.\n // 4. Any leftover ( < CHUNK_SIZE ) stays in `buffer` to be prefixed by\n // the next read.\n // ---\n const reader = stream.getReader();\n let buffer = new Uint8Array();\n let bufferOffset = 0;\n\n try {\n while (true) {\n // \u2500\u2500 Step-1: pull next blob fragment (\u224864 KiB) from the stream\n const { done, value } = await reader.read();\n if (done) break; // EOF \u21D2 exit outer loop\n\n if (value && value.length) {\n /*\n * \u2500\u2500 Step-2: concatenate the newly-read bytes **after** any leftover\n * bytes we still haven\u2019t consumed (bufferOffset marks the\n * start of that tail). We create a fresh Uint8Array to\n * avoid costly shifting of the existing buffer.\n */\n const unreadTail = buffer.subarray(bufferOffset);\n const newBuffer = new Uint8Array(unreadTail.length + value.length);\n newBuffer.set(unreadTail, 0);\n newBuffer.set(value, unreadTail.length);\n buffer = newBuffer;\n bufferOffset = 0;\n\n /*\n * \u2500\u2500 Step-3: while the sliding-window holds at least one full\n * CHUNK_SIZE-byte block, slice it out and push it into the\n * trie. We may loop multiple times if the stream chunk was\n * very large.\n */\n while (buffer.length - bufferOffset >= CHUNK_SIZE) {\n const chunk = buffer.subarray(bufferOffset, bufferOffset + CHUNK_SIZE);\n trie.push_chunk(chunk);\n bufferOffset += CHUNK_SIZE;\n }\n }\n }\n\n // \u2500\u2500 Step-4: push the leftover bytes (< CHUNK_SIZE)\n if (buffer.length - bufferOffset > 0) {\n trie.push_chunk(buffer.subarray(bufferOffset));\n }\n } finally {\n reader.releaseLock();\n }\n\n // Retrieve Merkle root from the trie and cache it\n const rootHash = trie.get_root();\n const fingerprint = registry.createType('H256', rootHash) as H256;\n\n this.fingerprint = fingerprint;\n return fingerprint;\n }\n\n /**\n * Compute the FileKey for this file.\n *\n * The caller must provide:\n * \u2022 owner \u2013 32-byte AccountId (Uint8Array or 0x-prefixed hex string)\n * \u2022 bucketId \u2013 32-byte BucketId (Uint8Array or 0x-prefixed hex string)\n * \u2022 location \u2013 path string (encoded to bytes as-is)\n */\n async computeFileKey(owner: AccountId, bucketId: H256, location: string): Promise<H256> {\n if (this.fileKey) {\n return this.fileKey;\n }\n\n const fp = await this.getFingerprint();\n\n const metadata = new FileMetadata(\n owner.toU8a(),\n bucketId.toU8a(),\n new TextEncoder().encode(location),\n BigInt(this.file.size),\n fp.toU8a(),\n );\n\n const fileKey = metadata.getFileKey();\n const registry = new TypeRegistry();\n this.fileKey = registry.createType('H256', fileKey) as H256;\n return this.fileKey;\n }\n}\n", "export class HttpError extends Error {\n public readonly status: number;\n public readonly body?: unknown;\n\n constructor(message: string, status: number, body?: unknown) {\n super(message);\n this.name = 'HttpError';\n this.status = status;\n this.body = body;\n }\n}\n\nexport class NetworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'NetworkError';\n }\n}\n\nexport class TimeoutError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n", "import { HttpError, NetworkError, TimeoutError } from './errors.js';\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\nexport type HttpClientConfig = {\n baseUrl: string;\n timeoutMs?: number;\n defaultHeaders?: Record<string, string>;\n fetchImpl?: typeof fetch;\n};\n\nexport type RequestOptions = {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n query?: Record<string, string | number | boolean>;\n /**\n * Optional request body. If a non-BodyInit object is provided and no\n * explicit Content-Type header is set, it will be JSON-encoded with\n * 'application/json'.\n */\n body?: BodyInit | unknown;\n /**\n * If true, returns the raw Response without consuming the body.\n * Useful for streaming downloads.\n */\n raw?: boolean;\n};\n\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly timeoutMs: number;\n private readonly defaultHeaders: Record<string, string>;\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: HttpClientConfig) {\n if (!options.baseUrl) throw new Error('HttpClient: baseUrl is required');\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.defaultHeaders = { Accept: 'application/json', ...(options.defaultHeaders ?? {}) };\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n async request<T>(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n options: RequestOptions = {},\n ): Promise<T | Response> {\n const url = this.buildUrl(path, options.query);\n const headers = { ...this.defaultHeaders, ...(options.headers ?? {}) };\n\n // Support timeout via AbortController if no external signal provided\n const controller = !options.signal && this.timeoutMs > 0 ? new AbortController() : undefined;\n const signal = options.signal ?? controller?.signal;\n\n const timer: ReturnType<typeof setTimeout> | undefined = controller\n ? setTimeout(() => controller.abort(), this.timeoutMs)\n : undefined;\n\n try {\n // Auto-encode JSON bodies if caller passed a plain object and no Content-Type\n const hasExplicitContentType = Object.keys(headers).some(\n (h) => h.toLowerCase() === 'content-type',\n );\n const candidate = options.body;\n let body: BodyInit | null = null;\n if (candidate !== undefined && candidate !== null) {\n if (this.isBodyInit(candidate)) {\n body = candidate;\n } else {\n // For non-BodyInit payloads, send JSON\n if (!hasExplicitContentType) headers['Content-Type'] = 'application/json';\n body = JSON.stringify(candidate);\n }\n }\n\n const init: RequestInit = {\n method,\n headers,\n ...(signal ? { signal } : {}),\n ...(body !== null ? { body } : {}),\n };\n const fetchFn =\n typeof globalThis !== 'undefined' &&\n this.fetchImpl === (globalThis as unknown as { fetch: typeof fetch }).fetch\n ? (globalThis as unknown as { fetch: typeof fetch }).fetch.bind(globalThis)\n : this.fetchImpl;\n const res = await fetchFn(url, init);\n\n // If the response is not OK, consume body for error details and throw\n if (!res.ok) {\n const text = await res.text();\n const maybeJson = this.parseJsonSafely(text);\n throw new HttpError(\n `HTTP ${res.status} for ${method} ${url}`,\n res.status,\n maybeJson ?? text,\n );\n }\n\n // If raw response requested, return it without consuming the body\n if (options.raw) {\n return res as Response;\n }\n\n // Normal response processing - consume and parse the body\n const text = await res.text();\n const maybeJson = this.parseJsonSafely(text);\n return (maybeJson as T) ?? (text as unknown as T);\n } catch (err: unknown) {\n if (this.isAbortError(err)) {\n throw new TimeoutError(`Request timed out for ${method} ${path}`);\n }\n if (err instanceof HttpError) throw err;\n const msg = this.getErrorMessage(err);\n throw new NetworkError(msg ?? `Network error for ${method} ${path}`);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, options) as Promise<T>;\n }\n\n post<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, options ?? {}) as Promise<T>;\n }\n\n put<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('PUT', path, options ?? {}) as Promise<T>;\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options ?? {}) as Promise<T>;\n }\n\n getRaw(path: string, options?: RequestOptions): Promise<Response> {\n return this.request('GET', path, { ...options, raw: true }) as Promise<Response>;\n }\n\n private buildUrl(path: string, query?: Record<string, string | number | boolean>): string {\n const normalizedPath = path.startsWith('/') ? path : `/${path}`;\n const url = new URL(this.baseUrl + normalizedPath);\n\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n url.searchParams.set(k, String(v));\n }\n }\n\n return url.toString();\n }\n\n private parseJsonSafely(text: string): unknown | undefined {\n if (!text) return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n }\n\n private isBodyInit(value: unknown): value is BodyInit {\n return (\n typeof value === 'string' ||\n value instanceof Uint8Array ||\n (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) ||\n (typeof Blob !== 'undefined' && value instanceof Blob) ||\n (typeof FormData !== 'undefined' && value instanceof FormData) ||\n (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream)\n );\n }\n\n private isAbortError(err: unknown): err is { name: string } {\n return (\n typeof err === 'object' &&\n err !== null &&\n 'name' in err &&\n typeof (err as { name?: unknown }).name === 'string' &&\n (err as { name: string }).name === 'AbortError'\n );\n }\n\n private getErrorMessage(err: unknown): string | undefined {\n if (typeof err === 'string') return err;\n if (typeof err === 'object' && err !== null && 'message' in err) {\n const m = (err as { message?: unknown }).message;\n if (typeof m === 'string') return m;\n }\n return undefined;\n }\n}\n", "let initPromise: Promise<void> | null = null;\n\nexport async function initWasm(): Promise<void> {\n if (initPromise) {\n // If initialization is already in progress, wait for the same Promise\n return initPromise;\n }\n\n // Create the initialization Promise and store it\n initPromise = (async () => {\n // Import the web-style init function\n const wasmInit = (await import('../wasm/pkg/storagehub_wasm.js')).default;\n\n const wasmUrl = new URL('../wasm/pkg/storagehub_wasm_bg.wasm', import.meta.url);\n if (typeof window === 'undefined') {\n // Node.js: read WASM bytes and pass as ArrayBuffer\n const fsMod = 'node:fs/promises';\n const { readFile } = await import(fsMod);\n const buf = await readFile(wasmUrl);\n await wasmInit(buf);\n } else {\n // Browser: pass URL or fetch promise\n await wasmInit(wasmUrl.href);\n }\n })();\n\n return initPromise;\n}\n", "/**\n * Base abstraction for wallet integrations.\n *\n * Any concrete wallet (e.g. a browser extension wallet, a hardware wallet or a\n * mobile-SDK based wallet) must extend this class and implement the methods\n * for retrieving the active account address, sending transactions, and\n * signing arbitrary messages.\n */\nimport type { TransactionRequest } from 'ethers';\n\nexport abstract class WalletBase {\n /**\n * Return the public address for the currently selected account.\n *\n * Implementations may need to prompt the user to unlock the wallet or to\n * choose an account if more than one is available.\n */\n public abstract getAddress(): Promise<string>;\n\n /**\n * Send a transaction through the wallet and return the transaction hash.\n *\n * This is the primary operation for most EIP-1193 compatible wallets which\n * do not support producing detached transaction signatures.\n */\n public abstract sendTransaction(tx: TransactionRequest): Promise<string>;\n\n /**\n * Sign an arbitrary message and return the signature.\n *\n * This is commonly used for off-chain authentication flows (e.g. signing a\n * nonce) or for verifying ownership of an address.\n *\n * @param msg The message to sign, either as raw bytes (`Uint8Array`) or a\n * regular UTF-8 string.\n * @returns A signature string, typically hex-encoded.\n */\n public abstract signMessage(msg: Uint8Array | string): Promise<string>;\n}\n", "import { WalletBase } from './base.js';\nimport { BrowserProvider, type Eip1193Provider, type TransactionRequest } from 'ethers';\n\ndeclare global {\n /**\n * EIP-1193 injected provider placed on the window object by browser wallets.\n * The exact shape is library-specific; we wrap it via ethers' BrowserProvider.\n */\n interface Window {\n ethereum?: unknown;\n }\n}\n\n/**\n * Generic wallet integration for any EIP-1193 compliant injected provider.\n *\n * Implements the minimal `WalletBase` contract (fetching the current address,\n * sending transactions, and signing arbitrary messages) using ethers v6.\n */\nexport class Eip1193Wallet extends WalletBase {\n private constructor(private readonly provider: BrowserProvider) {\n super();\n }\n\n /**\n * Create a wallet from an existing EIP-1193 provider instance.\n */\n public static fromProvider(provider: Eip1193Provider): Eip1193Wallet {\n return new Eip1193Wallet(new BrowserProvider(provider));\n }\n\n /**\n * Request connection to the injected provider at `window.ethereum` and\n * create a new `Eip1193Wallet`.\n *\n * Internally this triggers the extension UI via `eth_requestAccounts` which\n * asks the user to authorise account access.\n *\n * @throws If no injected provider is found.\n */\n public static async connect(): Promise<Eip1193Wallet> {\n if (typeof window.ethereum === 'undefined') {\n throw new Error('EIP-1193 provider not found. Please install a compatible wallet.');\n }\n\n const provider = new BrowserProvider(window.ethereum as Eip1193Provider);\n await provider.send('eth_requestAccounts', []);\n return new Eip1193Wallet(provider);\n }\n\n /** @inheritdoc */\n public async getAddress(): Promise<string> {\n const signer = await this.provider.getSigner();\n return signer.getAddress();\n }\n\n /** @inheritdoc */\n public async sendTransaction(tx: TransactionRequest): Promise<string> {\n const signer = await this.provider.getSigner();\n const txRequest: Partial<TransactionRequest> = {};\n if (tx.to) txRequest.to = tx.to;\n if (tx.data && tx.data !== '0x') txRequest.data = tx.data;\n if (tx.value && tx.value !== 0n) txRequest.value = tx.value;\n if (tx.gasLimit && tx.gasLimit !== 0n) txRequest.gasLimit = tx.gasLimit;\n const response = await signer.sendTransaction(txRequest);\n return response.hash;\n }\n\n /** @inheritdoc */\n public async signMessage(msg: Uint8Array | string): Promise<string> {\n const signer = await this.provider.getSigner();\n return signer.signMessage(msg);\n }\n}\n", "export type WalletErrorCode = 'InvalidPrivateKey' | 'InvalidMnemonic';\n\nexport class WalletError extends Error {\n public readonly name = 'WalletError';\n public readonly code: WalletErrorCode;\n\n public constructor(code: WalletErrorCode, message?: string) {\n super(message ?? code);\n this.code = code;\n }\n}\n", "import { WalletBase } from './base.js';\nimport { WalletError } from './errors.js';\nimport {\n type HDNodeWallet,\n hexlify,\n type Provider,\n Transaction,\n type TransactionRequest,\n Wallet as EthersWallet,\n} from 'ethers';\n\n/**\n * A local, in-memory wallet implementation.\n *\n * @warning This class is intended for development and testing purposes only.\n * It manages private keys in memory and is not suitable for production use\n * where secure key management is required.\n */\nexport class LocalWallet extends WalletBase {\n private constructor(\n private readonly wallet: EthersWallet | HDNodeWallet,\n private readonly provider?: Provider,\n ) {\n super();\n }\n\n /**\n * Create an instance from an existing private key.\n *\n * @param privateKey - A 0x-prefixed hex string containing the private key.\n * @returns A new `LocalWallet` that can sign on behalf of the key\u02BCs address.\n */\n public static fromPrivateKey(privateKey: string, provider?: Provider): LocalWallet {\n // Validate early to provide a stable error type regardless of ethers internals\n const isHex = /^0x[0-9a-fA-F]{64}$/.test(privateKey);\n if (!isHex) throw new WalletError('InvalidPrivateKey');\n\n try {\n return new LocalWallet(new EthersWallet(privateKey, provider), provider);\n } catch {\n throw new WalletError('InvalidPrivateKey');\n }\n }\n\n /**\n * Create an instance from a BIP-39 mnemonic phrase.\n *\n * @param mnemonic - The 12/24-word mnemonic phrase.\n * @returns A new `LocalWallet` bound to the first account derived from the\n * mnemonic.\n */\n public static fromMnemonic(mnemonic: string, provider?: Provider): LocalWallet {\n try {\n const wallet = EthersWallet.fromPhrase(mnemonic);\n const connected = provider ? wallet.connect(provider) : wallet;\n return new LocalWallet(connected, provider);\n } catch {\n throw new WalletError('InvalidMnemonic');\n }\n }\n\n /**\n * Generate a brand-new keypair on the fly.\n *\n * @returns A freshly generated `LocalWallet` with a random private key.\n */\n public static createRandom(provider?: Provider): LocalWallet {\n const wallet = EthersWallet.createRandom();\n const connected = provider ? wallet.connect(provider) : wallet;\n return new LocalWallet(connected, provider);\n }\n\n /** @inheritdoc */\n public getAddress(): Promise<string> {\n return Promise.resolve(this.wallet.address);\n }\n\n public signTransaction(tx: Uint8Array): Promise<string> {\n const hexTx = hexlify(tx);\n return this.wallet.signTransaction(Transaction.from(hexTx));\n }\n\n /** @inheritdoc */\n public async sendTransaction(tx: TransactionRequest): Promise<string> {\n if (!this.provider) {\n throw new Error('No provider configured for LocalWallet; cannot send transaction');\n }\n const connected = this.wallet.connect(this.provider);\n const response = await connected.sendTransaction(tx);\n return response.hash;\n }\n\n /** @inheritdoc */\n public signMessage(msg: Uint8Array | string): Promise<string> {\n return this.wallet.signMessage(msg);\n }\n}\n"],
5
+ "mappings": "6HAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,aAAAC,EAAA,YAAAC,GAAA,aAAAC,KAQA,SAASC,GAAuB,CAC5B,OAAIC,IAA4B,MAAQA,EAAwB,aAAe,KAC3EA,EAA0B,IAAI,WAAWC,EAAK,OAAO,MAAM,GAExDD,CACX,CAEA,SAASE,EAAmBC,EAAKC,EAAK,CAClC,OAAAD,EAAMA,IAAQ,EACPE,EAAkB,OAAON,EAAqB,EAAE,SAASI,EAAKA,EAAMC,CAAG,CAAC,CACnF,CAIA,SAASE,EAAkBC,EAAKC,EAAQ,CACpC,IAAML,EAAMK,EAAOD,EAAI,OAAS,EAAG,CAAC,IAAM,EAC1C,OAAAR,EAAqB,EAAE,IAAIQ,EAAKJ,EAAM,CAAC,EACvCM,EAAkBF,EAAI,OACfJ,CACX,CAEA,SAASO,EAAoBP,EAAKC,EAAK,CACnC,OAAAD,EAAMA,IAAQ,EACPJ,EAAqB,EAAE,SAASI,EAAM,EAAGA,EAAM,EAAIC,CAAG,CACjE,CAEA,SAASO,EAAwBC,EAAK,CAClC,IAAMC,EAAQZ,EAAK,oBAAoB,IAAIW,CAAG,EAC9C,OAAAX,EAAK,0BAA0BW,CAAG,EAC3BC,CACX,CAuGA,eAAeC,EAAWC,EAAQC,EAAS,CACvC,GAAI,OAAO,UAAa,YAAcD,aAAkB,SAAU,CAC9D,GAAI,OAAO,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nB,CAQA,OAAc,eAAeC,EAAoBD,EAAkC,CAGjF,GAAI,CADU,sBAAsB,KAAKC,CAAU,EACvC,MAAM,IAAIC,EAAY,mBAAmB,EAErD,GAAI,CACF,OAAO,IAAIL,EAAY,IAAIF,EAAaM,EAAYD,CAAQ,EAAGA,CAAQ,CACzE,MAAQ,CACN,MAAM,IAAIE,EAAY,mBAAmB,CAC3C,CACF,CASA,OAAc,aAAaC,EAAkBH,EAAkC,CAC7E,GAAI,CACF,IAAMD,EAASJ,EAAa,WAAWQ,CAAQ,EACzCC,EAAYJ,EAAWD,EAAO,QAAQC,CAAQ,EAAID,EACxD,OAAO,IAAIF,EAAYO,EAAWJ,CAAQ,CAC5C,MAAQ,CACN,MAAM,IAAIE,EAAY,iBAAiB,CACzC,CACF,CAOA,OAAc,aAAaF,EAAkC,CAC3D,IAAMD,EAASJ,EAAa,aAAa,EACnCS,EAAYJ,EAAWD,EAAO,QAAQC,CAAQ,EAAID,EACxD,OAAO,IAAIF,EAAYO,EAAWJ,CAAQ,CAC5C,CAGO,YAA8B,CACnC,OAAO,QAAQ,QAAQ,KAAK,OAAO,OAAO,CAC5C,CAEO,gBAAgBK,EAAiC,CACtD,IAAMC,EAAQb,GAAQY,CAAE,EACxB,OAAO,KAAK,OAAO,gBAAgBX,GAAY,KAAKY,CAAK,CAAC,CAC5D,CAGA,MAAa,gBAAgBD,EAAyC,CACpE,GAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,iEAAiE,EAInF,OADiB,MADC,KAAK,OAAO,QAAQ,KAAK,QAAQ,EAClB,gBAAgBA,CAAE,GACnC,IAClB,CAGO,YAAYE,EAA2C,CAC5D,OAAO,KAAK,OAAO,YAAYA,CAAG,CACpC,CACF",
6
+ "names": ["storagehub_wasm_exports", "__export", "FileMetadata", "FileTrie", "storagehub_wasm_default", "initSync", "getUint8ArrayMemory0", "cachedUint8ArrayMemory0", "wasm", "getStringFromWasm0", "ptr", "len", "cachedTextDecoder", "passArray8ToWasm0", "arg", "malloc", "WASM_VECTOR_LEN", "getArrayU8FromWasm0", "takeFromExternrefTable0", "idx", "value", "__wbg_load", "module", "imports", "e", "bytes", "instance", "__wbg_get_imports", "table", "offset", "arg0", "arg1", "__wbg_finalize_init", "__wbg_init", "module_or_path", "FileMetadataFinalization", "FileTrieFinalization", "init_storagehub_wasm", "__esmMin", "owner", "bucket_id", "location", "size", "fingerprint", "ptr0", "len0", "ptr1", "len1", "ptr2", "len2", "ptr3", "len3", "ret", "v1", "init_storagehub_wasm", "TypeRegistry", "FileManager", "file", "registry", "trie", "FileTrie", "reader", "buffer", "bufferOffset", "done", "value", "unreadTail", "newBuffer", "chunk", "rootHash", "fingerprint", "owner", "bucketId", "location", "fp", "fileKey", "FileMetadata", "HttpError", "message", "status", "body", "NetworkError", "TimeoutError", "DEFAULT_TIMEOUT_MS", "HttpClient", "options", "method", "path", "url", "headers", "controller", "signal", "timer", "hasExplicitContentType", "h", "candidate", "body", "init", "res", "text", "maybeJson", "HttpError", "err", "TimeoutError", "msg", "NetworkError", "query", "normalizedPath", "k", "v", "value", "m", "initPromise", "initWasm", "wasmInit", "wasmUrl", "fsMod", "readFile", "buf", "WalletBase", "BrowserProvider", "Eip1193Wallet", "_Eip1193Wallet", "WalletBase", "provider", "tx", "signer", "txRequest", "msg", "WalletError", "code", "message", "hexlify", "Transaction", "EthersWallet", "LocalWallet", "_LocalWallet", "WalletBase", "wallet", "provider", "privateKey", "WalletError", "mnemonic", "connected", "tx", "hexTx", "msg"]
7
+ }
package/dist/init.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function initWasm(): Promise<void>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Base abstraction for wallet integrations.
3
+ *
4
+ * Any concrete wallet (e.g. a browser extension wallet, a hardware wallet or a
5
+ * mobile-SDK based wallet) must extend this class and implement the methods
6
+ * for retrieving the active account address, sending transactions, and
7
+ * signing arbitrary messages.
8
+ */
9
+ import type { TransactionRequest } from 'ethers';
10
+ export declare abstract class WalletBase {
11
+ /**
12
+ * Return the public address for the currently selected account.
13
+ *
14
+ * Implementations may need to prompt the user to unlock the wallet or to
15
+ * choose an account if more than one is available.
16
+ */
17
+ abstract getAddress(): Promise<string>;
18
+ /**
19
+ * Send a transaction through the wallet and return the transaction hash.
20
+ *
21
+ * This is the primary operation for most EIP-1193 compatible wallets which
22
+ * do not support producing detached transaction signatures.
23
+ */
24
+ abstract sendTransaction(tx: TransactionRequest): Promise<string>;
25
+ /**
26
+ * Sign an arbitrary message and return the signature.
27
+ *
28
+ * This is commonly used for off-chain authentication flows (e.g. signing a
29
+ * nonce) or for verifying ownership of an address.
30
+ *
31
+ * @param msg The message to sign, either as raw bytes (`Uint8Array`) or a
32
+ * regular UTF-8 string.
33
+ * @returns A signature string, typically hex-encoded.
34
+ */
35
+ abstract signMessage(msg: Uint8Array | string): Promise<string>;
36
+ }
@@ -0,0 +1,41 @@
1
+ import { WalletBase } from './base.js';
2
+ import { type Eip1193Provider, type TransactionRequest } from 'ethers';
3
+ declare global {
4
+ /**
5
+ * EIP-1193 injected provider placed on the window object by browser wallets.
6
+ * The exact shape is library-specific; we wrap it via ethers' BrowserProvider.
7
+ */
8
+ interface Window {
9
+ ethereum?: unknown;
10
+ }
11
+ }
12
+ /**
13
+ * Generic wallet integration for any EIP-1193 compliant injected provider.
14
+ *
15
+ * Implements the minimal `WalletBase` contract (fetching the current address,
16
+ * sending transactions, and signing arbitrary messages) using ethers v6.
17
+ */
18
+ export declare class Eip1193Wallet extends WalletBase {
19
+ private readonly provider;
20
+ private constructor();
21
+ /**
22
+ * Create a wallet from an existing EIP-1193 provider instance.
23
+ */
24
+ static fromProvider(provider: Eip1193Provider): Eip1193Wallet;
25
+ /**
26
+ * Request connection to the injected provider at `window.ethereum` and
27
+ * create a new `Eip1193Wallet`.
28
+ *
29
+ * Internally this triggers the extension UI via `eth_requestAccounts` which
30
+ * asks the user to authorise account access.
31
+ *
32
+ * @throws If no injected provider is found.
33
+ */
34
+ static connect(): Promise<Eip1193Wallet>;
35
+ /** @inheritdoc */
36
+ getAddress(): Promise<string>;
37
+ /** @inheritdoc */
38
+ sendTransaction(tx: TransactionRequest): Promise<string>;
39
+ /** @inheritdoc */
40
+ signMessage(msg: Uint8Array | string): Promise<string>;
41
+ }
@@ -0,0 +1,6 @@
1
+ export type WalletErrorCode = 'InvalidPrivateKey' | 'InvalidMnemonic';
2
+ export declare class WalletError extends Error {
3
+ readonly name = "WalletError";
4
+ readonly code: WalletErrorCode;
5
+ constructor(code: WalletErrorCode, message?: string);
6
+ }
@@ -0,0 +1,42 @@
1
+ import { WalletBase } from './base.js';
2
+ import { type Provider, type TransactionRequest } from 'ethers';
3
+ /**
4
+ * A local, in-memory wallet implementation.
5
+ *
6
+ * @warning This class is intended for development and testing purposes only.
7
+ * It manages private keys in memory and is not suitable for production use
8
+ * where secure key management is required.
9
+ */
10
+ export declare class LocalWallet extends WalletBase {
11
+ private readonly wallet;
12
+ private readonly provider?;
13
+ private constructor();
14
+ /**
15
+ * Create an instance from an existing private key.
16
+ *
17
+ * @param privateKey - A 0x-prefixed hex string containing the private key.
18
+ * @returns A new `LocalWallet` that can sign on behalf of the keyʼs address.
19
+ */
20
+ static fromPrivateKey(privateKey: string, provider?: Provider): LocalWallet;
21
+ /**
22
+ * Create an instance from a BIP-39 mnemonic phrase.
23
+ *
24
+ * @param mnemonic - The 12/24-word mnemonic phrase.
25
+ * @returns A new `LocalWallet` bound to the first account derived from the
26
+ * mnemonic.
27
+ */
28
+ static fromMnemonic(mnemonic: string, provider?: Provider): LocalWallet;
29
+ /**
30
+ * Generate a brand-new keypair on the fly.
31
+ *
32
+ * @returns A freshly generated `LocalWallet` with a random private key.
33
+ */
34
+ static createRandom(provider?: Provider): LocalWallet;
35
+ /** @inheritdoc */
36
+ getAddress(): Promise<string>;
37
+ signTransaction(tx: Uint8Array): Promise<string>;
38
+ /** @inheritdoc */
39
+ sendTransaction(tx: TransactionRequest): Promise<string>;
40
+ /** @inheritdoc */
41
+ signMessage(msg: Uint8Array | string): Promise<string>;
42
+ }
package/dist/wasm.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { FileMetadata, FileTrie } from '../wasm/pkg/storagehub_wasm.js';
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@storagehub-sdk/core",
3
+ "version": "0.0.1",
4
+ "description": "Core primitives for StorageHub SDK (types, crypto, filemanager, storage, wasm bindings)",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./wasm/pkg/*": "./wasm/pkg/*"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "registry": "https://registry.npmjs.org/"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "wasm/pkg",
20
+ "README.md"
21
+ ],
22
+ "dependencies": {
23
+ "@polkadot/types": "^10.10.3",
24
+ "ethers": "^6.15.0"
25
+ },
26
+ "devDependencies": {
27
+ "@eslint/eslintrc": "2.1.4",
28
+ "@types/node": "^20.11.19"
29
+ },
30
+ "engines": {
31
+ "node": ">=22"
32
+ },
33
+ "scripts": {
34
+ "build": "node ../scripts/build.js",
35
+ "build:types": "tsc --emitDeclarationOnly -p tsconfig.json",
36
+ "dev": "node ../scripts/build.js --watch",
37
+ "lint": "eslint \"{src/**/*.ts,src/**/*.tsx}\"",
38
+ "format": "prettier --write \"{src/**/*.ts,src/**/*.tsx}\"",
39
+ "format:check": "prettier --check \"{src/**/*.ts,src/**/*.tsx}\"",
40
+ "test": "vitest",
41
+ "typecheck": "tsc --noEmit",
42
+ "coverage": "vitest run --coverage",
43
+ "build:wasm": "wasm-pack build ./wasm --target web --release --out-dir pkg && rm -f ./wasm/pkg/package.json ./wasm/pkg/.gitignore"
44
+ }
45
+ }
@@ -0,0 +1,65 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export class FileMetadata {
4
+ free(): void;
5
+ /**
6
+ * Constructs a new `FileMetadata`.
7
+ * * `owner`, `bucket_id`, `fingerprint` – 32-byte arrays (passed as slices)
8
+ * * `location` – arbitrary byte string (file path)
9
+ * * `size` – file size in bytes
10
+ */
11
+ constructor(owner: Uint8Array, bucket_id: Uint8Array, location: Uint8Array, size: bigint, fingerprint: Uint8Array);
12
+ /**
13
+ * Returns the FileKey (blake2_256 hash of SCALE-encoded metadata) as a
14
+ * 32-byte `Uint8Array`.
15
+ */
16
+ getFileKey(): Uint8Array;
17
+ }
18
+ export class FileTrie {
19
+ free(): void;
20
+ constructor();
21
+ push_chunk(bytes: Uint8Array): void;
22
+ /**
23
+ * Current Merkle root as a hex string.
24
+ */
25
+ get_root(): Uint8Array;
26
+ }
27
+
28
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
29
+
30
+ export interface InitOutput {
31
+ readonly memory: WebAssembly.Memory;
32
+ readonly __wbg_filetrie_free: (a: number, b: number) => void;
33
+ readonly filetrie_new: () => number;
34
+ readonly filetrie_push_chunk: (a: number, b: number, c: number) => void;
35
+ readonly filetrie_get_root: (a: number) => [number, number];
36
+ readonly __wbg_filemetadata_free: (a: number, b: number) => void;
37
+ readonly filemetadata_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number) => [number, number, number];
38
+ readonly filemetadata_getFileKey: (a: number) => [number, number];
39
+ readonly __wbindgen_export_0: WebAssembly.Table;
40
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
41
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
42
+ readonly __externref_table_dealloc: (a: number) => void;
43
+ readonly __wbindgen_start: () => void;
44
+ }
45
+
46
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
47
+ /**
48
+ * Instantiates the given `module`, which can either be bytes or
49
+ * a precompiled `WebAssembly.Module`.
50
+ *
51
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
52
+ *
53
+ * @returns {InitOutput}
54
+ */
55
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
56
+
57
+ /**
58
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
59
+ * for everything else, calls `WebAssembly.instantiate` directly.
60
+ *
61
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
62
+ *
63
+ * @returns {Promise<InitOutput>}
64
+ */
65
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,265 @@
1
+ let wasm;
2
+
3
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
4
+
5
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ function getStringFromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
19
+ }
20
+
21
+ let WASM_VECTOR_LEN = 0;
22
+
23
+ function passArray8ToWasm0(arg, malloc) {
24
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
25
+ getUint8ArrayMemory0().set(arg, ptr / 1);
26
+ WASM_VECTOR_LEN = arg.length;
27
+ return ptr;
28
+ }
29
+
30
+ function getArrayU8FromWasm0(ptr, len) {
31
+ ptr = ptr >>> 0;
32
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
33
+ }
34
+
35
+ function takeFromExternrefTable0(idx) {
36
+ const value = wasm.__wbindgen_export_0.get(idx);
37
+ wasm.__externref_table_dealloc(idx);
38
+ return value;
39
+ }
40
+
41
+ const FileMetadataFinalization = (typeof FinalizationRegistry === 'undefined')
42
+ ? { register: () => {}, unregister: () => {} }
43
+ : new FinalizationRegistry(ptr => wasm.__wbg_filemetadata_free(ptr >>> 0, 1));
44
+
45
+ export class FileMetadata {
46
+
47
+ __destroy_into_raw() {
48
+ const ptr = this.__wbg_ptr;
49
+ this.__wbg_ptr = 0;
50
+ FileMetadataFinalization.unregister(this);
51
+ return ptr;
52
+ }
53
+
54
+ free() {
55
+ const ptr = this.__destroy_into_raw();
56
+ wasm.__wbg_filemetadata_free(ptr, 0);
57
+ }
58
+ /**
59
+ * Constructs a new `FileMetadata`.
60
+ * * `owner`, `bucket_id`, `fingerprint` – 32-byte arrays (passed as slices)
61
+ * * `location` – arbitrary byte string (file path)
62
+ * * `size` – file size in bytes
63
+ * @param {Uint8Array} owner
64
+ * @param {Uint8Array} bucket_id
65
+ * @param {Uint8Array} location
66
+ * @param {bigint} size
67
+ * @param {Uint8Array} fingerprint
68
+ */
69
+ constructor(owner, bucket_id, location, size, fingerprint) {
70
+ const ptr0 = passArray8ToWasm0(owner, wasm.__wbindgen_malloc);
71
+ const len0 = WASM_VECTOR_LEN;
72
+ const ptr1 = passArray8ToWasm0(bucket_id, wasm.__wbindgen_malloc);
73
+ const len1 = WASM_VECTOR_LEN;
74
+ const ptr2 = passArray8ToWasm0(location, wasm.__wbindgen_malloc);
75
+ const len2 = WASM_VECTOR_LEN;
76
+ const ptr3 = passArray8ToWasm0(fingerprint, wasm.__wbindgen_malloc);
77
+ const len3 = WASM_VECTOR_LEN;
78
+ const ret = wasm.filemetadata_new(ptr0, len0, ptr1, len1, ptr2, len2, size, ptr3, len3);
79
+ if (ret[2]) {
80
+ throw takeFromExternrefTable0(ret[1]);
81
+ }
82
+ this.__wbg_ptr = ret[0] >>> 0;
83
+ FileMetadataFinalization.register(this, this.__wbg_ptr, this);
84
+ return this;
85
+ }
86
+ /**
87
+ * Returns the FileKey (blake2_256 hash of SCALE-encoded metadata) as a
88
+ * 32-byte `Uint8Array`.
89
+ * @returns {Uint8Array}
90
+ */
91
+ getFileKey() {
92
+ const ret = wasm.filemetadata_getFileKey(this.__wbg_ptr);
93
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
94
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
95
+ return v1;
96
+ }
97
+ }
98
+
99
+ const FileTrieFinalization = (typeof FinalizationRegistry === 'undefined')
100
+ ? { register: () => {}, unregister: () => {} }
101
+ : new FinalizationRegistry(ptr => wasm.__wbg_filetrie_free(ptr >>> 0, 1));
102
+
103
+ export class FileTrie {
104
+
105
+ __destroy_into_raw() {
106
+ const ptr = this.__wbg_ptr;
107
+ this.__wbg_ptr = 0;
108
+ FileTrieFinalization.unregister(this);
109
+ return ptr;
110
+ }
111
+
112
+ free() {
113
+ const ptr = this.__destroy_into_raw();
114
+ wasm.__wbg_filetrie_free(ptr, 0);
115
+ }
116
+ constructor() {
117
+ const ret = wasm.filetrie_new();
118
+ this.__wbg_ptr = ret >>> 0;
119
+ FileTrieFinalization.register(this, this.__wbg_ptr, this);
120
+ return this;
121
+ }
122
+ /**
123
+ * @param {Uint8Array} bytes
124
+ */
125
+ push_chunk(bytes) {
126
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
127
+ const len0 = WASM_VECTOR_LEN;
128
+ wasm.filetrie_push_chunk(this.__wbg_ptr, ptr0, len0);
129
+ }
130
+ /**
131
+ * Current Merkle root as a hex string.
132
+ * @returns {Uint8Array}
133
+ */
134
+ get_root() {
135
+ const ret = wasm.filetrie_get_root(this.__wbg_ptr);
136
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
137
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
138
+ return v1;
139
+ }
140
+ }
141
+
142
+ async function __wbg_load(module, imports) {
143
+ if (typeof Response === 'function' && module instanceof Response) {
144
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
145
+ try {
146
+ return await WebAssembly.instantiateStreaming(module, imports);
147
+
148
+ } catch (e) {
149
+ if (module.headers.get('Content-Type') != 'application/wasm') {
150
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
151
+
152
+ } else {
153
+ throw e;
154
+ }
155
+ }
156
+ }
157
+
158
+ const bytes = await module.arrayBuffer();
159
+ return await WebAssembly.instantiate(bytes, imports);
160
+
161
+ } else {
162
+ const instance = await WebAssembly.instantiate(module, imports);
163
+
164
+ if (instance instanceof WebAssembly.Instance) {
165
+ return { instance, module };
166
+
167
+ } else {
168
+ return instance;
169
+ }
170
+ }
171
+ }
172
+
173
+ function __wbg_get_imports() {
174
+ const imports = {};
175
+ imports.wbg = {};
176
+ imports.wbg.__wbindgen_init_externref_table = function() {
177
+ const table = wasm.__wbindgen_export_0;
178
+ const offset = table.grow(4);
179
+ table.set(0, undefined);
180
+ table.set(offset + 0, undefined);
181
+ table.set(offset + 1, null);
182
+ table.set(offset + 2, true);
183
+ table.set(offset + 3, false);
184
+ ;
185
+ };
186
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
187
+ const ret = getStringFromWasm0(arg0, arg1);
188
+ return ret;
189
+ };
190
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
191
+ throw new Error(getStringFromWasm0(arg0, arg1));
192
+ };
193
+
194
+ return imports;
195
+ }
196
+
197
+ function __wbg_init_memory(imports, memory) {
198
+
199
+ }
200
+
201
+ function __wbg_finalize_init(instance, module) {
202
+ wasm = instance.exports;
203
+ __wbg_init.__wbindgen_wasm_module = module;
204
+ cachedUint8ArrayMemory0 = null;
205
+
206
+
207
+ wasm.__wbindgen_start();
208
+ return wasm;
209
+ }
210
+
211
+ function initSync(module) {
212
+ if (wasm !== undefined) return wasm;
213
+
214
+
215
+ if (typeof module !== 'undefined') {
216
+ if (Object.getPrototypeOf(module) === Object.prototype) {
217
+ ({module} = module)
218
+ } else {
219
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
220
+ }
221
+ }
222
+
223
+ const imports = __wbg_get_imports();
224
+
225
+ __wbg_init_memory(imports);
226
+
227
+ if (!(module instanceof WebAssembly.Module)) {
228
+ module = new WebAssembly.Module(module);
229
+ }
230
+
231
+ const instance = new WebAssembly.Instance(module, imports);
232
+
233
+ return __wbg_finalize_init(instance, module);
234
+ }
235
+
236
+ async function __wbg_init(module_or_path) {
237
+ if (wasm !== undefined) return wasm;
238
+
239
+
240
+ if (typeof module_or_path !== 'undefined') {
241
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
242
+ ({module_or_path} = module_or_path)
243
+ } else {
244
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
245
+ }
246
+ }
247
+
248
+ if (typeof module_or_path === 'undefined') {
249
+ module_or_path = new URL('storagehub_wasm_bg.wasm', import.meta.url);
250
+ }
251
+ const imports = __wbg_get_imports();
252
+
253
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
254
+ module_or_path = fetch(module_or_path);
255
+ }
256
+
257
+ __wbg_init_memory(imports);
258
+
259
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
260
+
261
+ return __wbg_finalize_init(instance, module);
262
+ }
263
+
264
+ export { initSync };
265
+ export default __wbg_init;
Binary file
@@ -0,0 +1,15 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_filetrie_free: (a: number, b: number) => void;
5
+ export const filetrie_new: () => number;
6
+ export const filetrie_push_chunk: (a: number, b: number, c: number) => void;
7
+ export const filetrie_get_root: (a: number) => [number, number];
8
+ export const __wbg_filemetadata_free: (a: number, b: number) => void;
9
+ export const filemetadata_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number) => [number, number, number];
10
+ export const filemetadata_getFileKey: (a: number) => [number, number];
11
+ export const __wbindgen_export_0: WebAssembly.Table;
12
+ export const __wbindgen_malloc: (a: number, b: number) => number;
13
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
14
+ export const __externref_table_dealloc: (a: number) => void;
15
+ export const __wbindgen_start: () => void;