@interop/was-react 0.8.3 → 0.10.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 +50 -44
- package/dist/auth/chapi.d.ts.map +1 -1
- package/dist/auth/chapi.js +5 -4
- package/dist/auth/chapi.js.map +1 -1
- package/dist/auth/loginFlow.d.ts.map +1 -1
- package/dist/auth/loginFlow.js +48 -50
- package/dist/auth/loginFlow.js.map +1 -1
- package/dist/auth/loginRequest.d.ts +38 -5
- package/dist/auth/loginRequest.d.ts.map +1 -1
- package/dist/auth/loginRequest.js +66 -5
- package/dist/auth/loginRequest.js.map +1 -1
- package/dist/auth/verifyResponse.d.ts +7 -4
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +23 -13
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/auth/walletRequestTypes.d.ts +9 -90
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/config.d.ts +9 -9
- package/dist/config.js +0 -0
- package/dist/dev/provisionDevGrants.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.js +18 -19
- package/dist/dev/provisionDevGrants.js.map +1 -1
- package/dist/grants.d.ts +19 -9
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +17 -2
- package/dist/grants.js.map +1 -1
- package/dist/identity/agents.d.ts +1 -1
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +10 -25
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/appSession.d.ts +27 -0
- package/dist/identity/appSession.d.ts.map +1 -1
- package/dist/identity/appSession.js +51 -13
- package/dist/identity/appSession.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +7 -0
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +11 -14
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/identity/seedStore.d.ts +19 -0
- package/dist/identity/seedStore.d.ts.map +1 -1
- package/dist/identity/seedStore.js +40 -13
- package/dist/identity/seedStore.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/jsonLd.d.ts +19 -0
- package/dist/jsonLd.d.ts.map +1 -0
- package/dist/jsonLd.js +24 -0
- package/dist/jsonLd.js.map +1 -0
- package/dist/mui/AdoptDialog.d.ts.map +1 -1
- package/dist/mui/AdoptDialog.js +7 -3
- package/dist/mui/AdoptDialog.js.map +1 -1
- package/dist/mui/ClearDataDialog.d.ts.map +1 -1
- package/dist/mui/ClearDataDialog.js +12 -11
- package/dist/mui/ClearDataDialog.js.map +1 -1
- package/dist/mui/ConfirmDialog.d.ts +35 -0
- package/dist/mui/ConfirmDialog.d.ts.map +1 -0
- package/dist/mui/ConfirmDialog.js +18 -0
- package/dist/mui/ConfirmDialog.js.map +1 -0
- package/dist/mui/LogoutDialog.d.ts.map +1 -1
- package/dist/mui/LogoutDialog.js +7 -3
- package/dist/mui/LogoutDialog.js.map +1 -1
- package/dist/react/documentApp.d.ts +29 -0
- package/dist/react/documentApp.d.ts.map +1 -1
- package/dist/react/documentApp.js +9 -38
- package/dist/react/documentApp.js.map +1 -1
- package/dist/react/hooks.d.ts +13 -7
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +17 -11
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +9 -9
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +100 -96
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/adopt.d.ts +5 -1
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +8 -24
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +27 -20
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +12 -6
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +118 -74
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/sharedCollectionReader.d.ts +1 -1
- package/dist/storage/sharedCollectionReader.d.ts.map +1 -1
- package/dist/storage/sharedCollectionReader.js +79 -81
- package/dist/storage/sharedCollectionReader.js.map +1 -1
- package/dist/storage/storageManager.d.ts +3 -1
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +20 -6
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/syncController.d.ts +1 -16
- package/dist/storage/syncController.d.ts.map +1 -1
- package/dist/storage/syncController.js +38 -58
- package/dist/storage/syncController.js.map +1 -1
- package/dist/storage/syncStatusStore.d.ts +8 -6
- package/dist/storage/syncStatusStore.d.ts.map +1 -1
- package/dist/storage/syncStatusStore.js +6 -6
- package/dist/storage/syncStatusStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +34 -2
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +45 -7
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +47 -38
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/sync/changesQuery.d.ts.map +1 -1
- package/dist/sync/changesQuery.js +2 -12
- package/dist/sync/changesQuery.js.map +1 -1
- package/dist/sync/docCipher.d.ts +17 -9
- package/dist/sync/docCipher.d.ts.map +1 -1
- package/dist/sync/docCipher.js +17 -11
- package/dist/sync/docCipher.js.map +1 -1
- package/dist/sync/feedMasterPort.d.ts +6 -0
- package/dist/sync/feedMasterPort.d.ts.map +1 -1
- package/dist/sync/feedMasterPort.js +82 -40
- package/dist/sync/feedMasterPort.js.map +1 -1
- package/dist/sync/index.d.ts +6 -5
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +6 -3
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/lww.d.ts +15 -14
- package/dist/sync/lww.d.ts.map +1 -1
- package/dist/sync/lww.js +3 -3
- package/dist/sync/lww.js.map +1 -1
- package/dist/sync/lwwConflictHandler.d.ts +3 -10
- package/dist/sync/lwwConflictHandler.d.ts.map +1 -1
- package/dist/sync/lwwConflictHandler.js +7 -17
- package/dist/sync/lwwConflictHandler.js.map +1 -1
- package/dist/sync/pushWrites.d.ts +6 -8
- package/dist/sync/pushWrites.d.ts.map +1 -1
- package/dist/sync/pushWrites.js +56 -83
- package/dist/sync/pushWrites.js.map +1 -1
- package/dist/sync/types.d.ts +80 -4
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js +36 -18
- package/dist/sync/types.js.map +1 -1
- package/dist/sync/wasSyncPort.d.ts +0 -11
- package/dist/sync/wasSyncPort.d.ts.map +1 -1
- package/dist/sync/wasSyncPort.js +8 -33
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +5 -5
- package/dist/identity/initAppSession.d.ts +0 -27
- package/dist/identity/initAppSession.d.ts.map +0 -1
- package/dist/identity/initAppSession.js +0 -30
- package/dist/identity/initAppSession.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncStatusStore.js","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"syncStatusStore.js","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAWhC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,EAWpC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CACnC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE;KACzD,CAAC,CAAC;IACL,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;CACnC,CAAC,CAAC,CAAA;AASH;;;;;;;;;;;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"}
|
|
@@ -27,8 +27,9 @@ import type { ZcapClient } from '@interop/ezcap';
|
|
|
27
27
|
import type { IZcap } from '@interop/data-integrity-core';
|
|
28
28
|
import { WasClient } from '@interop/was-client';
|
|
29
29
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
30
|
+
import type { EncryptionDescriptorSource } from '@interop/wallet-core/descriptors';
|
|
30
31
|
import type { WasCollectionConfig } from '../config.js';
|
|
31
|
-
import type
|
|
32
|
+
import { type ParsedGrants } from '../grants.js';
|
|
32
33
|
/**
|
|
33
34
|
* The outcome of a best-effort encryption-descriptor PUT, for diagnostics.
|
|
34
35
|
*/
|
|
@@ -123,9 +124,18 @@ export declare class WasRemoteStore {
|
|
|
123
124
|
* no-op fallback for servers/wallets that did not provision the roster.
|
|
124
125
|
*
|
|
125
126
|
* @param collectionId {string} the WAS collection id
|
|
127
|
+
* @param [options] {object} supply this when the caller has ALREADY read the
|
|
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"
|
|
132
|
+
* @param options.encryption {CollectionEncryption | undefined} the
|
|
133
|
+
* already-read descriptor
|
|
126
134
|
* @returns {Promise<DeclarationResult>}
|
|
127
135
|
*/
|
|
128
|
-
markCollectionEncrypted(collectionId: string
|
|
136
|
+
markCollectionEncrypted(collectionId: string, options?: {
|
|
137
|
+
encryption: CollectionEncryption | undefined;
|
|
138
|
+
}): Promise<DeclarationResult>;
|
|
129
139
|
/**
|
|
130
140
|
* Best-effort declaration of a public collection's equality-indexed
|
|
131
141
|
* attributes (`{ indexes: [...] }`) on its collection description, invoked
|
|
@@ -189,4 +199,26 @@ export declare class WasRemoteStore {
|
|
|
189
199
|
id: string;
|
|
190
200
|
}): string;
|
|
191
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* The `EncryptionDescriptorSource` (`@interop/wallet-core/descriptors`) over a
|
|
204
|
+
* delegated {@link WasRemoteStore}: one Collection Description read per
|
|
205
|
+
* collection, invoked with THAT collection's delegated zcap. It is the seam the
|
|
206
|
+
* descriptor-refresh machinery -- the local store's unknown-epoch policy and a
|
|
207
|
+
* shared collection's self-refreshing cipher -- re-reads a rotated key-epoch
|
|
208
|
+
* roster through.
|
|
209
|
+
*
|
|
210
|
+
* Deliberately NOT `wasDescriptorSource` from the same subpath: that one
|
|
211
|
+
* describes through the client's root capability, which a relying-party app
|
|
212
|
+
* never holds. Every read here must invoke the per-collection grant, which is
|
|
213
|
+
* exactly what {@link WasRemoteStore.readCollectionEncryption} does (and, like
|
|
214
|
+
* the rest of the descriptor plumbing, it answers `undefined` rather than
|
|
215
|
+
* throwing when the read is unauthorized or the app is offline).
|
|
216
|
+
*
|
|
217
|
+
* @param options {object}
|
|
218
|
+
* @param options.remoteStore {WasRemoteStore}
|
|
219
|
+
* @returns {EncryptionDescriptorSource}
|
|
220
|
+
*/
|
|
221
|
+
export declare function remoteDescriptorSource({ remoteStore }: {
|
|
222
|
+
remoteStore: WasRemoteStore;
|
|
223
|
+
}): EncryptionDescriptorSource;
|
|
192
224
|
//# sourceMappingURL=wasRemoteStore.d.ts.map
|
|
@@ -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;
|
|
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,0BA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OAwBG;IACG,uBAAuB,CAC3B,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;QAAE,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAA;KAAE,GACzD,OAAO,CAAC,iBAAiB,CAAC;IAgB7B;;;;;;;;;;;;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;IAkE9B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EACX,YAAY,EACZ,EAAE,EACH,EAAE;QACD,YAAY,EAAE,MAAM,CAAA;QACpB,EAAE,EAAE,MAAM,CAAA;KACX,GAAG,MAAM;CAwDX;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACZ,EAAE;IACD,WAAW,EAAE,cAAc,CAAA;CAC5B,GAAG,0BAA0B,CAM7B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WasClient } from '@interop/was-client';
|
|
2
2
|
import { createEdvEncryption } from '@interop/was-client/edv';
|
|
3
3
|
import { errorStatus, errorMessage } from '../sync/index.js';
|
|
4
|
+
import { collectionPath } from '../grants.js';
|
|
4
5
|
export class WasRemoteStore {
|
|
5
6
|
was;
|
|
6
7
|
serverUrl;
|
|
@@ -75,7 +76,7 @@ export class WasRemoteStore {
|
|
|
75
76
|
try {
|
|
76
77
|
const response = await this.was.request({
|
|
77
78
|
capability,
|
|
78
|
-
path:
|
|
79
|
+
path: collectionPath({ spaceId: this.spaceId, collectionId }),
|
|
79
80
|
method: 'GET'
|
|
80
81
|
});
|
|
81
82
|
const description = response.data;
|
|
@@ -101,13 +102,22 @@ export class WasRemoteStore {
|
|
|
101
102
|
* no-op fallback for servers/wallets that did not provision the roster.
|
|
102
103
|
*
|
|
103
104
|
* @param collectionId {string} the WAS collection id
|
|
105
|
+
* @param [options] {object} supply this when the caller has ALREADY read the
|
|
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"
|
|
110
|
+
* @param options.encryption {CollectionEncryption | undefined} the
|
|
111
|
+
* already-read descriptor
|
|
104
112
|
* @returns {Promise<DeclarationResult>}
|
|
105
113
|
*/
|
|
106
|
-
async markCollectionEncrypted(collectionId) {
|
|
114
|
+
async markCollectionEncrypted(collectionId, options) {
|
|
107
115
|
if (this.#configById.get(collectionId)?.visibility === 'public') {
|
|
108
116
|
return { collectionId, ok: true, skipped: true };
|
|
109
117
|
}
|
|
110
|
-
const existing =
|
|
118
|
+
const existing = options
|
|
119
|
+
? options.encryption
|
|
120
|
+
: await this.readCollectionEncryption(collectionId);
|
|
111
121
|
if (existing) {
|
|
112
122
|
return { collectionId, ok: true, skipped: true };
|
|
113
123
|
}
|
|
@@ -199,7 +209,8 @@ export class WasRemoteStore {
|
|
|
199
209
|
// The list endpoint is the trailing-slash collection items URL.
|
|
200
210
|
const response = await this.was.request({
|
|
201
211
|
capability,
|
|
202
|
-
path:
|
|
212
|
+
path: `${collectionPath({ spaceId: this.spaceId, collectionId })}/` +
|
|
213
|
+
`?${params.join('&')}`,
|
|
203
214
|
method: 'GET'
|
|
204
215
|
});
|
|
205
216
|
const page = response.data;
|
|
@@ -246,8 +257,9 @@ export class WasRemoteStore {
|
|
|
246
257
|
if (!capability) {
|
|
247
258
|
throw new Error(`No delegated capability covers collection "${collectionId}".`);
|
|
248
259
|
}
|
|
249
|
-
return (
|
|
250
|
-
|
|
260
|
+
return (this.serverUrl +
|
|
261
|
+
collectionPath({ spaceId: this.spaceId, collectionId }) +
|
|
262
|
+
`/${encodeURIComponent(id)}`);
|
|
251
263
|
}
|
|
252
264
|
/**
|
|
253
265
|
* The shared best-effort collection-description PUT behind the encryption
|
|
@@ -262,7 +274,7 @@ export class WasRemoteStore {
|
|
|
262
274
|
try {
|
|
263
275
|
const response = await this.was.request({
|
|
264
276
|
capability,
|
|
265
|
-
path:
|
|
277
|
+
path: collectionPath({ spaceId: this.spaceId, collectionId }),
|
|
266
278
|
method: 'PUT',
|
|
267
279
|
json: description
|
|
268
280
|
});
|
|
@@ -275,4 +287,30 @@ export class WasRemoteStore {
|
|
|
275
287
|
}
|
|
276
288
|
}
|
|
277
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* The `EncryptionDescriptorSource` (`@interop/wallet-core/descriptors`) over a
|
|
292
|
+
* delegated {@link WasRemoteStore}: one Collection Description read per
|
|
293
|
+
* collection, invoked with THAT collection's delegated zcap. It is the seam the
|
|
294
|
+
* descriptor-refresh machinery -- the local store's unknown-epoch policy and a
|
|
295
|
+
* shared collection's self-refreshing cipher -- re-reads a rotated key-epoch
|
|
296
|
+
* roster through.
|
|
297
|
+
*
|
|
298
|
+
* Deliberately NOT `wasDescriptorSource` from the same subpath: that one
|
|
299
|
+
* describes through the client's root capability, which a relying-party app
|
|
300
|
+
* never holds. Every read here must invoke the per-collection grant, which is
|
|
301
|
+
* exactly what {@link WasRemoteStore.readCollectionEncryption} does (and, like
|
|
302
|
+
* the rest of the descriptor plumbing, it answers `undefined` rather than
|
|
303
|
+
* throwing when the read is unauthorized or the app is offline).
|
|
304
|
+
*
|
|
305
|
+
* @param options {object}
|
|
306
|
+
* @param options.remoteStore {WasRemoteStore}
|
|
307
|
+
* @returns {EncryptionDescriptorSource}
|
|
308
|
+
*/
|
|
309
|
+
export function remoteDescriptorSource({ remoteStore }) {
|
|
310
|
+
return {
|
|
311
|
+
async collectionEncryption({ collectionId }) {
|
|
312
|
+
return await remoteStore.readCollectionEncryption(collectionId);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
278
316
|
//# sourceMappingURL=wasRemoteStore.js.map
|
|
@@ -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;
|
|
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,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE5D,OAAO,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAA;AAyChE,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,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,UAAU,CA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AY,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;CAC1B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgH5B"}
|
package/dist/storage/wasSync.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WasRemoteStore } from './wasRemoteStore.js';
|
|
1
|
+
import { WasRemoteStore, remoteDescriptorSource } from './wasRemoteStore.js';
|
|
2
2
|
import { SharedCollectionReader } from './sharedCollectionReader.js';
|
|
3
3
|
/**
|
|
4
4
|
* Builds the remote store, opens the shared-collection readers, and starts
|
|
@@ -33,45 +33,52 @@ export async function startWasSync({ parsed, zcapClient, collections, localStore
|
|
|
33
33
|
zcapClient,
|
|
34
34
|
collections
|
|
35
35
|
});
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
// One pass per REGISTERED collection the grant set covers -- the registry is
|
|
37
|
+
// what this app declared, so a granted id it never registered is none of this
|
|
38
|
+
// bootstrap's business. Two things happen per collection:
|
|
39
|
+
//
|
|
40
|
+
// - the best-effort collection-description PUTs; non-fatal either way
|
|
41
|
+
// (envelopes replicate into an unmarked collection just the same, and a
|
|
42
|
+
// query against undeclared indexes fails with a descriptive 400). Each
|
|
43
|
+
// helper skips the collections it does not apply to (reported ok +
|
|
44
|
+
// skipped): the encryption descriptor skips public collections, the indexes
|
|
45
|
+
// declaration skips private ones and public ones with no declared indexes;
|
|
46
|
+
// - the private collection's encryption descriptor is fetched: rebuild that
|
|
47
|
+
// collection's cipher when its epoch roster differs from what the local
|
|
48
|
+
// store opened with (a wallet-side rotation, or first-ever epochs), and hand
|
|
49
|
+
// the fresh set to the descriptor-cache refresher so an offline session can
|
|
50
|
+
// rebuild its epoch-aware ciphers without a live read.
|
|
51
|
+
//
|
|
52
|
+
// The description is READ ONCE per collection and feeds both: the same
|
|
53
|
+
// descriptor answers the encryption PUT's read-before-write roster-clobber
|
|
54
|
+
// guard and the cipher rebuild, rather than each fetching it separately.
|
|
55
|
+
//
|
|
56
|
+
// SHARED collections never appear here: they are wallet-owned, absent from
|
|
57
|
+
// the app-owned registry, and a read-only grant would draw nothing but a
|
|
58
|
+
// pointless 403.
|
|
59
|
+
const granted = collections.filter(collection => parsed.byCollectionId[collection.id] !== undefined);
|
|
60
|
+
const descriptors = {};
|
|
61
|
+
await Promise.all(granted.map(async ({ id: collectionId, visibility }) => {
|
|
62
|
+
if (visibility !== 'public') {
|
|
63
|
+
const encryption = await remoteStore.readCollectionEncryption(collectionId);
|
|
64
|
+
if (encryption) {
|
|
65
|
+
descriptors[collectionId] = encryption;
|
|
66
|
+
await localStore.applyRemoteDescriptor({ collectionId, encryption });
|
|
67
|
+
}
|
|
68
|
+
const declared = await remoteStore.markCollectionEncrypted(collectionId, { encryption });
|
|
69
|
+
if (!declared.ok) {
|
|
70
|
+
console.warn(`Encryption descriptor PUT not authorized for "${collectionId}" (status ${declared.status ?? 'n/a'}).`);
|
|
71
|
+
}
|
|
49
72
|
}
|
|
50
73
|
const indexes = await remoteStore.declareCollectionIndexes(collectionId);
|
|
51
74
|
if (!indexes.ok) {
|
|
52
75
|
console.warn(`Indexes declaration PUT not authorized for "${collectionId}" (status ${indexes.status ?? 'n/a'}).`);
|
|
53
76
|
}
|
|
54
77
|
}));
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
// its epoch-aware ciphers without a live read.
|
|
60
|
-
const privateIds = collections
|
|
61
|
-
.filter(collection => collection.visibility !== 'public')
|
|
62
|
-
.map(collection => collection.id)
|
|
63
|
-
.filter(id => parsed.byCollectionId[id] !== undefined);
|
|
64
|
-
const descriptors = {};
|
|
65
|
-
await Promise.all(privateIds.map(async (collectionId) => {
|
|
66
|
-
const encryption = await remoteStore.readCollectionEncryption(collectionId);
|
|
67
|
-
if (encryption) {
|
|
68
|
-
descriptors[collectionId] = encryption;
|
|
69
|
-
await localStore.applyRemoteDescriptor({ collectionId, encryption });
|
|
70
|
-
}
|
|
71
|
-
}));
|
|
72
|
-
// Install the one-shot epoch refresher so a decrypt that meets an unseen epoch
|
|
73
|
-
// (a rotation on another device) re-reads the descriptor and rebuilds the cipher.
|
|
74
|
-
localStore.setEpochRefresher(collectionId => remoteStore.readCollectionEncryption(collectionId));
|
|
78
|
+
// Install the encryption-descriptor source so a decrypt that meets an unseen
|
|
79
|
+
// epoch (a rotation on another device) re-reads the descriptor and rebuilds
|
|
80
|
+
// the cipher -- once per collection per session.
|
|
81
|
+
localStore.setDescriptorSource(remoteDescriptorSource({ remoteStore }));
|
|
75
82
|
if (onDescriptorsFetched) {
|
|
76
83
|
await onDescriptorsFetched(descriptors);
|
|
77
84
|
}
|
|
@@ -80,16 +87,18 @@ export async function startWasSync({ parsed, zcapClient, collections, localStore
|
|
|
80
87
|
// roster. Every failure mode here is a warn-and-skip -- an uncovered grant,
|
|
81
88
|
// a collection with no roster, an app that is not (or is no longer) a
|
|
82
89
|
// recipient -- so a removed share degrades one reader, never the session.
|
|
90
|
+
// Opened concurrently: each `open` costs a description read plus an ECDH
|
|
91
|
+
// unwrap, and no reader depends on another.
|
|
83
92
|
const sharedReaders = {};
|
|
84
|
-
|
|
93
|
+
await Promise.all(sharedCollections.map(async ({ key, id }) => {
|
|
85
94
|
if (!parsed.byCollectionId[id]) {
|
|
86
95
|
console.warn(`Skipping shared collection "${id}": no delegated capability covers it.`);
|
|
87
|
-
|
|
96
|
+
return;
|
|
88
97
|
}
|
|
89
98
|
if (!identityKeys) {
|
|
90
99
|
console.warn(`Skipping shared collection "${id}": no identity key-agreement key was ` +
|
|
91
100
|
`supplied to decrypt it with.`);
|
|
92
|
-
|
|
101
|
+
return;
|
|
93
102
|
}
|
|
94
103
|
try {
|
|
95
104
|
sharedReaders[key] = await SharedCollectionReader.open({
|
|
@@ -102,7 +111,7 @@ export async function startWasSync({ parsed, zcapClient, collections, localStore
|
|
|
102
111
|
catch (err) {
|
|
103
112
|
console.warn(`Skipping shared collection "${id}":`, err);
|
|
104
113
|
}
|
|
105
|
-
}
|
|
114
|
+
}));
|
|
106
115
|
await syncController.start({
|
|
107
116
|
remoteStore,
|
|
108
117
|
localStore,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasSync.js","sourceRoot":"","sources":["../../src/storage/wasSync.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"wasSync.js","sourceRoot":"","sources":["../../src/storage/wasSync.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAcpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,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,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changesQuery.d.ts","sourceRoot":"","sources":["../../src/sync/changesQuery.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,OAAO,EACR,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"changesQuery.d.ts","sourceRoot":"","sources":["../../src/sync/changesQuery.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,OAAO,EACR,MAAM,YAAY,CAAA;AAGnB;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CASnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,IAE/C,gBAAgB,cAAc,GAAG,SAAS,EAC1C,WAAW,MAAM,KAChB,OAAO,CAAC;IACT,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,CAAA;IACnC,UAAU,EAAE,cAAc,GAAG,SAAS,CAAA;CACvC,CAAC,CAcH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { copyOptionalBodyFields } from './types.js';
|
|
1
2
|
/**
|
|
2
3
|
* Maps one `changes`-feed wire document into an RxDB document. The envelope
|
|
3
4
|
* fields map straight across; the content body stays under `data` (omitted for
|
|
@@ -17,18 +18,7 @@ export function wireDocToRxDoc(doc) {
|
|
|
17
18
|
version: doc.version,
|
|
18
19
|
_deleted: doc._deleted
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
rxDoc.data = doc.data;
|
|
22
|
-
}
|
|
23
|
-
if (doc.metaVersion !== undefined) {
|
|
24
|
-
rxDoc.metaVersion = doc.metaVersion;
|
|
25
|
-
}
|
|
26
|
-
if (doc.custom !== undefined) {
|
|
27
|
-
rxDoc.custom = doc.custom;
|
|
28
|
-
}
|
|
29
|
-
if (doc.epoch !== undefined) {
|
|
30
|
-
rxDoc.epoch = doc.epoch;
|
|
31
|
-
}
|
|
21
|
+
copyOptionalBodyFields({ source: doc, target: rxDoc });
|
|
32
22
|
return rxDoc;
|
|
33
23
|
}
|
|
34
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changesQuery.js","sourceRoot":"","sources":["../../src/sync/changesQuery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"changesQuery.js","sourceRoot":"","sources":["../../src/sync/changesQuery.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,MAAM,KAAK,GAA2B;QACpC,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ;KACvB,CAAA;IACD,sBAAsB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IACjD,OAAO,KAAK,UAAU,IAAI,CACxB,cAA0C,EAC1C,SAAiB;QAKjB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;YAChC,kEAAkE;YAClE,iCAAiC;YACjC,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;YACnE,KAAK,EAAE,SAAS;SACjB,CAAC,CAAA;QACF,OAAO;YACL,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC;YACjD,oEAAoE;YACpE,8DAA8D;YAC9D,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,cAAc;SAClD,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
package/dist/sync/docCipher.d.ts
CHANGED
|
@@ -18,6 +18,23 @@
|
|
|
18
18
|
import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
|
|
19
19
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
20
20
|
import type { Json } from './types.js';
|
|
21
|
+
/**
|
|
22
|
+
* Whether an error is the EDV codec's `UnknownEpochError` -- a stored envelope
|
|
23
|
+
* naming a JWE recipient this cipher cannot route, which is the signal to
|
|
24
|
+
* re-read the collection's encryption descriptor and rebuild the cipher.
|
|
25
|
+
*
|
|
26
|
+
* The `name` check is not belt-and-braces: a cipher built by
|
|
27
|
+
* `@interop/wallet-core` throws that package's OWN instance of the class (its
|
|
28
|
+
* dependency tree resolves a second physical copy of `@interop/was-client`, so
|
|
29
|
+
* the constructor is a different function object and `instanceof` is false
|
|
30
|
+
* here). The class sets `this.name`, which is stable across copies. Once the
|
|
31
|
+
* two copies dedupe from the npm registry the `instanceof` arm alone would
|
|
32
|
+
* suffice, and the `name` arm is harmless.
|
|
33
|
+
*
|
|
34
|
+
* @param err {unknown}
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
export declare function isUnknownEpochError(err: unknown): boolean;
|
|
21
38
|
/**
|
|
22
39
|
* A per-collection document cipher. `encrypt` is the create path (mints a random
|
|
23
40
|
* envelope id); `encryptUpdate` is the in-place update path (re-encrypts under
|
|
@@ -48,15 +65,6 @@ export interface DocCipher {
|
|
|
48
65
|
envelope: Json;
|
|
49
66
|
}): Promise<Json>;
|
|
50
67
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Whether a stored body is an EDV encryption envelope (carries an object `jwe`)
|
|
53
|
-
* rather than plaintext. Lets read paths stay tolerant of any legacy plaintext
|
|
54
|
-
* row.
|
|
55
|
-
*
|
|
56
|
-
* @param data {Json | undefined}
|
|
57
|
-
* @returns {boolean}
|
|
58
|
-
*/
|
|
59
|
-
export declare function isEncryptedEnvelope(data: Json | undefined): boolean;
|
|
60
68
|
/**
|
|
61
69
|
* Builds the pass-through codec for a PUBLIC (plaintext) collection: payloads
|
|
62
70
|
* are stored as-is, and the stored resource id IS the payload's logical `id`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.d.ts","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"docCipher.d.ts","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;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AAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,oBAAoB,CAAA;CAClC,GAAG,OAAO,CAAC,SAAS,CAAC,CASrB"}
|
package/dist/sync/docCipher.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { createEdvDocCipher } from '@interop/was-client/edv';
|
|
1
|
+
import { createEdvDocCipher, UnknownEpochError } from '@interop/was-client/edv';
|
|
2
|
+
import { isEncryptedEnvelope } from '@interop/was-client/sync';
|
|
2
3
|
/**
|
|
3
|
-
* Whether
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Whether an error is the EDV codec's `UnknownEpochError` -- a stored envelope
|
|
5
|
+
* naming a JWE recipient this cipher cannot route, which is the signal to
|
|
6
|
+
* re-read the collection's encryption descriptor and rebuild the cipher.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* The `name` check is not belt-and-braces: a cipher built by
|
|
9
|
+
* `@interop/wallet-core` throws that package's OWN instance of the class (its
|
|
10
|
+
* dependency tree resolves a second physical copy of `@interop/was-client`, so
|
|
11
|
+
* the constructor is a different function object and `instanceof` is false
|
|
12
|
+
* here). The class sets `this.name`, which is stable across copies. Once the
|
|
13
|
+
* two copies dedupe from the npm registry the `instanceof` arm alone would
|
|
14
|
+
* suffice, and the `name` arm is harmless.
|
|
15
|
+
*
|
|
16
|
+
* @param err {unknown}
|
|
8
17
|
* @returns {boolean}
|
|
9
18
|
*/
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const jwe = data.jwe;
|
|
15
|
-
return jwe !== null && typeof jwe === 'object';
|
|
19
|
+
export function isUnknownEpochError(err) {
|
|
20
|
+
return (err instanceof UnknownEpochError ||
|
|
21
|
+
(err instanceof Error && err.name === 'UnknownEpochError'));
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
24
|
* Builds the pass-through codec for a PUBLIC (plaintext) collection: payloads
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAG9D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,CACL,GAAG,YAAY,iBAAiB;QAChC,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAC3D,CAAA;AACH,CAAC;AAuBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,YAAY,EAGb;IACC,MAAM,SAAS,GAAG,CAAC,IAAU,EAAU,EAAE;QACvC,MAAM,EAAE,GAAI,IAAgC,EAAE,EAAE,CAAA;QAChD,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,kCAAkC,YAAY,2BAA2B,CAC1E,CAAA;QACH,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC,CAAA;IACD,MAAM,eAAe,GAAG,CAAC,IAAU,EAAQ,EAAE;QAC3C,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,eAAe,YAAY,yCAAyC;gBAClE,yBAAyB,CAC5B,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAkB;YACpC,OAAO,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QAChD,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,IAAI,EAA8B;YAC1D,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QAC/B,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAsB;YAC5C,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,eAAe,EACf,WAAW,EACX,YAAY,EACZ,UAAU,EAMX;IACC,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC;QACtC,eAAe;QACf,WAAW;QACX,YAAY;QACZ,YAAY,EAAE,QAAQ;QACtB,GAAG,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,CAAC;KAClC,CAAC,CAAA;IACF,OAAO,MAA8B,CAAA;AACvC,CAAC"}
|
|
@@ -25,6 +25,12 @@ import type { WasSyncBasePort, WasSyncPort } from './types.js';
|
|
|
25
25
|
* feed. `query`, `putContent`, `deleteContent`, and `putMeta` pass straight
|
|
26
26
|
* through.
|
|
27
27
|
*
|
|
28
|
+
* A walk starts at the feed's origin, so resolving one resource pages past many
|
|
29
|
+
* others. With a per-push-batch `cache` the walk memoizes every one of them, and
|
|
30
|
+
* a row that finds a walk already running waits for it rather than starting a
|
|
31
|
+
* second -- so a batch of k conflicting rows costs one feed scan instead of k
|
|
32
|
+
* concurrent ones. Without a `cache` the behavior is exactly as before.
|
|
33
|
+
*
|
|
28
34
|
* @param base {WasSyncBasePort}
|
|
29
35
|
* @returns {WasSyncPort}
|
|
30
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedMasterPort.d.ts","sourceRoot":"","sources":["../../src/sync/feedMasterPort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAIV,eAAe,EACf,WAAW,EAEZ,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"feedMasterPort.d.ts","sourceRoot":"","sources":["../../src/sync/feedMasterPort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAIV,eAAe,EACf,WAAW,EAEZ,MAAM,YAAY,CAAA;AAmFnB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAgCrE"}
|