@calimero-network/mero-js 22.9.0 → 23.1.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, HTTPError } from '../http-client/index.js';
2
- import type { HealthStatus, ReadinessStatus, 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, LinkAccountDeviceRequest, LinkAccountDeviceResponseData, RevokeAccountDeviceResponseData, MemberDevicesEntry, ListMemberDevicesOptions, 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, QueryContextRequest, QueryContextResponseData, ListMemberDevicesResponseData, SealToAccountRequest, SealedEnvelope, AdmitJoinRequest, AdmitJoinResponseData, WarrantNonceState } from './admin-types.js';
2
+ import type { HealthStatus, ReadinessStatus, 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, LinkAccountDeviceRequest, LinkAccountDeviceResponseData, RevokeAccountDeviceResponseData, MemberDevicesEntry, ListMemberDevicesOptions, GroupInfoResponseData, CreateGroupRequest, CreateGroupResponseData, DeleteGroupResponseData, ListGroupMembersResponseData, ListGroupContextsResponseData, AddGroupMembersRequest, RemoveGroupMembersRequest, UpdateMemberRoleRequest, MemberCapabilities, SetMemberCapabilitiesRequest, SetDefaultCapabilitiesRequest, SetMemberAutoFollowRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, GetTeeAdmissionPolicyResponseData, SetTeeAuthoringPolicyRequest, TransferOwnershipRequest, ChangeNamespaceAdminRequest, OwnerDeleteGroupRequest, RootGuardedOpRequest, 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, QueryContextRequest, QueryContextResponseData, ListMemberDevicesResponseData, SealToAccountRequest, SealedEnvelope, AdmitJoinRequest, AdmitJoinResponseData, WarrantNonceState } from './admin-types.js';
3
3
  import { type RedeemOutcome } from './redeem-invitation.js';
4
4
  /**
5
5
  * Thrown when a node answers the warrant-nonce route with a 404.
@@ -676,8 +676,28 @@ export declare class AdminApiClient {
676
676
  * and admitted TEEs stay members. The node applies the same op as
677
677
  * `setTeeAuthoringPolicy(groupId, { allowedMrtd: [] })`. `groupId` must be a
678
678
  * namespace root.
679
+ *
680
+ * `rootProof` is the signing admin's own root proof for that empty policy
681
+ * (`teeAuthoringPolicyOp([])`); omit it on a node that holds that root.
682
+ */
683
+ disableTeeAuthoringPolicy(groupId: string, options?: RootGuardedOpRequest): Promise<void>;
684
+ /**
685
+ * Hand the group to `newOwner`, who must already be one of its admins.
686
+ * Owner-only, and it needs the owner account's root proof; see
687
+ * {@link RootGuardedOpRequest}.
688
+ */
689
+ transferOwnership(groupId: string, request: TransferOwnershipRequest): Promise<void>;
690
+ /**
691
+ * Repoint the namespace's admin pin at `newAdmin`, a member of its root.
692
+ * Owner-only, with the owner account's root proof; see {@link RootGuardedOpRequest}.
693
+ */
694
+ changeNamespaceAdmin(namespaceId: string, request: ChangeNamespaceAdminRequest): Promise<void>;
695
+ /**
696
+ * Delete a group through the owner-only path: it must hold no contexts, and
697
+ * the op needs the owner account's root proof. {@link deleteGroup} is the
698
+ * admin-level cascading delete.
679
699
  */
680
- disableTeeAuthoringPolicy(groupId: string): Promise<void>;
700
+ ownerDeleteGroup(groupId: string, request?: OwnerDeleteGroupRequest): Promise<void>;
681
701
  setGroupMetadata(groupId: string, request: SetGroupMetadataRequest): Promise<void>;
682
702
  getGroupMetadata(groupId: string): Promise<MetadataRecord | null>;
683
703
  setMemberMetadata(groupId: string, identity: string, request: SetMemberMetadataRequest): Promise<void>;
