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