cojson 0.3.6 → 0.4.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.
Files changed (81) hide show
  1. package/dist/coValue.d.ts +7 -12
  2. package/dist/coValue.js.map +1 -1
  3. package/dist/coValueCore.d.ts +9 -4
  4. package/dist/coValueCore.js +69 -33
  5. package/dist/coValueCore.js.map +1 -1
  6. package/dist/coValues/account.d.ts +62 -0
  7. package/dist/{account.js → coValues/account.js} +19 -11
  8. package/dist/coValues/account.js.map +1 -0
  9. package/dist/coValues/coList.d.ts +19 -19
  10. package/dist/coValues/coList.js.map +1 -1
  11. package/dist/coValues/coMap.d.ts +31 -23
  12. package/dist/coValues/coMap.js +4 -6
  13. package/dist/coValues/coMap.js.map +1 -1
  14. package/dist/coValues/coStream.d.ts +19 -19
  15. package/dist/coValues/coStream.js.map +1 -1
  16. package/dist/{group.d.ts → coValues/group.d.ts} +27 -38
  17. package/dist/{group.js → coValues/group.js} +69 -73
  18. package/dist/coValues/group.js.map +1 -0
  19. package/dist/ids.d.ts +1 -1
  20. package/dist/index.d.ts +15 -11
  21. package/dist/index.js +10 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/localNode.d.ts +20 -7
  24. package/dist/localNode.js +74 -39
  25. package/dist/localNode.js.map +1 -1
  26. package/dist/media.d.ts +1 -1
  27. package/dist/permissions.d.ts +1 -1
  28. package/dist/permissions.js +43 -22
  29. package/dist/permissions.js.map +1 -1
  30. package/dist/queriedCoValues/queriedAccount.d.ts +13 -0
  31. package/dist/queriedCoValues/queriedAccount.js +24 -0
  32. package/dist/queriedCoValues/queriedAccount.js.map +1 -0
  33. package/dist/queriedCoValues/queriedCoList.d.ts +10 -10
  34. package/dist/queriedCoValues/queriedCoList.js +11 -15
  35. package/dist/queriedCoValues/queriedCoList.js.map +1 -1
  36. package/dist/queriedCoValues/queriedCoMap.d.ts +14 -21
  37. package/dist/queriedCoValues/queriedCoMap.js +27 -28
  38. package/dist/queriedCoValues/queriedCoMap.js.map +1 -1
  39. package/dist/queriedCoValues/queriedCoStream.d.ts +9 -9
  40. package/dist/queriedCoValues/queriedCoStream.js +44 -20
  41. package/dist/queriedCoValues/queriedCoStream.js.map +1 -1
  42. package/dist/queriedCoValues/queriedGroup.d.ts +29 -0
  43. package/dist/queriedCoValues/queriedGroup.js +54 -0
  44. package/dist/queriedCoValues/queriedGroup.js.map +1 -0
  45. package/dist/queries.d.ts +40 -9
  46. package/dist/queries.js +104 -39
  47. package/dist/queries.js.map +1 -1
  48. package/dist/sync.js +1 -0
  49. package/dist/sync.js.map +1 -1
  50. package/dist/tests/testUtils.d.ts +15 -7
  51. package/dist/tests/testUtils.js +16 -17
  52. package/dist/tests/testUtils.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/coValue.ts +12 -31
  55. package/src/coValueCore.ts +100 -40
  56. package/src/{account.ts → coValues/account.ts} +46 -27
  57. package/src/coValues/coList.ts +24 -28
  58. package/src/coValues/coMap.ts +42 -68
  59. package/src/coValues/coStream.ts +20 -26
  60. package/src/{group.ts → coValues/group.ts} +121 -141
  61. package/src/ids.ts +1 -1
  62. package/src/index.ts +25 -10
  63. package/src/localNode.ts +180 -77
  64. package/src/media.ts +1 -1
  65. package/src/permissions.ts +67 -36
  66. package/src/queriedCoValues/queriedAccount.ts +40 -0
  67. package/src/queriedCoValues/queriedCoList.ts +22 -30
  68. package/src/queriedCoValues/queriedCoMap.ts +60 -72
  69. package/src/queriedCoValues/queriedCoStream.ts +67 -37
  70. package/src/queriedCoValues/queriedGroup.ts +90 -0
  71. package/src/queries.ts +181 -60
  72. package/src/sync.ts +1 -0
  73. package/src/tests/account.test.ts +14 -9
  74. package/src/tests/coValueCore.test.ts +2 -2
  75. package/src/tests/permissions.test.ts +351 -242
  76. package/src/tests/queries.test.ts +98 -79
  77. package/src/tests/sync.test.ts +11 -11
  78. package/src/tests/testUtils.ts +16 -18
  79. package/dist/account.d.ts +0 -58
  80. package/dist/account.js.map +0 -1
  81. package/dist/group.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { newRandomSessionID } from "../coValueCore.js";
2
2
  import { expectMap } from "../coValue.js";
