cojson 0.18.19 → 0.18.20

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.
Files changed (56) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +12 -0
  3. package/dist/GarbageCollector.d.ts +2 -1
  4. package/dist/GarbageCollector.d.ts.map +1 -1
  5. package/dist/GarbageCollector.js +3 -2
  6. package/dist/GarbageCollector.js.map +1 -1
  7. package/dist/coValueCore/coValueCore.d.ts +28 -25
  8. package/dist/coValueCore/coValueCore.d.ts.map +1 -1
  9. package/dist/coValueCore/coValueCore.js +128 -90
  10. package/dist/coValueCore/coValueCore.js.map +1 -1
  11. package/dist/coValueCore/utils.d.ts +6 -0
  12. package/dist/coValueCore/utils.d.ts.map +1 -1
  13. package/dist/coValueCore/utils.js +53 -25
  14. package/dist/coValueCore/utils.js.map +1 -1
  15. package/dist/localNode.d.ts +5 -4
  16. package/dist/localNode.d.ts.map +1 -1
  17. package/dist/localNode.js +31 -37
  18. package/dist/localNode.js.map +1 -1
  19. package/dist/sync.d.ts.map +1 -1
  20. package/dist/sync.js +56 -69
  21. package/dist/sync.js.map +1 -1
  22. package/dist/tests/GarbageCollector.test.js +14 -0
  23. package/dist/tests/GarbageCollector.test.js.map +1 -1
  24. package/dist/tests/SyncStateManager.test.js +1 -1
  25. package/dist/tests/coValueCore.dependencies.test.d.ts +2 -0
  26. package/dist/tests/coValueCore.dependencies.test.d.ts.map +1 -0
  27. package/dist/tests/coValueCore.dependencies.test.js +55 -0
  28. package/dist/tests/coValueCore.dependencies.test.js.map +1 -0
  29. package/dist/tests/coValueCore.test.js +2 -2
  30. package/dist/tests/coValueCore.test.js.map +1 -1
  31. package/dist/tests/coValueCoreLoadingState.test.js +43 -62
  32. package/dist/tests/coValueCoreLoadingState.test.js.map +1 -1
  33. package/dist/tests/permissions.test.js +117 -117
  34. package/dist/tests/permissions.test.js.map +1 -1
  35. package/dist/tests/sync.load.test.js +238 -9
  36. package/dist/tests/sync.load.test.js.map +1 -1
  37. package/dist/tests/sync.peerReconciliation.test.js +7 -6
  38. package/dist/tests/sync.peerReconciliation.test.js.map +1 -1
  39. package/dist/tests/testUtils.d.ts.map +1 -1
  40. package/dist/tests/testUtils.js +2 -1
  41. package/dist/tests/testUtils.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/GarbageCollector.ts +5 -2
  44. package/src/coValueCore/coValueCore.ts +172 -118
  45. package/src/coValueCore/utils.ts +85 -31
  46. package/src/localNode.ts +43 -48
  47. package/src/sync.ts +63 -89
  48. package/src/tests/GarbageCollector.test.ts +20 -0
  49. package/src/tests/SyncStateManager.test.ts +1 -1
  50. package/src/tests/coValueCore.dependencies.test.ts +90 -0
  51. package/src/tests/coValueCore.test.ts +2 -2
  52. package/src/tests/coValueCoreLoadingState.test.ts +50 -66
  53. package/src/tests/permissions.test.ts +120 -123
  54. package/src/tests/sync.load.test.ts +308 -9
  55. package/src/tests/sync.peerReconciliation.test.ts +7 -6
  56. package/src/tests/testUtils.ts +5 -3
