cojson 0.6.7 → 0.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -0
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +3 -3
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/account.js +5 -5
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +39 -58
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +20 -61
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +14 -64
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.js +57 -59
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.js +17 -12
- package/dist/coreToCoValue.js.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/localNode.js +54 -38
- package/dist/localNode.js.map +1 -1
- package/dist/permissions.js +2 -2
- package/dist/permissions.js.map +1 -1
- package/dist/tests/testUtils.js +6 -11
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/typeUtils/expectGroup.js +2 -2
- package/dist/typeUtils/expectGroup.js.map +1 -1
- package/dist/typeUtils/isCoValue.js +8 -8
- package/dist/typeUtils/isCoValue.js.map +1 -1
- package/package.json +3 -4
- package/src/coValue.ts +21 -21
- package/src/coValueCore.ts +8 -8
- package/src/coValues/account.ts +14 -26
- package/src/coValues/coList.ts +58 -97
- package/src/coValues/coMap.ts +27 -129
- package/src/coValues/coStream.ts +31 -137
- package/src/coValues/group.ts +52 -46
- package/src/coreToCoValue.ts +16 -12
- package/src/index.ts +27 -36
- package/src/jsonValue.ts +1 -1
- package/src/localNode.ts +88 -75
- package/src/media.ts +4 -4
- package/src/permissions.ts +2 -2
- package/src/tests/account.test.ts +12 -12
- package/src/tests/coValue.test.ts +149 -182
- package/src/tests/coValueCore.test.ts +8 -3
- package/src/tests/crypto.test.ts +7 -0
- package/src/tests/group.test.ts +13 -6
- package/src/tests/permissions.test.ts +648 -840
- package/src/tests/sync.test.ts +44 -68
- package/src/tests/testUtils.ts +6 -11
- package/src/typeUtils/expectGroup.ts +4 -4
- package/src/typeUtils/isCoValue.ts +11 -11
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { expect, test, beforeEach } from "vitest";
|
|
1
2
|
import { newRandomSessionID } from "../coValueCore.js";
|
|
2
3
|
import { expectMap } from "../coValue.js";
|
|
3
|
-
import {
|
|
4
|
+
import { RawGroup } from "../coValues/group.js";
|
|
4
5
|
import {
|
|
5
6
|
createdNowUnique,
|
|
6
7
|
newRandomKeySecret,
|
|
@@ -20,6 +21,12 @@ import {
|
|
|
20
21
|
import { ControlledAgent, cojsonReady } from "../index.js";
|
|
21
22
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
22
23
|
|
|
24
|
+
import { webcrypto } from "node:crypto";
|
|
25
|
+
if (!("crypto" in globalThis)) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
(globalThis as any).crypto = webcrypto;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
beforeEach(async () => {
|
|
24
31
|
await cojsonReady;
|
|
25
32
|
});
|
|
@@ -35,7 +42,7 @@ test("Initial admin can add another admin to a group (high level)", () => {
|
|
|
35
42
|
test("Added admin can add a third admin to a group", () => {
|
|
36
43
|
const { groupCore, otherAdmin, node } = groupWithTwoAdmins();
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
const groupAsOtherAdmin = expectGroup(
|
|
39
46
|
groupCore
|
|
40
47
|
.testWithDifferentAccount(
|
|
41
48
|
otherAdmin,
|
|
@@ -48,18 +55,14 @@ test("Added admin can add a third admin to a group", () => {
|
|
|
48
55
|
|
|
49
56
|
const thirdAdmin = node.createAccount("thirdAdmin");
|
|
50
57
|
|
|
51
|
-
groupAsOtherAdmin
|
|
52
|
-
editable.set(thirdAdmin.id, "admin", "trusting");
|
|
53
|
-
expect(editable.get(thirdAdmin.id)).toEqual("admin");
|
|
54
|
-
});
|
|
55
|
-
|
|
58
|
+
groupAsOtherAdmin.set(thirdAdmin.id, "admin", "trusting");
|
|
56
59
|
expect(groupAsOtherAdmin.get(thirdAdmin.id)).toEqual("admin");
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
test("Added adming can add a third admin to a group (high level)", () => {
|
|
60
63
|
const { group, otherAdmin, node } = groupWithTwoAdminsHighLevel();
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
const groupAsOtherAdmin = expectGroup(
|
|
63
66
|
group.core
|
|
64
67
|
.testWithDifferentAccount(
|
|
65
68
|
otherAdmin,
|
|
@@ -70,7 +73,7 @@ test("Added adming can add a third admin to a group (high level)", () => {
|
|
|
70
73
|
|
|
71
74
|
const thirdAdmin = groupAsOtherAdmin.core.node.createAccount("thirdAdmin");
|
|
72
75
|
|
|
73
|
-
groupAsOtherAdmin
|
|
76
|
+
groupAsOtherAdmin.addMember(thirdAdmin, "admin");
|
|
74
77
|
|
|
75
78
|
expect(groupAsOtherAdmin.get(thirdAdmin.id)).toEqual("admin");
|
|
76
79
|
});
|
|
@@ -78,16 +81,14 @@ test("Added adming can add a third admin to a group (high level)", () => {
|
|
|
78
81
|
test("Admins can't demote other admins in a group", () => {
|
|
79
82
|
const { groupCore, admin, otherAdmin } = groupWithTwoAdmins();
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
82
85
|
|
|
83
|
-
groupContent
|
|
84
|
-
|
|
85
|
-
expect(editable.get(otherAdmin.id)).toEqual("admin");
|
|
86
|
-
});
|
|
86
|
+
groupContent.set(otherAdmin.id, "writer", "trusting");
|
|
87
|
+
expect(groupContent.get(otherAdmin.id)).toEqual("admin");
|
|
87
88
|
|
|
88
89
|
expect(groupContent.get(otherAdmin.id)).toEqual("admin");
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
const groupAsOtherAdmin = expectGroup(
|
|
91
92
|
groupCore
|
|
92
93
|
.testWithDifferentAccount(
|
|
93
94
|
otherAdmin,
|
|
@@ -96,11 +97,7 @@ test("Admins can't demote other admins in a group", () => {
|
|
|
96
97
|
.getCurrentContent()
|
|
97
98
|
);
|
|
98
99
|
|
|
99
|
-
groupAsOtherAdmin
|
|
100
|
-
editable.set(admin.id, "writer", "trusting");
|
|
101
|
-
expect(editable.get(admin.id)).toEqual("admin");
|
|
102
|
-
});
|
|
103
|
-
|
|
100
|
+
groupAsOtherAdmin.set(admin.id, "writer", "trusting");
|
|
104
101
|
expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
|
|
105
102
|
});
|
|
106
103
|
|
|
@@ -127,17 +124,14 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
127
124
|
const { groupCore, node } = newGroup();
|
|
128
125
|
const writer = node.createAccount("writer");
|
|
129
126
|
|
|
130
|
-
|
|
127
|
+
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
131
128
|
|
|
132
|
-
groupContent.
|
|
133
|
-
|
|
134
|
-
expect(editable.get(writer.id)).toEqual("writer");
|
|
135
|
-
});
|
|
129
|
+
groupContent.set(writer.id, "writer", "trusting");
|
|
130
|
+
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
136
131
|
|
|
137
|
-
groupContent = expectGroup(groupCore.getCurrentContent());
|
|
138
132
|
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
139
133
|
|
|
140
|
-
|
|
134
|
+
const groupAsWriter = expectGroup(
|
|
141
135
|
groupCore
|
|
142
136
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
143
137
|
.getCurrentContent()
|
|
@@ -147,26 +141,22 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
147
141
|
|
|
148
142
|
const otherAgent = node.createAccount("otherAgent");
|
|
149
143
|
|
|
150
|
-
groupAsWriter
|
|
151
|
-
|
|
152
|
-
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
153
|
-
|
|
154
|
-
editable.set(otherAgent.id, "writer", "trusting");
|
|
155
|
-
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
144
|
+
groupAsWriter.set(otherAgent.id, "admin", "trusting");
|
|
145
|
+
expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
|
|
156
146
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
147
|
+
groupAsWriter.set(otherAgent.id, "writer", "trusting");
|
|
148
|
+
expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
|
|
160
149
|
|
|
150
|
+
groupAsWriter.set(otherAgent.id, "reader", "trusting");
|
|
161
151
|
expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
|
|
162
152
|
});
|
|
163
153
|
|
|
164
154
|
test("Admins an add writers to a group, who can't add admins, writers, or readers (high level)", () => {
|
|
165
|
-
|
|
155
|
+
const { group, node } = newGroupHighLevel();
|
|
166
156
|
|
|
167
157
|
const writer = node.createAccount("writer");
|
|
168
158
|
|
|
169
|
-
group
|
|
159
|
+
group.addMember(writer, "writer");
|
|
170
160
|
expect(group.get(writer.id)).toEqual("writer");
|
|
171
161
|
|
|
172
162
|
const groupAsWriter = expectGroup(
|
|
@@ -196,17 +186,12 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
196
186
|
const { groupCore, node } = newGroup();
|
|
197
187
|
const reader = node.createAccount("reader");
|
|
198
188
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
groupContent.edit((editable) => {
|
|
202
|
-
editable.set(reader.id, "reader", "trusting");
|
|
203
|
-
expect(editable.get(reader.id)).toEqual("reader");
|
|
204
|
-
});
|
|
189
|
+
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
205
190
|
|
|
206
|
-
groupContent
|
|
191
|
+
groupContent.set(reader.id, "reader", "trusting");
|
|
207
192
|
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
208
193
|
|
|
209
|
-
|
|
194
|
+
const groupAsReader = expectGroup(
|
|
210
195
|
groupCore
|
|
211
196
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
212
197
|
.getCurrentContent()
|
|
@@ -216,26 +201,23 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
216
201
|
|
|
217
202
|
const otherAgent = node.createAccount("otherAgent");
|
|
218
203
|
|
|
219
|
-
groupAsReader
|
|
220
|
-
|
|
221
|
-
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
204
|
+
groupAsReader.set(otherAgent.id, "admin", "trusting");
|
|
205
|
+
expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
|
|
222
206
|
|
|
223
|
-
|
|
224
|
-
|
|
207
|
+
groupAsReader.set(otherAgent.id, "writer", "trusting");
|
|
208
|
+
expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
|
|
225
209
|
|
|
226
|
-
|
|
227
|
-
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
228
|
-
});
|
|
210
|
+
groupAsReader.set(otherAgent.id, "reader", "trusting");
|
|
229
211
|
|
|
230
212
|
expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
|
|
231
213
|
});
|
|
232
214
|
|
|
233
215
|
test("Admins can add readers to a group, who can't add admins, writers, or readers (high level)", () => {
|
|
234
|
-
|
|
216
|
+
const { group, node } = newGroupHighLevel();
|
|
235
217
|
|
|
236
218
|
const reader = node.createAccount("reader");
|
|
237
219
|
|
|
238
|
-
group
|
|
220
|
+
group.addMember(reader, "reader");
|
|
239
221
|
expect(group.get(reader.id)).toEqual("reader");
|
|
240
222
|
|
|
241
223
|
const groupAsReader = expectGroup(
|
|
@@ -273,26 +255,16 @@ test("Admins can write to an object that is owned by their group", () => {
|
|
|
273
255
|
|
|
274
256
|
let childContent = expectMap(childObject.getCurrentContent());
|
|
275
257
|
|
|
276
|
-
childContent.
|
|
277
|
-
editable.set("foo", "bar", "trusting");
|
|
278
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
childContent = expectMap(childObject.getCurrentContent());
|
|
282
|
-
|
|
258
|
+
childContent.set("foo", "bar", "trusting");
|
|
283
259
|
expect(childContent.get("foo")).toEqual("bar");
|
|
284
260
|
});
|
|
285
261
|
|
|
286
262
|
test("Admins can write to an object that is owned by their group (high level)", () => {
|
|
287
263
|
const { node, group } = newGroupHighLevel();
|
|
288
264
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
childObject = childObject.edit((editable) => {
|
|
292
|
-
editable.set("foo", "bar", "trusting");
|
|
293
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
294
|
-
});
|
|
265
|
+
const childObject = group.createMap();
|
|
295
266
|
|
|
267
|
+
childObject.set("foo", "bar", "trusting");
|
|
296
268
|
expect(childObject.get("foo")).toEqual("bar");
|
|
297
269
|
});
|
|
298
270
|
|
|
@@ -301,10 +273,9 @@ test("Writers can write to an object that is owned by their group", () => {
|
|
|
301
273
|
|
|
302
274
|
const writer = node.createAccount("writer");
|
|
303
275
|
|
|
304
|
-
expectGroup(groupCore.getCurrentContent())
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
});
|
|
276
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
277
|
+
group.set(writer.id, "writer", "trusting");
|
|
278
|
+
expect(group.get(writer.id)).toEqual("writer");
|
|
308
279
|
|
|
309
280
|
const childObject = node.createCoValue({
|
|
310
281
|
type: "comap",
|
|
@@ -318,17 +289,11 @@ test("Writers can write to an object that is owned by their group", () => {
|
|
|
318
289
|
newRandomSessionID(writer.id)
|
|
319
290
|
);
|
|
320
291
|
|
|
321
|
-
|
|
292
|
+
const childContentAsWriter = expectMap(
|
|
322
293
|
childObjectAsWriter.getCurrentContent()
|
|
323
294
|
);
|
|
324
295
|
|
|
325
|
-
childContentAsWriter.
|
|
326
|
-
editable.set("foo", "bar", "trusting");
|
|
327
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
childContentAsWriter = expectMap(childObjectAsWriter.getCurrentContent());
|
|
331
|
-
|
|
296
|
+
childContentAsWriter.set("foo", "bar", "trusting");
|
|
332
297
|
expect(childContentAsWriter.get("foo")).toEqual("bar");
|
|
333
298
|
});
|
|
334
299
|
|
|
@@ -341,17 +306,13 @@ test("Writers can write to an object that is owned by their group (high level)",
|
|
|
341
306
|
|
|
342
307
|
const childObject = group.createMap();
|
|
343
308
|
|
|
344
|
-
|
|
309
|
+
const childObjectAsWriter = expectMap(
|
|
345
310
|
childObject.core
|
|
346
311
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
347
312
|
.getCurrentContent()
|
|
348
313
|
);
|
|
349
314
|
|
|
350
|
-
childObjectAsWriter
|
|
351
|
-
editable.set("foo", "bar", "trusting");
|
|
352
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
353
|
-
});
|
|
354
|
-
|
|
315
|
+
childObjectAsWriter.set("foo", "bar", "trusting");
|
|
355
316
|
expect(childObjectAsWriter.get("foo")).toEqual("bar");
|
|
356
317
|
});
|
|
357
318
|
|
|
@@ -360,10 +321,9 @@ test("Readers can not write to an object that is owned by their group", () => {
|
|
|
360
321
|
|
|
361
322
|
const reader = node.createAccount("reader");
|
|
362
323
|
|
|
363
|
-
expectGroup(groupCore.getCurrentContent())
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
});
|
|
324
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
325
|
+
group.set(reader.id, "reader", "trusting");
|
|
326
|
+
expect(group.get(reader.id)).toEqual("reader");
|
|
367
327
|
|
|
368
328
|
const childObject = node.createCoValue({
|
|
369
329
|
type: "comap",
|
|
@@ -377,17 +337,11 @@ test("Readers can not write to an object that is owned by their group", () => {
|
|
|
377
337
|
newRandomSessionID(reader.id)
|
|
378
338
|
);
|
|
379
339
|
|
|
380
|
-
|
|
340
|
+
const childContentAsReader = expectMap(
|
|
381
341
|
childObjectAsReader.getCurrentContent()
|
|
382
342
|
);
|
|
383
343
|
|
|
384
|
-
childContentAsReader.
|
|
385
|
-
editable.set("foo", "bar", "trusting");
|
|
386
|
-
expect(editable.get("foo")).toBeUndefined();
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
childContentAsReader = expectMap(childObjectAsReader.getCurrentContent());
|
|
390
|
-
|
|
344
|
+
childContentAsReader.set("foo", "bar", "trusting");
|
|
391
345
|
expect(childContentAsReader.get("foo")).toBeUndefined();
|
|
392
346
|
});
|
|
393
347
|
|
|
@@ -400,17 +354,13 @@ test("Readers can not write to an object that is owned by their group (high leve
|
|
|
400
354
|
|
|
401
355
|
const childObject = group.createMap();
|
|
402
356
|
|
|
403
|
-
|
|
357
|
+
const childObjectAsReader = expectMap(
|
|
404
358
|
childObject.core
|
|
405
359
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
406
360
|
.getCurrentContent()
|
|
407
361
|
);
|
|
408
362
|
|
|
409
|
-
childObjectAsReader
|
|
410
|
-
editable.set("foo", "bar", "trusting");
|
|
411
|
-
expect(editable.get("foo")).toBeUndefined();
|
|
412
|
-
});
|
|
413
|
-
|
|
363
|
+
childObjectAsReader.set("foo", "bar", "trusting");
|
|
414
364
|
expect(childObjectAsReader.get("foo")).toBeUndefined();
|
|
415
365
|
});
|
|
416
366
|
|
|
@@ -419,30 +369,28 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
419
369
|
|
|
420
370
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
421
371
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
});
|
|
372
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
373
|
+
const revelation = seal({
|
|
374
|
+
message: readKey,
|
|
375
|
+
from: admin.currentSealerSecret(),
|
|
376
|
+
to: admin.currentSealerID(),
|
|
377
|
+
nOnceMaterial: {
|
|
378
|
+
in: groupCore.id,
|
|
379
|
+
tx: groupCore.nextTransactionID(),
|
|
380
|
+
},
|
|
381
|
+
});
|
|
433
382
|
|
|
434
|
-
|
|
383
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
435
384
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
385
|
+
expect(groupContent.get(`${readKeyID}_for_${admin.id}`)).toEqual(
|
|
386
|
+
revelation
|
|
387
|
+
);
|
|
439
388
|
|
|
440
|
-
|
|
389
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
441
390
|
|
|
442
|
-
|
|
391
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID);
|
|
443
392
|
|
|
444
|
-
|
|
445
|
-
});
|
|
393
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
446
394
|
|
|
447
395
|
const childObject = node.createCoValue({
|
|
448
396
|
type: "comap",
|
|
@@ -451,27 +399,18 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
451
399
|
...createdNowUnique(),
|
|
452
400
|
});
|
|
453
401
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
childContent.edit((editable) => {
|
|
457
|
-
editable.set("foo", "bar", "private");
|
|
458
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
459
|
-
});
|
|
402
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
460
403
|
|
|
461
|
-
childContent
|
|
404
|
+
childContent.set("foo", "bar", "private");
|
|
462
405
|
expect(childContent.get("foo")).toEqual("bar");
|
|
463
406
|
});
|
|
464
407
|
|
|
465
408
|
test("Admins can set group read key and then use it to create and read private transactions in owned objects (high level)", () => {
|
|
466
409
|
const { node, group, admin } = newGroupHighLevel();
|
|
467
410
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
childObject = childObject.edit((editable) => {
|
|
471
|
-
editable.set("foo", "bar", "private");
|
|
472
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
473
|
-
});
|
|
411
|
+
const childObject = group.createMap();
|
|
474
412
|
|
|
413
|
+
childObject.set("foo", "bar", "private");
|
|
475
414
|
expect(childObject.get("foo")).toEqual("bar");
|
|
476
415
|
});
|
|
477
416
|
|
|
@@ -484,37 +423,35 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
484
423
|
|
|
485
424
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
486
425
|
|
|
487
|
-
groupContent.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
},
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
editable.set(`${readKeyID}_for_${writer.id}`, revelation2, "trusting");
|
|
514
|
-
|
|
515
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
426
|
+
groupContent.set(writer.id, "writer", "trusting");
|
|
427
|
+
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
428
|
+
|
|
429
|
+
const revelation1 = seal({
|
|
430
|
+
message: readKey,
|
|
431
|
+
from: admin.currentSealerSecret(),
|
|
432
|
+
to: admin.currentSealerID(),
|
|
433
|
+
nOnceMaterial: {
|
|
434
|
+
in: groupCore.id,
|
|
435
|
+
tx: groupCore.nextTransactionID(),
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
440
|
+
|
|
441
|
+
const revelation2 = seal({
|
|
442
|
+
message: readKey,
|
|
443
|
+
from: admin.currentSealerSecret(),
|
|
444
|
+
to: writer.currentSealerID(),
|
|
445
|
+
nOnceMaterial: {
|
|
446
|
+
in: groupCore.id,
|
|
447
|
+
tx: groupCore.nextTransactionID(),
|
|
448
|
+
},
|
|
516
449
|
});
|
|
517
450
|
|
|
451
|
+
groupContent.set(`${readKeyID}_for_${writer.id}`, revelation2, "trusting");
|
|
452
|
+
|
|
453
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
454
|
+
|
|
518
455
|
const childObject = node.createCoValue({
|
|
519
456
|
type: "comap",
|
|
520
457
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
@@ -529,17 +466,11 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
529
466
|
|
|
530
467
|
expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
|
|
531
468
|
|
|
532
|
-
|
|
469
|
+
const childContentAsWriter = expectMap(
|
|
533
470
|
childObjectAsWriter.getCurrentContent()
|
|
534
471
|
);
|
|
535
472
|
|
|
536
|
-
childContentAsWriter.
|
|
537
|
-
editable.set("foo", "bar", "private");
|
|
538
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
childContentAsWriter = expectMap(childObjectAsWriter.getCurrentContent());
|
|
542
|
-
|
|
473
|
+
childContentAsWriter.set("foo", "bar", "private");
|
|
543
474
|
expect(childContentAsWriter.get("foo")).toEqual("bar");
|
|
544
475
|
});
|
|
545
476
|
|
|
@@ -552,17 +483,13 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
552
483
|
|
|
553
484
|
const childObject = group.createMap();
|
|
554
485
|
|
|
555
|
-
|
|
486
|
+
const childObjectAsWriter = expectMap(
|
|
556
487
|
childObject.core
|
|
557
488
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
558
489
|
.getCurrentContent()
|
|
559
490
|
);
|
|
560
491
|
|
|
561
|
-
childObjectAsWriter
|
|
562
|
-
editable.set("foo", "bar", "private");
|
|
563
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
564
|
-
});
|
|
565
|
-
|
|
492
|
+
childObjectAsWriter.set("foo", "bar", "private");
|
|
566
493
|
expect(childObjectAsWriter.get("foo")).toEqual("bar");
|
|
567
494
|
});
|
|
568
495
|
|
|
@@ -575,37 +502,35 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
575
502
|
|
|
576
503
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
577
504
|
|
|
578
|
-
groupContent.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
},
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
editable.set(`${readKeyID}_for_${reader.id}`, revelation2, "trusting");
|
|
605
|
-
|
|
606
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
505
|
+
groupContent.set(reader.id, "reader", "trusting");
|
|
506
|
+
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
507
|
+
|
|
508
|
+
const revelation1 = seal({
|
|
509
|
+
message: readKey,
|
|
510
|
+
from: admin.currentSealerSecret(),
|
|
511
|
+
to: admin.currentSealerID(),
|
|
512
|
+
nOnceMaterial: {
|
|
513
|
+
in: groupCore.id,
|
|
514
|
+
tx: groupCore.nextTransactionID(),
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
519
|
+
|
|
520
|
+
const revelation2 = seal({
|
|
521
|
+
message: readKey,
|
|
522
|
+
from: admin.currentSealerSecret(),
|
|
523
|
+
to: reader.currentSealerID(),
|
|
524
|
+
nOnceMaterial: {
|
|
525
|
+
in: groupCore.id,
|
|
526
|
+
tx: groupCore.nextTransactionID(),
|
|
527
|
+
},
|
|
607
528
|
});
|
|
608
529
|
|
|
530
|
+
groupContent.set(`${readKeyID}_for_${reader.id}`, revelation2, "trusting");
|
|
531
|
+
|
|
532
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
533
|
+
|
|
609
534
|
const childObject = node.createCoValue({
|
|
610
535
|
type: "comap",
|
|
611
536
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
@@ -613,10 +538,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
613
538
|
...createdNowUnique(),
|
|
614
539
|
});
|
|
615
540
|
|
|
616
|
-
expectMap(childObject.getCurrentContent())
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
541
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
542
|
+
|
|
543
|
+
childContent.set("foo", "bar", "private");
|
|
544
|
+
expect(childContent.get("foo")).toEqual("bar");
|
|
620
545
|
|
|
621
546
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
622
547
|
reader,
|
|
@@ -639,12 +564,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
639
564
|
|
|
640
565
|
group.addMember(reader, "reader");
|
|
641
566
|
|
|
642
|
-
|
|
567
|
+
const childObject = group.createMap();
|
|
643
568
|
|
|
644
|
-
childObject
|
|
645
|
-
|
|
646
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
647
|
-
});
|
|
569
|
+
childObject.set("foo", "bar", "private");
|
|
570
|
+
expect(childObject.get("foo")).toEqual("bar");
|
|
648
571
|
|
|
649
572
|
const childContentAsReader = expectMap(
|
|
650
573
|
childObject.core
|
|
@@ -666,37 +589,35 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
666
589
|
|
|
667
590
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
668
591
|
|
|
669
|
-
groupContent.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
},
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
684
|
-
|
|
685
|
-
const revelation2 = seal({
|
|
686
|
-
message: readKey,
|
|
687
|
-
from: admin.currentSealerSecret(),
|
|
688
|
-
to: reader1.currentSealerID(),
|
|
689
|
-
nOnceMaterial: {
|
|
690
|
-
in: groupCore.id,
|
|
691
|
-
tx: groupCore.nextTransactionID(),
|
|
692
|
-
},
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
editable.set(`${readKeyID}_for_${reader1.id}`, revelation2, "trusting");
|
|
696
|
-
|
|
697
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
592
|
+
groupContent.set(reader1.id, "reader", "trusting");
|
|
593
|
+
expect(groupContent.get(reader1.id)).toEqual("reader");
|
|
594
|
+
|
|
595
|
+
const revelation1 = seal({
|
|
596
|
+
message: readKey,
|
|
597
|
+
from: admin.currentSealerSecret(),
|
|
598
|
+
to: admin.currentSealerID(),
|
|
599
|
+
nOnceMaterial: {
|
|
600
|
+
in: groupCore.id,
|
|
601
|
+
tx: groupCore.nextTransactionID(),
|
|
602
|
+
},
|
|
698
603
|
});
|
|
699
604
|
|
|
605
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
606
|
+
|
|
607
|
+
const revelation2 = seal({
|
|
608
|
+
message: readKey,
|
|
609
|
+
from: admin.currentSealerSecret(),
|
|
610
|
+
to: reader1.currentSealerID(),
|
|
611
|
+
nOnceMaterial: {
|
|
612
|
+
in: groupCore.id,
|
|
613
|
+
tx: groupCore.nextTransactionID(),
|
|
614
|
+
},
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
groupContent.set(`${readKeyID}_for_${reader1.id}`, revelation2, "trusting");
|
|
618
|
+
|
|
619
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
620
|
+
|
|
700
621
|
const childObject = node.createCoValue({
|
|
701
622
|
type: "comap",
|
|
702
623
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
@@ -704,10 +625,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
704
625
|
...createdNowUnique(),
|
|
705
626
|
});
|
|
706
627
|
|
|
707
|
-
expectMap(childObject.getCurrentContent())
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
628
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
629
|
+
|
|
630
|
+
childContent.set("foo", "bar", "private");
|
|
631
|
+
expect(childContent.get("foo")).toEqual("bar");
|
|
711
632
|
|
|
712
633
|
const childObjectAsReader1 = childObject.testWithDifferentAccount(
|
|
713
634
|
reader1,
|
|
@@ -722,20 +643,18 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
722
643
|
|
|
723
644
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
724
645
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
},
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
editable.set(`${readKeyID}_for_${reader2.id}`, revelation3, "trusting");
|
|
646
|
+
const revelation3 = seal({
|
|
647
|
+
message: readKey,
|
|
648
|
+
from: admin.currentSealerSecret(),
|
|
649
|
+
to: reader2.currentSealerID(),
|
|
650
|
+
nOnceMaterial: {
|
|
651
|
+
in: groupCore.id,
|
|
652
|
+
tx: groupCore.nextTransactionID(),
|
|
653
|
+
},
|
|
737
654
|
});
|
|
738
655
|
|
|
656
|
+
groupContent.set(`${readKeyID}_for_${reader2.id}`, revelation3, "trusting");
|
|
657
|
+
|
|
739
658
|
const childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
740
659
|
reader2,
|
|
741
660
|
newRandomSessionID(reader2.id)
|
|
@@ -759,12 +678,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
759
678
|
|
|
760
679
|
group.addMember(reader1, "reader");
|
|
761
680
|
|
|
762
|
-
|
|
681
|
+
const childObject = group.createMap();
|
|
763
682
|
|
|
764
|
-
childObject
|
|
765
|
-
|
|
766
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
767
|
-
});
|
|
683
|
+
childObject.set("foo", "bar", "private");
|
|
684
|
+
expect(childObject.get("foo")).toEqual("bar");
|
|
768
685
|
|
|
769
686
|
const childContentAsReader1 = expectMap(
|
|
770
687
|
childObject.core
|
|
@@ -790,25 +707,23 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
790
707
|
|
|
791
708
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
792
709
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
},
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
806
|
-
|
|
807
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
808
|
-
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
809
|
-
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
710
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
711
|
+
const revelation1 = seal({
|
|
712
|
+
message: readKey,
|
|
713
|
+
from: admin.currentSealerSecret(),
|
|
714
|
+
to: admin.currentSealerID(),
|
|
715
|
+
nOnceMaterial: {
|
|
716
|
+
in: groupCore.id,
|
|
717
|
+
tx: groupCore.nextTransactionID(),
|
|
718
|
+
},
|
|
810
719
|
});
|
|
811
720
|
|
|
721
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
722
|
+
|
|
723
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
724
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID);
|
|
725
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
726
|
+
|
|
812
727
|
const childObject = node.createCoValue({
|
|
813
728
|
type: "comap",
|
|
814
729
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
@@ -816,72 +731,50 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
816
731
|
...createdNowUnique(),
|
|
817
732
|
});
|
|
818
733
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
childContent.edit((editable) => {
|
|
822
|
-
editable.set("foo", "bar", "private");
|
|
823
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
824
|
-
});
|
|
734
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
825
735
|
|
|
826
|
-
childContent
|
|
736
|
+
childContent.set("foo", "bar", "private");
|
|
827
737
|
expect(childContent.get("foo")).toEqual("bar");
|
|
828
738
|
|
|
829
|
-
|
|
830
|
-
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
739
|
+
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
831
740
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
741
|
+
const revelation2 = seal({
|
|
742
|
+
message: readKey2,
|
|
743
|
+
from: admin.currentSealerSecret(),
|
|
744
|
+
to: admin.currentSealerID(),
|
|
745
|
+
nOnceMaterial: {
|
|
746
|
+
in: groupCore.id,
|
|
747
|
+
tx: groupCore.nextTransactionID(),
|
|
748
|
+
},
|
|
749
|
+
});
|
|
841
750
|
|
|
842
|
-
|
|
751
|
+
groupContent.set(`${readKeyID2}_for_${admin.id}`, revelation2, "trusting");
|
|
843
752
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
});
|
|
753
|
+
groupContent.set("readKey", readKeyID2, "trusting");
|
|
754
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID2);
|
|
755
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
|
|
848
756
|
|
|
849
|
-
childContent = expectMap(childObject.getCurrentContent());
|
|
850
757
|
expect(childContent.get("foo")).toEqual("bar");
|
|
851
758
|
|
|
852
|
-
childContent.
|
|
853
|
-
editable.set("foo2", "bar2", "private");
|
|
854
|
-
expect(editable.get("foo2")).toEqual("bar2");
|
|
855
|
-
});
|
|
856
|
-
childContent = expectMap(childObject.getCurrentContent());
|
|
857
|
-
expect(childContent.get("foo")).toEqual("bar");
|
|
759
|
+
childContent.set("foo2", "bar2", "private");
|
|
858
760
|
expect(childContent.get("foo2")).toEqual("bar2");
|
|
859
761
|
});
|
|
860
762
|
|
|
861
763
|
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 (high level)", () => {
|
|
862
764
|
const { group } = newGroupHighLevel();
|
|
863
765
|
|
|
864
|
-
|
|
766
|
+
const childObject = group.createMap();
|
|
865
767
|
|
|
866
768
|
const firstReadKey = childObject.core.getCurrentReadKey();
|
|
867
769
|
|
|
868
|
-
childObject
|
|
869
|
-
editable.set("foo", "bar", "private");
|
|
870
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
871
|
-
});
|
|
872
|
-
|
|
770
|
+
childObject.set("foo", "bar", "private");
|
|
873
771
|
expect(childObject.get("foo")).toEqual("bar");
|
|
874
772
|
|
|
875
773
|
group.rotateReadKey();
|
|
876
774
|
|
|
877
775
|
expect(childObject.core.getCurrentReadKey()).not.toEqual(firstReadKey);
|
|
878
776
|
|
|
879
|
-
childObject
|
|
880
|
-
editable.set("foo2", "bar2", "private");
|
|
881
|
-
expect(editable.get("foo2")).toEqual("bar2");
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
expect(childObject.get("foo")).toEqual("bar");
|
|
777
|
+
childObject.set("foo2", "bar2", "private");
|
|
885
778
|
expect(childObject.get("foo2")).toEqual("bar2");
|
|
886
779
|
});
|
|
887
780
|
|
|
@@ -898,85 +791,76 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
898
791
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
899
792
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
900
793
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
},
|
|
910
|
-
});
|
|
911
|
-
|
|
912
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
913
|
-
|
|
914
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
915
|
-
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
916
|
-
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
794
|
+
const revelation = seal({
|
|
795
|
+
message: readKey,
|
|
796
|
+
from: admin.currentSealerSecret(),
|
|
797
|
+
to: admin.currentSealerID(),
|
|
798
|
+
nOnceMaterial: {
|
|
799
|
+
in: groupCore.id,
|
|
800
|
+
tx: groupCore.nextTransactionID(),
|
|
801
|
+
},
|
|
917
802
|
});
|
|
918
803
|
|
|
919
|
-
|
|
804
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
920
805
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
806
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
807
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID);
|
|
808
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
809
|
+
|
|
810
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
811
|
+
|
|
812
|
+
childContent.set("foo", "bar", "private");
|
|
813
|
+
expect(childContent.get("foo")).toEqual("bar");
|
|
925
814
|
|
|
926
|
-
childContent = expectMap(childObject.getCurrentContent());
|
|
927
815
|
expect(childContent.get("foo")).toEqual("bar");
|
|
928
816
|
|
|
929
817
|
const reader = node.createAccount("reader");
|
|
930
818
|
|
|
931
819
|
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
932
820
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
);
|
|
966
|
-
|
|
967
|
-
editable.set("readKey", readKeyID2, "trusting");
|
|
968
|
-
|
|
969
|
-
expect(editable.get("readKey")).toEqual(readKeyID2);
|
|
970
|
-
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
|
|
971
|
-
|
|
972
|
-
editable.set(reader.id, "reader", "trusting");
|
|
973
|
-
expect(editable.get(reader.id)).toEqual("reader");
|
|
974
|
-
});
|
|
821
|
+
const revelation2 = seal({
|
|
822
|
+
message: readKey2,
|
|
823
|
+
from: admin.currentSealerSecret(),
|
|
824
|
+
to: admin.currentSealerID(),
|
|
825
|
+
nOnceMaterial: {
|
|
826
|
+
in: groupCore.id,
|
|
827
|
+
tx: groupCore.nextTransactionID(),
|
|
828
|
+
},
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
groupContent.set(`${readKeyID2}_for_${admin.id}`, revelation2, "trusting");
|
|
832
|
+
|
|
833
|
+
const revelation3 = seal({
|
|
834
|
+
message: readKey2,
|
|
835
|
+
from: admin.currentSealerSecret(),
|
|
836
|
+
to: reader.currentSealerID(),
|
|
837
|
+
nOnceMaterial: {
|
|
838
|
+
in: groupCore.id,
|
|
839
|
+
tx: groupCore.nextTransactionID(),
|
|
840
|
+
},
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
groupContent.set(`${readKeyID2}_for_${reader.id}`, revelation3, "trusting");
|
|
844
|
+
|
|
845
|
+
groupContent.set(
|
|
846
|
+
`${readKeyID}_for_${readKeyID2}`,
|
|
847
|
+
encryptKeySecret({
|
|
848
|
+
toEncrypt: { id: readKeyID, secret: readKey },
|
|
849
|
+
encrypting: { id: readKeyID2, secret: readKey2 },
|
|
850
|
+
}).encrypted,
|
|
851
|
+
"trusting"
|
|
852
|
+
);
|
|
975
853
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
854
|
+
groupContent.set("readKey", readKeyID2, "trusting");
|
|
855
|
+
|
|
856
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID2);
|
|
857
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
|
|
858
|
+
|
|
859
|
+
groupContent.set(reader.id, "reader", "trusting");
|
|
860
|
+
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
861
|
+
|
|
862
|
+
childContent.set("foo2", "bar2", "private");
|
|
863
|
+
expect(childContent.get("foo2")).toEqual("bar2");
|
|
980
864
|
|
|
981
865
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
982
866
|
reader,
|
|
@@ -996,14 +880,12 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
996
880
|
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)", () => {
|
|
997
881
|
const { node, group } = newGroupHighLevel();
|
|
998
882
|
|
|
999
|
-
|
|
883
|
+
const childObject = group.createMap();
|
|
1000
884
|
|
|
1001
885
|
const firstReadKey = childObject.core.getCurrentReadKey();
|
|
1002
886
|
|
|
1003
|
-
childObject
|
|
1004
|
-
|
|
1005
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
1006
|
-
});
|
|
887
|
+
childObject.set("foo", "bar", "private");
|
|
888
|
+
expect(childObject.get("foo")).toEqual("bar");
|
|
1007
889
|
|
|
1008
890
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1009
891
|
|
|
@@ -1015,10 +897,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
1015
897
|
|
|
1016
898
|
group.addMember(reader, "reader");
|
|
1017
899
|
|
|
1018
|
-
childObject
|
|
1019
|
-
|
|
1020
|
-
expect(editable.get("foo2")).toEqual("bar2");
|
|
1021
|
-
});
|
|
900
|
+
childObject.set("foo2", "bar2", "private");
|
|
901
|
+
expect(childObject.get("foo2")).toEqual("bar2");
|
|
1022
902
|
|
|
1023
903
|
const childContentAsReader = expectMap(
|
|
1024
904
|
childObject.core
|
|
@@ -1046,61 +926,54 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1046
926
|
|
|
1047
927
|
const reader2 = node.createAccount("reader2");
|
|
1048
928
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
},
|
|
1058
|
-
});
|
|
1059
|
-
|
|
1060
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
1061
|
-
|
|
1062
|
-
const revelation2 = seal({
|
|
1063
|
-
message: readKey,
|
|
1064
|
-
from: admin.currentSealerSecret(),
|
|
1065
|
-
to: reader.currentSealerID(),
|
|
1066
|
-
nOnceMaterial: {
|
|
1067
|
-
in: groupCore.id,
|
|
1068
|
-
tx: groupCore.nextTransactionID(),
|
|
1069
|
-
},
|
|
1070
|
-
});
|
|
1071
|
-
|
|
1072
|
-
editable.set(`${readKeyID}_for_${reader.id}`, revelation2, "trusting");
|
|
1073
|
-
|
|
1074
|
-
const revelation3 = seal({
|
|
1075
|
-
message: readKey,
|
|
1076
|
-
from: admin.currentSealerSecret(),
|
|
1077
|
-
to: reader2.currentSealerID(),
|
|
1078
|
-
nOnceMaterial: {
|
|
1079
|
-
in: groupCore.id,
|
|
1080
|
-
tx: groupCore.nextTransactionID(),
|
|
1081
|
-
},
|
|
1082
|
-
});
|
|
1083
|
-
|
|
1084
|
-
editable.set(`${readKeyID}_for_${reader2.id}`, revelation3, "trusting");
|
|
1085
|
-
|
|
1086
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
1087
|
-
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
1088
|
-
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
1089
|
-
|
|
1090
|
-
editable.set(reader.id, "reader", "trusting");
|
|
1091
|
-
expect(editable.get(reader.id)).toEqual("reader");
|
|
1092
|
-
editable.set(reader2.id, "reader", "trusting");
|
|
1093
|
-
expect(editable.get(reader2.id)).toEqual("reader");
|
|
929
|
+
const revelation1 = seal({
|
|
930
|
+
message: readKey,
|
|
931
|
+
from: admin.currentSealerSecret(),
|
|
932
|
+
to: admin.currentSealerID(),
|
|
933
|
+
nOnceMaterial: {
|
|
934
|
+
in: groupCore.id,
|
|
935
|
+
tx: groupCore.nextTransactionID(),
|
|
936
|
+
},
|
|
1094
937
|
});
|
|
1095
938
|
|
|
1096
|
-
|
|
939
|
+
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
1097
940
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
941
|
+
const revelation2 = seal({
|
|
942
|
+
message: readKey,
|
|
943
|
+
from: admin.currentSealerSecret(),
|
|
944
|
+
to: reader.currentSealerID(),
|
|
945
|
+
nOnceMaterial: {
|
|
946
|
+
in: groupCore.id,
|
|
947
|
+
tx: groupCore.nextTransactionID(),
|
|
948
|
+
},
|
|
1101
949
|
});
|
|
1102
950
|
|
|
1103
|
-
|
|
951
|
+
groupContent.set(`${readKeyID}_for_${reader.id}`, revelation2, "trusting");
|
|
952
|
+
|
|
953
|
+
const revelation3 = seal({
|
|
954
|
+
message: readKey,
|
|
955
|
+
from: admin.currentSealerSecret(),
|
|
956
|
+
to: reader2.currentSealerID(),
|
|
957
|
+
nOnceMaterial: {
|
|
958
|
+
in: groupCore.id,
|
|
959
|
+
tx: groupCore.nextTransactionID(),
|
|
960
|
+
},
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
groupContent.set(`${readKeyID}_for_${reader2.id}`, revelation3, "trusting");
|
|
964
|
+
|
|
965
|
+
groupContent.set("readKey", readKeyID, "trusting");
|
|
966
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID);
|
|
967
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey);
|
|
968
|
+
|
|
969
|
+
groupContent.set(reader.id, "reader", "trusting");
|
|
970
|
+
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
971
|
+
groupContent.set(reader2.id, "reader", "trusting");
|
|
972
|
+
expect(groupContent.get(reader2.id)).toEqual("reader");
|
|
973
|
+
|
|
974
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
975
|
+
|
|
976
|
+
childContent.set("foo", "bar", "private");
|
|
1104
977
|
expect(childContent.get("foo")).toEqual("bar");
|
|
1105
978
|
|
|
1106
979
|
let childObjectAsReader = childObject.testWithDifferentAccount(
|
|
@@ -1123,55 +996,50 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1123
996
|
|
|
1124
997
|
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
1125
998
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
},
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
|
-
editable.set(
|
|
1138
|
-
`${readKeyID2}_for_${admin.id}`,
|
|
1139
|
-
newRevelation1,
|
|
1140
|
-
"trusting"
|
|
1141
|
-
);
|
|
1142
|
-
|
|
1143
|
-
const newRevelation2 = seal({
|
|
1144
|
-
message: readKey2,
|
|
1145
|
-
from: admin.currentSealerSecret(),
|
|
1146
|
-
to: reader2.currentSealerID(),
|
|
1147
|
-
nOnceMaterial: {
|
|
1148
|
-
in: groupCore.id,
|
|
1149
|
-
tx: groupCore.nextTransactionID(),
|
|
1150
|
-
},
|
|
1151
|
-
});
|
|
1152
|
-
|
|
1153
|
-
editable.set(
|
|
1154
|
-
`${readKeyID2}_for_${reader2.id}`,
|
|
1155
|
-
newRevelation2,
|
|
1156
|
-
"trusting"
|
|
1157
|
-
);
|
|
1158
|
-
|
|
1159
|
-
editable.set("readKey", readKeyID2, "trusting");
|
|
1160
|
-
expect(editable.get("readKey")).toEqual(readKeyID2);
|
|
1161
|
-
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
|
|
1162
|
-
|
|
1163
|
-
editable.set(reader.id, "revoked", "trusting");
|
|
1164
|
-
// expect(editable.get(reader.id)).toEqual("revoked");
|
|
999
|
+
const newRevelation1 = seal({
|
|
1000
|
+
message: readKey2,
|
|
1001
|
+
from: admin.currentSealerSecret(),
|
|
1002
|
+
to: admin.currentSealerID(),
|
|
1003
|
+
nOnceMaterial: {
|
|
1004
|
+
in: groupCore.id,
|
|
1005
|
+
tx: groupCore.nextTransactionID(),
|
|
1006
|
+
},
|
|
1165
1007
|
});
|
|
1166
1008
|
|
|
1167
|
-
|
|
1009
|
+
groupContent.set(
|
|
1010
|
+
`${readKeyID2}_for_${admin.id}`,
|
|
1011
|
+
newRevelation1,
|
|
1012
|
+
"trusting"
|
|
1013
|
+
);
|
|
1168
1014
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1015
|
+
const newRevelation2 = seal({
|
|
1016
|
+
message: readKey2,
|
|
1017
|
+
from: admin.currentSealerSecret(),
|
|
1018
|
+
to: reader2.currentSealerID(),
|
|
1019
|
+
nOnceMaterial: {
|
|
1020
|
+
in: groupCore.id,
|
|
1021
|
+
tx: groupCore.nextTransactionID(),
|
|
1022
|
+
},
|
|
1173
1023
|
});
|
|
1174
1024
|
|
|
1025
|
+
groupContent.set(
|
|
1026
|
+
`${readKeyID2}_for_${reader2.id}`,
|
|
1027
|
+
newRevelation2,
|
|
1028
|
+
"trusting"
|
|
1029
|
+
);
|
|
1030
|
+
|
|
1031
|
+
groupContent.set("readKey", readKeyID2, "trusting");
|
|
1032
|
+
expect(groupContent.get("readKey")).toEqual(readKeyID2);
|
|
1033
|
+
expect(groupCore.getCurrentReadKey().secret).toEqual(readKey2);
|
|
1034
|
+
|
|
1035
|
+
groupContent.set(reader.id, "revoked", "trusting");
|
|
1036
|
+
// expect(editable.get(reader.id)).toEqual("revoked");
|
|
1037
|
+
|
|
1038
|
+
expect(childObject.getCurrentReadKey().secret).toEqual(readKey2);
|
|
1039
|
+
|
|
1040
|
+
childContent.set("foo2", "bar2", "private");
|
|
1041
|
+
expect(childContent.get("foo2")).toEqual("bar2");
|
|
1042
|
+
|
|
1175
1043
|
// TODO: make sure these instances of coValues sync between each other so this isn't necessary?
|
|
1176
1044
|
childObjectAsReader = childObject.testWithDifferentAccount(
|
|
1177
1045
|
reader,
|
|
@@ -1193,12 +1061,10 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1193
1061
|
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 (high level)", () => {
|
|
1194
1062
|
const { node, group } = newGroupHighLevel();
|
|
1195
1063
|
|
|
1196
|
-
|
|
1064
|
+
const childObject = group.createMap();
|
|
1197
1065
|
|
|
1198
|
-
childObject
|
|
1199
|
-
|
|
1200
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
1201
|
-
});
|
|
1066
|
+
childObject.set("foo", "bar", "private");
|
|
1067
|
+
expect(childObject.get("foo")).toEqual("bar");
|
|
1202
1068
|
|
|
1203
1069
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1204
1070
|
|
|
@@ -1213,22 +1079,15 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1213
1079
|
group.addMember(reader, "reader");
|
|
1214
1080
|
group.addMember(reader2, "reader");
|
|
1215
1081
|
|
|
1216
|
-
childObject
|
|
1217
|
-
editable.set("foo2", "bar2", "private");
|
|
1218
|
-
expect(editable.get("foo2")).toEqual("bar2");
|
|
1219
|
-
});
|
|
1220
|
-
|
|
1221
|
-
expect(childObject.get("foo")).toEqual("bar");
|
|
1082
|
+
childObject.set("foo2", "bar2", "private");
|
|
1222
1083
|
expect(childObject.get("foo2")).toEqual("bar2");
|
|
1223
1084
|
|
|
1224
|
-
group.removeMember(reader
|
|
1085
|
+
group.removeMember(reader);
|
|
1225
1086
|
|
|
1226
1087
|
expect(childObject.core.getCurrentReadKey()).not.toEqual(secondReadKey);
|
|
1227
1088
|
|
|
1228
|
-
childObject
|
|
1229
|
-
|
|
1230
|
-
expect(editable.get("foo3")).toEqual("bar3");
|
|
1231
|
-
});
|
|
1089
|
+
childObject.set("foo3", "bar3", "private");
|
|
1090
|
+
expect(childObject.get("foo3")).toEqual("bar3");
|
|
1232
1091
|
|
|
1233
1092
|
const childContentAsReader2 = expectMap(
|
|
1234
1093
|
childObject.core
|
|
@@ -1275,42 +1134,38 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1275
1134
|
const inviteSecret = newRandomAgentSecret();
|
|
1276
1135
|
const inviteID = getAgentID(inviteSecret);
|
|
1277
1136
|
|
|
1278
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
editable.set(
|
|
1308
|
-
`${readKeyID}_for_${inviteID}`,
|
|
1309
|
-
revelationForInvite,
|
|
1310
|
-
"trusting"
|
|
1311
|
-
);
|
|
1137
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1138
|
+
|
|
1139
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1140
|
+
const revelation = seal({
|
|
1141
|
+
message: readKey,
|
|
1142
|
+
from: admin.currentSealerSecret(),
|
|
1143
|
+
to: admin.currentSealerID(),
|
|
1144
|
+
nOnceMaterial: {
|
|
1145
|
+
in: groupCore.id,
|
|
1146
|
+
tx: groupCore.nextTransactionID(),
|
|
1147
|
+
},
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
group.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1151
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1152
|
+
|
|
1153
|
+
group.set(inviteID, "adminInvite", "trusting");
|
|
1154
|
+
|
|
1155
|
+
expect(group.get(inviteID)).toEqual("adminInvite");
|
|
1156
|
+
|
|
1157
|
+
const revelationForInvite = seal({
|
|
1158
|
+
message: readKey,
|
|
1159
|
+
from: admin.currentSealerSecret(),
|
|
1160
|
+
to: getAgentSealerID(inviteID),
|
|
1161
|
+
nOnceMaterial: {
|
|
1162
|
+
in: groupCore.id,
|
|
1163
|
+
tx: groupCore.nextTransactionID(),
|
|
1164
|
+
},
|
|
1312
1165
|
});
|
|
1313
1166
|
|
|
1167
|
+
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
1168
|
+
|
|
1314
1169
|
const groupAsInvite = expectGroup(
|
|
1315
1170
|
groupCore
|
|
1316
1171
|
.testWithDifferentAccount(
|
|
@@ -1323,35 +1178,33 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1323
1178
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1324
1179
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1325
1180
|
|
|
1326
|
-
groupAsInvite.
|
|
1327
|
-
editable.set(invitedAdminID, "admin", "trusting");
|
|
1181
|
+
groupAsInvite.set(invitedAdminID, "admin", "trusting");
|
|
1328
1182
|
|
|
1329
|
-
|
|
1183
|
+
expect(groupAsInvite.get(invitedAdminID)).toEqual("admin");
|
|
1330
1184
|
|
|
1331
|
-
|
|
1185
|
+
const readKeyAsInvite = groupAsInvite.core.getCurrentReadKey();
|
|
1332
1186
|
|
|
1333
|
-
|
|
1187
|
+
expect(readKeyAsInvite.secret).toBeDefined();
|
|
1334
1188
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1189
|
+
const revelation2 = seal({
|
|
1190
|
+
message: readKeyAsInvite.secret!,
|
|
1191
|
+
from: getAgentSealerSecret(invitedAdminSecret),
|
|
1192
|
+
to: getAgentSealerID(invitedAdminID),
|
|
1193
|
+
nOnceMaterial: {
|
|
1194
|
+
in: groupCore.id,
|
|
1195
|
+
tx: groupCore.nextTransactionID(),
|
|
1196
|
+
},
|
|
1197
|
+
});
|
|
1344
1198
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1199
|
+
groupAsInvite.set(
|
|
1200
|
+
`${readKeyAsInvite.id}_for_${invitedAdminID}`,
|
|
1201
|
+
revelation2,
|
|
1202
|
+
"trusting"
|
|
1203
|
+
);
|
|
1350
1204
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
});
|
|
1205
|
+
expect(
|
|
1206
|
+
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedAdminID}`)
|
|
1207
|
+
).toEqual(revelation2);
|
|
1355
1208
|
});
|
|
1356
1209
|
|
|
1357
1210
|
test("Admins can create an adminInvite, which can add an admin (high-level)", async () => {
|
|
@@ -1380,10 +1233,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
1380
1233
|
expect(groupAsInvitedAdmin.get(invitedAdminID)).toEqual("admin");
|
|
1381
1234
|
expect(groupAsInvitedAdmin.core.getCurrentReadKey().secret).toBeDefined();
|
|
1382
1235
|
|
|
1383
|
-
groupAsInvitedAdmin
|
|
1384
|
-
thirdAdminID,
|
|
1385
|
-
"admin"
|
|
1386
|
-
);
|
|
1236
|
+
groupAsInvitedAdmin.addMemberInternal(thirdAdminID, "admin");
|
|
1387
1237
|
|
|
1388
1238
|
expect(groupAsInvitedAdmin.get(thirdAdminID)).toEqual("admin");
|
|
1389
1239
|
});
|
|
@@ -1394,42 +1244,38 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1394
1244
|
const inviteSecret = newRandomAgentSecret();
|
|
1395
1245
|
const inviteID = getAgentID(inviteSecret);
|
|
1396
1246
|
|
|
1397
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
editable.set(
|
|
1427
|
-
`${readKeyID}_for_${inviteID}`,
|
|
1428
|
-
revelationForInvite,
|
|
1429
|
-
"trusting"
|
|
1430
|
-
);
|
|
1247
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1248
|
+
|
|
1249
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1250
|
+
const revelation = seal({
|
|
1251
|
+
message: readKey,
|
|
1252
|
+
from: admin.currentSealerSecret(),
|
|
1253
|
+
to: admin.currentSealerID(),
|
|
1254
|
+
nOnceMaterial: {
|
|
1255
|
+
in: groupCore.id,
|
|
1256
|
+
tx: groupCore.nextTransactionID(),
|
|
1257
|
+
},
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
group.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1261
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1262
|
+
|
|
1263
|
+
group.set(inviteID, "writerInvite", "trusting");
|
|
1264
|
+
|
|
1265
|
+
expect(group.get(inviteID)).toEqual("writerInvite");
|
|
1266
|
+
|
|
1267
|
+
const revelationForInvite = seal({
|
|
1268
|
+
message: readKey,
|
|
1269
|
+
from: admin.currentSealerSecret(),
|
|
1270
|
+
to: getAgentSealerID(inviteID),
|
|
1271
|
+
nOnceMaterial: {
|
|
1272
|
+
in: groupCore.id,
|
|
1273
|
+
tx: groupCore.nextTransactionID(),
|
|
1274
|
+
},
|
|
1431
1275
|
});
|
|
1432
1276
|
|
|
1277
|
+
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
1278
|
+
|
|
1433
1279
|
const groupAsInvite = expectGroup(
|
|
1434
1280
|
groupCore
|
|
1435
1281
|
.testWithDifferentAccount(
|
|
@@ -1442,35 +1288,33 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1442
1288
|
const invitedWriterSecret = newRandomAgentSecret();
|
|
1443
1289
|
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1444
1290
|
|
|
1445
|
-
groupAsInvite.
|
|
1446
|
-
editable.set(invitedWriterID, "writer", "trusting");
|
|
1291
|
+
groupAsInvite.set(invitedWriterID, "writer", "trusting");
|
|
1447
1292
|
|
|
1448
|
-
|
|
1293
|
+
expect(groupAsInvite.get(invitedWriterID)).toEqual("writer");
|
|
1449
1294
|
|
|
1450
|
-
|
|
1295
|
+
const readKeyAsInvite = groupAsInvite.core.getCurrentReadKey();
|
|
1451
1296
|
|
|
1452
|
-
|
|
1297
|
+
expect(readKeyAsInvite.secret).toBeDefined();
|
|
1453
1298
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1299
|
+
const revelation2 = seal({
|
|
1300
|
+
message: readKeyAsInvite.secret!,
|
|
1301
|
+
from: getAgentSealerSecret(invitedWriterSecret),
|
|
1302
|
+
to: getAgentSealerID(invitedWriterID),
|
|
1303
|
+
nOnceMaterial: {
|
|
1304
|
+
in: groupCore.id,
|
|
1305
|
+
tx: groupCore.nextTransactionID(),
|
|
1306
|
+
},
|
|
1307
|
+
});
|
|
1463
1308
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1309
|
+
groupAsInvite.set(
|
|
1310
|
+
`${readKeyAsInvite.id}_for_${invitedWriterID}`,
|
|
1311
|
+
revelation2,
|
|
1312
|
+
"trusting"
|
|
1313
|
+
);
|
|
1469
1314
|
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
});
|
|
1315
|
+
expect(
|
|
1316
|
+
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedWriterID}`)
|
|
1317
|
+
).toEqual(revelation2);
|
|
1474
1318
|
});
|
|
1475
1319
|
|
|
1476
1320
|
test("Admins can create a writerInvite, which can add a writer (high-level)", async () => {
|
|
@@ -1503,42 +1347,38 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1503
1347
|
const inviteSecret = newRandomAgentSecret();
|
|
1504
1348
|
const inviteID = getAgentID(inviteSecret);
|
|
1505
1349
|
|
|
1506
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
editable.set(
|
|
1536
|
-
`${readKeyID}_for_${inviteID}`,
|
|
1537
|
-
revelationForInvite,
|
|
1538
|
-
"trusting"
|
|
1539
|
-
);
|
|
1350
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1351
|
+
|
|
1352
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1353
|
+
const revelation = seal({
|
|
1354
|
+
message: readKey,
|
|
1355
|
+
from: admin.currentSealerSecret(),
|
|
1356
|
+
to: admin.currentSealerID(),
|
|
1357
|
+
nOnceMaterial: {
|
|
1358
|
+
in: groupCore.id,
|
|
1359
|
+
tx: groupCore.nextTransactionID(),
|
|
1360
|
+
},
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
group.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1364
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1365
|
+
|
|
1366
|
+
group.set(inviteID, "readerInvite", "trusting");
|
|
1367
|
+
|
|
1368
|
+
expect(group.get(inviteID)).toEqual("readerInvite");
|
|
1369
|
+
|
|
1370
|
+
const revelationForInvite = seal({
|
|
1371
|
+
message: readKey,
|
|
1372
|
+
from: admin.currentSealerSecret(),
|
|
1373
|
+
to: getAgentSealerID(inviteID),
|
|
1374
|
+
nOnceMaterial: {
|
|
1375
|
+
in: groupCore.id,
|
|
1376
|
+
tx: groupCore.nextTransactionID(),
|
|
1377
|
+
},
|
|
1540
1378
|
});
|
|
1541
1379
|
|
|
1380
|
+
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
1381
|
+
|
|
1542
1382
|
const groupAsInvite = expectGroup(
|
|
1543
1383
|
groupCore
|
|
1544
1384
|
.testWithDifferentAccount(
|
|
@@ -1551,35 +1391,33 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1551
1391
|
const invitedReaderSecret = newRandomAgentSecret();
|
|
1552
1392
|
const invitedReaderID = getAgentID(invitedReaderSecret);
|
|
1553
1393
|
|
|
1554
|
-
groupAsInvite.
|
|
1555
|
-
editable.set(invitedReaderID, "reader", "trusting");
|
|
1394
|
+
groupAsInvite.set(invitedReaderID, "reader", "trusting");
|
|
1556
1395
|
|
|
1557
|
-
|
|
1396
|
+
expect(groupAsInvite.get(invitedReaderID)).toEqual("reader");
|
|
1558
1397
|
|
|
1559
|
-
|
|
1398
|
+
const readKeyAsInvite = groupAsInvite.core.getCurrentReadKey();
|
|
1560
1399
|
|
|
1561
|
-
|
|
1400
|
+
expect(readKeyAsInvite.secret).toBeDefined();
|
|
1562
1401
|
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1402
|
+
const revelation2 = seal({
|
|
1403
|
+
message: readKeyAsInvite.secret!,
|
|
1404
|
+
from: getAgentSealerSecret(invitedReaderSecret),
|
|
1405
|
+
to: getAgentSealerID(invitedReaderID),
|
|
1406
|
+
nOnceMaterial: {
|
|
1407
|
+
in: groupCore.id,
|
|
1408
|
+
tx: groupCore.nextTransactionID(),
|
|
1409
|
+
},
|
|
1410
|
+
});
|
|
1572
1411
|
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1412
|
+
groupAsInvite.set(
|
|
1413
|
+
`${readKeyAsInvite.id}_for_${invitedReaderID}`,
|
|
1414
|
+
revelation,
|
|
1415
|
+
"trusting"
|
|
1416
|
+
);
|
|
1578
1417
|
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
});
|
|
1418
|
+
expect(
|
|
1419
|
+
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedReaderID}`)
|
|
1420
|
+
).toEqual(revelation);
|
|
1583
1421
|
});
|
|
1584
1422
|
|
|
1585
1423
|
test("Admins can create a readerInvite, which can add a reader (high-level)", async () => {
|
|
@@ -1612,42 +1450,38 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1612
1450
|
const inviteSecret = newRandomAgentSecret();
|
|
1613
1451
|
const inviteID = getAgentID(inviteSecret);
|
|
1614
1452
|
|
|
1615
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1628
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
1629
|
-
|
|
1630
|
-
editable.set(inviteID, "writerInvite", "trusting");
|
|
1631
|
-
|
|
1632
|
-
expect(editable.get(inviteID)).toEqual("writerInvite");
|
|
1633
|
-
|
|
1634
|
-
const revelationForInvite = seal({
|
|
1635
|
-
message: readKey,
|
|
1636
|
-
from: admin.currentSealerSecret(),
|
|
1637
|
-
to: getAgentSealerID(inviteID),
|
|
1638
|
-
nOnceMaterial: {
|
|
1639
|
-
in: groupCore.id,
|
|
1640
|
-
tx: groupCore.nextTransactionID(),
|
|
1641
|
-
},
|
|
1642
|
-
});
|
|
1643
|
-
|
|
1644
|
-
editable.set(
|
|
1645
|
-
`${readKeyID}_for_${inviteID}`,
|
|
1646
|
-
revelationForInvite,
|
|
1647
|
-
"trusting"
|
|
1648
|
-
);
|
|
1453
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1454
|
+
|
|
1455
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1456
|
+
const revelation = seal({
|
|
1457
|
+
message: readKey,
|
|
1458
|
+
from: admin.currentSealerSecret(),
|
|
1459
|
+
to: admin.currentSealerID(),
|
|
1460
|
+
nOnceMaterial: {
|
|
1461
|
+
in: groupCore.id,
|
|
1462
|
+
tx: groupCore.nextTransactionID(),
|
|
1463
|
+
},
|
|
1649
1464
|
});
|
|
1650
1465
|
|
|
1466
|
+
group.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1467
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1468
|
+
|
|
1469
|
+
group.set(inviteID, "writerInvite", "trusting");
|
|
1470
|
+
|
|
1471
|
+
expect(group.get(inviteID)).toEqual("writerInvite");
|
|
1472
|
+
|
|
1473
|
+
const revelationForInvite = seal({
|
|
1474
|
+
message: readKey,
|
|
1475
|
+
from: admin.currentSealerSecret(),
|
|
1476
|
+
to: getAgentSealerID(inviteID),
|
|
1477
|
+
nOnceMaterial: {
|
|
1478
|
+
in: groupCore.id,
|
|
1479
|
+
tx: groupCore.nextTransactionID(),
|
|
1480
|
+
},
|
|
1481
|
+
});
|
|
1482
|
+
|
|
1483
|
+
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
1484
|
+
|
|
1651
1485
|
const groupAsInvite = expectGroup(
|
|
1652
1486
|
groupCore
|
|
1653
1487
|
.testWithDifferentAccount(
|
|
@@ -1660,10 +1494,8 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1660
1494
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1661
1495
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1662
1496
|
|
|
1663
|
-
groupAsInvite.
|
|
1664
|
-
|
|
1665
|
-
expect(editable.get(invitedAdminID)).toBeUndefined();
|
|
1666
|
-
});
|
|
1497
|
+
groupAsInvite.set(invitedAdminID, "admin", "trusting");
|
|
1498
|
+
expect(groupAsInvite.get(invitedAdminID)).toBeUndefined();
|
|
1667
1499
|
});
|
|
1668
1500
|
|
|
1669
1501
|
test("ReaderInvites can not invite admins", () => {
|
|
@@ -1672,42 +1504,38 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1672
1504
|
const inviteSecret = newRandomAgentSecret();
|
|
1673
1505
|
const inviteID = getAgentID(inviteSecret);
|
|
1674
1506
|
|
|
1675
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1688
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
1689
|
-
|
|
1690
|
-
editable.set(inviteID, "readerInvite", "trusting");
|
|
1691
|
-
|
|
1692
|
-
expect(editable.get(inviteID)).toEqual("readerInvite");
|
|
1693
|
-
|
|
1694
|
-
const revelationForInvite = seal({
|
|
1695
|
-
message: readKey,
|
|
1696
|
-
from: admin.currentSealerSecret(),
|
|
1697
|
-
to: getAgentSealerID(inviteID),
|
|
1698
|
-
nOnceMaterial: {
|
|
1699
|
-
in: groupCore.id,
|
|
1700
|
-
tx: groupCore.nextTransactionID(),
|
|
1701
|
-
},
|
|
1702
|
-
});
|
|
1703
|
-
|
|
1704
|
-
editable.set(
|
|
1705
|
-
`${readKeyID}_for_${inviteID}`,
|
|
1706
|
-
revelationForInvite,
|
|
1707
|
-
"trusting"
|
|
1708
|
-
);
|
|
1507
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1508
|
+
|
|
1509
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1510
|
+
const revelation = seal({
|
|
1511
|
+
message: readKey,
|
|
1512
|
+
from: admin.currentSealerSecret(),
|
|
1513
|
+
to: admin.currentSealerID(),
|
|
1514
|
+
nOnceMaterial: {
|
|
1515
|
+
in: groupCore.id,
|
|
1516
|
+
tx: groupCore.nextTransactionID(),
|
|
1517
|
+
},
|
|
1709
1518
|
});
|
|
1710
1519
|
|
|
1520
|
+
group.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1521
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1522
|
+
|
|
1523
|
+
group.set(inviteID, "readerInvite", "trusting");
|
|
1524
|
+
|
|
1525
|
+
expect(group.get(inviteID)).toEqual("readerInvite");
|
|
1526
|
+
|
|
1527
|
+
const revelationForInvite = seal({
|
|
1528
|
+
message: readKey,
|
|
1529
|
+
from: admin.currentSealerSecret(),
|
|
1530
|
+
to: getAgentSealerID(inviteID),
|
|
1531
|
+
nOnceMaterial: {
|
|
1532
|
+
in: groupCore.id,
|
|
1533
|
+
tx: groupCore.nextTransactionID(),
|
|
1534
|
+
},
|
|
1535
|
+
});
|
|
1536
|
+
|
|
1537
|
+
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
1538
|
+
|
|
1711
1539
|
const groupAsInvite = expectGroup(
|
|
1712
1540
|
groupCore
|
|
1713
1541
|
.testWithDifferentAccount(
|
|
@@ -1720,10 +1548,8 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1720
1548
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1721
1549
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1722
1550
|
|
|
1723
|
-
groupAsInvite.
|
|
1724
|
-
|
|
1725
|
-
expect(editable.get(invitedAdminID)).toBeUndefined();
|
|
1726
|
-
});
|
|
1551
|
+
groupAsInvite.set(invitedAdminID, "admin", "trusting");
|
|
1552
|
+
expect(groupAsInvite.get(invitedAdminID)).toBeUndefined();
|
|
1727
1553
|
});
|
|
1728
1554
|
|
|
1729
1555
|
test("ReaderInvites can not invite writers", () => {
|
|
@@ -1732,42 +1558,38 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1732
1558
|
const inviteSecret = newRandomAgentSecret();
|
|
1733
1559
|
const inviteID = getAgentID(inviteSecret);
|
|
1734
1560
|
|
|
1735
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
editable.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1748
|
-
editable.set("readKey", readKeyID, "trusting");
|
|
1749
|
-
|
|
1750
|
-
editable.set(inviteID, "readerInvite", "trusting");
|
|
1751
|
-
|
|
1752
|
-
expect(editable.get(inviteID)).toEqual("readerInvite");
|
|
1753
|
-
|
|
1754
|
-
const revelationForInvite = seal({
|
|
1755
|
-
message: readKey,
|
|
1756
|
-
from: admin.currentSealerSecret(),
|
|
1757
|
-
to: getAgentSealerID(inviteID),
|
|
1758
|
-
nOnceMaterial: {
|
|
1759
|
-
in: groupCore.id,
|
|
1760
|
-
tx: groupCore.nextTransactionID(),
|
|
1761
|
-
},
|
|
1762
|
-
});
|
|
1763
|
-
|
|
1764
|
-
editable.set(
|
|
1765
|
-
`${readKeyID}_for_${inviteID}`,
|
|
1766
|
-
revelationForInvite,
|
|
1767
|
-
"trusting"
|
|
1768
|
-
);
|
|
1561
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1562
|
+
|
|
1563
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1564
|
+
const revelation = seal({
|
|
1565
|
+
message: readKey,
|
|
1566
|
+
from: admin.currentSealerSecret(),
|
|
1567
|
+
to: admin.currentSealerID(),
|
|
1568
|
+
nOnceMaterial: {
|
|
1569
|
+
in: groupCore.id,
|
|
1570
|
+
tx: groupCore.nextTransactionID(),
|
|
1571
|
+
},
|
|
1769
1572
|
});
|
|
1770
1573
|
|
|
1574
|
+
group.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
1575
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1576
|
+
|
|
1577
|
+
group.set(inviteID, "readerInvite", "trusting");
|
|
1578
|
+
|
|
1579
|
+
expect(group.get(inviteID)).toEqual("readerInvite");
|
|
1580
|
+
|
|
1581
|
+
const revelationForInvite = seal({
|
|
1582
|
+
message: readKey,
|
|
1583
|
+
from: admin.currentSealerSecret(),
|
|
1584
|
+
to: getAgentSealerID(inviteID),
|
|
1585
|
+
nOnceMaterial: {
|
|
1586
|
+
in: groupCore.id,
|
|
1587
|
+
tx: groupCore.nextTransactionID(),
|
|
1588
|
+
},
|
|
1589
|
+
});
|
|
1590
|
+
|
|
1591
|
+
group.set(`${readKeyID}_for_${inviteID}`, revelationForInvite, "trusting");
|
|
1592
|
+
|
|
1771
1593
|
const groupAsInvite = expectGroup(
|
|
1772
1594
|
groupCore
|
|
1773
1595
|
.testWithDifferentAccount(
|
|
@@ -1780,10 +1602,8 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1780
1602
|
const invitedWriterSecret = newRandomAgentSecret();
|
|
1781
1603
|
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1782
1604
|
|
|
1783
|
-
groupAsInvite.
|
|
1784
|
-
|
|
1785
|
-
expect(editable.get(invitedWriterID)).toBeUndefined();
|
|
1786
|
-
});
|
|
1605
|
+
groupAsInvite.set(invitedWriterID, "writer", "trusting");
|
|
1606
|
+
expect(groupAsInvite.get(invitedWriterID)).toBeUndefined();
|
|
1787
1607
|
});
|
|
1788
1608
|
|
|
1789
1609
|
test("Can give read permission to 'everyone'", () => {
|
|
@@ -1796,21 +1616,19 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
1796
1616
|
...createdNowUnique(),
|
|
1797
1617
|
});
|
|
1798
1618
|
|
|
1799
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
});
|
|
1619
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1620
|
+
|
|
1621
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1622
|
+
group.set("everyone", "reader", "trusting");
|
|
1623
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1624
|
+
group.set(`${readKeyID}_for_everyone`, readKey, "trusting");
|
|
1805
1625
|
|
|
1806
1626
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
1807
1627
|
|
|
1808
1628
|
expect(childContent.get("foo")).toBeUndefined();
|
|
1809
1629
|
|
|
1810
|
-
childContent.
|
|
1811
|
-
|
|
1812
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
1813
|
-
});
|
|
1630
|
+
childContent.set("foo", "bar", "private");
|
|
1631
|
+
expect(childContent.get("foo")).toEqual("bar");
|
|
1814
1632
|
|
|
1815
1633
|
const newAccount = new ControlledAgent(newRandomAgentSecret());
|
|
1816
1634
|
|
|
@@ -1835,10 +1653,8 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
|
|
|
1835
1653
|
|
|
1836
1654
|
group.addMember("everyone", "reader");
|
|
1837
1655
|
|
|
1838
|
-
childObject.
|
|
1839
|
-
|
|
1840
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
1841
|
-
});
|
|
1656
|
+
childObject.set("foo", "bar", "private");
|
|
1657
|
+
expect(childObject.get("foo")).toEqual("bar");
|
|
1842
1658
|
|
|
1843
1659
|
const newAccount = new ControlledAgent(newRandomAgentSecret());
|
|
1844
1660
|
|
|
@@ -1864,21 +1680,19 @@ test("Can give write permission to 'everyone'", () => {
|
|
|
1864
1680
|
...createdNowUnique(),
|
|
1865
1681
|
});
|
|
1866
1682
|
|
|
1867
|
-
expectGroup(groupCore.getCurrentContent())
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
});
|
|
1683
|
+
const group = expectGroup(groupCore.getCurrentContent());
|
|
1684
|
+
|
|
1685
|
+
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1686
|
+
group.set("everyone", "writer", "trusting");
|
|
1687
|
+
group.set("readKey", readKeyID, "trusting");
|
|
1688
|
+
group.set(`${readKeyID}_for_everyone`, readKey, "trusting");
|
|
1873
1689
|
|
|
1874
1690
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
1875
1691
|
|
|
1876
1692
|
expect(childContent.get("foo")).toBeUndefined();
|
|
1877
1693
|
|
|
1878
|
-
childContent.
|
|
1879
|
-
|
|
1880
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
1881
|
-
});
|
|
1694
|
+
childContent.set("foo", "bar", "private");
|
|
1695
|
+
expect(childContent.get("foo")).toEqual("bar");
|
|
1882
1696
|
|
|
1883
1697
|
const newAccount = new ControlledAgent(newRandomAgentSecret());
|
|
1884
1698
|
|
|
@@ -1893,10 +1707,8 @@ test("Can give write permission to 'everyone'", () => {
|
|
|
1893
1707
|
|
|
1894
1708
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
1895
1709
|
|
|
1896
|
-
childContent2.
|
|
1897
|
-
|
|
1898
|
-
expect(editable.get("foo")).toEqual("bar2");
|
|
1899
|
-
});
|
|
1710
|
+
childContent2.set("foo", "bar2", "private");
|
|
1711
|
+
expect(childContent2.get("foo")).toEqual("bar2");
|
|
1900
1712
|
});
|
|
1901
1713
|
|
|
1902
1714
|
test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
@@ -1908,10 +1720,8 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
1908
1720
|
|
|
1909
1721
|
group.addMember("everyone", "writer");
|
|
1910
1722
|
|
|
1911
|
-
childObject.
|
|
1912
|
-
|
|
1913
|
-
expect(editable.get("foo")).toEqual("bar");
|
|
1914
|
-
});
|
|
1723
|
+
childObject.set("foo", "bar", "private");
|
|
1724
|
+
expect(childObject.get("foo")).toEqual("bar");
|
|
1915
1725
|
|
|
1916
1726
|
const newAccount = new ControlledAgent(newRandomAgentSecret());
|
|
1917
1727
|
|
|
@@ -1926,9 +1736,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
1926
1736
|
|
|
1927
1737
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
1928
1738
|
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
expect(editable.get("foo")).toEqual("bar2");
|
|
1933
|
-
});
|
|
1739
|
+
console.log("Before anon set");
|
|
1740
|
+
childContent2.set("foo", "bar2", "private");
|
|
1741
|
+
expect(childContent2.get("foo")).toEqual("bar2");
|
|
1934
1742
|
});
|