@calimero-network/mero-js 19.18.0 → 19.20.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.
@@ -1,5 +1,5 @@
1
1
  import { HttpClient } from '../http-client/index.js';
2
- import type { HealthStatus, AdminAuthStatus, InstallApplicationRequest, InstallApplicationResponseData, InstallDevApplicationRequest, UninstallApplicationResponseData, ListApplicationsResponseData, GetApplicationResponseData, ApplicationVersionEntry, GetApplicationAbiResponseData, GetLatestVersionResponseData, ListPackagesResponseData, ListVersionsResponseData, CreateContextRequest, CreateContextResponseData, DeleteContextResponseData, GetContextsResponseData, Context, GenerateContextIdentityResponseData, GetContextIdentitiesResponseData, JoinContextResponseData, JoinSubgroupInheritanceResponseData, ContextGroupResponseData, ContextStorageResponseData, InviteSpecializedNodeRequest, InviteSpecializedNodeResponseData, UpdateContextApplicationRequest, ResyncContextRequest, ResyncContextResponseData, ContextsWithExecutorsResponseData, UploadBlobRequest, UploadBlobResponseData, DeleteBlobResponseData, ListBlobsResponseData, GetBlobInfoResponseData, BlobReadOptions, CreateContextAliasRequest, CreateApplicationAliasRequest, CreateDeviceAliasRequest, CreateAliasResponseData, LookupAliasResponseData, DeleteAliasResponseData, ListAliasesResponseData, ListNamespacesResponseData, CreateNamespaceRequest, CreateNamespaceResponseData, DeleteNamespaceResponseData, CreateNamespaceInvitationRequest, CreateNamespaceInvitationResponseData, CreateRecursiveInvitationResponseData, JoinNamespaceRequest, JoinNamespaceResponseData, CreateGroupInNamespaceRequest, CreateGroupInNamespaceResponseData, SubgroupEntry, Namespace, NamespaceIdentity, NodeIdentity, AccountPairInitRequest, AccountPairInitResponseData, AccountPairCompleteRequest, AccountPairCompleteResponseData, AccountSignWithRootRequest, AccountSignWithRootResponseData, RelinkDeviceRequest, RelinkDeviceResponseData, RescopeDeviceRequest, RescopeDeviceResponseData, LabelDeviceRequest, LabelDeviceResponseData, AccountDeviceEntry, AccountApplicationEntry, RevokeAccountDeviceRequest, RevokeAccountDeviceResponseData, GroupInfoResponseData, CreateGroupRequest, CreateGroupResponseData, DeleteGroupResponseData, ListGroupMembersResponseData, ListGroupContextsResponseData, AddGroupMembersRequest, RemoveGroupMembersRequest, UpdateMemberRoleRequest, MemberCapabilities, SetMemberCapabilitiesRequest, SetDefaultCapabilitiesRequest, SetMemberAutoFollowRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, GetTeeAdmissionPolicyResponseData, SetGroupMetadataRequest, SetMemberMetadataRequest, SetContextMetadataRequest, MetadataRecord, SyncGroupResponseData, UpgradeGroupRequest, UpgradeGroupResponseData, GroupUpgradeStatusResponseData, MigrationStatus, CascadeStatusEntry, RetryGroupUpgradeResponseData, ReparentGroupRequest, ReparentGroupResponseData, IssueOwnershipProofRequest, IssueNamespaceOwnershipProofRequest, IssueOwnershipProofResponseData, CreateGroupInvitationRequest, CreateGroupInvitationResponseData, CreateRecursiveGroupInvitationResponseData, JoinGroupRequest, JoinGroupResponseData, TeeInfoResponseData, TeeAttestRequest, TeeAttestResponseData, TeeVerifyQuoteRequest, TeeVerifyQuoteResponseData, PerformIntentRequest, PerformIntentResponseData, IntentRelayInfo, AdmitJoinRequest, AdmitJoinResponseData } from './admin-types.js';
2
+ import type { HealthStatus, AdminAuthStatus, InstallApplicationRequest, InstallApplicationResponseData, InstallDevApplicationRequest, UninstallApplicationResponseData, ListApplicationsResponseData, GetApplicationResponseData, ApplicationVersionEntry, GetApplicationAbiResponseData, GetLatestVersionResponseData, ListPackagesResponseData, ListVersionsResponseData, CreateContextRequest, CreateContextResponseData, DeleteContextResponseData, GetContextsResponseData, Context, GenerateContextIdentityResponseData, GetContextIdentitiesResponseData, JoinContextResponseData, JoinSubgroupInheritanceResponseData, ContextGroupResponseData, ContextStorageResponseData, InviteSpecializedNodeRequest, InviteSpecializedNodeResponseData, UpdateContextApplicationRequest, ResyncContextRequest, ResyncContextResponseData, ContextsWithExecutorsResponseData, UploadBlobRequest, UploadBlobResponseData, DeleteBlobResponseData, ListBlobsResponseData, GetBlobInfoResponseData, BlobReadOptions, CreateContextAliasRequest, CreateApplicationAliasRequest, CreateDeviceAliasRequest, CreateAliasResponseData, LookupAliasResponseData, DeleteAliasResponseData, ListAliasesResponseData, ListNamespacesResponseData, CreateNamespaceRequest, CreateNamespaceResponseData, DeleteNamespaceResponseData, CreateNamespaceInvitationRequest, CreateNamespaceInvitationResponseData, CreateRecursiveInvitationResponseData, JoinNamespaceRequest, JoinNamespaceResponseData, CreateGroupInNamespaceRequest, CreateGroupInNamespaceResponseData, SubgroupEntry, Namespace, NamespaceIdentity, NodeIdentity, AccountPairInitRequest, AccountPairInitResponseData, AccountPairCompleteRequest, AccountPairCompleteResponseData, AccountSignWithRootRequest, AccountSignWithRootResponseData, RelinkDeviceRequest, RelinkDeviceResponseData, RescopeDeviceRequest, RescopeDeviceResponseData, LabelDeviceRequest, LabelDeviceResponseData, AccountDeviceEntry, AccountApplicationEntry, RevokeAccountDeviceRequest, RevokeAccountDeviceResponseData, GroupInfoResponseData, CreateGroupRequest, CreateGroupResponseData, DeleteGroupResponseData, ListGroupMembersResponseData, ListGroupContextsResponseData, AddGroupMembersRequest, RemoveGroupMembersRequest, UpdateMemberRoleRequest, MemberCapabilities, SetMemberCapabilitiesRequest, SetDefaultCapabilitiesRequest, SetMemberAutoFollowRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, GetTeeAdmissionPolicyResponseData, SetTeeAuthoringPolicyRequest, SetGroupMetadataRequest, SetMemberMetadataRequest, SetContextMetadataRequest, MetadataRecord, SyncGroupResponseData, UpgradeGroupRequest, UpgradeGroupResponseData, GroupUpgradeStatusResponseData, MigrationStatus, CascadeStatusEntry, RetryGroupUpgradeResponseData, ReparentGroupRequest, ReparentGroupResponseData, IssueOwnershipProofRequest, IssueNamespaceOwnershipProofRequest, IssueOwnershipProofResponseData, CreateGroupInvitationRequest, CreateGroupInvitationResponseData, CreateRecursiveGroupInvitationResponseData, JoinGroupRequest, JoinGroupResponseData, TeeInfoResponseData, TeeAttestRequest, TeeAttestResponseData, TeeVerifyQuoteRequest, TeeVerifyQuoteResponseData, PerformIntentRequest, PerformIntentResponseData, IntentRelayInfo, AdmitJoinRequest, AdmitJoinResponseData } from './admin-types.js';
3
3
  /**
4
4
  * Compare two version strings by SemVer 2.0 precedence, ascending: negative if
5
5
  * `a < b`, positive if `a > b`, `0` if equal. Build metadata (`+...`) is stripped
@@ -460,6 +460,13 @@ export declare class AdminApiClient {
460
460
  setSubgroupVisibility(groupId: string, request: SetSubgroupVisibilityRequest): Promise<void>;
461
461
  setTeeAdmissionPolicy(groupId: string, request: SetTeeAdmissionPolicyRequest): Promise<void>;
462
462
  getTeeAdmissionPolicy(groupId: string): Promise<GetTeeAdmissionPolicyResponseData>;
463
+ /**
464
+ * Sets which admitted TEEs may author as the TEE authority. Pass
465
+ * `{ allowedMrtd: [] }` to turn TEE authorship off. `groupId` must be a
466
+ * namespace root; the node refuses a subgroup. The node exposes no read-back
467
+ * route for this policy.
468
+ */
469
+ setTeeAuthoringPolicy(groupId: string, request: SetTeeAuthoringPolicyRequest): Promise<void>;
463
470
  setGroupMetadata(groupId: string, request: SetGroupMetadataRequest): Promise<void>;