@@ -11,45 +11,45 @@ test("Initial admin can add another admin to a group", () => {
11
11
  test("Initial admin can add another admin to a group (high level)", () => {
12
12
  groupWithTwoAdminsHighLevel();
13
13
  });
14
- test("Added admin can add a third admin to a group", () => {
14
+ test("Added admin can add a third admin to a group", async () => {
15
15
  const { groupCore, otherAdmin, node } = groupWithTwoAdmins();
16
- const groupAsOtherAdmin = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(otherAdmin));
16
+ const groupAsOtherAdmin = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(otherAdmin));
17
17
  expect(groupAsOtherAdmin.get(otherAdmin.id)).toEqual("admin");
18
18
  const thirdAdmin = createAccountInNode(groupAsOtherAdmin.core.node);
19
19
  groupAsOtherAdmin.set(thirdAdmin.id, "admin", "trusting");
20
20
  expect(groupAsOtherAdmin.get(thirdAdmin.id)).toEqual("admin");
21
21
  });
22
- test("Added adming can add a third admin to a group (high level)", () => {
22
+ test("Added adming can add a third admin to a group (high level)", async () => {
23
23
  const { group, otherAdmin } = groupWithTwoAdminsHighLevel();
24
- const groupAsOtherAdmin = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(otherAdmin));
24
+ const groupAsOtherAdmin = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(otherAdmin));
25
25
  const thirdAdmin = createAccountInNode(groupAsOtherAdmin.core.node);
26
26
  groupAsOtherAdmin.addMember(thirdAdmin, "admin");
27
27
  expect(groupAsOtherAdmin.get(thirdAdmin.id)).toEqual("admin");
28
28
  });
29
- test("Admins can't demote other admins in a group", () => {
29
+ test("Admins can't demote other admins in a group", async () => {
30
30
  const { groupCore, admin, otherAdmin } = groupWithTwoAdmins();
31
31
  const groupContent = expectGroup(groupCore.getCurrentContent());
32
32
  groupContent.set(otherAdmin.id, "writer", "trusting");
33
33
  expect(groupContent.get(otherAdmin.id)).toEqual("admin");
34
34
  expect(groupContent.get(otherAdmin.id)).toEqual("admin");
35
- const groupAsOtherAdmin = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(otherAdmin));
35
+ const groupAsOtherAdmin = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(otherAdmin));
36
36
  groupAsOtherAdmin.set(admin.id, "writer", "trusting");
37
37
  expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
38
38
  });
39
- test("Admins can't demote other admins in a group (high level)", () => {
39
+ test("Admins can't demote other admins in a group (high level)", async () => {
40
40
  const { group, admin, otherAdmin } = groupWithTwoAdminsHighLevel();
41
- const groupAsOtherAdmin = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(otherAdmin));
41
+ const groupAsOtherAdmin = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(otherAdmin));
42
42
  expect(() => groupAsOtherAdmin.addMemberInternal(admin.id, "writer")).toThrow("Administrators cannot demote other administrators in a group");
43
43
  expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
44
44
  });
45
- test("Admins an add writers to a group, who can't add admins, writers, or readers", () => {
45
+ test("Admins an add writers to a group, who can't add admins, writers, or readers", async () => {
46
46
  const { groupCore, node } = newGroup();
47
47
  const writer = createAccountInNode(node);
48
48
  const groupContent = expectGroup(groupCore.getCurrentContent());
49
49
  groupContent.set(writer.id, "writer", "trusting");
50
50
  expect(groupContent.get(writer.id)).toEqual("writer");
51
51
  expect(groupContent.get(writer.id)).toEqual("writer");
52
- const groupAsWriter = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(writer));
52
+ const groupAsWriter = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(writer));
53
53
  expect(groupAsWriter.get(writer.id)).toEqual("writer");
54
54
  const otherAgent = createAccountInNode(node);
55
55
  groupAsWriter.set(otherAgent.id, "admin", "trusting");
@@ -59,12 +59,12 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
59
59
  groupAsWriter.set(otherAgent.id, "reader", "trusting");
60
60
  expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
61
61
  });
62
- test("Admins an add writers to a group, who can't add admins, writers, or readers (high level)", () => {
62
+ test("Admins an add writers to a group, who can't add admins, writers, or readers (high level)", async () => {
63
63
  const { group, node } = newGroupHighLevel();
64
64
  const writer = createAccountInNode(node);
65
65
  group.addMember(writer, "writer");
66
66
  expect(group.get(writer.id)).toEqual("writer");
67
- const groupAsWriter = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(writer));
67
+ const groupAsWriter = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(writer));
68
68
  expect(groupAsWriter.get(writer.id)).toEqual("writer");
69
69
  const otherAgent = createAccountInNode(groupAsWriter.core.node);
70
70
  expect(() => groupAsWriter.addMember(otherAgent, "admin")).toThrow("Failed to set role due to insufficient permissions (role of current account is writer)");
@@ -72,13 +72,13 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
72
72
  expect(() => groupAsWriter.addMember(otherAgent, "reader")).toThrow("Failed to set role due to insufficient permissions (role of current account is writer)");
73
73
  expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
74
74
  });
75
- test("Admins can add readers to a group, who can't add admins, writers, or readers", () => {
75
+ test("Admins can add readers to a group, who can't add admins, writers, or readers", async () => {
76
76
  const { groupCore, node } = newGroup();
77
77
  const reader = createAccountInNode(node);
78
78
  const groupContent = expectGroup(groupCore.getCurrentContent());
79
79
  groupContent.set(reader.id, "reader", "trusting");
80
80
  expect(groupContent.get(reader.id)).toEqual("reader");
81
- const groupAsReader = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(reader));
81
+ const groupAsReader = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(reader));
82
82
  expect(groupAsReader.get(reader.id)).toEqual("reader");
83
83
  const otherAgent = createAccountInNode(node);
84
84
  groupAsReader.set(otherAgent.id, "admin", "trusting");
@@ -88,12 +88,12 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
88
88
  groupAsReader.set(otherAgent.id, "reader", "trusting");
89
89
  expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
90
90
  });
91
- test("Admins can add readers to a group, who can't add admins, writers, or readers (high level)", () => {
91
+ test("Admins can add readers to a group, who can't add admins, writers, or readers (high level)", async () => {
92
92
  const { group, node } = newGroupHighLevel();
93
93
  const reader = createAccountInNode(node);
94
94
  group.addMember(reader, "reader");
95
95
  expect(group.get(reader.id)).toEqual("reader");
96
- const groupAsReader = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(reader));
96
+ const groupAsReader = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(reader));
97
97
  expect(groupAsReader.get(reader.id)).toEqual("reader");
98
98
  const otherAgent = createAccountInNode(groupAsReader.core.node);
99
99
  expect(() => groupAsReader.addMember(otherAgent, "admin")).toThrow("Failed to set role due to insufficient permissions (role of current account is reader)");
@@ -119,7 +119,7 @@ test("Admins can write to an object that is owned by their group (high level)",
119
119
  childObject.set("foo", "bar", "trusting");
120
120
  expect(childObject.get("foo")).toEqual("bar");
121
121
  });
122
- test("Writers can write to an object that is owned by their group", () => {
122
+ test("Writers can write to an object that is owned by their group", async () => {
123
123
  const { node, groupCore } = newGroup();
124
124
  const writer = createAccountInNode(node);
125
125
  const group = expectGroup(groupCore.getCurrentContent());
@@ -131,20 +131,20 @@ test("Writers can write to an object that is owned by their group", () => {
131
131
  meta: null,
132
132
  ...Crypto.createdNowUnique(),
133
133
  });
134
- const childObjectAsWriter = expectMap(childObject.contentInClonedNodeWithDifferentAccount(writer));
134
+ const childObjectAsWriter = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(writer));
135
135
  childObjectAsWriter.set("foo", "bar", "trusting");
136
136
  expect(childObjectAsWriter.get("foo")).toEqual("bar");
137
137
  });
138
- test("Writers can write to an object that is owned by their group (high level)", () => {
138
+ test("Writers can write to an object that is owned by their group (high level)", async () => {
139
139
  const { node, group } = newGroupHighLevel();
140
140
  const writer = createAccountInNode(node);
141
141
  group.addMember(writer, "writer");
142
142
  const childObject = group.createMap();
143
- const childObjectAsWriter = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(writer));
143
+ const childObjectAsWriter = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(writer));
144
144
  childObjectAsWriter.set("foo", "bar", "trusting");
145
145
  expect(childObjectAsWriter.get("foo")).toEqual("bar");
146
146
  });
147
- test("Readers can not write to an object that is owned by their group", () => {
147
+ test("Readers can not write to an object that is owned by their group", async () => {
148
148
  const { node, groupCore } = newGroup();
149
149
  const reader = createAccountInNode(node);
150
150
  const group = expectGroup(groupCore.getCurrentContent());
@@ -156,17 +156,17 @@ test("Readers can not write to an object that is owned by their group", () => {
156
156
  meta: null,
157
157
  ...Crypto.createdNowUnique(),
158
158
  });
159
- const childObjectAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
159
+ const childObjectAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
160
160
  childObjectAsReader.set("foo", "bar", "trusting");
161
161
  childObjectAsReader.set("foo", "bar", "trusting");
162
162
  expect(childObjectAsReader.get("foo")).toBeUndefined();
163
163
  });
164
- test("Readers can not write to an object that is owned by their group (high level)", () => {
164
+ test("Readers can not write to an object that is owned by their group (high level)", async () => {
165
165
  const { node, group } = newGroupHighLevel();
166
166
  const reader = createAccountInNode(node);
167
167
  group.addMember(reader, "reader");
168
168
  const childObject = group.createMap();
169
- const childObjectAsReader = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader));
169
+ const childObjectAsReader = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader));
170
170
  childObjectAsReader.set("foo", "bar", "trusting");
171
171
  expect(childObjectAsReader.get("foo")).toBeUndefined();
172
172
  });
@@ -204,7 +204,7 @@ test("Admins can set group read key and then use it to create and read private t
204
204
  childObject.set("foo", "bar", "private");
205
205
  expect(childObject.get("foo")).toEqual("bar");
206
206
  });
207
- test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects", () => {
207
+ test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects", async () => {
208
208
  const { node, groupCore, admin } = newGroup();
209
209
  const writer = createAccountInNode(node);
210
210
  const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
@@ -238,22 +238,22 @@ test("Admins can set group read key and then writers can use it to create and re
238
238
  meta: null,
239
239
  ...Crypto.createdNowUnique(),
240
240
  });
241
- const childObjectAsWriter = expectMap(childObject.contentInClonedNodeWithDifferentAccount(writer));
241
+ const childObjectAsWriter = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(writer));
242
242
  expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
243
243
  expect(childObjectAsWriter.core.getCurrentReadKey().secret).toEqual(readKey);
244
244
  childObjectAsWriter.set("foo", "bar", "private");
245
245
  expect(childObjectAsWriter.get("foo")).toEqual("bar");
246
246
  });
