cojson 0.1.8 → 0.1.10
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/dist/account.d.ts +6 -3
- package/dist/account.js +4 -2
- package/dist/account.js.map +1 -1
- package/dist/coValue.d.ts +44 -80
- package/dist/coValue.js +4 -348
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore.d.ts +84 -0
- package/dist/coValueCore.js +356 -0
- package/dist/coValueCore.js.map +1 -0
- package/dist/coValues/coList.d.ts +114 -0
- package/dist/{contentTypes → coValues}/coList.js +59 -19
- package/dist/coValues/coList.js.map +1 -0
- package/dist/{contentTypes → coValues}/coMap.d.ts +25 -7
- package/dist/{contentTypes → coValues}/coMap.js +34 -15
- package/dist/coValues/coMap.js.map +1 -0
- package/dist/coValues/coStream.d.ts +69 -0
- package/dist/coValues/coStream.js +131 -0
- package/dist/coValues/coStream.js.map +1 -0
- package/dist/coValues/static.d.ts +14 -0
- package/dist/coValues/static.js +20 -0
- package/dist/coValues/static.js.map +1 -0
- package/dist/group.d.ts +57 -9
- package/dist/group.js +94 -28
- package/dist/group.js.map +1 -1
- package/dist/index.d.ts +19 -10
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +59 -5
- package/dist/node.js +36 -15
- package/dist/node.js.map +1 -1
- package/dist/permissions.d.ts +2 -2
- package/dist/permissions.js +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/sync.d.ts +3 -3
- package/dist/sync.js +2 -2
- package/dist/sync.js.map +1 -1
- package/dist/testUtils.d.ts +2 -2
- package/dist/testUtils.js +1 -1
- package/dist/testUtils.js.map +1 -1
- package/package.json +2 -2
- package/src/account.test.ts +1 -1
- package/src/account.ts +8 -5
- package/src/coValue.test.ts +335 -129
- package/src/coValue.ts +52 -576
- package/src/coValueCore.test.ts +180 -0
- package/src/coValueCore.ts +592 -0
- package/src/{contentTypes → coValues}/coList.ts +91 -42
- package/src/{contentTypes → coValues}/coMap.ts +40 -20
- package/src/coValues/coStream.ts +249 -0
- package/src/coValues/static.ts +31 -0
- package/src/group.test.ts +47 -0
- package/src/group.ts +120 -50
- package/src/index.ts +43 -28
- package/src/node.ts +48 -27
- package/src/permissions.test.ts +32 -32
- package/src/permissions.ts +5 -5
- package/src/sync.test.ts +77 -77
- package/src/sync.ts +5 -5
- package/src/testUtils.ts +1 -1
- package/tsconfig.json +1 -2
- package/dist/contentType.d.ts +0 -15
- package/dist/contentType.js +0 -7
- package/dist/contentType.js.map +0 -1
- package/dist/contentTypes/coList.d.ts +0 -77
- package/dist/contentTypes/coList.js.map +0 -1
- package/dist/contentTypes/coMap.js.map +0 -1
- package/dist/contentTypes/coStream.d.ts +0 -11
- package/dist/contentTypes/coStream.js +0 -16
- package/dist/contentTypes/coStream.js.map +0 -1
- package/dist/contentTypes/static.d.ts +0 -11
- package/dist/contentTypes/static.js +0 -14
- package/dist/contentTypes/static.js.map +0 -1
- package/src/contentType.test.ts +0 -284
- package/src/contentType.ts +0 -26
- package/src/contentTypes/coStream.ts +0 -24
- package/src/contentTypes/static.ts +0 -22
package/src/permissions.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { newRandomSessionID } from "./
|
|
2
|
-
import { expectMap } from "./
|
|
1
|
+
import { newRandomSessionID } from "./coValueCore.js";
|
|
2
|
+
import { expectMap } from "./coValue.js";
|
|
3
3
|
import { Group, expectGroupContent } from "./group.js";
|
|
4
4
|
import {
|
|
5
5
|
createdNowUnique,
|
|
@@ -63,7 +63,7 @@ test("Added adming can add a third admin to a group (high level)", () => {
|
|
|
63
63
|
|
|
64
64
|
groupAsOtherAdmin.addMember(thirdAdmin.id, "admin");
|
|
65
65
|
|
|
66
|
-
expect(groupAsOtherAdmin.
|
|
66
|
+
expect(groupAsOtherAdmin.underlyingMap.get(thirdAdmin.id)).toEqual("admin");
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
test("Admins can't demote other admins in a group", () => {
|
|
@@ -112,7 +112,7 @@ test("Admins can't demote other admins in a group (high level)", () => {
|
|
|
112
112
|
"Failed to set role"
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
expect(groupAsOtherAdmin.
|
|
115
|
+
expect(groupAsOtherAdmin.underlyingMap.get(admin.id)).toEqual("admin");
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
test("Admins an add writers to a group, who can't add admins, writers, or readers", () => {
|
|
@@ -164,14 +164,14 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
164
164
|
const writer = node.createAccount("writer");
|
|
165
165
|
|
|
166
166
|
group.addMember(writer.id, "writer");
|
|
167
|
-
expect(group.
|
|
167
|
+
expect(group.underlyingMap.get(writer.id)).toEqual("writer");
|
|
168
168
|
|
|
169
169
|
const groupAsWriter = group.testWithDifferentAccount(
|
|
170
170
|
writer,
|
|
171
171
|
newRandomSessionID(writer.id)
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
-
expect(groupAsWriter.
|
|
174
|
+
expect(groupAsWriter.underlyingMap.get(writer.id)).toEqual("writer");
|
|
175
175
|
|
|
176
176
|
const otherAgent = node.createAccount("otherAgent");
|
|
177
177
|
|
|
@@ -185,7 +185,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
185
185
|
"Failed to set role"
|
|
186
186
|
);
|
|
187
187
|
|
|
188
|
-
expect(groupAsWriter.
|
|
188
|
+
expect(groupAsWriter.underlyingMap.get(otherAgent.id)).toBeUndefined();
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
test("Admins can add readers to a group, who can't add admins, writers, or readers", () => {
|
|
@@ -237,14 +237,14 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
237
237
|
const reader = node.createAccount("reader");
|
|
238
238
|
|
|
239
239
|
group.addMember(reader.id, "reader");
|
|
240
|
-
expect(group.
|
|
240
|
+
expect(group.underlyingMap.get(reader.id)).toEqual("reader");
|
|
241
241
|
|
|
242
242
|
const groupAsReader = group.testWithDifferentAccount(
|
|
243
243
|
reader,
|
|
244
244
|
newRandomSessionID(reader.id)
|
|
245
245
|
);
|
|
246
246
|
|
|
247
|
-
expect(groupAsReader.
|
|
247
|
+
expect(groupAsReader.underlyingMap.get(reader.id)).toEqual("reader");
|
|
248
248
|
|
|
249
249
|
const otherAgent = node.createAccount("otherAgent");
|
|
250
250
|
|
|
@@ -258,7 +258,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
258
258
|
"Failed to set role"
|
|
259
259
|
);
|
|
260
260
|
|
|
261
|
-
expect(groupAsReader.
|
|
261
|
+
expect(groupAsReader.underlyingMap.get(otherAgent.id)).toBeUndefined();
|
|
262
262
|
});
|
|
263
263
|
|
|
264
264
|
test("Admins can write to an object that is owned by their group", () => {
|
|
@@ -342,7 +342,7 @@ test("Writers can write to an object that is owned by their group (high level)",
|
|
|
342
342
|
const childObject = group.createMap();
|
|
343
343
|
|
|
344
344
|
let childObjectAsWriter = expectMap(
|
|
345
|
-
childObject.
|
|
345
|
+
childObject.core
|
|
346
346
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
347
347
|
.getCurrentContent()
|
|
348
348
|
);
|
|
@@ -401,7 +401,7 @@ test("Readers can not write to an object that is owned by their group (high leve
|
|
|
401
401
|
const childObject = group.createMap();
|
|
402
402
|
|
|
403
403
|
let childObjectAsReader = expectMap(
|
|
404
|
-
childObject.
|
|
404
|
+
childObject.core
|
|
405
405
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
406
406
|
.getCurrentContent()
|
|
407
407
|
);
|
|
@@ -553,7 +553,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
553
553
|
const childObject = group.createMap();
|
|
554
554
|
|
|
555
555
|
let childObjectAsWriter = expectMap(
|
|
556
|
-
childObject.
|
|
556
|
+
childObject.core
|
|
557
557
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
558
558
|
.getCurrentContent()
|
|
559
559
|
);
|
|
@@ -647,7 +647,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
647
647
|
});
|
|
648
648
|
|
|
649
649
|
const childContentAsReader = expectMap(
|
|
650
|
-
childObject.
|
|
650
|
+
childObject.core
|
|
651
651
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
652
652
|
.getCurrentContent()
|
|
653
653
|
);
|
|
@@ -767,7 +767,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
767
767
|
});
|
|
768
768
|
|
|
769
769
|
const childContentAsReader1 = expectMap(
|
|
770
|
-
childObject.
|
|
770
|
+
childObject.core
|
|
771
771
|
.testWithDifferentAccount(reader1, newRandomSessionID(reader1.id))
|
|
772
772
|
.getCurrentContent()
|
|
773
773
|
);
|
|
@@ -777,7 +777,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
777
777
|
group.addMember(reader2.id, "reader");
|
|
778
778
|
|
|
779
779
|
const childContentAsReader2 = expectMap(
|
|
780
|
-
childObject.
|
|
780
|
+
childObject.core
|
|
781
781
|
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
782
782
|
.getCurrentContent()
|
|
783
783
|
);
|
|
@@ -863,7 +863,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
863
863
|
|
|
864
864
|
let childObject = group.createMap();
|
|
865
865
|
|
|
866
|
-
const firstReadKey = childObject.
|
|
866
|
+
const firstReadKey = childObject.core.getCurrentReadKey();
|
|
867
867
|
|
|
868
868
|
childObject = childObject.edit((editable) => {
|
|
869
869
|
editable.set("foo", "bar", "private");
|
|
@@ -874,7 +874,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
874
874
|
|
|
875
875
|
group.rotateReadKey();
|
|
876
876
|
|
|
877
|
-
expect(childObject.
|
|
877
|
+
expect(childObject.core.getCurrentReadKey()).not.toEqual(firstReadKey);
|
|
878
878
|
|
|
879
879
|
childObject = childObject.edit((editable) => {
|
|
880
880
|
editable.set("foo2", "bar2", "private");
|
|
@@ -998,7 +998,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
998
998
|
|
|
999
999
|
let childObject = group.createMap();
|
|
1000
1000
|
|
|
1001
|
-
const firstReadKey = childObject.
|
|
1001
|
+
const firstReadKey = childObject.core.getCurrentReadKey();
|
|
1002
1002
|
|
|
1003
1003
|
childObject = childObject.edit((editable) => {
|
|
1004
1004
|
editable.set("foo", "bar", "private");
|
|
@@ -1009,7 +1009,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
1009
1009
|
|
|
1010
1010
|
group.rotateReadKey();
|
|
1011
1011
|
|
|
1012
|
-
expect(childObject.
|
|
1012
|
+
expect(childObject.core.getCurrentReadKey()).not.toEqual(firstReadKey);
|
|
1013
1013
|
|
|
1014
1014
|
const reader = node.createAccount("reader");
|
|
1015
1015
|
|
|
@@ -1021,7 +1021,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
1021
1021
|
});
|
|
1022
1022
|
|
|
1023
1023
|
const childContentAsReader = expectMap(
|
|
1024
|
-
childObject.
|
|
1024
|
+
childObject.core
|
|
1025
1025
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
1026
1026
|
.getCurrentContent()
|
|
1027
1027
|
);
|
|
@@ -1204,7 +1204,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1204
1204
|
|
|
1205
1205
|
group.rotateReadKey();
|
|
1206
1206
|
|
|
1207
|
-
const secondReadKey = childObject.
|
|
1207
|
+
const secondReadKey = childObject.core.getCurrentReadKey();
|
|
1208
1208
|
|
|
1209
1209
|
const reader = node.createAccount("reader");
|
|
1210
1210
|
|
|
@@ -1223,7 +1223,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1223
1223
|
|
|
1224
1224
|
group.removeMember(reader.id);
|
|
1225
1225
|
|
|
1226
|
-
expect(childObject.
|
|
1226
|
+
expect(childObject.core.getCurrentReadKey()).not.toEqual(secondReadKey);
|
|
1227
1227
|
|
|
1228
1228
|
childObject = childObject.edit((editable) => {
|
|
1229
1229
|
editable.set("foo3", "bar3", "private");
|
|
@@ -1231,7 +1231,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1231
1231
|
});
|
|
1232
1232
|
|
|
1233
1233
|
const childContentAsReader2 = expectMap(
|
|
1234
|
-
childObject.
|
|
1234
|
+
childObject.core
|
|
1235
1235
|
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
1236
1236
|
.getCurrentContent()
|
|
1237
1237
|
);
|
|
@@ -1242,7 +1242,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1242
1242
|
|
|
1243
1243
|
expect(
|
|
1244
1244
|
expectMap(
|
|
1245
|
-
childObject.
|
|
1245
|
+
childObject.core
|
|
1246
1246
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
1247
1247
|
.getCurrentContent()
|
|
1248
1248
|
).get("foo3")
|
|
@@ -1373,14 +1373,14 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
1373
1373
|
nodeAsInvitedAdmin
|
|
1374
1374
|
);
|
|
1375
1375
|
|
|
1376
|
-
expect(groupAsInvitedAdmin.
|
|
1376
|
+
expect(groupAsInvitedAdmin.underlyingMap.get(invitedAdminID)).toEqual("admin");
|
|
1377
1377
|
expect(
|
|
1378
|
-
groupAsInvitedAdmin.
|
|
1378
|
+
groupAsInvitedAdmin.underlyingMap.core.getCurrentReadKey().secret
|
|
1379
1379
|
).toBeDefined();
|
|
1380
1380
|
|
|
1381
1381
|
groupAsInvitedAdmin.addMemberInternal(thirdAdminID, "admin");
|
|
1382
1382
|
|
|
1383
|
-
expect(groupAsInvitedAdmin.
|
|
1383
|
+
expect(groupAsInvitedAdmin.underlyingMap.get(thirdAdminID)).toEqual("admin");
|
|
1384
1384
|
});
|
|
1385
1385
|
|
|
1386
1386
|
test("Admins can create a writerInvite, which can add a writer", () => {
|
|
@@ -1484,9 +1484,9 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
|
|
|
1484
1484
|
nodeAsInvitedWriter
|
|
1485
1485
|
);
|
|
1486
1486
|
|
|
1487
|
-
expect(groupAsInvitedWriter.
|
|
1487
|
+
expect(groupAsInvitedWriter.underlyingMap.get(invitedWriterID)).toEqual("writer");
|
|
1488
1488
|
expect(
|
|
1489
|
-
groupAsInvitedWriter.
|
|
1489
|
+
groupAsInvitedWriter.underlyingMap.core.getCurrentReadKey().secret
|
|
1490
1490
|
).toBeDefined();
|
|
1491
1491
|
});
|
|
1492
1492
|
|
|
@@ -1592,9 +1592,9 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
|
|
|
1592
1592
|
nodeAsInvitedReader
|
|
1593
1593
|
);
|
|
1594
1594
|
|
|
1595
|
-
expect(groupAsInvitedReader.
|
|
1595
|
+
expect(groupAsInvitedReader.underlyingMap.get(invitedReaderID)).toEqual("reader");
|
|
1596
1596
|
expect(
|
|
1597
|
-
groupAsInvitedReader.
|
|
1597
|
+
groupAsInvitedReader.underlyingMap.core.getCurrentReadKey().secret
|
|
1598
1598
|
).toBeDefined();
|
|
1599
1599
|
});
|
|
1600
1600
|
|
package/src/permissions.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { CoID } from "./
|
|
2
|
-
import { MapOpPayload } from "./
|
|
1
|
+
import { CoID } from "./coValue.js";
|
|
2
|
+
import { MapOpPayload } from "./coValues/coMap.js";
|
|
3
3
|
import { JsonValue } from "./jsonValue.js";
|
|
4
4
|
import {
|
|
5
5
|
KeyID,
|
|
6
6
|
} from "./crypto.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
CoValueCore,
|
|
9
9
|
Transaction,
|
|
10
10
|
TrustingTransaction,
|
|
11
11
|
accountOrAgentIDfromSessionID,
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./coValueCore.js";
|
|
13
13
|
import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
|
|
14
14
|
import {
|
|
15
15
|
AccountID,
|
|
@@ -31,7 +31,7 @@ export type Role =
|
|
|
31
31
|
| "readerInvite";
|
|
32
32
|
|
|
33
33
|
export function determineValidTransactions(
|
|
34
|
-
coValue:
|
|
34
|
+
coValue: CoValueCore
|
|
35
35
|
): { txID: TransactionID; tx: Transaction }[] {
|
|
36
36
|
if (coValue.header.ruleset.type === "group") {
|
|
37
37
|
const allTrustingTransactionsSorted = Object.entries(
|