@calimero-network/mero-js 26.6.0 → 26.8.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.
@@ -219,6 +219,13 @@ export declare class AdminApiClient {
219
219
  */
220
220
  admitJoin(namespaceId: string, request: AdmitJoinRequest): Promise<AdmitJoinResponseData>;
221
221
  joinNamespace(namespaceId: string, request: JoinNamespaceRequest): Promise<JoinNamespaceResponseData>;
222
+ /**
223
+ * Bring back a namespace the user removed from this node while the account
224
+ * stayed a member (POST /admin-api/namespaces/:namespace_id/join, no
225
+ * invitation). Such namespaces are the `forgotten` ones in
226
+ * {@link listNamespacesForApplication}.
227
+ */
228
+ restoreNamespace(namespaceId: string): Promise<JoinNamespaceResponseData>;
222
229
  /**
223
230
  * Join the namespace an invitation grants, and say what happened — including
224
231
  * when the request failed but the join landed anyway.
@@ -623,8 +630,15 @@ export declare class AdminApiClient {
623
630
  leaveGroup(groupId: string): Promise<void>;
624
631
  /** Leave a context (POST /admin-api/contexts/:context_id/leave). */
625
632
  leaveContext(contextId: string): Promise<void>;
626
- /** Leave a namespace (POST /admin-api/namespaces/:namespace_id/leave). */
627
- leaveNamespace(namespaceId: string): Promise<void>;
633
+ /**
634
+ * Leave a namespace (POST /admin-api/namespaces/:namespace_id/leave).
635
+ *
636
+ * With `purge`, every device of the account also takes the namespace off its
637
+ * disk. Core reads `purge` from the query string, so it is not in the body.
638
+ */
639
+ leaveNamespace(namespaceId: string, options?: {
640
+ purge?: boolean;
641
+ }): Promise<void>;
628
642
  /** Issue a group ownership proof (POST /admin-api/groups/:group_id/issue-ownership-proof). */
629
643
  issueOwnershipProof(groupId: string, request: IssueOwnershipProofRequest): Promise<IssueOwnershipProofResponseData>;
630
644
  /** Issue a namespace ownership proof (POST /admin-api/groups/:group_id/issue-namespace-ownership-proof). */
@@ -523,6 +523,15 @@ export class AdminApiClient {
523
523
  }
524
524
  return data;
525
525
  }
