cojson 0.8.11 → 0.8.16
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/CHANGELOG.md +94 -82
- package/dist/native/PeerKnownStates.js +1 -1
- package/dist/native/PeerKnownStates.js.map +1 -1
- package/dist/native/PeerState.js +4 -1
- package/dist/native/PeerState.js.map +1 -1
- package/dist/native/PriorityBasedMessageQueue.js +1 -10
- package/dist/native/PriorityBasedMessageQueue.js.map +1 -1
- package/dist/native/base64url.js.map +1 -1
- package/dist/native/base64url.test.js +1 -1
- package/dist/native/base64url.test.js.map +1 -1
- package/dist/native/coValue.js.map +1 -1
- package/dist/native/coValueCore.js +141 -149
- package/dist/native/coValueCore.js.map +1 -1
- package/dist/native/coValueState.js.map +1 -1
- package/dist/native/coValues/account.js +6 -6
- package/dist/native/coValues/account.js.map +1 -1
- package/dist/native/coValues/coList.js +2 -3
- package/dist/native/coValues/coList.js.map +1 -1
- package/dist/native/coValues/coMap.js +1 -1
- package/dist/native/coValues/coMap.js.map +1 -1
- package/dist/native/coValues/coStream.js +3 -5
- package/dist/native/coValues/coStream.js.map +1 -1
- package/dist/native/coValues/group.js +11 -11
- package/dist/native/coValues/group.js.map +1 -1
- package/dist/native/coreToCoValue.js +2 -2
- package/dist/native/coreToCoValue.js.map +1 -1
- package/dist/native/crypto/PureJSCrypto.js +4 -4
- package/dist/native/crypto/PureJSCrypto.js.map +1 -1
- package/dist/native/crypto/crypto.js.map +1 -1
- package/dist/native/exports.js +12 -12
- package/dist/native/exports.js.map +1 -1
- package/dist/native/ids.js.map +1 -1
- package/dist/native/jsonStringify.js.map +1 -1
- package/dist/native/localNode.js +6 -8
- package/dist/native/localNode.js.map +1 -1
- package/dist/native/permissions.js +4 -7
- package/dist/native/permissions.js.map +1 -1
- package/dist/native/priority.js.map +1 -1
- package/dist/native/storage/FileSystem.js.map +1 -1
- package/dist/native/storage/chunksAndKnownStates.js +2 -4
- package/dist/native/storage/chunksAndKnownStates.js.map +1 -1
- package/dist/native/storage/index.js +7 -16
- package/dist/native/storage/index.js.map +1 -1
- package/dist/native/streamUtils.js.map +1 -1
- package/dist/native/sync.js +6 -8
- package/dist/native/sync.js.map +1 -1
- package/dist/native/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
- package/dist/native/typeUtils/expectGroup.js.map +1 -1
- package/dist/native/typeUtils/isAccountID.js.map +1 -1
- package/dist/native/typeUtils/isCoValue.js +1 -1
- package/dist/native/typeUtils/isCoValue.js.map +1 -1
- package/dist/web/PeerKnownStates.js +1 -1
- package/dist/web/PeerKnownStates.js.map +1 -1
- package/dist/web/PeerState.js +4 -1
- package/dist/web/PeerState.js.map +1 -1
- package/dist/web/PriorityBasedMessageQueue.js +1 -10
- package/dist/web/PriorityBasedMessageQueue.js.map +1 -1
- package/dist/web/base64url.js.map +1 -1
- package/dist/web/base64url.test.js +1 -1
- package/dist/web/base64url.test.js.map +1 -1
- package/dist/web/coValue.js.map +1 -1
- package/dist/web/coValueCore.js +141 -149
- package/dist/web/coValueCore.js.map +1 -1
- package/dist/web/coValueState.js.map +1 -1
- package/dist/web/coValues/account.js +6 -6
- package/dist/web/coValues/account.js.map +1 -1
- package/dist/web/coValues/coList.js +2 -3
- package/dist/web/coValues/coList.js.map +1 -1
- package/dist/web/coValues/coMap.js +1 -1
- package/dist/web/coValues/coMap.js.map +1 -1
- package/dist/web/coValues/coStream.js +3 -5
- package/dist/web/coValues/coStream.js.map +1 -1
- package/dist/web/coValues/group.js +11 -11
- package/dist/web/coValues/group.js.map +1 -1
- package/dist/web/coreToCoValue.js +2 -2
- package/dist/web/coreToCoValue.js.map +1 -1
- package/dist/web/crypto/PureJSCrypto.js +4 -4
- package/dist/web/crypto/PureJSCrypto.js.map +1 -1
- package/dist/web/crypto/WasmCrypto.js +5 -5
- package/dist/web/crypto/WasmCrypto.js.map +1 -1
- package/dist/web/crypto/crypto.js.map +1 -1
- package/dist/web/exports.js +12 -12
- package/dist/web/exports.js.map +1 -1
- package/dist/web/ids.js.map +1 -1
- package/dist/web/jsonStringify.js.map +1 -1
- package/dist/web/localNode.js +6 -8
- package/dist/web/localNode.js.map +1 -1
- package/dist/web/permissions.js +4 -7
- package/dist/web/permissions.js.map +1 -1
- package/dist/web/priority.js.map +1 -1
- package/dist/web/storage/FileSystem.js.map +1 -1
- package/dist/web/storage/chunksAndKnownStates.js +2 -4
- package/dist/web/storage/chunksAndKnownStates.js.map +1 -1
- package/dist/web/storage/index.js +7 -16
- package/dist/web/storage/index.js.map +1 -1
- package/dist/web/streamUtils.js.map +1 -1
- package/dist/web/sync.js +6 -8
- package/dist/web/sync.js.map +1 -1
- package/dist/web/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
- package/dist/web/typeUtils/expectGroup.js.map +1 -1
- package/dist/web/typeUtils/isAccountID.js.map +1 -1
- package/dist/web/typeUtils/isCoValue.js +1 -1
- package/dist/web/typeUtils/isCoValue.js.map +1 -1
- package/package.json +4 -14
- package/src/PeerKnownStates.ts +91 -89
- package/src/PeerState.ts +72 -69
- package/src/PriorityBasedMessageQueue.ts +42 -49
- package/src/base64url.test.ts +24 -24
- package/src/base64url.ts +44 -45
- package/src/coValue.ts +45 -45
- package/src/coValueCore.ts +746 -785
- package/src/coValueState.ts +82 -72
- package/src/coValues/account.ts +143 -150
- package/src/coValues/coList.ts +520 -522
- package/src/coValues/coMap.ts +283 -285
- package/src/coValues/coStream.ts +320 -324
- package/src/coValues/group.ts +306 -305
- package/src/coreToCoValue.ts +28 -31
- package/src/crypto/PureJSCrypto.ts +188 -194
- package/src/crypto/WasmCrypto.ts +236 -254
- package/src/crypto/crypto.ts +302 -309
- package/src/exports.ts +116 -116
- package/src/ids.ts +9 -9
- package/src/jsonStringify.ts +46 -46
- package/src/jsonValue.ts +24 -10
- package/src/localNode.ts +635 -660
- package/src/media.ts +3 -3
- package/src/permissions.ts +272 -278
- package/src/priority.ts +21 -19
- package/src/storage/FileSystem.ts +91 -99
- package/src/storage/chunksAndKnownStates.ts +110 -115
- package/src/storage/index.ts +466 -497
- package/src/streamUtils.ts +60 -60
- package/src/sync.ts +593 -615
- package/src/tests/PeerKnownStates.test.ts +38 -34
- package/src/tests/PeerState.test.ts +101 -64
- package/src/tests/PriorityBasedMessageQueue.test.ts +91 -91
- package/src/tests/account.test.ts +59 -59
- package/src/tests/coList.test.ts +65 -65
- package/src/tests/coMap.test.ts +137 -137
- package/src/tests/coStream.test.ts +254 -257
- package/src/tests/coValueCore.test.ts +153 -156
- package/src/tests/crypto.test.ts +136 -144
- package/src/tests/cryptoImpl.test.ts +205 -197
- package/src/tests/group.test.ts +24 -24
- package/src/tests/permissions.test.ts +1306 -1371
- package/src/tests/priority.test.ts +65 -82
- package/src/tests/sync.test.ts +1300 -1291
- package/src/tests/testUtils.ts +52 -53
- package/src/typeUtils/accountOrAgentIDfromSessionID.ts +4 -4
- package/src/typeUtils/expectGroup.ts +9 -9
- package/src/typeUtils/isAccountID.ts +1 -1
- package/src/typeUtils/isCoValue.ts +9 -9
- package/tsconfig.json +4 -6
- package/tsconfig.native.json +9 -11
- package/tsconfig.web.json +4 -10
- package/.eslintrc.cjs +0 -25
- package/.prettierrc.js +0 -9
|
@@ -1,104 +1,87 @@
|
|
|
1
|
-
import { expect, test
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
2
3
|
import { LocalNode } from "../localNode.js";
|
|
4
|
+
import { CO_VALUE_PRIORITY, getPriorityFromHeader } from "../priority.js";
|
|
3
5
|
import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
|
|
4
|
-
import { getPriorityFromHeader, CO_VALUE_PRIORITY } from "../priority.js";
|
|
5
|
-
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
6
6
|
|
|
7
7
|
const Crypto = await WasmCrypto.create();
|
|
8
8
|
|
|
9
9
|
describe("getPriorityFromHeader", () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("returns MEDIUM priority for costream type", () => {
|
|
19
|
-
const node = new LocalNode(
|
|
20
|
-
...randomAnonymousAccountAndSessionID(),
|
|
21
|
-
Crypto,
|
|
22
|
-
);
|
|
23
|
-
const costream = node.createCoValue({
|
|
24
|
-
type: "costream",
|
|
25
|
-
ruleset: { type: "unsafeAllowAll" },
|
|
26
|
-
meta: null,
|
|
27
|
-
...Crypto.createdNowUnique(),
|
|
28
|
-
});
|
|
10
|
+
test("returns MEDIUM priority for boolean or undefined headers", () => {
|
|
11
|
+
expect(getPriorityFromHeader(true)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
|
|
12
|
+
expect(getPriorityFromHeader(false)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
|
|
13
|
+
expect(getPriorityFromHeader(undefined)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
|
|
14
|
+
});
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
test("returns MEDIUM priority for costream type", () => {
|
|
17
|
+
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
|
|
18
|
+
const costream = node.createCoValue({
|
|
19
|
+
type: "costream",
|
|
20
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
21
|
+
meta: null,
|
|
22
|
+
...Crypto.createdNowUnique(),
|
|
33
23
|
});
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
const costream = node.createCoValue({
|
|
41
|
-
type: "costream",
|
|
42
|
-
ruleset: { type: "unsafeAllowAll" },
|
|
43
|
-
meta: { type: "binary" },
|
|
44
|
-
...Crypto.createdNowUnique(),
|
|
45
|
-
});
|
|
25
|
+
expect(getPriorityFromHeader(costream.header)).toEqual(
|
|
26
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
27
|
+
);
|
|
28
|
+
});
|
|
46
29
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
test("returns LOW priority for binary costream type", () => {
|
|
31
|
+
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
|
|
32
|
+
const costream = node.createCoValue({
|
|
33
|
+
type: "costream",
|
|
34
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
35
|
+
meta: { type: "binary" },
|
|
36
|
+
...Crypto.createdNowUnique(),
|
|
50
37
|
});
|
|
51
38
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
39
|
+
expect(getPriorityFromHeader(costream.header)).toEqual(
|
|
40
|
+
CO_VALUE_PRIORITY.LOW,
|
|
41
|
+
);
|
|
42
|
+
});
|
|
57
43
|
|
|
58
|
-
|
|
44
|
+
test("returns HIGH priority for account type", async () => {
|
|
45
|
+
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
CO_VALUE_PRIORITY.HIGH,
|
|
62
|
-
);
|
|
63
|
-
});
|
|
47
|
+
const account = node.createAccount(node.crypto.newRandomAgentSecret());
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
const group = node.createGroup();
|
|
49
|
+
expect(getPriorityFromHeader(account.core.header)).toEqual(
|
|
50
|
+
CO_VALUE_PRIORITY.HIGH,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
54
|
+
test("returns HIGH priority for group type", () => {
|
|
55
|
+
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
|
|
56
|
+
const group = node.createGroup();
|
|
76
57
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
58
|
+
expect(getPriorityFromHeader(group.core.header)).toEqual(
|
|
59
|
+
CO_VALUE_PRIORITY.HIGH,
|
|
60
|
+
);
|
|
61
|
+
});
|
|
82
62
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
ruleset: { type: "unsafeAllowAll" },
|
|
86
|
-
meta: null,
|
|
87
|
-
...Crypto.createdNowUnique(),
|
|
88
|
-
});
|
|
63
|
+
test("returns MEDIUM priority for other types", () => {
|
|
64
|
+
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
|
|
89
65
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
66
|
+
const comap = node.createCoValue({
|
|
67
|
+
type: "comap",
|
|
68
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
69
|
+
meta: null,
|
|
70
|
+
...Crypto.createdNowUnique(),
|
|
71
|
+
});
|
|
96
72
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
73
|
+
const colist = node.createCoValue({
|
|
74
|
+
type: "colist",
|
|
75
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
76
|
+
meta: null,
|
|
77
|
+
...Crypto.createdNowUnique(),
|
|
103
78
|
});
|
|
79
|
+
|
|
80
|
+
expect(getPriorityFromHeader(comap.header)).toEqual(
|
|
81
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
82
|
+
);
|
|
83
|
+
expect(getPriorityFromHeader(colist.header)).toEqual(
|
|
84
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
85
|
+
);
|
|
86
|
+
});
|
|
104
87
|
});
|