@cubist-labs/cubesigner-sdk 0.4.280 → 0.4.284
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/spec/env/beta.json +0 -6
- package/dist/src/audit_log.d.ts +3 -3
- package/dist/src/client/api_client.d.ts.map +1 -1
- package/dist/src/key.d.ts +35 -2
- package/dist/src/key.d.ts.map +1 -1
- package/dist/src/key.js +34 -1
- package/dist/src/mfa.d.ts.map +1 -1
- package/dist/src/org.d.ts.map +1 -1
- package/dist/src/role.d.ts.map +1 -1
- package/dist/src/schema.d.ts +571 -56
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts.map +1 -1
- package/dist/src/schema_types.js +3 -1
- package/dist/src/scopes.d.ts.map +1 -1
- package/dist/src/scopes.js +12 -7
- package/package.json +1 -1
- package/src/key.ts +50 -0
- package/src/schema.ts +626 -59
- package/src/schema_types.ts +2 -0
- package/src/scopes.ts +11 -6
package/package.json
CHANGED
package/src/key.ts
CHANGED
|
@@ -32,8 +32,10 @@ import type {
|
|
|
32
32
|
KeyPropertiesPatch,
|
|
33
33
|
Eip7702SignRequest,
|
|
34
34
|
SignResponse,
|
|
35
|
+
Scope,
|
|
35
36
|
} from "./schema_types.ts";
|
|
36
37
|
import type {
|
|
38
|
+
Ace,
|
|
37
39
|
ApiClient,
|
|
38
40
|
AvaChain,
|
|
39
41
|
BabylonRegistrationRequest,
|
|
@@ -59,6 +61,18 @@ import { encodeToHex, encodeToBase64 } from "./util.ts";
|
|
|
59
61
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
60
62
|
import type { KeyAttestationClaims } from "./schema_types.ts";
|
|
61
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Key access-control entry.
|
|
66
|
+
*
|
|
67
|
+
* This type allows specifying any valid {@link Scope} as an action, but CubeSigner
|
|
68
|
+
* denies setting invalid / unsupported actions.
|
|
69
|
+
*/
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
71
|
+
export type KeyAce = Ace<Scope, {}>;
|
|
72
|
+
|
|
73
|
+
/** Key ACL type. */
|
|
74
|
+
export type KeyAcl = KeyAce[];
|
|
75
|
+
|
|
62
76
|
/** Secp256k1 key type */
|
|
63
77
|
export enum Secp256k1 {
|
|
64
78
|
Evm = "SecpEthAddr",
|
|
@@ -252,6 +266,17 @@ export class Key {
|
|
|
252
266
|
await this.update({ policy }, mfaReceipt);
|
|
253
267
|
}
|
|
254
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Set new ACL (overwriting any existing ACL previously set for this key)
|
|
271
|
+
*
|
|
272
|
+
* @param acl The new ACL to set, or `null` to clear the ACL.
|
|
273
|
+
* @param mfaReceipt Optional MFA receipt(s)
|
|
274
|
+
* @throws if MFA is required and no receipts are provided
|
|
275
|
+
*/
|
|
276
|
+
async setAcl(acl: KeyAcl | null, mfaReceipt?: MfaReceipts) {
|
|
277
|
+
await this.update({ acl }, mfaReceipt);
|
|
278
|
+
}
|
|
279
|
+
|
|
255
280
|
/**
|
|
256
281
|
* Set new edit policy (overwriting any edit policies previously set for this key)
|
|
257
282
|
*
|
|
@@ -412,6 +437,31 @@ export class Key {
|
|
|
412
437
|
return (data.policy ?? []) as unknown as KeyPolicy;
|
|
413
438
|
}
|
|
414
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Append to existing key ACL. This append is not atomic -- it uses {@link acl}
|
|
442
|
+
* to fetch the current ACL and then {@link setAcl} to set the ACL -- and
|
|
443
|
+
* should not be used across concurrent sessions.
|
|
444
|
+
*
|
|
445
|
+
* @param acl The ACL to append to the existing one.
|
|
446
|
+
* @param mfaReceipt Optional MFA receipt(s)
|
|
447
|
+
* @throws If MFA is required and no MFA receipts are provided
|
|
448
|
+
*/
|
|
449
|
+
async appendAcl(acl: KeyAcl, mfaReceipt?: MfaReceipts) {
|
|
450
|
+
const existing = await this.acl();
|
|
451
|
+
const newAcl: KeyAcl = [...(existing ?? []), ...acl];
|
|
452
|
+
await this.update({ acl: newAcl, version: this.cached.version }, mfaReceipt);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Get the key ACL.
|
|
457
|
+
*
|
|
458
|
+
* @returns The key ACL, or `undefined` if it is not set.
|
|
459
|
+
*/
|
|
460
|
+
async acl(): Promise<KeyAcl | undefined> {
|
|
461
|
+
const data = await this.fetch();
|
|
462
|
+
return data.acl as unknown as KeyAcl | undefined;
|
|
463
|
+
}
|
|
464
|
+
|
|
415
465
|
/**
|
|
416
466
|
* Get the edit policy for the key.
|
|
417
467
|
*
|