@synonymdev/pubky 0.5.4 → 0.6.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -159
- package/index.cjs +1565 -385
- package/index.js +1672 -461
- package/package.json +3 -2
- package/pubky.d.ts +706 -82
- 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
|
-
|
|
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
|
-
|
|
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
|
|
37
|
-
|
|
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
|
|
29
|
+
function getStringFromWasm0(ptr, len) {
|
|
46
30
|
ptr = ptr >>> 0;
|
|
47
|
-
return
|
|
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
|
-
|
|
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 getArrayU8FromWasm0(ptr, len) {
|
|
115
|
+
ptr = ptr >>> 0;
|
|
116
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function isLikeNone(x) {
|
|
120
|
+
return x === undefined || x === null;
|
|
121
|
+
}
|
|
122
|
+
|
|
119
123
|
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
120
124
|
? { register: () => {}, unregister: () => {} }
|
|
121
125
|
: new FinalizationRegistry(state => {
|
|
@@ -219,24 +223,10 @@ function _assertClass(instance, klass) {
|
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
function takeFromExternrefTable0(idx) {
|
|
222
|
-
const value = wasm.
|
|
226
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
223
227
|
wasm.__externref_table_dealloc(idx);
|
|
224
228
|
return value;
|
|
225
229
|
}
|
|
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
230
|
|
|
241
231
|
function passArray8ToWasm0(arg, malloc) {
|
|
242
232
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
@@ -244,36 +234,37 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
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.
|
|
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
|
/**
|
|
249
|
+
* Set the global logging verbosity for the WASM Pubky SDK. Routes Rust `log` output to the browser console.
|
|
250
|
+
*
|
|
251
|
+
* Accepted values (case-insensitive): "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 {string} 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.
|
|
277
268
|
* @param {string} level
|
|
278
269
|
*/
|
|
279
270
|
module.exports.setLogLevel = function(level) {
|
|
@@ -285,59 +276,143 @@ module.exports.setLogLevel = function(level) {
|
|
|
285
276
|
}
|
|
286
277
|
};
|
|
287
278
|
|
|
288
|
-
|
|
289
|
-
|
|
279
|
+
/**
|
|
280
|
+
* Validate and normalize a capabilities string.
|
|
281
|
+
*
|
|
282
|
+
* - Normalizes action order (`wr` -> `rw`)
|
|
283
|
+
* - Throws `InvalidInput` listing malformed entries.
|
|
284
|
+
*
|
|
285
|
+
* @param {string} input
|
|
286
|
+
* @returns {string} Normalized string (same shape as input).
|
|
287
|
+
* @throws {PubkyJsError} `{ name: "InvalidInput" }` with a helpful message.
|
|
288
|
+
* @param {string} input
|
|
289
|
+
* @returns {string}
|
|
290
|
+
*/
|
|
291
|
+
module.exports.validateCapabilities = function(input) {
|
|
292
|
+
let deferred3_0;
|
|
293
|
+
let deferred3_1;
|
|
294
|
+
try {
|
|
295
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
296
|
+
const len0 = WASM_VECTOR_LEN;
|
|
297
|
+
const ret = wasm.validateCapabilities(ptr0, len0);
|
|
298
|
+
var ptr2 = ret[0];
|
|
299
|
+
var len2 = ret[1];
|
|
300
|
+
if (ret[3]) {
|
|
301
|
+
ptr2 = 0; len2 = 0;
|
|
302
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
303
|
+
}
|
|
304
|
+
deferred3_0 = ptr2;
|
|
305
|
+
deferred3_1 = len2;
|
|
306
|
+
return getStringFromWasm0(ptr2, len2);
|
|
307
|
+
} finally {
|
|
308
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
function __wbg_adapter_54(arg0, arg1) {
|
|
313
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h1ed9ddf46f2cacfa(arg0, arg1);
|
|
290
314
|
}
|
|
291
315
|
|
|
292
|
-
function
|
|
293
|
-
wasm.
|
|
316
|
+
function __wbg_adapter_57(arg0, arg1, arg2) {
|
|
317
|
+
wasm.closure170_externref_shim(arg0, arg1, arg2);
|
|
294
318
|
}
|
|
295
319
|
|
|
296
|
-
function
|
|
297
|
-
wasm.
|
|
320
|
+
function __wbg_adapter_120(arg0, arg1, arg2, arg3) {
|
|
321
|
+
wasm.closure74_externref_shim(arg0, arg1, arg2, arg3);
|
|
298
322
|
}
|
|
299
323
|
|
|
324
|
+
const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
|
|
325
|
+
|
|
300
326
|
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
301
327
|
|
|
302
328
|
const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
|
|
303
329
|
|
|
304
|
-
const
|
|
330
|
+
const AuthFlowFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
305
331
|
? { register: () => {}, unregister: () => {} }
|
|
306
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
307
|
-
|
|
308
|
-
|
|
332
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_authflow_free(ptr >>> 0, 1));
|
|
333
|
+
/**
|
|
334
|
+
* Start and control a pubkyauth authorization flow.
|
|
335
|
+
*
|
|
336
|
+
* Typical flow:
|
|
337
|
+
* 1) `AuthFlow.start(...)` or `pubky.startAuthFlow(...)`
|
|
338
|
+
* 2) Show `authorizationUrl()` as QR/deeplink to the user’s signing device
|
|
339
|
+
* 3) `awaitApproval()` to receive a ready `Session`
|
|
340
|
+
*/
|
|
341
|
+
class AuthFlow {
|
|
309
342
|
|
|
310
343
|
static __wrap(ptr) {
|
|
311
344
|
ptr = ptr >>> 0;
|
|
312
|
-
const obj = Object.create(
|
|
345
|
+
const obj = Object.create(AuthFlow.prototype);
|
|
313
346
|
obj.__wbg_ptr = ptr;
|
|
314
|
-
|
|
347
|
+
AuthFlowFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
315
348
|
return obj;
|
|
316
349
|
}
|
|
317
350
|
|
|
318
351
|
__destroy_into_raw() {
|
|
319
352
|
const ptr = this.__wbg_ptr;
|
|
320
353
|
this.__wbg_ptr = 0;
|
|
321
|
-
|
|
354
|
+
AuthFlowFinalization.unregister(this);
|
|
322
355
|
return ptr;
|
|
323
356
|
}
|
|
324
357
|
|
|
325
358
|
free() {
|
|
326
359
|
const ptr = this.__destroy_into_raw();
|
|
327
|
-
wasm.
|
|
360
|
+
wasm.__wbg_authflow_free(ptr, 0);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Start a flow (standalone).
|
|
364
|
+
* Prefer `pubky.startAuthFlow()` to reuse a façade client.
|
|
365
|
+
*
|
|
366
|
+
* @param {string} capabilities
|
|
367
|
+
* Comma-separated capabilities, e.g. `"/pub/app/:rw,/priv/foo.txt:r"`.
|
|
368
|
+
* Each entry must be `"<scope>:<actions>"`, where:
|
|
369
|
+
* - `scope` starts with `/` (e.g. `/pub/example.app/`)
|
|
370
|
+
* - `actions` is any combo of `r` and/or `w` (order is normalized; `wr` -> `rw`)
|
|
371
|
+
* Empty string is allowed (no scopes).
|
|
372
|
+
*
|
|
373
|
+
* @param {string} [relay]
|
|
374
|
+
* Optional HTTP relay base, e.g. `"https://demo.httprelay.io/link/"`.
|
|
375
|
+
* Defaults to the default Synonym-hosted relay when omitted.
|
|
376
|
+
*
|
|
377
|
+
* @returns {AuthFlow}
|
|
378
|
+
* A running auth flow. Call `authorizationUrl()` to show the deep link,
|
|
379
|
+
* then `awaitApproval()` to receive a `Session`.
|
|
380
|
+
* @throws {PubkyJsError}
|
|
381
|
+
* - `{ name: "InvalidInput", message: string }` if any capability entry is invalid
|
|
382
|
+
* or for an invalid relay URL.
|
|
383
|
+
* @example
|
|
384
|
+
* const flow = AuthFlow.start("/pub/my.app/:rw,/pub/pubky.app/:w");
|
|
385
|
+
* renderQRCode(flow.authorizationUrl());
|
|
386
|
+
* const session = await flow.awaitApproval();
|
|
387
|
+
* @param {string} capabilities
|
|
388
|
+
* @param {string | null} [relay]
|
|
389
|
+
* @returns {AuthFlow}
|
|
390
|
+
*/
|
|
391
|
+
static start(capabilities, relay) {
|
|
392
|
+
const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
393
|
+
const len0 = WASM_VECTOR_LEN;
|
|
394
|
+
var ptr1 = isLikeNone(relay) ? 0 : passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
395
|
+
var len1 = WASM_VECTOR_LEN;
|
|
396
|
+
const ret = wasm.authflow_start(ptr0, len0, ptr1, len1);
|
|
397
|
+
if (ret[2]) {
|
|
398
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
399
|
+
}
|
|
400
|
+
return AuthFlow.__wrap(ret[0]);
|
|
328
401
|
}
|
|
329
402
|
/**
|
|
330
|
-
*
|
|
331
|
-
* to request an authentication or authorization token.
|
|
403
|
+
* Return the authorization deep link (URL) to show as QR or open on the signer device.
|
|
332
404
|
*
|
|
333
|
-
*
|
|
405
|
+
* @returns {string} A `pubkyauth://…` or `https://…` URL with channel info.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* renderQr(flow.authorizationUrl());
|
|
334
409
|
* @returns {string}
|
|
335
410
|
*/
|
|
336
|
-
|
|
411
|
+
authorizationUrl() {
|
|
337
412
|
let deferred1_0;
|
|
338
413
|
let deferred1_1;
|
|
339
414
|
try {
|
|
340
|
-
const ret = wasm.
|
|
415
|
+
const ret = wasm.authflow_authorizationUrl(this.__wbg_ptr);
|
|
341
416
|
deferred1_0 = ret[0];
|
|
342
417
|
deferred1_1 = ret[1];
|
|
343
418
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -346,203 +421,239 @@ class AuthRequest {
|
|
|
346
421
|
}
|
|
347
422
|
}
|
|
348
423
|
/**
|
|
349
|
-
*
|
|
424
|
+
* Block until the user approves on their signer device; returns a `Session`.
|
|
425
|
+
*
|
|
426
|
+
* @returns {Promise<Session>}
|
|
427
|
+
* Resolves when approved; rejects on timeout/cancel/network errors.
|
|
428
|
+
*
|
|
429
|
+
* @throws {PubkyJsError}
|
|
430
|
+
* - `RequestError` if relay/network fails
|
|
431
|
+
* - `AuthenticationError` if approval is denied/invalid
|
|
432
|
+
* @returns {Promise<Session>}
|
|
433
|
+
*/
|
|
434
|
+
awaitApproval() {
|
|
435
|
+
const ptr = this.__destroy_into_raw();
|
|
436
|
+
const ret = wasm.authflow_awaitApproval(ptr);
|
|
437
|
+
return ret;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Block until the user approves on their signer device; returns an `AuthToken`.
|
|
350
441
|
*
|
|
351
|
-
*
|
|
442
|
+
* @returns {Promise<AuthToken>}
|
|
443
|
+
* Resolves when approved; rejects on timeout/cancel/network errors.
|
|
444
|
+
*
|
|
445
|
+
* @throws {PubkyJsError}
|
|
446
|
+
* - `RequestError` if relay/network fails
|
|
447
|
+
* @returns {Promise<AuthToken>}
|
|
448
|
+
*/
|
|
449
|
+
awaitToken() {
|
|
450
|
+
const ptr = this.__destroy_into_raw();
|
|
451
|
+
const ret = wasm.authflow_awaitToken(ptr);
|
|
452
|
+
return ret;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Non-blocking single poll step (advanced UIs).
|
|
352
456
|
*
|
|
353
|
-
*
|
|
354
|
-
* @returns {Promise<
|
|
457
|
+
* @returns {Promise<Session|null>} A session if the approval arrived, otherwise `null`.
|
|
458
|
+
* @returns {Promise<Session | undefined>}
|
|
355
459
|
*/
|
|
356
|
-
|
|
357
|
-
const ret = wasm.
|
|
460
|
+
tryPollOnce() {
|
|
461
|
+
const ret = wasm.authflow_tryPollOnce(this.__wbg_ptr);
|
|
358
462
|
return ret;
|
|
359
463
|
}
|
|
360
464
|
}
|
|
361
|
-
module.exports.
|
|
465
|
+
module.exports.AuthFlow = AuthFlow;
|
|
362
466
|
|
|
363
|
-
const
|
|
467
|
+
const AuthTokenFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
364
468
|
? { register: () => {}, unregister: () => {} }
|
|
365
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
366
|
-
|
|
367
|
-
|
|
469
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_authtoken_free(ptr >>> 0, 1));
|
|
470
|
+
/**
|
|
471
|
+
* AuthToken: signed, time-bound proof of key ownership.
|
|
472
|
+
*
|
|
473
|
+
* Returned by [`AuthFlow.awaitToken()`] on the 3rd-party app side when doing **authentication-only**
|
|
474
|
+
* flows (no homeserver session). You can inspect who authenticated and which capabilities were
|
|
475
|
+
* requested, or serialize the token and send it to a backend to verify.
|
|
476
|
+
*
|
|
477
|
+
* ### Typical usage
|
|
478
|
+
* ```js
|
|
479
|
+
* // Start an auth-only flow (no capabilities)
|
|
480
|
+
* const flow = pubky.startAuthFlow("", relay);
|
|
481
|
+
*
|
|
482
|
+
* // Wait for the signer to approve; returns an AuthToken
|
|
483
|
+
* const token = await flow.awaitToken();
|
|
484
|
+
*
|
|
485
|
+
* // Identify the user
|
|
486
|
+
* console.log(token.publicKey().z32());
|
|
487
|
+
*
|
|
488
|
+
* // Optionally forward to a server for verification:
|
|
489
|
+
* await fetch("/api/verify", { method: "POST", body: token.toBytes() });
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* ### Binary format
|
|
493
|
+
* `AuthToken` serializes to a canonical binary (postcard) form; use [`AuthToken.toBytes()`] to get a
|
|
494
|
+
* `Uint8Array`, and [`AuthToken.verify()`] to parse + verify on the server.
|
|
495
|
+
*/
|
|
496
|
+
class AuthToken {
|
|
368
497
|
|
|
369
498
|
static __wrap(ptr) {
|
|
370
499
|
ptr = ptr >>> 0;
|
|
371
|
-
const obj = Object.create(
|
|
500
|
+
const obj = Object.create(AuthToken.prototype);
|
|
372
501
|
obj.__wbg_ptr = ptr;
|
|
373
|
-
|
|
502
|
+
AuthTokenFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
374
503
|
return obj;
|
|
375
504
|
}
|
|
376
505
|
|
|
377
506
|
__destroy_into_raw() {
|
|
378
507
|
const ptr = this.__wbg_ptr;
|
|
379
508
|
this.__wbg_ptr = 0;
|
|
380
|
-
|
|
509
|
+
AuthTokenFinalization.unregister(this);
|
|
381
510
|
return ptr;
|
|
382
511
|
}
|
|
383
512
|
|
|
384
513
|
free() {
|
|
385
514
|
const ptr = this.__destroy_into_raw();
|
|
386
|
-
wasm.
|
|
515
|
+
wasm.__wbg_authtoken_free(ptr, 0);
|
|
387
516
|
}
|
|
388
517
|
/**
|
|
389
|
-
*
|
|
518
|
+
* Parse and verify an `AuthToken` from its canonical bytes.
|
|
390
519
|
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
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.
|
|
520
|
+
* - Verifies version, timestamp freshness window, and signature.
|
|
521
|
+
* - Throws on invalid/expired/unknown version.
|
|
408
522
|
*
|
|
409
|
-
*
|
|
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>}
|
|
433
|
-
*/
|
|
434
|
-
signin(keypair) {
|
|
435
|
-
_assertClass(keypair, Keypair);
|
|
436
|
-
const ret = wasm.client_signin(this.__wbg_ptr, keypair.__wbg_ptr);
|
|
437
|
-
return ret;
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
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.
|
|
523
|
+
* Use this on your server after receiving `Uint8Array` from the client.
|
|
443
524
|
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
525
|
+
* ```js
|
|
526
|
+
* import { AuthToken } from "@synonymdev/pubky";
|
|
527
|
+
*
|
|
528
|
+
* export async function POST(req) {
|
|
529
|
+
* const bytes = new Uint8Array(await req.arrayBuffer());
|
|
530
|
+
* const token = AuthToken.verify(bytes); // throws on failure
|
|
531
|
+
* return new Response(token.publicKey().z32(), { status: 200 });
|
|
532
|
+
* }
|
|
533
|
+
* ```
|
|
534
|
+
* @param {Uint8Array} bytes
|
|
535
|
+
* @returns {AuthToken}
|
|
448
536
|
*/
|
|
449
|
-
|
|
450
|
-
const
|
|
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);
|
|
537
|
+
static verify(bytes) {
|
|
538
|
+
const ret = wasm.authtoken_verify(bytes);
|
|
455
539
|
if (ret[2]) {
|
|
456
540
|
throw takeFromExternrefTable0(ret[1]);
|
|
457
541
|
}
|
|
458
|
-
return
|
|
542
|
+
return AuthToken.__wrap(ret[0]);
|
|
459
543
|
}
|
|
460
544
|
/**
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
545
|
+
* Deserialize an `AuthToken` **without** verification.
|
|
546
|
+
*
|
|
547
|
+
* Most apps should call [`AuthToken.verify()`]. This is provided for tooling or diagnostics
|
|
548
|
+
* where you want to inspect the structure first.
|
|
549
|
+
*
|
|
550
|
+
* Throws if the bytes cannot be parsed as a valid serialized token.
|
|
551
|
+
* @param {Uint8Array} bytes
|
|
552
|
+
* @returns {AuthToken}
|
|
466
553
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return ret;
|
|
554
|
+
static fromBytes(bytes) {
|
|
555
|
+
const ret = wasm.authtoken_fromBytes(bytes);
|
|
556
|
+
if (ret[2]) {
|
|
557
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
558
|
+
}
|
|
559
|
+
return AuthToken.__wrap(ret[0]);
|
|
473
560
|
}
|
|
474
561
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
562
|
+
* Returns the **public key** that authenticated with this token.
|
|
563
|
+
*
|
|
564
|
+
* Use `.z32()` on the returned `PublicKey` to get the string form.
|
|
565
|
+
*
|
|
566
|
+
* ```js
|
|
567
|
+
* const who = token.publicKey().z32();
|
|
568
|
+
* ```
|
|
569
|
+
* @returns {PublicKey}
|
|
480
570
|
*/
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
return ret;
|
|
571
|
+
publicKey() {
|
|
572
|
+
const ret = wasm.authtoken_publicKey(this.__wbg_ptr);
|
|
573
|
+
return PublicKey.__wrap(ret);
|
|
485
574
|
}
|
|
486
575
|
/**
|
|
487
|
-
*
|
|
576
|
+
* Returns the **capabilities** requested by the flow at the time this token was signed.
|
|
488
577
|
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
578
|
+
* Most auth-only flows pass an empty string to `startAuthFlow("", relay)`, so this will
|
|
579
|
+
* commonly be an empty array.
|
|
491
580
|
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
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>}
|
|
581
|
+
* Returns: `string[]`, where each item is the canonical entry `"<scope>:<actions>"`.
|
|
582
|
+
*
|
|
583
|
+
* Example entry: `"/pub/my.app/:rw"`
|
|
584
|
+
* @returns {Array<any>}
|
|
502
585
|
*/
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
_assertClass(host, PublicKey);
|
|
506
|
-
const ret = wasm.client_republishHomeserver(this.__wbg_ptr, keypair.__wbg_ptr, host.__wbg_ptr);
|
|
586
|
+
capabilities() {
|
|
587
|
+
const ret = wasm.authtoken_capabilities(this.__wbg_ptr);
|
|
507
588
|
return ret;
|
|
508
589
|
}
|
|
509
590
|
/**
|
|
510
|
-
*
|
|
591
|
+
* Serialize the token to a `Uint8Array` in its **canonical** (postcard) binary format.
|
|
511
592
|
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
* @
|
|
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>>}
|
|
593
|
+
* Use this to send the token to a backend for verification.
|
|
594
|
+
*
|
|
595
|
+
* ```js
|
|
596
|
+
* const bytes = token.toBytes();
|
|
597
|
+
* await fetch("/api/verify", { method: "POST", body: bytes });
|
|
598
|
+
* ```
|
|
599
|
+
* @returns {Uint8Array}
|
|
524
600
|
*/
|
|
525
|
-
|
|
526
|
-
const
|
|
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);
|
|
601
|
+
toBytes() {
|
|
602
|
+
const ret = wasm.authtoken_toBytes(this.__wbg_ptr);
|
|
531
603
|
return ret;
|
|
532
604
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
605
|
+
}
|
|
606
|
+
module.exports.AuthToken = AuthToken;
|
|
607
|
+
|
|
608
|
+
const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
609
|
+
? { register: () => {}, unregister: () => {} }
|
|
610
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_client_free(ptr >>> 0, 1));
|
|
611
|
+
/**
|
|
612
|
+
* Low-level HTTP bridge used by the Pubky façade and actors.
|
|
613
|
+
*
|
|
614
|
+
* - Supports `pubky://<user-z32>/<abs-path>` and `http(s)://` URLs.
|
|
615
|
+
* - In browsers/undici, passes `credentials: "include"` to send cookies.
|
|
616
|
+
*/
|
|
617
|
+
class Client {
|
|
618
|
+
|
|
619
|
+
static __wrap(ptr) {
|
|
620
|
+
ptr = ptr >>> 0;
|
|
621
|
+
const obj = Object.create(Client.prototype);
|
|
622
|
+
obj.__wbg_ptr = ptr;
|
|
623
|
+
ClientFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
624
|
+
return obj;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
__destroy_into_raw() {
|
|
628
|
+
const ptr = this.__wbg_ptr;
|
|
629
|
+
this.__wbg_ptr = 0;
|
|
630
|
+
ClientFinalization.unregister(this);
|
|
631
|
+
return ptr;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
free() {
|
|
635
|
+
const ptr = this.__destroy_into_raw();
|
|
636
|
+
wasm.__wbg_client_free(ptr, 0);
|
|
543
637
|
}
|
|
544
638
|
/**
|
|
545
|
-
* Create a
|
|
639
|
+
* Create a Pubky HTTP client.
|
|
640
|
+
*
|
|
641
|
+
* @param {PubkyClientConfig} [config]
|
|
642
|
+
* Optional transport overrides:
|
|
643
|
+
* `{ pkarr?: { relays?: string[], request_timeout?: number } }`.
|
|
644
|
+
*
|
|
645
|
+
* @returns {Client}
|
|
646
|
+
* A configured low-level client. Prefer `new Pubky().client()` unless you
|
|
647
|
+
* need custom relays/timeouts.
|
|
648
|
+
*
|
|
649
|
+
* @throws {InvalidInput}
|
|
650
|
+
* If any PKARR relay URL is invalid.
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* const client = new Client({
|
|
654
|
+
* pkarr: { relays: ["https://relay1/","https://relay2/"], request_timeout: 8000 }
|
|
655
|
+
* });
|
|
656
|
+
* const pubky = Pubky.withClient(client);
|
|
546
657
|
* @param {PubkyClientConfig | null} [config_opt]
|
|
547
658
|
*/
|
|
548
659
|
constructor(config_opt) {
|
|
@@ -555,10 +666,23 @@ class Client {
|
|
|
555
666
|
return this;
|
|
556
667
|
}
|
|
557
668
|
/**
|
|
558
|
-
* Create a client
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
669
|
+
* Create a client wired for **local testnet**.
|
|
670
|
+
*
|
|
671
|
+
* Sets PKARR relays to `http://<host>:15411/` and enables WASM `pubky://`
|
|
672
|
+
* mapping for that host.
|
|
673
|
+
*
|
|
674
|
+
* @param {string} [host="localhost"]
|
|
675
|
+
* Testnet hostname or IP.
|
|
676
|
+
*
|
|
677
|
+
* @returns {Client}
|
|
678
|
+
* A client ready to talk to your local testnet.
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* const client = Client.testnet(); // localhost
|
|
682
|
+
* const pubky = Pubky.withClient(client);
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* const client = Client.testnet("docker0"); // custom host
|
|
562
686
|
* @param {string | null} [host]
|
|
563
687
|
* @returns {Client}
|
|
564
688
|
*/
|
|
@@ -566,7 +690,30 @@ class Client {
|
|
|
566
690
|
var ptr0 = isLikeNone(host) ? 0 : passStringToWasm0(host, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
567
691
|
var len0 = WASM_VECTOR_LEN;
|
|
568
692
|
const ret = wasm.client_testnet(ptr0, len0);
|
|
569
|
-
|
|
693
|
+
if (ret[2]) {
|
|
694
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
695
|
+
}
|
|
696
|
+
return Client.__wrap(ret[0]);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Perform a raw fetch. Works with `pubky://` or `http(s)://` URLs.
|
|
700
|
+
*
|
|
701
|
+
* @param {string} url
|
|
702
|
+
* @param {RequestInit=} init Standard fetch options; `credentials: "include"` recommended for session I/O.
|
|
703
|
+
* @returns {Promise<Response>}
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* const client = pubky.client();
|
|
707
|
+
* const res = await client.fetch(`pubky://${user}/pub/app/file.txt`, { method: "PUT", body: "hi", credentials: "include" });
|
|
708
|
+
* @param {string} url
|
|
709
|
+
* @param {any | null} [init]
|
|
710
|
+
* @returns {Promise<Promise<any>>}
|
|
711
|
+
*/
|
|
712
|
+
fetch(url, init) {
|
|
713
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
714
|
+
const len0 = WASM_VECTOR_LEN;
|
|
715
|
+
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(init) ? 0 : addToExternrefTable0(init));
|
|
716
|
+
return ret;
|
|
570
717
|
}
|
|
571
718
|
}
|
|
572
719
|
module.exports.Client = Client;
|
|
@@ -624,9 +771,7 @@ class Keypair {
|
|
|
624
771
|
*/
|
|
625
772
|
secretKey() {
|
|
626
773
|
const ret = wasm.keypair_secretKey(this.__wbg_ptr);
|
|
627
|
-
|
|
628
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
629
|
-
return v1;
|
|
774
|
+
return ret;
|
|
630
775
|
}
|
|
631
776
|
/**
|
|
632
777
|
* Returns the [PublicKey] of this keypair.
|
|
@@ -636,9 +781,345 @@ class Keypair {
|
|
|
636
781
|
const ret = wasm.keypair_publicKey(this.__wbg_ptr);
|
|
637
782
|
return PublicKey.__wrap(ret);
|
|
638
783
|
}
|
|
784
|
+
/**
|
|
785
|
+
* Create a recovery file for this keypair (encrypted with the given passphrase).
|
|
786
|
+
* @param {string} passphrase
|
|
787
|
+
* @returns {Uint8Array}
|
|
788
|
+
*/
|
|
789
|
+
createRecoveryFile(passphrase) {
|
|
790
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
791
|
+
const len0 = WASM_VECTOR_LEN;
|
|
792
|
+
const ret = wasm.keypair_createRecoveryFile(this.__wbg_ptr, ptr0, len0);
|
|
793
|
+
return ret;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Decrypt a recovery file and return a Keypair (decrypted with the given passphrase).
|
|
797
|
+
* @param {Uint8Array} recovery_file
|
|
798
|
+
* @param {string} passphrase
|
|
799
|
+
* @returns {Keypair}
|
|
800
|
+
*/
|
|
801
|
+
static fromRecoveryFile(recovery_file, passphrase) {
|
|
802
|
+
const ptr0 = passArray8ToWasm0(recovery_file, wasm.__wbindgen_malloc);
|
|
803
|
+
const len0 = WASM_VECTOR_LEN;
|
|
804
|
+
const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
805
|
+
const len1 = WASM_VECTOR_LEN;
|
|
806
|
+
const ret = wasm.keypair_fromRecoveryFile(ptr0, len0, ptr1, len1);
|
|
807
|
+
if (ret[2]) {
|
|
808
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
809
|
+
}
|
|
810
|
+
return Keypair.__wrap(ret[0]);
|
|
811
|
+
}
|
|
639
812
|
}
|
|
640
813
|
module.exports.Keypair = Keypair;
|
|
641
814
|
|
|
815
|
+
const PkdnsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
816
|
+
? { register: () => {}, unregister: () => {} }
|
|
817
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_pkdns_free(ptr >>> 0, 1));
|
|
818
|
+
/**
|
|
819
|
+
* Resolve/publish `_pubky` PKDNS records (homeserver pointers).
|
|
820
|
+
*/
|
|
821
|
+
class Pkdns {
|
|
822
|
+
|
|
823
|
+
static __wrap(ptr) {
|
|
824
|
+
ptr = ptr >>> 0;
|
|
825
|
+
const obj = Object.create(Pkdns.prototype);
|
|
826
|
+
obj.__wbg_ptr = ptr;
|
|
827
|
+
PkdnsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
828
|
+
return obj;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
__destroy_into_raw() {
|
|
832
|
+
const ptr = this.__wbg_ptr;
|
|
833
|
+
this.__wbg_ptr = 0;
|
|
834
|
+
PkdnsFinalization.unregister(this);
|
|
835
|
+
return ptr;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
free() {
|
|
839
|
+
const ptr = this.__destroy_into_raw();
|
|
840
|
+
wasm.__wbg_pkdns_free(ptr, 0);
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Read-only PKDNS actor (no keypair; resolve only).
|
|
844
|
+
*/
|
|
845
|
+
constructor() {
|
|
846
|
+
const ret = wasm.pkdns_new();
|
|
847
|
+
if (ret[2]) {
|
|
848
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
849
|
+
}
|
|
850
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
851
|
+
PkdnsFinalization.register(this, this.__wbg_ptr, this);
|
|
852
|
+
return this;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* PKDNS actor with publishing enabled (requires a keypair).
|
|
856
|
+
* @param {Keypair} keypair
|
|
857
|
+
* @returns {Pkdns}
|
|
858
|
+
*/
|
|
859
|
+
static fromKeypair(keypair) {
|
|
860
|
+
_assertClass(keypair, Keypair);
|
|
861
|
+
const ret = wasm.pkdns_fromKeypair(keypair.__wbg_ptr);
|
|
862
|
+
if (ret[2]) {
|
|
863
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
864
|
+
}
|
|
865
|
+
return Pkdns.__wrap(ret[0]);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Resolve the homeserver for a given public key (read-only).
|
|
869
|
+
*
|
|
870
|
+
* @param {PublicKey} user
|
|
871
|
+
* @returns {Promise<string|undefined>} Homeserver public key (z32) or `undefined` if not found.
|
|
872
|
+
* @param {PublicKey} pubky
|
|
873
|
+
* @returns {Promise<string | undefined>}
|
|
874
|
+
*/
|
|
875
|
+
getHomeserverOf(pubky) {
|
|
876
|
+
_assertClass(pubky, PublicKey);
|
|
877
|
+
const ret = wasm.pkdns_getHomeserverOf(this.__wbg_ptr, pubky.__wbg_ptr);
|
|
878
|
+
return ret;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Resolve the homeserver for **this** user (requires keypair).
|
|
882
|
+
*
|
|
883
|
+
* @returns {Promise<string|undefined>} Homeserver public key (z32) or `undefined` if not found.
|
|
884
|
+
* @returns {Promise<string | undefined>}
|
|
885
|
+
*/
|
|
886
|
+
getHomeserver() {
|
|
887
|
+
const ret = wasm.pkdns_getHomeserver(this.__wbg_ptr);
|
|
888
|
+
return ret;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Republish homeserver if record is missing/stale.
|
|
892
|
+
*
|
|
893
|
+
* Requires keypair or to be signer bound.
|
|
894
|
+
*
|
|
895
|
+
* @param {PublicKey=} overrideHost Optional new homeserver to publish (migration).
|
|
896
|
+
* @returns {Promise<void>}
|
|
897
|
+
* @param {PublicKey | null} [host_override]
|
|
898
|
+
* @returns {Promise<void>}
|
|
899
|
+
*/
|
|
900
|
+
publishHomeserverForce(host_override) {
|
|
901
|
+
let ptr0 = 0;
|
|
902
|
+
if (!isLikeNone(host_override)) {
|
|
903
|
+
_assertClass(host_override, PublicKey);
|
|
904
|
+
ptr0 = host_override.__destroy_into_raw();
|
|
905
|
+
}
|
|
906
|
+
const ret = wasm.pkdns_publishHomeserverForce(this.__wbg_ptr, ptr0);
|
|
907
|
+
return ret;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Force publish homeserver immediately (even if fresh).
|
|
911
|
+
*
|
|
912
|
+
* Requires keypair or to be signer bound.
|
|
913
|
+
*
|
|
914
|
+
* @param {PublicKey=} overrideHost Optional new homeserver to publish (migration).
|
|
915
|
+
* @returns {Promise<void>}
|
|
916
|
+
* @param {PublicKey | null} [host_override]
|
|
917
|
+
* @returns {Promise<void>}
|
|
918
|
+
*/
|
|
919
|
+
publishHomeserverIfStale(host_override) {
|
|
920
|
+
let ptr0 = 0;
|
|
921
|
+
if (!isLikeNone(host_override)) {
|
|
922
|
+
_assertClass(host_override, PublicKey);
|
|
923
|
+
ptr0 = host_override.__destroy_into_raw();
|
|
924
|
+
}
|
|
925
|
+
const ret = wasm.pkdns_publishHomeserverIfStale(this.__wbg_ptr, ptr0);
|
|
926
|
+
return ret;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
module.exports.Pkdns = Pkdns;
|
|
930
|
+
|
|
931
|
+
const PubkyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
932
|
+
? { register: () => {}, unregister: () => {} }
|
|
933
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_pubky_free(ptr >>> 0, 1));
|
|
934
|
+
/**
|
|
935
|
+
* High-level entrypoint to the Pubky SDK.
|
|
936
|
+
*/
|
|
937
|
+
class Pubky {
|
|
938
|
+
|
|
939
|
+
static __wrap(ptr) {
|
|
940
|
+
ptr = ptr >>> 0;
|
|
941
|
+
const obj = Object.create(Pubky.prototype);
|
|
942
|
+
obj.__wbg_ptr = ptr;
|
|
943
|
+
PubkyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
944
|
+
return obj;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
__destroy_into_raw() {
|
|
948
|
+
const ptr = this.__wbg_ptr;
|
|
949
|
+
this.__wbg_ptr = 0;
|
|
950
|
+
PubkyFinalization.unregister(this);
|
|
951
|
+
return ptr;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
free() {
|
|
955
|
+
const ptr = this.__destroy_into_raw();
|
|
956
|
+
wasm.__wbg_pubky_free(ptr, 0);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Create a Pubky façade wired for **mainnet** defaults (public relays).
|
|
960
|
+
*
|
|
961
|
+
* @returns {Pubky}
|
|
962
|
+
* A new façade instance. Use this to create signers, start auth flows, etc.
|
|
963
|
+
*
|
|
964
|
+
* @example
|
|
965
|
+
* const pubky = new Pubky();
|
|
966
|
+
* const signer = pubky.signer(Keypair.random());
|
|
967
|
+
*/
|
|
968
|
+
constructor() {
|
|
969
|
+
const ret = wasm.pubky_new();
|
|
970
|
+
if (ret[2]) {
|
|
971
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
972
|
+
}
|
|
973
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
974
|
+
PubkyFinalization.register(this, this.__wbg_ptr, this);
|
|
975
|
+
return this;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Create a Pubky façade preconfigured for a **local testnet**.
|
|
979
|
+
*
|
|
980
|
+
* If `host` is provided, PKARR and HTTP endpoints are derived as `http://<host>:ports/...`.
|
|
981
|
+
* If omitted, `"localhost"` is assumed (handy for `cargo install pubky-testnet`).
|
|
982
|
+
*
|
|
983
|
+
* @param {string=} host Optional host (e.g. `"localhost"`, `"docker-host"`, `"127.0.0.1"`).
|
|
984
|
+
* @returns {Pubky}
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* const pubky = Pubky.testnet(); // localhost default
|
|
988
|
+
* const pubky = Pubky.testnet("docker-host"); // custom hostname/IP
|
|
989
|
+
* @param {string | null} [host]
|
|
990
|
+
* @returns {Pubky}
|
|
991
|
+
*/
|
|
992
|
+
static testnet(host) {
|
|
993
|
+
var ptr0 = isLikeNone(host) ? 0 : passStringToWasm0(host, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
994
|
+
var len0 = WASM_VECTOR_LEN;
|
|
995
|
+
const ret = wasm.pubky_testnet(ptr0, len0);
|
|
996
|
+
if (ret[2]) {
|
|
997
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
998
|
+
}
|
|
999
|
+
return Pubky.__wrap(ret[0]);
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Wrap an existing configured HTTP client into a Pubky façade.
|
|
1003
|
+
*
|
|
1004
|
+
* @param {Client} client A previously constructed client.
|
|
1005
|
+
* @returns {Pubky}
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* const client = Client.testnet();
|
|
1009
|
+
* const pubky = Pubky.withClient(client);
|
|
1010
|
+
* @param {Client} client
|
|
1011
|
+
* @returns {Pubky}
|
|
1012
|
+
*/
|
|
1013
|
+
static withClient(client) {
|
|
1014
|
+
_assertClass(client, Client);
|
|
1015
|
+
const ret = wasm.pubky_withClient(client.__wbg_ptr);
|
|
1016
|
+
return Pubky.__wrap(ret);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Start a **pubkyauth** flow.
|
|
1020
|
+
*
|
|
1021
|
+
* Provide a **capabilities string** and (optionally) a relay base URL.
|
|
1022
|
+
* The capabilities string is a comma-separated list of entries:
|
|
1023
|
+
* `"<scope>:<actions>"`, where:
|
|
1024
|
+
* - `scope` starts with `/` (e.g. `/pub/example.app/`).
|
|
1025
|
+
* - `actions` is any combo of `r` and/or `w` (order normalized; `wr` -> `rw`).
|
|
1026
|
+
* Pass `""` for no scopes (read-only public session).
|
|
1027
|
+
*
|
|
1028
|
+
* @param {string} capabilities Comma-separated caps, e.g. `"/pub/app/:rw,/pub/foo/file:r"`.
|
|
1029
|
+
* @param {string=} relay Optional HTTP relay base (e.g. `"https://…/link/"`).
|
|
1030
|
+
* @returns {AuthFlow}
|
|
1031
|
+
* A running auth flow. Call `authorizationUrl()` to show a QR/deeplink,
|
|
1032
|
+
* then `awaitApproval()` to obtain a `Session`.
|
|
1033
|
+
*
|
|
1034
|
+
* @throws {PubkyJsError}
|
|
1035
|
+
* - `{ name: "InvalidInput" }` for malformed capabilities or bad relay URL
|
|
1036
|
+
* - `{ name: "RequestError" }` if the flow cannot be started (network/relay)
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* const flow = pubky.startAuthFlow("/pub/my.app/:rw");
|
|
1040
|
+
* renderQr(flow.authorizationUrl());
|
|
1041
|
+
* const session = await flow.awaitApproval();
|
|
1042
|
+
* @param {string} capabilities
|
|
1043
|
+
* @param {string | null} [relay]
|
|
1044
|
+
* @returns {AuthFlow}
|
|
1045
|
+
*/
|
|
1046
|
+
startAuthFlow(capabilities, relay) {
|
|
1047
|
+
const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1048
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1049
|
+
var ptr1 = isLikeNone(relay) ? 0 : passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1050
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1051
|
+
const ret = wasm.pubky_startAuthFlow(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1052
|
+
if (ret[2]) {
|
|
1053
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1054
|
+
}
|
|
1055
|
+
return AuthFlow.__wrap(ret[0]);
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Create a `Signer` from an existing `Keypair`.
|
|
1059
|
+
*
|
|
1060
|
+
* @param {Keypair} keypair The user’s keys.
|
|
1061
|
+
* @returns {Signer}
|
|
1062
|
+
*
|
|
1063
|
+
* @example
|
|
1064
|
+
* const signer = pubky.signer(Keypair.random());
|
|
1065
|
+
* const session = await signer.signup(homeserverPk, null);
|
|
1066
|
+
* @param {Keypair} keypair
|
|
1067
|
+
* @returns {Signer}
|
|
1068
|
+
*/
|
|
1069
|
+
signer(keypair) {
|
|
1070
|
+
_assertClass(keypair, Keypair);
|
|
1071
|
+
var ptr0 = keypair.__destroy_into_raw();
|
|
1072
|
+
const ret = wasm.pubky_signer(this.__wbg_ptr, ptr0);
|
|
1073
|
+
return Signer.__wrap(ret);
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Public, unauthenticated storage API.
|
|
1077
|
+
*
|
|
1078
|
+
* Use for **read-only** public access via addressed paths:
|
|
1079
|
+
* `"<user-z32>/pub/…"`.
|
|
1080
|
+
*
|
|
1081
|
+
* @returns {PublicStorage}
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* const pub = pubky.publicStorage();
|
|
1085
|
+
* const text = await pub.getText(`${userPk.z32()}/pub/example.com/hello.txt`);
|
|
1086
|
+
* @returns {PublicStorage}
|
|
1087
|
+
*/
|
|
1088
|
+
publicStorage() {
|
|
1089
|
+
const ret = wasm.pubky_publicStorage(this.__wbg_ptr);
|
|
1090
|
+
return PublicStorage.__wrap(ret);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Read-only PKDNS (Pkarr) resolver.
|
|
1094
|
+
*
|
|
1095
|
+
* @returns {Pkdns}
|
|
1096
|
+
*
|
|
1097
|
+
* @example
|
|
1098
|
+
* const dns = pubky.pkdns();
|
|
1099
|
+
* const homeserver = await dns.getHomeserverOf(userPk);
|
|
1100
|
+
* @returns {Pkdns}
|
|
1101
|
+
*/
|
|
1102
|
+
pkdns() {
|
|
1103
|
+
const ret = wasm.pubky_pkdns(this.__wbg_ptr);
|
|
1104
|
+
return Pkdns.__wrap(ret);
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Access the underlying HTTP client (advanced).
|
|
1108
|
+
*
|
|
1109
|
+
* @returns {Client}
|
|
1110
|
+
* Use this for low-level `fetch()` calls or testing with raw URLs.
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* const r = await pubky.client().fetch(`pubky://${user}/pub/app/file.txt`, { credentials: "include" });
|
|
1114
|
+
* @returns {Client}
|
|
1115
|
+
*/
|
|
1116
|
+
client() {
|
|
1117
|
+
const ret = wasm.pubky_client(this.__wbg_ptr);
|
|
1118
|
+
return Client.__wrap(ret);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
module.exports.Pubky = Pubky;
|
|
1122
|
+
|
|
642
1123
|
const PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
643
1124
|
? { register: () => {}, unregister: () => {} }
|
|
644
1125
|
: new FinalizationRegistry(ptr => wasm.__wbg_publickey_free(ptr >>> 0, 1));
|
|
@@ -666,202 +1147,775 @@ class PublicKey {
|
|
|
666
1147
|
}
|
|
667
1148
|
/**
|
|
668
1149
|
* Convert the PublicKey to Uint8Array
|
|
669
|
-
* @deprecated Use `toUint8Array` instead
|
|
670
1150
|
* @returns {Uint8Array}
|
|
671
1151
|
*/
|
|
672
|
-
|
|
673
|
-
const ret = wasm.
|
|
674
|
-
|
|
675
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
676
|
-
return v1;
|
|
1152
|
+
toUint8Array() {
|
|
1153
|
+
const ret = wasm.publickey_toUint8Array(this.__wbg_ptr);
|
|
1154
|
+
return ret;
|
|
677
1155
|
}
|
|
678
1156
|
/**
|
|
679
|
-
*
|
|
680
|
-
* @returns {
|
|
1157
|
+
* Returns the z-base32 encoding of this public key
|
|
1158
|
+
* @returns {string}
|
|
681
1159
|
*/
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
1160
|
+
z32() {
|
|
1161
|
+
let deferred1_0;
|
|
1162
|
+
let deferred1_1;
|
|
1163
|
+
try {
|
|
1164
|
+
const ret = wasm.publickey_z32(this.__wbg_ptr);
|
|
1165
|
+
deferred1_0 = ret[0];
|
|
1166
|
+
deferred1_1 = ret[1];
|
|
1167
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1168
|
+
} finally {
|
|
1169
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* @throws
|
|
1174
|
+
* @param {string} value
|
|
1175
|
+
* @returns {PublicKey}
|
|
1176
|
+
*/
|
|
1177
|
+
static from(value) {
|
|
1178
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1179
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1180
|
+
const ret = wasm.publickey_from(ptr0, len0);
|
|
1181
|
+
if (ret[2]) {
|
|
1182
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1183
|
+
}
|
|
1184
|
+
return PublicKey.__wrap(ret[0]);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
module.exports.PublicKey = PublicKey;
|
|
1188
|
+
|
|
1189
|
+
const PublicStorageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1190
|
+
? { register: () => {}, unregister: () => {} }
|
|
1191
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_publicstorage_free(ptr >>> 0, 1));
|
|
1192
|
+
/**
|
|
1193
|
+
* Read-only public storage using addressed paths (`"<user-z32>/pub/...")`.
|
|
1194
|
+
*/
|
|
1195
|
+
class PublicStorage {
|
|
1196
|
+
|
|
1197
|
+
static __wrap(ptr) {
|
|
1198
|
+
ptr = ptr >>> 0;
|
|
1199
|
+
const obj = Object.create(PublicStorage.prototype);
|
|
1200
|
+
obj.__wbg_ptr = ptr;
|
|
1201
|
+
PublicStorageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1202
|
+
return obj;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
__destroy_into_raw() {
|
|
1206
|
+
const ptr = this.__wbg_ptr;
|
|
1207
|
+
this.__wbg_ptr = 0;
|
|
1208
|
+
PublicStorageFinalization.unregister(this);
|
|
1209
|
+
return ptr;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
free() {
|
|
1213
|
+
const ptr = this.__destroy_into_raw();
|
|
1214
|
+
wasm.__wbg_publicstorage_free(ptr, 0);
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Construct PublicStorage using global client (mainline relays).
|
|
1218
|
+
*/
|
|
1219
|
+
constructor() {
|
|
1220
|
+
const ret = wasm.publicstorage_new();
|
|
1221
|
+
if (ret[2]) {
|
|
1222
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1223
|
+
}
|
|
1224
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
1225
|
+
PublicStorageFinalization.register(this, this.__wbg_ptr, this);
|
|
1226
|
+
return this;
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* List a directory. Results are `pubky://…` absolute URLs.
|
|
1230
|
+
*
|
|
1231
|
+
* @param {string} address Addressed directory (must end with `/`).
|
|
1232
|
+
* @param {string|null=} cursor Optional suffix or full URL to start **after**.
|
|
1233
|
+
* @param {boolean=} reverse Default `false`. When `true`, newest/lexicographically-last first.
|
|
1234
|
+
* @param {number=} limit Optional result limit.
|
|
1235
|
+
* @param {boolean=} shallow Default `false`. When `true`, lists only first-level entries.
|
|
1236
|
+
* @returns {Promise<string[]>}
|
|
1237
|
+
* @param {string} address
|
|
1238
|
+
* @param {string | null} [cursor]
|
|
1239
|
+
* @param {boolean | null} [reverse]
|
|
1240
|
+
* @param {number | null} [limit]
|
|
1241
|
+
* @param {boolean | null} [shallow]
|
|
1242
|
+
* @returns {Promise<string[]>}
|
|
1243
|
+
*/
|
|
1244
|
+
list(address, cursor, reverse, limit, shallow) {
|
|
1245
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1246
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1247
|
+
var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1248
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1249
|
+
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);
|
|
1250
|
+
return ret;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Fetch bytes from an addressed path.
|
|
1254
|
+
*
|
|
1255
|
+
* @param {string} address
|
|
1256
|
+
* @returns {Promise<Uint8Array>}
|
|
1257
|
+
* @param {string} address
|
|
1258
|
+
* @returns {Promise<Uint8Array>}
|
|
1259
|
+
*/
|
|
1260
|
+
getBytes(address) {
|
|
1261
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1262
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1263
|
+
const ret = wasm.publicstorage_getBytes(this.__wbg_ptr, ptr0, len0);
|
|
1264
|
+
return ret;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Fetch text from an addressed path as UTF-8 text.
|
|
1268
|
+
*
|
|
1269
|
+
* @param {string} address
|
|
1270
|
+
* @returns {Promise<string>}
|
|
1271
|
+
* @param {string} address
|
|
1272
|
+
* @returns {Promise<string>}
|
|
1273
|
+
*/
|
|
1274
|
+
getText(address) {
|
|
1275
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1277
|
+
const ret = wasm.publicstorage_getText(this.__wbg_ptr, ptr0, len0);
|
|
1278
|
+
return ret;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Fetch JSON from an addressed path.
|
|
1282
|
+
*
|
|
1283
|
+
* @param {string} address `"<user-z32>/pub/.../file.json"` or `pubky://<user>/pub/...`.
|
|
1284
|
+
* @returns {Promise<any>}
|
|
1285
|
+
* @param {string} address
|
|
1286
|
+
* @returns {Promise<any>}
|
|
1287
|
+
*/
|
|
1288
|
+
getJson(address) {
|
|
1289
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1290
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1291
|
+
const ret = wasm.publicstorage_getJson(this.__wbg_ptr, ptr0, len0);
|
|
1292
|
+
return ret;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Check if a path exists.
|
|
1296
|
+
*
|
|
1297
|
+
* @param {string} address
|
|
1298
|
+
* @returns {Promise<boolean>}
|
|
1299
|
+
* @param {string} address
|
|
1300
|
+
* @returns {Promise<boolean>}
|
|
1301
|
+
*/
|
|
1302
|
+
exists(address) {
|
|
1303
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1304
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1305
|
+
const ret = wasm.publicstorage_exists(this.__wbg_ptr, ptr0, len0);
|
|
1306
|
+
return ret;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Get metadata for an address
|
|
1310
|
+
*
|
|
1311
|
+
* @param {string} address `"<user-z32>/pub/.../file.json"` or `pubky://<user>/pub/...`.
|
|
1312
|
+
* @returns {Promise<ResourceStats|undefined>} `undefined` if the resource does not exist.
|
|
1313
|
+
* @throws {PubkyJsError} On invalid input or transport/server errors.
|
|
1314
|
+
* @param {string} address
|
|
1315
|
+
* @returns {Promise<ResourceStats | undefined>}
|
|
1316
|
+
*/
|
|
1317
|
+
stats(address) {
|
|
1318
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1320
|
+
const ret = wasm.publicstorage_stats(this.__wbg_ptr, ptr0, len0);
|
|
1321
|
+
return ret;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
module.exports.PublicStorage = PublicStorage;
|
|
1325
|
+
|
|
1326
|
+
const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1327
|
+
? { register: () => {}, unregister: () => {} }
|
|
1328
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr >>> 0, 1));
|
|
1329
|
+
/**
|
|
1330
|
+
* An authenticated context “as the user”.
|
|
1331
|
+
* - Use `storage()` for reads/writes (absolute paths like `/pub/app/file.txt`)
|
|
1332
|
+
* - Cookie is managed automatically by the underlying fetch client
|
|
1333
|
+
*/
|
|
1334
|
+
class Session {
|
|
1335
|
+
|
|
1336
|
+
static __wrap(ptr) {
|
|
1337
|
+
ptr = ptr >>> 0;
|
|
1338
|
+
const obj = Object.create(Session.prototype);
|
|
1339
|
+
obj.__wbg_ptr = ptr;
|
|
1340
|
+
SessionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1341
|
+
return obj;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
__destroy_into_raw() {
|
|
1345
|
+
const ptr = this.__wbg_ptr;
|
|
1346
|
+
this.__wbg_ptr = 0;
|
|
1347
|
+
SessionFinalization.unregister(this);
|
|
1348
|
+
return ptr;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
free() {
|
|
1352
|
+
const ptr = this.__destroy_into_raw();
|
|
1353
|
+
wasm.__wbg_session_free(ptr, 0);
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Retrieve immutable info about this session (user & capabilities).
|
|
1357
|
+
*
|
|
1358
|
+
* @returns {SessionInfo}
|
|
1359
|
+
* @returns {SessionInfo}
|
|
1360
|
+
*/
|
|
1361
|
+
info() {
|
|
1362
|
+
const ret = wasm.session_info(this.__wbg_ptr);
|
|
1363
|
+
return SessionInfo.__wrap(ret);
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Access the session-scoped storage API (read/write).
|
|
1367
|
+
*
|
|
1368
|
+
* @returns {SessionStorage}
|
|
1369
|
+
* @returns {SessionStorage}
|
|
1370
|
+
*/
|
|
1371
|
+
storage() {
|
|
1372
|
+
const ret = wasm.session_storage(this.__wbg_ptr);
|
|
1373
|
+
return SessionStorage.__wrap(ret);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Invalidate the session on the server (clears server cookie).
|
|
1377
|
+
* It also consumes this JS/Wasm Session. Further calls will fail.
|
|
1378
|
+
*
|
|
1379
|
+
* @returns {Promise<void>}
|
|
1380
|
+
* @returns {Promise<void>}
|
|
1381
|
+
*/
|
|
1382
|
+
signout() {
|
|
1383
|
+
const ptr = this.__destroy_into_raw();
|
|
1384
|
+
const ret = wasm.session_signout(ptr);
|
|
1385
|
+
return ret;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
module.exports.Session = Session;
|
|
1389
|
+
|
|
1390
|
+
const SessionInfoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1391
|
+
? { register: () => {}, unregister: () => {} }
|
|
1392
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sessioninfo_free(ptr >>> 0, 1));
|
|
1393
|
+
/**
|
|
1394
|
+
* Static snapshot of session metadata.
|
|
1395
|
+
*/
|
|
1396
|
+
class SessionInfo {
|
|
1397
|
+
|
|
1398
|
+
static __wrap(ptr) {
|
|
1399
|
+
ptr = ptr >>> 0;
|
|
1400
|
+
const obj = Object.create(SessionInfo.prototype);
|
|
1401
|
+
obj.__wbg_ptr = ptr;
|
|
1402
|
+
SessionInfoFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1403
|
+
return obj;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
__destroy_into_raw() {
|
|
1407
|
+
const ptr = this.__wbg_ptr;
|
|
1408
|
+
this.__wbg_ptr = 0;
|
|
1409
|
+
SessionInfoFinalization.unregister(this);
|
|
1410
|
+
return ptr;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
free() {
|
|
1414
|
+
const ptr = this.__destroy_into_raw();
|
|
1415
|
+
wasm.__wbg_sessioninfo_free(ptr, 0);
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* The user’s public key for this session.
|
|
1419
|
+
*
|
|
1420
|
+
* @returns {PublicKey}
|
|
1421
|
+
* @returns {PublicKey}
|
|
1422
|
+
*/
|
|
1423
|
+
publicKey() {
|
|
1424
|
+
const ret = wasm.sessioninfo_publicKey(this.__wbg_ptr);
|
|
1425
|
+
return PublicKey.__wrap(ret);
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Effective capabilities granted to this session.
|
|
1429
|
+
*
|
|
1430
|
+
* @returns {string[]} Normalized capability entries (e.g. `"/pub/app/:rw"`).
|
|
1431
|
+
* @returns {string[]}
|
|
1432
|
+
*/
|
|
1433
|
+
capabilities() {
|
|
1434
|
+
const ret = wasm.sessioninfo_capabilities(this.__wbg_ptr);
|
|
1435
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1436
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
686
1437
|
return v1;
|
|
687
1438
|
}
|
|
1439
|
+
}
|
|
1440
|
+
module.exports.SessionInfo = SessionInfo;
|
|
1441
|
+
|
|
1442
|
+
const SessionStorageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1443
|
+
? { register: () => {}, unregister: () => {} }
|
|
1444
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sessionstorage_free(ptr >>> 0, 1));
|
|
1445
|
+
/**
|
|
1446
|
+
* Read/write storage scoped to **your** session (absolute paths: `/pub/...`).
|
|
1447
|
+
*/
|
|
1448
|
+
class SessionStorage {
|
|
1449
|
+
|
|
1450
|
+
static __wrap(ptr) {
|
|
1451
|
+
ptr = ptr >>> 0;
|
|
1452
|
+
const obj = Object.create(SessionStorage.prototype);
|
|
1453
|
+
obj.__wbg_ptr = ptr;
|
|
1454
|
+
SessionStorageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1455
|
+
return obj;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
__destroy_into_raw() {
|
|
1459
|
+
const ptr = this.__wbg_ptr;
|
|
1460
|
+
this.__wbg_ptr = 0;
|
|
1461
|
+
SessionStorageFinalization.unregister(this);
|
|
1462
|
+
return ptr;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
free() {
|
|
1466
|
+
const ptr = this.__destroy_into_raw();
|
|
1467
|
+
wasm.__wbg_sessionstorage_free(ptr, 0);
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* List a directory (absolute session path). Returns `pubky://…` URLs.
|
|
1471
|
+
*
|
|
1472
|
+
* @param {string} path Must end with `/`.
|
|
1473
|
+
* @param {string|null=} cursor Optional suffix or full URL to start **after**.
|
|
1474
|
+
* @param {boolean=} reverse Default `false`.
|
|
1475
|
+
* @param {number=} limit Optional result limit.
|
|
1476
|
+
* @param {boolean=} shallow Default `false`.
|
|
1477
|
+
* @returns {Promise<string[]>}
|
|
1478
|
+
* @param {string} path
|
|
1479
|
+
* @param {string | null} [cursor]
|
|
1480
|
+
* @param {boolean | null} [reverse]
|
|
1481
|
+
* @param {number | null} [limit]
|
|
1482
|
+
* @param {boolean | null} [shallow]
|
|
1483
|
+
* @returns {Promise<string[]>}
|
|
1484
|
+
*/
|
|
1485
|
+
list(path, cursor, reverse, limit, shallow) {
|
|
1486
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1487
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1488
|
+
var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1489
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1490
|
+
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);
|
|
1491
|
+
return ret;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* GET bytes from an absolute session path.
|
|
1495
|
+
*
|
|
1496
|
+
* @param {string} path
|
|
1497
|
+
* @returns {Promise<Uint8Array>}
|
|
1498
|
+
* @param {string} path
|
|
1499
|
+
* @returns {Promise<Uint8Array>}
|
|
1500
|
+
*/
|
|
1501
|
+
getBytes(path) {
|
|
1502
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1503
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1504
|
+
const ret = wasm.sessionstorage_getBytes(this.__wbg_ptr, ptr0, len0);
|
|
1505
|
+
return ret;
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* GET text from an absolute session path.
|
|
1509
|
+
*
|
|
1510
|
+
* @param {string} path
|
|
1511
|
+
* @returns {Promise<string>}
|
|
1512
|
+
* @param {string} path
|
|
1513
|
+
* @returns {Promise<string>}
|
|
1514
|
+
*/
|
|
1515
|
+
getText(path) {
|
|
1516
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1517
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1518
|
+
const ret = wasm.sessionstorage_getText(this.__wbg_ptr, ptr0, len0);
|
|
1519
|
+
return ret;
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* GET JSON from an absolute session path.
|
|
1523
|
+
*
|
|
1524
|
+
* @param {string} path
|
|
1525
|
+
* @returns {Promise<any>}
|
|
1526
|
+
* @param {string} addr
|
|
1527
|
+
* @returns {Promise<any>}
|
|
1528
|
+
*/
|
|
1529
|
+
getJson(addr) {
|
|
1530
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1531
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1532
|
+
const ret = wasm.sessionstorage_getJson(this.__wbg_ptr, ptr0, len0);
|
|
1533
|
+
return ret;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Check existence.
|
|
1537
|
+
*
|
|
1538
|
+
* @param {string} path
|
|
1539
|
+
* @returns {Promise<boolean>}
|
|
1540
|
+
* @param {string} path
|
|
1541
|
+
* @returns {Promise<boolean>}
|
|
1542
|
+
*/
|
|
1543
|
+
exists(path) {
|
|
1544
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1545
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1546
|
+
const ret = wasm.sessionstorage_exists(this.__wbg_ptr, ptr0, len0);
|
|
1547
|
+
return ret;
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Get metadata for an absolute, session-scoped path (e.g. `"/pub/app/file.json"`).
|
|
1551
|
+
*
|
|
1552
|
+
* @param {string} path Absolute path under your user (starts with `/`).
|
|
1553
|
+
* @returns {Promise<ResourceStats|undefined>} `undefined` if the resource does not exist.
|
|
1554
|
+
* @throws {PubkyJsError} On invalid input or transport/server errors.
|
|
1555
|
+
* @param {string} path
|
|
1556
|
+
* @returns {Promise<ResourceStats | undefined>}
|
|
1557
|
+
*/
|
|
1558
|
+
stats(path) {
|
|
1559
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1560
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1561
|
+
const ret = wasm.sessionstorage_stats(this.__wbg_ptr, ptr0, len0);
|
|
1562
|
+
return ret;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* PUT binary at an absolute session path.
|
|
1566
|
+
*
|
|
1567
|
+
* @param {string} path
|
|
1568
|
+
* @param {Uint8Array} bytes
|
|
1569
|
+
* @returns {Promise<void>}
|
|
1570
|
+
* @param {string} path
|
|
1571
|
+
* @param {Uint8Array} body
|
|
1572
|
+
* @returns {Promise<void>}
|
|
1573
|
+
*/
|
|
1574
|
+
putBytes(path, body) {
|
|
1575
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1576
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1577
|
+
const ptr1 = passArray8ToWasm0(body, wasm.__wbindgen_malloc);
|
|
1578
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1579
|
+
const ret = wasm.sessionstorage_putBytes(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1580
|
+
return ret;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* PUT text at an absolute session path.
|
|
1584
|
+
*
|
|
1585
|
+
* @param {string} path
|
|
1586
|
+
* @param {string} text
|
|
1587
|
+
* @returns {Promise<void>}
|
|
1588
|
+
* @param {string} path
|
|
1589
|
+
* @param {string} body
|
|
1590
|
+
* @returns {Promise<void>}
|
|
1591
|
+
*/
|
|
1592
|
+
putText(path, body) {
|
|
1593
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1594
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1595
|
+
const ptr1 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1596
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1597
|
+
const ret = wasm.sessionstorage_putText(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1598
|
+
return ret;
|
|
1599
|
+
}
|
|
688
1600
|
/**
|
|
689
|
-
*
|
|
690
|
-
*
|
|
1601
|
+
* PUT JSON at an absolute session path.
|
|
1602
|
+
*
|
|
1603
|
+
* @param {string} path Absolute path (e.g. `"/pub/app/data.json"`).
|
|
1604
|
+
* @param {any} value JSON-serializable value.
|
|
1605
|
+
* @returns {Promise<void>}
|
|
1606
|
+
* @param {string} path
|
|
1607
|
+
* @param {any} body
|
|
1608
|
+
* @returns {Promise<void>}
|
|
691
1609
|
*/
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
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);
|
|
702
|
-
}
|
|
1610
|
+
putJson(path, body) {
|
|
1611
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1612
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1613
|
+
const ret = wasm.sessionstorage_putJson(this.__wbg_ptr, ptr0, len0, body);
|
|
1614
|
+
return ret;
|
|
703
1615
|
}
|
|
704
1616
|
/**
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
* @
|
|
1617
|
+
* Delete a path (file or empty directory).
|
|
1618
|
+
*
|
|
1619
|
+
* @param {string} path
|
|
1620
|
+
* @returns {Promise<void>}
|
|
1621
|
+
* @param {string} path
|
|
1622
|
+
* @returns {Promise<void>}
|
|
708
1623
|
*/
|
|
709
|
-
|
|
710
|
-
const ptr0 = passStringToWasm0(
|
|
1624
|
+
delete(path) {
|
|
1625
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
711
1626
|
const len0 = WASM_VECTOR_LEN;
|
|
712
|
-
const ret = wasm.
|
|
713
|
-
|
|
714
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
715
|
-
}
|
|
716
|
-
return PublicKey.__wrap(ret[0]);
|
|
1627
|
+
const ret = wasm.sessionstorage_delete(this.__wbg_ptr, ptr0, len0);
|
|
1628
|
+
return ret;
|
|
717
1629
|
}
|
|
718
1630
|
}
|
|
719
|
-
module.exports.
|
|
1631
|
+
module.exports.SessionStorage = SessionStorage;
|
|
720
1632
|
|
|
721
|
-
const
|
|
1633
|
+
const SignerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
722
1634
|
? { register: () => {}, unregister: () => {} }
|
|
723
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
724
|
-
|
|
725
|
-
|
|
1635
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_signer_free(ptr >>> 0, 1));
|
|
1636
|
+
/**
|
|
1637
|
+
* Holds a user’s `Keypair` and performs identity operations:
|
|
1638
|
+
* - `signup` creates a new homeserver user.
|
|
1639
|
+
* - `signin` creates a homeserver session for an existing user.
|
|
1640
|
+
* - Approve pubkyauth requests
|
|
1641
|
+
* - Publish PKDNS when signer-bound
|
|
1642
|
+
*/
|
|
1643
|
+
class Signer {
|
|
726
1644
|
|
|
727
1645
|
static __wrap(ptr) {
|
|
728
1646
|
ptr = ptr >>> 0;
|
|
729
|
-
const obj = Object.create(
|
|
1647
|
+
const obj = Object.create(Signer.prototype);
|
|
730
1648
|
obj.__wbg_ptr = ptr;
|
|
731
|
-
|
|
1649
|
+
SignerFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
732
1650
|
return obj;
|
|
733
1651
|
}
|
|
734
1652
|
|
|
735
1653
|
__destroy_into_raw() {
|
|
736
1654
|
const ptr = this.__wbg_ptr;
|
|
737
1655
|
this.__wbg_ptr = 0;
|
|
738
|
-
|
|
1656
|
+
SignerFinalization.unregister(this);
|
|
739
1657
|
return ptr;
|
|
740
1658
|
}
|
|
741
1659
|
|
|
742
1660
|
free() {
|
|
743
1661
|
const ptr = this.__destroy_into_raw();
|
|
744
|
-
wasm.
|
|
1662
|
+
wasm.__wbg_signer_free(ptr, 0);
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Create a signer from a `Keypair` (prefer `pubky.signer(kp)`).
|
|
1666
|
+
*
|
|
1667
|
+
* @param {Keypair} keypair
|
|
1668
|
+
* @returns {Signer}
|
|
1669
|
+
* @param {Keypair} keypair
|
|
1670
|
+
* @returns {Signer}
|
|
1671
|
+
*/
|
|
1672
|
+
static fromKeypair(keypair) {
|
|
1673
|
+
_assertClass(keypair, Keypair);
|
|
1674
|
+
const ret = wasm.signer_fromKeypair(keypair.__wbg_ptr);
|
|
1675
|
+
return Signer.__wrap(ret);
|
|
745
1676
|
}
|
|
746
1677
|
/**
|
|
747
|
-
*
|
|
1678
|
+
* Get the public key of this signer.
|
|
1679
|
+
*
|
|
1680
|
+
* @returns {PublicKey}
|
|
748
1681
|
* @returns {PublicKey}
|
|
749
1682
|
*/
|
|
750
|
-
|
|
751
|
-
const ret = wasm.
|
|
1683
|
+
publicKey() {
|
|
1684
|
+
const ret = wasm.signer_publicKey(this.__wbg_ptr);
|
|
752
1685
|
return PublicKey.__wrap(ret);
|
|
753
1686
|
}
|
|
754
1687
|
/**
|
|
755
|
-
*
|
|
756
|
-
*
|
|
1688
|
+
* Sign up at a homeserver. Returns a ready `Session`.
|
|
1689
|
+
*
|
|
1690
|
+
* Creates a valid homeserver Session with root capabilities
|
|
1691
|
+
*
|
|
1692
|
+
* @param {PublicKey} homeserver The homeserver’s public key.
|
|
1693
|
+
* @param {string|null} signupToken Invite/registration token or `null`.
|
|
1694
|
+
* @returns {Promise<Session>}
|
|
1695
|
+
*
|
|
1696
|
+
* @throws {PubkyJsError}
|
|
1697
|
+
* - `AuthenticationError` (bad/expired token)
|
|
1698
|
+
* - `RequestError` (network/server)
|
|
1699
|
+
* @param {PublicKey} homeserver
|
|
1700
|
+
* @param {string | null} [signup_token]
|
|
1701
|
+
* @returns {Promise<Session>}
|
|
757
1702
|
*/
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
var
|
|
761
|
-
|
|
762
|
-
|
|
1703
|
+
signup(homeserver, signup_token) {
|
|
1704
|
+
_assertClass(homeserver, PublicKey);
|
|
1705
|
+
var ptr0 = isLikeNone(signup_token) ? 0 : passStringToWasm0(signup_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1706
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1707
|
+
const ret = wasm.signer_signup(this.__wbg_ptr, homeserver.__wbg_ptr, ptr0, len0);
|
|
1708
|
+
return ret;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Fast sign-in for a returning user. Publishes PKDNS in the background.
|
|
1712
|
+
*
|
|
1713
|
+
* Creates a valid homeserver Session with root capabilities
|
|
1714
|
+
*
|
|
1715
|
+
* @returns {Promise<Session>}
|
|
1716
|
+
*
|
|
1717
|
+
* @throws {PubkyJsError}
|
|
1718
|
+
* @returns {Promise<Session>}
|
|
1719
|
+
*/
|
|
1720
|
+
signin() {
|
|
1721
|
+
const ret = wasm.signer_signin(this.__wbg_ptr);
|
|
1722
|
+
return ret;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Blocking sign-in. Waits for PKDNS publish to complete (slower; safer).
|
|
1726
|
+
*
|
|
1727
|
+
* Creates a valid homeserver Session with root capabilities
|
|
1728
|
+
*
|
|
1729
|
+
* @returns {Promise<Session>}
|
|
1730
|
+
* @returns {Promise<Session>}
|
|
1731
|
+
*/
|
|
1732
|
+
signinBlocking() {
|
|
1733
|
+
const ret = wasm.signer_signinBlocking(this.__wbg_ptr);
|
|
1734
|
+
return ret;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Approve a `pubkyauth://` request URL (encrypts & POSTs the signed AuthToken).
|
|
1738
|
+
* @param {string} pubkyauth_url
|
|
1739
|
+
* @returns {Promise<void>}
|
|
1740
|
+
*/
|
|
1741
|
+
approveAuthRequest(pubkyauth_url) {
|
|
1742
|
+
const ptr0 = passStringToWasm0(pubkyauth_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1743
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1744
|
+
const ret = wasm.signer_approveAuthRequest(this.__wbg_ptr, ptr0, len0);
|
|
1745
|
+
return ret;
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Get a PKDNS actor bound to this signer's client & keypair (publishing enabled).
|
|
1749
|
+
*
|
|
1750
|
+
* @returns {Pkdns}
|
|
1751
|
+
* @returns {Pkdns}
|
|
1752
|
+
*/
|
|
1753
|
+
pkdns() {
|
|
1754
|
+
const ret = wasm.signer_pkdns(this.__wbg_ptr);
|
|
1755
|
+
return Pkdns.__wrap(ret);
|
|
763
1756
|
}
|
|
764
1757
|
}
|
|
765
|
-
module.exports.
|
|
1758
|
+
module.exports.Signer = Signer;
|
|
766
1759
|
|
|
767
|
-
module.exports.
|
|
768
|
-
arg0
|
|
1760
|
+
module.exports.__wbg_Error_0497d5bdba9362e5 = function(arg0, arg1) {
|
|
1761
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1762
|
+
return ret;
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
1766
|
+
const ret = String(arg1);
|
|
1767
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1768
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1769
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1770
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
769
1771
|
};
|
|
770
1772
|
|
|
771
|
-
module.exports.
|
|
1773
|
+
module.exports.__wbg_abort_18ba44d46e13d7fe = function(arg0) {
|
|
772
1774
|
arg0.abort();
|
|
773
1775
|
};
|
|
774
1776
|
|
|
775
|
-
module.exports.
|
|
1777
|
+
module.exports.__wbg_abort_4198a1129c47f21a = function(arg0, arg1) {
|
|
1778
|
+
arg0.abort(arg1);
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
module.exports.__wbg_append_0342728346e47425 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
776
1782
|
arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
777
1783
|
}, arguments) };
|
|
778
1784
|
|
|
779
|
-
module.exports.
|
|
1785
|
+
module.exports.__wbg_arrayBuffer_d58b858456021d7f = function() { return handleError(function (arg0) {
|
|
780
1786
|
const ret = arg0.arrayBuffer();
|
|
781
1787
|
return ret;
|
|
782
1788
|
}, arguments) };
|
|
783
1789
|
|
|
784
|
-
module.exports.
|
|
1790
|
+
module.exports.__wbg_authtoken_new = function(arg0) {
|
|
1791
|
+
const ret = AuthToken.__wrap(arg0);
|
|
1792
|
+
return ret;
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
module.exports.__wbg_buffer_a1a27a0dfa70165d = function(arg0) {
|
|
785
1796
|
const ret = arg0.buffer;
|
|
786
1797
|
return ret;
|
|
787
1798
|
};
|
|
788
1799
|
|
|
789
|
-
module.exports.
|
|
790
|
-
const ret = arg0.call(arg1);
|
|
1800
|
+
module.exports.__wbg_call_f2db6205e5c51dc8 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1801
|
+
const ret = arg0.call(arg1, arg2);
|
|
791
1802
|
return ret;
|
|
792
1803
|
}, arguments) };
|
|
793
1804
|
|
|
794
|
-
module.exports.
|
|
795
|
-
const ret = arg0.call(arg1
|
|
1805
|
+
module.exports.__wbg_call_fbe8be8bf6436ce5 = function() { return handleError(function (arg0, arg1) {
|
|
1806
|
+
const ret = arg0.call(arg1);
|
|
796
1807
|
return ret;
|
|
797
1808
|
}, arguments) };
|
|
798
1809
|
|
|
799
|
-
module.exports.
|
|
1810
|
+
module.exports.__wbg_clearTimeout_6222fede17abcb1a = function(arg0) {
|
|
800
1811
|
const ret = clearTimeout(arg0);
|
|
801
1812
|
return ret;
|
|
802
1813
|
};
|
|
803
1814
|
|
|
804
|
-
module.exports.
|
|
1815
|
+
module.exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
805
1816
|
const ret = arg0.crypto;
|
|
806
1817
|
return ret;
|
|
807
1818
|
};
|
|
808
1819
|
|
|
809
|
-
module.exports.
|
|
1820
|
+
module.exports.__wbg_debug_103948ed4c500577 = function(arg0, arg1, arg2, arg3) {
|
|
810
1821
|
console.debug(arg0, arg1, arg2, arg3);
|
|
811
1822
|
};
|
|
812
1823
|
|
|
813
|
-
module.exports.
|
|
1824
|
+
module.exports.__wbg_done_4d01f352bade43b7 = function(arg0) {
|
|
814
1825
|
const ret = arg0.done;
|
|
815
1826
|
return ret;
|
|
816
1827
|
};
|
|
817
1828
|
|
|
818
|
-
module.exports.
|
|
1829
|
+
module.exports.__wbg_entries_41651c850143b957 = function(arg0) {
|
|
1830
|
+
const ret = Object.entries(arg0);
|
|
1831
|
+
return ret;
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
module.exports.__wbg_error_624160881466fd69 = function(arg0, arg1, arg2, arg3) {
|
|
819
1835
|
console.error(arg0, arg1, arg2, arg3);
|
|
820
1836
|
};
|
|
821
1837
|
|
|
822
|
-
module.exports.
|
|
823
|
-
const ret =
|
|
1838
|
+
module.exports.__wbg_fetch_0fde801b2e1aa024 = function(arg0) {
|
|
1839
|
+
const ret = fetch(arg0);
|
|
824
1840
|
return ret;
|
|
825
1841
|
};
|
|
826
1842
|
|
|
827
|
-
module.exports.
|
|
828
|
-
const ret = fetch(
|
|
1843
|
+
module.exports.__wbg_fetch_a8e43a4e138dfc93 = function(arg0, arg1) {
|
|
1844
|
+
const ret = arg0.fetch(arg1);
|
|
829
1845
|
return ret;
|
|
830
1846
|
};
|
|
831
1847
|
|
|
832
|
-
module.exports.
|
|
1848
|
+
module.exports.__wbg_fetch_f156d10be9a5c88a = function(arg0) {
|
|
833
1849
|
const ret = fetch(arg0);
|
|
834
1850
|
return ret;
|
|
835
1851
|
};
|
|
836
1852
|
|
|
837
|
-
module.exports.
|
|
1853
|
+
module.exports.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return handleError(function (arg0, arg1) {
|
|
838
1854
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
839
1855
|
}, arguments) };
|
|
840
1856
|
|
|
841
|
-
module.exports.
|
|
1857
|
+
module.exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
842
1858
|
arg0.getRandomValues(arg1);
|
|
843
1859
|
}, arguments) };
|
|
844
1860
|
|
|
845
|
-
module.exports.
|
|
1861
|
+
module.exports.__wbg_get_92470be87867c2e5 = function() { return handleError(function (arg0, arg1) {
|
|
846
1862
|
const ret = Reflect.get(arg0, arg1);
|
|
847
1863
|
return ret;
|
|
848
1864
|
}, arguments) };
|
|
849
1865
|
|
|
850
|
-
module.exports.
|
|
1866
|
+
module.exports.__wbg_get_a131a44bd1eb6979 = function(arg0, arg1) {
|
|
1867
|
+
const ret = arg0[arg1 >>> 0];
|
|
1868
|
+
return ret;
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
module.exports.__wbg_has_809e438ee9d787a7 = function() { return handleError(function (arg0, arg1) {
|
|
851
1872
|
const ret = Reflect.has(arg0, arg1);
|
|
852
1873
|
return ret;
|
|
853
1874
|
}, arguments) };
|
|
854
1875
|
|
|
855
|
-
module.exports.
|
|
1876
|
+
module.exports.__wbg_headers_0f0cbdc6290b6780 = function(arg0) {
|
|
856
1877
|
const ret = arg0.headers;
|
|
857
1878
|
return ret;
|
|
858
1879
|
};
|
|
859
1880
|
|
|
860
|
-
module.exports.
|
|
1881
|
+
module.exports.__wbg_info_a1cc312ecc877319 = function(arg0, arg1, arg2, arg3) {
|
|
861
1882
|
console.info(arg0, arg1, arg2, arg3);
|
|
862
1883
|
};
|
|
863
1884
|
|
|
864
|
-
module.exports.
|
|
1885
|
+
module.exports.__wbg_instanceof_ArrayBuffer_a8b6f580b363f2bc = function(arg0) {
|
|
1886
|
+
let result;
|
|
1887
|
+
try {
|
|
1888
|
+
result = arg0 instanceof ArrayBuffer;
|
|
1889
|
+
} catch (_) {
|
|
1890
|
+
result = false;
|
|
1891
|
+
}
|
|
1892
|
+
const ret = result;
|
|
1893
|
+
return ret;
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
module.exports.__wbg_instanceof_Headers_8b4c0df841a5ed48 = function(arg0) {
|
|
1897
|
+
let result;
|
|
1898
|
+
try {
|
|
1899
|
+
result = arg0 instanceof Headers;
|
|
1900
|
+
} catch (_) {
|
|
1901
|
+
result = false;
|
|
1902
|
+
}
|
|
1903
|
+
const ret = result;
|
|
1904
|
+
return ret;
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
module.exports.__wbg_instanceof_Map_80cc65041c96417a = function(arg0) {
|
|
1908
|
+
let result;
|
|
1909
|
+
try {
|
|
1910
|
+
result = arg0 instanceof Map;
|
|
1911
|
+
} catch (_) {
|
|
1912
|
+
result = false;
|
|
1913
|
+
}
|
|
1914
|
+
const ret = result;
|
|
1915
|
+
return ret;
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
module.exports.__wbg_instanceof_Response_e80ce8b7a2b968d2 = function(arg0) {
|
|
865
1919
|
let result;
|
|
866
1920
|
try {
|
|
867
1921
|
result = arg0 instanceof Response;
|
|
@@ -872,38 +1926,84 @@ module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function(arg0) {
|
|
|
872
1926
|
return ret;
|
|
873
1927
|
};
|
|
874
1928
|
|
|
875
|
-
module.exports.
|
|
1929
|
+
module.exports.__wbg_instanceof_Uint8Array_ca460677bc155827 = function(arg0) {
|
|
1930
|
+
let result;
|
|
1931
|
+
try {
|
|
1932
|
+
result = arg0 instanceof Uint8Array;
|
|
1933
|
+
} catch (_) {
|
|
1934
|
+
result = false;
|
|
1935
|
+
}
|
|
1936
|
+
const ret = result;
|
|
1937
|
+
return ret;
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
module.exports.__wbg_isArray_5f090bed72bd4f89 = function(arg0) {
|
|
1941
|
+
const ret = Array.isArray(arg0);
|
|
1942
|
+
return ret;
|
|
1943
|
+
};
|
|
1944
|
+
|
|
1945
|
+
module.exports.__wbg_isSafeInteger_90d7c4674047d684 = function(arg0) {
|
|
1946
|
+
const ret = Number.isSafeInteger(arg0);
|
|
1947
|
+
return ret;
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1950
|
+
module.exports.__wbg_iterator_4068add5b2aef7a6 = function() {
|
|
876
1951
|
const ret = Symbol.iterator;
|
|
877
1952
|
return ret;
|
|
878
1953
|
};
|
|
879
1954
|
|
|
880
|
-
module.exports.
|
|
1955
|
+
module.exports.__wbg_length_ab6d22b5ead75c72 = function(arg0) {
|
|
1956
|
+
const ret = arg0.length;
|
|
1957
|
+
return ret;
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
module.exports.__wbg_length_f00ec12454a5d9fd = function(arg0) {
|
|
881
1961
|
const ret = arg0.length;
|
|
882
1962
|
return ret;
|
|
883
1963
|
};
|
|
884
1964
|
|
|
885
|
-
module.exports.
|
|
1965
|
+
module.exports.__wbg_log_bff357b3df4db934 = function(arg0, arg1, arg2, arg3) {
|
|
886
1966
|
console.log(arg0, arg1, arg2, arg3);
|
|
887
1967
|
};
|
|
888
1968
|
|
|
889
|
-
module.exports.
|
|
1969
|
+
module.exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
890
1970
|
const ret = arg0.msCrypto;
|
|
891
1971
|
return ret;
|
|
892
1972
|
};
|
|
893
1973
|
|
|
894
|
-
module.exports.
|
|
1974
|
+
module.exports.__wbg_new_07b483f72211fd66 = function() {
|
|
1975
|
+
const ret = new Object();
|
|
1976
|
+
return ret;
|
|
1977
|
+
};
|
|
1978
|
+
|
|
1979
|
+
module.exports.__wbg_new_186abcfdff244e42 = function() { return handleError(function () {
|
|
1980
|
+
const ret = new AbortController();
|
|
1981
|
+
return ret;
|
|
1982
|
+
}, arguments) };
|
|
1983
|
+
|
|
1984
|
+
module.exports.__wbg_new_4796e1cd2eb9ea6d = function() { return handleError(function () {
|
|
895
1985
|
const ret = new Headers();
|
|
896
1986
|
return ret;
|
|
897
1987
|
}, arguments) };
|
|
898
1988
|
|
|
899
|
-
module.exports.
|
|
1989
|
+
module.exports.__wbg_new_58353953ad2097cc = function() {
|
|
1990
|
+
const ret = new Array();
|
|
1991
|
+
return ret;
|
|
1992
|
+
};
|
|
1993
|
+
|
|
1994
|
+
module.exports.__wbg_new_a979b4b45bd55c7f = function() {
|
|
1995
|
+
const ret = new Map();
|
|
1996
|
+
return ret;
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
module.exports.__wbg_new_e30c39c06edaabf2 = function(arg0, arg1) {
|
|
900
2000
|
try {
|
|
901
2001
|
var state0 = {a: arg0, b: arg1};
|
|
902
2002
|
var cb0 = (arg0, arg1) => {
|
|
903
2003
|
const a = state0.a;
|
|
904
2004
|
state0.a = 0;
|
|
905
2005
|
try {
|
|
906
|
-
return
|
|
2006
|
+
return __wbg_adapter_120(a, state0.b, arg0, arg1);
|
|
907
2007
|
} finally {
|
|
908
2008
|
state0.a = a;
|
|
909
2009
|
}
|
|
@@ -915,100 +2015,90 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
|
|
|
915
2015
|
}
|
|
916
2016
|
};
|
|
917
2017
|
|
|
918
|
-
module.exports.
|
|
919
|
-
const ret = new Object();
|
|
920
|
-
return ret;
|
|
921
|
-
};
|
|
922
|
-
|
|
923
|
-
module.exports.__wbg_new_78feb108b6472713 = function() {
|
|
924
|
-
const ret = new Array();
|
|
925
|
-
return ret;
|
|
926
|
-
};
|
|
927
|
-
|
|
928
|
-
module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
2018
|
+
module.exports.__wbg_new_e52b3efaaa774f96 = function(arg0) {
|
|
929
2019
|
const ret = new Uint8Array(arg0);
|
|
930
2020
|
return ret;
|
|
931
2021
|
};
|
|
932
2022
|
|
|
933
|
-
module.exports.
|
|
934
|
-
const ret = new
|
|
2023
|
+
module.exports.__wbg_newfromslice_7c05ab1297cb2d88 = function(arg0, arg1) {
|
|
2024
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
935
2025
|
return ret;
|
|
936
|
-
}
|
|
2026
|
+
};
|
|
937
2027
|
|
|
938
|
-
module.exports.
|
|
2028
|
+
module.exports.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
|
|
939
2029
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
940
2030
|
return ret;
|
|
941
2031
|
};
|
|
942
2032
|
|
|
943
|
-
module.exports.
|
|
2033
|
+
module.exports.__wbg_newwithbyteoffsetandlength_3b01ecda099177e8 = function(arg0, arg1, arg2) {
|
|
944
2034
|
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
945
2035
|
return ret;
|
|
946
2036
|
};
|
|
947
2037
|
|
|
948
|
-
module.exports.
|
|
2038
|
+
module.exports.__wbg_newwithlength_08f872dc1e3ada2e = function(arg0) {
|
|
949
2039
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
950
2040
|
return ret;
|
|
951
2041
|
};
|
|
952
2042
|
|
|
953
|
-
module.exports.
|
|
2043
|
+
module.exports.__wbg_newwithstrandinit_f8a9dbe009d6be37 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
954
2044
|
const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
|
|
955
2045
|
return ret;
|
|
956
2046
|
}, arguments) };
|
|
957
2047
|
|
|
958
|
-
module.exports.
|
|
2048
|
+
module.exports.__wbg_next_8bb824d217961b5d = function(arg0) {
|
|
959
2049
|
const ret = arg0.next;
|
|
960
2050
|
return ret;
|
|
961
2051
|
};
|
|
962
2052
|
|
|
963
|
-
module.exports.
|
|
2053
|
+
module.exports.__wbg_next_e2da48d8fff7439a = function() { return handleError(function (arg0) {
|
|
964
2054
|
const ret = arg0.next();
|
|
965
2055
|
return ret;
|
|
966
2056
|
}, arguments) };
|
|
967
2057
|
|
|
968
|
-
module.exports.
|
|
2058
|
+
module.exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
969
2059
|
const ret = arg0.node;
|
|
970
2060
|
return ret;
|
|
971
2061
|
};
|
|
972
2062
|
|
|
973
|
-
module.exports.
|
|
2063
|
+
module.exports.__wbg_now_eb0821f3bd9f6529 = function() {
|
|
974
2064
|
const ret = Date.now();
|
|
975
2065
|
return ret;
|
|
976
2066
|
};
|
|
977
2067
|
|
|
978
|
-
module.exports.
|
|
979
|
-
const ret = arg0
|
|
2068
|
+
module.exports.__wbg_parse_c7ba327fb6231e7f = function() { return handleError(function (arg0, arg1) {
|
|
2069
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
980
2070
|
return ret;
|
|
981
|
-
};
|
|
2071
|
+
}, arguments) };
|
|
982
2072
|
|
|
983
|
-
module.exports.
|
|
984
|
-
const ret =
|
|
2073
|
+
module.exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
2074
|
+
const ret = arg0.process;
|
|
985
2075
|
return ret;
|
|
986
2076
|
};
|
|
987
2077
|
|
|
988
|
-
module.exports.
|
|
2078
|
+
module.exports.__wbg_push_73fd7b5550ebf707 = function(arg0, arg1) {
|
|
989
2079
|
const ret = arg0.push(arg1);
|
|
990
2080
|
return ret;
|
|
991
2081
|
};
|
|
992
2082
|
|
|
993
|
-
module.exports.
|
|
2083
|
+
module.exports.__wbg_queueMicrotask_46c1df247678729f = function(arg0) {
|
|
994
2084
|
queueMicrotask(arg0);
|
|
995
2085
|
};
|
|
996
2086
|
|
|
997
|
-
module.exports.
|
|
2087
|
+
module.exports.__wbg_queueMicrotask_8acf3ccb75ed8d11 = function(arg0) {
|
|
998
2088
|
const ret = arg0.queueMicrotask;
|
|
999
2089
|
return ret;
|
|
1000
2090
|
};
|
|
1001
2091
|
|
|
1002
|
-
module.exports.
|
|
2092
|
+
module.exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
1003
2093
|
arg0.randomFillSync(arg1);
|
|
1004
2094
|
}, arguments) };
|
|
1005
2095
|
|
|
1006
|
-
module.exports.
|
|
2096
|
+
module.exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
1007
2097
|
const ret = module.require;
|
|
1008
2098
|
return ret;
|
|
1009
2099
|
}, arguments) };
|
|
1010
2100
|
|
|
1011
|
-
module.exports.
|
|
2101
|
+
module.exports.__wbg_resolve_0dac8c580ffd4678 = function(arg0) {
|
|
1012
2102
|
const ret = Promise.resolve(arg0);
|
|
1013
2103
|
return ret;
|
|
1014
2104
|
};
|
|
@@ -1018,95 +2108,116 @@ module.exports.__wbg_session_new = function(arg0) {
|
|
|
1018
2108
|
return ret;
|
|
1019
2109
|
};
|
|
1020
2110
|
|
|
1021
|
-
module.exports.
|
|
2111
|
+
module.exports.__wbg_setTimeout_2b339866a2aa3789 = function(arg0, arg1) {
|
|
1022
2112
|
const ret = setTimeout(arg0, arg1);
|
|
1023
2113
|
return ret;
|
|
1024
2114
|
};
|
|
1025
2115
|
|
|
1026
|
-
module.exports.
|
|
2116
|
+
module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
2117
|
+
arg0[arg1] = arg2;
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
module.exports.__wbg_set_7422acbe992d64ab = function(arg0, arg1, arg2) {
|
|
2121
|
+
arg0[arg1 >>> 0] = arg2;
|
|
2122
|
+
};
|
|
2123
|
+
|
|
2124
|
+
module.exports.__wbg_set_b042eef31c50834d = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
2125
|
+
arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
2126
|
+
}, arguments) };
|
|
2127
|
+
|
|
2128
|
+
module.exports.__wbg_set_d6bdfd275fb8a4ce = function(arg0, arg1, arg2) {
|
|
2129
|
+
const ret = arg0.set(arg1, arg2);
|
|
2130
|
+
return ret;
|
|
2131
|
+
};
|
|
2132
|
+
|
|
2133
|
+
module.exports.__wbg_set_fe4e79d1ed3b0e9b = function(arg0, arg1, arg2) {
|
|
1027
2134
|
arg0.set(arg1, arg2 >>> 0);
|
|
1028
2135
|
};
|
|
1029
2136
|
|
|
1030
|
-
module.exports.
|
|
2137
|
+
module.exports.__wbg_setbody_971ec015fc13d6b4 = function(arg0, arg1) {
|
|
1031
2138
|
arg0.body = arg1;
|
|
1032
2139
|
};
|
|
1033
2140
|
|
|
1034
|
-
module.exports.
|
|
2141
|
+
module.exports.__wbg_setcache_a94cd14dc0cc72a2 = function(arg0, arg1) {
|
|
2142
|
+
arg0.cache = __wbindgen_enum_RequestCache[arg1];
|
|
2143
|
+
};
|
|
2144
|
+
|
|
2145
|
+
module.exports.__wbg_setcredentials_920d91fb5984c94a = function(arg0, arg1) {
|
|
1035
2146
|
arg0.credentials = __wbindgen_enum_RequestCredentials[arg1];
|
|
1036
2147
|
};
|
|
1037
2148
|
|
|
1038
|
-
module.exports.
|
|
2149
|
+
module.exports.__wbg_setheaders_65a4eb4c0443ae61 = function(arg0, arg1) {
|
|
1039
2150
|
arg0.headers = arg1;
|
|
1040
2151
|
};
|
|
1041
2152
|
|
|
1042
|
-
module.exports.
|
|
2153
|
+
module.exports.__wbg_setmethod_8ce1be0b4d701b7c = function(arg0, arg1, arg2) {
|
|
1043
2154
|
arg0.method = getStringFromWasm0(arg1, arg2);
|
|
1044
2155
|
};
|
|
1045
2156
|
|
|
1046
|
-
module.exports.
|
|
2157
|
+
module.exports.__wbg_setmode_bd35f026f55b6247 = function(arg0, arg1) {
|
|
1047
2158
|
arg0.mode = __wbindgen_enum_RequestMode[arg1];
|
|
1048
2159
|
};
|
|
1049
2160
|
|
|
1050
|
-
module.exports.
|
|
2161
|
+
module.exports.__wbg_setsignal_8e72abfe7ee03c97 = function(arg0, arg1) {
|
|
1051
2162
|
arg0.signal = arg1;
|
|
1052
2163
|
};
|
|
1053
2164
|
|
|
1054
|
-
module.exports.
|
|
2165
|
+
module.exports.__wbg_signal_b96223519a041faa = function(arg0) {
|
|
1055
2166
|
const ret = arg0.signal;
|
|
1056
2167
|
return ret;
|
|
1057
2168
|
};
|
|
1058
2169
|
|
|
1059
|
-
module.exports.
|
|
2170
|
+
module.exports.__wbg_static_accessor_GLOBAL_487c52c58d65314d = function() {
|
|
1060
2171
|
const ret = typeof global === 'undefined' ? null : global;
|
|
1061
2172
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1062
2173
|
};
|
|
1063
2174
|
|
|
1064
|
-
module.exports.
|
|
2175
|
+
module.exports.__wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291 = function() {
|
|
1065
2176
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1066
2177
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1067
2178
|
};
|
|
1068
2179
|
|
|
1069
|
-
module.exports.
|
|
2180
|
+
module.exports.__wbg_static_accessor_SELF_78c9e3071b912620 = function() {
|
|
1070
2181
|
const ret = typeof self === 'undefined' ? null : self;
|
|
1071
2182
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1072
2183
|
};
|
|
1073
2184
|
|
|
1074
|
-
module.exports.
|
|
2185
|
+
module.exports.__wbg_static_accessor_WINDOW_a093d21393777366 = function() {
|
|
1075
2186
|
const ret = typeof window === 'undefined' ? null : window;
|
|
1076
2187
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1077
2188
|
};
|
|
1078
2189
|
|
|
1079
|
-
module.exports.
|
|
2190
|
+
module.exports.__wbg_status_a54682bbe52f9058 = function(arg0) {
|
|
1080
2191
|
const ret = arg0.status;
|
|
1081
2192
|
return ret;
|
|
1082
2193
|
};
|
|
1083
2194
|
|
|
1084
|
-
module.exports.
|
|
2195
|
+
module.exports.__wbg_stringify_c242842b97f054cc = function() { return handleError(function (arg0) {
|
|
1085
2196
|
const ret = JSON.stringify(arg0);
|
|
1086
2197
|
return ret;
|
|
1087
2198
|
}, arguments) };
|
|
1088
2199
|
|
|
1089
|
-
module.exports.
|
|
2200
|
+
module.exports.__wbg_subarray_dd4ade7d53bd8e26 = function(arg0, arg1, arg2) {
|
|
1090
2201
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1091
2202
|
return ret;
|
|
1092
2203
|
};
|
|
1093
2204
|
|
|
1094
|
-
module.exports.
|
|
2205
|
+
module.exports.__wbg_text_ec0e22f60e30dd2f = function() { return handleError(function (arg0) {
|
|
1095
2206
|
const ret = arg0.text();
|
|
1096
2207
|
return ret;
|
|
1097
2208
|
}, arguments) };
|
|
1098
2209
|
|
|
1099
|
-
module.exports.
|
|
1100
|
-
const ret = arg0.then(arg1);
|
|
2210
|
+
module.exports.__wbg_then_82ab9fb4080f1707 = function(arg0, arg1, arg2) {
|
|
2211
|
+
const ret = arg0.then(arg1, arg2);
|
|
1101
2212
|
return ret;
|
|
1102
2213
|
};
|
|
1103
2214
|
|
|
1104
|
-
module.exports.
|
|
1105
|
-
const ret = arg0.then(arg1
|
|
2215
|
+
module.exports.__wbg_then_db882932c0c714c6 = function(arg0, arg1) {
|
|
2216
|
+
const ret = arg0.then(arg1);
|
|
1106
2217
|
return ret;
|
|
1107
2218
|
};
|
|
1108
2219
|
|
|
1109
|
-
module.exports.
|
|
2220
|
+
module.exports.__wbg_url_e6ed869ea05b7a71 = function(arg0, arg1) {
|
|
1110
2221
|
const ret = arg1.url;
|
|
1111
2222
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1112
2223
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -1114,20 +2225,52 @@ module.exports.__wbg_url_ae10c34ca209681d = function(arg0, arg1) {
|
|
|
1114
2225
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1115
2226
|
};
|
|
1116
2227
|
|
|
1117
|
-
module.exports.
|
|
2228
|
+
module.exports.__wbg_value_17b896954e14f896 = function(arg0) {
|
|
1118
2229
|
const ret = arg0.value;
|
|
1119
2230
|
return ret;
|
|
1120
2231
|
};
|
|
1121
2232
|
|
|
1122
|
-
module.exports.
|
|
2233
|
+
module.exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
1123
2234
|
const ret = arg0.versions;
|
|
1124
2235
|
return ret;
|
|
1125
2236
|
};
|
|
1126
2237
|
|
|
1127
|
-
module.exports.
|
|
2238
|
+
module.exports.__wbg_warn_90607373221a6b1c = function(arg0, arg1, arg2, arg3) {
|
|
1128
2239
|
console.warn(arg0, arg1, arg2, arg3);
|
|
1129
2240
|
};
|
|
1130
2241
|
|
|
2242
|
+
module.exports.__wbindgen_array_new = function() {
|
|
2243
|
+
const ret = [];
|
|
2244
|
+
return ret;
|
|
2245
|
+
};
|
|
2246
|
+
|
|
2247
|
+
module.exports.__wbindgen_array_push = function(arg0, arg1) {
|
|
2248
|
+
arg0.push(arg1);
|
|
2249
|
+
};
|
|
2250
|
+
|
|
2251
|
+
module.exports.__wbindgen_bigint_from_i64 = function(arg0) {
|
|
2252
|
+
const ret = arg0;
|
|
2253
|
+
return ret;
|
|
2254
|
+
};
|
|
2255
|
+
|
|
2256
|
+
module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
2257
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
2258
|
+
return ret;
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
2262
|
+
const v = arg1;
|
|
2263
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
2264
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
2265
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
module.exports.__wbindgen_boolean_get = function(arg0) {
|
|
2269
|
+
const v = arg0;
|
|
2270
|
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
2271
|
+
return ret;
|
|
2272
|
+
};
|
|
2273
|
+
|
|
1131
2274
|
module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
1132
2275
|
const obj = arg0.original;
|
|
1133
2276
|
if (obj.cnt-- == 1) {
|
|
@@ -1138,13 +2281,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
1138
2281
|
return ret;
|
|
1139
2282
|
};
|
|
1140
2283
|
|
|
1141
|
-
module.exports.
|
|
1142
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2284
|
+
module.exports.__wbindgen_closure_wrapper2747 = function(arg0, arg1, arg2) {
|
|
2285
|
+
const ret = makeMutClosure(arg0, arg1, 154, __wbg_adapter_54);
|
|
1143
2286
|
return ret;
|
|
1144
2287
|
};
|
|
1145
2288
|
|
|
1146
|
-
module.exports.
|
|
1147
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2289
|
+
module.exports.__wbindgen_closure_wrapper3056 = function(arg0, arg1, arg2) {
|
|
2290
|
+
const ret = makeMutClosure(arg0, arg1, 154, __wbg_adapter_57);
|
|
1148
2291
|
return ret;
|
|
1149
2292
|
};
|
|
1150
2293
|
|
|
@@ -1156,8 +2299,13 @@ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
|
1156
2299
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1157
2300
|
};
|
|
1158
2301
|
|
|
2302
|
+
module.exports.__wbindgen_in = function(arg0, arg1) {
|
|
2303
|
+
const ret = arg0 in arg1;
|
|
2304
|
+
return ret;
|
|
2305
|
+
};
|
|
2306
|
+
|
|
1159
2307
|
module.exports.__wbindgen_init_externref_table = function() {
|
|
1160
|
-
const table = wasm.
|
|
2308
|
+
const table = wasm.__wbindgen_export_4;
|
|
1161
2309
|
const offset = table.grow(4);
|
|
1162
2310
|
table.set(0, undefined);
|
|
1163
2311
|
table.set(offset + 0, undefined);
|
|
@@ -1167,11 +2315,21 @@ module.exports.__wbindgen_init_externref_table = function() {
|
|
|
1167
2315
|
;
|
|
1168
2316
|
};
|
|
1169
2317
|
|
|
2318
|
+
module.exports.__wbindgen_is_bigint = function(arg0) {
|
|
2319
|
+
const ret = typeof(arg0) === 'bigint';
|
|
2320
|
+
return ret;
|
|
2321
|
+
};
|
|
2322
|
+
|
|
1170
2323
|
module.exports.__wbindgen_is_function = function(arg0) {
|
|
1171
2324
|
const ret = typeof(arg0) === 'function';
|
|
1172
2325
|
return ret;
|
|
1173
2326
|
};
|
|
1174
2327
|
|
|
2328
|
+
module.exports.__wbindgen_is_null = function(arg0) {
|
|
2329
|
+
const ret = arg0 === null;
|
|
2330
|
+
return ret;
|
|
2331
|
+
};
|
|
2332
|
+
|
|
1175
2333
|
module.exports.__wbindgen_is_object = function(arg0) {
|
|
1176
2334
|
const val = arg0;
|
|
1177
2335
|
const ret = typeof(val) === 'object' && val !== null;
|
|
@@ -1188,11 +2346,33 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
|
1188
2346
|
return ret;
|
|
1189
2347
|
};
|
|
1190
2348
|
|
|
2349
|
+
module.exports.__wbindgen_jsval_eq = function(arg0, arg1) {
|
|
2350
|
+
const ret = arg0 === arg1;
|
|
2351
|
+
return ret;
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
2355
|
+
const ret = arg0 == arg1;
|
|
2356
|
+
return ret;
|
|
2357
|
+
};
|
|
2358
|
+
|
|
1191
2359
|
module.exports.__wbindgen_memory = function() {
|
|
1192
2360
|
const ret = wasm.memory;
|
|
1193
2361
|
return ret;
|
|
1194
2362
|
};
|
|
1195
2363
|
|
|
2364
|
+
module.exports.__wbindgen_number_get = function(arg0, arg1) {
|
|
2365
|
+
const obj = arg1;
|
|
2366
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
2367
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
2368
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2371
|
+
module.exports.__wbindgen_number_new = function(arg0) {
|
|
2372
|
+
const ret = arg0;
|
|
2373
|
+
return ret;
|
|
2374
|
+
};
|
|
2375
|
+
|
|
1196
2376
|
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
1197
2377
|
const obj = arg1;
|
|
1198
2378
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|