@calimero-network/mero-react 9.6.0 → 9.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -494,14 +494,17 @@ function createNodeAdmin(input, deps = {}) {
|
|
|
494
494
|
|
|
495
495
|
// src/delegated/govern.ts
|
|
496
496
|
var GROUP_NAMESPACE_PREFIX = "calimero.delegated.group-namespace.";
|
|
497
|
+
var learned = /* @__PURE__ */ new Map();
|
|
497
498
|
function readGroupNamespaces(account) {
|
|
499
|
+
let stored = {};
|
|
498
500
|
try {
|
|
499
|
-
|
|
501
|
+
stored = JSON.parse(localStorage.getItem(GROUP_NAMESPACE_PREFIX + account) ?? "{}");
|
|
500
502
|
} catch {
|
|
501
|
-
return {};
|
|
502
503
|
}
|
|
504
|
+
return { ...stored, ...learned.get(account) };
|
|
503
505
|
}
|
|
504
506
|
function rememberGroupNamespace(account, groupId, namespaceId) {
|
|
507
|
+
learned.set(account, { ...learned.get(account), [groupId]: namespaceId });
|
|
505
508
|
try {
|
|
506
509
|
const all = readGroupNamespaces(account);
|
|
507
510
|
all[groupId] = namespaceId;
|
|
@@ -579,8 +582,8 @@ var NODE_ONLY = /* @__PURE__ */ new Set([
|
|
|
579
582
|
]);
|
|
580
583
|
function createAccountAdmin(input, deps = {}) {
|
|
581
584
|
const { session: s, read, app } = input;
|
|
582
|
-
const
|
|
583
|
-
const
|
|
585
|
+
const governGroupOp = deps.govern?.group ?? governGroup;
|
|
586
|
+
const governRootOp = deps.govern?.root ?? governRoot;
|
|
584
587
|
const createContext2 = deps.createContext ?? createDelegatedContext;
|
|
585
588
|
const found = deps.found ?? foundDelegatedNamespace;
|
|
586
589
|
const latestVersion = deps.latestVersion ?? latestPublishedVersion;
|
|
@@ -594,6 +597,19 @@ function createAccountAdmin(input, deps = {}) {
|
|
|
594
597
|
if (read === null) throw new NoRelayError("this call");
|
|
595
598
|
return read;
|
|
596
599
|
};
|
|
600
|
+
async function knowNamespaceOf(groupId) {
|
|
601
|
+
if (namespaceOfGroup(s, groupId)) return;
|
|
602
|
+
const info = await relay().getGroupInfo(groupId);
|
|
603
|
+
rememberGroupNamespace(s.account, groupId, info.namespaceId ?? groupId);
|
|
604
|
+
}
|
|
605
|
+
const group = async (session, groupId, op) => {
|
|
606
|
+
await knowNamespaceOf(groupId);
|
|
607
|
+
return governGroupOp(session, groupId, op);
|
|
608
|
+
};
|
|
609
|
+
const root = async (session, groupId, op) => {
|
|
610
|
+
await knowNamespaceOf(groupId);
|
|
611
|
+
return governRootOp(session, groupId, op);
|
|
612
|
+
};
|
|
597
613
|
async function isMemberOfContextGroup(contextId, knownGroupId) {
|
|
598
614
|
const groupId = knownGroupId ?? String(await relay().getContextGroup(contextId));
|
|
599
615
|
const { members } = await relay().listGroupMembers(groupId);
|
|
@@ -1221,6 +1237,7 @@ function getPermissionsForMode(mode) {
|
|
|
1221
1237
|
case "multi-context" /* MultiContext */:
|
|
1222
1238
|
return [
|
|
1223
1239
|
"context:create",
|
|
1240
|
+
"context:delete",
|
|
1224
1241
|
"context:list",
|
|
1225
1242
|
"context:execute",
|
|
1226
1243
|
"context:subscribe",
|