cojson 0.7.0-alpha.37 → 0.7.0-alpha.38
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 +3 -2
- package/.prettierrc.js +9 -0
- package/.turbo/turbo-build.log +1 -34
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +1106 -0
- package/CHANGELOG.md +6 -0
- package/README.md +3 -1
- package/dist/base64url.test.js +25 -0
- package/dist/base64url.test.js.map +1 -0
- package/dist/coValueCore.js +16 -15
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/account.js +16 -15
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/group.js +13 -14
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.js.map +1 -1
- package/dist/crypto/PureJSCrypto.js +89 -0
- package/dist/crypto/PureJSCrypto.js.map +1 -0
- package/dist/crypto/WasmCrypto.js +127 -0
- package/dist/crypto/WasmCrypto.js.map +1 -0
- package/dist/crypto/crypto.js +151 -0
- package/dist/crypto/crypto.js.map +1 -0
- package/dist/ids.js +4 -2
- package/dist/ids.js.map +1 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/dist/jsonStringify.js.map +1 -1
- package/dist/localNode.js +24 -24
- package/dist/localNode.js.map +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/storage/FileSystem.js +2 -2
- package/dist/storage/FileSystem.js.map +1 -1
- package/dist/storage/chunksAndKnownStates.js +2 -2
- package/dist/storage/chunksAndKnownStates.js.map +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/sync.js +6 -2
- package/dist/sync.js.map +1 -1
- package/dist/tests/account.test.js +58 -0
- package/dist/tests/account.test.js.map +1 -0
- package/dist/tests/coList.test.js +76 -0
- package/dist/tests/coList.test.js.map +1 -0
- package/dist/tests/coMap.test.js +136 -0
- package/dist/tests/coMap.test.js.map +1 -0
- package/dist/tests/coStream.test.js +172 -0
- package/dist/tests/coStream.test.js.map +1 -0
- package/dist/tests/coValueCore.test.js +114 -0
- package/dist/tests/coValueCore.test.js.map +1 -0
- package/dist/tests/crypto.test.js +118 -0
- package/dist/tests/crypto.test.js.map +1 -0
- package/dist/tests/cryptoImpl.test.js +113 -0
- package/dist/tests/cryptoImpl.test.js.map +1 -0
- package/dist/tests/group.test.js +34 -0
- package/dist/tests/group.test.js.map +1 -0
- package/dist/tests/permissions.test.js +1060 -0
- package/dist/tests/permissions.test.js.map +1 -0
- package/dist/tests/sync.test.js +816 -0
- package/dist/tests/sync.test.js.map +1 -0
- package/dist/tests/testUtils.js +10 -9
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
- package/dist/typeUtils/isAccountID.js.map +1 -1
- package/dist/typeUtils/isCoValue.js.map +1 -1
- package/package.json +14 -28
- package/src/base64url.test.ts +6 -6
- package/src/coValue.ts +1 -1
- package/src/coValueCore.ts +87 -85
- package/src/coValues/account.ts +26 -28
- package/src/coValues/coList.ts +10 -10
- package/src/coValues/coMap.ts +10 -10
- package/src/coValues/coStream.ts +17 -17
- package/src/coValues/group.ts +93 -109
- package/src/coreToCoValue.ts +5 -2
- package/src/crypto/PureJSCrypto.ts +200 -0
- package/src/crypto/WasmCrypto.ts +259 -0
- package/src/crypto/crypto.ts +336 -0
- package/src/ids.ts +8 -7
- package/src/index.ts +11 -19
- package/src/jsonStringify.ts +6 -4
- package/src/jsonValue.ts +2 -2
- package/src/localNode.ts +86 -80
- package/src/media.ts +3 -3
- package/src/permissions.ts +14 -16
- package/src/storage/FileSystem.ts +31 -30
- package/src/storage/chunksAndKnownStates.ts +24 -17
- package/src/storage/index.ts +41 -37
- package/src/streamUtils.ts +12 -12
- package/src/sync.ts +56 -40
- package/src/tests/account.test.ts +8 -12
- package/src/tests/coList.test.ts +19 -25
- package/src/tests/coMap.test.ts +25 -30
- package/src/tests/coStream.test.ts +28 -38
- package/src/tests/coValueCore.test.ts +35 -36
- package/src/tests/crypto.test.ts +66 -72
- package/src/tests/cryptoImpl.test.ts +183 -0
- package/src/tests/group.test.ts +16 -17
- package/src/tests/permissions.test.ts +237 -254
- package/src/tests/sync.test.ts +119 -120
- package/src/tests/testUtils.ts +22 -19
- package/src/typeUtils/accountOrAgentIDfromSessionID.ts +1 -2
- package/src/typeUtils/expectGroup.ts +1 -1
- package/src/typeUtils/isAccountID.ts +0 -1
- package/src/typeUtils/isCoValue.ts +1 -2
- package/tsconfig.json +0 -1
- package/dist/crypto.js +0 -255
- package/dist/crypto.js.map +0 -1
- package/src/crypto.ts +0 -485
|
@@ -1,35 +1,16 @@
|
|
|
1
|
-
import { expect, test
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
2
|
import { newRandomSessionID } from "../coValueCore.js";
|
|
3
3
|
import { expectMap } from "../coValue.js";
|
|
4
|
-
import { RawGroup } from "../coValues/group.js";
|
|
5
|
-
import {
|
|
6
|
-
createdNowUnique,
|
|
7
|
-
newRandomKeySecret,
|
|
8
|
-
seal,
|
|
9
|
-
encryptKeySecret,
|
|
10
|
-
newRandomAgentSecret,
|
|
11
|
-
getAgentID,
|
|
12
|
-
getAgentSealerSecret,
|
|
13
|
-
getAgentSealerID,
|
|
14
|
-
} from "../crypto.js";
|
|
15
4
|
import {
|
|
16
5
|
newGroup,
|
|
17
6
|
newGroupHighLevel,
|
|
18
7
|
groupWithTwoAdmins,
|
|
19
8
|
groupWithTwoAdminsHighLevel,
|
|
20
9
|
} from "./testUtils.js";
|
|
21
|
-
import { ControlledAgent,
|
|
10
|
+
import { ControlledAgent, WasmCrypto } from "../index.js";
|
|
22
11
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
23
12
|
|
|
24
|
-
|
|
25
|
-
if (!("crypto" in globalThis)) {
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
(globalThis as any).crypto = webcrypto;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
beforeEach(async () => {
|
|
31
|
-
await cojsonReady;
|
|
32
|
-
});
|
|
13
|
+
const Crypto = await WasmCrypto.create();
|
|
33
14
|
|
|
34
15
|
test("Initial admin can add another admin to a group", () => {
|
|
35
16
|
groupWithTwoAdmins();
|
|
@@ -46,9 +27,9 @@ test("Added admin can add a third admin to a group", () => {
|
|
|
46
27
|
groupCore
|
|
47
28
|
.testWithDifferentAccount(
|
|
48
29
|
otherAdmin,
|
|
49
|
-
newRandomSessionID(otherAdmin.id)
|
|
30
|
+
newRandomSessionID(otherAdmin.id),
|
|
50
31
|
)
|
|
51
|
-
.getCurrentContent()
|
|
32
|
+
.getCurrentContent(),
|
|
52
33
|
);
|
|
53
34
|
|
|
54
35
|
expect(groupAsOtherAdmin.get(otherAdmin.id)).toEqual("admin");
|
|
@@ -60,15 +41,15 @@ test("Added admin can add a third admin to a group", () => {
|
|
|
60
41
|
});
|
|
61
42
|
|
|
62
43
|
test("Added adming can add a third admin to a group (high level)", () => {
|
|
63
|
-
const { group, otherAdmin
|
|
44
|
+
const { group, otherAdmin } = groupWithTwoAdminsHighLevel();
|
|
64
45
|
|
|
65
46
|
const groupAsOtherAdmin = expectGroup(
|
|
66
47
|
group.core
|
|
67
48
|
.testWithDifferentAccount(
|
|
68
49
|
otherAdmin,
|
|
69
|
-
newRandomSessionID(otherAdmin.id)
|
|
50
|
+
newRandomSessionID(otherAdmin.id),
|
|
70
51
|
)
|
|
71
|
-
.getCurrentContent()
|
|
52
|
+
.getCurrentContent(),
|
|
72
53
|
);
|
|
73
54
|
|
|
74
55
|
const thirdAdmin = groupAsOtherAdmin.core.node.createAccount();
|
|
@@ -92,9 +73,9 @@ test("Admins can't demote other admins in a group", () => {
|
|
|
92
73
|
groupCore
|
|
93
74
|
.testWithDifferentAccount(
|
|
94
75
|
otherAdmin,
|
|
95
|
-
newRandomSessionID(otherAdmin.id)
|
|
76
|
+
newRandomSessionID(otherAdmin.id),
|
|
96
77
|
)
|
|
97
|
-
.getCurrentContent()
|
|
78
|
+
.getCurrentContent(),
|
|
98
79
|
);
|
|
99
80
|
|
|
100
81
|
groupAsOtherAdmin.set(admin.id, "writer", "trusting");
|
|
@@ -108,13 +89,13 @@ test("Admins can't demote other admins in a group (high level)", () => {
|
|
|
108
89
|
group.core
|
|
109
90
|
.testWithDifferentAccount(
|
|
110
91
|
otherAdmin,
|
|
111
|
-
newRandomSessionID(otherAdmin.id)
|
|
92
|
+
newRandomSessionID(otherAdmin.id),
|
|
112
93
|
)
|
|
113
|
-
.getCurrentContent()
|
|
94
|
+
.getCurrentContent(),
|
|
114
95
|
);
|
|
115
96
|
|
|
116
97
|
expect(() =>
|
|
117
|
-
groupAsOtherAdmin.addMemberInternal(admin.id, "writer")
|
|
98
|
+
groupAsOtherAdmin.addMemberInternal(admin.id, "writer"),
|
|
118
99
|
).toThrow("Failed to set role");
|
|
119
100
|
|
|
120
101
|
expect(groupAsOtherAdmin.get(admin.id)).toEqual("admin");
|
|
@@ -134,7 +115,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
134
115
|
const groupAsWriter = expectGroup(
|
|
135
116
|
groupCore
|
|
136
117
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
137
|
-
.getCurrentContent()
|
|
118
|
+
.getCurrentContent(),
|
|
138
119
|
);
|
|
139
120
|
|
|
140
121
|
expect(groupAsWriter.get(writer.id)).toEqual("writer");
|
|
@@ -162,7 +143,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
162
143
|
const groupAsWriter = expectGroup(
|
|
163
144
|
group.core
|
|
164
145
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
165
|
-
.getCurrentContent()
|
|
146
|
+
.getCurrentContent(),
|
|
166
147
|
);
|
|
167
148
|
|
|
168
149
|
expect(groupAsWriter.get(writer.id)).toEqual("writer");
|
|
@@ -170,13 +151,13 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
170
151
|
const otherAgent = groupAsWriter.core.node.createAccount();
|
|
171
152
|
|
|
172
153
|
expect(() => groupAsWriter.addMember(otherAgent, "admin")).toThrow(
|
|
173
|
-
"Failed to set role"
|
|
154
|
+
"Failed to set role",
|
|
174
155
|
);
|
|
175
156
|
expect(() => groupAsWriter.addMember(otherAgent, "writer")).toThrow(
|
|
176
|
-
"Failed to set role"
|
|
157
|
+
"Failed to set role",
|
|
177
158
|
);
|
|
178
159
|
expect(() => groupAsWriter.addMember(otherAgent, "reader")).toThrow(
|
|
179
|
-
"Failed to set role"
|
|
160
|
+
"Failed to set role",
|
|
180
161
|
);
|
|
181
162
|
|
|
182
163
|
expect(groupAsWriter.get(otherAgent.id)).toBeUndefined();
|
|
@@ -194,7 +175,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
194
175
|
const groupAsReader = expectGroup(
|
|
195
176
|
groupCore
|
|
196
177
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
197
|
-
.getCurrentContent()
|
|
178
|
+
.getCurrentContent(),
|
|
198
179
|
);
|
|
199
180
|
|
|
200
181
|
expect(groupAsReader.get(reader.id)).toEqual("reader");
|
|
@@ -223,7 +204,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
223
204
|
const groupAsReader = expectGroup(
|
|
224
205
|
group.core
|
|
225
206
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
226
|
-
.getCurrentContent()
|
|
207
|
+
.getCurrentContent(),
|
|
227
208
|
);
|
|
228
209
|
|
|
229
210
|
expect(groupAsReader.get(reader.id)).toEqual("reader");
|
|
@@ -231,13 +212,13 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
231
212
|
const otherAgent = groupAsReader.core.node.createAccount();
|
|
232
213
|
|
|
233
214
|
expect(() => groupAsReader.addMember(otherAgent, "admin")).toThrow(
|
|
234
|
-
"Failed to set role"
|
|
215
|
+
"Failed to set role",
|
|
235
216
|
);
|
|
236
217
|
expect(() => groupAsReader.addMember(otherAgent, "writer")).toThrow(
|
|
237
|
-
"Failed to set role"
|
|
218
|
+
"Failed to set role",
|
|
238
219
|
);
|
|
239
220
|
expect(() => groupAsReader.addMember(otherAgent, "reader")).toThrow(
|
|
240
|
-
"Failed to set role"
|
|
221
|
+
"Failed to set role",
|
|
241
222
|
);
|
|
242
223
|
|
|
243
224
|
expect(groupAsReader.get(otherAgent.id)).toBeUndefined();
|
|
@@ -250,17 +231,17 @@ test("Admins can write to an object that is owned by their group", () => {
|
|
|
250
231
|
type: "comap",
|
|
251
232
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
252
233
|
meta: null,
|
|
253
|
-
...createdNowUnique(),
|
|
234
|
+
...Crypto.createdNowUnique(),
|
|
254
235
|
});
|
|
255
236
|
|
|
256
|
-
|
|
237
|
+
const childContent = expectMap(childObject.getCurrentContent());
|
|
257
238
|
|
|
258
239
|
childContent.set("foo", "bar", "trusting");
|
|
259
240
|
expect(childContent.get("foo")).toEqual("bar");
|
|
260
241
|
});
|
|
261
242
|
|
|
262
243
|
test("Admins can write to an object that is owned by their group (high level)", () => {
|
|
263
|
-
const {
|
|
244
|
+
const { group } = newGroupHighLevel();
|
|
264
245
|
|
|
265
246
|
const childObject = group.createMap();
|
|
266
247
|
|
|
@@ -281,16 +262,16 @@ test("Writers can write to an object that is owned by their group", () => {
|
|
|
281
262
|
type: "comap",
|
|
282
263
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
283
264
|
meta: null,
|
|
284
|
-
...createdNowUnique(),
|
|
265
|
+
...Crypto.createdNowUnique(),
|
|
285
266
|
});
|
|
286
267
|
|
|
287
268
|
const childObjectAsWriter = childObject.testWithDifferentAccount(
|
|
288
269
|
writer,
|
|
289
|
-
newRandomSessionID(writer.id)
|
|
270
|
+
newRandomSessionID(writer.id),
|
|
290
271
|
);
|
|
291
272
|
|
|
292
273
|
const childContentAsWriter = expectMap(
|
|
293
|
-
childObjectAsWriter.getCurrentContent()
|
|
274
|
+
childObjectAsWriter.getCurrentContent(),
|
|
294
275
|
);
|
|
295
276
|
|
|
296
277
|
childContentAsWriter.set("foo", "bar", "trusting");
|
|
@@ -309,7 +290,7 @@ test("Writers can write to an object that is owned by their group (high level)",
|
|
|
309
290
|
const childObjectAsWriter = expectMap(
|
|
310
291
|
childObject.core
|
|
311
292
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
312
|
-
.getCurrentContent()
|
|
293
|
+
.getCurrentContent(),
|
|
313
294
|
);
|
|
314
295
|
|
|
315
296
|
childObjectAsWriter.set("foo", "bar", "trusting");
|
|
@@ -329,16 +310,16 @@ test("Readers can not write to an object that is owned by their group", () => {
|
|
|
329
310
|
type: "comap",
|
|
330
311
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
331
312
|
meta: null,
|
|
332
|
-
...createdNowUnique(),
|
|
313
|
+
...Crypto.createdNowUnique(),
|
|
333
314
|
});
|
|
334
315
|
|
|
335
316
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
336
317
|
reader,
|
|
337
|
-
newRandomSessionID(reader.id)
|
|
318
|
+
newRandomSessionID(reader.id),
|
|
338
319
|
);
|
|
339
320
|
|
|
340
321
|
const childContentAsReader = expectMap(
|
|
341
|
-
childObjectAsReader.getCurrentContent()
|
|
322
|
+
childObjectAsReader.getCurrentContent(),
|
|
342
323
|
);
|
|
343
324
|
|
|
344
325
|
childContentAsReader.set("foo", "bar", "trusting");
|
|
@@ -357,7 +338,7 @@ test("Readers can not write to an object that is owned by their group (high leve
|
|
|
357
338
|
const childObjectAsReader = expectMap(
|
|
358
339
|
childObject.core
|
|
359
340
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
360
|
-
.getCurrentContent()
|
|
341
|
+
.getCurrentContent(),
|
|
361
342
|
);
|
|
362
343
|
|
|
363
344
|
childObjectAsReader.set("foo", "bar", "trusting");
|
|
@@ -369,8 +350,8 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
369
350
|
|
|
370
351
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
371
352
|
|
|
372
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
373
|
-
const revelation = seal({
|
|
353
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
354
|
+
const revelation = Crypto.seal({
|
|
374
355
|
message: readKey,
|
|
375
356
|
from: admin.currentSealerSecret(),
|
|
376
357
|
to: admin.currentSealerID(),
|
|
@@ -383,7 +364,7 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
383
364
|
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation, "trusting");
|
|
384
365
|
|
|
385
366
|
expect(groupContent.get(`${readKeyID}_for_${admin.id}`)).toEqual(
|
|
386
|
-
revelation
|
|
367
|
+
revelation,
|
|
387
368
|
);
|
|
388
369
|
|
|
389
370
|
groupContent.set("readKey", readKeyID, "trusting");
|
|
@@ -396,7 +377,7 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
396
377
|
type: "comap",
|
|
397
378
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
398
379
|
meta: null,
|
|
399
|
-
...createdNowUnique(),
|
|
380
|
+
...Crypto.createdNowUnique(),
|
|
400
381
|
});
|
|
401
382
|
|
|
402
383
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
@@ -406,7 +387,7 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
406
387
|
});
|
|
407
388
|
|
|
408
389
|
test("Admins can set group read key and then use it to create and read private transactions in owned objects (high level)", () => {
|
|
409
|
-
const {
|
|
390
|
+
const { group } = newGroupHighLevel();
|
|
410
391
|
|
|
411
392
|
const childObject = group.createMap();
|
|
412
393
|
|
|
@@ -419,14 +400,14 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
419
400
|
|
|
420
401
|
const writer = node.createAccount();
|
|
421
402
|
|
|
422
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
403
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
423
404
|
|
|
424
405
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
425
406
|
|
|
426
407
|
groupContent.set(writer.id, "writer", "trusting");
|
|
427
408
|
expect(groupContent.get(writer.id)).toEqual("writer");
|
|
428
409
|
|
|
429
|
-
const revelation1 = seal({
|
|
410
|
+
const revelation1 = Crypto.seal({
|
|
430
411
|
message: readKey,
|
|
431
412
|
from: admin.currentSealerSecret(),
|
|
432
413
|
to: admin.currentSealerID(),
|
|
@@ -438,7 +419,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
438
419
|
|
|
439
420
|
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
440
421
|
|
|
441
|
-
const revelation2 = seal({
|
|
422
|
+
const revelation2 = Crypto.seal({
|
|
442
423
|
message: readKey,
|
|
443
424
|
from: admin.currentSealerSecret(),
|
|
444
425
|
to: writer.currentSealerID(),
|
|
@@ -456,18 +437,18 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
456
437
|
type: "comap",
|
|
457
438
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
458
439
|
meta: null,
|
|
459
|
-
...createdNowUnique(),
|
|
440
|
+
...Crypto.createdNowUnique(),
|
|
460
441
|
});
|
|
461
442
|
|
|
462
443
|
const childObjectAsWriter = childObject.testWithDifferentAccount(
|
|
463
444
|
writer,
|
|
464
|
-
newRandomSessionID(writer.id)
|
|
445
|
+
newRandomSessionID(writer.id),
|
|
465
446
|
);
|
|
466
447
|
|
|
467
448
|
expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
|
|
468
449
|
|
|
469
450
|
const childContentAsWriter = expectMap(
|
|
470
|
-
childObjectAsWriter.getCurrentContent()
|
|
451
|
+
childObjectAsWriter.getCurrentContent(),
|
|
471
452
|
);
|
|
472
453
|
|
|
473
454
|
childContentAsWriter.set("foo", "bar", "private");
|
|
@@ -475,7 +456,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
475
456
|
});
|
|
476
457
|
|
|
477
458
|
test("Admins can set group read key and then writers can use it to create and read private transactions in owned objects (high level)", () => {
|
|
478
|
-
const { node, group
|
|
459
|
+
const { node, group } = newGroupHighLevel();
|
|
479
460
|
|
|
480
461
|
const writer = node.createAccount();
|
|
481
462
|
|
|
@@ -486,7 +467,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
486
467
|
const childObjectAsWriter = expectMap(
|
|
487
468
|
childObject.core
|
|
488
469
|
.testWithDifferentAccount(writer, newRandomSessionID(writer.id))
|
|
489
|
-
.getCurrentContent()
|
|
470
|
+
.getCurrentContent(),
|
|
490
471
|
);
|
|
491
472
|
|
|
492
473
|
childObjectAsWriter.set("foo", "bar", "private");
|
|
@@ -498,14 +479,14 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
498
479
|
|
|
499
480
|
const reader = node.createAccount();
|
|
500
481
|
|
|
501
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
482
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
502
483
|
|
|
503
484
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
504
485
|
|
|
505
486
|
groupContent.set(reader.id, "reader", "trusting");
|
|
506
487
|
expect(groupContent.get(reader.id)).toEqual("reader");
|
|
507
488
|
|
|
508
|
-
const revelation1 = seal({
|
|
489
|
+
const revelation1 = Crypto.seal({
|
|
509
490
|
message: readKey,
|
|
510
491
|
from: admin.currentSealerSecret(),
|
|
511
492
|
to: admin.currentSealerID(),
|
|
@@ -517,7 +498,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
517
498
|
|
|
518
499
|
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
519
500
|
|
|
520
|
-
const revelation2 = seal({
|
|
501
|
+
const revelation2 = Crypto.seal({
|
|
521
502
|
message: readKey,
|
|
522
503
|
from: admin.currentSealerSecret(),
|
|
523
504
|
to: reader.currentSealerID(),
|
|
@@ -535,7 +516,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
535
516
|
type: "comap",
|
|
536
517
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
537
518
|
meta: null,
|
|
538
|
-
...createdNowUnique(),
|
|
519
|
+
...Crypto.createdNowUnique(),
|
|
539
520
|
});
|
|
540
521
|
|
|
541
522
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
@@ -545,20 +526,20 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
545
526
|
|
|
546
527
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
547
528
|
reader,
|
|
548
|
-
newRandomSessionID(reader.id)
|
|
529
|
+
newRandomSessionID(reader.id),
|
|
549
530
|
);
|
|
550
531
|
|
|
551
532
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey);
|
|
552
533
|
|
|
553
534
|
const childContentAsReader = expectMap(
|
|
554
|
-
childObjectAsReader.getCurrentContent()
|
|
535
|
+
childObjectAsReader.getCurrentContent(),
|
|
555
536
|
);
|
|
556
537
|
|
|
557
538
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
558
539
|
});
|
|
559
540
|
|
|
560
541
|
test("Admins can set group read key and then use it to create private transactions in owned objects, which readers can read (high level)", () => {
|
|
561
|
-
const { node, group
|
|
542
|
+
const { node, group } = newGroupHighLevel();
|
|
562
543
|
|
|
563
544
|
const reader = node.createAccount();
|
|
564
545
|
|
|
@@ -572,7 +553,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
572
553
|
const childContentAsReader = expectMap(
|
|
573
554
|
childObject.core
|
|
574
555
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
575
|
-
.getCurrentContent()
|
|
556
|
+
.getCurrentContent(),
|
|
576
557
|
);
|
|
577
558
|
|
|
578
559
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
@@ -585,14 +566,14 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
585
566
|
|
|
586
567
|
const reader2 = node.createAccount();
|
|
587
568
|
|
|
588
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
569
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
589
570
|
|
|
590
571
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
591
572
|
|
|
592
573
|
groupContent.set(reader1.id, "reader", "trusting");
|
|
593
574
|
expect(groupContent.get(reader1.id)).toEqual("reader");
|
|
594
575
|
|
|
595
|
-
const revelation1 = seal({
|
|
576
|
+
const revelation1 = Crypto.seal({
|
|
596
577
|
message: readKey,
|
|
597
578
|
from: admin.currentSealerSecret(),
|
|
598
579
|
to: admin.currentSealerID(),
|
|
@@ -604,7 +585,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
604
585
|
|
|
605
586
|
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
606
587
|
|
|
607
|
-
const revelation2 = seal({
|
|
588
|
+
const revelation2 = Crypto.seal({
|
|
608
589
|
message: readKey,
|
|
609
590
|
from: admin.currentSealerSecret(),
|
|
610
591
|
to: reader1.currentSealerID(),
|
|
@@ -622,7 +603,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
622
603
|
type: "comap",
|
|
623
604
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
624
605
|
meta: null,
|
|
625
|
-
...createdNowUnique(),
|
|
606
|
+
...Crypto.createdNowUnique(),
|
|
626
607
|
});
|
|
627
608
|
|
|
628
609
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
@@ -632,18 +613,18 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
632
613
|
|
|
633
614
|
const childObjectAsReader1 = childObject.testWithDifferentAccount(
|
|
634
615
|
reader1,
|
|
635
|
-
newRandomSessionID(reader1.id)
|
|
616
|
+
newRandomSessionID(reader1.id),
|
|
636
617
|
);
|
|
637
618
|
|
|
638
619
|
expect(childObjectAsReader1.getCurrentReadKey().secret).toEqual(readKey);
|
|
639
620
|
|
|
640
621
|
const childContentAsReader1 = expectMap(
|
|
641
|
-
childObjectAsReader1.getCurrentContent()
|
|
622
|
+
childObjectAsReader1.getCurrentContent(),
|
|
642
623
|
);
|
|
643
624
|
|
|
644
625
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
645
626
|
|
|
646
|
-
const revelation3 = seal({
|
|
627
|
+
const revelation3 = Crypto.seal({
|
|
647
628
|
message: readKey,
|
|
648
629
|
from: admin.currentSealerSecret(),
|
|
649
630
|
to: reader2.currentSealerID(),
|
|
@@ -657,20 +638,20 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
657
638
|
|
|
658
639
|
const childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
659
640
|
reader2,
|
|
660
|
-
newRandomSessionID(reader2.id)
|
|
641
|
+
newRandomSessionID(reader2.id),
|
|
661
642
|
);
|
|
662
643
|
|
|
663
644
|
expect(childObjectAsReader2.getCurrentReadKey().secret).toEqual(readKey);
|
|
664
645
|
|
|
665
646
|
const childContentAsReader2 = expectMap(
|
|
666
|
-
childObjectAsReader2.getCurrentContent()
|
|
647
|
+
childObjectAsReader2.getCurrentContent(),
|
|
667
648
|
);
|
|
668
649
|
|
|
669
650
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
670
651
|
});
|
|
671
652
|
|
|
672
653
|
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)", () => {
|
|
673
|
-
const { node, group
|
|
654
|
+
const { node, group } = newGroupHighLevel();
|
|
674
655
|
|
|
675
656
|
const reader1 = node.createAccount();
|
|
676
657
|
|
|
@@ -686,7 +667,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
686
667
|
const childContentAsReader1 = expectMap(
|
|
687
668
|
childObject.core
|
|
688
669
|
.testWithDifferentAccount(reader1, newRandomSessionID(reader1.id))
|
|
689
|
-
.getCurrentContent()
|
|
670
|
+
.getCurrentContent(),
|
|
690
671
|
);
|
|
691
672
|
|
|
692
673
|
expect(childContentAsReader1.get("foo")).toEqual("bar");
|
|
@@ -696,7 +677,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
696
677
|
const childContentAsReader2 = expectMap(
|
|
697
678
|
childObject.core
|
|
698
679
|
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
699
|
-
.getCurrentContent()
|
|
680
|
+
.getCurrentContent(),
|
|
700
681
|
);
|
|
701
682
|
|
|
702
683
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
@@ -707,8 +688,8 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
707
688
|
|
|
708
689
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
709
690
|
|
|
710
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
711
|
-
const revelation1 = seal({
|
|
691
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
692
|
+
const revelation1 = Crypto.seal({
|
|
712
693
|
message: readKey,
|
|
713
694
|
from: admin.currentSealerSecret(),
|
|
714
695
|
to: admin.currentSealerID(),
|
|
@@ -728,7 +709,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
728
709
|
type: "comap",
|
|
729
710
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
730
711
|
meta: null,
|
|
731
|
-
...createdNowUnique(),
|
|
712
|
+
...Crypto.createdNowUnique(),
|
|
732
713
|
});
|
|
733
714
|
|
|
734
715
|
const childContent = expectMap(childObject.getCurrentContent());
|
|
@@ -736,9 +717,9 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
736
717
|
childContent.set("foo", "bar", "private");
|
|
737
718
|
expect(childContent.get("foo")).toEqual("bar");
|
|
738
719
|
|
|
739
|
-
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
720
|
+
const { secret: readKey2, id: readKeyID2 } = Crypto.newRandomKeySecret();
|
|
740
721
|
|
|
741
|
-
const revelation2 = seal({
|
|
722
|
+
const revelation2 = Crypto.seal({
|
|
742
723
|
message: readKey2,
|
|
743
724
|
from: admin.currentSealerSecret(),
|
|
744
725
|
to: admin.currentSealerID(),
|
|
@@ -785,13 +766,13 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
785
766
|
type: "comap",
|
|
786
767
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
787
768
|
meta: null,
|
|
788
|
-
...createdNowUnique(),
|
|
769
|
+
...Crypto.createdNowUnique(),
|
|
789
770
|
});
|
|
790
771
|
|
|
791
772
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
792
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
773
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
793
774
|
|
|
794
|
-
const revelation = seal({
|
|
775
|
+
const revelation = Crypto.seal({
|
|
795
776
|
message: readKey,
|
|
796
777
|
from: admin.currentSealerSecret(),
|
|
797
778
|
to: admin.currentSealerID(),
|
|
@@ -816,9 +797,9 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
816
797
|
|
|
817
798
|
const reader = node.createAccount();
|
|
818
799
|
|
|
819
|
-
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
800
|
+
const { secret: readKey2, id: readKeyID2 } = Crypto.newRandomKeySecret();
|
|
820
801
|
|
|
821
|
-
const revelation2 = seal({
|
|
802
|
+
const revelation2 = Crypto.seal({
|
|
822
803
|
message: readKey2,
|
|
823
804
|
from: admin.currentSealerSecret(),
|
|
824
805
|
to: admin.currentSealerID(),
|
|
@@ -830,7 +811,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
830
811
|
|
|
831
812
|
groupContent.set(`${readKeyID2}_for_${admin.id}`, revelation2, "trusting");
|
|
832
813
|
|
|
833
|
-
const revelation3 = seal({
|
|
814
|
+
const revelation3 = Crypto.seal({
|
|
834
815
|
message: readKey2,
|
|
835
816
|
from: admin.currentSealerSecret(),
|
|
836
817
|
to: reader.currentSealerID(),
|
|
@@ -844,11 +825,11 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
844
825
|
|
|
845
826
|
groupContent.set(
|
|
846
827
|
`${readKeyID}_for_${readKeyID2}`,
|
|
847
|
-
encryptKeySecret({
|
|
828
|
+
Crypto.encryptKeySecret({
|
|
848
829
|
toEncrypt: { id: readKeyID, secret: readKey },
|
|
849
830
|
encrypting: { id: readKeyID2, secret: readKey2 },
|
|
850
831
|
}).encrypted,
|
|
851
|
-
"trusting"
|
|
832
|
+
"trusting",
|
|
852
833
|
);
|
|
853
834
|
|
|
854
835
|
groupContent.set("readKey", readKeyID2, "trusting");
|
|
@@ -864,13 +845,13 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
864
845
|
|
|
865
846
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
866
847
|
reader,
|
|
867
|
-
newRandomSessionID(reader.id)
|
|
848
|
+
newRandomSessionID(reader.id),
|
|
868
849
|
);
|
|
869
850
|
|
|
870
851
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey2);
|
|
871
852
|
|
|
872
853
|
const childContentAsReader = expectMap(
|
|
873
|
-
childObjectAsReader.getCurrentContent()
|
|
854
|
+
childObjectAsReader.getCurrentContent(),
|
|
874
855
|
);
|
|
875
856
|
|
|
876
857
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
@@ -903,7 +884,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
903
884
|
const childContentAsReader = expectMap(
|
|
904
885
|
childObject.core
|
|
905
886
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
906
|
-
.getCurrentContent()
|
|
887
|
+
.getCurrentContent(),
|
|
907
888
|
);
|
|
908
889
|
|
|
909
890
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
@@ -917,16 +898,16 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
917
898
|
type: "comap",
|
|
918
899
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
919
900
|
meta: null,
|
|
920
|
-
...createdNowUnique(),
|
|
901
|
+
...Crypto.createdNowUnique(),
|
|
921
902
|
});
|
|
922
903
|
|
|
923
904
|
const groupContent = expectGroup(groupCore.getCurrentContent());
|
|
924
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
905
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
925
906
|
const reader = node.createAccount();
|
|
926
907
|
|
|
927
908
|
const reader2 = node.createAccount();
|
|
928
909
|
|
|
929
|
-
const revelation1 = seal({
|
|
910
|
+
const revelation1 = Crypto.seal({
|
|
930
911
|
message: readKey,
|
|
931
912
|
from: admin.currentSealerSecret(),
|
|
932
913
|
to: admin.currentSealerID(),
|
|
@@ -938,7 +919,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
938
919
|
|
|
939
920
|
groupContent.set(`${readKeyID}_for_${admin.id}`, revelation1, "trusting");
|
|
940
921
|
|
|
941
|
-
const revelation2 = seal({
|
|
922
|
+
const revelation2 = Crypto.seal({
|
|
942
923
|
message: readKey,
|
|
943
924
|
from: admin.currentSealerSecret(),
|
|
944
925
|
to: reader.currentSealerID(),
|
|
@@ -950,7 +931,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
950
931
|
|
|
951
932
|
groupContent.set(`${readKeyID}_for_${reader.id}`, revelation2, "trusting");
|
|
952
933
|
|
|
953
|
-
const revelation3 = seal({
|
|
934
|
+
const revelation3 = Crypto.seal({
|
|
954
935
|
message: readKey,
|
|
955
936
|
from: admin.currentSealerSecret(),
|
|
956
937
|
to: reader2.currentSealerID(),
|
|
@@ -978,25 +959,25 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
978
959
|
|
|
979
960
|
let childObjectAsReader = childObject.testWithDifferentAccount(
|
|
980
961
|
reader,
|
|
981
|
-
newRandomSessionID(reader.id)
|
|
962
|
+
newRandomSessionID(reader.id),
|
|
982
963
|
);
|
|
983
964
|
|
|
984
965
|
expect(
|
|
985
|
-
expectMap(childObjectAsReader.getCurrentContent()).get("foo")
|
|
966
|
+
expectMap(childObjectAsReader.getCurrentContent()).get("foo"),
|
|
986
967
|
).toEqual("bar");
|
|
987
968
|
|
|
988
969
|
let childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
989
970
|
reader,
|
|
990
|
-
newRandomSessionID(reader.id)
|
|
971
|
+
newRandomSessionID(reader.id),
|
|
991
972
|
);
|
|
992
973
|
|
|
993
974
|
expect(
|
|
994
|
-
expectMap(childObjectAsReader2.getCurrentContent()).get("foo")
|
|
975
|
+
expectMap(childObjectAsReader2.getCurrentContent()).get("foo"),
|
|
995
976
|
).toEqual("bar");
|
|
996
977
|
|
|
997
|
-
const { secret: readKey2, id: readKeyID2 } = newRandomKeySecret();
|
|
978
|
+
const { secret: readKey2, id: readKeyID2 } = Crypto.newRandomKeySecret();
|
|
998
979
|
|
|
999
|
-
const newRevelation1 = seal({
|
|
980
|
+
const newRevelation1 = Crypto.seal({
|
|
1000
981
|
message: readKey2,
|
|
1001
982
|
from: admin.currentSealerSecret(),
|
|
1002
983
|
to: admin.currentSealerID(),
|
|
@@ -1009,10 +990,10 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1009
990
|
groupContent.set(
|
|
1010
991
|
`${readKeyID2}_for_${admin.id}`,
|
|
1011
992
|
newRevelation1,
|
|
1012
|
-
"trusting"
|
|
993
|
+
"trusting",
|
|
1013
994
|
);
|
|
1014
995
|
|
|
1015
|
-
const newRevelation2 = seal({
|
|
996
|
+
const newRevelation2 = Crypto.seal({
|
|
1016
997
|
message: readKey2,
|
|
1017
998
|
from: admin.currentSealerSecret(),
|
|
1018
999
|
to: reader2.currentSealerID(),
|
|
@@ -1025,7 +1006,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1025
1006
|
groupContent.set(
|
|
1026
1007
|
`${readKeyID2}_for_${reader2.id}`,
|
|
1027
1008
|
newRevelation2,
|
|
1028
|
-
"trusting"
|
|
1009
|
+
"trusting",
|
|
1029
1010
|
);
|
|
1030
1011
|
|
|
1031
1012
|
groupContent.set("readKey", readKeyID2, "trusting");
|
|
@@ -1043,18 +1024,18 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1043
1024
|
// TODO: make sure these instances of coValues sync between each other so this isn't necessary?
|
|
1044
1025
|
childObjectAsReader = childObject.testWithDifferentAccount(
|
|
1045
1026
|
reader,
|
|
1046
|
-
newRandomSessionID(reader.id)
|
|
1027
|
+
newRandomSessionID(reader.id),
|
|
1047
1028
|
);
|
|
1048
1029
|
childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
1049
1030
|
reader2,
|
|
1050
|
-
newRandomSessionID(reader2.id)
|
|
1031
|
+
newRandomSessionID(reader2.id),
|
|
1051
1032
|
);
|
|
1052
1033
|
|
|
1053
1034
|
expect(
|
|
1054
|
-
expectMap(childObjectAsReader.getCurrentContent()).get("foo2")
|
|
1035
|
+
expectMap(childObjectAsReader.getCurrentContent()).get("foo2"),
|
|
1055
1036
|
).toBeUndefined();
|
|
1056
1037
|
expect(
|
|
1057
|
-
expectMap(childObjectAsReader2.getCurrentContent()).get("foo2")
|
|
1038
|
+
expectMap(childObjectAsReader2.getCurrentContent()).get("foo2"),
|
|
1058
1039
|
).toEqual("bar2");
|
|
1059
1040
|
});
|
|
1060
1041
|
|
|
@@ -1092,7 +1073,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1092
1073
|
const childContentAsReader2 = expectMap(
|
|
1093
1074
|
childObject.core
|
|
1094
1075
|
.testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
|
|
1095
|
-
.getCurrentContent()
|
|
1076
|
+
.getCurrentContent(),
|
|
1096
1077
|
);
|
|
1097
1078
|
|
|
1098
1079
|
expect(childContentAsReader2.get("foo")).toEqual("bar");
|
|
@@ -1103,8 +1084,8 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1103
1084
|
expectMap(
|
|
1104
1085
|
childObject.core
|
|
1105
1086
|
.testWithDifferentAccount(reader, newRandomSessionID(reader.id))
|
|
1106
|
-
.getCurrentContent()
|
|
1107
|
-
).get("foo3")
|
|
1087
|
+
.getCurrentContent(),
|
|
1088
|
+
).get("foo3"),
|
|
1108
1089
|
).toBeUndefined();
|
|
1109
1090
|
});
|
|
1110
1091
|
|
|
@@ -1115,29 +1096,29 @@ test("Can create two owned objects in the same group and they will have differen
|
|
|
1115
1096
|
type: "comap",
|
|
1116
1097
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
1117
1098
|
meta: null,
|
|
1118
|
-
...createdNowUnique(),
|
|
1099
|
+
...Crypto.createdNowUnique(),
|
|
1119
1100
|
});
|
|
1120
1101
|
|
|
1121
1102
|
const childObject2 = node.createCoValue({
|
|
1122
1103
|
type: "comap",
|
|
1123
1104
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
1124
1105
|
meta: null,
|
|
1125
|
-
...createdNowUnique(),
|
|
1106
|
+
...Crypto.createdNowUnique(),
|
|
1126
1107
|
});
|
|
1127
1108
|
|
|
1128
1109
|
expect(childObject1.id).not.toEqual(childObject2.id);
|
|
1129
1110
|
});
|
|
1130
1111
|
|
|
1131
1112
|
test("Admins can create an adminInvite, which can add an admin", () => {
|
|
1132
|
-
const {
|
|
1113
|
+
const { groupCore, admin } = newGroup();
|
|
1133
1114
|
|
|
1134
|
-
const inviteSecret = newRandomAgentSecret();
|
|
1135
|
-
const inviteID = getAgentID(inviteSecret);
|
|
1115
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
1116
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
1136
1117
|
|
|
1137
1118
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1138
1119
|
|
|
1139
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1140
|
-
const revelation = seal({
|
|
1120
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1121
|
+
const revelation = Crypto.seal({
|
|
1141
1122
|
message: readKey,
|
|
1142
1123
|
from: admin.currentSealerSecret(),
|
|
1143
1124
|
to: admin.currentSealerID(),
|
|
@@ -1154,10 +1135,10 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1154
1135
|
|
|
1155
1136
|
expect(group.get(inviteID)).toEqual("adminInvite");
|
|
1156
1137
|
|
|
1157
|
-
const revelationForInvite = seal({
|
|
1138
|
+
const revelationForInvite = Crypto.seal({
|
|
1158
1139
|
message: readKey,
|
|
1159
1140
|
from: admin.currentSealerSecret(),
|
|
1160
|
-
to: getAgentSealerID(inviteID),
|
|
1141
|
+
to: Crypto.getAgentSealerID(inviteID),
|
|
1161
1142
|
nOnceMaterial: {
|
|
1162
1143
|
in: groupCore.id,
|
|
1163
1144
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1169,14 +1150,14 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1169
1150
|
const groupAsInvite = expectGroup(
|
|
1170
1151
|
groupCore
|
|
1171
1152
|
.testWithDifferentAccount(
|
|
1172
|
-
new ControlledAgent(inviteSecret),
|
|
1173
|
-
newRandomSessionID(inviteID)
|
|
1153
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
1154
|
+
newRandomSessionID(inviteID),
|
|
1174
1155
|
)
|
|
1175
|
-
.getCurrentContent()
|
|
1156
|
+
.getCurrentContent(),
|
|
1176
1157
|
);
|
|
1177
1158
|
|
|
1178
|
-
const invitedAdminSecret = newRandomAgentSecret();
|
|
1179
|
-
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1159
|
+
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
1160
|
+
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
1180
1161
|
|
|
1181
1162
|
groupAsInvite.set(invitedAdminID, "admin", "trusting");
|
|
1182
1163
|
|
|
@@ -1186,10 +1167,10 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1186
1167
|
|
|
1187
1168
|
expect(readKeyAsInvite.secret).toBeDefined();
|
|
1188
1169
|
|
|
1189
|
-
const revelation2 = seal({
|
|
1170
|
+
const revelation2 = Crypto.seal({
|
|
1190
1171
|
message: readKeyAsInvite.secret!,
|
|
1191
|
-
from: getAgentSealerSecret(invitedAdminSecret),
|
|
1192
|
-
to: getAgentSealerID(invitedAdminID),
|
|
1172
|
+
from: Crypto.getAgentSealerSecret(invitedAdminSecret),
|
|
1173
|
+
to: Crypto.getAgentSealerID(invitedAdminID),
|
|
1193
1174
|
nOnceMaterial: {
|
|
1194
1175
|
in: groupCore.id,
|
|
1195
1176
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1199,33 +1180,33 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1199
1180
|
groupAsInvite.set(
|
|
1200
1181
|
`${readKeyAsInvite.id}_for_${invitedAdminID}`,
|
|
1201
1182
|
revelation2,
|
|
1202
|
-
"trusting"
|
|
1183
|
+
"trusting",
|
|
1203
1184
|
);
|
|
1204
1185
|
|
|
1205
1186
|
expect(
|
|
1206
|
-
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedAdminID}`)
|
|
1187
|
+
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedAdminID}`),
|
|
1207
1188
|
).toEqual(revelation2);
|
|
1208
1189
|
});
|
|
1209
1190
|
|
|
1210
1191
|
test("Admins can create an adminInvite, which can add an admin (high-level)", async () => {
|
|
1211
|
-
const { node, group
|
|
1192
|
+
const { node, group } = newGroupHighLevel();
|
|
1212
1193
|
|
|
1213
1194
|
const inviteSecret = group.createInvite("admin");
|
|
1214
1195
|
|
|
1215
|
-
const invitedAdminSecret = newRandomAgentSecret();
|
|
1216
|
-
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1196
|
+
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
1197
|
+
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
1217
1198
|
|
|
1218
1199
|
const nodeAsInvitedAdmin = node.testWithDifferentAccount(
|
|
1219
|
-
new ControlledAgent(invitedAdminSecret),
|
|
1220
|
-
newRandomSessionID(invitedAdminID)
|
|
1200
|
+
new ControlledAgent(invitedAdminSecret, Crypto),
|
|
1201
|
+
newRandomSessionID(invitedAdminID),
|
|
1221
1202
|
);
|
|
1222
1203
|
|
|
1223
1204
|
await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
|
|
1224
1205
|
|
|
1225
|
-
const thirdAdmin = newRandomAgentSecret();
|
|
1226
|
-
const thirdAdminID = getAgentID(thirdAdmin);
|
|
1206
|
+
const thirdAdmin = Crypto.newRandomAgentSecret();
|
|
1207
|
+
const thirdAdminID = Crypto.getAgentID(thirdAdmin);
|
|
1227
1208
|
|
|
1228
|
-
|
|
1209
|
+
const groupAsInvitedAdmin = await nodeAsInvitedAdmin.load(group.id);
|
|
1229
1210
|
if (groupAsInvitedAdmin === "unavailable") {
|
|
1230
1211
|
throw new Error("groupAsInvitedAdmin is unavailable");
|
|
1231
1212
|
}
|
|
@@ -1239,15 +1220,15 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
1239
1220
|
});
|
|
1240
1221
|
|
|
1241
1222
|
test("Admins can create a writerInvite, which can add a writer", () => {
|
|
1242
|
-
const {
|
|
1223
|
+
const { groupCore, admin } = newGroup();
|
|
1243
1224
|
|
|
1244
|
-
const inviteSecret = newRandomAgentSecret();
|
|
1245
|
-
const inviteID = getAgentID(inviteSecret);
|
|
1225
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
1226
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
1246
1227
|
|
|
1247
1228
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1248
1229
|
|
|
1249
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1250
|
-
const revelation = seal({
|
|
1230
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1231
|
+
const revelation = Crypto.seal({
|
|
1251
1232
|
message: readKey,
|
|
1252
1233
|
from: admin.currentSealerSecret(),
|
|
1253
1234
|
to: admin.currentSealerID(),
|
|
@@ -1264,10 +1245,10 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1264
1245
|
|
|
1265
1246
|
expect(group.get(inviteID)).toEqual("writerInvite");
|
|
1266
1247
|
|
|
1267
|
-
const revelationForInvite = seal({
|
|
1248
|
+
const revelationForInvite = Crypto.seal({
|
|
1268
1249
|
message: readKey,
|
|
1269
1250
|
from: admin.currentSealerSecret(),
|
|
1270
|
-
to: getAgentSealerID(inviteID),
|
|
1251
|
+
to: Crypto.getAgentSealerID(inviteID),
|
|
1271
1252
|
nOnceMaterial: {
|
|
1272
1253
|
in: groupCore.id,
|
|
1273
1254
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1279,14 +1260,14 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1279
1260
|
const groupAsInvite = expectGroup(
|
|
1280
1261
|
groupCore
|
|
1281
1262
|
.testWithDifferentAccount(
|
|
1282
|
-
new ControlledAgent(inviteSecret),
|
|
1283
|
-
newRandomSessionID(inviteID)
|
|
1263
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
1264
|
+
newRandomSessionID(inviteID),
|
|
1284
1265
|
)
|
|
1285
|
-
.getCurrentContent()
|
|
1266
|
+
.getCurrentContent(),
|
|
1286
1267
|
);
|
|
1287
1268
|
|
|
1288
|
-
const invitedWriterSecret = newRandomAgentSecret();
|
|
1289
|
-
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1269
|
+
const invitedWriterSecret = Crypto.newRandomAgentSecret();
|
|
1270
|
+
const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
|
|
1290
1271
|
|
|
1291
1272
|
groupAsInvite.set(invitedWriterID, "writer", "trusting");
|
|
1292
1273
|
|
|
@@ -1296,10 +1277,10 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1296
1277
|
|
|
1297
1278
|
expect(readKeyAsInvite.secret).toBeDefined();
|
|
1298
1279
|
|
|
1299
|
-
const revelation2 = seal({
|
|
1280
|
+
const revelation2 = Crypto.seal({
|
|
1300
1281
|
message: readKeyAsInvite.secret!,
|
|
1301
|
-
from: getAgentSealerSecret(invitedWriterSecret),
|
|
1302
|
-
to: getAgentSealerID(invitedWriterID),
|
|
1282
|
+
from: Crypto.getAgentSealerSecret(invitedWriterSecret),
|
|
1283
|
+
to: Crypto.getAgentSealerID(invitedWriterID),
|
|
1303
1284
|
nOnceMaterial: {
|
|
1304
1285
|
in: groupCore.id,
|
|
1305
1286
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1309,25 +1290,25 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1309
1290
|
groupAsInvite.set(
|
|
1310
1291
|
`${readKeyAsInvite.id}_for_${invitedWriterID}`,
|
|
1311
1292
|
revelation2,
|
|
1312
|
-
"trusting"
|
|
1293
|
+
"trusting",
|
|
1313
1294
|
);
|
|
1314
1295
|
|
|
1315
1296
|
expect(
|
|
1316
|
-
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedWriterID}`)
|
|
1297
|
+
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedWriterID}`),
|
|
1317
1298
|
).toEqual(revelation2);
|
|
1318
1299
|
});
|
|
1319
1300
|
|
|
1320
1301
|
test("Admins can create a writerInvite, which can add a writer (high-level)", async () => {
|
|
1321
|
-
const { node, group
|
|
1302
|
+
const { node, group } = newGroupHighLevel();
|
|
1322
1303
|
|
|
1323
1304
|
const inviteSecret = group.createInvite("writer");
|
|
1324
1305
|
|
|
1325
|
-
const invitedWriterSecret = newRandomAgentSecret();
|
|
1326
|
-
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1306
|
+
const invitedWriterSecret = Crypto.newRandomAgentSecret();
|
|
1307
|
+
const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
|
|
1327
1308
|
|
|
1328
1309
|
const nodeAsInvitedWriter = node.testWithDifferentAccount(
|
|
1329
|
-
new ControlledAgent(invitedWriterSecret),
|
|
1330
|
-
newRandomSessionID(invitedWriterID)
|
|
1310
|
+
new ControlledAgent(invitedWriterSecret, Crypto),
|
|
1311
|
+
newRandomSessionID(invitedWriterID),
|
|
1331
1312
|
);
|
|
1332
1313
|
|
|
1333
1314
|
await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
|
|
@@ -1342,15 +1323,15 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
|
|
|
1342
1323
|
});
|
|
1343
1324
|
|
|
1344
1325
|
test("Admins can create a readerInvite, which can add a reader", () => {
|
|
1345
|
-
const {
|
|
1326
|
+
const { groupCore, admin } = newGroup();
|
|
1346
1327
|
|
|
1347
|
-
const inviteSecret = newRandomAgentSecret();
|
|
1348
|
-
const inviteID = getAgentID(inviteSecret);
|
|
1328
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
1329
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
1349
1330
|
|
|
1350
1331
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1351
1332
|
|
|
1352
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1353
|
-
const revelation = seal({
|
|
1333
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1334
|
+
const revelation = Crypto.seal({
|
|
1354
1335
|
message: readKey,
|
|
1355
1336
|
from: admin.currentSealerSecret(),
|
|
1356
1337
|
to: admin.currentSealerID(),
|
|
@@ -1367,10 +1348,10 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1367
1348
|
|
|
1368
1349
|
expect(group.get(inviteID)).toEqual("readerInvite");
|
|
1369
1350
|
|
|
1370
|
-
const revelationForInvite = seal({
|
|
1351
|
+
const revelationForInvite = Crypto.seal({
|
|
1371
1352
|
message: readKey,
|
|
1372
1353
|
from: admin.currentSealerSecret(),
|
|
1373
|
-
to: getAgentSealerID(inviteID),
|
|
1354
|
+
to: Crypto.getAgentSealerID(inviteID),
|
|
1374
1355
|
nOnceMaterial: {
|
|
1375
1356
|
in: groupCore.id,
|
|
1376
1357
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1382,14 +1363,14 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1382
1363
|
const groupAsInvite = expectGroup(
|
|
1383
1364
|
groupCore
|
|
1384
1365
|
.testWithDifferentAccount(
|
|
1385
|
-
new ControlledAgent(inviteSecret),
|
|
1386
|
-
newRandomSessionID(inviteID)
|
|
1366
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
1367
|
+
newRandomSessionID(inviteID),
|
|
1387
1368
|
)
|
|
1388
|
-
.getCurrentContent()
|
|
1369
|
+
.getCurrentContent(),
|
|
1389
1370
|
);
|
|
1390
1371
|
|
|
1391
|
-
const invitedReaderSecret = newRandomAgentSecret();
|
|
1392
|
-
const invitedReaderID = getAgentID(invitedReaderSecret);
|
|
1372
|
+
const invitedReaderSecret = Crypto.newRandomAgentSecret();
|
|
1373
|
+
const invitedReaderID = Crypto.getAgentID(invitedReaderSecret);
|
|
1393
1374
|
|
|
1394
1375
|
groupAsInvite.set(invitedReaderID, "reader", "trusting");
|
|
1395
1376
|
|
|
@@ -1399,38 +1380,28 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1399
1380
|
|
|
1400
1381
|
expect(readKeyAsInvite.secret).toBeDefined();
|
|
1401
1382
|
|
|
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
|
-
});
|
|
1411
|
-
|
|
1412
1383
|
groupAsInvite.set(
|
|
1413
1384
|
`${readKeyAsInvite.id}_for_${invitedReaderID}`,
|
|
1414
1385
|
revelation,
|
|
1415
|
-
"trusting"
|
|
1386
|
+
"trusting",
|
|
1416
1387
|
);
|
|
1417
1388
|
|
|
1418
1389
|
expect(
|
|
1419
|
-
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedReaderID}`)
|
|
1390
|
+
groupAsInvite.get(`${readKeyAsInvite.id}_for_${invitedReaderID}`),
|
|
1420
1391
|
).toEqual(revelation);
|
|
1421
1392
|
});
|
|
1422
1393
|
|
|
1423
1394
|
test("Admins can create a readerInvite, which can add a reader (high-level)", async () => {
|
|
1424
|
-
const { node, group
|
|
1395
|
+
const { node, group } = newGroupHighLevel();
|
|
1425
1396
|
|
|
1426
1397
|
const inviteSecret = group.createInvite("reader");
|
|
1427
1398
|
|
|
1428
|
-
const invitedReaderSecret = newRandomAgentSecret();
|
|
1429
|
-
const invitedReaderID = getAgentID(invitedReaderSecret);
|
|
1399
|
+
const invitedReaderSecret = Crypto.newRandomAgentSecret();
|
|
1400
|
+
const invitedReaderID = Crypto.getAgentID(invitedReaderSecret);
|
|
1430
1401
|
|
|
1431
1402
|
const nodeAsInvitedReader = node.testWithDifferentAccount(
|
|
1432
|
-
new ControlledAgent(invitedReaderSecret),
|
|
1433
|
-
newRandomSessionID(invitedReaderID)
|
|
1403
|
+
new ControlledAgent(invitedReaderSecret, Crypto),
|
|
1404
|
+
newRandomSessionID(invitedReaderID),
|
|
1434
1405
|
);
|
|
1435
1406
|
|
|
1436
1407
|
await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
|
|
@@ -1445,15 +1416,15 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
|
|
|
1445
1416
|
});
|
|
1446
1417
|
|
|
1447
1418
|
test("WriterInvites can not invite admins", () => {
|
|
1448
|
-
const {
|
|
1419
|
+
const { groupCore, admin } = newGroup();
|
|
1449
1420
|
|
|
1450
|
-
const inviteSecret = newRandomAgentSecret();
|
|
1451
|
-
const inviteID = getAgentID(inviteSecret);
|
|
1421
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
1422
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
1452
1423
|
|
|
1453
1424
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1454
1425
|
|
|
1455
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1456
|
-
const revelation = seal({
|
|
1426
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1427
|
+
const revelation = Crypto.seal({
|
|
1457
1428
|
message: readKey,
|
|
1458
1429
|
from: admin.currentSealerSecret(),
|
|
1459
1430
|
to: admin.currentSealerID(),
|
|
@@ -1470,10 +1441,10 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1470
1441
|
|
|
1471
1442
|
expect(group.get(inviteID)).toEqual("writerInvite");
|
|
1472
1443
|
|
|
1473
|
-
const revelationForInvite = seal({
|
|
1444
|
+
const revelationForInvite = Crypto.seal({
|
|
1474
1445
|
message: readKey,
|
|
1475
1446
|
from: admin.currentSealerSecret(),
|
|
1476
|
-
to: getAgentSealerID(inviteID),
|
|
1447
|
+
to: Crypto.getAgentSealerID(inviteID),
|
|
1477
1448
|
nOnceMaterial: {
|
|
1478
1449
|
in: groupCore.id,
|
|
1479
1450
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1485,29 +1456,29 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1485
1456
|
const groupAsInvite = expectGroup(
|
|
1486
1457
|
groupCore
|
|
1487
1458
|
.testWithDifferentAccount(
|
|
1488
|
-
new ControlledAgent(inviteSecret),
|
|
1489
|
-
newRandomSessionID(inviteID)
|
|
1459
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
1460
|
+
newRandomSessionID(inviteID),
|
|
1490
1461
|
)
|
|
1491
|
-
.getCurrentContent()
|
|
1462
|
+
.getCurrentContent(),
|
|
1492
1463
|
);
|
|
1493
1464
|
|
|
1494
|
-
const invitedAdminSecret = newRandomAgentSecret();
|
|
1495
|
-
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1465
|
+
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
1466
|
+
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
1496
1467
|
|
|
1497
1468
|
groupAsInvite.set(invitedAdminID, "admin", "trusting");
|
|
1498
1469
|
expect(groupAsInvite.get(invitedAdminID)).toBeUndefined();
|
|
1499
1470
|
});
|
|
1500
1471
|
|
|
1501
1472
|
test("ReaderInvites can not invite admins", () => {
|
|
1502
|
-
const {
|
|
1473
|
+
const { groupCore, admin } = newGroup();
|
|
1503
1474
|
|
|
1504
|
-
const inviteSecret = newRandomAgentSecret();
|
|
1505
|
-
const inviteID = getAgentID(inviteSecret);
|
|
1475
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
1476
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
1506
1477
|
|
|
1507
1478
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1508
1479
|
|
|
1509
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1510
|
-
const revelation = seal({
|
|
1480
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1481
|
+
const revelation = Crypto.seal({
|
|
1511
1482
|
message: readKey,
|
|
1512
1483
|
from: admin.currentSealerSecret(),
|
|
1513
1484
|
to: admin.currentSealerID(),
|
|
@@ -1524,10 +1495,10 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1524
1495
|
|
|
1525
1496
|
expect(group.get(inviteID)).toEqual("readerInvite");
|
|
1526
1497
|
|
|
1527
|
-
const revelationForInvite = seal({
|
|
1498
|
+
const revelationForInvite = Crypto.seal({
|
|
1528
1499
|
message: readKey,
|
|
1529
1500
|
from: admin.currentSealerSecret(),
|
|
1530
|
-
to: getAgentSealerID(inviteID),
|
|
1501
|
+
to: Crypto.getAgentSealerID(inviteID),
|
|
1531
1502
|
nOnceMaterial: {
|
|
1532
1503
|
in: groupCore.id,
|
|
1533
1504
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1539,29 +1510,29 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1539
1510
|
const groupAsInvite = expectGroup(
|
|
1540
1511
|
groupCore
|
|
1541
1512
|
.testWithDifferentAccount(
|
|
1542
|
-
new ControlledAgent(inviteSecret),
|
|
1543
|
-
newRandomSessionID(inviteID)
|
|
1513
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
1514
|
+
newRandomSessionID(inviteID),
|
|
1544
1515
|
)
|
|
1545
|
-
.getCurrentContent()
|
|
1516
|
+
.getCurrentContent(),
|
|
1546
1517
|
);
|
|
1547
1518
|
|
|
1548
|
-
const invitedAdminSecret = newRandomAgentSecret();
|
|
1549
|
-
const invitedAdminID = getAgentID(invitedAdminSecret);
|
|
1519
|
+
const invitedAdminSecret = Crypto.newRandomAgentSecret();
|
|
1520
|
+
const invitedAdminID = Crypto.getAgentID(invitedAdminSecret);
|
|
1550
1521
|
|
|
1551
1522
|
groupAsInvite.set(invitedAdminID, "admin", "trusting");
|
|
1552
1523
|
expect(groupAsInvite.get(invitedAdminID)).toBeUndefined();
|
|
1553
1524
|
});
|
|
1554
1525
|
|
|
1555
1526
|
test("ReaderInvites can not invite writers", () => {
|
|
1556
|
-
const {
|
|
1527
|
+
const { groupCore, admin } = newGroup();
|
|
1557
1528
|
|
|
1558
|
-
const inviteSecret = newRandomAgentSecret();
|
|
1559
|
-
const inviteID = getAgentID(inviteSecret);
|
|
1529
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
1530
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
1560
1531
|
|
|
1561
1532
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1562
1533
|
|
|
1563
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1564
|
-
const revelation = seal({
|
|
1534
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1535
|
+
const revelation = Crypto.seal({
|
|
1565
1536
|
message: readKey,
|
|
1566
1537
|
from: admin.currentSealerSecret(),
|
|
1567
1538
|
to: admin.currentSealerID(),
|
|
@@ -1578,10 +1549,10 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1578
1549
|
|
|
1579
1550
|
expect(group.get(inviteID)).toEqual("readerInvite");
|
|
1580
1551
|
|
|
1581
|
-
const revelationForInvite = seal({
|
|
1552
|
+
const revelationForInvite = Crypto.seal({
|
|
1582
1553
|
message: readKey,
|
|
1583
1554
|
from: admin.currentSealerSecret(),
|
|
1584
|
-
to: getAgentSealerID(inviteID),
|
|
1555
|
+
to: Crypto.getAgentSealerID(inviteID),
|
|
1585
1556
|
nOnceMaterial: {
|
|
1586
1557
|
in: groupCore.id,
|
|
1587
1558
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1593,14 +1564,14 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1593
1564
|
const groupAsInvite = expectGroup(
|
|
1594
1565
|
groupCore
|
|
1595
1566
|
.testWithDifferentAccount(
|
|
1596
|
-
new ControlledAgent(inviteSecret),
|
|
1597
|
-
newRandomSessionID(inviteID)
|
|
1567
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
1568
|
+
newRandomSessionID(inviteID),
|
|
1598
1569
|
)
|
|
1599
|
-
.getCurrentContent()
|
|
1570
|
+
.getCurrentContent(),
|
|
1600
1571
|
);
|
|
1601
1572
|
|
|
1602
|
-
const invitedWriterSecret = newRandomAgentSecret();
|
|
1603
|
-
const invitedWriterID = getAgentID(invitedWriterSecret);
|
|
1573
|
+
const invitedWriterSecret = Crypto.newRandomAgentSecret();
|
|
1574
|
+
const invitedWriterID = Crypto.getAgentID(invitedWriterSecret);
|
|
1604
1575
|
|
|
1605
1576
|
groupAsInvite.set(invitedWriterID, "writer", "trusting");
|
|
1606
1577
|
expect(groupAsInvite.get(invitedWriterID)).toBeUndefined();
|
|
@@ -1613,12 +1584,12 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
1613
1584
|
type: "comap",
|
|
1614
1585
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
1615
1586
|
meta: null,
|
|
1616
|
-
...createdNowUnique(),
|
|
1587
|
+
...Crypto.createdNowUnique(),
|
|
1617
1588
|
});
|
|
1618
1589
|
|
|
1619
1590
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1620
1591
|
|
|
1621
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1592
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1622
1593
|
group.set("everyone", "reader", "trusting");
|
|
1623
1594
|
group.set("readKey", readKeyID, "trusting");
|
|
1624
1595
|
group.set(`${readKeyID}_for_everyone`, readKey, "trusting");
|
|
@@ -1630,15 +1601,18 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
1630
1601
|
childContent.set("foo", "bar", "private");
|
|
1631
1602
|
expect(childContent.get("foo")).toEqual("bar");
|
|
1632
1603
|
|
|
1633
|
-
const newAccount = new ControlledAgent(
|
|
1604
|
+
const newAccount = new ControlledAgent(
|
|
1605
|
+
Crypto.newRandomAgentSecret(),
|
|
1606
|
+
Crypto,
|
|
1607
|
+
);
|
|
1634
1608
|
|
|
1635
1609
|
const childContent2 = expectMap(
|
|
1636
1610
|
childObject
|
|
1637
1611
|
.testWithDifferentAccount(
|
|
1638
1612
|
newAccount,
|
|
1639
|
-
newRandomSessionID(newAccount.currentAgentID())
|
|
1613
|
+
newRandomSessionID(newAccount.currentAgentID()),
|
|
1640
1614
|
)
|
|
1641
|
-
.getCurrentContent()
|
|
1615
|
+
.getCurrentContent(),
|
|
1642
1616
|
);
|
|
1643
1617
|
|
|
1644
1618
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
@@ -1656,15 +1630,18 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
|
|
|
1656
1630
|
childObject.set("foo", "bar", "private");
|
|
1657
1631
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1658
1632
|
|
|
1659
|
-
const newAccount = new ControlledAgent(
|
|
1633
|
+
const newAccount = new ControlledAgent(
|
|
1634
|
+
Crypto.newRandomAgentSecret(),
|
|
1635
|
+
Crypto,
|
|
1636
|
+
);
|
|
1660
1637
|
|
|
1661
1638
|
const childContent2 = expectMap(
|
|
1662
1639
|
childObject.core
|
|
1663
1640
|
.testWithDifferentAccount(
|
|
1664
|
-
new ControlledAgent(newRandomAgentSecret()),
|
|
1665
|
-
newRandomSessionID(newAccount.currentAgentID())
|
|
1641
|
+
new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto),
|
|
1642
|
+
newRandomSessionID(newAccount.currentAgentID()),
|
|
1666
1643
|
)
|
|
1667
|
-
.getCurrentContent()
|
|
1644
|
+
.getCurrentContent(),
|
|
1668
1645
|
);
|
|
1669
1646
|
|
|
1670
1647
|
expect(childContent2.get("foo")).toEqual("bar");
|
|
@@ -1677,12 +1654,12 @@ test("Can give write permission to 'everyone'", async () => {
|
|
|
1677
1654
|
type: "comap",
|
|
1678
1655
|
ruleset: { type: "ownedByGroup", group: groupCore.id },
|
|
1679
1656
|
meta: null,
|
|
1680
|
-
...createdNowUnique(),
|
|
1657
|
+
...Crypto.createdNowUnique(),
|
|
1681
1658
|
});
|
|
1682
1659
|
|
|
1683
1660
|
const group = expectGroup(groupCore.getCurrentContent());
|
|
1684
1661
|
|
|
1685
|
-
const { secret: readKey, id: readKeyID } = newRandomKeySecret();
|
|
1662
|
+
const { secret: readKey, id: readKeyID } = Crypto.newRandomKeySecret();
|
|
1686
1663
|
group.set("everyone", "writer", "trusting");
|
|
1687
1664
|
group.set("readKey", readKeyID, "trusting");
|
|
1688
1665
|
group.set(`${readKeyID}_for_everyone`, readKey, "trusting");
|
|
@@ -1694,15 +1671,18 @@ test("Can give write permission to 'everyone'", async () => {
|
|
|
1694
1671
|
childContent.set("foo", "bar", "private");
|
|
1695
1672
|
expect(childContent.get("foo")).toEqual("bar");
|
|
1696
1673
|
|
|
1697
|
-
const newAccount = new ControlledAgent(
|
|
1674
|
+
const newAccount = new ControlledAgent(
|
|
1675
|
+
Crypto.newRandomAgentSecret(),
|
|
1676
|
+
Crypto,
|
|
1677
|
+
);
|
|
1698
1678
|
|
|
1699
1679
|
const childContent2 = expectMap(
|
|
1700
1680
|
childObject
|
|
1701
1681
|
.testWithDifferentAccount(
|
|
1702
1682
|
newAccount,
|
|
1703
|
-
newRandomSessionID(newAccount.currentAgentID())
|
|
1683
|
+
newRandomSessionID(newAccount.currentAgentID()),
|
|
1704
1684
|
)
|
|
1705
|
-
.getCurrentContent()
|
|
1685
|
+
.getCurrentContent(),
|
|
1706
1686
|
);
|
|
1707
1687
|
|
|
1708
1688
|
// TODO: resolve race condition
|
|
@@ -1726,15 +1706,18 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
1726
1706
|
childObject.set("foo", "bar", "private");
|
|
1727
1707
|
expect(childObject.get("foo")).toEqual("bar");
|
|
1728
1708
|
|
|
1729
|
-
const newAccount = new ControlledAgent(
|
|
1709
|
+
const newAccount = new ControlledAgent(
|
|
1710
|
+
Crypto.newRandomAgentSecret(),
|
|
1711
|
+
Crypto,
|
|
1712
|
+
);
|
|
1730
1713
|
|
|
1731
1714
|
const childContent2 = expectMap(
|
|
1732
1715
|
childObject.core
|
|
1733
1716
|
.testWithDifferentAccount(
|
|
1734
1717
|
newAccount,
|
|
1735
|
-
newRandomSessionID(newAccount.currentAgentID())
|
|
1718
|
+
newRandomSessionID(newAccount.currentAgentID()),
|
|
1736
1719
|
)
|
|
1737
|
-
.getCurrentContent()
|
|
1720
|
+
.getCurrentContent(),
|
|
1738
1721
|
);
|
|
1739
1722
|
|
|
1740
1723
|
expect(childContent2.get("foo")).toEqual("bar");
|