@interop/was-react 0.13.0 → 0.14.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 +19 -18
- package/dist/auth/loginFlow.js +3 -3
- package/dist/auth/walletRequestTypes.d.ts +30 -47
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/config.d.ts +9 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -0
- package/dist/config.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +15 -13
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +15 -16
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/identity/seedStore.d.ts.map +1 -1
- package/dist/identity/seedStore.js +4 -3
- package/dist/identity/seedStore.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/documentApp.d.ts +5 -5
- package/dist/react/documentApp.d.ts.map +1 -1
- package/dist/react/documentApp.js +14 -17
- package/dist/react/documentApp.js.map +1 -1
- package/dist/session/authStore.d.ts +7 -5
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +92 -57
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/adopt.d.ts +6 -5
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +22 -10
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/entityStore.d.ts +25 -6
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +16 -7
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +51 -61
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/sharedCollectionReader.d.ts +2 -2
- package/dist/storage/sharedCollectionReader.d.ts.map +1 -1
- package/dist/storage/sharedCollectionReader.js +21 -21
- package/dist/storage/sharedCollectionReader.js.map +1 -1
- package/dist/storage/storageManager.d.ts +30 -0
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +46 -0
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +6 -7
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +7 -11
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts +11 -3
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +21 -7
- package/dist/storage/wasSync.js.map +1 -1
- package/package.json +1 -2
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* {@link requireRemoteStore} inside their verbs rather than importing them
|
|
9
9
|
* directly, which keeps this module free of store imports (no cycle) and lets
|
|
10
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
|
+
* and {@link stampLww} is the one place a payload's last-write-wins fields are
|
|
15
|
+
* minted, so no caller has to remember to stamp.
|
|
11
16
|
*/
|
|
12
17
|
import { uuidv7 } from 'uuidv7';
|
|
13
18
|
import { DEFAULT_STORAGE_KEY_PREFIX } from '../config.js';
|
|
@@ -126,4 +131,45 @@ export function getWriterId({ storageKeyPrefix = DEFAULT_STORAGE_KEY_PREFIX } =
|
|
|
126
131
|
return fallbackWriterId;
|
|
127
132
|
}
|
|
128
133
|
}
|
|
134
|
+
let resolvedWriterId = null;
|
|
135
|
+
/**
|
|
136
|
+
* Installs the session's resolved writer id (called once by the session store,
|
|
137
|
+
* under the app's configured `storageKeyPrefix`, before any replica opens).
|
|
138
|
+
*
|
|
139
|
+
* @param id {string}
|
|
140
|
+
* @returns {void}
|
|
141
|
+
*/
|
|
142
|
+
export function setWriterId(id) {
|
|
143
|
+
resolvedWriterId = id;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The session's resolved writer id, or throws if it has not been installed
|
|
147
|
+
* yet. Deliberately never falls back to {@link getWriterId}: that would resolve
|
|
148
|
+
* under the DEFAULT key prefix, so an app with a custom `storageKeyPrefix`
|
|
149
|
+
* would silently stamp a second writer id.
|
|
150
|
+
*
|
|
151
|
+
* @returns {string}
|
|
152
|
+
*/
|
|
153
|
+
export function requireWriterId() {
|
|
154
|
+
if (!resolvedWriterId) {
|
|
155
|
+
throw new Error('Writer id is not resolved; create the session store first.');
|
|
156
|
+
}
|
|
157
|
+
return resolvedWriterId;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Stamps a payload with fresh last-write-wins fields: the current instant as
|
|
161
|
+
* `updatedAt` and the session's resolved writer id. Any values the caller
|
|
162
|
+
* supplied are overwritten -- a stamp must describe THIS write, or a hydrated
|
|
163
|
+
* doc's older `updatedAt` would ride a later edit and lose the conflict.
|
|
164
|
+
*
|
|
165
|
+
* @param payload {object}
|
|
166
|
+
* @returns {object} the payload with the LWW fields set
|
|
167
|
+
*/
|
|
168
|
+
export function stampLww(payload) {
|
|
169
|
+
return {
|
|
170
|
+
...payload,
|
|
171
|
+
updatedAt: new Date().toISOString(),
|
|
172
|
+
writerId: requireWriterId()
|
|
173
|
+
};
|
|
174
|
+
}
|
|
129
175
|
//# sourceMappingURL=storageManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageManager.js","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"storageManager.js","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AAKzD,IAAI,UAAU,GAAsB,IAAI,CAAA;AACxC,IAAI,WAAW,GAA0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C1C,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,MAAM,EAAE,CAAA;YAChD,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;YACrC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IAAC,MAAM,CAAC;QACP,gBAAgB,KAAK,MAAM,EAAE,CAAA;QAC7B,OAAO,gBAAgB,CAAA;IACzB,CAAC;AACH,CAAC;AAED,IAAI,gBAAgB,GAAkB,IAAI,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,gBAAgB,GAAG,EAAE,CAAA;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;IACH,CAAC;IACD,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAA2B,OAAU;IAC3D,OAAO;QACL,GAAG,OAAO;QACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,eAAe,EAAE;KAC5B,CAAA;AACH,CAAC"}
|
|
@@ -124,16 +124,15 @@ export declare class WasRemoteStore {
|
|
|
124
124
|
* no-op fallback for servers/wallets that did not provision the roster.
|
|
125
125
|
*
|
|
126
126
|
* @param collectionId {string} the WAS collection id
|
|
127
|
-
* @param
|
|
128
|
-
* collection description, to spend one authenticated GET rather than two:
|
|
129
|
-
* the read-before-PUT guard then turns on the descriptor handed in here
|
|
130
|
-
* instead of re-reading it. `undefined` means "read, and the collection
|
|
131
|
-
* carries no descriptor" -- not "unknown"
|
|
127
|
+
* @param options {object}
|
|
132
128
|
* @param options.encryption {CollectionEncryption | undefined} the
|
|
133
|
-
* already-read descriptor
|
|
129
|
+
* already-read descriptor the caller fetched from the collection
|
|
130
|
+
* description (the bootstrap reads it once and feeds both the cipher
|
|
131
|
+
* rebuild and this guard). `undefined` means "read, and the collection
|
|
132
|
+
* carries no descriptor" -- not "unknown"
|
|
134
133
|
* @returns {Promise<DeclarationResult>}
|
|
135
134
|
*/
|
|
136
|
-
markCollectionEncrypted(collectionId: string,
|
|
135
|
+
markCollectionEncrypted(collectionId: string, { encryption }: {
|
|
137
136
|
encryption: CollectionEncryption | undefined;
|
|
138
137
|
}): Promise<DeclarationResult>;
|
|
139
138
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasRemoteStore.d.ts","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAA;AAQlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACh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B,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAA;KAAE,GAC/D,OAAO,CAAC,iBAAiB,CAAC;IAa7B;;;;;;;;;;;;OAYG;IACG,wBAAwB,CAC5B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,iBAAiB,CAAC;IAe7B;;;;;;;;;;;;;;;;;;;OAmBG;IACG,yBAAyB,CAAC,EAC9B,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACP,EAAE;QACD,YAAY,EAAE,MAAM,CAAA;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiE9B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EACX,YAAY,EACZ,EAAE,EACH,EAAE;QACD,YAAY,EAAE,MAAM,CAAA;QACpB,EAAE,EAAE,MAAM,CAAA;KACX,GAAG,MAAM;CAuDX;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACZ,EAAE;IACD,WAAW,EAAE,cAAc,CAAA;CAC5B,GAAG,0BAA0B,CAM7B"}
|
|
@@ -102,23 +102,19 @@ export class WasRemoteStore {
|
|
|
102
102
|
* no-op fallback for servers/wallets that did not provision the roster.
|
|
103
103
|
*
|
|
104
104
|
* @param collectionId {string} the WAS collection id
|
|
105
|
-
* @param
|
|
106
|
-
* collection description, to spend one authenticated GET rather than two:
|
|
107
|
-
* the read-before-PUT guard then turns on the descriptor handed in here
|
|
108
|
-
* instead of re-reading it. `undefined` means "read, and the collection
|
|
109
|
-
* carries no descriptor" -- not "unknown"
|
|
105
|
+
* @param options {object}
|
|
110
106
|
* @param options.encryption {CollectionEncryption | undefined} the
|
|
111
|
-
* already-read descriptor
|
|
107
|
+
* already-read descriptor the caller fetched from the collection
|
|
108
|
+
* description (the bootstrap reads it once and feeds both the cipher
|
|
109
|
+
* rebuild and this guard). `undefined` means "read, and the collection
|
|
110
|
+
* carries no descriptor" -- not "unknown"
|
|
112
111
|
* @returns {Promise<DeclarationResult>}
|
|
113
112
|
*/
|
|
114
|
-
async markCollectionEncrypted(collectionId,
|
|
113
|
+
async markCollectionEncrypted(collectionId, { encryption }) {
|
|
115
114
|
if (this.#configById.get(collectionId)?.visibility === 'public') {
|
|
116
115
|
return { collectionId, ok: true, skipped: true };
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
? options.encryption
|
|
120
|
-
: await this.readCollectionEncryption(collectionId);
|
|
121
|
-
if (existing) {
|
|
117
|
+
if (encryption) {
|
|
122
118
|
return { collectionId, ok: true, skipped: true };
|
|
123
119
|
}
|
|
124
120
|
return this.#putDescription({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasRemoteStore.js","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,EACZ,KAAK,EACN,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA2C5D,MAAM,OAAO,cAAc;IACT,GAAG,CAAW;IACd,SAAS,CAAQ;IACjB,OAAO,CAAQ;IACtB,eAAe,CAAuB;IAC/C,sEAAsE;IACtE,4DAA4D;IACnD,WAAW,CAAgC;IAEpD,YAAoB,EAClB,GAAG,EACH,MAAM,EACN,UAAU,EAKX;QACC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,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AG,YAAY,CAAC,GAAG,CAAC,CAAA;YACjC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;QAC5D,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,WAAW,EAGZ;IACC,OAAO;QACL,KAAK,CAAC,oBAAoB,CAAC,EAAE,YAAY,EAA4B;YACnE,OAAO,MAAM,WAAW,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAA;QACjE,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -24,7 +24,7 @@ import type { RxChangeEvent } from 'rxdb/plugins/core';
|
|
|
24
24
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
25
25
|
import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
|
|
26
26
|
import { type SyncedDoc } from '../sync/index.js';
|
|
27
|
-
import type
|
|
27
|
+
import { type SharedCollectionConfig, type WasCollectionConfig } from '../config.js';
|
|
28
28
|
import type { ParsedGrants } from '../grants.js';
|
|
29
29
|
import { WasRemoteStore } from './wasRemoteStore.js';
|
|
30
30
|
import { SharedCollectionReader } from './sharedCollectionReader.js';
|
|
@@ -46,7 +46,8 @@ export interface WasSyncBootstrap {
|
|
|
46
46
|
* cipher). Used at login time, BEFORE any replication exists: the connected
|
|
47
47
|
* replica must open epoch-aware -- epoch-from-birth leaves no single-key
|
|
48
48
|
* fallback, and the adoption merge writes into it before sync starts. The
|
|
49
|
-
* sync bootstrap
|
|
49
|
+
* sync bootstrap reuses these reads (its `knownDescriptors` input) rather
|
|
50
|
+
* than re-issuing them.
|
|
50
51
|
*
|
|
51
52
|
* @param options {object}
|
|
52
53
|
* @param options.parsed {ParsedGrants}
|
|
@@ -85,9 +86,15 @@ export declare function readRemoteDescriptors({ parsed, zcapClient, collections
|
|
|
85
86
|
* @param [options.onDescriptorsFetched] {(descriptors) => void | Promise<void>} given
|
|
86
87
|
* the freshly fetched per-collection encryption descriptors (by WAS collection
|
|
87
88
|
* id), to refresh the offline descriptor cache
|
|
89
|
+
* @param [options.knownDescriptors] {Record<string, CollectionEncryption>}
|
|
90
|
+
* descriptors the caller ALREADY read live in this same bring-up (the
|
|
91
|
+
* login-time {@link readRemoteDescriptors} pass); the bootstrap reuses them
|
|
92
|
+
* instead of re-issuing the same GET seconds later. A hot restore passes
|
|
93
|
+
* none -- there the bootstrap read IS the freshness refresh over the
|
|
94
|
+
* offline cache
|
|
88
95
|
* @returns {Promise<WasSyncBootstrap>}
|
|
89
96
|
*/
|
|
90
|
-
export declare function startWasSync({ parsed, zcapClient, collections, localStore, syncController, onRemoteChange, sharedCollections, identityKeys, onAuthError, onDescriptorsFetched }: {
|
|
97
|
+
export declare function startWasSync({ parsed, zcapClient, collections, localStore, syncController, onRemoteChange, sharedCollections, identityKeys, onAuthError, onDescriptorsFetched, knownDescriptors }: {
|
|
91
98
|
parsed: ParsedGrants;
|
|
92
99
|
zcapClient: ZcapClient;
|
|
93
100
|
collections: WasCollectionConfig[];
|
|
@@ -101,5 +108,6 @@ export declare function startWasSync({ parsed, zcapClient, collections, localSto
|
|
|
101
108
|
};
|
|
102
109
|
onAuthError?: () => void;
|
|
103
110
|
onDescriptorsFetched?: (descriptors: Record<string, CollectionEncryption>) => void | Promise<void>;
|
|
111
|
+
knownDescriptors?: Record<string, CollectionEncryption>;
|
|
104
112
|
}): Promise<WasSyncBootstrap>;
|
|
105
113
|
//# sourceMappingURL=wasSync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasSync.d.ts","sourceRoot":"","sources":["../../src/storage/wasSync.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACt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E;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,mBAAmB,EAAE,CAAA;CACnC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAoBhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAsB,EACtB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,gBAAqB,EACtB,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,mBAAmB,EAAE,CAAA;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,CACd,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,KAC5B,IAAI,CAAA;IACT,iBAAiB,CAAC,EAAE,sBAAsB,EAAE,CAAA;IAC5C,YAAY,CAAC,EAAE;QACb,eAAe,EAAE,gBAAgB,CAAA;QACjC,WAAW,EAAE,YAAY,CAAA;KAC1B,CAAA;IACD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,oBAAoB,CAAC,EAAE,CACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,KAC9C,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CACxD,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA+H5B"}
|
package/dist/storage/wasSync.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { hasKeyEpochs } from '../sync/index.js';
|
|
2
|
+
import { isPublicCollection } from '../config.js';
|
|
2
3
|
import { WasRemoteStore, remoteDescriptorSource } from './wasRemoteStore.js';
|
|
3
4
|
import { SharedCollectionReader } from './sharedCollectionReader.js';
|
|
4
5
|
/**
|
|
@@ -8,7 +9,8 @@ import { SharedCollectionReader } from './sharedCollectionReader.js';
|
|
|
8
9
|
* cipher). Used at login time, BEFORE any replication exists: the connected
|
|
9
10
|
* replica must open epoch-aware -- epoch-from-birth leaves no single-key
|
|
10
11
|
* fallback, and the adoption merge writes into it before sync starts. The
|
|
11
|
-
* sync bootstrap
|
|
12
|
+
* sync bootstrap reuses these reads (its `knownDescriptors` input) rather
|
|
13
|
+
* than re-issuing them.
|
|
12
14
|
*
|
|
13
15
|
* @param options {object}
|
|
14
16
|
* @param options.parsed {ParsedGrants}
|
|
@@ -24,8 +26,9 @@ export async function readRemoteDescriptors({ parsed, zcapClient, collections })
|
|
|
24
26
|
collections
|
|
25
27
|
});
|
|
26
28
|
const descriptors = {};
|
|
27
|
-
await Promise.all(collections.map(async (
|
|
28
|
-
|
|
29
|
+
await Promise.all(collections.map(async (collection) => {
|
|
30
|
+
const { id } = collection;
|
|
31
|
+
if (isPublicCollection(collection) || !parsed.byCollectionId[id]) {
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
34
|
const encryption = await remoteStore.readCollectionEncryption(id);
|
|
@@ -60,9 +63,15 @@ export async function readRemoteDescriptors({ parsed, zcapClient, collections })
|
|
|
60
63
|
* @param [options.onDescriptorsFetched] {(descriptors) => void | Promise<void>} given
|
|
61
64
|
* the freshly fetched per-collection encryption descriptors (by WAS collection
|
|
62
65
|
* id), to refresh the offline descriptor cache
|
|
66
|
+
* @param [options.knownDescriptors] {Record<string, CollectionEncryption>}
|
|
67
|
+
* descriptors the caller ALREADY read live in this same bring-up (the
|
|
68
|
+
* login-time {@link readRemoteDescriptors} pass); the bootstrap reuses them
|
|
69
|
+
* instead of re-issuing the same GET seconds later. A hot restore passes
|
|
70
|
+
* none -- there the bootstrap read IS the freshness refresh over the
|
|
71
|
+
* offline cache
|
|
63
72
|
* @returns {Promise<WasSyncBootstrap>}
|
|
64
73
|
*/
|
|
65
|
-
export async function startWasSync({ parsed, zcapClient, collections, localStore, syncController, onRemoteChange, sharedCollections = [], identityKeys, onAuthError, onDescriptorsFetched }) {
|
|
74
|
+
export async function startWasSync({ parsed, zcapClient, collections, localStore, syncController, onRemoteChange, sharedCollections = [], identityKeys, onAuthError, onDescriptorsFetched, knownDescriptors = {} }) {
|
|
66
75
|
const remoteStore = WasRemoteStore.fromGrants({
|
|
67
76
|
parsed,
|
|
68
77
|
zcapClient,
|
|
@@ -93,9 +102,14 @@ export async function startWasSync({ parsed, zcapClient, collections, localStore
|
|
|
93
102
|
// pointless 403.
|
|
94
103
|
const granted = collections.filter(collection => parsed.byCollectionId[collection.id] !== undefined);
|
|
95
104
|
const descriptors = {};
|
|
96
|
-
await Promise.all(granted.map(async (
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
await Promise.all(granted.map(async (collection) => {
|
|
106
|
+
const { id: collectionId } = collection;
|
|
107
|
+
if (!isPublicCollection(collection)) {
|
|
108
|
+
// A descriptor the login flow read seconds ago is reused as-is; only
|
|
109
|
+
// ids it did not cover (or a hot restore, which passes none) are read
|
|
110
|
+
// live here.
|
|
111
|
+
const encryption = knownDescriptors[collectionId] ??
|
|
112
|
+
(await remoteStore.readCollectionEncryption(collectionId));
|
|
99
113
|
// Only an epoch-bearing descriptor enters the offline cache or
|
|
100
114
|
// rebuilds a cipher; a collection without a key-epoch roster stays
|
|
101
115
|
// fail-closed, stated plainly here rather than surfacing later as
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasSync.js","sourceRoot":"","sources":["../../src/storage/wasSync.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,YAAY,EAAkB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"wasSync.js","sourceRoot":"","sources":["../../src/storage/wasSync.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,YAAY,EAAkB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ACD,OAAM;QACR,CAAC;QACD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CACV,+BAA+B,EAAE,uCAAuC;gBACtE,8BAA8B,CACjC,CAAA;YACD,OAAM;QACR,CAAC;QACD,IAAI,CAAC;YACH,aAAa,CAAC,GAAG,CAAC,GAAG,MAAM,sBAAsB,CAAC,IAAI,CAAC;gBACrD,WAAW;gBACX,eAAe,EAAE,YAAY,CAAC,eAAe;gBAC7C,WAAW,EAAE,YAAY,CAAC,WAAW;gBACrC,YAAY,EAAE,EAAE;aACjB,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;QAC1D,CAAC;IACH,CAAC,CAAC,CACH,CAAA;IAED,MAAM,cAAc,CAAC,KAAK,CAAC;QACzB,WAAW;QACX,UAAU;QACV,cAAc;QACd,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC,CAAA;IACF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAA;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/was-react",
|
|
3
3
|
"description": "React library for building 'Bring Your Own Everything' (BYOE) apps on Wallet Attached Storage: DID Auth login via CHAPI wallet, local-first encrypted storage, and background sync to a WAS server.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"@emotion/react": "^11.14.0",
|
|
85
85
|
"@emotion/styled": "^11.14.1",
|
|
86
86
|
"@eslint/js": "^10.0.1",
|
|
87
|
-
"@interop/x25519-key-agreement-key": "^5.2.1",
|
|
88
87
|
"@mui/icons-material": "^9.0.0",
|
|
89
88
|
"@mui/material": "^9.0.0",
|
|
90
89
|
"@playwright/test": "^1.60.0",
|