@calimero-network/mero-react 9.10.0 → 9.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.cjs +70 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +68 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1119,6 +1119,53 @@ declare const HA_ACCOUNT_NOT_LINKED_MESSAGE = "link this account to your cloud u
|
|
|
1119
1119
|
*/
|
|
1120
1120
|
declare const HA_REFUSAL_MESSAGES: Record<string, string>;
|
|
1121
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* An application's id, computed the way merod computes it.
|
|
1124
|
+
*
|
|
1125
|
+
* core's `ApplicationId::for_bundle(package, signer_id)` is
|
|
1126
|
+
* `sha256(borsh((package, signer_id)))`: the package name and the publisher's
|
|
1127
|
+
* signing key together decide which app a bundle IS, and the version is not an
|
|
1128
|
+
* input, so every version a publisher ships under one package installs as the
|
|
1129
|
+
* same application. A node learns the id when it installs the bundle; an
|
|
1130
|
+
* account installs nothing, so it has to derive the id from the same two
|
|
1131
|
+
* inputs — both of which the registry's bundle listing carries.
|
|
1132
|
+
*/
|
|
1133
|
+
/** A bundle entry as `GET {registry}/api/v2/bundles?package=…` lists it. */
|
|
1134
|
+
interface RegistryBundle {
|
|
1135
|
+
package?: string;
|
|
1136
|
+
signerId?: string;
|
|
1137
|
+
appVersion?: string;
|
|
1138
|
+
yanked?: boolean;
|
|
1139
|
+
publishedAt?: string;
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* `sha256(borsh((pkg, signerId)))` as lowercase hex: core's
|
|
1143
|
+
* `ApplicationId::for_bundle`. A borsh tuple is its fields concatenated.
|
|
1144
|
+
*/
|
|
1145
|
+
declare function applicationIdForBundle(pkg: string, signerId: string): Promise<string>;
|
|
1146
|
+
/**
|
|
1147
|
+
* The entry a package resolves to: its newest version that is not yanked. The
|
|
1148
|
+
* one rule for "latest", shared by the version lookup and the id derivation so
|
|
1149
|
+
* the two cannot disagree about which bundle an account is founding on.
|
|
1150
|
+
*/
|
|
1151
|
+
declare function selectLatestBundle<B extends RegistryBundle>(bundles: readonly B[]): B | undefined;
|
|
1152
|
+
interface ResolvedApplication {
|
|
1153
|
+
applicationId: string;
|
|
1154
|
+
signerId: string;
|
|
1155
|
+
version: string;
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* The application id an account founds `pkg` on, learned from the registry.
|
|
1159
|
+
*
|
|
1160
|
+
* Refused when the non-yanked versions of `pkg` name more than one publisher:
|
|
1161
|
+
* that is two different applications under one package name (the id binds the
|
|
1162
|
+
* signer), and picking either silently would commit the founder — who signs
|
|
1163
|
+
* `TargetApplicationSet` naming the id — to an app it did not choose.
|
|
1164
|
+
*/
|
|
1165
|
+
declare function resolveApplicationIdFromRegistry(registryUrl: string, pkg: string, deps?: {
|
|
1166
|
+
fetch?: typeof fetch;
|
|
1167
|
+
}): Promise<ResolvedApplication>;
|
|
1168
|
+
|
|
1122
1169
|
/**
|
|
1123
1170
|
* An account's group management through a relay: one delegated governance op
|
|
1124
1171
|
* per call (`RelayClient.govern`), posted to the relay that serves the group's
|
|
@@ -2127,4 +2174,4 @@ declare function clearContextIdentity(): void;
|
|
|
2127
2174
|
*/
|
|
2128
2175
|
declare function clearAllStorage(): void;
|
|
2129
2176
|
|
|
2130
|
-
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, isReturningFromWallet, 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 };
|
|
2177
|
+
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 RegistryBundle, type RelayResolutionFailure, type RelayResolutionStep, type ResolveRelayFromInvitationInput, type ResolveRelayResult, type ResolvedApplication, type ResolvedInvitationRelay, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseAccountEnrolmentOptions, type UseBlobUrlOptions, type UseDelegatedBootstrapOptions, type UseDelegatedBootstrapResult, type UseEphemeralOptions, type UseEphemeralResult, applicationIdForBundle, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, isReturningFromWallet, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveApplicationIdFromRegistry, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, selectLatestBundle, 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
|
@@ -1119,6 +1119,53 @@ declare const HA_ACCOUNT_NOT_LINKED_MESSAGE = "link this account to your cloud u
|
|
|
1119
1119
|
*/
|
|
1120
1120
|
declare const HA_REFUSAL_MESSAGES: Record<string, string>;
|
|
1121
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* An application's id, computed the way merod computes it.
|
|
1124
|
+
*
|
|
1125
|
+
* core's `ApplicationId::for_bundle(package, signer_id)` is
|
|
1126
|
+
* `sha256(borsh((package, signer_id)))`: the package name and the publisher's
|
|
1127
|
+
* signing key together decide which app a bundle IS, and the version is not an
|
|
1128
|
+
* input, so every version a publisher ships under one package installs as the
|
|
1129
|
+
* same application. A node learns the id when it installs the bundle; an
|
|
1130
|
+
* account installs nothing, so it has to derive the id from the same two
|
|
1131
|
+
* inputs — both of which the registry's bundle listing carries.
|
|
1132
|
+
*/
|
|
1133
|
+
/** A bundle entry as `GET {registry}/api/v2/bundles?package=…` lists it. */
|
|
1134
|
+
interface RegistryBundle {
|
|
1135
|
+
package?: string;
|
|
1136
|
+
signerId?: string;
|
|
1137
|
+
appVersion?: string;
|
|
1138
|
+
yanked?: boolean;
|
|
1139
|
+
publishedAt?: string;
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* `sha256(borsh((pkg, signerId)))` as lowercase hex: core's
|
|
1143
|
+
* `ApplicationId::for_bundle`. A borsh tuple is its fields concatenated.
|
|
1144
|
+
*/
|
|
1145
|
+
declare function applicationIdForBundle(pkg: string, signerId: string): Promise<string>;
|
|
1146
|
+
/**
|
|
1147
|
+
* The entry a package resolves to: its newest version that is not yanked. The
|
|
1148
|
+
* one rule for "latest", shared by the version lookup and the id derivation so
|
|
1149
|
+
* the two cannot disagree about which bundle an account is founding on.
|
|
1150
|
+
*/
|
|
1151
|
+
declare function selectLatestBundle<B extends RegistryBundle>(bundles: readonly B[]): B | undefined;
|
|
1152
|
+
interface ResolvedApplication {
|
|
1153
|
+
applicationId: string;
|
|
1154
|
+
signerId: string;
|
|
1155
|
+
version: string;
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* The application id an account founds `pkg` on, learned from the registry.
|
|
1159
|
+
*
|
|
1160
|
+
* Refused when the non-yanked versions of `pkg` name more than one publisher:
|
|
1161
|
+
* that is two different applications under one package name (the id binds the
|
|
1162
|
+
* signer), and picking either silently would commit the founder — who signs
|
|
1163
|
+
* `TargetApplicationSet` naming the id — to an app it did not choose.
|
|
1164
|
+
*/
|
|
1165
|
+
declare function resolveApplicationIdFromRegistry(registryUrl: string, pkg: string, deps?: {
|
|
1166
|
+
fetch?: typeof fetch;
|
|
1167
|
+
}): Promise<ResolvedApplication>;
|
|
1168
|
+
|
|
1122
1169
|
/**
|
|
1123
1170
|
* An account's group management through a relay: one delegated governance op
|
|
1124
1171
|
* per call (`RelayClient.govern`), posted to the relay that serves the group's
|
|
@@ -2127,4 +2174,4 @@ declare function clearContextIdentity(): void;
|
|
|
2127
2174
|
*/
|
|
2128
2175
|
declare function clearAllStorage(): void;
|
|
2129
2176
|
|
|
2130
|
-
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, isReturningFromWallet, 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 };
|
|
2177
|
+
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 RegistryBundle, type RelayResolutionFailure, type RelayResolutionStep, type ResolveRelayFromInvitationInput, type ResolveRelayResult, type ResolvedApplication, type ResolvedInvitationRelay, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseAccountEnrolmentOptions, type UseBlobUrlOptions, type UseDelegatedBootstrapOptions, type UseDelegatedBootstrapResult, type UseEphemeralOptions, type UseEphemeralResult, applicationIdForBundle, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, isReturningFromWallet, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveApplicationIdFromRegistry, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, selectLatestBundle, 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
|
@@ -437,6 +437,56 @@ async function listDelegatedNamespaces(s) {
|
|
|
437
437
|
return out;
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
+
// src/delegated/application-id.ts
|
|
441
|
+
function borshString(s) {
|
|
442
|
+
const bytes = new TextEncoder().encode(s);
|
|
443
|
+
const out = new Uint8Array(4 + bytes.length);
|
|
444
|
+
new DataView(out.buffer).setUint32(0, bytes.length, true);
|
|
445
|
+
out.set(bytes, 4);
|
|
446
|
+
return out;
|
|
447
|
+
}
|
|
448
|
+
async function applicationIdForBundle(pkg, signerId) {
|
|
449
|
+
const a = borshString(pkg);
|
|
450
|
+
const b = borshString(signerId);
|
|
451
|
+
const tuple = new Uint8Array(a.length + b.length);
|
|
452
|
+
tuple.set(a, 0);
|
|
453
|
+
tuple.set(b, a.length);
|
|
454
|
+
const digest = await crypto.subtle.digest("SHA-256", tuple);
|
|
455
|
+
return Array.from(new Uint8Array(digest), (x) => x.toString(16).padStart(2, "0")).join("");
|
|
456
|
+
}
|
|
457
|
+
function newer(a, b) {
|
|
458
|
+
const [x, y] = [a, b].map((v) => v.split(/[.-]/).map((n) => Number.parseInt(n, 10) || 0));
|
|
459
|
+
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
|
460
|
+
if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) > (y[i] ?? 0);
|
|
461
|
+
}
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
function selectLatestBundle(bundles) {
|
|
465
|
+
return bundles.filter((b) => !b.yanked && typeof b.appVersion === "string" && b.appVersion.length > 0).reduce((best, b) => !best || newer(b.appVersion, best.appVersion) ? b : best, void 0);
|
|
466
|
+
}
|
|
467
|
+
async function fetchRegistryBundles(registryUrl, pkg, fetchFn = globalThis.fetch) {
|
|
468
|
+
const url = `${registryUrl.replace(/\/+$/, "")}/api/v2/bundles?package=${encodeURIComponent(pkg)}`;
|
|
469
|
+
const response = await fetchFn(url, { headers: { Accept: "application/json" } });
|
|
470
|
+
if (!response.ok) throw new Error(`the registry has no ${pkg} (HTTP ${response.status})`);
|
|
471
|
+
const body = await response.json();
|
|
472
|
+
return Array.isArray(body) ? body : [];
|
|
473
|
+
}
|
|
474
|
+
async function resolveApplicationIdFromRegistry(registryUrl, pkg, deps = {}) {
|
|
475
|
+
const bundles = await fetchRegistryBundles(registryUrl, pkg, deps.fetch);
|
|
476
|
+
const live = bundles.filter((b) => !b.yanked);
|
|
477
|
+
const signers = [...new Set(live.map((b) => b.signerId).filter((s) => typeof s === "string" && s.length > 0))];
|
|
478
|
+
if (signers.length > 1) {
|
|
479
|
+
throw new Error(
|
|
480
|
+
`the registry lists ${pkg} under more than one publisher (${signers.join(", ")}): refusing to guess which application it is`
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
const latest = selectLatestBundle(live);
|
|
484
|
+
if (!latest) throw new Error(`the registry lists no version of ${pkg}`);
|
|
485
|
+
const signerId = latest.signerId;
|
|
486
|
+
if (!signerId) throw new Error(`the registry names no publisher for ${pkg} ${latest.appVersion}`);
|
|
487
|
+
return { applicationId: await applicationIdForBundle(pkg, signerId), signerId, version: latest.appVersion };
|
|
488
|
+
}
|
|
489
|
+
|
|
440
490
|
// src/delegated/create-context.ts
|
|
441
491
|
function governanceNonce(relay, group) {
|
|
442
492
|
return { next: async () => nextGovernanceNonce(relay, group) };
|
|
@@ -585,20 +635,9 @@ async function enableHaBestEffort(s, namespaceId, salt, relayUrl, deps) {
|
|
|
585
635
|
}
|
|
586
636
|
}
|
|
587
637
|
async function latestPublishedVersion(registryUrl, pkg, fetchFn = globalThis.fetch) {
|
|
588
|
-
const
|
|
589
|
-
const response = await fetchFn(url, { headers: { Accept: "application/json" } });
|
|
590
|
-
if (!response.ok) throw new Error(`the registry has no ${pkg} (HTTP ${response.status})`);
|
|
591
|
-
const bundles = await response.json();
|
|
592
|
-
const newer = (a, b) => {
|
|
593
|
-
const [x, y] = [a, b].map((v) => v.split(/[.-]/).map((n) => Number.parseInt(n, 10) || 0));
|
|
594
|
-
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
|
595
|
-
if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) > (y[i] ?? 0);
|
|
596
|
-
}
|
|
597
|
-
return false;
|
|
598
|
-
};
|
|
599
|
-
const latest = bundles.map((b) => b.appVersion).filter((v) => typeof v === "string" && v.length > 0).reduce((best, v) => !best || newer(v, best) ? v : best, void 0);
|
|
638
|
+
const latest = selectLatestBundle(await fetchRegistryBundles(registryUrl, pkg, fetchFn));
|
|
600
639
|
if (!latest) throw new Error(`the registry lists no version of ${pkg}`);
|
|
601
|
-
return latest;
|
|
640
|
+
return latest.appVersion;
|
|
602
641
|
}
|
|
603
642
|
|
|
604
643
|
// src/admin/node-admin.ts
|
|
@@ -1395,6 +1434,7 @@ function clearAllStorage() {
|
|
|
1395
1434
|
});
|
|
1396
1435
|
}
|
|
1397
1436
|
var MeroContext = createContext(null);
|
|
1437
|
+
var DEFAULT_REGISTRY_URL = "https://apps.calimero.network";
|
|
1398
1438
|
var isBrowser = typeof window !== "undefined";
|
|
1399
1439
|
function getPermissionsForMode(mode) {
|
|
1400
1440
|
switch (mode) {
|
|
@@ -1568,6 +1608,17 @@ function MeroProvider({
|
|
|
1568
1608
|
if (apps.length === 1) {
|
|
1569
1609
|
setApplicationIdState(apps[0]);
|
|
1570
1610
|
}
|
|
1611
|
+
if (apps.length === 0 && packageName) {
|
|
1612
|
+
try {
|
|
1613
|
+
const { applicationId: derived } = await resolveApplicationIdFromRegistry(
|
|
1614
|
+
registryUrl ?? DEFAULT_REGISTRY_URL,
|
|
1615
|
+
packageName
|
|
1616
|
+
);
|
|
1617
|
+
if (active) setApplicationIdState(derived);
|
|
1618
|
+
} catch (e) {
|
|
1619
|
+
console.warn(`[mero-react] could not learn the application id of ${packageName} from the registry`, e);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1571
1622
|
} catch {
|
|
1572
1623
|
}
|
|
1573
1624
|
})();
|
|
@@ -1575,7 +1626,7 @@ function MeroProvider({
|
|
|
1575
1626
|
active = false;
|
|
1576
1627
|
stop.abort();
|
|
1577
1628
|
};
|
|
1578
|
-
}, [delegated, contextId]);
|
|
1629
|
+
}, [delegated, contextId, packageName, registryUrl]);
|
|
1579
1630
|
useEffect(() => {
|
|
1580
1631
|
if (delegated) return;
|
|
1581
1632
|
let active = true;
|
|
@@ -3924,7 +3975,7 @@ function useNamespacesForApplication(applicationId) {
|
|
|
3924
3975
|
);
|
|
3925
3976
|
return { namespaces: data, loading, error, refetch };
|
|
3926
3977
|
}
|
|
3927
|
-
var
|
|
3978
|
+
var DEFAULT_REGISTRY_URL2 = "https://apps.calimero.network";
|
|
3928
3979
|
function useCreateNamespace() {
|
|
3929
3980
|
const { mero, isDelegated, app, cloudBaseUrl } = useMero();
|
|
3930
3981
|
const { loading, error, run } = useAsyncMutation();
|
|
@@ -3938,7 +3989,7 @@ function useCreateNamespace() {
|
|
|
3938
3989
|
if (!pkg) {
|
|
3939
3990
|
throw new Error("this app names no registry package, so a founded namespace could not be given its application");
|
|
3940
3991
|
}
|
|
3941
|
-
const version = app.packageVersion ?? await latestPublishedVersion(app.registryUrl ??
|
|
3992
|
+
const version = app.packageVersion ?? await latestPublishedVersion(app.registryUrl ?? DEFAULT_REGISTRY_URL2, pkg);
|
|
3942
3993
|
return foundDelegatedNamespace(
|
|
3943
3994
|
session,
|
|
3944
3995
|
{
|
|
@@ -5065,6 +5116,6 @@ function useJoinInvitation() {
|
|
|
5065
5116
|
return { joinInvitation, joining, memberships, invitationRedeemer };
|
|
5066
5117
|
}
|
|
5067
5118
|
|
|
5068
|
-
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, isReturningFromWallet, 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 };
|
|
5119
|
+
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, applicationIdForBundle, bootstrapFromInvitation, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearDelegatedCredential, clearNodeUrl, clearTokenNodeUrl, createAccountAdmin, createDelegatedContext, createNodeAdmin, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, isFinalInvitationError, isReturningFromWallet, joinWithNode, listDelegatedContexts, localStorageTokenStorage, normaliseAccount, pinRelayNodeKey, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveApplicationIdFromRegistry, resolveMeroTheme, resolveRelayFromInvitation, saveDelegatedCredential, selectLatestBundle, 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 };
|
|
5069
5120
|
//# sourceMappingURL=index.js.map
|
|
5070
5121
|
//# sourceMappingURL=index.js.map
|