464
471
  getGroupMetadata(groupId: string): Promise<MetadataRecord | null>;
465
472
  setMemberMetadata(groupId: string, identity: string, request: SetMemberMetadataRequest): Promise<void>;
@@ -852,6 +852,15 @@ export class AdminApiClient {
852
852
  const response = await this.httpClient.get(`/admin-api/groups/${groupId}/settings/tee-admission-policy`);
853
853
  return response.data ?? response;
854
854
  }
855
+ /**
856
+ * Sets which admitted TEEs may author as the TEE authority. Pass
857
+ * `{ allowedMrtd: [] }` to turn TEE authorship off. `groupId` must be a
858
+ * namespace root; the node refuses a subgroup. The node exposes no read-back
859
+ * route for this policy.
860
+ */
861
+ async setTeeAuthoringPolicy(groupId, request) {
862
+ await this.httpClient.put(`/admin-api/groups/${groupId}/settings/tee-authoring-policy`, request);
863
+ }
855
864
  // ---- Group / member / context metadata ----
856
865
  async setGroupMetadata(groupId, request) {
857
866
  await this.httpClient.put(`/admin-api/groups/${groupId}/metadata`, request);
@@ -1303,6 +1303,17 @@ export interface GetTeeAdmissionPolicyResponseData {
1303
1303
  allowedTcbStatuses: string[];
1304
1304
  acceptMock: boolean;
1305
1305
  }
1306
+ /**
1307
+ * Which admitted TEEs may author as the group's TEE authority (the writer behind
1308
+ * `TeeOnly` storage and `#[app::tee]` methods). A TEE whose attested MRTD is in
1309
+ * `allowedMrtd` may author; an empty list turns TEE authorship off.
1310
+ *
1311
+ * Namespace-scoped: set it on the namespace root. The node refuses it on a subgroup.
1312
+ */
1313
+ export interface SetTeeAuthoringPolicyRequest {
1314
+ allowedMrtd: string[];
1315
+ }
1316
+ export type SetTeeAuthoringPolicyResponseData = Record<string, never>;
1306
1317
  /**
1307
1318
  * Generic metadata record attached to a group, group member, or
1308
1319
  * context-registered-in-a-group (core `calimero_primitives::metadata::MetadataRecord`).
@@ -530,13 +530,24 @@ export declare class CloudClient {
530
530
  * Ask the fleet to host a claimed namespace — the step that gets a relay
531
531
  * assigned.
532
532
  *
533
- * Takes no body: {@link claimNamespace} already established ownership, and
534
- * this is the separate "now host it" half. Idempotent.
533
+ * Carries no proof: {@link claimNamespace} already established ownership,
534
+ * and this is the separate "now host it" half. Idempotent.
535
+ *
536
+ * `admitterAddrs` is where the owner's own node can be dialed — take it from
537
+ * that node's network status with {@link admitterAddrsFromNetworkStatus}.
538
+ * The first fleet node placed on a namespace has nobody but the owner to ask
539
+ * for admission, and without these it can only broadcast and hope the
540
+ * owner's node — often a laptop behind a relay — hears it. They are a dial
541
+ * hint, not a grant: the owner's node admits by its own policy. Omit them to
542
+ * leave whatever the cloud already holds; pass them again when the node's
543
+ * relay address changes, and they replace the stored ones.
535
544
  *
536
545
  * Not to be confused with {@link enableHA}, which opens the cloud's web flow
537
546
  * in a browser tab for a user to complete by hand. This is the API call.
538
547
  */
539
- enableNamespaceHa(namespaceId: string): Promise<unknown>;
548
+ enableNamespaceHa(namespaceId: string, options?: {
549
+ admitterAddrs?: readonly string[];
550
+ }): Promise<unknown>;
540
551
  /**
541
552
  * Stop hosting a claimed namespace.
542
553
  *
@@ -680,3 +691,15 @@ export declare class CloudClient {
680
691
  */
681
692
  private adoptRollingRefresh;
682
693
  }
