@dignetwork/dig-sdk 0.0.1-alpha.99 → 0.2.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.
Files changed (162) hide show
  1. package/LICENSE +21 -7
  2. package/README.md +412 -0
  3. package/dist/adapters.cjs +356 -0
  4. package/dist/adapters.cjs.map +1 -0
  5. package/dist/adapters.d.cts +20 -0
  6. package/dist/adapters.d.ts +20 -0
  7. package/dist/adapters.js +347 -0
  8. package/dist/adapters.js.map +1 -0
  9. package/dist/dev-shim-DfKRA1ok.d.cts +128 -0
  10. package/dist/dev-shim-DfKRA1ok.d.ts +128 -0
  11. package/dist/dig-client-entry-ChYxUvBn.d.cts +372 -0
  12. package/dist/dig-client-entry-ChYxUvBn.d.ts +372 -0
  13. package/dist/dig-client.cjs +443 -0
  14. package/dist/dig-client.cjs.map +1 -0
  15. package/dist/dig-client.d.cts +1 -0
  16. package/dist/dig-client.d.ts +1 -0
  17. package/dist/dig-client.js +432 -0
  18. package/dist/dig-client.js.map +1 -0
  19. package/dist/index.cjs +1186 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +502 -0
  22. package/dist/index.d.ts +502 -5
  23. package/dist/index.js +1156 -19
  24. package/dist/index.js.map +1 -0
  25. package/dist/next.cjs +369 -0
  26. package/dist/next.cjs.map +1 -0
  27. package/dist/next.d.cts +23 -0
  28. package/dist/next.d.ts +23 -0
  29. package/dist/next.js +362 -0
  30. package/dist/next.js.map +1 -0
  31. package/dist/spend.cjs +14 -0
  32. package/dist/spend.cjs.map +1 -0
  33. package/dist/spend.d.cts +1 -0
  34. package/dist/spend.d.ts +1 -0
  35. package/dist/spend.js +3 -0
  36. package/dist/spend.js.map +1 -0
  37. package/dist/vite.cjs +381 -0
  38. package/dist/vite.cjs.map +1 -0
  39. package/dist/vite.d.cts +35 -0
  40. package/dist/vite.d.ts +35 -0
  41. package/dist/vite.js +375 -0
  42. package/dist/vite.js.map +1 -0
  43. package/package.json +87 -59
  44. package/vendor/PROVENANCE.md +102 -0
  45. package/vendor/dig_client.d.ts +150 -0
  46. package/vendor/dig_client.mjs +805 -0
  47. package/vendor/dig_client_bg.wasm +0 -0
  48. package/dist/DataIntegrityTree/DataIntegrityTree.d.ts +0 -163
  49. package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +0 -1
  50. package/dist/DataIntegrityTree/DataIntegrityTree.js +0 -707
  51. package/dist/DataIntegrityTree/DataLayerError.d.ts +0 -6
  52. package/dist/DataIntegrityTree/DataLayerError.d.ts.map +0 -1
  53. package/dist/DataIntegrityTree/DataLayerError.js +0 -17
  54. package/dist/DataIntegrityTree/index.d.ts +0 -2
  55. package/dist/DataIntegrityTree/index.d.ts.map +0 -1
  56. package/dist/DataIntegrityTree/index.js +0 -17
  57. package/dist/DigNetwork/ContentServer.d.ts +0 -31
  58. package/dist/DigNetwork/ContentServer.d.ts.map +0 -1
  59. package/dist/DigNetwork/ContentServer.js +0 -176
  60. package/dist/DigNetwork/DigChallenge.d.ts +0 -82
  61. package/dist/DigNetwork/DigChallenge.d.ts.map +0 -1
  62. package/dist/DigNetwork/DigChallenge.js +0 -144
  63. package/dist/DigNetwork/DigNetwork.d.ts +0 -14
  64. package/dist/DigNetwork/DigNetwork.d.ts.map +0 -1
  65. package/dist/DigNetwork/DigNetwork.js +0 -169
  66. package/dist/DigNetwork/DigPeer.d.ts +0 -24
  67. package/dist/DigNetwork/DigPeer.d.ts.map +0 -1
  68. package/dist/DigNetwork/DigPeer.js +0 -118
  69. package/dist/DigNetwork/IncentiveServer.d.ts +0 -13
  70. package/dist/DigNetwork/IncentiveServer.d.ts.map +0 -1
  71. package/dist/DigNetwork/IncentiveServer.js +0 -76
  72. package/dist/DigNetwork/PropagationServer.d.ts +0 -81
  73. package/dist/DigNetwork/PropagationServer.d.ts.map +0 -1
  74. package/dist/DigNetwork/PropagationServer.js +0 -563
  75. package/dist/DigNetwork/index.d.ts +0 -4
  76. package/dist/DigNetwork/index.d.ts.map +0 -1
  77. package/dist/DigNetwork/index.js +0 -19
  78. package/dist/blockchain/DataStore.d.ts +0 -67
  79. package/dist/blockchain/DataStore.d.ts.map +0 -1
  80. package/dist/blockchain/DataStore.js +0 -413
  81. package/dist/blockchain/DataStoreSerializer.d.ts +0 -52
  82. package/dist/blockchain/DataStoreSerializer.d.ts.map +0 -1
  83. package/dist/blockchain/DataStoreSerializer.js +0 -109
  84. package/dist/blockchain/FullNodePeer.d.ts +0 -31
  85. package/dist/blockchain/FullNodePeer.d.ts.map +0 -1
  86. package/dist/blockchain/FullNodePeer.js +0 -295
  87. package/dist/blockchain/ServerCoin.d.ts +0 -29
  88. package/dist/blockchain/ServerCoin.d.ts.map +0 -1
  89. package/dist/blockchain/ServerCoin.js +0 -324
  90. package/dist/blockchain/Wallet.d.ts +0 -28
  91. package/dist/blockchain/Wallet.d.ts.map +0 -1
  92. package/dist/blockchain/Wallet.js +0 -253
  93. package/dist/blockchain/coins.d.ts +0 -6
  94. package/dist/blockchain/coins.d.ts.map +0 -1
  95. package/dist/blockchain/coins.js +0 -102
  96. package/dist/blockchain/index.d.ts +0 -8
  97. package/dist/blockchain/index.d.ts.map +0 -1
  98. package/dist/blockchain/index.js +0 -36
  99. package/dist/index.d.ts.map +0 -1
  100. package/dist/prompts.d.ts +0 -21
  101. package/dist/prompts.d.ts.map +0 -1
  102. package/dist/prompts.js +0 -149
  103. package/dist/types.d.ts +0 -64
  104. package/dist/types.d.ts.map +0 -1
  105. package/dist/types.js +0 -2
  106. package/dist/utils/ContentScanner.d.ts +0 -63
  107. package/dist/utils/ContentScanner.d.ts.map +0 -1
  108. package/dist/utils/ContentScanner.js +0 -175
  109. package/dist/utils/Environment.d.ts +0 -18
  110. package/dist/utils/Environment.d.ts.map +0 -1
  111. package/dist/utils/Environment.js +0 -85
  112. package/dist/utils/FileCache.d.ts +0 -11
  113. package/dist/utils/FileCache.d.ts.map +0 -1
  114. package/dist/utils/FileCache.js +0 -58
  115. package/dist/utils/FileTransfer.d.ts +0 -47
  116. package/dist/utils/FileTransfer.d.ts.map +0 -1
  117. package/dist/utils/FileTransfer.js +0 -209
  118. package/dist/utils/NconfManager.d.ts +0 -11
  119. package/dist/utils/NconfManager.d.ts.map +0 -1
  120. package/dist/utils/NconfManager.js +0 -56
  121. package/dist/utils/StoreArchiveManager.d.ts +0 -45
  122. package/dist/utils/StoreArchiveManager.d.ts.map +0 -1
  123. package/dist/utils/StoreArchiveManager.js +0 -153
  124. package/dist/utils/asyncPool.d.ts +0 -9
  125. package/dist/utils/asyncPool.d.ts.map +0 -1
  126. package/dist/utils/asyncPool.js +0 -23
  127. package/dist/utils/config.d.ts +0 -68
  128. package/dist/utils/config.d.ts.map +0 -1
  129. package/dist/utils/config.js +0 -223
  130. package/dist/utils/connectionUtils.d.ts +0 -10
  131. package/dist/utils/connectionUtils.d.ts.map +0 -1
  132. package/dist/utils/connectionUtils.js +0 -18
  133. package/dist/utils/credentialsUtils.d.ts +0 -8
  134. package/dist/utils/credentialsUtils.d.ts.map +0 -1
  135. package/dist/utils/credentialsUtils.js +0 -122
  136. package/dist/utils/directoryUtils.d.ts +0 -9
  137. package/dist/utils/directoryUtils.d.ts.map +0 -1
  138. package/dist/utils/directoryUtils.js +0 -110
  139. package/dist/utils/encryption.d.ts +0 -8
  140. package/dist/utils/encryption.d.ts.map +0 -1
  141. package/dist/utils/encryption.js +0 -55
  142. package/dist/utils/hashUtils.d.ts +0 -8
  143. package/dist/utils/hashUtils.d.ts.map +0 -1
  144. package/dist/utils/hashUtils.js +0 -44
  145. package/dist/utils/index.d.ts +0 -14
  146. package/dist/utils/index.d.ts.map +0 -1
  147. package/dist/utils/index.js +0 -29
  148. package/dist/utils/merkle.d.ts +0 -2
  149. package/dist/utils/merkle.d.ts.map +0 -1
  150. package/dist/utils/merkle.js +0 -28
  151. package/dist/utils/network.d.ts +0 -2
  152. package/dist/utils/network.d.ts.map +0 -1
  153. package/dist/utils/network.js +0 -54
  154. package/dist/utils/spinnerUtils.d.ts +0 -2
  155. package/dist/utils/spinnerUtils.d.ts.map +0 -1
  156. package/dist/utils/spinnerUtils.js +0 -47
  157. package/dist/utils/ssl.d.ts +0 -5
  158. package/dist/utils/ssl.d.ts.map +0 -1
  159. package/dist/utils/ssl.js +0 -50
  160. package/dist/utils/validationUtils.d.ts +0 -9
  161. package/dist/utils/validationUtils.d.ts.map +0 -1
  162. package/dist/utils/validationUtils.js +0 -55
