@synonymdev/pubky 0.2.0 → 0.4.0-rc1
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 +24 -36
- package/index.cjs +1161 -1
- package/index.js +1267 -0
- package/package.json +5 -5
- package/pubky.d.ts +34 -96
- package/pubky_bg.wasm +0 -0
- package/browser.js +0 -1244
package/index.cjs
CHANGED
|
@@ -3,4 +3,1164 @@ const makeFetchCookie = require("fetch-cookie").default;
|
|
|
3
3
|
let originalFetch = globalThis.fetch;
|
|
4
4
|
globalThis.fetch = makeFetchCookie(originalFetch);
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
let imports = {};
|
|
8
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
9
|
+
let wasm;
|
|
10
|
+
const { TextDecoder, TextEncoder } = require(`util`);
|
|
11
|
+
|
|
12
|
+
const heap = new Array(128).fill(undefined);
|
|
13
|
+
|
|
14
|
+
heap.push(undefined, null, true, false);
|
|
15
|
+
|
|
16
|
+
function getObject(idx) { return heap[idx]; }
|
|
17
|
+
|
|
18
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
19
|
+
|
|
20
|
+
cachedTextDecoder.decode();
|
|
21
|
+
|
|
22
|
+
let cachedUint8ArrayMemory0 = null;
|
|
23
|
+
|
|
24
|
+
function getUint8ArrayMemory0() {
|
|
25
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
26
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
27
|
+
}
|
|
28
|
+
return cachedUint8ArrayMemory0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getStringFromWasm0(ptr, len) {
|
|
32
|
+
ptr = ptr >>> 0;
|
|
33
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let heap_next = heap.length;
|
|
37
|
+
|
|
38
|
+
function addHeapObject(obj) {
|
|
39
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
40
|
+
const idx = heap_next;
|
|
41
|
+
heap_next = heap[idx];
|
|
42
|
+
|
|
43
|
+
heap[idx] = obj;
|
|
44
|
+
return idx;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function handleError(f, args) {
|
|
48
|
+
try {
|
|
49
|
+
return f.apply(this, args);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function dropObject(idx) {
|
|
56
|
+
if (idx < 132) return;
|
|
57
|
+
heap[idx] = heap_next;
|
|
58
|
+
heap_next = idx;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function takeObject(idx) {
|
|
62
|
+
const ret = getObject(idx);
|
|
63
|
+
dropObject(idx);
|
|
64
|
+
return ret;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isLikeNone(x) {
|
|
68
|
+
return x === undefined || x === null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let WASM_VECTOR_LEN = 0;
|
|
72
|
+
|
|
73
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
74
|
+
|
|
75
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
76
|
+
? function (arg, view) {
|
|
77
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
78
|
+
}
|
|
79
|
+
: function (arg, view) {
|
|
80
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
81
|
+
view.set(buf);
|
|
82
|
+
return {
|
|
83
|
+
read: arg.length,
|
|
84
|
+
written: buf.length
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
89
|
+
|
|
90
|
+
if (realloc === undefined) {
|
|
91
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
92
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
93
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
94
|
+
WASM_VECTOR_LEN = buf.length;
|
|
95
|
+
return ptr;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let len = arg.length;
|
|
99
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
100
|
+
|
|
101
|
+
const mem = getUint8ArrayMemory0();
|
|
102
|
+
|
|
103
|
+
let offset = 0;
|
|
104
|
+
|
|
105
|
+
for (; offset < len; offset++) {
|
|
106
|
+
const code = arg.charCodeAt(offset);
|
|
107
|
+
if (code > 0x7F) break;
|
|
108
|
+
mem[ptr + offset] = code;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (offset !== len) {
|
|
112
|
+
if (offset !== 0) {
|
|
113
|
+
arg = arg.slice(offset);
|
|
114
|
+
}
|
|
115
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
116
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
117
|
+
const ret = encodeString(arg, view);
|
|
118
|
+
|
|
119
|
+
offset += ret.written;
|
|
120
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
WASM_VECTOR_LEN = offset;
|
|
124
|
+
return ptr;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let cachedDataViewMemory0 = null;
|
|
128
|
+
|
|
129
|
+
function getDataViewMemory0() {
|
|
130
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
131
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
132
|
+
}
|
|
133
|
+
return cachedDataViewMemory0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
137
|
+
? { register: () => {}, unregister: () => {} }
|
|
138
|
+
: new FinalizationRegistry(state => {
|
|
139
|
+
wasm.__wbindgen_export_3.get(state.dtor)(state.a, state.b)
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
143
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
144
|
+
const real = (...args) => {
|
|
145
|
+
// First up with a closure we increment the internal reference
|
|
146
|
+
// count. This ensures that the Rust closure environment won't
|
|
147
|
+
// be deallocated while we're invoking it.
|
|
148
|
+
state.cnt++;
|
|
149
|
+
const a = state.a;
|
|
150
|
+
state.a = 0;
|
|
151
|
+
try {
|
|
152
|
+
return f(a, state.b, ...args);
|
|
153
|
+
} finally {
|
|
154
|
+
if (--state.cnt === 0) {
|
|
155
|
+
wasm.__wbindgen_export_3.get(state.dtor)(a, state.b);
|
|
156
|
+
CLOSURE_DTORS.unregister(state);
|
|
157
|
+
} else {
|
|
158
|
+
state.a = a;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
real.original = state;
|
|
163
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
164
|
+
return real;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function debugString(val) {
|
|
168
|
+
// primitive types
|
|
169
|
+
const type = typeof val;
|
|
170
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
171
|
+
return `${val}`;
|
|
172
|
+
}
|
|
173
|
+
if (type == 'string') {
|
|
174
|
+
return `"${val}"`;
|
|
175
|
+
}
|
|
176
|
+
if (type == 'symbol') {
|
|
177
|
+
const description = val.description;
|
|
178
|
+
if (description == null) {
|
|
179
|
+
return 'Symbol';
|
|
180
|
+
} else {
|
|
181
|
+
return `Symbol(${description})`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (type == 'function') {
|
|
185
|
+
const name = val.name;
|
|
186
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
187
|
+
return `Function(${name})`;
|
|
188
|
+
} else {
|
|
189
|
+
return 'Function';
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// objects
|
|
193
|
+
if (Array.isArray(val)) {
|
|
194
|
+
const length = val.length;
|
|
195
|
+
let debug = '[';
|
|
196
|
+
if (length > 0) {
|
|
197
|
+
debug += debugString(val[0]);
|
|
198
|
+
}
|
|
199
|
+
for(let i = 1; i < length; i++) {
|
|
200
|
+
debug += ', ' + debugString(val[i]);
|
|
201
|
+
}
|
|
202
|
+
debug += ']';
|
|
203
|
+
return debug;
|
|
204
|
+
}
|
|
205
|
+
// Test for built-in
|
|
206
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
207
|
+
let className;
|
|
208
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
209
|
+
className = builtInMatches[1];
|
|
210
|
+
} else {
|
|
211
|
+
// Failed to match the standard '[object ClassName]'
|
|
212
|
+
return toString.call(val);
|
|
213
|
+
}
|
|
214
|
+
if (className == 'Object') {
|
|
215
|
+
// we're a user defined class or Object
|
|
216
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
217
|
+
// easier than looping through ownProperties of `val`.
|
|
218
|
+
try {
|
|
219
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
220
|
+
} catch (_) {
|
|
221
|
+
return 'Object';
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// errors
|
|
225
|
+
if (val instanceof Error) {
|
|
226
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
227
|
+
}
|
|
228
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
229
|
+
return className;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function _assertClass(instance, klass) {
|
|
233
|
+
if (!(instance instanceof klass)) {
|
|
234
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
239
|
+
* using the `passphrase`.
|
|
240
|
+
* @param {Keypair} keypair
|
|
241
|
+
* @param {string} passphrase
|
|
242
|
+
* @returns {Uint8Array}
|
|
243
|
+
*/
|
|
244
|
+
module.exports.createRecoveryFile = function(keypair, passphrase) {
|
|
245
|
+
try {
|
|
246
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
247
|
+
_assertClass(keypair, Keypair);
|
|
248
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
249
|
+
const len0 = WASM_VECTOR_LEN;
|
|
250
|
+
wasm.createRecoveryFile(retptr, keypair.__wbg_ptr, ptr0, len0);
|
|
251
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
252
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
253
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
254
|
+
if (r2) {
|
|
255
|
+
throw takeObject(r1);
|
|
256
|
+
}
|
|
257
|
+
return takeObject(r0);
|
|
258
|
+
} finally {
|
|
259
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
264
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
265
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
266
|
+
WASM_VECTOR_LEN = arg.length;
|
|
267
|
+
return ptr;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
271
|
+
* using the `passphrase`.
|
|
272
|
+
* @param {Uint8Array} recovery_file
|
|
273
|
+
* @param {string} passphrase
|
|
274
|
+
* @returns {Keypair}
|
|
275
|
+
*/
|
|
276
|
+
module.exports.decryptRecoveryFile = function(recovery_file, passphrase) {
|
|
277
|
+
try {
|
|
278
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
279
|
+
const ptr0 = passArray8ToWasm0(recovery_file, wasm.__wbindgen_malloc);
|
|
280
|
+
const len0 = WASM_VECTOR_LEN;
|
|
281
|
+
const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
282
|
+
const len1 = WASM_VECTOR_LEN;
|
|
283
|
+
wasm.decryptRecoveryFile(retptr, ptr0, len0, ptr1, len1);
|
|
284
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
285
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
286
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
287
|
+
if (r2) {
|
|
288
|
+
throw takeObject(r1);
|
|
289
|
+
}
|
|
290
|
+
return Keypair.__wrap(r0);
|
|
291
|
+
} finally {
|
|
292
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @param {string} level
|
|
298
|
+
*/
|
|
299
|
+
module.exports.setLogLevel = function(level) {
|
|
300
|
+
try {
|
|
301
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
302
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
303
|
+
const len0 = WASM_VECTOR_LEN;
|
|
304
|
+
wasm.setLogLevel(retptr, ptr0, len0);
|
|
305
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
306
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
307
|
+
if (r1) {
|
|
308
|
+
throw takeObject(r0);
|
|
309
|
+
}
|
|
310
|
+
} finally {
|
|
311
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
316
|
+
ptr = ptr >>> 0;
|
|
317
|
+
const mem = getDataViewMemory0();
|
|
318
|
+
const result = [];
|
|
319
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
320
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
function __wbg_adapter_28(arg0, arg1, arg2) {
|
|
325
|
+
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6aa613d03ec1284e(arg0, arg1, addHeapObject(arg2));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function __wbg_adapter_153(arg0, arg1, arg2, arg3) {
|
|
329
|
+
wasm.wasm_bindgen__convert__closures__invoke2_mut__h2095b693172537bf(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
333
|
+
|
|
334
|
+
const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
|
|
335
|
+
|
|
336
|
+
const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
337
|
+
? { register: () => {}, unregister: () => {} }
|
|
338
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_client_free(ptr >>> 0, 1));
|
|
339
|
+
/**
|
|
340
|
+
* A client for Pubky homeserver API, as well as generic HTTP requests to Pubky urls.
|
|
341
|
+
*/
|
|
342
|
+
class Client {
|
|
343
|
+
|
|
344
|
+
static __wrap(ptr) {
|
|
345
|
+
ptr = ptr >>> 0;
|
|
346
|
+
const obj = Object.create(Client.prototype);
|
|
347
|
+
obj.__wbg_ptr = ptr;
|
|
348
|
+
ClientFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
349
|
+
return obj;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
__destroy_into_raw() {
|
|
353
|
+
const ptr = this.__wbg_ptr;
|
|
354
|
+
this.__wbg_ptr = 0;
|
|
355
|
+
ClientFinalization.unregister(this);
|
|
356
|
+
return ptr;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
free() {
|
|
360
|
+
const ptr = this.__destroy_into_raw();
|
|
361
|
+
wasm.__wbg_client_free(ptr, 0);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Signup to a homeserver and update Pkarr accordingly.
|
|
365
|
+
*
|
|
366
|
+
* The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
|
|
367
|
+
* for example "pubky.o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy"
|
|
368
|
+
* @param {Keypair} keypair
|
|
369
|
+
* @param {PublicKey} homeserver
|
|
370
|
+
* @returns {Promise<Session>}
|
|
371
|
+
*/
|
|
372
|
+
signup(keypair, homeserver) {
|
|
373
|
+
_assertClass(keypair, Keypair);
|
|
374
|
+
_assertClass(homeserver, PublicKey);
|
|
375
|
+
const ret = wasm.client_signup(this.__wbg_ptr, keypair.__wbg_ptr, homeserver.__wbg_ptr);
|
|
376
|
+
return takeObject(ret);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Check the current sesison for a given Pubky in its homeserver.
|
|
380
|
+
*
|
|
381
|
+
* Returns [Session] or `None` (if recieved `404 NOT_FOUND`),
|
|
382
|
+
* or throws the recieved error if the response has any other `>=400` status code.
|
|
383
|
+
* @param {PublicKey} pubky
|
|
384
|
+
* @returns {Promise<Session | undefined>}
|
|
385
|
+
*/
|
|
386
|
+
session(pubky) {
|
|
387
|
+
_assertClass(pubky, PublicKey);
|
|
388
|
+
const ret = wasm.client_session(this.__wbg_ptr, pubky.__wbg_ptr);
|
|
389
|
+
return takeObject(ret);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Signout from a homeserver.
|
|
393
|
+
* @param {PublicKey} pubky
|
|
394
|
+
* @returns {Promise<void>}
|
|
395
|
+
*/
|
|
396
|
+
signout(pubky) {
|
|
397
|
+
_assertClass(pubky, PublicKey);
|
|
398
|
+
const ret = wasm.client_signout(this.__wbg_ptr, pubky.__wbg_ptr);
|
|
399
|
+
return takeObject(ret);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Signin to a homeserver using the root Keypair.
|
|
403
|
+
* @param {Keypair} keypair
|
|
404
|
+
* @returns {Promise<void>}
|
|
405
|
+
*/
|
|
406
|
+
signin(keypair) {
|
|
407
|
+
_assertClass(keypair, Keypair);
|
|
408
|
+
const ret = wasm.client_signin(this.__wbg_ptr, keypair.__wbg_ptr);
|
|
409
|
+
return takeObject(ret);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Return `pubkyauth://` url and wait for the incoming [AuthToken]
|
|
413
|
+
* verifying that AuthToken, and if capabilities were requested, signing in to
|
|
414
|
+
* the Pubky's homeserver and returning the [Session] information.
|
|
415
|
+
*
|
|
416
|
+
* Returns a tuple of [pubkyAuthUrl, Promise<Session>]
|
|
417
|
+
* @param {string} relay
|
|
418
|
+
* @param {string} capabilities
|
|
419
|
+
* @returns {Array<any>}
|
|
420
|
+
*/
|
|
421
|
+
authRequest(relay, capabilities) {
|
|
422
|
+
try {
|
|
423
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
424
|
+
const ptr0 = passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
425
|
+
const len0 = WASM_VECTOR_LEN;
|
|
426
|
+
const ptr1 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
427
|
+
const len1 = WASM_VECTOR_LEN;
|
|
428
|
+
wasm.client_authRequest(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
429
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
430
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
431
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
432
|
+
if (r2) {
|
|
433
|
+
throw takeObject(r1);
|
|
434
|
+
}
|
|
435
|
+
return takeObject(r0);
|
|
436
|
+
} finally {
|
|
437
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Sign an [pubky_common::auth::AuthToken], encrypt it and send it to the
|
|
442
|
+
* source of the pubkyauth request url.
|
|
443
|
+
* @param {Keypair} keypair
|
|
444
|
+
* @param {string} pubkyauth_url
|
|
445
|
+
* @returns {Promise<void>}
|
|
446
|
+
*/
|
|
447
|
+
sendAuthToken(keypair, pubkyauth_url) {
|
|
448
|
+
_assertClass(keypair, Keypair);
|
|
449
|
+
const ptr0 = passStringToWasm0(pubkyauth_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
450
|
+
const len0 = WASM_VECTOR_LEN;
|
|
451
|
+
const ret = wasm.client_sendAuthToken(this.__wbg_ptr, keypair.__wbg_ptr, ptr0, len0);
|
|
452
|
+
return takeObject(ret);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Returns a list of Pubky urls (as strings).
|
|
456
|
+
*
|
|
457
|
+
* - `url`: The Pubky url (string) to the directory you want to list its content.
|
|
458
|
+
* - `cursor`: Either a full `pubky://` Url (from previous list response),
|
|
459
|
+
* or a path (to a file or directory) relative to the `url`
|
|
460
|
+
* - `reverse`: List in reverse order
|
|
461
|
+
* - `limit` Limit the number of urls in the response
|
|
462
|
+
* - `shallow`: List directories and files, instead of flat list of files.
|
|
463
|
+
* @param {string} url
|
|
464
|
+
* @param {string | undefined} [cursor]
|
|
465
|
+
* @param {boolean | undefined} [reverse]
|
|
466
|
+
* @param {number | undefined} [limit]
|
|
467
|
+
* @param {boolean | undefined} [shallow]
|
|
468
|
+
* @returns {Promise<Array<any>>}
|
|
469
|
+
*/
|
|
470
|
+
list(url, cursor, reverse, limit, shallow) {
|
|
471
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
472
|
+
const len0 = WASM_VECTOR_LEN;
|
|
473
|
+
var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
474
|
+
var len1 = WASM_VECTOR_LEN;
|
|
475
|
+
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);
|
|
476
|
+
return takeObject(ret);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* @param {string} url
|
|
480
|
+
* @param {any | undefined} [request_init]
|
|
481
|
+
* @returns {Promise<Promise<any>>}
|
|
482
|
+
*/
|
|
483
|
+
fetch(url, request_init) {
|
|
484
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
485
|
+
const len0 = WASM_VECTOR_LEN;
|
|
486
|
+
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(request_init) ? 0 : addHeapObject(request_init));
|
|
487
|
+
return takeObject(ret);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Create Client with default Settings including default relays
|
|
491
|
+
*/
|
|
492
|
+
constructor() {
|
|
493
|
+
const ret = wasm.client_new();
|
|
494
|
+
this.__wbg_ptr = ret >>> 0;
|
|
495
|
+
ClientFinalization.register(this, this.__wbg_ptr, this);
|
|
496
|
+
return this;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Create a client with with configurations appropriate for local testing:
|
|
500
|
+
* - set Pkarr relays to `["http://localhost:15411"]` instead of default relay.
|
|
501
|
+
* @returns {Client}
|
|
502
|
+
*/
|
|
503
|
+
static testnet() {
|
|
504
|
+
const ret = wasm.client_testnet();
|
|
505
|
+
return Client.__wrap(ret);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
module.exports.Client = Client;
|
|
509
|
+
|
|
510
|
+
const KeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
511
|
+
? { register: () => {}, unregister: () => {} }
|
|
512
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0, 1));
|
|
513
|
+
|
|
514
|
+
class Keypair {
|
|
515
|
+
|
|
516
|
+
static __wrap(ptr) {
|
|
517
|
+
ptr = ptr >>> 0;
|
|
518
|
+
const obj = Object.create(Keypair.prototype);
|
|
519
|
+
obj.__wbg_ptr = ptr;
|
|
520
|
+
KeypairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
521
|
+
return obj;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
__destroy_into_raw() {
|
|
525
|
+
const ptr = this.__wbg_ptr;
|
|
526
|
+
this.__wbg_ptr = 0;
|
|
527
|
+
KeypairFinalization.unregister(this);
|
|
528
|
+
return ptr;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
free() {
|
|
532
|
+
const ptr = this.__destroy_into_raw();
|
|
533
|
+
wasm.__wbg_keypair_free(ptr, 0);
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Generate a random [Keypair]
|
|
537
|
+
* @returns {Keypair}
|
|
538
|
+
*/
|
|
539
|
+
static random() {
|
|
540
|
+
const ret = wasm.keypair_random();
|
|
541
|
+
return Keypair.__wrap(ret);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Generate a [Keypair] from a secret key.
|
|
545
|
+
* @param {Uint8Array} secret_key
|
|
546
|
+
* @returns {Keypair}
|
|
547
|
+
*/
|
|
548
|
+
static fromSecretKey(secret_key) {
|
|
549
|
+
try {
|
|
550
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
551
|
+
wasm.keypair_fromSecretKey(retptr, addHeapObject(secret_key));
|
|
552
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
553
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
554
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
555
|
+
if (r2) {
|
|
556
|
+
throw takeObject(r1);
|
|
557
|
+
}
|
|
558
|
+
return Keypair.__wrap(r0);
|
|
559
|
+
} finally {
|
|
560
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Returns the secret key of this keypair.
|
|
565
|
+
* @returns {Uint8Array}
|
|
566
|
+
*/
|
|
567
|
+
secretKey() {
|
|
568
|
+
const ret = wasm.keypair_secretKey(this.__wbg_ptr);
|
|
569
|
+
return takeObject(ret);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Returns the [PublicKey] of this keypair.
|
|
573
|
+
* @returns {PublicKey}
|
|
574
|
+
*/
|
|
575
|
+
publicKey() {
|
|
576
|
+
const ret = wasm.keypair_publicKey(this.__wbg_ptr);
|
|
577
|
+
return PublicKey.__wrap(ret);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
module.exports.Keypair = Keypair;
|
|
581
|
+
|
|
582
|
+
const PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
583
|
+
? { register: () => {}, unregister: () => {} }
|
|
584
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_publickey_free(ptr >>> 0, 1));
|
|
585
|
+
|
|
586
|
+
class PublicKey {
|
|
587
|
+
|
|
588
|
+
static __wrap(ptr) {
|
|
589
|
+
ptr = ptr >>> 0;
|
|
590
|
+
const obj = Object.create(PublicKey.prototype);
|
|
591
|
+
obj.__wbg_ptr = ptr;
|
|
592
|
+
PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
593
|
+
return obj;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
__destroy_into_raw() {
|
|
597
|
+
const ptr = this.__wbg_ptr;
|
|
598
|
+
this.__wbg_ptr = 0;
|
|
599
|
+
PublicKeyFinalization.unregister(this);
|
|
600
|
+
return ptr;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
free() {
|
|
604
|
+
const ptr = this.__destroy_into_raw();
|
|
605
|
+
wasm.__wbg_publickey_free(ptr, 0);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Convert the PublicKey to Uint8Array
|
|
609
|
+
* @returns {Uint8Array}
|
|
610
|
+
*/
|
|
611
|
+
to_uint8array() {
|
|
612
|
+
const ret = wasm.publickey_to_uint8array(this.__wbg_ptr);
|
|
613
|
+
return takeObject(ret);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Returns the z-base32 encoding of this public key
|
|
617
|
+
* @returns {string}
|
|
618
|
+
*/
|
|
619
|
+
z32() {
|
|
620
|
+
let deferred1_0;
|
|
621
|
+
let deferred1_1;
|
|
622
|
+
try {
|
|
623
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
624
|
+
wasm.publickey_z32(retptr, this.__wbg_ptr);
|
|
625
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
626
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
627
|
+
deferred1_0 = r0;
|
|
628
|
+
deferred1_1 = r1;
|
|
629
|
+
return getStringFromWasm0(r0, r1);
|
|
630
|
+
} finally {
|
|
631
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
632
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* @throws
|
|
637
|
+
* @param {any} value
|
|
638
|
+
* @returns {PublicKey}
|
|
639
|
+
*/
|
|
640
|
+
static from(value) {
|
|
641
|
+
try {
|
|
642
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
643
|
+
wasm.publickey_from(retptr, addHeapObject(value));
|
|
644
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
645
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
646
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
647
|
+
if (r2) {
|
|
648
|
+
throw takeObject(r1);
|
|
649
|
+
}
|
|
650
|
+
return PublicKey.__wrap(r0);
|
|
651
|
+
} finally {
|
|
652
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
module.exports.PublicKey = PublicKey;
|
|
657
|
+
|
|
658
|
+
const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
659
|
+
? { register: () => {}, unregister: () => {} }
|
|
660
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr >>> 0, 1));
|
|
661
|
+
|
|
662
|
+
class Session {
|
|
663
|
+
|
|
664
|
+
static __wrap(ptr) {
|
|
665
|
+
ptr = ptr >>> 0;
|
|
666
|
+
const obj = Object.create(Session.prototype);
|
|
667
|
+
obj.__wbg_ptr = ptr;
|
|
668
|
+
SessionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
669
|
+
return obj;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
__destroy_into_raw() {
|
|
673
|
+
const ptr = this.__wbg_ptr;
|
|
674
|
+
this.__wbg_ptr = 0;
|
|
675
|
+
SessionFinalization.unregister(this);
|
|
676
|
+
return ptr;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
free() {
|
|
680
|
+
const ptr = this.__destroy_into_raw();
|
|
681
|
+
wasm.__wbg_session_free(ptr, 0);
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Return the [PublicKey] of this session
|
|
685
|
+
* @returns {PublicKey}
|
|
686
|
+
*/
|
|
687
|
+
pubky() {
|
|
688
|
+
const ret = wasm.session_pubky(this.__wbg_ptr);
|
|
689
|
+
return PublicKey.__wrap(ret);
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Return the capabilities that this session has.
|
|
693
|
+
* @returns {(string)[]}
|
|
694
|
+
*/
|
|
695
|
+
capabilities() {
|
|
696
|
+
try {
|
|
697
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
698
|
+
wasm.session_capabilities(retptr, this.__wbg_ptr);
|
|
699
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
700
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
701
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
702
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
703
|
+
return v1;
|
|
704
|
+
} finally {
|
|
705
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
module.exports.Session = Session;
|
|
710
|
+
|
|
711
|
+
module.exports.__wbg_abort_05026c983d86824c = function(arg0) {
|
|
712
|
+
getObject(arg0).abort();
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
module.exports.__wbg_append_72d1635ad8643998 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
716
|
+
getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
717
|
+
}, arguments) };
|
|
718
|
+
|
|
719
|
+
module.exports.__wbg_arrayBuffer_d0ca2ad8bda0039b = function() { return handleError(function (arg0) {
|
|
720
|
+
const ret = getObject(arg0).arrayBuffer();
|
|
721
|
+
return addHeapObject(ret);
|
|
722
|
+
}, arguments) };
|
|
723
|
+
|
|
724
|
+
module.exports.__wbg_buffer_61b7ce01341d7f88 = function(arg0) {
|
|
725
|
+
const ret = getObject(arg0).buffer;
|
|
726
|
+
return addHeapObject(ret);
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
module.exports.__wbg_byteLength_1b2d953758afc500 = function(arg0) {
|
|
730
|
+
const ret = getObject(arg0).byteLength;
|
|
731
|
+
return ret;
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
module.exports.__wbg_call_500db948e69c7330 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
735
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
736
|
+
return addHeapObject(ret);
|
|
737
|
+
}, arguments) };
|
|
738
|
+
|
|
739
|
+
module.exports.__wbg_call_b0d8e36992d9900d = function() { return handleError(function (arg0, arg1) {
|
|
740
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
741
|
+
return addHeapObject(ret);
|
|
742
|
+
}, arguments) };
|
|
743
|
+
|
|
744
|
+
module.exports.__wbg_crypto_ed58b8e10a292839 = function(arg0) {
|
|
745
|
+
const ret = getObject(arg0).crypto;
|
|
746
|
+
return addHeapObject(ret);
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
module.exports.__wbg_debug_19114f11037e4658 = function(arg0, arg1, arg2, arg3) {
|
|
750
|
+
console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
module.exports.__wbg_done_f22c1561fa919baa = function(arg0) {
|
|
754
|
+
const ret = getObject(arg0).done;
|
|
755
|
+
return ret;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
module.exports.__wbg_error_483d659117b6f3f6 = function(arg0, arg1, arg2, arg3) {
|
|
759
|
+
console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
module.exports.__wbg_fetch_229368eecee9d217 = function(arg0, arg1) {
|
|
763
|
+
const ret = getObject(arg0).fetch(getObject(arg1));
|
|
764
|
+
return addHeapObject(ret);
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
module.exports.__wbg_fetch_408fc9f7fddb9d4e = function(arg0) {
|
|
768
|
+
const ret = fetch(getObject(arg0));
|
|
769
|
+
return addHeapObject(ret);
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
module.exports.__wbg_fetch_4465c2b10f21a927 = function(arg0) {
|
|
773
|
+
const ret = fetch(getObject(arg0));
|
|
774
|
+
return addHeapObject(ret);
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
|
|
778
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
779
|
+
}, arguments) };
|
|
780
|
+
|
|
781
|
+
module.exports.__wbg_get_bbccf8970793c087 = function() { return handleError(function (arg0, arg1) {
|
|
782
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
783
|
+
return addHeapObject(ret);
|
|
784
|
+
}, arguments) };
|
|
785
|
+
|
|
786
|
+
module.exports.__wbg_getheaders_82a20f9b60524a86 = function(arg0) {
|
|
787
|
+
const ret = getObject(arg0).headers;
|
|
788
|
+
return addHeapObject(ret);
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
module.exports.__wbg_has_94c2fc1d261bbfe9 = function() { return handleError(function (arg0, arg1) {
|
|
792
|
+
const ret = Reflect.has(getObject(arg0), getObject(arg1));
|
|
793
|
+
return ret;
|
|
794
|
+
}, arguments) };
|
|
795
|
+
|
|
796
|
+
module.exports.__wbg_headers_24e3e19fe3f187c0 = function(arg0) {
|
|
797
|
+
const ret = getObject(arg0).headers;
|
|
798
|
+
return addHeapObject(ret);
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
module.exports.__wbg_info_18e75e6ce8a36a90 = function(arg0, arg1, arg2, arg3) {
|
|
802
|
+
console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
module.exports.__wbg_instanceof_Response_d3453657e10c4300 = function(arg0) {
|
|
806
|
+
let result;
|
|
807
|
+
try {
|
|
808
|
+
result = getObject(arg0) instanceof Response;
|
|
809
|
+
} catch (_) {
|
|
810
|
+
result = false;
|
|
811
|
+
}
|
|
812
|
+
const ret = result;
|
|
813
|
+
return ret;
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
module.exports.__wbg_instanceof_Uint8Array_28af5bc19d6acad8 = function(arg0) {
|
|
817
|
+
let result;
|
|
818
|
+
try {
|
|
819
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
820
|
+
} catch (_) {
|
|
821
|
+
result = false;
|
|
822
|
+
}
|
|
823
|
+
const ret = result;
|
|
824
|
+
return ret;
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
module.exports.__wbg_iterator_23604bb983791576 = function() {
|
|
828
|
+
const ret = Symbol.iterator;
|
|
829
|
+
return addHeapObject(ret);
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
module.exports.__wbg_length_65d1cd11729ced11 = function(arg0) {
|
|
833
|
+
const ret = getObject(arg0).length;
|
|
834
|
+
return ret;
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
module.exports.__wbg_log_bc77772961bf21bb = function(arg0, arg1, arg2, arg3) {
|
|
838
|
+
console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
|
|
842
|
+
const ret = getObject(arg0).msCrypto;
|
|
843
|
+
return addHeapObject(ret);
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
module.exports.__wbg_new_254fa9eac11932ae = function() {
|
|
847
|
+
const ret = new Array();
|
|
848
|
+
return addHeapObject(ret);
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
module.exports.__wbg_new_35d748855c4620b9 = function() { return handleError(function () {
|
|
852
|
+
const ret = new Headers();
|
|
853
|
+
return addHeapObject(ret);
|
|
854
|
+
}, arguments) };
|
|
855
|
+
|
|
856
|
+
module.exports.__wbg_new_3d446df9155128ef = function(arg0, arg1) {
|
|
857
|
+
try {
|
|
858
|
+
var state0 = {a: arg0, b: arg1};
|
|
859
|
+
var cb0 = (arg0, arg1) => {
|
|
860
|
+
const a = state0.a;
|
|
861
|
+
state0.a = 0;
|
|
862
|
+
try {
|
|
863
|
+
return __wbg_adapter_153(a, state0.b, arg0, arg1);
|
|
864
|
+
} finally {
|
|
865
|
+
state0.a = a;
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
const ret = new Promise(cb0);
|
|
869
|
+
return addHeapObject(ret);
|
|
870
|
+
} finally {
|
|
871
|
+
state0.a = state0.b = 0;
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
module.exports.__wbg_new_3ff5b33b1ce712df = function(arg0) {
|
|
876
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
877
|
+
return addHeapObject(ret);
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
module.exports.__wbg_new_5f48f21d4be11586 = function() { return handleError(function () {
|
|
881
|
+
const ret = new AbortController();
|
|
882
|
+
return addHeapObject(ret);
|
|
883
|
+
}, arguments) };
|
|
884
|
+
|
|
885
|
+
module.exports.__wbg_new_688846f374351c92 = function() {
|
|
886
|
+
const ret = new Object();
|
|
887
|
+
return addHeapObject(ret);
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
module.exports.__wbg_newnoargs_fd9e4bf8be2bc16d = function(arg0, arg1) {
|
|
891
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
892
|
+
return addHeapObject(ret);
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
module.exports.__wbg_newwithbyteoffsetandlength_ba35896968751d91 = function(arg0, arg1, arg2) {
|
|
896
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
897
|
+
return addHeapObject(ret);
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
module.exports.__wbg_newwithlength_34ce8f1051e74449 = function(arg0) {
|
|
901
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
902
|
+
return addHeapObject(ret);
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
module.exports.__wbg_newwithstrandinit_a1f6583f20e4faff = function() { return handleError(function (arg0, arg1, arg2) {
|
|
906
|
+
const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
|
|
907
|
+
return addHeapObject(ret);
|
|
908
|
+
}, arguments) };
|
|
909
|
+
|
|
910
|
+
module.exports.__wbg_next_01dd9234a5bf6d05 = function() { return handleError(function (arg0) {
|
|
911
|
+
const ret = getObject(arg0).next();
|
|
912
|
+
return addHeapObject(ret);
|
|
913
|
+
}, arguments) };
|
|
914
|
+
|
|
915
|
+
module.exports.__wbg_next_137428deb98342b0 = function(arg0) {
|
|
916
|
+
const ret = getObject(arg0).next;
|
|
917
|
+
return addHeapObject(ret);
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
module.exports.__wbg_node_02999533c4ea02e3 = function(arg0) {
|
|
921
|
+
const ret = getObject(arg0).node;
|
|
922
|
+
return addHeapObject(ret);
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
module.exports.__wbg_now_64d0bb151e5d3889 = function() {
|
|
926
|
+
const ret = Date.now();
|
|
927
|
+
return ret;
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
module.exports.__wbg_process_5c1d670bc53614b8 = function(arg0) {
|
|
931
|
+
const ret = getObject(arg0).process;
|
|
932
|
+
return addHeapObject(ret);
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
module.exports.__wbg_publickey_new = function(arg0) {
|
|
936
|
+
const ret = PublicKey.__wrap(arg0);
|
|
937
|
+
return addHeapObject(ret);
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
module.exports.__wbg_push_6edad0df4b546b2c = function(arg0, arg1) {
|
|
941
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
942
|
+
return ret;
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
module.exports.__wbg_queueMicrotask_2181040e064c0dc8 = function(arg0) {
|
|
946
|
+
queueMicrotask(getObject(arg0));
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
module.exports.__wbg_queueMicrotask_ef9ac43769cbcc4f = function(arg0) {
|
|
950
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
951
|
+
return addHeapObject(ret);
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) {
|
|
955
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
956
|
+
}, arguments) };
|
|
957
|
+
|
|
958
|
+
module.exports.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
|
|
959
|
+
const ret = module.require;
|
|
960
|
+
return addHeapObject(ret);
|
|
961
|
+
}, arguments) };
|
|
962
|
+
|
|
963
|
+
module.exports.__wbg_resolve_0bf7c44d641804f9 = function(arg0) {
|
|
964
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
965
|
+
return addHeapObject(ret);
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
module.exports.__wbg_session_new = function(arg0) {
|
|
969
|
+
const ret = Session.__wrap(arg0);
|
|
970
|
+
return addHeapObject(ret);
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
module.exports.__wbg_set_23d69db4e5c66a6e = function(arg0, arg1, arg2) {
|
|
974
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
module.exports.__wbg_setbody_64920df008e48adc = function(arg0, arg1) {
|
|
978
|
+
getObject(arg0).body = getObject(arg1);
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
module.exports.__wbg_setcredentials_cfc15e48e3a3a535 = function(arg0, arg1) {
|
|
982
|
+
getObject(arg0).credentials = __wbindgen_enum_RequestCredentials[arg1];
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
module.exports.__wbg_setheaders_4c921e8e226bdfa7 = function(arg0, arg1) {
|
|
986
|
+
getObject(arg0).headers = getObject(arg1);
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
module.exports.__wbg_setmethod_cfc7f688ba46a6be = function(arg0, arg1, arg2) {
|
|
990
|
+
getObject(arg0).method = getStringFromWasm0(arg1, arg2);
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
module.exports.__wbg_setmode_cd03637eb7da01e0 = function(arg0, arg1) {
|
|
994
|
+
getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
module.exports.__wbg_setsignal_f766190d206f09e5 = function(arg0, arg1) {
|
|
998
|
+
getObject(arg0).signal = getObject(arg1);
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
module.exports.__wbg_signal_1fdadeba2d04660e = function(arg0) {
|
|
1002
|
+
const ret = getObject(arg0).signal;
|
|
1003
|
+
return addHeapObject(ret);
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
module.exports.__wbg_static_accessor_GLOBAL_0be7472e492ad3e3 = function() {
|
|
1007
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1008
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
module.exports.__wbg_static_accessor_GLOBAL_THIS_1a6eb482d12c9bfb = function() {
|
|
1012
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1013
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
module.exports.__wbg_static_accessor_SELF_1dc398a895c82351 = function() {
|
|
1017
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1018
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
module.exports.__wbg_static_accessor_WINDOW_ae1c80c7eea8d64a = function() {
|
|
1022
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1023
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
module.exports.__wbg_status_317f53bc4c7638df = function(arg0) {
|
|
1027
|
+
const ret = getObject(arg0).status;
|
|
1028
|
+
return ret;
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
module.exports.__wbg_stringify_f4f701bc34ceda61 = function() { return handleError(function (arg0) {
|
|
1032
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
1033
|
+
return addHeapObject(ret);
|
|
1034
|
+
}, arguments) };
|
|
1035
|
+
|
|
1036
|
+
module.exports.__wbg_subarray_46adeb9b86949d12 = function(arg0, arg1, arg2) {
|
|
1037
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1038
|
+
return addHeapObject(ret);
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
module.exports.__wbg_text_dfc4cb7631d2eb34 = function() { return handleError(function (arg0) {
|
|
1042
|
+
const ret = getObject(arg0).text();
|
|
1043
|
+
return addHeapObject(ret);
|
|
1044
|
+
}, arguments) };
|
|
1045
|
+
|
|
1046
|
+
module.exports.__wbg_then_0438fad860fe38e1 = function(arg0, arg1) {
|
|
1047
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
1048
|
+
return addHeapObject(ret);
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
module.exports.__wbg_then_0ffafeddf0e182a4 = function(arg0, arg1, arg2) {
|
|
1052
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
1053
|
+
return addHeapObject(ret);
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
module.exports.__wbg_url_5327bc0a41a9b085 = function(arg0, arg1) {
|
|
1057
|
+
const ret = getObject(arg1).url;
|
|
1058
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1059
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1060
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1061
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
module.exports.__wbg_value_4c32fd138a88eee2 = function(arg0) {
|
|
1065
|
+
const ret = getObject(arg0).value;
|
|
1066
|
+
return addHeapObject(ret);
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
module.exports.__wbg_versions_c71aa1626a93e0a1 = function(arg0) {
|
|
1070
|
+
const ret = getObject(arg0).versions;
|
|
1071
|
+
return addHeapObject(ret);
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
module.exports.__wbg_warn_cb8be8bbf790a5d6 = function(arg0, arg1, arg2, arg3) {
|
|
1075
|
+
console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
1079
|
+
const obj = takeObject(arg0).original;
|
|
1080
|
+
if (obj.cnt-- == 1) {
|
|
1081
|
+
obj.a = 0;
|
|
1082
|
+
return true;
|
|
1083
|
+
}
|
|
1084
|
+
const ret = false;
|
|
1085
|
+
return ret;
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
module.exports.__wbindgen_closure_wrapper2630 = function(arg0, arg1, arg2) {
|
|
1089
|
+
const ret = makeMutClosure(arg0, arg1, 540, __wbg_adapter_28);
|
|
1090
|
+
return addHeapObject(ret);
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
1094
|
+
const ret = debugString(getObject(arg1));
|
|
1095
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1096
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1097
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1098
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
module.exports.__wbindgen_is_function = function(arg0) {
|
|
1102
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
1103
|
+
return ret;
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
module.exports.__wbindgen_is_null = function(arg0) {
|
|
1107
|
+
const ret = getObject(arg0) === null;
|
|
1108
|
+
return ret;
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
module.exports.__wbindgen_is_object = function(arg0) {
|
|
1112
|
+
const val = getObject(arg0);
|
|
1113
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1114
|
+
return ret;
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
module.exports.__wbindgen_is_string = function(arg0) {
|
|
1118
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
1119
|
+
return ret;
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
1123
|
+
const ret = getObject(arg0) === undefined;
|
|
1124
|
+
return ret;
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
module.exports.__wbindgen_memory = function() {
|
|
1128
|
+
const ret = wasm.memory;
|
|
1129
|
+
return addHeapObject(ret);
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1132
|
+
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
1133
|
+
const ret = getObject(arg0);
|
|
1134
|
+
return addHeapObject(ret);
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
1138
|
+
takeObject(arg0);
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
1142
|
+
const obj = getObject(arg1);
|
|
1143
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1144
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1145
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1146
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1147
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
1151
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1152
|
+
return addHeapObject(ret);
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
1156
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
const path = require('path').join(__dirname, 'pubky_bg.wasm');
|
|
1160
|
+
const bytes = require('fs').readFileSync(path);
|
|
1161
|
+
|
|
1162
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
1163
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
1164
|
+
wasm = wasmInstance.exports;
|
|
1165
|
+
module.exports.__wasm = wasm;
|
|
1166
|
+
|