3
- import { Group, expectGroupContent } from "../group.js";
3
+ import { Group, expectGroup } from "../coValues/group.js";
4
4
  import {
5
5
  createdNowUnique,
6
6
  newRandomKeySecret,
@@ -32,123 +32,105 @@ test("Initial admin can add another admin to a group (high level)", () => {
32
32
  });
33
33
 
34
34
  test("Added admin can add a third admin to a group", () => {
35
- const { group, otherAdmin, node } = groupWithTwoAdmins();
35
+ const { groupCore, otherAdmin, node } = groupWithTwoAdmins();
36
36
 
37
- const groupAsOtherAdmin = group.testWithDifferentAccount(
37
+ let groupAsOtherAdmin = expectGroup(groupCore.testWithDifferentAccount(
38
38
  otherAdmin,
39
39
  newRandomSessionID(otherAdmin.id)
40
- );
41
-
42
- let otherContent = expectGroupContent(
43
- groupAsOtherAdmin.getCurrentContent()
44
- );
40
+ ).getCurrentContent());
45
41
 
46
- expect(otherContent.get(otherAdmin.id)).toEqual("admin");
42
+ expect(groupAsOtherAdmin.get(otherAdmin.id)).toEqual("admin");
47
43
 
48
44
  const thirdAdmin = node.createAccount("thirdAdmin");
49
45
 
50
- otherContent.edit((editable) => {
46
+ groupAsOtherAdmin = groupAsOtherAdmin.edit((editable) => {
51
47
  editable.set(thirdAdmin.id, "admin", "trusting");
52
48
  expect(editable.get(thirdAdmin.id)).toEqual("admin");
53
49
  });
54
50
 
55
- otherContent = expectGroupContent(groupAsOtherAdmin.getCurrentContent());
56
-
57
- expect(otherContent.get(thirdAdmin.id)).toEqual("admin");
51
+ expect(groupAsOtherAdmin.get(thirdAdmin.id)).toEqual("admin");
58
52
  });
59
53
 
60
54
  test("Added adming can add a third admin to a group (high level)", () => {
61
55
  const { group, otherAdmin, node } = groupWithTwoAdminsHighLevel();
62
56
 
63
- const groupAsOtherAdmin = group.testWithDifferentAccount(
57
+ let groupAsOtherAdmin = expectGroup(group.core.testWithDifferentAccount(
64
58
  otherAdmin,
65
59
  newRandomSessionID(otherAdmin.id)
66
- );
60
+ ).getCurrentContent());
67
61
 
68
- const thirdAdmin = node.createAccount("thirdAdmin");
62
+ const thirdAdmin = groupAsOtherAdmin.core.node.createAccount("thirdAdmin");
69
63
 
70
- groupAsOtherAdmin.addMember(thirdAdmin.id, "admin");
64
+ groupAsOtherAdmin = groupAsOtherAdmin.addMember(thirdAdmin.id, "admin");
71
65
 
72
- expect(groupAsOtherAdmin.underlyingMap.get(thirdAdmin.id)).toEqual("admin");
66
+ expect(groupAsOtherAdmin.get(thirdAdmin.id)).toEqual("admin");
73
67
  });
74
68
 
75
69
  test("Admins can't demote other admins in a group", () => {
76
- const { group, admin, otherAdmin } = groupWithTwoAdmins();
70
+ const { groupCore, admin, otherAdmin } = groupWithTwoAdmins();
77
71
 
78
- let groupContent = expectGroupContent(group.getCurrentContent());
72
+ let groupContent = expectGroup(groupCore.getCurrentContent());
79
73
 
80
- groupContent.edit((editable) => {
74
+ groupContent = groupContent.edit((editable) => {
81
75
  editable.set(otherAdmin.id, "writer", "trusting");
82
76
  expect(editable.get(otherAdmin.id)).toEqual("admin");
83
77
  });
84
78
 
85
- groupContent = expectGroupContent(group.getCurrentContent());
86
79
  expect(groupContent.get(otherAdmin.id)).toEqual("admin");
87
80
 
88
- const groupAsOtherAdmin = group.testWithDifferentAccount(
81
+ let groupAsOtherAdmin = expectGroup(groupCore.testWithDifferentAccount(
89
82
  otherAdmin,
90
83
  newRandomSessionID(otherAdmin.id)
91
- );
84
+ ).getCurrentContent());
92
85
 
93
- let groupContentAsOtherAdmin = expectGroupContent(
94
- groupAsOtherAdmin.getCurrentContent()
95
- );
96
-
97
- groupContentAsOtherAdmin.edit((editable) => {
86
+ groupAsOtherAdmin = groupAsOtherAdmin.edit((editable) => {
98
87
  editable.set(admin.id, "writer", "trusting");
99
88
  expect(editable.get(admin.id)).toEqual("admin");
100
89
  });
101
90
 
102
- groupContentAsOtherAdmin = expectGroupContent(
103
- groupAsOtherAdmin.getCurrentContent()
104
- );
105
-
106
- expect(groupContentAsOtherAdmin.get(admin.id)).toEqual("admin");
91
+ expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
107
92
  });
108
93
 
109
94
  test("Admins can't demote other admins in a group (high level)", () => {
110
95
  const { group, admin, otherAdmin } = groupWithTwoAdminsHighLevel();
111
96
 
112
- const groupAsOtherAdmin = group.testWithDifferentAccount(
97
+ const groupAsOtherAdmin = expectGroup(group.core.testWithDifferentAccount(
113
98
  otherAdmin,
114
99
  newRandomSessionID(otherAdmin.id)
115
- );
100
+ ).getCurrentContent());
116
101
 
117
102
  expect(() =>
118
103
  groupAsOtherAdmin.addMemberInternal(admin.id, "writer")
119
104
  ).toThrow("Failed to set role");
120
105
 
121
- expect(groupAsOtherAdmin.underlyingMap.get(admin.id)).toEqual("admin");
106
+ expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
122
107
  });
123
108
 
124
109
  test("Admins an add writers to a group, who can't add admins, writers, or readers", () => {
125
- const { group, node } = newGroup();
110
+ const { groupCore, node } = newGroup();
126
111
  const writer = node.createAccount("writer");
127
112
 
128
- let groupContent = expectGroupContent(group.getCurrentContent());
113
+ let groupContent = expectGroup(groupCore.getCurrentContent());
129
114
 
130
115
  groupContent.edit((editable) => {
131
116
  editable.set(writer.id, "writer", "trusting");
132
117
  expect(editable.get(writer.id)).toEqual("writer");
133
118
  });
134
119
 
135
- groupContent = expectGroupContent(group.getCurrentContent());
120
+ groupContent = expectGroup(groupCore.getCurrentContent());
136
121
  expect(groupContent.get(writer.id)).toEqual("writer");
137
122
 
138
- const groupAsWriter = group.testWithDifferentAccount(
123
+ let groupAsWriter = expectGroup(groupCore.testWithDifferentAccount(
139
124
  writer,
140
125
  newRandomSessionID(writer.id)
141
- );
126
+ ).getCurrentContent());
142
127
 
143
- let groupContentAsWriter = expectGroupContent(
144
- groupAsWriter.getCurrentContent()
145
- );
146
128
 
147
- expect(groupContentAsWriter.get(writer.id)).toEqual("writer");
129
+ expect(groupAsWriter.get(writer.id)).toEqual("writer");
148
130
 
149
131
  const otherAgent = node.createAccount("otherAgent");
150
132
 
151
- groupContentAsWriter.edit((editable) => {
133
+ groupAsWriter = groupAsWriter.edit((editable) => {
152
134
  editable.set(otherAgent.id, "admin", "trusting");
153
135
  expect(editable.get(otherAgent.id)).toBeUndefined();
154
136
 
@@ -159,29 +141,25 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
159
141
  expect(editable.get(otherAgent.id)).toBeUndefined();
160
142
  });
161
143
 
162
- groupContentAsWriter = expectGroupContent(
163
- groupAsWriter.getCurrentContent()
164
- );
165
-
166
- expect(groupContentAsWriter.get(otherAgent.id)).toBeUndefined();
144
+ expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
167
145
  });
168
146
 
169
147
  test("Admins an add writers to a group, who can't add admins, writers, or readers (high level)", () => {
170
- const { group, node } = newGroupHighLevel();
148
+ let { group, node } = newGroupHighLevel();
171
149
 
172
150
  const writer = node.createAccount("writer");
173
151
 
174
- group.addMember(writer.id, "writer");
175
- expect(group.underlyingMap.get(writer.id)).toEqual("writer");
152
+ group = group.addMember(writer.id, "writer");
153
+ expect(group.get(writer.id)).toEqual("writer");
176
154
 
177
- const groupAsWriter = group.testWithDifferentAccount(
155
+ const groupAsWriter = expectGroup(group.core.testWithDifferentAccount(
178
156
  writer,
179
157
  newRandomSessionID(writer.id)
180
- );
158
+ ).getCurrentContent());
181
159
 
182
- expect(groupAsWriter.underlyingMap.get(writer.id)).toEqual("writer");
160
+ expect(groupAsWriter.get(writer.id)).toEqual("writer");
183
161
 
184
- const otherAgent = node.createAccount("otherAgent");
162
+ const otherAgent = groupAsWriter.core.node.createAccount("otherAgent");
185
163
 
186
164
  expect(() => groupAsWriter.addMember(otherAgent.id, "admin")).toThrow(
187
165
  "Failed to set role"
@@ -193,37 +171,33 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
193
171
  "Failed to set role"
194
172
  );
195
173
 
196
- expect(groupAsWriter.underlyingMap.get(otherAgent.id)).toBeUndefined();
174
+ expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
197
175
  });
198
176
 
199
177
  test("Admins can add readers to a group, who can't add admins, writers, or readers", () => {
200
- const { group, node } = newGroup();
178
+ const { groupCore, node } = newGroup();
201
179
  const reader = node.createAccount("reader");
202
180
 
203
- let groupContent = expectGroupContent(group.getCurrentContent());
181
+ let groupContent = expectGroup(groupCore.getCurrentContent());
204
182
 
205
183
  groupContent.edit((editable) => {
206
184
  editable.set(reader.id, "reader", "trusting");
207
185
  expect(editable.get(reader.id)).toEqual("reader");
208
186
  });
209
187
 
210
- groupContent = expectGroupContent(group.getCurrentContent());
188
+ groupContent = expectGroup(groupCore.getCurrentContent());
211
189
  expect(groupContent.get(reader.id)).toEqual("reader");
212
190
 
213
- const groupAsReader = group.testWithDifferentAccount(
191
+ let groupAsReader = expectGroup(groupCore.testWithDifferentAccount(
214
192
  reader,
215
193
  newRandomSessionID(reader.id)
216
- );
217
-
218
- let groupContentAsReader = expectGroupContent(
219
- groupAsReader.getCurrentContent()
220
- );
194
+ ).getCurrentContent());
221
195
 
222
- expect(groupContentAsReader.get(reader.id)).toEqual("reader");
196
+ expect(groupAsReader.get(reader.id)).toEqual("reader");
223
197
 
224
198
  const otherAgent = node.createAccount("otherAgent");
225
199
 
226
- groupContentAsReader.edit((editable) => {
200
+ groupAsReader = groupAsReader.edit((editable) => {
227
201
  editable.set(otherAgent.id, "admin", "trusting");
228
202
  expect(editable.get(otherAgent.id)).toBeUndefined();
229
203
 
@@ -234,29 +208,25 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
234
208
  expect(editable.get(otherAgent.id)).toBeUndefined();
235
209
  });
236
210
 
237
- groupContentAsReader = expectGroupContent(
238
- groupAsReader.getCurrentContent()
239
- );
240
-
241
- expect(groupContentAsReader.get(otherAgent.id)).toBeUndefined();
211
+ expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
242
212
  });
243
213
 
244
214
  test("Admins can add readers to a group, who can't add admins, writers, or readers (high level)", () => {
245
- const { group, node } = newGroupHighLevel();
215
+ let { group, node } = newGroupHighLevel();
246
216
 
247
217
  const reader = node.createAccount("reader");
248
218
 
249
- group.addMember(reader.id, "reader");
250
- expect(group.underlyingMap.get(reader.id)).toEqual("reader");
219
+ group = group.addMember(reader.id, "reader");
220
+ expect(group.get(reader.id)).toEqual("reader");
251
221
 
252
- const groupAsReader = group.testWithDifferentAccount(
222
+ const groupAsReader = expectGroup(group.core.testWithDifferentAccount(
253
223
  reader,
254
224
  newRandomSessionID(reader.id)
255
- );
225
+ ).getCurrentContent());
256
226
 
257
- expect(groupAsReader.underlyingMap.get(reader.id)).toEqual("reader");
227
+ expect(groupAsReader.get(reader.id)).toEqual("reader");
258
228
 
259
- const otherAgent = node.createAccount("otherAgent");
229
+ const otherAgent = groupAsReader.core.node.createAccount("otherAgent");
260
230
 
261
231
  expect(() => groupAsReader.addMember(otherAgent.id, "admin")).toThrow(
262
232
  "Failed to set role"
@@ -268,15 +238,15 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
268
238
  "Failed to set role"
269
239
  );
270
240
 
271
- expect(groupAsReader.underlyingMap.get(otherAgent.id)).toBeUndefined();
241
+ expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
272
242
  });
273
243
 
274
244
  test("Admins can write to an object that is owned by their group", () => {
275
- const { node, group } = newGroup();
245
+ const { node, groupCore } = newGroup();
276
246
 
277
247
  const childObject = node.createCoValue({
278
248
  type: "comap",
279
- ruleset: { type: "ownedByGroup", group: group.id },
249
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
280
250
  meta: null,
281
251
  ...createdNowUnique(),
282
252
  });
@@ -307,18 +277,18 @@ test("Admins can write to an object that is owned by their group (high level)",
307
277
  });
308
278
 
309
279
  test("Writers can write to an object that is owned by their group", () => {
310
- const { node, group } = newGroup();
280
+ const { node, groupCore } = newGroup();
311
281
 
312
282
  const writer = node.createAccount("writer");
313
283
 
314
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
284
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
315
285
  editable.set(writer.id, "writer", "trusting");
316
286
  expect(editable.get(writer.id)).toEqual("writer");
317
287
  });
318
288
 
319
289
  const childObject = node.createCoValue({
320
290
  type: "comap",
321
- ruleset: { type: "ownedByGroup", group: group.id },
291
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
322
292
  meta: null,
323
293
  ...createdNowUnique(),
324
294
  });
@@ -366,18 +336,18 @@ test("Writers can write to an object that is owned by their group (high level)",
366
336
  });
367
337
 
368
338
  test("Readers can not write to an object that is owned by their group", () => {
369
- const { node, group } = newGroup();
339
+ const { node, groupCore } = newGroup();
370
340
 
371
341
  const reader = node.createAccount("reader");
372
342
 
373
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
343
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
374
344
  editable.set(reader.id, "reader", "trusting");
375
345
  expect(editable.get(reader.id)).toEqual("reader");
376
346
  });
377
347
 
378
348
  const childObject = node.createCoValue({
379
349
  type: "comap",
380
- ruleset: { type: "ownedByGroup", group: group.id },
350
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
381
351
  meta: null,
382
352
  ...createdNowUnique(),
383
353
  });
@@ -425,9 +395,9 @@ test("Readers can not write to an object that is owned by their group (high leve
425
395
  });
426
396
 
427
397
  test("Admins can set group read key and then use it to create and read private transactions in owned objects", () => {
428
- const { node, group, admin } = newGroup();
398
+ const { node, groupCore, admin } = newGroup();
429
399
 
430
- const groupContent = expectGroupContent(group.getCurrentContent());
400
+ const groupContent = expectGroup(groupCore.getCurrentContent());
431
401
 
432
402
  groupContent.edit((editable) => {
433
403
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
@@ -436,8 +406,8 @@ test("Admins can set group read key and then use it to create and read private t
436
406
  from: admin.currentSealerSecret(),
437
407
  to: admin.currentSealerID(),
438
408
  nOnceMaterial: {
439
- in: group.id,
440
- tx: group.nextTransactionID(),
409
+ in: groupCore.id,
410
+ tx: groupCore.nextTransactionID(),
441
411
  },
442
412
  });
443
413
 
@@ -451,12 +421,12 @@ test("Admins can set group read key and then use it to create and read private t
451
421
 
452
422
  expect(editable.get("readKey")).toEqual(readKeyID);
453
423
 
454
- expect(group.getCurrentReadKey().secret).toEqual(readKey);
424
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
455
425
  });
456
426
 
457
427
  const childObject = node.createCoValue({
458
428
  type: "comap",
459
- ruleset: { type: "ownedByGroup", group: group.id },
429
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
460
430
  meta: null,
461
431
  ...createdNowUnique(),
462
432
  });
@@ -486,13 +456,13 @@ test("Admins can set group read key and then use it to create and read private t
486
456
  });
487
457
 
488
458
  test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects", () => {
489
- const { node, group, admin } = newGroup();
459
+ const { node, groupCore, admin } = newGroup();
490
460
 
491
461
  const writer = node.createAccount("writer");
492
462
 
493
463
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
494
464
 
495
- const groupContent = expectGroupContent(group.getCurrentContent());
465
+ const groupContent = expectGroup(groupCore.getCurrentContent());
496
466
 
497
467
  groupContent.edit((editable) => {
498
468
  editable.set(writer.id, "writer", "trusting");
@@ -503,8 +473,8 @@ test("Admins can set group read key and then writers can use it to create and re
503
473
  from: admin.currentSealerSecret(),
504
474
  to: admin.currentSealerID(),
505
475
  nOnceMaterial: {
506
- in: group.id,
507
- tx: group.nextTransactionID(),
476
+ in: groupCore.id,
477
+ tx: groupCore.nextTransactionID(),
508
478
  },
509
479
  });
510
480
 
@@ -515,8 +485,8 @@ test("Admins can set group read key and then writers can use it to create and re
515
485
  from: admin.currentSealerSecret(),
516
486
  to: writer.currentSealerID(),
517
487
  nOnceMaterial: {
518
- in: group.id,
519
- tx: group.nextTransactionID(),
488
+ in: groupCore.id,
489
+ tx: groupCore.nextTransactionID(),
520
490
  },
521
491
  });
522
492
 
@@ -527,7 +497,7 @@ test("Admins can set group read key and then writers can use it to create and re
527
497
 
528
498
  const childObject = node.createCoValue({
529
499
  type: "comap",
530
- ruleset: { type: "ownedByGroup", group: group.id },
500
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
531
501
  meta: null,
532
502
  ...createdNowUnique(),
533
503
  });
@@ -577,13 +547,13 @@ test("Admins can set group read key and then writers can use it to create and re
577
547
  });
578
548
 
579
549
  test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read", () => {
580
- const { node, group, admin } = newGroup();
550
+ const { node, groupCore, admin } = newGroup();
581
551
 
582
552
  const reader = node.createAccount("reader");
583
553
 
584
554
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
585
555
 
586
- const groupContent = expectGroupContent(group.getCurrentContent());
556
+ const groupContent = expectGroup(groupCore.getCurrentContent());
587
557
 
588
558
  groupContent.edit((editable) => {
589
559
  editable.set(reader.id, "reader", "trusting");
@@ -594,8 +564,8 @@ test("Admins can set group read key and then use it to create private transactio
594
564
  from: admin.currentSealerSecret(),
595
565
  to: admin.currentSealerID(),
596
566
  nOnceMaterial: {
597
- in: group.id,
598
- tx: group.nextTransactionID(),
567
+ in: groupCore.id,
568
+ tx: groupCore.nextTransactionID(),
599
569
  },
600
570
  });
601
571
 
@@ -606,8 +576,8 @@ test("Admins can set group read key and then use it to create private transactio
606
576
  from: admin.currentSealerSecret(),
607
577
  to: reader.currentSealerID(),
608
578
  nOnceMaterial: {
609
- in: group.id,
610
- tx: group.nextTransactionID(),
579
+ in: groupCore.id,
580
+ tx: groupCore.nextTransactionID(),
611
581
  },
612
582
  });
613
583
 
@@ -618,7 +588,7 @@ test("Admins can set group read key and then use it to create private transactio
618
588
 
619
589
  const childObject = node.createCoValue({
620
590
  type: "comap",
621
- ruleset: { type: "ownedByGroup", group: group.id },
591
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
622
592
  meta: null,
623
593
  ...createdNowUnique(),
624
594
  });
@@ -666,7 +636,7 @@ test("Admins can set group read key and then use it to create private transactio
666
636
  });
667
637
 
668
638
  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", () => {
669
- const { node, group, admin } = newGroup();
639
+ const { node, groupCore, admin } = newGroup();
670
640
 
671
641
  const reader1 = node.createAccount("reader1");
672
642
 
@@ -674,7 +644,7 @@ test("Admins can set group read key and then use it to create private transactio
674
644
 
675
645
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
676
646
 
677
- const groupContent = expectGroupContent(group.getCurrentContent());
647
+ const groupContent = expectGroup(groupCore.getCurrentContent());
678
648
 
679
649
  groupContent.edit((editable) => {
680
650
  editable.set(reader1.id, "reader", "trusting");
@@ -685,8 +655,8 @@ test("Admins can set group read key and then use it to create private transactio
685
655
  from: admin.currentSealerSecret(),
686
656
  to: admin.currentSealerID(),
687
657
  nOnceMaterial: {
688
- in: group.id,
689
- tx: group.nextTransactionID(),
658
+ in: groupCore.id,
659
+ tx: groupCore.nextTransactionID(),
690
660
  },
691
661
  });
692
662
 
@@ -697,8 +667,8 @@ test("Admins can set group read key and then use it to create private transactio
697
667
  from: admin.currentSealerSecret(),
698
668
  to: reader1.currentSealerID(),
699
669
  nOnceMaterial: {
700
- in: group.id,
701
- tx: group.nextTransactionID(),
670
+ in: groupCore.id,
671
+ tx: groupCore.nextTransactionID(),
702
672
  },
703
673
  });
704
674
 
@@ -709,7 +679,7 @@ test("Admins can set group read key and then use it to create private transactio
709
679
 
710
680
  const childObject = node.createCoValue({
711
681
  type: "comap",
712
- ruleset: { type: "ownedByGroup", group: group.id },
682
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
713
683
  meta: null,
714
684
  ...createdNowUnique(),
715
685
  });
@@ -738,8 +708,8 @@ test("Admins can set group read key and then use it to create private transactio
738
708
  from: admin.currentSealerSecret(),
739
709
  to: reader2.currentSealerID(),
740
710
  nOnceMaterial: {
741
- in: group.id,
742
- tx: group.nextTransactionID(),
711
+ in: groupCore.id,
712
+ tx: groupCore.nextTransactionID(),
743
713
  },
744
714
  });
745
715
 
@@ -796,9 +766,9 @@ test("Admins can set group read key and then use it to create private transactio
796
766
  });
797
767
 
798
768
  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", () => {
799
- const { node, group, admin } = newGroup();
769
+ const { node, groupCore, admin } = newGroup();
800
770
 
801
- const groupContent = expectGroupContent(group.getCurrentContent());
771
+ const groupContent = expectGroup(groupCore.getCurrentContent());
802
772
 
803
773
  groupContent.edit((editable) => {
804
774
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
@@ -807,8 +777,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
807
777
  from: admin.currentSealerSecret(),
808
778
  to: admin.currentSealerID(),
809
779
  nOnceMaterial: {
810
- in: group.id,
811
- tx: group.nextTransactionID(),
780
+ in: groupCore.id,
781
+ tx: groupCore.nextTransactionID(),
812
782
  },
813
783
  });
814
784
 
@@ -816,12 +786,12 @@ test("Admins can set group read key, make a private transaction in an owned obje
816
786
 
817
787
  editable.set("readKey", readKeyID, "trusting");
818
788
  expect(editable.get("readKey")).toEqual(readKeyID);
819
- expect(group.getCurrentReadKey().secret).toEqual(readKey);
789
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
820
790
  });
821
791
 
822
792
  const childObject = node.createCoValue({
823
793
  type: "comap",
824
- ruleset: { type: "ownedByGroup", group: group.id },
794
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
825
795
  meta: null,
826
796
  ...createdNowUnique(),
827
797
  });
@@ -844,8 +814,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
844
814
  from: admin.currentSealerSecret(),
845
815
  to: admin.currentSealerID(),
846
816
  nOnceMaterial: {
847
- in: group.id,
848
- tx: group.nextTransactionID(),
817
+ in: groupCore.id,
818
+ tx: groupCore.nextTransactionID(),
849
819
  },
850
820
  });
851
821
 
@@ -853,7 +823,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
853
823
 
854
824
  editable.set("readKey", readKeyID2, "trusting");
855
825
  expect(editable.get("readKey")).toEqual(readKeyID2);
856
- expect(group.getCurrentReadKey().secret).toEqual(readKey2);
826
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
857
827
  });
858
828
 
859
829
  childContent = expectMap(childObject.getCurrentContent());
@@ -896,16 +866,16 @@ test("Admins can set group read key, make a private transaction in an owned obje
896
866
  });
897
867
 
898
868
  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", () => {
899
- const { node, group, admin } = newGroup();
869
+ const { node, groupCore, admin } = newGroup();
900
870
 
901
871
  const childObject = node.createCoValue({
902
872
  type: "comap",
903
- ruleset: { type: "ownedByGroup", group: group.id },
873
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
904
874
  meta: null,
905
875
  ...createdNowUnique(),
906
876
  });
907
877
 
908
- const groupContent = expectGroupContent(group.getCurrentContent());
878
+ const groupContent = expectGroup(groupCore.getCurrentContent());
909
879
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
910
880
 
911
881
  groupContent.edit((editable) => {
@@ -914,8 +884,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
914
884
  from: admin.currentSealerSecret(),
915
885
  to: admin.currentSealerID(),
916
886
  nOnceMaterial: {
917
- in: group.id,
918
- tx: group.nextTransactionID(),
887
+ in: groupCore.id,
888
+ tx: groupCore.nextTransactionID(),
919
889
  },
920
890
  });
921
891
 
@@ -923,7 +893,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
923
893
 
924
894
  editable.set("readKey", readKeyID, "trusting");
925
895
  expect(editable.get("readKey")).toEqual(readKeyID);
926
- expect(group.getCurrentReadKey().secret).toEqual(readKey);
896
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
927
897
  });
928
898
 
929
899
  let childContent = expectMap(childObject.getCurrentContent());
@@ -946,8 +916,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
946
916
  from: admin.currentSealerSecret(),
947
917
  to: admin.currentSealerID(),
948
918
  nOnceMaterial: {
949
- in: group.id,
950
- tx: group.nextTransactionID(),
919
+ in: groupCore.id,
920
+ tx: groupCore.nextTransactionID(),
951
921
  },
952
922
  });
953
923
 
@@ -958,8 +928,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
958
928
  from: admin.currentSealerSecret(),
959
929
  to: reader.currentSealerID(),
960
930
  nOnceMaterial: {
961
- in: group.id,
962
- tx: group.nextTransactionID(),
931
+ in: groupCore.id,
932
+ tx: groupCore.nextTransactionID(),
963
933
  },
964
934
  });