247
- test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects (high level)", () => {
247
+ test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects (high level)", async () => {
248
248
  const { node, group } = newGroupHighLevel();
249
249
  const writer = createAccountInNode(node);
250
250
  group.addMember(writer, "writer");
251
251
  const childObject = group.createMap();
252
- const childObjectAsWriter = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(writer));
252
+ const childObjectAsWriter = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(writer));
253
253
  childObjectAsWriter.set("foo", "bar", "private");
254
254
  expect(childObjectAsWriter.get("foo")).toEqual("bar");
255
255
  });
256
- test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read", () => {
256
+ test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read", async () => {
257
257
  const { node, groupCore, admin } = newGroup();
258
258
  const reader = createAccountInNode(node);
259
259
  const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
@@ -290,21 +290,21 @@ test("Admins can set group read key and then use it to create private transactio
290
290
  const childContent = expectMap(childObject.getCurrentContent());
291
291
  childContent.set("foo", "bar", "private");
292
292
  expect(childContent.get("foo")).toEqual("bar");
293
- const childObjectAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
293
+ const childObjectAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
294
294
  expect(childObjectAsReader.core.getCurrentReadKey().secret).toEqual(readKey);
295
295
  expect(childObjectAsReader.get("foo")).toEqual("bar");
296
296
  });
297
- test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read (high level)", () => {
297
+ test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read (high level)", async () => {
298
298
  const { node, group } = newGroupHighLevel();
299
299
  const reader = createAccountInNode(node);
300
300
  group.addMember(reader, "reader");
301
301
  const childObject = group.createMap();
302
302
  childObject.set("foo", "bar", "private");
303
303
  expect(childObject.get("foo")).toEqual("bar");
304
- const childContentAsReader = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader));
304
+ const childContentAsReader = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader));
305
305
  expect(childContentAsReader.get("foo")).toEqual("bar");
306
306
  });
307
- test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read, even with a separate later revelation for the same read key", () => {
307
+ test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read, even with a separate later revelation for the same read key", async () => {
308
308
  const { node, groupCore, admin } = newGroup();
309
309
  const reader1 = createAccountInNode(node);
310
310
  const reader2 = createAccountInNode(node);
@@ -342,7 +342,7 @@ test("Admins can set group read key and then use it to create private transactio
342
342
  const childContent = expectMap(childObject.getCurrentContent());
343
343
  childContent.set("foo", "bar", "private");
344
344
  expect(childContent.get("foo")).toEqual("bar");
345
- const childObjectAsReader1 = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader1));
345
+ const childObjectAsReader1 = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader1));
346
346
  expect(childObjectAsReader1.core.getCurrentReadKey().secret).toEqual(readKey);
347
347
  expect(childObjectAsReader1.get("foo")).toEqual("bar");
348
348
  const revelation3 = Crypto.seal({
@@ -355,13 +355,13 @@ test("Admins can set group read key and then use it to create private transactio
355
355
  },
356
356
  });
357
357
  groupContent.set(`${readKeyID}_for_${reader2.id}`, revelation3, "trusting");
358
- const childObjectAsReader2 = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader2));
358
+ const childObjectAsReader2 = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader2));
359
359
  // Need to copy the account coValue to the new node to be able to read the readKey
360
- childObjectAsReader2.core.node.cloneVerifiedStateFrom(node, reader2.id);
360
+ await childObjectAsReader2.core.node.loadVerifiedStateFrom(node, reader2.id);
361
361
  expect(childObjectAsReader2.core.getCurrentReadKey().secret).toEqual(readKey);
362
362
  expect(childObjectAsReader2.get("foo")).toEqual("bar");
363
363
  });
364
- test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read, even with a separate later revelation for the same read key (high level)", () => {
364
+ test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read, even with a separate later revelation for the same read key (high level)", async () => {
365
365
  const { node, group } = newGroupHighLevel();
366
366
  const reader1 = createAccountInNode(node);
367
367
  const reader2 = createAccountInNode(node);
@@ -369,10 +369,10 @@ test("Admins can set group read key and then use it to create private transactio
369
369
  const childObject = group.createMap();
370
370
  childObject.set("foo", "bar", "private");
371
371
  expect(childObject.get("foo")).toEqual("bar");
372
- const childContentAsReader1 = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader1));
372
+ const childContentAsReader1 = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader1));
373
373
  expect(childContentAsReader1.get("foo")).toEqual("bar");
374
374
  group.addMember(reader2, "reader");
375
- const childContentAsReader2 = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader2));
375
+ const childContentAsReader2 = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader2));
376
376
  expect(childContentAsReader2.get("foo")).toEqual("bar");
377
377
  });
378
378
  test("Admins can set group read key, make a private transaction in an owned object, rotate the read key, make another private transaction, and both can be read by the admin", () => {
@@ -430,7 +430,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
430
430
  childObject.set("foo2", "bar2", "private");
431
431
  expect(childObject.get("foo2")).toEqual("bar2");
432
432
  });
