@interop/was-react 0.19.0 → 0.20.1
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 +4 -3
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +10 -5
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/identity/agents.d.ts +5 -0
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +10 -3
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +5 -1
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +15 -28
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +3 -2
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +8 -4
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +9 -0
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +113 -47
- package/dist/session/authStore.js.map +1 -1
- package/dist/session/localWipe.d.ts +1 -1
- package/dist/session/localWipe.js +2 -2
- package/dist/session/localWipe.js.map +1 -1
- package/dist/storage/adopt.d.ts +4 -1
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +4 -3
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/descriptorManager.d.ts +1 -0
- package/dist/storage/descriptorManager.d.ts.map +1 -1
- package/dist/storage/descriptorManager.js +39 -21
- package/dist/storage/descriptorManager.js.map +1 -1
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +3 -0
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/publicUrl.js +3 -3
- package/dist/storage/storageContext.d.ts +178 -0
- package/dist/storage/storageContext.d.ts.map +1 -0
- package/dist/storage/storageContext.js +331 -0
- package/dist/storage/storageContext.js.map +1 -0
- package/dist/storage/storageManager.d.ts +61 -76
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +59 -150
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/syncController.d.ts +10 -1
- package/dist/storage/syncController.d.ts.map +1 -1
- package/dist/storage/syncController.js +12 -4
- package/dist/storage/syncController.js.map +1 -1
- package/dist/storage/syncStatusStore.d.ts +23 -2
- package/dist/storage/syncStatusStore.d.ts.map +1 -1
- package/dist/storage/syncStatusStore.js +22 -13
- package/dist/storage/syncStatusStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +24 -10
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +91 -36
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts +24 -9
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +52 -21
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/storage/writerId.d.ts +36 -0
- package/dist/storage/writerId.d.ts.map +1 -0
- package/dist/storage/writerId.js +76 -0
- package/dist/storage/writerId.js.map +1 -0
- package/package.json +9 -9
- package/dist/storage/rehydrate.d.ts +0 -64
- package/dist/storage/rehydrate.d.ts.map +0 -1
- package/dist/storage/rehydrate.js +0 -132
- package/dist/storage/rehydrate.js.map +0 -1
|
@@ -1,200 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The storage manager: a thin process-wide holder for the one {@link LocalStore}
|
|
6
|
-
* instance, the per-session {@link WasRemoteStore}, plus the per-install writer
|
|
7
|
-
* id. Entity stores reach for the stores through {@link requireStore} /
|
|
8
|
-
* {@link requireRemoteStore} inside their verbs rather than importing them
|
|
9
|
-
* directly, which keeps this module free of store imports (no cycle) and lets
|
|
10
|
-
* the app own the init/hydrate ordering.
|
|
11
|
-
*
|
|
12
|
-
* It also owns the writer-id concern end to end: {@link getWriterId} resolves
|
|
13
|
-
* the per-install id, {@link setWriterId} installs the session's resolved value,
|
|
14
|
-
* {@link clearWriterId} removes it (the clear-data wipe), and {@link stampLww}
|
|
15
|
-
* is the one place a payload's last-write-wins fields are minted, so no caller
|
|
16
|
-
* has to remember to stamp.
|
|
17
|
-
*/
|
|
18
|
-
import { uuidv7 } from 'uuidv7';
|
|
19
|
-
import { DEFAULT_STORAGE_KEY_PREFIX } from '../config.js';
|
|
20
|
-
let localStore = null;
|
|
21
|
-
let remoteStore = null;
|
|
1
|
+
let active = null;
|
|
22
2
|
/**
|
|
23
|
-
*
|
|
3
|
+
* Makes `context` the active one (called by the session store at creation, so
|
|
4
|
+
* the facades resolve before any replica opens, again right before it opens a
|
|
5
|
+
* replica, and by {@link StorageContext.attachStore}). Idempotent for the
|
|
6
|
+
* context already active; throws while a DIFFERENT context still has a replica
|
|
7
|
+
* attached.
|
|
24
8
|
*
|
|
25
|
-
* @param
|
|
9
|
+
* @param context {StorageContext}
|
|
26
10
|
* @returns {void}
|
|
27
11
|
*/
|
|
28
|
-
export function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* The opened store, or throws if the app has not bootstrapped yet.
|
|
33
|
-
*
|
|
34
|
-
* @returns {LocalStore}
|
|
35
|
-
*/
|
|
36
|
-
export function requireStore() {
|
|
37
|
-
if (!localStore) {
|
|
38
|
-
throw new Error('LocalStore is not initialized; open it first.');
|
|
12
|
+
export function activateStorageContext(context) {
|
|
13
|
+
if (active && active !== context && active.hasStore()) {
|
|
14
|
+
throw new Error('Another storage context still has a replica attached; ' +
|
|
15
|
+
'one process hosts one live session (one provider) at a time.');
|
|
39
16
|
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Whether the store has been opened.
|
|
44
|
-
*
|
|
45
|
-
* @returns {boolean}
|
|
46
|
-
*/
|
|
47
|
-
export function hasStore() {
|
|
48
|
-
return localStore !== null;
|
|
17
|
+
active = context;
|
|
49
18
|
}
|
|
50
19
|
/**
|
|
51
|
-
* Releases the
|
|
20
|
+
* Releases the active pointer if `context` holds it (called by
|
|
21
|
+
* `StorageContext.detachStore`, so every path that detaches a replica --
|
|
22
|
+
* `destroy`, logout, clear-data, the connected activation's fallback to
|
|
23
|
+
* `local` -- releases it and re-claims on re-attach); a no-op for any other
|
|
24
|
+
* context. Until the next claim the facades throw rather than resolve a
|
|
25
|
+
* retired session.
|
|
52
26
|
*
|
|
27
|
+
* @param context {StorageContext}
|
|
53
28
|
* @returns {void}
|
|
54
29
|
*/
|
|
55
|
-
export function
|
|
56
|
-
|
|
30
|
+
export function deactivateStorageContext(context) {
|
|
31
|
+
if (active === context) {
|
|
32
|
+
active = null;
|
|
33
|
+
}
|
|
57
34
|
}
|
|
58
35
|
/**
|
|
59
|
-
*
|
|
60
|
-
* has bootstrapped it from the granted zcaps).
|
|
36
|
+
* Whether a storage context is active.
|
|
61
37
|
*
|
|
62
|
-
* @
|
|
63
|
-
* @returns {void}
|
|
38
|
+
* @returns {boolean}
|
|
64
39
|
*/
|
|
65
|
-
export function
|
|
66
|
-
|
|
40
|
+
export function hasStorageContext() {
|
|
41
|
+
return active !== null;
|
|
67
42
|
}
|
|
68
43
|
/**
|
|
69
|
-
* The
|
|
70
|
-
* session is active (local-only mode, or sync has not bootstrapped yet).
|
|
44
|
+
* The active storage context, or throws if no session store has been created.
|
|
71
45
|
*
|
|
72
|
-
* @returns {
|
|
46
|
+
* @returns {StorageContext}
|
|
73
47
|
*/
|
|
74
|
-
export function
|
|
75
|
-
if (!
|
|
76
|
-
throw new Error('No
|
|
48
|
+
export function requireStorageContext() {
|
|
49
|
+
if (!active) {
|
|
50
|
+
throw new Error('No storage context is active; create the session store first.');
|
|
77
51
|
}
|
|
78
|
-
return
|
|
52
|
+
return active;
|
|
79
53
|
}
|
|
80
54
|
/**
|
|
81
|
-
*
|
|
55
|
+
* The active session's opened replica, or throws if none is open.
|
|
82
56
|
*
|
|
83
|
-
* @returns {
|
|
57
|
+
* @returns {LocalStore}
|
|
84
58
|
*/
|
|
85
|
-
export function
|
|
86
|
-
return
|
|
59
|
+
export function requireStore() {
|
|
60
|
+
return requireStorageContext().requireStore();
|
|
87
61
|
}
|
|
88
62
|
/**
|
|
89
|
-
*
|
|
63
|
+
* Whether the active session has a replica open.
|
|
90
64
|
*
|
|
91
|
-
* @returns {
|
|
65
|
+
* @returns {boolean}
|
|
92
66
|
*/
|
|
93
|
-
export function
|
|
94
|
-
|
|
67
|
+
export function hasStore() {
|
|
68
|
+
return active?.hasStore() ?? false;
|
|
95
69
|
}
|
|
96
70
|
/**
|
|
97
|
-
* The
|
|
98
|
-
*
|
|
99
|
-
* fresh on the next run.
|
|
100
|
-
*/
|
|
101
|
-
let fallbackWriterId = null;
|
|
102
|
-
/**
|
|
103
|
-
* A stable per-install writer id (the last-write-wins tiebreak stamped into
|
|
104
|
-
* every payload), persisted in localStorage under `<prefix>writerId`. In an
|
|
105
|
-
* environment without `localStorage` it falls back to a process-stable
|
|
106
|
-
* unpersisted id instead of throwing.
|
|
71
|
+
* The active session's remote store, or throws while no wallet-connected
|
|
72
|
+
* session is active.
|
|
107
73
|
*
|
|
108
|
-
*
|
|
109
|
-
* miss it adopts a value left under the pre-rename `<prefix>clientId` key and
|
|
110
|
-
* removes the old one, so an existing install keeps stamping the same id
|
|
111
|
-
* across the rename rather than looking like a second writer.
|
|
112
|
-
*
|
|
113
|
-
* @param [options] {object}
|
|
114
|
-
* @param [options.storageKeyPrefix] {string} the localStorage key prefix
|
|
115
|
-
* (defaults to {@link DEFAULT_STORAGE_KEY_PREFIX})
|
|
116
|
-
* @returns {string}
|
|
74
|
+
* @returns {WasRemoteStore}
|
|
117
75
|
*/
|
|
118
|
-
export function
|
|
119
|
-
|
|
120
|
-
const legacyKey = `${storageKeyPrefix}clientId`;
|
|
121
|
-
try {
|
|
122
|
-
let id = localStorage.getItem(writerIdKey);
|
|
123
|
-
if (!id) {
|
|
124
|
-
id = localStorage.getItem(legacyKey) || uuidv7();
|
|
125
|
-
localStorage.setItem(writerIdKey, id);
|
|
126
|
-
localStorage.removeItem(legacyKey);
|
|
127
|
-
}
|
|
128
|
-
return id;
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
fallbackWriterId ??= uuidv7();
|
|
132
|
-
return fallbackWriterId;
|
|
133
|
-
}
|
|
76
|
+
export function requireRemoteStore() {
|
|
77
|
+
return requireStorageContext().requireRemoteStore();
|
|
134
78
|
}
|
|
135
|
-
let resolvedWriterId = null;
|
|
136
79
|
/**
|
|
137
|
-
*
|
|
138
|
-
* under the app's configured `storageKeyPrefix`, before any replica opens).
|
|
80
|
+
* Whether the active session has a remote store available.
|
|
139
81
|
*
|
|
140
|
-
* @
|
|
141
|
-
* @returns {void}
|
|
82
|
+
* @returns {boolean}
|
|
142
83
|
*/
|
|
143
|
-
export function
|
|
144
|
-
|
|
84
|
+
export function hasRemoteStore() {
|
|
85
|
+
return active?.hasRemoteStore() ?? false;
|
|
145
86
|
}
|
|
146
87
|
/**
|
|
147
|
-
* The session's
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
88
|
+
* The active session's writer id, or throws if no session store exists yet.
|
|
89
|
+
* Deliberately never falls back to `getWriterId`: that would resolve under the
|
|
90
|
+
* DEFAULT key prefix, so an app with a custom `storageKeyPrefix` would silently
|
|
91
|
+
* stamp a second writer id.
|
|
151
92
|
*
|
|
152
93
|
* @returns {string}
|
|
153
94
|
*/
|
|
154
95
|
export function requireWriterId() {
|
|
155
|
-
|
|
156
|
-
throw new Error('Writer id is not resolved; create the session store first.');
|
|
157
|
-
}
|
|
158
|
-
return resolvedWriterId;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Clears the persisted writer id (the clear-data grade of the wipe): removes
|
|
162
|
-
* both the current key and the pre-rename one, so nothing this library wrote
|
|
163
|
-
* survives in localStorage. A fresh id is installed in memory rather than the
|
|
164
|
-
* resolved one being dropped, because the session keeps running over its new
|
|
165
|
-
* anonymous replica and its write verbs still have to stamp; nothing persists
|
|
166
|
-
* it, so the next run resolves and stores an id of its own.
|
|
167
|
-
*
|
|
168
|
-
* @param [options] {object}
|
|
169
|
-
* @param [options.storageKeyPrefix] {string} the localStorage key prefix
|
|
170
|
-
* (defaults to {@link DEFAULT_STORAGE_KEY_PREFIX})
|
|
171
|
-
* @returns {void}
|
|
172
|
-
*/
|
|
173
|
-
export function clearWriterId({ storageKeyPrefix = DEFAULT_STORAGE_KEY_PREFIX } = {}) {
|
|
174
|
-
try {
|
|
175
|
-
localStorage.removeItem(`${storageKeyPrefix}writerId`);
|
|
176
|
-
localStorage.removeItem(`${storageKeyPrefix}clientId`);
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
// No localStorage in this environment: nothing was persisted to clear.
|
|
180
|
-
}
|
|
181
|
-
fallbackWriterId = null;
|
|
182
|
-
setWriterId(uuidv7());
|
|
96
|
+
return requireStorageContext().writerId;
|
|
183
97
|
}
|
|
184
98
|
/**
|
|
185
|
-
* Stamps a payload with fresh last-write-wins fields
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* doc's older `updatedAt` would ride a later edit and lose the conflict.
|
|
99
|
+
* Stamps a payload with fresh last-write-wins fields under the active session
|
|
100
|
+
* (see {@link StorageContext.stampLww}); the entity-store write verbs call it
|
|
101
|
+
* on every write, and an app writing through `LocalStore` directly does too.
|
|
189
102
|
*
|
|
190
103
|
* @param payload {object}
|
|
191
104
|
* @returns {object} the payload with the LWW fields set
|
|
192
105
|
*/
|
|
193
106
|
export function stampLww(payload) {
|
|
194
|
-
return
|
|
195
|
-
...payload,
|
|
196
|
-
updatedAt: new Date().toISOString(),
|
|
197
|
-
writerId: requireWriterId()
|
|
198
|
-
};
|
|
107
|
+
return requireStorageContext().stampLww(payload);
|
|
199
108
|
}
|
|
200
109
|
//# sourceMappingURL=storageManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageManager.js","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storageManager.js","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAyBA,IAAI,MAAM,GAA0B,IAAI,CAAA;AAExC;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAuB;IAC5D,IAAI,MAAM,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,wDAAwD;YACtD,8DAA8D,CACjE,CAAA;IACH,CAAC;IACD,MAAM,GAAG,OAAO,CAAA;AAClB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAuB;IAC9D,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,MAAM,GAAG,IAAI,CAAA;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,KAAK,IAAI,CAAA;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,qBAAqB,EAAE,CAAC,YAAY,EAAE,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,MAAM,EAAE,QAAQ,EAAE,IAAI,KAAK,CAAA;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,qBAAqB,EAAE,CAAC,kBAAkB,EAAE,CAAA;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,EAAE,cAAc,EAAE,IAAI,KAAK,CAAA;AAC1C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,qBAAqB,EAAE,CAAC,QAAQ,CAAA;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAA2B,OAAU;IAC3D,OAAO,qBAAqB,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { type SyncedDoc } from '../sync/index.js';
|
|
|
3
3
|
import { type WasCollectionConfig, type WasSyncConfig } from '../config.js';
|
|
4
4
|
import type { LocalStore } from './localStore.js';
|
|
5
5
|
import type { WasRemoteStore } from './wasRemoteStore.js';
|
|
6
|
+
import type { SyncStatusStore } from './syncStatusStore.js';
|
|
6
7
|
/**
|
|
7
8
|
* Whether a replication error signals expired/revoked storage access. Every WAS
|
|
8
9
|
* request the replication makes funnels through the sync port, which maps a
|
|
@@ -24,8 +25,16 @@ export declare function isAuthError(err: unknown): boolean;
|
|
|
24
25
|
*/
|
|
25
26
|
export declare class SyncController {
|
|
26
27
|
#private;
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @param options {object}
|
|
30
|
+
* @param options.collections {WasCollectionConfig[]}
|
|
31
|
+
* @param options.syncStatus {SyncStatusStore} the session's per-collection
|
|
32
|
+
* status store this controller reports into
|
|
33
|
+
* @param [options.sync] {WasSyncConfig}
|
|
34
|
+
*/
|
|
35
|
+
constructor({ collections, syncStatus, sync }: {
|
|
28
36
|
collections: WasCollectionConfig[];
|
|
37
|
+
syncStatus: SyncStatusStore;
|
|
29
38
|
sync?: WasSyncConfig;
|
|
30
39
|
});
|
|
31
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncController.d.ts","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAML,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"syncController.d.ts","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAML,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAO3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CA+BjD;AAED;;GAEG;AACH,qBAAa,cAAc;;IAazB;;;;;;OAMG;gBACS,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACL,EAAE;QACD,WAAW,EAAE,mBAAmB,EAAE,CAAA;QAClC,UAAU,EAAE,eAAe,CAAA;QAC3B,IAAI,CAAC,EAAE,aAAa,CAAA;KACrB;IAMD;;;;;;;;;;;;;OAaG;IACG,KAAK,CAAC,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACZ,EAAE;QACD,WAAW,EAAE,cAAc,CAAA;QAC3B,UAAU,EAAE,UAAU,CAAA;QACtB,cAAc,CAAC,EAAE,CACf,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,KAC5B,IAAI,CAAA;QACT,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgIjB;;;;;OAKG;IACH,MAAM,IAAI,IAAI;IAMd;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createWasReplication, createWasSyncPort, withFeedMasterRead, WasSyncAuthError } from '../sync/index.js';
|
|
2
2
|
import { DEFAULT_SYNC_POLL_MS } from '../config.js';
|
|
3
|
-
import { useSyncStatusStore } from './syncStatusStore.js';
|
|
4
3
|
/**
|
|
5
4
|
* Whether a replication error signals expired/revoked storage access. Every WAS
|
|
6
5
|
* request the replication makes funnels through the sync port, which maps a
|
|
@@ -48,13 +47,22 @@ export function isAuthError(err) {
|
|
|
48
47
|
export class SyncController {
|
|
49
48
|
#collections;
|
|
50
49
|
#sync;
|
|
50
|
+
#syncStatus;
|
|
51
51
|
#replications = [];
|
|
52
52
|
#onlineHandler;
|
|
53
53
|
#pollTimer;
|
|
54
54
|
#started = false;
|
|
55
55
|
#stopped = false;
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* @param options {object}
|
|
58
|
+
* @param options.collections {WasCollectionConfig[]}
|
|
59
|
+
* @param options.syncStatus {SyncStatusStore} the session's per-collection
|
|
60
|
+
* status store this controller reports into
|
|
61
|
+
* @param [options.sync] {WasSyncConfig}
|
|
62
|
+
*/
|
|
63
|
+
constructor({ collections, syncStatus, sync }) {
|
|
57
64
|
this.#collections = collections;
|
|
65
|
+
this.#syncStatus = syncStatus;
|
|
58
66
|
this.#sync = sync ?? {};
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
@@ -79,7 +87,7 @@ export class SyncController {
|
|
|
79
87
|
return;
|
|
80
88
|
}
|
|
81
89
|
this.#started = true;
|
|
82
|
-
const setStatus =
|
|
90
|
+
const setStatus = this.#syncStatus.getState().setStatus;
|
|
83
91
|
const batchSize = this.#sync.batchSize;
|
|
84
92
|
const retryMs = this.#sync.retryMs;
|
|
85
93
|
const pollMs = this.#sync.pollMs ?? DEFAULT_SYNC_POLL_MS;
|
|
@@ -211,7 +219,7 @@ export class SyncController {
|
|
|
211
219
|
// bootstrap) sees the controller as terminally stopped and bails.
|
|
212
220
|
this.#stopped = true;
|
|
213
221
|
await this.#teardownReplications();
|
|
214
|
-
|
|
222
|
+
this.#syncStatus.getState().reset();
|
|
215
223
|
this.#started = false;
|
|
216
224
|
}
|
|
217
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncController.js","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AAgCA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EAGrB,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"syncController.js","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AAgCA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EAGrB,MAAM,cAAc,CAAA;AAUrB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAW,CAAA;IAC/B,MAAM,KAAK,GAAc,CAAC,GAAG,CAAC,CAAA;IAC9B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC7B,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC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AC;gBACzC,YAAY,CAAC,WAAW,EAAE,CAAA;YAC5B,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,MAAM,EAAE,CAAA;YACtB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACJ,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC3C,KAAK,CAAC,MAAM,EAAE,CAAA;QAChB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI;QACR,qEAAqE;QACrE,kEAAkE;QAClE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAA;QACnC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;IACvB,CAAC;CACF"}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The per-collection replication status store, mirroring the WAS per-replica
|
|
6
|
+
* sync-status vocabulary, keyed by the registry's logical collection key. One
|
|
7
|
+
* is created per {@link StorageContext} (so per session provider, never
|
|
8
|
+
* process-wide): the sync controller writes to it off the RxDB replication
|
|
9
|
+
* `active$` / `error$` streams, and `useSyncStatus` reads it through the
|
|
10
|
+
* provider. In-memory only, like the session -- reset on logout.
|
|
11
|
+
*/
|
|
12
|
+
import { type StoreApi } from 'zustand/vanilla';
|
|
1
13
|
/**
|
|
2
14
|
* A single collection's replication status:
|
|
3
15
|
* - `idle` -- configured but no cycle has run yet
|
|
@@ -6,7 +18,7 @@
|
|
|
6
18
|
* - `error` -- last cycle failed (RxDB is backing off / will retry)
|
|
7
19
|
*/
|
|
8
20
|
export type SyncStatus = 'idle' | 'syncing' | 'synced' | 'error';
|
|
9
|
-
|
|
21
|
+
interface SyncStatusState {
|
|
10
22
|
/**
|
|
11
23
|
* Keyed by the registry's LOGICAL collection key (`WasCollectionConfig.key`,
|
|
12
24
|
* e.g. `actionItems`), not the WAS wire id. Two registry entries may share one
|
|
@@ -17,7 +29,15 @@ export declare const useSyncStatusStore: import("zustand").UseBoundStore<import(
|
|
|
17
29
|
statuses: Record<string, SyncStatus>;
|
|
18
30
|
setStatus: (collectionKey: string, status: SyncStatus) => void;
|
|
19
31
|
reset: () => void;
|
|
20
|
-
}
|
|
32
|
+
}
|
|
33
|
+
export type SyncStatusStore = StoreApi<SyncStatusState>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates one session's sync status store (a vanilla zustand store; subscribe
|
|
36
|
+
* to it from React with zustand's `useStore`).
|
|
37
|
+
*
|
|
38
|
+
* @returns {SyncStatusStore}
|
|
39
|
+
*/
|
|
40
|
+
export declare function createSyncStatusStore(): SyncStatusStore;
|
|
21
41
|
/**
|
|
22
42
|
* The aggregate replication status derived from the per-collection statuses:
|
|
23
43
|
* `offline` when no replication is running (local-only), otherwise rolled up as
|
|
@@ -41,4 +61,5 @@ export declare function deriveSyncRollup(statuses: SyncStatus[]): {
|
|
|
41
61
|
label: string;
|
|
42
62
|
title: string;
|
|
43
63
|
};
|
|
64
|
+
export {};
|
|
44
65
|
//# sourceMappingURL=syncStatusStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncStatusStore.d.ts","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"syncStatusStore.d.ts","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEhE,UAAU,eAAe;IACvB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACpC,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;IAC9D,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAA;AAEvD;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CASvD;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEnE;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG;IACxD,KAAK,EAAE,UAAU,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CA2BA"}
|
|
@@ -2,20 +2,29 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The per-collection replication status store, mirroring the WAS per-replica
|
|
6
|
+
* sync-status vocabulary, keyed by the registry's logical collection key. One
|
|
7
|
+
* is created per {@link StorageContext} (so per session provider, never
|
|
8
|
+
* process-wide): the sync controller writes to it off the RxDB replication
|
|
9
|
+
* `active$` / `error$` streams, and `useSyncStatus` reads it through the
|
|
10
|
+
* provider. In-memory only, like the session -- reset on logout.
|
|
10
11
|
*/
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
import { createStore } from 'zustand/vanilla';
|
|
13
|
+
/**
|
|
14
|
+
* Creates one session's sync status store (a vanilla zustand store; subscribe
|
|
15
|
+
* to it from React with zustand's `useStore`).
|
|
16
|
+
*
|
|
17
|
+
* @returns {SyncStatusStore}
|
|
18
|
+
*/
|
|
19
|
+
export function createSyncStatusStore() {
|
|
20
|
+
return createStore()(set => ({
|
|
21
|
+
statuses: {},
|
|
22
|
+
setStatus: (collectionKey, status) => set(state => ({
|
|
23
|
+
statuses: { ...state.statuses, [collectionKey]: status }
|
|
24
|
+
})),
|
|
25
|
+
reset: () => set({ statuses: {} })
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
19
28
|
/**
|
|
20
29
|
* Rolls the per-collection replication statuses up to a single aggregate plus
|
|
21
30
|
* its display copy. With no collections registered it reports `offline`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncStatusStore.js","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"syncStatusStore.js","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAiB,MAAM,iBAAiB,CAAA;AA0B5D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,WAAW,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5C,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CACnC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACZ,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE;SACzD,CAAC,CAAC;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;KACnC,CAAC,CAAC,CAAA;AACL,CAAC;AASD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAsB;IAKrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,mDAAmD;SAC3D,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,OAAO;YACL,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,+DAA+D;SACvE,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,sDAAsD;SAC9D,CAAA;IACH,CAAC;IACD,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,oDAAoD;KAC5D,CAAA;AACH,CAAC"}
|
|
@@ -120,10 +120,16 @@ export declare class WasRemoteStore {
|
|
|
120
120
|
* Reads one collection's `encryption` descriptor from its Collection Description,
|
|
121
121
|
* invoked with that collection's delegated zcap. Returns the
|
|
122
122
|
* {@link CollectionEncryption} block (a multi-recipient descriptor carries key
|
|
123
|
-
* epochs) or `undefined` when the
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
123
|
+
* epochs), or `undefined` only when the answer is genuinely "no descriptor":
|
|
124
|
+
* no capability covers the collection, the collection is not found (which is
|
|
125
|
+
* also how WAS answers an unauthorized read), or the description carries no
|
|
126
|
+
* `encryption` member.
|
|
127
|
+
*
|
|
128
|
+
* Any other failure (a dropped connection, a 5xx) is thrown, wrapped with
|
|
129
|
+
* the collection id. It must NOT read as "no descriptor": a caller that takes
|
|
130
|
+
* it for one opens the collection under the fail-closed placeholder cipher,
|
|
131
|
+
* and a correctly provisioned collection then fails its first write or
|
|
132
|
+
* decrypt for a network hiccup.
|
|
127
133
|
*
|
|
128
134
|
* @param collectionId {string} the WAS collection id
|
|
129
135
|
* @returns {Promise<CollectionEncryption | undefined>}
|
|
@@ -138,9 +144,13 @@ export declare class WasRemoteStore {
|
|
|
138
144
|
* NOT `Collection.meta()`: that one DECODES `custom` to plaintext, which
|
|
139
145
|
* `applyMeta` cannot consume.
|
|
140
146
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
147
|
+
* Answers `undefined` for exactly the outcomes that mean "no metadata": no
|
|
148
|
+
* capability covers the collection, the read answered not-found (which is
|
|
149
|
+
* also how WAS answers an unauthorized read), or the backend has no metadata
|
|
150
|
+
* support (`501`). Any other failure is thrown, wrapped with the collection
|
|
151
|
+
* id, like {@link readCollectionEncryption}: a dropped connection is an
|
|
152
|
+
* unknown answer, not an absent one, and a caller that took it for "no
|
|
153
|
+
* schema" would skip the blinded-index install over a guess.
|
|
144
154
|
*
|
|
145
155
|
* @param collectionId {string} the WAS collection id
|
|
146
156
|
* @returns {Promise<{ custom?: unknown } | undefined>}
|
|
@@ -301,9 +311,13 @@ export declare class WasRemoteStore {
|
|
|
301
311
|
* Deliberately NOT `wasDescriptorSource` from the same subpath: that one
|
|
302
312
|
* describes through the client's root capability, which a relying-party app
|
|
303
313
|
* never holds. Every read here must invoke the per-collection grant, which is
|
|
304
|
-
* exactly what {@link WasRemoteStore.readCollectionEncryption} does
|
|
305
|
-
*
|
|
306
|
-
*
|
|
314
|
+
* exactly what {@link WasRemoteStore.readCollectionEncryption} does.
|
|
315
|
+
*
|
|
316
|
+
* A read that fails for a transient reason is warned about and answered as
|
|
317
|
+
* `undefined` here: the refresh guard is already spent by the time the source
|
|
318
|
+
* is consulted, so the decrypt retry fails the same way it would under no
|
|
319
|
+
* refresh at all, and the caller sees the envelope's own unknown-epoch error
|
|
320
|
+
* rather than a network one.
|
|
307
321
|
*
|
|
308
322
|
* @param options {object}
|
|
309
323
|
* @param options.remoteStore {WasRemoteStore}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasRemoteStore.d.ts","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"wasRemoteStore.d.ts","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAGL,SAAS,EAEV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAA;AASlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,CAAC,EAAE,M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