@@ -1192,9 +1192,45 @@ export class AdminApiClient {
1192
1192
  * and admitted TEEs stay members. The node applies the same op as
1193
1193
  * `setTeeAuthoringPolicy(groupId, { allowedMrtd: [] })`. `groupId` must be a
1194
1194
  * namespace root.
1195
+ *
1196
+ * `rootProof` is the signing admin's own root proof for that empty policy
1197
+ * (`teeAuthoringPolicyOp([])`); omit it on a node that holds that root.
1198
+ */
1199
+ async disableTeeAuthoringPolicy(groupId, options = {}) {
1200
+ const path = `/admin-api/groups/${groupId}/settings/tee-authoring-policy`;
1201
+ if (options.rootProof === undefined) {
1202
+ await this.httpClient.delete(path);
1203
+ return;
1204
+ }
1205
+ await this.httpClient.request(path, {
1206
+ method: 'DELETE',
1207
+ body: JSON.stringify({ rootProof: options.rootProof }),
1208
+ headers: { 'Content-Type': 'application/json' },
1209
+ });
1210
+ }
1211
+ // ---- Root-guarded owner ops (core schema 18) ----
1212
+ /**
1213
+ * Hand the group to `newOwner`, who must already be one of its admins.
1214
+ * Owner-only, and it needs the owner account's root proof; see
1215
+ * {@link RootGuardedOpRequest}.
1216
+ */
1217
+ async transferOwnership(groupId, request) {
1218
+ await this.httpClient.post(`/admin-api/groups/${groupId}/transfer-ownership`, request);
1219
+ }
1220
+ /**
1221
+ * Repoint the namespace's admin pin at `newAdmin`, a member of its root.
1222
+ * Owner-only, with the owner account's root proof; see {@link RootGuardedOpRequest}.
1223
+ */
1224
+ async changeNamespaceAdmin(namespaceId, request) {
1225
+ await this.httpClient.post(`/admin-api/namespaces/${namespaceId}/admin`, request);
1226
+ }
1227
+ /**
1228
+ * Delete a group through the owner-only path: it must hold no contexts, and
1229
+ * the op needs the owner account's root proof. {@link deleteGroup} is the
1230
+ * admin-level cascading delete.
1195
1231
  */
1196
- async disableTeeAuthoringPolicy(groupId) {
1197
- await this.httpClient.delete(`/admin-api/groups/${groupId}/settings/tee-authoring-policy`);
1232
+ async ownerDeleteGroup(groupId, request = {}) {
1233
+ await this.httpClient.post(`/admin-api/groups/${groupId}/owner-delete`, request);
1198
1234
  }
1199
1235
  // ---- Group / member / context metadata ----
1200
1236
  async setGroupMetadata(groupId, request) {
@@ -758,7 +758,9 @@ export interface AccountPairInitResponseData {
758
758
  */
759
759
  signPublicKey: string;
760
760
  /**
761
- * Ed25519 signature over the account, the device id and both keys above, hex.
761
+ * The time the device signed, then its Ed25519 signature over the account, the
762
+ * device id, both keys above and that time, hex (8 + 64 bytes). The holder's
763
+ * node refuses a statement older than a few minutes.
762
764
  *
763
765
  * Carried so the three values arrive as a statement by the device that minted
764
766
  * them rather than as assertions by whoever relayed them; `pair-complete`
@@ -1337,6 +1339,19 @@ export interface GroupInfo {
1337
1339
  * `null` if no metadata has ever been set for this group.
1338
1340
  */
1339
1341
  metadata?: MetadataRecord | null;
1342
+ /** Hex hash of the group's authorization-relevant state, for convergence polling. */
1343
+ groupStateHash?: string;
1344
+ /**
1345
+ * The namespace this group belongs to (itself, for a namespace root). An
1346
+ * owner-op root proof binds it. Absent from nodes before core schema 18.
1347
+ */
1348
+ namespaceId?: string;
1349
+ /**
1350
+ * How many root-guarded owner ops this group has applied: the `counter` a
1351
+ * root proof for its next one must name. Absent from nodes before core
1352
+ * schema 18.
1353
+ */
1354
+ ownerOpCounter?: number;
1340
1355
  }
1341
1356
  export type GroupInfoResponseData = GroupInfo;
1342
1357
  /**
@@ -1513,6 +1528,12 @@ export interface MeasurementTeeAdmissionPolicyRequest {
1513
1528
  acceptMock: boolean;
1514
1529
  /** Absent means `replica`. */
1515
1530
  mode?: TeeAdmissionMode;
1531
+ /**
1532
+ * Hex borsh of the signing admin's own root proof for this policy op
1533
+ * ({@link signOwnerOpProof} with the matching policy encoder). Omit it on a
1534
+ * node that holds that admin's account root, which signs one itself.
1535
+ */
1536
+ rootProof?: string;
1516
1537
  }
1517
1538
  /** A policy that admits by signed release. The node refuses measurement lists beside it. */
1518
1539
  export interface SignedReleaseTeeAdmissionPolicyRequest {
@@ -1521,6 +1542,12 @@ export interface SignedReleaseTeeAdmissionPolicyRequest {
1521
1542
  acceptMock: boolean;
1522
1543
  /** Absent means `replica`. */
1523
1544
  mode?: TeeAdmissionMode;
1545
+ /**
1546
+ * Hex borsh of the signing admin's own root proof for this policy op
1547
+ * ({@link signOwnerOpProof} with the matching policy encoder). Omit it on a
1548
+ * node that holds that admin's account root, which signs one itself.
1549
+ */
1550
+ rootProof?: string;
1524
1551
  }
1525
1552
  export type SetTeeAdmissionPolicyRequest = MeasurementTeeAdmissionPolicyRequest | SignedReleaseTeeAdmissionPolicyRequest;
1526
1553
  export type SetTeeAdmissionPolicyResponseData = Record<string, never>;
@@ -1551,7 +1578,42 @@ export interface GetTeeAdmissionPolicyResponseData {
1551
1578
  */
1552
1579
  export interface SetTeeAuthoringPolicyRequest {
1553
1580
  allowedMrtd: string[];
1581
+ /**
1582
+ * Hex borsh of the signing admin's own root proof for this policy op
1583
+ * ({@link signOwnerOpProof} with the matching policy encoder). Omit it on a
1584
+ * node that holds that admin's account root, which signs one itself.
1585
+ */
1586
+ rootProof?: string;
1587
+ }
1588
+ /**
1589
+ * The root proof an owner-level op carries (core schema 18).
1590
+ *
1591
+ * A device key alone cannot transfer a group, repoint a namespace's admin,
1592
+ * delete a group through the owner-only path, or set a TEE policy: each needs a
1593
+ * proof signed by the account's ROOT key. On a node that holds that root (as
1594
+ * `merod init` provisions) omit `rootProof` and the node signs it. Otherwise sign
1595
+ * one offline with {@link signOwnerOpProof}, over the group's current
1596
+ * `ownerOpCounter` and `namespaceId` from {@link GroupInfo}. Each proof applies
1597
+ * once. Without either, the node answers `403`.
1598
+ */
1599
+ export interface RootGuardedOpRequest {
1600
+ /** Hex borsh of an `AccountProof<OwnerOpAuthorization>`. */
1601
+ rootProof?: string;
1554
1602
  }
1603
+ /** Hand a group to `newOwner`, an account (64 hex) that is already one of its admins. */
1604
+ export interface TransferOwnershipRequest extends RootGuardedOpRequest {
1605
+ newOwner: string;
1606
+ }
1607
+ /** Repoint a namespace's admin pin at `newAdmin`, an account that is a member of its root. */
1608
+ export interface ChangeNamespaceAdminRequest extends RootGuardedOpRequest {
1609
+ newAdmin: string;
1610
+ }
1611
+ /**
1612
+ * The owner-only deletion of a group that holds no contexts. The admin-level
1613
+ * cascading delete is {@link AdminApiClient.deleteGroup}.
1614
+ */
1615
+ export type OwnerDeleteGroupRequest = RootGuardedOpRequest;
1616
+ export type RootGuardedOpResponseData = Record<string, never>;
1555
1617
  export type SetTeeAuthoringPolicyResponseData = Record<string, never>;
1556
1618
  /**
1557
1619
  * Generic metadata record attached to a group, group member, or