@synonymdev/pubky 0.10.0-alpha.0 → 0.11.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 +99 -22
- package/index.cjs +1240 -58
- package/index.js +1241 -59
- package/package.json +8 -3
- package/pubky.d.ts +319 -32
- package/pubky_bg.wasm +0 -0
package/index.cjs
CHANGED
|
@@ -5,6 +5,464 @@ globalThis.fetch = makeFetchCookie(originalFetch);
|
|
|
5
5
|
|
|
6
6
|
/* @ts-self-types="./pubky.d.ts" */
|
|
7
7
|
|
|
8
|
+
const PUBKY_SESSIONS_DB_NAME = "pubky-auth";
|
|
9
|
+
const PUBKY_SESSIONS_DB_VERSION = 1;
|
|
10
|
+
const PUBKY_SESSIONS_STORE_NAME = "storedSessions";
|
|
11
|
+
const PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME = "delegatedGrantKeys";
|
|
12
|
+
|
|
13
|
+
/** Assert that IndexedDB is available for browser session persistence. */
|
|
14
|
+
function requireIndexedDb() {
|
|
15
|
+
if (!globalThis.indexedDB) {
|
|
16
|
+
throw new Error("Pubky session persistence requires IndexedDB.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Create an operation-specific error while preserving the IndexedDB cause.
|
|
21
|
+
* Used for backwards compatability because old browsers don't support the cause property.
|
|
22
|
+
*/
|
|
23
|
+
function contextualSessionStoreError(message, cause) {
|
|
24
|
+
const error = new Error(message, { cause });
|
|
25
|
+
if (cause !== undefined && error.cause === undefined) {
|
|
26
|
+
error.cause = cause;
|
|
27
|
+
}
|
|
28
|
+
return error;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Open the IndexedDB database used for browser auth persistence.
|
|
33
|
+
*
|
|
34
|
+
* The database contains session records and delegated WebCrypto key handles so
|
|
35
|
+
* both stores are created here even though single-store helpers use only one.
|
|
36
|
+
*/
|
|
37
|
+
function openSessionStoreDb() {
|
|
38
|
+
requireIndexedDb();
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const request = indexedDB.open(PUBKY_SESSIONS_DB_NAME, PUBKY_SESSIONS_DB_VERSION);
|
|
41
|
+
request.onupgradeneeded = () => {
|
|
42
|
+
const db = request.result;
|
|
43
|
+
if (!db.objectStoreNames.contains(PUBKY_SESSIONS_STORE_NAME)) {
|
|
44
|
+
db.createObjectStore(PUBKY_SESSIONS_STORE_NAME, { keyPath: "id" });
|
|
45
|
+
}
|
|
46
|
+
if (!db.objectStoreNames.contains(PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME)) {
|
|
47
|
+
db.createObjectStore(PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME, { keyPath: "keyId" });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
request.onsuccess = () => resolve(request.result);
|
|
51
|
+
request.onerror = () => reject(request.error ?? new Error("Opening Pubky session store failed."));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Run an IndexedDB operation against the stored-session object store.
|
|
57
|
+
*
|
|
58
|
+
* The callback receives the object store and returns a request. This wrapper
|
|
59
|
+
* resolves only after the transaction commits, not when the request succeeds.
|
|
60
|
+
*/
|
|
61
|
+
async function withSessionStore(mode, operation) {
|
|
62
|
+
const db = await openSessionStoreDb();
|
|
63
|
+
try {
|
|
64
|
+
return await new Promise((resolve, reject) => {
|
|
65
|
+
const tx = db.transaction(PUBKY_SESSIONS_STORE_NAME, mode);
|
|
66
|
+
const store = tx.objectStore(PUBKY_SESSIONS_STORE_NAME);
|
|
67
|
+
let result;
|
|
68
|
+
let settled = false;
|
|
69
|
+
|
|
70
|
+
function fail(error) {
|
|
71
|
+
if (settled) return;
|
|
72
|
+
settled = true;
|
|
73
|
+
reject(error);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const request = operation(store);
|
|
78
|
+
request.onsuccess = () => {
|
|
79
|
+
result = request.result;
|
|
80
|
+
};
|
|
81
|
+
request.onerror = () => fail(request.error ?? new Error("Pubky session store request failed."));
|
|
82
|
+
} catch (error) {
|
|
83
|
+
fail(error);
|
|
84
|
+
}
|
|
85
|
+
tx.onerror = () => fail(tx.error ?? new Error("Pubky session store transaction failed."));
|
|
86
|
+
tx.onabort = () => fail(tx.error ?? new Error("Pubky session store transaction aborted."));
|
|
87
|
+
tx.oncomplete = () => {
|
|
88
|
+
if (settled) return;
|
|
89
|
+
settled = true;
|
|
90
|
+
resolve(result);
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
} finally {
|
|
94
|
+
db.close();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Return whether browser session persistence can open its IndexedDB database. */
|
|
99
|
+
async function __pubkySessionStoreIsAvailable() {
|
|
100
|
+
if (!globalThis.indexedDB) return false;
|
|
101
|
+
try {
|
|
102
|
+
const db = await openSessionStoreDb();
|
|
103
|
+
db.close();
|
|
104
|
+
return true;
|
|
105
|
+
} catch (_error) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Persist or replace a browser session record. */
|
|
111
|
+
async function __pubkySessionStorePut(record) {
|
|
112
|
+
requireIndexedDb();
|
|
113
|
+
try {
|
|
114
|
+
await withSessionStore("readwrite", (store) => store.put(record));
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw contextualSessionStoreError("Saving Pubky session failed.", error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Load a browser session record by id. */
|
|
121
|
+
async function __pubkySessionStoreGet(id) {
|
|
122
|
+
requireIndexedDb();
|
|
123
|
+
try {
|
|
124
|
+
return await withSessionStore("readonly", (store) => store.get(id));
|
|
125
|
+
} catch (error) {
|
|
126
|
+
throw contextualSessionStoreError("Reading Pubky session failed.", error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** List all browser session records, returning an empty list if storage is unavailable. */
|
|
131
|
+
async function __pubkySessionStoreList() {
|
|
132
|
+
if (!globalThis.indexedDB) return [];
|
|
133
|
+
try {
|
|
134
|
+
return (await withSessionStore("readonly", (store) => store.getAll())) ?? [];
|
|
135
|
+
} catch (_error) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Remove one browser session record by id. */
|
|
141
|
+
async function __pubkySessionStoreDelete(id) {
|
|
142
|
+
requireIndexedDb();
|
|
143
|
+
try {
|
|
144
|
+
await withSessionStore("readwrite", (store) => store.delete(id));
|
|
145
|
+
} catch (error) {
|
|
146
|
+
throw contextualSessionStoreError("Removing Pubky session failed.", error);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Clear saved session records and the delegated keys referenced by those records.
|
|
152
|
+
*
|
|
153
|
+
* Delegated keys not referenced by the supplied ids are intentionally preserved,
|
|
154
|
+
* because they may belong to pending or unsaved grant flows.
|
|
155
|
+
*/
|
|
156
|
+
async function __pubkySessionStoreClear(delegatedKeyIds) {
|
|
157
|
+
requireIndexedDb();
|
|
158
|
+
const db = await openSessionStoreDb();
|
|
159
|
+
try {
|
|
160
|
+
await new Promise((resolve, reject) => {
|
|
161
|
+
const tx = db.transaction(
|
|
162
|
+
[PUBKY_SESSIONS_STORE_NAME, PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME],
|
|
163
|
+
"readwrite",
|
|
164
|
+
);
|
|
165
|
+
const sessions = tx.objectStore(PUBKY_SESSIONS_STORE_NAME);
|
|
166
|
+
const keys = tx.objectStore(PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME);
|
|
167
|
+
sessions.clear();
|
|
168
|
+
for (const keyId of new Set(delegatedKeyIds ?? [])) {
|
|
169
|
+
keys.delete(keyId);
|
|
170
|
+
}
|
|
171
|
+
tx.oncomplete = () => resolve();
|
|
172
|
+
tx.onerror = () => reject(tx.error ?? new Error("Clearing Pubky session store failed."));
|
|
173
|
+
tx.onabort = () => reject(tx.error ?? new Error("Clearing Pubky session store aborted."));
|
|
174
|
+
});
|
|
175
|
+
} finally {
|
|
176
|
+
db.close();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Clear all browser auth records, including all delegated key handles. */
|
|
181
|
+
async function __pubkySessionStoreClearAll() {
|
|
182
|
+
requireIndexedDb();
|
|
183
|
+
const db = await openSessionStoreDb();
|
|
184
|
+
try {
|
|
185
|
+
await new Promise((resolve, reject) => {
|
|
186
|
+
const tx = db.transaction(
|
|
187
|
+
[PUBKY_SESSIONS_STORE_NAME, PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME],
|
|
188
|
+
"readwrite",
|
|
189
|
+
);
|
|
190
|
+
tx.objectStore(PUBKY_SESSIONS_STORE_NAME).clear();
|
|
191
|
+
tx.objectStore(PUBKY_SESSIONS_DELEGATED_KEYS_STORE_NAME).clear();
|
|
192
|
+
tx.oncomplete = () => resolve();
|
|
193
|
+
tx.onerror = () => reject(tx.error ?? new Error("Clearing Pubky auth store failed."));
|
|
194
|
+
tx.onabort = () => reject(tx.error ?? new Error("Clearing Pubky auth store aborted."));
|
|
195
|
+
});
|
|
196
|
+
} finally {
|
|
197
|
+
db.close();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const PUBKY_GRANT_KEYS_DB_NAME = "pubky-auth";
|
|
202
|
+
const PUBKY_GRANT_KEYS_DB_VERSION = 1;
|
|
203
|
+
const PUBKY_GRANT_KEYS_STORE_NAME = "delegatedGrantKeys";
|
|
204
|
+
const PUBKY_GRANT_KEYS_SESSION_STORE_NAME = "storedSessions";
|
|
205
|
+
let canUseDelegationPromise;
|
|
206
|
+
const TEST_CAN_USE_DELEGATION_OVERRIDE = "__pubkyGrantCanUseDelegationOverride";
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Assert that this runtime can persist non-extractable browser signing keys.
|
|
210
|
+
*
|
|
211
|
+
* SubtleCrypto is exposed only in secure contexts. We rely on browser feature
|
|
212
|
+
* detection here so each browser can decide which origins are trustworthy,
|
|
213
|
+
* including localhost, file://, extension pages, and workers.
|
|
214
|
+
*/
|
|
215
|
+
function requireBrowserCrypto() {
|
|
216
|
+
const g = globalThis;
|
|
217
|
+
|
|
218
|
+
if (!g.crypto?.subtle || !g.indexedDB) {
|
|
219
|
+
if (!g.isSecureContext) {
|
|
220
|
+
throw new Error("Delegated grant keys require a secure browser context.");
|
|
221
|
+
}
|
|
222
|
+
throw new Error("Delegated grant keys require browser WebCrypto and IndexedDB.");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function contextualError(message, cause) {
|
|
227
|
+
const error = new Error(message, { cause });
|
|
228
|
+
if (cause !== undefined && error.cause === undefined) {
|
|
229
|
+
error.cause = cause;
|
|
230
|
+
}
|
|
231
|
+
return error;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Return whether this runtime appears able to use delegated grant keys.
|
|
236
|
+
*
|
|
237
|
+
* This is a synchronous feature check only. Starting, resuming, or restoring a
|
|
238
|
+
* delegated flow can still fail later if IndexedDB access is denied, storage is
|
|
239
|
+
* cleared, or a saved key id no longer exists.
|
|
240
|
+
*/
|
|
241
|
+
function __pubkyGrantIsDelegationAvailable() {
|
|
242
|
+
const g = globalThis;
|
|
243
|
+
return Boolean(g.isSecureContext && g.crypto?.subtle && g.indexedDB);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Return whether this runtime can actually create, store, and use browser-held
|
|
248
|
+
* Ed25519 delegated grant keys.
|
|
249
|
+
*
|
|
250
|
+
* Some browser-like runtimes expose secure WebCrypto and IndexedDB but do not
|
|
251
|
+
* implement Ed25519. Cache the probe because it creates a real CryptoKey and
|
|
252
|
+
* verifies that IndexedDB can store/delete it.
|
|
253
|
+
*/
|
|
254
|
+
async function __pubkyGrantCanUseDelegation() {
|
|
255
|
+
const override = globalThis[TEST_CAN_USE_DELEGATION_OVERRIDE];
|
|
256
|
+
if (override === true || override === false) return override;
|
|
257
|
+
|
|
258
|
+
if (!canUseDelegationPromise) {
|
|
259
|
+
canUseDelegationPromise = (async () => {
|
|
260
|
+
try {
|
|
261
|
+
requireBrowserCrypto();
|
|
262
|
+
const keyId = `__pubky_probe_${randomKeyId()}`;
|
|
263
|
+
const pair = await crypto.subtle.generateKey({ name: "Ed25519" }, false, ["sign", "verify"]);
|
|
264
|
+
const publicKeyRaw = new Uint8Array(await crypto.subtle.exportKey("raw", pair.publicKey));
|
|
265
|
+
const data = new TextEncoder().encode("pubky-delegated-grant-probe");
|
|
266
|
+
const signature = new Uint8Array(await crypto.subtle.sign({ name: "Ed25519" }, pair.privateKey, data));
|
|
267
|
+
if (publicKeyRaw.length !== 32 || signature.length !== 64) return false;
|
|
268
|
+
await putRecord({
|
|
269
|
+
keyId,
|
|
270
|
+
privateKey: pair.privateKey,
|
|
271
|
+
publicKeyRaw,
|
|
272
|
+
createdAt: Date.now(),
|
|
273
|
+
});
|
|
274
|
+
await deleteRecord(keyId);
|
|
275
|
+
return true;
|
|
276
|
+
} catch (_error) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
})();
|
|
280
|
+
}
|
|
281
|
+
return await canUseDelegationPromise;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Open the IndexedDB database used for delegated grant keys.
|
|
286
|
+
*
|
|
287
|
+
* Records are keyed by the SDK-level key id and contain a non-extractable
|
|
288
|
+
* CryptoKey plus the raw public key bytes needed for grant metadata.
|
|
289
|
+
*/
|
|
290
|
+
function openGrantKeyDb() {
|
|
291
|
+
requireBrowserCrypto();
|
|
292
|
+
return new Promise((resolve, reject) => {
|
|
293
|
+
const request = indexedDB.open(PUBKY_GRANT_KEYS_DB_NAME, PUBKY_GRANT_KEYS_DB_VERSION);
|
|
294
|
+
request.onupgradeneeded = () => {
|
|
295
|
+
const db = request.result;
|
|
296
|
+
if (!db.objectStoreNames.contains(PUBKY_GRANT_KEYS_STORE_NAME)) {
|
|
297
|
+
db.createObjectStore(PUBKY_GRANT_KEYS_STORE_NAME, { keyPath: "keyId" });
|
|
298
|
+
}
|
|
299
|
+
if (!db.objectStoreNames.contains(PUBKY_GRANT_KEYS_SESSION_STORE_NAME)) {
|
|
300
|
+
db.createObjectStore(PUBKY_GRANT_KEYS_SESSION_STORE_NAME, { keyPath: "id" });
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
request.onsuccess = () => resolve(request.result);
|
|
304
|
+
request.onerror = () => reject(request.error ?? new Error("Opening delegated grant key store failed."));
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Run an IndexedDB operation against the delegated-key object store.
|
|
310
|
+
*
|
|
311
|
+
* The callback receives the object store and returns a request. This wrapper
|
|
312
|
+
* resolves only after the transaction commits, not when the request succeeds.
|
|
313
|
+
*/
|
|
314
|
+
async function withGrantKeyStore(mode, operation) {
|
|
315
|
+
const db = await openGrantKeyDb();
|
|
316
|
+
try {
|
|
317
|
+
return await new Promise((resolve, reject) => {
|
|
318
|
+
const tx = db.transaction(PUBKY_GRANT_KEYS_STORE_NAME, mode);
|
|
319
|
+
const store = tx.objectStore(PUBKY_GRANT_KEYS_STORE_NAME);
|
|
320
|
+
let result;
|
|
321
|
+
let settled = false;
|
|
322
|
+
|
|
323
|
+
function fail(error) {
|
|
324
|
+
if (settled) return;
|
|
325
|
+
settled = true;
|
|
326
|
+
reject(error);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
try {
|
|
330
|
+
const request = operation(store);
|
|
331
|
+
request.onsuccess = () => {
|
|
332
|
+
result = request.result;
|
|
333
|
+
};
|
|
334
|
+
request.onerror = () => fail(request.error ?? new Error("Delegated grant key request failed."));
|
|
335
|
+
} catch (error) {
|
|
336
|
+
fail(error);
|
|
337
|
+
}
|
|
338
|
+
tx.onerror = () => fail(tx.error ?? new Error("Delegated grant key transaction failed."));
|
|
339
|
+
tx.onabort = () => fail(tx.error ?? new Error("Delegated grant key transaction aborted."));
|
|
340
|
+
tx.oncomplete = () => {
|
|
341
|
+
if (settled) return;
|
|
342
|
+
settled = true;
|
|
343
|
+
resolve(result);
|
|
344
|
+
};
|
|
345
|
+
});
|
|
346
|
+
} finally {
|
|
347
|
+
db.close();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Load a delegated-key record by key id.
|
|
353
|
+
*
|
|
354
|
+
* Returns `undefined` when the key id is unknown. Callers decide whether that
|
|
355
|
+
* should create a new key or surface a restore/signing error.
|
|
356
|
+
*/
|
|
357
|
+
async function getRecord(keyId) {
|
|
358
|
+
try {
|
|
359
|
+
return await withGrantKeyStore("readonly", (store) => store.get(keyId));
|
|
360
|
+
} catch (error) {
|
|
361
|
+
throw contextualError("Reading delegated grant key failed.", error);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Persist a delegated-key record.
|
|
367
|
+
*
|
|
368
|
+
* The private key is a non-extractable CryptoKey, so IndexedDB stores a browser
|
|
369
|
+
* handle rather than raw private key bytes.
|
|
370
|
+
*/
|
|
371
|
+
async function putRecord(record) {
|
|
372
|
+
try {
|
|
373
|
+
await withGrantKeyStore("readwrite", (store) => store.put(record));
|
|
374
|
+
} catch (error) {
|
|
375
|
+
throw contextualError("Saving delegated grant key failed.", error);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
async function deleteRecord(keyId) {
|
|
380
|
+
try {
|
|
381
|
+
await withGrantKeyStore("readwrite", (store) => store.delete(keyId));
|
|
382
|
+
} catch (error) {
|
|
383
|
+
throw contextualError("Deleting delegated grant key failed.", error);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Generate an opaque key id for the IndexedDB record.
|
|
389
|
+
*
|
|
390
|
+
* Use randomUUID when available, with a getRandomValues fallback for older
|
|
391
|
+
* secure browser contexts.
|
|
392
|
+
*/
|
|
393
|
+
function randomKeyId() {
|
|
394
|
+
if (globalThis.crypto?.randomUUID) return crypto.randomUUID();
|
|
395
|
+
const bytes = new Uint8Array(16);
|
|
396
|
+
crypto.getRandomValues(bytes);
|
|
397
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Ensure a delegated grant signing key exists.
|
|
402
|
+
*
|
|
403
|
+
* If `keyId` is provided by an internal restore/reuse path and already exists,
|
|
404
|
+
* return its public key. Otherwise generate a new non-extractable Ed25519
|
|
405
|
+
* keypair, store the private CryptoKey in IndexedDB, and return
|
|
406
|
+
* `{ keyId, publicKey }`.
|
|
407
|
+
*/
|
|
408
|
+
async function __pubkyGrantEnsureDelegatedKey(keyId) {
|
|
409
|
+
requireBrowserCrypto();
|
|
410
|
+
const resolvedKeyId = keyId || randomKeyId();
|
|
411
|
+
const existing = await getRecord(resolvedKeyId);
|
|
412
|
+
if (existing) {
|
|
413
|
+
return { keyId: resolvedKeyId, publicKey: new Uint8Array(existing.publicKeyRaw) };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const pair = await crypto.subtle.generateKey({ name: "Ed25519" }, false, ["sign", "verify"]);
|
|
417
|
+
const publicKeyRaw = new Uint8Array(await crypto.subtle.exportKey("raw", pair.publicKey));
|
|
418
|
+
await putRecord({
|
|
419
|
+
keyId: resolvedKeyId,
|
|
420
|
+
privateKey: pair.privateKey,
|
|
421
|
+
publicKeyRaw,
|
|
422
|
+
createdAt: Date.now(),
|
|
423
|
+
});
|
|
424
|
+
return { keyId: resolvedKeyId, publicKey: publicKeyRaw };
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Load the public key bytes for a delegated grant key.
|
|
429
|
+
*
|
|
430
|
+
* Used during delegated session restore to verify that saved metadata still
|
|
431
|
+
* matches the browser-held key.
|
|
432
|
+
*/
|
|
433
|
+
async function __pubkyGrantLoadDelegatedPublicKey(keyId) {
|
|
434
|
+
requireBrowserCrypto();
|
|
435
|
+
const existing = await getRecord(keyId);
|
|
436
|
+
if (!existing) throw new Error(`Delegated grant key not found: ${keyId}`);
|
|
437
|
+
return new Uint8Array(existing.publicKeyRaw);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Sign a grant PoP JWS signing input with a delegated browser key.
|
|
442
|
+
*
|
|
443
|
+
* `signingInput` is the exact ASCII JWS signing input produced by Rust:
|
|
444
|
+
* `base64url(header) + "." + base64url(claims)`. The raw Ed25519 signature
|
|
445
|
+
* bytes are returned to Rust, which finishes compact JWS serialization.
|
|
446
|
+
*/
|
|
447
|
+
async function __pubkyGrantDelegatedSign(keyId, signingInput) {
|
|
448
|
+
requireBrowserCrypto();
|
|
449
|
+
const existing = await getRecord(keyId);
|
|
450
|
+
if (!existing?.privateKey) throw new Error(`Delegated grant key not found: ${keyId}`);
|
|
451
|
+
const data = new TextEncoder().encode(signingInput);
|
|
452
|
+
return new Uint8Array(await crypto.subtle.sign({ name: "Ed25519" }, existing.privateKey, data));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Delete a browser-held delegated grant key by id.
|
|
457
|
+
*
|
|
458
|
+
* Used when a persisted delegated session record is removed from the SDK
|
|
459
|
+
* session store. Missing keys are treated as already deleted.
|
|
460
|
+
*/
|
|
461
|
+
async function __pubkyGrantDeleteDelegatedKey(keyId) {
|
|
462
|
+
requireBrowserCrypto();
|
|
463
|
+
await deleteRecord(keyId);
|
|
464
|
+
}
|
|
465
|
+
|
|
8
466
|
/**
|
|
9
467
|
* Start and control a pubkyauth authorization flow.
|
|
10
468
|
*
|
|
@@ -135,6 +593,9 @@ class AuthFlow {
|
|
|
135
593
|
* Optional HTTP relay base, e.g. `"https://demo.httprelay.io/inbox/"`.
|
|
136
594
|
* Defaults to the default Synonym-hosted relay when omitted.
|
|
137
595
|
*
|
|
596
|
+
* @param {XCallbackParams} [xCallback]
|
|
597
|
+
* Optional return destinations for success, error, and cancellation.
|
|
598
|
+
*
|
|
138
599
|
* @returns {AuthFlow}
|
|
139
600
|
* A running auth flow. Call `authorizationUrl()` to show the deep link,
|
|
140
601
|
* then `awaitApproval()` to receive a `Session`.
|
|
@@ -150,16 +611,17 @@ class AuthFlow {
|
|
|
150
611
|
* @param {Capabilities} capabilities
|
|
151
612
|
* @param {AuthFlowKind} kind
|
|
152
613
|
* @param {string | null} [relay]
|
|
614
|
+
* @param {XCallbackParams | null} [x_callback]
|
|
153
615
|
* @returns {AuthFlow}
|
|
154
616
|
*/
|
|
155
|
-
static start(capabilities, kind, relay) {
|
|
617
|
+
static start(capabilities, kind, relay, x_callback) {
|
|
156
618
|
const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
619
|
const len0 = WASM_VECTOR_LEN;
|
|
158
620
|
_assertClass(kind, AuthFlowKind);
|
|
159
621
|
var ptr1 = kind.__destroy_into_raw();
|
|
160
622
|
var ptr2 = isLikeNone(relay) ? 0 : passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
623
|
var len2 = WASM_VECTOR_LEN;
|
|
162
|
-
const ret = wasm.authflow_start(ptr0, len0, ptr1, ptr2, len2);
|
|
624
|
+
const ret = wasm.authflow_start(ptr0, len0, ptr1, ptr2, len2, isLikeNone(x_callback) ? 0 : addToExternrefTable0(x_callback));
|
|
163
625
|
if (ret[2]) {
|
|
164
626
|
throw takeFromExternrefTable0(ret[1]);
|
|
165
627
|
}
|
|
@@ -386,6 +848,103 @@ class AuthToken {
|
|
|
386
848
|
if (Symbol.dispose) AuthToken.prototype[Symbol.dispose] = AuthToken.prototype.free;
|
|
387
849
|
exports.AuthToken = AuthToken;
|
|
388
850
|
|
|
851
|
+
/**
|
|
852
|
+
* Browser-backed durable store for completed grant sessions.
|
|
853
|
+
*/
|
|
854
|
+
class BrowserSessionStore {
|
|
855
|
+
static __wrap(ptr) {
|
|
856
|
+
ptr = ptr >>> 0;
|
|
857
|
+
const obj = Object.create(BrowserSessionStore.prototype);
|
|
858
|
+
obj.__wbg_ptr = ptr;
|
|
859
|
+
BrowserSessionStoreFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
860
|
+
return obj;
|
|
861
|
+
}
|
|
862
|
+
__destroy_into_raw() {
|
|
863
|
+
const ptr = this.__wbg_ptr;
|
|
864
|
+
this.__wbg_ptr = 0;
|
|
865
|
+
BrowserSessionStoreFinalization.unregister(this);
|
|
866
|
+
return ptr;
|
|
867
|
+
}
|
|
868
|
+
free() {
|
|
869
|
+
const ptr = this.__destroy_into_raw();
|
|
870
|
+
wasm.__wbg_browsersessionstore_free(ptr, 0);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Clear all local stored session records for this origin.
|
|
874
|
+
*
|
|
875
|
+
* Delegated keys referenced by those stored session records are removed.
|
|
876
|
+
* Delegated keys that only belong to pending grant flows are preserved.
|
|
877
|
+
* @returns {Promise<void>}
|
|
878
|
+
*/
|
|
879
|
+
clear() {
|
|
880
|
+
const ret = wasm.browsersessionstore_clear(this.__wbg_ptr);
|
|
881
|
+
return ret;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Clear all browser auth persistence owned by this SDK origin.
|
|
885
|
+
*
|
|
886
|
+
* This removes all stored session records and all browser-held delegated
|
|
887
|
+
* grant keys, including keys for pending delegated grant flows. Saved
|
|
888
|
+
* delegated flow state becomes unrestorable. This does not revoke remote
|
|
889
|
+
* grants or immediately invalidate already-live in-memory sessions.
|
|
890
|
+
* @returns {Promise<void>}
|
|
891
|
+
*/
|
|
892
|
+
clearAll() {
|
|
893
|
+
const ret = wasm.browsersessionstore_clearAll(this.__wbg_ptr);
|
|
894
|
+
return ret;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Whether IndexedDB is available for durable session persistence.
|
|
898
|
+
* @returns {Promise<boolean>}
|
|
899
|
+
*/
|
|
900
|
+
isAvailable() {
|
|
901
|
+
const ret = wasm.browsersessionstore_isAvailable(this.__wbg_ptr);
|
|
902
|
+
return ret;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* List all locally stored sessions for this origin.
|
|
906
|
+
* @returns {Promise<StoredSessionInfo[]>}
|
|
907
|
+
*/
|
|
908
|
+
list() {
|
|
909
|
+
const ret = wasm.browsersessionstore_list(this.__wbg_ptr);
|
|
910
|
+
return ret;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Remove local stored session metadata and any SDK-owned delegated key for that record.
|
|
914
|
+
* @param {string} id
|
|
915
|
+
* @returns {Promise<void>}
|
|
916
|
+
*/
|
|
917
|
+
remove(id) {
|
|
918
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
919
|
+
const len0 = WASM_VECTOR_LEN;
|
|
920
|
+
const ret = wasm.browsersessionstore_remove(this.__wbg_ptr, ptr0, len0);
|
|
921
|
+
return ret;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Restore a specific stored session by id.
|
|
925
|
+
* @param {string} id
|
|
926
|
+
* @returns {Promise<Session>}
|
|
927
|
+
*/
|
|
928
|
+
restore(id) {
|
|
929
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
930
|
+
const len0 = WASM_VECTOR_LEN;
|
|
931
|
+
const ret = wasm.browsersessionstore_restore(this.__wbg_ptr, ptr0, len0);
|
|
932
|
+
return ret;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Persist a completed grant session in IndexedDB.
|
|
936
|
+
* @param {Session} session
|
|
937
|
+
* @returns {Promise<StoredSessionInfo>}
|
|
938
|
+
*/
|
|
939
|
+
save(session) {
|
|
940
|
+
_assertClass(session, Session);
|
|
941
|
+
const ret = wasm.browsersessionstore_save(this.__wbg_ptr, session.__wbg_ptr);
|
|
942
|
+
return ret;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (Symbol.dispose) BrowserSessionStore.prototype[Symbol.dispose] = BrowserSessionStore.prototype.free;
|
|
946
|
+
exports.BrowserSessionStore = BrowserSessionStore;
|
|
947
|
+
|
|
389
948
|
/**
|
|
390
949
|
* Low-level HTTP bridge used by the Pubky facade and actors.
|
|
391
950
|
*
|
|
@@ -561,6 +1120,89 @@ class CookieSession {
|
|
|
561
1120
|
if (Symbol.dispose) CookieSession.prototype[Symbol.dispose] = CookieSession.prototype.free;
|
|
562
1121
|
exports.CookieSession = CookieSession;
|
|
563
1122
|
|
|
1123
|
+
/**
|
|
1124
|
+
* Parsed direct signup deeplink.
|
|
1125
|
+
*/
|
|
1126
|
+
class DirectSignupDeepLink {
|
|
1127
|
+
static __wrap(ptr) {
|
|
1128
|
+
ptr = ptr >>> 0;
|
|
1129
|
+
const obj = Object.create(DirectSignupDeepLink.prototype);
|
|
1130
|
+
obj.__wbg_ptr = ptr;
|
|
1131
|
+
DirectSignupDeepLinkFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1132
|
+
return obj;
|
|
1133
|
+
}
|
|
1134
|
+
__destroy_into_raw() {
|
|
1135
|
+
const ptr = this.__wbg_ptr;
|
|
1136
|
+
this.__wbg_ptr = 0;
|
|
1137
|
+
DirectSignupDeepLinkFinalization.unregister(this);
|
|
1138
|
+
return ptr;
|
|
1139
|
+
}
|
|
1140
|
+
free() {
|
|
1141
|
+
const ptr = this.__destroy_into_raw();
|
|
1142
|
+
wasm.__wbg_directsignupdeeplink_free(ptr, 0);
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Homeserver public key requested for account creation.
|
|
1146
|
+
* @returns {PublicKey}
|
|
1147
|
+
*/
|
|
1148
|
+
get homeserver() {
|
|
1149
|
+
const ret = wasm.directsignupdeeplink_homeserver(this.__wbg_ptr);
|
|
1150
|
+
return PublicKey.__wrap(ret);
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Parse a direct signup deeplink URL.
|
|
1154
|
+
* @param {string} url
|
|
1155
|
+
* @returns {DirectSignupDeepLink}
|
|
1156
|
+
*/
|
|
1157
|
+
static parse(url) {
|
|
1158
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1159
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1160
|
+
const ret = wasm.directsignupdeeplink_parse(ptr0, len0);
|
|
1161
|
+
if (ret[2]) {
|
|
1162
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1163
|
+
}
|
|
1164
|
+
return DirectSignupDeepLink.__wrap(ret[0]);
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Optional signup token included in the request.
|
|
1168
|
+
* @returns {string | undefined}
|
|
1169
|
+
*/
|
|
1170
|
+
get signupToken() {
|
|
1171
|
+
const ret = wasm.directsignupdeeplink_signupToken(this.__wbg_ptr);
|
|
1172
|
+
let v1;
|
|
1173
|
+
if (ret[0] !== 0) {
|
|
1174
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1175
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1176
|
+
}
|
|
1177
|
+
return v1;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* @returns {string}
|
|
1181
|
+
*/
|
|
1182
|
+
toString() {
|
|
1183
|
+
let deferred1_0;
|
|
1184
|
+
let deferred1_1;
|
|
1185
|
+
try {
|
|
1186
|
+
const ret = wasm.directsignupdeeplink_toString(this.__wbg_ptr);
|
|
1187
|
+
deferred1_0 = ret[0];
|
|
1188
|
+
deferred1_1 = ret[1];
|
|
1189
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1190
|
+
} finally {
|
|
1191
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Optional x-callback-url metadata carried by this deep link.
|
|
1196
|
+
* @returns {XCallbackParams}
|
|
1197
|
+
*/
|
|
1198
|
+
get xCallback() {
|
|
1199
|
+
const ret = wasm.directsignupdeeplink_xCallback(this.__wbg_ptr);
|
|
1200
|
+
return ret;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (Symbol.dispose) DirectSignupDeepLink.prototype[Symbol.dispose] = DirectSignupDeepLink.prototype.free;
|
|
1204
|
+
exports.DirectSignupDeepLink = DirectSignupDeepLink;
|
|
1205
|
+
|
|
564
1206
|
/**
|
|
565
1207
|
* A single event from the event stream.
|
|
566
1208
|
*
|
|
@@ -674,6 +1316,15 @@ exports.Event = Event;
|
|
|
674
1316
|
* console.log(event.eventType, event.resource.path);
|
|
675
1317
|
* }
|
|
676
1318
|
* ```
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```typescript
|
|
1322
|
+
* // Private events: attach a session and request a `/priv/...` path.
|
|
1323
|
+
* const stream = await pubky.eventStreamForUser(userPubkey, null)
|
|
1324
|
+
* .session(session)
|
|
1325
|
+
* .path("/priv/app/")
|
|
1326
|
+
* .subscribe();
|
|
1327
|
+
* ```
|
|
677
1328
|
*/
|
|
678
1329
|
class EventStreamBuilder {
|
|
679
1330
|
static __wrap(ptr) {
|
|
@@ -777,12 +1428,17 @@ class EventStreamBuilder {
|
|
|
777
1428
|
return EventStreamBuilder.__wrap(ret);
|
|
778
1429
|
}
|
|
779
1430
|
/**
|
|
780
|
-
* Filter events by path
|
|
1431
|
+
* Filter events by path. Call once per path to receive the
|
|
1432
|
+
* union of several scopes (e.g. `/pub/` plus a private `/priv/app/`).
|
|
1433
|
+
*
|
|
1434
|
+
* Format: a path WITHOUT the `pubky://` scheme or user pubkey. A trailing
|
|
1435
|
+
* slash matches a directory and all its descendants (`/pub/files/`); no
|
|
1436
|
+
* trailing slash matches an exact file (`/pub/notes.txt`).
|
|
781
1437
|
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
1438
|
+
* Private (`/priv/...`) paths require a session attached via `session()`;
|
|
1439
|
+
* without one the homeserver rejects the subscription with 401.
|
|
784
1440
|
*
|
|
785
|
-
* @param {string} path - Path
|
|
1441
|
+
* @param {string} path - Path filter (repeatable)
|
|
786
1442
|
* @returns {EventStreamBuilder} - Builder for chaining
|
|
787
1443
|
* @param {string} path
|
|
788
1444
|
* @returns {EventStreamBuilder}
|
|
@@ -811,6 +1467,26 @@ class EventStreamBuilder {
|
|
|
811
1467
|
const ret = wasm.eventstreambuilder_reverse(ptr);
|
|
812
1468
|
return EventStreamBuilder.__wrap(ret);
|
|
813
1469
|
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Authenticate the subscription with a user `Session`.
|
|
1472
|
+
*
|
|
1473
|
+
* Required to receive private (`/priv/...`) events: the session credential
|
|
1474
|
+
* (grant or cookie) is attached so the homeserver can authorize each private
|
|
1475
|
+
* `path()` against the session's read capabilities. Public subscriptions
|
|
1476
|
+
* don't need this.
|
|
1477
|
+
*
|
|
1478
|
+
*
|
|
1479
|
+
* @param {Session} session - The authenticated session
|
|
1480
|
+
* @returns {EventStreamBuilder} - Builder for chaining
|
|
1481
|
+
* @param {Session} session
|
|
1482
|
+
* @returns {EventStreamBuilder}
|
|
1483
|
+
*/
|
|
1484
|
+
session(session) {
|
|
1485
|
+
const ptr = this.__destroy_into_raw();
|
|
1486
|
+
_assertClass(session, Session);
|
|
1487
|
+
const ret = wasm.eventstreambuilder_session(ptr, session.__wbg_ptr);
|
|
1488
|
+
return EventStreamBuilder.__wrap(ret);
|
|
1489
|
+
}
|
|
814
1490
|
/**
|
|
815
1491
|
* Subscribe to the event stream.
|
|
816
1492
|
*
|
|
@@ -895,6 +1571,18 @@ class GrantAuthFlow {
|
|
|
895
1571
|
const ret = wasm.grantauthflow_awaitApproval(this.__wbg_ptr);
|
|
896
1572
|
return ret;
|
|
897
1573
|
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Whether delegated grant auth is available in the current JS runtime.
|
|
1576
|
+
*
|
|
1577
|
+
* This checks for a secure browser context with WebCrypto `crypto.subtle`
|
|
1578
|
+
* and IndexedDB. It is a coarse synchronous feature-detection helper only;
|
|
1579
|
+
* some runtimes expose those primitives without Ed25519 support.
|
|
1580
|
+
* @returns {boolean}
|
|
1581
|
+
*/
|
|
1582
|
+
static get isDelegationAvailable() {
|
|
1583
|
+
const ret = wasm.grantauthflow_isDelegationAvailable();
|
|
1584
|
+
return ret !== 0;
|
|
1585
|
+
}
|
|
898
1586
|
/**
|
|
899
1587
|
* Resume a previously saved pending grant auth flow (standalone).
|
|
900
1588
|
* Prefer `pubky.resumeGrantAuthFlow()` to reuse a facade client.
|
|
@@ -902,7 +1590,7 @@ class GrantAuthFlow {
|
|
|
902
1590
|
* **Security:** `savedState` contains the relay secret and PoP client private key.
|
|
903
1591
|
* Store it only temporarily and delete it once the flow completes or is abandoned.
|
|
904
1592
|
*
|
|
905
|
-
* @param {string} savedState A string produced by `grantFlow.
|
|
1593
|
+
* @param {string} savedState A string produced by `grantFlow.saveLocal()`.
|
|
906
1594
|
* @returns {GrantAuthFlow} A flow reconnected to the original relay channel.
|
|
907
1595
|
* @param {string} saved_state
|
|
908
1596
|
* @returns {GrantAuthFlow}
|
|
@@ -914,20 +1602,62 @@ class GrantAuthFlow {
|
|
|
914
1602
|
if (ret[2]) {
|
|
915
1603
|
throw takeFromExternrefTable0(ret[1]);
|
|
916
1604
|
}
|
|
917
|
-
return GrantAuthFlow.__wrap(ret[0]);
|
|
1605
|
+
return GrantAuthFlow.__wrap(ret[0]);
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Resume a previously saved pending delegated grant auth flow.
|
|
1609
|
+
*
|
|
1610
|
+
* Runtime: delegated grant keys require a secure browser context with
|
|
1611
|
+
* WebCrypto `crypto.subtle` and IndexedDB. The saved `keyId` must still
|
|
1612
|
+
* exist in IndexedDB for the same origin. Unsupported runtimes reject with
|
|
1613
|
+
* `ClientStateError`.
|
|
1614
|
+
* @param {string} saved_state
|
|
1615
|
+
* @returns {Promise<GrantAuthFlow>}
|
|
1616
|
+
*/
|
|
1617
|
+
static resumeDelegated(saved_state) {
|
|
1618
|
+
const ptr0 = passStringToWasm0(saved_state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1619
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1620
|
+
const ret = wasm.grantauthflow_resumeDelegated(ptr0, len0);
|
|
1621
|
+
return ret;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Save sensitive state required to resume this delegated pending grant flow.
|
|
1625
|
+
*
|
|
1626
|
+
* This does not export the delegated private key, but it includes the relay
|
|
1627
|
+
* secret in the authorization URL. Store it only temporarily and delete it
|
|
1628
|
+
* once the flow completes or is abandoned.
|
|
1629
|
+
* @returns {string}
|
|
1630
|
+
*/
|
|
1631
|
+
saveDelegated() {
|
|
1632
|
+
let deferred2_0;
|
|
1633
|
+
let deferred2_1;
|
|
1634
|
+
try {
|
|
1635
|
+
const ret = wasm.grantauthflow_saveDelegated(this.__wbg_ptr);
|
|
1636
|
+
var ptr1 = ret[0];
|
|
1637
|
+
var len1 = ret[1];
|
|
1638
|
+
if (ret[3]) {
|
|
1639
|
+
ptr1 = 0; len1 = 0;
|
|
1640
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1641
|
+
}
|
|
1642
|
+
deferred2_0 = ptr1;
|
|
1643
|
+
deferred2_1 = len1;
|
|
1644
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1645
|
+
} finally {
|
|
1646
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1647
|
+
}
|
|
918
1648
|
}
|
|
919
1649
|
/**
|
|
920
|
-
* Save sensitive state required to resume this pending grant flow.
|
|
1650
|
+
* Save sensitive state required to resume this pending local grant flow.
|
|
921
1651
|
*
|
|
922
1652
|
* @returns {string} Opaque state for `GrantAuthFlow.resume()` or
|
|
923
1653
|
* `pubky.resumeGrantAuthFlow()`.
|
|
924
1654
|
* @returns {string}
|
|
925
1655
|
*/
|
|
926
|
-
|
|
1656
|
+
saveLocal() {
|
|
927
1657
|
let deferred2_0;
|
|
928
1658
|
let deferred2_1;
|
|
929
1659
|
try {
|
|
930
|
-
const ret = wasm.
|
|
1660
|
+
const ret = wasm.grantauthflow_saveLocal(this.__wbg_ptr);
|
|
931
1661
|
var ptr1 = ret[0];
|
|
932
1662
|
var len1 = ret[1];
|
|
933
1663
|
if (ret[3]) {
|
|
@@ -942,8 +1672,8 @@ class GrantAuthFlow {
|
|
|
942
1672
|
}
|
|
943
1673
|
}
|
|
944
1674
|
/**
|
|
945
|
-
* Start a grant-backed flow
|
|
946
|
-
* Prefer `pubky.startGrantAuthFlow()` to reuse a facade client.
|
|
1675
|
+
* Start a grant-backed flow with a new DHT client.
|
|
1676
|
+
* Prefer `pubky.startGrantAuthFlow()` to reuse a facade DHT client.
|
|
947
1677
|
*
|
|
948
1678
|
* @param {string} capabilities
|
|
949
1679
|
* Comma-separated capabilities, e.g. `"/pub/app/:rw,/priv/foo.txt:r"`.
|
|
@@ -953,7 +1683,7 @@ class GrantAuthFlow {
|
|
|
953
1683
|
* The kind of authentication flow to perform.
|
|
954
1684
|
*
|
|
955
1685
|
* @param {GrantAuthFlowOptions} options
|
|
956
|
-
* Options for the grant flow: `{ clientId, relay? }`.
|
|
1686
|
+
* Options for the grant flow: `{ clientId, relay?, xCallback? }`.
|
|
957
1687
|
*
|
|
958
1688
|
* @returns {GrantAuthFlow}
|
|
959
1689
|
* A running grant auth flow. Call `authorizationUrl()` to show the deep link,
|
|
@@ -974,6 +1704,28 @@ class GrantAuthFlow {
|
|
|
974
1704
|
}
|
|
975
1705
|
return GrantAuthFlow.__wrap(ret[0]);
|
|
976
1706
|
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Start a browser delegated grant-backed flow.
|
|
1709
|
+
*
|
|
1710
|
+
* The SDK creates a fresh non-extractable WebCrypto Ed25519 key in
|
|
1711
|
+
* IndexedDB and uses that key for grant Proof-of-Possession signing.
|
|
1712
|
+
*
|
|
1713
|
+
* Runtime: delegated grant keys require a secure browser context with
|
|
1714
|
+
* WebCrypto `crypto.subtle` and IndexedDB. Unsupported runtimes reject
|
|
1715
|
+
* with `ClientStateError`.
|
|
1716
|
+
* @param {Capabilities} capabilities
|
|
1717
|
+
* @param {AuthFlowKind} kind
|
|
1718
|
+
* @param {GrantAuthFlowOptions} options
|
|
1719
|
+
* @returns {Promise<GrantAuthFlow>}
|
|
1720
|
+
*/
|
|
1721
|
+
static startDelegated(capabilities, kind, options) {
|
|
1722
|
+
const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1723
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1724
|
+
_assertClass(kind, AuthFlowKind);
|
|
1725
|
+
var ptr1 = kind.__destroy_into_raw();
|
|
1726
|
+
const ret = wasm.grantauthflow_startDelegated(ptr0, len0, ptr1, options);
|
|
1727
|
+
return ret;
|
|
1728
|
+
}
|
|
977
1729
|
/**
|
|
978
1730
|
* Non-blocking single poll step (advanced UIs).
|
|
979
1731
|
*
|
|
@@ -1164,7 +1916,7 @@ class GrantSession {
|
|
|
1164
1916
|
wasm.__wbg_grantsession_free(ptr, 0);
|
|
1165
1917
|
}
|
|
1166
1918
|
/**
|
|
1167
|
-
* Export the
|
|
1919
|
+
* Export the portable local secret material needed to restore this grant session.
|
|
1168
1920
|
*
|
|
1169
1921
|
* Treat the returned string as bearer-equivalent secret material until the
|
|
1170
1922
|
* grant expires or is revoked.
|
|
@@ -1172,8 +1924,8 @@ class GrantSession {
|
|
|
1172
1924
|
* @returns {Promise<string>}
|
|
1173
1925
|
* @returns {Promise<string>}
|
|
1174
1926
|
*/
|
|
1175
|
-
|
|
1176
|
-
const ret = wasm.
|
|
1927
|
+
exportLocalSecret() {
|
|
1928
|
+
const ret = wasm.grantsession_exportLocalSecret(this.__wbg_ptr);
|
|
1177
1929
|
return ret;
|
|
1178
1930
|
}
|
|
1179
1931
|
/**
|
|
@@ -1561,6 +2313,8 @@ class Pkdns {
|
|
|
1561
2313
|
* Resolve the homeserver for **this** user (requires keypair).
|
|
1562
2314
|
*
|
|
1563
2315
|
* @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined` if not found.
|
|
2316
|
+
* @throws When no keypair is attached, Pkarr resolution fails, or a resolved `_pubky` target
|
|
2317
|
+
* is malformed.
|
|
1564
2318
|
* @returns {Promise<PublicKey | undefined>}
|
|
1565
2319
|
*/
|
|
1566
2320
|
getHomeserver() {
|
|
@@ -1571,7 +2325,9 @@ class Pkdns {
|
|
|
1571
2325
|
* Resolve the homeserver for a given public key (read-only).
|
|
1572
2326
|
*
|
|
1573
2327
|
* @param {PublicKey} user
|
|
1574
|
-
* @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined`
|
|
2328
|
+
* @returns {Promise<PublicKey|undefined>} Homeserver public key, or `undefined` when the
|
|
2329
|
+
* user has no resolvable homeserver record.
|
|
2330
|
+
* @throws When Pkarr resolution fails or a resolved `_pubky` target is malformed.
|
|
1575
2331
|
* @param {PublicKey} pubky
|
|
1576
2332
|
* @returns {Promise<PublicKey | undefined>}
|
|
1577
2333
|
*/
|
|
@@ -1655,6 +2411,18 @@ class Pubky {
|
|
|
1655
2411
|
const ptr = this.__destroy_into_raw();
|
|
1656
2412
|
wasm.__wbg_pubky_free(ptr, 0);
|
|
1657
2413
|
}
|
|
2414
|
+
/**
|
|
2415
|
+
* Browser-backed store for explicitly persisted completed grant sessions.
|
|
2416
|
+
*
|
|
2417
|
+
* Use `browserSessionStore.save(session)` after a successful grant auth flow to make
|
|
2418
|
+
* the session restorable after reload. The store supports multiple accounts
|
|
2419
|
+
* and multiple grants per account.
|
|
2420
|
+
* @returns {BrowserSessionStore}
|
|
2421
|
+
*/
|
|
2422
|
+
get browserSessionStore() {
|
|
2423
|
+
const ret = wasm.pubky_browserSessionStore(this.__wbg_ptr);
|
|
2424
|
+
return BrowserSessionStore.__wrap(ret);
|
|
2425
|
+
}
|
|
1658
2426
|
/**
|
|
1659
2427
|
* Access the underlying HTTP client (advanced).
|
|
1660
2428
|
*
|
|
@@ -1739,7 +2507,9 @@ class Pubky {
|
|
|
1739
2507
|
* Uses an internal read-only Pkdns actor.
|
|
1740
2508
|
*
|
|
1741
2509
|
* @param {PublicKey} user
|
|
1742
|
-
* @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined`
|
|
2510
|
+
* @returns {Promise<PublicKey|undefined>} Homeserver public key, or `undefined` when the
|
|
2511
|
+
* user has no resolvable homeserver record.
|
|
2512
|
+
* @throws When Pkarr resolution fails or a resolved `_pubky` target is malformed.
|
|
1743
2513
|
* @param {PublicKey} user_public_key
|
|
1744
2514
|
* @returns {Promise<PublicKey | undefined>}
|
|
1745
2515
|
*/
|
|
@@ -1790,11 +2560,11 @@ class Pubky {
|
|
|
1790
2560
|
/**
|
|
1791
2561
|
* Restore a session from a previously exported token or snapshot, using this instance's client.
|
|
1792
2562
|
*
|
|
1793
|
-
* Accepts grant secret tokens from `session.
|
|
2563
|
+
* Accepts grant secret tokens from `session.exportLocalSecret()` and legacy cookie
|
|
1794
2564
|
* secret tokens. Also accepts legacy cookie metadata snapshots from `session.export()`.
|
|
1795
2565
|
* Grant restore mints a fresh short-lived bearer.
|
|
1796
2566
|
*
|
|
1797
|
-
* @param {string} exported A string produced by `session.
|
|
2567
|
+
* @param {string} exported A string produced by `session.exportLocalSecret()` or legacy `session.export()`.
|
|
1798
2568
|
* @returns {Promise<Session>}
|
|
1799
2569
|
* A rehydrated session bound to this SDK's HTTP client.
|
|
1800
2570
|
*
|
|
@@ -1812,11 +2582,17 @@ class Pubky {
|
|
|
1812
2582
|
/**
|
|
1813
2583
|
* Resume a previously started **pubkyauth** flow from its saved `authorizationUrl`.
|
|
1814
2584
|
*
|
|
2585
|
+
* If the user refreshes or navigates away mid-flow, WASM memory is lost and
|
|
2586
|
+
* the original `AuthFlow` object is gone. You can reconnect to the same relay
|
|
2587
|
+
* channel by saving the `authorizationUrl` beforehand and calling this method
|
|
2588
|
+
* after reload.
|
|
2589
|
+
*
|
|
1815
2590
|
* The relay inbox retains messages for **~5 minutes**. Resume is only
|
|
1816
2591
|
* viable within that window; afterwards start a fresh flow.
|
|
1817
2592
|
*
|
|
1818
2593
|
* **Security:** The URL contains the `client_secret` in plaintext.
|
|
1819
|
-
*
|
|
2594
|
+
* Store it in `sessionStorage` (scoped to the tab), **not** `localStorage`,
|
|
2595
|
+
* and delete it as soon as the resumed flow completes or is abandoned.
|
|
1820
2596
|
* See `startCookieAuthFlow()` docs for full storage guidance.
|
|
1821
2597
|
*
|
|
1822
2598
|
* @param {string} authorizationUrl The `pubkyauth://…` URL from a previous flow.
|
|
@@ -1824,6 +2600,23 @@ class Pubky {
|
|
|
1824
2600
|
* @throws {PubkyError}
|
|
1825
2601
|
* - `{ name: "AuthenticationError" }` if the URL is invalid or not a signin/signup link
|
|
1826
2602
|
* - `{ name: "RequestError" }` on network/relay failure
|
|
2603
|
+
*
|
|
2604
|
+
* @example
|
|
2605
|
+
* // 1) Before a potential refresh, persist the URL.
|
|
2606
|
+
* const flow = pubky.startCookieAuthFlow("/pub/my-cool-app/:rw", AuthFlowKind.signin());
|
|
2607
|
+
* sessionStorage.setItem("pubky-auth-url", flow.authorizationUrl);
|
|
2608
|
+
* renderQr(flow.authorizationUrl);
|
|
2609
|
+
*
|
|
2610
|
+
* // 2) After reload, resume from the saved URL.
|
|
2611
|
+
* const savedUrl = sessionStorage.getItem("pubky-auth-url");
|
|
2612
|
+
* if (savedUrl) {
|
|
2613
|
+
* try {
|
|
2614
|
+
* const resumed = pubky.resumeCookieAuthFlow(savedUrl);
|
|
2615
|
+
* const session = await resumed.awaitApproval();
|
|
2616
|
+
* } finally {
|
|
2617
|
+
* sessionStorage.removeItem("pubky-auth-url");
|
|
2618
|
+
* }
|
|
2619
|
+
* }
|
|
1827
2620
|
* @param {string} authorization_url
|
|
1828
2621
|
* @returns {AuthFlow}
|
|
1829
2622
|
*/
|
|
@@ -1836,13 +2629,29 @@ class Pubky {
|
|
|
1836
2629
|
}
|
|
1837
2630
|
return AuthFlow.__wrap(ret[0]);
|
|
1838
2631
|
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Resume a previously saved pending delegated grant auth flow.
|
|
2634
|
+
*
|
|
2635
|
+
* Runtime: delegated grant keys require a secure browser context with
|
|
2636
|
+
* WebCrypto `crypto.subtle` and IndexedDB. The saved `keyId` must still
|
|
2637
|
+
* exist in IndexedDB for the same origin. Unsupported runtimes reject with
|
|
2638
|
+
* `ClientStateError`.
|
|
2639
|
+
* @param {string} saved_state
|
|
2640
|
+
* @returns {Promise<GrantAuthFlow>}
|
|
2641
|
+
*/
|
|
2642
|
+
resumeDelegatedGrantAuthFlow(saved_state) {
|
|
2643
|
+
const ptr0 = passStringToWasm0(saved_state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2644
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2645
|
+
const ret = wasm.pubky_resumeDelegatedGrantAuthFlow(this.__wbg_ptr, ptr0, len0);
|
|
2646
|
+
return ret;
|
|
2647
|
+
}
|
|
1839
2648
|
/**
|
|
1840
2649
|
* Resume a previously saved pending grant auth flow.
|
|
1841
2650
|
*
|
|
1842
2651
|
* **Security:** `savedState` contains the relay secret and PoP client private key.
|
|
1843
2652
|
* Delete it from storage as soon as the resumed flow completes.
|
|
1844
2653
|
*
|
|
1845
|
-
* @param {string} savedState A string produced by `grantFlow.
|
|
2654
|
+
* @param {string} savedState A string produced by `grantFlow.saveLocal()`.
|
|
1846
2655
|
* @returns {GrantAuthFlow} A flow reconnected to the original relay channel.
|
|
1847
2656
|
* @param {string} saved_state
|
|
1848
2657
|
* @returns {GrantAuthFlow}
|
|
@@ -1893,6 +2702,7 @@ class Pubky {
|
|
|
1893
2702
|
* - `AuthFlowKind.signin()` - Sign in to an existing account.
|
|
1894
2703
|
* - `AuthFlowKind.signup(homeserverPublicKey, signupToken)` - Sign up for a new account.
|
|
1895
2704
|
* @param {string=} relay Optional HTTP relay base (e.g. `"https://…/inbox/"`).
|
|
2705
|
+
* @param {XCallbackParams=} xCallback Optional app return destinations.
|
|
1896
2706
|
* @returns {AuthFlow}
|
|
1897
2707
|
* A running auth flow. Show `authorizationUrl` as QR/deeplink,
|
|
1898
2708
|
* then `awaitApproval()` to obtain a `Session`.
|
|
@@ -1908,16 +2718,17 @@ class Pubky {
|
|
|
1908
2718
|
* @param {Capabilities} capabilities
|
|
1909
2719
|
* @param {AuthFlowKind} kind
|
|
1910
2720
|
* @param {string | null} [relay]
|
|
2721
|
+
* @param {XCallbackParams | null} [x_callback]
|
|
1911
2722
|
* @returns {AuthFlow}
|
|
1912
2723
|
*/
|
|
1913
|
-
startCookieAuthFlow(capabilities, kind, relay) {
|
|
2724
|
+
startCookieAuthFlow(capabilities, kind, relay, x_callback) {
|
|
1914
2725
|
const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1915
2726
|
const len0 = WASM_VECTOR_LEN;
|
|
1916
2727
|
_assertClass(kind, AuthFlowKind);
|
|
1917
2728
|
var ptr1 = kind.__destroy_into_raw();
|
|
1918
2729
|
var ptr2 = isLikeNone(relay) ? 0 : passStringToWasm0(relay, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1919
2730
|
var len2 = WASM_VECTOR_LEN;
|
|
1920
|
-
const ret = wasm.pubky_startCookieAuthFlow(this.__wbg_ptr, ptr0, len0, ptr1, ptr2, len2);
|
|
2731
|
+
const ret = wasm.pubky_startCookieAuthFlow(this.__wbg_ptr, ptr0, len0, ptr1, ptr2, len2, isLikeNone(x_callback) ? 0 : addToExternrefTable0(x_callback));
|
|
1921
2732
|
if (ret[2]) {
|
|
1922
2733
|
throw takeFromExternrefTable0(ret[1]);
|
|
1923
2734
|
}
|
|
@@ -1931,13 +2742,14 @@ class Pubky {
|
|
|
1931
2742
|
*
|
|
1932
2743
|
* @param {string} capabilities Comma-separated caps, e.g. `"/pub/app/:rw,/pub/foo/file:r"`.
|
|
1933
2744
|
* @param {AuthFlowKind} kind The kind of authentication flow to perform.
|
|
1934
|
-
* @param {GrantAuthFlowOptions} options Options for the grant flow:
|
|
1935
|
-
*
|
|
2745
|
+
* @param {GrantAuthFlowOptions} options Options for the grant flow:
|
|
2746
|
+
* `{ clientId, relay?, xCallback? }`.
|
|
2747
|
+
* @returns {Promise<GrantAuthFlow>}
|
|
1936
2748
|
* A running grant auth flow. Show `authorizationUrl` as QR/deeplink,
|
|
1937
2749
|
* then `awaitApproval()` to obtain a grant-backed `Session`.
|
|
1938
2750
|
*
|
|
1939
2751
|
* @example
|
|
1940
|
-
* const flow = pubky.startGrantAuthFlow(
|
|
2752
|
+
* const flow = await pubky.startGrantAuthFlow(
|
|
1941
2753
|
* "/pub/my-cool-app/:rw",
|
|
1942
2754
|
* AuthFlowKind.signin(),
|
|
1943
2755
|
* { clientId: "my-cool-app.example" },
|
|
@@ -1945,7 +2757,7 @@ class Pubky {
|
|
|
1945
2757
|
* @param {Capabilities} capabilities
|
|
1946
2758
|
* @param {AuthFlowKind} kind
|
|
1947
2759
|
* @param {GrantAuthFlowOptions} options
|
|
1948
|
-
* @returns {GrantAuthFlow}
|
|
2760
|
+
* @returns {Promise<GrantAuthFlow>}
|
|
1949
2761
|
*/
|
|
1950
2762
|
startGrantAuthFlow(capabilities, kind, options) {
|
|
1951
2763
|
const ptr0 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -1953,10 +2765,7 @@ class Pubky {
|
|
|
1953
2765
|
_assertClass(kind, AuthFlowKind);
|
|
1954
2766
|
var ptr1 = kind.__destroy_into_raw();
|
|
1955
2767
|
const ret = wasm.pubky_startGrantAuthFlow(this.__wbg_ptr, ptr0, len0, ptr1, options);
|
|
1956
|
-
|
|
1957
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
1958
|
-
}
|
|
1959
|
-
return GrantAuthFlow.__wrap(ret[0]);
|
|
2768
|
+
return ret;
|
|
1960
2769
|
}
|
|
1961
2770
|
/**
|
|
1962
2771
|
* Create a Pubky facade preconfigured for a **local testnet**.
|
|
@@ -2393,6 +3202,14 @@ class SeedExportDeepLink {
|
|
|
2393
3202
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2394
3203
|
}
|
|
2395
3204
|
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Optional x-callback-url metadata carried by this deep link.
|
|
3207
|
+
* @returns {XCallbackParams}
|
|
3208
|
+
*/
|
|
3209
|
+
get xCallback() {
|
|
3210
|
+
const ret = wasm.seedexportdeeplink_xCallback(this.__wbg_ptr);
|
|
3211
|
+
return ret;
|
|
3212
|
+
}
|
|
2396
3213
|
}
|
|
2397
3214
|
if (Symbol.dispose) SeedExportDeepLink.prototype[Symbol.dispose] = SeedExportDeepLink.prototype.free;
|
|
2398
3215
|
exports.SeedExportDeepLink = SeedExportDeepLink;
|
|
@@ -2441,7 +3258,7 @@ class Session {
|
|
|
2441
3258
|
* @returns {string}
|
|
2442
3259
|
* A base64 string to store (e.g. in `localStorage`).
|
|
2443
3260
|
*
|
|
2444
|
-
* @deprecated Prefer `
|
|
3261
|
+
* @deprecated Prefer `exportLocalSecret()` for grant sessions.
|
|
2445
3262
|
* @returns {string}
|
|
2446
3263
|
*/
|
|
2447
3264
|
export() {
|
|
@@ -2457,11 +3274,12 @@ class Session {
|
|
|
2457
3274
|
}
|
|
2458
3275
|
}
|
|
2459
3276
|
/**
|
|
2460
|
-
* Export the secret material needed to restore this session.
|
|
3277
|
+
* Export the local secret material needed to restore this session.
|
|
2461
3278
|
*
|
|
2462
|
-
* For grant sessions this exports the grant JWS and PoP client secret;
|
|
2463
|
-
* mints a fresh bearer. For legacy cookie sessions this exports the
|
|
2464
|
-
* when the SDK owns it.
|
|
3279
|
+
* For local grant sessions this exports the grant JWS and PoP client secret;
|
|
3280
|
+
* restoring mints a fresh bearer. For legacy cookie sessions this exports the
|
|
3281
|
+
* cookie secret when the SDK owns it. Delegated browser grant sessions cannot
|
|
3282
|
+
* export raw secret material; use `BrowserSessionStore`.
|
|
2465
3283
|
*
|
|
2466
3284
|
* Treat the returned string as a bearer-equivalent secret until the grant or
|
|
2467
3285
|
* cookie session expires or is revoked.
|
|
@@ -2470,8 +3288,8 @@ class Session {
|
|
|
2470
3288
|
* A secret token that can be passed to `pubky.restoreSession()`.
|
|
2471
3289
|
* @returns {Promise<string>}
|
|
2472
3290
|
*/
|
|
2473
|
-
|
|
2474
|
-
const ret = wasm.
|
|
3291
|
+
exportLocalSecret() {
|
|
3292
|
+
const ret = wasm.session_exportLocalSecret(this.__wbg_ptr);
|
|
2475
3293
|
return ret;
|
|
2476
3294
|
}
|
|
2477
3295
|
/**
|
|
@@ -2854,6 +3672,20 @@ class Signer {
|
|
|
2854
3672
|
}
|
|
2855
3673
|
return Signer.__wrap(ret[0]);
|
|
2856
3674
|
}
|
|
3675
|
+
/**
|
|
3676
|
+
* Handle a `pubkyauth://` deep link.
|
|
3677
|
+
*
|
|
3678
|
+
* Auth requests are approved through their relay. A `direct_signup` link
|
|
3679
|
+
* creates an account on its target homeserver.
|
|
3680
|
+
* @param {string} pubkyauth_url
|
|
3681
|
+
* @returns {Promise<void>}
|
|
3682
|
+
*/
|
|
3683
|
+
handleDeepLink(pubkyauth_url) {
|
|
3684
|
+
const ptr0 = passStringToWasm0(pubkyauth_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3685
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3686
|
+
const ret = wasm.signer_handleDeepLink(this.__wbg_ptr, ptr0, len0);
|
|
3687
|
+
return ret;
|
|
3688
|
+
}
|
|
2857
3689
|
/**
|
|
2858
3690
|
* Get a PKDNS actor bound to this signer's client & keypair (publishing enabled).
|
|
2859
3691
|
*
|
|
@@ -3058,6 +3890,14 @@ class SigninDeepLink {
|
|
|
3058
3890
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3059
3891
|
}
|
|
3060
3892
|
}
|
|
3893
|
+
/**
|
|
3894
|
+
* Optional x-callback-url metadata carried by this deep link.
|
|
3895
|
+
* @returns {XCallbackParams}
|
|
3896
|
+
*/
|
|
3897
|
+
get xCallback() {
|
|
3898
|
+
const ret = wasm.signindeeplink_xCallback(this.__wbg_ptr);
|
|
3899
|
+
return ret;
|
|
3900
|
+
}
|
|
3061
3901
|
}
|
|
3062
3902
|
if (Symbol.dispose) SigninDeepLink.prototype[Symbol.dispose] = SigninDeepLink.prototype.free;
|
|
3063
3903
|
exports.SigninDeepLink = SigninDeepLink;
|
|
@@ -3198,6 +4038,14 @@ class SigninGrantDeepLink {
|
|
|
3198
4038
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3199
4039
|
}
|
|
3200
4040
|
}
|
|
4041
|
+
/**
|
|
4042
|
+
* Optional x-callback-url metadata carried by this deep link.
|
|
4043
|
+
* @returns {XCallbackParams}
|
|
4044
|
+
*/
|
|
4045
|
+
get xCallback() {
|
|
4046
|
+
const ret = wasm.signingrantdeeplink_xCallback(this.__wbg_ptr);
|
|
4047
|
+
return ret;
|
|
4048
|
+
}
|
|
3201
4049
|
}
|
|
3202
4050
|
if (Symbol.dispose) SigninGrantDeepLink.prototype[Symbol.dispose] = SigninGrantDeepLink.prototype.free;
|
|
3203
4051
|
exports.SigninGrantDeepLink = SigninGrantDeepLink;
|
|
@@ -3304,6 +4152,14 @@ class SignupDeepLink {
|
|
|
3304
4152
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3305
4153
|
}
|
|
3306
4154
|
}
|
|
4155
|
+
/**
|
|
4156
|
+
* Optional x-callback-url metadata carried by this deep link.
|
|
4157
|
+
* @returns {XCallbackParams}
|
|
4158
|
+
*/
|
|
4159
|
+
get xCallback() {
|
|
4160
|
+
const ret = wasm.signupdeeplink_xCallback(this.__wbg_ptr);
|
|
4161
|
+
return ret;
|
|
4162
|
+
}
|
|
3307
4163
|
}
|
|
3308
4164
|
if (Symbol.dispose) SignupDeepLink.prototype[Symbol.dispose] = SignupDeepLink.prototype.free;
|
|
3309
4165
|
exports.SignupDeepLink = SignupDeepLink;
|
|
@@ -3469,10 +4325,165 @@ class SignupGrantDeepLink {
|
|
|
3469
4325
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3470
4326
|
}
|
|
3471
4327
|
}
|
|
4328
|
+
/**
|
|
4329
|
+
* Optional x-callback-url metadata carried by this deep link.
|
|
4330
|
+
* @returns {XCallbackParams}
|
|
4331
|
+
*/
|
|
4332
|
+
get xCallback() {
|
|
4333
|
+
const ret = wasm.signupgrantdeeplink_xCallback(this.__wbg_ptr);
|
|
4334
|
+
return ret;
|
|
4335
|
+
}
|
|
3472
4336
|
}
|
|
3473
4337
|
if (Symbol.dispose) SignupGrantDeepLink.prototype[Symbol.dispose] = SignupGrantDeepLink.prototype.free;
|
|
3474
4338
|
exports.SignupGrantDeepLink = SignupGrantDeepLink;
|
|
3475
4339
|
|
|
4340
|
+
/**
|
|
4341
|
+
* Metadata for a session saved in the browser session store.
|
|
4342
|
+
*/
|
|
4343
|
+
class StoredSessionInfo {
|
|
4344
|
+
static __wrap(ptr) {
|
|
4345
|
+
ptr = ptr >>> 0;
|
|
4346
|
+
const obj = Object.create(StoredSessionInfo.prototype);
|
|
4347
|
+
obj.__wbg_ptr = ptr;
|
|
4348
|
+
StoredSessionInfoFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4349
|
+
return obj;
|
|
4350
|
+
}
|
|
4351
|
+
__destroy_into_raw() {
|
|
4352
|
+
const ptr = this.__wbg_ptr;
|
|
4353
|
+
this.__wbg_ptr = 0;
|
|
4354
|
+
StoredSessionInfoFinalization.unregister(this);
|
|
4355
|
+
return ptr;
|
|
4356
|
+
}
|
|
4357
|
+
free() {
|
|
4358
|
+
const ptr = this.__destroy_into_raw();
|
|
4359
|
+
wasm.__wbg_storedsessioninfo_free(ptr, 0);
|
|
4360
|
+
}
|
|
4361
|
+
/**
|
|
4362
|
+
* Authorized capabilities.
|
|
4363
|
+
* @returns {string[]}
|
|
4364
|
+
*/
|
|
4365
|
+
get capabilities() {
|
|
4366
|
+
const ret = wasm.storedsessioninfo_capabilities(this.__wbg_ptr);
|
|
4367
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
4368
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
4369
|
+
return v1;
|
|
4370
|
+
}
|
|
4371
|
+
/**
|
|
4372
|
+
* Application/client identifier.
|
|
4373
|
+
* @returns {string}
|
|
4374
|
+
*/
|
|
4375
|
+
get clientId() {
|
|
4376
|
+
let deferred1_0;
|
|
4377
|
+
let deferred1_1;
|
|
4378
|
+
try {
|
|
4379
|
+
const ret = wasm.storedsessioninfo_clientId(this.__wbg_ptr);
|
|
4380
|
+
deferred1_0 = ret[0];
|
|
4381
|
+
deferred1_1 = ret[1];
|
|
4382
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4383
|
+
} finally {
|
|
4384
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
/**
|
|
4388
|
+
* Local save timestamp, in Unix milliseconds.
|
|
4389
|
+
* @returns {number}
|
|
4390
|
+
*/
|
|
4391
|
+
get createdAt() {
|
|
4392
|
+
const ret = wasm.storedsessioninfo_createdAt(this.__wbg_ptr);
|
|
4393
|
+
return ret;
|
|
4394
|
+
}
|
|
4395
|
+
/**
|
|
4396
|
+
* Underlying grant expiry timestamp, in Unix seconds.
|
|
4397
|
+
* @returns {number}
|
|
4398
|
+
*/
|
|
4399
|
+
get grantExpiresAt() {
|
|
4400
|
+
const ret = wasm.storedsessioninfo_grantExpiresAt(this.__wbg_ptr);
|
|
4401
|
+
return ret;
|
|
4402
|
+
}
|
|
4403
|
+
/**
|
|
4404
|
+
* Grant identifier backing this stored session.
|
|
4405
|
+
* @returns {string}
|
|
4406
|
+
*/
|
|
4407
|
+
get grantId() {
|
|
4408
|
+
let deferred1_0;
|
|
4409
|
+
let deferred1_1;
|
|
4410
|
+
try {
|
|
4411
|
+
const ret = wasm.storedsessioninfo_grantId(this.__wbg_ptr);
|
|
4412
|
+
deferred1_0 = ret[0];
|
|
4413
|
+
deferred1_1 = ret[1];
|
|
4414
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4415
|
+
} finally {
|
|
4416
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
/**
|
|
4420
|
+
* Homeserver public key as z32.
|
|
4421
|
+
* @returns {string}
|
|
4422
|
+
*/
|
|
4423
|
+
get homeserver() {
|
|
4424
|
+
let deferred1_0;
|
|
4425
|
+
let deferred1_1;
|
|
4426
|
+
try {
|
|
4427
|
+
const ret = wasm.storedsessioninfo_homeserver(this.__wbg_ptr);
|
|
4428
|
+
deferred1_0 = ret[0];
|
|
4429
|
+
deferred1_1 = ret[1];
|
|
4430
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4431
|
+
} finally {
|
|
4432
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
/**
|
|
4436
|
+
* Stable local identifier for this stored session.
|
|
4437
|
+
* @returns {string}
|
|
4438
|
+
*/
|
|
4439
|
+
get id() {
|
|
4440
|
+
let deferred1_0;
|
|
4441
|
+
let deferred1_1;
|
|
4442
|
+
try {
|
|
4443
|
+
const ret = wasm.storedsessioninfo_id(this.__wbg_ptr);
|
|
4444
|
+
deferred1_0 = ret[0];
|
|
4445
|
+
deferred1_1 = ret[1];
|
|
4446
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4447
|
+
} finally {
|
|
4448
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
/**
|
|
4452
|
+
* User public key as z32.
|
|
4453
|
+
* @returns {string}
|
|
4454
|
+
*/
|
|
4455
|
+
get publicKey() {
|
|
4456
|
+
let deferred1_0;
|
|
4457
|
+
let deferred1_1;
|
|
4458
|
+
try {
|
|
4459
|
+
const ret = wasm.storedsessioninfo_publicKey(this.__wbg_ptr);
|
|
4460
|
+
deferred1_0 = ret[0];
|
|
4461
|
+
deferred1_1 = ret[1];
|
|
4462
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4463
|
+
} finally {
|
|
4464
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
/**
|
|
4468
|
+
* `delegated` for origin-bound WebCrypto sessions, `localSecret` for raw local PoP secret storage.
|
|
4469
|
+
* @returns {string}
|
|
4470
|
+
*/
|
|
4471
|
+
get storageMode() {
|
|
4472
|
+
let deferred1_0;
|
|
4473
|
+
let deferred1_1;
|
|
4474
|
+
try {
|
|
4475
|
+
const ret = wasm.storedsessioninfo_storageMode(this.__wbg_ptr);
|
|
4476
|
+
deferred1_0 = ret[0];
|
|
4477
|
+
deferred1_1 = ret[1];
|
|
4478
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4479
|
+
} finally {
|
|
4480
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
if (Symbol.dispose) StoredSessionInfo.prototype[Symbol.dispose] = StoredSessionInfo.prototype.free;
|
|
4485
|
+
exports.StoredSessionInfo = StoredSessionInfo;
|
|
4486
|
+
|
|
3476
4487
|
/**
|
|
3477
4488
|
* Resolve a `pubky://` or `pubky<pk>/…` identifier into the homeserver transport URL.
|
|
3478
4489
|
*
|
|
@@ -3537,12 +4548,12 @@ exports.setLogLevel = setLogLevel;
|
|
|
3537
4548
|
* Validate and normalize a capabilities string.
|
|
3538
4549
|
*
|
|
3539
4550
|
* - Normalizes action order (`wr` -> `rw`)
|
|
3540
|
-
* - Throws `InvalidInput`
|
|
4551
|
+
* - Throws `InvalidInput` identifying the first malformed entry.
|
|
3541
4552
|
*
|
|
3542
4553
|
* @param {string} input
|
|
3543
4554
|
* @returns {string} Normalized string (same shape as input).
|
|
3544
4555
|
* @throws {PubkyError} `{ name: "InvalidInput" }` with a helpful message.
|
|
3545
|
-
* The error's `data` field is `{ invalidEntries: string[] }`
|
|
4556
|
+
* The error's `data` field is `{ invalidEntries: string[] }` containing the malformed token.
|
|
3546
4557
|
* @param {string} input
|
|
3547
4558
|
* @returns {string}
|
|
3548
4559
|
*/
|
|
@@ -3567,6 +4578,68 @@ function validateCapabilities(input) {
|
|
|
3567
4578
|
}
|
|
3568
4579
|
}
|
|
3569
4580
|
exports.validateCapabilities = validateCapabilities;
|
|
4581
|
+
const import1 = {
|
|
4582
|
+
__pubkyGrantIsDelegationAvailable,
|
|
4583
|
+
__pubkyGrantCanUseDelegation,
|
|
4584
|
+
__pubkyGrantEnsureDelegatedKey,
|
|
4585
|
+
__pubkyGrantLoadDelegatedPublicKey,
|
|
4586
|
+
__pubkyGrantDelegatedSign,
|
|
4587
|
+
__pubkyGrantDeleteDelegatedKey,
|
|
4588
|
+
};
|
|
4589
|
+
const import2 = {
|
|
4590
|
+
__pubkySessionStoreIsAvailable,
|
|
4591
|
+
__pubkySessionStorePut,
|
|
4592
|
+
__pubkySessionStoreGet,
|
|
4593
|
+
__pubkySessionStoreList,
|
|
4594
|
+
__pubkySessionStoreDelete,
|
|
4595
|
+
__pubkySessionStoreClear,
|
|
4596
|
+
__pubkySessionStoreClearAll,
|
|
4597
|
+
};
|
|
4598
|
+
const import3 = {
|
|
4599
|
+
__pubkySessionStoreIsAvailable,
|
|
4600
|
+
__pubkySessionStorePut,
|
|
4601
|
+
__pubkySessionStoreGet,
|
|
4602
|
+
__pubkySessionStoreList,
|
|
4603
|
+
__pubkySessionStoreDelete,
|
|
4604
|
+
__pubkySessionStoreClear,
|
|
4605
|
+
__pubkySessionStoreClearAll,
|
|
4606
|
+
};
|
|
4607
|
+
const import4 = {
|
|
4608
|
+
__pubkySessionStoreIsAvailable,
|
|
4609
|
+
__pubkySessionStorePut,
|
|
4610
|
+
__pubkySessionStoreGet,
|
|
4611
|
+
__pubkySessionStoreList,
|
|
4612
|
+
__pubkySessionStoreDelete,
|
|
4613
|
+
__pubkySessionStoreClear,
|
|
4614
|
+
__pubkySessionStoreClearAll,
|
|
4615
|
+
};
|
|
4616
|
+
const import5 = {
|
|
4617
|
+
__pubkySessionStoreIsAvailable,
|
|
4618
|
+
__pubkySessionStorePut,
|
|
4619
|
+
__pubkySessionStoreGet,
|
|
4620
|
+
__pubkySessionStoreList,
|
|
4621
|
+
__pubkySessionStoreDelete,
|
|
4622
|
+
__pubkySessionStoreClear,
|
|
4623
|
+
__pubkySessionStoreClearAll,
|
|
4624
|
+
};
|
|
4625
|
+
const import6 = {
|
|
4626
|
+
__pubkySessionStoreIsAvailable,
|
|
4627
|
+
__pubkySessionStorePut,
|
|
4628
|
+
__pubkySessionStoreGet,
|
|
4629
|
+
__pubkySessionStoreList,
|
|
4630
|
+
__pubkySessionStoreDelete,
|
|
4631
|
+
__pubkySessionStoreClear,
|
|
4632
|
+
__pubkySessionStoreClearAll,
|
|
4633
|
+
};
|
|
4634
|
+
const import7 = {
|
|
4635
|
+
__pubkyGrantIsDelegationAvailable,
|
|
4636
|
+
__pubkyGrantCanUseDelegation,
|
|
4637
|
+
__pubkyGrantEnsureDelegatedKey,
|
|
4638
|
+
__pubkyGrantLoadDelegatedPublicKey,
|
|
4639
|
+
__pubkyGrantDelegatedSign,
|
|
4640
|
+
__pubkyGrantDeleteDelegatedKey,
|
|
4641
|
+
};
|
|
4642
|
+
|
|
3570
4643
|
function __wbg_get_imports() {
|
|
3571
4644
|
const import0 = {
|
|
3572
4645
|
__proto__: null,
|
|
@@ -3581,6 +4654,80 @@ function __wbg_get_imports() {
|
|
|
3581
4654
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3582
4655
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3583
4656
|
},
|
|
4657
|
+
__wbg___pubkyGrantDelegatedSign_5cb443da0321d209: function(arg0, arg1, arg2, arg3) {
|
|
4658
|
+
let deferred0_0;
|
|
4659
|
+
let deferred0_1;
|
|
4660
|
+
let deferred1_0;
|
|
4661
|
+
let deferred1_1;
|
|
4662
|
+
try {
|
|
4663
|
+
deferred0_0 = arg0;
|
|
4664
|
+
deferred0_1 = arg1;
|
|
4665
|
+
deferred1_0 = arg2;
|
|
4666
|
+
deferred1_1 = arg3;
|
|
4667
|
+
const ret = __pubkyGrantDelegatedSign(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
|
|
4668
|
+
return ret;
|
|
4669
|
+
} finally {
|
|
4670
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
4671
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4672
|
+
}
|
|
4673
|
+
},
|
|
4674
|
+
__wbg___pubkyGrantDeleteDelegatedKey_0f4d62b84caef0fa: function(arg0, arg1) {
|
|
4675
|
+
let deferred0_0;
|
|
4676
|
+
let deferred0_1;
|
|
4677
|
+
try {
|
|
4678
|
+
deferred0_0 = arg0;
|
|
4679
|
+
deferred0_1 = arg1;
|
|
4680
|
+
const ret = __pubkyGrantDeleteDelegatedKey(getStringFromWasm0(arg0, arg1));
|
|
4681
|
+
return ret;
|
|
4682
|
+
} finally {
|
|
4683
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
4684
|
+
}
|
|
4685
|
+
},
|
|
4686
|
+
__wbg___pubkyGrantEnsureDelegatedKey_8e535d8d53f48fdc: function(arg0, arg1) {
|
|
4687
|
+
let v0;
|
|
4688
|
+
if (arg0 !== 0) {
|
|
4689
|
+
v0 = getStringFromWasm0(arg0, arg1).slice();
|
|
4690
|
+
wasm.__wbindgen_free(arg0, arg1 * 1, 1);
|
|
4691
|
+
}
|
|
4692
|
+
const ret = __pubkyGrantEnsureDelegatedKey(v0);
|
|
4693
|
+
return ret;
|
|
4694
|
+
},
|
|
4695
|
+
__wbg___pubkyGrantLoadDelegatedPublicKey_501aaeb6b721477e: function(arg0, arg1) {
|
|
4696
|
+
let deferred0_0;
|
|
4697
|
+
let deferred0_1;
|
|
4698
|
+
try {
|
|
4699
|
+
deferred0_0 = arg0;
|
|
4700
|
+
deferred0_1 = arg1;
|
|
4701
|
+
const ret = __pubkyGrantLoadDelegatedPublicKey(getStringFromWasm0(arg0, arg1));
|
|
4702
|
+
return ret;
|
|
4703
|
+
} finally {
|
|
4704
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
4705
|
+
}
|
|
4706
|
+
},
|
|
4707
|
+
__wbg___pubkySessionStoreDelete_9809101d930e5c86: function(arg0, arg1) {
|
|
4708
|
+
let deferred0_0;
|
|
4709
|
+
let deferred0_1;
|
|
4710
|
+
try {
|
|
4711
|
+
deferred0_0 = arg0;
|
|
4712
|
+
deferred0_1 = arg1;
|
|
4713
|
+
const ret = __pubkySessionStoreDelete(getStringFromWasm0(arg0, arg1));
|
|
4714
|
+
return ret;
|
|
4715
|
+
} finally {
|
|
4716
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
4717
|
+
}
|
|
4718
|
+
},
|
|
4719
|
+
__wbg___pubkySessionStoreGet_c67e79fe9c058d05: function(arg0, arg1) {
|
|
4720
|
+
let deferred0_0;
|
|
4721
|
+
let deferred0_1;
|
|
4722
|
+
try {
|
|
4723
|
+
deferred0_0 = arg0;
|
|
4724
|
+
deferred0_1 = arg1;
|
|
4725
|
+
const ret = __pubkySessionStoreGet(getStringFromWasm0(arg0, arg1));
|
|
4726
|
+
return ret;
|
|
4727
|
+
} finally {
|
|
4728
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
4729
|
+
}
|
|
4730
|
+
},
|
|
3584
4731
|
__wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51: function(arg0, arg1) {
|
|
3585
4732
|
const v = arg1;
|
|
3586
4733
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
@@ -3756,7 +4903,7 @@ function __wbg_get_imports() {
|
|
|
3756
4903
|
const ret = arg0.fetch(arg1);
|
|
3757
4904
|
return ret;
|
|
3758
4905
|
},
|
|
3759
|
-
|
|
4906
|
+
__wbg_fetch_7888dbbb5aebe24d: function(arg0) {
|
|
3760
4907
|
const ret = fetch(arg0);
|
|
3761
4908
|
return ret;
|
|
3762
4909
|
},
|
|
@@ -3798,6 +4945,14 @@ function __wbg_get_imports() {
|
|
|
3798
4945
|
const ret = arg0.value;
|
|
3799
4946
|
return ret;
|
|
3800
4947
|
},
|
|
4948
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
4949
|
+
const ret = arg0[arg1];
|
|
4950
|
+
return ret;
|
|
4951
|
+
},
|
|
4952
|
+
__wbg_grantauthflow_new: function(arg0) {
|
|
4953
|
+
const ret = GrantAuthFlow.__wrap(arg0);
|
|
4954
|
+
return ret;
|
|
4955
|
+
},
|
|
3801
4956
|
__wbg_grantinfo_new: function(arg0) {
|
|
3802
4957
|
const ret = GrantInfo.__wrap(arg0);
|
|
3803
4958
|
return ret;
|
|
@@ -3943,7 +5098,7 @@ function __wbg_get_imports() {
|
|
|
3943
5098
|
const a = state0.a;
|
|
3944
5099
|
state0.a = 0;
|
|
3945
5100
|
try {
|
|
3946
|
-
return
|
|
5101
|
+
return wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___js_sys_4b0493a0be09c0f___Function_fn_wasm_bindgen_77cee878d4ea2fd9___JsValue_____wasm_bindgen_77cee878d4ea2fd9___sys__Undefined___js_sys_4b0493a0be09c0f___Function_fn_wasm_bindgen_77cee878d4ea2fd9___JsValue_____wasm_bindgen_77cee878d4ea2fd9___sys__Undefined_______true_(a, state0.b, arg0, arg1);
|
|
3947
5102
|
} finally {
|
|
3948
5103
|
state0.a = a;
|
|
3949
5104
|
}
|
|
@@ -4129,6 +5284,10 @@ function __wbg_get_imports() {
|
|
|
4129
5284
|
const ret = arg0.status;
|
|
4130
5285
|
return ret;
|
|
4131
5286
|
},
|
|
5287
|
+
__wbg_storedsessioninfo_new: function(arg0) {
|
|
5288
|
+
const ret = StoredSessionInfo.__wrap(arg0);
|
|
5289
|
+
return ret;
|
|
5290
|
+
},
|
|
4132
5291
|
__wbg_stringify_91082ed7a5a5769e: function() { return handleError(function (arg0) {
|
|
4133
5292
|
const ret = JSON.stringify(arg0);
|
|
4134
5293
|
return ret;
|
|
@@ -4176,18 +5335,18 @@ function __wbg_get_imports() {
|
|
|
4176
5335
|
console.warn(arg0, arg1, arg2, arg3);
|
|
4177
5336
|
},
|
|
4178
5337
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
4179
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
4180
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
5338
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 130, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
5339
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___wasm_bindgen_77cee878d4ea2fd9___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_77cee878d4ea2fd9___JsError___true_);
|
|
4181
5340
|
return ret;
|
|
4182
5341
|
},
|
|
4183
5342
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
4184
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
4185
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
5343
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 266, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
5344
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___wasm_bindgen_77cee878d4ea2fd9___JsValue______true_);
|
|
4186
5345
|
return ret;
|
|
4187
5346
|
},
|
|
4188
5347
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
4189
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
4190
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
5348
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 264, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
5349
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke_______true_);
|
|
4191
5350
|
return ret;
|
|
4192
5351
|
},
|
|
4193
5352
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -4223,6 +5382,13 @@ function __wbg_get_imports() {
|
|
|
4223
5382
|
return ret;
|
|
4224
5383
|
},
|
|
4225
5384
|
__wbindgen_cast_000000000000000a: function(arg0, arg1) {
|
|
5385
|
+
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
|
|
5386
|
+
wasm.__wbindgen_free(arg0, arg1 * 4, 4);
|
|
5387
|
+
// Cast intrinsic for `Vector(NamedExternref("StoredSessionInfo")) -> Externref`.
|
|
5388
|
+
const ret = v0;
|
|
5389
|
+
return ret;
|
|
5390
|
+
},
|
|
5391
|
+
__wbindgen_cast_000000000000000b: function(arg0, arg1) {
|
|
4226
5392
|
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
|
|
4227
5393
|
wasm.__wbindgen_free(arg0, arg1 * 4, 4);
|
|
4228
5394
|
// Cast intrinsic for `Vector(NamedExternref("string")) -> Externref`.
|
|
@@ -4242,26 +5408,33 @@ function __wbg_get_imports() {
|
|
|
4242
5408
|
return {
|
|
4243
5409
|
__proto__: null,
|
|
4244
5410
|
"./pubky_bg.js": import0,
|
|
5411
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline1.js": import1,
|
|
5412
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline0.js": import2,
|
|
5413
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline0.js": import3,
|
|
5414
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline0.js": import4,
|
|
5415
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline0.js": import5,
|
|
5416
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline0.js": import6,
|
|
5417
|
+
"./snippets/pubky-wasm-aeccd1286880adbb/inline1.js": import7,
|
|
4245
5418
|
};
|
|
4246
5419
|
}
|
|
4247
5420
|
|
|
4248
|
-
function
|
|
4249
|
-
wasm.
|
|
5421
|
+
function wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke_______true_(arg0, arg1) {
|
|
5422
|
+
wasm.wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke_______true_(arg0, arg1);
|
|
4250
5423
|
}
|
|
4251
5424
|
|
|
4252
|
-
function
|
|
4253
|
-
wasm.
|
|
5425
|
+
function wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___wasm_bindgen_77cee878d4ea2fd9___JsValue______true_(arg0, arg1, arg2) {
|
|
5426
|
+
wasm.wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___wasm_bindgen_77cee878d4ea2fd9___JsValue______true_(arg0, arg1, arg2);
|
|
4254
5427
|
}
|
|
4255
5428
|
|
|
4256
|
-
function
|
|
4257
|
-
const ret = wasm.
|
|
5429
|
+
function wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___wasm_bindgen_77cee878d4ea2fd9___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_77cee878d4ea2fd9___JsError___true_(arg0, arg1, arg2) {
|
|
5430
|
+
const ret = wasm.wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___wasm_bindgen_77cee878d4ea2fd9___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_77cee878d4ea2fd9___JsError___true_(arg0, arg1, arg2);
|
|
4258
5431
|
if (ret[1]) {
|
|
4259
5432
|
throw takeFromExternrefTable0(ret[0]);
|
|
4260
5433
|
}
|
|
4261
5434
|
}
|
|
4262
5435
|
|
|
4263
|
-
function
|
|
4264
|
-
wasm.
|
|
5436
|
+
function wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___js_sys_4b0493a0be09c0f___Function_fn_wasm_bindgen_77cee878d4ea2fd9___JsValue_____wasm_bindgen_77cee878d4ea2fd9___sys__Undefined___js_sys_4b0493a0be09c0f___Function_fn_wasm_bindgen_77cee878d4ea2fd9___JsValue_____wasm_bindgen_77cee878d4ea2fd9___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
|
|
5437
|
+
wasm.wasm_bindgen_77cee878d4ea2fd9___convert__closures_____invoke___js_sys_4b0493a0be09c0f___Function_fn_wasm_bindgen_77cee878d4ea2fd9___JsValue_____wasm_bindgen_77cee878d4ea2fd9___sys__Undefined___js_sys_4b0493a0be09c0f___Function_fn_wasm_bindgen_77cee878d4ea2fd9___JsValue_____wasm_bindgen_77cee878d4ea2fd9___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
|
|
4265
5438
|
}
|
|
4266
5439
|
|
|
4267
5440
|
|
|
@@ -4287,12 +5460,18 @@ const AuthFlowKindFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
4287
5460
|
const AuthTokenFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4288
5461
|
? { register: () => {}, unregister: () => {} }
|
|
4289
5462
|
: new FinalizationRegistry(ptr => wasm.__wbg_authtoken_free(ptr >>> 0, 1));
|
|
5463
|
+
const BrowserSessionStoreFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5464
|
+
? { register: () => {}, unregister: () => {} }
|
|
5465
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_browsersessionstore_free(ptr >>> 0, 1));
|
|
4290
5466
|
const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4291
5467
|
? { register: () => {}, unregister: () => {} }
|
|
4292
5468
|
: new FinalizationRegistry(ptr => wasm.__wbg_client_free(ptr >>> 0, 1));
|
|
4293
5469
|
const CookieSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4294
5470
|
? { register: () => {}, unregister: () => {} }
|
|
4295
5471
|
: new FinalizationRegistry(ptr => wasm.__wbg_cookiesession_free(ptr >>> 0, 1));
|
|
5472
|
+
const DirectSignupDeepLinkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5473
|
+
? { register: () => {}, unregister: () => {} }
|
|
5474
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_directsignupdeeplink_free(ptr >>> 0, 1));
|
|
4296
5475
|
const EventFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4297
5476
|
? { register: () => {}, unregister: () => {} }
|
|
4298
5477
|
: new FinalizationRegistry(ptr => wasm.__wbg_event_free(ptr >>> 0, 1));
|
|
@@ -4368,6 +5547,9 @@ const SignupDeepLinkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
4368
5547
|
const SignupGrantDeepLinkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4369
5548
|
? { register: () => {}, unregister: () => {} }
|
|
4370
5549
|
: new FinalizationRegistry(ptr => wasm.__wbg_signupgrantdeeplink_free(ptr >>> 0, 1));
|
|
5550
|
+
const StoredSessionInfoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5551
|
+
? { register: () => {}, unregister: () => {} }
|
|
5552
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_storedsessioninfo_free(ptr >>> 0, 1));
|
|
4371
5553
|
|
|
4372
5554
|
function addToExternrefTable0(obj) {
|
|
4373
5555
|
const idx = wasm.__externref_table_alloc();
|