433
- test("Admins can set group read key, make a private transaction in an owned object, rotate the read key, add a reader, make another private transaction in the owned object, and both can be read by the reader", () => {
433
+ test("Admins can set group read key, make a private transaction in an owned object, rotate the read key, add a reader, make another private transaction in the owned object, and both can be read by the reader", async () => {
434
434
  const { node, groupCore, admin } = newGroup();
435
435
  const childObject = node.createCoValue({
436
436
  type: "comap",
@@ -490,12 +490,12 @@ test("Admins can set group read key, make a private transaction in an owned obje
490
490
  expect(groupContent.get(reader.id)).toEqual("reader");
491
491
  childContent.set("foo2", "bar2", "private");
492
492
  expect(childContent.get("foo2")).toEqual("bar2");
493
- const childObjectAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
493
+ const childObjectAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
494
494
  expect(childObjectAsReader.core.getCurrentReadKey().secret).toEqual(readKey2);
495
495
  expect(childObjectAsReader.get("foo")).toEqual("bar");
496
496
  expect(childObjectAsReader.get("foo2")).toEqual("bar2");
497
497
  });
498
- test("Admins can set group read key, make a private transaction in an owned object, rotate the read key, add a reader, make another private transaction in the owned object, and both can be read by the reader (high level)", () => {
498
+ test("Admins can set group read key, make a private transaction in an owned object, rotate the read key, add a reader, make another private transaction in the owned object, and both can be read by the reader (high level)", async () => {
499
499
  const { node, group } = newGroupHighLevel();
500
500
  const childObject = group.createMap();
501
501
  const firstReadKey = childObject.core.getCurrentReadKey();
@@ -508,19 +508,19 @@ test("Admins can set group read key, make a private transaction in an owned obje
508
508
  group.addMember(reader, "reader");
509
509
  childObject.set("foo2", "bar2", "private");
510
510
  expect(childObject.get("foo2")).toEqual("bar2");
511
- const childContentAsReader = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader));
511
+ const childContentAsReader = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader));
512
512
  expect(childContentAsReader.get("foo")).toEqual("bar");
513
513
  expect(childContentAsReader.get("foo2")).toEqual("bar2");
514
514
  });
515
- test("only admins can add agent ids", () => {
515
+ test("only admins can add agent ids", async () => {
516
516
  const { groupCore } = newGroup();
517
517
  const inviteSecret = Crypto.newRandomAgentSecret();
518
518
  const inviteID = Crypto.getAgentID(inviteSecret);
519
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
519
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
520
520
  groupAsInvite.set(inviteID, "adminInvite", "trusting");
521
521
  expect(groupAsInvite.get(inviteID)).toEqual(undefined);
522
522
  });
523
- test("Admins can set group read rey, make a private transaction in an owned object, rotate the read key, add two readers, rotate the read key again to kick out one reader, make another private transaction in the owned object, and only the remaining reader can read both transactions", () => {
523
+ test("Admins can set group read rey, make a private transaction in an owned object, rotate the read key, add two readers, rotate the read key again to kick out one reader, make another private transaction in the owned object, and only the remaining reader can read both transactions", async () => {
524
524
  const { node, groupCore, admin } = newGroup();
525
525
  const childObject = node.createCoValue({
526
526
  type: "comap",
@@ -572,9 +572,9 @@ test("Admins can set group read rey, make a private transaction in an owned obje
572
572
  const childContent = expectMap(childObject.getCurrentContent());
573
573
  childContent.set("foo", "bar", "private");
574
574
  expect(childContent.get("foo")).toEqual("bar");
575
- let childObjectAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
575
+ let childObjectAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
576
576
  expect(childObjectAsReader.get("foo")).toEqual("bar");
577
- let childObjectAsReader2 = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader2));
577
+ let childObjectAsReader2 = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader2));
578
578
  expect(childObjectAsReader2.get("foo")).toEqual("bar");
579
579
  const { secret: readKey2, id: readKeyID2 } = Crypto.newRandomKeySecret();
580
580
  const newRevelation1 = Crypto.seal({
@@ -606,8 +606,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
606
606
  childContent.set("foo2", "bar2", "private");
607
607
  expect(childContent.get("foo2")).toEqual("bar2");
608
608
  // TODO: make sure these instances of coValues sync between each other so this isn't necessary?
609
- childObjectAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
610
- childObjectAsReader2 = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader2));
609
+ childObjectAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
610
+ childObjectAsReader2 = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader2));
611
611
  expect(childObjectAsReader.get("foo2")).toBeUndefined();
612
612
  expect(childObjectAsReader2.get("foo2")).toEqual("bar2");
613
613
  });
@@ -629,11 +629,11 @@ test("Admins can set group read rey, make a private transaction in an owned obje
629
629
  expect(childObject.core.getCurrentReadKey()).not.toEqual(secondReadKey);
630
630
  childObject.set("foo3", "bar3", "private");
631
631
  expect(childObject.get("foo3")).toEqual("bar3");
632
- const childContentAsReader2 = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader2));
632
+ const childContentAsReader2 = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader2));
633
633
  expect(childContentAsReader2.get("foo")).toEqual("bar");
634
634
  expect(childContentAsReader2.get("foo2")).toEqual("bar2");
635
635
  expect(childContentAsReader2.get("foo3")).toEqual("bar3");
636
- expect(expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(reader)).get("foo3")).toBeUndefined();
636
+ expect(expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(reader)).get("foo3")).toBeUndefined();
637
637
  });
638
638
  test("Can create two owned objects in the same group and they will have different ids", () => {
639
639
  const { node, groupCore } = newGroup();
@@ -651,7 +651,7 @@ test("Can create two owned objects in the same group and they will have differen
651
651
  });
652
652
  expect(childObject1.id).not.toEqual(childObject2.id);
653
653
  });
654
- test("Admins can create an adminInvite, which can add an admin", () => {
654
+ test("Admins can create an adminInvite, which can add an admin", async () => {
655
655
  const { groupCore, admin } = newGroup();
656
656
  const inviteSecret = Crypto.newRandomAgentSecret();
657
657
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -680,7 +680,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
680
680
  },
681
681
  });
682
682
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
683
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
683
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
684
684
  const invitedAdminSecret = Crypto.newRandomAgentSecret();
685
685
  const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
686
686
  groupAsInvite.set(invitedAdminID, "admin", "trusting");
@@ -704,7 +704,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
704
704
  const inviteSecret = group.createInvite("admin");
705
705
  const invitedAdminSecret = Crypto.newRandomAgentSecret();
706
706
  const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
707
- const nodeAsInvitedAdmin = node.loadCoValueAsDifferentAgent(group.id, invitedAdminSecret).node;
707
+ const nodeAsInvitedAdmin = (await node.loadCoValueAsDifferentAgent(group.id, invitedAdminSecret)).node;
708
708
  await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
709
709
  const thirdAdmin = Crypto.newRandomAgentSecret();
710
710
  const thirdAdminID = Crypto.getAgentID(thirdAdmin);
@@ -717,7 +717,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
717
717
  groupAsInvitedAdmin.addMemberInternal(thirdAdminID, "admin");
718
718
  expect(groupAsInvitedAdmin.get(thirdAdminID)).toEqual("admin");
719
719
  });
720
- test("Admins can create a writerInvite, which can add a writer", () => {
720
+ test("Admins can create a writerInvite, which can add a writer", async () => {
721
721
  const { groupCore, admin } = newGroup();
722
722
  const inviteSecret = Crypto.newRandomAgentSecret();
723
723
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -746,7 +746,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
746
746
  },
747
747
  });
748
748
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
749
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
749
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
750
750
  const invitedWriterSecret = Crypto.newRandomAgentSecret();
751
751
  const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
752
752
  groupAsInvite.set(invitedWriterID, "writer", "trusting");
@@ -770,7 +770,7 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
770
770
  const inviteSecret = group.createInvite("writer");
771
771
  const invitedWriterSecret = Crypto.newRandomAgentSecret();
772
772
  const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
773
- const nodeAsInvitedWriter = node.loadCoValueAsDifferentAgent(group.id, invitedWriterSecret).node;
773
+ const nodeAsInvitedWriter = (await node.loadCoValueAsDifferentAgent(group.id, invitedWriterSecret)).node;
774
774
  await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
775
775
  const groupAsInvitedWriter = await nodeAsInvitedWriter.load(group.id);
776
776
  if (groupAsInvitedWriter === "unavailable") {
@@ -779,7 +779,7 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
779
779
  expect(groupAsInvitedWriter.get(invitedWriterID)).toEqual("writer");
780
780
  expect(groupAsInvitedWriter.core.getCurrentReadKey().secret).toBeDefined();
781
781
  });
