@synonymdev/pubky 0.5.4 → 0.6.0-rc.6

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 (6) hide show
  1. package/README.md +265 -154
  2. package/index.cjs +1932 -400
  3. package/index.js +2068 -475
  4. package/package.json +10 -5
  5. package/pubky.d.ts +818 -84
  6. package/pubky_bg.wasm +0 -0
package/index.cjs CHANGED
@@ -9,10 +9,6 @@ imports['__wbindgen_placeholder__'] = module.exports;
9
9
  let wasm;
10
10
  const { TextDecoder, TextEncoder } = require(`util`);
11
11
 
12
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- cachedTextDecoder.decode();
15
-
16
12
  let cachedUint8ArrayMemory0 = null;
17
13
 
18
14
  function getUint8ArrayMemory0() {
@@ -22,38 +18,22 @@ function getUint8ArrayMemory0() {
22
18
  return cachedUint8ArrayMemory0;
23
19
  }
24
20
 
25
- function getStringFromWasm0(ptr, len) {
26
- ptr = ptr >>> 0;
27
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
28
- }
21
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
29
22
 
30
- function addToExternrefTable0(obj) {
31
- const idx = wasm.__externref_table_alloc();
32
- wasm.__wbindgen_export_2.set(idx, obj);
33
- return idx;
34
- }
23
+ cachedTextDecoder.decode();
35
24
 
36
- function handleError(f, args) {
37
- try {
38
- return f.apply(this, args);
39
- } catch (e) {
40
- const idx = addToExternrefTable0(e);
41
- wasm.__wbindgen_exn_store(idx);
42
- }
25
+ function decodeText(ptr, len) {
26
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
43
27
  }
44
28
 
45
- function getArrayU8FromWasm0(ptr, len) {
29
+ function getStringFromWasm0(ptr, len) {
46
30
  ptr = ptr >>> 0;
47
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
48
- }
49
-
50
- function isLikeNone(x) {
51
- return x === undefined || x === null;
31
+ return decodeText(ptr, len);
52
32
  }
53
33
 
54
34
  let WASM_VECTOR_LEN = 0;
55
35
 
56
- let cachedTextEncoder = new TextEncoder('utf-8');
36
+ const cachedTextEncoder = new TextEncoder('utf-8');
57
37
 
58
38
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
59
39
  ? function (arg, view) {
@@ -116,6 +96,30 @@ function getDataViewMemory0() {
116
96
  return cachedDataViewMemory0;
117
97
  }
118
98
 
99
+ function addToExternrefTable0(obj) {
100
+ const idx = wasm.__externref_table_alloc();
101
+ wasm.__wbindgen_export_4.set(idx, obj);
102
+ return idx;
103
+ }
104
+
105
+ function handleError(f, args) {
106
+ try {
107
+ return f.apply(this, args);
108
+ } catch (e) {
109
+ const idx = addToExternrefTable0(e);
110
+ wasm.__wbindgen_exn_store(idx);
111
+ }
112
+ }
113
+
114
+ function isLikeNone(x) {
115
+ return x === undefined || x === null;
116
+ }
117
+
118
+ function getArrayU8FromWasm0(ptr, len) {
119
+ ptr = ptr >>> 0;
120
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
121
+ }
122
+
119
123
  const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
120
124
  ? { register: () => {}, unregister: () => {} }
121
125
  : new FinalizationRegistry(state => {
@@ -212,132 +216,235 @@ function debugString(val) {
212
216
  return className;
213
217
  }
214
218
 
219
+ function takeFromExternrefTable0(idx) {
220
+ const value = wasm.__wbindgen_export_4.get(idx);
221
+ wasm.__externref_table_dealloc(idx);
222
+ return value;
223
+ }
224
+
215
225
  function _assertClass(instance, klass) {
216
226
  if (!(instance instanceof klass)) {
217
227
  throw new Error(`expected instance of ${klass.name}`);
218
228
  }
219
229
  }
220
230
 
221
- function takeFromExternrefTable0(idx) {
222
- const value = wasm.__wbindgen_export_2.get(idx);
223
- wasm.__externref_table_dealloc(idx);
224
- return value;
225
- }
226
- /**
227
- * Create a recovery file of the `keypair`, containing the secret key encrypted
228
- * using the `passphrase`.
229
- * @param {Keypair} keypair
230
- * @param {string} passphrase
231
- * @returns {Uint8Array}
232
- */
233
- module.exports.createRecoveryFile = function(keypair, passphrase) {
234
- _assertClass(keypair, Keypair);
235
- const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
236
- const len0 = WASM_VECTOR_LEN;
237
- const ret = wasm.createRecoveryFile(keypair.__wbg_ptr, ptr0, len0);
238
- return ret;
239
- };
240
-
241
231
  function passArray8ToWasm0(arg, malloc) {
242
232
  const ptr = malloc(arg.length * 1, 1) >>> 0;
243
233
  getUint8ArrayMemory0().set(arg, ptr / 1);
244
234
  WASM_VECTOR_LEN = arg.length;
245
235
  return ptr;
246
236
  }
247
- /**
248
- * Create a recovery file of the `keypair`, containing the secret key encrypted
249
- * using the `passphrase`.
250
- * @param {Uint8Array} recovery_file
251
- * @param {string} passphrase
252
- * @returns {Keypair}
253
- */
254
- module.exports.decryptRecoveryFile = function(recovery_file, passphrase) {
255
- const ptr0 = passArray8ToWasm0(recovery_file, wasm.__wbindgen_malloc);
256
- const len0 = WASM_VECTOR_LEN;
257
- const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
258
- const len1 = WASM_VECTOR_LEN;
259
- const ret = wasm.decryptRecoveryFile(ptr0, len0, ptr1, len1);
260
- if (ret[2]) {
261
- throw takeFromExternrefTable0(ret[1]);
262
- }
263
- return Keypair.__wrap(ret[0]);
264
- };
265
237
 
266
238
  function getArrayJsValueFromWasm0(ptr, len) {
267
239
  ptr = ptr >>> 0;
268
240
  const mem = getDataViewMemory0();
269
241
  const result = [];
270
242
  for (let i = ptr; i < ptr + 4 * len; i += 4) {
271
- result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
243
+ result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
272
244
  }
273
245
  wasm.__externref_drop_slice(ptr, len);
274
246
  return result;
275
247
  }
276
248
  /**
277
- * @param {string} level
249
+ * Set the global logging verbosity for the WASM Pubky SDK. Routes Rust `log` output to the browser console.
250
+ *
251
+ * Accepted values (case-sensitive): "error" | "warn" | "info" | "debug" | "trace".
252
+ * Effects:
253
+ * - Initializes the logger once; subsequent calls may throw if the logger is already set.
254
+ * - Emits a single info log: `Log level set to: <level>`.
255
+ * - Messages at or above `level` are forwarded to the appropriate `console.*` method.
256
+ *
257
+ * @param {Level} level
258
+ * Minimum log level to enable. One of: "error" | "warn" | "info" | "debug" | "trace".
259
+ *
260
+ * @returns {void}
261
+ *
262
+ * @throws {Error}
263
+ * If `level` is invalid ("Invalid log level") or the logger cannot be initialized
264
+ * (e.g., already initialized).
265
+ *
266
+ * Usage:
267
+ * Call once at application startup, before invoking other SDK APIs.
268
+ * @param {Level} level
278
269
  */
279
270
  module.exports.setLogLevel = function(level) {
280
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
281
- const len0 = WASM_VECTOR_LEN;
282
- const ret = wasm.setLogLevel(ptr0, len0);
271
+ const ret = wasm.setLogLevel((__wbindgen_enum_Level.indexOf(level) + 1 || 6) - 1);
283
272
  if (ret[1]) {
284
273
  throw takeFromExternrefTable0(ret[0]);
285
274
  }
286
275
  };
287
276
 
288
- function __wbg_adapter_28(arg0, arg1) {
289
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h05941f9305bd75fb(arg0, arg1);
277
+ /**
278
+ * Resolve a `pubky://` or `pubky<pk>/…` identifier into the homeserver transport URL.
279
+ *
280
+ * @param {string} identifier Either `pubky<pk>/...` (preferred) or `pubky://<pk>/...`.
281
+ * @returns {string} HTTPS URL in the form `https://_pubky.<pk>/...`.
282
+ * @param {string} identifier
283
+ * @returns {string}
284
+ */
285
+ module.exports.resolvePubky = function(identifier) {
286
+ let deferred3_0;
287
+ let deferred3_1;
288
+ try {
289
+ const ptr0 = passStringToWasm0(identifier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
290
+ const len0 = WASM_VECTOR_LEN;
291
+ const ret = wasm.resolvePubky(ptr0, len0);
292
+ var ptr2 = ret[0];
293
+ var len2 = ret[1];
294
+ if (ret[3]) {
295
+ ptr2 = 0; len2 = 0;
296
+ throw takeFromExternrefTable0(ret[2]);
297
+ }
298
+ deferred3_0 = ptr2;
299
+ deferred3_1 = len2;
300
+ return getStringFromWasm0(ptr2, len2);
301
+ } finally {
302
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
303
+ }
304
+ };
305
+
306
+ /**
307
+ * Validate and normalize a capabilities string.
308
+ *
309
+ * - Normalizes action order (`wr` -> `rw`)
310
+ * - Throws `InvalidInput` listing malformed entries.
311
+ *
312
+ * @param {string} input
313
+ * @returns {string} Normalized string (same shape as input).
314
+ * @throws {PubkyError} `{ name: "InvalidInput" }` with a helpful message.
315
+ * The error's `data` field is `{ invalidEntries: string[] }` listing malformed tokens.
316
+ * @param {string} input
317
+ * @returns {string}
318
+ */
319
+ module.exports.validateCapabilities = function(input) {
320
+ let deferred3_0;
321
+ let deferred3_1;
322
+ try {
323
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
324
+ const len0 = WASM_VECTOR_LEN;
325
+ const ret = wasm.validateCapabilities(ptr0, len0);
326
+ var ptr2 = ret[0];
327
+ var len2 = ret[1];
328
+ if (ret[3]) {
329
+ ptr2 = 0; len2 = 0;
330
+ throw takeFromExternrefTable0(ret[2]);
331
+ }
332
+ deferred3_0 = ptr2;
333
+ deferred3_1 = len2;
334
+ return getStringFromWasm0(ptr2, len2);
335
+ } finally {
336
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
337
+ }
338
+ };
339
+
340
+ function __wbg_adapter_54(arg0, arg1) {
341
+ wasm.wasm_bindgen__convert__closures_____invoke__hb6e4fd3a69a27099(arg0, arg1);
290
342
  }
291
343
 
292
- function __wbg_adapter_31(arg0, arg1, arg2) {
293
- wasm.closure147_externref_shim(arg0, arg1, arg2);
344
+ function __wbg_adapter_57(arg0, arg1, arg2) {
345
+ wasm.closure179_externref_shim(arg0, arg1, arg2);
294
346
  }
295
347
 
296
- function __wbg_adapter_74(arg0, arg1, arg2, arg3) {
297
- wasm.closure70_externref_shim(arg0, arg1, arg2, arg3);
348
+ function __wbg_adapter_128(arg0, arg1, arg2, arg3) {
349
+ wasm.closure89_externref_shim(arg0, arg1, arg2, arg3);
298
350
  }
299
351
 
352
+ const __wbindgen_enum_Level = ["error", "warn", "info", "debug", "trace"];
353
+
354
+ const __wbindgen_enum_ReadableStreamType = ["bytes"];
355
+
356
+ const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
357
+
300
358
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
301
359
 
302
360
  const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
303
361
 
304
- const AuthRequestFinalization = (typeof FinalizationRegistry === 'undefined')
362
+ const AuthFlowFinalization = (typeof FinalizationRegistry === 'undefined')
305
363
  ? { register: () => {}, unregister: () => {} }
306
- : new FinalizationRegistry(ptr => wasm.__wbg_authrequest_free(ptr >>> 0, 1));
307
-
308
- class AuthRequest {
364
+ : new FinalizationRegistry(ptr => wasm.__wbg_authflow_free(ptr >>> 0, 1));
365
+ /**
366
+ * Start and control a pubkyauth authorization flow.
367
+ *
368
+ * Typical flow:
369
+ * 1) `AuthFlow.start(...)` or `pubky.startAuthFlow(...)`
370
+ * 2) Show `authorizationUrl()` as QR/deeplink to the user’s signing device
371
+ * 3) `awaitApproval()` to receive a ready `Session`
372
+ */
373
+ class AuthFlow {
309
374
 
310
375
  static __wrap(ptr) {
311
376
  ptr = ptr >>> 0;
312
- const obj = Object.create(AuthRequest.prototype);
377
+ const obj = Object.create(AuthFlow.prototype);
313
378
  obj.__wbg_ptr = ptr;
314
- AuthRequestFinalization.register(obj, obj.__wbg_ptr, obj);
379
+ AuthFlowFinalization.register(obj, obj.__wbg_ptr, obj);
315
380
  return obj;
316
381
  }
317
382
 
318
383
  __destroy_into_raw() {
319
384
  const ptr = this.__wbg_ptr;
320
385
  this.__wbg_ptr = 0;
321
- AuthRequestFinalization.unregister(this);
386
+ AuthFlowFinalization.unregister(this);
322
387
  return ptr;
323
388
  }
324
389
 
325
390
  free() {
326
391
  const ptr = this.__destroy_into_raw();
327
- wasm.__wbg_authrequest_free(ptr, 0);
392
+ wasm.__wbg_authflow_free(ptr, 0);
393
+ }
394
+ /**
395
+ * Start a flow (standalone).
396
+ * Prefer `pubky.startAuthFlow()` to reuse a facade client.
397
+ *
398
+ * @param {string} capabilities
399
+ * Comma-separated capabilities, e.g. `"/pub/app/:rw,/priv/foo.txt:r"`.
400
+ * Each entry must be `"<scope>:<actions>"`, where:
401
+ * - `scope` starts with `/` (e.g. `/pub/example.app/`)
402
+ * - `actions` is any combo of `r` and/or `w` (order is normalized; `wr` -> `rw`)
403
+ * Empty string is allowed (no scopes).
404
+ *
405
+ * @param {string} [relay]
406
+ * Optional HTTP relay base, e.g. `"https://demo.httprelay.io/link/"`.
407
+ * Defaults to the default Synonym-hosted relay when omitted.
408
+ *
409
+ * @returns {AuthFlow}
410
+ * A running auth flow. Call `authorizationUrl()` to show the deep link,
411
+ * then `awaitApproval()` to receive a `Session`.
412
+ * @throws {PubkyError}
413
+ * - `{ name: "InvalidInput", message: string }` if any capability entry is invalid
414
+ * or for an invalid relay URL.
415
+ * @example
416
+ * const flow = AuthFlow.start("/pub/my.app/:rw,/pub/pubky.app/:w");
417
+ * renderQRCode(flow.authorizationUrl());
418
+ * const session = await flow.awaitApproval();
419
+ * @param {Capabilities} capabilities
420
+ * @param {string | null} [relay]
421
+ * @returns {AuthFlow}
422
+ */
423
+ static start(capabilities, relay) {
424
+ const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
425
+ const len0 = WASM_VECTOR_LEN;
426
+ var ptr1 = isLikeNone(relay) ? 0 : passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
427
+ var len1 = WASM_VECTOR_LEN;
428
+ const ret = wasm.authflow_start(ptr0, len0, ptr1, len1);
429
+ if (ret[2]) {
430
+ throw takeFromExternrefTable0(ret[1]);
431
+ }
432
+ return AuthFlow.__wrap(ret[0]);
328
433
  }
329
434
  /**
330
- * Returns the Pubky Auth url, which you should show to the user
331
- * to request an authentication or authorization token.
435
+ * Return the authorization deep link (URL) to show as QR or open on the signer device.
436
+ *
437
+ * @returns {string} A `pubkyauth://…` or `https://…` URL with channel info.
332
438
  *
333
- * Wait for this token using `this.response()`.
439
+ * @example
440
+ * renderQr(flow.authorizationUrl());
334
441
  * @returns {string}
335
442
  */
336
- url() {
443
+ get authorizationUrl() {
337
444
  let deferred1_0;
338
445
  let deferred1_1;
339
446
  try {
340
- const ret = wasm.authrequest_url(this.__wbg_ptr);
447
+ const ret = wasm.authflow_authorizationUrl(this.__wbg_ptr);
341
448
  deferred1_0 = ret[0];
342
449
  deferred1_1 = ret[1];
343
450
  return getStringFromWasm0(ret[0], ret[1]);
@@ -346,194 +453,234 @@ class AuthRequest {
346
453
  }
347
454
  }
348
455
  /**
349
- * Wait for the user to send an authentication or authorization proof.
456
+ * Block until the user approves on their signer device; returns a `Session`.
457
+ *
458
+ * @returns {Promise<Session>}
459
+ * Resolves when approved; rejects on timeout/cancel/network errors.
460
+ *
461
+ * @throws {PubkyError}
462
+ * - `RequestError` if relay/network fails
463
+ * - `AuthenticationError` if approval is denied/invalid
464
+ * @returns {Promise<Session>}
465
+ */
466
+ awaitApproval() {
467
+ const ptr = this.__destroy_into_raw();
468
+ const ret = wasm.authflow_awaitApproval(ptr);
469
+ return ret;
470
+ }
471
+ /**
472
+ * Block until the user approves on their signer device; returns an `AuthToken`.
473
+ *
474
+ * @returns {Promise<AuthToken>}
475
+ * Resolves when approved; rejects on timeout/cancel/network errors.
350
476
  *
351
- * If successful, you should expect an instance of [PublicKey]
477
+ * @throws {PubkyError}
478
+ * - `RequestError` if relay/network fails
479
+ * @returns {Promise<AuthToken>}
480
+ */
481
+ awaitToken() {
482
+ const ptr = this.__destroy_into_raw();
483
+ const ret = wasm.authflow_awaitToken(ptr);
484
+ return ret;
485
+ }
486
+ /**
487
+ * Non-blocking single poll step (advanced UIs).
352
488
  *
353
- * Otherwise it will throw an error.
354
- * @returns {Promise<PublicKey>}
489
+ * @returns {Promise<Session|undefined>} A session if the approval arrived, otherwise `undefined`.
490
+ * @returns {Promise<Session | undefined>}
355
491
  */
356
- response() {
357
- const ret = wasm.authrequest_response(this.__wbg_ptr);
492
+ tryPollOnce() {
493
+ const ret = wasm.authflow_tryPollOnce(this.__wbg_ptr);
358
494
  return ret;
359
495
  }
360
496
  }
361
- module.exports.AuthRequest = AuthRequest;
497
+ module.exports.AuthFlow = AuthFlow;
362
498
 
363
- const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
499
+ const AuthTokenFinalization = (typeof FinalizationRegistry === 'undefined')
364
500
  ? { register: () => {}, unregister: () => {} }
365
- : new FinalizationRegistry(ptr => wasm.__wbg_client_free(ptr >>> 0, 1));
366
-
367
- class Client {
501
+ : new FinalizationRegistry(ptr => wasm.__wbg_authtoken_free(ptr >>> 0, 1));
502
+ /**
503
+ * AuthToken: signed, time-bound proof of key ownership.
504
+ *
505
+ * Returned by [`AuthFlow.awaitToken()`] on the 3rd-party app side when doing **authentication-only**
506
+ * flows (no homeserver session). You can inspect who authenticated and which capabilities were
507
+ * requested, or serialize the token and send it to a backend to verify.
508
+ *
509
+ * ### Typical usage
510
+ * ```js
511
+ * // Start an auth-only flow (no capabilities)
512
+ * const flow = pubky.startAuthFlow("", relay);
513
+ *
514
+ * // Wait for the signer to approve; returns an AuthToken
515
+ * const token = await flow.awaitToken();
516
+ *
517
+ * // Identify the user
518
+ * console.log(token.publicKey().z32());
519
+ *
520
+ * // Optionally forward to a server for verification:
521
+ * await fetch("/api/verify", { method: "POST", body: token.toBytes() });
522
+ * ```
523
+ *
524
+ * ### Binary format
525
+ * `AuthToken` serializes to a canonical binary (postcard) form; use [`AuthToken.toBytes()`] to get a
526
+ * `Uint8Array`, and [`AuthToken.verify()`] to parse + verify on the server.
527
+ */
528
+ class AuthToken {
368
529
 
369
530
  static __wrap(ptr) {
370
531
  ptr = ptr >>> 0;
371
- const obj = Object.create(Client.prototype);
532
+ const obj = Object.create(AuthToken.prototype);
372
533
  obj.__wbg_ptr = ptr;
373
- ClientFinalization.register(obj, obj.__wbg_ptr, obj);
534
+ AuthTokenFinalization.register(obj, obj.__wbg_ptr, obj);
374
535
  return obj;
375
536
  }
376
537
 
377
538
  __destroy_into_raw() {
378
539
  const ptr = this.__wbg_ptr;
379
540
  this.__wbg_ptr = 0;
380
- ClientFinalization.unregister(this);
541
+ AuthTokenFinalization.unregister(this);
381
542
  return ptr;
382
543
  }
383
544
 
384
545
  free() {
385
546
  const ptr = this.__destroy_into_raw();
386
- wasm.__wbg_client_free(ptr, 0);
547
+ wasm.__wbg_authtoken_free(ptr, 0);
387
548
  }
388
549
  /**
389
- * Signup to a homeserver and update Pkarr accordingly.
550
+ * Parse and verify an `AuthToken` from its canonical bytes.
390
551
  *
391
- * The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
392
- * for example "pubky.o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy"
393
- * @param {Keypair} keypair
394
- * @param {PublicKey} homeserver
395
- * @param {string | null} [signup_token]
396
- * @returns {Promise<Session>}
397
- */
398
- signup(keypair, homeserver, signup_token) {
399
- _assertClass(keypair, Keypair);
400
- _assertClass(homeserver, PublicKey);
401
- var ptr0 = isLikeNone(signup_token) ? 0 : passStringToWasm0(signup_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
402
- var len0 = WASM_VECTOR_LEN;
403
- const ret = wasm.client_signup(this.__wbg_ptr, keypair.__wbg_ptr, homeserver.__wbg_ptr, ptr0, len0);
404
- return ret;
405
- }
406
- /**
407
- * Check the current session for a given Pubky in its homeserver.
552
+ * - Verifies version, timestamp freshness window, and signature.
553
+ * - Throws on invalid/expired/unknown version.
408
554
  *
409
- * Returns [Session] or `None` (if received `404 NOT_FOUND`),
410
- * or throws the received error if the response has any other `>=400` status code.
411
- * @param {PublicKey} pubky
412
- * @returns {Promise<Session | undefined>}
413
- */
414
- session(pubky) {
415
- _assertClass(pubky, PublicKey);
416
- const ret = wasm.client_session(this.__wbg_ptr, pubky.__wbg_ptr);
417
- return ret;
418
- }
419
- /**
420
- * Signout from a homeserver.
421
- * @param {PublicKey} pubky
422
- * @returns {Promise<void>}
423
- */
424
- signout(pubky) {
425
- _assertClass(pubky, PublicKey);
426
- const ret = wasm.client_signout(this.__wbg_ptr, pubky.__wbg_ptr);
427
- return ret;
428
- }
429
- /**
430
- * Signin to a homeserver using the root Keypair.
431
- * @param {Keypair} keypair
432
- * @returns {Promise<void>}
555
+ * Use this on your server after receiving `Uint8Array` from the client.
556
+ *
557
+ * ```js
558
+ * import { AuthToken } from "@synonymdev/pubky";
559
+ *
560
+ * export async function POST(req) {
561
+ * const bytes = new Uint8Array(await req.arrayBuffer());
562
+ * const token = AuthToken.verify(bytes); // throws on failure
563
+ * return new Response(token.publicKey().z32(), { status: 200 });
564
+ * }
565
+ * ```
566
+ * @param {Uint8Array} bytes
567
+ * @returns {AuthToken}
433
568
  */
434
- signin(keypair) {
435
- _assertClass(keypair, Keypair);
436
- const ret = wasm.client_signin(this.__wbg_ptr, keypair.__wbg_ptr);
437
- return ret;
569
+ static verify(bytes) {
570
+ const ret = wasm.authtoken_verify(bytes);
571
+ if (ret[2]) {
572
+ throw takeFromExternrefTable0(ret[1]);
573
+ }
574
+ return AuthToken.__wrap(ret[0]);
438
575
  }
439
576
  /**
440
- * Return `pubkyauth://` url and wait for the incoming [AuthToken]
441
- * verifying that AuthToken, and if capabilities were requested, signing in to
442
- * the Pubky's homeserver and returning the [Session] information.
577
+ * Deserialize an `AuthToken` **without** verification.
443
578
  *
444
- * Returns a [AuthRequest]
445
- * @param {string} relay
446
- * @param {string} capabilities
447
- * @returns {AuthRequest}
579
+ * Most apps should call [`AuthToken.verify()`]. This is provided for tooling or diagnostics
580
+ * where you want to inspect the structure first.
581
+ *
582
+ * Throws if the bytes cannot be parsed as a valid serialized token.
583
+ * @param {Uint8Array} bytes
584
+ * @returns {AuthToken}
448
585
  */
449
- authRequest(relay, capabilities) {
450
- const ptr0 = passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
451
- const len0 = WASM_VECTOR_LEN;
452
- const ptr1 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
453
- const len1 = WASM_VECTOR_LEN;
454
- const ret = wasm.client_authRequest(this.__wbg_ptr, ptr0, len0, ptr1, len1);
586
+ static fromBytes(bytes) {
587
+ const ret = wasm.authtoken_fromBytes(bytes);
455
588
  if (ret[2]) {
456
589
  throw takeFromExternrefTable0(ret[1]);
457
590
  }
458
- return AuthRequest.__wrap(ret[0]);
591
+ return AuthToken.__wrap(ret[0]);
459
592
  }
460
593
  /**
461
- * Sign an [pubky_common::auth::AuthToken], encrypt it and send it to the
462
- * source of the pubkyauth request url.
463
- * @param {Keypair} keypair
464
- * @param {string} pubkyauth_url
465
- * @returns {Promise<void>}
594
+ * Returns the **public key** that authenticated with this token.
595
+ *
596
+ * Use `.z32()` on the returned `PublicKey` to get the string form.
597
+ *
598
+ * @example
599
+ * const who = sessionInfo.publicKey.z32();
600
+ * @returns {PublicKey}
466
601
  */
467
- sendAuthToken(keypair, pubkyauth_url) {
468
- _assertClass(keypair, Keypair);
469
- const ptr0 = passStringToWasm0(pubkyauth_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
470
- const len0 = WASM_VECTOR_LEN;
471
- const ret = wasm.client_sendAuthToken(this.__wbg_ptr, keypair.__wbg_ptr, ptr0, len0);
472
- return ret;
602
+ get publicKey() {
603
+ const ret = wasm.authtoken_publicKey(this.__wbg_ptr);
604
+ return PublicKey.__wrap(ret);
473
605
  }
474
606
  /**
475
- * Get the homeserver id for a given Pubky public key.
476
- * Looks up the pkarr packet for the given public key and returns the content of the first `_pubky` SVCB record.
477
- * Throws an error if no homeserver is found.
478
- * @param {PublicKey} public_key
479
- * @returns {Promise<PublicKey>}
607
+ * Returns the **capabilities** requested by the flow at the time this token was signed.
608
+ *
609
+ * Most auth-only flows pass an empty string to `startAuthFlow("", relay)`, so this will
610
+ * commonly be an empty array.
611
+ *
612
+ * Returns: `string[]`, where each item is the canonical entry `"<scope>:<actions>"`.
613
+ *
614
+ * Example entry: `"/pub/my.app/:rw"`
615
+ * @returns {string[]}
480
616
  */
481
- getHomeserver(public_key) {
482
- _assertClass(public_key, PublicKey);
483
- const ret = wasm.client_getHomeserver(this.__wbg_ptr, public_key.__wbg_ptr);
484
- return ret;
617
+ get capabilities() {
618
+ const ret = wasm.authtoken_capabilities(this.__wbg_ptr);
619
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
620
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
621
+ return v1;
485
622
  }
486
623
  /**
487
- * Republish the user's PKarr record pointing to their homeserver.
624
+ * Serialize the token to a `Uint8Array` in its **canonical** (postcard) binary format.
488
625
  *
489
- * This method will republish the record if no record exists or if the existing record
490
- * is older than 6 hours.
626
+ * Use this to send the token to a backend for verification.
491
627
  *
492
- * The method is intended for clients and key managers (e.g., pubky-ring) to
493
- * keep the records of active users fresh and available in the DHT and relays.
494
- * It is intended to be used only after failed signin due to homeserver resolution
495
- * failure. This method is lighter than performing a re-signup into the last known
496
- * homeserver, but does not return a session token, so a signin must be done after
497
- * republishing. On a failed signin due to homeserver resolution failure, a key
498
- * manager should always attempt to republish the last known homeserver.
499
- * @param {Keypair} keypair
500
- * @param {PublicKey} host
501
- * @returns {Promise<void>}
628
+ * ```js
629
+ * const bytes = token.toBytes();
630
+ * await fetch("/api/verify", { method: "POST", body: bytes });
631
+ * ```
632
+ * @returns {Uint8Array}
502
633
  */
503
- republishHomeserver(keypair, host) {
504
- _assertClass(keypair, Keypair);
505
- _assertClass(host, PublicKey);
506
- const ret = wasm.client_republishHomeserver(this.__wbg_ptr, keypair.__wbg_ptr, host.__wbg_ptr);
634
+ toBytes() {
635
+ const ret = wasm.authtoken_toBytes(this.__wbg_ptr);
507
636
  return ret;
508
637
  }
638
+ }
639
+ module.exports.AuthToken = AuthToken;
640
+
641
+ const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
642
+ ? { register: () => {}, unregister: () => {} }
643
+ : new FinalizationRegistry(ptr => wasm.__wbg_client_free(ptr >>> 0, 1));
644
+ /**
645
+ * Low-level HTTP bridge used by the Pubky facade and actors.
646
+ *
647
+ * - Supports `http(s)://` URLs targeting Pubky or ICANN hosts.
648
+ * - In browsers/undici, passes `credentials: "include"` to send cookies.
649
+ */
650
+ class Client {
651
+
652
+ static __wrap(ptr) {
653
+ ptr = ptr >>> 0;
654
+ const obj = Object.create(Client.prototype);
655
+ obj.__wbg_ptr = ptr;
656
+ ClientFinalization.register(obj, obj.__wbg_ptr, obj);
657
+ return obj;
658
+ }
659
+
660
+ __destroy_into_raw() {
661
+ const ptr = this.__wbg_ptr;
662
+ this.__wbg_ptr = 0;
663
+ ClientFinalization.unregister(this);
664
+ return ptr;
665
+ }
666
+
667
+ free() {
668
+ const ptr = this.__destroy_into_raw();
669
+ wasm.__wbg_client_free(ptr, 0);
670
+ }
509
671
  /**
510
- * Returns a list of Pubky urls (as strings).
672
+ * Perform a raw fetch. Works with `http(s)://` URLs.
511
673
  *
512
- * - `url`: The Pubky url (string) to the directory you want to list its content.
513
- * - `cursor`: Either a full `pubky://` Url (from previous list response),
514
- * or a path (to a file or directory) relative to the `url`
515
- * - `reverse`: List in reverse order
516
- * - `limit` Limit the number of urls in the response
517
- * - `shallow`: List directories and files, instead of flat list of files.
518
674
  * @param {string} url
519
- * @param {string | null} [cursor]
520
- * @param {boolean | null} [reverse]
521
- * @param {number | null} [limit]
522
- * @param {boolean | null} [shallow]
523
- * @returns {Promise<Array<any>>}
524
- */
525
- list(url, cursor, reverse, limit, shallow) {
526
- const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
527
- const len0 = WASM_VECTOR_LEN;
528
- var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
529
- var len1 = WASM_VECTOR_LEN;
530
- const ret = wasm.client_list(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(reverse) ? 0xFFFFFF : reverse ? 1 : 0, isLikeNone(limit) ? 0xFFFFFF : limit, isLikeNone(shallow) ? 0xFFFFFF : shallow ? 1 : 0);
531
- return ret;
532
- }
533
- /**
675
+ * @param {RequestInit} init Standard fetch options; `credentials: "include"` recommended for session I/O.
676
+ * @returns {Promise<Response>}
677
+ *
678
+ * @example
679
+ * const client = pubky.client;
680
+ * const res = await client.fetch(`https://_pubky.${user}/pub/app/file.txt`, { method: "PUT", body: "hi", credentials: "include" });
534
681
  * @param {string} url
535
- * @param {any | null} [init]
536
- * @returns {Promise<Promise<any>>}
682
+ * @param {RequestInit | null} [init]
683
+ * @returns {Promise<Response>}
537
684
  */
538
685
  fetch(url, init) {
539
686
  const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -542,7 +689,24 @@ class Client {
542
689
  return ret;
543
690
  }
544
691
  /**
545
- * Create a new Pubky Client with an optional configuration.
692
+ * Create a Pubky HTTP client.
693
+ *
694
+ * @param {PubkyClientConfig} [config]
695
+ * Optional transport overrides:
696
+ * `{ pkarr?: { relays?: string[], request_timeout?: number } }`.
697
+ *
698
+ * @returns {Client}
699
+ * A configured low-level client. Prefer `new Pubky().client` unless you
700
+ * need custom relays/timeouts.
701
+ *
702
+ * @throws {InvalidInput}
703
+ * If any PKARR relay URL is invalid.
704
+ *
705
+ * @example
706
+ * const client = new Client({
707
+ * pkarr: { relays: ["https://relay1/","https://relay2/"], request_timeout: 8000 }
708
+ * });
709
+ * const pubky = Pubky.withClient(client);
546
710
  * @param {PubkyClientConfig | null} [config_opt]
547
711
  */
548
712
  constructor(config_opt) {
@@ -555,10 +719,22 @@ class Client {
555
719
  return this;
556
720
  }
557
721
  /**
558
- * Create a client with with configurations appropriate for local testing:
559
- * - set Pkarr relays to `http://<host>:15411` (defaults to `localhost`).
560
- * - transform `pubky://<pkarr public key>` to `http://<host>` instead of `https:`
561
- * and read the homeserver HTTP port from the PKarr record.
722
+ * Create a client wired for **local testnet**.
723
+ *
724
+ * Configures PKARR relays for the testnet and remembers the hostname for WASM `_pubky` mapping.
725
+ *
726
+ * @param {string} [host="localhost"]
727
+ * Testnet hostname or IP.
728
+ *
729
+ * @returns {Client}
730
+ * A client ready to talk to your local testnet.
731
+ *
732
+ * @example
733
+ * const client = Client.testnet(); // localhost
734
+ * const pubky = Pubky.withClient(client);
735
+ *
736
+ * @example
737
+ * const client = Client.testnet("docker0"); // custom host
562
738
  * @param {string | null} [host]
563
739
  * @returns {Client}
564
740
  */
@@ -566,18 +742,158 @@ class Client {
566
742
  var ptr0 = isLikeNone(host) ? 0 : passStringToWasm0(host, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
567
743
  var len0 = WASM_VECTOR_LEN;
568
744
  const ret = wasm.client_testnet(ptr0, len0);
569
- return Client.__wrap(ret);
745
+ if (ret[2]) {
746
+ throw takeFromExternrefTable0(ret[1]);
747
+ }
748
+ return Client.__wrap(ret[0]);
570
749
  }
571
750
  }
572
751
  module.exports.Client = Client;
573
752
 
574
- const KeypairFinalization = (typeof FinalizationRegistry === 'undefined')
753
+ const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined')
575
754
  ? { register: () => {}, unregister: () => {} }
576
- : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0, 1));
755
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1));
577
756
 
578
- class Keypair {
757
+ class IntoUnderlyingByteSource {
579
758
 
580
- static __wrap(ptr) {
759
+ __destroy_into_raw() {
760
+ const ptr = this.__wbg_ptr;
761
+ this.__wbg_ptr = 0;
762
+ IntoUnderlyingByteSourceFinalization.unregister(this);
763
+ return ptr;
764
+ }
765
+
766
+ free() {
767
+ const ptr = this.__destroy_into_raw();
768
+ wasm.__wbg_intounderlyingbytesource_free(ptr, 0);
769
+ }
770
+ /**
771
+ * @returns {ReadableStreamType}
772
+ */
773
+ get type() {
774
+ const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr);
775
+ return __wbindgen_enum_ReadableStreamType[ret];
776
+ }
777
+ /**
778
+ * @returns {number}
779
+ */
780
+ get autoAllocateChunkSize() {
781
+ const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr);
782
+ return ret >>> 0;
783
+ }
784
+ /**
785
+ * @param {ReadableByteStreamController} controller
786
+ */
787
+ start(controller) {
788
+ wasm.intounderlyingbytesource_start(this.__wbg_ptr, controller);
789
+ }
790
+ /**
791
+ * @param {ReadableByteStreamController} controller
792
+ * @returns {Promise<any>}
793
+ */
794
+ pull(controller) {
795
+ const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, controller);
796
+ return ret;
797
+ }
798
+ cancel() {
799
+ const ptr = this.__destroy_into_raw();
800
+ wasm.intounderlyingbytesource_cancel(ptr);
801
+ }
802
+ }
803
+ module.exports.IntoUnderlyingByteSource = IntoUnderlyingByteSource;
804
+
805
+ const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined')
806
+ ? { register: () => {}, unregister: () => {} }
807
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1));
808
+
809
+ class IntoUnderlyingSink {
810
+
811
+ __destroy_into_raw() {
812
+ const ptr = this.__wbg_ptr;
813
+ this.__wbg_ptr = 0;
814
+ IntoUnderlyingSinkFinalization.unregister(this);
815
+ return ptr;
816
+ }
817
+
818
+ free() {
819
+ const ptr = this.__destroy_into_raw();
820
+ wasm.__wbg_intounderlyingsink_free(ptr, 0);
821
+ }
822
+ /**
823
+ * @param {any} chunk
824
+ * @returns {Promise<any>}
825
+ */
826
+ write(chunk) {
827
+ const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk);
828
+ return ret;
829
+ }
830
+ /**
831
+ * @returns {Promise<any>}
832
+ */
833
+ close() {
834
+ const ptr = this.__destroy_into_raw();
835
+ const ret = wasm.intounderlyingsink_close(ptr);
836
+ return ret;
837
+ }
838
+ /**
839
+ * @param {any} reason
840
+ * @returns {Promise<any>}
841
+ */
842
+ abort(reason) {
843
+ const ptr = this.__destroy_into_raw();
844
+ const ret = wasm.intounderlyingsink_abort(ptr, reason);
845
+ return ret;
846
+ }
847
+ }
848
+ module.exports.IntoUnderlyingSink = IntoUnderlyingSink;
849
+
850
+ const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
851
+ ? { register: () => {}, unregister: () => {} }
852
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
853
+
854
+ class IntoUnderlyingSource {
855
+
856
+ static __wrap(ptr) {
857
+ ptr = ptr >>> 0;
858
+ const obj = Object.create(IntoUnderlyingSource.prototype);
859
+ obj.__wbg_ptr = ptr;
860
+ IntoUnderlyingSourceFinalization.register(obj, obj.__wbg_ptr, obj);
861
+ return obj;
862
+ }
863
+
864
+ __destroy_into_raw() {
865
+ const ptr = this.__wbg_ptr;
866
+ this.__wbg_ptr = 0;
867
+ IntoUnderlyingSourceFinalization.unregister(this);
868
+ return ptr;
869
+ }
870
+
871
+ free() {
872
+ const ptr = this.__destroy_into_raw();
873
+ wasm.__wbg_intounderlyingsource_free(ptr, 0);
874
+ }
875
+ /**
876
+ * @param {ReadableStreamDefaultController} controller
877
+ * @returns {Promise<any>}
878
+ */
879
+ pull(controller) {
880
+ const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller);
881
+ return ret;
882
+ }
883
+ cancel() {
884
+ const ptr = this.__destroy_into_raw();
885
+ wasm.intounderlyingsource_cancel(ptr);
886
+ }
887
+ }
888
+ module.exports.IntoUnderlyingSource = IntoUnderlyingSource;
889
+
890
+ const KeypairFinalization = (typeof FinalizationRegistry === 'undefined')
891
+ ? { register: () => {}, unregister: () => {} }
892
+ : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0, 1));
893
+
894
+ class Keypair {
895
+
896
+ static __wrap(ptr) {
581
897
  ptr = ptr >>> 0;
582
898
  const obj = Object.create(Keypair.prototype);
583
899
  obj.__wbg_ptr = ptr;
@@ -624,244 +940,1271 @@ class Keypair {
624
940
  */
625
941
  secretKey() {
626
942
  const ret = wasm.keypair_secretKey(this.__wbg_ptr);
627
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
628
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
629
- return v1;
943
+ return ret;
630
944
  }
631
945
  /**
632
946
  * Returns the [PublicKey] of this keypair.
947
+ *
948
+ * Use `.z32()` on the returned `PublicKey` to get the string form.
949
+ *
950
+ * @example
951
+ * const who = keypair.publicKey.z32();
633
952
  * @returns {PublicKey}
634
953
  */
635
- publicKey() {
954
+ get publicKey() {
636
955
  const ret = wasm.keypair_publicKey(this.__wbg_ptr);
637
956
  return PublicKey.__wrap(ret);
638
957
  }
958
+ /**
959
+ * Create a recovery file for this keypair (encrypted with the given passphrase).
960
+ * @param {string} passphrase
961
+ * @returns {Uint8Array}
962
+ */
963
+ createRecoveryFile(passphrase) {
964
+ const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
965
+ const len0 = WASM_VECTOR_LEN;
966
+ const ret = wasm.keypair_createRecoveryFile(this.__wbg_ptr, ptr0, len0);
967
+ return ret;
968
+ }
969
+ /**
970
+ * Decrypt a recovery file and return a Keypair (decrypted with the given passphrase).
971
+ * @param {Uint8Array} recovery_file
972
+ * @param {string} passphrase
973
+ * @returns {Keypair}
974
+ */
975
+ static fromRecoveryFile(recovery_file, passphrase) {
976
+ const ptr0 = passArray8ToWasm0(recovery_file, wasm.__wbindgen_malloc);
977
+ const len0 = WASM_VECTOR_LEN;
978
+ const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
979
+ const len1 = WASM_VECTOR_LEN;
980
+ const ret = wasm.keypair_fromRecoveryFile(ptr0, len0, ptr1, len1);
981
+ if (ret[2]) {
982
+ throw takeFromExternrefTable0(ret[1]);
983
+ }
984
+ return Keypair.__wrap(ret[0]);
985
+ }
639
986
  }
640
987
  module.exports.Keypair = Keypair;
641
988
 
642
- const PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
989
+ const PkdnsFinalization = (typeof FinalizationRegistry === 'undefined')
643
990
  ? { register: () => {}, unregister: () => {} }
644
- : new FinalizationRegistry(ptr => wasm.__wbg_publickey_free(ptr >>> 0, 1));
645
-
646
- class PublicKey {
991
+ : new FinalizationRegistry(ptr => wasm.__wbg_pkdns_free(ptr >>> 0, 1));
992
+ /**
993
+ * Resolve/publish `_pubky` PKDNS records (homeserver pointers).
994
+ */
995
+ class Pkdns {
647
996
 
648
997
  static __wrap(ptr) {
649
998
  ptr = ptr >>> 0;
650
- const obj = Object.create(PublicKey.prototype);
999
+ const obj = Object.create(Pkdns.prototype);
651
1000
  obj.__wbg_ptr = ptr;
652
- PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1001
+ PkdnsFinalization.register(obj, obj.__wbg_ptr, obj);
653
1002
  return obj;
654
1003
  }
655
1004
 
656
1005
  __destroy_into_raw() {
657
1006
  const ptr = this.__wbg_ptr;
658
1007
  this.__wbg_ptr = 0;
659
- PublicKeyFinalization.unregister(this);
1008
+ PkdnsFinalization.unregister(this);
660
1009
  return ptr;
661
1010
  }
662
1011
 
663
1012
  free() {
664
1013
  const ptr = this.__destroy_into_raw();
665
- wasm.__wbg_publickey_free(ptr, 0);
1014
+ wasm.__wbg_pkdns_free(ptr, 0);
666
1015
  }
667
1016
  /**
668
- * Convert the PublicKey to Uint8Array
669
- * @deprecated Use `toUint8Array` instead
670
- * @returns {Uint8Array}
1017
+ * Read-only PKDNS actor (no keypair; resolve only).
671
1018
  */
672
- to_uint8array() {
673
- const ret = wasm.publickey_to_uint8array(this.__wbg_ptr);
674
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
675
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
676
- return v1;
1019
+ constructor() {
1020
+ const ret = wasm.pkdns_new();
1021
+ if (ret[2]) {
1022
+ throw takeFromExternrefTable0(ret[1]);
1023
+ }
1024
+ this.__wbg_ptr = ret[0] >>> 0;
1025
+ PkdnsFinalization.register(this, this.__wbg_ptr, this);
1026
+ return this;
677
1027
  }
678
1028
  /**
679
- * Convert the PublicKey to Uint8Array
680
- * @returns {Uint8Array}
1029
+ * PKDNS actor with publishing enabled (requires a keypair).
1030
+ * @param {Keypair} keypair
1031
+ * @returns {Pkdns}
681
1032
  */
682
- toUint8Array() {
683
- const ret = wasm.publickey_toUint8Array(this.__wbg_ptr);
684
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
685
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
686
- return v1;
1033
+ static fromKeypair(keypair) {
1034
+ _assertClass(keypair, Keypair);
1035
+ const ret = wasm.pkdns_fromKeypair(keypair.__wbg_ptr);
1036
+ if (ret[2]) {
1037
+ throw takeFromExternrefTable0(ret[1]);
1038
+ }
1039
+ return Pkdns.__wrap(ret[0]);
687
1040
  }
688
1041
  /**
689
- * Returns the z-base32 encoding of this public key
690
- * @returns {string}
1042
+ * Resolve the homeserver for a given public key (read-only).
1043
+ *
1044
+ * @param {PublicKey} user
1045
+ * @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined` if not found.
1046
+ * @param {PublicKey} pubky
1047
+ * @returns {Promise<PublicKey | undefined>}
691
1048
  */
692
- z32() {
693
- let deferred1_0;
694
- let deferred1_1;
695
- try {
696
- const ret = wasm.publickey_z32(this.__wbg_ptr);
697
- deferred1_0 = ret[0];
698
- deferred1_1 = ret[1];
699
- return getStringFromWasm0(ret[0], ret[1]);
700
- } finally {
701
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1049
+ getHomeserverOf(pubky) {
1050
+ _assertClass(pubky, PublicKey);
1051
+ const ret = wasm.pkdns_getHomeserverOf(this.__wbg_ptr, pubky.__wbg_ptr);
1052
+ return ret;
1053
+ }
1054
+ /**
1055
+ * Resolve the homeserver for **this** user (requires keypair).
1056
+ *
1057
+ * @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined` if not found.
1058
+ * @returns {Promise<PublicKey | undefined>}
1059
+ */
1060
+ getHomeserver() {
1061
+ const ret = wasm.pkdns_getHomeserver(this.__wbg_ptr);
1062
+ return ret;
1063
+ }
1064
+ /**
1065
+ * Force publish homeserver immediately (even if fresh).
1066
+ *
1067
+ * Requires keypair or to be signer bound.
1068
+ *
1069
+ * @param {PublicKey=} overrideHost Optional new homeserver to publish (migration).
1070
+ * @returns {Promise<void>}
1071
+ * @param {PublicKey | null} [host_override]
1072
+ * @returns {Promise<void>}
1073
+ */
1074
+ publishHomeserverForce(host_override) {
1075
+ let ptr0 = 0;
1076
+ if (!isLikeNone(host_override)) {
1077
+ _assertClass(host_override, PublicKey);
1078
+ ptr0 = host_override.__destroy_into_raw();
702
1079
  }
1080
+ const ret = wasm.pkdns_publishHomeserverForce(this.__wbg_ptr, ptr0);
1081
+ return ret;
703
1082
  }
704
1083
  /**
705
- * @throws
706
- * @param {string} value
707
- * @returns {PublicKey}
1084
+ * Republish homeserver if record is missing/stale.
1085
+ *
1086
+ * Requires keypair or to be signer bound.
1087
+ *
1088
+ * @param {PublicKey=} overrideHost Optional new homeserver to publish (migration).
1089
+ * @returns {Promise<void>}
1090
+ * @param {PublicKey | null} [host_override]
1091
+ * @returns {Promise<void>}
708
1092
  */
709
- static from(value) {
710
- const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
711
- const len0 = WASM_VECTOR_LEN;
712
- const ret = wasm.publickey_from(ptr0, len0);
713
- if (ret[2]) {
714
- throw takeFromExternrefTable0(ret[1]);
1093
+ publishHomeserverIfStale(host_override) {
1094
+ let ptr0 = 0;
1095
+ if (!isLikeNone(host_override)) {
1096
+ _assertClass(host_override, PublicKey);
1097
+ ptr0 = host_override.__destroy_into_raw();
715
1098
  }
716
- return PublicKey.__wrap(ret[0]);
1099
+ const ret = wasm.pkdns_publishHomeserverIfStale(this.__wbg_ptr, ptr0);
1100
+ return ret;
717
1101
  }
718
1102
  }
719
- module.exports.PublicKey = PublicKey;
1103
+ module.exports.Pkdns = Pkdns;
720
1104
 
721
- const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
1105
+ const PubkyFinalization = (typeof FinalizationRegistry === 'undefined')
722
1106
  ? { register: () => {}, unregister: () => {} }
723
- : new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr >>> 0, 1));
724
-
725
- class Session {
1107
+ : new FinalizationRegistry(ptr => wasm.__wbg_pubky_free(ptr >>> 0, 1));
1108
+ /**
1109
+ * High-level entrypoint to the Pubky SDK.
1110
+ */
1111
+ class Pubky {
726
1112
 
727
1113
  static __wrap(ptr) {
728
1114
  ptr = ptr >>> 0;
729
- const obj = Object.create(Session.prototype);
1115
+ const obj = Object.create(Pubky.prototype);
730
1116
  obj.__wbg_ptr = ptr;
731
- SessionFinalization.register(obj, obj.__wbg_ptr, obj);
1117
+ PubkyFinalization.register(obj, obj.__wbg_ptr, obj);
732
1118
  return obj;
733
1119
  }
734
1120
 
735
1121
  __destroy_into_raw() {
736
1122
  const ptr = this.__wbg_ptr;
737
1123
  this.__wbg_ptr = 0;
738
- SessionFinalization.unregister(this);
1124
+ PubkyFinalization.unregister(this);
739
1125
  return ptr;
740
1126
  }
741
1127
 
742
1128
  free() {
743
1129
  const ptr = this.__destroy_into_raw();
744
- wasm.__wbg_session_free(ptr, 0);
1130
+ wasm.__wbg_pubky_free(ptr, 0);
1131
+ }
1132
+ /**
1133
+ * Create a Pubky facade wired for **mainnet** defaults (public relays).
1134
+ *
1135
+ * @returns {Pubky}
1136
+ * A new facade instance. Use this to create signers, start auth flows, etc.
1137
+ *
1138
+ * @example
1139
+ * const pubky = new Pubky();
1140
+ * const signer = pubky.signer(Keypair.random());
1141
+ */
1142
+ constructor() {
1143
+ const ret = wasm.pubky_new();
1144
+ if (ret[2]) {
1145
+ throw takeFromExternrefTable0(ret[1]);
1146
+ }
1147
+ this.__wbg_ptr = ret[0] >>> 0;
1148
+ PubkyFinalization.register(this, this.__wbg_ptr, this);
1149
+ return this;
1150
+ }
1151
+ /**
1152
+ * Create a Pubky facade preconfigured for a **local testnet**.
1153
+ *
1154
+ * If `host` is provided, PKARR and HTTP endpoints are derived as `http://<host>:ports/...`.
1155
+ * If omitted, `"localhost"` is assumed (handy for `cargo install pubky-testnet`).
1156
+ *
1157
+ * @param {string=} host Optional host (e.g. `"localhost"`, `"docker-host"`, `"127.0.0.1"`).
1158
+ * @returns {Pubky}
1159
+ *
1160
+ * @example
1161
+ * const pubky = Pubky.testnet(); // localhost default
1162
+ * const pubky = Pubky.testnet("docker-host"); // custom hostname/IP
1163
+ * @param {string | null} [host]
1164
+ * @returns {Pubky}
1165
+ */
1166
+ static testnet(host) {
1167
+ var ptr0 = isLikeNone(host) ? 0 : passStringToWasm0(host, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1168
+ var len0 = WASM_VECTOR_LEN;
1169
+ const ret = wasm.pubky_testnet(ptr0, len0);
1170
+ if (ret[2]) {
1171
+ throw takeFromExternrefTable0(ret[1]);
1172
+ }
1173
+ return Pubky.__wrap(ret[0]);
1174
+ }
1175
+ /**
1176
+ * Wrap an existing configured HTTP client into a Pubky facade.
1177
+ *
1178
+ * @param {Client} client A previously constructed client.
1179
+ * @returns {Pubky}
1180
+ *
1181
+ * @example
1182
+ * const client = Client.testnet();
1183
+ * const pubky = Pubky.withClient(client);
1184
+ * @param {Client} client
1185
+ * @returns {Pubky}
1186
+ */
1187
+ static withClient(client) {
1188
+ _assertClass(client, Client);
1189
+ const ret = wasm.pubky_withClient(client.__wbg_ptr);
1190
+ return Pubky.__wrap(ret);
1191
+ }
1192
+ /**
1193
+ * Start a **pubkyauth** flow.
1194
+ *
1195
+ * Provide a **capabilities string** and (optionally) a relay base URL.
1196
+ * The capabilities string is a comma-separated list of entries:
1197
+ * `"<scope>:<actions>"`, where:
1198
+ * - `scope` starts with `/` (e.g. `/pub/example.app/`).
1199
+ * - `actions` is any combo of `r` and/or `w` (order normalized; `wr` -> `rw`).
1200
+ * Pass `""` for no scopes (read-only public session).
1201
+ *
1202
+ * @param {string} capabilities Comma-separated caps, e.g. `"/pub/app/:rw,/pub/foo/file:r"`.
1203
+ * @param {string=} relay Optional HTTP relay base (e.g. `"https://…/link/"`).
1204
+ * @returns {AuthFlow}
1205
+ * A running auth flow. Show `authorizationUrl` as QR/deeplink,
1206
+ * then `awaitApproval()` to obtain a `Session`.
1207
+ *
1208
+ * @throws {PubkyError}
1209
+ * - `{ name: "InvalidInput" }` for malformed capabilities or bad relay URL
1210
+ * - `{ name: "RequestError" }` if the flow cannot be started (network/relay)
1211
+ *
1212
+ * @example
1213
+ * const flow = pubky.startAuthFlow("/pub/my.app/:rw");
1214
+ * renderQr(flow.authorizationUrl);
1215
+ * const session = await flow.awaitApproval();
1216
+ * @param {Capabilities} capabilities
1217
+ * @param {string | null} [relay]
1218
+ * @returns {AuthFlow}
1219
+ */
1220
+ startAuthFlow(capabilities, relay) {
1221
+ const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1222
+ const len0 = WASM_VECTOR_LEN;
1223
+ var ptr1 = isLikeNone(relay) ? 0 : passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1224
+ var len1 = WASM_VECTOR_LEN;
1225
+ const ret = wasm.pubky_startAuthFlow(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1226
+ if (ret[2]) {
1227
+ throw takeFromExternrefTable0(ret[1]);
1228
+ }
1229
+ return AuthFlow.__wrap(ret[0]);
1230
+ }
1231
+ /**
1232
+ * Create a `Signer` from an existing `Keypair`.
1233
+ *
1234
+ * @param {Keypair} keypair The user’s keys.
1235
+ * @returns {Signer}
1236
+ *
1237
+ * @example
1238
+ * const signer = pubky.signer(Keypair.random());
1239
+ * const session = await signer.signup(homeserverPk, null);
1240
+ * @param {Keypair} keypair
1241
+ * @returns {Signer}
1242
+ */
1243
+ signer(keypair) {
1244
+ _assertClass(keypair, Keypair);
1245
+ const ret = wasm.pubky_signer(this.__wbg_ptr, keypair.__wbg_ptr);
1246
+ return Signer.__wrap(ret);
1247
+ }
1248
+ /**
1249
+ * Public, unauthenticated storage API.
1250
+ *
1251
+ * Use for **read-only** public access via addressed paths:
1252
+ * `"<user-z32>/pub/…"`.
1253
+ *
1254
+ * @returns {PublicStorage}
1255
+ *
1256
+ * @example
1257
+ * const text = await pubky.publicStorage.getText(`${userPk.z32()}/pub/example.com/hello.txt`);
1258
+ * @returns {PublicStorage}
1259
+ */
1260
+ get publicStorage() {
1261
+ const ret = wasm.pubky_client(this.__wbg_ptr);
1262
+ return PublicStorage.__wrap(ret);
1263
+ }
1264
+ /**
1265
+ * Resolve the homeserver for a given public key (read-only).
1266
+ *
1267
+ * Uses an internal read-only Pkdns actor.
1268
+ *
1269
+ * @param {PublicKey} user
1270
+ * @returns {Promise<PublicKey|undefined>} Homeserver public key (z32) or `undefined` if not found.
1271
+ * @param {PublicKey} user_public_key
1272
+ * @returns {Promise<PublicKey | undefined>}
1273
+ */
1274
+ getHomeserverOf(user_public_key) {
1275
+ _assertClass(user_public_key, PublicKey);
1276
+ const ret = wasm.pubky_getHomeserverOf(this.__wbg_ptr, user_public_key.__wbg_ptr);
1277
+ return ret;
1278
+ }
1279
+ /**
1280
+ * Access the underlying HTTP client (advanced).
1281
+ *
1282
+ * @returns {Client}
1283
+ * Use this for low-level `fetch()` calls or testing with raw URLs.
1284
+ *
1285
+ * @example
1286
+ * const r = await pubky.client.fetch(`pubky://${user}/pub/app/file.txt`, { credentials: "include" });
1287
+ * @returns {Client}
1288
+ */
1289
+ get client() {
1290
+ const ret = wasm.pubky_client(this.__wbg_ptr);
1291
+ return Client.__wrap(ret);
1292
+ }
1293
+ }
1294
+ module.exports.Pubky = Pubky;
1295
+
1296
+ const PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1297
+ ? { register: () => {}, unregister: () => {} }
1298
+ : new FinalizationRegistry(ptr => wasm.__wbg_publickey_free(ptr >>> 0, 1));
1299
+
1300
+ class PublicKey {
1301
+
1302
+ static __wrap(ptr) {
1303
+ ptr = ptr >>> 0;
1304
+ const obj = Object.create(PublicKey.prototype);
1305
+ obj.__wbg_ptr = ptr;
1306
+ PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1307
+ return obj;
1308
+ }
1309
+
1310
+ __destroy_into_raw() {
1311
+ const ptr = this.__wbg_ptr;
1312
+ this.__wbg_ptr = 0;
1313
+ PublicKeyFinalization.unregister(this);
1314
+ return ptr;
1315
+ }
1316
+
1317
+ free() {
1318
+ const ptr = this.__destroy_into_raw();
1319
+ wasm.__wbg_publickey_free(ptr, 0);
1320
+ }
1321
+ /**
1322
+ * Convert the PublicKey to Uint8Array
1323
+ * @returns {Uint8Array}
1324
+ */
1325
+ toUint8Array() {
1326
+ const ret = wasm.publickey_toUint8Array(this.__wbg_ptr);
1327
+ return ret;
1328
+ }
1329
+ /**
1330
+ * Returns the z-base32 encoding of this public key
1331
+ * @returns {string}
1332
+ */
1333
+ z32() {
1334
+ let deferred1_0;
1335
+ let deferred1_1;
1336
+ try {
1337
+ const ret = wasm.publickey_z32(this.__wbg_ptr);
1338
+ deferred1_0 = ret[0];
1339
+ deferred1_1 = ret[1];
1340
+ return getStringFromWasm0(ret[0], ret[1]);
1341
+ } finally {
1342
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1343
+ }
1344
+ }
1345
+ /**
1346
+ * @throws
1347
+ * @param {string} value
1348
+ * @returns {PublicKey}
1349
+ */
1350
+ static from(value) {
1351
+ const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1352
+ const len0 = WASM_VECTOR_LEN;
1353
+ const ret = wasm.publickey_from(ptr0, len0);
1354
+ if (ret[2]) {
1355
+ throw takeFromExternrefTable0(ret[1]);
1356
+ }
1357
+ return PublicKey.__wrap(ret[0]);
1358
+ }
1359
+ }
1360
+ module.exports.PublicKey = PublicKey;
1361
+
1362
+ const PublicStorageFinalization = (typeof FinalizationRegistry === 'undefined')
1363
+ ? { register: () => {}, unregister: () => {} }
1364
+ : new FinalizationRegistry(ptr => wasm.__wbg_publicstorage_free(ptr >>> 0, 1));
1365
+ /**
1366
+ * Read-only public storage using addressed paths (`"<user-z32>/pub/...")`.
1367
+ */
1368
+ class PublicStorage {
1369
+
1370
+ static __wrap(ptr) {
1371
+ ptr = ptr >>> 0;
1372
+ const obj = Object.create(PublicStorage.prototype);
1373
+ obj.__wbg_ptr = ptr;
1374
+ PublicStorageFinalization.register(obj, obj.__wbg_ptr, obj);
1375
+ return obj;
1376
+ }
1377
+
1378
+ __destroy_into_raw() {
1379
+ const ptr = this.__wbg_ptr;
1380
+ this.__wbg_ptr = 0;
1381
+ PublicStorageFinalization.unregister(this);
1382
+ return ptr;
1383
+ }
1384
+
1385
+ free() {
1386
+ const ptr = this.__destroy_into_raw();
1387
+ wasm.__wbg_publicstorage_free(ptr, 0);
1388
+ }
1389
+ /**
1390
+ * Construct PublicStorage using global client (mainline relays).
1391
+ */
1392
+ constructor() {
1393
+ const ret = wasm.publicstorage_new();
1394
+ if (ret[2]) {
1395
+ throw takeFromExternrefTable0(ret[1]);
1396
+ }
1397
+ this.__wbg_ptr = ret[0] >>> 0;
1398
+ PublicStorageFinalization.register(this, this.__wbg_ptr, this);
1399
+ return this;
1400
+ }
1401
+ /**
1402
+ * List a directory. Results are `pubky://…` identifier URLs.
1403
+ *
1404
+ * @param {Address} address Addressed directory (must end with `/`).
1405
+ * @param {string|null=} cursor Optional suffix or full URL to start **after**.
1406
+ * @param {boolean=} reverse Default `false`. When `true`, newest/lexicographically-last first.
1407
+ * @param {number=} limit Optional result limit.
1408
+ * @param {boolean=} shallow Default `false`. When `true`, lists only first-level entries.
1409
+ * @returns {Promise<string[]>}
1410
+ * @param {Address} address
1411
+ * @param {string | null} [cursor]
1412
+ * @param {boolean | null} [reverse]
1413
+ * @param {number | null} [limit]
1414
+ * @param {boolean | null} [shallow]
1415
+ * @returns {Promise<string[]>}
1416
+ */
1417
+ list(address, cursor, reverse, limit, shallow) {
1418
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1419
+ const len0 = WASM_VECTOR_LEN;
1420
+ var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1421
+ var len1 = WASM_VECTOR_LEN;
1422
+ const ret = wasm.publicstorage_list(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(reverse) ? 0xFFFFFF : reverse ? 1 : 0, isLikeNone(limit) ? 0xFFFFFF : limit, isLikeNone(shallow) ? 0xFFFFFF : shallow ? 1 : 0);
1423
+ return ret;
1424
+ }
1425
+ /**
1426
+ * Perform a streaming `GET` and expose the raw `Response` object.
1427
+ *
1428
+ * @param {Address} address
1429
+ * @returns {Promise<Response>}
1430
+ * @param {Address} address
1431
+ * @returns {Promise<Response>}
1432
+ */
1433
+ get(address) {
1434
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1435
+ const len0 = WASM_VECTOR_LEN;
1436
+ const ret = wasm.publicstorage_get(this.__wbg_ptr, ptr0, len0);
1437
+ return ret;
1438
+ }
1439
+ /**
1440
+ * Fetch bytes from an addressed path.
1441
+ *
1442
+ * @param {Address} address
1443
+ * @returns {Promise<Uint8Array>}
1444
+ * @param {Address} address
1445
+ * @returns {Promise<Uint8Array>}
1446
+ */
1447
+ getBytes(address) {
1448
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1449
+ const len0 = WASM_VECTOR_LEN;
1450
+ const ret = wasm.publicstorage_getBytes(this.__wbg_ptr, ptr0, len0);
1451
+ return ret;
1452
+ }
1453
+ /**
1454
+ * Fetch text from an addressed path as UTF-8 text.
1455
+ *
1456
+ * @param {Address} address
1457
+ * @returns {Promise<string>}
1458
+ * @param {Address} address
1459
+ * @returns {Promise<string>}
1460
+ */
1461
+ getText(address) {
1462
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1463
+ const len0 = WASM_VECTOR_LEN;
1464
+ const ret = wasm.publicstorage_getText(this.__wbg_ptr, ptr0, len0);
1465
+ return ret;
1466
+ }
1467
+ /**
1468
+ * Fetch JSON from an addressed path.
1469
+ *
1470
+ * @param {Address} address `"pubky<user>/pub/.../file.json"` (preferred) or `pubky://<user>/pub/...`.
1471
+ * @returns {Promise<any>}
1472
+ * @param {Address} address
1473
+ * @returns {Promise<any>}
1474
+ */
1475
+ getJson(address) {
1476
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1477
+ const len0 = WASM_VECTOR_LEN;
1478
+ const ret = wasm.publicstorage_getJson(this.__wbg_ptr, ptr0, len0);
1479
+ return ret;
1480
+ }
1481
+ /**
1482
+ * Check if a path exists.
1483
+ *
1484
+ * @param {Address} address
1485
+ * @returns {Promise<boolean>}
1486
+ * @param {Address} address
1487
+ * @returns {Promise<boolean>}
1488
+ */
1489
+ exists(address) {
1490
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1491
+ const len0 = WASM_VECTOR_LEN;
1492
+ const ret = wasm.publicstorage_exists(this.__wbg_ptr, ptr0, len0);
1493
+ return ret;
1494
+ }
1495
+ /**
1496
+ * Get metadata for an address
1497
+ *
1498
+ * @param {Address} address `"pubky<user>/pub/.../file.json"` (preferred) or `pubky://<user>/pub/...`.
1499
+ * @returns {Promise<ResourceStats|undefined>} `undefined` if the resource does not exist.
1500
+ * @throws {PubkyError} On invalid input or transport/server errors.
1501
+ * @param {Address} address
1502
+ * @returns {Promise<ResourceStats | undefined>}
1503
+ */
1504
+ stats(address) {
1505
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1506
+ const len0 = WASM_VECTOR_LEN;
1507
+ const ret = wasm.publicstorage_stats(this.__wbg_ptr, ptr0, len0);
1508
+ return ret;
1509
+ }
1510
+ }
1511
+ module.exports.PublicStorage = PublicStorage;
1512
+
1513
+ const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
1514
+ ? { register: () => {}, unregister: () => {} }
1515
+ : new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr >>> 0, 1));
1516
+ /**
1517
+ * An authenticated context “as the user”.
1518
+ * - Use `storage` for reads/writes (absolute paths like `/pub/app/file.txt`)
1519
+ * - Cookie is managed automatically by the underlying fetch client
1520
+ */
1521
+ class Session {
1522
+
1523
+ static __wrap(ptr) {
1524
+ ptr = ptr >>> 0;
1525
+ const obj = Object.create(Session.prototype);
1526
+ obj.__wbg_ptr = ptr;
1527
+ SessionFinalization.register(obj, obj.__wbg_ptr, obj);
1528
+ return obj;
1529
+ }
1530
+
1531
+ __destroy_into_raw() {
1532
+ const ptr = this.__wbg_ptr;
1533
+ this.__wbg_ptr = 0;
1534
+ SessionFinalization.unregister(this);
1535
+ return ptr;
1536
+ }
1537
+
1538
+ free() {
1539
+ const ptr = this.__destroy_into_raw();
1540
+ wasm.__wbg_session_free(ptr, 0);
1541
+ }
1542
+ /**
1543
+ * Retrieve immutable info about this session (user & capabilities).
1544
+ *
1545
+ * @returns {SessionInfo}
1546
+ * @returns {SessionInfo}
1547
+ */
1548
+ get info() {
1549
+ const ret = wasm.session_info(this.__wbg_ptr);
1550
+ return SessionInfo.__wrap(ret);
1551
+ }
1552
+ /**
1553
+ * Access the session-scoped storage API (read/write).
1554
+ *
1555
+ * @returns {SessionStorage}
1556
+ * @returns {SessionStorage}
1557
+ */
1558
+ get storage() {
1559
+ const ret = wasm.session_storage(this.__wbg_ptr);
1560
+ return SessionStorage.__wrap(ret);
1561
+ }
1562
+ /**
1563
+ * Invalidate the session on the server (clears server cookie).
1564
+ * Further calls to storage API will fail.
1565
+ *
1566
+ * @returns {Promise<void>}
1567
+ * @returns {Promise<void>}
1568
+ */
1569
+ signout() {
1570
+ const ret = wasm.session_signout(this.__wbg_ptr);
1571
+ return ret;
1572
+ }
1573
+ }
1574
+ module.exports.Session = Session;
1575
+
1576
+ const SessionInfoFinalization = (typeof FinalizationRegistry === 'undefined')
1577
+ ? { register: () => {}, unregister: () => {} }
1578
+ : new FinalizationRegistry(ptr => wasm.__wbg_sessioninfo_free(ptr >>> 0, 1));
1579
+ /**
1580
+ * Static snapshot of session metadata.
1581
+ */
1582
+ class SessionInfo {
1583
+
1584
+ static __wrap(ptr) {
1585
+ ptr = ptr >>> 0;
1586
+ const obj = Object.create(SessionInfo.prototype);
1587
+ obj.__wbg_ptr = ptr;
1588
+ SessionInfoFinalization.register(obj, obj.__wbg_ptr, obj);
1589
+ return obj;
1590
+ }
1591
+
1592
+ __destroy_into_raw() {
1593
+ const ptr = this.__wbg_ptr;
1594
+ this.__wbg_ptr = 0;
1595
+ SessionInfoFinalization.unregister(this);
1596
+ return ptr;
1597
+ }
1598
+
1599
+ free() {
1600
+ const ptr = this.__destroy_into_raw();
1601
+ wasm.__wbg_sessioninfo_free(ptr, 0);
1602
+ }
1603
+ /**
1604
+ * The user’s public key for this session.
1605
+ *
1606
+ * Use `.z32()` on the returned `PublicKey` to get the string form.
1607
+ *
1608
+ * @returns {PublicKey}
1609
+ *
1610
+ * @example
1611
+ * const who = sessionInfo.publicKey.z32();
1612
+ * @returns {PublicKey}
1613
+ */
1614
+ get publicKey() {
1615
+ const ret = wasm.sessioninfo_publicKey(this.__wbg_ptr);
1616
+ return PublicKey.__wrap(ret);
1617
+ }
1618
+ /**
1619
+ * Effective capabilities granted to this session.
1620
+ *
1621
+ * @returns {string[]} Normalized capability entries (e.g. `"/pub/app/:rw"`).
1622
+ * @returns {string[]}
1623
+ */
1624
+ get capabilities() {
1625
+ const ret = wasm.sessioninfo_capabilities(this.__wbg_ptr);
1626
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1627
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1628
+ return v1;
1629
+ }
1630
+ }
1631
+ module.exports.SessionInfo = SessionInfo;
1632
+
1633
+ const SessionStorageFinalization = (typeof FinalizationRegistry === 'undefined')
1634
+ ? { register: () => {}, unregister: () => {} }
1635
+ : new FinalizationRegistry(ptr => wasm.__wbg_sessionstorage_free(ptr >>> 0, 1));
1636
+ /**
1637
+ * Read/write storage scoped to **your** session (absolute paths: `/pub/...`).
1638
+ */
1639
+ class SessionStorage {
1640
+
1641
+ static __wrap(ptr) {
1642
+ ptr = ptr >>> 0;
1643
+ const obj = Object.create(SessionStorage.prototype);
1644
+ obj.__wbg_ptr = ptr;
1645
+ SessionStorageFinalization.register(obj, obj.__wbg_ptr, obj);
1646
+ return obj;
1647
+ }
1648
+
1649
+ __destroy_into_raw() {
1650
+ const ptr = this.__wbg_ptr;
1651
+ this.__wbg_ptr = 0;
1652
+ SessionStorageFinalization.unregister(this);
1653
+ return ptr;
1654
+ }
1655
+
1656
+ free() {
1657
+ const ptr = this.__destroy_into_raw();
1658
+ wasm.__wbg_sessionstorage_free(ptr, 0);
1659
+ }
1660
+ /**
1661
+ * List a directory (absolute session path). Returns `pubky://…` URLs.
1662
+ *
1663
+ * @param {Path} path Must end with `/`.
1664
+ * @param {string|null=} cursor Optional suffix or full URL to start **after**.
1665
+ * @param {boolean=} reverse Default `false`.
1666
+ * @param {number=} limit Optional result limit.
1667
+ * @param {boolean=} shallow Default `false`.
1668
+ * @returns {Promise<string[]>}
1669
+ * @param {Path} path
1670
+ * @param {string | null} [cursor]
1671
+ * @param {boolean | null} [reverse]
1672
+ * @param {number | null} [limit]
1673
+ * @param {boolean | null} [shallow]
1674
+ * @returns {Promise<string[]>}
1675
+ */
1676
+ list(path, cursor, reverse, limit, shallow) {
1677
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1678
+ const len0 = WASM_VECTOR_LEN;
1679
+ var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1680
+ var len1 = WASM_VECTOR_LEN;
1681
+ const ret = wasm.sessionstorage_list(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(reverse) ? 0xFFFFFF : reverse ? 1 : 0, isLikeNone(limit) ? 0xFFFFFF : limit, isLikeNone(shallow) ? 0xFFFFFF : shallow ? 1 : 0);
1682
+ return ret;
1683
+ }
1684
+ /**
1685
+ * GET a streaming response for an absolute session path.
1686
+ *
1687
+ * @param {Path} path
1688
+ * @returns {Promise<Response>}
1689
+ * @param {Path} path
1690
+ * @returns {Promise<Response>}
1691
+ */
1692
+ get(path) {
1693
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1694
+ const len0 = WASM_VECTOR_LEN;
1695
+ const ret = wasm.sessionstorage_get(this.__wbg_ptr, ptr0, len0);
1696
+ return ret;
1697
+ }
1698
+ /**
1699
+ * GET bytes from an absolute session path.
1700
+ *
1701
+ * @param {Path} path
1702
+ * @returns {Promise<Uint8Array>}
1703
+ * @param {Path} path
1704
+ * @returns {Promise<Uint8Array>}
1705
+ */
1706
+ getBytes(path) {
1707
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1708
+ const len0 = WASM_VECTOR_LEN;
1709
+ const ret = wasm.sessionstorage_getBytes(this.__wbg_ptr, ptr0, len0);
1710
+ return ret;
1711
+ }
1712
+ /**
1713
+ * GET text from an absolute session path.
1714
+ *
1715
+ * @param {Path} path
1716
+ * @returns {Promise<string>}
1717
+ * @param {Path} path
1718
+ * @returns {Promise<string>}
1719
+ */
1720
+ getText(path) {
1721
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1722
+ const len0 = WASM_VECTOR_LEN;
1723
+ const ret = wasm.sessionstorage_getText(this.__wbg_ptr, ptr0, len0);
1724
+ return ret;
1725
+ }
1726
+ /**
1727
+ * GET JSON from an absolute session path.
1728
+ *
1729
+ * @param {Path} path
1730
+ * @returns {Promise<any>}
1731
+ * @param {Path} path
1732
+ * @returns {Promise<any>}
1733
+ */
1734
+ getJson(path) {
1735
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1736
+ const len0 = WASM_VECTOR_LEN;
1737
+ const ret = wasm.sessionstorage_getJson(this.__wbg_ptr, ptr0, len0);
1738
+ return ret;
1739
+ }
1740
+ /**
1741
+ * Check existence.
1742
+ *
1743
+ * @param {Path} path
1744
+ * @returns {Promise<boolean>}
1745
+ * @param {Path} path
1746
+ * @returns {Promise<boolean>}
1747
+ */
1748
+ exists(path) {
1749
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1750
+ const len0 = WASM_VECTOR_LEN;
1751
+ const ret = wasm.sessionstorage_exists(this.__wbg_ptr, ptr0, len0);
1752
+ return ret;
1753
+ }
1754
+ /**
1755
+ * Get metadata for an absolute, session-scoped path (e.g. `"/pub/app/file.json"`).
1756
+ *
1757
+ * @param {Path} path Absolute path under your user (starts with `/`).
1758
+ * @returns {Promise<ResourceStats|undefined>} `undefined` if the resource does not exist.
1759
+ * @throws {PubkyError} On invalid input or transport/server errors.
1760
+ * @param {Path} path
1761
+ * @returns {Promise<ResourceStats | undefined>}
1762
+ */
1763
+ stats(path) {
1764
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1765
+ const len0 = WASM_VECTOR_LEN;
1766
+ const ret = wasm.sessionstorage_stats(this.__wbg_ptr, ptr0, len0);
1767
+ return ret;
1768
+ }
1769
+ /**
1770
+ * PUT binary at an absolute session path.
1771
+ *
1772
+ * @param {Path} path
1773
+ * @param {Uint8Array} bytes
1774
+ * @returns {Promise<void>}
1775
+ * @param {Path} path
1776
+ * @param {Uint8Array} body
1777
+ * @returns {Promise<void>}
1778
+ */
1779
+ putBytes(path, body) {
1780
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1781
+ const len0 = WASM_VECTOR_LEN;
1782
+ const ptr1 = passArray8ToWasm0(body, wasm.__wbindgen_malloc);
1783
+ const len1 = WASM_VECTOR_LEN;
1784
+ const ret = wasm.sessionstorage_putBytes(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1785
+ return ret;
1786
+ }
1787
+ /**
1788
+ * PUT text at an absolute session path.
1789
+ *
1790
+ * @param {Path} path
1791
+ * @param {string} text
1792
+ * @returns {Promise<void>}
1793
+ * @param {Path} path
1794
+ * @param {string} body
1795
+ * @returns {Promise<void>}
1796
+ */
1797
+ putText(path, body) {
1798
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1799
+ const len0 = WASM_VECTOR_LEN;
1800
+ const ptr1 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1801
+ const len1 = WASM_VECTOR_LEN;
1802
+ const ret = wasm.sessionstorage_putText(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1803
+ return ret;
1804
+ }
1805
+ /**
1806
+ * PUT JSON at an absolute session path.
1807
+ *
1808
+ * @param {Path} path Absolute path (e.g. `"/pub/app/data.json"`).
1809
+ * @param {any} value JSON-serializable value.
1810
+ * @returns {Promise<void>}
1811
+ * @param {Path} path
1812
+ * @param {any} body
1813
+ * @returns {Promise<void>}
1814
+ */
1815
+ putJson(path, body) {
1816
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1817
+ const len0 = WASM_VECTOR_LEN;
1818
+ const ret = wasm.sessionstorage_putJson(this.__wbg_ptr, ptr0, len0, body);
1819
+ return ret;
1820
+ }
1821
+ /**
1822
+ * Delete a path (file or empty directory).
1823
+ *
1824
+ * @param {Path} path
1825
+ * @returns {Promise<void>}
1826
+ * @param {Path} path
1827
+ * @returns {Promise<void>}
1828
+ */
1829
+ delete(path) {
1830
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1831
+ const len0 = WASM_VECTOR_LEN;
1832
+ const ret = wasm.sessionstorage_delete(this.__wbg_ptr, ptr0, len0);
1833
+ return ret;
1834
+ }
1835
+ }
1836
+ module.exports.SessionStorage = SessionStorage;
1837
+
1838
+ const SignerFinalization = (typeof FinalizationRegistry === 'undefined')
1839
+ ? { register: () => {}, unregister: () => {} }
1840
+ : new FinalizationRegistry(ptr => wasm.__wbg_signer_free(ptr >>> 0, 1));
1841
+ /**
1842
+ * Holds a user’s `Keypair` and performs identity operations:
1843
+ * - `signup` creates a new homeserver user.
1844
+ * - `signin` creates a homeserver session for an existing user.
1845
+ * - Approve pubkyauth requests
1846
+ * - Publish PKDNS when signer-bound
1847
+ */
1848
+ class Signer {
1849
+
1850
+ static __wrap(ptr) {
1851
+ ptr = ptr >>> 0;
1852
+ const obj = Object.create(Signer.prototype);
1853
+ obj.__wbg_ptr = ptr;
1854
+ SignerFinalization.register(obj, obj.__wbg_ptr, obj);
1855
+ return obj;
1856
+ }
1857
+
1858
+ __destroy_into_raw() {
1859
+ const ptr = this.__wbg_ptr;
1860
+ this.__wbg_ptr = 0;
1861
+ SignerFinalization.unregister(this);
1862
+ return ptr;
1863
+ }
1864
+
1865
+ free() {
1866
+ const ptr = this.__destroy_into_raw();
1867
+ wasm.__wbg_signer_free(ptr, 0);
1868
+ }
1869
+ /**
1870
+ * Create a signer from a `Keypair` (prefer `pubky.signer(kp)`).
1871
+ *
1872
+ * @param {Keypair} keypair
1873
+ * @returns {Signer}
1874
+ * @param {Keypair} keypair
1875
+ * @returns {Signer}
1876
+ */
1877
+ static fromKeypair(keypair) {
1878
+ _assertClass(keypair, Keypair);
1879
+ const ret = wasm.signer_fromKeypair(keypair.__wbg_ptr);
1880
+ if (ret[2]) {
1881
+ throw takeFromExternrefTable0(ret[1]);
1882
+ }
1883
+ return Signer.__wrap(ret[0]);
1884
+ }
1885
+ /**
1886
+ * Get the public key of this signer.
1887
+ *
1888
+ * @returns {PublicKey}
1889
+ * @returns {PublicKey}
1890
+ */
1891
+ get publicKey() {
1892
+ const ret = wasm.signer_publicKey(this.__wbg_ptr);
1893
+ return PublicKey.__wrap(ret);
1894
+ }
1895
+ /**
1896
+ * Sign up at a homeserver. Returns a ready `Session`.
1897
+ *
1898
+ * Creates a valid homeserver Session with root capabilities
1899
+ *
1900
+ * @param {PublicKey} homeserver The homeserver’s public key.
1901
+ * @param {string|null} signupToken Invite/registration token or `null`.
1902
+ * @returns {Promise<Session>}
1903
+ *
1904
+ * @throws {PubkyError}
1905
+ * - `AuthenticationError` (bad/expired token)
1906
+ * - `RequestError` (network/server)
1907
+ * @param {PublicKey} homeserver
1908
+ * @param {string | null} [signup_token]
1909
+ * @returns {Promise<Session>}
1910
+ */
1911
+ signup(homeserver, signup_token) {
1912
+ _assertClass(homeserver, PublicKey);
1913
+ var ptr0 = isLikeNone(signup_token) ? 0 : passStringToWasm0(signup_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1914
+ var len0 = WASM_VECTOR_LEN;
1915
+ const ret = wasm.signer_signup(this.__wbg_ptr, homeserver.__wbg_ptr, ptr0, len0);
1916
+ return ret;
1917
+ }
1918
+ /**
1919
+ * Fast sign-in for a returning user. Publishes PKDNS in the background.
1920
+ *
1921
+ * Creates a valid homeserver Session with root capabilities
1922
+ *
1923
+ * @returns {Promise<Session>}
1924
+ *
1925
+ * @throws {PubkyError}
1926
+ * @returns {Promise<Session>}
1927
+ */
1928
+ signin() {
1929
+ const ret = wasm.signer_signin(this.__wbg_ptr);
1930
+ return ret;
1931
+ }
1932
+ /**
1933
+ * Blocking sign-in. Waits for PKDNS publish to complete (slower; safer).
1934
+ *
1935
+ * Creates a valid homeserver Session with root capabilities
1936
+ *
1937
+ * @returns {Promise<Session>}
1938
+ * @returns {Promise<Session>}
1939
+ */
1940
+ signinBlocking() {
1941
+ const ret = wasm.signer_signinBlocking(this.__wbg_ptr);
1942
+ return ret;
745
1943
  }
746
1944
  /**
747
- * Return the [PublicKey] of this session
748
- * @returns {PublicKey}
1945
+ * Approve a `pubkyauth://` request URL (encrypts & POSTs the signed AuthToken).
1946
+ * @param {string} pubkyauth_url
1947
+ * @returns {Promise<void>}
749
1948
  */
750
- pubky() {
751
- const ret = wasm.session_pubky(this.__wbg_ptr);
752
- return PublicKey.__wrap(ret);
1949
+ approveAuthRequest(pubkyauth_url) {
1950
+ const ptr0 = passStringToWasm0(pubkyauth_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1951
+ const len0 = WASM_VECTOR_LEN;
1952
+ const ret = wasm.signer_approveAuthRequest(this.__wbg_ptr, ptr0, len0);
1953
+ return ret;
753
1954
  }
754
1955
  /**
755
- * Return the capabilities that this session has.
756
- * @returns {string[]}
1956
+ * Get a PKDNS actor bound to this signer's client & keypair (publishing enabled).
1957
+ *
1958
+ * @returns {Pkdns}
1959
+ *
1960
+ * @example
1961
+ * await signer.pkdns.publishHomeserverIfStale(homeserverPk);
1962
+ * @returns {Pkdns}
757
1963
  */
758
- capabilities() {
759
- const ret = wasm.session_capabilities(this.__wbg_ptr);
760
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
761
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
762
- return v1;
1964
+ get pkdns() {
1965
+ const ret = wasm.signer_pkdns(this.__wbg_ptr);
1966
+ return Pkdns.__wrap(ret);
763
1967
  }
764
1968
  }
765
- module.exports.Session = Session;
1969
+ module.exports.Signer = Signer;
766
1970
 
767
- module.exports.__wbg_abort_410ec47a64ac6117 = function(arg0, arg1) {
768
- arg0.abort(arg1);
1971
+ module.exports.__wbg_Error_0497d5bdba9362e5 = function(arg0, arg1) {
1972
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1973
+ return ret;
1974
+ };
1975
+
1976
+ module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1977
+ const ret = String(arg1);
1978
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1979
+ const len1 = WASM_VECTOR_LEN;
1980
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1981
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
769
1982
  };
770
1983
 
771
- module.exports.__wbg_abort_775ef1d17fc65868 = function(arg0) {
1984
+ module.exports.__wbg_abort_18ba44d46e13d7fe = function(arg0) {
772
1985
  arg0.abort();
773
1986
  };
774
1987
 
775
- module.exports.__wbg_append_8c7dd8d641a5f01b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1988
+ module.exports.__wbg_abort_4198a1129c47f21a = function(arg0, arg1) {
1989
+ arg0.abort(arg1);
1990
+ };
1991
+
1992
+ module.exports.__wbg_append_0342728346e47425 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
776
1993
  arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
777
1994
  }, arguments) };
778
1995
 
779
- module.exports.__wbg_arrayBuffer_d1b44c4390db422f = function() { return handleError(function (arg0) {
1996
+ module.exports.__wbg_arrayBuffer_d58b858456021d7f = function() { return handleError(function (arg0) {
780
1997
  const ret = arg0.arrayBuffer();
781
1998
  return ret;
782
1999
  }, arguments) };
783
2000
 
784
- module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
2001
+ module.exports.__wbg_authtoken_new = function(arg0) {
2002
+ const ret = AuthToken.__wrap(arg0);
2003
+ return ret;
2004
+ };
2005
+
2006
+ module.exports.__wbg_body_e1e045c770257634 = function(arg0) {
2007
+ const ret = arg0.body;
2008
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2009
+ };
2010
+
2011
+ module.exports.__wbg_buffer_a1a27a0dfa70165d = function(arg0) {
785
2012
  const ret = arg0.buffer;
786
2013
  return ret;
787
2014
  };
788
2015
 
789
- module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
790
- const ret = arg0.call(arg1);
2016
+ module.exports.__wbg_buffer_e495ba54cee589cc = function(arg0) {
2017
+ const ret = arg0.buffer;
791
2018
  return ret;
792
- }, arguments) };
2019
+ };
2020
+
2021
+ module.exports.__wbg_byobRequest_56aa768ee4dfed17 = function(arg0) {
2022
+ const ret = arg0.byobRequest;
2023
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2024
+ };
2025
+
2026
+ module.exports.__wbg_byteLength_937f8a52f9697148 = function(arg0) {
2027
+ const ret = arg0.byteLength;
2028
+ return ret;
2029
+ };
2030
+
2031
+ module.exports.__wbg_byteOffset_4d94b7170e641898 = function(arg0) {
2032
+ const ret = arg0.byteOffset;
2033
+ return ret;
2034
+ };
793
2035
 
794
- module.exports.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
2036
+ module.exports.__wbg_call_f2db6205e5c51dc8 = function() { return handleError(function (arg0, arg1, arg2) {
795
2037
  const ret = arg0.call(arg1, arg2);
796
2038
  return ret;
797
2039
  }, arguments) };
798
2040
 
799
- module.exports.__wbg_clearTimeout_86721db0036bea98 = function(arg0) {
2041
+ module.exports.__wbg_call_fbe8be8bf6436ce5 = function() { return handleError(function (arg0, arg1) {
2042
+ const ret = arg0.call(arg1);
2043
+ return ret;
2044
+ }, arguments) };
2045
+
2046
+ module.exports.__wbg_cancel_4d78160f447bbbeb = function(arg0) {
2047
+ const ret = arg0.cancel();
2048
+ return ret;
2049
+ };
2050
+
2051
+ module.exports.__wbg_catch_b51fce253ee18ec3 = function(arg0, arg1) {
2052
+ const ret = arg0.catch(arg1);
2053
+ return ret;
2054
+ };
2055
+
2056
+ module.exports.__wbg_clearTimeout_6222fede17abcb1a = function(arg0) {
800
2057
  const ret = clearTimeout(arg0);
801
2058
  return ret;
802
2059
  };
803
2060
 
804
- module.exports.__wbg_crypto_ed58b8e10a292839 = function(arg0) {
2061
+ module.exports.__wbg_close_290fb040af98d3ac = function() { return handleError(function (arg0) {
2062
+ arg0.close();
2063
+ }, arguments) };
2064
+
2065
+ module.exports.__wbg_close_b2641ef0870e518c = function() { return handleError(function (arg0) {
2066
+ arg0.close();
2067
+ }, arguments) };
2068
+
2069
+ module.exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
805
2070
  const ret = arg0.crypto;
806
2071
  return ret;
807
2072
  };
808
2073
 
809
- module.exports.__wbg_debug_e17b51583ca6a632 = function(arg0, arg1, arg2, arg3) {
2074
+ module.exports.__wbg_debug_103948ed4c500577 = function(arg0, arg1, arg2, arg3) {
810
2075
  console.debug(arg0, arg1, arg2, arg3);
811
2076
  };
812
2077
 
813
- module.exports.__wbg_done_769e5ede4b31c67b = function(arg0) {
2078
+ module.exports.__wbg_done_4d01f352bade43b7 = function(arg0) {
814
2079
  const ret = arg0.done;
815
2080
  return ret;
816
2081
  };
817
2082
 
818
- module.exports.__wbg_error_80de38b3f7cc3c3c = function(arg0, arg1, arg2, arg3) {
2083
+ module.exports.__wbg_enqueue_a62faa171c4fd287 = function() { return handleError(function (arg0, arg1) {
2084
+ arg0.enqueue(arg1);
2085
+ }, arguments) };
2086
+
2087
+ module.exports.__wbg_entries_41651c850143b957 = function(arg0) {
2088
+ const ret = Object.entries(arg0);
2089
+ return ret;
2090
+ };
2091
+
2092
+ module.exports.__wbg_error_624160881466fd69 = function(arg0, arg1, arg2, arg3) {
819
2093
  console.error(arg0, arg1, arg2, arg3);
820
2094
  };
821
2095
 
822
- module.exports.__wbg_fetch_509096533071c657 = function(arg0, arg1) {
2096
+ module.exports.__wbg_fetch_a4b4512b936c2d70 = function(arg0) {
2097
+ const ret = fetch(arg0);
2098
+ return ret;
2099
+ };
2100
+
2101
+ module.exports.__wbg_fetch_a8e43a4e138dfc93 = function(arg0, arg1) {
823
2102
  const ret = arg0.fetch(arg1);
824
2103
  return ret;
825
2104
  };
826
2105
 
827
- module.exports.__wbg_fetch_9e120ad639656465 = function(arg0) {
2106
+ module.exports.__wbg_fetch_f156d10be9a5c88a = function(arg0) {
828
2107
  const ret = fetch(arg0);
829
2108
  return ret;
830
2109
  };
831
2110
 
832
- module.exports.__wbg_fetch_d36a73832f0a45e8 = function(arg0) {
833
- const ret = fetch(arg0);
2111
+ module.exports.__wbg_from_12ff8e47307bd4c7 = function(arg0) {
2112
+ const ret = Array.from(arg0);
834
2113
  return ret;
835
2114
  };
836
2115
 
837
- module.exports.__wbg_getRandomValues_78e016fdd1d721cf = function() { return handleError(function (arg0, arg1) {
2116
+ module.exports.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return handleError(function (arg0, arg1) {
838
2117
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
839
2118
  }, arguments) };
840
2119
 
841
- module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
2120
+ module.exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
842
2121
  arg0.getRandomValues(arg1);
843
2122
  }, arguments) };
844
2123
 
845
- module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
2124
+ module.exports.__wbg_getReader_48e00749fe3f6089 = function() { return handleError(function (arg0) {
2125
+ const ret = arg0.getReader();
2126
+ return ret;
2127
+ }, arguments) };
2128
+
2129
+ module.exports.__wbg_get_92470be87867c2e5 = function() { return handleError(function (arg0, arg1) {
846
2130
  const ret = Reflect.get(arg0, arg1);
847
2131
  return ret;
848
2132
  }, arguments) };
849
2133
 
850
- module.exports.__wbg_has_a5ea9117f258a0ec = function() { return handleError(function (arg0, arg1) {
2134
+ module.exports.__wbg_get_a131a44bd1eb6979 = function(arg0, arg1) {
2135
+ const ret = arg0[arg1 >>> 0];
2136
+ return ret;
2137
+ };
2138
+
2139
+ module.exports.__wbg_getdone_8355ddb2bc75c731 = function(arg0) {
2140
+ const ret = arg0.done;
2141
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2142
+ };
2143
+
2144
+ module.exports.__wbg_getvalue_c1890a401d13f00b = function(arg0) {
2145
+ const ret = arg0.value;
2146
+ return ret;
2147
+ };
2148
+
2149
+ module.exports.__wbg_has_809e438ee9d787a7 = function() { return handleError(function (arg0, arg1) {
851
2150
  const ret = Reflect.has(arg0, arg1);
852
2151
  return ret;
853
2152
  }, arguments) };
854
2153
 
855
- module.exports.__wbg_headers_9cb51cfd2ac780a4 = function(arg0) {
2154
+ module.exports.__wbg_headers_0f0cbdc6290b6780 = function(arg0) {
856
2155
  const ret = arg0.headers;
857
2156
  return ret;
858
2157
  };
859
2158
 
860
- module.exports.__wbg_info_033d8b8a0838f1d3 = function(arg0, arg1, arg2, arg3) {
2159
+ module.exports.__wbg_info_a1cc312ecc877319 = function(arg0, arg1, arg2, arg3) {
861
2160
  console.info(arg0, arg1, arg2, arg3);
862
2161
  };
863
2162
 
864
- module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function(arg0) {
2163
+ module.exports.__wbg_instanceof_ArrayBuffer_a8b6f580b363f2bc = function(arg0) {
2164
+ let result;
2165
+ try {
2166
+ result = arg0 instanceof ArrayBuffer;
2167
+ } catch (_) {
2168
+ result = false;
2169
+ }
2170
+ const ret = result;
2171
+ return ret;
2172
+ };
2173
+
2174
+ module.exports.__wbg_instanceof_Error_58a92d81483a4b16 = function(arg0) {
2175
+ let result;
2176
+ try {
2177
+ result = arg0 instanceof Error;
2178
+ } catch (_) {
2179
+ result = false;
2180
+ }
2181
+ const ret = result;
2182
+ return ret;
2183
+ };
2184
+
2185
+ module.exports.__wbg_instanceof_Headers_8b4c0df841a5ed48 = function(arg0) {
2186
+ let result;
2187
+ try {
2188
+ result = arg0 instanceof Headers;
2189
+ } catch (_) {
2190
+ result = false;
2191
+ }
2192
+ const ret = result;
2193
+ return ret;
2194
+ };
2195
+
2196
+ module.exports.__wbg_instanceof_Map_80cc65041c96417a = function(arg0) {
2197
+ let result;
2198
+ try {
2199
+ result = arg0 instanceof Map;
2200
+ } catch (_) {
2201
+ result = false;
2202
+ }
2203
+ const ret = result;
2204
+ return ret;
2205
+ };
2206
+
2207
+ module.exports.__wbg_instanceof_Response_e80ce8b7a2b968d2 = function(arg0) {
865
2208
  let result;
866
2209
  try {
867
2210
  result = arg0 instanceof Response;
@@ -872,38 +2215,89 @@ module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function(arg0) {
872
2215
  return ret;
873
2216
  };
874
2217
 
875
- module.exports.__wbg_iterator_9a24c88df860dc65 = function() {
2218
+ module.exports.__wbg_instanceof_Uint8Array_ca460677bc155827 = function(arg0) {
2219
+ let result;
2220
+ try {
2221
+ result = arg0 instanceof Uint8Array;
2222
+ } catch (_) {
2223
+ result = false;
2224
+ }
2225
+ const ret = result;
2226
+ return ret;
2227
+ };
2228
+
2229
+ module.exports.__wbg_isArray_5f090bed72bd4f89 = function(arg0) {
2230
+ const ret = Array.isArray(arg0);
2231
+ return ret;
2232
+ };
2233
+
2234
+ module.exports.__wbg_isSafeInteger_90d7c4674047d684 = function(arg0) {
2235
+ const ret = Number.isSafeInteger(arg0);
2236
+ return ret;
2237
+ };
2238
+
2239
+ module.exports.__wbg_iterator_4068add5b2aef7a6 = function() {
876
2240
  const ret = Symbol.iterator;
877
2241
  return ret;
878
2242
  };
879
2243
 
880
- module.exports.__wbg_length_a446193dc22c12f8 = function(arg0) {
2244
+ module.exports.__wbg_length_ab6d22b5ead75c72 = function(arg0) {
881
2245
  const ret = arg0.length;
882
2246
  return ret;
883
2247
  };
884
2248
 
885
- module.exports.__wbg_log_cad59bb680daec67 = function(arg0, arg1, arg2, arg3) {
2249
+ module.exports.__wbg_length_f00ec12454a5d9fd = function(arg0) {
2250
+ const ret = arg0.length;
2251
+ return ret;
2252
+ };
2253
+
2254
+ module.exports.__wbg_log_bff357b3df4db934 = function(arg0, arg1, arg2, arg3) {
886
2255
  console.log(arg0, arg1, arg2, arg3);
887
2256
  };
888
2257
 
889
- module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
2258
+ module.exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
890
2259
  const ret = arg0.msCrypto;
891
2260
  return ret;
892
2261
  };
893
2262
 
894
- module.exports.__wbg_new_018dcc2d6c8c2f6a = function() { return handleError(function () {
2263
+ module.exports.__wbg_new_07b483f72211fd66 = function() {
2264
+ const ret = new Object();
2265
+ return ret;
2266
+ };
2267
+
2268
+ module.exports.__wbg_new_186abcfdff244e42 = function() { return handleError(function () {
2269
+ const ret = new AbortController();
2270
+ return ret;
2271
+ }, arguments) };
2272
+
2273
+ module.exports.__wbg_new_476169e6d59f23ae = function(arg0, arg1) {
2274
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2275
+ return ret;
2276
+ };
2277
+
2278
+ module.exports.__wbg_new_4796e1cd2eb9ea6d = function() { return handleError(function () {
895
2279
  const ret = new Headers();
896
2280
  return ret;
897
2281
  }, arguments) };
898
2282
 
899
- module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
2283
+ module.exports.__wbg_new_58353953ad2097cc = function() {
2284
+ const ret = new Array();
2285
+ return ret;
2286
+ };
2287
+
2288
+ module.exports.__wbg_new_a979b4b45bd55c7f = function() {
2289
+ const ret = new Map();
2290
+ return ret;
2291
+ };
2292
+
2293
+ module.exports.__wbg_new_e30c39c06edaabf2 = function(arg0, arg1) {
900
2294
  try {
901
2295
  var state0 = {a: arg0, b: arg1};
902
2296
  var cb0 = (arg0, arg1) => {
903
2297
  const a = state0.a;
904
2298
  state0.a = 0;
905
2299
  try {
906
- return __wbg_adapter_74(a, state0.b, arg0, arg1);
2300
+ return __wbg_adapter_128(a, state0.b, arg0, arg1);
907
2301
  } finally {
908
2302
  state0.a = a;
909
2303
  }
@@ -915,67 +2309,72 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
915
2309
  }
916
2310
  };
917
2311
 
918
- module.exports.__wbg_new_405e22f390576ce2 = function() {
919
- const ret = new Object();
2312
+ module.exports.__wbg_new_e52b3efaaa774f96 = function(arg0) {
2313
+ const ret = new Uint8Array(arg0);
920
2314
  return ret;
921
2315
  };
922
2316
 
923
- module.exports.__wbg_new_78feb108b6472713 = function() {
924
- const ret = new Array();
2317
+ module.exports.__wbg_newfromslice_7c05ab1297cb2d88 = function(arg0, arg1) {
2318
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
925
2319
  return ret;
926
2320
  };
927
2321
 
928
- module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
929
- const ret = new Uint8Array(arg0);
2322
+ module.exports.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
2323
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
930
2324
  return ret;
931
2325
  };
932
2326
 
933
- module.exports.__wbg_new_e25e5aab09ff45db = function() { return handleError(function () {
934
- const ret = new AbortController();
935
- return ret;
936
- }, arguments) };
937
-
938
- module.exports.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
939
- const ret = new Function(getStringFromWasm0(arg0, arg1));
2327
+ module.exports.__wbg_newwithbyteoffsetandlength_3b01ecda099177e8 = function(arg0, arg1, arg2) {
2328
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
940
2329
  return ret;
941
2330
  };
942
2331
 
943
- module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
944
- const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
2332
+ module.exports.__wbg_newwithintounderlyingsource_b47f6a6a596a7f24 = function(arg0, arg1) {
2333
+ const ret = new ReadableStream(IntoUnderlyingSource.__wrap(arg0), arg1);
945
2334
  return ret;
946
2335
  };
947
2336
 
948
- module.exports.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
2337
+ module.exports.__wbg_newwithlength_08f872dc1e3ada2e = function(arg0) {
949
2338
  const ret = new Uint8Array(arg0 >>> 0);
950
2339
  return ret;
951
2340
  };
952
2341
 
953
- module.exports.__wbg_newwithstrandinit_06c535e0a867c635 = function() { return handleError(function (arg0, arg1, arg2) {
2342
+ module.exports.__wbg_newwithoptreadablestreamandinit_ce4ecbe22555867e = function() { return handleError(function (arg0, arg1) {
2343
+ const ret = new Response(arg0, arg1);
2344
+ return ret;
2345
+ }, arguments) };
2346
+
2347
+ module.exports.__wbg_newwithstrandinit_f8a9dbe009d6be37 = function() { return handleError(function (arg0, arg1, arg2) {
954
2348
  const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
955
2349
  return ret;
956
2350
  }, arguments) };
957
2351
 
958
- module.exports.__wbg_next_25feadfc0913fea9 = function(arg0) {
2352
+ module.exports.__wbg_next_8bb824d217961b5d = function(arg0) {
959
2353
  const ret = arg0.next;
960
2354
  return ret;
961
2355
  };
962
2356
 
963
- module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
2357
+ module.exports.__wbg_next_e2da48d8fff7439a = function() { return handleError(function (arg0) {
964
2358
  const ret = arg0.next();
965
2359
  return ret;
966
2360
  }, arguments) };
967
2361
 
968
- module.exports.__wbg_node_02999533c4ea02e3 = function(arg0) {
2362
+ module.exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
969
2363
  const ret = arg0.node;
970
2364
  return ret;
971
2365
  };
972
2366
 
973
- module.exports.__wbg_now_807e54c39636c349 = function() {
2367
+ module.exports.__wbg_now_eb0821f3bd9f6529 = function() {
974
2368
  const ret = Date.now();
975
2369
  return ret;
976
2370
  };
977
2371
 
978
- module.exports.__wbg_process_5c1d670bc53614b8 = function(arg0) {
2372
+ module.exports.__wbg_parse_c7ba327fb6231e7f = function() { return handleError(function (arg0, arg1) {
2373
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
2374
+ return ret;
2375
+ }, arguments) };
2376
+
2377
+ module.exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
979
2378
  const ret = arg0.process;
980
2379
  return ret;
981
2380
  };
@@ -985,128 +2384,187 @@ module.exports.__wbg_publickey_new = function(arg0) {
985
2384
  return ret;
986
2385
  };
987
2386
 
988
- module.exports.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
989
- const ret = arg0.push(arg1);
990
- return ret;
991
- };
992
-
993
- module.exports.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function(arg0) {
2387
+ module.exports.__wbg_queueMicrotask_46c1df247678729f = function(arg0) {
994
2388
  queueMicrotask(arg0);
995
2389
  };
996
2390
 
997
- module.exports.__wbg_queueMicrotask_d3219def82552485 = function(arg0) {
2391
+ module.exports.__wbg_queueMicrotask_8acf3ccb75ed8d11 = function(arg0) {
998
2392
  const ret = arg0.queueMicrotask;
999
2393
  return ret;
1000
2394
  };
1001
2395
 
1002
- module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) {
2396
+ module.exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
1003
2397
  arg0.randomFillSync(arg1);
1004
2398
  }, arguments) };
1005
2399
 
1006
- module.exports.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
2400
+ module.exports.__wbg_read_f4b89f69cc51efc7 = function(arg0) {
2401
+ const ret = arg0.read();
2402
+ return ret;
2403
+ };
2404
+
2405
+ module.exports.__wbg_releaseLock_c589dd51c0812aca = function(arg0) {
2406
+ arg0.releaseLock();
2407
+ };
2408
+
2409
+ module.exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
1007
2410
  const ret = module.require;
1008
2411
  return ret;
1009
2412
  }, arguments) };
1010
2413
 
1011
- module.exports.__wbg_resolve_4851785c9c5f573d = function(arg0) {
2414
+ module.exports.__wbg_resolve_0dac8c580ffd4678 = function(arg0) {
1012
2415
  const ret = Promise.resolve(arg0);
1013
2416
  return ret;
1014
2417
  };
1015
2418
 
2419
+ module.exports.__wbg_respond_b227f1c3be2bb879 = function() { return handleError(function (arg0, arg1) {
2420
+ arg0.respond(arg1 >>> 0);
2421
+ }, arguments) };
2422
+
1016
2423
  module.exports.__wbg_session_new = function(arg0) {
1017
2424
  const ret = Session.__wrap(arg0);
1018
2425
  return ret;
1019
2426
  };
1020
2427
 
1021
- module.exports.__wbg_setTimeout_2e707715f8cc9497 = function(arg0, arg1) {
2428
+ module.exports.__wbg_setTimeout_2b339866a2aa3789 = function(arg0, arg1) {
1022
2429
  const ret = setTimeout(arg0, arg1);
1023
2430
  return ret;
1024
2431
  };
1025
2432
 
1026
- module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
2433
+ module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
2434
+ arg0[arg1] = arg2;
2435
+ };
2436
+
2437
+ module.exports.__wbg_set_7422acbe992d64ab = function(arg0, arg1, arg2) {
2438
+ arg0[arg1 >>> 0] = arg2;
2439
+ };
2440
+
2441
+ module.exports.__wbg_set_b042eef31c50834d = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
2442
+ arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2443
+ }, arguments) };
2444
+
2445
+ module.exports.__wbg_set_c43293f93a35998a = function() { return handleError(function (arg0, arg1, arg2) {
2446
+ const ret = Reflect.set(arg0, arg1, arg2);
2447
+ return ret;
2448
+ }, arguments) };
2449
+
2450
+ module.exports.__wbg_set_d6bdfd275fb8a4ce = function(arg0, arg1, arg2) {
2451
+ const ret = arg0.set(arg1, arg2);
2452
+ return ret;
2453
+ };
2454
+
2455
+ module.exports.__wbg_set_fe4e79d1ed3b0e9b = function(arg0, arg1, arg2) {
1027
2456
  arg0.set(arg1, arg2 >>> 0);
1028
2457
  };
1029
2458
 
1030
- module.exports.__wbg_setbody_5923b78a95eedf29 = function(arg0, arg1) {
2459
+ module.exports.__wbg_setbody_971ec015fc13d6b4 = function(arg0, arg1) {
1031
2460
  arg0.body = arg1;
1032
2461
  };
1033
2462
 
1034
- module.exports.__wbg_setcredentials_c3a22f1cd105a2c6 = function(arg0, arg1) {
2463
+ module.exports.__wbg_setcache_a94cd14dc0cc72a2 = function(arg0, arg1) {
2464
+ arg0.cache = __wbindgen_enum_RequestCache[arg1];
2465
+ };
2466
+
2467
+ module.exports.__wbg_setcredentials_920d91fb5984c94a = function(arg0, arg1) {
1035
2468
  arg0.credentials = __wbindgen_enum_RequestCredentials[arg1];
1036
2469
  };
1037
2470
 
1038
- module.exports.__wbg_setheaders_834c0bdb6a8949ad = function(arg0, arg1) {
2471
+ module.exports.__wbg_setheaders_408564032a1382da = function(arg0, arg1) {
1039
2472
  arg0.headers = arg1;
1040
2473
  };
1041
2474
 
1042
- module.exports.__wbg_setmethod_3c5280fe5d890842 = function(arg0, arg1, arg2) {
2475
+ module.exports.__wbg_setheaders_65a4eb4c0443ae61 = function(arg0, arg1) {
2476
+ arg0.headers = arg1;
2477
+ };
2478
+
2479
+ module.exports.__wbg_sethighwatermark_3017ad772d071dcb = function(arg0, arg1) {
2480
+ arg0.highWaterMark = arg1;
2481
+ };
2482
+
2483
+ module.exports.__wbg_setmethod_8ce1be0b4d701b7c = function(arg0, arg1, arg2) {
1043
2484
  arg0.method = getStringFromWasm0(arg1, arg2);
1044
2485
  };
1045
2486
 
1046
- module.exports.__wbg_setmode_5dc300b865044b65 = function(arg0, arg1) {
2487
+ module.exports.__wbg_setmode_bd35f026f55b6247 = function(arg0, arg1) {
1047
2488
  arg0.mode = __wbindgen_enum_RequestMode[arg1];
1048
2489
  };
1049
2490
 
1050
- module.exports.__wbg_setsignal_75b21ef3a81de905 = function(arg0, arg1) {
2491
+ module.exports.__wbg_setname_098bc917fa3ff0d0 = function(arg0, arg1, arg2) {
2492
+ arg0.name = getStringFromWasm0(arg1, arg2);
2493
+ };
2494
+
2495
+ module.exports.__wbg_setsignal_8e72abfe7ee03c97 = function(arg0, arg1) {
1051
2496
  arg0.signal = arg1;
1052
2497
  };
1053
2498
 
1054
- module.exports.__wbg_signal_aaf9ad74119f20a4 = function(arg0) {
2499
+ module.exports.__wbg_setstatus_bd5b448a903a8658 = function(arg0, arg1) {
2500
+ arg0.status = arg1;
2501
+ };
2502
+
2503
+ module.exports.__wbg_setstatustext_01104c878f7651a0 = function(arg0, arg1, arg2) {
2504
+ arg0.statusText = getStringFromWasm0(arg1, arg2);
2505
+ };
2506
+
2507
+ module.exports.__wbg_signal_b96223519a041faa = function(arg0) {
1055
2508
  const ret = arg0.signal;
1056
2509
  return ret;
1057
2510
  };
1058
2511
 
1059
- module.exports.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
2512
+ module.exports.__wbg_static_accessor_GLOBAL_487c52c58d65314d = function() {
1060
2513
  const ret = typeof global === 'undefined' ? null : global;
1061
2514
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1062
2515
  };
1063
2516
 
1064
- module.exports.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
2517
+ module.exports.__wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291 = function() {
1065
2518
  const ret = typeof globalThis === 'undefined' ? null : globalThis;
1066
2519
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1067
2520
  };
1068
2521
 
1069
- module.exports.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
2522
+ module.exports.__wbg_static_accessor_SELF_78c9e3071b912620 = function() {
1070
2523
  const ret = typeof self === 'undefined' ? null : self;
1071
2524
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1072
2525
  };
1073
2526
 
1074
- module.exports.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
2527
+ module.exports.__wbg_static_accessor_WINDOW_a093d21393777366 = function() {
1075
2528
  const ret = typeof window === 'undefined' ? null : window;
1076
2529
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1077
2530
  };
1078
2531
 
1079
- module.exports.__wbg_status_f6360336ca686bf0 = function(arg0) {
2532
+ module.exports.__wbg_status_a54682bbe52f9058 = function(arg0) {
1080
2533
  const ret = arg0.status;
1081
2534
  return ret;
1082
2535
  };
1083
2536
 
1084
- module.exports.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) {
2537
+ module.exports.__wbg_stringify_c242842b97f054cc = function() { return handleError(function (arg0) {
1085
2538
  const ret = JSON.stringify(arg0);
1086
2539
  return ret;
1087
2540
  }, arguments) };
1088
2541
 
1089
- module.exports.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
2542
+ module.exports.__wbg_subarray_dd4ade7d53bd8e26 = function(arg0, arg1, arg2) {
1090
2543
  const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1091
2544
  return ret;
1092
2545
  };
1093
2546
 
1094
- module.exports.__wbg_text_7805bea50de2af49 = function() { return handleError(function (arg0) {
2547
+ module.exports.__wbg_text_ec0e22f60e30dd2f = function() { return handleError(function (arg0) {
1095
2548
  const ret = arg0.text();
1096
2549
  return ret;
1097
2550
  }, arguments) };
1098
2551
 
1099
- module.exports.__wbg_then_44b73946d2fb3e7d = function(arg0, arg1) {
2552
+ module.exports.__wbg_then_82ab9fb4080f1707 = function(arg0, arg1, arg2) {
2553
+ const ret = arg0.then(arg1, arg2);
2554
+ return ret;
2555
+ };
2556
+
2557
+ module.exports.__wbg_then_db882932c0c714c6 = function(arg0, arg1) {
1100
2558
  const ret = arg0.then(arg1);
1101
2559
  return ret;
1102
2560
  };
1103
2561
 
1104
- module.exports.__wbg_then_48b406749878a531 = function(arg0, arg1, arg2) {
1105
- const ret = arg0.then(arg1, arg2);
2562
+ module.exports.__wbg_toString_21791a66666b3afd = function(arg0) {
2563
+ const ret = arg0.toString();
1106
2564
  return ret;
1107
2565
  };
1108
2566
 
1109
- module.exports.__wbg_url_ae10c34ca209681d = function(arg0, arg1) {
2567
+ module.exports.__wbg_url_e6ed869ea05b7a71 = function(arg0, arg1) {
1110
2568
  const ret = arg1.url;
1111
2569
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1112
2570
  const len1 = WASM_VECTOR_LEN;
@@ -1114,20 +2572,57 @@ module.exports.__wbg_url_ae10c34ca209681d = function(arg0, arg1) {
1114
2572
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1115
2573
  };
1116
2574
 
1117
- module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
2575
+ module.exports.__wbg_value_17b896954e14f896 = function(arg0) {
1118
2576
  const ret = arg0.value;
1119
2577
  return ret;
1120
2578
  };
1121
2579
 
1122
- module.exports.__wbg_versions_c71aa1626a93e0a1 = function(arg0) {
2580
+ module.exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
1123
2581
  const ret = arg0.versions;
1124
2582
  return ret;
1125
2583
  };
1126
2584
 
1127
- module.exports.__wbg_warn_aaf1f4664a035bd6 = function(arg0, arg1, arg2, arg3) {
2585
+ module.exports.__wbg_view_a9ad80dcbad7cf1c = function(arg0) {
2586
+ const ret = arg0.view;
2587
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2588
+ };
2589
+
2590
+ module.exports.__wbg_warn_90607373221a6b1c = function(arg0, arg1, arg2, arg3) {
1128
2591
  console.warn(arg0, arg1, arg2, arg3);
1129
2592
  };
1130
2593
 
2594
+ module.exports.__wbindgen_array_new = function() {
2595
+ const ret = [];
2596
+ return ret;
2597
+ };
2598
+
2599
+ module.exports.__wbindgen_array_push = function(arg0, arg1) {
2600
+ arg0.push(arg1);
2601
+ };
2602
+
2603
+ module.exports.__wbindgen_bigint_from_i64 = function(arg0) {
2604
+ const ret = arg0;
2605
+ return ret;
2606
+ };
2607
+
2608
+ module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
2609
+ const ret = BigInt.asUintN(64, arg0);
2610
+ return ret;
2611
+ };
2612
+
2613
+ module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
2614
+ const v = arg1;
2615
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2616
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2617
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2618
+ };
2619
+
2620
+ module.exports.__wbindgen_boolean_get = function(arg0) {
2621
+ const v = arg0;
2622
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
2623
+ return ret;
2624
+ };
2625
+
1131
2626
  module.exports.__wbindgen_cb_drop = function(arg0) {
1132
2627
  const obj = arg0.original;
1133
2628
  if (obj.cnt-- == 1) {
@@ -1138,13 +2633,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
1138
2633
  return ret;
1139
2634
  };
1140
2635
 
1141
- module.exports.__wbindgen_closure_wrapper2423 = function(arg0, arg1, arg2) {
1142
- const ret = makeMutClosure(arg0, arg1, 129, __wbg_adapter_28);
2636
+ module.exports.__wbindgen_closure_wrapper2879 = function(arg0, arg1, arg2) {
2637
+ const ret = makeMutClosure(arg0, arg1, 165, __wbg_adapter_54);
1143
2638
  return ret;
1144
2639
  };
1145
2640
 
1146
- module.exports.__wbindgen_closure_wrapper2756 = function(arg0, arg1, arg2) {
1147
- const ret = makeMutClosure(arg0, arg1, 129, __wbg_adapter_31);
2641
+ module.exports.__wbindgen_closure_wrapper2888 = function(arg0, arg1, arg2) {
2642
+ const ret = makeMutClosure(arg0, arg1, 178, __wbg_adapter_57);
1148
2643
  return ret;
1149
2644
  };
1150
2645
 
@@ -1156,8 +2651,13 @@ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
1156
2651
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1157
2652
  };
1158
2653
 
2654
+ module.exports.__wbindgen_in = function(arg0, arg1) {
2655
+ const ret = arg0 in arg1;
2656
+ return ret;
2657
+ };
2658
+
1159
2659
  module.exports.__wbindgen_init_externref_table = function() {
1160
- const table = wasm.__wbindgen_export_2;
2660
+ const table = wasm.__wbindgen_export_4;
1161
2661
  const offset = table.grow(4);
1162
2662
  table.set(0, undefined);
1163
2663
  table.set(offset + 0, undefined);
@@ -1167,11 +2667,21 @@ module.exports.__wbindgen_init_externref_table = function() {
1167
2667
  ;
1168
2668
  };
1169
2669
 
2670
+ module.exports.__wbindgen_is_bigint = function(arg0) {
2671
+ const ret = typeof(arg0) === 'bigint';
2672
+ return ret;
2673
+ };
2674
+
1170
2675
  module.exports.__wbindgen_is_function = function(arg0) {
1171
2676
  const ret = typeof(arg0) === 'function';
1172
2677
  return ret;
1173
2678
  };
1174
2679
 
2680
+ module.exports.__wbindgen_is_null = function(arg0) {
2681
+ const ret = arg0 === null;
2682
+ return ret;
2683
+ };
2684
+
1175
2685
  module.exports.__wbindgen_is_object = function(arg0) {
1176
2686
  const val = arg0;
1177
2687
  const ret = typeof(val) === 'object' && val !== null;
@@ -1188,11 +2698,33 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
1188
2698
  return ret;
1189
2699
  };
1190
2700
 
2701
+ module.exports.__wbindgen_jsval_eq = function(arg0, arg1) {
2702
+ const ret = arg0 === arg1;
2703
+ return ret;
2704
+ };
2705
+
2706
+ module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
2707
+ const ret = arg0 == arg1;
2708
+ return ret;
2709
+ };
2710
+
1191
2711
  module.exports.__wbindgen_memory = function() {
1192
2712
  const ret = wasm.memory;
1193
2713
  return ret;
1194
2714
  };
1195
2715
 
2716
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
2717
+ const obj = arg1;
2718
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2719
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2720
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2721
+ };
2722
+
2723
+ module.exports.__wbindgen_number_new = function(arg0) {
2724
+ const ret = arg0;
2725
+ return ret;
2726
+ };
2727
+
1196
2728
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
1197
2729
  const obj = arg1;
1198
2730
  const ret = typeof(obj) === 'string' ? obj : undefined;