cojson 0.10.8 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +20 -0
- package/dist/CoValuesStore.d.ts +12 -0
- package/dist/CoValuesStore.d.ts.map +1 -0
- package/dist/PeerKnownStates.d.ts +38 -0
- package/dist/PeerKnownStates.d.ts.map +1 -0
- package/dist/PeerState.d.ts +46 -0
- package/dist/PeerState.d.ts.map +1 -0
- package/dist/PriorityBasedMessageQueue.d.ts +18 -0
- package/dist/PriorityBasedMessageQueue.d.ts.map +1 -0
- package/dist/SyncStateManager.d.ts +20 -0
- package/dist/SyncStateManager.d.ts.map +1 -0
- package/dist/base64url.d.ts +3 -0
- package/dist/base64url.d.ts.map +1 -0
- package/dist/base64url.test.d.ts +2 -0
- package/dist/base64url.test.d.ts.map +1 -0
- package/dist/coValue.d.ts +52 -0
- package/dist/coValue.d.ts.map +1 -0
- package/dist/coValueCore.d.ts +143 -0
- package/dist/coValueCore.d.ts.map +1 -0
- package/dist/coValueCore.js +3 -9
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValueState.d.ts +58 -0
- package/dist/coValueState.d.ts.map +1 -0
- package/dist/coValues/account.d.ts +69 -0
- package/dist/coValues/account.d.ts.map +1 -0
- package/dist/coValues/account.js +9 -10
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.d.ts +163 -0
- package/dist/coValues/coList.d.ts.map +1 -0
- package/dist/coValues/coMap.d.ts +142 -0
- package/dist/coValues/coMap.d.ts.map +1 -0
- package/dist/coValues/coPlainText.d.ts +33 -0
- package/dist/coValues/coPlainText.d.ts.map +1 -0
- package/dist/coValues/coStream.d.ts +109 -0
- package/dist/coValues/coStream.d.ts.map +1 -0
- package/dist/coValues/group.d.ts +143 -0
- package/dist/coValues/group.d.ts.map +1 -0
- package/dist/coValues/group.js +52 -6
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.d.ts +15 -0
- package/dist/coreToCoValue.d.ts.map +1 -0
- package/dist/crypto/PureJSCrypto.d.ts +50 -0
- package/dist/crypto/PureJSCrypto.d.ts.map +1 -0
- package/dist/crypto/WasmCrypto.d.ts +49 -0
- package/dist/crypto/WasmCrypto.d.ts.map +1 -0
- package/dist/crypto/crypto.d.ts +142 -0
- package/dist/crypto/crypto.d.ts.map +1 -0
- package/dist/exports.d.ts +84 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/ids.d.ts +23 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/jsonStringify.d.ts +7 -0
- package/dist/jsonStringify.d.ts.map +1 -0
- package/dist/jsonValue.d.ts +45 -0
- package/dist/jsonValue.d.ts.map +1 -0
- package/dist/localNode.d.ts +111 -0
- package/dist/localNode.d.ts.map +1 -0
- package/dist/localNode.js +3 -5
- package/dist/localNode.js.map +1 -1
- package/dist/logger.d.ts +33 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/permissions.d.ts +24 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +5 -9
- package/dist/permissions.js.map +1 -1
- package/dist/priority.d.ts +19 -0
- package/dist/priority.d.ts.map +1 -0
- package/dist/storage/FileSystem.d.ts +37 -0
- package/dist/storage/FileSystem.d.ts.map +1 -0
- package/dist/storage/chunksAndKnownStates.d.ts +7 -0
- package/dist/storage/chunksAndKnownStates.d.ts.map +1 -0
- package/dist/storage/index.d.ts +52 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/streamUtils.d.ts +13 -0
- package/dist/streamUtils.d.ts.map +1 -0
- package/dist/sync.d.ts +97 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/tests/PeerKnownStates.test.d.ts +2 -0
- package/dist/tests/PeerKnownStates.test.d.ts.map +1 -0
- package/dist/tests/PeerKnownStates.test.js +82 -0
- package/dist/tests/PeerKnownStates.test.js.map +1 -0
- package/dist/tests/PeerState.test.d.ts +2 -0
- package/dist/tests/PeerState.test.d.ts.map +1 -0
- package/dist/tests/PeerState.test.js +188 -0
- package/dist/tests/PeerState.test.js.map +1 -0
- package/dist/tests/PriorityBasedMessageQueue.test.d.ts +2 -0
- package/dist/tests/PriorityBasedMessageQueue.test.d.ts.map +1 -0
- package/dist/tests/PriorityBasedMessageQueue.test.js +120 -0
- package/dist/tests/PriorityBasedMessageQueue.test.js.map +1 -0
- package/dist/tests/SyncStateManager.test.d.ts +2 -0
- package/dist/tests/SyncStateManager.test.d.ts.map +1 -0
- package/dist/tests/SyncStateManager.test.js +127 -0
- package/dist/tests/SyncStateManager.test.js.map +1 -0
- package/dist/tests/account.test.d.ts +2 -0
- package/dist/tests/account.test.d.ts.map +1 -0
- package/dist/tests/account.test.js +66 -0
- package/dist/tests/account.test.js.map +1 -0
- package/dist/tests/coList.test.d.ts +2 -0
- package/dist/tests/coList.test.d.ts.map +1 -0
- package/dist/tests/coList.test.js +120 -0
- package/dist/tests/coList.test.js.map +1 -0
- package/dist/tests/coMap.test.d.ts +2 -0
- package/dist/tests/coMap.test.d.ts.map +1 -0
- package/dist/tests/coMap.test.js +164 -0
- package/dist/tests/coMap.test.js.map +1 -0
- package/dist/tests/coPlainText.test.d.ts +2 -0
- package/dist/tests/coPlainText.test.d.ts.map +1 -0
- package/dist/tests/coPlainText.test.js +99 -0
- package/dist/tests/coPlainText.test.js.map +1 -0
- package/dist/tests/coStream.test.d.ts +2 -0
- package/dist/tests/coStream.test.d.ts.map +1 -0
- package/dist/tests/coStream.test.js +206 -0
- package/dist/tests/coStream.test.js.map +1 -0
- package/dist/tests/coValueCore.test.d.ts +2 -0
- package/dist/tests/coValueCore.test.d.ts.map +1 -0
- package/dist/tests/coValueCore.test.js +164 -0
- package/dist/tests/coValueCore.test.js.map +1 -0
- package/dist/tests/coValueState.test.d.ts +2 -0
- package/dist/tests/coValueState.test.d.ts.map +1 -0
- package/dist/tests/coValueState.test.js +364 -0
- package/dist/tests/coValueState.test.js.map +1 -0
- package/dist/tests/crypto.test.d.ts +2 -0
- package/dist/tests/crypto.test.d.ts.map +1 -0
- package/dist/tests/crypto.test.js +144 -0
- package/dist/tests/crypto.test.js.map +1 -0
- package/dist/tests/cryptoImpl.test.d.ts +2 -0
- package/dist/tests/cryptoImpl.test.d.ts.map +1 -0
- package/dist/tests/cryptoImpl.test.js +144 -0
- package/dist/tests/cryptoImpl.test.js.map +1 -0
- package/dist/tests/group.test.d.ts +2 -0
- package/dist/tests/group.test.d.ts.map +1 -0
- package/dist/tests/group.test.js +576 -0
- package/dist/tests/group.test.js.map +1 -0
- package/dist/tests/logger.test.d.ts +2 -0
- package/dist/tests/logger.test.d.ts.map +1 -0
- package/dist/tests/logger.test.js +118 -0
- package/dist/tests/logger.test.js.map +1 -0
- package/dist/tests/permissions.test.d.ts +2 -0
- package/dist/tests/permissions.test.d.ts.map +1 -0
- package/dist/tests/permissions.test.js +2051 -0
- package/dist/tests/permissions.test.js.map +1 -0
- package/dist/tests/priority.test.d.ts +2 -0
- package/dist/tests/priority.test.d.ts.map +1 -0
- package/dist/tests/priority.test.js +61 -0
- package/dist/tests/priority.test.js.map +1 -0
- package/dist/tests/sync.test.d.ts +2 -0
- package/dist/tests/sync.test.d.ts.map +1 -0
- package/dist/tests/sync.test.js +1548 -0
- package/dist/tests/sync.test.js.map +1 -0
- package/dist/tests/testUtils.d.ts +142 -0
- package/dist/tests/testUtils.d.ts.map +1 -0
- package/dist/tests/testUtils.js +315 -0
- package/dist/tests/testUtils.js.map +1 -0
- package/dist/typeUtils/accountOrAgentIDfromSessionID.d.ts +4 -0
- package/dist/typeUtils/accountOrAgentIDfromSessionID.d.ts.map +1 -0
- package/dist/typeUtils/expectGroup.d.ts +4 -0
- package/dist/typeUtils/expectGroup.d.ts.map +1 -0
- package/dist/typeUtils/isAccountID.d.ts +4 -0
- package/dist/typeUtils/isAccountID.d.ts.map +1 -0
- package/dist/typeUtils/isCoValue.d.ts +4 -0
- package/dist/typeUtils/isCoValue.d.ts.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/coValueCore.ts +3 -9
- package/src/coValues/account.ts +15 -15
- package/src/coValues/group.ts +85 -12
- package/src/jsonValue.ts +9 -5
- package/src/localNode.ts +3 -5
- package/src/permissions.ts +5 -15
- package/src/tests/coValueCore.test.ts +2 -2
- package/src/tests/group.test.ts +187 -0
- package/src/tests/permissions.test.ts +330 -57
- package/src/tests/testUtils.ts +4 -1
- package/tsconfig.json +4 -2
|
@@ -5,6 +5,7 @@ import { WasmCrypto } from "../crypto/WasmCrypto.js";
|
|
|
5
5
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
6
6
|
import {
|
|
7
7
|
connectTwoPeers,
|
|
8
|
+
createThreeConnectedNodes,
|
|
8
9
|
createTwoConnectedNodes,
|
|
9
10
|
groupWithTwoAdmins,
|
|
10
11
|
groupWithTwoAdminsHighLevel,
|
|
@@ -358,7 +359,7 @@ test("Admins can set group read key and then use it to create and read private t
|
|
|
358
359
|
const revelation = Crypto.seal({
|
|
359
360
|
message: readKey,
|
|
360
361
|
from: admin.currentSealerSecret(),
|
|
361
|
-
to: admin.currentSealerID()
|
|
362
|
+
to: admin.currentSealerID(),
|
|
362
363
|
nOnceMaterial: {
|
|
363
364
|
in: groupCore.id,
|
|
364
365
|
tx: groupCore.nextTransactionID(),
|
|
@@ -412,7 +413,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
412
413
|
const revelation1 = Crypto.seal({
|
|
413
414
|
message: readKey,
|
|
414
415
|
from: admin.currentSealerSecret(),
|
|
415
|
-
to: admin.currentSealerID()
|
|
416
|
+
to: admin.currentSealerID(),
|
|
416
417
|
nOnceMaterial: {
|
|
417
418
|
in: groupCore.id,
|
|
418
419
|
tx: groupCore.nextTransactionID(),
|
|
@@ -424,7 +425,7 @@ test("Admins can set group read key and then writers can use it to create and re
|
|
|
424
425
|
const revelation2 = Crypto.seal({
|
|
425
426
|
message: readKey,
|
|
426
427
|
from: admin.currentSealerSecret(),
|
|
427
|
-
to: writer.currentSealerID()
|
|
428
|
+
to: writer.currentSealerID(),
|
|
428
429
|
nOnceMaterial: {
|
|
429
430
|
in: groupCore.id,
|
|
430
431
|
tx: groupCore.nextTransactionID(),
|
|
@@ -491,7 +492,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
491
492
|
const revelation1 = Crypto.seal({
|
|
492
493
|
message: readKey,
|
|
493
494
|
from: admin.currentSealerSecret(),
|
|
494
|
-
to: admin.currentSealerID()
|
|
495
|
+
to: admin.currentSealerID(),
|
|
495
496
|
nOnceMaterial: {
|
|
496
497
|
in: groupCore.id,
|
|
497
498
|
tx: groupCore.nextTransactionID(),
|
|
@@ -503,7 +504,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
503
504
|
const revelation2 = Crypto.seal({
|
|
504
505
|
message: readKey,
|
|
505
506
|
from: admin.currentSealerSecret(),
|
|
506
|
-
to: reader.currentSealerID()
|
|
507
|
+
to: reader.currentSealerID(),
|
|
507
508
|
nOnceMaterial: {
|
|
508
509
|
in: groupCore.id,
|
|
509
510
|
tx: groupCore.nextTransactionID(),
|
|
@@ -578,7 +579,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
578
579
|
const revelation1 = Crypto.seal({
|
|
579
580
|
message: readKey,
|
|
580
581
|
from: admin.currentSealerSecret(),
|
|
581
|
-
to: admin.currentSealerID()
|
|
582
|
+
to: admin.currentSealerID(),
|
|
582
583
|
nOnceMaterial: {
|
|
583
584
|
in: groupCore.id,
|
|
584
585
|
tx: groupCore.nextTransactionID(),
|
|
@@ -590,7 +591,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
590
591
|
const revelation2 = Crypto.seal({
|
|
591
592
|
message: readKey,
|
|
592
593
|
from: admin.currentSealerSecret(),
|
|
593
|
-
to: reader1.currentSealerID()
|
|
594
|
+
to: reader1.currentSealerID(),
|
|
594
595
|
nOnceMaterial: {
|
|
595
596
|
in: groupCore.id,
|
|
596
597
|
tx: groupCore.nextTransactionID(),
|
|
@@ -629,7 +630,7 @@ test("Admins can set group read key and then use it to create private transactio
|
|
|
629
630
|
const revelation3 = Crypto.seal({
|
|
630
631
|
message: readKey,
|
|
631
632
|
from: admin.currentSealerSecret(),
|
|
632
|
-
to: reader2.currentSealerID()
|
|
633
|
+
to: reader2.currentSealerID(),
|
|
633
634
|
nOnceMaterial: {
|
|
634
635
|
in: groupCore.id,
|
|
635
636
|
tx: groupCore.nextTransactionID(),
|
|
@@ -694,7 +695,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
694
695
|
const revelation1 = Crypto.seal({
|
|
695
696
|
message: readKey,
|
|
696
697
|
from: admin.currentSealerSecret(),
|
|
697
|
-
to: admin.currentSealerID()
|
|
698
|
+
to: admin.currentSealerID(),
|
|
698
699
|
nOnceMaterial: {
|
|
699
700
|
in: groupCore.id,
|
|
700
701
|
tx: groupCore.nextTransactionID(),
|
|
@@ -724,7 +725,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
724
725
|
const revelation2 = Crypto.seal({
|
|
725
726
|
message: readKey2,
|
|
726
727
|
from: admin.currentSealerSecret(),
|
|
727
|
-
to: admin.currentSealerID()
|
|
728
|
+
to: admin.currentSealerID(),
|
|
728
729
|
nOnceMaterial: {
|
|
729
730
|
in: groupCore.id,
|
|
730
731
|
tx: groupCore.nextTransactionID(),
|
|
@@ -777,7 +778,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
777
778
|
const revelation = Crypto.seal({
|
|
778
779
|
message: readKey,
|
|
779
780
|
from: admin.currentSealerSecret(),
|
|
780
|
-
to: admin.currentSealerID()
|
|
781
|
+
to: admin.currentSealerID(),
|
|
781
782
|
nOnceMaterial: {
|
|
782
783
|
in: groupCore.id,
|
|
783
784
|
tx: groupCore.nextTransactionID(),
|
|
@@ -804,7 +805,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
804
805
|
const revelation2 = Crypto.seal({
|
|
805
806
|
message: readKey2,
|
|
806
807
|
from: admin.currentSealerSecret(),
|
|
807
|
-
to: admin.currentSealerID()
|
|
808
|
+
to: admin.currentSealerID(),
|
|
808
809
|
nOnceMaterial: {
|
|
809
810
|
in: groupCore.id,
|
|
810
811
|
tx: groupCore.nextTransactionID(),
|
|
@@ -816,7 +817,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
816
817
|
const revelation3 = Crypto.seal({
|
|
817
818
|
message: readKey2,
|
|
818
819
|
from: admin.currentSealerSecret(),
|
|
819
|
-
to: reader.currentSealerID()
|
|
820
|
+
to: reader.currentSealerID(),
|
|
820
821
|
nOnceMaterial: {
|
|
821
822
|
in: groupCore.id,
|
|
822
823
|
tx: groupCore.nextTransactionID(),
|
|
@@ -893,6 +894,26 @@ test("Admins can set group read key, make a private transaction in an owned obje
|
|
|
893
894
|
expect(childContentAsReader.get("foo2")).toEqual("bar2");
|
|
894
895
|
});
|
|
895
896
|
|
|
897
|
+
test("only admins can add agent ids", () => {
|
|
898
|
+
const { groupCore } = newGroup();
|
|
899
|
+
|
|
900
|
+
const inviteSecret = Crypto.newRandomAgentSecret();
|
|
901
|
+
const inviteID = Crypto.getAgentID(inviteSecret);
|
|
902
|
+
|
|
903
|
+
const groupAsInvite = expectGroup(
|
|
904
|
+
groupCore
|
|
905
|
+
.testWithDifferentAccount(
|
|
906
|
+
new ControlledAgent(inviteSecret, Crypto),
|
|
907
|
+
Crypto.newRandomSessionID(inviteID),
|
|
908
|
+
)
|
|
909
|
+
.getCurrentContent(),
|
|
910
|
+
);
|
|
911
|
+
|
|
912
|
+
groupAsInvite.set(inviteID, "adminInvite", "trusting");
|
|
913
|
+
|
|
914
|
+
expect(groupAsInvite.get(inviteID)).toEqual(undefined);
|
|
915
|
+
});
|
|
916
|
+
|
|
896
917
|
test("Admins can set group read rey, make a private transaction in an owned object, rotate the read key, add two readers, rotate the read key again to kick out one reader, make another private transaction in the owned object, and only the remaining reader can read both transactions", () => {
|
|
897
918
|
const { node, groupCore, admin } = newGroup();
|
|
898
919
|
|
|
@@ -912,7 +933,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
912
933
|
const revelation1 = Crypto.seal({
|
|
913
934
|
message: readKey,
|
|
914
935
|
from: admin.currentSealerSecret(),
|
|
915
|
-
to: admin.currentSealerID()
|
|
936
|
+
to: admin.currentSealerID(),
|
|
916
937
|
nOnceMaterial: {
|
|
917
938
|
in: groupCore.id,
|
|
918
939
|
tx: groupCore.nextTransactionID(),
|
|
@@ -924,7 +945,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
924
945
|
const revelation2 = Crypto.seal({
|
|
925
946
|
message: readKey,
|
|
926
947
|
from: admin.currentSealerSecret(),
|
|
927
|
-
to: reader.currentSealerID()
|
|
948
|
+
to: reader.currentSealerID(),
|
|
928
949
|
nOnceMaterial: {
|
|
929
950
|
in: groupCore.id,
|
|
930
951
|
tx: groupCore.nextTransactionID(),
|
|
@@ -936,7 +957,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
936
957
|
const revelation3 = Crypto.seal({
|
|
937
958
|
message: readKey,
|
|
938
959
|
from: admin.currentSealerSecret(),
|
|
939
|
-
to: reader2.currentSealerID()
|
|
960
|
+
to: reader2.currentSealerID(),
|
|
940
961
|
nOnceMaterial: {
|
|
941
962
|
in: groupCore.id,
|
|
942
963
|
tx: groupCore.nextTransactionID(),
|
|
@@ -982,7 +1003,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
982
1003
|
const newRevelation1 = Crypto.seal({
|
|
983
1004
|
message: readKey2,
|
|
984
1005
|
from: admin.currentSealerSecret(),
|
|
985
|
-
to: admin.currentSealerID()
|
|
1006
|
+
to: admin.currentSealerID(),
|
|
986
1007
|
nOnceMaterial: {
|
|
987
1008
|
in: groupCore.id,
|
|
988
1009
|
tx: groupCore.nextTransactionID(),
|
|
@@ -994,7 +1015,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
|
|
|
994
1015
|
const newRevelation2 = Crypto.seal({
|
|
995
1016
|
message: readKey2,
|
|
996
1017
|
from: admin.currentSealerSecret(),
|
|
997
|
-
to: reader2.currentSealerID()
|
|
1018
|
+
to: reader2.currentSealerID(),
|
|
998
1019
|
nOnceMaterial: {
|
|
999
1020
|
in: groupCore.id,
|
|
1000
1021
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1119,7 +1140,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
|
|
|
1119
1140
|
const revelation = Crypto.seal({
|
|
1120
1141
|
message: readKey,
|
|
1121
1142
|
from: admin.currentSealerSecret(),
|
|
1122
|
-
to: admin.currentSealerID()
|
|
1143
|
+
to: admin.currentSealerID(),
|
|
1123
1144
|
nOnceMaterial: {
|
|
1124
1145
|
in: groupCore.id,
|
|
1125
1146
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1229,7 +1250,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
|
|
|
1229
1250
|
const revelation = Crypto.seal({
|
|
1230
1251
|
message: readKey,
|
|
1231
1252
|
from: admin.currentSealerSecret(),
|
|
1232
|
-
to: admin.currentSealerID()
|
|
1253
|
+
to: admin.currentSealerID(),
|
|
1233
1254
|
nOnceMaterial: {
|
|
1234
1255
|
in: groupCore.id,
|
|
1235
1256
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1332,7 +1353,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
|
|
|
1332
1353
|
const revelation = Crypto.seal({
|
|
1333
1354
|
message: readKey,
|
|
1334
1355
|
from: admin.currentSealerSecret(),
|
|
1335
|
-
to: admin.currentSealerID()
|
|
1356
|
+
to: admin.currentSealerID(),
|
|
1336
1357
|
nOnceMaterial: {
|
|
1337
1358
|
in: groupCore.id,
|
|
1338
1359
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1425,7 +1446,7 @@ test("WriterInvites can not invite admins", () => {
|
|
|
1425
1446
|
const revelation = Crypto.seal({
|
|
1426
1447
|
message: readKey,
|
|
1427
1448
|
from: admin.currentSealerSecret(),
|
|
1428
|
-
to: admin.currentSealerID()
|
|
1449
|
+
to: admin.currentSealerID(),
|
|
1429
1450
|
nOnceMaterial: {
|
|
1430
1451
|
in: groupCore.id,
|
|
1431
1452
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1479,7 +1500,7 @@ test("ReaderInvites can not invite admins", () => {
|
|
|
1479
1500
|
const revelation = Crypto.seal({
|
|
1480
1501
|
message: readKey,
|
|
1481
1502
|
from: admin.currentSealerSecret(),
|
|
1482
|
-
to: admin.currentSealerID()
|
|
1503
|
+
to: admin.currentSealerID(),
|
|
1483
1504
|
nOnceMaterial: {
|
|
1484
1505
|
in: groupCore.id,
|
|
1485
1506
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1533,7 +1554,7 @@ test("ReaderInvites can not invite writers", () => {
|
|
|
1533
1554
|
const revelation = Crypto.seal({
|
|
1534
1555
|
message: readKey,
|
|
1535
1556
|
from: admin.currentSealerSecret(),
|
|
1536
|
-
to: admin.currentSealerID()
|
|
1557
|
+
to: admin.currentSealerID(),
|
|
1537
1558
|
nOnceMaterial: {
|
|
1538
1559
|
in: groupCore.id,
|
|
1539
1560
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1587,7 +1608,7 @@ test("WriteOnlyInvites can not invite writers", () => {
|
|
|
1587
1608
|
const revelation = Crypto.seal({
|
|
1588
1609
|
message: readKey,
|
|
1589
1610
|
from: admin.currentSealerSecret(),
|
|
1590
|
-
to: admin.currentSealerID()
|
|
1611
|
+
to: admin.currentSealerID(),
|
|
1591
1612
|
nOnceMaterial: {
|
|
1592
1613
|
in: groupCore.id,
|
|
1593
1614
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1641,7 +1662,7 @@ test("WriteOnlyInvites can not invite admins", () => {
|
|
|
1641
1662
|
const revelation = Crypto.seal({
|
|
1642
1663
|
message: readKey,
|
|
1643
1664
|
from: admin.currentSealerSecret(),
|
|
1644
|
-
to: admin.currentSealerID()
|
|
1665
|
+
to: admin.currentSealerID(),
|
|
1645
1666
|
nOnceMaterial: {
|
|
1646
1667
|
in: groupCore.id,
|
|
1647
1668
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1695,7 +1716,7 @@ test("WriteOnlyInvites can invite writeOnly", () => {
|
|
|
1695
1716
|
const revelation = Crypto.seal({
|
|
1696
1717
|
message: readKey,
|
|
1697
1718
|
from: admin.currentSealerSecret(),
|
|
1698
|
-
to: admin.currentSealerID()
|
|
1719
|
+
to: admin.currentSealerID(),
|
|
1699
1720
|
nOnceMaterial: {
|
|
1700
1721
|
in: groupCore.id,
|
|
1701
1722
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1749,7 +1770,7 @@ test("WriteOnlyInvites can set writeKeys", () => {
|
|
|
1749
1770
|
const revelation = Crypto.seal({
|
|
1750
1771
|
message: readKey,
|
|
1751
1772
|
from: admin.currentSealerSecret(),
|
|
1752
|
-
to: admin.currentSealerID()
|
|
1773
|
+
to: admin.currentSealerID(),
|
|
1753
1774
|
nOnceMaterial: {
|
|
1754
1775
|
in: groupCore.id,
|
|
1755
1776
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1800,7 +1821,7 @@ test("Invites can't override key revelations", () => {
|
|
|
1800
1821
|
const revelation = Crypto.seal({
|
|
1801
1822
|
message: readKey,
|
|
1802
1823
|
from: admin.currentSealerSecret(),
|
|
1803
|
-
to: admin.currentSealerID()
|
|
1824
|
+
to: admin.currentSealerID(),
|
|
1804
1825
|
nOnceMaterial: {
|
|
1805
1826
|
in: groupCore.id,
|
|
1806
1827
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1855,7 +1876,7 @@ test("WriteOnlyInvites can't override writeKeys", () => {
|
|
|
1855
1876
|
const revelation = Crypto.seal({
|
|
1856
1877
|
message: readKey,
|
|
1857
1878
|
from: admin.currentSealerSecret(),
|
|
1858
|
-
to: admin.currentSealerID()
|
|
1879
|
+
to: admin.currentSealerID(),
|
|
1859
1880
|
nOnceMaterial: {
|
|
1860
1881
|
in: groupCore.id,
|
|
1861
1882
|
tx: groupCore.nextTransactionID(),
|
|
@@ -1929,7 +1950,7 @@ test("Can give read permission to 'everyone'", () => {
|
|
|
1929
1950
|
childObject
|
|
1930
1951
|
.testWithDifferentAccount(
|
|
1931
1952
|
newAccount,
|
|
1932
|
-
Crypto.newRandomSessionID(newAccount.currentAgentID()
|
|
1953
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()),
|
|
1933
1954
|
)
|
|
1934
1955
|
.getCurrentContent(),
|
|
1935
1956
|
);
|
|
@@ -1955,7 +1976,7 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
|
|
|
1955
1976
|
childObject.core
|
|
1956
1977
|
.testWithDifferentAccount(
|
|
1957
1978
|
new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto),
|
|
1958
|
-
Crypto.newRandomSessionID(newAccount.currentAgentID()
|
|
1979
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()),
|
|
1959
1980
|
)
|
|
1960
1981
|
.getCurrentContent(),
|
|
1961
1982
|
);
|
|
@@ -1993,7 +2014,7 @@ test("Can give write permission to 'everyone'", async () => {
|
|
|
1993
2014
|
childObject
|
|
1994
2015
|
.testWithDifferentAccount(
|
|
1995
2016
|
newAccount,
|
|
1996
|
-
Crypto.newRandomSessionID(newAccount.currentAgentID()
|
|
2017
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()),
|
|
1997
2018
|
)
|
|
1998
2019
|
.getCurrentContent(),
|
|
1999
2020
|
);
|
|
@@ -2025,7 +2046,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
|
|
|
2025
2046
|
childObject.core
|
|
2026
2047
|
.testWithDifferentAccount(
|
|
2027
2048
|
newAccount,
|
|
2028
|
-
Crypto.newRandomSessionID(newAccount.currentAgentID()
|
|
2049
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()),
|
|
2029
2050
|
)
|
|
2030
2051
|
.getCurrentContent(),
|
|
2031
2052
|
);
|
|
@@ -2087,7 +2108,7 @@ test("Writers, readers and invitees can not set parent extensions", () => {
|
|
|
2087
2108
|
group.core
|
|
2088
2109
|
.testWithDifferentAccount(
|
|
2089
2110
|
adminInvite,
|
|
2090
|
-
Crypto.newRandomSessionID(adminInvite.currentAgentID()
|
|
2111
|
+
Crypto.newRandomSessionID(adminInvite.currentAgentID()),
|
|
2091
2112
|
)
|
|
2092
2113
|
.getCurrentContent(),
|
|
2093
2114
|
);
|
|
@@ -2099,9 +2120,7 @@ test("Writers, readers and invitees can not set parent extensions", () => {
|
|
|
2099
2120
|
group.core
|
|
2100
2121
|
.testWithDifferentAccount(
|
|
2101
2122
|
writerInvite,
|
|
2102
|
-
Crypto.newRandomSessionID(
|
|
2103
|
-
writerInvite.currentAgentID()._unsafeUnwrap(),
|
|
2104
|
-
),
|
|
2123
|
+
Crypto.newRandomSessionID(writerInvite.currentAgentID()),
|
|
2105
2124
|
)
|
|
2106
2125
|
.getCurrentContent(),
|
|
2107
2126
|
);
|
|
@@ -2113,9 +2132,7 @@ test("Writers, readers and invitees can not set parent extensions", () => {
|
|
|
2113
2132
|
group.core
|
|
2114
2133
|
.testWithDifferentAccount(
|
|
2115
2134
|
readerInvite,
|
|
2116
|
-
Crypto.newRandomSessionID(
|
|
2117
|
-
readerInvite.currentAgentID()._unsafeUnwrap(),
|
|
2118
|
-
),
|
|
2135
|
+
Crypto.newRandomSessionID(readerInvite.currentAgentID()),
|
|
2119
2136
|
)
|
|
2120
2137
|
.getCurrentContent(),
|
|
2121
2138
|
);
|
|
@@ -2209,7 +2226,7 @@ test("Invitees can not set child extensions", () => {
|
|
|
2209
2226
|
group.core
|
|
2210
2227
|
.testWithDifferentAccount(
|
|
2211
2228
|
adminInvite,
|
|
2212
|
-
Crypto.newRandomSessionID(adminInvite.currentAgentID()
|
|
2229
|
+
Crypto.newRandomSessionID(adminInvite.currentAgentID()),
|
|
2213
2230
|
)
|
|
2214
2231
|
.getCurrentContent(),
|
|
2215
2232
|
);
|
|
@@ -2221,9 +2238,7 @@ test("Invitees can not set child extensions", () => {
|
|
|
2221
2238
|
group.core
|
|
2222
2239
|
.testWithDifferentAccount(
|
|
2223
2240
|
writerInvite,
|
|
2224
|
-
Crypto.newRandomSessionID(
|
|
2225
|
-
writerInvite.currentAgentID()._unsafeUnwrap(),
|
|
2226
|
-
),
|
|
2241
|
+
Crypto.newRandomSessionID(writerInvite.currentAgentID()),
|
|
2227
2242
|
)
|
|
2228
2243
|
.getCurrentContent(),
|
|
2229
2244
|
);
|
|
@@ -2235,9 +2250,7 @@ test("Invitees can not set child extensions", () => {
|
|
|
2235
2250
|
group.core
|
|
2236
2251
|
.testWithDifferentAccount(
|
|
2237
2252
|
readerInvite,
|
|
2238
|
-
Crypto.newRandomSessionID(
|
|
2239
|
-
readerInvite.currentAgentID()._unsafeUnwrap(),
|
|
2240
|
-
),
|
|
2253
|
+
Crypto.newRandomSessionID(readerInvite.currentAgentID()),
|
|
2241
2254
|
)
|
|
2242
2255
|
.getCurrentContent(),
|
|
2243
2256
|
);
|
|
@@ -2422,7 +2435,7 @@ test("Writers, readers and invites can't reveal parent read keys to child groups
|
|
|
2422
2435
|
group.core
|
|
2423
2436
|
.testWithDifferentAccount(
|
|
2424
2437
|
adminInvite,
|
|
2425
|
-
Crypto.newRandomSessionID(adminInvite.currentAgentID()
|
|
2438
|
+
Crypto.newRandomSessionID(adminInvite.currentAgentID()),
|
|
2426
2439
|
)
|
|
2427
2440
|
.getCurrentContent(),
|
|
2428
2441
|
);
|
|
@@ -2440,9 +2453,7 @@ test("Writers, readers and invites can't reveal parent read keys to child groups
|
|
|
2440
2453
|
group.core
|
|
2441
2454
|
.testWithDifferentAccount(
|
|
2442
2455
|
writerInvite,
|
|
2443
|
-
Crypto.newRandomSessionID(
|
|
2444
|
-
writerInvite.currentAgentID()._unsafeUnwrap(),
|
|
2445
|
-
),
|
|
2456
|
+
Crypto.newRandomSessionID(writerInvite.currentAgentID()),
|
|
2446
2457
|
)
|
|
2447
2458
|
.getCurrentContent(),
|
|
2448
2459
|
);
|
|
@@ -2460,9 +2471,7 @@ test("Writers, readers and invites can't reveal parent read keys to child groups
|
|
|
2460
2471
|
group.core
|
|
2461
2472
|
.testWithDifferentAccount(
|
|
2462
2473
|
readerInvite,
|
|
2463
|
-
Crypto.newRandomSessionID(
|
|
2464
|
-
readerInvite.currentAgentID()._unsafeUnwrap(),
|
|
2465
|
-
),
|
|
2474
|
+
Crypto.newRandomSessionID(readerInvite.currentAgentID()),
|
|
2466
2475
|
)
|
|
2467
2476
|
.getCurrentContent(),
|
|
2468
2477
|
);
|
|
@@ -2814,6 +2823,270 @@ test("Calling extend to create grand-child groups parent and child references an
|
|
|
2814
2823
|
expect(childContentAsReader.get("foo")).toEqual("bar");
|
|
2815
2824
|
});
|
|
2816
2825
|
|
|
2826
|
+
test("revoking access on a child group doesn't block access to that group if a more permissive role is inheritable", async () => {
|
|
2827
|
+
const { node1, node2 } = await createTwoConnectedNodes("server", "server");
|
|
2828
|
+
|
|
2829
|
+
const group = node1.node.createGroup();
|
|
2830
|
+
const parentGroup = node1.node.createGroup();
|
|
2831
|
+
|
|
2832
|
+
group.extend(parentGroup);
|
|
2833
|
+
|
|
2834
|
+
const randomUser = await loadCoValueOrFail(node1.node, node2.accountID);
|
|
2835
|
+
|
|
2836
|
+
parentGroup.addMember(randomUser, "writer");
|
|
2837
|
+
group.addMember(randomUser, "writer");
|
|
2838
|
+
await group.removeMember(randomUser);
|
|
2839
|
+
|
|
2840
|
+
const childMap = group.createMap();
|
|
2841
|
+
|
|
2842
|
+
childMap.set("foo", "bar", "private");
|
|
2843
|
+
|
|
2844
|
+
const mapOnNode2 = await loadCoValueOrFail(node2.node, childMap.id);
|
|
2845
|
+
|
|
2846
|
+
mapOnNode2.set("foo", "baz", "private");
|
|
2847
|
+
|
|
2848
|
+
expect(mapOnNode2.get("foo")).toEqual("baz");
|
|
2849
|
+
});
|
|
2850
|
+
|
|
2851
|
+
test("revoking access on a parent group doesn't block access to the child group if the same role is inheritable from a grand-parent group", async () => {
|
|
2852
|
+
const { node1, node2 } = await createTwoConnectedNodes("server", "server");
|
|
2853
|
+
|
|
2854
|
+
const group = node1.node.createGroup();
|
|
2855
|
+
const parentGroup = node1.node.createGroup();
|
|
2856
|
+
const grandParentGroup = node1.node.createGroup();
|
|
2857
|
+
|
|
2858
|
+
group.extend(parentGroup);
|
|
2859
|
+
parentGroup.extend(grandParentGroup);
|
|
2860
|
+
|
|
2861
|
+
const randomUser = await loadCoValueOrFail(node1.node, node2.accountID);
|
|
2862
|
+
|
|
2863
|
+
grandParentGroup.addMember(randomUser, "writer");
|
|
2864
|
+
parentGroup.addMember(randomUser, "writer");
|
|
2865
|
+
await parentGroup.removeMember(randomUser);
|
|
2866
|
+
|
|
2867
|
+
const childMap = group.createMap();
|
|
2868
|
+
|
|
2869
|
+
childMap.set("foo", "bar", "private");
|
|
2870
|
+
|
|
2871
|
+
const mapOnNode2 = await loadCoValueOrFail(node2.node, childMap.id);
|
|
2872
|
+
|
|
2873
|
+
mapOnNode2.set("foo", "baz", "private");
|
|
2874
|
+
|
|
2875
|
+
expect(mapOnNode2.get("foo")).toEqual("baz");
|
|
2876
|
+
});
|
|
2877
|
+
|
|
2878
|
+
test("revoking access on a parent group doesn't block access to the child group if the same role is inheritable from another parent group", async () => {
|
|
2879
|
+
const { node1, node2 } = await createTwoConnectedNodes("server", "server");
|
|
2880
|
+
|
|
2881
|
+
const group = node1.node.createGroup();
|
|
2882
|
+
const parentGroup1 = node1.node.createGroup();
|
|
2883
|
+
const parentGroup2 = node1.node.createGroup();
|
|
2884
|
+
|
|
2885
|
+
group.extend(parentGroup1);
|
|
2886
|
+
group.extend(parentGroup2);
|
|
2887
|
+
|
|
2888
|
+
const randomUser = await loadCoValueOrFail(node1.node, node2.accountID);
|
|
2889
|
+
|
|
2890
|
+
parentGroup1.addMember(randomUser, "writer");
|
|
2891
|
+
parentGroup2.addMember(randomUser, "writer");
|
|
2892
|
+
await parentGroup1.removeMember(randomUser);
|
|
2893
|
+
|
|
2894
|
+
const childMap = group.createMap();
|
|
2895
|
+
|
|
2896
|
+
childMap.set("foo", "bar", "private");
|
|
2897
|
+
|
|
2898
|
+
const mapOnNode2 = await loadCoValueOrFail(node2.node, childMap.id);
|
|
2899
|
+
|
|
2900
|
+
mapOnNode2.set("foo", "baz", "private");
|
|
2901
|
+
|
|
2902
|
+
expect(mapOnNode2.get("foo")).toEqual("baz");
|
|
2903
|
+
});
|
|
2904
|
+
|
|
2905
|
+
test("revoking write access to parent group", async () => {
|
|
2906
|
+
// Start with a node and a group
|
|
2907
|
+
const { group, node } = newGroupHighLevel();
|
|
2908
|
+
|
|
2909
|
+
// Create a parent group and relate it to the existing group
|
|
2910
|
+
const parentGroup = node.createGroup();
|
|
2911
|
+
group.extend(parentGroup);
|
|
2912
|
+
|
|
2913
|
+
// Create an account (`alice`) that can write to the parent group
|
|
2914
|
+
// Create an account (`bob`) that can write to the child group
|
|
2915
|
+
const alice = node.createAccount();
|
|
2916
|
+
const bob = node.createAccount();
|
|
2917
|
+
parentGroup.addMember(alice, "writer");
|
|
2918
|
+
group.addMember(bob, "writer");
|
|
2919
|
+
|
|
2920
|
+
// The child group has a map that can be written to by `bob`
|
|
2921
|
+
const mapCore = node.createCoValue({
|
|
2922
|
+
type: "comap",
|
|
2923
|
+
ruleset: { type: "ownedByGroup", group: group.id },
|
|
2924
|
+
meta: null,
|
|
2925
|
+
...Crypto.createdNowUnique(),
|
|
2926
|
+
});
|
|
2927
|
+
const bobMap = expectMap(
|
|
2928
|
+
mapCore
|
|
2929
|
+
.testWithDifferentAccount(bob, Crypto.newRandomSessionID(bob.id))
|
|
2930
|
+
.getCurrentContent(),
|
|
2931
|
+
);
|
|
2932
|
+
|
|
2933
|
+
// `bob` sets `foo` to `bar`
|
|
2934
|
+
bobMap.set("foo", "bar", "private");
|
|
2935
|
+
// `bob`'s change is made successfully
|
|
2936
|
+
expect(bobMap.get("foo")).toEqual("bar");
|
|
2937
|
+
|
|
2938
|
+
const aliceMap = expectMap(
|
|
2939
|
+
mapCore
|
|
2940
|
+
.testWithDifferentAccount(alice, Crypto.newRandomSessionID(alice.id))
|
|
2941
|
+
.getCurrentContent(),
|
|
2942
|
+
);
|
|
2943
|
+
// `alice` sets `foo` to `baz`
|
|
2944
|
+
aliceMap.set("foo", "baz", "private");
|
|
2945
|
+
// `alice`'s change is made successfully
|
|
2946
|
+
expect(aliceMap.get("foo")).toEqual("baz");
|
|
2947
|
+
|
|
2948
|
+
// The two groups are no longer related
|
|
2949
|
+
await group.revokeExtend(parentGroup);
|
|
2950
|
+
|
|
2951
|
+
// `bob` sets `foo` to `abc`
|
|
2952
|
+
bobMap.set("foo", "abc", "private");
|
|
2953
|
+
// `bob`'s change is made successfully
|
|
2954
|
+
expect(bobMap.get("foo")).toEqual("abc");
|
|
2955
|
+
|
|
2956
|
+
const aliceMapAfterUnextend = expectMap(
|
|
2957
|
+
mapCore
|
|
2958
|
+
.testWithDifferentAccount(alice, Crypto.newRandomSessionID(alice.id))
|
|
2959
|
+
.getCurrentContent(),
|
|
2960
|
+
);
|
|
2961
|
+
// `alice` attempts to set `foo` to `def`, but fails
|
|
2962
|
+
expect(() => aliceMapAfterUnextend.set("foo", "def", "private")).toThrow(
|
|
2963
|
+
"Can't make transaction without read key secret",
|
|
2964
|
+
);
|
|
2965
|
+
// `alice`'s change is not made successfully
|
|
2966
|
+
expect(aliceMapAfterUnextend.get("foo")).not.toEqual("def");
|
|
2967
|
+
});
|
|
2968
|
+
|
|
2969
|
+
test("revoking read access to parent group", async () => {
|
|
2970
|
+
// Start with two nodes
|
|
2971
|
+
const { node1, node2 } = await createTwoConnectedNodes("server", "server");
|
|
2972
|
+
const group = node1.node.createGroup();
|
|
2973
|
+
|
|
2974
|
+
// Create a parent group and relate it to the existing group
|
|
2975
|
+
const parentGroup = node1.node.createGroup();
|
|
2976
|
+
group.extend(parentGroup);
|
|
2977
|
+
|
|
2978
|
+
// Create an account (`alice`) that can read from the parent group
|
|
2979
|
+
// Create an account (`bob`) that can write to the child group
|
|
2980
|
+
const alice = await loadCoValueOrFail(node1.node, node2.accountID);
|
|
2981
|
+
const bob = await loadCoValueOrFail(node1.node, node1.accountID);
|
|
2982
|
+
parentGroup.addMember(alice, "reader");
|
|
2983
|
+
group.addMember(bob, "writer");
|
|
2984
|
+
|
|
2985
|
+
// The child group has a map that can be written to by `bob`
|
|
2986
|
+
const bobMap = group.createMap();
|
|
2987
|
+
|
|
2988
|
+
// `bob` sets `foo` to `bar`
|
|
2989
|
+
bobMap.set("foo", "bar", "private");
|
|
2990
|
+
// `bob`'s change is made successfully
|
|
2991
|
+
expect(bobMap.get("foo")).toEqual("bar");
|
|
2992
|
+
|
|
2993
|
+
const aliceMap = await loadCoValueOrFail(node2.node, bobMap.id);
|
|
2994
|
+
// `alice` reads `foo` as `bar`
|
|
2995
|
+
expect(aliceMap.get("foo")).toEqual("bar");
|
|
2996
|
+
|
|
2997
|
+
// The two groups are no longer related
|
|
2998
|
+
await group.revokeExtend(parentGroup);
|
|
2999
|
+
|
|
3000
|
+
// `bob` sets `foo` to `abc`
|
|
3001
|
+
bobMap.set("foo", "abc", "private");
|
|
3002
|
+
// `bob`'s change is made successfully
|
|
3003
|
+
expect(bobMap.get("foo")).toEqual("abc");
|
|
3004
|
+
|
|
3005
|
+
// `alice` reads `foo` as `bar`
|
|
3006
|
+
expect(aliceMap.get("foo")).toEqual("bar");
|
|
3007
|
+
});
|
|
3008
|
+
|
|
3009
|
+
test("revoking read access to grandparent group", async () => {
|
|
3010
|
+
// Start with two nodes
|
|
3011
|
+
const { node1, node2, node3 } = await createThreeConnectedNodes(
|
|
3012
|
+
"server",
|
|
3013
|
+
"server",
|
|
3014
|
+
"server",
|
|
3015
|
+
);
|
|
3016
|
+
const group = node1.node.createGroup();
|
|
3017
|
+
|
|
3018
|
+
// Create group hierarchy
|
|
3019
|
+
const parentGroup = node1.node.createGroup();
|
|
3020
|
+
const grandParentGroup = node1.node.createGroup();
|
|
3021
|
+
group.extend(parentGroup);
|
|
3022
|
+
parentGroup.extend(grandParentGroup);
|
|
3023
|
+
|
|
3024
|
+
// Create an account (`alice`) that can read from the parent group
|
|
3025
|
+
// Create an account (`bob`) that can write to the child group
|
|
3026
|
+
// Create an account (`charlie`) that can read from the grandparent group
|
|
3027
|
+
const alice = await loadCoValueOrFail(node1.node, node2.accountID);
|
|
3028
|
+
const bob = await loadCoValueOrFail(node1.node, node1.accountID);
|
|
3029
|
+
const charlie = await loadCoValueOrFail(node1.node, node3.accountID);
|
|
3030
|
+
parentGroup.addMember(alice, "reader");
|
|
3031
|
+
group.addMember(bob, "writer");
|
|
3032
|
+
grandParentGroup.addMember(charlie, "reader");
|
|
3033
|
+
|
|
3034
|
+
// The child group has a map that can be written to by `bob`
|
|
3035
|
+
const bobMap = group.createMap();
|
|
3036
|
+
|
|
3037
|
+
// `bob` sets `foo` to `bar`
|
|
3038
|
+
bobMap.set("foo", "bar", "private");
|
|
3039
|
+
// `bob`'s change is made successfully
|
|
3040
|
+
expect(bobMap.get("foo")).toEqual("bar");
|
|
3041
|
+
|
|
3042
|
+
const aliceMap = await loadCoValueOrFail(node2.node, bobMap.id);
|
|
3043
|
+
// `alice` reads `foo` as `bar`
|
|
3044
|
+
expect(aliceMap.get("foo")).toEqual("bar");
|
|
3045
|
+
|
|
3046
|
+
const charlieMap = await loadCoValueOrFail(node3.node, bobMap.id);
|
|
3047
|
+
// `charlie` reads `foo` as `bar`
|
|
3048
|
+
expect(charlieMap.get("foo")).toEqual("bar");
|
|
3049
|
+
|
|
3050
|
+
// The groups are no longer related
|
|
3051
|
+
await parentGroup.revokeExtend(grandParentGroup);
|
|
3052
|
+
await group.revokeExtend(parentGroup);
|
|
3053
|
+
|
|
3054
|
+
// `bob` sets `foo` to `abc`
|
|
3055
|
+
bobMap.set("foo", "abc", "private");
|
|
3056
|
+
// `bob`'s change is made successfully
|
|
3057
|
+
expect(bobMap.get("foo")).toEqual("abc");
|
|
3058
|
+
|
|
3059
|
+
// `alice` reads `foo` as `bar`
|
|
3060
|
+
expect(aliceMap.get("foo")).toEqual("bar");
|
|
3061
|
+
// `charlie` reads `foo` as `bar`
|
|
3062
|
+
expect(charlieMap.get("foo")).toEqual("bar");
|
|
3063
|
+
});
|
|
3064
|
+
|
|
3065
|
+
test("a user should have write access if the parent group has everyone as a writer", async () => {
|
|
3066
|
+
const { node1, node2 } = await createTwoConnectedNodes("server", "server");
|
|
3067
|
+
|
|
3068
|
+
const group = node1.node.createGroup();
|
|
3069
|
+
const parentGroup = node1.node.createGroup();
|
|
3070
|
+
|
|
3071
|
+
group.extend(parentGroup);
|
|
3072
|
+
|
|
3073
|
+
parentGroup.addMember("everyone", "writer");
|
|
3074
|
+
|
|
3075
|
+
const randomUser = await loadCoValueOrFail(node1.node, node2.accountID);
|
|
3076
|
+
|
|
3077
|
+
group.addMember(randomUser, "reader");
|
|
3078
|
+
|
|
3079
|
+
const childMap = group.createMap();
|
|
3080
|
+
|
|
3081
|
+
childMap.set("foo", "bar", "private");
|
|
3082
|
+
|
|
3083
|
+
const mapOnNode2 = await loadCoValueOrFail(node2.node, childMap.id);
|
|
3084
|
+
|
|
3085
|
+
mapOnNode2.set("foo", "baz", "private");
|
|
3086
|
+
|
|
3087
|
+
expect(mapOnNode2.get("foo")).toEqual("baz");
|
|
3088
|
+
});
|
|
3089
|
+
|
|
2817
3090
|
test("High-level permissions work correctly when a group is extended", async () => {
|
|
2818
3091
|
const { group, node } = newGroupHighLevel();
|
|
2819
3092
|
const parentGroup = node.createGroup();
|
|
@@ -2941,7 +3214,7 @@ test("Can revoke read permission from 'everyone'", async () => {
|
|
|
2941
3214
|
childObject.core
|
|
2942
3215
|
.testWithDifferentAccount(
|
|
2943
3216
|
newAccount,
|
|
2944
|
-
Crypto.newRandomSessionID(newAccount.currentAgentID()
|
|
3217
|
+
Crypto.newRandomSessionID(newAccount.currentAgentID()),
|
|
2945
3218
|
)
|
|
2946
3219
|
.getCurrentContent(),
|
|
2947
3220
|
);
|
|
@@ -2963,7 +3236,7 @@ test("Can revoke read permission from 'everyone'", async () => {
|
|
|
2963
3236
|
childObject.core
|
|
2964
3237
|
.testWithDifferentAccount(
|
|
2965
3238
|
newAccount2,
|
|
2966
|
-
Crypto.newRandomSessionID(newAccount2.currentAgentID()
|
|
3239
|
+
Crypto.newRandomSessionID(newAccount2.currentAgentID()),
|
|
2967
3240
|
)
|
|
2968
3241
|
.getCurrentContent(),
|
|
2969
3242
|
);
|