cojson 0.0.24 → 0.1.1
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/README.md +1 -1
- package/dist/account.d.ts +4 -4
- package/dist/account.js +7 -7
- package/dist/account.js.map +1 -1
- package/dist/coValue.d.ts +2 -2
- package/dist/coValue.js +23 -23
- package/dist/coValue.js.map +1 -1
- package/dist/{team.d.ts → group.d.ts} +7 -7
- package/dist/{team.js → group.js} +24 -24
- package/dist/group.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +3 -3
- package/dist/node.js +41 -39
- package/dist/node.js.map +1 -1
- package/dist/permissions.d.ts +3 -3
- package/dist/permissions.js +13 -13
- package/dist/permissions.js.map +1 -1
- package/dist/testUtils.d.ts +8 -8
- package/dist/testUtils.js +19 -19
- package/dist/testUtils.js.map +1 -1
- package/package.json +2 -2
- package/src/account.test.ts +7 -7
- package/src/account.ts +8 -8
- package/src/coValue.test.ts +5 -5
- package/src/coValue.ts +24 -24
- package/src/{team.ts → group.ts} +31 -31
- package/src/index.ts +4 -4
- package/src/node.ts +48 -46
- package/src/permissions.test.ts +303 -303
- package/src/permissions.ts +16 -16
- package/src/sync.test.ts +74 -74
- package/src/testUtils.ts +19 -19
- package/dist/team.js.map +0 -1
package/src/permissions.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { newRandomSessionID } from "./coValue.js";
|
|
2
2
|
import { expectMap } from "./contentType.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Group, expectGroupContent } from "./group.js";
|
|
4
4
|
import {
|
|
5
5
|
createdNowUnique,
|
|
6
6
|
newRandomKeySecret,
|
|
@@ -12,30 +12,30 @@ import {
|
|
|
12
12
|
getAgentSealerID,
|
|
13
13
|
} from "./crypto.js";
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
newGroup,
|
|
16
|
+
newGroupHighLevel,
|
|
17
|
+
groupWithTwoAdmins,
|
|
18
|
+
groupWithTwoAdminsHighLevel,
|
|
19
19
|
} from "./testUtils.js";
|
|
20
20
|
import { AnonymousControlledAccount } from "./index.js";
|
|
21
21
|
|
|
22
|
-
test("Initial admin can add another admin to a
|
|
23
|
-
|
|
22
|
+
test("Initial admin can add another admin to a group", () => {
|
|
23
|
+
groupWithTwoAdmins();
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
test("Initial admin can add another admin to a
|
|
27
|
-
|
|
26
|
+
test("Initial admin can add another admin to a group (high level)", () => {
|
|
27
|
+
groupWithTwoAdminsHighLevel();
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test("Added admin can add a third admin to a
|
|
31
|
-
const {
|
|
30
|
+
test("Added admin can add a third admin to a group", () => {
|
|
31
|
+
const { group, otherAdmin, node } = groupWithTwoAdmins();
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const groupAsOtherAdmin = group.testWithDifferentAccount(
|
|
34
34
|
otherAdmin,
|
|
35
35
|
newRandomSessionID(otherAdmin.id)
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
let otherContent =
|
|
38
|
+
let otherContent = expectGroupContent(groupAsOtherAdmin.getCurrentContent());
|
|
39
39
|
|
|
40
40
|
expect(otherContent.get(otherAdmin.id)).toEqual("admin");
|
|
41
41
|
|
|
@@ -46,103 +46,103 @@ test("Added admin can add a third admin to a team", () => {
|
|
|
46
46
|
expect(editable.get(thirdAdmin.id)).toEqual("admin");
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
otherContent =
|
|
49
|
+
otherContent = expectGroupContent(groupAsOtherAdmin.getCurrentContent());
|
|
50
50
|
|
|
51
51
|
expect(otherContent.get(thirdAdmin.id)).toEqual("admin");
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
test("Added adming can add a third admin to a
|
|
55
|
-
const {
|
|
54
|
+
test("Added adming can add a third admin to a group (high level)", () => {
|
|
55
|
+
const { group, otherAdmin, node } = groupWithTwoAdminsHighLevel();
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const groupAsOtherAdmin = group.testWithDifferentAccount(
|
|
58
58
|
otherAdmin,
|
|
59
59
|
newRandomSessionID(otherAdmin.id)
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
const thirdAdmin = node.createAccount("thirdAdmin");
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
groupAsOtherAdmin.addMember(thirdAdmin.id, "admin");
|
|
65
65
|
|
|
66
|
-
expect(
|
|
66
|
+
expect(groupAsOtherAdmin.groupMap.get(thirdAdmin.id)).toEqual("admin");
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
test("Admins can't demote other admins in a
|
|
70
|
-
const {
|
|
69
|
+
test("Admins can't demote other admins in a group", () => {
|
|
70
|
+
const { group, admin, otherAdmin } = groupWithTwoAdmins();
|
|
71
71
|
|
|
72
|
-
let
|
|
72
|
+
let groupContent = expectGroupContent(group.getCurrentContent());
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
groupContent.edit((editable) => {
|
|
75
75
|
editable.set(otherAdmin.id, "writer", "trusting");
|
|
76
76
|
expect(editable.get(otherAdmin.id)).toEqual("admin");
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
expect(
|
|
79
|
+
groupContent = expectGroupContent(group.getCurrentContent());
|
|
80
|
+
expect(groupContent.get(otherAdmin.id)).toEqual("admin");
|
|
81
81
|
|
|
82
|
-
const
|
|
82
|
+
const groupAsOtherAdmin = group.testWithDifferentAccount(
|
|
83
83
|
otherAdmin,
|
|
84
84
|
newRandomSessionID(otherAdmin.id)
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
-
let
|
|
88
|
-
|
|
87
|
+
let groupContentAsOtherAdmin = expectGroupContent(
|
|
88
|
+
groupAsOtherAdmin.getCurrentContent()
|
|
89
89
|
);
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
groupContentAsOtherAdmin.edit((editable) => {
|
|
92
92
|
editable.set(admin.id, "writer", "trusting");
|
|
93
93
|
expect(editable.get(admin.id)).toEqual("admin");
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
groupContentAsOtherAdmin = expectGroupContent(
|
|
97
|
+
groupAsOtherAdmin.getCurrentContent()
|
|
98
98
|
);
|
|
99
99
|
|
|
100
|
-
expect(
|
|
100
|
+
expect(groupContentAsOtherAdmin.get(admin.id)).toEqual("admin");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
test("Admins can't demote other admins in a
|
|
104
|
-
const {
|
|
103
|
+
test("Admins can't demote other admins in a group (high level)", () => {
|
|
104
|
+
const { group, admin, otherAdmin } = groupWithTwoAdminsHighLevel();
|
|
105
105
|
|
|
106
|
-
const
|
|
106
|
+
const groupAsOtherAdmin = group.testWithDifferentAccount(
|
|
107
107
|
otherAdmin,
|
|
108
108
|
newRandomSessionID(otherAdmin.id)
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
expect(() =>
|
|
111
|
+
expect(() => groupAsOtherAdmin.addMember(admin.id, "writer")).toThrow(
|
|
112
112
|
"Failed to set role"
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
expect(
|
|
115
|
+
expect(groupAsOtherAdmin.groupMap.get(admin.id)).toEqual("admin");
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
test("Admins an add writers to a
|
|
119
|
-
const {
|
|
118
|
+
test("Admins an add writers to a group, who can't add admins, writers, or readers", () => {
|
|
119
|
+
const { group, node } = newGroup();
|
|
120
120
|
const writer = node.createAccount("writer");
|
|
121
121
|
|
|
122
|
-
let
|
|
122
|
+
let groupContent = expectGroupContent(group.getCurrentContent());
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
groupContent.edit((editable) => {
|
|
125
125
|
editable.set(writer.id, "writer", "trusting");
|
|
126
126
|
expect(editable.get(writer.id)).toEqual("writer");
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
expect(
|
|
129
|
+
groupContent = expectGroupContent(group.getCurrentContent());
|
|
130
|
+
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
131
131
|
|
|
132
|
-
const
|
|
132
|
+
const groupAsWriter = group.testWithDifferentAccount(
|
|
133
133
|
writer,
|
|
134
134
|
newRandomSessionID(writer.id)
|
|
135
135
|
);
|
|
136
136
|
|
|
137
|
-
let
|
|
138
|
-
|
|
137
|
+
let groupContentAsWriter = expectGroupContent(
|
|
138
|
+
groupAsWriter.getCurrentContent()
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
-
expect(
|
|
141
|
+
expect(groupContentAsWriter.get(writer.id)).toEqual("writer");
|
|
142
142
|
|
|
143
143
|
const otherAgent = node.createAccount("otherAgent");
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
groupContentAsWriter.edit((editable) => {
|
|
146
146
|
editable.set(otherAgent.id, "admin", "trusting");
|
|
147
147
|
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
148
148
|
|
|
@@ -153,69 +153,69 @@ test("Admins an add writers to a team, who can't add admins, writers, or readers
|
|
|
153
153
|
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
groupContentAsWriter = expectGroupContent(groupAsWriter.getCurrentContent());
|
|
157
157
|
|
|
158
|
-
expect(
|
|
158
|
+
expect(groupContentAsWriter.get(otherAgent.id)).toBeUndefined();
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
test("Admins an add writers to a
|
|
162
|
-
const {
|
|
161
|
+
test("Admins an add writers to a group, who can't add admins, writers, or readers (high level)", () => {
|
|
162
|
+
const { group, node } = newGroupHighLevel();
|
|
163
163
|
|
|
164
164
|
const writer = node.createAccount("writer");
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
expect(
|
|
166
|
+
group.addMember(writer.id, "writer");
|
|
167
|
+
expect(group.groupMap.get(writer.id)).toEqual("writer");
|
|
168
168
|
|
|
169
|
-
const
|
|
169
|
+
const groupAsWriter = group.testWithDifferentAccount(
|
|
170
170
|
writer,
|
|
171
171
|
newRandomSessionID(writer.id)
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
-
expect(
|
|
174
|
+
expect(groupAsWriter.groupMap.get(writer.id)).toEqual("writer");
|
|
175
175
|
|
|
176
176
|
const otherAgent = node.createAccount("otherAgent");
|
|
177
177
|
|
|
178
|
-
expect(() =>
|
|
178
|
+
expect(() => groupAsWriter.addMember(otherAgent.id, "admin")).toThrow(
|
|
179
179
|
"Failed to set role"
|
|
180
180
|
);
|
|
181
|
-
expect(() =>
|
|
181
|
+
expect(() => groupAsWriter.addMember(otherAgent.id, "writer")).toThrow(
|
|
182
182
|
"Failed to set role"
|
|
183
183
|
);
|
|
184
|
-
expect(() =>
|
|
184
|
+
expect(() => groupAsWriter.addMember(otherAgent.id, "reader")).toThrow(
|
|
185
185
|
"Failed to set role"
|
|
186
186
|
);
|
|
187
187
|
|
|
188
|
-
expect(
|
|
188
|
+
expect(groupAsWriter.groupMap.get(otherAgent.id)).toBeUndefined();
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
-
test("Admins can add readers to a
|
|
192
|
-
const {
|
|
191
|
+
test("Admins can add readers to a group, who can't add admins, writers, or readers", () => {
|
|
192
|
+
const { group, node } = newGroup();
|
|
193
193
|
const reader = node.createAccount("reader");
|
|
194
194
|
|
|
195
|
-
let
|
|
195
|
+
let groupContent = expectGroupContent(group.getCurrentContent());
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
groupContent.edit((editable) => {
|
|
198
198
|
editable.set(reader.id, "reader", "trusting");
|
|
199
199
|
expect(editable.get(reader.id)).toEqual("reader");
|
|
200
200
|
});
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
expect(
|
|
202
|
+
groupContent = expectGroupContent(group.getCurrentContent());
|
|
203
|
+
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
204
204
|
|
|
205
|
-
const
|
|
205
|
+
const groupAsReader = group.testWithDifferentAccount(
|
|
206
206
|
reader,
|
|
207
207
|
newRandomSessionID(reader.id)
|
|
208
208
|
);
|
|
209
209
|
|
|
210
|
-
let
|
|
211
|
-
|
|
210
|
+
let groupContentAsReader = expectGroupContent(
|
|
211
|
+
groupAsReader.getCurrentContent()
|
|
212
212
|
);
|
|
213
213
|
|
|
214
|
-
expect(
|
|
214
|
+
expect(groupContentAsReader.get(reader.id)).toEqual("reader");
|
|
215
215
|
|
|
216
216
|
const otherAgent = node.createAccount("otherAgent");
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
groupContentAsReader.edit((editable) => {
|
|
219
219
|
editable.set(otherAgent.id, "admin", "trusting");
|
|
220
220
|
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
221
221
|
|
|
@@ -226,47 +226,47 @@ test("Admins can add readers to a team, who can't add admins, writers, or reader
|
|
|
226
226
|
expect(editable.get(otherAgent.id)).toBeUndefined();
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
groupContentAsReader = expectGroupContent(groupAsReader.getCurrentContent());
|
|
230
230
|
|
|
231
|
-
expect(
|
|
231
|
+
expect(groupContentAsReader.get(otherAgent.id)).toBeUndefined();
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
test("Admins can add readers to a
|
|
235
|
-
const {
|
|
234
|
+
test("Admins can add readers to a group, who can't add admins, writers, or readers (high level)", () => {
|
|
235
|
+
const { group, node } = newGroupHighLevel();
|
|
236
236
|
|
|
237
237
|
const reader = node.createAccount("reader");
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
expect(
|
|
239
|
+
group.addMember(reader.id, "reader");
|
|
240
|
+
expect(group.groupMap.get(reader.id)).toEqual("reader");
|
|
241
241
|
|
|
242
|
-
const
|
|
242
|
+
const groupAsReader = group.testWithDifferentAccount(
|
|
243
243
|
reader,
|
|
244
244
|
newRandomSessionID(reader.id)
|
|
245
245
|
);
|
|
246
246
|
|
|
247
|
-
expect(
|
|
247
|
+
expect(groupAsReader.groupMap.get(reader.id)).toEqual("reader");
|
|
248
248
|
|
|
249
249
|
const otherAgent = node.createAccount("otherAgent");
|
|
250
250
|
|
|
251
|
-
expect(() =>
|
|
251
|
+
expect(() => groupAsReader.addMember(otherAgent.id, "admin")).toThrow(
|
|
252
252
|
"Failed to set role"
|
|
253
253
|
);
|
|
254
|
-
expect(() =>
|
|
254
|
+
expect(() => groupAsReader.addMember(otherAgent.id, "writer")).toThrow(
|
|
255
255
|
"Failed to set role"
|
|
256
256
|
);
|
|
257
|
-
expect(() =>
|
|
257
|
+
expect(() => groupAsReader.addMember(otherAgent.id, "reader")).toThrow(
|
|
258
258
|
"Failed to set role"
|
|
259
259
|
);
|
|
260
260
|
|
|
261
|
-
expect(
|
|
261
|
+
expect(groupAsReader.groupMap.get(otherAgent.id)).toBeUndefined();
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
-
test("Admins can write to an object that is owned by their
|
|
265
|
-
const { node,
|
|
264
|
+
test("Admins can write to an object that is owned by their group", () => {
|
|
265
|
+
const { node, group } = newGroup();
|
|
266
266
|
|
|
267
267
|
const childObject = node.createCoValue({
|
|
268
268
|
type: "comap",
|
|
269
|
-
ruleset: { type: "
|
|
269
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
270
270
|
meta: null,
|
|
271
271
|
...createdNowUnique(),
|
|
272
272
|
});
|
|
@@ -283,10 +283,10 @@ test("Admins can write to an object that is owned by their team", () => {
|
|
|
283
283
|
expect(childContent.get("foo")).toEqual("bar");
|
|
284
284
|
});
|
|
285
285
|
|
|
286
|
-
test("Admins can write to an object that is owned by their
|
|
287
|
-
const { node,
|
|
286
|
+
test("Admins can write to an object that is owned by their group (high level)", () => {
|
|
287
|
+
const { node, group } = newGroupHighLevel();
|
|
288
288
|
|
|
289
|
-
let childObject =
|
|
289
|
+
let childObject = group.createMap();
|
|
290
290
|
|
|
291
291
|
childObject = childObject.edit((editable) => {
|
|
292
292
|
editable.set("foo", "bar", "trusting");
|
|
@@ -296,19 +296,19 @@ test("Admins can write to an object that is owned by their team (high level)", (
|
|
|
296
296
|
expect(childObject.get("foo")).toEqual("bar");
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
-
test("Writers can write to an object that is owned by their
|
|
300
|
-
const { node,
|
|
299
|
+
test("Writers can write to an object that is owned by their group", () => {
|
|
300
|
+
const { node, group } = newGroup();
|
|
301
301
|
|
|
302
302
|
const writer = node.createAccount("writer");
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
305
305
|
editable.set(writer.id, "writer", "trusting");
|
|
306
306
|
expect(editable.get(writer.id)).toEqual("writer");
|
|
307
307
|
});
|
|
308
308
|
|
|
309
309
|
const childObject = node.createCoValue({
|
|
310
310
|
type: "comap",
|
|
311
|
-
ruleset: { type: "
|
|
311
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
312
312
|
meta: null,
|
|
313
313
|
...createdNowUnique(),
|
|
314
314
|
});
|
|
@@ -332,14 +332,14 @@ test("Writers can write to an object that is owned by their team", () => {
|
|
|
332
332
|
expect(childContentAsWriter.get("foo")).toEqual("bar");
|
|
333
333
|
});
|
|
334
334
|
|
|
335
|
-
test("Writers can write to an object that is owned by their
|
|
336
|
-
const { node,
|
|
335
|
+
test("Writers can write to an object that is owned by their group (high level)", () => {
|
|
336
|
+
const { node, group } = newGroupHighLevel();
|
|
337
337
|
|
|
338
338
|
const writer = node.createAccount("writer");
|
|
339
339
|
|
|
340
|
-
|
|
340
|
+
group.addMember(writer.id, "writer");
|
|
341
341
|
|
|
342
|
-
const childObject =
|
|
342
|
+
const childObject = group.createMap();
|
|
343
343
|
|
|
344
344
|
let childObjectAsWriter = expectMap(
|
|
345
345
|
childObject.coValue
|
|
@@ -355,19 +355,19 @@ test("Writers can write to an object that is owned by their team (high level)",
|
|
|
355
355
|
expect(childObjectAsWriter.get("foo")).toEqual("bar");
|
|
356
356
|
});
|
|
357
357
|
|
|
358
|
-
test("Readers can not write to an object that is owned by their
|
|
359
|
-
const { node,
|
|
358
|
+
test("Readers can not write to an object that is owned by their group", () => {
|
|
359
|
+
const { node, group } = newGroup();
|
|
360
360
|
|
|
361
361
|
const reader = node.createAccount("reader");
|
|
362
362
|
|
|
363
|
-
|
|
363
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
364
364
|
editable.set(reader.id, "reader", "trusting");
|
|
365
365
|
expect(editable.get(reader.id)).toEqual("reader");
|
|
366
366
|
});
|
|
367
367
|
|
|
368
368
|
const childObject = node.createCoValue({
|
|
369
369
|
type: "comap",
|
|
370
|
-
ruleset: { type: "
|
|
370
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
371
371
|
meta: null,
|
|
372
372
|
...createdNowUnique(),
|
|
373
373
|
});
|
|
@@ -391,14 +391,14 @@ test("Readers can not write to an object that is owned by their team", () => {
|
|
|
391
391
|
expect(childContentAsReader.get("foo")).toBeUndefined();
|
|
392
392
|
});
|
|
393
393
|
|
|
394
|
-
test("Readers can not write to an object that is owned by their
|
|
395
|
-
const { node,
|
|
394
|
+
test("Readers can not write to an object that is owned by their group (high level)", () => {
|
|
395
|
+
const { node, group } = newGroupHighLevel();
|
|
396
396
|
|
|
397
397
|
const reader = node.createAccount("reader");
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
group.addMember(reader.id, "reader");
|
|
400
400
|
|
|
401
|
-
const childObject =
|
|
401
|
+
const childObject = group.createMap();
|
|
402
402
|
|
|
403
403
|
let childObjectAsReader = expectMap(
|
|
404
404
|
childObject.coValue
|
|
@@ -414,20 +414,20 @@ test("Readers can not write to an object that is owned by their team (high level
|
|
|
414
414
|
expect(childObjectAsReader.get("foo")).toBeUndefined();
|
|
415
415
|
});
|
|
416
416
|
|
|
417
|
-
test("Admins can set
|
|
418
|
-
const { node,
|
|
417
|
+
test("Admins can set group read key and then use it to create and read private transactions in owned objects", () => {
|
|
418
|
+
const { node, group, admin } = newGroup();
|
|
419
419
|
|
|
420
|
-
const
|
|
420
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
421
421
|
|
|
422
|
-
|
|
422
|
+
groupContent.edit((editable) => {
|
|
423
423
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
424
424
|
const revelation = seal(
|
|
425
425
|
readKey,
|
|
426
426
|
admin.currentSealerSecret(),
|
|
427
427
|
admin.currentSealerID(),
|
|
428
428
|
{
|
|
429
|
-
in:
|
|
430
|
-
tx:
|
|
429
|
+
in: group.id,
|
|
430
|
+
tx: group.nextTransactionID(),
|
|
431
431
|
}
|
|
432
432
|
);
|
|
433
433
|
|
|
@@ -441,12 +441,12 @@ test("Admins can set team read key and then use it to create and read private tr
|
|
|
441
441
|
|
|
442
442
|
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
443
443
|
|
|
444
|
-
expect(
|
|
444
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey);
|
|
445
445
|
});
|
|
446
446
|
|
|
447
447
|
const childObject = node.createCoValue({
|
|
448
448
|
type: "comap",
|
|
449
|
-
ruleset: { type: "
|
|
449
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
450
450
|
meta: null,
|
|
451
451
|
...createdNowUnique(),
|
|
452
452
|
});
|
|
@@ -462,10 +462,10 @@ test("Admins can set team read key and then use it to create and read private tr
|
|
|
462
462
|
expect(childContent.get("foo")).toEqual("bar");
|
|
463
463
|
});
|
|
464
464
|
|
|
465
|
-
test("Admins can set
|
|
466
|
-
const { node,
|
|
465
|
+
test("Admins can set group read key and then use it to create and read private transactions in owned objects (high level)", () => {
|
|
466
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
467
467
|
|
|
468
|
-
let childObject =
|
|
468
|
+
let childObject = group.createMap();
|
|
469
469
|
|
|
470
470
|
childObject = childObject.edit((editable) => {
|
|
471
471
|
editable.set("foo", "bar", "private");
|
|
@@ -475,16 +475,16 @@ test("Admins can set team read key and then use it to create and read private tr
|
|
|
475
475
|
expect(childObject.get("foo")).toEqual("bar");
|
|
476
476
|
});
|
|
477
477
|
|
|
478
|
-
test("Admins can set
|
|
479
|
-
const { node,
|
|
478
|
+
test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects", () => {
|
|
479
|
+
const { node, group, admin } = newGroup();
|
|
480
480
|
|
|
481
481
|
const writer = node.createAccount("writer");
|
|
482
482
|
|
|
483
483
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
484
484
|
|
|
485
|
-
const
|
|
485
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
486
486
|
|
|
487
|
-
|
|
487
|
+
groupContent.edit((editable) => {
|
|
488
488
|
editable.set(writer.id, "writer", "trusting");
|
|
489
489
|
expect(editable.get(writer.id)).toEqual("writer");
|
|
490
490
|
|
|
@@ -493,8 +493,8 @@ test("Admins can set team read key and then writers can use it to create and rea
|
|
|
493
493
|
admin.currentSealerSecret(),
|
|
494
494
|
admin.currentSealerID(),
|
|
495
495
|
{
|
|
496
|
-
in:
|
|
497
|
-
tx:
|
|
496
|
+
in: group.id,
|
|
497
|
+
tx: group.nextTransactionID(),
|
|
498
498
|
}
|
|
499
499
|
);
|
|
500
500
|
|
|
@@ -505,8 +505,8 @@ test("Admins can set team read key and then writers can use it to create and rea
|
|
|
505
505
|
admin.currentSealerSecret(),
|
|
506
506
|
writer.currentSealerID(),
|
|
507
507
|
{
|
|
508
|
-
in:
|
|
509
|
-
tx:
|
|
508
|
+
in: group.id,
|
|
509
|
+
tx: group.nextTransactionID(),
|
|
510
510
|
}
|
|
511
511
|
);
|
|
512
512
|
|
|
@@ -517,7 +517,7 @@ test("Admins can set team read key and then writers can use it to create and rea
|
|
|
517
517
|
|
|
518
518
|
const childObject = node.createCoValue({
|
|
519
519
|
type: "comap",
|
|
520
|
-
ruleset: { type: "
|
|
520
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
521
521
|
meta: null,
|
|
522
522
|
...createdNowUnique(),
|
|
523
523
|
});
|
|
@@ -543,14 +543,14 @@ test("Admins can set team read key and then writers can use it to create and rea
|
|
|
543
543
|
expect(childContentAsWriter.get("foo")).toEqual("bar");
|
|
544
544
|
});
|
|
545
545
|
|
|
546
|
-
test("Admins can set
|
|
547
|
-
const { node,
|
|
546
|
+
test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects (high level)", () => {
|
|
547
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
548
548
|
|
|
549
549
|
const writer = node.createAccount("writer");
|
|
550
550
|
|
|
551
|
-
|
|
551
|
+
group.addMember(writer.id, "writer");
|
|
552
552
|
|
|
553
|
-
const childObject =
|
|
553
|
+
const childObject = group.createMap();
|
|
554
554
|
|
|
555
555
|
let childObjectAsWriter = expectMap(
|
|
556
556
|
childObject.coValue
|
|
@@ -566,16 +566,16 @@ test("Admins can set team read key and then writers can use it to create and rea
|
|
|
566
566
|
expect(childObjectAsWriter.get("foo")).toEqual("bar");
|
|
567
567
|
});
|
|
568
568
|
|
|
569
|
-
test("Admins can set
|
|
570
|
-
const { node,
|
|
569
|
+
test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read", () => {
|
|
570
|
+
const { node, group, admin } = newGroup();
|
|
571
571
|
|
|
572
572
|
const reader = node.createAccount("reader");
|
|
573
573
|
|
|
574
574
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
575
575
|
|
|
576
|
-
const
|
|
576
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
577
577
|
|
|
578
|
-
|
|
578
|
+
groupContent.edit((editable) => {
|
|
579
579
|
editable.set(reader.id, "reader", "trusting");
|
|
580
580
|
expect(editable.get(reader.id)).toEqual("reader");
|
|
581
581
|
|
|
@@ -584,8 +584,8 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
584
584
|
admin.currentSealerSecret(),
|
|
585
585
|
admin.currentSealerID(),
|
|
586
586
|
{
|
|
587
|
-
in:
|
|
588
|
-
tx:
|
|
587
|
+
in: group.id,
|
|
588
|
+
tx: group.nextTransactionID(),
|
|
589
589
|
}
|
|
590
590
|
);
|
|
591
591
|
|
|
@@ -596,8 +596,8 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
596
596
|
admin.currentSealerSecret(),
|
|
597
597
|
reader.currentSealerID(),
|
|
598
598
|
{
|
|
599
|
-
in:
|
|
600
|
-
tx:
|
|
599
|
+
in: group.id,
|
|
600
|
+
tx: group.nextTransactionID(),
|
|
601
601
|
}
|
|
602
602
|
);
|
|
603
603
|
|
|
@@ -608,7 +608,7 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
608
608
|
|
|
609
609
|
const childObject = node.createCoValue({
|
|
610
610
|
type: "comap",
|
|
611
|
-
ruleset: { type: "
|
|
611
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
612
612
|
meta: null,
|
|
613
613
|
...createdNowUnique(),
|
|
614
614
|
});
|
|
@@ -632,14 +632,14 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
632
632
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
633
633
|
});
|
|
634
634
|
|
|
635
|
-
test("Admins can set
|
|
636
|
-
const { node,
|
|
635
|
+
test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read (high level)", () => {
|
|
636
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
637
637
|
|
|
638
638
|
const reader = node.createAccount("reader");
|
|
639
639
|
|
|
640
|
-
|
|
640
|
+
group.addMember(reader.id, "reader");
|
|
641
641
|
|
|
642
|
-
let childObject =
|
|
642
|
+
let childObject = group.createMap();
|
|
643
643
|
|
|
644
644
|
childObject = childObject.edit((editable) => {
|
|
645
645
|
editable.set("foo", "bar", "private");
|
|
@@ -655,8 +655,8 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
655
655
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
656
656
|
});
|
|
657
657
|
|
|
658
|
-
test("Admins can set
|
|
659
|
-
const { node,
|
|
658
|
+
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", () => {
|
|
659
|
+
const { node, group, admin } = newGroup();
|
|
660
660
|
|
|
661
661
|
const reader1 = node.createAccount("reader1");
|
|
662
662
|
|
|
@@ -664,9 +664,9 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
664
664
|
|
|
665
665
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
666
666
|
|
|
667
|
-
const
|
|
667
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
668
668
|
|
|
669
|
-
|
|
669
|
+
groupContent.edit((editable) => {
|
|
670
670
|
editable.set(reader1.id, "reader", "trusting");
|
|
671
671
|
expect(editable.get(reader1.id)).toEqual("reader");
|
|
672
672
|
|
|
@@ -675,8 +675,8 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
675
675
|
admin.currentSealerSecret(),
|
|
676
676
|
admin.currentSealerID(),
|
|
677
677
|
{
|
|
678
|
-
in:
|
|
679
|
-
tx:
|
|
678
|
+
in: group.id,
|
|
679
|
+
tx: group.nextTransactionID(),
|
|
680
680
|
}
|
|
681
681
|
);
|
|
682
682
|
|
|
@@ -687,8 +687,8 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
687
687
|
admin.currentSealerSecret(),
|
|
688
688
|
reader1.currentSealerID(),
|
|
689
689
|
{
|
|
690
|
-
in:
|
|
691
|
-
tx:
|
|
690
|
+
in: group.id,
|
|
691
|
+
tx: group.nextTransactionID(),
|
|
692
692
|
}
|
|
693
693
|
);
|
|
694
694
|
|
|
@@ -699,7 +699,7 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
699
699
|
|
|
700
700
|
const childObject = node.createCoValue({
|
|
701
701
|
type: "comap",
|
|
702
|
-
ruleset: { type: "
|
|
702
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
703
703
|
meta: null,
|
|
704
704
|
...createdNowUnique(),
|
|
705
705
|
});
|
|
@@ -722,14 +722,14 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
722
722
|
|
|
723
723
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
724
724
|
|
|
725
|
-
|
|
725
|
+
groupContent.edit((editable) => {
|
|
726
726
|
const revelation3 = seal(
|
|
727
727
|
readKey,
|
|
728
728
|
admin.currentSealerSecret(),
|
|
729
729
|
reader2.currentSealerID(),
|
|
730
730
|
{
|
|
731
|
-
in:
|
|
732
|
-
tx:
|
|
731
|
+
in: group.id,
|
|
732
|
+
tx: group.nextTransactionID(),
|
|
733
733
|
}
|
|
734
734
|
);
|
|
735
735
|
|
|
@@ -750,16 +750,16 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
750
750
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
751
751
|
});
|
|
752
752
|
|
|
753
|
-
test("Admins can set
|
|
754
|
-
const { node,
|
|
753
|
+
test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read, even with a separate later revelation for the same read key (high level)", () => {
|
|
754
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
755
755
|
|
|
756
756
|
const reader1 = node.createAccount("reader1");
|
|
757
757
|
|
|
758
758
|
const reader2 = node.createAccount("reader2");
|
|
759
759
|
|
|
760
|
-
|
|
760
|
+
group.addMember(reader1.id, "reader");
|
|
761
761
|
|
|
762
|
-
let childObject =
|
|
762
|
+
let childObject = group.createMap();
|
|
763
763
|
|
|
764
764
|
childObject = childObject.edit((editable) => {
|
|
765
765
|
editable.set("foo", "bar", "private");
|
|
@@ -774,7 +774,7 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
774
774
|
|
|
775
775
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
776
776
|
|
|
777
|
-
|
|
777
|
+
group.addMember(reader2.id, "reader");
|
|
778
778
|
|
|
779
779
|
const childContentAsReader2 = expectMap(
|
|
780
780
|
childObject.coValue
|
|
@@ -785,20 +785,20 @@ test("Admins can set team read key and then use it to create private transaction
|
|
|
785
785
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
786
786
|
});
|
|
787
787
|
|
|
788
|
-
test("Admins can set
|
|
789
|
-
const { node,
|
|
788
|
+
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", () => {
|
|
789
|
+
const { node, group, admin } = newGroup();
|
|
790
790
|
|
|
791
|
-
const
|
|
791
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
792
792
|
|
|
793
|
-
|
|
793
|
+
groupContent.edit((editable) => {
|
|
794
794
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
795
795
|
const revelation = seal(
|
|
796
796
|
readKey,
|
|
797
797
|
admin.currentSealerSecret(),
|
|
798
798
|
admin.currentSealerID(),
|
|
799
799
|
{
|
|
800
|
-
in:
|
|
801
|
-
tx:
|
|
800
|
+
in: group.id,
|
|
801
|
+
tx: group.nextTransactionID(),
|
|
802
802
|
}
|
|
803
803
|
);
|
|
804
804
|
|
|
@@ -806,12 +806,12 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
806
806
|
|
|
807
807
|
editable.set("readKey", readKeyID, "trusting");
|
|
808
808
|
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
809
|
-
expect(
|
|
809
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey);
|
|
810
810
|
});
|
|
811
811
|
|
|
812
812
|
const childObject = node.createCoValue({
|
|
813
813
|
type: "comap",
|
|
814
|
-
ruleset: { type: "
|
|
814
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
815
815
|
meta: null,
|
|
816
816
|
...createdNowUnique(),
|
|
817
817
|
});
|
|
@@ -826,7 +826,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
826
826
|
childContent = expectMap(childObject.getCurrentContent());
|
|
827
827
|
expect(childContent.get("foo")).toEqual("bar");
|
|
828
828
|
|
|
829
|
-
|
|
829
|
+
groupContent.edit((editable) => {
|
|
830
830
|
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
831
831
|
|
|
832
832
|
const revelation = seal(
|
|
@@ -834,8 +834,8 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
834
834
|
admin.currentSealerSecret(),
|
|
835
835
|
admin.currentSealerID(),
|
|
836
836
|
{
|
|
837
|
-
in:
|
|
838
|
-
tx:
|
|
837
|
+
in: group.id,
|
|
838
|
+
tx: group.nextTransactionID(),
|
|
839
839
|
}
|
|
840
840
|
);
|
|
841
841
|
|
|
@@ -843,7 +843,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
843
843
|
|
|
844
844
|
editable.set("readKey", readKeyID2, "trusting");
|
|
845
845
|
expect(editable.get("readKey")).toEqual(readKeyID2);
|
|
846
|
-
expect(
|
|
846
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey2);
|
|
847
847
|
});
|
|
848
848
|
|
|
849
849
|
childContent = expectMap(childObject.getCurrentContent());
|
|
@@ -858,10 +858,10 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
858
858
|
expect(childContent.get("foo2")).toEqual("bar2");
|
|
859
859
|
});
|
|
860
860
|
|
|
861
|
-
test("Admins can set
|
|
862
|
-
const {
|
|
861
|
+
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
|
+
const { group } = newGroupHighLevel();
|
|
863
863
|
|
|
864
|
-
let childObject =
|
|
864
|
+
let childObject = group.createMap();
|
|
865
865
|
|
|
866
866
|
const firstReadKey = childObject.coValue.getCurrentReadKey();
|
|
867
867
|
|
|
@@ -872,7 +872,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
872
872
|
|
|
873
873
|
expect(childObject.get("foo")).toEqual("bar");
|
|
874
874
|
|
|
875
|
-
|
|
875
|
+
group.rotateReadKey();
|
|
876
876
|
|
|
877
877
|
expect(childObject.coValue.getCurrentReadKey()).not.toEqual(firstReadKey);
|
|
878
878
|
|
|
@@ -885,27 +885,27 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
885
885
|
expect(childObject.get("foo2")).toEqual("bar2");
|
|
886
886
|
});
|
|
887
887
|
|
|
888
|
-
test("Admins can set
|
|
889
|
-
const { node,
|
|
888
|
+
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", () => {
|
|
889
|
+
const { node, group, admin } = newGroup();
|
|
890
890
|
|
|
891
891
|
const childObject = node.createCoValue({
|
|
892
892
|
type: "comap",
|
|
893
|
-
ruleset: { type: "
|
|
893
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
894
894
|
meta: null,
|
|
895
895
|
...createdNowUnique(),
|
|
896
896
|
});
|
|
897
897
|
|
|
898
|
-
const
|
|
898
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
899
899
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
900
900
|
|
|
901
|
-
|
|
901
|
+
groupContent.edit((editable) => {
|
|
902
902
|
const revelation = seal(
|
|
903
903
|
readKey,
|
|
904
904
|
admin.currentSealerSecret(),
|
|
905
905
|
admin.currentSealerID(),
|
|
906
906
|
{
|
|
907
|
-
in:
|
|
908
|
-
tx:
|
|
907
|
+
in: group.id,
|
|
908
|
+
tx: group.nextTransactionID(),
|
|
909
909
|
}
|
|
910
910
|
);
|
|
911
911
|
|
|
@@ -913,7 +913,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
913
913
|
|
|
914
914
|
editable.set("readKey", readKeyID, "trusting");
|
|
915
915
|
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
916
|
-
expect(
|
|
916
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey);
|
|
917
917
|
});
|
|
918
918
|
|
|
919
919
|
let childContent = expectMap(childObject.getCurrentContent());
|
|
@@ -930,14 +930,14 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
930
930
|
|
|
931
931
|
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
932
932
|
|
|
933
|
-
|
|
933
|
+
groupContent.edit((editable) => {
|
|
934
934
|
const revelation2 = seal(
|
|
935
935
|
readKey2,
|
|
936
936
|
admin.currentSealerSecret(),
|
|
937
937
|
admin.currentSealerID(),
|
|
938
938
|
{
|
|
939
|
-
in:
|
|
940
|
-
tx:
|
|
939
|
+
in: group.id,
|
|
940
|
+
tx: group.nextTransactionID(),
|
|
941
941
|
}
|
|
942
942
|
);
|
|
943
943
|
|
|
@@ -948,8 +948,8 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
948
948
|
admin.currentSealerSecret(),
|
|
949
949
|
reader.currentSealerID(),
|
|
950
950
|
{
|
|
951
|
-
in:
|
|
952
|
-
tx:
|
|
951
|
+
in: group.id,
|
|
952
|
+
tx: group.nextTransactionID(),
|
|
953
953
|
}
|
|
954
954
|
);
|
|
955
955
|
|
|
@@ -967,7 +967,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
967
967
|
editable.set("readKey", readKeyID2, "trusting");
|
|
968
968
|
|
|
969
969
|
expect(editable.get("readKey")).toEqual(readKeyID2);
|
|
970
|
-
expect(
|
|
970
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey2);
|
|
971
971
|
|
|
972
972
|
editable.set(reader.id, "reader", "trusting");
|
|
973
973
|
expect(editable.get(reader.id)).toEqual("reader");
|
|
@@ -993,10 +993,10 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
993
993
|
expect(childContentAsReader.get("foo2")).toEqual("bar2");
|
|
994
994
|
});
|
|
995
995
|
|
|
996
|
-
test("Admins can set
|
|
997
|
-
const { node,
|
|
996
|
+
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
|
+
const { node, group } = newGroupHighLevel();
|
|
998
998
|
|
|
999
|
-
let childObject =
|
|
999
|
+
let childObject = group.createMap();
|
|
1000
1000
|
|
|
1001
1001
|
const firstReadKey = childObject.coValue.getCurrentReadKey();
|
|
1002
1002
|
|
|
@@ -1007,13 +1007,13 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
1007
1007
|
|
|
1008
1008
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1009
1009
|
|
|
1010
|
-
|
|
1010
|
+
group.rotateReadKey();
|
|
1011
1011
|
|
|
1012
1012
|
expect(childObject.coValue.getCurrentReadKey()).not.toEqual(firstReadKey);
|
|
1013
1013
|
|
|
1014
1014
|
const reader = node.createAccount("reader");
|
|
1015
1015
|
|
|
1016
|
-
|
|
1016
|
+
group.addMember(reader.id, "reader");
|
|
1017
1017
|
|
|
1018
1018
|
childObject = childObject.edit((editable) => {
|
|
1019
1019
|
editable.set("foo2", "bar2", "private");
|
|
@@ -1030,30 +1030,30 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
|
|
1030
1030
|
expect(childContentAsReader.get("foo2")).toEqual("bar2");
|
|
1031
1031
|
});
|
|
1032
1032
|
|
|
1033
|
-
test("Admins can set
|
|
1034
|
-
const { node,
|
|
1033
|
+
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", () => {
|
|
1034
|
+
const { node, group, admin } = newGroup();
|
|
1035
1035
|
|
|
1036
1036
|
const childObject = node.createCoValue({
|
|
1037
1037
|
type: "comap",
|
|
1038
|
-
ruleset: { type: "
|
|
1038
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
1039
1039
|
meta: null,
|
|
1040
1040
|
...createdNowUnique(),
|
|
1041
1041
|
});
|
|
1042
1042
|
|
|
1043
|
-
const
|
|
1043
|
+
const groupContent = expectGroupContent(group.getCurrentContent());
|
|
1044
1044
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1045
1045
|
const reader = node.createAccount("reader");
|
|
1046
1046
|
|
|
1047
1047
|
const reader2 = node.createAccount("reader2");
|
|
1048
1048
|
|
|
1049
|
-
|
|
1049
|
+
groupContent.edit((editable) => {
|
|
1050
1050
|
const revelation1 = seal(
|
|
1051
1051
|
readKey,
|
|
1052
1052
|
admin.currentSealerSecret(),
|
|
1053
1053
|
admin.currentSealerID(),
|
|
1054
1054
|
{
|
|
1055
|
-
in:
|
|
1056
|
-
tx:
|
|
1055
|
+
in: group.id,
|
|
1056
|
+
tx: group.nextTransactionID(),
|
|
1057
1057
|
}
|
|
1058
1058
|
);
|
|
1059
1059
|
|
|
@@ -1064,8 +1064,8 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1064
1064
|
admin.currentSealerSecret(),
|
|
1065
1065
|
reader.currentSealerID(),
|
|
1066
1066
|
{
|
|
1067
|
-
in:
|
|
1068
|
-
tx:
|
|
1067
|
+
in: group.id,
|
|
1068
|
+
tx: group.nextTransactionID(),
|
|
1069
1069
|
}
|
|
1070
1070
|
);
|
|
1071
1071
|
|
|
@@ -1076,8 +1076,8 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1076
1076
|
admin.currentSealerSecret(),
|
|
1077
1077
|
reader2.currentSealerID(),
|
|
1078
1078
|
{
|
|
1079
|
-
in:
|
|
1080
|
-
tx:
|
|
1079
|
+
in: group.id,
|
|
1080
|
+
tx: group.nextTransactionID(),
|
|
1081
1081
|
}
|
|
1082
1082
|
);
|
|
1083
1083
|
|
|
@@ -1085,7 +1085,7 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1085
1085
|
|
|
1086
1086
|
editable.set("readKey", readKeyID, "trusting");
|
|
1087
1087
|
expect(editable.get("readKey")).toEqual(readKeyID);
|
|
1088
|
-
expect(
|
|
1088
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey);
|
|
1089
1089
|
|
|
1090
1090
|
editable.set(reader.id, "reader", "trusting");
|
|
1091
1091
|
expect(editable.get(reader.id)).toEqual("reader");
|
|
@@ -1123,14 +1123,14 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1123
1123
|
|
|
1124
1124
|
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
1125
1125
|
|
|
1126
|
-
|
|
1126
|
+
groupContent.edit((editable) => {
|
|
1127
1127
|
const newRevelation1 = seal(
|
|
1128
1128
|
readKey2,
|
|
1129
1129
|
admin.currentSealerSecret(),
|
|
1130
1130
|
admin.currentSealerID(),
|
|
1131
1131
|
{
|
|
1132
|
-
in:
|
|
1133
|
-
tx:
|
|
1132
|
+
in: group.id,
|
|
1133
|
+
tx: group.nextTransactionID(),
|
|
1134
1134
|
}
|
|
1135
1135
|
);
|
|
1136
1136
|
|
|
@@ -1145,8 +1145,8 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1145
1145
|
admin.currentSealerSecret(),
|
|
1146
1146
|
reader2.currentSealerID(),
|
|
1147
1147
|
{
|
|
1148
|
-
in:
|
|
1149
|
-
tx:
|
|
1148
|
+
in: group.id,
|
|
1149
|
+
tx: group.nextTransactionID(),
|
|
1150
1150
|
}
|
|
1151
1151
|
);
|
|
1152
1152
|
|
|
@@ -1158,7 +1158,7 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1158
1158
|
|
|
1159
1159
|
editable.set("readKey", readKeyID2, "trusting");
|
|
1160
1160
|
expect(editable.get("readKey")).toEqual(readKeyID2);
|
|
1161
|
-
expect(
|
|
1161
|
+
expect(group.getCurrentReadKey().secret).toEqual(readKey2);
|
|
1162
1162
|
|
|
1163
1163
|
editable.set(reader.id, "revoked", "trusting");
|
|
1164
1164
|
// expect(editable.get(reader.id)).toEqual("revoked");
|
|
@@ -1190,10 +1190,10 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1190
1190
|
).toEqual("bar2");
|
|
1191
1191
|
});
|
|
1192
1192
|
|
|
1193
|
-
test("Admins can set
|
|
1194
|
-
const { node,
|
|
1193
|
+
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
|
+
const { node, group } = newGroupHighLevel();
|
|
1195
1195
|
|
|
1196
|
-
let childObject =
|
|
1196
|
+
let childObject = group.createMap();
|
|
1197
1197
|
|
|
1198
1198
|
childObject = childObject.edit((editable) => {
|
|
1199
1199
|
editable.set("foo", "bar", "private");
|
|
@@ -1202,7 +1202,7 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1202
1202
|
|
|
1203
1203
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1204
1204
|
|
|
1205
|
-
|
|
1205
|
+
group.rotateReadKey();
|
|
1206
1206
|
|
|
1207
1207
|
const secondReadKey = childObject.coValue.getCurrentReadKey();
|
|
1208
1208
|
|
|
@@ -1210,8 +1210,8 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1210
1210
|
|
|
1211
1211
|
const reader2 = node.createAccount("reader2");
|
|
1212
1212
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1213
|
+
group.addMember(reader.id, "reader");
|
|
1214
|
+
group.addMember(reader2.id, "reader");
|
|
1215
1215
|
|
|
1216
1216
|
childObject = childObject.edit((editable) => {
|
|
1217
1217
|
editable.set("foo2", "bar2", "private");
|
|
@@ -1221,7 +1221,7 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1221
1221
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1222
1222
|
expect(childObject.get("foo2")).toEqual("bar2");
|
|
1223
1223
|
|
|
1224
|
-
|
|
1224
|
+
group.removeMember(reader.id);
|
|
1225
1225
|
|
|
1226
1226
|
expect(childObject.coValue.getCurrentReadKey()).not.toEqual(secondReadKey);
|
|
1227
1227
|
|
|
@@ -1249,19 +1249,19 @@ test("Admins can set team read rey, make a private transaction in an owned objec
|
|
|
1249
1249
|
).toBeUndefined();
|
|
1250
1250
|
});
|
|
1251
1251
|
|
|
1252
|
-
test("Can create two owned objects in the same
|
|
1253
|
-
const { node,
|
|
1252
|
+
test("Can create two owned objects in the same group and they will have different ids", () => {
|
|
1253
|
+
const { node, group } = newGroup();
|
|
1254
1254
|
|
|
1255
1255
|
const childObject1 = node.createCoValue({
|
|
1256
1256
|
type: "comap",
|
|
1257
|
-
ruleset: { type: "
|
|
1257
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
1258
1258
|
meta: null,
|
|
1259
1259
|
...createdNowUnique(),
|
|
1260
1260
|
});
|
|
1261
1261
|
|
|
1262
1262
|
const childObject2 = node.createCoValue({
|
|
1263
1263
|
type: "comap",
|
|
1264
|
-
ruleset: { type: "
|
|
1264
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
1265
1265
|
meta: null,
|
|
1266
1266
|
...createdNowUnique(),
|
|
1267
1267
|
});
|
|
@@ -1270,20 +1270,20 @@ test("Can create two owned objects in the same team and they will have different
|
|
|
1270
1270
|
});
|
|
1271
1271
|
|
|
1272
1272
|
test("Admins can create an adminInvite, which can add an admin", () => {
|
|
1273
|
-
const { node,
|
|
1273
|
+
const { node, group, admin } = newGroup();
|
|
1274
1274
|
|
|
1275
1275
|
const inviteSecret = newRandomAgentSecret();
|
|
1276
1276
|
const inviteID = getAgentID(inviteSecret);
|
|
1277
1277
|
|
|
1278
|
-
|
|
1278
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
1279
1279
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1280
1280
|
const revelation = seal(
|
|
1281
1281
|
readKey,
|
|
1282
1282
|
admin.currentSealerSecret(),
|
|
1283
1283
|
admin.currentSealerID(),
|
|
1284
1284
|
{
|
|
1285
|
-
in:
|
|
1286
|
-
tx:
|
|
1285
|
+
in: group.id,
|
|
1286
|
+
tx: group.nextTransactionID(),
|
|
1287
1287
|
}
|
|
1288
1288
|
);
|
|
1289
1289
|
|
|
@@ -1299,8 +1299,8 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1299
1299
|
admin.currentSealerSecret(),
|
|
1300
1300
|
getAgentSealerID(inviteID),
|
|
1301
1301
|
{
|
|
1302
|
-
in:
|
|
1303
|
-
tx:
|
|
1302
|
+
in: group.id,
|
|
1303
|
+
tx: group.nextTransactionID(),
|
|
1304
1304
|
}
|
|
1305
1305
|
);
|
|
1306
1306
|
|
|
@@ -1311,7 +1311,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1311
1311
|
);
|
|
1312
1312
|
});
|
|
1313
1313
|
|
|
1314
|
-
const
|
|
1314
|
+
const groupAsInvite = group.testWithDifferentAccount(
|
|
1315
1315
|
new AnonymousControlledAccount(inviteSecret),
|
|
1316
1316
|
newRandomSessionID(inviteID)
|
|
1317
1317
|
);
|
|
@@ -1319,12 +1319,12 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1319
1319
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1320
1320
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1321
1321
|
|
|
1322
|
-
|
|
1322
|
+
expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
|
|
1323
1323
|
editable.set(invitedAdminID, "admin", "trusting");
|
|
1324
1324
|
|
|
1325
1325
|
expect(editable.get(invitedAdminID)).toEqual("admin");
|
|
1326
1326
|
|
|
1327
|
-
const readKey =
|
|
1327
|
+
const readKey = groupAsInvite.getCurrentReadKey();
|
|
1328
1328
|
|
|
1329
1329
|
expect(readKey.secret).toBeDefined();
|
|
1330
1330
|
|
|
@@ -1333,8 +1333,8 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1333
1333
|
getAgentSealerSecret(invitedAdminSecret),
|
|
1334
1334
|
getAgentSealerID(invitedAdminID),
|
|
1335
1335
|
{
|
|
1336
|
-
in:
|
|
1337
|
-
tx:
|
|
1336
|
+
in: group.id,
|
|
1337
|
+
tx: group.nextTransactionID(),
|
|
1338
1338
|
}
|
|
1339
1339
|
);
|
|
1340
1340
|
|
|
@@ -1351,9 +1351,9 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1351
1351
|
});
|
|
1352
1352
|
|
|
1353
1353
|
test("Admins can create an adminInvite, which can add an admin (high-level)", async () => {
|
|
1354
|
-
const { node,
|
|
1354
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
1355
1355
|
|
|
1356
|
-
const inviteSecret =
|
|
1356
|
+
const inviteSecret = group.createInvite("admin");
|
|
1357
1357
|
|
|
1358
1358
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1359
1359
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
@@ -1363,41 +1363,41 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
1363
1363
|
newRandomSessionID(invitedAdminID)
|
|
1364
1364
|
);
|
|
1365
1365
|
|
|
1366
|
-
await nodeAsInvitedAdmin.acceptInvite(
|
|
1366
|
+
await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
|
|
1367
1367
|
|
|
1368
1368
|
const thirdAdmin = newRandomAgentSecret();
|
|
1369
1369
|
const thirdAdminID = getAgentID(thirdAdmin);
|
|
1370
1370
|
|
|
1371
|
-
const
|
|
1372
|
-
await nodeAsInvitedAdmin.load(
|
|
1371
|
+
const groupAsInvitedAdmin = new Group(
|
|
1372
|
+
await nodeAsInvitedAdmin.load(group.id),
|
|
1373
1373
|
nodeAsInvitedAdmin
|
|
1374
1374
|
);
|
|
1375
1375
|
|
|
1376
|
-
expect(
|
|
1376
|
+
expect(groupAsInvitedAdmin.groupMap.get(invitedAdminID)).toEqual("admin");
|
|
1377
1377
|
expect(
|
|
1378
|
-
|
|
1378
|
+
groupAsInvitedAdmin.groupMap.coValue.getCurrentReadKey().secret
|
|
1379
1379
|
).toBeDefined();
|
|
1380
1380
|
|
|
1381
|
-
|
|
1381
|
+
groupAsInvitedAdmin.addMember(thirdAdminID, "admin");
|
|
1382
1382
|
|
|
1383
|
-
expect(
|
|
1383
|
+
expect(groupAsInvitedAdmin.groupMap.get(thirdAdminID)).toEqual("admin");
|
|
1384
1384
|
});
|
|
1385
1385
|
|
|
1386
1386
|
test("Admins can create a writerInvite, which can add a writer", () => {
|
|
1387
|
-
const { node,
|
|
1387
|
+
const { node, group, admin } = newGroup();
|
|
1388
1388
|
|
|
1389
1389
|
const inviteSecret = newRandomAgentSecret();
|
|
1390
1390
|
const inviteID = getAgentID(inviteSecret);
|
|
1391
1391
|
|
|
1392
|
-
|
|
1392
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
1393
1393
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1394
1394
|
const revelation = seal(
|
|
1395
1395
|
readKey,
|
|
1396
1396
|
admin.currentSealerSecret(),
|
|
1397
1397
|
admin.currentSealerID(),
|
|
1398
1398
|
{
|
|
1399
|
-
in:
|
|
1400
|
-
tx:
|
|
1399
|
+
in: group.id,
|
|
1400
|
+
tx: group.nextTransactionID(),
|
|
1401
1401
|
}
|
|
1402
1402
|
);
|
|
1403
1403
|
|
|
@@ -1413,8 +1413,8 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1413
1413
|
admin.currentSealerSecret(),
|
|
1414
1414
|
getAgentSealerID(inviteID),
|
|
1415
1415
|
{
|
|
1416
|
-
in:
|
|
1417
|
-
tx:
|
|
1416
|
+
in: group.id,
|
|
1417
|
+
tx: group.nextTransactionID(),
|
|
1418
1418
|
}
|
|
1419
1419
|
);
|
|
1420
1420
|
|
|
@@ -1425,7 +1425,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1425
1425
|
);
|
|
1426
1426
|
});
|
|
1427
1427
|
|
|
1428
|
-
const
|
|
1428
|
+
const groupAsInvite = group.testWithDifferentAccount(
|
|
1429
1429
|
new AnonymousControlledAccount(inviteSecret),
|
|
1430
1430
|
newRandomSessionID(inviteID)
|
|
1431
1431
|
);
|
|
@@ -1433,12 +1433,12 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1433
1433
|
const invitedWriterSecret = newRandomAgentSecret();
|
|
1434
1434
|
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1435
1435
|
|
|
1436
|
-
|
|
1436
|
+
expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
|
|
1437
1437
|
editable.set(invitedWriterID, "writer", "trusting");
|
|
1438
1438
|
|
|
1439
1439
|
expect(editable.get(invitedWriterID)).toEqual("writer");
|
|
1440
1440
|
|
|
1441
|
-
const readKey =
|
|
1441
|
+
const readKey = groupAsInvite.getCurrentReadKey();
|
|
1442
1442
|
|
|
1443
1443
|
expect(readKey.secret).toBeDefined();
|
|
1444
1444
|
|
|
@@ -1447,8 +1447,8 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1447
1447
|
getAgentSealerSecret(invitedWriterSecret),
|
|
1448
1448
|
getAgentSealerID(invitedWriterID),
|
|
1449
1449
|
{
|
|
1450
|
-
in:
|
|
1451
|
-
tx:
|
|
1450
|
+
in: group.id,
|
|
1451
|
+
tx: group.nextTransactionID(),
|
|
1452
1452
|
}
|
|
1453
1453
|
);
|
|
1454
1454
|
|
|
@@ -1465,9 +1465,9 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1465
1465
|
});
|
|
1466
1466
|
|
|
1467
1467
|
test("Admins can create a writerInvite, which can add a writer (high-level)", async () => {
|
|
1468
|
-
const { node,
|
|
1468
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
1469
1469
|
|
|
1470
|
-
const inviteSecret =
|
|
1470
|
+
const inviteSecret = group.createInvite("writer");
|
|
1471
1471
|
|
|
1472
1472
|
const invitedWriterSecret = newRandomAgentSecret();
|
|
1473
1473
|
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
@@ -1477,35 +1477,35 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
|
|
|
1477
1477
|
newRandomSessionID(invitedWriterID)
|
|
1478
1478
|
);
|
|
1479
1479
|
|
|
1480
|
-
await nodeAsInvitedWriter.acceptInvite(
|
|
1480
|
+
await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
|
|
1481
1481
|
|
|
1482
|
-
const
|
|
1483
|
-
await nodeAsInvitedWriter.load(
|
|
1482
|
+
const groupAsInvitedWriter = new Group(
|
|
1483
|
+
await nodeAsInvitedWriter.load(group.id),
|
|
1484
1484
|
nodeAsInvitedWriter
|
|
1485
1485
|
);
|
|
1486
1486
|
|
|
1487
|
-
expect(
|
|
1487
|
+
expect(groupAsInvitedWriter.groupMap.get(invitedWriterID)).toEqual("writer");
|
|
1488
1488
|
expect(
|
|
1489
|
-
|
|
1489
|
+
groupAsInvitedWriter.groupMap.coValue.getCurrentReadKey().secret
|
|
1490
1490
|
).toBeDefined();
|
|
1491
1491
|
});
|
|
1492
1492
|
|
|
1493
1493
|
|
|
1494
1494
|
test("Admins can create a readerInvite, which can add a reader", () => {
|
|
1495
|
-
const { node,
|
|
1495
|
+
const { node, group, admin } = newGroup();
|
|
1496
1496
|
|
|
1497
1497
|
const inviteSecret = newRandomAgentSecret();
|
|
1498
1498
|
const inviteID = getAgentID(inviteSecret);
|
|
1499
1499
|
|
|
1500
|
-
|
|
1500
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
1501
1501
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1502
1502
|
const revelation = seal(
|
|
1503
1503
|
readKey,
|
|
1504
1504
|
admin.currentSealerSecret(),
|
|
1505
1505
|
admin.currentSealerID(),
|
|
1506
1506
|
{
|
|
1507
|
-
in:
|
|
1508
|
-
tx:
|
|
1507
|
+
in: group.id,
|
|
1508
|
+
tx: group.nextTransactionID(),
|
|
1509
1509
|
}
|
|
1510
1510
|
);
|
|
1511
1511
|
|
|
@@ -1521,8 +1521,8 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1521
1521
|
admin.currentSealerSecret(),
|
|
1522
1522
|
getAgentSealerID(inviteID),
|
|
1523
1523
|
{
|
|
1524
|
-
in:
|
|
1525
|
-
tx:
|
|
1524
|
+
in: group.id,
|
|
1525
|
+
tx: group.nextTransactionID(),
|
|
1526
1526
|
}
|
|
1527
1527
|
);
|
|
1528
1528
|
|
|
@@ -1533,7 +1533,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1533
1533
|
);
|
|
1534
1534
|
});
|
|
1535
1535
|
|
|
1536
|
-
const
|
|
1536
|
+
const groupAsInvite = group.testWithDifferentAccount(
|
|
1537
1537
|
new AnonymousControlledAccount(inviteSecret),
|
|
1538
1538
|
newRandomSessionID(inviteID)
|
|
1539
1539
|
);
|
|
@@ -1541,12 +1541,12 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1541
1541
|
const invitedReaderSecret = newRandomAgentSecret();
|
|
1542
1542
|
const invitedReaderID = getAgentID(invitedReaderSecret);
|
|
1543
1543
|
|
|
1544
|
-
|
|
1544
|
+
expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
|
|
1545
1545
|
editable.set(invitedReaderID, "reader", "trusting");
|
|
1546
1546
|
|
|
1547
1547
|
expect(editable.get(invitedReaderID)).toEqual("reader");
|
|
1548
1548
|
|
|
1549
|
-
const readKey =
|
|
1549
|
+
const readKey = groupAsInvite.getCurrentReadKey();
|
|
1550
1550
|
|
|
1551
1551
|
expect(readKey.secret).toBeDefined();
|
|
1552
1552
|
|
|
@@ -1555,8 +1555,8 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1555
1555
|
getAgentSealerSecret(invitedReaderSecret),
|
|
1556
1556
|
getAgentSealerID(invitedReaderID),
|
|
1557
1557
|
{
|
|
1558
|
-
in:
|
|
1559
|
-
tx:
|
|
1558
|
+
in: group.id,
|
|
1559
|
+
tx: group.nextTransactionID(),
|
|
1560
1560
|
}
|
|
1561
1561
|
);
|
|
1562
1562
|
|
|
@@ -1573,9 +1573,9 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1573
1573
|
});
|
|
1574
1574
|
|
|
1575
1575
|
test("Admins can create a readerInvite, which can add a reader (high-level)", async () => {
|
|
1576
|
-
const { node,
|
|
1576
|
+
const { node, group, admin } = newGroupHighLevel();
|
|
1577
1577
|
|
|
1578
|
-
const inviteSecret =
|
|
1578
|
+
const inviteSecret = group.createInvite("reader");
|
|
1579
1579
|
|
|
1580
1580
|
const invitedReaderSecret = newRandomAgentSecret();
|
|
1581
1581
|
const invitedReaderID = getAgentID(invitedReaderSecret);
|
|
@@ -1585,34 +1585,34 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
|
|
|
1585
1585
|
newRandomSessionID(invitedReaderID)
|
|
1586
1586
|
);
|
|
1587
1587
|
|
|
1588
|
-
await nodeAsInvitedReader.acceptInvite(
|
|
1588
|
+
await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
|
|
1589
1589
|
|
|
1590
|
-
const
|
|
1591
|
-
await nodeAsInvitedReader.load(
|
|
1590
|
+
const groupAsInvitedReader = new Group(
|
|
1591
|
+
await nodeAsInvitedReader.load(group.id),
|
|
1592
1592
|
nodeAsInvitedReader
|
|
1593
1593
|
);
|
|
1594
1594
|
|
|
1595
|
-
expect(
|
|
1595
|
+
expect(groupAsInvitedReader.groupMap.get(invitedReaderID)).toEqual("reader");
|
|
1596
1596
|
expect(
|
|
1597
|
-
|
|
1597
|
+
groupAsInvitedReader.groupMap.coValue.getCurrentReadKey().secret
|
|
1598
1598
|
).toBeDefined();
|
|
1599
1599
|
});
|
|
1600
1600
|
|
|
1601
1601
|
test("WriterInvites can not invite admins", () => {
|
|
1602
|
-
const { node,
|
|
1602
|
+
const { node, group, admin } = newGroup();
|
|
1603
1603
|
|
|
1604
1604
|
const inviteSecret = newRandomAgentSecret();
|
|
1605
1605
|
const inviteID = getAgentID(inviteSecret);
|
|
1606
1606
|
|
|
1607
|
-
|
|
1607
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
1608
1608
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1609
1609
|
const revelation = seal(
|
|
1610
1610
|
readKey,
|
|
1611
1611
|
admin.currentSealerSecret(),
|
|
1612
1612
|
admin.currentSealerID(),
|
|
1613
1613
|
{
|
|
1614
|
-
in:
|
|
1615
|
-
tx:
|
|
1614
|
+
in: group.id,
|
|
1615
|
+
tx: group.nextTransactionID(),
|
|
1616
1616
|
}
|
|
1617
1617
|
);
|
|
1618
1618
|
|
|
@@ -1628,8 +1628,8 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1628
1628
|
admin.currentSealerSecret(),
|
|
1629
1629
|
getAgentSealerID(inviteID),
|
|
1630
1630
|
{
|
|
1631
|
-
in:
|
|
1632
|
-
tx:
|
|
1631
|
+
in: group.id,
|
|
1632
|
+
tx: group.nextTransactionID(),
|
|
1633
1633
|
}
|
|
1634
1634
|
);
|
|
1635
1635
|
|
|
@@ -1640,7 +1640,7 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1640
1640
|
);
|
|
1641
1641
|
});
|
|
1642
1642
|
|
|
1643
|
-
const
|
|
1643
|
+
const groupAsInvite = group.testWithDifferentAccount(
|
|
1644
1644
|
new AnonymousControlledAccount(inviteSecret),
|
|
1645
1645
|
newRandomSessionID(inviteID)
|
|
1646
1646
|
);
|
|
@@ -1648,27 +1648,27 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1648
1648
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1649
1649
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1650
1650
|
|
|
1651
|
-
|
|
1651
|
+
expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
|
|
1652
1652
|
editable.set(invitedAdminID, "admin", "trusting");
|
|
1653
1653
|
expect(editable.get(invitedAdminID)).toBeUndefined();
|
|
1654
1654
|
});
|
|
1655
1655
|
});
|
|
1656
1656
|
|
|
1657
1657
|
test("ReaderInvites can not invite admins", () => {
|
|
1658
|
-
const { node,
|
|
1658
|
+
const { node, group, admin } = newGroup();
|
|
1659
1659
|
|
|
1660
1660
|
const inviteSecret = newRandomAgentSecret();
|
|
1661
1661
|
const inviteID = getAgentID(inviteSecret);
|
|
1662
1662
|
|
|
1663
|
-
|
|
1663
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
1664
1664
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1665
1665
|
const revelation = seal(
|
|
1666
1666
|
readKey,
|
|
1667
1667
|
admin.currentSealerSecret(),
|
|
1668
1668
|
admin.currentSealerID(),
|
|
1669
1669
|
{
|
|
1670
|
-
in:
|
|
1671
|
-
tx:
|
|
1670
|
+
in: group.id,
|
|
1671
|
+
tx: group.nextTransactionID(),
|
|
1672
1672
|
}
|
|
1673
1673
|
);
|
|
1674
1674
|
|
|
@@ -1684,8 +1684,8 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1684
1684
|
admin.currentSealerSecret(),
|
|
1685
1685
|
getAgentSealerID(inviteID),
|
|
1686
1686
|
{
|
|
1687
|
-
in:
|
|
1688
|
-
tx:
|
|
1687
|
+
in: group.id,
|
|
1688
|
+
tx: group.nextTransactionID(),
|
|
1689
1689
|
}
|
|
1690
1690
|
);
|
|
1691
1691
|
|
|
@@ -1696,7 +1696,7 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1696
1696
|
);
|
|
1697
1697
|
});
|
|
1698
1698
|
|
|
1699
|
-
const
|
|
1699
|
+
const groupAsInvite = group.testWithDifferentAccount(
|
|
1700
1700
|
new AnonymousControlledAccount(inviteSecret),
|
|
1701
1701
|
newRandomSessionID(inviteID)
|
|
1702
1702
|
);
|
|
@@ -1704,27 +1704,27 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1704
1704
|
const invitedAdminSecret = newRandomAgentSecret();
|
|
1705
1705
|
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1706
1706
|
|
|
1707
|
-
|
|
1707
|
+
expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
|
|
1708
1708
|
editable.set(invitedAdminID, "admin", "trusting");
|
|
1709
1709
|
expect(editable.get(invitedAdminID)).toBeUndefined();
|
|
1710
1710
|
});
|
|
1711
1711
|
});
|
|
1712
1712
|
|
|
1713
1713
|
test("ReaderInvites can not invite writers", () => {
|
|
1714
|
-
const { node,
|
|
1714
|
+
const { node, group, admin } = newGroup();
|
|
1715
1715
|
|
|
1716
1716
|
const inviteSecret = newRandomAgentSecret();
|
|
1717
1717
|
const inviteID = getAgentID(inviteSecret);
|
|
1718
1718
|
|
|
1719
|
-
|
|
1719
|
+
expectGroupContent(group.getCurrentContent()).edit((editable) => {
|
|
1720
1720
|
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1721
1721
|
const revelation = seal(
|
|
1722
1722
|
readKey,
|
|
1723
1723
|
admin.currentSealerSecret(),
|
|
1724
1724
|
admin.currentSealerID(),
|
|
1725
1725
|
{
|
|
1726
|
-
in:
|
|
1727
|
-
tx:
|
|
1726
|
+
in: group.id,
|
|
1727
|
+
tx: group.nextTransactionID(),
|
|
1728
1728
|
}
|
|
1729
1729
|
);
|
|
1730
1730
|
|
|
@@ -1740,8 +1740,8 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1740
1740
|
admin.currentSealerSecret(),
|
|
1741
1741
|
getAgentSealerID(inviteID),
|
|
1742
1742
|
{
|
|
1743
|
-
in:
|
|
1744
|
-
tx:
|
|
1743
|
+
in: group.id,
|
|
1744
|
+
tx: group.nextTransactionID(),
|
|
1745
1745
|
}
|
|
1746
1746
|
);
|
|
1747
1747
|
|
|
@@ -1752,7 +1752,7 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1752
1752
|
);
|
|
1753
1753
|
});
|
|
1754
1754
|
|
|
1755
|
-
const
|
|
1755
|
+
const groupAsInvite = group.testWithDifferentAccount(
|
|
1756
1756
|
new AnonymousControlledAccount(inviteSecret),
|
|
1757
1757
|
newRandomSessionID(inviteID)
|
|
1758
1758
|
);
|
|
@@ -1760,7 +1760,7 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1760
1760
|
const invitedWriterSecret = newRandomAgentSecret();
|
|
1761
1761
|
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1762
1762
|
|
|
1763
|
-
|
|
1763
|
+
expectGroupContent(groupAsInvite.getCurrentContent()).edit((editable) => {
|
|
1764
1764
|
editable.set(invitedWriterID, "writer", "trusting");
|
|
1765
1765
|
expect(editable.get(invitedWriterID)).toBeUndefined();
|
|
1766
1766
|
});
|