@calimero-network/mero-js 19.24.1 → 19.25.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, 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';
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, 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, QueryContextRequest, QueryContextResponseData, ListMemberDevicesOptions, ListMemberDevicesResponseData, SealToAccountRequest, SealedEnvelope, 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
@@ -15,6 +15,12 @@ export declare class AdminApiClient {
15
15
  private httpClient;
16
16
  constructor(httpClient: HttpClient);
17
17
  healthCheck(): Promise<HealthStatus>;
18
+ /**
19
+ * Whether the node has finished starting and its store answers. Public, like
20
+ * {@link healthCheck}; unlike it, a node that is up but not ready answers
21
+ * `503`, which this surfaces as an `HTTPError` whose body names the stage.
22
+ */
23
+ readinessCheck(): Promise<ReadinessStatus>;
18
24
  isAuthed(): Promise<AdminAuthStatus>;
19
25
  /**
20
26
  * Install a published application by its `package@version` coordinates. The
@@ -178,6 +184,16 @@ export declare class AdminApiClient {
178
184
  * {@link PerformIntentRequest.warrant}.
179
185
  */
180
186
  performIntent(contextId: string, request: PerformIntentRequest): Promise<PerformIntentResponseData>;
187
+ /**
188
+ * Read a context as the session's ACCOUNT, without minting a warrant.
189
+ *
190
+ * Needs an account-authenticated session — one from {@link login}, not the
191
+ * admin password login — and refuses otherwise with a `401`. The account must
192
+ * be a member of the group owning the context (`403` if not), and the method
193
+ * must be declared read-only in the app's ABI (`409` if not; a write needs
194
+ * {@link performIntent}).
195
+ */
196
+ queryContext(contextId: string, request: QueryContextRequest): Promise<QueryContextResponseData>;
181
197
  /**
182
198
  * Ask what this node can do for a member in `contextId`, before they sign
183
199
  * anything.
@@ -366,6 +382,18 @@ export declare class AdminApiClient {
366
382
  getSubgroupVisibility(groupId: string): Promise<string>;
367
383
  deleteGroup(groupId: string): Promise<DeleteGroupResponseData>;
368
384
  listGroupMembers(groupId: string): Promise<ListGroupMembersResponseData>;
385
+ /**
386
+ * Member accounts in the group and the devices bound to each. An admin node
387
+ * sees every account; a plain member only its own. `403` if this node is not a
388
+ * member of the group.
389
+ */
390
+ listMemberDevices(groupId: string, options?: ListMemberDevicesOptions): Promise<ListMemberDevicesResponseData>;
391
+ /**
392
+ * Seal a small payload to a member account's root key. This node must be a
393
+ * member of the group, and `account` must be an account the group knows, so
394
+ * the route reaches no further than the caller already does.
395
+ */
396
+ sealToAccount(groupId: string, account: string, request: SealToAccountRequest): Promise<SealedEnvelope>;
369
397
  listGroupContexts(groupId: string): Promise<ListGroupContextsResponseData>;
370
398
  addGroupMembers(groupId: string, request: AddGroupMembersRequest): Promise<void>;
371
399
  removeGroupMembers(groupId: string, request: RemoveGroupMembersRequest): Promise<void>;
@@ -104,6 +104,14 @@ export class AdminApiClient {
104
104
  async healthCheck() {
105
105
  return unwrap(await this.httpClient.get('/admin-api/health'));
106
106
  }
107
+ /**
108
+ * Whether the node has finished starting and its store answers. Public, like
109
+ * {@link healthCheck}; unlike it, a node that is up but not ready answers
110
+ * `503`, which this surfaces as an `HTTPError` whose body names the stage.
111
+ */
112
+ async readinessCheck() {
113
+ return unwrap(await this.httpClient.get('/admin-api/ready'));
114
+ }
107
115
  async isAuthed() {
108
116
  return this.httpClient.get('/admin-api/is-authed');
109
117
  }
@@ -452,6 +460,18 @@ export class AdminApiClient {
452
460
  async performIntent(contextId, request) {
453
461
  return unwrap(await this.httpClient.post(`/admin-api/contexts/${contextId}/intents`, request));
454
462
  }
463
+ /**
464
+ * Read a context as the session's ACCOUNT, without minting a warrant.
465
+ *
466
+ * Needs an account-authenticated session — one from {@link login}, not the
467
+ * admin password login — and refuses otherwise with a `401`. The account must
468
+ * be a member of the group owning the context (`403` if not), and the method
469
+ * must be declared read-only in the app's ABI (`409` if not; a write needs
470
+ * {@link performIntent}).
471
+ */
472
+ async queryContext(contextId, request) {
473
+ return unwrap(await this.httpClient.post(`/admin-api/contexts/${contextId}/query`, request));
474
+ }
455
475
  /**
456
476
  * Ask what this node can do for a member in `contextId`, before they sign
457
477
  * anything.
@@ -725,6 +745,29 @@ export class AdminApiClient {
725
745
  }
726
746
  return response;
727
747
  }
748
+ /**
749
+ * Member accounts in the group and the devices bound to each. An admin node
750
+ * sees every account; a plain member only its own. `403` if this node is not a
751
+ * member of the group.
752
+ */
753
+ async listMemberDevices(groupId, options = {}) {
754
+ const params = new URLSearchParams();
755
+ if (options.offset !== undefined)
756
+ params.set('offset', String(options.offset));
757
+ if (options.limit !== undefined)
758
+ params.set('limit', String(options.limit));
759
+ const query = params.toString();
760
+ const path = `/admin-api/groups/${groupId}/member-devices${query ? `?${query}` : ''}`;
761
+ return this.httpClient.get(path);
762
+ }
763
+ /**
764
+ * Seal a small payload to a member account's root key. This node must be a
765
+ * member of the group, and `account` must be an account the group knows, so
766
+ * the route reaches no further than the caller already does.
767
+ */
768
+ async sealToAccount(groupId, account, request) {
769
+ return unwrap(await this.httpClient.post(`/admin-api/groups/${groupId}/accounts/${account}/seal`, request));
770
+ }
728
771
  async listGroupContexts(groupId) {
729
772
  return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}/contexts`));
730
773
  }
@@ -2,6 +2,15 @@ export { ApiResponse } from '../http-client/index.js';
2
2
  export interface HealthStatus {
3
3
  status: string;
4
4
  }
5
+ /**
6
+ * What `GET /admin-api/ready` reports: `ready` once the node has finished
7
+ * starting up and its store answers. A node that is not ready answers `503`
8
+ * with its lifecycle stage (or `store_unavailable`) as the status, which the
9
+ * client surfaces as an `HTTPError`.
10
+ */
11
+ export interface ReadinessStatus {
12
+ status: string;
13
+ }
5
14
  export interface AdminAuthStatus {
6
15
  data: {
7
16
  status: string;
@@ -412,6 +421,24 @@ export interface PerformIntentRequest {
412
421
  authorProof: string;
413
422
  }
414
423
  /** What a performed intent reports back. */
424
+ /**
425
+ * A read of a context, run as the caller's account. Needs no warrant: a read
426
+ * publishes nothing, so there is no peer to convince.
427
+ */
428
+ export interface QueryContextRequest {
429
+ /**
430
+ * The method to call. It must be declared read-only in the application's ABI
431
+ * (a `&self` method in a Rust app); anything else is refused with a `409`,
432
+ * because a write needs a warrant ({@link PerformIntentRequest}).
433
+ */
434
+ method: string;
435
+ /** Its arguments, as the JSON the guest will receive. */
436
+ argsJson: unknown;
437
+ }
438
+ export interface QueryContextResponseData {
439
+ /** The method's own return value. */
440
+ returns: unknown | null;
441
+ }
415
442
  export interface PerformIntentResponseData {
416
443
  /**
417
444
  * The context's scope root after the run — how a caller sees that it wrote.
@@ -1225,6 +1252,57 @@ export interface ListGroupMembersResponseData {
1225
1252
  */
1226
1253
  data?: GroupMember[];
1227
1254
  }
1255
+ /** One device bound to a member account. */
1256
+ export interface MemberDevice {
1257
+ /** 64 hex; the form `revokeAccountDevice` takes. */
1258
+ deviceId: string;
1259
+ /**
1260
+ * The key this device's signatures carry, 64 hex. Joins against the
1261
+ * identities a context lists.
1262
+ */
1263
+ signingKey: string;
1264
+ }
1265
+ /** A member account and the devices bound to it in the namespace. */
1266
+ export interface MemberDevicesEntry {
1267
+ /** The member's ACCOUNT, 64 hex. */
1268
+ account: string;
1269
+ devices: MemberDevice[];
1270
+ }
1271
+ export interface ListMemberDevicesOptions {
1272
+ offset?: number;
1273
+ limit?: number;
1274
+ }
1275
+ export interface ListMemberDevicesResponseData {
1276
+ /**
1277
+ * Every account in the group if the calling node is an admin; only its own
1278
+ * entry if it is a plain member.
1279
+ */
1280
+ members: MemberDevicesEntry[];
1281
+ }
1282
+ export interface SealToAccountRequest {
1283
+ /**
1284
+ * Hex-encoded plaintext. Small by design: the route exists to hand an account
1285
+ * something like a list of namespace ids, and the node caps the size.
1286
+ */
1287
+ plaintext: string;
1288
+ }
1289
+ /**
1290
+ * A payload sealed to an account's root key. Only that account's root can open
1291
+ * it; the node that sealed it cannot.
1292
+ */
1293
+ export interface SealedEnvelope {
1294
+ /**
1295
+ * The root-key epoch it was sealed under. A rotated root still opens envelopes
1296
+ * from its own epoch, so a recipient holding several needs to know which.
1297
+ */
1298
+ accountRootEpoch: number;
1299
+ /** Hex, 32 bytes: the one-shot sender key. */
1300
+ ephemeralPublicKey: string;
1301
+ /** Hex, 12 bytes: the AES-256-GCM nonce. */
1302
+ nonce: string;
1303
+ /** Hex: the ciphertext with its 16-byte tag appended. */
1304
+ ciphertext: string;
1305
+ }
1228
1306
  export interface GroupContextEntry {
1229
1307
  contextId: string;
1230
1308
  name?: string;