cojson 0.20.6 → 0.20.8
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 +29 -0
- package/dist/SyncStateManager.d.ts.map +1 -1
- package/dist/SyncStateManager.js +0 -2
- package/dist/SyncStateManager.js.map +1 -1
- package/dist/base64url.d.ts +15 -0
- package/dist/base64url.d.ts.map +1 -1
- package/dist/base64url.js +101 -5
- package/dist/base64url.js.map +1 -1
- package/dist/base64url.test.js +76 -1
- package/dist/base64url.test.js.map +1 -1
- package/dist/coValue.d.ts +2 -1
- package/dist/coValue.d.ts.map +1 -1
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore/coValueCore.d.ts +9 -11
- package/dist/coValueCore/coValueCore.d.ts.map +1 -1
- package/dist/coValueCore/coValueCore.js +92 -65
- package/dist/coValueCore/coValueCore.js.map +1 -1
- package/dist/coValueCore/verifiedState.d.ts +38 -7
- package/dist/coValueCore/verifiedState.d.ts.map +1 -1
- package/dist/coValueCore/verifiedState.js +226 -30
- package/dist/coValueCore/verifiedState.js.map +1 -1
- package/dist/coValues/binaryCoStream.d.ts +63 -0
- package/dist/coValues/binaryCoStream.d.ts.map +1 -0
- package/dist/coValues/binaryCoStream.js +125 -0
- package/dist/coValues/binaryCoStream.js.map +1 -0
- package/dist/coValues/coList.d.ts +3 -1
- package/dist/coValues/coList.d.ts.map +1 -1
- package/dist/coValues/coList.js +15 -6
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.d.ts +1 -1
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/coValues/coMap.js +2 -2
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.d.ts +0 -38
- package/dist/coValues/coStream.d.ts.map +1 -1
- package/dist/coValues/coStream.js +0 -86
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.d.ts +44 -6
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/group.js +198 -17
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.d.ts +2 -1
- package/dist/coreToCoValue.d.ts.map +1 -1
- package/dist/coreToCoValue.js +2 -1
- package/dist/coreToCoValue.js.map +1 -1
- package/dist/crypto/NapiCrypto.d.ts +18 -24
- package/dist/crypto/NapiCrypto.d.ts.map +1 -1
- package/dist/crypto/NapiCrypto.js +98 -60
- package/dist/crypto/NapiCrypto.js.map +1 -1
- package/dist/crypto/RNCrypto.d.ts +16 -3
- package/dist/crypto/RNCrypto.d.ts.map +1 -1
- package/dist/crypto/RNCrypto.js +117 -54
- package/dist/crypto/RNCrypto.js.map +1 -1
- package/dist/crypto/WasmCrypto.d.ts +18 -24
- package/dist/crypto/WasmCrypto.d.ts.map +1 -1
- package/dist/crypto/WasmCrypto.js +100 -61
- package/dist/crypto/WasmCrypto.js.map +1 -1
- package/dist/crypto/crypto.d.ts +55 -19
- package/dist/crypto/crypto.d.ts.map +1 -1
- package/dist/crypto/crypto.js +14 -3
- package/dist/crypto/crypto.js.map +1 -1
- package/dist/exports.d.ts +7 -3
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +4 -2
- package/dist/exports.js.map +1 -1
- package/dist/localNode.d.ts +3 -1
- package/dist/localNode.d.ts.map +1 -1
- package/dist/localNode.js +10 -3
- package/dist/localNode.js.map +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/permissions.d.ts +2 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +19 -3
- package/dist/permissions.js.map +1 -1
- package/dist/queue/OutgoingLoadQueue.d.ts.map +1 -1
- package/dist/queue/OutgoingLoadQueue.js +4 -3
- package/dist/queue/OutgoingLoadQueue.js.map +1 -1
- package/dist/storage/sqliteAsync/client.d.ts +24 -12
- package/dist/storage/sqliteAsync/client.d.ts.map +1 -1
- package/dist/storage/sqliteAsync/client.js +70 -58
- package/dist/storage/sqliteAsync/client.js.map +1 -1
- package/dist/storage/sqliteAsync/types.d.ts +1 -1
- package/dist/storage/sqliteAsync/types.d.ts.map +1 -1
- package/dist/storage/types.d.ts +1 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +7 -1
- package/dist/sync.js.map +1 -1
- package/dist/tests/CojsonMessageChannel.test.js +2 -2
- package/dist/tests/OutgoingLoadQueue.test.js +39 -1
- package/dist/tests/OutgoingLoadQueue.test.js.map +1 -1
- package/dist/tests/SQLiteClientAsync.test.d.ts +2 -0
- package/dist/tests/SQLiteClientAsync.test.d.ts.map +1 -0
- package/dist/tests/SQLiteClientAsync.test.js +64 -0
- package/dist/tests/SQLiteClientAsync.test.js.map +1 -0
- package/dist/tests/StorageApiAsync.test.js +2 -8
- package/dist/tests/StorageApiAsync.test.js.map +1 -1
- package/dist/tests/SyncStateManager.test.js +2 -2
- package/dist/tests/WasmCrypto.test.js +1 -15
- package/dist/tests/WasmCrypto.test.js.map +1 -1
- package/dist/tests/coList.test.js +24 -5
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coStream.test.js +4 -3
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/coValueCore.initTransaction.test.d.ts +2 -0
- package/dist/tests/coValueCore.initTransaction.test.d.ts.map +1 -0
- package/dist/tests/coValueCore.initTransaction.test.js +438 -0
- package/dist/tests/coValueCore.initTransaction.test.js.map +1 -0
- package/dist/tests/coValueCore.test.js +11 -19
- package/dist/tests/coValueCore.test.js.map +1 -1
- package/dist/tests/crypto.test.js +83 -0
- package/dist/tests/crypto.test.js.map +1 -1
- package/dist/tests/deleteCoValue.test.js +5 -5
- package/dist/tests/deleteCoValue.test.js.map +1 -1
- package/dist/tests/group.inheritance.test.js +11 -0
- package/dist/tests/group.inheritance.test.js.map +1 -1
- package/dist/tests/group.test.js +24 -1
- package/dist/tests/group.test.js.map +1 -1
- package/dist/tests/groupSealer.test.d.ts +2 -0
- package/dist/tests/groupSealer.test.d.ts.map +1 -0
- package/dist/tests/groupSealer.test.js +913 -0
- package/dist/tests/groupSealer.test.js.map +1 -0
- package/dist/tests/setup.js +5 -0
- package/dist/tests/setup.js.map +1 -1
- package/dist/tests/sync.auth.test.js +10 -10
- package/dist/tests/sync.concurrentLoad.test.js +12 -12
- package/dist/tests/sync.deleted.test.js +8 -8
- package/dist/tests/sync.garbageCollection.test.js +10 -10
- package/dist/tests/sync.invite.test.js +12 -12
- package/dist/tests/sync.known.test.js +2 -2
- package/dist/tests/sync.load.test.js +107 -107
- package/dist/tests/sync.mesh.test.js +164 -46
- package/dist/tests/sync.mesh.test.js.map +1 -1
- package/dist/tests/sync.multipleServers.test.js +43 -43
- package/dist/tests/sync.peerReconciliation.test.js +29 -29
- package/dist/tests/sync.sharding.test.js +3 -3
- package/dist/tests/sync.storage.test.js +104 -104
- package/dist/tests/sync.storage.test.js.map +1 -1
- package/dist/tests/sync.storageAsync.test.js +56 -56
- package/dist/tests/sync.upload.test.js +22 -22
- package/dist/tests/testStorage.d.ts +2 -0
- package/dist/tests/testStorage.d.ts.map +1 -1
- package/dist/tests/testStorage.js +30 -6
- package/dist/tests/testStorage.js.map +1 -1
- package/dist/typeUtils/isCoValue.js +1 -1
- package/dist/typeUtils/isCoValue.js.map +1 -1
- package/package.json +4 -4
- package/src/SyncStateManager.ts +0 -2
- package/src/base64url.test.ts +89 -1
- package/src/base64url.ts +134 -6
- package/src/coValue.ts +2 -1
- package/src/coValueCore/coValueCore.ts +126 -84
- package/src/coValueCore/verifiedState.ts +335 -53
- package/src/coValues/binaryCoStream.ts +217 -0
- package/src/coValues/coList.ts +21 -8
- package/src/coValues/coMap.ts +3 -0
- package/src/coValues/coStream.ts +0 -170
- package/src/coValues/group.ts +270 -21
- package/src/coreToCoValue.ts +2 -1
- package/src/crypto/NapiCrypto.ts +198 -95
- package/src/crypto/RNCrypto.ts +229 -102
- package/src/crypto/WasmCrypto.ts +201 -95
- package/src/crypto/crypto.ts +118 -45
- package/src/exports.ts +11 -5
- package/src/localNode.ts +17 -1
- package/src/media.ts +1 -1
- package/src/permissions.ts +30 -7
- package/src/queue/OutgoingLoadQueue.ts +5 -2
- package/src/storage/sqliteAsync/client.ts +136 -115
- package/src/storage/sqliteAsync/types.ts +3 -1
- package/src/storage/types.ts +4 -0
- package/src/sync.ts +10 -1
- package/src/tests/CojsonMessageChannel.test.ts +2 -2
- package/src/tests/OutgoingLoadQueue.test.ts +65 -1
- package/src/tests/SQLiteClientAsync.test.ts +75 -0
- package/src/tests/StorageApiAsync.test.ts +4 -9
- package/src/tests/SyncStateManager.test.ts +2 -2
- package/src/tests/WasmCrypto.test.ts +1 -25
- package/src/tests/coList.test.ts +39 -5
- package/src/tests/coStream.test.ts +4 -5
- package/src/tests/coValueCore.initTransaction.test.ts +836 -0
- package/src/tests/coValueCore.test.ts +11 -22
- package/src/tests/crypto.test.ts +107 -0
- package/src/tests/deleteCoValue.test.ts +5 -5
- package/src/tests/group.inheritance.test.ts +16 -0
- package/src/tests/group.test.ts +29 -1
- package/src/tests/groupSealer.test.ts +1473 -0
- package/src/tests/setup.ts +6 -0
- package/src/tests/sync.auth.test.ts +10 -10
- package/src/tests/sync.concurrentLoad.test.ts +12 -12
- package/src/tests/sync.deleted.test.ts +8 -8
- package/src/tests/sync.garbageCollection.test.ts +10 -10
- package/src/tests/sync.invite.test.ts +12 -12
- package/src/tests/sync.known.test.ts +2 -2
- package/src/tests/sync.load.test.ts +107 -107
- package/src/tests/sync.mesh.test.ts +189 -46
- package/src/tests/sync.multipleServers.test.ts +43 -43
- package/src/tests/sync.peerReconciliation.test.ts +29 -29
- package/src/tests/sync.sharding.test.ts +3 -3
- package/src/tests/sync.storage.test.ts +104 -104
- package/src/tests/sync.storageAsync.test.ts +56 -56
- package/src/tests/sync.upload.test.ts +22 -22
- package/src/tests/testStorage.ts +39 -9
- package/src/typeUtils/isCoValue.ts +1 -1
- package/dist/coValueCore/SessionMap.d.ts +0 -55
- package/dist/coValueCore/SessionMap.d.ts.map +0 -1
- package/dist/coValueCore/SessionMap.js +0 -206
- package/dist/coValueCore/SessionMap.js.map +0 -1
- package/dist/tests/coreWasm.test.d.ts +0 -2
- package/dist/tests/coreWasm.test.d.ts.map +0 -1
- package/dist/tests/coreWasm.test.js +0 -203
- package/dist/tests/coreWasm.test.js.map +0 -1
- package/src/coValueCore/SessionMap.ts +0 -394
- package/src/tests/coreWasm.test.ts +0 -452
package/src/tests/coList.test.ts
CHANGED
|
@@ -210,6 +210,7 @@ test("init the list correctly", () => {
|
|
|
210
210
|
"universe",
|
|
211
211
|
"hello",
|
|
212
212
|
]);
|
|
213
|
+
expect(content.core.verified.header.createdAt).toBeDefined();
|
|
213
214
|
});
|
|
214
215
|
|
|
215
216
|
test("Items prepended to start appear with latest first", () => {
|
|
@@ -904,6 +905,8 @@ describe("CoList Branching", () => {
|
|
|
904
905
|
// Client1 adds items to the branch
|
|
905
906
|
aliceBranch.append("eggs", undefined, "trusting");
|
|
906
907
|
|
|
908
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
909
|
+
|
|
907
910
|
// Client2 loads the branch from a different session
|
|
908
911
|
const branchOnClient2 = await loadCoValueOrFail(
|
|
909
912
|
client2.node,
|
|
@@ -917,11 +920,11 @@ describe("CoList Branching", () => {
|
|
|
917
920
|
"trusting",
|
|
918
921
|
);
|
|
919
922
|
|
|
920
|
-
// Merge the branch back to source
|
|
921
923
|
branchOnClient2.core.mergeBranch();
|
|
922
924
|
|
|
923
|
-
// Wait for sync
|
|
924
|
-
await
|
|
925
|
+
// Wait for all coValues to sync on both nodes
|
|
926
|
+
await client2.node.syncManager.waitForAllCoValuesSync();
|
|
927
|
+
await client1.node.syncManager.waitForAllCoValuesSync();
|
|
925
928
|
|
|
926
929
|
// Source list should contain the final state
|
|
927
930
|
expect(groceryList.toJSON()).toEqual(["milk", "eggs", "cheese"]);
|
|
@@ -960,6 +963,8 @@ describe("CoList Branching", () => {
|
|
|
960
963
|
// Client2 adds different items to second branch
|
|
961
964
|
bobBranch.append("eggs", undefined, "trusting");
|
|
962
965
|
|
|
966
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
967
|
+
|
|
963
968
|
// Client2 loads first branch and modifies it
|
|
964
969
|
const aliceBranchOnClient2 = await loadCoValueOrFail(
|
|
965
970
|
client2.node,
|
|
@@ -975,8 +980,9 @@ describe("CoList Branching", () => {
|
|
|
975
980
|
|
|
976
981
|
bobBranch.core.mergeBranch();
|
|
977
982
|
|
|
978
|
-
// Wait for sync
|
|
979
|
-
await
|
|
983
|
+
// Wait for all coValues to sync on both nodes
|
|
984
|
+
await client2.node.syncManager.waitForAllCoValuesSync();
|
|
985
|
+
await client1.node.syncManager.waitForAllCoValuesSync();
|
|
980
986
|
|
|
981
987
|
// Source list should contain all changes
|
|
982
988
|
expect(groceryList.toJSON()).toMatchInlineSnapshot(`
|
|
@@ -1017,3 +1023,31 @@ test("the list should rebuild when the group permissions change", async () => {
|
|
|
1017
1023
|
expect(listOnBob.version).toEqual(1);
|
|
1018
1024
|
expect(listOnBob.totalValidTransactions).toEqual(1);
|
|
1019
1025
|
});
|
|
1026
|
+
|
|
1027
|
+
test("items appended after a losing init transaction are preserved", async () => {
|
|
1028
|
+
const alice = setupTestNode({ connected: true });
|
|
1029
|
+
const bob = setupTestNode({ connected: true });
|
|
1030
|
+
|
|
1031
|
+
const group = alice.node.createGroup();
|
|
1032
|
+
group.addMember("everyone", "writer");
|
|
1033
|
+
|
|
1034
|
+
const list = group.createList(
|
|
1035
|
+
["alice-init"],
|
|
1036
|
+
undefined,
|
|
1037
|
+
"trusting",
|
|
1038
|
+
undefined,
|
|
1039
|
+
{ fww: "init" },
|
|
1040
|
+
);
|
|
1041
|
+
|
|
1042
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
1043
|
+
|
|
1044
|
+
const listOnBob = await loadCoValueOrFail(bob.node, list.id);
|
|
1045
|
+
|
|
1046
|
+
listOnBob.appendItems(["bob-init"], undefined, "trusting", { fww: "init" });
|
|
1047
|
+
listOnBob.appendItems(["bob-update"], undefined, "trusting");
|
|
1048
|
+
|
|
1049
|
+
await waitFor(() => {
|
|
1050
|
+
expect(listOnBob.toJSON()).toEqual(["alice-init", "bob-update"]);
|
|
1051
|
+
expect(list.toJSON()).toEqual(["alice-init", "bob-update"]);
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
@@ -2,10 +2,9 @@ import { beforeEach, describe, expect, test } from "vitest";
|
|
|
2
2
|
import { expectStream } from "../coValue.js";
|
|
3
3
|
import {
|
|
4
4
|
BinaryStreamItem,
|
|
5
|
-
CoStreamItem,
|
|
6
5
|
RawBinaryCoStream,
|
|
7
|
-
|
|
8
|
-
} from "../coValues/coStream.js";
|
|
6
|
+
} from "../coValues/binaryCoStream.js";
|
|
7
|
+
import { CoStreamItem, RawCoStreamView } from "../coValues/coStream.js";
|
|
9
8
|
import { TRANSACTION_CONFIG } from "../config.js";
|
|
10
9
|
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
11
10
|
import { SessionID } from "../ids.js";
|
|
@@ -202,7 +201,7 @@ test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE)
|
|
|
202
201
|
throw new Error("CoValue is not available");
|
|
203
202
|
}
|
|
204
203
|
|
|
205
|
-
const sessionEntry = coValue.verified.
|
|
204
|
+
const sessionEntry = coValue.verified.getSession(node.currentSessionID)!;
|
|
206
205
|
expect(sessionEntry.transactions.length).toEqual(12);
|
|
207
206
|
expect(sessionEntry.signatureAfter[0]).not.toBeDefined();
|
|
208
207
|
expect(sessionEntry.signatureAfter[1]).not.toBeDefined();
|
|
@@ -278,7 +277,7 @@ test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we s
|
|
|
278
277
|
throw new Error("CoValue is not available");
|
|
279
278
|
}
|
|
280
279
|
|
|
281
|
-
const sessionEntry = coValue.verified.
|
|
280
|
+
const sessionEntry = coValue.verified.getSession(node.currentSessionID)!;
|
|
282
281
|
expect(sessionEntry.transactions.length).toEqual(5);
|
|
283
282
|
expect(sessionEntry.signatureAfter[0]).not.toBeDefined();
|
|
284
283
|
expect(sessionEntry.signatureAfter[1]).toBeDefined();
|