694
+ /**
695
+ * The addresses a fleet node can dial to ask this node for admission, from the
696
+ * node's `GET /admin-api/network/status` (see `AdminApiClient`).
697
+ *
698
+ * Its `externalAddrs`, each made to end in `/p2p/<localPeerId>`: that is the
699
+ * shape core dials, and an external address is usually reported without it. A
700
+ * relay-circuit address already contains `/p2p/` — the relay's — so the test is
701
+ * whether it ends in this node's own id, not whether it names a peer at all.
702
+ * Anything that is not a multiaddr is dropped. Empty when the status names no
703
+ * peer id or no external address, which is an honest "not dialable yet".
704
+ */
705
+ export declare function admitterAddrsFromNetworkStatus(status: unknown): string[];
@@ -418,14 +418,26 @@ export class CloudClient {
418
418
  * Ask the fleet to host a claimed namespace — the step that gets a relay
419
419
  * assigned.
420
420
  *
421
- * Takes no body: {@link claimNamespace} already established ownership, and
422
- * this is the separate "now host it" half. Idempotent.
421
+ * Carries no proof: {@link claimNamespace} already established ownership,
422
+ * and this is the separate "now host it" half. Idempotent.
423
+ *
424
+ * `admitterAddrs` is where the owner's own node can be dialed — take it from
425
+ * that node's network status with {@link admitterAddrsFromNetworkStatus}.
426
+ * The first fleet node placed on a namespace has nobody but the owner to ask
427
+ * for admission, and without these it can only broadcast and hope the
428
+ * owner's node — often a laptop behind a relay — hears it. They are a dial
429
+ * hint, not a grant: the owner's node admits by its own policy. Omit them to
430
+ * leave whatever the cloud already holds; pass them again when the node's
431
+ * relay address changes, and they replace the stored ones.
423
432
  *
424
433
  * Not to be confused with {@link enableHA}, which opens the cloud's web flow
425
434
  * in a browser tab for a user to complete by hand. This is the API call.
426
435
  */
427
- async enableNamespaceHa(namespaceId) {
428
- return this.request('POST', `/api/cloud/namespaces/${encodeURIComponent(namespaceId)}/enable-ha`, { body: {} });
436
+ async enableNamespaceHa(namespaceId, options = {}) {
437
+ const body = options.admitterAddrs === undefined
438
+ ? {}
439
+ : { admitter_addrs: [...options.admitterAddrs] };
440
+ return this.request('POST', `/api/cloud/namespaces/${encodeURIComponent(namespaceId)}/enable-ha`, { body });
429
441
  }
430
442
  /**
431
443
  * Stop hosting a claimed namespace.
@@ -737,3 +749,38 @@ export class CloudClient {
737
749
  void this.notifySession(this.session);
738
750
  }
739
751
  }
752
+ /**
753
+ * The addresses a fleet node can dial to ask this node for admission, from the
754
+ * node's `GET /admin-api/network/status` (see `AdminApiClient`).
755
+ *
756
+ * Its `externalAddrs`, each made to end in `/p2p/<localPeerId>`: that is the
757
+ * shape core dials, and an external address is usually reported without it. A
758
+ * relay-circuit address already contains `/p2p/` — the relay's — so the test is
759
+ * whether it ends in this node's own id, not whether it names a peer at all.
760
+ * Anything that is not a multiaddr is dropped. Empty when the status names no
761
+ * peer id or no external address, which is an honest "not dialable yet".
762
+ */
763
+ export function admitterAddrsFromNetworkStatus(status) {
764
+ const record = status && typeof status === 'object'
765
+ ? (status.data ?? status)
766
+ : undefined;
767
+ if (!record || typeof record !== 'object')
768
+ return [];
769
+ const peerId = record.localPeerId;
770
+ const external = record.externalAddrs;
771
+ if (typeof peerId !== 'string' || !peerId || !Array.isArray(external))
772
+ return [];
773
+ const suffix = `/p2p/${peerId}`;
774
+ const out = [];
775
+ for (const entry of external) {
776
+ if (typeof entry !== 'string')
777
+ continue;
778
+ const addr = entry.trim();
779
+ if (!addr.startsWith('/'))
780
+ continue;
781
+ const dialable = addr.endsWith(suffix) ? addr : `${addr}${suffix}`;
782
+ if (!out.includes(dialable))
783
+ out.push(dialable);
784
+ }
785
+ return out;
786
+ }
@@ -1,4 +1,4 @@
1
- export { CloudClient } from './cloud-client.js';
1
+ export { CloudClient, admitterAddrsFromNetworkStatus } from './cloud-client.js';
2
2
  export type { CloudClientConfig, CloudSession, CloudNamespace, CloudRelay, CloudAccountRelay, CloudNamespaceNode, CloudNamespaceRouting, CloudMachine, CloudMachineNamespace, CloudLinkedAccount, CloudLinkedAccounts, CloudAccountLink, AccountLinkChallenge, AccountLinkProof, AccountLinkHandoff, AccountLinkCallback, AccountLoginChallenge, AccountLoginProof, EnableHAOptions, DisableHAOptions, } from './cloud-client.js';
3
3
  export { connectCloud } from './connect.js';
4
4
  export type { ConnectCloudOptions, CloudConnection } from './connect.js';
@@ -1,3 +1,3 @@
1
- export { CloudClient } from './cloud-client.js';
1
+ export { CloudClient, admitterAddrsFromNetworkStatus } from './cloud-client.js';
2
2
  export { connectCloud } from './connect.js';
3
3
  export { signRoutingChallenge, routingProofHeaders } from './routing-proof.js';