@calimero-network/mero-react 9.6.1 → 9.6.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/dist/index.cjs +31 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -562,12 +562,22 @@ var NODE_ONLY = /* @__PURE__ */ new Set([
|
|
|
562
562
|
"uninstallApplication",
|
|
563
563
|
"generateContextIdentity",
|
|
564
564
|
"deleteContext",
|
|
565
|
+
// A node's leaveContext is a local opt-out (a tombstone, its own identity rows)
|
|
566
|
+
// and publishes nothing; an account has nothing local to opt out of, and
|
|
567
|
+
// leaving the context's group instead is leaveGroup.
|
|
568
|
+
"leaveContext",
|
|
565
569
|
"createContextAlias",
|
|
566
570
|
"createApplicationAlias",
|
|
567
571
|
"createDeviceAlias",
|
|
568
572
|
"deleteContextAlias",
|
|
569
573
|
"deleteApplicationAlias",
|
|
570
574
|
"deleteDeviceAlias",
|
|
575
|
+
"lookupContextAlias",
|
|
576
|
+
"lookupApplicationAlias",
|
|
577
|
+
"lookupDeviceAlias",
|
|
578
|
+
"listContextAliases",
|
|
579
|
+
"listApplicationAliases",
|
|
580
|
+
"listDeviceAliases",
|
|
571
581
|
"deleteNamespace",
|
|
572
582
|
"createGroupInvitation",
|
|
573
583
|
"joinGroup",
|
|
@@ -576,10 +586,16 @@ var NODE_ONLY = /* @__PURE__ */ new Set([
|
|
|
576
586
|
"deleteBlob",
|
|
577
587
|
"listAccountDevices",
|
|
578
588
|
"revokeAccountDevice",
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
589
|
+
// Core rc.76 asks the NODE to be the namespace admin for this read, which a
|
|
590
|
+
// relay is not, so an account that is the admin is answered a bare 403.
|
|
591
|
+
// Refused by name until core checks the caller, as it does for the other two.
|
|
592
|
+
"getMigrationStatus"
|
|
582
593
|
]);
|
|
594
|
+
function isAlreadyDirectMember(e) {
|
|
595
|
+
if (!(e instanceof Error)) return false;
|
|
596
|
+
const status = e.status;
|
|
597
|
+
return (status === void 0 || status === 409) && /signer [0-9a-f]+ is a direct member/i.test(e.message);
|
|
598
|
+
}
|
|
583
599
|
function createAccountAdmin(input, deps = {}) {
|
|
584
600
|
const { session: s, read, app } = input;
|
|
585
601
|
const governGroupOp = deps.govern?.group ?? governGroup;
|
|
@@ -610,8 +626,17 @@ function createAccountAdmin(input, deps = {}) {
|
|
|
610
626
|
await knowNamespaceOf(groupId);
|
|
611
627
|
return governRootOp(session, groupId, op);
|
|
612
628
|
};
|
|
629
|
+
async function joinOpen(groupId) {
|
|
630
|
+
try {
|
|
631
|
+
await root(s, groupId, meroJs.memberJoinedOpenOp({ member: s.account, groupId, credential: s.credential }));
|
|
632
|
+
return true;
|
|
633
|
+
} catch (e) {
|
|
634
|
+
if (isAlreadyDirectMember(e)) return false;
|
|
635
|
+
throw e;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
613
638
|
async function isMemberOfContextGroup(contextId, knownGroupId) {
|
|
614
|
-
const groupId =
|
|
639
|
+
const groupId = String(await relay().getContextGroup(contextId));
|
|
615
640
|
const { members } = await relay().listGroupMembers(groupId);
|
|
616
641
|
return members.some((m) => m.identity.toLowerCase() === s.account.toLowerCase());
|
|
617
642
|
}
|
|
@@ -679,11 +704,6 @@ function createAccountAdmin(input, deps = {}) {
|
|
|
679
704
|
async leaveNamespace(namespaceId) {
|
|
680
705
|
await group(s, namespaceId, meroJs.memberLeftOp(s.account));
|
|
681
706
|
},
|
|
682
|
-
// An account holds no context identity: leaving a context is leaving its group.
|
|
683
|
-
async leaveContext(contextId) {
|
|
684
|
-
const groupId = await relay().getContextGroup(contextId);
|
|
685
|
-
await group(s, String(groupId), meroJs.memberLeftOp(s.account));
|
|
686
|
-
},
|
|
687
707
|
// An account runs as itself in every context it can reach (the relay
|
|
688
708
|
// executes as the account), so its identity there is the account. Owned
|
|
689
709
|
// when its account is a member of the context's group, as on a node a
|
|
@@ -692,11 +712,7 @@ function createAccountAdmin(input, deps = {}) {
|
|
|
692
712
|
return { identities: await isMemberOfContextGroup(contextId) ? [s.account] : [] };
|
|
693
713
|
},
|
|
694
714
|
async joinContext(contextId) {
|
|
695
|
-
|
|
696
|
-
if (await isMemberOfContextGroup(contextId, groupId)) {
|
|
697
|
-
return { contextId, memberPublicKey: s.account };
|
|
698
|
-
}
|
|
699
|
-
await root(s, groupId, meroJs.memberJoinedOpenOp({ member: s.account, groupId, credential: s.credential }));
|
|
715
|
+
await joinOpen(String(await relay().getContextGroup(contextId)));
|
|
700
716
|
return { contextId, memberPublicKey: s.account };
|
|
701
717
|
},
|
|
702
718
|
async createContext(req) {
|
|
@@ -738,12 +754,7 @@ function createAccountAdmin(input, deps = {}) {
|
|
|
738
754
|
// An open subgroup is joined the way `joinContext` joins one: MemberJoinedOpen
|
|
739
755
|
// on the subgroup, and nothing to do for a member already in it.
|
|
740
756
|
async joinSubgroupInheritance(groupId) {
|
|
741
|
-
|
|
742
|
-
if (members.some((m) => m.identity.toLowerCase() === s.account.toLowerCase())) {
|
|
743
|
-
return { groupId, memberPublicKey: s.account, wasInherited: false };
|
|
744
|
-
}
|
|
745
|
-
await root(s, groupId, meroJs.memberJoinedOpenOp({ member: s.account, groupId, credential: s.credential }));
|
|
746
|
-
return { groupId, memberPublicKey: s.account, wasInherited: true };
|
|
757
|
+
return { groupId, memberPublicKey: s.account, wasInherited: await joinOpen(groupId) };
|
|
747
758
|
},
|
|
748
759
|
async detachContextFromGroup(groupId, contextId) {
|
|
749
760
|
await group(s, groupId, meroJs.contextDetachedOp(contextId));
|