@@ -0,0 +1,372 @@
1
+ /** The read-crypto functions the SDK uses from the dig_client WASM. */
2
+ interface DigClientWasm {
3
+ /** `retrieval_key = SHA-256(canonical rootless urn)`, lowercase hex. Empty key ⇒ index.html. */
4
+ retrievalKey(storeIdHex: string, resourceKey: string): string;
5
+ /** Derive the 32-byte AES-256 content key (lowercase hex). `saltHex` for a private store. */
6
+ deriveKey(storeIdHex: string, resourceKey: string, saltHex?: string | null): string;
7
+ /**
8
+ * Verify `ciphertext` is included under `trustedRootHex` via the base64 merkle `proofB64`.
9
+ * Returns true on success, false on ANY verification failure (a decoy returns false rather than
10
+ * throwing). Throws only on malformed inputs.
11
+ */
12
+ verifyInclusion(ciphertext: Uint8Array, proofB64: string, trustedRootHex: string): boolean;
13
+ /** AES-256-GCM-SIV-open a single chunk under an explicit 32-byte `keyHex`. Throws on tag fail. */
14
+ decryptChunk(keyHex: string, ciphertext: Uint8Array): Uint8Array;
15
+ /**
16
+ * Full read pipeline: gate (inclusion) then decrypt (URN key, split by `chunkLens`), returning
17
+ * plaintext bytes. `chunkLens` may be null/empty for a single-chunk resource.
18
+ */
19
+ decryptResource(storeIdHex: string, resourceKey: string, ciphertext: Uint8Array, proofB64: string, trustedRootHex: string, saltHex?: string | null, chunkLens?: Uint32Array | null): Uint8Array;
20
+ /** As `decryptResource`, returning UTF-8 text. */
21
+ decryptResourceToText(storeIdHex: string, resourceKey: string, ciphertext: Uint8Array, proofB64: string, trustedRootHex: string, saltHex?: string | null, chunkLens?: Uint32Array | null): string;
22
+ /** Seal a resource's plaintext as one GCM-SIV blob under its per-URN key (the encrypt inverse). */
23
+ encryptResource(storeIdHex: string, resourceKey: string, plaintext: Uint8Array, saltHex?: string | null): Uint8Array;
24
+ /** Reconstruct the canonical rootless URN string. */
25
+ reconstructUrn(storeIdHex: string, resourceKey: string): string;
26
+ /** Reconstruct a root-pinned display URN string. */
27
+ reconstructUrnWithRoot(storeIdHex: string, rootHex: string, resourceKey: string): string;
28
+ /** Library version (matches the crate version). */
29
+ version(): string;
30
+ }
31
+
32
+ /** A normalized `{ publicKey, signature }` pair from a wallet sign, both as `0x`-prefixed hex. */
33
+ interface SignResult {
34
+ /** The signing public key (synthetic BLS key), `0x`-prefixed hex. */
35
+ publicKey: string | null;
36
+ /** The BLS signature, `0x`-prefixed hex (or the raw wallet string). */
37
+ signature: string | null;
38
+ }
39
+ /**
40
+ * The minimal injected-provider contract the SDK detects on `window.chia` (the DIG Browser's
41
+ * in-process wallet, or a compatible CHIP-0002 extension). Mirrors the DIG Browser provider:
42
+ * `request({ method, params })` returns the wallet's `data`; `connect(eager)` blocks on per-origin
43
+ * approval; `on`/`off` are EIP-1193-style event hooks.
44
+ */
45
+ interface InjectedChiaProvider {
46
+ /** Unspoofable marker the DIG Browser provider sets; the SDK prefers a provider that has it. */
47
+ isDIG?: boolean;
48
+ /** Some providers expose a connected flag. */
49
+ isConnected?: boolean;
50
+ /** One CHIP-0002 RPC. Bare names auto-prefix to `chip0002_`; `chia_*` passes through. */
51
+ request(args: {
52
+ method: string;
53
+ params?: unknown;
54
+ }): Promise<unknown>;
55
+ /** Ask the wallet to approve this origin. Blocks until approved/rejected. */
56
+ connect?(eager?: boolean): Promise<unknown>;
57
+ on?(event: string, fn: (data: unknown) => void): void;
58
+ off?(event: string, fn: (data: unknown) => void): void;
59
+ }
60
+ declare global {
61
+ var chia: InjectedChiaProvider | undefined;
62
+ interface Window {
63
+ chia?: InjectedChiaProvider;
64
+ }
65
+ }
66
+ /** Which wallet transport is backing a `ChiaProvider`. */
67
+ type WalletBackend = "injected" | "walletconnect";
68
+ /** A connected wallet session, returned by `ChiaProvider.connect()`. */
69
+ interface WalletSession {
70
+ /** The transport backing this session. */
71
+ backend: WalletBackend;
72
+ /** The CAIP-2 chain id (e.g. "chia:mainnet"). */
73
+ chain: string;
74
+ /**
75
+ * The session topic. For WalletConnect this is the real relay topic; for the injected backend
76
+ * it is a stable sentinel ("injected") — callers do not need to inspect it.
77
+ */
78
+ topic: string;
79
+ /** The wallet's receive address, when known at connect time. */
80
+ address?: string | null;
81
+ }
82
+ /** Options for `DigClient.read*` calls — chiefly which dig RPC endpoint to use. */
83
+ interface ReadOptions {
84
+ /** dig RPC endpoint. Defaults to the public `https://rpc.dig.net`. */
85
+ rpc?: string;
86
+ }
87
+ /** The result of reading a resource by URN. */
88
+ interface ReadResult {
89
+ /** Store identity (64-hex). */
90
+ storeId: string;
91
+ /** The on-chain generation root the content was verified against (or null if none supplied). */
92
+ root: string | null;
93
+ /** The resource path within the store. */
94
+ resourceKey: string;
95
+ /** Private-store salt used (or null). */
96
+ salt: string | null;
97
+ /**
98
+ * The resource bytes. When `decrypted` is true these are the authenticated plaintext; when
99
+ * false they are the RAW served ciphertext (a decoy / wrong-key / wrong-salt response is just
100
+ * opaque bytes — the model is oblivious, so this is never a "not found" verdict).
101
+ */
102
+ bytes: Uint8Array;
103
+ /** Advisory: did the served bytes' inclusion proof verify against `root`? */
104
+ verified: boolean;
105
+ /** Did the bytes decrypt+authenticate under this URN's derived key? */
106
+ decrypted: boolean;
107
+ }
108
+ /**
109
+ * The on-chain CHIP-0007 metadata of a collection item, as returned by the dig RPC. Hashes are
110
+ * lowercase-hex 32-byte digests (or `null` when absent); URIs are the dig:// / https locations the
111
+ * bytes are served from. Mirrors the on-chain `NftMetadata` (the dig RPC decodes it from the NFT's
112
+ * metadata pointer). All fields optional/nullable so a non-standard metadata updater still parses.
113
+ */
114
+ interface CollectionItemMetadata {
115
+ /** 1-based edition number within the series. */
116
+ edition_number?: number;
117
+ /** Total editions in the series. */
118
+ edition_total?: number;
119
+ /** Primary media URIs (dig:// first, https fallback by convention). */
120
+ data_uris?: string[];
121
+ /** `sha256(media_bytes)`, lowercase hex, or null. */
122
+ data_hash?: string | null;
123
+ /** CHIP-0007 metadata-JSON URIs. */
124
+ metadata_uris?: string[];
125
+ /** `sha256(metadata_json_bytes)`, lowercase hex, or null. */
126
+ metadata_hash?: string | null;
127
+ /** License document URIs. */
128
+ license_uris?: string[];
129
+ /** `sha256(license_bytes)`, lowercase hex, or null. */
130
+ license_hash?: string | null;
131
+ }
132
+ /**
133
+ * One NFT in a collection, resolved to its CURRENT on-chain state by `DigClient.listCollectionItems`
134
+ * (owner-independent: the reported owner is live, walked forward through the singleton lineage, not
135
+ * the mint-time owner). All hashes/ids are lowercase hex.
136
+ */
137
+ interface CollectionItem {
138
+ /** The NFT's stable launcher id (its `nft1…` id encodes this), lowercase hex. */
139
+ launcher_id: string;
140
+ /** The current (unspent) coin id of the NFT singleton, lowercase hex. */
141
+ coin_id: string;
142
+ /** The current assigned owner DID launcher id (lowercase hex), or null when unattributed. */
143
+ owner_did: string | null;
144
+ /** The puzzle hash royalties are paid to in offer trades, lowercase hex. */
145
+ royalty_puzzle_hash: string;
146
+ /** Royalty as hundredths of a percent (300 = 3%). */
147
+ royalty_basis_points: number;
148
+ /** The CURRENT owner (p2) puzzle hash — where the NFT lives now, lowercase hex. */
149
+ owner_puzzle_hash: string;
150
+ /** The decoded on-chain CHIP-0007 metadata, or null when it does not decode. */
151
+ metadata: CollectionItemMetadata | null;
152
+ }
153
+ /** A deterministic, paginated page of collection items, from `DigClient.listCollectionItems`. */
154
+ interface CollectionItemsPage {
155
+ /** This page's items, in the requested (input launcher-id) order. */
156
+ items: CollectionItem[];
157
+ /** The offset this page started at. */
158
+ offset: number;
159
+ /** The page size requested (clamped to the server cap of 200). */
160
+ limit: number;
161
+ /** Total launcher ids in the requested collection set. */
162
+ total: number;
163
+ /** The offset of the next page, or null when this is the last page. */
164
+ next_offset: number | null;
165
+ }
166
+ /** Collection-level facts from `DigClient.getCollection` — derived from the resolved item set. */
167
+ interface CollectionMeta {
168
+ /** The creator DID launcher id the items AGREE on (lowercase hex), or null when mixed/none. */
169
+ did: string | null;
170
+ /** The DID the caller declared, echoed back (lowercase hex), or null. */
171
+ declared_did: string | null;
172
+ /** How many launcher ids were requested. */
173
+ item_count: number;
174
+ /** How many of those resolved to a live on-chain NFT. */
175
+ resolved_count: number;
176
+ /** The royalty (basis points) every item agrees on, or null when mixed. */
177
+ royalty_basis_points: number | null;
178
+ }
179
+ /** The two root-independent keys a URN maps to (derived client-side, nothing sent to the network). */
180
+ interface UrnKeys {
181
+ storeId: string;
182
+ root: string | null;
183
+ resourceKey: string;
184
+ salt: string | null;
185
+ /** `SHA-256(canonical rootless URN)`, lowercase hex — what the dig RPC is addressed by. */
186
+ retrievalKey: string;
187
+ /** The per-URN AES-256-GCM-SIV decryption key, lowercase hex. */
188
+ decryptionKey: string;
189
+ }
190
+
191
+ /** The default public dig RPC endpoint. */
192
+ declare const DEFAULT_RPC = "https://rpc.dig.net";
193
+ /** Options to construct a DigClient. */
194
+ interface DigClientOptions {
195
+ /** dig RPC endpoint. Defaults to the public `https://rpc.dig.net`. */
196
+ rpc?: string;
197
+ /** Override `fetch` (e.g. an instrumented one). Defaults to the global `fetch`. */
198
+ fetch?: typeof fetch;
199
+ }
200
+ /**
201
+ * The read-crypto client. Construct once and reuse — the wasm is loaded + SRI-verified lazily on
202
+ * the first read and memoized process/page-wide.
203
+ *
204
+ * @example
205
+ * const dig = new DigClient();
206
+ * const { bytes, decrypted } = await dig.read({
207
+ * urn: "urn:dig:chia:<storeId>/index.html",
208
+ * root: "<onchain-root-hex>",
209
+ * });
210
+ * if (decrypted) console.log(new TextDecoder().decode(bytes));
211
+ */
212
+ declare class DigClient {
213
+ private readonly rpc;
214
+ private readonly fetchImpl;
215
+ constructor(options?: DigClientOptions);
216
+ /** Load (and SRI-verify) the read-crypto wasm. Exposed for callers that want the raw functions. */
217
+ wasm(): Promise<DigClientWasm>;
218
+ /** `retrieval_key = SHA-256(canonical rootless URN)`, lowercase hex. */
219
+ retrievalKey(storeId: string, resourceKey: string): Promise<string>;
220
+ /** Derive the per-URN AES-256-GCM-SIV key, lowercase hex. `salt` for a private store. */
221
+ deriveKey(storeId: string, resourceKey: string, salt?: string | null): Promise<string>;
222
+ /** Verify served `ciphertext` is included under `root` via the base64 merkle `proof`. */
223
+ verifyInclusion(ciphertext: Uint8Array, proof: string, root: string): Promise<boolean>;
224
+ /** Reconstruct the canonical rootless URN whose SHA-256 is the retrieval key. */
225
+ reconstructUrn(storeId: string, resourceKey: string): Promise<string>;
226
+ /**
227
+ * Derive, client-side, the two root-independent keys a URN maps to (retrieval + decryption).
228
+ * Nothing is sent to the network — pure local derivation via the wasm.
229
+ */
230
+ deriveUrnKeys(input: {
231
+ urn: string;
232
+ salt?: string | null;
233
+ }): Promise<UrnKeys>;
234
+ /**
235
+ * Fetch + verify + decrypt one resource by URN. `root` is the on-chain generation root to verify
236
+ * against (resolved by the caller from the chain); when omitted, the root embedded in the URN is
237
+ * used. Returns the bytes plus advisory `verified`/`decrypted` flags. NEVER throws "not found"
238
+ * (presence is unknowable) — it throws only on a transport failure.
239
+ */
240
+ read(input: {
241
+ urn: string;
242
+ root?: string | null;
243
+ salt?: string | null;
244
+ }, opts?: ReadOptions): Promise<ReadResult>;
245
+ /** As `read`, but decoding the plaintext to a UTF-8 string when it decrypts (else throws). */
246
+ readText(input: {
247
+ urn: string;
248
+ root?: string | null;
249
+ salt?: string | null;
250
+ }, opts?: ReadOptions): Promise<string>;
251
+ /**
252
+ * Read by explicit (storeId, resourceKey, root, salt) rather than a URN string. The oblivious
253
+ * download primitive the URN read is built on.
254
+ */
255
+ readResource(input: {
256
+ storeId: string;
257
+ resourceKey: string;
258
+ root: string;
259
+ salt?: string | null;
260
+ }, opts?: ReadOptions): Promise<ReadResult>;
261
+ /**
262
+ * Read a collection's public, owner-independent facts (creator DID, item count, uniform royalty)
263
+ * from the dig RPC (`dig.getCollection`). The collection's item set is its NFT launcher ids — the
264
+ * authoritative, owner-independent anchor the mint produced (a DID-attributed NFT is hinted to its
265
+ * OWNER at mint, not to the creator DID, so launcher ids — not the DID — are the read key). Pass
266
+ * the optional `did` to have it echoed back and recorded as the declared creator.
267
+ *
268
+ * No wallet, no read-crypto wasm — a plain JSON-RPC read. Throws a coded {@link DigSdkError} on a
269
+ * transport/RPC failure (never a "not found": an empty/partly-confirmed set just resolves to fewer
270
+ * items).
271
+ *
272
+ * @example
273
+ * const meta = await dig.getCollection({ launcherIds: ["ab…", "cd…"], did: "ef…" });
274
+ * console.log(meta.resolved_count, meta.royalty_basis_points);
275
+ */
276
+ getCollection(input: {
277
+ launcherIds: string[];
278
+ did?: string | null;
279
+ }, opts?: ReadOptions): Promise<CollectionMeta>;
280
+ /**
281
+ * Read a deterministic, paginated page of a collection's items (`dig.listCollectionItems`), each
282
+ * resolved to its CURRENT on-chain state — current owner, royalty, and CHIP-0007 metadata — by the
283
+ * RPC walking the singleton lineage forward to the live tip (so the owner is never the stale
284
+ * mint-time owner). Items come back in the input launcher-id order. `limit` is clamped to the
285
+ * server cap (200); `offset` defaults to 0.
286
+ *
287
+ * Throws a coded {@link DigSdkError} on a transport/RPC failure.
288
+ *
289
+ * @example
290
+ * let page = await dig.listCollectionItems({ launcherIds, limit: 50 });
291
+ * for (const item of page.items) console.log(item.launcher_id, item.owner_puzzle_hash);
292
+ * // page.next_offset is null on the last page.
293
+ */
294
+ listCollectionItems(input: {
295
+ launcherIds: string[];
296
+ offset?: number;
297
+ limit?: number;
298
+ }, opts?: ReadOptions): Promise<CollectionItemsPage>;
299
+ private fetchCiphertext;
300
+ private rpcCall;
301
+ }
302
+
303
+ /** SHA-256 (lowercase hex) of vendor/dig_client_bg.wasm — the SRI digest. Fail closed on mismatch. */
304
+ declare const DIG_CLIENT_WASM_SHA256 = "ff486be806f908a2a90780e499a04dbd34e10e3b97be0470cb9ee841a1e49e77";
305
+ /** Optional explicit wasm inputs, for environments where auto-resolution can't find vendor/. */
306
+ interface WasmConfig {
307
+ /**
308
+ * The wasm bytes (already loaded). When provided, SRI is still enforced unless `skipIntegrity`.
309
+ * Pass this in CSP-strict browsers where you fetch + verify the bytes yourself.
310
+ */
311
+ wasmBytes?: BufferSource;
312
+ /**
313
+ * URL to the wasm-bindgen glue module (vendor/dig_client.mjs) for browser dynamic import. When
314
+ * omitted in a browser, the loader tries to import the glue relative to this module.
315
+ */
316
+ glueUrl?: string;
317
+ /**
318
+ * URL to fetch the wasm bytes from (browser) when `wasmBytes` is not supplied. The fetched bytes
319
+ * are SRI-verified before init.
320
+ */
321
+ wasmUrl?: string;
322
+ /** Skip the SRI check. Only for tests / trusted custom builds — NOT recommended. */
323
+ skipIntegrity?: boolean;
324
+ }
325
+ /**
326
+ * Override how the read-crypto wasm is located/loaded. Call BEFORE the first `DigClient` read.
327
+ * Mainly for browsers without a bundler that resolves package files, or CSP-strict apps that fetch
328
+ * + verify the wasm bytes themselves and hand them in. Resets any cached instance.
329
+ */
330
+ declare function configureWasm(config: WasmConfig): void;
331
+ /**
332
+ * Load, SRI-verify, and instantiate the read-crypto wasm, returning its functions. Memoized — at
333
+ * most one init per process/page. Fails closed on an integrity mismatch.
334
+ */
335
+ declare function loadDigClientWasm(): Promise<DigClientWasm>;
336
+
337
+ /** The parts of a parsed DIG URN. `root`/`salt` are null when absent. */
338
+ interface ParsedUrn {
339
+ /** Store identity (64-hex launcher id), lowercased. */
340
+ readonly storeId: string;
341
+ /** Generation root (64-hex), lowercased — or null for the root-independent form. */
342
+ readonly root: string | null;
343
+ /** Resource path within the store (verbatim, not lowercased). */
344
+ readonly resourceKey: string;
345
+ /** Private-store secret salt (hex), lowercased — or null for a public store. */
346
+ readonly salt: string | null;
347
+ }
348
+ /**
349
+ * Parse a DIG URN into its parts. Throws on a malformed URN.
350
+ *
351
+ * @example
352
+ * parseUrn("urn:dig:chia:" + "ab".repeat(32) + "/index.html")
353
+ * // → { storeId: "abab…", root: null, resourceKey: "index.html", salt: null }
354
+ */
355
+ declare function parseUrn(raw: string): ParsedUrn;
356
+ /** True iff `raw` is a syntactically valid DIG URN. Never throws. */
357
+ declare function isUrn(raw: string): boolean;
358
+ /**
359
+ * Reconstruct the canonical, root-INDEPENDENT URN string for a store + resource key:
360
+ * `urn:dig:chia:<store_id>/<resource_key>`. An empty resource key resolves to the default view
361
+ * `index.html`. This is the form whose SHA-256 is the retrieval key and whose bytes seed the AES
362
+ * key — matching the wasm's `reconstructUrn`.
363
+ */
364
+ declare function reconstructUrn(storeId: string, resourceKey: string): string;
365
+ /**
366
+ * Reconstruct a root-PINNED display URN: `urn:dig:chia:<store_id>:<root>/<resource_key>`. Useful
367
+ * for sharing a URN bound to a specific generation; the retrieval/AES keys still use the rootless
368
+ * form (`reconstructUrn`).
369
+ */
370
+ declare function reconstructUrnWithRoot(storeId: string, root: string, resourceKey: string): string;
371
+
372
+ export { type CollectionItem as C, DEFAULT_RPC as D, type InjectedChiaProvider as I, type ParsedUrn as P, type ReadOptions as R, type SignResult as S, type UrnKeys as U, type WalletBackend as W, type WalletSession as a, type CollectionItemMetadata as b, type CollectionItemsPage as c, type CollectionMeta as d, DIG_CLIENT_WASM_SHA256 as e, DigClient as f, type DigClientOptions as g, type DigClientWasm as h, type ReadResult as i, type WasmConfig as j, configureWasm as k, isUrn as l, loadDigClientWasm as m, reconstructUrnWithRoot as n, parseUrn as p, reconstructUrn as r };