@cubist-labs/cubesigner-sdk 0.4.259 → 0.4.262

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,6 @@
1
1
  import type {
2
2
  CreateOidcUserOptions,
3
+ DeleteUserOptions,
3
4
  IdentityProof,
4
5
  KeyInRoleInfo,
5
6
  KeyInfo,
@@ -202,6 +203,14 @@ export type SessionSelector =
202
203
  | {
203
204
  /** Selects all sessions tied to a user with this ID. */
204
205
  user: string;
206
+ }
207
+ | {
208
+ /**
209
+ * Selects all *role* sessions created by the user with this ID (user sessions are not
210
+ * affected). Org owners select sessions across all roles; other users only across roles
211
+ * they are still a member of.
212
+ */
213
+ role_created_by: string;
205
214
  };
206
215
 
207
216
  /**
@@ -736,9 +745,11 @@ export class ApiClient extends BaseClient {
736
745
  * Remove the user from the org.
737
746
  *
738
747
  * @param userId The ID of the user to remove.
748
+ * @param opts Options for user deletion.
749
+ * @param opts.revoke_role_sessions_they_created Whether to revoke role sessions created by the removed user.
739
750
  * @returns An empty response
740
751
  */
741
- async orgUserDelete(userId: string): Promise<Empty> {
752
+ async orgUserDelete(userId: string, opts?: DeleteUserOptions): Promise<Empty> {
742
753
  const o = op("/v0/org/{org_id}/users/{user_id}", "delete");
743
754
 
744
755
  return this.exec(o, {
@@ -746,6 +757,7 @@ export class ApiClient extends BaseClient {
746
757
  path: {
747
758
  user_id: userId,
748
759
  },
760
+ query: opts,
749
761
  },
750
762
  });
751
763
  }
@@ -860,13 +872,18 @@ export class ApiClient extends BaseClient {
860
872
  * Delete an existing OIDC user.
861
873
  *
862
874
  * @param identity The identity of the OIDC user
875
+ * @param opts Options for user deletion.
876
+ * @param opts.revoke_role_sessions_they_created Whether to revoke role sessions created by the removed user.
863
877
  * @returns An empty response
864
878
  */
865
- async orgUserDeleteOidc(identity: OidcIdentity): Promise<Empty> {
879
+ async orgUserDeleteOidc(identity: OidcIdentity, opts?: DeleteUserOptions): Promise<Empty> {
866
880
  const o = op("/v0/org/{org_id}/users/oidc", "delete");
867
881
 
868
882
  return this.exec(o, {
869
883
  body: identity,
884
+ params: {
885
+ query: opts,
886
+ },
870
887
  });
871
888
  }
872
889
 
@@ -3198,6 +3215,65 @@ export class ApiClient extends BaseClient {
3198
3215
  ).then(assertOk);
3199
3216
  }
3200
3217
 
3218
+ /**
3219
+ * Initiate login via Sign-in With Solana (SIWS).
3220
+ *
3221
+ * The response contains a challenge which must be answered (via {@link siwsLoginComplete})
3222
+ * to obtain an OIDC token.
3223
+ *
3224
+ * @param env The environment to use
3225
+ * @param orgId The org to login to
3226
+ * @param body The request body
3227
+ * @param headers Optional headers to set
3228
+ * @returns The challenge that needs to be answered via {@link siwsLoginComplete}
3229
+ */
3230
+ static async siwsLoginInit(
3231
+ env: EnvInterface,
3232
+ orgId: string,
3233
+ body: schemas["SiwsInitRequest"],
3234
+ headers?: HeadersInit,
3235
+ ): Promise<schemas["SiwsInitResponse"]> {
3236
+ const o = op("/v0/org/{org_id}/oidc/siws", "post");
3237
+ return await retryOn5XX(() =>
3238
+ o({
3239
+ baseUrl: env.SignerApiRoot,
3240
+ params: { path: { org_id: orgId } },
3241
+ body,
3242
+ headers,
3243
+ }),
3244
+ ).then(assertOk);
3245
+ }
3246
+
3247
+ /**
3248
+ * Complete login via Sign-in With Solana (SIWS).
3249
+ *
3250
+ * The challenge returned by {@link siwsLoginInit} should be signed
3251
+ * and submitted via this API call to obtain an OIDC token, which can
3252
+ * then be used to log in via {@link oidcSessionCreate}.
3253
+ *
3254
+ * @param env The environment to use
3255
+ * @param orgId The org to login to
3256
+ * @param body The request body
3257
+ * @param headers Optional headers to set
3258
+ * @returns An OIDC token which can be used to log in via OIDC (see {@link oidcSessionCreate})
3259
+ */
3260
+ static async siwsLoginComplete(
3261
+ env: EnvInterface,
3262
+ orgId: string,
3263
+ body: schemas["SiwsCompleteRequest"],
3264
+ headers?: HeadersInit,
3265
+ ): Promise<schemas["SiwsCompleteResponse"]> {
3266
+ const o = op("/v0/org/{org_id}/oidc/siws", "patch");
3267
+ return await retryOn5XX(() =>
3268
+ o({
3269
+ baseUrl: env.SignerApiRoot,
3270
+ params: { path: { org_id: orgId } },
3271
+ body,
3272
+ headers,
3273
+ }),
3274
+ ).then(assertOk);
3275
+ }
3276
+
3201
3277
  /**
3202
3278
  * Initiate the login with passkey flow.
3203
3279
  *
package/src/role.ts CHANGED
@@ -484,8 +484,30 @@ export type NamedPolicyReference = {
484
484
  Reference: PolicyReference;
485
485
  };
486
486
 
487
+ /** Explicit "permit" vs "deny" policy outcome, with or without a descriptive message. */
488
+ export type Const = ConstOutcome | { outcome: ConstOutcome; message: string };
489
+
490
+ /** Explicit "permit" vs "deny" policy outcome. */
491
+ export type ConstOutcome = "Permit" | "Deny";
492
+
493
+ /**
494
+ * A {@link https://github.com/google/cel-spec Common Expression Language}
495
+ * policy to evaluate against the following context:
496
+ *
497
+ * ```json
498
+ * {
499
+ * "operation": OperationKind,
500
+ * "identity": <UserOrRoleId>,
501
+ * "body": <RequestBodyJson>
502
+ * }
503
+ * ```
504
+ */
505
+ export type Cel = { Cel: string };
506
+
487
507
  /** Key policies that restrict the requests that the signing endpoints accept */
488
508
  export type KeyDenyPolicy =
509
+ | Const
510
+ | Cel
489
511
  | OperationAllowlist
490
512
  | TxReceiver
491
513
  | TxDeposit
@@ -508,6 +530,7 @@ export type KeyDenyPolicy =
508
530
  | PolicyAnd
509
531
  | PolicyOr
510
532
  | PolicyNot
533
+ | PolicyIte
511
534
  | NamedPolicyReference;
512
535
 
513
536
  /**
@@ -545,6 +568,30 @@ export type RolePolicy = RolePolicyRule[];
545
568
 
546
569
  export type RolePolicyRule = KeyDenyPolicy | PolicyReference;
547
570
 
571
+ /** Conditional policy */
572
+ export type Conditional = {
573
+ /** The condition to evaluate first. */
574
+ if: KeyDenyPolicy;
575
+
576
+ /** The policy to apply when the condition evaluates to 'Permit'. */
577
+ then: KeyDenyPolicy;
578
+ };
579
+
580
+ /** One or more conditional policies */
581
+ export type Conditionals =
582
+ | Conditional
583
+ | {
584
+ conditionals: Conditional[];
585
+ };
586
+
587
+ /** If-then-else policy */
588
+ export type PolicyIte = {
589
+ IfThenElse: Conditionals & {
590
+ /** The policy to apply when none of the conditionals apply. */
591
+ else: KeyDenyPolicy;
592
+ };
593
+ };
594
+
548
595
  export type PolicyAnd = {
549
596
  And: KeyDenyPolicy[];
550
597
  };