@calimero-network/mero-react 9.7.1 → 9.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1086,10 +1086,25 @@ declare function foundDelegatedNamespace(s: DelegatedSession, req?: {
1086
1086
  };
1087
1087
  }, deps?: {
1088
1088
  fetch?: typeof fetch;
1089
- }): Promise<{
1089
+ /** The cloud to enable HA on; mero-js's default when unset. */
1090
+ cloudBaseUrl?: string;
1091
+ }): Promise<FoundedDelegatedNamespace>;
1092
+ /** What {@link foundDelegatedNamespace} returns. */
1093
+ interface FoundedDelegatedNamespace {
1090
1094
  namespaceId: string;
1091
1095
  teeEnabled: boolean;
1092
- }>;
1096
+ /** Whether the cloud agreed to host the namespace (HA) right after founding. */
1097
+ haEnabled: boolean;
1098
+ /** Why `haEnabled` is `false`, in words a person can act on. */
1099
+ haError?: string;
1100
+ }
1101
+ /** What an app can tell a person whose account the cloud cannot place. */
1102
+ declare const HA_ACCOUNT_NOT_LINKED_MESSAGE = "link this account to your cloud user in the wallet so invitees can find this namespace";
1103
+ /**
1104
+ * What to tell a person for each refusal the cloud names, keyed by its code.
1105
+ * Every one leaves the namespace founded; only hosting was refused.
1106
+ */
1107
+ declare const HA_REFUSAL_MESSAGES: Record<string, string>;
1093
1108
 
