@taladb/web 0.7.10 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/taladb_web.d.ts +7 -7
- package/pkg/taladb_web.js +16 -16
- package/pkg/taladb_web_bg.wasm +0 -0
- package/pkg/taladb_web_bg.wasm.d.ts +7 -7
- package/worker/taladb.worker.js +27 -2
package/package.json
CHANGED
package/pkg/package.json
CHANGED
package/pkg/taladb_web.d.ts
CHANGED
|
@@ -416,13 +416,13 @@ export interface InitOutput {
|
|
|
416
416
|
readonly idb_load_snapshot: (a: number, b: number) => any;
|
|
417
417
|
readonly idb_save_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
418
418
|
readonly opfs_open_backend: (a: number, b: number) => any;
|
|
419
|
-
readonly
|
|
420
|
-
readonly
|
|
421
|
-
readonly
|
|
422
|
-
readonly
|
|
423
|
-
readonly
|
|
424
|
-
readonly
|
|
425
|
-
readonly
|
|
419
|
+
readonly wasm_bindgen__closure__destroy__h019ad81c65a5ac2e: (a: number, b: number) => void;
|
|
420
|
+
readonly wasm_bindgen__closure__destroy__h53c506fd33a34156: (a: number, b: number) => void;
|
|
421
|
+
readonly wasm_bindgen__closure__destroy__h60a9a75571791338: (a: number, b: number) => void;
|
|
422
|
+
readonly wasm_bindgen__convert__closures_____invoke__hc8d470a46e185f12: (a: number, b: number, c: any) => [number, number];
|
|
423
|
+
readonly wasm_bindgen__convert__closures_____invoke__h19185396894e5dfb: (a: number, b: number, c: any, d: any) => void;
|
|
424
|
+
readonly wasm_bindgen__convert__closures_____invoke__h48d87b3a361fad65: (a: number, b: number, c: any) => void;
|
|
425
|
+
readonly wasm_bindgen__convert__closures_____invoke__h88d126a9c69f3dfa: (a: number, b: number) => void;
|
|
426
426
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
427
427
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
428
428
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/pkg/taladb_web.js
CHANGED
|
@@ -1453,7 +1453,7 @@ function __wbg_get_imports() {
|
|
|
1453
1453
|
const a = state0.a;
|
|
1454
1454
|
state0.a = 0;
|
|
1455
1455
|
try {
|
|
1456
|
-
return
|
|
1456
|
+
return wasm_bindgen__convert__closures_____invoke__h19185396894e5dfb(a, state0.b, arg0, arg1);
|
|
1457
1457
|
} finally {
|
|
1458
1458
|
state0.a = a;
|
|
1459
1459
|
}
|
|
@@ -1475,7 +1475,7 @@ function __wbg_get_imports() {
|
|
|
1475
1475
|
const a = state0.a;
|
|
1476
1476
|
state0.a = 0;
|
|
1477
1477
|
try {
|
|
1478
|
-
return
|
|
1478
|
+
return wasm_bindgen__convert__closures_____invoke__h19185396894e5dfb(a, state0.b, arg0, arg1);
|
|
1479
1479
|
} finally {
|
|
1480
1480
|
state0.a = a;
|
|
1481
1481
|
}
|
|
@@ -1636,18 +1636,18 @@ function __wbg_get_imports() {
|
|
|
1636
1636
|
return ret;
|
|
1637
1637
|
},
|
|
1638
1638
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1639
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1640
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1639
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 197, function: Function { arguments: [], shim_idx: 198, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1640
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h019ad81c65a5ac2e, wasm_bindgen__convert__closures_____invoke__h88d126a9c69f3dfa);
|
|
1641
1641
|
return ret;
|
|
1642
1642
|
},
|
|
1643
1643
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1644
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1645
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1644
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 633, function: Function { arguments: [Externref], shim_idx: 634, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1645
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h53c506fd33a34156, wasm_bindgen__convert__closures_____invoke__hc8d470a46e185f12);
|
|
1646
1646
|
return ret;
|
|
1647
1647
|
},
|
|
1648
1648
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1649
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1650
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1649
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 89, function: Function { arguments: [Externref], shim_idx: 90, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1650
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h60a9a75571791338, wasm_bindgen__convert__closures_____invoke__h48d87b3a361fad65);
|
|
1651
1651
|
return ret;
|
|
1652
1652
|
},
|
|
1653
1653
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -1693,23 +1693,23 @@ function __wbg_get_imports() {
|
|
|
1693
1693
|
};
|
|
1694
1694
|
}
|
|
1695
1695
|
|
|
1696
|
-
function
|
|
1697
|
-
wasm.
|
|
1696
|
+
function wasm_bindgen__convert__closures_____invoke__h88d126a9c69f3dfa(arg0, arg1) {
|
|
1697
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h88d126a9c69f3dfa(arg0, arg1);
|
|
1698
1698
|
}
|
|
1699
1699
|
|
|
1700
|
-
function
|
|
1701
|
-
wasm.
|
|
1700
|
+
function wasm_bindgen__convert__closures_____invoke__h48d87b3a361fad65(arg0, arg1, arg2) {
|
|
1701
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h48d87b3a361fad65(arg0, arg1, arg2);
|
|
1702
1702
|
}
|
|
1703
1703
|
|
|
1704
|
-
function
|
|
1705
|
-
const ret = wasm.
|
|
1704
|
+
function wasm_bindgen__convert__closures_____invoke__hc8d470a46e185f12(arg0, arg1, arg2) {
|
|
1705
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__hc8d470a46e185f12(arg0, arg1, arg2);
|
|
1706
1706
|
if (ret[1]) {
|
|
1707
1707
|
throw takeFromExternrefTable0(ret[0]);
|
|
1708
1708
|
}
|
|
1709
1709
|
}
|
|
1710
1710
|
|
|
1711
|
-
function
|
|
1712
|
-
wasm.
|
|
1711
|
+
function wasm_bindgen__convert__closures_____invoke__h19185396894e5dfb(arg0, arg1, arg2, arg3) {
|
|
1712
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h19185396894e5dfb(arg0, arg1, arg2, arg3);
|
|
1713
1713
|
}
|
|
1714
1714
|
|
|
1715
1715
|
|
package/pkg/taladb_web_bg.wasm
CHANGED
|
Binary file
|
|
@@ -60,13 +60,13 @@ export const opfs_load_snapshot: (a: number, b: number) => any;
|
|
|
60
60
|
export const idb_load_snapshot: (a: number, b: number) => any;
|
|
61
61
|
export const idb_save_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
62
62
|
export const opfs_open_backend: (a: number, b: number) => any;
|
|
63
|
-
export const
|
|
64
|
-
export const
|
|
65
|
-
export const
|
|
66
|
-
export const
|
|
67
|
-
export const
|
|
68
|
-
export const
|
|
69
|
-
export const
|
|
63
|
+
export const wasm_bindgen__closure__destroy__h019ad81c65a5ac2e: (a: number, b: number) => void;
|
|
64
|
+
export const wasm_bindgen__closure__destroy__h53c506fd33a34156: (a: number, b: number) => void;
|
|
65
|
+
export const wasm_bindgen__closure__destroy__h60a9a75571791338: (a: number, b: number) => void;
|
|
66
|
+
export const wasm_bindgen__convert__closures_____invoke__hc8d470a46e185f12: (a: number, b: number, c: any) => [number, number];
|
|
67
|
+
export const wasm_bindgen__convert__closures_____invoke__h19185396894e5dfb: (a: number, b: number, c: any, d: any) => void;
|
|
68
|
+
export const wasm_bindgen__convert__closures_____invoke__h48d87b3a361fad65: (a: number, b: number, c: any) => void;
|
|
69
|
+
export const wasm_bindgen__convert__closures_____invoke__h88d126a9c69f3dfa: (a: number, b: number) => void;
|
|
70
70
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
71
71
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
72
72
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/worker/taladb.worker.js
CHANGED
|
@@ -124,6 +124,22 @@ const isDev = typeof location !== 'undefined' && (location.hostname === 'localho
|
|
|
124
124
|
const log = isDev ? console.log.bind(console, '[TalaDB Worker]') : () => {};
|
|
125
125
|
const warn = isDev ? console.warn.bind(console, '[TalaDB Worker]') : () => {};
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Origin of the page that spawned this DedicatedWorker. Messages from any
|
|
129
|
+
* other origin are silently dropped. Null only in edge environments where
|
|
130
|
+
* `location` is unavailable, in which case the check is skipped.
|
|
131
|
+
*/
|
|
132
|
+
const WORKER_ORIGIN = typeof location !== 'undefined' ? location.origin : null;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Per-worker-instance random token. Included in every `taladb:secondary-write`
|
|
136
|
+
* BroadcastChannel message so the primary tab can reject unauthenticated
|
|
137
|
+
* injections that omit a token.
|
|
138
|
+
*/
|
|
139
|
+
const SESSION_TOKEN = (typeof self.crypto !== 'undefined' && typeof self.crypto.randomUUID === 'function')
|
|
140
|
+
? self.crypto.randomUUID()
|
|
141
|
+
: Array.from(self.crypto.getRandomValues(new Uint8Array(16)), b => b.toString(16).padStart(2, '0')).join('');
|
|
142
|
+
|
|
127
143
|
/**
|
|
128
144
|
* Resolving this releases the Web Lock and closes the sync handle.
|
|
129
145
|
* Set inside doInit; called by the 'close' op or when the worker terminates.
|
|
@@ -288,7 +304,7 @@ function pushChangesetToPrimary() {
|
|
|
288
304
|
const parsed = JSON.parse(changeset);
|
|
289
305
|
if (parsed.length === 0) return;
|
|
290
306
|
lastSecondaryPushMs = Date.now();
|
|
291
|
-
broadcastChannel.postMessage({ type: 'taladb:secondary-write', changeset });
|
|
307
|
+
broadcastChannel.postMessage({ type: 'taladb:secondary-write', token: SESSION_TOKEN, changeset });
|
|
292
308
|
log(`Broadcast ${parsed.length} change(s) to primary tab`);
|
|
293
309
|
} catch (err) {
|
|
294
310
|
warn('Failed to export changeset for primary tab:', err);
|
|
@@ -314,6 +330,12 @@ function onWriteCommitted() {
|
|
|
314
330
|
// ---------------------------------------------------------------------------
|
|
315
331
|
|
|
316
332
|
self.onmessage = async (e) => {
|
|
333
|
+
// Reject messages from unexpected origins. In a DedicatedWorker only the
|
|
334
|
+
// creating page can post messages (browser-enforced), but this guard is a
|
|
335
|
+
// defence-in-depth measure in case the worker is ever repurposed.
|
|
336
|
+
if (WORKER_ORIGIN && e.origin && e.origin !== WORKER_ORIGIN) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
317
339
|
const { id, op, ...args } = e.data;
|
|
318
340
|
try {
|
|
319
341
|
const result = await dispatch(op, args);
|
|
@@ -531,8 +553,11 @@ async function doInit(dbName, configJson) {
|
|
|
531
553
|
const resolve = pendingSnapshotResolve;
|
|
532
554
|
pendingSnapshotResolve = null;
|
|
533
555
|
resolve();
|
|
534
|
-
} else if (e.data?.type === 'taladb:secondary-write' && !idbFallback && db) {
|
|
556
|
+
} else if (e.data?.type === 'taladb:secondary-write' && typeof e.data.token === 'string' && e.data.token.length > 0 && !idbFallback && db) {
|
|
535
557
|
// Primary (OPFS) tab: a secondary tab made a write — merge it in via LWW.
|
|
558
|
+
// The token requirement rejects unauthenticated injection attempts that
|
|
559
|
+
// omit the SESSION_TOKEN field (not a guarantee against same-origin attackers
|
|
560
|
+
// who observe the token, but defence-in-depth against naive injection).
|
|
536
561
|
try {
|
|
537
562
|
const applied = db.importChangeset(e.data.changeset);
|
|
538
563
|
if (applied > 0) {
|