@dignetwork/dig-sdk 0.1.0 → 0.2.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.
Files changed (40) hide show
  1. package/README.md +159 -11
  2. package/dist/adapters.cjs +56 -15
  3. package/dist/adapters.cjs.map +1 -1
  4. package/dist/adapters.d.cts +2 -2
  5. package/dist/adapters.d.ts +2 -2
  6. package/dist/adapters.js +56 -15
  7. package/dist/adapters.js.map +1 -1
  8. package/dist/{dev-shim-Bgw8X2E9.d.cts → dev-shim-DfKRA1ok.d.cts} +13 -3
  9. package/dist/{dev-shim-Bgw8X2E9.d.ts → dev-shim-DfKRA1ok.d.ts} +13 -3
  10. package/dist/{dig-client-entry-BIzuZ7Rs.d.cts → dig-client-entry-Bc95rd_t.d.cts} +120 -7
  11. package/dist/{dig-client-entry-BIzuZ7Rs.d.ts → dig-client-entry-Bc95rd_t.d.ts} +120 -7
  12. package/dist/dig-client.cjs +163 -43
  13. package/dist/dig-client.cjs.map +1 -1
  14. package/dist/dig-client.d.cts +1 -1
  15. package/dist/dig-client.d.ts +1 -1
  16. package/dist/dig-client.js +163 -43
  17. package/dist/dig-client.js.map +1 -1
  18. package/dist/index.cjs +495 -56
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +313 -3
  21. package/dist/index.d.ts +313 -3
  22. package/dist/index.js +489 -57
  23. package/dist/index.js.map +1 -1
  24. package/dist/next.cjs +58 -15
  25. package/dist/next.cjs.map +1 -1
  26. package/dist/next.d.cts +1 -1
  27. package/dist/next.d.ts +1 -1
  28. package/dist/next.js +58 -15
  29. package/dist/next.js.map +1 -1
  30. package/dist/vite.cjs +58 -15
  31. package/dist/vite.cjs.map +1 -1
  32. package/dist/vite.d.cts +1 -1
  33. package/dist/vite.d.ts +1 -1
  34. package/dist/vite.js +58 -15
  35. package/dist/vite.js.map +1 -1
  36. package/package.json +5 -6
  37. package/vendor/PROVENANCE.md +0 -102
  38. package/vendor/dig_client.d.ts +0 -150
  39. package/vendor/dig_client.mjs +0 -805
  40. package/vendor/dig_client_bg.wasm +0 -0
