cojson 0.7.35 → 0.8.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/.turbo/turbo-build.log +2 -7
- package/.turbo/turbo-lint.log +4 -0
- package/CHANGELOG.md +7 -0
- package/dist/PeerState.js +13 -5
- package/dist/PeerState.js.map +1 -1
- package/dist/coValueCore.js +0 -6
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/account.js +2 -3
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.js +8 -8
- package/dist/coValues/group.js.map +1 -1
- package/dist/crypto/crypto.js +3 -0
- package/dist/crypto/crypto.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/localNode.js +9 -9
- package/dist/localNode.js.map +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/tests/account.test.js +1 -2
- package/dist/tests/account.test.js.map +1 -1
- package/dist/tests/permissions.test.js +41 -42
- package/dist/tests/permissions.test.js.map +1 -1
- package/dist/tests/sync.test.js +4 -5
- package/dist/tests/sync.test.js.map +1 -1
- package/dist/tests/testUtils.js +1 -2
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
- package/dist/typeUtils/isAccountID.js.map +1 -1
- package/package.json +1 -1
- package/src/PeerState.ts +18 -7
- package/src/coValueCore.ts +7 -15
- package/src/coValues/account.ts +5 -6
- package/src/coValues/coList.ts +4 -4
- package/src/coValues/coMap.ts +3 -3
- package/src/coValues/coStream.ts +8 -8
- package/src/coValues/group.ts +15 -11
- package/src/crypto/crypto.ts +5 -0
- package/src/ids.ts +2 -2
- package/src/index.ts +4 -4
- package/src/localNode.ts +18 -18
- package/src/permissions.ts +5 -5
- package/src/tests/account.test.ts +1 -2
- package/src/tests/permissions.test.ts +41 -42
- package/src/tests/sync.test.ts +8 -8
- package/src/tests/testUtils.ts +1 -2
- package/src/typeUtils/accountOrAgentIDfromSessionID.ts +3 -3
- package/src/typeUtils/isAccountID.ts +2 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
|
-
import { newRandomSessionID } from "../coValueCore.js";
|
|
3
2
|
import { expectMap } from "../coValue.js";
|
|
4
3
|
import {
|
|
5
4
|
newGroup,
|
|
@@ -27,7 +26,7 @@ test("Added admin can add a third admin to a group", () => {
|
|
|
27
26
|
groupCore
|
|
28
27
|
.testWithDifferentAccount(
|
|
29
28
|
otherAdmin,
|
|
30
|
-
newRandomSessionID(otherAdmin.id),
|
|
29
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
31
30
|
)
|
|
32
31
|
.getCurrentContent(),
|
|
33
32
|
);
|
|
@@ -47,7 +46,7 @@ test("Added adming can add a third admin to a group (high level)", () => {
|
|
|
47
46
|
group.core
|
|
48
47
|
.testWithDifferentAccount(
|
|
49
48
|
otherAdmin,
|
|
50
|
-
newRandomSessionID(otherAdmin.id),
|
|
49
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
51
50
|
)
|
|
52
51
|
.getCurrentContent(),
|
|
53
52
|
);
|
|
@@ -73,7 +72,7 @@ test("Admins can't demote other admins in a group", () => {
|
|
|
73
72
|
groupCore
|
|
74
73
|
.testWithDifferentAccount(
|
|
75
74
|
otherAdmin,
|
|
76
|
-
newRandomSessionID(otherAdmin.id),
|
|
75
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
77
76
|
)
|
|
78
77
|
.getCurrentContent(),
|
|
79
78
|
);
|
|
@@ -89,7 +88,7 @@ test("Admins can't demote other admins in a group (high level)", () => {
|
|
|
89
88
|
group.core
|
|
90
89
|
.testWithDifferentAccount(
|
|
91
90
|
otherAdmin,
|
|
92
|
-
newRandomSessionID(otherAdmin.id),
|
|
91
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
93
92
|
)
|
|
94
93
|
.getCurrentContent(),
|
|
95
94
|
);
|
|
@@ -114,7 +113,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
114
113
|
|
|
115
114
|
const groupAsWriter = expectGroup(
|
|
116
115
|
groupCore
|
|
117
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
116
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
118
117
|
.getCurrentContent(),
|
|
119
118
|
);
|
|
120
119
|
|
|
@@ -142,7 +141,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
142
141
|
|
|
143
142
|
const groupAsWriter = expectGroup(
|
|
144
143
|
group.core
|
|
145
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
144
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
146
145
|
.getCurrentContent(),
|
|
147
146
|
);
|
|
148
147
|
|
|
@@ -174,7 +173,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
174
173
|
|
|
175
174
|
const groupAsReader = expectGroup(
|
|
176
175
|
groupCore
|
|
177
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
176
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
178
177
|
.getCurrentContent(),
|
|
179
178
|
);
|
|
180
179
|
|
|
@@ -203,7 +202,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
203
202
|
|
|
204
203
|
const groupAsReader = expectGroup(
|
|
205
204
|
group.core
|
|
206
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
205
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
207
206
|
.getCurrentContent(),
|
|
208
207
|
);
|
|
209
208
|
|
|
@@ -267,7 +266,7 @@ test("Writers can write to an object that is owned by their group", () => {
|
|
|
267
266
|
|
|
268
267
|
const childObjectAsWriter = childObject.testWithDifferentAccount(
|
|
269
268
|
writer,
|
|
270
|
-
newRandomSessionID(writer.id),
|
|
269
|
+
Crypto.newRandomSessionID(writer.id),
|
|
271
270
|
);
|
|
272
271
|
|
|
273
272
|
const childContentAsWriter = expectMap(
|
|
@@ -289,7 +288,7 @@ test("Writers can write to an object that is owned by their group (high level)",
|
|
|
289
288
|
|
|
290
289
|
const childObjectAsWriter = expectMap(
|
|
291
290
|
childObject.core
|
|
292
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
291
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
293
292
|
.getCurrentContent(),
|
|
294
293
|
);
|
|
295
294
|
|
|
@@ -315,7 +314,7 @@ test("Readers can not write to an object that is owned by their group", () => {
|
|
|
315
314
|
|
|
316
315
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
317
316
|
reader,
|
|
318
|
-
newRandomSessionID(reader.id),
|
|
317
|
+
Crypto.newRandomSessionID(reader.id),
|
|
319
318
|
);
|
|
320
319
|
|
|
321
320
|
const childContentAsReader = expectMap(
|
|
@@ -337,7 +336,7 @@ test("Readers can not write to an object that is owned by their group (high leve
|
|
|
337
336
|
|
|
338
337
|
const childObjectAsReader = expectMap(
|
|
339
338
|
childObject.core
|
|
340
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
339
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
341
340
|
.getCurrentContent(),
|
|
342
341
|
);
|
|
343
342
|
|
|
@@ -442,7 +441,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
442
441
|
|
|
443
442
|
const childObjectAsWriter = childObject.testWithDifferentAccount(
|
|
444
443
|
writer,
|
|
445
|
-
newRandomSessionID(writer.id),
|
|
444
|
+
Crypto.newRandomSessionID(writer.id),
|
|
446
445
|
);
|
|
447
446
|
|
|
448
447
|
expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -466,7 +465,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
466
465
|
|
|
467
466
|
const childObjectAsWriter = expectMap(
|
|
468
467
|
childObject.core
|
|
469
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
468
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
470
469
|
.getCurrentContent(),
|
|
471
470
|
);
|
|
472
471
|
|
|
@@ -526,7 +525,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
526
525
|
|
|
527
526
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
528
527
|
reader,
|
|
529
|
-
newRandomSessionID(reader.id),
|
|
528
|
+
Crypto.newRandomSessionID(reader.id),
|
|
530
529
|
);
|
|
531
530
|
|
|
532
531
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -552,7 +551,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
552
551
|
|
|
553
552
|
const childContentAsReader = expectMap(
|
|
554
553
|
childObject.core
|
|
555
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
554
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
556
555
|
.getCurrentContent(),
|
|
557
556
|
);
|
|
558
557
|
|
|
@@ -613,7 +612,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
613
612
|
|
|
614
613
|
const childObjectAsReader1 = childObject.testWithDifferentAccount(
|
|
615
614
|
reader1,
|
|
616
|
-
newRandomSessionID(reader1.id),
|
|
615
|
+
Crypto.newRandomSessionID(reader1.id),
|
|
617
616
|
);
|
|
618
617
|
|
|
619
618
|
expect(childObjectAsReader1.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -638,7 +637,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
638
637
|
|
|
639
638
|
const childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
640
639
|
reader2,
|
|
641
|
-
newRandomSessionID(reader2.id),
|
|
640
|
+
Crypto.newRandomSessionID(reader2.id),
|
|
642
641
|
);
|
|
643
642
|
|
|
644
643
|
expect(childObjectAsReader2.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -666,7 +665,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
666
665
|
|
|
667
666
|
const childContentAsReader1 = expectMap(
|
|
668
667
|
childObject.core
|
|
669
|
-
.testWithDifferentAccount(reader1, newRandomSessionID(reader1.id))
|
|
668
|
+
.testWithDifferentAccount(reader1, Crypto.newRandomSessionID(reader1.id))
|
|
670
669
|
.getCurrentContent(),
|
|
671
670
|
);
|
|
672
671
|
|
|
@@ -676,7 +675,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
676
675
|
|
|
677
676
|
const childContentAsReader2 = expectMap(
|
|
678
677
|
childObject.core
|
|
679
|
-
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
678
|
+
.testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id))
|
|
680
679
|
.getCurrentContent(),
|
|
681
680
|
);
|
|
682
681
|
|
|
@@ -845,7 +844,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
845
844
|
|
|
846
845
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
847
846
|
reader,
|
|
848
|
-
newRandomSessionID(reader.id),
|
|
847
|
+
Crypto.newRandomSessionID(reader.id),
|
|
849
848
|
);
|
|
850
849
|
|
|
851
850
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey2);
|
|
@@ -883,7 +882,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
883
882
|
|
|
884
883
|
const childContentAsReader = expectMap(
|
|
885
884
|
childObject.core
|
|
886
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
885
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
887
886
|
.getCurrentContent(),
|
|
888
887
|
);
|
|
889
888
|
|
|
@@ -959,7 +958,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
959
958
|
|
|
960
959
|
let childObjectAsReader = childObject.testWithDifferentAccount(
|
|
961
960
|
reader,
|
|
962
|
-
newRandomSessionID(reader.id),
|
|
961
|
+
Crypto.newRandomSessionID(reader.id),
|
|
963
962
|
);
|
|
964
963
|
|
|
965
964
|
expect(
|
|
@@ -968,7 +967,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
968
967
|
|
|
969
968
|
let childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
970
969
|
reader,
|
|
971
|
-
newRandomSessionID(reader.id),
|
|
970
|
+
Crypto.newRandomSessionID(reader.id),
|
|
972
971
|
);
|
|
973
972
|
|
|
974
973
|
expect(
|
|
@@ -1024,11 +1023,11 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1024
1023
|
// TODO: make sure these instances of coValues sync between each other so this isn't necessary?
|
|
1025
1024
|
childObjectAsReader = childObject.testWithDifferentAccount(
|
|
1026
1025
|
reader,
|
|
1027
|
-
newRandomSessionID(reader.id),
|
|
1026
|
+
Crypto.newRandomSessionID(reader.id),
|
|
1028
1027
|
);
|
|
1029
1028
|
childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
1030
1029
|
reader2,
|
|
1031
|
-
newRandomSessionID(reader2.id),
|
|
1030
|
+
Crypto.newRandomSessionID(reader2.id),
|
|
1032
1031
|
);
|
|
1033
1032
|
|
|
1034
1033
|
expect(
|
|
@@ -1072,7 +1071,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1072
1071
|
|
|
1073
1072
|
const childContentAsReader2 = expectMap(
|
|
1074
1073
|
childObject.core
|
|
1075
|
-
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
1074
|
+
.testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id))
|
|
1076
1075
|
.getCurrentContent(),
|
|
1077
1076
|
);
|
|
1078
1077
|
|
|
@@ -1083,7 +1082,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1083
1082
|
expect(
|
|
1084
1083
|
expectMap(
|
|
1085
1084
|
childObject.core
|
|
1086
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
1085
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
1087
1086
|
.getCurrentContent(),
|
|
1088
1087
|
).get("foo3"),
|
|
1089
1088
|
).toBeUndefined();
|
|
@@ -1151,7 +1150,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1151
1150
|
groupCore
|
|
1152
1151
|
.testWithDifferentAccount(
|
|
1153
1152
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1154
|
-
newRandomSessionID(inviteID),
|
|
1153
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1155
1154
|
)
|
|
1156
1155
|
.getCurrentContent(),
|
|
1157
1156
|
);
|
|
@@ -1198,7 +1197,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
1198
1197
|
|
|
1199
1198
|
const nodeAsInvitedAdmin = node.testWithDifferentAccount(
|
|
1200
1199
|
new ControlledAgent(invitedAdminSecret, Crypto),
|
|
1201
|
-
newRandomSessionID(invitedAdminID),
|
|
1200
|
+
Crypto.newRandomSessionID(invitedAdminID),
|
|
1202
1201
|
);
|
|
1203
1202
|
|
|
1204
1203
|
await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
|
|
@@ -1261,7 +1260,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1261
1260
|
groupCore
|
|
1262
1261
|
.testWithDifferentAccount(
|
|
1263
1262
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1264
|
-
newRandomSessionID(inviteID),
|
|
1263
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1265
1264
|
)
|
|
1266
1265
|
.getCurrentContent(),
|
|
1267
1266
|
);
|
|
@@ -1308,7 +1307,7 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
|
|
|
1308
1307
|
|
|
1309
1308
|
const nodeAsInvitedWriter = node.testWithDifferentAccount(
|
|
1310
1309
|
new ControlledAgent(invitedWriterSecret, Crypto),
|
|
1311
|
-
newRandomSessionID(invitedWriterID),
|
|
1310
|
+
Crypto.newRandomSessionID(invitedWriterID),
|
|
1312
1311
|
);
|
|
1313
1312
|
|
|
1314
1313
|
await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
|
|
@@ -1364,7 +1363,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1364
1363
|
groupCore
|
|
1365
1364
|
.testWithDifferentAccount(
|
|
1366
1365
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1367
|
-
newRandomSessionID(inviteID),
|
|
1366
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1368
1367
|
)
|
|
1369
1368
|
.getCurrentContent(),
|
|
1370
1369
|
);
|
|
@@ -1401,7 +1400,7 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
|
|
|
1401
1400
|
|
|
1402
1401
|
const nodeAsInvitedReader = node.testWithDifferentAccount(
|
|
1403
1402
|
new ControlledAgent(invitedReaderSecret, Crypto),
|
|
1404
|
-
newRandomSessionID(invitedReaderID),
|
|
1403
|
+
Crypto.newRandomSessionID(invitedReaderID),
|
|
1405
1404
|
);
|
|
1406
1405
|
|
|
1407
1406
|
await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
|
|
@@ -1457,7 +1456,7 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1457
1456
|
groupCore
|
|
1458
1457
|
.testWithDifferentAccount(
|
|
1459
1458
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1460
|
-
newRandomSessionID(inviteID),
|
|
1459
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1461
1460
|
)
|
|
1462
1461
|
.getCurrentContent(),
|
|
1463
1462
|
);
|
|
@@ -1511,7 +1510,7 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1511
1510
|
groupCore
|
|
1512
1511
|
.testWithDifferentAccount(
|
|
1513
1512
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1514
|
-
newRandomSessionID(inviteID),
|
|
1513
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1515
1514
|
)
|
|
1516
1515
|
.getCurrentContent(),
|
|
1517
1516
|
);
|
|
@@ -1565,7 +1564,7 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1565
1564
|
groupCore
|
|
1566
1565
|
.testWithDifferentAccount(
|
|
1567
1566
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1568
|
-
newRandomSessionID(inviteID),
|
|
1567
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1569
1568
|
)
|
|
1570
1569
|
.getCurrentContent(),
|
|
1571
1570
|
);
|
|
@@ -1610,7 +1609,7 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
1610
1609
|
childObject
|
|
1611
1610
|
.testWithDifferentAccount(
|
|
1612
1611
|
newAccount,
|
|
1613
|
-
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1612
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1614
1613
|
)
|
|
1615
1614
|
.getCurrentContent(),
|
|
1616
1615
|
);
|
|
@@ -1639,7 +1638,7 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
|
|
|
1639
1638
|
childObject.core
|
|
1640
1639
|
.testWithDifferentAccount(
|
|
1641
1640
|
new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto),
|
|
1642
|
-
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1641
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1643
1642
|
)
|
|
1644
1643
|
.getCurrentContent(),
|
|
1645
1644
|
);
|
|
@@ -1680,7 +1679,7 @@ test("Can give write permission to 'everyone'", async () => {
|
|
|
1680
1679
|
childObject
|
|
1681
1680
|
.testWithDifferentAccount(
|
|
1682
1681
|
newAccount,
|
|
1683
|
-
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1682
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1684
1683
|
)
|
|
1685
1684
|
.getCurrentContent(),
|
|
1686
1685
|
);
|
|
@@ -1715,7 +1714,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
1715
1714
|
childObject.core
|
|
1716
1715
|
.testWithDifferentAccount(
|
|
1717
1716
|
newAccount,
|
|
1718
|
-
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1717
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
|
|
1719
1718
|
)
|
|
1720
1719
|
.getCurrentContent(),
|
|
1721
1720
|
);
|
package/src/tests/sync.test.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { MapOpPayload, RawCoMap } from "../coValues/coMap.js";
|
|
|
5
5
|
import { RawGroup } from "../coValues/group.js";
|
|
6
6
|
import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
|
|
7
7
|
import { connectedPeers, newQueuePair } from "../streamUtils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { RawAccountID } from "../coValues/account.js";
|
|
9
9
|
import { stableStringify } from "../jsonStringify.js";
|
|
10
10
|
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
11
11
|
import { expectMap } from "../coValue.js";
|
|
12
|
-
import { CoValueHeader
|
|
12
|
+
import { CoValueHeader } from "../coValueCore.js";
|
|
13
13
|
import { getPriorityFromHeader } from "../priority.js";
|
|
14
14
|
|
|
15
15
|
const Crypto = await WasmCrypto.create();
|
|
@@ -726,7 +726,7 @@ test.skip("When replaying creation and transactions of a coValue as new content,
|
|
|
726
726
|
crashOnClose: true,
|
|
727
727
|
});
|
|
728
728
|
|
|
729
|
-
const node2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
729
|
+
const node2 = new LocalNode(admin, Crypto.newRandomSessionID(admin.id), Crypto);
|
|
730
730
|
|
|
731
731
|
const [inRx2, inTx2] = newQueuePair();
|
|
732
732
|
const [outRx2, outTx2] = newQueuePair();
|
|
@@ -878,7 +878,7 @@ test("Can sync a coValue through a server to another client", async () => {
|
|
|
878
878
|
client1.syncManager.addPeer(serverAsPeerForClient1);
|
|
879
879
|
server.syncManager.addPeer(client1AsPeer);
|
|
880
880
|
|
|
881
|
-
const client2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
881
|
+
const client2 = new LocalNode(admin, Crypto.newRandomSessionID(admin.id), Crypto);
|
|
882
882
|
|
|
883
883
|
const [serverAsPeerForClient2, client2AsPeer] = connectedPeers(
|
|
884
884
|
"serverFor2",
|
|
@@ -926,7 +926,7 @@ test("Can sync a coValue with private transactions through a server to another c
|
|
|
926
926
|
client1.syncManager.addPeer(serverAsPeer);
|
|
927
927
|
server.syncManager.addPeer(client1AsPeer);
|
|
928
928
|
|
|
929
|
-
const client2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
929
|
+
const client2 = new LocalNode(admin, client1.crypto.newRandomSessionID(admin.id), Crypto);
|
|
930
930
|
|
|
931
931
|
const [serverAsOtherPeer, client2AsPeer] = connectedPeers(
|
|
932
932
|
"server",
|
|
@@ -1074,7 +1074,7 @@ test("If we start loading a coValue before connecting to a peer that has it, it
|
|
|
1074
1074
|
const map = group.createMap();
|
|
1075
1075
|
map.set("hello", "world", "trusting");
|
|
1076
1076
|
|
|
1077
|
-
const node2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
1077
|
+
const node2 = new LocalNode(admin, Crypto.newRandomSessionID(admin.id), Crypto);
|
|
1078
1078
|
|
|
1079
1079
|
const [node1asPeer, node2asPeer] = connectedPeers("peer1", "peer2", {
|
|
1080
1080
|
peer1role: "server",
|
|
@@ -1559,7 +1559,7 @@ function groupContentEx(group: RawGroup) {
|
|
|
1559
1559
|
};
|
|
1560
1560
|
}
|
|
1561
1561
|
|
|
1562
|
-
function _admContEx(adminID:
|
|
1562
|
+
function _admContEx(adminID: RawAccountID) {
|
|
1563
1563
|
return {
|
|
1564
1564
|
action: "content",
|
|
1565
1565
|
id: adminID,
|
|
@@ -1573,7 +1573,7 @@ function groupStateEx(group: RawGroup) {
|
|
|
1573
1573
|
};
|
|
1574
1574
|
}
|
|
1575
1575
|
|
|
1576
|
-
function _admStateEx(adminID:
|
|
1576
|
+
function _admStateEx(adminID: RawAccountID) {
|
|
1577
1577
|
return {
|
|
1578
1578
|
action: "known",
|
|
1579
1579
|
id: adminID,
|
package/src/tests/testUtils.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect } from "vitest";
|
|
2
|
-
import { newRandomSessionID } from "../coValueCore.js";
|
|
3
2
|
import { LocalNode } from "../localNode.js";
|
|
4
3
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
5
4
|
import { ControlledAgent } from "../coValues/account.js";
|
|
@@ -14,7 +13,7 @@ export function randomAnonymousAccountAndSessionID(): [
|
|
|
14
13
|
] {
|
|
15
14
|
const agentSecret = Crypto.newRandomAgentSecret();
|
|
16
15
|
|
|
17
|
-
const sessionID = newRandomSessionID(Crypto.getAgentID(agentSecret));
|
|
16
|
+
const sessionID = Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret));
|
|
18
17
|
|
|
19
18
|
return [new ControlledAgent(agentSecret, Crypto), sessionID];
|
|
20
19
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AgentID, SessionID } from "../ids.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RawAccountID } from "../coValues/account.js";
|
|
3
3
|
|
|
4
4
|
export function accountOrAgentIDfromSessionID(
|
|
5
5
|
sessionID: SessionID,
|
|
6
|
-
):
|
|
6
|
+
): RawAccountID | AgentID {
|
|
7
7
|
const until = sessionID.indexOf("_session");
|
|
8
|
-
return sessionID.slice(0, until) as
|
|
8
|
+
return sessionID.slice(0, until) as RawAccountID | AgentID;
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawAccountID } from "../coValues/account.js";
|
|
2
2
|
import type { AgentID } from "../ids.js";
|
|
3
3
|
|
|
4
|
-
export function isAccountID(id:
|
|
4
|
+
export function isAccountID(id: RawAccountID | AgentID): id is RawAccountID {
|
|
5
5
|
return id.startsWith("co_");
|
|
6
6
|
}
|