965
935
 
@@ -977,7 +947,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
977
947
  editable.set("readKey", readKeyID2, "trusting");
978
948
 
979
949
  expect(editable.get("readKey")).toEqual(readKeyID2);
980
- expect(group.getCurrentReadKey().secret).toEqual(readKey2);
950
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
981
951
 
982
952
  editable.set(reader.id, "reader", "trusting");
983
953
  expect(editable.get(reader.id)).toEqual("reader");
@@ -1041,16 +1011,16 @@ test("Admins can set group read key, make a private transaction in an owned obje
1041
1011
  });
1042
1012
 
1043
1013
  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", () => {
1044
- const { node, group, admin } = newGroup();
1014
+ const { node, groupCore, admin } = newGroup();
1045
1015
 
1046
1016
  const childObject = node.createCoValue({
1047
1017
  type: "comap",
1048
- ruleset: { type: "ownedByGroup", group: group.id },
1018
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
1049
1019
  meta: null,
1050
1020
  ...createdNowUnique(),
1051
1021
  });
1052
1022
 
1053
- const groupContent = expectGroupContent(group.getCurrentContent());
1023
+ const groupContent = expectGroup(groupCore.getCurrentContent());
1054
1024
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1055
1025
  const reader = node.createAccount("reader");
1056
1026
 