782
- test("Admins can create a readerInvite, which can add a reader", () => {
782
+ test("Admins can create a readerInvite, which can add a reader", async () => {
783
783
  const { groupCore, admin } = newGroup();
784
784
  const inviteSecret = Crypto.newRandomAgentSecret();
785
785
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -808,7 +808,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
808
808
  },
809
809
  });
810
810
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
811
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
811
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
812
812
  const invitedReaderSecret = Crypto.newRandomAgentSecret();
813
813
  const invitedReaderID = Crypto.getAgentID(invitedReaderSecret);
814
814
  groupAsInvite.set(invitedReaderID, "reader", "trusting");
@@ -823,7 +823,7 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
823
823
  const inviteSecret = group.createInvite("reader");
824
824
  const invitedReaderSecret = Crypto.newRandomAgentSecret();
825
825
  const invitedReaderID = Crypto.getAgentID(invitedReaderSecret);
826
- const nodeAsInvitedReader = node.loadCoValueAsDifferentAgent(group.id, invitedReaderSecret).node;
826
+ const nodeAsInvitedReader = (await node.loadCoValueAsDifferentAgent(group.id, invitedReaderSecret)).node;
827
827
  await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
828
828
  const groupAsInvitedReader = await nodeAsInvitedReader.load(group.id);
829
829
  if (groupAsInvitedReader === "unavailable") {
@@ -832,7 +832,7 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
832
832
  expect(groupAsInvitedReader.get(invitedReaderID)).toEqual("reader");
833
833
  expect(groupAsInvitedReader.core.getCurrentReadKey().secret).toBeDefined();
834
834
  });
