@cubist-labs/cubesigner-sdk 0.4.276 → 0.4.279

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git",
6
6
  "directory": "packages/sdk"
7
7
  },
8
- "version": "0.4.276",
8
+ "version": "0.4.279",
9
9
  "type": "module",
10
10
  "description": "CubeSigner TypeScript SDK",
11
11
  "license": "MIT OR Apache-2.0",
package/src/acl.ts CHANGED
@@ -7,7 +7,9 @@ export type Ace<TAction, TCtx> = {
7
7
  subjects: AceAttribute<string>;
8
8
  /** The actions being performed */
9
9
  actions: AceAttribute<TAction>;
10
+ /** The effect of this access control entry. */
11
+ effect?: "Allow" | "Deny";
10
12
  } & TCtx;
11
13
 
12
14
  /** An attribute of an access control entry. */
13
- export type AceAttribute<T> = "*" | T | T[];
15
+ export type AceAttribute<T> = "*" | T | T[] | { except: T[] };
@@ -224,6 +224,55 @@ export type SessionSelector =
224
224
  role?: string;
225
225
  };
226
226
 
227
+ /**
228
+ * Options for listing the users in an org.
229
+ */
230
+ export interface ListUsersOptions {
231
+ /** Pagination options. Defaults to fetching the entire result set. */
232
+ page?: PageOpts;
233
+
234
+ /**
235
+ * If defined, all returned users will contain this string in their name or email.
236
+ */
237
+ searchQuery?: string;
238
+
239
+ /**
240
+ * If defined, only users with one of these roles in the org are returned,
241
+ * grouped by role in descending role order (owners first, aliens last).
242
+ */
243
+ membership?: MemberRole[];
244
+ }
245
+
246
+ /**
247
+ * Options for listing the pending invitations in an org.
248
+ */
249
+ export interface ListInvitationsOptions {
250
+ /** Pagination options. Defaults to fetching the entire result set. */
251
+ page?: PageOpts;
252
+
253
+ /**
254
+ * If defined, only invitations for one of these roles are returned,
255
+ * grouped by role in descending role order (owners first, aliens last).
256
+ */
257
+ membership?: MemberRole[];
258
+ }
259
+
260
+ /**
261
+ * Distinguishes the `ListUsersOptions` argument of {@link ApiClient.orgUsersList}
262
+ * from its deprecated leading `PageOpts` argument. This works because the two types
263
+ * have disjoint keys: any of the `PageOpts` keys being present identifies a `PageOpts`,
264
+ * so everything else is a `ListUsersOptions`. An argument with none of those keys
265
+ * (e.g. `{}`) is reported as `ListUsersOptions`, which is harmless: neither
266
+ * interpretation restricts the result set.
267
+ *
268
+ * @param arg The first argument passed to `orgUsersList`.
269
+ * @returns Whether `arg` is a `ListUsersOptions` (as opposed to `PageOpts`).
270
+ */
271
+ function isListUsersOptions(arg: ListUsersOptions | PageOpts | undefined): arg is ListUsersOptions {
272
+ if (arg === undefined) return false;
273
+ return !("size" in arg || "start" in arg || "all" in arg);
274
+ }
275
+
227
276
  /**
228
277
  * An extension of BaseClient that adds specialized methods for api endpoints
229
278
  */
