cojson 0.7.35 → 0.8.3
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/.turbo/turbo-build.log +2 -7
- package/.turbo/turbo-lint.log +4 -0
- package/CHANGELOG.md +13 -0
- package/dist/{PeerState.js → native/PeerState.js} +13 -5
- package/dist/native/PeerState.js.map +1 -0
- package/dist/native/PriorityBasedMessageQueue.js.map +1 -0
- package/dist/native/base64url.js.map +1 -0
- package/dist/native/base64url.test.js.map +1 -0
- package/dist/native/coValue.js.map +1 -0
- package/dist/{coValueCore.js → native/coValueCore.js} +0 -6
- package/dist/native/coValueCore.js.map +1 -0
- package/dist/{coValues → native/coValues}/account.js +2 -3
- package/dist/native/coValues/account.js.map +1 -0
- package/dist/native/coValues/coList.js.map +1 -0
- package/dist/native/coValues/coMap.js.map +1 -0
- package/dist/native/coValues/coStream.js.map +1 -0
- package/dist/{coValues → native/coValues}/group.js +8 -8
- package/dist/native/coValues/group.js.map +1 -0
- package/dist/native/coreToCoValue.js.map +1 -0
- package/dist/{crypto → native/crypto}/PureJSCrypto.js +4 -0
- package/dist/native/crypto/PureJSCrypto.js.map +1 -0
- package/dist/{crypto → native/crypto}/crypto.js +4 -1
- package/dist/native/crypto/crypto.js.map +1 -0
- package/dist/native/ids.js.map +1 -0
- package/dist/{index.js → native/index.native.js} +4 -6
- package/dist/native/index.native.js.map +1 -0
- package/dist/native/jsonStringify.js.map +1 -0
- package/dist/{jsonValue.js.map → native/jsonValue.js.map} +1 -1
- package/dist/{localNode.js → native/localNode.js} +44 -38
- package/dist/native/localNode.js.map +1 -0
- package/dist/native/media.js.map +1 -0
- package/dist/native/permissions.js.map +1 -0
- package/dist/native/priority.js.map +1 -0
- package/dist/native/storage/FileSystem.js.map +1 -0
- package/dist/{storage → native/storage}/chunksAndKnownStates.js +1 -1
- package/dist/native/storage/chunksAndKnownStates.js.map +1 -0
- package/dist/native/storage/index.js.map +1 -0
- package/dist/native/streamUtils.js.map +1 -0
- package/dist/native/sync.js.map +1 -0
- package/dist/native/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -0
- package/dist/native/typeUtils/expectGroup.js.map +1 -0
- package/dist/native/typeUtils/isAccountID.js.map +1 -0
- package/dist/native/typeUtils/isCoValue.js.map +1 -0
- package/dist/web/PeerState.js +66 -0
- package/dist/web/PeerState.js.map +1 -0
- package/dist/web/PriorityBasedMessageQueue.js +51 -0
- package/dist/web/PriorityBasedMessageQueue.js.map +1 -0
- package/dist/web/base64url.js +59 -0
- package/dist/web/base64url.js.map +1 -0
- package/dist/web/base64url.test.js +25 -0
- package/dist/web/base64url.test.js.map +1 -0
- package/dist/web/coValue.js +19 -0
- package/dist/web/coValue.js.map +1 -0
- package/dist/web/coValueCore.js +693 -0
- package/dist/web/coValueCore.js.map +1 -0
- package/dist/web/coValues/account.js +96 -0
- package/dist/web/coValues/account.js.map +1 -0
- package/dist/web/coValues/coList.js +393 -0
- package/dist/web/coValues/coList.js.map +1 -0
- package/dist/web/coValues/coMap.js +197 -0
- package/dist/web/coValues/coMap.js.map +1 -0
- package/dist/web/coValues/coStream.js +220 -0
- package/dist/web/coValues/coStream.js.map +1 -0
- package/dist/web/coValues/group.js +250 -0
- package/dist/web/coValues/group.js.map +1 -0
- package/dist/web/coreToCoValue.js +42 -0
- package/dist/web/coreToCoValue.js.map +1 -0
- package/dist/web/crypto/PureJSCrypto.js +93 -0
- package/dist/web/crypto/PureJSCrypto.js.map +1 -0
- package/dist/{crypto → web/crypto}/WasmCrypto.js +3 -0
- package/dist/web/crypto/WasmCrypto.js.map +1 -0
- package/dist/web/crypto/crypto.js +154 -0
- package/dist/web/crypto/crypto.js.map +1 -0
- package/dist/web/ids.js +17 -0
- package/dist/web/ids.js.map +1 -0
- package/dist/web/index.web.js +40 -0
- package/dist/web/index.web.js.map +1 -0
- package/dist/web/jsonStringify.js +57 -0
- package/dist/web/jsonStringify.js.map +1 -0
- package/dist/web/jsonValue.js +2 -0
- package/dist/web/jsonValue.js.map +1 -0
- package/dist/web/localNode.js +442 -0
- package/dist/web/localNode.js.map +1 -0
- package/dist/web/media.js +2 -0
- package/dist/web/media.js.map +1 -0
- package/dist/web/permissions.js +206 -0
- package/dist/web/permissions.js.map +1 -0
- package/dist/web/priority.js +31 -0
- package/dist/web/priority.js.map +1 -0
- package/dist/web/storage/FileSystem.js +58 -0
- package/dist/web/storage/FileSystem.js.map +1 -0
- package/dist/web/storage/chunksAndKnownStates.js +100 -0
- package/dist/web/storage/chunksAndKnownStates.js.map +1 -0
- package/dist/web/storage/index.js +348 -0
- package/dist/web/storage/index.js.map +1 -0
- package/dist/web/streamUtils.js +41 -0
- package/dist/web/streamUtils.js.map +1 -0
- package/dist/web/sync.js +504 -0
- package/dist/web/sync.js.map +1 -0
- package/dist/web/typeUtils/accountOrAgentIDfromSessionID.js +5 -0
- package/dist/web/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -0
- package/dist/web/typeUtils/expectGroup.js +13 -0
- package/dist/web/typeUtils/expectGroup.js.map +1 -0
- package/dist/web/typeUtils/isAccountID.js +4 -0
- package/dist/web/typeUtils/isAccountID.js.map +1 -0
- package/dist/web/typeUtils/isCoValue.js +11 -0
- package/dist/web/typeUtils/isCoValue.js.map +1 -0
- package/package.json +25 -8
- package/src/PeerState.ts +18 -7
- package/src/coValue.ts +1 -1
- package/src/coValueCore.ts +9 -14
- package/src/coValues/account.ts +12 -7
- package/src/coValues/coList.ts +4 -4
- package/src/coValues/coMap.ts +3 -3
- package/src/coValues/coStream.ts +8 -8
- package/src/coValues/group.ts +15 -11
- package/src/crypto/PureJSCrypto.ts +5 -0
- package/src/crypto/WasmCrypto.ts +4 -0
- package/src/crypto/crypto.ts +11 -1
- package/src/ids.ts +2 -2
- package/src/{index.ts → index.native.ts} +7 -8
- package/src/index.web.ts +152 -0
- package/src/localNode.ts +75 -67
- package/src/permissions.ts +5 -5
- package/src/storage/chunksAndKnownStates.ts +1 -1
- package/src/storage/index.ts +1 -1
- package/src/tests/account.test.ts +1 -2
- package/src/tests/coList.test.ts +1 -1
- package/src/tests/coMap.test.ts +1 -1
- package/src/tests/coStream.test.ts +2 -1
- package/src/tests/cryptoImpl.test.ts +24 -2
- package/src/tests/group.test.ts +6 -8
- package/src/tests/permissions.test.ts +90 -43
- package/src/tests/priority.test.ts +44 -15
- package/src/tests/sync.test.ts +8 -8
- package/src/tests/testUtils.ts +1 -2
- package/src/typeUtils/accountOrAgentIDfromSessionID.ts +3 -3
- package/src/typeUtils/isAccountID.ts +2 -2
- package/tsconfig.json +5 -4
- package/tsconfig.native.json +12 -0
- package/tsconfig.web.json +11 -0
- package/dist/PeerState.js.map +0 -1
- package/dist/PriorityBasedMessageQueue.js.map +0 -1
- package/dist/base64url.js.map +0 -1
- package/dist/base64url.test.js.map +0 -1
- package/dist/coValue.js.map +0 -1
- package/dist/coValueCore.js.map +0 -1
- package/dist/coValues/account.js.map +0 -1
- package/dist/coValues/coList.js.map +0 -1
- package/dist/coValues/coMap.js.map +0 -1
- package/dist/coValues/coStream.js.map +0 -1
- package/dist/coValues/group.js.map +0 -1
- package/dist/coreToCoValue.js.map +0 -1
- package/dist/crypto/PureJSCrypto.js.map +0 -1
- package/dist/crypto/WasmCrypto.js.map +0 -1
- package/dist/crypto/crypto.js.map +0 -1
- package/dist/ids.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsonStringify.js.map +0 -1
- package/dist/localNode.js.map +0 -1
- package/dist/media.js.map +0 -1
- package/dist/permissions.js.map +0 -1
- package/dist/priority.js.map +0 -1
- package/dist/storage/FileSystem.js.map +0 -1
- package/dist/storage/chunksAndKnownStates.js.map +0 -1
- package/dist/storage/index.js.map +0 -1
- package/dist/streamUtils.js.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/tests/PeerState.test.js +0 -80
- package/dist/tests/PeerState.test.js.map +0 -1
- package/dist/tests/PriorityBasedMessageQueue.test.js +0 -97
- package/dist/tests/PriorityBasedMessageQueue.test.js.map +0 -1
- package/dist/tests/account.test.js +0 -59
- package/dist/tests/account.test.js.map +0 -1
- package/dist/tests/coList.test.js +0 -76
- package/dist/tests/coList.test.js.map +0 -1
- package/dist/tests/coMap.test.js +0 -136
- package/dist/tests/coMap.test.js.map +0 -1
- package/dist/tests/coStream.test.js +0 -205
- package/dist/tests/coStream.test.js.map +0 -1
- package/dist/tests/coValueCore.test.js +0 -124
- package/dist/tests/coValueCore.test.js.map +0 -1
- package/dist/tests/crypto.test.js +0 -118
- package/dist/tests/crypto.test.js.map +0 -1
- package/dist/tests/cryptoImpl.test.js +0 -113
- package/dist/tests/cryptoImpl.test.js.map +0 -1
- package/dist/tests/group.test.js +0 -34
- package/dist/tests/group.test.js.map +0 -1
- package/dist/tests/permissions.test.js +0 -1060
- package/dist/tests/permissions.test.js.map +0 -1
- package/dist/tests/priority.test.js +0 -61
- package/dist/tests/priority.test.js.map +0 -1
- package/dist/tests/sync.test.js +0 -1187
- package/dist/tests/sync.test.js.map +0 -1
- package/dist/tests/testUtils.js +0 -60
- package/dist/tests/testUtils.js.map +0 -1
- package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +0 -1
- package/dist/typeUtils/expectGroup.js.map +0 -1
- package/dist/typeUtils/isAccountID.js.map +0 -1
- package/dist/typeUtils/isCoValue.js.map +0 -1
- /package/dist/{PriorityBasedMessageQueue.js → native/PriorityBasedMessageQueue.js} +0 -0
- /package/dist/{base64url.js → native/base64url.js} +0 -0
- /package/dist/{base64url.test.js → native/base64url.test.js} +0 -0
- /package/dist/{coValue.js → native/coValue.js} +0 -0
- /package/dist/{coValues → native/coValues}/coList.js +0 -0
- /package/dist/{coValues → native/coValues}/coMap.js +0 -0
- /package/dist/{coValues → native/coValues}/coStream.js +0 -0
- /package/dist/{coreToCoValue.js → native/coreToCoValue.js} +0 -0
- /package/dist/{ids.js → native/ids.js} +0 -0
- /package/dist/{jsonStringify.js → native/jsonStringify.js} +0 -0
- /package/dist/{jsonValue.js → native/jsonValue.js} +0 -0
- /package/dist/{media.js → native/media.js} +0 -0
- /package/dist/{permissions.js → native/permissions.js} +0 -0
- /package/dist/{priority.js → native/priority.js} +0 -0
- /package/dist/{storage → native/storage}/FileSystem.js +0 -0
- /package/dist/{storage → native/storage}/index.js +0 -0
- /package/dist/{streamUtils.js → native/streamUtils.js} +0 -0
- /package/dist/{sync.js → native/sync.js} +0 -0
- /package/dist/{typeUtils → native/typeUtils}/accountOrAgentIDfromSessionID.js +0 -0
- /package/dist/{typeUtils → native/typeUtils}/expectGroup.js +0 -0
- /package/dist/{typeUtils → native/typeUtils}/isAccountID.js +0 -0
- /package/dist/{typeUtils → native/typeUtils}/isCoValue.js +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
|
-
import { newRandomSessionID } from "../coValueCore.js";
|
|
3
2
|
import { expectMap } from "../coValue.js";
|
|
4
3
|
import {
|
|
5
4
|
newGroup,
|
|
@@ -7,8 +6,9 @@ import {
|
|
|
7
6
|
groupWithTwoAdmins,
|
|
8
7
|
groupWithTwoAdminsHighLevel,
|
|
9
8
|
} from "./testUtils.js";
|
|
10
|
-
import { ControlledAgent, WasmCrypto } from "../index.js";
|
|
11
9
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
10
|
+
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
11
|
+
import { ControlledAgent } from "../coValues/account.js";
|
|
12
12
|
|
|
13
13
|
const Crypto = await WasmCrypto.create();
|
|
14
14
|
|
|
@@ -27,7 +27,7 @@ test("Added admin can add a third admin to a group", () => {
|
|
|
27
27
|
groupCore
|
|
28
28
|
.testWithDifferentAccount(
|
|
29
29
|
otherAdmin,
|
|
30
|
-
newRandomSessionID(otherAdmin.id),
|
|
30
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
31
31
|
)
|
|
32
32
|
.getCurrentContent(),
|
|
33
33
|
);
|
|
@@ -47,7 +47,7 @@ test("Added adming can add a third admin to a group (high level)", () => {
|
|
|
47
47
|
group.core
|
|
48
48
|
.testWithDifferentAccount(
|
|
49
49
|
otherAdmin,
|
|
50
|
-
newRandomSessionID(otherAdmin.id),
|
|
50
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
51
51
|
)
|
|
52
52
|
.getCurrentContent(),
|
|
53
53
|
);
|
|
@@ -73,7 +73,7 @@ test("Admins can't demote other admins in a group", () => {
|
|
|
73
73
|
groupCore
|
|
74
74
|
.testWithDifferentAccount(
|
|
75
75
|
otherAdmin,
|
|
76
|
-
newRandomSessionID(otherAdmin.id),
|
|
76
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
77
77
|
)
|
|
78
78
|
.getCurrentContent(),
|
|
79
79
|
);
|
|
@@ -89,7 +89,7 @@ test("Admins can't demote other admins in a group (high level)", () => {
|
|
|
89
89
|
group.core
|
|
90
90
|
.testWithDifferentAccount(
|
|
91
91
|
otherAdmin,
|
|
92
|
-
newRandomSessionID(otherAdmin.id),
|
|
92
|
+
Crypto.newRandomSessionID(otherAdmin.id),
|
|
93
93
|
)
|
|
94
94
|
.getCurrentContent(),
|
|
95
95
|
);
|
|
@@ -114,7 +114,10 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
114
114
|
|
|
115
115
|
const groupAsWriter = expectGroup(
|
|
116
116
|
groupCore
|
|
117
|
-
.testWithDifferentAccount(
|
|
117
|
+
.testWithDifferentAccount(
|
|
118
|
+
writer,
|
|
119
|
+
Crypto.newRandomSessionID(writer.id),
|
|
120
|
+
)
|
|
118
121
|
.getCurrentContent(),
|
|
119
122
|
);
|
|
120
123
|
|
|
@@ -142,7 +145,10 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
|
|
|
142
145
|
|
|
143
146
|
const groupAsWriter = expectGroup(
|
|
144
147
|
group.core
|
|
145
|
-
.testWithDifferentAccount(
|
|
148
|
+
.testWithDifferentAccount(
|
|
149
|
+
writer,
|
|
150
|
+
Crypto.newRandomSessionID(writer.id),
|
|
151
|
+
)
|
|
146
152
|
.getCurrentContent(),
|
|
147
153
|
);
|
|
148
154
|
|
|
@@ -174,7 +180,10 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
174
180
|
|
|
175
181
|
const groupAsReader = expectGroup(
|
|
176
182
|
groupCore
|
|
177
|
-
.testWithDifferentAccount(
|
|
183
|
+
.testWithDifferentAccount(
|
|
184
|
+
reader,
|
|
185
|
+
Crypto.newRandomSessionID(reader.id),
|
|
186
|
+
)
|
|
178
187
|
.getCurrentContent(),
|
|
179
188
|
);
|
|
180
189
|
|
|
@@ -203,7 +212,10 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
|
|
|
203
212
|
|
|
204
213
|
const groupAsReader = expectGroup(
|
|
205
214
|
group.core
|
|
206
|
-
.testWithDifferentAccount(
|
|
215
|
+
.testWithDifferentAccount(
|
|
216
|
+
reader,
|
|
217
|
+
Crypto.newRandomSessionID(reader.id),
|
|
218
|
+
)
|
|
207
219
|
.getCurrentContent(),
|
|
208
220
|
);
|
|
209
221
|
|
|
@@ -267,7 +279,7 @@ test("Writers can write to an object that is owned by their group", () => {
|
|
|
267
279
|
|
|
268
280
|
const childObjectAsWriter = childObject.testWithDifferentAccount(
|
|
269
281
|
writer,
|
|
270
|
-
newRandomSessionID(writer.id),
|
|
282
|
+
Crypto.newRandomSessionID(writer.id),
|
|
271
283
|
);
|
|
272
284
|
|
|
273
285
|
const childContentAsWriter = expectMap(
|
|
@@ -289,7 +301,10 @@ test("Writers can write to an object that is owned by their group (high level)",
|
|
|
289
301
|
|
|
290
302
|
const childObjectAsWriter = expectMap(
|
|
291
303
|
childObject.core
|
|
292
|
-
.testWithDifferentAccount(
|
|
304
|
+
.testWithDifferentAccount(
|
|
305
|
+
writer,
|
|
306
|
+
Crypto.newRandomSessionID(writer.id),
|
|
307
|
+
)
|
|
293
308
|
.getCurrentContent(),
|
|
294
309
|
);
|
|
295
310
|
|
|
@@ -315,7 +330,7 @@ test("Readers can not write to an object that is owned by their group", () => {
|
|
|
315
330
|
|
|
316
331
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
317
332
|
reader,
|
|
318
|
-
newRandomSessionID(reader.id),
|
|
333
|
+
Crypto.newRandomSessionID(reader.id),
|
|
319
334
|
);
|
|
320
335
|
|
|
321
336
|
const childContentAsReader = expectMap(
|
|
@@ -337,7 +352,10 @@ test("Readers can not write to an object that is owned by their group (high leve
|
|
|
337
352
|
|
|
338
353
|
const childObjectAsReader = expectMap(
|
|
339
354
|
childObject.core
|
|
340
|
-
.testWithDifferentAccount(
|
|
355
|
+
.testWithDifferentAccount(
|
|
356
|
+
reader,
|
|
357
|
+
Crypto.newRandomSessionID(reader.id),
|
|
358
|
+
)
|
|
341
359
|
.getCurrentContent(),
|
|
342
360
|
);
|
|
343
361
|
|
|
@@ -442,7 +460,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
442
460
|
|
|
443
461
|
const childObjectAsWriter = childObject.testWithDifferentAccount(
|
|
444
462
|
writer,
|
|
445
|
-
newRandomSessionID(writer.id),
|
|
463
|
+
Crypto.newRandomSessionID(writer.id),
|
|
446
464
|
);
|
|
447
465
|
|
|
448
466
|
expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -466,7 +484,10 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
466
484
|
|
|
467
485
|
const childObjectAsWriter = expectMap(
|
|
468
486
|
childObject.core
|
|
469
|
-
.testWithDifferentAccount(
|
|
487
|
+
.testWithDifferentAccount(
|
|
488
|
+
writer,
|
|
489
|
+
Crypto.newRandomSessionID(writer.id),
|
|
490
|
+
)
|
|
470
491
|
.getCurrentContent(),
|
|
471
492
|
);
|
|
472
493
|
|
|
@@ -526,7 +547,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
526
547
|
|
|
527
548
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
528
549
|
reader,
|
|
529
|
-
newRandomSessionID(reader.id),
|
|
550
|
+
Crypto.newRandomSessionID(reader.id),
|
|
530
551
|
);
|
|
531
552
|
|
|
532
553
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -552,7 +573,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
552
573
|
|
|
553
574
|
const childContentAsReader = expectMap(
|
|
554
575
|
childObject.core
|
|
555
|
-
.testWithDifferentAccount(
|
|
576
|
+
.testWithDifferentAccount(
|
|
577
|
+
reader,
|
|
578
|
+
Crypto.newRandomSessionID(reader.id),
|
|
579
|
+
)
|
|
556
580
|
.getCurrentContent(),
|
|
557
581
|
);
|
|
558
582
|
|
|
@@ -613,7 +637,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
613
637
|
|
|
614
638
|
const childObjectAsReader1 = childObject.testWithDifferentAccount(
|
|
615
639
|
reader1,
|
|
616
|
-
newRandomSessionID(reader1.id),
|
|
640
|
+
Crypto.newRandomSessionID(reader1.id),
|
|
617
641
|
);
|
|
618
642
|
|
|
619
643
|
expect(childObjectAsReader1.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -638,7 +662,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
638
662
|
|
|
639
663
|
const childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
640
664
|
reader2,
|
|
641
|
-
newRandomSessionID(reader2.id),
|
|
665
|
+
Crypto.newRandomSessionID(reader2.id),
|
|
642
666
|
);
|
|
643
667
|
|
|
644
668
|
expect(childObjectAsReader2.getCurrentReadKey().secret).toEqual(readKey);
|
|
@@ -666,7 +690,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
666
690
|
|
|
667
691
|
const childContentAsReader1 = expectMap(
|
|
668
692
|
childObject.core
|
|
669
|
-
.testWithDifferentAccount(
|
|
693
|
+
.testWithDifferentAccount(
|
|
694
|
+
reader1,
|
|
695
|
+
Crypto.newRandomSessionID(reader1.id),
|
|
696
|
+
)
|
|
670
697
|
.getCurrentContent(),
|
|
671
698
|
);
|
|
672
699
|
|
|
@@ -676,7 +703,10 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
676
703
|
|
|
677
704
|
const childContentAsReader2 = expectMap(
|
|
678
705
|
childObject.core
|
|
679
|
-
.testWithDifferentAccount(
|
|
706
|
+
.testWithDifferentAccount(
|
|
707
|
+
reader2,
|
|
708
|
+
Crypto.newRandomSessionID(reader2.id),
|
|
709
|
+
)
|
|
680
710
|
.getCurrentContent(),
|
|
681
711
|
);
|
|
682
712
|
|
|
@@ -845,7 +875,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
845
875
|
|
|
846
876
|
const childObjectAsReader = childObject.testWithDifferentAccount(
|
|
847
877
|
reader,
|
|
848
|
-
newRandomSessionID(reader.id),
|
|
878
|
+
Crypto.newRandomSessionID(reader.id),
|
|
849
879
|
);
|
|
850
880
|
|
|
851
881
|
expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey2);
|
|
@@ -883,7 +913,10 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
883
913
|
|
|
884
914
|
const childContentAsReader = expectMap(
|
|
885
915
|
childObject.core
|
|
886
|
-
.testWithDifferentAccount(
|
|
916
|
+
.testWithDifferentAccount(
|
|
917
|
+
reader,
|
|
918
|
+
Crypto.newRandomSessionID(reader.id),
|
|
919
|
+
)
|
|
887
920
|
.getCurrentContent(),
|
|
888
921
|
);
|
|
889
922
|
|
|
@@ -959,7 +992,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
959
992
|
|
|
960
993
|
let childObjectAsReader = childObject.testWithDifferentAccount(
|
|
961
994
|
reader,
|
|
962
|
-
newRandomSessionID(reader.id),
|
|
995
|
+
Crypto.newRandomSessionID(reader.id),
|
|
963
996
|
);
|
|
964
997
|
|
|
965
998
|
expect(
|
|
@@ -968,7 +1001,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
968
1001
|
|
|
969
1002
|
let childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
970
1003
|
reader,
|
|
971
|
-
newRandomSessionID(reader.id),
|
|
1004
|
+
Crypto.newRandomSessionID(reader.id),
|
|
972
1005
|
);
|
|
973
1006
|
|
|
974
1007
|
expect(
|
|
@@ -1024,11 +1057,11 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1024
1057
|
// TODO: make sure these instances of coValues sync between each other so this isn't necessary?
|
|
1025
1058
|
childObjectAsReader = childObject.testWithDifferentAccount(
|
|
1026
1059
|
reader,
|
|
1027
|
-
newRandomSessionID(reader.id),
|
|
1060
|
+
Crypto.newRandomSessionID(reader.id),
|
|
1028
1061
|
);
|
|
1029
1062
|
childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
1030
1063
|
reader2,
|
|
1031
|
-
newRandomSessionID(reader2.id),
|
|
1064
|
+
Crypto.newRandomSessionID(reader2.id),
|
|
1032
1065
|
);
|
|
1033
1066
|
|
|
1034
1067
|
expect(
|
|
@@ -1072,7 +1105,10 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1072
1105
|
|
|
1073
1106
|
const childContentAsReader2 = expectMap(
|
|
1074
1107
|
childObject.core
|
|
1075
|
-
.testWithDifferentAccount(
|
|
1108
|
+
.testWithDifferentAccount(
|
|
1109
|
+
reader2,
|
|
1110
|
+
Crypto.newRandomSessionID(reader2.id),
|
|
1111
|
+
)
|
|
1076
1112
|
.getCurrentContent(),
|
|
1077
1113
|
);
|
|
1078
1114
|
|
|
@@ -1083,7 +1119,10 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
1083
1119
|
expect(
|
|
1084
1120
|
expectMap(
|
|
1085
1121
|
childObject.core
|
|
1086
|
-
.testWithDifferentAccount(
|
|
1122
|
+
.testWithDifferentAccount(
|
|
1123
|
+
reader,
|
|
1124
|
+
Crypto.newRandomSessionID(reader.id),
|
|
1125
|
+
)
|
|
1087
1126
|
.getCurrentContent(),
|
|
1088
1127
|
).get("foo3"),
|
|
1089
1128
|
).toBeUndefined();
|
|
@@ -1151,7 +1190,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1151
1190
|
groupCore
|
|
1152
1191
|
.testWithDifferentAccount(
|
|
1153
1192
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1154
|
-
newRandomSessionID(inviteID),
|
|
1193
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1155
1194
|
)
|
|
1156
1195
|
.getCurrentContent(),
|
|
1157
1196
|
);
|
|
@@ -1198,7 +1237,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
|
|
|
1198
1237
|
|
|
1199
1238
|
const nodeAsInvitedAdmin = node.testWithDifferentAccount(
|
|
1200
1239
|
new ControlledAgent(invitedAdminSecret, Crypto),
|
|
1201
|
-
newRandomSessionID(invitedAdminID),
|
|
1240
|
+
Crypto.newRandomSessionID(invitedAdminID),
|
|
1202
1241
|
);
|
|
1203
1242
|
|
|
1204
1243
|
await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
|
|
@@ -1261,7 +1300,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1261
1300
|
groupCore
|
|
1262
1301
|
.testWithDifferentAccount(
|
|
1263
1302
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1264
|
-
newRandomSessionID(inviteID),
|
|
1303
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1265
1304
|
)
|
|
1266
1305
|
.getCurrentContent(),
|
|
1267
1306
|
);
|
|
@@ -1308,7 +1347,7 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
|
|
|
1308
1347
|
|
|
1309
1348
|
const nodeAsInvitedWriter = node.testWithDifferentAccount(
|
|
1310
1349
|
new ControlledAgent(invitedWriterSecret, Crypto),
|
|
1311
|
-
newRandomSessionID(invitedWriterID),
|
|
1350
|
+
Crypto.newRandomSessionID(invitedWriterID),
|
|
1312
1351
|
);
|
|
1313
1352
|
|
|
1314
1353
|
await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
|
|
@@ -1364,7 +1403,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1364
1403
|
groupCore
|
|
1365
1404
|
.testWithDifferentAccount(
|
|
1366
1405
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1367
|
-
newRandomSessionID(inviteID),
|
|
1406
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1368
1407
|
)
|
|
1369
1408
|
.getCurrentContent(),
|
|
1370
1409
|
);
|
|
@@ -1401,7 +1440,7 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
|
|
|
1401
1440
|
|
|
1402
1441
|
const nodeAsInvitedReader = node.testWithDifferentAccount(
|
|
1403
1442
|
new ControlledAgent(invitedReaderSecret, Crypto),
|
|
1404
|
-
newRandomSessionID(invitedReaderID),
|
|
1443
|
+
Crypto.newRandomSessionID(invitedReaderID),
|
|
1405
1444
|
);
|
|
1406
1445
|
|
|
1407
1446
|
await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
|
|
@@ -1457,7 +1496,7 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1457
1496
|
groupCore
|
|
1458
1497
|
.testWithDifferentAccount(
|
|
1459
1498
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1460
|
-
newRandomSessionID(inviteID),
|
|
1499
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1461
1500
|
)
|
|
1462
1501
|
.getCurrentContent(),
|
|
1463
1502
|
);
|
|
@@ -1511,7 +1550,7 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1511
1550
|
groupCore
|
|
1512
1551
|
.testWithDifferentAccount(
|
|
1513
1552
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1514
|
-
newRandomSessionID(inviteID),
|
|
1553
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1515
1554
|
)
|
|
1516
1555
|
.getCurrentContent(),
|
|
1517
1556
|
);
|
|
@@ -1565,7 +1604,7 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1565
1604
|
groupCore
|
|
1566
1605
|
.testWithDifferentAccount(
|
|
1567
1606
|
new ControlledAgent(inviteSecret, Crypto),
|
|
1568
|
-
newRandomSessionID(inviteID),
|
|
1607
|
+
Crypto.newRandomSessionID(inviteID),
|
|
1569
1608
|
)
|
|
1570
1609
|
.getCurrentContent(),
|
|
1571
1610
|
);
|
|
@@ -1610,7 +1649,9 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
1610
1649
|
childObject
|
|
1611
1650
|
.testWithDifferentAccount(
|
|
1612
1651
|
newAccount,
|
|
1613
|
-
newRandomSessionID(
|
|
1652
|
+
Crypto.newRandomSessionID(
|
|
1653
|
+
newAccount.currentAgentID()._unsafeUnwrap(),
|
|
1654
|
+
),
|
|
1614
1655
|
)
|
|
1615
1656
|
.getCurrentContent(),
|
|
1616
1657
|
);
|
|
@@ -1639,7 +1680,9 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
|
|
|
1639
1680
|
childObject.core
|
|
1640
1681
|
.testWithDifferentAccount(
|
|
1641
1682
|
new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto),
|
|
1642
|
-
newRandomSessionID(
|
|
1683
|
+
Crypto.newRandomSessionID(
|
|
1684
|
+
newAccount.currentAgentID()._unsafeUnwrap(),
|
|
1685
|
+
),
|
|
1643
1686
|
)
|
|
1644
1687
|
.getCurrentContent(),
|
|
1645
1688
|
);
|
|
@@ -1680,7 +1723,9 @@ test("Can give write permission to 'everyone'", async () => {
|
|
|
1680
1723
|
childObject
|
|
1681
1724
|
.testWithDifferentAccount(
|
|
1682
1725
|
newAccount,
|
|
1683
|
-
newRandomSessionID(
|
|
1726
|
+
Crypto.newRandomSessionID(
|
|
1727
|
+
newAccount.currentAgentID()._unsafeUnwrap(),
|
|
1728
|
+
),
|
|
1684
1729
|
)
|
|
1685
1730
|
.getCurrentContent(),
|
|
1686
1731
|
);
|
|
@@ -1715,7 +1760,9 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
1715
1760
|
childObject.core
|
|
1716
1761
|
.testWithDifferentAccount(
|
|
1717
1762
|
newAccount,
|
|
1718
|
-
newRandomSessionID(
|
|
1763
|
+
Crypto.newRandomSessionID(
|
|
1764
|
+
newAccount.currentAgentID()._unsafeUnwrap(),
|
|
1765
|
+
),
|
|
1719
1766
|
)
|
|
1720
1767
|
.getCurrentContent(),
|
|
1721
1768
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { expect, test, describe } from "vitest";
|
|
2
|
-
import { WasmCrypto } from "../index.js";
|
|
3
2
|
import { LocalNode } from "../localNode.js";
|
|
4
3
|
import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
|
|
5
4
|
import { getPriorityFromHeader, CO_VALUE_PRIORITY } from "../priority.js";
|
|
5
|
+
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
6
6
|
|
|
7
7
|
const Crypto = await WasmCrypto.create();
|
|
8
8
|
|
|
@@ -10,11 +10,16 @@ describe("getPriorityFromHeader", () => {
|
|
|
10
10
|
test("returns MEDIUM priority for boolean or undefined headers", () => {
|
|
11
11
|
expect(getPriorityFromHeader(true)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
|
|
12
12
|
expect(getPriorityFromHeader(false)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
|
|
13
|
-
expect(getPriorityFromHeader(undefined)).toEqual(
|
|
13
|
+
expect(getPriorityFromHeader(undefined)).toEqual(
|
|
14
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
15
|
+
);
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
test("returns MEDIUM priority for costream type", () => {
|
|
17
|
-
const node = new LocalNode(
|
|
19
|
+
const node = new LocalNode(
|
|
20
|
+
...randomAnonymousAccountAndSessionID(),
|
|
21
|
+
Crypto,
|
|
22
|
+
);
|
|
18
23
|
const costream = node.createCoValue({
|
|
19
24
|
type: "costream",
|
|
20
25
|
ruleset: { type: "unsafeAllowAll" },
|
|
@@ -22,11 +27,16 @@ describe("getPriorityFromHeader", () => {
|
|
|
22
27
|
...Crypto.createdNowUnique(),
|
|
23
28
|
});
|
|
24
29
|
|
|
25
|
-
expect(getPriorityFromHeader(costream.header)).toEqual(
|
|
30
|
+
expect(getPriorityFromHeader(costream.header)).toEqual(
|
|
31
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
32
|
+
);
|
|
26
33
|
});
|
|
27
34
|
|
|
28
35
|
test("returns LOW priority for binary costream type", () => {
|
|
29
|
-
const node = new LocalNode(
|
|
36
|
+
const node = new LocalNode(
|
|
37
|
+
...randomAnonymousAccountAndSessionID(),
|
|
38
|
+
Crypto,
|
|
39
|
+
);
|
|
30
40
|
const costream = node.createCoValue({
|
|
31
41
|
type: "costream",
|
|
32
42
|
ruleset: { type: "unsafeAllowAll" },
|
|
@@ -34,27 +44,42 @@ describe("getPriorityFromHeader", () => {
|
|
|
34
44
|
...Crypto.createdNowUnique(),
|
|
35
45
|
});
|
|
36
46
|
|
|
37
|
-
expect(getPriorityFromHeader(costream.header)).toEqual(
|
|
47
|
+
expect(getPriorityFromHeader(costream.header)).toEqual(
|
|
48
|
+
CO_VALUE_PRIORITY.LOW,
|
|
49
|
+
);
|
|
38
50
|
});
|
|
39
51
|
|
|
40
52
|
test("returns HIGH priority for account type", async () => {
|
|
41
|
-
const node =new LocalNode(
|
|
53
|
+
const node = new LocalNode(
|
|
54
|
+
...randomAnonymousAccountAndSessionID(),
|
|
55
|
+
Crypto,
|
|
56
|
+
);
|
|
42
57
|
|
|
43
58
|
const account = node.createAccount(node.crypto.newRandomAgentSecret());
|
|
44
59
|
|
|
45
|
-
expect(getPriorityFromHeader(account.core.header)).toEqual(
|
|
60
|
+
expect(getPriorityFromHeader(account.core.header)).toEqual(
|
|
61
|
+
CO_VALUE_PRIORITY.HIGH,
|
|
62
|
+
);
|
|
46
63
|
});
|
|
47
64
|
|
|
48
65
|
test("returns HIGH priority for group type", () => {
|
|
49
|
-
const node = new LocalNode(
|
|
66
|
+
const node = new LocalNode(
|
|
67
|
+
...randomAnonymousAccountAndSessionID(),
|
|
68
|
+
Crypto,
|
|
69
|
+
);
|
|
50
70
|
const group = node.createGroup();
|
|
51
71
|
|
|
52
|
-
expect(getPriorityFromHeader(group.core.header)).toEqual(
|
|
72
|
+
expect(getPriorityFromHeader(group.core.header)).toEqual(
|
|
73
|
+
CO_VALUE_PRIORITY.HIGH,
|
|
74
|
+
);
|
|
53
75
|
});
|
|
54
76
|
|
|
55
77
|
test("returns MEDIUM priority for other types", () => {
|
|
56
|
-
const node = new LocalNode(
|
|
57
|
-
|
|
78
|
+
const node = new LocalNode(
|
|
79
|
+
...randomAnonymousAccountAndSessionID(),
|
|
80
|
+
Crypto,
|
|
81
|
+
);
|
|
82
|
+
|
|
58
83
|
const comap = node.createCoValue({
|
|
59
84
|
type: "comap",
|
|
60
85
|
ruleset: { type: "unsafeAllowAll" },
|
|
@@ -69,7 +94,11 @@ describe("getPriorityFromHeader", () => {
|
|
|
69
94
|
...Crypto.createdNowUnique(),
|
|
70
95
|
});
|
|
71
96
|
|
|
72
|
-
expect(getPriorityFromHeader(comap.header)).toEqual(
|
|
73
|
-
|
|
97
|
+
expect(getPriorityFromHeader(comap.header)).toEqual(
|
|
98
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
99
|
+
);
|
|
100
|
+
expect(getPriorityFromHeader(colist.header)).toEqual(
|
|
101
|
+
CO_VALUE_PRIORITY.MEDIUM,
|
|
102
|
+
);
|
|
74
103
|
});
|
|
75
|
-
});
|
|
104
|
+
});
|
package/src/tests/sync.test.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { MapOpPayload, RawCoMap } from "../coValues/coMap.js";
|
|
|
5
5
|
import { RawGroup } from "../coValues/group.js";
|
|
6
6
|
import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
|
|
7
7
|
import { connectedPeers, newQueuePair } from "../streamUtils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { RawAccountID } from "../coValues/account.js";
|
|
9
9
|
import { stableStringify } from "../jsonStringify.js";
|
|
10
10
|
import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
11
11
|
import { expectMap } from "../coValue.js";
|
|
12
|
-
import { CoValueHeader
|
|
12
|
+
import { CoValueHeader } from "../coValueCore.js";
|
|
13
13
|
import { getPriorityFromHeader } from "../priority.js";
|
|
14
14
|
|
|
15
15
|
const Crypto = await WasmCrypto.create();
|
|
@@ -726,7 +726,7 @@ test.skip("When replaying creation and transactions of a coValue as new content,
|
|
|
726
726
|
crashOnClose: true,
|
|
727
727
|
});
|
|
728
728
|
|
|
729
|
-
const node2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
729
|
+
const node2 = new LocalNode(admin, Crypto.newRandomSessionID(admin.id), Crypto);
|
|
730
730
|
|
|
731
731
|
const [inRx2, inTx2] = newQueuePair();
|
|
732
732
|
const [outRx2, outTx2] = newQueuePair();
|
|
@@ -878,7 +878,7 @@ test("Can sync a coValue through a server to another client", async () => {
|
|
|
878
878
|
client1.syncManager.addPeer(serverAsPeerForClient1);
|
|
879
879
|
server.syncManager.addPeer(client1AsPeer);
|
|
880
880
|
|
|
881
|
-
const client2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
881
|
+
const client2 = new LocalNode(admin, Crypto.newRandomSessionID(admin.id), Crypto);
|
|
882
882
|
|
|
883
883
|
const [serverAsPeerForClient2, client2AsPeer] = connectedPeers(
|
|
884
884
|
"serverFor2",
|
|
@@ -926,7 +926,7 @@ test("Can sync a coValue with private transactions through a server to another c
|
|
|
926
926
|
client1.syncManager.addPeer(serverAsPeer);
|
|
927
927
|
server.syncManager.addPeer(client1AsPeer);
|
|
928
928
|
|
|
929
|
-
const client2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
929
|
+
const client2 = new LocalNode(admin, client1.crypto.newRandomSessionID(admin.id), Crypto);
|
|
930
930
|
|
|
931
931
|
const [serverAsOtherPeer, client2AsPeer] = connectedPeers(
|
|
932
932
|
"server",
|
|
@@ -1074,7 +1074,7 @@ test("If we start loading a coValue before connecting to a peer that has it, it
|
|
|
1074
1074
|
const map = group.createMap();
|
|
1075
1075
|
map.set("hello", "world", "trusting");
|
|
1076
1076
|
|
|
1077
|
-
const node2 = new LocalNode(admin, newRandomSessionID(admin.id), Crypto);
|
|
1077
|
+
const node2 = new LocalNode(admin, Crypto.newRandomSessionID(admin.id), Crypto);
|
|
1078
1078
|
|
|
1079
1079
|
const [node1asPeer, node2asPeer] = connectedPeers("peer1", "peer2", {
|
|
1080
1080
|
peer1role: "server",
|
|
@@ -1559,7 +1559,7 @@ function groupContentEx(group: RawGroup) {
|
|
|
1559
1559
|
};
|
|
1560
1560
|
}
|
|
1561
1561
|
|
|
1562
|
-
function _admContEx(adminID:
|
|
1562
|
+
function _admContEx(adminID: RawAccountID) {
|
|
1563
1563
|
return {
|
|
1564
1564
|
action: "content",
|
|
1565
1565
|
id: adminID,
|
|
@@ -1573,7 +1573,7 @@ function groupStateEx(group: RawGroup) {
|
|
|
1573
1573
|
};
|
|
1574
1574
|
}
|
|
1575
1575
|
|
|
1576
|
-
function _admStateEx(adminID:
|
|
1576
|
+
function _admStateEx(adminID: RawAccountID) {
|
|
1577
1577
|
return {
|
|
1578
1578
|
action: "known",
|
|
1579
1579
|
id: adminID,
|
package/src/tests/testUtils.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect } from "vitest";
|
|
2
|
-
import { newRandomSessionID } from "../coValueCore.js";
|
|
3
2
|
import { LocalNode } from "../localNode.js";
|
|
4
3
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
5
4
|
import { ControlledAgent } from "../coValues/account.js";
|
|
@@ -14,7 +13,7 @@ export function randomAnonymousAccountAndSessionID(): [
|
|
|
14
13
|
] {
|
|
15
14
|
const agentSecret = Crypto.newRandomAgentSecret();
|
|
16
15
|
|
|
17
|
-
const sessionID = newRandomSessionID(Crypto.getAgentID(agentSecret));
|
|
16
|
+
const sessionID = Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret));
|
|
18
17
|
|
|
19
18
|
return [new ControlledAgent(agentSecret, Crypto), sessionID];
|
|
20
19
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AgentID, SessionID } from "../ids.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RawAccountID } from "../coValues/account.js";
|
|
3
3
|
|
|
4
4
|
export function accountOrAgentIDfromSessionID(
|
|
5
5
|
sessionID: SessionID,
|
|
6
|
-
):
|
|
6
|
+
): RawAccountID | AgentID {
|
|
7
7
|
const until = sessionID.indexOf("_session");
|
|
8
|
-
return sessionID.slice(0, until) as
|
|
8
|
+
return sessionID.slice(0, until) as RawAccountID | AgentID;
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawAccountID } from "../coValues/account.js";
|
|
2
2
|
import type { AgentID } from "../ids.js";
|
|
3
3
|
|
|
4
|
-
export function isAccountID(id:
|
|
4
|
+
export function isAccountID(id: RawAccountID | AgentID): id is RawAccountID {
|
|
5
5
|
return id.startsWith("co_");
|
|
6
6
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
3
|
+
"lib": [
|
|
4
|
+
"ESNext"
|
|
5
|
+
],
|
|
4
6
|
"module": "esnext",
|
|
5
7
|
"target": "ES2020",
|
|
6
8
|
"moduleResolution": "bundler",
|
|
@@ -9,7 +11,6 @@
|
|
|
9
11
|
"skipLibCheck": true,
|
|
10
12
|
"forceConsistentCasingInFileNames": true,
|
|
11
13
|
"noUncheckedIndexedAccess": true,
|
|
12
|
-
"esModuleInterop": true
|
|
14
|
+
"esModuleInterop": true,
|
|
13
15
|
},
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
+
}
|