@@ -1062,8 +1032,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1062
1032
  from: admin.currentSealerSecret(),
1063
1033
  to: admin.currentSealerID(),
1064
1034
  nOnceMaterial: {
1065
- in: group.id,
1066
- tx: group.nextTransactionID(),
1035
+ in: groupCore.id,
1036
+ tx: groupCore.nextTransactionID(),
1067
1037
  },
1068
1038
  });
1069
1039
 
@@ -1074,8 +1044,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1074
1044
  from: admin.currentSealerSecret(),
1075
1045
  to: reader.currentSealerID(),
1076
1046
  nOnceMaterial: {
1077
- in: group.id,
1078
- tx: group.nextTransactionID(),
1047
+ in: groupCore.id,
1048
+ tx: groupCore.nextTransactionID(),
1079
1049
  },
1080
1050
  });
1081
1051
 
@@ -1086,8 +1056,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1086
1056
  from: admin.currentSealerSecret(),
1087
1057
  to: reader2.currentSealerID(),
1088
1058
  nOnceMaterial: {
1089
- in: group.id,
1090
- tx: group.nextTransactionID(),
1059
+ in: groupCore.id,
1060
+ tx: groupCore.nextTransactionID(),
1091
1061
  },
1092
1062
  });
1093
1063
 
@@ -1095,7 +1065,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1095
1065
 