1094
1109
  /**
1095
1110
  * An account's group management through a relay: one delegated governance op
@@ -1132,6 +1147,22 @@ declare class NoRelayError extends Error {
1132
1147
  readonly method: string;
1133
1148
  constructor(method: string);
1134
1149
  }
1150
+ /**
1151
+ * Why an account's invitation was not minted: nobody its claimant could reach
1152
+ * would admit them. A claimant with no node finds its admitter through the
1153
+ * cloud's routing, intersected with the invitation's signed admitters, so an
1154
+ * invitation the cloud routes to none of them can only fail in their hands.
1155
+ *
1156
+ * - `not-hosted` — the cloud serves the namespace on no node: HA was never
1157
+ * enabled for it (not linked in the wallet, quota, or founding not attested).
1158
+ * - `no-named-node` — the cloud's nodes are not among the admitters this
1159
+ * invitation would name.
1160
+ */
1161
+ declare class InvitationNotClaimableError extends Error {
1162
+ readonly namespaceId: string;
1163
+ readonly reason: 'not-hosted' | 'no-named-node';
1164
+ constructor(namespaceId: string, reason: 'not-hosted' | 'no-named-node');
1165
+ }
1135
1166
  interface AccountAdminDeps {
1136
1167
  govern?: {
1137
1168
  group: typeof governGroup;
@@ -1150,6 +1181,17 @@ interface AccountAdminDeps {
1150
1181
  join?: (namespaceId: string, invitation: SignedGroupOpenInvitation) => Promise<{
1151
1182
  namespaceId: string;
1152
1183
  }>;
1184
+ /**
1185
+ * The cloud's routing for a namespace (`CloudClient.getNamespaceRouting`):
1186
+ * the nodes a node-less invitee can be admitted through. Given, an
1187
+ * invitation is minted only if one of them is an admitter it names; a lookup
1188
+ * that fails does not block minting. The provider supplies it.
1189
+ */
1190
+ routing?: (namespaceId: string) => Promise<{
1191
+ nodes: ReadonlyArray<{
1192
+ account: string | null;
1193
+ }>;
1194
+ }>;
1153
1195
  }
1154
1196
  declare function createAccountAdmin(input: {
1155
1197
  session: DelegatedSession;
@@ -1552,10 +1594,7 @@ declare function useNamespacesForApplication(applicationId?: string | null): {
1552
1594
  refetch: () => Promise<void>;
1553
1595
  };
1554
1596
  declare function useCreateNamespace(): {
1555
- createNamespace: (request: CreateNamespaceRequest) => Promise<{
1556
- namespaceId: string;
1557
- teeEnabled: boolean;
1558
- } | _calimero_network_mero_js.CreateNamespaceResponseData | null>;
1597
+ createNamespace: (request: CreateNamespaceRequest) => Promise<FoundedDelegatedNamespace | _calimero_network_mero_js.CreateNamespaceResponseData | null>;
1559
1598
  loading: boolean;
1560
1599
  error: Error | null;
1561
1600
  };
@@ -2054,4 +2093,4 @@ declare function clearContextIdentity(): void;
2054
2093
  */
2055
2094
  declare function clearAllStorage(): void;
2056
2095
 
2057
- export { type AccountAdminDeps, type AccountEnrolment, AccountSignInPanel, type AccountSignInPanelProps, type AppContext, AppMode, type ApplicationContextRecord, type BlobHookOptions, type BootstrapFailure, type BootstrapFromInvitationInput, type BootstrapResult, type BootstrapStep, type BootstrapSuccess, CalimeroLogo, type CalimeroLogoProps, ConnectButton, ConnectButtonAccount, type ConnectButtonAccountProps, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CreatePrivateContextRequest, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type DelegatedCredential, type DelegatedSession, type ExecutionResult, type JoinInvitationInput, type JoinInvitationResult, type JoinInvitationStep, type JoinWithNodeFailure, type JoinWithNodeInput, type JoinWithNodeResult, type JoinWithNodeStep, type JoinWithNodeSuccess, LoginModal, type LoginModalProps, type LoginModalTab, MERO_CSS_VARS, type MeroCapabilities, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type MutationOptions, NoRelayError, NotForAccountError, type RelayResolutionFailure, type RelayResolutionStep, type ResolveRelayFromInvitationInput, type ResolveRelayResult, type ResolvedInvitationRelay, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseAccountEnrolmentOptions, type UseBlobUrlOptions, type UseDelegatedBootstrapOptions, type UseDelegatedBootstrapResult, type UseEphemeralOptions, type UseEphemeralResult, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAccountEnrolment, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useCreatePrivateContext, useDefaultCapabilities, useDelegatedBootstrap, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinInvitation, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRedeemInvitation, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
2096
+ export { type AccountAdminDeps, type AccountEnrolment, AccountSignInPanel, type AccountSignInPanelProps, type AppContext, AppMode, type ApplicationContextRecord, type BlobHookOptions, type BootstrapFailure, type BootstrapFromInvitationInput, type BootstrapResult, type BootstrapStep, type BootstrapSuccess, CalimeroLogo, type CalimeroLogoProps, ConnectButton, ConnectButtonAccount, type ConnectButtonAccountProps, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CreatePrivateContextRequest, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type DelegatedCredential, type DelegatedSession, type ExecutionResult, type FoundedDelegatedNamespace, HA_ACCOUNT_NOT_LINKED_MESSAGE, HA_REFUSAL_MESSAGES, InvitationNotClaimableError, type JoinInvitationInput, type JoinInvitationResult, type JoinInvitationStep, type JoinWithNodeFailure, type JoinWithNodeInput, type JoinWithNodeResult, type JoinWithNodeStep, type JoinWithNodeSuccess, LoginModal, type LoginModalProps, type LoginModalTab, MERO_CSS_VARS, type MeroCapabilities, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type MutationOptions, NoRelayError, NotForAccountError, type RelayResolutionFailure, type RelayResolutionStep, type ResolveRelayFromInvitationInput, type ResolveRelayResult, type ResolvedInvitationRelay, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseAccountEnrolmentOptions, type UseBlobUrlOptions, type UseDelegatedBootstrapOptions, type UseDelegatedBootstrapResult, type UseEphemeralOptions, type UseEphemeralResult, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAccountEnrolment, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useCreatePrivateContext, useDefaultCapabilities, useDelegatedBootstrap, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinInvitation, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRedeemInvitation, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
package/dist/index.d.ts CHANGED
@@ -1086,10 +1086,25 @@ declare function foundDelegatedNamespace(s: DelegatedSession, req?: {
1086
1086
  };
1087
1087
  }, deps?: {
1088
1088
  fetch?: typeof fetch;
1089
- }): Promise<{
1089
+ /** The cloud to enable HA on; mero-js's default when unset. */
1090
+ cloudBaseUrl?: string;
1091
+ }): Promise<FoundedDelegatedNamespace>;
1092
+ /** What {@link foundDelegatedNamespace} returns. */
1093
+ interface FoundedDelegatedNamespace {
1090
1094
  namespaceId: string;
1091
1095
  teeEnabled: boolean;
1092
- }>;
1096
+ /** Whether the cloud agreed to host the namespace (HA) right after founding. */
1097
+ haEnabled: boolean;
1098
+ /** Why `haEnabled` is `false`, in words a person can act on. */
1099
+ haError?: string;
1100
+ }
1101
+ /** What an app can tell a person whose account the cloud cannot place. */
1102
+ declare const HA_ACCOUNT_NOT_LINKED_MESSAGE = "link this account to your cloud user in the wallet so invitees can find this namespace";
1103
+ /**
1104
+ * What to tell a person for each refusal the cloud names, keyed by its code.
1105
+ * Every one leaves the namespace founded; only hosting was refused.
1106
+ */
1107
+ declare const HA_REFUSAL_MESSAGES: Record<string, string>;
1093
1108
 
1094
1109
  /**
1095
1110
  * An account's group management through a relay: one delegated governance op
@@ -1132,6 +1147,22 @@ declare class NoRelayError extends Error {
1132
1147
  readonly method: string;
1133
1148
  constructor(method: string);
1134
1149
  }
1150
+ /**
1151
+ * Why an account's invitation was not minted: nobody its claimant could reach
1152
+ * would admit them. A claimant with no node finds its admitter through the
1153
+ * cloud's routing, intersected with the invitation's signed admitters, so an
1154
+ * invitation the cloud routes to none of them can only fail in their hands.
1155
+ *
1156
+ * - `not-hosted` — the cloud serves the namespace on no node: HA was never
1157
+ * enabled for it (not linked in the wallet, quota, or founding not attested).
1158
+ * - `no-named-node` — the cloud's nodes are not among the admitters this
1159
+ * invitation would name.
1160
+ */
1161
+ declare class InvitationNotClaimableError extends Error {
1162
+ readonly namespaceId: string;
1163
+ readonly reason: 'not-hosted' | 'no-named-node';
1164
+ constructor(namespaceId: string, reason: 'not-hosted' | 'no-named-node');
1165
+ }
1135
1166
  interface AccountAdminDeps {
1136
1167
  govern?: {
1137
1168
  group: typeof governGroup;
@@ -1150,6 +1181,17 @@ interface AccountAdminDeps {
1150
1181
  join?: (namespaceId: string, invitation: SignedGroupOpenInvitation) => Promise<{
1151
1182
  namespaceId: string;
1152
1183
  }>;
1184
+ /**
1185
+ * The cloud's routing for a namespace (`CloudClient.getNamespaceRouting`):
1186
+ * the nodes a node-less invitee can be admitted through. Given, an
1187
+ * invitation is minted only if one of them is an admitter it names; a lookup
1188
+ * that fails does not block minting. The provider supplies it.
1189
+ */
1190
+ routing?: (namespaceId: string) => Promise<{
1191
+ nodes: ReadonlyArray<{
1192
+ account: string | null;
1193
+ }>;
1194
+ }>;
1153
1195
  }
1154
1196
  declare function createAccountAdmin(input: {
1155
1197
  session: DelegatedSession;
@@ -1552,10 +1594,7 @@ declare function useNamespacesForApplication(applicationId?: string | null): {
1552
1594
  refetch: () => Promise<void>;
1553
1595
  };
1554
1596
  declare function useCreateNamespace(): {
1555
- createNamespace: (request: CreateNamespaceRequest) => Promise<{
1556
- namespaceId: string;
1557
- teeEnabled: boolean;
1558
- } | _calimero_network_mero_js.CreateNamespaceResponseData | null>;
1597
+ createNamespace: (request: CreateNamespaceRequest) => Promise<FoundedDelegatedNamespace | _calimero_network_mero_js.CreateNamespaceResponseData | null>;
1559
1598
  loading: boolean;
1560
1599
  error: Error | null;
1561
1600
  };
@@ -2054,4 +2093,4 @@ declare function clearContextIdentity(): void;
2054
2093
  */
2055
2094
  declare function clearAllStorage(): void;
2056
2095
 
2057
- export { type AccountAdminDeps, type AccountEnrolment, AccountSignInPanel, type AccountSignInPanelProps, type AppContext, AppMode, type ApplicationContextRecord, type BlobHookOptions, type BootstrapFailure, type BootstrapFromInvitationInput, type BootstrapResult, type BootstrapStep, type BootstrapSuccess, CalimeroLogo, type CalimeroLogoProps, ConnectButton, ConnectButtonAccount, type ConnectButtonAccountProps, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CreatePrivateContextRequest, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type DelegatedCredential, type DelegatedSession, type ExecutionResult, type JoinInvitationInput, type JoinInvitationResult, type JoinInvitationStep, type JoinWithNodeFailure, type JoinWithNodeInput, type JoinWithNodeResult, type JoinWithNodeStep, type JoinWithNodeSuccess, LoginModal, type LoginModalProps, type LoginModalTab, MERO_CSS_VARS, type MeroCapabilities, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type MutationOptions, NoRelayError, NotForAccountError, type RelayResolutionFailure, type RelayResolutionStep, type ResolveRelayFromInvitationInput, type ResolveRelayResult, type ResolvedInvitationRelay, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseAccountEnrolmentOptions, type UseBlobUrlOptions, type UseDelegatedBootstrapOptions, type UseDelegatedBootstrapResult, type UseEphemeralOptions, type UseEphemeralResult, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAccountEnrolment, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useCreatePrivateContext, useDefaultCapabilities, useDelegatedBootstrap, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinInvitation, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRedeemInvitation, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
2096
+ export { type AccountAdminDeps, type AccountEnrolment, AccountSignInPanel, type AccountSignInPanelProps, type AppContext, AppMode, type ApplicationContextRecord, type BlobHookOptions, type BootstrapFailure, type BootstrapFromInvitationInput, type BootstrapResult, type BootstrapStep, type BootstrapSuccess, CalimeroLogo, type CalimeroLogoProps, ConnectButton, ConnectButtonAccount, type ConnectButtonAccountProps, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CreatePrivateContextRequest, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type DelegatedCredential, type DelegatedSession, type ExecutionResult, type FoundedDelegatedNamespace, HA_ACCOUNT_NOT_LINKED_MESSAGE, HA_REFUSAL_MESSAGES, InvitationNotClaimableError, type JoinInvitationInput, type JoinInvitationResult, type JoinInvitationStep, type JoinWithNodeFailure, type JoinWithNodeInput, type JoinWithNodeResult, type JoinWithNodeStep, type JoinWithNodeSuccess, LoginModal, type LoginModalProps, type LoginModalTab, MERO_CSS_VARS, type MeroCapabilities, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type MutationOptions, NoRelayError, NotForAccountError, type RelayResolutionFailure, type RelayResolutionStep, type ResolveRelayFromInvitationInput, type ResolveRelayResult, type ResolvedInvitationRelay, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseAccountEnrolmentOptions, type UseBlobUrlOptions, type UseDelegatedBootstrapOptions, type UseDelegatedBootstrapResult, type UseEphemeralOptions, type UseEphemeralResult, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAccountEnrolment, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useCreatePrivateContext, useDefaultCapabilities, useDelegatedBootstrap, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinInvitation, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRedeemInvitation, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createContext, useMemo, useState, useRef, useCallback, useEffect, useContext } from 'react';
2
- import { signGroupInvitation, signMemberJoinOp, CloudClient, LocalStorageTokenStore, parseAuthCallback, MeroJs, buildAuthLoginUrl, DEFAULT_LOCAL_NODE_PORTS, discoverLocalNodes, nodeEndpoint, readEnrolmentCallback, completeDeviceEnrolment, deviceEnrolmentUrl, memberJoinedOpenOp, signerFromSecret, groupDeletedOp, memberAddedOp, memberRemovedOp, subgroupCreation, memberRoleSetOp, defaultCapabilitiesSetOp, subgroupVisibilitySetOp, groupMetadataSetOp, memberMetadataSetOp, contextMetadataSetOp, groupReparentedOp, contextDetachedOp, compareSemver, AuthRevokedError, HTTPError, memberLeftOp, memberCapabilitySetOp, attestRelayNodeKey, createMeroClient, RelayClient, createLocalStorageNonceSource, classifyError, login, defaultAudience, createSignedReleaseVerifier, fetchNodeRelease, cloudNodeReleaseUrl, DEFAULT_RELEASE_MIRROR, fetchNodeReleaseVersion } from '@calimero-network/mero-js';
2
+ import { signGroupInvitation, signMemberJoinOp, CloudClient, LocalStorageTokenStore, parseAuthCallback, MeroJs, buildAuthLoginUrl, DEFAULT_LOCAL_NODE_PORTS, discoverLocalNodes, nodeEndpoint, readEnrolmentCallback, completeDeviceEnrolment, deviceEnrolmentUrl, memberJoinedOpenOp, signerFromSecret, groupDeletedOp, memberAddedOp, memberRemovedOp, subgroupCreation, memberRoleSetOp, defaultCapabilitiesSetOp, subgroupVisibilitySetOp, groupMetadataSetOp, memberMetadataSetOp, contextMetadataSetOp, groupReparentedOp, contextDetachedOp, compareSemver, AuthRevokedError, HTTPError, memberLeftOp, memberCapabilitySetOp, attestRelayNodeKey, createMeroClient, RelayClient, createLocalStorageNonceSource, classifyError, login, defaultAudience, AccountNotLinkedError, AccountHaRefusedError, createSignedReleaseVerifier, fetchNodeRelease, cloudNodeReleaseUrl, DEFAULT_RELEASE_MIRROR, fetchNodeReleaseVersion } from '@calimero-network/mero-js';
3
3
  export * from '@calimero-network/mero-js';
4
4
  export { CAPABILITIES, DEFAULT_LOCAL_NODE_PORTS, discoverLocalNodes, hasCap, localNodeUrl, nodeEndpoint, probeNodeHealth, withCap, withoutCap } from '@calimero-network/mero-js';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -454,7 +454,51 @@ async function foundDelegatedNamespace(s, req = {}, deps = {}) {
454
454
  `founded ${founded.namespaceId} but could not give it its application: ${founded.applicationError ?? "unknown reason"}`
455
455
  );
456
456
  }
457
- return { namespaceId: founded.namespaceId, teeEnabled: founded.teeEnabled };
457
+ const ha = founded.teeEnabled ? await enableHaBestEffort(s, founded.namespaceId, founded.salt, relay, deps) : {
458
+ haEnabled: false,
459
+ haError: `the relay did not attest the founding, so no fleet node could be admitted for HA${founded.teeError ? `: ${founded.teeError}` : ""}`
460
+ };
461
+ return { namespaceId: founded.namespaceId, teeEnabled: founded.teeEnabled, ...ha };
462
+ }
463
+ var HA_ACCOUNT_NOT_LINKED_MESSAGE = "link this account to your cloud user in the wallet so invitees can find this namespace";
464
+ var HA_REFUSAL_MESSAGES = {
465
+ account_not_linked: HA_ACCOUNT_NOT_LINKED_MESSAGE,
466
+ account_linked_to_several_users: "this account is linked to more than one cloud user, so the cloud cannot tell whose plan hosts the namespace: unlink it from all but one in the wallet",
467
+ ha_request_pending: "another namespace of this account is still waiting to be hosted; the cloud hosts one new namespace at a time without a cloud sign-in. Sign in to the cloud and turn off hosting for the waiting namespace, or wait until it is hosted",
468
+ unknown_relay: "the cloud does not run the relay this namespace was founded on, so it cannot host it",
469
+ relay_not_dialable: "the relay this namespace was founded on has not reported its address to the cloud yet; try enabling hosting again shortly"
470
+ };
471
+ function blockingNamespace(e) {
472
+ try {
473
+ const body = JSON.parse(e.bodyText ?? "");
474
+ const id = body?.detail?.namespace_id ?? body?.namespace_id;
475
+ return typeof id === "string" && /^[0-9a-f]{64}$/i.test(id) ? id.toLowerCase() : null;
476
+ } catch {
477
+ return null;
478
+ }
479
+ }
480
+ async function enableHaBestEffort(s, namespaceId, salt, relayUrl, deps) {
481
+ try {
482
+ await new CloudClient({ cloudBaseUrl: deps.cloudBaseUrl, fetch: deps.fetch }).enableHaAsAccount({
483
+ namespaceId,
484
+ salt,
485
+ accountId: s.account,
486
+ credential: s.credential,
487
+ deviceSecret: s.deviceSecret,
488
+ // The relay that founded it: the cloud hands it to the fleet node as its
489
+ // admitter, so the node does not have to find it by discovery.
490
+ relayUrl
491
+ });
492
+ return { haEnabled: true };
493
+ } catch (e) {
494
+ if (e instanceof AccountNotLinkedError) return { haEnabled: false, haError: HA_ACCOUNT_NOT_LINKED_MESSAGE };
495
+ if (e instanceof AccountHaRefusedError && HA_REFUSAL_MESSAGES[e.code]) {
496
+ const blocking = e.code === "ha_request_pending" ? blockingNamespace(e) : null;
497
+ const message = HA_REFUSAL_MESSAGES[e.code];
498
+ return { haEnabled: false, haError: blocking ? `${message} (waiting: ${blocking})` : message };
499
+ }
500
+ return { haEnabled: false, haError: e instanceof Error ? e.message : String(e) };
501
+ }
458
502
  }
459
503
  async function latestPublishedVersion(registryUrl, pkg, fetchFn = globalThis.fetch) {
460
504
  const url = `${registryUrl.replace(/\/+$/, "")}/api/v2/bundles?package=${encodeURIComponent(pkg)}`;
@@ -559,6 +603,16 @@ var NoRelayError = class extends Error {
559
603
  this.name = "NoRelayError";
560
604
  }
561
605
  };
606
+ var InvitationNotClaimableError = class extends Error {
607
+ constructor(namespaceId, reason) {
608
+ super(
609
+ reason === "not-hosted" ? `nobody could claim an invitation to ${namespaceId} yet: the namespace is not hosted in the cloud, so an invitee with no node has no relay to be admitted through. Link this account to your cloud user in the wallet and enable HA for the namespace, then invite.` : `nobody could claim an invitation to ${namespaceId}: the cloud routes to none of the relays or admins it would name as admitters`
610
+ );
611
+ this.namespaceId = namespaceId;
612
+ this.reason = reason;
613
+ this.name = "InvitationNotClaimableError";
614
+ }
615
+ };
562
616
  var EMPTY_READS = {
563
617
  listNamespaces: async () => [],
564
618
  listNamespacesForApplication: async () => [],
@@ -612,6 +666,7 @@ function createAccountAdmin(input, deps = {}) {
612
666
  const latestVersion = deps.latestVersion ?? latestPublishedVersion;
613
667
  const signInvitation = deps.signInvitation ?? signGroupInvitation;
614
668
  const join = deps.join;
669
+ const routing = deps.routing;
615
670
  async function joinNamespace(namespaceId, req) {
616
671
  if (!join) throw new NotForAccountError("joinNamespace without a join handler");
617
672
  return join(namespaceId, req.invitation);
@@ -659,12 +714,12 @@ function createAccountAdmin(input, deps = {}) {
659
714
  async createNamespace(req) {
660
715
  if (!app.packageName) throw new NotForAccountError("createNamespace without a packageName");
661
716
  const version = app.packageVersion ?? await latestVersion(app.registryUrl ?? "https://apps.calimero.network", app.packageName);
662
- const { namespaceId } = await found(s, {
717
+ const { namespaceId, haEnabled, haError } = await found(s, {
663
718
  defaultCapabilities: 231,
664
719
  application: { applicationId: req.applicationId, package: app.packageName, version }
665
720
  });
666
721
  if (req.name) await group(s, namespaceId, groupMetadataSetOp({ name: req.name }));
667
- return { namespaceId };
722
+ return { namespaceId, haEnabled, ...haError !== void 0 ? { haError } : {} };
668
723
  },
669
724
  async createGroupInNamespace(namespaceId, req = {}) {
670
725
  const { op } = await subgroupCreation({ parentId: namespaceId, restricted: req.visibility !== "open", admin: s.account });
@@ -737,6 +792,22 @@ function createAccountAdmin(input, deps = {}) {
737
792
  async createNamespaceInvitation(namespaceId) {
738
793
  const [{ members }, info] = await Promise.all([relay().listGroupMembers(namespaceId), relay().getGroupInfo(namespaceId)]);
739
794
  const relays = members.filter((m) => m.role === "RelayTee").map((m) => m.identity.toLowerCase());
795
+ if (routing) {
796
+ const named = new Set(
797
+ relays.length > 0 ? relays : members.filter((m) => m.role === "Admin").map((m) => m.identity.toLowerCase())
798
+ );
799
+ let nodes = null;
800
+ try {
801
+ nodes = (await routing(namespaceId)).nodes;
802
+ } catch {
803
+ }
804
+ if (nodes !== null) {
805
+ if (nodes.length === 0) throw new InvitationNotClaimableError(namespaceId, "not-hosted");
806
+ if (!nodes.some((n) => n.account !== null && named.has(n.account.toLowerCase()))) {
807
+ throw new InvitationNotClaimableError(namespaceId, "no-named-node");
808
+ }
809
+ }
810
+ }
740
811
  const invitation = await signInvitation({
741
812
  groupId: namespaceId,
742
813
  inviterAccount: s.account,
@@ -1558,7 +1629,14 @@ function MeroProvider({
1558
1629
  const app = { packageName, packageVersion, registryUrl };
1559
1630
  if (delegated !== null) {
1560
1631
  const deps = {
1561
- join: (namespaceId, invitation) => joinAsAccount(delegated, namespaceId, invitation, { cloudBaseUrl, onJoined: connectWithAccount })
1632
+ join: (namespaceId, invitation) => joinAsAccount(delegated, namespaceId, invitation, { cloudBaseUrl, onJoined: connectWithAccount }),
1633
+ // Founding enables HA on the same cloud the joins resolve relays from.
1634
+ found: (session, req) => foundDelegatedNamespace(session, req, { cloudBaseUrl }),
1635
+ // Invitations are checked against the routing their claimants will use.
1636
+ routing: (namespaceId) => new CloudClient({
1637
+ cloudBaseUrl,
1638
+ routingCredential: { credential: delegated.credential, deviceSecret: delegated.deviceSecret }
1639
+ }).getNamespaceRouting(namespaceId)
1562
1640
  };
1563
1641
  if (delegated.relayUrl === null) return createAccountAdmin({ session: delegated, read: null, app }, deps);
1564
1642
  if (!mero) return null;
@@ -3734,7 +3812,7 @@ function useNamespacesForApplication(applicationId) {
3734
3812
  }
3735
3813
  var DEFAULT_REGISTRY_URL = "https://apps.calimero.network";
3736
3814
  function useCreateNamespace() {
3737
- const { mero, isDelegated, app } = useMero();
3815
+ const { mero, isDelegated, app, cloudBaseUrl } = useMero();
3738
3816
  const { loading, error, run } = useAsyncMutation();
3739
3817
  const createNamespace = useCallback(
3740
3818
  async (request) => {
@@ -3747,16 +3825,20 @@ function useCreateNamespace() {
3747
3825
  throw new Error("this app names no registry package, so a founded namespace could not be given its application");
3748
3826
  }
3749
3827
  const version = app.packageVersion ?? await latestPublishedVersion(app.registryUrl ?? DEFAULT_REGISTRY_URL, pkg);
3750
- return foundDelegatedNamespace(session, {
3751
- defaultCapabilities: 231,
3752
- application: { applicationId: request.applicationId, package: pkg, version }
3753
- });
3828
+ return foundDelegatedNamespace(
3829
+ session,
3830
+ {
3831
+ defaultCapabilities: 231,
3832
+ application: { applicationId: request.applicationId, package: pkg, version }
3833
+ },
3834
+ { cloudBaseUrl }
3835
+ );
3754
3836
  });
3755
3837
  }
3756
3838
  if (!mero) return null;
3757
3839
  return run(() => mero.admin.createNamespace(request));
3758
3840
  },
3759
- [mero, run, isDelegated, app]
3841
+ [mero, run, isDelegated, app, cloudBaseUrl]
3760
3842
  );
3761
3843
  return { createNamespace, loading, error };
3762
3844
  }
@@ -4869,6 +4951,6 @@ function useJoinInvitation() {
4869
4951
  return { joinInvitation, joining, memberships, invitationRedeemer };
4870
4952
  }
4871
4953
 
4872
- export { AccountSignInPanel, AppMode, CalimeroLogo, ConnectButton, ConnectButtonAccount, ConnectionType, DEFAULT_MIGRATION_POLL_INTERVAL_MS, LoginModal, MERO_CSS_VARS, MeroContext, MeroProvider, MigrationAdminPanel, MigrationPendingBanner, NoRelayError, NotForAccountError, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAccountEnrolment, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useCreatePrivateContext, useDefaultCapabilities, useDelegatedBootstrap, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinInvitation, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRedeemInvitation, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
4954
+ export { AccountSignInPanel, AppMode, CalimeroLogo, ConnectButton, ConnectButtonAccount, ConnectionType, DEFAULT_MIGRATION_POLL_INTERVAL_MS, HA_ACCOUNT_NOT_LINKED_MESSAGE, HA_REFUSAL_MESSAGES, InvitationNotClaimableError, LoginModal, MERO_CSS_VARS, MeroContext, MeroProvider, MigrationAdminPanel, MigrationPendingBanner, NoRelayError, NotForAccountError, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAccountEnrolment, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useCreatePrivateContext, useDefaultCapabilities, useDelegatedBootstrap, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinInvitation, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRedeemInvitation, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
4873
4955
  //# sourceMappingURL=index.js.map
4874
4956
  //# sourceMappingURL=index.js.map