526
+ /**
527
+ * Bring back a namespace the user removed from this node while the account
528
+ * stayed a member (POST /admin-api/namespaces/:namespace_id/join, no
529
+ * invitation). Such namespaces are the `forgotten` ones in
530
+ * {@link listNamespacesForApplication}.
531
+ */
532
+ async restoreNamespace(namespaceId) {
533
+ return unwrap(await this.httpClient.post(`/admin-api/namespaces/${pathSegment(namespaceId)}/join`, {}, { timeoutMs: 65000 }));
534
+ }
526
535
  /**
527
536
  * Join the namespace an invitation grants, and say what happened — including
528
537
  * when the request failed but the join landed anyway.
@@ -1137,9 +1146,15 @@ export class AdminApiClient {
1137
1146
  async leaveContext(contextId) {
1138
1147
  await this.httpClient.post(`/admin-api/contexts/${pathSegment(contextId)}/leave`, {});
1139
1148
  }
1140
- /** Leave a namespace (POST /admin-api/namespaces/:namespace_id/leave). */
1141
- async leaveNamespace(namespaceId) {
1142
- await this.httpClient.post(`/admin-api/namespaces/${pathSegment(namespaceId)}/leave`, {});
1149
+ /**
1150
+ * Leave a namespace (POST /admin-api/namespaces/:namespace_id/leave).
1151
+ *
1152
+ * With `purge`, every device of the account also takes the namespace off its
1153
+ * disk. Core reads `purge` from the query string, so it is not in the body.
1154
+ */
1155
+ async leaveNamespace(namespaceId, options = {}) {
1156
+ const query = options.purge ? '?purge=true' : '';
1157
+ await this.httpClient.post(`/admin-api/namespaces/${pathSegment(namespaceId)}/leave${query}`, {});
1143
1158
  }
1144
1159
  /** Issue a group ownership proof (POST /admin-api/groups/:group_id/issue-ownership-proof). */
1145
1160
  async issueOwnershipProof(groupId, request) {
@@ -377,6 +377,12 @@ export interface Namespace {
377
377
  * current on another. Absent when nothing is held, and on nodes that predate it.
378
378
  */
379
379
  heldOps?: NamespaceHeldOps;
380
+ /**
381
+ * The user removed this namespace from this node and the account is still a
382
+ * member. Set only by {@link AdminApiClient.listNamespacesForApplication};
383
+ * {@link AdminApiClient.restoreNamespace} brings it back.
384
+ */
385
+ forgotten?: boolean;
380
386
  }
381
387
  /** The group ops a namespace holds unapplied on the node that answered. */
382
388
  export interface NamespaceHeldOps {
@@ -669,6 +675,8 @@ export interface JoinNamespaceResponseData {
669
675
  * is how the caller addresses the member it just became.
670
676
  */
671
677
  memberAccount: string;
678
+ /** The name a restored namespace had when it was removed. Set only by a restore. */
679
+ name?: string;
672
680
  }
673
681
  export interface CreateGroupInNamespaceRequest {
674
682
  groupName?: string;
@@ -36,11 +36,17 @@ export interface VerifySignedAgentPolicyOptions {
36
36
  identity?: string;
37
37
  /** The OIDC issuer required. Defaults to {@link KMS_RELEASE_SIGNER}'s. */
38
38
  issuer?: string;
39
+ /**
40
+ * The image role the allowlist must be for: `agent` (the default), or
41
+ * `inference`, the release's `kms-inference-attestation-policy.<profile>.json`
42
+ * for its private inference image. Both have the same shape and signer.
43
+ */
44
+ role?: 'agent' | 'inference';
39
45
  }
40
46
  /**
41
47
  * Verify an agent allowlist against its cosign bundle, as `cosign verify-blob`
42
48
  * would, and return it parsed. Rejects unless it was signed by the KMS release
43
- * workflow, it is an agent allowlist (`role: "agent"`) for the profile asked
49
+ * workflow, it is an allowlist for `options.role` (default `agent`) and the profile asked
44
50
  * for, every list in it is non-empty, and `expectedVersion`, when given, is its
45
51
  * `version`.
46
52
  */
@@ -27,7 +27,7 @@ const LISTS = [
27
27
  /**
28
28
  * Verify an agent allowlist against its cosign bundle, as `cosign verify-blob`
29
29
  * would, and return it parsed. Rejects unless it was signed by the KMS release
30
- * workflow, it is an agent allowlist (`role: "agent"`) for the profile asked
30
+ * workflow, it is an allowlist for `options.role` (default `agent`) and the profile asked
31
31
  * for, every list in it is non-empty, and `expectedVersion`, when given, is its
32
32
  * `version`.
33
33
  */
@@ -44,8 +44,9 @@ export async function verifySignedAgentPolicy(policy, bundle, options = {}) {
44
44
  catch {
45
45
  throw new Error('The signed agent policy is not JSON');
46
46
  }
47
- if (parsed?.role !== 'agent') {
48
- throw new Error(`The signed file is a ${JSON.stringify(parsed?.role)} policy, not an agent one`);
47
+ const role = options.role ?? 'agent';
48
+ if (parsed?.role !== role) {
49
+ throw new Error(`The signed file is a ${JSON.stringify(parsed?.role)} policy, not an ${role} one`);
49
50
  }
50
51
  const profile = options.profile ?? PRODUCTION_PROFILE;
51
52
  if (parsed.profile !== profile) {