1096
1066
  editable.set("readKey", readKeyID, "trusting");
1097
1067
  expect(editable.get("readKey")).toEqual(readKeyID);
1098
- expect(group.getCurrentReadKey().secret).toEqual(readKey);
1068
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
1099
1069
 
1100
1070
  editable.set(reader.id, "reader", "trusting");
1101
1071
  expect(editable.get(reader.id)).toEqual("reader");
@@ -1139,8 +1109,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1139
1109
  from: admin.currentSealerSecret(),
1140
1110
  to: admin.currentSealerID(),
1141
1111
  nOnceMaterial: {
1142
- in: group.id,
1143
- tx: group.nextTransactionID(),
1112
+ in: groupCore.id,
1113
+ tx: groupCore.nextTransactionID(),
1144
1114
  },
1145
1115
  });
1146
1116
 
@@ -1155,8 +1125,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1155
1125
  from: admin.currentSealerSecret(),
1156
1126
  to: reader2.currentSealerID(),
1157
1127
  nOnceMaterial: {
1158
- in: group.id,
1159
- tx: group.nextTransactionID(),
1128
+ in: groupCore.id,
1129
+ tx: groupCore.nextTransactionID(),
1160
1130
  },
1161
1131
  });
1162
1132
 
@@ -1168,7 +1138,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1168
1138
 
1169
1139
  editable.set("readKey", readKeyID2, "trusting");
1170
1140
  expect(editable.get("readKey")).toEqual(readKeyID2);
1171
- expect(group.getCurrentReadKey().secret).toEqual(readKey2);
1141
+ expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
1172
1142
 
1173
1143
  editable.set(reader.id, "revoked", "trusting");
1174
1144
  // expect(editable.get(reader.id)).toEqual("revoked");
@@ -1260,18 +1230,18 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1260
1230
  });
1261
1231
 
