@calimero-network/mero-react 9.11.1 → 9.11.2

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 CHANGED
@@ -3133,6 +3133,8 @@ function base58ToHex(input) {
3133
3133
  for (let k = 0; k < input.length && input[k] === "1"; k++) bytes.push(0);
3134
3134
  return bytes.reverse().map((b) => b.toString(16).padStart(2, "0")).join("");
3135
3135
  }
3136
+
3137
+ // src/hooks/index.ts
3136
3138
  var NO_EPHEMERAL_SURFACE_MESSAGE = "useEphemeral: this client has no `mero.ephemeral` surface. Ephemeral presence requires @calimero-network/mero-js >= 9.1.0; upgrade the installed @calimero-network/mero-js (and any lockfile pin) to use it.";
3137
3139
  var COULD_NOT_RESOLVE_IDENTITY_MESSAGE = "useEphemeral: could not resolve a local context identity, so your own presence cannot be filtered out. Pass includeSelf: true to accept this.";
3138
3140
  var REPLAY_RECONCILE_MS = 50;
@@ -3498,9 +3500,9 @@ function useSubscription(input, callback) {
3498
3500
  }, [mero, contextIdsKey, groupIdsKey]);
3499
3501
  }
3500
3502
  function useContexts(applicationId) {
3501
- const { mero, isDelegated } = useMero();
3503
+ const { admin, isDelegated } = useMero();
3502
3504
  const { data, loading, error, refetch } = useAsyncResource(
3503
- mero ? async () => {
3505
+ admin ? async () => {
3504
3506
  if (isDelegated) {
3505
3507
  const session = readDelegatedSession();
3506
3508
  const listed = session ? await listDelegatedContexts(session) : [];
@@ -3509,11 +3511,11 @@ function useContexts(applicationId) {
3509
3511
  );
3510
3512
  return mapApplicationContexts(own);
3511
3513
  }
3512
- const response = applicationId ? await mero.admin.getContextsForApplication(applicationId) : await mero.admin.getContexts();
3514
+ const response = applicationId ? await admin.getContextsForApplication(applicationId) : await admin.getContexts();
3513
3515
  return mapApplicationContexts(response.contexts ?? []);
3514
3516
  } : null,
3515
3517
  [],
3516
- [mero, applicationId, isDelegated]
3518
+ [admin, applicationId, isDelegated]
3517
3519
  );
3518
3520
  return { contexts: data, loading, error, refetch };
3519
3521
  }
@@ -3521,11 +3523,11 @@ function useApplicationContexts(applicationId) {
3521
3523
  return useContexts(applicationId);
3522
3524
  }
3523
3525
  function useGroupMembers(groupId) {
3524
- const { mero } = useMero();
3526
+ const { admin } = useMero();
3525
3527
  const { data, loading, error, refetch } = useAsyncResource(
3526
- mero && groupId ? () => mero.admin.listGroupMembers(groupId) : null,
3528
+ admin && groupId ? () => admin.listGroupMembers(groupId) : null,
3527
3529
  null,
3528
- [mero, groupId]
3530
+ [admin, groupId]
3529
3531
  );
3530
3532
  return {
3531
3533
  members: data?.members ?? [],
@@ -3535,44 +3537,44 @@ function useGroupMembers(groupId) {
3535
3537
  };
3536
3538
  }
3537
3539
  function useGroupContexts(groupId) {
3538
- const { mero } = useMero();
3540
+ const { admin } = useMero();
3539
3541
  const { data, loading, error, refetch } = useAsyncResource(
3540
- mero && groupId ? () => mero.admin.listGroupContexts(groupId) : null,
3542
+ admin && groupId ? () => admin.listGroupContexts(groupId) : null,
3541
3543
  [],
3542
- [mero, groupId]
3544
+ [admin, groupId]
3543
3545
  );
3544
3546
  return { contexts: data, loading, error, refetch };
3545
3547
  }
3546
3548
  function useGroupInvitations() {
3547
- const { mero } = useMero();
3549
+ const { admin } = useMero();
3548
3550
  const { loading, error, run } = useAsyncMutation();
3549
3551
  const createInvitation = react.useCallback(
3550
3552
  async (groupId, request) => {
3551
- if (!mero) {
3553
+ if (!admin) {
3552
3554
  return null;
3553
3555
  }
3554
- return run(() => mero.admin.createGroupInvitation(groupId, request));
3556
+ return run(() => admin.createGroupInvitation(groupId, request));
3555
3557
  },
3556
- [mero, run]
3558
+ [admin, run]
3557
3559
  );
3558
3560
  return { createInvitation, loading, error };
3559
3561
  }
3560
3562
  function useJoinGroup() {
3561
- const { mero } = useMero();
3563
+ const { admin } = useMero();
3562
3564
  const { loading, error, run } = useAsyncMutation();
3563
3565
  const joinGroup = react.useCallback(
3564
3566
  async (request) => {
3565
- if (!mero) {
3567
+ if (!admin) {
3566
3568
  return null;
3567
3569
  }
3568
- return run(() => mero.admin.joinGroup(request));
3570
+ return run(() => admin.joinGroup(request));
3569
3571
  },
3570
- [mero, run]
3572
+ [admin, run]
3571
3573
  );
3572
3574
  return { joinGroup, loading, error };
3573
3575
  }
3574
3576
  function useGroupCapabilities(groupId, memberId) {
3575
- const { mero } = useMero();
3577
+ const { admin } = useMero();
3576
3578
  const [capabilities, setCapabilitiesState] = react.useState(null);
3577
3579
  const [loading, setLoading] = react.useState(false);
3578
3580
  const [error, setError] = react.useState(null);
@@ -3580,7 +3582,7 @@ function useGroupCapabilities(groupId, memberId) {
3580
3582
  const reqRef = react.useRef(0);
3581
3583
  const refetch = react.useCallback(async () => {
3582
3584
  const seq = ++reqRef.current;
3583
- if (!mero || !groupId || !memberId) {
3585
+ if (!admin || !groupId || !memberId) {
3584
3586
  if (mountedRef.current && seq === reqRef.current) {
3585
3587
  setCapabilitiesState(null);
3586
3588
  setError(null);
@@ -3593,7 +3595,7 @@ function useGroupCapabilities(groupId, memberId) {
3593
3595
  setError(null);
3594
3596
  }
3595
3597
  try {
3596
- const response = await mero.admin.getMemberCapabilities(groupId, memberId);
3598
+ const response = await admin.getMemberCapabilities(groupId, memberId);
3597
3599
  if (mountedRef.current && seq === reqRef.current) {
3598
3600
  setCapabilitiesState(response.capabilities);
3599
3601
  }
@@ -3609,7 +3611,7 @@ function useGroupCapabilities(groupId, memberId) {
3609
3611
  setLoading(false);
3610
3612
  }
3611
3613
  }
3612
- }, [groupId, memberId, mero, mountedRef]);
3614
+ }, [groupId, memberId, admin, mountedRef]);
3613
3615
  react.useEffect(() => {
3614
3616
  reqRef.current += 1;
3615
3617
  setCapabilitiesState(null);
@@ -3620,7 +3622,7 @@ function useGroupCapabilities(groupId, memberId) {
3620
3622
  }, [refetch]);
3621
3623
  const setCapabilities = react.useCallback(
3622
3624
  async (nextCapabilities) => {
3623
- if (!mero || !groupId || !memberId) {
3625
+ if (!admin || !groupId || !memberId) {
3624
3626
  return null;
3625
3627
  }
3626
3628
  if (mountedRef.current) {
@@ -3628,7 +3630,7 @@ function useGroupCapabilities(groupId, memberId) {
3628
3630
  setError(null);
3629
3631
  }
3630
3632
  try {
3631
- await mero.admin.setMemberCapabilities(groupId, memberId, { capabilities: nextCapabilities });
3633
+ await admin.setMemberCapabilities(groupId, memberId, { capabilities: nextCapabilities });
3632
3634
  if (mountedRef.current) {
3633
3635
  setCapabilitiesState(nextCapabilities);
3634
3636
  }
@@ -3645,19 +3647,19 @@ function useGroupCapabilities(groupId, memberId) {
3645
3647
  }
3646
3648
  }
3647
3649
  },
3648
- [groupId, memberId, mero, mountedRef]
3650
+ [groupId, memberId, admin, mountedRef]
3649
3651
  );
3650
3652
  return { capabilities, loading, error, refetch, setCapabilities };
3651
3653
  }
3652
3654
  function useContextDiscovery(options) {
3653
- const { mero } = useMero();
3655
+ const { admin } = useMero();
3654
3656
  const [context, setContext] = react.useState(null);
3655
3657
  const [loading, setLoading] = react.useState(false);
3656
3658
  const [error, setError] = react.useState(null);
3657
3659
  const mountedRef = useMountedRef();
3658
3660
  const knownContextIdsKey = JSON.stringify(options.knownContextIds ?? []);
3659
3661
  const discover = react.useCallback(async () => {
3660
- if (!mero) {
3662
+ if (!admin) {
3661
3663
  const notConnectedError = new Error("Not connected");
3662
3664
  if (mountedRef.current) {
3663
3665
  setError(notConnectedError);
@@ -3676,7 +3678,7 @@ function useContextDiscovery(options) {
3676
3678
  while (Date.now() <= deadline) {
3677
3679
  if (options.targetAlias) {
3678
3680
  const aliasMatch = extractAliasContextId(
3679
- await mero.admin.lookupContextAlias(options.targetAlias)
3681
+ await admin.lookupContextAlias(options.targetAlias)
3680
3682
  );
3681
3683
  if (aliasMatch && !knownContextIds.has(aliasMatch)) {
3682
3684
  const discoveredFromAlias = {
@@ -3689,7 +3691,7 @@ function useContextDiscovery(options) {
3689
3691
  return discoveredFromAlias;
3690
3692
  }
3691
3693
  }
3692
- const response = await mero.admin.getContextsForApplication(options.applicationId);
3694
+ const response = await admin.getContextsForApplication(options.applicationId);
3693
3695
  const contexts = mapApplicationContexts(response.contexts ?? []);
3694
3696
  const discovered = contexts.find(
3695
3697
  (applicationContext) => !knownContextIds.has(applicationContext.contextId)
@@ -3727,7 +3729,7 @@ function useContextDiscovery(options) {
3727
3729
  }
3728
3730
  }, [
3729
3731
  knownContextIdsKey,
3730
- mero,
3732
+ admin,
3731
3733
  mountedRef,
3732
3734
  options.applicationId,
3733
3735
  options.knownContextIds,
@@ -3745,7 +3747,7 @@ function useContextDiscovery(options) {
3745
3747
  return { context, loading, error, discover, reset };
3746
3748
  }
3747
3749
  function useCreateContext() {
3748
- const { mero, isDelegated } = useMero();
3750
+ const { admin, isDelegated } = useMero();
3749
3751
  const { loading, error, run } = useAsyncMutation();
3750
3752
  const createContext2 = react.useCallback(
3751
3753
  async (request) => {
@@ -3760,15 +3762,15 @@ function useCreateContext() {
3760
3762
  })
3761
3763
  );
3762
3764
  }
3763
- if (!mero) return null;
3764
- return run(() => mero.admin.createContext(request));
3765
+ if (!admin) return null;
3766
+ return run(() => admin.createContext(request));
3765
3767
  },
3766
- [mero, run, isDelegated]
3768
+ [admin, run, isDelegated]
3767
3769
  );
3768
3770
  return { createContext: createContext2, loading, error };
3769
3771
  }
3770
3772
  function useCreatePrivateContext() {
3771
- const { mero, isDelegated } = useMero();
3773
+ const { admin, isDelegated } = useMero();
3772
3774
  const { loading, error, run } = useAsyncMutation();
3773
3775
  const createPrivateContext = react.useCallback(
3774
3776
  async (request) => {
@@ -3777,15 +3779,15 @@ function useCreatePrivateContext() {
3777
3779
  if (!session) return null;
3778
3780
  return run(() => createDelegatedPrivateContext(session, request));
3779
3781
  }
3780
- if (!mero) return null;
3782
+ if (!admin) return null;
3781
3783
  return run(async () => {
3782
- const { groupId } = await mero.admin.createGroupInNamespace(request.namespaceId, {
3784
+ const { groupId } = await admin.createGroupInNamespace(request.namespaceId, {
3783
3785
  visibility: "restricted"
3784
3786
  });
3785
- await mero.admin.addGroupMembers(groupId, {
3787
+ await admin.addGroupMembers(groupId, {
3786
3788
  members: request.members.map((identity) => ({ identity, role: "Member" }))
3787
3789
  });
3788
- const { contextId } = await mero.admin.createContext({
3790
+ const { contextId } = await admin.createContext({
3789
3791
  applicationId: request.applicationId,
3790
3792
  groupId,
3791
3793
  initializationParams: request.initializationParams
@@ -3793,36 +3795,36 @@ function useCreatePrivateContext() {
3793
3795
  return { contextId };
3794
3796
  });
3795
3797
  },
3796
- [mero, run, isDelegated]
3798
+ [admin, run, isDelegated]
3797
3799
  );
3798
3800
  return { createPrivateContext, loading, error };
3799
3801
  }
3800
3802
  function useDeleteContext() {
3801
- const { mero } = useMero();
3803
+ const { admin } = useMero();
3802
3804
  const { loading, error, run } = useAsyncMutation();
3803
3805
  const deleteContext = react.useCallback(
3804
3806
  async (contextId) => {
3805
- if (!mero) return null;
3806
- return run(() => mero.admin.deleteContext(contextId));
3807
+ if (!admin) return null;
3808
+ return run(() => admin.deleteContext(contextId));
3807
3809
  },
3808
- [mero, run]
3810
+ [admin, run]
3809
3811
  );
3810
3812
  return { deleteContext, loading, error };
3811
3813
  }
3812
3814
  function useJoinContext(options = {}) {
3813
- const { mero } = useMero();
3815
+ const { admin } = useMero();
3814
3816
  const { loading, error, failure, run } = useAsyncMutation(options);
3815
3817
  const joinContext = react.useCallback(
3816
3818
  async (contextId) => {
3817
- if (!mero) return null;
3818
- return run(() => mero.admin.joinContext(contextId));
3819
+ if (!admin) return null;
3820
+ return run(() => admin.joinContext(contextId));
3819
3821
  },
3820
- [mero, run]
3822
+ [admin, run]
3821
3823
  );
3822
3824
  return { joinContext, loading, error, failure };
3823
3825
  }
3824
3826
  function useJoinSubgroupInheritance() {
3825
- const { mero, isDelegated } = useMero();
3827
+ const { admin, isDelegated } = useMero();
3826
3828
  const { loading, error, run } = useAsyncMutation();
3827
3829
  const joinSubgroupInheritance = react.useCallback(
3828
3830
  async (groupId) => {
@@ -3835,425 +3837,334 @@ function useJoinSubgroupInheritance() {
3835
3837
  return { groupId, memberPublicKey: publicKey, wasInherited: false };
3836
3838
  });
3837
3839
  }
3838
- if (!mero) return null;
3839
- return run(() => mero.admin.joinSubgroupInheritance(groupId));
3840
+ if (!admin) return null;
3841
+ return run(() => admin.joinSubgroupInheritance(groupId));
3840
3842
  },
3841
- [mero, run, isDelegated]
3843
+ [admin, run, isDelegated]
3842
3844
  );
3843
3845
  return { joinSubgroupInheritance, loading, error };
3844
3846
  }
3845
3847
  function useContextGroup(contextId) {
3846
- const { mero } = useMero();
3848
+ const { admin } = useMero();
3847
3849
  const { data, loading, error, refetch } = useAsyncResource(
3848
- mero && contextId ? () => mero.admin.getContextGroup(contextId) : null,
3850
+ admin && contextId ? () => admin.getContextGroup(contextId) : null,
3849
3851
  null,
3850
- [mero, contextId]
3852
+ [admin, contextId]
3851
3853
  );
3852
3854
  return { groupId: data, loading, error, refetch };
3853
3855
  }
3854
3856
  function useGroupInfo(groupId) {
3855
- const { mero } = useMero();
3857
+ const { admin } = useMero();
3856
3858
  const { data, loading, error, refetch } = useAsyncResource(
3857
- mero && groupId ? () => mero.admin.getGroupInfo(groupId) : null,
3859
+ admin && groupId ? () => admin.getGroupInfo(groupId) : null,
3858
3860
  null,
3859
- [mero, groupId]
3861
+ [admin, groupId]
3860
3862
  );
3861
3863
  return { groupInfo: data, loading, error, refetch };
3862
3864
  }
3863
3865
  function useDeleteGroup() {
3864
- const { mero, isDelegated } = useMero();
3866
+ const { admin } = useMero();
3865
3867
  const { loading, error, run } = useAsyncMutation();
3866
3868
  const deleteGroup = react.useCallback(
3867
3869
  async (groupId) => {
3868
- if (isDelegated) {
3869
- const session = readDelegatedSession();
3870
- if (!session) return null;
3871
- return run(() => governRoot(session, groupId, meroJs.groupDeletedOp(groupId)));
3872
- }
3873
- if (!mero) return null;
3874
- return run(() => mero.admin.deleteGroup(groupId));
3870
+ if (!admin) return null;
3871
+ return run(() => admin.deleteGroup(groupId));
3875
3872
  },
3876
- [mero, run, isDelegated]
3873
+ [admin, run]
3877
3874
  );
3878
3875
  return { deleteGroup, loading, error };
3879
3876
  }
3880
3877
  function useSyncGroup() {
3881
- const { mero } = useMero();
3878
+ const { admin } = useMero();
3882
3879
  const { loading, error, run } = useAsyncMutation();
3883
3880
  const syncGroup = react.useCallback(
3884
3881
  async (groupId) => {
3885
- if (!mero) return null;
3886
- return run(() => mero.admin.syncGroup(groupId));
3882
+ if (!admin) return null;
3883
+ return run(() => admin.syncGroup(groupId));
3887
3884
  },
3888
- [mero, run]
3885
+ [admin, run]
3889
3886
  );
3890
3887
  return { syncGroup, loading, error };
3891
3888
  }
3892
3889
  function useAddGroupMembers() {
3893
- const { mero, isDelegated } = useMero();
3890
+ const { admin } = useMero();
3894
3891
  const { loading, error, run } = useAsyncMutation();
3895
3892
  const addGroupMembers = react.useCallback(
3896
3893
  async (groupId, request) => {
3897
- if (isDelegated) {
3898
- const session = readDelegatedSession();
3899
- if (!session) return null;
3900
- return run(async () => {
3901
- for (const m of request.members) {
3902
- await governGroup(session, groupId, meroJs.memberAddedOp(m.identity, m.role));
3903
- }
3904
- });
3905
- }
3906
- if (!mero) return null;
3907
- return run(() => mero.admin.addGroupMembers(groupId, request));
3894
+ if (!admin) return null;
3895
+ return run(() => admin.addGroupMembers(groupId, request));
3908
3896
  },
3909
- [mero, run, isDelegated]
3897
+ [admin, run]
3910
3898
  );
3911
3899
  return { addGroupMembers, loading, error };
3912
3900
  }
3913
3901
  function useRemoveGroupMembers() {
3914
- const { mero, isDelegated } = useMero();
3902
+ const { admin } = useMero();
3915
3903
  const { loading, error, run } = useAsyncMutation();
3916
3904
  const removeGroupMembers = react.useCallback(
3917
3905
  async (groupId, request) => {
3918
- if (isDelegated) {
3919
- const session = readDelegatedSession();
3920
- if (!session) return null;
3921
- return run(async () => {
3922
- for (const member of request.members) await governGroup(session, groupId, meroJs.memberRemovedOp(member));
3923
- });
3924
- }
3925
- if (!mero) return null;
3926
- return run(() => mero.admin.removeGroupMembers(groupId, request));
3906
+ if (!admin) return null;
3907
+ return run(() => admin.removeGroupMembers(groupId, request));
3927
3908
  },
3928
- [mero, run, isDelegated]
3909
+ [admin, run]
3929
3910
  );
3930
3911
  return { removeGroupMembers, loading, error };
3931
3912
  }
3932
3913
  function useNamespaces() {
3933
- const { mero } = useMero();
3914
+ const { admin } = useMero();
3934
3915
  const { data, loading, error, refetch } = useAsyncResource(
3935
- mero ? () => mero.admin.listNamespaces() : null,
3916
+ admin ? () => admin.listNamespaces() : null,
3936
3917
  [],
3937
- [mero]
3918
+ [admin]
3938
3919
  );
3939
3920
  return { namespaces: data, loading, error, refetch };
3940
3921
  }
3941
3922
  function useNamespace(namespaceId) {
3942
- const { mero } = useMero();
3923
+ const { admin } = useMero();
3943
3924
  const { data, loading, error, refetch } = useAsyncResource(
3944
- mero && namespaceId ? () => mero.admin.getNamespace(namespaceId) : null,
3925
+ admin && namespaceId ? () => admin.getNamespace(namespaceId) : null,
3945
3926
  null,
3946
- [mero, namespaceId]
3927
+ [admin, namespaceId]
3947
3928
  );
3948
3929
  return { namespace: data, loading, error, refetch };
3949
3930
  }
3950
3931
  function useNodeIdentity() {
3951
- const { mero } = useMero();
3932
+ const { admin } = useMero();
3952
3933
  const { data, loading, error, refetch } = useAsyncResource(
3953
- mero ? () => mero.admin.getNodeIdentity() : null,
3934
+ admin ? () => admin.getNodeIdentity() : null,
3954
3935
  null,
3955
- [mero]
3936
+ [admin]
3956
3937
  );
3957
3938
  return { identity: data, loading, error, refetch };
3958
3939
  }
3959
3940
  function useNamespaceIdentity(namespaceId) {
3960
- const { mero } = useMero();
3941
+ const { admin } = useMero();
3961
3942
  const { data, loading, error, refetch } = useAsyncResource(
3962
- mero && namespaceId ? () => mero.admin.getNamespaceIdentity(namespaceId) : null,
3943
+ admin && namespaceId ? () => admin.getNamespaceIdentity(namespaceId) : null,
3963
3944
  null,
3964
- [mero, namespaceId]
3945
+ [admin, namespaceId]
3965
3946
  );
3966
3947
  return { identity: data, loading, error, refetch };
3967
3948
  }
3968
3949
  function useNamespacesForApplication(applicationId) {
3969
- const { mero, isDelegated } = useMero();
3950
+ const { admin, isDelegated } = useMero();
3970
3951
  const { data, loading, error, refetch } = useAsyncResource(
3971
- mero && applicationId ? isDelegated ? async () => {
3952
+ admin && applicationId ? isDelegated ? async () => {
3972
3953
  const session = readDelegatedSession();
3973
3954
  const listed = session ? await listDelegatedNamespaces(session) : [];
3974
3955
  return listed.filter((ns) => ns.targetApplicationId === applicationId);
3975
- } : () => mero.admin.listNamespacesForApplication(applicationId) : null,
3956
+ } : () => admin.listNamespacesForApplication(applicationId) : null,
3976
3957
  [],
3977
- [mero, applicationId, isDelegated]
3958
+ [admin, applicationId, isDelegated]
3978
3959
  );
3979
3960
  return { namespaces: data, loading, error, refetch };
3980
3961
  }
3981
- var DEFAULT_REGISTRY_URL2 = "https://apps.calimero.network";
3982
3962
  function useCreateNamespace() {
3983
- const { mero, isDelegated, app, cloudBaseUrl } = useMero();
3963
+ const { admin } = useMero();
3984
3964
  const { loading, error, run } = useAsyncMutation();
3985
3965
  const createNamespace = react.useCallback(
3986
3966
  async (request) => {
3987
- if (isDelegated) {
3988
- const session = readDelegatedSession();
3989
- if (!session) return null;
3990
- const pkg = app.packageName;
3991
- return run(async () => {
3992
- if (!pkg) {
3993
- throw new Error("this app names no registry package, so a founded namespace could not be given its application");
3994
- }
3995
- const version = app.packageVersion ?? await latestPublishedVersion(app.registryUrl ?? DEFAULT_REGISTRY_URL2, pkg);
3996
- return foundDelegatedNamespace(
3997
- session,
3998
- {
3999
- defaultCapabilities: 231,
4000
- application: { applicationId: request.applicationId, package: pkg, version }
4001
- },
4002
- { cloudBaseUrl }
4003
- );
4004
- });
4005
- }
4006
- if (!mero) return null;
4007
- return run(() => mero.admin.createNamespace(request));
3967
+ if (!admin) return null;
3968
+ return run(() => admin.createNamespace(request));
4008
3969
  },
4009
- [mero, run, isDelegated, app, cloudBaseUrl]
3970
+ [admin, run]
4010
3971
  );
4011
3972
  return { createNamespace, loading, error };
4012
3973
  }
4013
3974
  function useDeleteNamespace() {
4014
- const { mero } = useMero();
3975
+ const { admin } = useMero();
4015
3976
  const { loading, error, run } = useAsyncMutation();
4016
3977
  const deleteNamespace = react.useCallback(
4017
3978
  async (namespaceId) => {
4018
- if (!mero) return null;
4019
- return run(() => mero.admin.deleteNamespace(namespaceId));
3979
+ if (!admin) return null;
3980
+ return run(() => admin.deleteNamespace(namespaceId));
4020
3981
  },
4021
- [mero, run]
3982
+ [admin, run]
4022
3983
  );
4023
3984
  return { deleteNamespace, loading, error };
4024
3985
  }
4025
3986
  function useCreateNamespaceInvitation() {
4026
- const { mero } = useMero();
3987
+ const { admin } = useMero();
4027
3988
  const { loading, error, run } = useAsyncMutation();
4028
3989
  const createNamespaceInvitation = react.useCallback(
4029
3990
  async (namespaceId, request) => {
4030
- if (!mero) return null;
4031
- return run(() => mero.admin.createNamespaceInvitation(namespaceId, request));
3991
+ if (!admin) return null;
3992
+ return run(() => admin.createNamespaceInvitation(namespaceId, request));
4032
3993
  },
4033
- [mero, run]
3994
+ [admin, run]
4034
3995
  );
4035
3996
  return { createNamespaceInvitation, loading, error };
4036
3997
  }
4037
3998
  function useJoinNamespace(options = {}) {
4038
- const { mero } = useMero();
3999
+ const { admin } = useMero();
4039
4000
  const { loading, error, failure, run } = useAsyncMutation(options);
4040
4001
  const joinNamespace = react.useCallback(
4041
4002
  async (namespaceId, request) => {
4042
- if (!mero) return null;
4043
- return run(() => mero.admin.joinNamespace(namespaceId, request));
4003
+ if (!admin) return null;
4004
+ return run(() => admin.joinNamespace(namespaceId, request));
4044
4005
  },
4045
- [mero, run]
4006
+ [admin, run]
4046
4007
  );
4047
4008
  return { joinNamespace, loading, error, failure };
4048
4009
  }
4049
4010
  function useRedeemInvitation() {
4050
- const { mero } = useMero();
4011
+ const { admin } = useMero();
4051
4012
  const mountedRef = useMountedRef();
4052
4013
  const [loading, setLoading] = react.useState(false);
4053
4014
  const [outcome, setOutcome] = react.useState(null);
4054
4015
  const redeem = react.useCallback(
4055
4016
  async (namespaceId, invitation, options = {}) => {
4056
- if (!mero) return null;
4017
+ if (!admin) return null;
4057
4018
  if (mountedRef.current) {
4058
4019
  setLoading(true);
4059
4020
  setOutcome(null);
4060
4021
  }
4061
4022
  try {
4062
- const result = await mero.admin.redeemInvitation(namespaceId, invitation, options);
4023
+ const result = await admin.redeemInvitation(namespaceId, invitation, options);
4063
4024
  if (mountedRef.current) setOutcome(result);
4064
4025
  return result;
4065
4026
  } finally {
4066
4027
  if (mountedRef.current) setLoading(false);
4067
4028
  }
4068
4029
  },
4069
- [mero, mountedRef]
4030
+ [admin, mountedRef]
4070
4031
  );
4071
4032
  return { redeem, outcome, loading };
4072
4033
  }
4073
4034
  function useCreateGroupInNamespace() {
4074
- const { mero, isDelegated } = useMero();
4035
+ const { admin } = useMero();
4075
4036
  const { loading, error, run } = useAsyncMutation();
4076
4037
  const createGroupInNamespace = react.useCallback(
4077
4038
  async (namespaceId, request) => {
4078
- if (isDelegated) {
4079
- const session = readDelegatedSession();
4080
- if (!session) return null;
4081
- return run(async () => {
4082
- const { groupId } = await governRoot(
4083
- session,
4084
- namespaceId,
4085
- // The id is derived from a fresh salt (core#4244); a node refuses any other.
4086
- (await meroJs.subgroupCreation({
4087
- parentId: namespaceId,
4088
- restricted: request?.visibility !== "open",
4089
- admin: session.account
4090
- })).op
4091
- );
4092
- rememberGroupNamespace(session.account, groupId, namespaceId);
4093
- return { groupId };
4094
- });
4095
- }
4096
- if (!mero) return null;
4097
- return run(() => mero.admin.createGroupInNamespace(namespaceId, request));
4039
+ if (!admin) return null;
4040
+ return run(() => admin.createGroupInNamespace(namespaceId, request));
4098
4041
  },
4099
- [mero, run, isDelegated]
4042
+ [admin, run]
4100
4043
  );
4101
4044
  return { createGroupInNamespace, loading, error };
4102
4045
  }
4103
4046
  function useNamespaceGroups(namespaceId) {
4104
- const { mero } = useMero();
4047
+ const { admin } = useMero();
4105
4048
  const { data, loading, error, refetch } = useAsyncResource(
4106
- mero && namespaceId ? () => mero.admin.listNamespaceGroups(namespaceId) : null,
4049
+ admin && namespaceId ? () => admin.listNamespaceGroups(namespaceId) : null,
4107
4050
  [],
4108
- [mero, namespaceId]
4051
+ [admin, namespaceId]
4109
4052
  );
4110
4053
  return { groups: data, loading, error, refetch };
4111
4054
  }
4112
4055
  function useUpdateMemberRole() {
4113
- const { mero, isDelegated } = useMero();
4056
+ const { admin } = useMero();
4114
4057
  const { loading, error, run } = useAsyncMutation();
4115
4058
  const updateMemberRole = react.useCallback(
4116
4059
  async (groupId, identity, request) => {
4117
- if (isDelegated) {
4118
- const session = readDelegatedSession();
4119
- if (!session) return null;
4120
- return run(() => governGroup(session, groupId, meroJs.memberRoleSetOp(identity, request.role)));
4121
- }
4122
- if (!mero) return null;
4123
- return run(() => mero.admin.updateMemberRole(groupId, identity, request));
4060
+ if (!admin) return null;
4061
+ return run(() => admin.updateMemberRole(groupId, identity, request));
4124
4062
  },
4125
- [mero, run, isDelegated]
4063
+ [admin, run]
4126
4064
  );
4127
4065
  return { updateMemberRole, loading, error };
4128
4066
  }
4129
4067
  function useSetDefaultCapabilities() {
4130
- const { mero, isDelegated } = useMero();
4068
+ const { admin } = useMero();
4131
4069
  const { loading, error, run } = useAsyncMutation();
4132
4070
  const setDefaultCapabilities = react.useCallback(
4133
4071
  async (groupId, request) => {
4134
- if (isDelegated) {
4135
- const session = readDelegatedSession();
4136
- if (!session) return null;
4137
- return run(() => governGroup(session, groupId, meroJs.defaultCapabilitiesSetOp(request.defaultCapabilities)));
4138
- }
4139
- if (!mero) return null;
4140
- return run(() => mero.admin.setDefaultCapabilities(groupId, request));
4072
+ if (!admin) return null;
4073
+ return run(() => admin.setDefaultCapabilities(groupId, request));
4141
4074
  },
4142
- [mero, run, isDelegated]
4075
+ [admin, run]
4143
4076
  );
4144
4077
  return { setDefaultCapabilities, loading, error };
4145
4078
  }
4146
4079
  function useSetSubgroupVisibility() {
4147
- const { mero, isDelegated } = useMero();
4080
+ const { admin } = useMero();
4148
4081
  const { loading, error, run } = useAsyncMutation();
4149
4082
  const setSubgroupVisibility = react.useCallback(
4150
4083
  async (groupId, request) => {
4151
- if (isDelegated) {
4152
- const session = readDelegatedSession();
4153
- if (!session) return null;
4154
- return run(
4155
- () => governGroup(session, groupId, meroJs.subgroupVisibilitySetOp(request.subgroupVisibility === "open" ? "open" : "restricted"))
4156
- );
4157
- }
4158
- if (!mero) return null;
4159
- return run(() => mero.admin.setSubgroupVisibility(groupId, request));
4084
+ if (!admin) return null;
4085
+ return run(() => admin.setSubgroupVisibility(groupId, request));
4160
4086
  },
4161
- [mero, run, isDelegated]
4087
+ [admin, run]
4162
4088
  );
4163
4089
  return { setSubgroupVisibility, loading, error };
4164
4090
  }
4165
4091
  function useDefaultCapabilities(groupId) {
4166
- const { mero } = useMero();
4092
+ const { admin } = useMero();
4167
4093
  const { data, loading, error, refetch } = useAsyncResource(
4168
- mero && groupId ? () => mero.admin.getDefaultCapabilities(groupId) : null,
4094
+ admin && groupId ? () => admin.getDefaultCapabilities(groupId) : null,
4169
4095
  null,
4170
- [mero, groupId]
4096
+ [admin, groupId]
4171
4097
  );
4172
4098
  return { defaultCapabilities: data, loading, error, refetch };
4173
4099
  }
4174
4100
  function useSubgroupVisibility(groupId) {
4175
- const { mero } = useMero();
4101
+ const { admin } = useMero();
4176
4102
  const { data, loading, error, refetch } = useAsyncResource(
4177
- mero && groupId ? () => mero.admin.getSubgroupVisibility(groupId) : null,
4103
+ admin && groupId ? () => admin.getSubgroupVisibility(groupId) : null,
4178
4104
  null,
4179
- [mero, groupId]
4105
+ [admin, groupId]
4180
4106
  );
4181
4107
  return { subgroupVisibility: data, loading, error, refetch };
4182
4108
  }
4183
4109
  function useSetTeeAdmissionPolicy() {
4184
- const { mero } = useMero();
4110
+ const { admin } = useMero();
4185
4111
  const { loading, error, run } = useAsyncMutation();
4186
4112
  const setTeeAdmissionPolicy = react.useCallback(
4187
4113
  async (groupId, request) => {
4188
- if (!mero) return null;
4189
- return run(() => mero.admin.setTeeAdmissionPolicy(groupId, request));
4114
+ if (!admin) return null;
4115
+ return run(() => admin.setTeeAdmissionPolicy(groupId, request));
4190
4116
  },
4191
- [mero, run]
4117
+ [admin, run]
4192
4118
  );
4193
4119
  return { setTeeAdmissionPolicy, loading, error };
4194
4120
  }
4195
4121
  function useSetGroupMetadata() {
4196
- const { mero, isDelegated } = useMero();
4122
+ const { admin } = useMero();
4197
4123
  const { loading, error, run } = useAsyncMutation();
4198
4124
  const setGroupMetadata = react.useCallback(
4199
4125
  async (groupId, request) => {
4200
- if (isDelegated) {
4201
- const session = readDelegatedSession();
4202
- if (!session) return null;
4203
- return run(() => governGroup(session, groupId, meroJs.groupMetadataSetOp(request)));
4204
- }
4205
- if (!mero) return null;
4206
- return run(() => mero.admin.setGroupMetadata(groupId, request));
4126
+ if (!admin) return null;
4127
+ return run(() => admin.setGroupMetadata(groupId, request));
4207
4128
  },
4208
- [mero, run, isDelegated]
4129
+ [admin, run]
4209
4130
  );
4210
4131
  return { setGroupMetadata, loading, error };
4211
4132
  }
4212
4133
  function useSetMemberMetadata() {
4213
- const { mero, isDelegated } = useMero();
4134
+ const { admin } = useMero();
4214
4135
  const { loading, error, run } = useAsyncMutation();
4215
4136
  const setMemberMetadata = react.useCallback(
4216
4137
  async (groupId, identity, request) => {
4217
- if (isDelegated) {
4218
- const session = readDelegatedSession();
4219
- if (!session) return null;
4220
- return run(() => governGroup(session, groupId, meroJs.memberMetadataSetOp(identity, request)));
4221
- }
4222
- if (!mero) return null;
4223
- return run(() => mero.admin.setMemberMetadata(groupId, identity, request));
4138
+ if (!admin) return null;
4139
+ return run(() => admin.setMemberMetadata(groupId, identity, request));
4224
4140
  },
4225
- [mero, run, isDelegated]
4141
+ [admin, run]
4226
4142
  );
4227
4143
  return { setMemberMetadata, loading, error };
4228
4144
  }
4229
4145
  function useSetContextMetadata() {
4230
- const { mero, isDelegated } = useMero();
4146
+ const { admin } = useMero();
4231
4147
  const { loading, error, run } = useAsyncMutation();
4232
4148
  const setContextMetadata = react.useCallback(
4233
4149
  async (groupId, contextId, request) => {
4234
- if (isDelegated) {
4235
- const session = readDelegatedSession();
4236
- if (!session) return null;
4237
- return run(() => governGroup(session, groupId, meroJs.contextMetadataSetOp(contextId, request)));
4238
- }
4239
- if (!mero) return null;
4240
- return run(() => mero.admin.setContextMetadata(groupId, contextId, request));
4150
+ if (!admin) return null;
4151
+ return run(() => admin.setContextMetadata(groupId, contextId, request));
4241
4152
  },
4242
- [mero, run, isDelegated]
4153
+ [admin, run]
4243
4154
  );
4244
4155
  return { setContextMetadata, loading, error };
4245
4156
  }
4246
4157
  function useGroupMetadata(groupId) {
4247
- const { mero } = useMero();
4158
+ const { admin } = useMero();
4248
4159
  const { data, loading, error, refetch } = useAsyncResource(
4249
- mero && groupId ? () => mero.admin.getGroupMetadata(groupId) : null,
4160
+ admin && groupId ? () => admin.getGroupMetadata(groupId) : null,
4250
4161
  null,
4251
- [mero, groupId]
4162
+ [admin, groupId]
4252
4163
  );
4253
4164
  return { metadata: data, loading, error, refetch };
4254
4165
  }
4255
4166
  function useMemberMetadata(groupId, identity) {
4256
- const { mero } = useMero();
4167
+ const { admin } = useMero();
4257
4168
  const [metadata, setMetadata] = react.useState(null);
4258
4169
  const [loading, setLoading] = react.useState(false);
4259
4170
  const [error, setError] = react.useState(null);
@@ -4266,7 +4177,7 @@ function useMemberMetadata(groupId, identity) {
4266
4177
  prevKey.current = key;
4267
4178
  const run = react.useCallback(
4268
4179
  async (signal) => {
4269
- if (!mero || !groupId || !identity) {
4180
+ if (!admin || !groupId || !identity) {
4270
4181
  if (!signal.aborted) {
4271
4182
  setMetadata(null);
4272
4183
  setError(null);
@@ -4279,7 +4190,7 @@ function useMemberMetadata(groupId, identity) {
4279
4190
  setError(null);
4280
4191
  }
4281
4192
  try {
4282
- const result = await mero.admin.getMemberMetadata(groupId, identity);
4193
+ const result = await admin.getMemberMetadata(groupId, identity);
4283
4194
  if (!signal.aborted) setMetadata(result);
4284
4195
  } catch (err) {
4285
4196
  if (!signal.aborted) setError(toError(err));
@@ -4287,7 +4198,7 @@ function useMemberMetadata(groupId, identity) {
4287
4198
  if (!signal.aborted) setLoading(false);
4288
4199
  }
4289
4200
  },
4290
- [mero, groupId, identity]
4201
+ [admin, groupId, identity]
4291
4202
  );
4292
4203
  react.useEffect(() => {
4293
4204
  const signal = { aborted: false };
@@ -4303,43 +4214,43 @@ function useMemberMetadata(groupId, identity) {
4303
4214
  return { metadata, loading, error, refetch };
4304
4215
  }
4305
4216
  function useUpgradeGroup() {
4306
- const { mero } = useMero();
4217
+ const { admin } = useMero();
4307
4218
  const { loading, error, run } = useAsyncMutation();
4308
4219
  const upgradeGroup = react.useCallback(
4309
4220
  async (groupId, request) => {
4310
- if (!mero) return null;
4311
- return run(() => mero.admin.upgradeGroup(groupId, request));
4221
+ if (!admin) return null;
4222
+ return run(() => admin.upgradeGroup(groupId, request));
4312
4223
  },
4313
- [mero, run]
4224
+ [admin, run]
4314
4225
  );
4315
4226
  return { upgradeGroup, loading, error };
4316
4227
  }
4317
4228
  function useInstallFromRegistry() {
4318
- const { mero } = useMero();
4229
+ const { admin } = useMero();
4319
4230
  const { loading, error, run } = useAsyncMutation();
4320
4231
  const installFromRegistry = react.useCallback(
4321
4232
  async (packageName, version) => {
4322
- if (!mero) return null;
4323
- return run(() => mero.admin.installApplication({ package: packageName, version }));
4233
+ if (!admin) return null;
4234
+ return run(() => admin.installApplication({ package: packageName, version }));
4324
4235
  },
4325
- [mero, run]
4236
+ [admin, run]
4326
4237
  );
4327
4238
  return { installFromRegistry, loading, error };
4328
4239
  }
4329
4240
  function useResyncContext() {
4330
- const { mero } = useMero();
4241
+ const { admin } = useMero();
4331
4242
  const { loading, error, run } = useAsyncMutation();
4332
4243
  const resyncContext = react.useCallback(
4333
4244
  async (contextId, request = {}) => {
4334
- if (!mero) return null;
4335
- return run(() => mero.admin.resyncContext(contextId, request));
4245
+ if (!admin) return null;
4246
+ return run(() => admin.resyncContext(contextId, request));
4336
4247
  },
4337
- [mero, run]
4248
+ [admin, run]
4338
4249
  );
4339
4250
  return { resyncContext, loading, error };
4340
4251
  }
4341
4252
  function useGroupUpgradeStatus(groupId) {
4342
- const { mero } = useMero();
4253
+ const { admin } = useMero();
4343
4254
  const [upgradeStatus, setUpgradeStatus] = react.useState(null);
4344
4255
  const [loading, setLoading] = react.useState(false);
4345
4256
  const [error, setError] = react.useState(null);
@@ -4347,7 +4258,7 @@ function useGroupUpgradeStatus(groupId) {
4347
4258
  const reqRef = react.useRef(0);
4348
4259
  const refetch = react.useCallback(async () => {
4349
4260
  const seq = ++reqRef.current;
4350
- if (!mero || !groupId) {
4261
+ if (!admin || !groupId) {
4351
4262
  if (mountedRef.current) {
4352
4263
  setUpgradeStatus(null);
4353
4264
  setError(null);
@@ -4360,7 +4271,7 @@ function useGroupUpgradeStatus(groupId) {
4360
4271
  setError(null);
4361
4272
  }
4362
4273
  try {
4363
- const result = await mero.admin.getGroupUpgradeStatus(groupId);
4274
+ const result = await admin.getGroupUpgradeStatus(groupId);
4364
4275
  if (mountedRef.current && seq === reqRef.current) {
4365
4276
  setUpgradeStatus(result);
4366
4277
  }
@@ -4374,7 +4285,7 @@ function useGroupUpgradeStatus(groupId) {
4374
4285
  setLoading(false);
4375
4286
  }
4376
4287
  }
4377
- }, [groupId, mero, mountedRef]);
4288
+ }, [groupId, admin, mountedRef]);
4378
4289
  react.useEffect(() => {
4379
4290
  reqRef.current += 1;
4380
4291
  setUpgradeStatus(null);
@@ -4386,60 +4297,47 @@ function useGroupUpgradeStatus(groupId) {
4386
4297
  return { upgradeStatus, loading, error, refetch };
4387
4298
  }
4388
4299
  function useRetryGroupUpgrade() {
4389
- const { mero } = useMero();
4300
+ const { admin } = useMero();
4390
4301
  const { loading, error, run } = useAsyncMutation();
4391
4302
  const retryGroupUpgrade = react.useCallback(
4392
4303
  async (groupId) => {
4393
- if (!mero) return null;
4394
- return run(() => mero.admin.retryGroupUpgrade(groupId));
4304
+ if (!admin) return null;
4305
+ return run(() => admin.retryGroupUpgrade(groupId));
4395
4306
  },
4396
- [mero, run]
4307
+ [admin, run]
4397
4308
  );
4398
4309
  return { retryGroupUpgrade, loading, error };
4399
4310
  }
4400
4311
  function useReparentGroup() {
4401
- const { mero, isDelegated } = useMero();
4312
+ const { admin } = useMero();
4402
4313
  const { loading, error, run } = useAsyncMutation();
4403
4314
  const reparentGroup = react.useCallback(
4404
4315
  async (childGroupId, request) => {
4405
- if (isDelegated) {
4406
- const session = readDelegatedSession();
4407
- if (!session) return null;
4408
- return run(async () => {
4409
- await governRoot(session, childGroupId, meroJs.groupReparentedOp(childGroupId, request.newParentId));
4410
- return { reparented: true };
4411
- });
4412
- }
4413
- if (!mero) return null;
4414
- return run(() => mero.admin.reparentGroup(childGroupId, request));
4316
+ if (!admin) return null;
4317
+ return run(() => admin.reparentGroup(childGroupId, request));
4415
4318
  },
4416
- [mero, run, isDelegated]
4319
+ [admin, run]
4417
4320
  );
4418
4321
  return { reparentGroup, loading, error };
4419
4322
  }
4420
4323
  function useSubgroups(groupId) {
4421
- const { mero } = useMero();
4324
+ const { admin } = useMero();
4422
4325
  const { data, loading, error, refetch } = useAsyncResource(
4423
- mero && groupId ? () => mero.admin.listSubgroups(groupId) : null,
4326
+ admin && groupId ? () => admin.listSubgroups(groupId) : null,
4424
4327
  [],
4425
- [mero, groupId]
4328
+ [admin, groupId]
4426
4329
  );
4427
4330
  return { subgroups: data, loading, error, refetch };
4428
4331
  }
4429
4332
  function useDetachContextFromGroup() {
4430
- const { mero, isDelegated } = useMero();
4333
+ const { admin } = useMero();
4431
4334
  const { loading, error, run } = useAsyncMutation();
4432
4335
  const detachContextFromGroup = react.useCallback(
4433
4336
  async (groupId, contextId) => {
4434
- if (isDelegated) {
4435
- const session = readDelegatedSession();
4436
- if (!session) return null;
4437
- return run(() => governGroup(session, groupId, meroJs.contextDetachedOp(contextId)));
4438
- }
4439
- if (!mero) return null;
4440
- return run(() => mero.admin.detachContextFromGroup(groupId, contextId));
4337
+ if (!admin) return null;
4338
+ return run(() => admin.detachContextFromGroup(groupId, contextId));
4441
4339
  },
4442
- [mero, run, isDelegated]
4340
+ [admin, run]
4443
4341
  );
4444
4342
  return { detachContextFromGroup, loading, error };
4445
4343
  }
@@ -4473,14 +4371,14 @@ function useMigrationEvents(namespaceId, onEvent) {
4473
4371
  return live;
4474
4372
  }
4475
4373
  function useMigrationStatus(namespaceId, options) {
4476
- const { mero } = useMero();
4374
+ const { admin } = useMero();
4477
4375
  const [status, setStatus] = react.useState(null);
4478
4376
  const [loading, setLoading] = react.useState(false);
4479
4377
  const [error, setError] = react.useState(null);
4480
4378
  const mountedRef = useMountedRef();
4481
4379
  const reqRef = react.useRef(0);
4482
4380
  const refetch = react.useCallback(async () => {
4483
- if (!mero || !namespaceId) {
4381
+ if (!admin || !namespaceId) {
4484
4382
  if (mountedRef.current) {
4485
4383
  setStatus(null);
4486
4384
  setError(null);
@@ -4494,7 +4392,7 @@ function useMigrationStatus(namespaceId, options) {
4494
4392
  setError(null);
4495
4393
  }
4496
4394
  try {
4497
- const result = await mero.admin.getMigrationStatus(namespaceId);
4395
+ const result = await admin.getMigrationStatus(namespaceId);
4498
4396
  if (mountedRef.current && seq === reqRef.current) {
4499
4397
  setStatus(result);
4500
4398
  }
@@ -4508,7 +4406,7 @@ function useMigrationStatus(namespaceId, options) {
4508
4406
  setLoading(false);
4509
4407
  }
4510
4408
  }
4511
- }, [namespaceId, mero, mountedRef]);
4409
+ }, [namespaceId, admin, mountedRef]);
4512
4410
  react.useEffect(() => {
4513
4411
  setStatus(null);
4514
4412
  setError(null);
@@ -4519,10 +4417,10 @@ function useMigrationStatus(namespaceId, options) {
4519
4417
  const sseLive = useMigrationEvents(namespaceId, () => void refetch());
4520
4418
  const pollIntervalMs = options?.pollIntervalMs ?? (sseLive ? void 0 : DEFAULT_MIGRATION_POLL_INTERVAL_MS);
4521
4419
  react.useEffect(() => {
4522
- if (!pollIntervalMs || !mero || !namespaceId) return;
4420
+ if (!pollIntervalMs || !admin || !namespaceId) return;
4523
4421
  const handle = setInterval(() => void refetch(), pollIntervalMs);
4524
4422
  return () => clearInterval(handle);
4525
- }, [pollIntervalMs, mero, namespaceId, refetch]);
4423
+ }, [pollIntervalMs, admin, namespaceId, refetch]);
4526
4424
  const rollup = status?.rollup ?? null;
4527
4425
  const members = status?.members ?? [];
4528
4426
  return {
@@ -4545,14 +4443,14 @@ function useMigrationStatus(namespaceId, options) {
4545
4443
  };
4546
4444
  }
4547
4445
  function useAppVersion(contextId, expected) {
4548
- const { mero } = useMero();
4446
+ const { mero, admin } = useMero();
4549
4447
  const [appVersion, setAppVersion] = react.useState(void 0);
4550
4448
  const [loading, setLoading] = react.useState(false);
4551
4449
  const [error, setError] = react.useState(null);
4552
4450
  const mountedRef = useMountedRef();
4553
4451
  const reqRef = react.useRef(0);
4554
4452
  const refetch = react.useCallback(async () => {
4555
- if (!mero || !contextId) {
4453
+ if (!admin || !contextId) {
4556
4454
  if (mountedRef.current) {
4557
4455
  setAppVersion(void 0);
4558
4456
  setError(null);
@@ -4566,7 +4464,7 @@ function useAppVersion(contextId, expected) {
4566
4464
  setError(null);
4567
4465
  }
4568
4466
  try {
4569
- const context = await mero.admin.getContext(contextId);
4467
+ const context = await admin.getContext(contextId);
4570
4468
  if (mountedRef.current && seq === reqRef.current) {
4571
4469
  setAppVersion(context.applicationVersion);
4572
4470
  }
@@ -4580,7 +4478,7 @@ function useAppVersion(contextId, expected) {
4580
4478
  setLoading(false);
4581
4479
  }
4582
4480
  }
4583
- }, [contextId, mero, mountedRef]);
4481
+ }, [contextId, admin, mountedRef]);
4584
4482
  react.useEffect(() => {
4585
4483
  setAppVersion(void 0);
4586
4484
  setError(null);
@@ -4603,14 +4501,14 @@ function useAppVersion(contextId, expected) {
4603
4501
  return { appVersion, expected, isStale, loading, error, refetch };
4604
4502
  }
4605
4503
  function useLatestVersion(registryUrl, packageName, currentVersion) {
4606
- const { mero } = useMero();
4504
+ const { admin } = useMero();
4607
4505
  const [versions, setVersions] = react.useState([]);
4608
4506
  const [loading, setLoading] = react.useState(false);
4609
4507
  const [error, setError] = react.useState(null);
4610
4508
  const mountedRef = useMountedRef();
4611
4509
  const reqRef = react.useRef(0);
4612
4510
  const refetch = react.useCallback(async () => {
4613
- if (!mero || !registryUrl || !packageName) {
4511
+ if (!admin || !registryUrl || !packageName) {
4614
4512
  reqRef.current += 1;
4615
4513
  if (mountedRef.current) {
4616
4514
  setVersions([]);
@@ -4625,7 +4523,7 @@ function useLatestVersion(registryUrl, packageName, currentVersion) {
4625
4523
  setError(null);
4626
4524
  }
4627
4525
  try {
4628
- const result = await mero.admin.getRegistryVersions(registryUrl, packageName);
4526
+ const result = await admin.getRegistryVersions(registryUrl, packageName);
4629
4527
  if (mountedRef.current && seq === reqRef.current) {
4630
4528
  setVersions(result);
4631
4529
  }
@@ -4639,7 +4537,7 @@ function useLatestVersion(registryUrl, packageName, currentVersion) {
4639
4537
  setLoading(false);
4640
4538
  }
4641
4539
  }
4642
- }, [mero, registryUrl, packageName, mountedRef]);
4540
+ }, [admin, registryUrl, packageName, mountedRef]);
4643
4541
  react.useEffect(() => {
4644
4542
  setVersions([]);
4645
4543
  setError(null);
@@ -4661,7 +4559,7 @@ function isZeroAppKey(appKey) {
4661
4559
  return !appKey || /^0+$/.test(appKey);
4662
4560
  }
4663
4561
  function useGroupAppVersion(groupId) {
4664
- const { mero } = useMero();
4562
+ const { mero, admin } = useMero();
4665
4563
  const [data, setData] = react.useState(EMPTY_GROUP_APP_VERSION);
4666
4564
  const [loading, setLoading] = react.useState(false);
4667
4565
  const [error, setError] = react.useState(null);
@@ -4669,7 +4567,7 @@ function useGroupAppVersion(groupId) {
4669
4567
  const reqRef = react.useRef(0);
4670
4568
  const refetch = react.useCallback(async () => {
4671
4569
  const seq = ++reqRef.current;
4672
- if (!mero || !groupId) {
4570
+ if (!admin || !groupId) {
4673
4571
  if (mountedRef.current) {
4674
4572
  setData(EMPTY_GROUP_APP_VERSION);
4675
4573
  setError(null);
@@ -4682,7 +4580,7 @@ function useGroupAppVersion(groupId) {
4682
4580
  setError(null);
4683
4581
  }
4684
4582
  try {
4685
- const namespaces = await mero.admin.listNamespaces();
4583
+ const namespaces = await admin.listNamespaces();
4686
4584
  const namespace = namespaces.find((entry) => entry.namespaceId === groupId);
4687
4585
  let appKey;
4688
4586
  let applicationId;
@@ -4691,7 +4589,7 @@ function useGroupAppVersion(groupId) {
4691
4589
  appKey = namespace.appKey;
4692
4590
  applicationId = namespace.targetApplicationId;
4693
4591
  } else {
4694
- const info = await mero.admin.getGroupInfo(groupId);
4592
+ const info = await admin.getGroupInfo(groupId);
4695
4593
  appKey = info.appKey;
4696
4594
  applicationId = info.targetApplicationId;
4697
4595
  activeUpgrade = info.activeUpgrade ?? null;
@@ -4699,7 +4597,7 @@ function useGroupAppVersion(groupId) {
4699
4597
  let version = null;
4700
4598
  let pendingApply = false;
4701
4599
  if (applicationId) {
4702
- const { application } = await mero.admin.getApplication(applicationId);
4600
+ const { application } = await admin.getApplication(applicationId);
4703
4601
  version = application?.version ?? null;
4704
4602
  if (application && !isZeroAppKey(appKey)) {
4705
4603
  const installedHex = base58ToHex(application.blob.bytecode).toLowerCase();
@@ -4719,7 +4617,7 @@ function useGroupAppVersion(groupId) {
4719
4617
  setLoading(false);
4720
4618
  }
4721
4619
  }
4722
- }, [groupId, mero, mountedRef]);
4620
+ }, [groupId, admin, mountedRef]);
4723
4621
  react.useEffect(() => {
4724
4622
  reqRef.current += 1;
4725
4623
  setData(EMPTY_GROUP_APP_VERSION);
@@ -4788,17 +4686,17 @@ function isBlobNotFound(error) {
4788
4686
  return !!error && error.status === 404;
4789
4687
  }
4790
4688
  function useBlobInfo(blobId, options) {
4791
- const { mero } = useMero();
4689
+ const { admin } = useMero();
4792
4690
  const contextId = options?.contextId;
4793
4691
  const { data, loading, error, refetch } = useAsyncResource(
4794
- mero && blobId ? () => mero.admin.getBlobInfo(blobId, contextId ? { contextId } : void 0) : null,
4692
+ admin && blobId ? () => admin.getBlobInfo(blobId, contextId ? { contextId } : void 0) : null,
4795
4693
  null,
4796
- [mero, blobId, contextId]
4694
+ [admin, blobId, contextId]
4797
4695
  );
4798
4696
  return { info: data, notFound: isBlobNotFound(error), loading, error, refetch };
4799
4697
  }
4800
4698
  function useBlobUrl(blobId, options) {
4801
- const { mero } = useMero();
4699
+ const { admin } = useMero();
4802
4700
  const contextId = options?.contextId;
4803
4701
  const type = options?.type;
4804
4702
  const mountedRef = useMountedRef();
@@ -4815,13 +4713,13 @@ function useBlobUrl(blobId, options) {
4815
4713
  }, []);
4816
4714
  const refetch = react.useCallback(async () => {
4817
4715
  const seq = ++reqRef.current;
4818
- if (!mero || !blobId) return;
4716
+ if (!admin || !blobId) return;
4819
4717
  if (mountedRef.current) {
4820
4718
  setLoading(true);
4821
4719
  setError(null);
4822
4720
  }
4823
4721
  try {
4824
- const bytes = await mero.admin.getBlob(blobId, contextId ? { contextId } : void 0);
4722
+ const bytes = await admin.getBlob(blobId, contextId ? { contextId } : void 0);
4825
4723
  if (!mountedRef.current || seq !== reqRef.current) return;
4826
4724
  revoke();
4827
4725
  const objectUrl = URL.createObjectURL(new Blob([bytes], type ? { type } : void 0));
@@ -4832,14 +4730,14 @@ function useBlobUrl(blobId, options) {
4832
4730
  } finally {
4833
4731
  if (mountedRef.current && seq === reqRef.current) setLoading(false);
4834
4732
  }
4835
- }, [mero, blobId, contextId, type, revoke, mountedRef]);
4733
+ }, [admin, blobId, contextId, type, revoke, mountedRef]);
4836
4734
  react.useEffect(() => {
4837
4735
  reqRef.current += 1;
4838
4736
  revoke();
4839
4737
  setUrl(null);
4840
4738
  setError(null);
4841
4739
  setLoading(false);
4842
- }, [mero, blobId, contextId, type, revoke]);
4740
+ }, [admin, blobId, contextId, type, revoke]);
4843
4741
  react.useEffect(() => {
4844
4742
  void refetch();
4845
4743
  }, [refetch]);
@@ -4847,14 +4745,14 @@ function useBlobUrl(blobId, options) {
4847
4745
  return { url, notFound: isBlobNotFound(error), loading, error, refetch };
4848
4746
  }
4849
4747
  function useUploadBlob() {
4850
- const { mero } = useMero();
4748
+ const { admin } = useMero();
4851
4749
  const { loading, error, run } = useAsyncMutation();
4852
4750
  const uploadBlob = react.useCallback(
4853
4751
  async (request) => {
4854
- if (!mero) return null;
4855
- return run(() => mero.admin.uploadBlob(request));
4752
+ if (!admin) return null;
4753
+ return run(() => admin.uploadBlob(request));
4856
4754
  },
4857
- [mero, run]
4755
+ [admin, run]
4858
4756
  );
4859
4757
  return { uploadBlob, loading, error };
4860
4758
  }