@cubist-labs/cubesigner-sdk 0.4.241 → 0.4.246
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/gamma.json +5 -0
- package/dist/src/audit_log.d.ts +5 -5
- package/dist/src/audit_log.js +1 -1
- package/dist/src/client/api_client.d.ts +22 -7
- package/dist/src/client/api_client.d.ts.map +1 -1
- package/dist/src/client/api_client.js +43 -13
- package/dist/src/client/base_client.d.ts +5 -1
- package/dist/src/client/base_client.d.ts.map +1 -1
- package/dist/src/client/base_client.js +16 -10
- package/dist/src/client/session.d.ts +3 -1
- package/dist/src/client/session.d.ts.map +1 -1
- package/dist/src/client/session.js +7 -3
- package/dist/src/client.d.ts +12 -5
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +15 -4
- package/dist/src/diffie_hellman.js +2 -2
- package/dist/src/env.d.ts +7 -0
- package/dist/src/env.d.ts.map +1 -1
- package/dist/src/env.js +14 -1
- package/dist/src/fetch.d.ts.map +1 -1
- package/dist/src/fetch.js +2 -3
- package/dist/src/key.d.ts +17 -1
- package/dist/src/key.d.ts.map +1 -1
- package/dist/src/key.js +19 -3
- package/dist/src/policy.d.ts +24 -7
- package/dist/src/policy.d.ts.map +1 -1
- package/dist/src/policy.js +34 -16
- package/dist/src/response.d.ts +29 -5
- package/dist/src/response.d.ts.map +1 -1
- package/dist/src/response.js +62 -24
- package/dist/src/schema.d.ts +975 -84
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +10 -1
- package/dist/src/schema_types.d.ts.map +1 -1
- package/dist/src/schema_types.js +2 -1
- package/dist/src/scopes.d.ts.map +1 -1
- package/dist/src/scopes.js +23 -3
- package/dist/src/user_export.d.ts +1 -1
- package/dist/src/user_export.js +3 -3
- package/dist/src/util.d.ts +7 -0
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +30 -7
- package/package.json +1 -1
- package/src/audit_log.ts +3 -5
- package/src/client/api_client.ts +54 -14
- package/src/client/base_client.ts +13 -3
- package/src/client/session.ts +10 -3
- package/src/client.ts +17 -4
- package/src/diffie_hellman.ts +1 -1
- package/src/env.ts +17 -0
- package/src/fetch.ts +1 -2
- package/src/key.ts +26 -2
- package/src/policy.ts +34 -16
- package/src/response.ts +72 -25
- package/src/schema.ts +1034 -92
- package/src/schema_types.ts +12 -1
- package/src/scopes.ts +22 -2
- package/src/user_export.ts +2 -2
- package/src/util.ts +34 -8
package/src/schema_types.ts
CHANGED
|
@@ -46,6 +46,7 @@ const AllOperationKinds: Record<OperationKind, true> = {
|
|
|
46
46
|
BabylonCovSign: true,
|
|
47
47
|
BabylonRegistration: true,
|
|
48
48
|
BabylonStaking: true,
|
|
49
|
+
BinanceSign: true,
|
|
49
50
|
BlobSign: true,
|
|
50
51
|
BtcMessageSign: true,
|
|
51
52
|
BtcSign: true,
|
|
@@ -193,6 +194,7 @@ export type MmiJrpcMethod =
|
|
|
193
194
|
| "custodian_getSignedMessageLink";
|
|
194
195
|
|
|
195
196
|
export type AcceptedResponse = schemas["AcceptedResponse"];
|
|
197
|
+
export type AcceptedValue = schemas["AcceptedValue"];
|
|
196
198
|
export type ErrorResponse = schemas["ErrorResponse"];
|
|
197
199
|
export type BtcSignatureKind = schemas["BtcSignatureKind"];
|
|
198
200
|
export type CsErrCode = schemas["SignerErrorCode"];
|
|
@@ -211,10 +213,14 @@ export type MfaPolicy = Omit<schemas["MfaPolicy"], "allowed_mfa_types"> & {
|
|
|
211
213
|
export type MfaVote = schemas["MfaVote"];
|
|
212
214
|
export type MfaRequestInfo = schemas["MfaRequestInfo"];
|
|
213
215
|
export type MfaProtectedAction = schemas["MfaProtectedAction"];
|
|
214
|
-
export type MfaRequired = schemas["
|
|
216
|
+
export type MfaRequired = schemas["MfaRequiredArgs"];
|
|
217
|
+
export type SignDryRun = schemas["SignDryRunArgs"];
|
|
218
|
+
export type BinanceDryRun = schemas["BinanceDryRunArgs"];
|
|
215
219
|
export type EvmTxCmp = schemas["EvmTxCmp"];
|
|
216
220
|
export type SolanaTxCmp = schemas["SolanaTxCmp"];
|
|
217
221
|
|
|
222
|
+
export type BinanceApiProperties = schemas["BinanceApiPropertiesPatch"];
|
|
223
|
+
|
|
218
224
|
export type CreateOrgRequest = schemas["CreateOrgRequest"];
|
|
219
225
|
export type OrgMetricName = schemas["MetricName"];
|
|
220
226
|
export type QueryMetricsRequest = schemas["QueryMetricsRequest"];
|
|
@@ -232,6 +238,11 @@ export type UserExportCompleteRequest = schemas["UserExportCompleteRequest"];
|
|
|
232
238
|
export type UserExportCompleteResponse = schemas["UserExportCompleteResponse"];
|
|
233
239
|
export type UserExportListResponse = schemas["PaginatedUserExportListResponse"];
|
|
234
240
|
export type UserExportKeyMaterial = schemas["JsonKeyPackage"];
|
|
241
|
+
export type JsonRpcResponse = schemas["JsonRpcResponse"];
|
|
242
|
+
export type JsonRpcRequest = schemas["RpcMethod"] & {
|
|
243
|
+
/** @description Request ID */
|
|
244
|
+
id?: string;
|
|
245
|
+
};
|
|
235
246
|
|
|
236
247
|
export type HistoricalTx = schemas["HistoricalTx"];
|
|
237
248
|
export type ListHistoricalTxResponse = schemas["PaginatedListHistoricalTxResponse"];
|
package/src/scopes.ts
CHANGED
|
@@ -30,6 +30,17 @@ export const AllScopes: Record<ExplicitScope, string> =
|
|
|
30
30
|
"sign:btc:message:*" : "Allows access to the BTC message signing endpoint for any key type",
|
|
31
31
|
"sign:btc:message:segwit" : "Allows access to the BTC message signing endpoint for segwit keys",
|
|
32
32
|
"sign:btc:message:legacy" : "Allows access to the BTC message signing endpoint for legacy keys",
|
|
33
|
+
"sign:binance:*" : "Allows access to the Binance sign endpoint, without restrictions",
|
|
34
|
+
"sign:binance:accountInfo" : "Allows access to the Binance sign endpoint, restricted to the 'AccountInfo' operation",
|
|
35
|
+
"sign:binance:deposit" : "Allows access to the Binance sign endpoint, restricted to the 'Deposit' method",
|
|
36
|
+
"sign:binance:subAccountAssets" : "Allows access to the Binance sign endpoint, restricted to the 'SubAccountAssets' operation",
|
|
37
|
+
"sign:binance:subAccountTransferHistory" : "Allows access to the Binance sign endpoint, restricted to the 'SubAccountTransferHistory' operation",
|
|
38
|
+
"sign:binance:subToMaster" : "Allows access to the Binance sign endpoint, restricted to the 'SubToMaster' operation",
|
|
39
|
+
"sign:binance:subToSub" : "Allows access to the Binance sign endpoint, restricted to the 'SubToSub' operation",
|
|
40
|
+
"sign:binance:universalTransfer" : "Allows access to the Binance sign endpoint, restricted to the 'UniversalTransfer' operation",
|
|
41
|
+
"sign:binance:universalTransferHistory" : "Allows access to the Binance sign endpoint, restricted to the 'UniversalTransferHistory' operation",
|
|
42
|
+
"sign:binance:withdraw" : "Allows access to the Binance sign endpoint, restricted to the 'Withdraw' operation",
|
|
43
|
+
"sign:binance:withdrawHistory" : "Allows access to the Binance sign endpoint, restricted to the 'WithdrawHistory' operation",
|
|
33
44
|
"sign:babylon:*" : "Allows access to all Babylon endpoints",
|
|
34
45
|
"sign:babylon:eots:*" : "Allows access to all Babylon EOTS endpoints",
|
|
35
46
|
"sign:babylon:eots:nonces" : "Allows access to the EOTS nonce generation endpoint",
|
|
@@ -91,6 +102,7 @@ export const AllScopes: Record<ExplicitScope, string> =
|
|
|
91
102
|
"manage:key:update:policy" : "Allows access only to the key 'update' endpoint, but restricting updates to the key 'policy' property",
|
|
92
103
|
"manage:key:update:enabled" : "Allows access only to the key 'update' endpoint, but restricting updates to the key 'enabled' property",
|
|
93
104
|
"manage:key:update:metadata" : "Allows access only to the key 'update' endpoint and restricts updates to the key 'metadata' property",
|
|
105
|
+
"manage:key:update:properties" : "Allows access only to the key 'update' endpoint and restricts updates to the key 'properties' property",
|
|
94
106
|
"manage:key:update:editPolicy" : "Allows access only to the key 'update' endpoint and restricts updates to the 'edit_policy' property",
|
|
95
107
|
"manage:key:delete" : "Allows access only to the key 'delete' endpoint",
|
|
96
108
|
"manage:policy:*" : "Allows access to all policy endpoints",
|
|
@@ -177,10 +189,16 @@ export const AllScopes: Record<ExplicitScope, string> =
|
|
|
177
189
|
"manage:org:invitation:cancel" : "Allows access only to the org endpoint for canceling pending invitations",
|
|
178
190
|
"manage:org:inviteUser" : "Allows access only to the org endpoint for inviting a new member or org owner to the org",
|
|
179
191
|
"manage:org:inviteAlien" : "Allows access only to the org endpoint for inviting a new alien user to the org",
|
|
180
|
-
"manage:org:updateMembership"
|
|
192
|
+
"manage:org:updateMembership:*" : "Allows access only to the org endpoint for updating existing user's org membership",
|
|
193
|
+
"manage:org:updateMembership:owner" : "Allows access only to the org endpoint for updating existing org Owner's membership",
|
|
194
|
+
"manage:org:updateMembership:member" : "Allows access only to the org endpoint for updating existing org Member's membership",
|
|
195
|
+
"manage:org:updateMembership:alien" : "Allows access only to the org endpoint for updating existing org Alien's membership",
|
|
181
196
|
"manage:org:listUsers" : "Allows access only to the org endpoint for listing all org users (members)",
|
|
182
197
|
"manage:org:user:get" : "Allows access only to the org endpoints for getting users by id or email",
|
|
183
|
-
"manage:org:deleteUser"
|
|
198
|
+
"manage:org:deleteUser:*" : "Allows access only to the org endpoint for deleting an OIDC user",
|
|
199
|
+
"manage:org:deleteUser:owner" : "Allows access only to the org endpoint for deleting a user, only when deleting an existing org Owner",
|
|
200
|
+
"manage:org:deleteUser:member" : "Allows access only to the org endpoint for deleting a user, only when deleting an existing org Member",
|
|
201
|
+
"manage:org:deleteUser:alien" : "Allows access only to the org endpoint for deleting a user, only when deleting an existing org Alien",
|
|
184
202
|
"manage:org:get" : "Allows access to retrieving organization information",
|
|
185
203
|
"manage:org:user:resetMfa" : "Allows an owner to initiate an MFA reset for a user",
|
|
186
204
|
"manage:org:update:*" : "Allows access to all org 'update' actions",
|
|
@@ -240,6 +258,8 @@ export const AllScopes: Record<ExplicitScope, string> =
|
|
|
240
258
|
"rpc:createTransaction:evm" : "Allows access to the RPC API endpoint, but only for the 'cs_createTransaction' function with an EVM transaction request.",
|
|
241
259
|
"rpc:getTransaction" : "Allows access to the RPC API endpoint, but only for the 'cs_getTransaction' function.",
|
|
242
260
|
"rpc:listTransactions" : "Allows access to the RPC API endpoint, but only for the 'cs_listTransactions' function.",
|
|
261
|
+
"rpc:retryTransaction" : "Allows access to the RPC API endpoint, but only for the 'cs_retryTransaction' function",
|
|
262
|
+
"rpc:binance" : "Allows access to the RPC API endpoint, but only for the 'cs_binance*' functions",
|
|
243
263
|
};
|
|
244
264
|
|
|
245
265
|
// Const for scope category labels
|
package/src/user_export.ts
CHANGED
|
@@ -27,7 +27,7 @@ export async function userExportKeygen(): Promise<CryptoKeyPair> {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Get the ArrayBuffer slice represented by a
|
|
30
|
+
* Get the ArrayBuffer slice represented by a Uint8Array
|
|
31
31
|
*
|
|
32
32
|
* @param b The buffer to convert
|
|
33
33
|
* @returns The resulting ArrayBuffer
|
|
@@ -52,7 +52,7 @@ export async function userExportDecrypt(
|
|
|
52
52
|
|
|
53
53
|
// decrypt the export ciphertext using the HPKE one-shot API
|
|
54
54
|
const tenc = new TextEncoder();
|
|
55
|
-
const tdec = new TextDecoder();
|
|
55
|
+
const tdec = new TextDecoder("utf-8");
|
|
56
56
|
const info = toArrayBuffer(tenc.encode(`cubist-signer::UserExportOwner::${response.user_id}`));
|
|
57
57
|
const public_key = toArrayBuffer(decodeBase64(response.ephemeral_public_key));
|
|
58
58
|
const ctxt = toArrayBuffer(decodeBase64(response.encrypted_key_material));
|
package/src/util.ts
CHANGED
|
@@ -27,6 +27,9 @@ export function pathJoin(dir: string, file: string): string {
|
|
|
27
27
|
return `${dir}${sep}${file}`;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// eslint-disable-next-line no-restricted-globals -- intentionally checking for Buffer before using it
|
|
31
|
+
const nodeBuffer = typeof Buffer === "function" ? Buffer : undefined;
|
|
32
|
+
|
|
30
33
|
/**
|
|
31
34
|
* Browser-friendly helper for decoding a 'base64'-encoded string into a byte array.
|
|
32
35
|
*
|
|
@@ -34,8 +37,8 @@ export function pathJoin(dir: string, file: string): string {
|
|
|
34
37
|
* @returns Decoded byte array
|
|
35
38
|
*/
|
|
36
39
|
export function decodeBase64(b64: string): Uint8Array {
|
|
37
|
-
return
|
|
38
|
-
?
|
|
40
|
+
return nodeBuffer
|
|
41
|
+
? nodeBuffer.from(b64, "base64")
|
|
39
42
|
: Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -60,10 +63,9 @@ export function decodeBase64Url(b64url: string): Uint8Array {
|
|
|
60
63
|
*/
|
|
61
64
|
export function encodeToBase64(buffer: Iterable<number> | ArrayBuffer): string {
|
|
62
65
|
const bytes = buffer instanceof ArrayBuffer ? new Uint8Array(buffer) : new Uint8Array(buffer);
|
|
63
|
-
const b64 =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
: btoa(bytes.reduce((s, b) => s + String.fromCharCode(b), ""));
|
|
66
|
+
const b64 = nodeBuffer
|
|
67
|
+
? nodeBuffer.from(bytes).toString("base64")
|
|
68
|
+
: btoa(bytes.reduce((s, b) => s + String.fromCharCode(b), ""));
|
|
67
69
|
return b64;
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -97,6 +99,30 @@ export function delay(ms: number): Promise<void> {
|
|
|
97
99
|
* @returns Hex string prefixed with "0x"
|
|
98
100
|
*/
|
|
99
101
|
export function encodeToHex(message: string | Uint8Array): string {
|
|
100
|
-
const
|
|
101
|
-
return "0x" +
|
|
102
|
+
const bytes = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
103
|
+
return "0x" + Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Decodes a hex string into a byte array.
|
|
108
|
+
*
|
|
109
|
+
* @param hex The hex string to decode, with or without a "0x" prefix
|
|
110
|
+
* @returns Decoded byte array
|
|
111
|
+
*/
|
|
112
|
+
export function decodeFromHex(hex: string): Uint8Array {
|
|
113
|
+
const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
114
|
+
|
|
115
|
+
if (clean.length % 2 !== 0) {
|
|
116
|
+
throw new Error(`Invalid hexadecimal string length, must be even: ${clean.length}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!/^[0-9a-fA-F]*$/.test(clean)) {
|
|
120
|
+
throw new Error(`Invalid hexadecimal character in: '${clean}'`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const bytes = new Uint8Array(clean.length / 2);
|
|
124
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
125
|
+
bytes[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
126
|
+
}
|
|
127
|
+
return bytes;
|
|
102
128
|
}
|