1262
1232
  test("Can create two owned objects in the same group and they will have different ids", () => {
1263
- const { node, group } = newGroup();
1233
+ const { node, groupCore } = newGroup();
1264
1234
 
1265
1235
  const childObject1 = node.createCoValue({
1266
1236
  type: "comap",
1267
- ruleset: { type: "ownedByGroup", group: group.id },
1237
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
1268
1238
  meta: null,
1269
1239
  ...createdNowUnique(),
1270
1240
  });
1271
1241
 
1272
1242
  const childObject2 = node.createCoValue({
1273
1243
  type: "comap",
1274
- ruleset: { type: "ownedByGroup", group: group.id },
1244
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
1275
1245
  meta: null,
1276
1246
  ...createdNowUnique(),
1277
1247
  });
@@ -1280,20 +1250,20 @@ test("Can create two owned objects in the same group and they will have differen
1280
1250
  });
1281
1251
 
1282
1252
  test("Admins can create an adminInvite, which can add an admin", () => {
1283
- const { node, group, admin } = newGroup();
1253
+ const { node, groupCore, admin } = newGroup();
1284
1254
 
1285
1255
  const inviteSecret = newRandomAgentSecret();
1286
1256
  const inviteID = getAgentID(inviteSecret);
1287
1257
 
1288
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
1258
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1289
1259
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1290
1260
  const revelation = seal({
1291
1261
  message: readKey,
1292
1262
  from: admin.currentSealerSecret(),
1293
1263
  to: admin.currentSealerID(),
1294
1264
  nOnceMaterial: {
1295
- in: group.id,
1296
- tx: group.nextTransactionID(),
1265
+ in: groupCore.id,
1266
+ tx: groupCore.nextTransactionID(),
1297
1267
  },
1298
1268
  });
1299
1269
 
@@ -1309,8 +1279,8 @@ test("Admins can create an adminInvite, which can add an admin", () => {
1309
1279
  from: admin.currentSealerSecret(),
1310
1280
  to: getAgentSealerID(inviteID),
1311
1281
  nOnceMaterial: {
1312
- in: group.id,
1313
- tx: group.nextTransactionID(),
1282
+ in: groupCore.id,
1283
+ tx: groupCore.nextTransactionID(),
1314
1284
  },
1315
1285
  });
1316
1286
 
@@ -1321,20 +1291,20 @@ test("Admins can create an adminInvite, which can add an admin", () => {
1321
1291
  );
1322
1292
  });
1323
1293
 
1324
- const groupAsInvite = group.testWithDifferentAccount(
1294
+ const groupAsInvite = expectGroup(groupCore.testWithDifferentAccount(
1325
1295
  new AnonymousControlledAccount(inviteSecret),
1326
1296
  newRandomSessionID(inviteID)
1327
- );
1297
+ ).getCurrentContent());
1328
1298
 
1329
1299
  const invitedAdminSecret = newRandomAgentSecret();
1330
1300
  const invitedAdminID = getAgentID(invitedAdminSecret);
1331
1301
 
1332
- expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
1302
+ groupAsInvite.edit((editable) => {
1333
1303
  editable.set(invitedAdminID, "admin", "trusting");
1334
1304
 
1335
1305
  expect(editable.get(invitedAdminID)).toEqual("admin");
1336
1306
 
1337
- const readKey = groupAsInvite.getCurrentReadKey();
1307
+ const readKey = groupAsInvite.core.getCurrentReadKey();
1338
1308
 
1339
1309
  expect(readKey.secret).toBeDefined();
1340
1310
 
@@ -1343,8 +1313,8 @@ test("Admins can create an adminInvite, which can add an admin", () => {
1343
1313
  from: getAgentSealerSecret(invitedAdminSecret),
1344
1314
  to: getAgentSealerID(invitedAdminID),
1345
1315
  nOnceMaterial: {
1346
- in: group.id,
1347
- tx: group.nextTransactionID(),
1316
+ in: groupCore.id,
1317
+ tx: groupCore.nextTransactionID(),
1348
1318
  },
1349
1319
  });
1350
1320
 
@@ -1378,40 +1348,37 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
1378
1348
  const thirdAdmin = newRandomAgentSecret();
1379
1349
  const thirdAdminID = getAgentID(thirdAdmin);
1380
1350
 
1381
- const groupAsInvitedAdmin = new Group(
1382
- await nodeAsInvitedAdmin.load(group.id),
1383
- nodeAsInvitedAdmin
1384
- );
1351
+ let groupAsInvitedAdmin = await nodeAsInvitedAdmin.load(group.id);
1385
1352
 
1386
- expect(groupAsInvitedAdmin.underlyingMap.get(invitedAdminID)).toEqual(
1353
+ expect(groupAsInvitedAdmin.get(invitedAdminID)).toEqual(
1387
1354
  "admin"
1388
1355
  );
1389
1356
  expect(
1390
- groupAsInvitedAdmin.underlyingMap.core.getCurrentReadKey().secret
1357
+ groupAsInvitedAdmin.core.getCurrentReadKey().secret
1391
1358
  ).toBeDefined();
1392
1359
 
1393
- groupAsInvitedAdmin.addMemberInternal(thirdAdminID, "admin");
1360
+ groupAsInvitedAdmin = groupAsInvitedAdmin.addMemberInternal(thirdAdminID, "admin");
1394
1361
 
1395
- expect(groupAsInvitedAdmin.underlyingMap.get(thirdAdminID)).toEqual(
1362
+ expect(groupAsInvitedAdmin.get(thirdAdminID)).toEqual(
1396
1363
  "admin"
1397
1364
  );
1398
1365
  });
1399
1366
 
1400
1367
  test("Admins can create a writerInvite, which can add a writer", () => {
1401
- const { node, group, admin } = newGroup();
1368
+ const { node, groupCore, admin } = newGroup();
1402
1369
 
1403
1370
  const inviteSecret = newRandomAgentSecret();
1404
1371
  const inviteID = getAgentID(inviteSecret);
1405
1372
 
1406
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
1373
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1407
1374
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1408
1375
  const revelation = seal({
1409
1376
  message: readKey,
1410
1377
  from: admin.currentSealerSecret(),
1411
1378
  to: admin.currentSealerID(),
1412
1379
  nOnceMaterial: {
1413
- in: group.id,
1414
- tx: group.nextTransactionID(),
1380
+ in: groupCore.id,
1381
+ tx: groupCore.nextTransactionID(),
1415
1382
  },
1416
1383
  });
1417
1384
 
@@ -1427,8 +1394,8 @@ test("Admins can create a writerInvite, which can add a writer", () => {
1427
1394
  from: admin.currentSealerSecret(),
1428
1395
  to: getAgentSealerID(inviteID),
1429
1396
  nOnceMaterial: {
1430
- in: group.id,
1431
- tx: group.nextTransactionID(),
1397
+ in: groupCore.id,
1398
+ tx: groupCore.nextTransactionID(),
1432
1399
  },
1433
1400
  });
1434
1401
 
@@ -1439,20 +1406,20 @@ test("Admins can create a writerInvite, which can add a writer", () => {
1439
1406
  );
1440
1407
  });
1441
1408
 
1442
- const groupAsInvite = group.testWithDifferentAccount(
1409
+ const groupAsInvite = expectGroup(groupCore.testWithDifferentAccount(
1443
1410
  new AnonymousControlledAccount(inviteSecret),
1444
1411
  newRandomSessionID(inviteID)
1445
- );
1412
+ ).getCurrentContent());
1446
1413
 
1447
1414
  const invitedWriterSecret = newRandomAgentSecret();
1448
1415
  const invitedWriterID = getAgentID(invitedWriterSecret);
1449
1416
 
1450
- expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
1417
+ groupAsInvite.edit((editable) => {
1451
1418
  editable.set(invitedWriterID, "writer", "trusting");
1452
1419
 
1453
1420
  expect(editable.get(invitedWriterID)).toEqual("writer");
1454
1421
 
1455
- const readKey = groupAsInvite.getCurrentReadKey();
1422
+ const readKey = groupAsInvite.core.getCurrentReadKey();
1456
1423
 
1457
1424
  expect(readKey.secret).toBeDefined();
1458
1425
 
@@ -1461,8 +1428,8 @@ test("Admins can create a writerInvite, which can add a writer", () => {
1461
1428
  from: getAgentSealerSecret(invitedWriterSecret),
1462
1429
  to: getAgentSealerID(invitedWriterID),
1463
1430
  nOnceMaterial: {
1464
- in: group.id,
1465
- tx: group.nextTransactionID(),
1431
+ in: groupCore.id,
1432
+ tx: groupCore.nextTransactionID(),
1466
1433
  },
1467
1434
  });
1468
1435
 
@@ -1493,34 +1460,31 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
1493
1460
 
1494
1461
  await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
1495
1462
 
1496
- const groupAsInvitedWriter = new Group(
1497
- await nodeAsInvitedWriter.load(group.id),
1498
- nodeAsInvitedWriter
1499
- );
1463
+ const groupAsInvitedWriter = await nodeAsInvitedWriter.load(group.id);
1500
1464
 
1501
- expect(groupAsInvitedWriter.underlyingMap.get(invitedWriterID)).toEqual(
1465
+ expect(groupAsInvitedWriter.get(invitedWriterID)).toEqual(
1502
1466
  "writer"
1503
1467
  );
1504
1468
  expect(
1505
- groupAsInvitedWriter.underlyingMap.core.getCurrentReadKey().secret
1469
+ groupAsInvitedWriter.core.getCurrentReadKey().secret
1506
1470
  ).toBeDefined();
1507
1471
  });
1508
1472
 
1509
1473
  test("Admins can create a readerInvite, which can add a reader", () => {
1510
- const { node, group, admin } = newGroup();
1474
+ const { node, groupCore, admin } = newGroup();
1511
1475
 
1512
1476
  const inviteSecret = newRandomAgentSecret();
1513
1477
  const inviteID = getAgentID(inviteSecret);
1514
1478
 
1515
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
1479
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1516
1480
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1517
1481
  const revelation = seal({
1518
1482
  message: readKey,
1519
1483
  from: admin.currentSealerSecret(),
1520
1484
  to: admin.currentSealerID(),
1521
1485
  nOnceMaterial: {
1522
- in: group.id,
1523
- tx: group.nextTransactionID(),
1486
+ in: groupCore.id,
1487
+ tx: groupCore.nextTransactionID(),
1524
1488
  },
1525
1489
  });
1526
1490
 
@@ -1536,8 +1500,8 @@ test("Admins can create a readerInvite, which can add a reader", () => {
1536
1500
  from: admin.currentSealerSecret(),
1537
1501
  to: getAgentSealerID(inviteID),
1538
1502
  nOnceMaterial: {
1539
- in: group.id,
1540
- tx: group.nextTransactionID(),
1503
+ in: groupCore.id,
1504
+ tx: groupCore.nextTransactionID(),
1541
1505
  },
1542
1506
  });
1543
1507
 
@@ -1548,20 +1512,20 @@ test("Admins can create a readerInvite, which can add a reader", () => {
1548
1512
  );
1549
1513
  });
1550
1514
 
1551
- const groupAsInvite = group.testWithDifferentAccount(
1515
+ const groupAsInvite = expectGroup(groupCore.testWithDifferentAccount(
1552
1516
  new AnonymousControlledAccount(inviteSecret),
1553
1517
  newRandomSessionID(inviteID)
1554
- );
1518
+ ).getCurrentContent());
1555
1519
 
1556
1520
  const invitedReaderSecret = newRandomAgentSecret();
1557
1521
  const invitedReaderID = getAgentID(invitedReaderSecret);
1558
1522
 
1559
- expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
1523
+ groupAsInvite.edit((editable) => {
1560
1524
  editable.set(invitedReaderID, "reader", "trusting");
1561
1525
 
1562
1526
  expect(editable.get(invitedReaderID)).toEqual("reader");
1563
1527
 
1564
- const readKey = groupAsInvite.getCurrentReadKey();
1528
+ const readKey = groupAsInvite.core.getCurrentReadKey();
1565
1529
 
1566
1530
  expect(readKey.secret).toBeDefined();
1567
1531
 
@@ -1570,8 +1534,8 @@ test("Admins can create a readerInvite, which can add a reader", () => {
1570
1534
  from: getAgentSealerSecret(invitedReaderSecret),
1571
1535
  to: getAgentSealerID(invitedReaderID),
1572
1536
  nOnceMaterial: {
1573
- in: group.id,
1574
- tx: group.nextTransactionID(),
1537
+ in: groupCore.id,
1538
+ tx: groupCore.nextTransactionID(),
1575
1539
  },
1576
1540
  });
1577
1541
 
@@ -1602,34 +1566,32 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
1602
1566
 
1603
1567
  await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
1604
1568
 
1605
- const groupAsInvitedReader = new Group(
1606
- await nodeAsInvitedReader.load(group.id),
1607
- nodeAsInvitedReader
1608
- );
1569
+ const groupAsInvitedReader =
1570
+ await nodeAsInvitedReader.load(group.id);
1609
1571
 
1610
- expect(groupAsInvitedReader.underlyingMap.get(invitedReaderID)).toEqual(
1572
+ expect(groupAsInvitedReader.get(invitedReaderID)).toEqual(
1611
1573
  "reader"
1612
1574
  );
1613
1575
  expect(
1614
- groupAsInvitedReader.underlyingMap.core.getCurrentReadKey().secret
1576
+ groupAsInvitedReader.core.getCurrentReadKey().secret
1615
1577
  ).toBeDefined();
1616
1578
  });
1617
1579
 
1618
1580
  test("WriterInvites can not invite admins", () => {
1619
- const { node, group, admin } = newGroup();
1581
+ const { node, groupCore, admin } = newGroup();
1620
1582
 
1621
1583
  const inviteSecret = newRandomAgentSecret();
1622
1584
  const inviteID = getAgentID(inviteSecret);
1623
1585
 
1624
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
1586
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1625
1587
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1626
1588
  const revelation = seal({
1627
1589
  message: readKey,
1628
1590
  from: admin.currentSealerSecret(),
1629
1591
  to: admin.currentSealerID(),
1630
1592
  nOnceMaterial: {
1631
- in: group.id,
1632
- tx: group.nextTransactionID(),
1593
+ in: groupCore.id,
1594
+ tx: groupCore.nextTransactionID(),
1633
1595
  },
1634
1596
  });
1635
1597
 
@@ -1645,8 +1607,8 @@ test("WriterInvites can not invite admins", () => {
1645
1607
  from: admin.currentSealerSecret(),
1646
1608
  to: getAgentSealerID(inviteID),
1647
1609
  nOnceMaterial: {
1648
- in: group.id,
1649
- tx: group.nextTransactionID(),
1610
+ in: groupCore.id,
1611
+ tx: groupCore.nextTransactionID(),
1650
1612
  },
1651
1613
  });
1652
1614
 
@@ -1657,35 +1619,35 @@ test("WriterInvites can not invite admins", () => {
1657
1619
  );
1658
1620
  });
1659
1621
 
1660
- const groupAsInvite = group.testWithDifferentAccount(
1622
+ const groupAsInvite = expectGroup(groupCore.testWithDifferentAccount(
1661
1623
  new AnonymousControlledAccount(inviteSecret),
1662
1624
  newRandomSessionID(inviteID)
1663
- );
1625
+ ).getCurrentContent());
1664
1626
 
1665
1627
  const invitedAdminSecret = newRandomAgentSecret();
1666
1628
  const invitedAdminID = getAgentID(invitedAdminSecret);
1667
1629
 
1668
- expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
1630
+ groupAsInvite.edit((editable) => {
1669
1631
  editable.set(invitedAdminID, "admin", "trusting");
1670
1632
  expect(editable.get(invitedAdminID)).toBeUndefined();
1671
1633
  });
1672
1634
  });
1673
1635
 
1674
1636
  test("ReaderInvites can not invite admins", () => {
1675
- const { node, group, admin } = newGroup();
1637
+ const { node, groupCore, admin } = newGroup();
1676
1638
 
1677
1639
  const inviteSecret = newRandomAgentSecret();
1678
1640
  const inviteID = getAgentID(inviteSecret);
1679
1641
 
1680
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
1642
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1681
1643
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1682
1644
  const revelation = seal({
1683
1645
  message: readKey,
1684
1646
  from: admin.currentSealerSecret(),
1685
1647
  to: admin.currentSealerID(),
1686
1648
  nOnceMaterial: {
1687
- in: group.id,
1688
- tx: group.nextTransactionID(),
1649
+ in: groupCore.id,
1650
+ tx: groupCore.nextTransactionID(),
1689
1651
  },
1690
1652
  });
1691
1653
 
@@ -1701,8 +1663,8 @@ test("ReaderInvites can not invite admins", () => {
1701
1663
  from: admin.currentSealerSecret(),
1702
1664
  to: getAgentSealerID(inviteID),
1703
1665
  nOnceMaterial: {
1704
- in: group.id,
1705
- tx: group.nextTransactionID(),
1666
+ in: groupCore.id,
1667
+ tx: groupCore.nextTransactionID(),
1706
1668
  },
1707
1669
  });
1708
1670
 
@@ -1713,35 +1675,35 @@ test("ReaderInvites can not invite admins", () => {
1713
1675
  );
1714
1676
  });
1715
1677
 
1716
- const groupAsInvite = group.testWithDifferentAccount(
1678
+ const groupAsInvite = expectGroup(groupCore.testWithDifferentAccount(
1717
1679
  new AnonymousControlledAccount(inviteSecret),
1718
1680
  newRandomSessionID(inviteID)
1719
- );
1681
+ ).getCurrentContent());
1720
1682
 
1721
1683
  const invitedAdminSecret = newRandomAgentSecret();
1722
1684
  const invitedAdminID = getAgentID(invitedAdminSecret);
1723
1685
 
1724
- expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
1686
+ groupAsInvite.edit((editable) => {
1725
1687
  editable.set(invitedAdminID, "admin", "trusting");
1726
1688
  expect(editable.get(invitedAdminID)).toBeUndefined();
1727
1689
  });
1728
1690
  });
1729
1691
 
1730
1692
  test("ReaderInvites can not invite writers", () => {
1731
- const { node, group, admin } = newGroup();
1693
+ const { node, groupCore, admin } = newGroup();
1732
1694
 
1733
1695
  const inviteSecret = newRandomAgentSecret();
1734
1696
  const inviteID = getAgentID(inviteSecret);
1735
1697
 
1736
- expectGroupContent(group.getCurrentContent()).edit((editable) => {
1698
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1737
1699
  const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1738
1700
  const revelation = seal({
1739
1701
  message: readKey,
1740
1702
  from: admin.currentSealerSecret(),
1741
1703
  to: admin.currentSealerID(),
1742
1704
  nOnceMaterial: {
1743
- in: group.id,
1744
- tx: group.nextTransactionID(),
1705
+ in: groupCore.id,
1706
+ tx: groupCore.nextTransactionID(),
1745
1707
  },
1746
1708
  });
1747
1709
 
@@ -1757,8 +1719,8 @@ test("ReaderInvites can not invite writers", () => {
1757
1719
  from: admin.currentSealerSecret(),
1758
1720
  to: getAgentSealerID(inviteID),
1759
1721
  nOnceMaterial: {
1760
- in: group.id,
1761
- tx: group.nextTransactionID(),
1722
+ in: groupCore.id,
1723
+ tx: groupCore.nextTransactionID(),
1762
1724
  },
1763
1725
  });
1764
1726
 
@@ -1769,16 +1731,163 @@ test("ReaderInvites can not invite writers", () => {
1769
1731
  );
1770
1732
  });
1771
1733
 
1772
- const groupAsInvite = group.testWithDifferentAccount(
1734
+ const groupAsInvite = expectGroup(groupCore.testWithDifferentAccount(
1773
1735
  new AnonymousControlledAccount(inviteSecret),
1774
1736
  newRandomSessionID(inviteID)
1775
- );
1737
+ ).getCurrentContent());
1776
1738
 
1777
1739
  const invitedWriterSecret = newRandomAgentSecret();
1778
1740
  const invitedWriterID = getAgentID(invitedWriterSecret);
1779
1741
 
1780
- expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
1742
+ groupAsInvite.edit((editable) => {
1781
1743
  editable.set(invitedWriterID, "writer", "trusting");
1782
1744
  expect(editable.get(invitedWriterID)).toBeUndefined();
1783
1745
  });
1784
1746
  });
1747
+
1748
+ test("Can give read permission to 'everyone'", () => {
1749
+ const { node, groupCore } = newGroup();
1750
+
1751
+ const childObject = node.createCoValue({
1752
+ type: "comap",
1753
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
1754
+ meta: null,
1755
+ ...createdNowUnique(),
1756
+ });
1757
+
1758
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1759
+ const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1760
+ editable.set("everyone", "reader", "trusting");
1761
+ editable.set("readKey", readKeyID, "trusting");
1762
+ editable.set(`${readKeyID}_for_everyone`, readKey, "trusting");
1763
+ });
1764
+
1765
+ const childContent = expectMap(childObject.getCurrentContent());
1766
+
1767
+ expect(childContent.get("foo")).toBeUndefined();
1768
+
1769
+ childContent.edit((editable) => {
1770
+ editable.set("foo", "bar", "private");
1771
+ expect(editable.get("foo")).toEqual("bar");
1772
+ });
1773
+
1774
+ const newAccount = new AnonymousControlledAccount(newRandomAgentSecret());
1775
+
1776
+ const childContent2 = expectMap(
1777
+ childObject
1778
+ .testWithDifferentAccount(
1779
+ newAccount,
1780
+ newRandomSessionID(newAccount.currentAgentID())
1781
+ )
1782
+ .getCurrentContent()
1783
+ );
1784
+
1785
+ expect(childContent2.get("foo")).toEqual("bar");
1786
+ });
1787
+
1788
+ test("Can give read permissions to 'everyone' (high-level)", async () => {
1789
+ const { group } = newGroupHighLevel();
1790
+
1791
+ const childObject = group.createMap();
1792
+
1793
+ expect(childObject.get("foo")).toBeUndefined();
1794
+
1795
+ group.addMember("everyone", "reader");
1796
+
1797
+ childObject.edit((editable) => {
1798
+ editable.set("foo", "bar", "private");
1799
+ expect(editable.get("foo")).toEqual("bar");
1800
+ });
1801
+
1802
+ const newAccount = new AnonymousControlledAccount(newRandomAgentSecret());
1803
+
1804
+ const childContent2 = expectMap(
1805
+ childObject.core
1806
+ .testWithDifferentAccount(
1807
+ new AnonymousControlledAccount(newRandomAgentSecret()),
1808
+ newRandomSessionID(newAccount.currentAgentID())
1809
+ )
1810
+ .getCurrentContent()
1811
+ );
1812
+
1813
+ expect(childContent2.get("foo")).toEqual("bar");
1814
+ });
1815
+
1816
+ test("Can give write permission to 'everyone'", () => {
1817
+ const { node, groupCore } = newGroup();
1818
+
1819
+ const childObject = node.createCoValue({
1820
+ type: "comap",
1821
+ ruleset: { type: "ownedByGroup", group: groupCore.id },
1822
+ meta: null,
1823
+ ...createdNowUnique(),
1824
+ });
1825
+
1826
+ expectGroup(groupCore.getCurrentContent()).edit((editable) => {
1827
+ const { secret: readKey, id: readKeyID } = newRandomKeySecret();
1828
+ editable.set("everyone", "writer", "trusting");
1829
+ editable.set("readKey", readKeyID, "trusting");
1830
+ editable.set(`${readKeyID}_for_everyone`, readKey, "trusting");
1831
+ });
1832
+
1833
+ const childContent = expectMap(childObject.getCurrentContent());
1834
+
1835
+ expect(childContent.get("foo")).toBeUndefined();
1836
+
1837
+ childContent.edit((editable) => {
1838
+ editable.set("foo", "bar", "private");
1839
+ expect(editable.get("foo")).toEqual("bar");
1840
+ });
1841
+
1842
+ const newAccount = new AnonymousControlledAccount(newRandomAgentSecret());
1843
+
1844
+ const childContent2 = expectMap(
1845
+ childObject
1846
+ .testWithDifferentAccount(
1847
+ newAccount,
1848
+ newRandomSessionID(newAccount.currentAgentID())
1849
+ )
1850
+ .getCurrentContent()
1851
+ );
1852
+
1853
+ expect(childContent2.get("foo")).toEqual("bar");
1854
+
1855
+ childContent2.edit((editable) => {
1856
+ editable.set("foo", "bar2", "private");
1857
+ expect(editable.get("foo")).toEqual("bar2");
1858
+ });
1859
+ });
1860
+
1861
+ test("Can give write permissions to 'everyone' (high-level)", async () => {
1862
+ const { group } = newGroupHighLevel();
1863
+
1864
+ const childObject = group.createMap();
1865
+
1866
+ expect(childObject.get("foo")).toBeUndefined();
1867
+
1868
+ group.addMember("everyone", "writer");
1869
+
1870
+ childObject.edit((editable) => {
1871
+ editable.set("foo", "bar", "private");
1872
+ expect(editable.get("foo")).toEqual("bar");
1873
+ });
1874
+
1875
+ const newAccount = new AnonymousControlledAccount(newRandomAgentSecret());
1876
+
1877
+ const childContent2 = expectMap(
1878
+ childObject.core
1879
+ .testWithDifferentAccount(
1880
+ newAccount,
1881
+ newRandomSessionID(newAccount.currentAgentID())
1882
+ )
1883
+ .getCurrentContent()
1884
+ );
1885
+
1886
+ expect(childContent2.get("foo")).toEqual("bar");
1887
+
1888
+ childContent2.edit((editable) => {
1889
+ console.log("Before anon set")
1890
+ editable.set("foo", "bar2", "private");
1891
+ expect(editable.get("foo")).toEqual("bar2");
1892
+ });
1893
+ });