@@ -1,805 +0,0 @@
1
- /* @ts-self-types="./dig_client.d.ts" */
2
-
3
- /**
4
- * Decrypt a SINGLE GCM-SIV chunk under an explicit 32-byte `key` (hex). Returns
5
- * the plaintext bytes. A failed tag check (tamper / wrong key) is an error.
6
- * Low-level escape hatch; most callers want `decryptResource`.
7
- * @param {string} key_hex
8
- * @param {Uint8Array} ciphertext
9
- * @returns {Uint8Array}
10
- */
11
- export function decryptChunk(key_hex, ciphertext) {
12
- const ptr0 = passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
13
- const len0 = WASM_VECTOR_LEN;
14
- const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
15
- const len1 = WASM_VECTOR_LEN;
16
- const ret = wasm.decryptChunk(ptr0, len0, ptr1, len1);
17
- if (ret[3]) {
18
- throw takeFromExternrefTable0(ret[2]);
19
- }
20
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
21
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
22
- return v3;
23
- }
24
-
25
- /**
26
- * Full read pipeline for a resource's served ciphertext (Digstore §9.3 + §11),
27
- * returning the decrypted plaintext bytes. Steps, in order (gate-then-decrypt):
28
- *
29
- * 1. **Integrity gate** — verify the served bytes' merkle inclusion against the
30
- * chain-anchored `trusted_root_hex` (proof base64 from `X-Dig-Inclusion-Proof`).
31
- * 2. **Confidentiality** — derive the URN key, split the PLAIN-concatenated
32
- * chunk ciphertexts by `chunk_lens` (the per-chunk CIPHERTEXT byte lengths in
33
- * order; D5/C9 — NO length framing on the wire), and AES-256-GCM-SIV-open
34
- * each, concatenating plaintext in order.
35
- *
36
- * `chunk_lens` may be empty for the common single-chunk resource (the whole blob
37
- * is one GCM-SIV ciphertext). They MUST sum to `ciphertext.len()`.
38
- * @param {string} store_id_hex
39
- * @param {string} resource_key
40
- * @param {Uint8Array} ciphertext
41
- * @param {string} proof_b64
42
- * @param {string} trusted_root_hex
43
- * @param {string | null} [salt_hex]
44
- * @param {Uint32Array | null} [chunk_lens]
45
- * @returns {Uint8Array}
46
- */
47
- export function decryptResource(store_id_hex, resource_key, ciphertext, proof_b64, trusted_root_hex, salt_hex, chunk_lens) {
48
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
- const len0 = WASM_VECTOR_LEN;
50
- const ptr1 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
51
- const len1 = WASM_VECTOR_LEN;
52
- const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
53
- const len2 = WASM_VECTOR_LEN;
54
- const ptr3 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
55
- const len3 = WASM_VECTOR_LEN;
56
- const ptr4 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
57
- const len4 = WASM_VECTOR_LEN;
58
- var ptr5 = isLikeNone(salt_hex) ? 0 : passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
- var len5 = WASM_VECTOR_LEN;
60
- var ptr6 = isLikeNone(chunk_lens) ? 0 : passArray32ToWasm0(chunk_lens, wasm.__wbindgen_malloc);
61
- var len6 = WASM_VECTOR_LEN;
62
- const ret = wasm.decryptResource(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
63
- if (ret[3]) {
64
- throw takeFromExternrefTable0(ret[2]);
65
- }
66
- var v8 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
67
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
68
- return v8;
69
- }
70
-
71
- /**
72
- * Convenience wrapper around [`decrypt_resource`] returning the plaintext as a
73
- * UTF-8 string (for HTML/text resources rendered into the sandbox iframe).
74
- * @param {string} store_id_hex
75
- * @param {string} resource_key
76
- * @param {Uint8Array} ciphertext
77
- * @param {string} proof_b64
78
- * @param {string} trusted_root_hex
79
- * @param {string | null} [salt_hex]
80
- * @param {Uint32Array | null} [chunk_lens]
81
- * @returns {string}
82
- */
83
- export function decryptResourceToText(store_id_hex, resource_key, ciphertext, proof_b64, trusted_root_hex, salt_hex, chunk_lens) {
84
- let deferred9_0;
85
- let deferred9_1;
86
- try {
87
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
88
- const len0 = WASM_VECTOR_LEN;
89
- const ptr1 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
90
- const len1 = WASM_VECTOR_LEN;
91
- const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
92
- const len2 = WASM_VECTOR_LEN;
93
- const ptr3 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
94
- const len3 = WASM_VECTOR_LEN;
95
- const ptr4 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
- const len4 = WASM_VECTOR_LEN;
97
- var ptr5 = isLikeNone(salt_hex) ? 0 : passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
98
- var len5 = WASM_VECTOR_LEN;
99
- var ptr6 = isLikeNone(chunk_lens) ? 0 : passArray32ToWasm0(chunk_lens, wasm.__wbindgen_malloc);
100
- var len6 = WASM_VECTOR_LEN;
101
- const ret = wasm.decryptResourceToText(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
102
- var ptr8 = ret[0];
103
- var len8 = ret[1];
104
- if (ret[3]) {
105
- ptr8 = 0; len8 = 0;
106
- throw takeFromExternrefTable0(ret[2]);
107
- }
108
- deferred9_0 = ptr8;
109
- deferred9_1 = len8;
110
- return getStringFromWasm0(ptr8, len8);
111
- } finally {
112
- wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
113
- }
114
- }
115
-
116
- /**
117
- * Derive the 32-byte AES-256 content key for a resource (Digstore §11.1/§11.4),
118
- * returned as lowercase hex. `salt_hex` is the 32-byte private-store secret salt
119
- * (omit / pass `null` for public stores). Mixing in a wrong/missing salt yields
120
- * a wrong key whose GCM-SIV tag will not verify.
121
- * @param {string} store_id_hex
122
- * @param {string} resource_key
123
- * @param {string | null} [salt_hex]
124
- * @returns {string}
125
- */
126
- export function deriveKey(store_id_hex, resource_key, salt_hex) {
127
- let deferred5_0;
128
- let deferred5_1;
129
- try {
130
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
- const len0 = WASM_VECTOR_LEN;
132
- const ptr1 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
- const len1 = WASM_VECTOR_LEN;
134
- var ptr2 = isLikeNone(salt_hex) ? 0 : passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
- var len2 = WASM_VECTOR_LEN;
136
- const ret = wasm.deriveKey(ptr0, len0, ptr1, len1, ptr2, len2);
137
- var ptr4 = ret[0];
138
- var len4 = ret[1];
139
- if (ret[3]) {
140
- ptr4 = 0; len4 = 0;
141
- throw takeFromExternrefTable0(ret[2]);
142
- }
143
- deferred5_0 = ptr4;
144
- deferred5_1 = len4;
145
- return getStringFromWasm0(ptr4, len4);
146
- } finally {
147
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
148
- }
149
- }
150
-
151
- /**
152
- * Seal a resource's plaintext as ONE AES-256-GCM-SIV blob under its per-URN key — the inverse of
153
- * the read path's chunk decrypt. The browser uses this to PRE-ENCRYPT a file before upload so the
154
- * server compiles the `.dig` from ciphertext alone (it never sees plaintext or any key). The
155
- * output is the resource's whole-file ciphertext; `digstore compile --pre-encrypted` stores it
156
- * verbatim as the single chunk, and `decryptResource`/`decryptChunk` under the same URN reverses
157
- * it. `salt_hex` is the store's secret salt for a private store (omit for a public store).
158
- * @param {string} store_id_hex
159
- * @param {string} resource_key
160
- * @param {Uint8Array} plaintext
161
- * @param {string | null} [salt_hex]
162
- * @returns {Uint8Array}
163
- */
164
- export function encryptResource(store_id_hex, resource_key, plaintext, salt_hex) {
165
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
166
- const len0 = WASM_VECTOR_LEN;
167
- const ptr1 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168
- const len1 = WASM_VECTOR_LEN;
169
- const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
170
- const len2 = WASM_VECTOR_LEN;
171
- var ptr3 = isLikeNone(salt_hex) ? 0 : passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
172
- var len3 = WASM_VECTOR_LEN;
173
- const ret = wasm.encryptResource(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
174
- if (ret[3]) {
175
- throw takeFromExternrefTable0(ret[2]);
176
- }
177
- var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
178
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
179
- return v5;
180
- }
181
-
182
- /**
183
- * On module load, install a `globalThis.digClient` object exposing the read
184
- * API, so non-bundler consumers (the standalone usercontent loader) can call
185
- * `globalThis.digClient.verifyInclusion(...)` / `.decryptResourceToText(...)`
186
- * after the wasm initializes. ES-module consumers can instead import the named
187
- * functions directly. Idempotent and best-effort (no-op if `globalThis` lacks
188
- * `Object`, e.g. in a non-browser host).
189
- */
190
- export function install_global() {
191
- wasm.install_global();
192
- }
193
-
194
- /**
195
- * Reconstruct the canonical ROOT-INDEPENDENT resource URN string for a store +
196
- * resource key: `urn:dig:chia:<store_id>[/<resource_key>]`. An empty resource
197
- * key resolves to the §8.5 default view `index.html`. This is the form whose
198
- * SHA-256 is the retrieval key and whose bytes seed the AES key.
199
- * @param {string} store_id_hex
200
- * @param {string} resource_key
201
- * @returns {string}
202
- */
203
- export function reconstructUrn(store_id_hex, resource_key) {
204
- let deferred4_0;
205
- let deferred4_1;
206
- try {
207
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
- const len0 = WASM_VECTOR_LEN;
209
- const ptr1 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
210
- const len1 = WASM_VECTOR_LEN;
211
- const ret = wasm.reconstructUrn(ptr0, len0, ptr1, len1);
212
- var ptr3 = ret[0];
213
- var len3 = ret[1];
214
- if (ret[3]) {
215
- ptr3 = 0; len3 = 0;
216
- throw takeFromExternrefTable0(ret[2]);
217
- }
218
- deferred4_0 = ptr3;
219
- deferred4_1 = len3;
220
- return getStringFromWasm0(ptr3, len3);
221
- } finally {
222
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
223
- }
224
- }
225
-
226
- /**
227
- * Reconstruct a ROOT-PINNED display URN: `urn:dig:chia:<store_id>:<root>/<key>`.
228
- * Useful for sharing a URN bound to a specific generation; the retrieval/AES
229
- * keys still use the rootless form (`reconstructUrn`).
230
- * @param {string} store_id_hex
231
- * @param {string} root_hex
232
- * @param {string} resource_key
233
- * @returns {string}
234
- */
235
- export function reconstructUrnWithRoot(store_id_hex, root_hex, resource_key) {
236
- let deferred5_0;
237
- let deferred5_1;
238
- try {
239
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
- const len0 = WASM_VECTOR_LEN;
241
- const ptr1 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
242
- const len1 = WASM_VECTOR_LEN;
243
- const ptr2 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
244
- const len2 = WASM_VECTOR_LEN;
245
- const ret = wasm.reconstructUrnWithRoot(ptr0, len0, ptr1, len1, ptr2, len2);
246
- var ptr4 = ret[0];
247
- var len4 = ret[1];
248
- if (ret[3]) {
249
- ptr4 = 0; len4 = 0;
250
- throw takeFromExternrefTable0(ret[2]);
251
- }
252
- deferred5_0 = ptr4;
253
- deferred5_1 = len4;
254
- return getStringFromWasm0(ptr4, len4);
255
- } finally {
256
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
257
- }
258
- }
259
-
260
- /**
261
- * `retrieval_key = SHA-256(canonical_rootless_urn)`, lowercase hex (Digstore
262
- * §7.3; API §17). The CDN is addressed by this hash; the URN itself is never
263
- * sent. An empty resource key resolves to `index.html`.
264
- * @param {string} store_id_hex
265
- * @param {string} resource_key
266
- * @returns {string}
267
- */
268
- export function retrievalKey(store_id_hex, resource_key) {
269
- let deferred4_0;
270
- let deferred4_1;
271
- try {
272
- const ptr0 = passStringToWasm0(store_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
273
- const len0 = WASM_VECTOR_LEN;
274
- const ptr1 = passStringToWasm0(resource_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
275
- const len1 = WASM_VECTOR_LEN;
276
- const ret = wasm.retrievalKey(ptr0, len0, ptr1, len1);
277
- var ptr3 = ret[0];
278
- var len3 = ret[1];
279
- if (ret[3]) {
280
- ptr3 = 0; len3 = 0;
281
- throw takeFromExternrefTable0(ret[2]);
282
- }
283
- deferred4_0 = ptr3;
284
- deferred4_1 = len3;
285
- return getStringFromWasm0(ptr3, len3);
286
- } finally {
287
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
288
- }
289
- }
290
-
291
- /**
292
- * Verify that `ciphertext` is included under `trusted_root_hex` via the base64
293
- * merkle `proof_b64` (Digstore §9.3; API §18). Returns `true` on success and
294
- * `false` on ANY verification failure (tampered bytes, non-chaining path, or a
295
- * root mismatch / decoy) — a decoy or wrong-store response returns `false`
296
- * rather than throwing, so a caller can treat it as "not found in this store".
297
- * Throws only on malformed inputs (bad base64 / hex / proof encoding).
298
- * @param {Uint8Array} ciphertext
299
- * @param {string} proof_b64
300
- * @param {string} trusted_root_hex
301
- * @returns {boolean}
302
- */
303
- export function verifyInclusion(ciphertext, proof_b64, trusted_root_hex) {
304
- const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
305
- const len0 = WASM_VECTOR_LEN;
306
- const ptr1 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
307
- const len1 = WASM_VECTOR_LEN;
308
- const ptr2 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
309
- const len2 = WASM_VECTOR_LEN;
310
- const ret = wasm.verifyInclusion(ptr0, len0, ptr1, len1, ptr2, len2);
311
- if (ret[2]) {
312
- throw takeFromExternrefTable0(ret[1]);
313
- }
314
- return ret[0] !== 0;
315
- }
316
-
317
- /**
318
- * Library version (matches the crate version), for SRI / compatibility checks.
319
- * @returns {string}
320
- */
321
- export function version() {
322
- let deferred1_0;
323
- let deferred1_1;
324
- try {
325
- const ret = wasm.version();
326
- deferred1_0 = ret[0];
327
- deferred1_1 = ret[1];
328
- return getStringFromWasm0(ret[0], ret[1]);
329
- } finally {
330
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
331
- }
332
- }
333
- function __wbg_get_imports() {
334
- const import0 = {
335
- __proto__: null,
336
- __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
337
- const ret = Error(getStringFromWasm0(arg0, arg1));
338
- return ret;
339
- },
340
- __wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
341
- const ret = arg0 === undefined;
342
- return ret;
343
- },
344
- __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
345
- throw new Error(getStringFromWasm0(arg0, arg1));
346
- },
347
- __wbg_new_2e117a478906f062: function() {
348
- const ret = new Object();
349
- return ret;
350
- },
351
- __wbg_set_4564f7dc44fcb0c9: function() { return handleError(function (arg0, arg1, arg2) {
352
- const ret = Reflect.set(arg0, arg1, arg2);
353
- return ret;
354
- }, arguments); },
355
- __wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938: function() {
356
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
357
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
358
- },
359
- __wbg_static_accessor_GLOBAL_ce44e66a4935da8c: function() {
360
- const ret = typeof global === 'undefined' ? null : global;
361
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
362
- },
363
- __wbg_static_accessor_SELF_44f6e0cb5e67cdad: function() {
364
- const ret = typeof self === 'undefined' ? null : self;
365
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
366
- },
367
- __wbg_static_accessor_WINDOW_168f178805d978fe: function() {
368
- const ret = typeof window === 'undefined' ? null : window;
369
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
370
- },
371
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
372
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [String, String, Option(String)], shim_idx: 1, ret: Result(String), inner_ret: Some(Result(String)) }, mutable: false }) -> Externref`.
373
- const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h68a3f7e1b7047a46);
374
- return ret;
375
- },
376
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
377
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [String, String, Vector(U8), String, String, Option(String), Option(Vector(U32))], shim_idx: 5, ret: Result(Vector(U8)), inner_ret: Some(Result(Vector(U8))) }, mutable: false }) -> Externref`.
378
- const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hc605e6b36f32dd24);
379
- return ret;
380
- },
381
- __wbindgen_cast_0000000000000003: function(arg0, arg1) {
382
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [String, String, Vector(U8), String, String, Option(String), Option(Vector(U32))], shim_idx: 6, ret: Result(String), inner_ret: Some(Result(String)) }, mutable: false }) -> Externref`.
383
- const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h58cab831a65fd6c8);
384
- return ret;
385
- },
386
- __wbindgen_cast_0000000000000004: function(arg0, arg1) {
387
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [String, String], shim_idx: 2, ret: Result(String), inner_ret: Some(Result(String)) }, mutable: false }) -> Externref`.
388
- const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd4233470ad4ef59f);
389
- return ret;
390
- },
391
- __wbindgen_cast_0000000000000005: function(arg0, arg1) {
392
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Vector(U8), String, String], shim_idx: 3, ret: Result(Boolean), inner_ret: Some(Result(Boolean)) }, mutable: false }) -> Externref`.
393
- const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h36771739d8dc18ae);
394
- return ret;
395
- },
396
- __wbindgen_cast_0000000000000006: function(arg0, arg1) {
397
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 4, ret: String, inner_ret: Some(String) }, mutable: false }) -> Externref`.
398
- const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h61ffc6ac64470c43);
399
- return ret;
400
- },
401
- __wbindgen_cast_0000000000000007: function(arg0, arg1) {
402
- // Cast intrinsic for `Ref(String) -> Externref`.
403
- const ret = getStringFromWasm0(arg0, arg1);
404
- return ret;
405
- },
406
- __wbindgen_init_externref_table: function() {
407
- const table = wasm.__wbindgen_externrefs;
408
- const offset = table.grow(4);
409
- table.set(0, undefined);
410
- table.set(offset + 0, undefined);
411
- table.set(offset + 1, null);
412
- table.set(offset + 2, true);
413
- table.set(offset + 3, false);
414
- },
415
- };
416
- return {
417
- __proto__: null,
418
- "./dig_client_bg.js": import0,
419
- };
420
- }
421
-
422
- function wasm_bindgen__convert__closures_____invoke__h61ffc6ac64470c43(arg0, arg1) {
423
- let deferred1_0;
424
- let deferred1_1;
425
- try {
426
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h61ffc6ac64470c43(arg0, arg1);
427
- deferred1_0 = ret[0];
428
- deferred1_1 = ret[1];
429
- return getStringFromWasm0(ret[0], ret[1]);
430
- } finally {
431
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
432
- }
433
- }
434
-
435
- function wasm_bindgen__convert__closures_____invoke__hd4233470ad4ef59f(arg0, arg1, arg2, arg3) {
436
- let deferred4_0;
437
- let deferred4_1;
438
- try {
439
- const ptr0 = passStringToWasm0(arg2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
440
- const len0 = WASM_VECTOR_LEN;
441
- const ptr1 = passStringToWasm0(arg3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
442
- const len1 = WASM_VECTOR_LEN;
443
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__hd4233470ad4ef59f(arg0, arg1, ptr0, len0, ptr1, len1);
444
- var ptr3 = ret[0];
445
- var len3 = ret[1];
446
- if (ret[3]) {
447
- ptr3 = 0; len3 = 0;
448
- throw takeFromExternrefTable0(ret[2]);
449
- }
450
- deferred4_0 = ptr3;
451
- deferred4_1 = len3;
452
- return getStringFromWasm0(ptr3, len3);
453
- } finally {
454
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
455
- }
456
- }
457
-
458
- function wasm_bindgen__convert__closures_____invoke__h36771739d8dc18ae(arg0, arg1, arg2, arg3, arg4) {
459
- const ptr0 = passArray8ToWasm0(arg2, wasm.__wbindgen_malloc);
460
- const len0 = WASM_VECTOR_LEN;
461
- const ptr1 = passStringToWasm0(arg3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
462
- const len1 = WASM_VECTOR_LEN;
463
- const ptr2 = passStringToWasm0(arg4, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
464
- const len2 = WASM_VECTOR_LEN;
465
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h36771739d8dc18ae(arg0, arg1, ptr0, len0, ptr1, len1, ptr2, len2);
466
- if (ret[2]) {
467
- throw takeFromExternrefTable0(ret[1]);
468
- }
469
- return ret[0] !== 0;
470
- }
471
-
472
- function wasm_bindgen__convert__closures_____invoke__h68a3f7e1b7047a46(arg0, arg1, arg2, arg3, arg4) {
473
- let deferred5_0;
474
- let deferred5_1;
475
- try {
476
- const ptr0 = passStringToWasm0(arg2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
477
- const len0 = WASM_VECTOR_LEN;
478
- const ptr1 = passStringToWasm0(arg3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
479
- const len1 = WASM_VECTOR_LEN;
480
- var ptr2 = isLikeNone(arg4) ? 0 : passStringToWasm0(arg4, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
481
- var len2 = WASM_VECTOR_LEN;
482
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h68a3f7e1b7047a46(arg0, arg1, ptr0, len0, ptr1, len1, ptr2, len2);
483
- var ptr4 = ret[0];
484
- var len4 = ret[1];
485
- if (ret[3]) {
486
- ptr4 = 0; len4 = 0;
487
- throw takeFromExternrefTable0(ret[2]);
488
- }
489
- deferred5_0 = ptr4;
490
- deferred5_1 = len4;
491
- return getStringFromWasm0(ptr4, len4);
492
- } finally {
493
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
494
- }
495
- }
496
-
497
- function wasm_bindgen__convert__closures_____invoke__hc605e6b36f32dd24(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
498
- const ptr0 = passStringToWasm0(arg2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
499
- const len0 = WASM_VECTOR_LEN;
500
- const ptr1 = passStringToWasm0(arg3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
501
- const len1 = WASM_VECTOR_LEN;
502
- const ptr2 = passArray8ToWasm0(arg4, wasm.__wbindgen_malloc);
503
- const len2 = WASM_VECTOR_LEN;
504
- const ptr3 = passStringToWasm0(arg5, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
505
- const len3 = WASM_VECTOR_LEN;
506
- const ptr4 = passStringToWasm0(arg6, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
507
- const len4 = WASM_VECTOR_LEN;
508
- var ptr5 = isLikeNone(arg7) ? 0 : passStringToWasm0(arg7, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
509
- var len5 = WASM_VECTOR_LEN;
510
- var ptr6 = isLikeNone(arg8) ? 0 : passArray32ToWasm0(arg8, wasm.__wbindgen_malloc);
511
- var len6 = WASM_VECTOR_LEN;
512
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__hc605e6b36f32dd24(arg0, arg1, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
513
- if (ret[3]) {
514
- throw takeFromExternrefTable0(ret[2]);
515
- }
516
- var v8 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
517
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
518
- return v8;
519
- }
520
-
521
- function wasm_bindgen__convert__closures_____invoke__h58cab831a65fd6c8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
522
- let deferred9_0;
523
- let deferred9_1;
524
- try {
525
- const ptr0 = passStringToWasm0(arg2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
526
- const len0 = WASM_VECTOR_LEN;
527
- const ptr1 = passStringToWasm0(arg3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
528
- const len1 = WASM_VECTOR_LEN;
529
- const ptr2 = passArray8ToWasm0(arg4, wasm.__wbindgen_malloc);
530
- const len2 = WASM_VECTOR_LEN;
531
- const ptr3 = passStringToWasm0(arg5, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
532
- const len3 = WASM_VECTOR_LEN;
533
- const ptr4 = passStringToWasm0(arg6, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
534
- const len4 = WASM_VECTOR_LEN;
535
- var ptr5 = isLikeNone(arg7) ? 0 : passStringToWasm0(arg7, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
536
- var len5 = WASM_VECTOR_LEN;
537
- var ptr6 = isLikeNone(arg8) ? 0 : passArray32ToWasm0(arg8, wasm.__wbindgen_malloc);
538
- var len6 = WASM_VECTOR_LEN;
539
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h58cab831a65fd6c8(arg0, arg1, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
540
- var ptr8 = ret[0];
541
- var len8 = ret[1];
542
- if (ret[3]) {
543
- ptr8 = 0; len8 = 0;
544
- throw takeFromExternrefTable0(ret[2]);
545
- }
546
- deferred9_0 = ptr8;
547
- deferred9_1 = len8;
548
- return getStringFromWasm0(ptr8, len8);
549
- } finally {
550
- wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
551
- }
552
- }
553
-
554
- function addToExternrefTable0(obj) {
555
- const idx = wasm.__externref_table_alloc();
556
- wasm.__wbindgen_externrefs.set(idx, obj);
557
- return idx;
558
- }
559
-
560
- const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
561
- ? { register: () => {}, unregister: () => {} }
562
- : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
563
-
564
- function getArrayU8FromWasm0(ptr, len) {
565
- ptr = ptr >>> 0;
566
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
567
- }
568
-
569
- function getStringFromWasm0(ptr, len) {
570
- return decodeText(ptr >>> 0, len);
571
- }
572
-
573
- let cachedUint32ArrayMemory0 = null;
574
- function getUint32ArrayMemory0() {
575
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
576
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
577
- }
578
- return cachedUint32ArrayMemory0;
579
- }
580
-
581
- let cachedUint8ArrayMemory0 = null;
582
- function getUint8ArrayMemory0() {
583
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
584
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
585
- }
586
- return cachedUint8ArrayMemory0;
587
- }
588
-
589
- function handleError(f, args) {
590
- try {
591
- return f.apply(this, args);
592
- } catch (e) {
593
- const idx = addToExternrefTable0(e);
594
- wasm.__wbindgen_exn_store(idx);
595
- }
596
- }
597
-
598
- function isLikeNone(x) {
599
- return x === undefined || x === null;
600
- }
601
-
602
- function makeClosure(arg0, arg1, f) {
603
- const state = { a: arg0, b: arg1, cnt: 1 };
604
- const real = (...args) => {
605
-
606
- // First up with a closure we increment the internal reference
607
- // count. This ensures that the Rust closure environment won't
608
- // be deallocated while we're invoking it.
609
- state.cnt++;
610
- try {
611
- return f(state.a, state.b, ...args);
612
- } finally {
613
- real._wbg_cb_unref();
614
- }
615
- };
616
- real._wbg_cb_unref = () => {
617
- if (--state.cnt === 0) {
618
- wasm.__wbindgen_destroy_closure(state.a, state.b);
619
- state.a = 0;
620
- CLOSURE_DTORS.unregister(state);
621
- }
622
- };
623
- CLOSURE_DTORS.register(real, state, state);
624
- return real;
625
- }
626
-
627
- function passArray32ToWasm0(arg, malloc) {
628
- const ptr = malloc(arg.length * 4, 4) >>> 0;
629
- getUint32ArrayMemory0().set(arg, ptr / 4);
630
- WASM_VECTOR_LEN = arg.length;
631
- return ptr;
632
- }
633
-
634
- function passArray8ToWasm0(arg, malloc) {
635
- const ptr = malloc(arg.length * 1, 1) >>> 0;
636
- getUint8ArrayMemory0().set(arg, ptr / 1);
637
- WASM_VECTOR_LEN = arg.length;
638
- return ptr;
639
- }
640
-
641
- function passStringToWasm0(arg, malloc, realloc) {
642
- if (realloc === undefined) {
643
- const buf = cachedTextEncoder.encode(arg);
644
- const ptr = malloc(buf.length, 1) >>> 0;
645
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
646
- WASM_VECTOR_LEN = buf.length;
647
- return ptr;
648
- }
649
-
650
- let len = arg.length;
651
- let ptr = malloc(len, 1) >>> 0;
652
-
653
- const mem = getUint8ArrayMemory0();
654
-
655
- let offset = 0;
656
-
657
- for (; offset < len; offset++) {
658
- const code = arg.charCodeAt(offset);
659
- if (code > 0x7F) break;
660
- mem[ptr + offset] = code;
661
- }
662
- if (offset !== len) {
663
- if (offset !== 0) {
664
- arg = arg.slice(offset);
665
- }
666
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
667
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
668
- const ret = cachedTextEncoder.encodeInto(arg, view);
669
-
670
- offset += ret.written;
671
- ptr = realloc(ptr, len, offset, 1) >>> 0;
672
- }
673
-
674
- WASM_VECTOR_LEN = offset;
675
- return ptr;
676
- }
677
-
678
- function takeFromExternrefTable0(idx) {
679
- const value = wasm.__wbindgen_externrefs.get(idx);
680
- wasm.__externref_table_dealloc(idx);
681
- return value;
682
- }
683
-
684
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
685
- cachedTextDecoder.decode();
686
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
687
- let numBytesDecoded = 0;
688
- function decodeText(ptr, len) {
689
- numBytesDecoded += len;
690
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
691
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
692
- cachedTextDecoder.decode();
693
- numBytesDecoded = len;
694
- }
695
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
696
- }
697
-
698
- const cachedTextEncoder = new TextEncoder();
699
-
700
- if (!('encodeInto' in cachedTextEncoder)) {
701
- cachedTextEncoder.encodeInto = function (arg, view) {
702
- const buf = cachedTextEncoder.encode(arg);
703
- view.set(buf);
704
- return {
705
- read: arg.length,
706
- written: buf.length
707
- };
708
- };
709
- }
710
-
711
- let WASM_VECTOR_LEN = 0;
712
-
713
- let wasmModule, wasmInstance, wasm;
714
- function __wbg_finalize_init(instance, module) {
715
- wasmInstance = instance;
716
- wasm = instance.exports;
717
- wasmModule = module;
718
- cachedUint32ArrayMemory0 = null;
719
- cachedUint8ArrayMemory0 = null;
720
- wasm.__wbindgen_start();
721
- return wasm;
722
- }
723
-
724
- async function __wbg_load(module, imports) {
725
- if (typeof Response === 'function' && module instanceof Response) {
726
- if (typeof WebAssembly.instantiateStreaming === 'function') {
727
- try {
728
- return await WebAssembly.instantiateStreaming(module, imports);
729
- } catch (e) {
730
- const validResponse = module.ok && expectedResponseType(module.type);
731
-
732
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
733
- 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);
734
-
735
- } else { throw e; }
736
- }
737
- }
738
-
739
- const bytes = await module.arrayBuffer();
740
- return await WebAssembly.instantiate(bytes, imports);
741
- } else {
742
- const instance = await WebAssembly.instantiate(module, imports);
743
-
744
- if (instance instanceof WebAssembly.Instance) {
745
- return { instance, module };
746
- } else {
747
- return instance;
748
- }
749
- }
750
-
751
- function expectedResponseType(type) {
752
- switch (type) {
753
- case 'basic': case 'cors': case 'default': return true;
754
- }
755
- return false;
756
- }
757
- }
758
-
759
- function initSync(module) {
760
- if (wasm !== undefined) return wasm;
761
-
762
-
763
- if (module !== undefined) {
764
- if (Object.getPrototypeOf(module) === Object.prototype) {
765
- ({module} = module)
766
- } else {
767
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
768
- }
769
- }
770
-
771
- const imports = __wbg_get_imports();
772
- if (!(module instanceof WebAssembly.Module)) {
773
- module = new WebAssembly.Module(module);
774
- }
775
- const instance = new WebAssembly.Instance(module, imports);
776
- return __wbg_finalize_init(instance, module);
777
- }
778
-
779
- async function __wbg_init(module_or_path) {
780
- if (wasm !== undefined) return wasm;
781
-
782
-
783
- if (module_or_path !== undefined) {
784
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
785
- ({module_or_path} = module_or_path)
786
- } else {
787
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
788
- }
789
- }
790
-
791
- if (module_or_path === undefined) {
792
- module_or_path = new URL('dig_client_bg.wasm', import.meta.url);
793
- }
794
- const imports = __wbg_get_imports();
795
-
796
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
797
- module_or_path = fetch(module_or_path);
798
- }
799
-
800
- const { instance, module } = await __wbg_load(await module_or_path, imports);
801
-
802
- return __wbg_finalize_init(instance, module);
803
- }
804
-
805
- export { initSync, __wbg_init as default };