cojson 0.18.31 → 0.18.33
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/SyncStateManager.d.ts.map +1 -1
- package/dist/SyncStateManager.js +2 -2
- package/dist/SyncStateManager.js.map +1 -1
- package/dist/coValueCore/SessionMap.d.ts +1 -0
- package/dist/coValueCore/SessionMap.d.ts.map +1 -1
- package/dist/coValueCore/SessionMap.js +17 -2
- package/dist/coValueCore/SessionMap.js.map +1 -1
- package/dist/coValueCore/coValueCore.d.ts +14 -9
- package/dist/coValueCore/coValueCore.d.ts.map +1 -1
- package/dist/coValueCore/coValueCore.js +62 -47
- package/dist/coValueCore/coValueCore.js.map +1 -1
- package/dist/coValueCore/verifiedState.d.ts +2 -2
- package/dist/coValueCore/verifiedState.d.ts.map +1 -1
- package/dist/coValueCore/verifiedState.js +86 -75
- package/dist/coValueCore/verifiedState.js.map +1 -1
- package/dist/coValues/group.d.ts +1 -0
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/group.js +24 -4
- package/dist/coValues/group.js.map +1 -1
- package/dist/crypto/PureJSCrypto.d.ts.map +1 -1
- package/dist/crypto/PureJSCrypto.js +2 -10
- package/dist/crypto/PureJSCrypto.js.map +1 -1
- package/dist/knownState.d.ts +1 -1
- package/dist/knownState.d.ts.map +1 -1
- package/dist/knownState.js +1 -1
- package/dist/knownState.js.map +1 -1
- package/dist/localNode.d.ts.map +1 -1
- package/dist/localNode.js +1 -2
- package/dist/localNode.js.map +1 -1
- package/dist/queue/LocalTransactionsSyncQueue.d.ts.map +1 -1
- package/dist/queue/LocalTransactionsSyncQueue.js +16 -1
- package/dist/queue/LocalTransactionsSyncQueue.js.map +1 -1
- package/dist/storage/knownState.js +2 -2
- package/dist/storage/knownState.js.map +1 -1
- package/dist/storage/sqlite/index.d.ts.map +1 -1
- package/dist/storage/sqlite/index.js +17 -3
- package/dist/storage/sqlite/index.js.map +1 -1
- package/dist/storage/sqlite/sqliteMigrations.d.ts +6 -1
- package/dist/storage/sqlite/sqliteMigrations.d.ts.map +1 -1
- package/dist/storage/sqlite/sqliteMigrations.js +1 -3
- package/dist/storage/sqlite/sqliteMigrations.js.map +1 -1
- package/dist/storage/sqlite/types.d.ts +2 -0
- package/dist/storage/sqlite/types.d.ts.map +1 -1
- package/dist/storage/sqliteAsync/index.d.ts.map +1 -1
- package/dist/storage/sqliteAsync/index.js +17 -3
- package/dist/storage/sqliteAsync/index.js.map +1 -1
- package/dist/storage/sqliteAsync/types.d.ts +2 -0
- package/dist/storage/sqliteAsync/types.d.ts.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +8 -2
- package/dist/sync.js.map +1 -1
- package/dist/tests/PureJSCrypto.test.js +1 -1
- package/dist/tests/PureJSCrypto.test.js.map +1 -1
- package/dist/tests/StorageApiAsync.test.js +11 -11
- package/dist/tests/StorageApiAsync.test.js.map +1 -1
- package/dist/tests/StorageApiSync.test.js +3 -3
- package/dist/tests/StorageApiSync.test.js.map +1 -1
- package/dist/tests/WasmCrypto.test.js +1 -1
- package/dist/tests/WasmCrypto.test.js.map +1 -1
- package/dist/tests/coPlainText.test.js +1 -1
- package/dist/tests/coStream.test.js +12 -12
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/coValueCore.isCompletelyDownloaded.test.d.ts +2 -0
- package/dist/tests/coValueCore.isCompletelyDownloaded.test.d.ts.map +1 -0
- package/dist/tests/coValueCore.isCompletelyDownloaded.test.js +421 -0
- package/dist/tests/coValueCore.isCompletelyDownloaded.test.js.map +1 -0
- package/dist/tests/coValueCore.isStreaming.test.d.ts +2 -0
- package/dist/tests/coValueCore.isStreaming.test.d.ts.map +1 -0
- package/dist/tests/coValueCore.isStreaming.test.js +181 -0
- package/dist/tests/coValueCore.isStreaming.test.js.map +1 -0
- package/dist/tests/coValueCore.newContentSince.test.d.ts +2 -0
- package/dist/tests/coValueCore.newContentSince.test.d.ts.map +1 -0
- package/dist/tests/coValueCore.newContentSince.test.js +808 -0
- package/dist/tests/coValueCore.newContentSince.test.js.map +1 -0
- package/dist/tests/coreWasm.test.js +2 -2
- package/dist/tests/coreWasm.test.js.map +1 -1
- package/dist/tests/group.childKeyRotation.test.d.ts +2 -0
- package/dist/tests/group.childKeyRotation.test.d.ts.map +1 -0
- package/dist/tests/group.childKeyRotation.test.js +261 -0
- package/dist/tests/group.childKeyRotation.test.js.map +1 -0
- package/dist/tests/group.removeMember.test.js +1 -114
- package/dist/tests/group.removeMember.test.js.map +1 -1
- package/dist/tests/knownState.test.js +11 -11
- package/dist/tests/knownState.test.js.map +1 -1
- package/dist/tests/sync.auth.test.js +6 -6
- package/dist/tests/sync.load.test.js +68 -5
- package/dist/tests/sync.load.test.js.map +1 -1
- package/dist/tests/sync.mesh.test.js +11 -17
- package/dist/tests/sync.mesh.test.js.map +1 -1
- package/dist/tests/sync.peerReconciliation.test.js +1 -1
- package/dist/tests/sync.storage.test.js +7 -7
- package/dist/tests/sync.storage.test.js.map +1 -1
- package/dist/tests/sync.storageAsync.test.js +4 -4
- package/dist/tests/sync.storageAsync.test.js.map +1 -1
- package/dist/tests/sync.upload.test.js +96 -40
- package/dist/tests/sync.upload.test.js.map +1 -1
- package/dist/tests/testUtils.d.ts +2 -0
- package/dist/tests/testUtils.d.ts.map +1 -1
- package/dist/tests/testUtils.js +22 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/package.json +3 -3
- package/src/SyncStateManager.ts +2 -5
- package/src/coValueCore/SessionMap.ts +26 -1
- package/src/coValueCore/coValueCore.ts +77 -55
- package/src/coValueCore/verifiedState.ts +123 -108
- package/src/coValues/group.ts +27 -4
- package/src/crypto/PureJSCrypto.ts +5 -21
- package/src/knownState.ts +1 -1
- package/src/localNode.ts +1 -2
- package/src/queue/LocalTransactionsSyncQueue.ts +25 -0
- package/src/storage/knownState.ts +2 -2
- package/src/storage/sqlite/index.ts +16 -3
- package/src/storage/sqlite/sqliteMigrations.ts +7 -4
- package/src/storage/sqlite/types.ts +2 -0
- package/src/storage/sqliteAsync/index.ts +19 -6
- package/src/storage/sqliteAsync/types.ts +2 -0
- package/src/sync.ts +7 -2
- package/src/tests/PureJSCrypto.test.ts +1 -2
- package/src/tests/StorageApiAsync.test.ts +11 -11
- package/src/tests/StorageApiSync.test.ts +3 -3
- package/src/tests/WasmCrypto.test.ts +1 -2
- package/src/tests/coPlainText.test.ts +1 -1
- package/src/tests/coStream.test.ts +12 -12
- package/src/tests/coValueCore.isCompletelyDownloaded.test.ts +589 -0
- package/src/tests/coValueCore.isStreaming.test.ts +271 -0
- package/src/tests/coValueCore.newContentSince.test.ts +966 -0
- package/src/tests/coreWasm.test.ts +2 -2
- package/src/tests/group.childKeyRotation.test.ts +431 -0
- package/src/tests/group.removeMember.test.ts +1 -184
- package/src/tests/knownState.test.ts +11 -11
- package/src/tests/sync.auth.test.ts +6 -6
- package/src/tests/sync.load.test.ts +80 -5
- package/src/tests/sync.mesh.test.ts +11 -17
- package/src/tests/sync.peerReconciliation.test.ts +1 -1
- package/src/tests/sync.storage.test.ts +7 -7
- package/src/tests/sync.storageAsync.test.ts +4 -4
- package/src/tests/sync.upload.test.ts +106 -40
- package/src/tests/testUtils.ts +24 -2
|
@@ -31,7 +31,7 @@ function getNewContentSince(
|
|
|
31
31
|
throw new Error(`CoValue ${coValue.id} is not verified`);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const contentMessage = coValue.
|
|
34
|
+
const contentMessage = coValue.newContentSince(knownState)?.[0];
|
|
35
35
|
|
|
36
36
|
if (!contentMessage) {
|
|
37
37
|
throw new Error(`No new content available for coValue ${coValue.id}`);
|
|
@@ -295,7 +295,7 @@ describe("StorageApiAsync", () => {
|
|
|
295
295
|
const contentMessage = getNewContentSince(group.core, knownState);
|
|
296
296
|
const correctionCallback = vi.fn((known) => {
|
|
297
297
|
expect(known).toEqual(emptyKnownState(group.id));
|
|
298
|
-
return group.core.
|
|
298
|
+
return group.core.newContentSince(known);
|
|
299
299
|
});
|
|
300
300
|
|
|
301
301
|
// Get initial known state
|
|
@@ -339,7 +339,7 @@ describe("StorageApiAsync", () => {
|
|
|
339
339
|
const contentMessage = getNewContentSince(group.core, knownState);
|
|
340
340
|
const correctionCallback = vi.fn((known) => {
|
|
341
341
|
expect(known).toEqual(initialKnownState);
|
|
342
|
-
return group.core.
|
|
342
|
+
return group.core.newContentSince(known);
|
|
343
343
|
});
|
|
344
344
|
|
|
345
345
|
// Get initial storage known state
|
|
@@ -539,16 +539,16 @@ describe("StorageApiAsync", () => {
|
|
|
539
539
|
}),
|
|
540
540
|
).toMatchInlineSnapshot(`
|
|
541
541
|
[
|
|
542
|
-
"test -> test-storage | CONTENT Core header: false new: After: 1 New: 1",
|
|
543
|
-
"test -> test-storage | CONTENT Core2 header: false new: After: 1 New: 1",
|
|
542
|
+
"test -> test-storage | CONTENT Core header: false new: After: 1 New: 1 expectContentUntil: header/3",
|
|
543
|
+
"test -> test-storage | CONTENT Core2 header: false new: After: 1 New: 1 expectContentUntil: header/3",
|
|
544
544
|
"test -> test-storage | CONTENT Core header: false new: After: 2 New: 1",
|
|
545
545
|
"test -> test-storage | CONTENT Core2 header: false new: After: 2 New: 1",
|
|
546
546
|
"test-storage -> test | KNOWN CORRECTION Core sessions: empty",
|
|
547
547
|
"test -> test-storage | CONTENT Core header: true new: After: 0 New: 3",
|
|
548
548
|
"test-storage -> test | KNOWN CORRECTION Core2 sessions: empty",
|
|
549
549
|
"test -> test-storage | CONTENT Core2 header: true new: After: 0 New: 3",
|
|
550
|
-
"test -> test-storage | CONTENT Core header: false new: After: 3 New: 1",
|
|
551
|
-
"test -> test-storage | CONTENT Core2 header: false new: After: 3 New: 1",
|
|
550
|
+
"test -> test-storage | CONTENT Core header: false new: After: 3 New: 1 expectContentUntil: header/5",
|
|
551
|
+
"test -> test-storage | CONTENT Core2 header: false new: After: 3 New: 1 expectContentUntil: header/5",
|
|
552
552
|
"test -> test-storage | CONTENT Core header: false new: After: 4 New: 1",
|
|
553
553
|
"test -> test-storage | CONTENT Core2 header: false new: After: 4 New: 1",
|
|
554
554
|
]
|
|
@@ -606,14 +606,14 @@ describe("StorageApiAsync", () => {
|
|
|
606
606
|
}),
|
|
607
607
|
).toMatchInlineSnapshot(`
|
|
608
608
|
[
|
|
609
|
-
"test -> test-storage | CONTENT Core header: false new: After: 1 New: 1",
|
|
610
|
-
"test -> test-storage | CONTENT Core2 header: false new: After: 1 New: 1",
|
|
609
|
+
"test -> test-storage | CONTENT Core header: false new: After: 1 New: 1 expectContentUntil: header/3",
|
|
610
|
+
"test -> test-storage | CONTENT Core2 header: false new: After: 1 New: 1 expectContentUntil: header/3",
|
|
611
611
|
"test -> test-storage | CONTENT Core header: false new: After: 2 New: 1",
|
|
612
612
|
"test -> test-storage | CONTENT Core2 header: false new: After: 2 New: 1",
|
|
613
613
|
"test-storage -> test | KNOWN CORRECTION Core sessions: empty",
|
|
614
614
|
"test -> test-storage | CONTENT Core header: true new: After: 0 New: 3",
|
|
615
|
-
"test -> test-storage | CONTENT Core header: false new: After: 3 New: 1",
|
|
616
|
-
"test -> test-storage | CONTENT Core2 header: false new: After: 3 New: 1",
|
|
615
|
+
"test -> test-storage | CONTENT Core header: false new: After: 3 New: 1 expectContentUntil: header/5",
|
|
616
|
+
"test -> test-storage | CONTENT Core2 header: false new: After: 3 New: 1 expectContentUntil: header/5",
|
|
617
617
|
"test -> test-storage | CONTENT Core header: false new: After: 4 New: 1",
|
|
618
618
|
"test -> test-storage | CONTENT Core2 header: false new: After: 4 New: 1",
|
|
619
619
|
]
|
|
@@ -26,7 +26,7 @@ function getNewContentSince(
|
|
|
26
26
|
throw new Error(`CoValue ${coValue.id} is not verified`);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const contentMessage = coValue.
|
|
29
|
+
const contentMessage = coValue.newContentSince(knownState)?.[0];
|
|
30
30
|
|
|
31
31
|
if (!contentMessage) {
|
|
32
32
|
throw new Error(`No new content available for coValue ${coValue.id}`);
|
|
@@ -274,7 +274,7 @@ describe("StorageApiSync", () => {
|
|
|
274
274
|
const contentMessage = getNewContentSince(group.core, knownState);
|
|
275
275
|
const correctionCallback = vi.fn((known) => {
|
|
276
276
|
expect(known).toEqual(emptyKnownState(group.id));
|
|
277
|
-
return group.core.
|
|
277
|
+
return group.core.newContentSince(known);
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
// Get initial known state
|
|
@@ -318,7 +318,7 @@ describe("StorageApiSync", () => {
|
|
|
318
318
|
const contentMessage = getNewContentSince(group.core, knownState);
|
|
319
319
|
const correctionCallback = vi.fn((known) => {
|
|
320
320
|
expect(known).toEqual(initialKnownState);
|
|
321
|
-
return group.core.
|
|
321
|
+
return group.core.newContentSince(known);
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
// Get initial storage known state
|
|
@@ -117,8 +117,7 @@ describe("WasmCrypto", () => {
|
|
|
117
117
|
true,
|
|
118
118
|
);
|
|
119
119
|
|
|
120
|
-
const content =
|
|
121
|
-
mapInOtherSession.core.verified.newContentSince(undefined)?.[0];
|
|
120
|
+
const content = mapInOtherSession.core.newContentSince(undefined)?.[0];
|
|
122
121
|
assert(content);
|
|
123
122
|
|
|
124
123
|
client.node.syncManager.handleNewContent(content, "storage");
|
|
@@ -371,7 +371,7 @@ test("chunks transactions when when the chars are longer than MAX_RECOMMENDED_TX
|
|
|
371
371
|
}),
|
|
372
372
|
).toMatchInlineSnapshot(`
|
|
373
373
|
[
|
|
374
|
-
"client -> storage | CONTENT CoPlainText header: true new: After: 0 New: 1",
|
|
374
|
+
"client -> storage | CONTENT CoPlainText header: true new: After: 0 New: 1 expectContentUntil: header/42",
|
|
375
375
|
"client -> storage | CONTENT CoPlainText header: false new: After: 1 New: 1",
|
|
376
376
|
"client -> storage | CONTENT CoPlainText header: false new: After: 2 New: 1",
|
|
377
377
|
"client -> storage | CONTENT CoPlainText header: false new: After: 3 New: 1",
|
|
@@ -217,24 +217,24 @@ test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE)
|
|
|
217
217
|
expect(sessionEntry.signatureAfter[10]).not.toBeDefined();
|
|
218
218
|
expect(sessionEntry.signatureAfter[11]).not.toBeDefined();
|
|
219
219
|
|
|
220
|
-
const newContent = coValue.
|
|
220
|
+
const newContent = coValue.newContentSince({
|
|
221
221
|
id: coValue.id,
|
|
222
222
|
header: false,
|
|
223
223
|
sessions: {},
|
|
224
224
|
})!;
|
|
225
225
|
|
|
226
|
-
expect(newContent.length).toEqual(
|
|
226
|
+
expect(newContent.length).toEqual(4);
|
|
227
227
|
expect(newContent[0]!.header).toBeDefined();
|
|
228
|
-
expect(newContent[
|
|
228
|
+
expect(newContent[0]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
229
229
|
sessionEntry.signatureAfter[3],
|
|
230
230
|
);
|
|
231
|
-
expect(newContent[
|
|
231
|
+
expect(newContent[1]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
232
232
|
sessionEntry.signatureAfter[6],
|
|
233
233
|
);
|
|
234
|
-
expect(newContent[
|
|
234
|
+
expect(newContent[2]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
235
235
|
sessionEntry.signatureAfter[9],
|
|
236
236
|
);
|
|
237
|
-
expect(newContent[
|
|
237
|
+
expect(newContent[3]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
238
238
|
sessionEntry.lastSignature,
|
|
239
239
|
);
|
|
240
240
|
});
|
|
@@ -286,24 +286,24 @@ test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we s
|
|
|
286
286
|
expect(sessionEntry.signatureAfter[3]).toBeDefined();
|
|
287
287
|
expect(sessionEntry.signatureAfter[4]).not.toBeDefined();
|
|
288
288
|
|
|
289
|
-
const newContent = coValue.
|
|
289
|
+
const newContent = coValue.newContentSince({
|
|
290
290
|
id: coValue.id,
|
|
291
291
|
header: false,
|
|
292
292
|
sessions: {},
|
|
293
293
|
})!;
|
|
294
294
|
|
|
295
|
-
expect(newContent.length).toEqual(
|
|
295
|
+
expect(newContent.length).toEqual(4);
|
|
296
296
|
expect(newContent[0]!.header).toBeDefined();
|
|
297
|
-
expect(newContent[
|
|
297
|
+
expect(newContent[0]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
298
298
|
sessionEntry.signatureAfter[1],
|
|
299
299
|
);
|
|
300
|
-
expect(newContent[
|
|
300
|
+
expect(newContent[1]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
301
301
|
sessionEntry.signatureAfter[2],
|
|
302
302
|
);
|
|
303
|
-
expect(newContent[
|
|
303
|
+
expect(newContent[2]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
304
304
|
sessionEntry.signatureAfter[3],
|
|
305
305
|
);
|
|
306
|
-
expect(newContent[
|
|
306
|
+
expect(newContent[3]!.new[node.currentSessionID]!.lastSignature).toEqual(
|
|
307
307
|
sessionEntry.lastSignature,
|
|
308
308
|
);
|
|
309
309
|
});
|