@calimero-network/mero-react 4.6.0 → 5.0.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/README.md +0 -1
- package/dist/index.cjs +25 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -63
- package/dist/index.d.ts +4 -63
- package/dist/index.js +5 -83
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -352,7 +352,6 @@ useGroupInfo, useGroupMembers, useGroupContexts, useGroupInvitations, useGroupCa
|
|
|
352
352
|
useJoinGroup, useDeleteGroup, useAddGroupMembers, useRemoveGroupMembers
|
|
353
353
|
useSyncGroup, useReparentGroup, useSubgroups
|
|
354
354
|
useUpgradeGroup, useGroupUpgradeStatus, useRetryGroupUpgrade
|
|
355
|
-
useRegisterGroupSigningKey, useUpdateGroupSettings
|
|
356
355
|
useSetGroupMetadata, useSetMemberMetadata, useSetContextMetadata
|
|
357
356
|
useGroupMetadata, useMemberMetadata, useUpdateMemberRole
|
|
358
357
|
useSetDefaultCapabilities, useDefaultCapabilities
|
package/dist/index.cjs
CHANGED
|
@@ -569,59 +569,6 @@ function CalimeroLogo({
|
|
|
569
569
|
);
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
// src/utils/nodeDiscovery.ts
|
|
573
|
-
var DEFAULT_LOCAL_NODE_PORTS = [2428, 2429, 2528, 2529];
|
|
574
|
-
var LOCAL_HOST = "localhost";
|
|
575
|
-
var DEFAULT_PROBE_TIMEOUT_MS = 2e3;
|
|
576
|
-
function localNodeUrl(port) {
|
|
577
|
-
return `http://${LOCAL_HOST}:${port}`;
|
|
578
|
-
}
|
|
579
|
-
function nodeEndpoint(baseUrl, path) {
|
|
580
|
-
const base = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
581
|
-
return new URL(path, base).toString();
|
|
582
|
-
}
|
|
583
|
-
async function probeNodeHealth(baseUrl, options = {}) {
|
|
584
|
-
const { timeoutMs = DEFAULT_PROBE_TIMEOUT_MS, signal } = options;
|
|
585
|
-
if (signal?.aborted) return false;
|
|
586
|
-
const controller = new AbortController();
|
|
587
|
-
const onAbort = () => controller.abort();
|
|
588
|
-
const listenerAdded = !!signal;
|
|
589
|
-
if (listenerAdded) signal.addEventListener("abort", onAbort, { once: true });
|
|
590
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
591
|
-
try {
|
|
592
|
-
const url = nodeEndpoint(baseUrl, "admin-api/health");
|
|
593
|
-
const res = await fetch(url, {
|
|
594
|
-
method: "GET",
|
|
595
|
-
signal: controller.signal
|
|
596
|
-
});
|
|
597
|
-
if (!res.ok) return false;
|
|
598
|
-
try {
|
|
599
|
-
const body = await res.json();
|
|
600
|
-
const status = body?.data?.status !== void 0 ? body?.data?.status : body?.status;
|
|
601
|
-
if (status === void 0) return true;
|
|
602
|
-
return typeof status === "string" && status.toLowerCase() === "alive";
|
|
603
|
-
} catch {
|
|
604
|
-
return true;
|
|
605
|
-
}
|
|
606
|
-
} catch {
|
|
607
|
-
return false;
|
|
608
|
-
} finally {
|
|
609
|
-
clearTimeout(timer);
|
|
610
|
-
if (listenerAdded) signal.removeEventListener("abort", onAbort);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
async function discoverLocalNodes(options = {}) {
|
|
614
|
-
const { ports = DEFAULT_LOCAL_NODE_PORTS, timeoutMs, signal } = options;
|
|
615
|
-
const results = await Promise.all(
|
|
616
|
-
ports.map(async (port) => {
|
|
617
|
-
const url = localNodeUrl(port);
|
|
618
|
-
const ok = await probeNodeHealth(url, { timeoutMs, signal });
|
|
619
|
-
return ok ? url : null;
|
|
620
|
-
})
|
|
621
|
-
);
|
|
622
|
-
return results.filter((url) => url !== null);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
572
|
// src/theme.ts
|
|
626
573
|
var defaultMeroTheme = Object.freeze({
|
|
627
574
|
primary: "#a5ff11",
|
|
@@ -921,7 +868,7 @@ function LoginModal({
|
|
|
921
868
|
onClose,
|
|
922
869
|
isOpen,
|
|
923
870
|
theme,
|
|
924
|
-
localNodePorts = DEFAULT_LOCAL_NODE_PORTS
|
|
871
|
+
localNodePorts = meroJs.DEFAULT_LOCAL_NODE_PORTS
|
|
925
872
|
}) {
|
|
926
873
|
const [selected, setSelected] = react.useState(CUSTOM_SELECTION);
|
|
927
874
|
const [discovered, setDiscovered] = react.useState([]);
|
|
@@ -952,7 +899,7 @@ function LoginModal({
|
|
|
952
899
|
setDiscovering(true);
|
|
953
900
|
setDiscovered([]);
|
|
954
901
|
setError(null);
|
|
955
|
-
discoverLocalNodes({ ports: localNodePorts, signal: controller.signal }).then((nodes) => {
|
|
902
|
+
meroJs.discoverLocalNodes({ ports: localNodePorts, signal: controller.signal }).then((nodes) => {
|
|
956
903
|
if (!active) return;
|
|
957
904
|
setDiscovered(nodes);
|
|
958
905
|
setSelected(nodes.length > 0 ? nodes[0] : CUSTOM_SELECTION);
|
|
@@ -986,7 +933,7 @@ function LoginModal({
|
|
|
986
933
|
setError(null);
|
|
987
934
|
try {
|
|
988
935
|
const response = await fetch(
|
|
989
|
-
nodeEndpoint(normalizedUrl, "admin-api/is-authed")
|
|
936
|
+
meroJs.nodeEndpoint(normalizedUrl, "admin-api/is-authed")
|
|
990
937
|
);
|
|
991
938
|
if (response.ok || response.status === 401) {
|
|
992
939
|
setLoading(false);
|
|
@@ -1517,7 +1464,6 @@ function useGroupMembers(groupId) {
|
|
|
1517
1464
|
);
|
|
1518
1465
|
return {
|
|
1519
1466
|
members: data?.members ?? [],
|
|
1520
|
-
selfIdentity: data?.selfIdentity ?? null,
|
|
1521
1467
|
loading,
|
|
1522
1468
|
error,
|
|
1523
1469
|
refetch
|
|
@@ -2018,18 +1964,6 @@ function useSetTeeAdmissionPolicy() {
|
|
|
2018
1964
|
);
|
|
2019
1965
|
return { setTeeAdmissionPolicy, loading, error };
|
|
2020
1966
|
}
|
|
2021
|
-
function useUpdateGroupSettings() {
|
|
2022
|
-
const { mero } = useMero();
|
|
2023
|
-
const { loading, error, run } = useAsyncMutation();
|
|
2024
|
-
const updateGroupSettings = react.useCallback(
|
|
2025
|
-
async (groupId, request) => {
|
|
2026
|
-
if (!mero) return null;
|
|
2027
|
-
return run(() => mero.admin.updateGroupSettings(groupId, request));
|
|
2028
|
-
},
|
|
2029
|
-
[mero, run]
|
|
2030
|
-
);
|
|
2031
|
-
return { updateGroupSettings, loading, error };
|
|
2032
|
-
}
|
|
2033
1967
|
function useSetGroupMetadata() {
|
|
2034
1968
|
const { mero } = useMero();
|
|
2035
1969
|
const { loading, error, run } = useAsyncMutation();
|
|
@@ -2118,18 +2052,6 @@ function useMemberMetadata(groupId, identity) {
|
|
|
2118
2052
|
}, [run]);
|
|
2119
2053
|
return { metadata, loading, error, refetch };
|
|
2120
2054
|
}
|
|
2121
|
-
function useRegisterGroupSigningKey() {
|
|
2122
|
-
const { mero } = useMero();
|
|
2123
|
-
const { loading, error, run } = useAsyncMutation();
|
|
2124
|
-
const registerGroupSigningKey = react.useCallback(
|
|
2125
|
-
async (groupId, request) => {
|
|
2126
|
-
if (!mero) return null;
|
|
2127
|
-
return run(() => mero.admin.registerGroupSigningKey(groupId, request));
|
|
2128
|
-
},
|
|
2129
|
-
[mero, run]
|
|
2130
|
-
);
|
|
2131
|
-
return { registerGroupSigningKey, loading, error };
|
|
2132
|
-
}
|
|
2133
2055
|
function useUpgradeGroup() {
|
|
2134
2056
|
const { mero } = useMero();
|
|
2135
2057
|
const { loading, error, run } = useAsyncMutation();
|
|
@@ -2471,12 +2393,12 @@ function useGroupAppVersion(groupId) {
|
|
|
2471
2393
|
if (namespace) {
|
|
2472
2394
|
appKey = namespace.appKey;
|
|
2473
2395
|
applicationId = namespace.targetApplicationId;
|
|
2474
|
-
upgradePolicy = namespace.upgradePolicy;
|
|
2396
|
+
upgradePolicy = namespace.upgradePolicy ?? null;
|
|
2475
2397
|
} else {
|
|
2476
2398
|
const info = await mero.admin.getGroupInfo(groupId);
|
|
2477
2399
|
appKey = info.appKey;
|
|
2478
2400
|
applicationId = info.targetApplicationId;
|
|
2479
|
-
upgradePolicy = info.upgradePolicy;
|
|
2401
|
+
upgradePolicy = info.upgradePolicy ?? null;
|
|
2480
2402
|
activeUpgrade = info.activeUpgrade ?? null;
|
|
2481
2403
|
}
|
|
2482
2404
|
let version = null;
|
|
@@ -2665,10 +2587,30 @@ Object.defineProperty(exports, "CAPABILITIES", {
|
|
|
2665
2587
|
enumerable: true,
|
|
2666
2588
|
get: function () { return meroJs.CAPABILITIES; }
|
|
2667
2589
|
});
|
|
2590
|
+
Object.defineProperty(exports, "DEFAULT_LOCAL_NODE_PORTS", {
|
|
2591
|
+
enumerable: true,
|
|
2592
|
+
get: function () { return meroJs.DEFAULT_LOCAL_NODE_PORTS; }
|
|
2593
|
+
});
|
|
2594
|
+
Object.defineProperty(exports, "discoverLocalNodes", {
|
|
2595
|
+
enumerable: true,
|
|
2596
|
+
get: function () { return meroJs.discoverLocalNodes; }
|
|
2597
|
+
});
|
|
2668
2598
|
Object.defineProperty(exports, "hasCap", {
|
|
2669
2599
|
enumerable: true,
|
|
2670
2600
|
get: function () { return meroJs.hasCap; }
|
|
2671
2601
|
});
|
|
2602
|
+
Object.defineProperty(exports, "localNodeUrl", {
|
|
2603
|
+
enumerable: true,
|
|
2604
|
+
get: function () { return meroJs.localNodeUrl; }
|
|
2605
|
+
});
|
|
2606
|
+
Object.defineProperty(exports, "nodeEndpoint", {
|
|
2607
|
+
enumerable: true,
|
|
2608
|
+
get: function () { return meroJs.nodeEndpoint; }
|
|
2609
|
+
});
|
|
2610
|
+
Object.defineProperty(exports, "probeNodeHealth", {
|
|
2611
|
+
enumerable: true,
|
|
2612
|
+
get: function () { return meroJs.probeNodeHealth; }
|
|
2613
|
+
});
|
|
2672
2614
|
Object.defineProperty(exports, "withCap", {
|
|
2673
2615
|
enumerable: true,
|
|
2674
2616
|
get: function () { return meroJs.withCap; }
|
|
@@ -2681,7 +2623,6 @@ exports.AppMode = AppMode;
|
|
|
2681
2623
|
exports.CalimeroLogo = CalimeroLogo;
|
|
2682
2624
|
exports.ConnectButton = ConnectButton;
|
|
2683
2625
|
exports.ConnectionType = ConnectionType;
|
|
2684
|
-
exports.DEFAULT_LOCAL_NODE_PORTS = DEFAULT_LOCAL_NODE_PORTS;
|
|
2685
2626
|
exports.LoginModal = LoginModal;
|
|
2686
2627
|
exports.MERO_CSS_VARS = MERO_CSS_VARS;
|
|
2687
2628
|
exports.MeroContext = MeroContext;
|
|
@@ -2696,16 +2637,12 @@ exports.clearNodeUrl = clearNodeUrl;
|
|
|
2696
2637
|
exports.clearTokenNodeUrl = clearTokenNodeUrl;
|
|
2697
2638
|
exports.cssVar = cssVar;
|
|
2698
2639
|
exports.defaultMeroTheme = defaultMeroTheme;
|
|
2699
|
-
exports.discoverLocalNodes = discoverLocalNodes;
|
|
2700
2640
|
exports.getApplicationId = getApplicationId;
|
|
2701
2641
|
exports.getContextId = getContextId;
|
|
2702
2642
|
exports.getContextIdentity = getContextIdentity;
|
|
2703
2643
|
exports.getNodeUrl = getNodeUrl;
|
|
2704
2644
|
exports.getTokenNodeUrl = getTokenNodeUrl;
|
|
2705
|
-
exports.localNodeUrl = localNodeUrl;
|
|
2706
2645
|
exports.localStorageTokenStorage = localStorageTokenStorage;
|
|
2707
|
-
exports.nodeEndpoint = nodeEndpoint;
|
|
2708
|
-
exports.probeNodeHealth = probeNodeHealth;
|
|
2709
2646
|
exports.resolveMeroTheme = resolveMeroTheme;
|
|
2710
2647
|
exports.setApplicationId = setApplicationId;
|
|
2711
2648
|
exports.setContextId = setContextId;
|
|
@@ -2752,7 +2689,6 @@ exports.useNamespaceGroups = useNamespaceGroups;
|
|
|
2752
2689
|
exports.useNamespaceIdentity = useNamespaceIdentity;
|
|
2753
2690
|
exports.useNamespaces = useNamespaces;
|
|
2754
2691
|
exports.useNamespacesForApplication = useNamespacesForApplication;
|
|
2755
|
-
exports.useRegisterGroupSigningKey = useRegisterGroupSigningKey;
|
|
2756
2692
|
exports.useRemoveGroupMembers = useRemoveGroupMembers;
|
|
2757
2693
|
exports.useReparentGroup = useReparentGroup;
|
|
2758
2694
|
exports.useResyncContext = useResyncContext;
|
|
@@ -2767,7 +2703,6 @@ exports.useSubgroupVisibility = useSubgroupVisibility;
|
|
|
2767
2703
|
exports.useSubgroups = useSubgroups;
|
|
2768
2704
|
exports.useSubscription = useSubscription;
|
|
2769
2705
|
exports.useSyncGroup = useSyncGroup;
|
|
2770
|
-
exports.useUpdateGroupSettings = useUpdateGroupSettings;
|
|
2771
2706
|
exports.useUpdateMemberRole = useUpdateMemberRole;
|
|
2772
2707
|
exports.useUpgradeGroup = useUpgradeGroup;
|
|
2773
2708
|
Object.keys(meroJs).forEach(function (k) {
|