835
- test("WriterInvites can not invite admins", () => {
835
+ test("WriterInvites can not invite admins", async () => {
836
836
  const { groupCore, admin } = newGroup();
837
837
  const inviteSecret = Crypto.newRandomAgentSecret();
838
838
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -861,13 +861,13 @@ test("WriterInvites can not invite admins", () => {
861
861
  },
862
862
  });
863
863
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
864
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
864
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
865
865
  const invitedAdminSecret = Crypto.newRandomAgentSecret();
866
866
  const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
867
867
  groupAsInvite.set(invitedAdminID, "admin", "trusting");
868
868
  expect(groupAsInvite.get(invitedAdminID)).toBeUndefined();
869
869
  });
870
- test("ReaderInvites can not invite admins", () => {
870
+ test("ReaderInvites can not invite admins", async () => {
871
871
  const { groupCore, admin } = newGroup();
872
872
  const inviteSecret = Crypto.newRandomAgentSecret();
873
873
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -896,13 +896,13 @@ test("ReaderInvites can not invite admins", () => {
896
896
  },
897
897
  });
898
898
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
899
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
899
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
900
900
  const invitedAdminSecret = Crypto.newRandomAgentSecret();
901
901
  const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
902
902
  groupAsInvite.set(invitedAdminID, "admin", "trusting");
903
903
  expect(groupAsInvite.get(invitedAdminID)).toBeUndefined();
904
904
  });
905
- test("ReaderInvites can not invite writers", () => {
905
+ test("ReaderInvites can not invite writers", async () => {
906
906
  const { groupCore, admin } = newGroup();
907
907
  const inviteSecret = Crypto.newRandomAgentSecret();
908
908
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -931,13 +931,13 @@ test("ReaderInvites can not invite writers", () => {
931
931
  },
932
932
  });
933
933
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
934
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
934
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
935
935
  const invitedWriterSecret = Crypto.newRandomAgentSecret();
936
936
  const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
937
937
  groupAsInvite.set(invitedWriterID, "writer", "trusting");
938
938
  expect(groupAsInvite.get(invitedWriterID)).toBeUndefined();
939
939
  });
940
- test("WriteOnlyInvites can not invite writers", () => {
940
+ test("WriteOnlyInvites can not invite writers", async () => {
941
941
  const { groupCore, admin } = newGroup();
942
942
  const inviteSecret = Crypto.newRandomAgentSecret();
943
943
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -966,13 +966,13 @@ test("WriteOnlyInvites can not invite writers", () => {
966
966
  },
967
967
  });
968
968
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
969
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
969
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
970
970
  const invitedWriterSecret = Crypto.newRandomAgentSecret();
971
971
  const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
972
972
  groupAsInvite.set(invitedWriterID, "writer", "trusting");
973
973
  expect(groupAsInvite.get(invitedWriterID)).toBeUndefined();
974
974
  });
975
- test("WriteOnlyInvites can not invite admins", () => {
975
+ test("WriteOnlyInvites can not invite admins", async () => {
976
976
  const { groupCore, admin } = newGroup();
977
977
  const inviteSecret = Crypto.newRandomAgentSecret();
978
978
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -1001,13 +1001,13 @@ test("WriteOnlyInvites can not invite admins", () => {
1001
1001
  },
1002
1002
  });
1003
1003
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
1004
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1004
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1005
1005
  const invitedWriterSecret = Crypto.newRandomAgentSecret();
1006
1006
  const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
1007
1007
  groupAsInvite.set(invitedWriterID, "admin", "trusting");
1008
1008
  expect(groupAsInvite.get(invitedWriterID)).toBeUndefined();
1009
1009
  });
1010
- test("WriteOnlyInvites can invite writeOnly", () => {
1010
+ test("WriteOnlyInvites can invite writeOnly", async () => {
1011
1011
  const { groupCore, admin } = newGroup();
1012
1012
  const inviteSecret = Crypto.newRandomAgentSecret();
1013
1013
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -1036,13 +1036,13 @@ test("WriteOnlyInvites can invite writeOnly", () => {
1036
1036
  },
1037
1037
  });
1038
1038
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
1039
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1039
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1040
1040
  const invitedWriterSecret = Crypto.newRandomAgentSecret();
1041
1041
  const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
1042
1042
  groupAsInvite.set(invitedWriterID, "writeOnly", "trusting");
1043
1043
  expect(groupAsInvite.get(invitedWriterID)).toEqual("writeOnly");
1044
1044
  });
1045
- test("WriteOnlyInvites can set writeKeys", () => {
1045
+ test("WriteOnlyInvites can set writeKeys", async () => {
1046
1046
  const { groupCore, admin } = newGroup();
1047
1047
  const inviteSecret = Crypto.newRandomAgentSecret();
1048
1048
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -1071,11 +1071,11 @@ test("WriteOnlyInvites can set writeKeys", () => {
1071
1071
  },
1072
1072
  });
1073
1073
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
1074
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1074
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1075
1075
  groupAsInvite.set(`writeKeyFor_${admin.id}`, readKeyID, "trusting");
1076
1076
  expect(groupAsInvite.get(`writeKeyFor_${admin.id}`)).toEqual(readKeyID);
1077
1077
  });
1078
- test("WriteOnlyInvites can't override writeKeys", () => {
1078
+ test("WriteOnlyInvites can't override writeKeys", async () => {
1079
1079
  const { groupCore, admin } = newGroup();
1080
1080
  const inviteSecret = Crypto.newRandomAgentSecret();
1081
1081
  const inviteID = Crypto.getAgentID(inviteSecret);
@@ -1104,12 +1104,12 @@ test("WriteOnlyInvites can't override writeKeys", () => {
1104
1104
  },
1105
1105
  });
1106
1106
  group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
1107
- const groupAsInvite = expectGroup(groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1107
+ const groupAsInvite = expectGroup(await groupCore.contentInClonedNodeWithDifferentAccount(new ControlledAgent(inviteSecret, Crypto)));
1108
1108
  groupAsInvite.set(`writeKeyFor_${admin.id}`, readKeyID, "trusting");
1109
1109
  groupAsInvite.set(`writeKeyFor_${admin.id}`, "Evil change", "trusting");
1110
1110
  expect(groupAsInvite.get(`writeKeyFor_${admin.id}`)).toEqual(readKeyID);
1111
1111
  });
1112
- test("Can give read permission to 'everyone'", () => {
1112
+ test("Can give read permission to 'everyone'", async () => {
1113
1113
  const { node, groupCore } = newGroup();
1114
1114
  const childObject = node.createCoValue({
1115
1115
  type: "comap",
@@ -1127,7 +1127,7 @@ test("Can give read permission to 'everyone'", () => {
1127
1127
  childContent.set("foo", "bar", "private");
1128
1128
  expect(childContent.get("foo")).toEqual("bar");
1129
1129
  const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
1130
- const childContent2 = expectMap(childObject.contentInClonedNodeWithDifferentAccount(newAccount));
1130
+ const childContent2 = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(newAccount));
1131
1131
  expect(childContent2.get("foo")).toEqual("bar");
1132
1132
  });
1133
1133
  test("Can give read permissions to 'everyone' (high-level)", async () => {
@@ -1138,7 +1138,7 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
1138
1138
  childObject.set("foo", "bar", "private");
1139
1139
  expect(childObject.get("foo")).toEqual("bar");
1140
1140
  const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
1141
- const childContent2 = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(newAccount));
1141
+ const childContent2 = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(newAccount));
1142
1142
  expect(childContent2.get("foo")).toEqual("bar");
1143
1143
  });
1144
1144
  test("Can give write permission to 'everyone'", async () => {
@@ -1159,7 +1159,7 @@ test("Can give write permission to 'everyone'", async () => {
1159
1159
  childContent.set("foo", "bar", "private");
1160
1160
  expect(childContent.get("foo")).toEqual("bar");
1161
1161
  const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
1162
- const childContent2 = expectMap(childObject.contentInClonedNodeWithDifferentAccount(newAccount));
1162
+ const childContent2 = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(newAccount));
1163
1163
  // TODO: resolve race condition
1164
1164
  await new Promise((resolve) => setTimeout(resolve, 50));
1165
1165
  expect(childContent2.get("foo")).toEqual("bar");
@@ -1174,7 +1174,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
1174
1174
  childObject.set("foo", "bar", "private");
1175
1175
  expect(childObject.get("foo")).toEqual("bar");
1176
1176
  const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
1177
- const childContent2 = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(newAccount));
1177
+ const childContent2 = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(newAccount));
1178
1178
  connectTwoPeers(group.core.node, childContent2.core.node, "server", "server");
1179
1179
  // Ensure that the group is available to newAccount
1180
1180
  await group.core.waitForSync();
@@ -1188,7 +1188,7 @@ test("Admins can set parent extensions", () => {
1188
1188
  group.set(`parent_${parentGroup.id}`, "extend", "trusting");
1189
1189
  expect(group.get(`parent_${parentGroup.id}`)).toEqual("extend");
1190
1190
  });
1191
- test("Writers, readers and invitees can not set parent extensions", () => {
1191
+ test("Writers, readers and invitees can not set parent extensions", async () => {
1192
1192
  const { group, node } = newGroupHighLevel();
1193
1193
  const parentGroup = node.createGroup();
1194
1194
  const writer = createAccountInNode(node);
@@ -1201,19 +1201,19 @@ test("Writers, readers and invitees can not set parent extensions", () => {
1201
1201
  group.addMember(adminInvite, "adminInvite");
1202
1202
  group.addMember(writerInvite, "writerInvite");
1203
1203
  group.addMember(readerInvite, "readerInvite");
1204
- const groupAsWriter = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(writer));
1204
+ const groupAsWriter = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(writer));
1205
1205
  groupAsWriter.set(`parent_${parentGroup.id}`, "extend", "trusting");
1206
1206
  expect(groupAsWriter.get(`parent_${parentGroup.id}`)).toBeUndefined();
1207
- const groupAsReader = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(reader));
1207
+ const groupAsReader = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(reader));
1208
1208
  groupAsReader.set(`parent_${parentGroup.id}`, "extend", "trusting");
1209
1209
  expect(groupAsReader.get(`parent_${parentGroup.id}`)).toBeUndefined();
1210
- const groupAsAdminInvite = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(adminInvite));
1210
+ const groupAsAdminInvite = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(adminInvite));
1211
1211
  groupAsAdminInvite.set(`parent_${parentGroup.id}`, "extend", "trusting");
1212
1212
  expect(groupAsAdminInvite.get(`parent_${parentGroup.id}`)).toBeUndefined();
1213
- const groupAsWriterInvite = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(writerInvite));
1213
+ const groupAsWriterInvite = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(writerInvite));
1214
1214
  groupAsWriterInvite.set(`parent_${parentGroup.id}`, "extend", "trusting");
1215
1215
  expect(groupAsWriterInvite.get(`parent_${parentGroup.id}`)).toBeUndefined();
1216
- const groupAsReaderInvite = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(readerInvite));
1216
+ const groupAsReaderInvite = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(readerInvite));
1217
1217
  groupAsReaderInvite.set(`parent_${parentGroup.id}`, "extend", "trusting");
1218
1218
  expect(groupAsReaderInvite.get(`parent_${parentGroup.id}`)).toBeUndefined();
1219
1219
  });
@@ -1237,7 +1237,7 @@ test("Admins can set child extensions when the admin role is inherited", async (
1237
1237
  expect(childGroupOnNode1.get(`child_${grandChildGroup.id}`)).toEqual("extend");
1238
1238
  expect(grandChildGroup.get(`parent_${childGroupOnNode1.id}`)).toEqual("extend");
1239
1239
  });
1240
- test("Writers, readers and writeOnly can set child extensions", () => {
1240
+ test("Writers, readers and writeOnly can set child extensions", async () => {
1241
1241
  const { group, node } = newGroupHighLevel();
1242
1242
  const childGroup = node.createGroup();
1243
1243
  const writer = createAccountInNode(node);
@@ -1246,10 +1246,10 @@ test("Writers, readers and writeOnly can set child extensions", () => {
1246
1246
  group.addMember(writer, "writer");
1247
1247
  group.addMember(reader, "reader");
1248
1248
  group.addMember(writeOnly, "writeOnly");
1249
- const groupAsWriter = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(writer));
1249
+ const groupAsWriter = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(writer));
1250
1250
  groupAsWriter.set(`child_${childGroup.id}`, "extend", "trusting");
1251
1251
  expect(groupAsWriter.get(`child_${childGroup.id}`)).toEqual("extend");
1252
- const groupAsReader = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(reader));
1252
+ const groupAsReader = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(reader));
1253
1253
  groupAsReader.set(`child_${childGroup.id}`, "extend", "trusting");
1254
1254
  expect(groupAsReader.get(`child_${childGroup.id}`)).toEqual("extend");
1255
1255
  });
@@ -1313,7 +1313,7 @@ test("Admins can reveal parent read keys to child groups", () => {
1313
1313
  group.set(`${readKeyID}_for_${parentReadKeyID}`, encrypted, "trusting");
1314
1314
  expect(group.get(`${readKeyID}_for_${parentReadKeyID}`)).toEqual(encrypted);
1315
1315
  });
1316
- test("Writers can't reveal parent read keys to child groups", () => {
1316
+ test("Writers can't reveal parent read keys to child groups", async () => {
1317
1317
  const { group, node } = newGroupHighLevel();
1318
1318
  const parentGroup = node.createGroup();
1319
1319
  const parentReadKeyID = parentGroup.get("readKey");
@@ -1328,11 +1328,11 @@ test("Writers can't reveal parent read keys to child groups", () => {
1328
1328
  const encrypted = "fake_encrypted_key_secret";
1329
1329
  const writer = createAccountInNode(node);
1330
1330
  group.addMember(writer, "writer");
1331
- const groupAsWriter = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(writer));
1331
+ const groupAsWriter = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(writer));
1332
1332
  groupAsWriter.set(`${readKeyID}_for_${parentReadKeyID}`, encrypted, "trusting");
1333
1333
  expect(groupAsWriter.get(`${readKeyID}_for_${parentReadKeyID}`)).toBeUndefined();
1334
1334
  });
1335
- test("Readers can't reveal parent read keys to child groups", () => {
1335
+ test("Readers can't reveal parent read keys to child groups", async () => {
1336
1336
  const { group, node } = newGroupHighLevel();
1337
1337
  const parentGroup = node.createGroup();
1338
1338
  const parentReadKeyID = parentGroup.get("readKey");
@@ -1347,11 +1347,11 @@ test("Readers can't reveal parent read keys to child groups", () => {
1347
1347
  const encrypted = "fake_encrypted_key_secret";
1348
1348
  const reader = createAccountInNode(node);
1349
1349
  group.addMember(reader, "reader");
1350
- const groupAsReader = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(reader));
1350
+ const groupAsReader = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(reader));
1351
1351
  groupAsReader.set(`${readKeyID}_for_${parentReadKeyID}`, encrypted, "trusting");
1352
1352
  expect(groupAsReader.get(`${readKeyID}_for_${parentReadKeyID}`)).toBeUndefined();
1353
1353
  });
1354
- test.skip("Admin invites can't reveal parent read keys to child groups", () => {
1354
+ test.skip("Admin invites can't reveal parent read keys to child groups", async () => {
1355
1355
  const { group, node } = newGroupHighLevel();
1356
1356
  const parentGroup = node.createGroup();
1357
1357
  const parentReadKeyID = parentGroup.get("readKey");
@@ -1366,11 +1366,11 @@ test.skip("Admin invites can't reveal parent read keys to child groups", () => {
1366
1366
  const encrypted = "fake_encrypted_key_secret";
1367
1367
  const adminInvite = createAccountInNode(node);
1368
1368
  group.addMember(adminInvite, "adminInvite");
1369
- const groupAsAdminInvite = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(adminInvite));
1369
+ const groupAsAdminInvite = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(adminInvite));
1370
1370
  groupAsAdminInvite.set(`${readKeyID}_for_${parentReadKeyID}`, encrypted, "trusting");
1371
1371
  expect(groupAsAdminInvite.get(`${readKeyID}_for_${parentReadKeyID}`)).toBeUndefined();
1372
1372
  });
1373
- test.skip("Writer invites can't reveal parent read keys to child groups", () => {
1373
+ test.skip("Writer invites can't reveal parent read keys to child groups", async () => {
1374
1374
  const { group, node } = newGroupHighLevel();
1375
1375
  const parentGroup = node.createGroup();
1376
1376
  const parentReadKeyID = parentGroup.get("readKey");
@@ -1385,11 +1385,11 @@ test.skip("Writer invites can't reveal parent read keys to child groups", () =>
1385
1385
  const encrypted = "fake_encrypted_key_secret";
1386
1386
  const writerInvite = createAccountInNode(node);
1387
1387
  group.addMember(writerInvite, "writerInvite");
1388
- const groupAsWriterInvite = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(writerInvite));
1388
+ const groupAsWriterInvite = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(writerInvite));
1389
1389
  groupAsWriterInvite.set(`${readKeyID}_for_${parentReadKeyID}`, encrypted, "trusting");
1390
1390
  expect(groupAsWriterInvite.get(`${readKeyID}_for_${parentReadKeyID}`)).toBeUndefined();
1391
1391
  });
1392
- test.skip("Reader invites can't reveal parent read keys to child groups", () => {
1392
+ test.skip("Reader invites can't reveal parent read keys to child groups", async () => {
1393
1393
  const { group, node } = newGroupHighLevel();
1394
1394
  const parentGroup = node.createGroup();
1395
1395
  const parentReadKeyID = parentGroup.get("readKey");
@@ -1404,11 +1404,11 @@ test.skip("Reader invites can't reveal parent read keys to child groups", () =>
1404
1404
  const encrypted = "fake_encrypted_key_secret";
1405
1405
  const readerInvite = createAccountInNode(node);
1406
1406
  group.addMember(readerInvite, "readerInvite");
1407
- const groupAsReaderInvite = expectGroup(group.core.contentInClonedNodeWithDifferentAccount(readerInvite));
1407
+ const groupAsReaderInvite = expectGroup(await group.core.contentInClonedNodeWithDifferentAccount(readerInvite));
1408
1408
  groupAsReaderInvite.set(`${readKeyID}_for_${parentReadKeyID}`, encrypted, "trusting");
1409
1409
  expect(groupAsReaderInvite.get(`${readKeyID}_for_${parentReadKeyID}`)).toBeUndefined();
1410
1410
  });
1411
- test("Writers and readers in a parent group can read from an object owned by a child group", () => {
1411
+ test("Writers and readers in a parent group can read from an object owned by a child group", async () => {
1412
1412
  const { group, node } = newGroupHighLevel();
1413
1413
  const parentGroup = node.createGroup();
1414
1414
  group.set(`parent_${parentGroup.id}`, "extend", "trusting");
@@ -1446,12 +1446,12 @@ test("Writers and readers in a parent group can read from an object owned by a c
1446
1446
  const childContent = expectMap(childObject.getCurrentContent());
1447
1447
  childContent.set("foo", "bar", "private");
1448
1448
  expect(childContent.get("foo")).toEqual("bar");
1449
- const childContentAsWriter = expectMap(childObject.contentInClonedNodeWithDifferentAccount(writer));
1449
+ const childContentAsWriter = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(writer));
1450
1450
  expect(childContentAsWriter.get("foo")).toEqual("bar");
1451
- const childContentAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
1451
+ const childContentAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
1452
1452
  expect(childContentAsReader.get("foo")).toEqual("bar");
1453
1453
  });
1454
- test("Writers in a parent group can write to an object owned by a child group", () => {
1454
+ test("Writers in a parent group can write to an object owned by a child group", async () => {
1455
1455
  const { group, node } = newGroupHighLevel();
1456
1456
  const parentGroup = node.createGroup();
1457
1457
  group.set(`parent_${parentGroup.id}`, "extend", "trusting");
@@ -1484,7 +1484,7 @@ test("Writers in a parent group can write to an object owned by a child group",
1484
1484
  meta: null,
1485
1485
  ...Crypto.createdNowUnique(),
1486
1486
  });
1487
- const childContentAsWriter = expectMap(childObject.contentInClonedNodeWithDifferentAccount(writer));
1487
+ const childContentAsWriter = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(writer));
1488
1488
  childContentAsWriter.set("foo", "bar", "private");
1489
1489
  expect(childContentAsWriter.get("foo")).toEqual("bar");
1490
1490
  });
@@ -1581,7 +1581,7 @@ test("When rotating the key of a grand-parent group, the keys of all child and g
1581
1581
  }
1582
1582
  expect(newChildReadKeyID).not.toEqual(currentChildReadKeyID);
1583
1583
  });
1584
- test("Calling extend on group sets up parent and child references and reveals child key to parent", () => {
1584
+ test("Calling extend on group sets up parent and child references and reveals child key to parent", async () => {
1585
1585
  const { group, node } = newGroupHighLevel();
1586
1586
  const parentGroup = node.createGroup();
1587
1587
  group.extend(parentGroup);
@@ -1606,10 +1606,10 @@ test("Calling extend on group sets up parent and child references and reveals ch
1606
1606
  });
1607
1607
  const childMap = expectMap(childObject.getCurrentContent());
1608
1608
  childMap.set("foo", "bar", "private");
1609
- const childContentAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
1609
+ const childContentAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
1610
1610
  expect(childContentAsReader.get("foo")).toEqual("bar");
1611
1611
  });
1612
- test("Calling extend to create grand-child groups parent and child references and reveals child key to parent(s)", () => {
1612
+ test("Calling extend to create grand-child groups parent and child references and reveals child key to parent(s)", async () => {
1613
1613
  const { group, node } = newGroupHighLevel();
1614
1614
  const parentGroup = node.createGroup();
1615
1615
  const grandParentGroup = node.createGroup();
@@ -1629,7 +1629,7 @@ test("Calling extend to create grand-child groups parent and child references an
1629
1629
  });
1630
1630
  const childMap = expectMap(childObject.getCurrentContent());
1631
1631
  childMap.set("foo", "bar", "private");
1632
- const childContentAsReader = expectMap(childObject.contentInClonedNodeWithDifferentAccount(reader));
1632
+ const childContentAsReader = expectMap(await childObject.contentInClonedNodeWithDifferentAccount(reader));
1633
1633
  expect(childContentAsReader.get("foo")).toEqual("bar");
1634
1634
  });
1635
1635
  test("revoking access on a child group doesn't block access to that group if a more permissive role is inheritable", async () => {
@@ -1700,12 +1700,12 @@ test("revoking write access to parent group", async () => {
1700
1700
  meta: null,
1701
1701
  ...Crypto.createdNowUnique(),
1702
1702
  });
1703
- const bobMap = expectMap(mapCore.contentInClonedNodeWithDifferentAccount(bob));
1703
+ const bobMap = expectMap(await mapCore.contentInClonedNodeWithDifferentAccount(bob));
1704
1704
  // `bob` sets `foo` to `bar`
1705
1705
  bobMap.set("foo", "bar", "private");
1706
1706
  // `bob`'s change is made successfully
1707
1707
  expect(bobMap.get("foo")).toEqual("bar");
1708
- const aliceMap = expectMap(mapCore.contentInClonedNodeWithDifferentAccount(alice));
1708
+ const aliceMap = expectMap(await mapCore.contentInClonedNodeWithDifferentAccount(alice));
1709
1709
  // `alice` sets `foo` to `baz`
1710
1710
  aliceMap.set("foo", "baz", "private");
1711
1711
  // `alice`'s change is made successfully
@@ -1716,7 +1716,7 @@ test("revoking write access to parent group", async () => {
1716
1716
  bobMap.set("foo", "abc", "private");
1717
1717
  // `bob`'s change is made successfully
1718
1718
  expect(bobMap.get("foo")).toEqual("abc");
1719
- const aliceMapAfterUnextend = expectMap(mapCore.contentInClonedNodeWithDifferentAccount(alice));
1719
+ const aliceMapAfterUnextend = expectMap(await mapCore.contentInClonedNodeWithDifferentAccount(alice));
1720
1720
  // `alice` attempts to set `foo` to `def`, but fails
1721
1721
  expect(() => aliceMapAfterUnextend.set("foo", "def", "private")).toThrow("Can't make transaction without read key secret");
1722
1722
  // `alice`'s change is not made successfully
@@ -1826,14 +1826,14 @@ test("High-level permissions work correctly when a group is extended", async ()
1826
1826
  });
1827
1827
  const map = expectMap(mapCore.getCurrentContent());
1828
1828
  map.set("foo", "bar", "private");
1829
- const mapAsReader = expectMap(mapCore.contentInClonedNodeWithDifferentAccount(reader));
1829
+ const mapAsReader = expectMap(await mapCore.contentInClonedNodeWithDifferentAccount(reader));
1830
1830
  expect(mapAsReader.get("foo")).toEqual("bar");
1831
1831
  const groupKeyBeforeRemove = group.core.getCurrentReadKey().id;
1832
1832
  await parentGroup.removeMember(reader);
1833
1833
  const groupKeyAfterRemove = group.core.getCurrentReadKey().id;
1834
1834
  expect(groupKeyAfterRemove).not.toEqual(groupKeyBeforeRemove);
1835
1835
  map.set("foo", "baz", "private");
1836
- const mapAsReaderAfterRemove = expectMap(mapCore.contentInClonedNodeWithDifferentAccount(reader));
1836
+ const mapAsReaderAfterRemove = expectMap(await mapCore.contentInClonedNodeWithDifferentAccount(reader));
1837
1837
  expect(mapAsReaderAfterRemove.get("foo")).not.toEqual("baz");
1838
1838
  });
1839
1839
  test("self-extensions should not break the permissions checks", () => {
@@ -1890,7 +1890,7 @@ test("Can revoke read permission from 'everyone'", async () => {
1890
1890
  expect(childObject.get("foo")).toEqual("bar");
1891
1891
  // Create a new account to verify access
1892
1892
  const newAccount = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
1893
- const childContent = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(newAccount));
1893
+ const childContent = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(newAccount));
1894
1894
  // Verify the new account can read
1895
1895
  expect(childContent.get("foo")).toEqual("bar");
1896
1896
  // Revoke everyone's access
@@ -1898,7 +1898,7 @@ test("Can revoke read permission from 'everyone'", async () => {
1898
1898
  childObject.set("foo", "updated after revoke", "private");
1899
1899
  // Create another new account to verify access is revoked
1900
1900
  const newAccount2 = new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto);
1901
- const childContent2 = expectMap(childObject.core.contentInClonedNodeWithDifferentAccount(newAccount2));
1901
+ const childContent2 = expectMap(await childObject.core.contentInClonedNodeWithDifferentAccount(newAccount2));
1902
1902
  // Verify the new account cannot read after revocation
1903
1903
  expect(childContent2.get("foo")).toEqual("bar");
1904
1904
  });