@synonymdev/pubky 0.1.6 → 0.1.8
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/nodejs/pubky.d.ts +125 -0
- package/nodejs/pubky.js +965 -0
- package/nodejs/pubky_bg.wasm +0 -0
- package/nodejs/pubky_bg.wasm.d.ts +32 -0
- package/package.json +8 -8
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
*/
|
|
5
|
+
export class Keypair {
|
|
6
|
+
free(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Generate a random [Keypair]
|
|
9
|
+
* @returns {Keypair}
|
|
10
|
+
*/
|
|
11
|
+
static random(): Keypair;
|
|
12
|
+
/**
|
|
13
|
+
* Generate a [Keypair] from a secret key.
|
|
14
|
+
* @param {Uint8Array} secret_key
|
|
15
|
+
* @returns {Keypair}
|
|
16
|
+
*/
|
|
17
|
+
static from_secret_key(secret_key: Uint8Array): Keypair;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the [PublicKey] of this keypair.
|
|
20
|
+
* @returns {PublicKey}
|
|
21
|
+
*/
|
|
22
|
+
publicKey(): PublicKey;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
*/
|
|
26
|
+
export class PubkyClient {
|
|
27
|
+
free(): void;
|
|
28
|
+
/**
|
|
29
|
+
*/
|
|
30
|
+
constructor();
|
|
31
|
+
/**
|
|
32
|
+
* Create a client with with configurations appropriate for local testing:
|
|
33
|
+
* - set Pkarr relays to `["http://localhost:15411/pkarr"]` instead of default relay.
|
|
34
|
+
* @returns {PubkyClient}
|
|
35
|
+
*/
|
|
36
|
+
static testnet(): PubkyClient;
|
|
37
|
+
/**
|
|
38
|
+
* Set Pkarr relays used for publishing and resolving Pkarr packets.
|
|
39
|
+
*
|
|
40
|
+
* By default, [PubkyClient] will use `["https://relay.pkarr.org"]`
|
|
41
|
+
* @param {any[]} relays
|
|
42
|
+
* @returns {PubkyClient}
|
|
43
|
+
*/
|
|
44
|
+
setPkarrRelays(relays: any[]): PubkyClient;
|
|
45
|
+
/**
|
|
46
|
+
* @returns {any[]}
|
|
47
|
+
*/
|
|
48
|
+
getPkarrRelays(): any[];
|
|
49
|
+
/**
|
|
50
|
+
* Signup to a homeserver and update Pkarr accordingly.
|
|
51
|
+
*
|
|
52
|
+
* The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
|
|
53
|
+
* for example "pubky.o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy"
|
|
54
|
+
* @param {Keypair} keypair
|
|
55
|
+
* @param {PublicKey} homeserver
|
|
56
|
+
* @returns {Promise<void>}
|
|
57
|
+
*/
|
|
58
|
+
signup(keypair: Keypair, homeserver: PublicKey): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Check the current sesison for a given Pubky in its homeserver.
|
|
61
|
+
*
|
|
62
|
+
* Returns [Session] or `None` (if recieved `404 NOT_FOUND`),
|
|
63
|
+
* or throws the recieved error if the response has any other `>=400` status code.
|
|
64
|
+
* @param {PublicKey} pubky
|
|
65
|
+
* @returns {Promise<Session | undefined>}
|
|
66
|
+
*/
|
|
67
|
+
session(pubky: PublicKey): Promise<Session | undefined>;
|
|
68
|
+
/**
|
|
69
|
+
* Signout from a homeserver.
|
|
70
|
+
* @param {PublicKey} pubky
|
|
71
|
+
* @returns {Promise<void>}
|
|
72
|
+
*/
|
|
73
|
+
signout(pubky: PublicKey): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Signin to a homeserver.
|
|
76
|
+
* @param {Keypair} keypair
|
|
77
|
+
* @returns {Promise<void>}
|
|
78
|
+
*/
|
|
79
|
+
signin(keypair: Keypair): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Upload a small payload to a given path.
|
|
82
|
+
* @param {string} url
|
|
83
|
+
* @param {Uint8Array} content
|
|
84
|
+
* @returns {Promise<void>}
|
|
85
|
+
*/
|
|
86
|
+
put(url: string, content: Uint8Array): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Download a small payload from a given path relative to a pubky author.
|
|
89
|
+
* @param {string} url
|
|
90
|
+
* @returns {Promise<Uint8Array | undefined>}
|
|
91
|
+
*/
|
|
92
|
+
get(url: string): Promise<Uint8Array | undefined>;
|
|
93
|
+
/**
|
|
94
|
+
* Delete a file at a path relative to a pubky author.
|
|
95
|
+
* @param {string} url
|
|
96
|
+
* @returns {Promise<void>}
|
|
97
|
+
*/
|
|
98
|
+
delete(url: string): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
*/
|
|
102
|
+
export class PublicKey {
|
|
103
|
+
free(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Convert the PublicKey to Uint8Array
|
|
106
|
+
* @returns {Uint8Array}
|
|
107
|
+
*/
|
|
108
|
+
to_uint8array(): Uint8Array;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the z-base32 encoding of this public key
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
z32(): string;
|
|
114
|
+
/**
|
|
115
|
+
* @throws
|
|
116
|
+
* @param {any} value
|
|
117
|
+
* @returns {PublicKey}
|
|
118
|
+
*/
|
|
119
|
+
static from(value: any): PublicKey;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
*/
|
|
123
|
+
export class Session {
|
|
124
|
+
free(): void;
|
|
125
|
+
}
|
package/nodejs/pubky.js
ADDED
|
@@ -0,0 +1,965 @@
|
|
|
1
|
+
let imports = {};
|
|
2
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
3
|
+
let wasm;
|
|
4
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
5
|
+
|
|
6
|
+
const heap = new Array(128).fill(undefined);
|
|
7
|
+
|
|
8
|
+
heap.push(undefined, null, true, false);
|
|
9
|
+
|
|
10
|
+
function getObject(idx) { return heap[idx]; }
|
|
11
|
+
|
|
12
|
+
let heap_next = heap.length;
|
|
13
|
+
|
|
14
|
+
function dropObject(idx) {
|
|
15
|
+
if (idx < 132) return;
|
|
16
|
+
heap[idx] = heap_next;
|
|
17
|
+
heap_next = idx;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function takeObject(idx) {
|
|
21
|
+
const ret = getObject(idx);
|
|
22
|
+
dropObject(idx);
|
|
23
|
+
return ret;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let WASM_VECTOR_LEN = 0;
|
|
27
|
+
|
|
28
|
+
let cachedUint8Memory0 = null;
|
|
29
|
+
|
|
30
|
+
function getUint8Memory0() {
|
|
31
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
32
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
33
|
+
}
|
|
34
|
+
return cachedUint8Memory0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
38
|
+
|
|
39
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
40
|
+
? function (arg, view) {
|
|
41
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
42
|
+
}
|
|
43
|
+
: function (arg, view) {
|
|
44
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
45
|
+
view.set(buf);
|
|
46
|
+
return {
|
|
47
|
+
read: arg.length,
|
|
48
|
+
written: buf.length
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
53
|
+
|
|
54
|
+
if (realloc === undefined) {
|
|
55
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
56
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
57
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
58
|
+
WASM_VECTOR_LEN = buf.length;
|
|
59
|
+
return ptr;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let len = arg.length;
|
|
63
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
64
|
+
|
|
65
|
+
const mem = getUint8Memory0();
|
|
66
|
+
|
|
67
|
+
let offset = 0;
|
|
68
|
+
|
|
69
|
+
for (; offset < len; offset++) {
|
|
70
|
+
const code = arg.charCodeAt(offset);
|
|
71
|
+
if (code > 0x7F) break;
|
|
72
|
+
mem[ptr + offset] = code;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (offset !== len) {
|
|
76
|
+
if (offset !== 0) {
|
|
77
|
+
arg = arg.slice(offset);
|
|
78
|
+
}
|
|
79
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
80
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
81
|
+
const ret = encodeString(arg, view);
|
|
82
|
+
|
|
83
|
+
offset += ret.written;
|
|
84
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
WASM_VECTOR_LEN = offset;
|
|
88
|
+
return ptr;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function isLikeNone(x) {
|
|
92
|
+
return x === undefined || x === null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let cachedInt32Memory0 = null;
|
|
96
|
+
|
|
97
|
+
function getInt32Memory0() {
|
|
98
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
99
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
100
|
+
}
|
|
101
|
+
return cachedInt32Memory0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
105
|
+
|
|
106
|
+
cachedTextDecoder.decode();
|
|
107
|
+
|
|
108
|
+
function getStringFromWasm0(ptr, len) {
|
|
109
|
+
ptr = ptr >>> 0;
|
|
110
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function addHeapObject(obj) {
|
|
114
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
115
|
+
const idx = heap_next;
|
|
116
|
+
heap_next = heap[idx];
|
|
117
|
+
|
|
118
|
+
heap[idx] = obj;
|
|
119
|
+
return idx;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function debugString(val) {
|
|
123
|
+
// primitive types
|
|
124
|
+
const type = typeof val;
|
|
125
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
126
|
+
return `${val}`;
|
|
127
|
+
}
|
|
128
|
+
if (type == 'string') {
|
|
129
|
+
return `"${val}"`;
|
|
130
|
+
}
|
|
131
|
+
if (type == 'symbol') {
|
|
132
|
+
const description = val.description;
|
|
133
|
+
if (description == null) {
|
|
134
|
+
return 'Symbol';
|
|
135
|
+
} else {
|
|
136
|
+
return `Symbol(${description})`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (type == 'function') {
|
|
140
|
+
const name = val.name;
|
|
141
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
142
|
+
return `Function(${name})`;
|
|
143
|
+
} else {
|
|
144
|
+
return 'Function';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// objects
|
|
148
|
+
if (Array.isArray(val)) {
|
|
149
|
+
const length = val.length;
|
|
150
|
+
let debug = '[';
|
|
151
|
+
if (length > 0) {
|
|
152
|
+
debug += debugString(val[0]);
|
|
153
|
+
}
|
|
154
|
+
for(let i = 1; i < length; i++) {
|
|
155
|
+
debug += ', ' + debugString(val[i]);
|
|
156
|
+
}
|
|
157
|
+
debug += ']';
|
|
158
|
+
return debug;
|
|
159
|
+
}
|
|
160
|
+
// Test for built-in
|
|
161
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
162
|
+
let className;
|
|
163
|
+
if (builtInMatches.length > 1) {
|
|
164
|
+
className = builtInMatches[1];
|
|
165
|
+
} else {
|
|
166
|
+
// Failed to match the standard '[object ClassName]'
|
|
167
|
+
return toString.call(val);
|
|
168
|
+
}
|
|
169
|
+
if (className == 'Object') {
|
|
170
|
+
// we're a user defined class or Object
|
|
171
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
172
|
+
// easier than looping through ownProperties of `val`.
|
|
173
|
+
try {
|
|
174
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
175
|
+
} catch (_) {
|
|
176
|
+
return 'Object';
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// errors
|
|
180
|
+
if (val instanceof Error) {
|
|
181
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
182
|
+
}
|
|
183
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
184
|
+
return className;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
188
|
+
? { register: () => {}, unregister: () => {} }
|
|
189
|
+
: new FinalizationRegistry(state => {
|
|
190
|
+
wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b)
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
194
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
195
|
+
const real = (...args) => {
|
|
196
|
+
// First up with a closure we increment the internal reference
|
|
197
|
+
// count. This ensures that the Rust closure environment won't
|
|
198
|
+
// be deallocated while we're invoking it.
|
|
199
|
+
state.cnt++;
|
|
200
|
+
const a = state.a;
|
|
201
|
+
state.a = 0;
|
|
202
|
+
try {
|
|
203
|
+
return f(a, state.b, ...args);
|
|
204
|
+
} finally {
|
|
205
|
+
if (--state.cnt === 0) {
|
|
206
|
+
wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
|
|
207
|
+
CLOSURE_DTORS.unregister(state);
|
|
208
|
+
} else {
|
|
209
|
+
state.a = a;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
real.original = state;
|
|
214
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
215
|
+
return real;
|
|
216
|
+
}
|
|
217
|
+
function __wbg_adapter_26(arg0, arg1, arg2) {
|
|
218
|
+
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha5424c6cb7b1ff0d(arg0, arg1, addHeapObject(arg2));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
let cachedUint32Memory0 = null;
|
|
222
|
+
|
|
223
|
+
function getUint32Memory0() {
|
|
224
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
225
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
226
|
+
}
|
|
227
|
+
return cachedUint32Memory0;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
231
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
232
|
+
const mem = getUint32Memory0();
|
|
233
|
+
for (let i = 0; i < array.length; i++) {
|
|
234
|
+
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
|
235
|
+
}
|
|
236
|
+
WASM_VECTOR_LEN = array.length;
|
|
237
|
+
return ptr;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
241
|
+
ptr = ptr >>> 0;
|
|
242
|
+
const mem = getUint32Memory0();
|
|
243
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
244
|
+
const result = [];
|
|
245
|
+
for (let i = 0; i < slice.length; i++) {
|
|
246
|
+
result.push(takeObject(slice[i]));
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function _assertClass(instance, klass) {
|
|
252
|
+
if (!(instance instanceof klass)) {
|
|
253
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
254
|
+
}
|
|
255
|
+
return instance.ptr;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
259
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
260
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
261
|
+
WASM_VECTOR_LEN = arg.length;
|
|
262
|
+
return ptr;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function handleError(f, args) {
|
|
266
|
+
try {
|
|
267
|
+
return f.apply(this, args);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function __wbg_adapter_114(arg0, arg1, arg2, arg3) {
|
|
273
|
+
wasm.wasm_bindgen__convert__closures__invoke2_mut__hcef77123246c6bdb(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const KeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
277
|
+
? { register: () => {}, unregister: () => {} }
|
|
278
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0));
|
|
279
|
+
/**
|
|
280
|
+
*/
|
|
281
|
+
class Keypair {
|
|
282
|
+
|
|
283
|
+
static __wrap(ptr) {
|
|
284
|
+
ptr = ptr >>> 0;
|
|
285
|
+
const obj = Object.create(Keypair.prototype);
|
|
286
|
+
obj.__wbg_ptr = ptr;
|
|
287
|
+
KeypairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
288
|
+
return obj;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
__destroy_into_raw() {
|
|
292
|
+
const ptr = this.__wbg_ptr;
|
|
293
|
+
this.__wbg_ptr = 0;
|
|
294
|
+
KeypairFinalization.unregister(this);
|
|
295
|
+
return ptr;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
free() {
|
|
299
|
+
const ptr = this.__destroy_into_raw();
|
|
300
|
+
wasm.__wbg_keypair_free(ptr);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Generate a random [Keypair]
|
|
304
|
+
* @returns {Keypair}
|
|
305
|
+
*/
|
|
306
|
+
static random() {
|
|
307
|
+
const ret = wasm.keypair_random();
|
|
308
|
+
return Keypair.__wrap(ret);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Generate a [Keypair] from a secret key.
|
|
312
|
+
* @param {Uint8Array} secret_key
|
|
313
|
+
* @returns {Keypair}
|
|
314
|
+
*/
|
|
315
|
+
static from_secret_key(secret_key) {
|
|
316
|
+
const ret = wasm.keypair_from_secret_key(addHeapObject(secret_key));
|
|
317
|
+
return Keypair.__wrap(ret);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Returns the [PublicKey] of this keypair.
|
|
321
|
+
* @returns {PublicKey}
|
|
322
|
+
*/
|
|
323
|
+
publicKey() {
|
|
324
|
+
const ret = wasm.keypair_publicKey(this.__wbg_ptr);
|
|
325
|
+
return PublicKey.__wrap(ret);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
module.exports.Keypair = Keypair;
|
|
329
|
+
|
|
330
|
+
const PubkyClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
331
|
+
? { register: () => {}, unregister: () => {} }
|
|
332
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_pubkyclient_free(ptr >>> 0));
|
|
333
|
+
/**
|
|
334
|
+
*/
|
|
335
|
+
class PubkyClient {
|
|
336
|
+
|
|
337
|
+
static __wrap(ptr) {
|
|
338
|
+
ptr = ptr >>> 0;
|
|
339
|
+
const obj = Object.create(PubkyClient.prototype);
|
|
340
|
+
obj.__wbg_ptr = ptr;
|
|
341
|
+
PubkyClientFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
342
|
+
return obj;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
__destroy_into_raw() {
|
|
346
|
+
const ptr = this.__wbg_ptr;
|
|
347
|
+
this.__wbg_ptr = 0;
|
|
348
|
+
PubkyClientFinalization.unregister(this);
|
|
349
|
+
return ptr;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
free() {
|
|
353
|
+
const ptr = this.__destroy_into_raw();
|
|
354
|
+
wasm.__wbg_pubkyclient_free(ptr);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
*/
|
|
358
|
+
constructor() {
|
|
359
|
+
const ret = wasm.pubkyclient_new();
|
|
360
|
+
this.__wbg_ptr = ret >>> 0;
|
|
361
|
+
return this;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Create a client with with configurations appropriate for local testing:
|
|
365
|
+
* - set Pkarr relays to `["http://localhost:15411/pkarr"]` instead of default relay.
|
|
366
|
+
* @returns {PubkyClient}
|
|
367
|
+
*/
|
|
368
|
+
static testnet() {
|
|
369
|
+
const ret = wasm.pubkyclient_testnet();
|
|
370
|
+
return PubkyClient.__wrap(ret);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Set Pkarr relays used for publishing and resolving Pkarr packets.
|
|
374
|
+
*
|
|
375
|
+
* By default, [PubkyClient] will use `["https://relay.pkarr.org"]`
|
|
376
|
+
* @param {any[]} relays
|
|
377
|
+
* @returns {PubkyClient}
|
|
378
|
+
*/
|
|
379
|
+
setPkarrRelays(relays) {
|
|
380
|
+
const ptr = this.__destroy_into_raw();
|
|
381
|
+
const ptr0 = passArrayJsValueToWasm0(relays, wasm.__wbindgen_malloc);
|
|
382
|
+
const len0 = WASM_VECTOR_LEN;
|
|
383
|
+
const ret = wasm.pubkyclient_setPkarrRelays(ptr, ptr0, len0);
|
|
384
|
+
return PubkyClient.__wrap(ret);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* @returns {any[]}
|
|
388
|
+
*/
|
|
389
|
+
getPkarrRelays() {
|
|
390
|
+
try {
|
|
391
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
392
|
+
wasm.pubkyclient_getPkarrRelays(retptr, this.__wbg_ptr);
|
|
393
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
394
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
395
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
396
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
397
|
+
return v1;
|
|
398
|
+
} finally {
|
|
399
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Signup to a homeserver and update Pkarr accordingly.
|
|
404
|
+
*
|
|
405
|
+
* The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
|
|
406
|
+
* for example "pubky.o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy"
|
|
407
|
+
* @param {Keypair} keypair
|
|
408
|
+
* @param {PublicKey} homeserver
|
|
409
|
+
* @returns {Promise<void>}
|
|
410
|
+
*/
|
|
411
|
+
signup(keypair, homeserver) {
|
|
412
|
+
_assertClass(keypair, Keypair);
|
|
413
|
+
_assertClass(homeserver, PublicKey);
|
|
414
|
+
const ret = wasm.pubkyclient_signup(this.__wbg_ptr, keypair.__wbg_ptr, homeserver.__wbg_ptr);
|
|
415
|
+
return takeObject(ret);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Check the current sesison for a given Pubky in its homeserver.
|
|
419
|
+
*
|
|
420
|
+
* Returns [Session] or `None` (if recieved `404 NOT_FOUND`),
|
|
421
|
+
* or throws the recieved error if the response has any other `>=400` status code.
|
|
422
|
+
* @param {PublicKey} pubky
|
|
423
|
+
* @returns {Promise<Session | undefined>}
|
|
424
|
+
*/
|
|
425
|
+
session(pubky) {
|
|
426
|
+
_assertClass(pubky, PublicKey);
|
|
427
|
+
const ret = wasm.pubkyclient_session(this.__wbg_ptr, pubky.__wbg_ptr);
|
|
428
|
+
return takeObject(ret);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Signout from a homeserver.
|
|
432
|
+
* @param {PublicKey} pubky
|
|
433
|
+
* @returns {Promise<void>}
|
|
434
|
+
*/
|
|
435
|
+
signout(pubky) {
|
|
436
|
+
_assertClass(pubky, PublicKey);
|
|
437
|
+
const ret = wasm.pubkyclient_signout(this.__wbg_ptr, pubky.__wbg_ptr);
|
|
438
|
+
return takeObject(ret);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Signin to a homeserver.
|
|
442
|
+
* @param {Keypair} keypair
|
|
443
|
+
* @returns {Promise<void>}
|
|
444
|
+
*/
|
|
445
|
+
signin(keypair) {
|
|
446
|
+
_assertClass(keypair, Keypair);
|
|
447
|
+
const ret = wasm.pubkyclient_signin(this.__wbg_ptr, keypair.__wbg_ptr);
|
|
448
|
+
return takeObject(ret);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Upload a small payload to a given path.
|
|
452
|
+
* @param {string} url
|
|
453
|
+
* @param {Uint8Array} content
|
|
454
|
+
* @returns {Promise<void>}
|
|
455
|
+
*/
|
|
456
|
+
put(url, content) {
|
|
457
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
458
|
+
const len0 = WASM_VECTOR_LEN;
|
|
459
|
+
const ptr1 = passArray8ToWasm0(content, wasm.__wbindgen_malloc);
|
|
460
|
+
const len1 = WASM_VECTOR_LEN;
|
|
461
|
+
const ret = wasm.pubkyclient_put(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
462
|
+
return takeObject(ret);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Download a small payload from a given path relative to a pubky author.
|
|
466
|
+
* @param {string} url
|
|
467
|
+
* @returns {Promise<Uint8Array | undefined>}
|
|
468
|
+
*/
|
|
469
|
+
get(url) {
|
|
470
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
471
|
+
const len0 = WASM_VECTOR_LEN;
|
|
472
|
+
const ret = wasm.pubkyclient_get(this.__wbg_ptr, ptr0, len0);
|
|
473
|
+
return takeObject(ret);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Delete a file at a path relative to a pubky author.
|
|
477
|
+
* @param {string} url
|
|
478
|
+
* @returns {Promise<void>}
|
|
479
|
+
*/
|
|
480
|
+
delete(url) {
|
|
481
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
482
|
+
const len0 = WASM_VECTOR_LEN;
|
|
483
|
+
const ret = wasm.pubkyclient_delete(this.__wbg_ptr, ptr0, len0);
|
|
484
|
+
return takeObject(ret);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
module.exports.PubkyClient = PubkyClient;
|
|
488
|
+
|
|
489
|
+
const PublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
490
|
+
? { register: () => {}, unregister: () => {} }
|
|
491
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_publickey_free(ptr >>> 0));
|
|
492
|
+
/**
|
|
493
|
+
*/
|
|
494
|
+
class PublicKey {
|
|
495
|
+
|
|
496
|
+
static __wrap(ptr) {
|
|
497
|
+
ptr = ptr >>> 0;
|
|
498
|
+
const obj = Object.create(PublicKey.prototype);
|
|
499
|
+
obj.__wbg_ptr = ptr;
|
|
500
|
+
PublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
501
|
+
return obj;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
__destroy_into_raw() {
|
|
505
|
+
const ptr = this.__wbg_ptr;
|
|
506
|
+
this.__wbg_ptr = 0;
|
|
507
|
+
PublicKeyFinalization.unregister(this);
|
|
508
|
+
return ptr;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
free() {
|
|
512
|
+
const ptr = this.__destroy_into_raw();
|
|
513
|
+
wasm.__wbg_publickey_free(ptr);
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Convert the PublicKey to Uint8Array
|
|
517
|
+
* @returns {Uint8Array}
|
|
518
|
+
*/
|
|
519
|
+
to_uint8array() {
|
|
520
|
+
const ret = wasm.publickey_to_uint8array(this.__wbg_ptr);
|
|
521
|
+
return takeObject(ret);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Returns the z-base32 encoding of this public key
|
|
525
|
+
* @returns {string}
|
|
526
|
+
*/
|
|
527
|
+
z32() {
|
|
528
|
+
let deferred1_0;
|
|
529
|
+
let deferred1_1;
|
|
530
|
+
try {
|
|
531
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
532
|
+
wasm.publickey_z32(retptr, this.__wbg_ptr);
|
|
533
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
534
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
535
|
+
deferred1_0 = r0;
|
|
536
|
+
deferred1_1 = r1;
|
|
537
|
+
return getStringFromWasm0(r0, r1);
|
|
538
|
+
} finally {
|
|
539
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
540
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* @throws
|
|
545
|
+
* @param {any} value
|
|
546
|
+
* @returns {PublicKey}
|
|
547
|
+
*/
|
|
548
|
+
static from(value) {
|
|
549
|
+
try {
|
|
550
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
551
|
+
wasm.publickey_from(retptr, addHeapObject(value));
|
|
552
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
553
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
554
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
555
|
+
if (r2) {
|
|
556
|
+
throw takeObject(r1);
|
|
557
|
+
}
|
|
558
|
+
return PublicKey.__wrap(r0);
|
|
559
|
+
} finally {
|
|
560
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
module.exports.PublicKey = PublicKey;
|
|
565
|
+
|
|
566
|
+
const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
567
|
+
? { register: () => {}, unregister: () => {} }
|
|
568
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr >>> 0));
|
|
569
|
+
/**
|
|
570
|
+
*/
|
|
571
|
+
class Session {
|
|
572
|
+
|
|
573
|
+
static __wrap(ptr) {
|
|
574
|
+
ptr = ptr >>> 0;
|
|
575
|
+
const obj = Object.create(Session.prototype);
|
|
576
|
+
obj.__wbg_ptr = ptr;
|
|
577
|
+
SessionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
578
|
+
return obj;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
__destroy_into_raw() {
|
|
582
|
+
const ptr = this.__wbg_ptr;
|
|
583
|
+
this.__wbg_ptr = 0;
|
|
584
|
+
SessionFinalization.unregister(this);
|
|
585
|
+
return ptr;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
free() {
|
|
589
|
+
const ptr = this.__destroy_into_raw();
|
|
590
|
+
wasm.__wbg_session_free(ptr);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
module.exports.Session = Session;
|
|
594
|
+
|
|
595
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
596
|
+
takeObject(arg0);
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
600
|
+
const obj = getObject(arg1);
|
|
601
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
602
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
603
|
+
var len1 = WASM_VECTOR_LEN;
|
|
604
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
605
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
module.exports.__wbg_session_new = function(arg0) {
|
|
609
|
+
const ret = Session.__wrap(arg0);
|
|
610
|
+
return addHeapObject(ret);
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
614
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
615
|
+
return addHeapObject(ret);
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
module.exports.__wbg_fetch_1e4e8ed1f64c7e28 = function(arg0) {
|
|
619
|
+
const ret = fetch(getObject(arg0));
|
|
620
|
+
return addHeapObject(ret);
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
624
|
+
const ret = getObject(arg0);
|
|
625
|
+
return addHeapObject(ret);
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
module.exports.__wbg_fetch_921fad6ef9e883dd = function(arg0, arg1) {
|
|
629
|
+
const ret = getObject(arg0).fetch(getObject(arg1));
|
|
630
|
+
return addHeapObject(ret);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
module.exports.__wbg_signal_a61f78a3478fd9bc = function(arg0) {
|
|
634
|
+
const ret = getObject(arg0).signal;
|
|
635
|
+
return addHeapObject(ret);
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
module.exports.__wbg_new_0d76b0581eca6298 = function() { return handleError(function () {
|
|
639
|
+
const ret = new AbortController();
|
|
640
|
+
return addHeapObject(ret);
|
|
641
|
+
}, arguments) };
|
|
642
|
+
|
|
643
|
+
module.exports.__wbg_abort_2aa7521d5690750e = function(arg0) {
|
|
644
|
+
getObject(arg0).abort();
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
module.exports.__wbg_newwithstrandinit_3fd6fba4083ff2d0 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
648
|
+
const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
|
|
649
|
+
return addHeapObject(ret);
|
|
650
|
+
}, arguments) };
|
|
651
|
+
|
|
652
|
+
module.exports.__wbg_instanceof_Response_849eb93e75734b6e = function(arg0) {
|
|
653
|
+
let result;
|
|
654
|
+
try {
|
|
655
|
+
result = getObject(arg0) instanceof Response;
|
|
656
|
+
} catch (_) {
|
|
657
|
+
result = false;
|
|
658
|
+
}
|
|
659
|
+
const ret = result;
|
|
660
|
+
return ret;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
module.exports.__wbg_url_5f6dc4009ac5f99d = function(arg0, arg1) {
|
|
664
|
+
const ret = getObject(arg1).url;
|
|
665
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
666
|
+
const len1 = WASM_VECTOR_LEN;
|
|
667
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
668
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
module.exports.__wbg_status_61a01141acd3cf74 = function(arg0) {
|
|
672
|
+
const ret = getObject(arg0).status;
|
|
673
|
+
return ret;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
module.exports.__wbg_headers_9620bfada380764a = function(arg0) {
|
|
677
|
+
const ret = getObject(arg0).headers;
|
|
678
|
+
return addHeapObject(ret);
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
module.exports.__wbg_arrayBuffer_29931d52c7206b02 = function() { return handleError(function (arg0) {
|
|
682
|
+
const ret = getObject(arg0).arrayBuffer();
|
|
683
|
+
return addHeapObject(ret);
|
|
684
|
+
}, arguments) };
|
|
685
|
+
|
|
686
|
+
module.exports.__wbg_new_ab6fd82b10560829 = function() { return handleError(function () {
|
|
687
|
+
const ret = new Headers();
|
|
688
|
+
return addHeapObject(ret);
|
|
689
|
+
}, arguments) };
|
|
690
|
+
|
|
691
|
+
module.exports.__wbg_append_7bfcb4937d1d5e29 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
692
|
+
getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
693
|
+
}, arguments) };
|
|
694
|
+
|
|
695
|
+
module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
696
|
+
const obj = takeObject(arg0).original;
|
|
697
|
+
if (obj.cnt-- == 1) {
|
|
698
|
+
obj.a = 0;
|
|
699
|
+
return true;
|
|
700
|
+
}
|
|
701
|
+
const ret = false;
|
|
702
|
+
return ret;
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
module.exports.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) {
|
|
706
|
+
queueMicrotask(getObject(arg0));
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
module.exports.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) {
|
|
710
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
711
|
+
return addHeapObject(ret);
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
module.exports.__wbindgen_is_function = function(arg0) {
|
|
715
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
716
|
+
return ret;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
module.exports.__wbindgen_is_object = function(arg0) {
|
|
720
|
+
const val = getObject(arg0);
|
|
721
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
722
|
+
return ret;
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
module.exports.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
|
|
726
|
+
const ret = getObject(arg0).crypto;
|
|
727
|
+
return addHeapObject(ret);
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
module.exports.__wbg_process_4a72847cc503995b = function(arg0) {
|
|
731
|
+
const ret = getObject(arg0).process;
|
|
732
|
+
return addHeapObject(ret);
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
module.exports.__wbg_versions_f686565e586dd935 = function(arg0) {
|
|
736
|
+
const ret = getObject(arg0).versions;
|
|
737
|
+
return addHeapObject(ret);
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
module.exports.__wbg_node_104a2ff8d6ea03a2 = function(arg0) {
|
|
741
|
+
const ret = getObject(arg0).node;
|
|
742
|
+
return addHeapObject(ret);
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
module.exports.__wbindgen_is_string = function(arg0) {
|
|
746
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
747
|
+
return ret;
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
module.exports.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () {
|
|
751
|
+
const ret = module.require;
|
|
752
|
+
return addHeapObject(ret);
|
|
753
|
+
}, arguments) };
|
|
754
|
+
|
|
755
|
+
module.exports.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {
|
|
756
|
+
const ret = getObject(arg0).msCrypto;
|
|
757
|
+
return addHeapObject(ret);
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
module.exports.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) {
|
|
761
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
762
|
+
}, arguments) };
|
|
763
|
+
|
|
764
|
+
module.exports.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
|
|
765
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
766
|
+
}, arguments) };
|
|
767
|
+
|
|
768
|
+
module.exports.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {
|
|
769
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
770
|
+
return addHeapObject(ret);
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
module.exports.__wbg_next_40fc327bfc8770e6 = function(arg0) {
|
|
774
|
+
const ret = getObject(arg0).next;
|
|
775
|
+
return addHeapObject(ret);
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
module.exports.__wbg_value_d93c65011f51a456 = function(arg0) {
|
|
779
|
+
const ret = getObject(arg0).value;
|
|
780
|
+
return addHeapObject(ret);
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
module.exports.__wbg_iterator_2cee6dadfd956dfa = function() {
|
|
784
|
+
const ret = Symbol.iterator;
|
|
785
|
+
return addHeapObject(ret);
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
module.exports.__wbg_new_72fb9a18b5ae2624 = function() {
|
|
789
|
+
const ret = new Object();
|
|
790
|
+
return addHeapObject(ret);
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
module.exports.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {
|
|
794
|
+
const ret = self.self;
|
|
795
|
+
return addHeapObject(ret);
|
|
796
|
+
}, arguments) };
|
|
797
|
+
|
|
798
|
+
module.exports.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () {
|
|
799
|
+
const ret = window.window;
|
|
800
|
+
return addHeapObject(ret);
|
|
801
|
+
}, arguments) };
|
|
802
|
+
|
|
803
|
+
module.exports.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () {
|
|
804
|
+
const ret = globalThis.globalThis;
|
|
805
|
+
return addHeapObject(ret);
|
|
806
|
+
}, arguments) };
|
|
807
|
+
|
|
808
|
+
module.exports.__wbg_global_207b558942527489 = function() { return handleError(function () {
|
|
809
|
+
const ret = global.global;
|
|
810
|
+
return addHeapObject(ret);
|
|
811
|
+
}, arguments) };
|
|
812
|
+
|
|
813
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
814
|
+
const ret = getObject(arg0) === undefined;
|
|
815
|
+
return ret;
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
module.exports.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) {
|
|
819
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
820
|
+
return addHeapObject(ret);
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
module.exports.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) {
|
|
824
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
825
|
+
return addHeapObject(ret);
|
|
826
|
+
}, arguments) };
|
|
827
|
+
|
|
828
|
+
module.exports.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
829
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
830
|
+
return addHeapObject(ret);
|
|
831
|
+
}, arguments) };
|
|
832
|
+
|
|
833
|
+
module.exports.__wbg_next_196c84450b364254 = function() { return handleError(function (arg0) {
|
|
834
|
+
const ret = getObject(arg0).next();
|
|
835
|
+
return addHeapObject(ret);
|
|
836
|
+
}, arguments) };
|
|
837
|
+
|
|
838
|
+
module.exports.__wbg_done_298b57d23c0fc80c = function(arg0) {
|
|
839
|
+
const ret = getObject(arg0).done;
|
|
840
|
+
return ret;
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
module.exports.__wbg_now_3014639a94423537 = function() {
|
|
844
|
+
const ret = Date.now();
|
|
845
|
+
return ret;
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
module.exports.__wbg_new_81740750da40724f = function(arg0, arg1) {
|
|
849
|
+
try {
|
|
850
|
+
var state0 = {a: arg0, b: arg1};
|
|
851
|
+
var cb0 = (arg0, arg1) => {
|
|
852
|
+
const a = state0.a;
|
|
853
|
+
state0.a = 0;
|
|
854
|
+
try {
|
|
855
|
+
return __wbg_adapter_114(a, state0.b, arg0, arg1);
|
|
856
|
+
} finally {
|
|
857
|
+
state0.a = a;
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
const ret = new Promise(cb0);
|
|
861
|
+
return addHeapObject(ret);
|
|
862
|
+
} finally {
|
|
863
|
+
state0.a = state0.b = 0;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
module.exports.__wbg_resolve_b0083a7967828ec8 = function(arg0) {
|
|
868
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
869
|
+
return addHeapObject(ret);
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
module.exports.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) {
|
|
873
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
874
|
+
return addHeapObject(ret);
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
module.exports.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) {
|
|
878
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
879
|
+
return addHeapObject(ret);
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
module.exports.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
883
|
+
const ret = getObject(arg0).buffer;
|
|
884
|
+
return addHeapObject(ret);
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
module.exports.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
|
|
888
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
889
|
+
return addHeapObject(ret);
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
module.exports.__wbg_new_63b92bc8671ed464 = function(arg0) {
|
|
893
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
894
|
+
return addHeapObject(ret);
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
module.exports.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {
|
|
898
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
899
|
+
return addHeapObject(ret);
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
module.exports.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {
|
|
903
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
904
|
+
return addHeapObject(ret);
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
module.exports.__wbg_length_c20a40f15020d68a = function(arg0) {
|
|
908
|
+
const ret = getObject(arg0).length;
|
|
909
|
+
return ret;
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
module.exports.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
|
|
913
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
module.exports.__wbg_get_e3c254076557e348 = function() { return handleError(function (arg0, arg1) {
|
|
917
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
918
|
+
return addHeapObject(ret);
|
|
919
|
+
}, arguments) };
|
|
920
|
+
|
|
921
|
+
module.exports.__wbg_has_0af94d20077affa2 = function() { return handleError(function (arg0, arg1) {
|
|
922
|
+
const ret = Reflect.has(getObject(arg0), getObject(arg1));
|
|
923
|
+
return ret;
|
|
924
|
+
}, arguments) };
|
|
925
|
+
|
|
926
|
+
module.exports.__wbg_set_1f9b04f170055d33 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
927
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
928
|
+
return ret;
|
|
929
|
+
}, arguments) };
|
|
930
|
+
|
|
931
|
+
module.exports.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
|
|
932
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
933
|
+
return addHeapObject(ret);
|
|
934
|
+
}, arguments) };
|
|
935
|
+
|
|
936
|
+
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
937
|
+
const ret = debugString(getObject(arg1));
|
|
938
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
939
|
+
const len1 = WASM_VECTOR_LEN;
|
|
940
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
941
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
945
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
module.exports.__wbindgen_memory = function() {
|
|
949
|
+
const ret = wasm.memory;
|
|
950
|
+
return addHeapObject(ret);
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
module.exports.__wbindgen_closure_wrapper1626 = function(arg0, arg1, arg2) {
|
|
954
|
+
const ret = makeMutClosure(arg0, arg1, 273, __wbg_adapter_26);
|
|
955
|
+
return addHeapObject(ret);
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
const path = require('path').join(__dirname, 'pubky_bg.wasm');
|
|
959
|
+
const bytes = require('fs').readFileSync(path);
|
|
960
|
+
|
|
961
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
962
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
963
|
+
wasm = wasmInstance.exports;
|
|
964
|
+
module.exports.__wasm = wasm;
|
|
965
|
+
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function __wbg_pubkyclient_free(a: number): void;
|
|
5
|
+
export function __wbg_session_free(a: number): void;
|
|
6
|
+
export function pubkyclient_new(): number;
|
|
7
|
+
export function pubkyclient_testnet(): number;
|
|
8
|
+
export function pubkyclient_setPkarrRelays(a: number, b: number, c: number): number;
|
|
9
|
+
export function pubkyclient_getPkarrRelays(a: number, b: number): void;
|
|
10
|
+
export function pubkyclient_signup(a: number, b: number, c: number): number;
|
|
11
|
+
export function pubkyclient_session(a: number, b: number): number;
|
|
12
|
+
export function pubkyclient_signout(a: number, b: number): number;
|
|
13
|
+
export function pubkyclient_signin(a: number, b: number): number;
|
|
14
|
+
export function pubkyclient_put(a: number, b: number, c: number, d: number, e: number): number;
|
|
15
|
+
export function pubkyclient_get(a: number, b: number, c: number): number;
|
|
16
|
+
export function pubkyclient_delete(a: number, b: number, c: number): number;
|
|
17
|
+
export function __wbg_keypair_free(a: number): void;
|
|
18
|
+
export function keypair_random(): number;
|
|
19
|
+
export function keypair_from_secret_key(a: number): number;
|
|
20
|
+
export function keypair_publicKey(a: number): number;
|
|
21
|
+
export function __wbg_publickey_free(a: number): void;
|
|
22
|
+
export function publickey_to_uint8array(a: number): number;
|
|
23
|
+
export function publickey_z32(a: number, b: number): void;
|
|
24
|
+
export function publickey_from(a: number, b: number): void;
|
|
25
|
+
export function __wbindgen_malloc(a: number, b: number): number;
|
|
26
|
+
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
27
|
+
export const __wbindgen_export_2: WebAssembly.Table;
|
|
28
|
+
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha5424c6cb7b1ff0d(a: number, b: number, c: number): void;
|
|
29
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
30
|
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|
|
31
|
+
export function __wbindgen_exn_store(a: number): void;
|
|
32
|
+
export function wasm_bindgen__convert__closures__invoke2_mut__hcef77123246c6bdb(a: number, b: number, c: number, d: number): void;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@synonymdev/pubky",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Pubky client",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.8",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"prepublishOnly": "npm run build && npm run test"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"nodejs",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"nodejs/pubky_bg.wasm",
|
|
21
|
+
"nodejs/pubky.js",
|
|
22
|
+
"nodejs/pubky.d.ts",
|
|
23
|
+
"nodejs/pubky_bg.wasm.d.ts",
|
|
24
|
+
"browser.js",
|
|
25
|
+
"index.js"
|
|
23
26
|
],
|
|
24
27
|
"main": "index.js",
|
|
25
28
|
"browser": "browser.js",
|
|
26
|
-
"types": "pubky.d.ts",
|
|
27
|
-
"sideEffects": [
|
|
28
|
-
"./snippets/*"
|
|
29
|
-
],
|
|
29
|
+
"types": "nodejs/pubky.d.ts",
|
|
30
30
|
"keywords": [
|
|
31
31
|
"web",
|
|
32
32
|
"dht",
|