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
package/dist/permissions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAE7F,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAE7F,OAAO,EAAE,UAAU,EAA4B,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAY,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAgBzD,MAAM,UAAU,0BAA0B,CACtC,OAAoB;IAEpB,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1C,MAAM,qBAAqB,GAAG;YAC1B,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE;SACnC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE;YAClC,OAAO,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;gBACjD,SAAS;gBACT,OAAO;gBACP,EAAE;aACL,CAAC,CAIC,CAAC;QACR,CAAC,CAAC,CAAC;QAEH,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAChC,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,MAA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,CAAC,CAAC;QAC3D,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,CAC/B,CAAC;AACN,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
|
-
import { newRandomSessionID } from "../coValueCore.js";
|
|
3
2
|
import { LocalNode } from "../localNode.js";
|
|
4
3
|
import { connectedPeers } from "../streamUtils.js";
|
|
5
4
|
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
@@ -47,7 +46,7 @@ test("Can create account with one node, and then load it on another", async () =
|
|
|
47
46
|
const node2 = await LocalNode.withLoadedAccount({
|
|
48
47
|
accountID,
|
|
49
48
|
accountSecret,
|
|
50
|
-
sessionID: newRandomSessionID(accountID),
|
|
49
|
+
sessionID: Crypto.newRandomSessionID(accountID),
|
|
51
50
|
peersToLoadFrom: [node1asPeer],
|
|
52
51
|
crypto: Crypto,
|
|
53
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.test.js","sourceRoot":"","sources":["../../src/tests/account.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"account.test.js","sourceRoot":"","sources":["../../src/tests/account.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;AAEzC,IAAI,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;IAC3E,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,GAC/C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AAK,aAAa;QAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE/D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
|
|
@@ -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 { newGroup, newGroupHighLevel, groupWithTwoAdmins, groupWithTwoAdminsHighLevel, } from "./testUtils.js";
|
|
5
4
|
import { ControlledAgent, WasmCrypto } from "../index.js";
|
|
@@ -14,7 +13,7 @@ test("Initial admin can add another admin to a group (high level)", () => {
|
|
|
14
13
|
test("Added admin can add a third admin to a group", () => {
|
|
15
14
|
const { groupCore, otherAdmin, node } = groupWithTwoAdmins();
|
|
16
15
|
const groupAsOtherAdmin = expectGroup(groupCore
|
|
17
|
-
.testWithDifferentAccount(otherAdmin, newRandomSessionID(otherAdmin.id))
|
|
16
|
+
.testWithDifferentAccount(otherAdmin, Crypto.newRandomSessionID(otherAdmin.id))
|
|
18
17
|
.getCurrentContent());
|
|
19
18
|
expect(groupAsOtherAdmin.get(otherAdmin.id)).toEqual("admin");
|
|
20
19
|
const thirdAdmin = node.createAccount();
|
|
@@ -24,7 +23,7 @@ test("Added admin can add a third admin to a group", () => {
|
|
|
24
23
|
test("Added adming can add a third admin to a group (high level)", () => {
|
|
25
24
|
const { group, otherAdmin } = groupWithTwoAdminsHighLevel();
|
|
26
25
|
const groupAsOtherAdmin = expectGroup(group.core
|
|
27
|
-
.testWithDifferentAccount(otherAdmin, newRandomSessionID(otherAdmin.id))
|
|
26
|
+
.testWithDifferentAccount(otherAdmin, Crypto.newRandomSessionID(otherAdmin.id))
|
|
28
27
|
.getCurrentContent());
|
|
29
28
|
const thirdAdmin = groupAsOtherAdmin.core.node.createAccount();
|
|
30
29
|
groupAsOtherAdmin.addMember(thirdAdmin, "admin");
|
|
@@ -37,7 +36,7 @@ test("Admins can't demote other admins in a group", () => {
|
|
|
37
36
|
expect(groupContent.get(otherAdmin.id)).toEqual("admin");
|
|
38
37
|
expect(groupContent.get(otherAdmin.id)).toEqual("admin");
|
|
39
38
|
const groupAsOtherAdmin = expectGroup(groupCore
|
|
40
|
-
.testWithDifferentAccount(otherAdmin, newRandomSessionID(otherAdmin.id))
|
|
39
|
+
.testWithDifferentAccount(otherAdmin, Crypto.newRandomSessionID(otherAdmin.id))
|
|
41
40
|
.getCurrentContent());
|
|
42
41
|
groupAsOtherAdmin.set(admin.id, "writer", "trusting");
|
|
43
42
|
expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
|
|
@@ -45,7 +44,7 @@ test("Admins can't demote other admins in a group", () => {
|
|
|
45
44
|
test("Admins can't demote other admins in a group (high level)", () => {
|
|
46
45
|
const { group, admin, otherAdmin } = groupWithTwoAdminsHighLevel();
|
|
47
46
|
const groupAsOtherAdmin = expectGroup(group.core
|
|
48
|
-
.testWithDifferentAccount(otherAdmin, newRandomSessionID(otherAdmin.id))
|
|
47
|
+
.testWithDifferentAccount(otherAdmin, Crypto.newRandomSessionID(otherAdmin.id))
|
|
49
48
|
.getCurrentContent());
|
|
50
49
|
expect(() => groupAsOtherAdmin.addMemberInternal(admin.id, "writer")).toThrow("Failed to set role");
|
|
51
50
|
expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
|
|
@@ -58,7 +57,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
58
57
|
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
59
58
|
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
60
59
|
const groupAsWriter = expectGroup(groupCore
|
|
61
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
60
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
62
61
|
.getCurrentContent());
|
|
63
62
|
expect(groupAsWriter.get(writer.id)).toEqual("writer");
|
|
64
63
|
const otherAgent = node.createAccount();
|
|
@@ -75,7 +74,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
75
74
|
group.addMember(writer, "writer");
|
|
76
75
|
expect(group.get(writer.id)).toEqual("writer");
|
|
77
76
|
const groupAsWriter = expectGroup(group.core
|
|
78
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
77
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
79
78
|
.getCurrentContent());
|
|
80
79
|
expect(groupAsWriter.get(writer.id)).toEqual("writer");
|
|
81
80
|
const otherAgent = groupAsWriter.core.node.createAccount();
|
|
@@ -91,7 +90,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
91
90
|
groupContent.set(reader.id, "reader", "trusting");
|
|
92
91
|
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
93
92
|
const groupAsReader = expectGroup(groupCore
|
|
94
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
93
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
95
94
|
.getCurrentContent());
|
|
96
95
|
expect(groupAsReader.get(reader.id)).toEqual("reader");
|
|
97
96
|
const otherAgent = node.createAccount();
|
|
@@ -108,7 +107,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
108
107
|
group.addMember(reader, "reader");
|
|
109
108
|
expect(group.get(reader.id)).toEqual("reader");
|
|
110
109
|
const groupAsReader = expectGroup(group.core
|
|
111
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
110
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
112
111
|
.getCurrentContent());
|
|
113
112
|
expect(groupAsReader.get(reader.id)).toEqual("reader");
|
|
114
113
|
const otherAgent = groupAsReader.core.node.createAccount();
|
|
@@ -147,7 +146,7 @@ test("Writers can write to an object that is owned by their group", () => {
|
|
|
147
146
|
meta: null,
|
|
148
147
|
...Crypto.createdNowUnique(),
|
|
149
148
|
});
|
|
150
|
-
const childObjectAsWriter = childObject.testWithDifferentAccount(writer, newRandomSessionID(writer.id));
|
|
149
|
+
const childObjectAsWriter = childObject.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id));
|
|
151
150
|
const childContentAsWriter = expectMap(childObjectAsWriter.getCurrentContent());
|
|
152
151
|
childContentAsWriter.set("foo", "bar", "trusting");
|
|
153
152
|
expect(childContentAsWriter.get("foo")).toEqual("bar");
|
|
@@ -158,7 +157,7 @@ test("Writers can write to an object that is owned by their group (high level)",
|
|
|
158
157
|
group.addMember(writer, "writer");
|
|
159
158
|
const childObject = group.createMap();
|
|
160
159
|
const childObjectAsWriter = expectMap(childObject.core
|
|
161
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
160
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
162
161
|
.getCurrentContent());
|
|
163
162
|
childObjectAsWriter.set("foo", "bar", "trusting");
|
|
164
163
|
expect(childObjectAsWriter.get("foo")).toEqual("bar");
|
|
@@ -175,7 +174,7 @@ test("Readers can not write to an object that is owned by their group", () => {
|
|
|
175
174
|
meta: null,
|
|
176
175
|
...Crypto.createdNowUnique(),
|
|
177
176
|
});
|
|
178
|
-
const childObjectAsReader = childObject.testWithDifferentAccount(reader, newRandomSessionID(reader.id));
|
|
177
|
+
const childObjectAsReader = childObject.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id));
|
|
179
178
|
const childContentAsReader = expectMap(childObjectAsReader.getCurrentContent());
|
|
180
179
|
childContentAsReader.set("foo", "bar", "trusting");
|
|
181
180
|
expect(childContentAsReader.get("foo")).toBeUndefined();
|
|
@@ -186,7 +185,7 @@ test("Readers can not write to an object that is owned by their group (high leve
|
|
|
186
185
|
group.addMember(reader, "reader");
|
|
187
186
|
const childObject = group.createMap();
|
|
188
187
|
const childObjectAsReader = expectMap(childObject.core
|
|
189
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
188
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
190
189
|
.getCurrentContent());
|
|
191
190
|
childObjectAsReader.set("foo", "bar", "trusting");
|
|
192
191
|
expect(childObjectAsReader.get("foo")).toBeUndefined();
|
|
@@ -259,7 +258,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
259
258
|
meta: null,
|
|
260
259
|
...Crypto.createdNowUnique(),
|
|
261
260
|
});
|
|
262
|
-
const childObjectAsWriter = childObject.testWithDifferentAccount(writer, newRandomSessionID(writer.id));
|
|
261
|
+
const childObjectAsWriter = childObject.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id));
|
|
263
262
|
expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
|
|
264
263
|
const childContentAsWriter = expectMap(childObjectAsWriter.getCurrentContent());
|
|
265
264
|
childContentAsWriter.set("foo", "bar", "private");
|
|
@@ -271,7 +270,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
271
270
|
group.addMember(writer, "writer");
|
|
272
271
|
const childObject = group.createMap();
|
|
273
272
|
const childObjectAsWriter = expectMap(childObject.core
|
|
274
|
-
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
273
|
+
.testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
|
|
275
274
|
.getCurrentContent());
|
|
276
275
|
childObjectAsWriter.set("foo", "bar", "private");
|
|
277
276
|
expect(childObjectAsWriter.get("foo")).toEqual("bar");
|
|
@@ -313,7 +312,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
313
312
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
314
313
|
childContent.set("foo", "bar", "private");
|
|
315
314
|
expect(childContent.get("foo")).toEqual("bar");
|
|
316
|
-
const childObjectAsReader = childObject.testWithDifferentAccount(reader, newRandomSessionID(reader.id));
|
|
315
|
+
const childObjectAsReader = childObject.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id));
|
|
317
316
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey);
|
|
318
317
|
const childContentAsReader = expectMap(childObjectAsReader.getCurrentContent());
|
|
319
318
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
@@ -326,7 +325,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
326
325
|
childObject.set("foo", "bar", "private");
|
|
327
326
|
expect(childObject.get("foo")).toEqual("bar");
|
|
328
327
|
const childContentAsReader = expectMap(childObject.core
|
|
329
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
328
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
330
329
|
.getCurrentContent());
|
|
331
330
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
332
331
|
});
|
|
@@ -368,7 +367,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
368
367
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
369
368
|
childContent.set("foo", "bar", "private");
|
|
370
369
|
expect(childContent.get("foo")).toEqual("bar");
|
|
371
|
-
const childObjectAsReader1 = childObject.testWithDifferentAccount(reader1, newRandomSessionID(reader1.id));
|
|
370
|
+
const childObjectAsReader1 = childObject.testWithDifferentAccount(reader1, Crypto.newRandomSessionID(reader1.id));
|
|
372
371
|
expect(childObjectAsReader1.getCurrentReadKey().secret).toEqual(readKey);
|
|
373
372
|
const childContentAsReader1 = expectMap(childObjectAsReader1.getCurrentContent());
|
|
374
373
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
@@ -382,7 +381,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
382
381
|
},
|
|
383
382
|
});
|
|
384
383
|
groupContent.set(`${readKeyID}_for_${reader2.id}`, revelation3, "trusting");
|
|
385
|
-
const childObjectAsReader2 = childObject.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id));
|
|
384
|
+
const childObjectAsReader2 = childObject.testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id));
|
|
386
385
|
expect(childObjectAsReader2.getCurrentReadKey().secret).toEqual(readKey);
|
|
387
386
|
const childContentAsReader2 = expectMap(childObjectAsReader2.getCurrentContent());
|
|
388
387
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
@@ -396,12 +395,12 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
396
395
|
childObject.set("foo", "bar", "private");
|
|
397
396
|
expect(childObject.get("foo")).toEqual("bar");
|
|
398
397
|
const childContentAsReader1 = expectMap(childObject.core
|
|
399
|
-
.testWithDifferentAccount(reader1, newRandomSessionID(reader1.id))
|
|
398
|
+
.testWithDifferentAccount(reader1, Crypto.newRandomSessionID(reader1.id))
|
|
400
399
|
.getCurrentContent());
|
|
401
400
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
402
401
|
group.addMember(reader2, "reader");
|
|
403
402
|
const childContentAsReader2 = expectMap(childObject.core
|
|
404
|
-
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
403
|
+
.testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id))
|
|
405
404
|
.getCurrentContent());
|
|
406
405
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
407
406
|
});
|
|
@@ -520,7 +519,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
520
519
|
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
521
520
|
childContent.set("foo2", "bar2", "private");
|
|
522
521
|
expect(childContent.get("foo2")).toEqual("bar2");
|
|
523
|
-
const childObjectAsReader = childObject.testWithDifferentAccount(reader, newRandomSessionID(reader.id));
|
|
522
|
+
const childObjectAsReader = childObject.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id));
|
|
524
523
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey2);
|
|
525
524
|
const childContentAsReader = expectMap(childObjectAsReader.getCurrentContent());
|
|
526
525
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
@@ -540,7 +539,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
540
539
|
childObject.set("foo2", "bar2", "private");
|
|
541
540
|
expect(childObject.get("foo2")).toEqual("bar2");
|
|
542
541
|
const childContentAsReader = expectMap(childObject.core
|
|
543
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
542
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
544
543
|
.getCurrentContent());
|
|
545
544
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
546
545
|
expect(childContentAsReader.get("foo2")).toEqual("bar2");
|
|
@@ -597,9 +596,9 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
597
596
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
598
597
|
childContent.set("foo", "bar", "private");
|
|
599
598
|
expect(childContent.get("foo")).toEqual("bar");
|
|
600
|
-
let childObjectAsReader = childObject.testWithDifferentAccount(reader, newRandomSessionID(reader.id));
|
|
599
|
+
let childObjectAsReader = childObject.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id));
|
|
601
600
|
expect(expectMap(childObjectAsReader.getCurrentContent()).get("foo")).toEqual("bar");
|
|
602
|
-
let childObjectAsReader2 = childObject.testWithDifferentAccount(reader, newRandomSessionID(reader.id));
|
|
601
|
+
let childObjectAsReader2 = childObject.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id));
|
|
603
602
|
expect(expectMap(childObjectAsReader2.getCurrentContent()).get("foo")).toEqual("bar");
|
|
604
603
|
const { secret: readKey2, id: readKeyID2 } = Crypto.newRandomKeySecret();
|
|
605
604
|
const newRevelation1 = Crypto.seal({
|
|
@@ -631,8 +630,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
631
630
|
childContent.set("foo2", "bar2", "private");
|
|
632
631
|
expect(childContent.get("foo2")).toEqual("bar2");
|
|
633
632
|
// TODO: make sure these instances of coValues sync between each other so this isn't necessary?
|
|
634
|
-
childObjectAsReader = childObject.testWithDifferentAccount(reader, newRandomSessionID(reader.id));
|
|
635
|
-
childObjectAsReader2 = childObject.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id));
|
|
633
|
+
childObjectAsReader = childObject.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id));
|
|
634
|
+
childObjectAsReader2 = childObject.testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id));
|
|
636
635
|
expect(expectMap(childObjectAsReader.getCurrentContent()).get("foo2")).toBeUndefined();
|
|
637
636
|
expect(expectMap(childObjectAsReader2.getCurrentContent()).get("foo2")).toEqual("bar2");
|
|
638
637
|
});
|
|
@@ -655,13 +654,13 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
655
654
|
childObject.set("foo3", "bar3", "private");
|
|
656
655
|
expect(childObject.get("foo3")).toEqual("bar3");
|
|
657
656
|
const childContentAsReader2 = expectMap(childObject.core
|
|
658
|
-
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
657
|
+
.testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id))
|
|
659
658
|
.getCurrentContent());
|
|
660
659
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
661
660
|
expect(childContentAsReader2.get("foo2")).toEqual("bar2");
|
|
662
661
|
expect(childContentAsReader2.get("foo3")).toEqual("bar3");
|
|
663
662
|
expect(expectMap(childObject.core
|
|
664
|
-
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
663
|
+
.testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
|
|
665
664
|
.getCurrentContent()).get("foo3")).toBeUndefined();
|
|
666
665
|
});
|
|
667
666
|
test("Can create two owned objects in the same group and they will have different ids", () => {
|
|
@@ -710,7 +709,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
710
709
|
});
|
|
711
710
|
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
712
711
|
const groupAsInvite = expectGroup(groupCore
|
|
713
|
-
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), newRandomSessionID(inviteID))
|
|
712
|
+
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), Crypto.newRandomSessionID(inviteID))
|
|
714
713
|
.getCurrentContent());
|
|
715
714
|
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
716
715
|
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
@@ -735,7 +734,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
735
734
|
const inviteSecret = group.createInvite("admin");
|
|
736
735
|
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
737
736
|
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
738
|
-
const nodeAsInvitedAdmin = node.testWithDifferentAccount(new ControlledAgent(invitedAdminSecret, Crypto), newRandomSessionID(invitedAdminID));
|
|
737
|
+
const nodeAsInvitedAdmin = node.testWithDifferentAccount(new ControlledAgent(invitedAdminSecret, Crypto), Crypto.newRandomSessionID(invitedAdminID));
|
|
739
738
|
await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
|
|
740
739
|
const thirdAdmin = Crypto.newRandomAgentSecret();
|
|
741
740
|
const thirdAdminID = Crypto.getAgentID(thirdAdmin);
|
|
@@ -778,7 +777,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
778
777
|
});
|
|
779
778
|
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
780
779
|
const groupAsInvite = expectGroup(groupCore
|
|
781
|
-
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), newRandomSessionID(inviteID))
|
|
780
|
+
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), Crypto.newRandomSessionID(inviteID))
|
|
782
781
|
.getCurrentContent());
|
|
783
782
|
const invitedWriterSecret = Crypto.newRandomAgentSecret();
|
|
784
783
|
const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
|
|
@@ -803,7 +802,7 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
|
|
|
803
802
|
const inviteSecret = group.createInvite("writer");
|
|
804
803
|
const invitedWriterSecret = Crypto.newRandomAgentSecret();
|
|
805
804
|
const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
|
|
806
|
-
const nodeAsInvitedWriter = node.testWithDifferentAccount(new ControlledAgent(invitedWriterSecret, Crypto), newRandomSessionID(invitedWriterID));
|
|
805
|
+
const nodeAsInvitedWriter = node.testWithDifferentAccount(new ControlledAgent(invitedWriterSecret, Crypto), Crypto.newRandomSessionID(invitedWriterID));
|
|
807
806
|
await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
|
|
808
807
|
const groupAsInvitedWriter = await nodeAsInvitedWriter.load(group.id);
|
|
809
808
|
if (groupAsInvitedWriter === "unavailable") {
|
|
@@ -842,7 +841,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
842
841
|
});
|
|
843
842
|
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
844
843
|
const groupAsInvite = expectGroup(groupCore
|
|
845
|
-
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), newRandomSessionID(inviteID))
|
|
844
|
+
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), Crypto.newRandomSessionID(inviteID))
|
|
846
845
|
.getCurrentContent());
|
|
847
846
|
const invitedReaderSecret = Crypto.newRandomAgentSecret();
|
|
848
847
|
const invitedReaderID = Crypto.getAgentID(invitedReaderSecret);
|
|
@@ -858,7 +857,7 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
|
|
|
858
857
|
const inviteSecret = group.createInvite("reader");
|
|
859
858
|
const invitedReaderSecret = Crypto.newRandomAgentSecret();
|
|
860
859
|
const invitedReaderID = Crypto.getAgentID(invitedReaderSecret);
|
|
861
|
-
const nodeAsInvitedReader = node.testWithDifferentAccount(new ControlledAgent(invitedReaderSecret, Crypto), newRandomSessionID(invitedReaderID));
|
|
860
|
+
const nodeAsInvitedReader = node.testWithDifferentAccount(new ControlledAgent(invitedReaderSecret, Crypto), Crypto.newRandomSessionID(invitedReaderID));
|
|
862
861
|
await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
|
|
863
862
|
const groupAsInvitedReader = await nodeAsInvitedReader.load(group.id);
|
|
864
863
|
if (groupAsInvitedReader === "unavailable") {
|
|
@@ -897,7 +896,7 @@ test("WriterInvites can not invite admins", () => {
|
|
|
897
896
|
});
|
|
898
897
|
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
899
898
|
const groupAsInvite = expectGroup(groupCore
|
|
900
|
-
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), newRandomSessionID(inviteID))
|
|
899
|
+
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), Crypto.newRandomSessionID(inviteID))
|
|
901
900
|
.getCurrentContent());
|
|
902
901
|
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
903
902
|
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
@@ -934,7 +933,7 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
934
933
|
});
|
|
935
934
|
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
936
935
|
const groupAsInvite = expectGroup(groupCore
|
|
937
|
-
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), newRandomSessionID(inviteID))
|
|
936
|
+
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), Crypto.newRandomSessionID(inviteID))
|
|
938
937
|
.getCurrentContent());
|
|
939
938
|
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
940
939
|
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
@@ -971,7 +970,7 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
971
970
|
});
|
|
972
971
|
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
973
972
|
const groupAsInvite = expectGroup(groupCore
|
|
974
|
-
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), newRandomSessionID(inviteID))
|
|
973
|
+
.testWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto), Crypto.newRandomSessionID(inviteID))
|
|
975
974
|
.getCurrentContent());
|
|
976
975
|
const invitedWriterSecret = Crypto.newRandomAgentSecret();
|
|
977
976
|
const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
|
|
@@ -997,7 +996,7 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
997
996
|
expect(childContent.get("foo")).toEqual("bar");
|
|
998
997
|
const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
|
|
999
998
|
const childContent2 = expectMap(childObject
|
|
1000
|
-
.testWithDifferentAccount(newAccount, newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
999
|
+
.testWithDifferentAccount(newAccount, Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1001
1000
|
.getCurrentContent());
|
|
1002
1001
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
1003
1002
|
});
|
|
@@ -1010,7 +1009,7 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
|
|
|
1010
1009
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1011
1010
|
const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
|
|
1012
1011
|
const childContent2 = expectMap(childObject.core
|
|
1013
|
-
.testWithDifferentAccount(new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto), newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1012
|
+
.testWithDifferentAccount(new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto), Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1014
1013
|
.getCurrentContent());
|
|
1015
1014
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
1016
1015
|
});
|
|
@@ -1033,7 +1032,7 @@ test("Can give write permission to 'everyone'", async () => {
|
|
|
1033
1032
|
expect(childContent.get("foo")).toEqual("bar");
|
|
1034
1033
|
const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
|
|
1035
1034
|
const childContent2 = expectMap(childObject
|
|
1036
|
-
.testWithDifferentAccount(newAccount, newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1035
|
+
.testWithDifferentAccount(newAccount, Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1037
1036
|
.getCurrentContent());
|
|
1038
1037
|
// TODO: resolve race condition
|
|
1039
1038
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
@@ -1050,7 +1049,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
1050
1049
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1051
1050
|
const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
|
|
1052
1051
|
const childContent2 = expectMap(childObject.core
|
|
1053
|
-
.testWithDifferentAccount(newAccount, newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1052
|
+
.testWithDifferentAccount(newAccount, Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()))
|
|
1054
1053
|
.getCurrentContent());
|
|
1055
1054
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
1056
1055
|
console.log("Before anon set");
|