@cubist-labs/cubesigner-sdk 0.4.254 → 0.4.259
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/dist/package.json +1 -1
- package/dist/src/audit_log.d.ts +5 -5
- package/dist/src/client/api_client.d.ts +18 -3
- package/dist/src/client/api_client.d.ts.map +1 -1
- package/dist/src/client/api_client.js +27 -4
- package/dist/src/key.d.ts +5 -8
- package/dist/src/key.d.ts.map +1 -1
- package/dist/src/key.js +6 -2
- package/dist/src/org.d.ts +463 -25
- package/dist/src/org.d.ts.map +1 -1
- package/dist/src/org.js +66 -26
- package/dist/src/schema.d.ts +531 -13
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +7 -0
- package/dist/src/schema_types.d.ts.map +1 -1
- package/dist/src/schema_types.js +23 -3
- package/dist/src/scopes.d.ts.map +1 -1
- package/dist/src/scopes.js +10 -1
- package/package.json +1 -1
- package/src/client/api_client.ts +36 -4
- package/src/key.ts +8 -8
- package/src/org.ts +82 -28
- package/src/schema.ts +581 -9
- package/src/schema_types.ts +30 -2
- package/src/scopes.ts +9 -0
package/src/client/api_client.ts
CHANGED
|
@@ -50,6 +50,7 @@ import type {
|
|
|
50
50
|
Empty,
|
|
51
51
|
UserOrgsResponse,
|
|
52
52
|
CreateKeyImportKeyResponse,
|
|
53
|
+
CreatePolicyImportKeyResponse,
|
|
53
54
|
ImportKeyRequest,
|
|
54
55
|
UpdatePolicyRequest,
|
|
55
56
|
ListPoliciesResponse,
|
|
@@ -147,6 +148,7 @@ import {
|
|
|
147
148
|
type InvokePolicyRequest,
|
|
148
149
|
type PolicySecretsInfo,
|
|
149
150
|
type SetPolicySecretRequest,
|
|
151
|
+
type UpdatePolicySecretsRequest,
|
|
150
152
|
type UploadWasmPolicyRequest,
|
|
151
153
|
type UploadWasmPolicyResponse,
|
|
152
154
|
type LoginRequest,
|
|
@@ -535,12 +537,16 @@ export class ApiClient extends BaseClient {
|
|
|
535
537
|
* Update the org.
|
|
536
538
|
*
|
|
537
539
|
* @param request The JSON request to send to the API server.
|
|
540
|
+
* @param mfaReceipt Optional MFA receipt(s)
|
|
538
541
|
* @returns Updated org information.
|
|
539
542
|
*/
|
|
540
|
-
async orgUpdate(
|
|
543
|
+
async orgUpdate(
|
|
544
|
+
request: UpdateOrgRequest,
|
|
545
|
+
mfaReceipt?: MfaReceipts,
|
|
546
|
+
): Promise<CubeSignerResponse<UpdateOrgResponse>> {
|
|
541
547
|
const o = op("/v0/org/{org_id}", "patch");
|
|
542
|
-
|
|
543
|
-
return this.
|
|
548
|
+
const reqFn = (headers?: HeadersInit) => this.exec(o, { body: request, headers });
|
|
549
|
+
return await CubeSignerResponse.create(this.env, reqFn, mfaReceipt);
|
|
544
550
|
}
|
|
545
551
|
|
|
546
552
|
/**
|
|
@@ -1540,7 +1546,17 @@ export class ApiClient extends BaseClient {
|
|
|
1540
1546
|
|
|
1541
1547
|
// #endregion
|
|
1542
1548
|
|
|
1543
|
-
// #region POLICY: policy(Create|Get|List|Update|Delete|Invoke), policySecret(Set|Delete),
|
|
1549
|
+
// #region POLICY: policyImportKeyCreate, policy(Create|Get|List|Update|Delete|Invoke), policySecret(Set|Delete), policySecrets(Get|Update)
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* Request a fresh policy import key.
|
|
1553
|
+
*
|
|
1554
|
+
* @returns A fresh policy import key
|
|
1555
|
+
*/
|
|
1556
|
+
async policyImportKeyCreate(): Promise<CreatePolicyImportKeyResponse> {
|
|
1557
|
+
const o = op("/v0/org/{org_id}/policy/import_key", "get");
|
|
1558
|
+
return await this.exec(o, {});
|
|
1559
|
+
}
|
|
1544
1560
|
|
|
1545
1561
|
/**
|
|
1546
1562
|
* Create a new named policy.
|
|
@@ -1698,6 +1714,22 @@ export class ApiClient extends BaseClient {
|
|
|
1698
1714
|
return this.exec(o, {});
|
|
1699
1715
|
}
|
|
1700
1716
|
|
|
1717
|
+
/**
|
|
1718
|
+
* Update org-level policy secrets metadata (e.g., the edit policy).
|
|
1719
|
+
*
|
|
1720
|
+
* @param request The update request.
|
|
1721
|
+
* @param mfaReceipt Optional MFA receipt(s).
|
|
1722
|
+
* @returns The updated policy secrets info.
|
|
1723
|
+
*/
|
|
1724
|
+
async policySecretsUpdate(
|
|
1725
|
+
request: UpdatePolicySecretsRequest,
|
|
1726
|
+
mfaReceipt?: MfaReceipts,
|
|
1727
|
+
): Promise<CubeSignerResponse<PolicySecretsInfo>> {
|
|
1728
|
+
const o = op("/v0/org/{org_id}/policy/secrets", "patch");
|
|
1729
|
+
const reqFn = async (headers?: HeadersInit) => this.exec(o, { body: request, headers });
|
|
1730
|
+
return await CubeSignerResponse.create(this.env, reqFn, mfaReceipt);
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1701
1733
|
/**
|
|
1702
1734
|
* Delete an org-level policy secret.
|
|
1703
1735
|
*
|
package/src/key.ts
CHANGED
|
@@ -29,8 +29,7 @@ import type {
|
|
|
29
29
|
DiffieHellmanResponse,
|
|
30
30
|
KeyInfoJwt,
|
|
31
31
|
KeyAttestationQuery,
|
|
32
|
-
|
|
33
|
-
CoinbaseApiProperties,
|
|
32
|
+
KeyPropertiesPatch,
|
|
34
33
|
} from "./schema_types";
|
|
35
34
|
import type {
|
|
36
35
|
ApiClient,
|
|
@@ -118,6 +117,10 @@ export enum P256 {
|
|
|
118
117
|
export const Mnemonic = "Mnemonic" as const;
|
|
119
118
|
export type Mnemonic = typeof Mnemonic;
|
|
120
119
|
|
|
120
|
+
/** HmacSha256 key type */
|
|
121
|
+
export const HmacSha256 = "HmacSha256" as const;
|
|
122
|
+
export type HmacSha256 = typeof HmacSha256;
|
|
123
|
+
|
|
121
124
|
/** Stark key type */
|
|
122
125
|
export const Stark = "Stark" as const;
|
|
123
126
|
export type Stark = typeof Stark;
|
|
@@ -127,12 +130,7 @@ export const BabyJubjub = "BabyJubjub" as const;
|
|
|
127
130
|
export type BabyJubjub = typeof BabyJubjub;
|
|
128
131
|
|
|
129
132
|
/** Key type */
|
|
130
|
-
export type KeyType = Secp256k1 | Bls | Ed25519 | Mnemonic | Stark | P256 | BabyJubjub;
|
|
131
|
-
|
|
132
|
-
/** The type representing all different kinds of key properties. */
|
|
133
|
-
export type KeyPropertiesPatch =
|
|
134
|
-
| ({ kind: "BinanceApi" } & BinanceApiProperties)
|
|
135
|
-
| ({ kind: "CoinbaseApi" } & CoinbaseApiProperties);
|
|
133
|
+
export type KeyType = Secp256k1 | Bls | Ed25519 | Mnemonic | HmacSha256 | Stark | P256 | BabyJubjub;
|
|
136
134
|
|
|
137
135
|
/**
|
|
138
136
|
* A representation of a signing key.
|
|
@@ -852,6 +850,8 @@ export function fromSchemaKeyType(ty: SchemaKeyType): KeyType {
|
|
|
852
850
|
return Ed25519.CoinbaseApi;
|
|
853
851
|
case "Stark":
|
|
854
852
|
return Stark;
|
|
853
|
+
case "HmacSha256":
|
|
854
|
+
return HmacSha256;
|
|
855
855
|
case "Mnemonic":
|
|
856
856
|
return Mnemonic;
|
|
857
857
|
case "P256CosmosAddr":
|
package/src/org.ts
CHANGED
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
OrgExtData,
|
|
30
30
|
AuditLogEntry,
|
|
31
31
|
AuditLogRequest,
|
|
32
|
+
MfaReceipts,
|
|
32
33
|
} from ".";
|
|
33
34
|
import { Contact } from "./contact";
|
|
34
35
|
import { C2FFunction, Key, MfaRequest, Role } from ".";
|
|
@@ -307,14 +308,26 @@ export class Org {
|
|
|
307
308
|
return data.enabled;
|
|
308
309
|
}
|
|
309
310
|
|
|
310
|
-
/**
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
/**
|
|
312
|
+
* Enable the org.
|
|
313
|
+
*
|
|
314
|
+
* @param opts Optional parameters
|
|
315
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
316
|
+
* @returns Org info
|
|
317
|
+
*/
|
|
318
|
+
async enable(opts?: { mfaReceipt?: MfaReceipts }) {
|
|
319
|
+
return await this.update({ enabled: true }, opts?.mfaReceipt);
|
|
313
320
|
}
|
|
314
321
|
|
|
315
|
-
/**
|
|
316
|
-
|
|
317
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Disable the org.
|
|
324
|
+
*
|
|
325
|
+
* @param opts Optional parameters
|
|
326
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
327
|
+
* @returns Org info
|
|
328
|
+
*/
|
|
329
|
+
async disable(opts?: { mfaReceipt?: MfaReceipts }) {
|
|
330
|
+
return await this.update({ enabled: false }, opts?.mfaReceipt);
|
|
318
331
|
}
|
|
319
332
|
|
|
320
333
|
/** @returns the policy for the org. */
|
|
@@ -333,10 +346,25 @@ export class Org {
|
|
|
333
346
|
* Set the policy for the org.
|
|
334
347
|
*
|
|
335
348
|
* @param policy The new policy for the org.
|
|
349
|
+
* @param opts Optional parameters
|
|
350
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
351
|
+
* @returns Org info
|
|
336
352
|
*/
|
|
337
|
-
async setPolicy(policy: OrgPolicy[]) {
|
|
353
|
+
async setPolicy(policy: OrgPolicy[], opts?: { mfaReceipt?: MfaReceipts }) {
|
|
338
354
|
const p = policy as unknown as Record<string, never>[];
|
|
339
|
-
await this.update({ policy: p });
|
|
355
|
+
return await this.update({ policy: p }, opts?.mfaReceipt);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Set the edit policy for the org.
|
|
360
|
+
*
|
|
361
|
+
* @param editPolicy The new edit policy for the org.
|
|
362
|
+
* @param opts Optional parameters
|
|
363
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
364
|
+
* @returns Org info
|
|
365
|
+
*/
|
|
366
|
+
async setEditPolicy(editPolicy: EditPolicy, opts?: { mfaReceipt?: MfaReceipts }) {
|
|
367
|
+
return await this.update({ edit_policy: editPolicy }, opts?.mfaReceipt);
|
|
340
368
|
}
|
|
341
369
|
|
|
342
370
|
/**
|
|
@@ -346,9 +374,12 @@ export class Org {
|
|
|
346
374
|
* It is analogous to how role policies apply to all sign requests performed by the corresponding role sessions.
|
|
347
375
|
*
|
|
348
376
|
* @param policy The new policy for the org.
|
|
377
|
+
* @param opts Optional parameters
|
|
378
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
379
|
+
* @returns Org info
|
|
349
380
|
*/
|
|
350
|
-
async setSignPolicy(policy: RolePolicy) {
|
|
351
|
-
await this.update({ sign_policy: policy });
|
|
381
|
+
async setSignPolicy(policy: RolePolicy, opts?: { mfaReceipt?: MfaReceipts }) {
|
|
382
|
+
return await this.update({ sign_policy: policy }, opts?.mfaReceipt);
|
|
352
383
|
}
|
|
353
384
|
|
|
354
385
|
/**
|
|
@@ -365,9 +396,12 @@ export class Org {
|
|
|
365
396
|
* Update the organization's extended properties (uncommon features not used by most users).
|
|
366
397
|
*
|
|
367
398
|
* @param props The new properties.
|
|
399
|
+
* @param opts Optional parameters
|
|
400
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
401
|
+
* @returns Org info
|
|
368
402
|
*/
|
|
369
|
-
async setExtendedProperties(props: OrgExtProps) {
|
|
370
|
-
await this.update({ ext_props: props });
|
|
403
|
+
async setExtendedProperties(props: OrgExtProps, opts?: { mfaReceipt?: MfaReceipts }) {
|
|
404
|
+
return await this.update({ ext_props: props }, opts?.mfaReceipt);
|
|
371
405
|
}
|
|
372
406
|
|
|
373
407
|
/**
|
|
@@ -377,8 +411,14 @@ export class Org {
|
|
|
377
411
|
* In other words, org admins can still assign unlimited number of keys to their alien users.
|
|
378
412
|
*
|
|
379
413
|
* @param alienKeyCountThreshold The new key count threshold.
|
|
380
|
-
|
|
381
|
-
|
|
414
|
+
* @param opts Optional parameters
|
|
415
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
416
|
+
* @returns Org info
|
|
417
|
+
*/
|
|
418
|
+
async setAlienKeyCountThreshold(
|
|
419
|
+
alienKeyCountThreshold: number,
|
|
420
|
+
opts?: { mfaReceipt?: MfaReceipts },
|
|
421
|
+
) {
|
|
382
422
|
const data = { ...((await this.getExtendedProperties()) ?? {}) };
|
|
383
423
|
|
|
384
424
|
// erase the metadata that cannot be updated
|
|
@@ -388,29 +428,37 @@ export class Org {
|
|
|
388
428
|
// update 'alien_key_count_threshold' and keep everything else the same
|
|
389
429
|
data.alien_key_count_threshold = alienKeyCountThreshold;
|
|
390
430
|
|
|
391
|
-
await this.update({ ext_props: data });
|
|
431
|
+
return await this.update({ ext_props: data }, opts?.mfaReceipt);
|
|
392
432
|
}
|
|
393
433
|
|
|
394
434
|
/**
|
|
395
435
|
* Set the notification endpoints for the org.
|
|
396
436
|
*
|
|
397
437
|
* @param notification_endpoints Endpoints.
|
|
438
|
+
* @param opts Optional parameters
|
|
439
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
440
|
+
* @returns Org info
|
|
398
441
|
*/
|
|
399
|
-
async setNotificationEndpoints(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
442
|
+
async setNotificationEndpoints(
|
|
443
|
+
notification_endpoints: NotificationEndpointConfiguration[],
|
|
444
|
+
opts?: { mfaReceipt?: MfaReceipts },
|
|
445
|
+
) {
|
|
446
|
+
return await this.update({ notification_endpoints }, opts?.mfaReceipt);
|
|
403
447
|
}
|
|
404
448
|
|
|
405
449
|
/**
|
|
406
450
|
* Set required MFA types for actions implicitly requiring MFA (see {@link MfaProtectedAction}).
|
|
407
451
|
*
|
|
408
452
|
* @param allowed_mfa_types Assignment of MFA types to actions that implicitly require MFA.
|
|
453
|
+
* @param opts Optional parameters
|
|
454
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
455
|
+
* @returns Org info
|
|
409
456
|
*/
|
|
410
|
-
async setAllowedMfaTypes(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
457
|
+
async setAllowedMfaTypes(
|
|
458
|
+
allowed_mfa_types: Partial<Record<MfaProtectedAction, MfaType[]>>,
|
|
459
|
+
opts?: { mfaReceipt?: MfaReceipts },
|
|
460
|
+
) {
|
|
461
|
+
return await this.update({ allowed_mfa_types }, opts?.mfaReceipt);
|
|
414
462
|
}
|
|
415
463
|
|
|
416
464
|
/**
|
|
@@ -723,11 +771,17 @@ export class Org {
|
|
|
723
771
|
* Note that this overwrites any existing configuration.
|
|
724
772
|
*
|
|
725
773
|
* @param configs Confidential Cloud Functions configuration.
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
774
|
+
* @param opts Optional parameters
|
|
775
|
+
* @param opts.mfaReceipt Optional MFA receipts
|
|
776
|
+
* @returns Org info
|
|
777
|
+
*/
|
|
778
|
+
async setC2FConfiguration(configs: C2FConfiguration, opts?: { mfaReceipt?: MfaReceipts }) {
|
|
779
|
+
return await this.update(
|
|
780
|
+
{
|
|
781
|
+
policy_engine_configuration: configs,
|
|
782
|
+
},
|
|
783
|
+
opts?.mfaReceipt,
|
|
784
|
+
);
|
|
731
785
|
}
|
|
732
786
|
|
|
733
787
|
/**
|