@@ -785,17 +834,18 @@ export class ApiClient extends BaseClient {
785
834
  * List pending invitations in the org, i.e., those that have neither been
786
835
  * accepted nor canceled, and have not expired.
787
836
  *
788
- * @param page Pagination options. Defaults to fetching the entire result set.
837
+ * @param opts Pagination and filtering options. Defaults to fetching the entire result set.
789
838
  * @returns Paginator for iterating over the pending invitations in the org.
790
839
  */
791
840
  orgInvitationsList(
792
- page?: PageOpts,
841
+ opts?: ListInvitationsOptions,
793
842
  ): Paginator<PaginatedListInvitationsResponse, InvitationInfo[]> {
794
843
  const o = op("/v0/org/{org_id}/invitations", "get");
795
844
 
796
845
  return Paginator.items(
797
- page ?? Page.default(),
798
- (pageQuery) => this.exec(o, { params: { query: { ...pageQuery } } }),
846
+ opts?.page ?? Page.default(),
847
+ (pageQuery) =>
848
+ this.exec(o, { params: { query: { membership: opts?.membership, ...pageQuery } } }),
799
849
  (r) => r.invitations,
800
850
  (r) => r.last_evaluated_key,
801
851
  );
@@ -840,19 +890,44 @@ export class ApiClient extends BaseClient {
840
890
  /**
841
891
  * List users in the org.
842
892
  *
893
+ * @overload
894
+ * @param opts Pagination and filtering options. Defaults to fetching the entire result set.
895
+ * @returns Paginator for iterating over the users in the org.
896
+ */
897
+ orgUsersList(opts?: ListUsersOptions): Paginator<GetUsersInOrgResponse, UserInOrgInfo[]>;
898
+ /**
899
+ * List users in the org.
900
+ *
901
+ * @overload
843
902
  * @param page Pagination options. Defaults to fetching the entire result set.
844
- * @param searchQuery Optional query string. If defined, all returned users will contain this string in their name or email.
903
+ * @param searchQuery Query string. If defined, all returned users will contain this string in their name or email.
845
904
  * @returns Paginator for iterating over the users in the org.
905
+ * @deprecated Use the `ListUsersOptions` parameter overload instead.
846
906
  */
847
907
  orgUsersList(
848
908
  page?: PageOpts,
849
909
  searchQuery?: string,
910
+ ): Paginator<GetUsersInOrgResponse, UserInOrgInfo[]>;
911
+ /**
912
+ * List users in the org.
913
+ *
914
+ * @param opts Either pagination and filtering options, or (deprecated) just pagination options.
915
+ * @param searchQuery Deprecated search query string; only used with the deprecated overload.
916
+ * @returns Paginator for iterating over the users in the org.
917
+ */
918
+ orgUsersList(
919
+ opts?: ListUsersOptions | PageOpts,
920
+ searchQuery?: string,
850
921
  ): Paginator<GetUsersInOrgResponse, UserInOrgInfo[]> {
922
+ const luOpts: ListUsersOptions = isListUsersOptions(opts) ? opts : { page: opts, searchQuery };
851
923
  const o = op("/v0/org/{org_id}/users", "get");
852
924
 
853
925
  return Paginator.items(
854
- page ?? Page.default(),
855
- (pageQuery) => this.exec(o, { params: { query: { q: searchQuery, ...pageQuery } } }),
926
+ luOpts.page ?? Page.default(),
927
+ (pageQuery) =>
928
+ this.exec(o, {
929
+ params: { query: { q: luOpts.searchQuery, membership: luOpts.membership, ...pageQuery } },
930
+ }),
856
931
  (r) => r.users.map(ApiClient.#processUserInOrgInfo),
857
932
  (r) => r.last_evaluated_key,
858
933
  );
@@ -2232,6 +2307,9 @@ export class ApiClient extends BaseClient {
2232
2307
  /**
2233
2308
  * List pending MFA requests accessible to the current user.
2234
2309
  *
2310
+ * Note that legacy MFA requests are not paginated: every accessible one is
2311
+ * returned in the first page, on top of the requested page limit.
2312
+ *
2235
2313
  * @param page Pagination options. Defaults to fetching the entire result set.
2236
2314
  * @returns Paginator for iterating over the MFA requests.
2237
2315
  */
package/src/org.ts CHANGED
@@ -32,6 +32,8 @@ import type {
32
32
  AuditLogRequest,
33
33
  MfaReceipts,
34
34
  InvitationInfo,
35
+ ListUsersOptions,
36
+ ListInvitationsOptions,
35
37
  } from "./index.ts";
36
38
  import { Contact } from "./contact.ts";
37
39
  import { C2FFunction, Key, MfaRequest, Role } from "./index.ts";
@@ -541,10 +543,11 @@ export class Org {
541
543
  * List all pending invitations in the organization, i.e., those that have
542
544
  * neither been accepted nor canceled, and have not expired.
543
545
  *
546
+ * @param opts Pagination and filtering options. Defaults to fetching the entire result set.
544
547
  * @returns The list of pending invitations
545
548
  */
546
- async invitations(): Promise<InvitationInfo[]> {
547
- return await this.#apiClient.orgInvitationsList().fetchAll();
549
+ async invitations(opts?: ListInvitationsOptions): Promise<InvitationInfo[]> {
550
+ return await this.#apiClient.orgInvitationsList(opts).fetchAll();
548
551
  }
549
552
 
550
553
  /**
@@ -617,11 +620,32 @@ export class Org {
617
620
  /**
618
621
  * List all users in the organization.
619
622
  *
620
- * @param searchQuery Optional query string. If defined, all returned users will contain this string in their name or email.
623
+ * @overload
624
+ * @param opts Additional options for filtering the users.
621
625
  * @returns The list of users
622
626
  */
623
- async users(searchQuery?: string): Promise<UserInOrgInfo[]> {
624
- return await this.#apiClient.orgUsersList(undefined, searchQuery).fetchAll();
627
+ async users(opts?: ListUsersOptions): Promise<UserInOrgInfo[]>;
628
+ /**
629
+ * List all users in the organization.
630
+ *
631
+ * @overload
632
+ * @param searchQuery Query string. If defined, all returned users will contain this string in their name or email.
633
+ * @returns The list of users
634
+ * @deprecated Use the `ListUsersOptions` parameter overload instead.
635
+ */
636
+ async users(searchQuery?: string): Promise<UserInOrgInfo[]>;
637
+ /**
638
+ * List all users in the organization.
639
+ *
640
+ * @param optsOrSearchQuery Either additional options for filtering the users, or (deprecated) a search query string.
641
+ * @returns The list of users
642
+ */
643
+ async users(optsOrSearchQuery?: ListUsersOptions | string): Promise<UserInOrgInfo[]> {
644
+ const opts: ListUsersOptions =
645
+ typeof optsOrSearchQuery === "string"
646
+ ? { searchQuery: optsOrSearchQuery }
647
+ : (optsOrSearchQuery ?? {});
648
+ return await this.#apiClient.orgUsersList(opts).fetchAll();
625
649
  }
626
650
 
627
651
  /**
package/src/policy.ts CHANGED
@@ -78,7 +78,7 @@ export type PolicyCtx = {
78
78
  * The resources (keys, roles, and key-in-roles) that the access control entry
79
79
  * applies to.
80
80
  */
81
- resources: AceAttribute<PolicyResource>;
81
+ resources?: AceAttribute<PolicyResource>;
82
82
  };
83
83
 
84
84
  /** A resource a policy is invoked with or attached to. */
package/src/schema.ts CHANGED
@@ -755,6 +755,8 @@ export interface paths {
755
755
  *
756
756
  * NOTE that if pagination is used and a page limit is set, the returned result
757
757
  * set may contain either FEWER or MORE elements than the requested page limit.
758
+ * In particular, legacy MFA requests are not paginated: every accessible one
759
+ * is returned in the first page, on top of the page limit.
758
760
  */
759
761
  get: operations["mfaList"];
760
762
  };
@@ -2880,6 +2882,9 @@ export interface components {
2880
2882
  /** @enum {string} */
2881
2883
  BadRequestErrorCode:
2882
2884
  | "GenericBadRequest"
2885
+ | "CannotVoteOnRedeemedRequest"
2886
+ | "PendingOpAlreadyVetoed"
2887
+ | "MultiplePendingOpsReferenced"
2883
2888
  | "DisallowedAllowRuleReference"
2884
2889
  | "InvalidPaginationToken"
2885
2890
  | "InvalidEmail"
@@ -7018,10 +7023,10 @@ export interface components {
7018
7023
  | "SessionPossiblyStolenToken"
7019
7024
  | "MfaDisallowedIdentity"
7020
7025
  | "MfaDisallowedApprover"
7026
+ | "PendingOpDisallowedApprover"
7021
7027
  | "MfaTypeNotAllowed"
7022
7028
  | "MfaNotApprovedYet"
7023
7029
  | "MfaConfirmationCodeMismatch"
7024
- | "MfaHttpRequestMismatch"
7025
7030
  | "MfaRemoveBelowMin"
7026
7031
  | "MfaOrgRequirementNotMet"
7027
7032
  | "MfaRegistrationDisallowed"
@@ -7985,13 +7990,16 @@ export interface components {
7985
7990
  * }
7986
7991
  */
7987
7992
  MfaPolicy: {
7988
- /** @description Users who are allowed to approve. If empty at creation time, default to the current user. */
7993
+ /**
7994
+ * @description Users who are allowed to approve. If empty, the current user
7995
+ * will be inserted by default.
7996
+ */
7989
7997
  allowed_approvers?: string[];
7990
7998
  /** @description Allowed approval types. When omitted, defaults to any. */
7991
7999
  allowed_mfa_types?: components["schemas"]["MfaType"][] | null;
7992
8000
  /**
7993
8001
  * Format: int32
7994
- * @description How many users to require to approve (defaults to 1).
8002
+ * @description How many users must approve (defaults to 1).
7995
8003
  */
7996
8004
  count?: number;
7997
8005
  lifetime?: components["schemas"]["Seconds"];
@@ -8054,7 +8062,7 @@ export interface components {
8054
8062
  MfaRequiredArgs: {
8055
8063
  /** @description Always set to first MFA id from `Self::ids` */
8056
8064
  id: string;
8057
- /** @description Non-empty MFA request IDs */
8065
+ /** @description Non-empty MFA request IDs or [`PendingOpPolicyRef`]-form refs */
8058
8066
  ids: string[];
8059
8067
  /** @description Organization id */
8060
8068
  org_id: string;
@@ -9347,6 +9355,8 @@ export interface components {
9347
9355
  | components["schemas"]["EvmTxDepositErrorCode"];
9348
9356
  /** @enum {string} */
9349
9357
  PolicyErrorOwnCodes:
9358
+ | "MfaHttpRequestMismatch"
9359
+ | "MfaExpired"
9350
9360
  | "Inapplicable"
9351
9361
  | "SuiTxReceiversDisallowedTransactionKind"
9352
9362
  | "SuiTxReceiversDisallowedTransferAddress"
@@ -9423,6 +9433,7 @@ export interface components {
9423
9433
  | "WasmPolicyFailed"
9424
9434
  | "WebhookPoliciesDisabled"
9425
9435
  | "DeniedByWebhook"
9436
+ | "MfaApprovalsNotYetValid"
9426
9437
  | "ExplicitlyDenied";
9427
9438
  /** @description A struct containing all the information about a specific version of a policy. */
9428
9439
  PolicyInfo: {
@@ -9523,8 +9534,7 @@ export interface components {
9523
9534
  | "ConcurrentSigningWhenTimeLimitPolicyIsDefined"
9524
9535
  | "BabylonEotsConcurrentSigning"
9525
9536
  | "TendermintStateError"
9526
- | "TendermintConcurrentSigning"
9527
- | "MfaApprovalsNotYetValid";
9537
+ | "TendermintConcurrentSigning";
9528
9538
  /** @description Contains outputs of previous transactions. */
9529
9539
  PrevOutputs: OneOf<
9530
9540
  [
@@ -10676,28 +10686,36 @@ export interface components {
10676
10686
  */
10677
10687
  created_validator_key_id: string;
10678
10688
  };
10689
+ /**
10690
+ * @description Approval state for a [`MfaRequest`] in [`MfaRequestSource::Legacy`] mode:
10691
+ * the per-policy [`ApprovalConstraints`] plus an inline `approved_by` map.
10692
+ * Pooled MfaRequests carry only [`ApprovalConstraints`] — their approvals live
10693
+ * on the linked [`PendingOp`] — so the type system enforces "no pooled
10694
+ * MfaRequest has an `approved_by`."
10695
+ */
10679
10696
  Status: {
10680
10697
  /** @description Users who are allowed to approve. Must be non-empty. */
10681
10698
  allowed_approvers: string[];
10682
10699
  /** @description Allowed approval types. When omitted, defaults to any. */
10683
10700
  allowed_mfa_types?: components["schemas"]["MfaType"][] | null;
10684
- /** @description Users who have already approved */
10685
- approved_by: {
10686
- [key: string]: {
10687
- [key: string]: components["schemas"]["ApprovalInfo"];
10688
- };
10689
- };
10690
10701
  /**
10691
10702
  * Format: int32
10692
- * @description How many users must approve
10703
+ * @description How many users must approve (defaults to 1).
10693
10704
  */
10694
10705
  count: number;
10695
10706
  /**
10696
10707
  * Format: int32
10697
- * @description How many auth factors to require per user
10708
+ * @description How many auth factors to require per user (defaults to 1).
10698
10709
  */
10699
10710
  num_auth_factors: number;
10700
10711
  request_comparer?: components["schemas"]["HttpRequestCmp"];
10712
+ } & {
10713
+ /** @description Users who have already approved. */
10714
+ approved_by: {
10715
+ [key: string]: {
10716
+ [key: string]: components["schemas"]["ApprovalInfo"];
10717
+ };
10718
+ };
10701
10719
  };
10702
10720
  /**
10703
10721
  * @description A single asset balance entry returned by [`SubAccountAssetsResponse`].
@@ -16229,6 +16247,8 @@ export interface operations {
16229
16247
  * the exact value previously returned as 'last_evaluated_key' from the same endpoint.
16230
16248
  */
16231
16249
  "page.start"?: string | null;
16250
+ /** @description Membership roles. If defined, only invitations for one of these roles are returned, grouped by role in descending role order (owners first, aliens last). */
16251
+ membership?: components["schemas"]["MemberRole"][] | null;
16232
16252
  };
16233
16253
  path: {
16234
16254
  /**
@@ -16735,6 +16755,8 @@ export interface operations {
16735
16755
  *
16736
16756
  * NOTE that if pagination is used and a page limit is set, the returned result
16737
16757
  * set may contain either FEWER or MORE elements than the requested page limit.
16758
+ * In particular, legacy MFA requests are not paginated: every accessible one
16759
+ * is returned in the first page, on top of the page limit.
16738
16760
  */
16739
16761
  mfaList: {
16740
16762
  parameters: {
@@ -19691,6 +19713,8 @@ export interface operations {
19691
19713
  "page.start"?: string | null;
19692
19714
  /** @description A query string. If defined, all returned users will contain this string in their name or email. */
19693
19715
  q?: string | null;
19716
+ /** @description Membership roles. If defined, only users with one of these roles in the org are returned, grouped by role in descending role order (owners first, aliens last). */
19717
+ membership?: components["schemas"]["MemberRole"][] | null;
19694
19718
  };
19695
19719
  path: {
19696
19720
  /**