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