@tatumio/wallet-sdk 0.2.1 → 0.3.1
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/README.md +18 -10
- package/dist/chains.d.ts +6 -2
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js.map +1 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +0 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/urls.d.ts +2 -8
- package/dist/constants/urls.d.ts.map +1 -1
- package/dist/constants/urls.js +2 -8
- package/dist/constants/urls.js.map +1 -1
- package/dist/eject/curves.d.ts +2 -2
- package/dist/eject/curves.js +2 -2
- package/dist/eject/matrix.d.ts +1 -1
- package/dist/eject/matrix.d.ts.map +1 -1
- package/dist/eject/matrix.js +1 -1
- package/dist/eject/matrix.js.map +1 -1
- package/dist/errors.d.ts +28 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +34 -2
- package/dist/errors.js.map +1 -1
- package/dist/http.d.ts +2 -2
- package/dist/http.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/portal/client-api.d.ts +2 -2
- package/dist/portal/client-api.js +2 -2
- package/dist/portal/custodian.d.ts +3 -3
- package/dist/portal/custodian.d.ts.map +1 -1
- package/dist/portal/custodian.js +3 -3
- package/dist/portal/custodian.js.map +1 -1
- package/dist/portal/enclave-api.d.ts +5 -7
- package/dist/portal/enclave-api.d.ts.map +1 -1
- package/dist/portal/enclave-api.js +15 -44
- package/dist/portal/enclave-api.js.map +1 -1
- package/dist/portal/types/client.d.ts +2 -2
- package/dist/portal/types/enclave.d.ts +4 -4
- package/dist/portal/types/enclave.d.ts.map +1 -1
- package/dist/portal/types/shared.d.ts +1 -1
- package/dist/portal/wallets-client.d.ts +9 -10
- package/dist/portal/wallets-client.d.ts.map +1 -1
- package/dist/portal/wallets-client.js +10 -10
- package/dist/portal/wallets-client.js.map +1 -1
- package/dist/sdk.d.ts +31 -15
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +38 -20
- package/dist/sdk.js.map +1 -1
- package/dist/tatum/api-client.js +1 -1
- package/dist/tatum/api-client.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/constants/paths.d.ts +0 -5
- package/dist/constants/paths.d.ts.map +0 -1
- package/dist/constants/paths.js +0 -5
- package/dist/constants/paths.js.map +0 -1
- package/dist/tatum/provider.d.ts +0 -26
- package/dist/tatum/provider.d.ts.map +0 -1
- package/dist/tatum/provider.js +0 -46
- package/dist/tatum/provider.js.map +0 -1
|
@@ -10,32 +10,25 @@ export const enclaveOperations = {
|
|
|
10
10
|
sendAssets: { method: 'POST', path: '/v1/assets/send' }
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* Enclave MPC layer (
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Enclave MPC layer (`/v1/...`). Operates on key shares;
|
|
14
|
+
* authenticates with the client's own token (Bearer) and never touches
|
|
15
|
+
* the Tatum API key. Chain operations (`sign`/`sendAssets`) require the caller
|
|
16
|
+
* to supply an `rpcUrl`. Internal — exposed through {@link WalletsClient}.
|
|
16
17
|
*/
|
|
17
18
|
export class EnclaveApi {
|
|
18
19
|
token;
|
|
19
|
-
provider;
|
|
20
20
|
sdkConfig;
|
|
21
|
-
constructor(token,
|
|
21
|
+
constructor(token, sdkConfig) {
|
|
22
22
|
this.token = token;
|
|
23
|
-
this.provider = provider;
|
|
24
23
|
this.sdkConfig = sdkConfig;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
request(operationName, options = {}) {
|
|
27
26
|
const operation = enclaveOperations[operationName];
|
|
28
27
|
const client = createPortalApiClient(this.sdkConfig, this.token, PORTAL_ENCLAVE_BASE_URL);
|
|
29
|
-
|
|
30
|
-
...options,
|
|
31
|
-
body: await this.withResolvedRpcUrl(options.body)
|
|
32
|
-
});
|
|
33
|
-
return client.request(requestOptions);
|
|
28
|
+
return client.request(buildRequestOptions(operation.method, operation.path, options));
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
await this.provider.trackWalletCreation(this.token);
|
|
38
|
-
return result;
|
|
30
|
+
generateWallet(options) {
|
|
31
|
+
return this.request('generateWallet', { ...options, body: {} });
|
|
39
32
|
}
|
|
40
33
|
backupWallet(options) {
|
|
41
34
|
return this.request('backupWallet', options);
|
|
@@ -43,36 +36,14 @@ export class EnclaveApi {
|
|
|
43
36
|
recoverWallet(options) {
|
|
44
37
|
return this.request('recoverWallet', options);
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await this.provider.trackTransaction(this.token);
|
|
49
|
-
return result;
|
|
39
|
+
sign(options) {
|
|
40
|
+
return this.request('sign', options);
|
|
50
41
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
await this.provider.trackTransaction(this.token);
|
|
54
|
-
return result;
|
|
42
|
+
rawSign(options) {
|
|
43
|
+
return this.request('rawSign', options);
|
|
55
44
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
await this.provider.trackTransaction(this.token);
|
|
59
|
-
return result;
|
|
45
|
+
sendAssets(options) {
|
|
46
|
+
return this.request('sendAssets', options);
|
|
60
47
|
}
|
|
61
|
-
async withResolvedRpcUrl(body) {
|
|
62
|
-
if (!isRecord(body) || typeof body.rpcUrl === 'string') {
|
|
63
|
-
return body;
|
|
64
|
-
}
|
|
65
|
-
const chain = typeof body.chain === 'string' ? body.chain : typeof body.chainId === 'string' ? body.chainId : undefined;
|
|
66
|
-
if (!chain) {
|
|
67
|
-
return body;
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
...body,
|
|
71
|
-
rpcUrl: await this.provider.getRpcUrl(chain)
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function isRecord(value) {
|
|
76
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
77
48
|
}
|
|
78
49
|
//# sourceMappingURL=enclave-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enclave-api.js","sourceRoot":"","sources":["../../src/portal/enclave-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"enclave-api.js","sourceRoot":"","sources":["../../src/portal/enclave-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAkBvD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE;IACxD,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE;IACpD,aAAa,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE;IACtD,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;IAC1C,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE;IACzD,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE;CAC/C,CAAC;AAIX;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAEF;IACA;IAFnB,YACmB,KAAa,EACb,SAA2B;QAD3B,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAkB;IAC3C,CAAC;IAEJ,OAAO,CAAsB,aAA+B,EAAE,UAA0B,EAAE;QACxF,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;QAE1F,OAAO,MAAM,CAAC,OAAO,CAAY,mBAAmB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACnG,CAAC;IAED,cAAc,CAAqC,OAA8B;QAC/E,OAAO,IAAI,CAAC,OAAO,CAAY,gBAAgB,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,YAAY,CACV,OAA+C;QAE/C,OAAO,IAAI,CAAC,OAAO,CAAY,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,aAAa,CACX,OAAgD;QAEhD,OAAO,IAAI,CAAC,OAAO,CAAY,eAAe,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAA2B,OAAuC;QACpE,OAAO,IAAI,CAAC,OAAO,CAAY,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,CACL,OAA4D;QAE5D,OAAO,IAAI,CAAC,OAAO,CAAY,SAAS,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CACR,OAA6C;QAE7C,OAAO,IAAI,CAAC,OAAO,CAAY,YAAY,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -62,8 +62,8 @@ export interface UpdateBackupSharePairsBody {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Body for storing a single client-encrypted backup share against its pair.
|
|
65
|
-
* Sent once per curve (SECP256K1, ED25519) as part of the
|
|
66
|
-
*
|
|
65
|
+
* Sent once per curve (SECP256K1, ED25519) as part of the managed-backup
|
|
66
|
+
* flow. Endpoint returns 204 No Content.
|
|
67
67
|
*/
|
|
68
68
|
export interface StoreBackupShareBody {
|
|
69
69
|
/** Ciphertext produced by encrypting the curve's backup share. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WalletChain } from
|
|
2
|
-
import type { CurveShares } from
|
|
1
|
+
import type { WalletChain } from "../../chains.js";
|
|
2
|
+
import type { CurveShares } from "./shared.js";
|
|
3
3
|
export type GenerateWalletResponse = CurveShares;
|
|
4
4
|
export interface BackupWalletBody {
|
|
5
5
|
/** JSON-stringified /v1/generate response. */
|
|
@@ -17,7 +17,7 @@ export interface SignBody {
|
|
|
17
17
|
share: string;
|
|
18
18
|
chainId: WalletChain;
|
|
19
19
|
to: string;
|
|
20
|
-
rpcUrl
|
|
20
|
+
rpcUrl: string;
|
|
21
21
|
metadataStr?: string;
|
|
22
22
|
sponsorGas?: boolean;
|
|
23
23
|
presignature?: string;
|
|
@@ -45,7 +45,7 @@ export interface SendAssetsBody {
|
|
|
45
45
|
to: string;
|
|
46
46
|
token: string;
|
|
47
47
|
amount: string;
|
|
48
|
-
rpcUrl
|
|
48
|
+
rpcUrl: string;
|
|
49
49
|
nonce?: string;
|
|
50
50
|
metadataStr?: string;
|
|
51
51
|
sponsorGas?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enclave.d.ts","sourceRoot":"","sources":["../../../src/portal/types/enclave.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,MAAM,oBA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YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestOptions } from '../../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Per-operation options for typed
|
|
3
|
+
* Per-operation options for typed API methods. Narrows the shared
|
|
4
4
|
* RequestOptions: when a type param is `never` the field is forbidden, otherwise
|
|
5
5
|
* required (Query defaults to forbidden). `headers` and `signal` stay available.
|
|
6
6
|
*/
|
|
@@ -3,7 +3,6 @@ import type { ClientOperation } from './client-api.js';
|
|
|
3
3
|
import type { EnclaveOperation } from './enclave-api.js';
|
|
4
4
|
import type { Curve } from './types/index.js';
|
|
5
5
|
import type { WalletChain } from '../chains.js';
|
|
6
|
-
import type { PortalTatumProvider } from '../tatum/provider.js';
|
|
7
6
|
import type { RequestOptions, WalletsSDKConfig } from '../types.js';
|
|
8
7
|
import type { BackupShareCipherTextResponse, BackupWalletBody, BackupWalletResponse, BuildTransactionBody, BuildTransactionResponse, ClientDetails, ClientEjectableBackupSharesQuery, ClientEjectableBackupSharesResponse, EvaluateTransactionBody, EvaluateTransactionQuery, EvaluateTransactionResponse, GenerateWalletResponse, PortalRequestOptions, RawSignBody, RawSignResponse, RecoverWalletBody, RecoverWalletResponse, SendAssetsBody, SendAssetsResponse, SignBody, SignResponse, StoreBackupShareBody, UpdateBackupSharePairsBody, UpdateSigningSharePairsBody } from './types/index.js';
|
|
9
8
|
export interface InitClientConfig {
|
|
@@ -11,10 +10,10 @@ export interface InitClientConfig {
|
|
|
11
10
|
}
|
|
12
11
|
export type WalletsClientRequestOptions = RequestOptions;
|
|
13
12
|
/**
|
|
14
|
-
* Client-scoped
|
|
13
|
+
* Client-scoped operations for a single client.
|
|
15
14
|
*
|
|
16
15
|
* Obtain via {@link TatumWalletsSdk.initClient}. Calls authenticate with the
|
|
17
|
-
* client's
|
|
16
|
+
* client's API key / Client Session Token. It is a thin facade over two
|
|
18
17
|
* internal layers — the client REST API ({@link ClientApi}, `/clients/me/...`)
|
|
19
18
|
* and the Enclave MPC API ({@link EnclaveApi}, wallet generation/signing/sending/
|
|
20
19
|
* backup/recovery, which operate on key shares).
|
|
@@ -22,16 +21,16 @@ export type WalletsClientRequestOptions = RequestOptions;
|
|
|
22
21
|
export declare class WalletsClient {
|
|
23
22
|
private readonly clientApi;
|
|
24
23
|
private readonly enclaveApi;
|
|
25
|
-
constructor(clientConfig: InitClientConfig,
|
|
24
|
+
constructor(clientConfig: InitClientConfig, sdkConfig: WalletsSDKConfig);
|
|
26
25
|
/**
|
|
27
26
|
* Escape hatch: dispatch any client REST operation by name with raw options.
|
|
28
27
|
* Prefer the typed methods; use this only for not-yet-modeled behavior.
|
|
29
28
|
*/
|
|
30
29
|
request<TResponse = unknown>(operationName: ClientOperation, options?: WalletsClientRequestOptions): Promise<TResponse>;
|
|
31
30
|
/**
|
|
32
|
-
* Escape hatch: dispatch any Enclave MPC operation by name.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* Escape hatch: dispatch any Enclave MPC operation by name. Chain operations
|
|
32
|
+
* (`sign`/`sendAssets`) require an `rpcUrl` in the body. Prefer the typed
|
|
33
|
+
* enclave methods below.
|
|
35
34
|
*/
|
|
36
35
|
enclaveRequest<TResponse = unknown>(operationName: EnclaveOperation, options?: WalletsClientRequestOptions): Promise<TResponse>;
|
|
37
36
|
/** Fetch this client's details — wallets, addresses, and share-pair statuses. */
|
|
@@ -49,11 +48,11 @@ export declare class WalletsClient {
|
|
|
49
48
|
updateSigningSharePairs<TResponse = void>(options: PortalRequestOptions<UpdateSigningSharePairsBody>): Promise<TResponse>;
|
|
50
49
|
/**
|
|
51
50
|
* Mark backup share pairs stored — the final step of a backup, after
|
|
52
|
-
* {@link storeEncryptedBackupShare} (
|
|
51
|
+
* {@link storeEncryptedBackupShare} (managed backup) or storing on your own backend.
|
|
53
52
|
*/
|
|
54
53
|
updateBackupSharePairs<TResponse = void>(options: PortalRequestOptions<UpdateBackupSharePairsBody>): Promise<TResponse>;
|
|
55
54
|
/**
|
|
56
|
-
* Store a client-encrypted backup share against its pair (
|
|
55
|
+
* Store a client-encrypted backup share against its pair (managed
|
|
57
56
|
* backups). Call once per curve with that curve's ciphertext, then mark the
|
|
58
57
|
* pairs stored via {@link updateBackupSharePairs}.
|
|
59
58
|
*/
|
|
@@ -106,7 +105,7 @@ export declare class WalletsClient {
|
|
|
106
105
|
}>): Promise<TResponse>;
|
|
107
106
|
/**
|
|
108
107
|
* Build, sign, and broadcast an asset transfer in one call (Enclave API).
|
|
109
|
-
*
|
|
108
|
+
* Requires an `rpcUrl` in the body (your own node or a Tatum gateway URL).
|
|
110
109
|
*/
|
|
111
110
|
sendAssets<TResponse = SendAssetsResponse>(options: PortalRequestOptions<SendAssetsBody>): Promise<TResponse>;
|
|
112
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets-client.d.ts","sourceRoot":"","sources":["../../src/portal/wallets-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wallets-client.d.ts","sourceRoot":"","sources":["../../src/portal/wallets-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,gCAAgC,EAChC,mCAAmC,EACnC,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,oBAAoB,E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iBAAiB,CAAC,GAC/C,OAAO,CAAC,SAAS,CAAC;IAIrB;;;;OAIG;IACH,IAAI,CAAC,SAAS,GAAG,YAAY,EAAE,OAAO,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAI3F;;;OAGG;IACH,OAAO,CAAC,SAAS,GAAG,eAAe,EACjC,OAAO,EAAE,oBAAoB,CAAC,WAAW,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,GAC3D,OAAO,CAAC,SAAS,CAAC;IAIrB;;;OAGG;IACH,UAAU,CAAC,SAAS,GAAG,kBAAkB,EACvC,OAAO,EAAE,oBAAoB,CAAC,cAAc,CAAC,GAC5C,OAAO,CAAC,SAAS,CAAC;CAGtB"}
|
|
@@ -2,10 +2,10 @@ import { ClientApi } from './client-api.js';
|
|
|
2
2
|
import { EnclaveApi } from './enclave-api.js';
|
|
3
3
|
import { reconstructPrivateKey } from '../eject/index.js';
|
|
4
4
|
/**
|
|
5
|
-
* Client-scoped
|
|
5
|
+
* Client-scoped operations for a single client.
|
|
6
6
|
*
|
|
7
7
|
* Obtain via {@link TatumWalletsSdk.initClient}. Calls authenticate with the
|
|
8
|
-
* client's
|
|
8
|
+
* client's API key / Client Session Token. It is a thin facade over two
|
|
9
9
|
* internal layers — the client REST API ({@link ClientApi}, `/clients/me/...`)
|
|
10
10
|
* and the Enclave MPC API ({@link EnclaveApi}, wallet generation/signing/sending/
|
|
11
11
|
* backup/recovery, which operate on key shares).
|
|
@@ -13,12 +13,12 @@ import { reconstructPrivateKey } from '../eject/index.js';
|
|
|
13
13
|
export class WalletsClient {
|
|
14
14
|
clientApi;
|
|
15
15
|
enclaveApi;
|
|
16
|
-
constructor(clientConfig,
|
|
16
|
+
constructor(clientConfig, sdkConfig) {
|
|
17
17
|
if (!clientConfig.token) {
|
|
18
18
|
throw new Error('Client token is required');
|
|
19
19
|
}
|
|
20
20
|
this.clientApi = new ClientApi(clientConfig.token, sdkConfig);
|
|
21
|
-
this.enclaveApi = new EnclaveApi(clientConfig.token,
|
|
21
|
+
this.enclaveApi = new EnclaveApi(clientConfig.token, sdkConfig);
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Escape hatch: dispatch any client REST operation by name with raw options.
|
|
@@ -28,9 +28,9 @@ export class WalletsClient {
|
|
|
28
28
|
return this.clientApi.request(operationName, options);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Escape hatch: dispatch any Enclave MPC operation by name.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* Escape hatch: dispatch any Enclave MPC operation by name. Chain operations
|
|
32
|
+
* (`sign`/`sendAssets`) require an `rpcUrl` in the body. Prefer the typed
|
|
33
|
+
* enclave methods below.
|
|
34
34
|
*/
|
|
35
35
|
enclaveRequest(operationName, options = {}) {
|
|
36
36
|
return this.enclaveApi.request(operationName, options);
|
|
@@ -57,13 +57,13 @@ export class WalletsClient {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Mark backup share pairs stored — the final step of a backup, after
|
|
60
|
-
* {@link storeEncryptedBackupShare} (
|
|
60
|
+
* {@link storeEncryptedBackupShare} (managed backup) or storing on your own backend.
|
|
61
61
|
*/
|
|
62
62
|
updateBackupSharePairs(options) {
|
|
63
63
|
return this.clientApi.updateBackupSharePairs(options);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Store a client-encrypted backup share against its pair (
|
|
66
|
+
* Store a client-encrypted backup share against its pair (managed
|
|
67
67
|
* backups). Call once per curve with that curve's ciphertext, then mark the
|
|
68
68
|
* pairs stored via {@link updateBackupSharePairs}.
|
|
69
69
|
*/
|
|
@@ -127,7 +127,7 @@ export class WalletsClient {
|
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Build, sign, and broadcast an asset transfer in one call (Enclave API).
|
|
130
|
-
*
|
|
130
|
+
* Requires an `rpcUrl` in the body (your own node or a Tatum gateway URL).
|
|
131
131
|
*/
|
|
132
132
|
sendAssets(options) {
|
|
133
133
|
return this.enclaveApi.sendAssets(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets-client.js","sourceRoot":"","sources":["../../src/portal/wallets-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"wallets-client.js","sourceRoot":"","sources":["../../src/portal/wallets-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAwC1D;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IACP,SAAS,CAAY;IACrB,UAAU,CAAa;IAExC,YAAY,YAA8B,EAAE,SAA2B;QACrE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC9D,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAED;;;OAGG;IACH,OAAO,CACL,aAA8B,EAC9B,UAAuC,EAAE;QAEzC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAY,aAAa,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACH,cAAc,CACZ,aAA+B,EAC/B,UAAuC,EAAE;QAEzC,OAAO,IAAI,CAAC,UAAU,CAAC,O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CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,sEAAsE;IAEtE;;;OAGG;IACH,cAAc,CAAqC,OAA8B;QAC/E,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAY,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED;;;OAGG;IACH,YAAY,CACV,OAA+C;QAE/C,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAY,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,mFAAmF;IACnF,aAAa,CACX,OAAgD;QAEhD,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAY,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACH,IAAI,CAA2B,OAAuC;QACpE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAY,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,OAAO,CACL,OAA4D;QAE5D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAY,OAAO,CAAC,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,UAAU,CACR,OAA6C;QAE7C,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAY,OAAO,CAAC,CAAC;IACxD,CAAC;CACF"}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -4,30 +4,46 @@ import { WalletsApiClient } from './tatum/api-client.js';
|
|
|
4
4
|
import type { InitClientConfig } from './portal/wallets-client.js';
|
|
5
5
|
import type { WalletsSDKConfig } from './types.js';
|
|
6
6
|
/**
|
|
7
|
-
* Entry point for the Tatum-hosted
|
|
7
|
+
* Entry point for the Tatum-hosted MPC wallet SDK.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Two scopes, two auth models:
|
|
10
|
+
* - {@link custodian} and {@link api} are **backend-only** — they require a
|
|
11
|
+
* Tatum `apiKey` (`x-api-key`) and throw if one was not configured. Use them
|
|
12
|
+
* to provision clients, mint sessions, and configure gas sponsorship.
|
|
13
|
+
* - {@link initClient} is **client-side** — it authenticates with a single
|
|
14
|
+
* client token (API key or Client Session Token) and needs **no Tatum
|
|
15
|
+
* `apiKey`**, so it is safe to run in a browser/mobile bundle.
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
18
|
+
* // Backend: provision a client with your Tatum API key.
|
|
15
19
|
* const wallets = new TatumWalletsSdk({ apiKey: process.env.TATUM_API_KEY! });
|
|
16
|
-
* const
|
|
17
|
-
*
|
|
20
|
+
* const newClient = await wallets.custodian.createClient({ body: { isAccountAbstracted: false } });
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Client-side: act on behalf of a single client — no apiKey needed.
|
|
24
|
+
* const wallets = new TatumWalletsSdk();
|
|
25
|
+
* const client = wallets.initClient({ token: clientSessionToken });
|
|
18
26
|
*/
|
|
19
27
|
export declare class TatumWalletsSdk {
|
|
20
28
|
private readonly config;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
private _api?;
|
|
30
|
+
private _custodian?;
|
|
31
|
+
constructor(config?: WalletsSDKConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Low-level Tatum API client (`x-api-key` auth). Escape hatch for raw,
|
|
34
|
+
* not-yet-modeled Tatum calls. Requires a Tatum `apiKey` — throws if absent.
|
|
35
|
+
*/
|
|
36
|
+
get api(): WalletsApiClient;
|
|
37
|
+
/**
|
|
38
|
+
* Custodian-scoped operations, authenticated with your Tatum
|
|
39
|
+
* `x-api-key`. Backend only — requires a Tatum `apiKey` and throws if absent.
|
|
40
|
+
*/
|
|
41
|
+
get custodian(): CustodianApi;
|
|
27
42
|
/**
|
|
28
|
-
* Create a client-scoped API for a single
|
|
43
|
+
* Create a client-scoped API for a single client. Needs no Tatum
|
|
44
|
+
* `apiKey` — authenticates with the client's own token.
|
|
29
45
|
*
|
|
30
|
-
* @param config - Holds the client's
|
|
46
|
+
* @param config - Holds the client's API key or Client Session Token (CST).
|
|
31
47
|
* @returns A {@link WalletsClient} bound to that token.
|
|
32
48
|
*/
|
|
33
49
|
initClient(config: InitClientConfig): WalletsClient;
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAe;IAId,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,IAAI,CAAC,CAAmB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAe;gBAEL,MAAM,GAAE,gBAAqB;IAE1D;;;OAGG;IACH,IAAI,GAAG,IAAI,gBAAgB,CAG1B;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,YAAY,CAG5B;IAED;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa;CAGpD"}
|
package/dist/sdk.js
CHANGED
|
@@ -1,41 +1,59 @@
|
|
|
1
1
|
import { CustodianApi } from './portal/custodian.js';
|
|
2
2
|
import { WalletsClient } from './portal/wallets-client.js';
|
|
3
3
|
import { WalletsApiClient } from './tatum/api-client.js';
|
|
4
|
-
import { PortalTatumProvider } from './tatum/provider.js';
|
|
5
4
|
/**
|
|
6
|
-
* Entry point for the Tatum-hosted
|
|
5
|
+
* Entry point for the Tatum-hosted MPC wallet SDK.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Two scopes, two auth models:
|
|
8
|
+
* - {@link custodian} and {@link api} are **backend-only** — they require a
|
|
9
|
+
* Tatum `apiKey` (`x-api-key`) and throw if one was not configured. Use them
|
|
10
|
+
* to provision clients, mint sessions, and configure gas sponsorship.
|
|
11
|
+
* - {@link initClient} is **client-side** — it authenticates with a single
|
|
12
|
+
* client token (API key or Client Session Token) and needs **no Tatum
|
|
13
|
+
* `apiKey`**, so it is safe to run in a browser/mobile bundle.
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
16
|
+
* // Backend: provision a client with your Tatum API key.
|
|
14
17
|
* const wallets = new TatumWalletsSdk({ apiKey: process.env.TATUM_API_KEY! });
|
|
15
|
-
* const
|
|
16
|
-
*
|
|
18
|
+
* const newClient = await wallets.custodian.createClient({ body: { isAccountAbstracted: false } });
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Client-side: act on behalf of a single client — no apiKey needed.
|
|
22
|
+
* const wallets = new TatumWalletsSdk();
|
|
23
|
+
* const client = wallets.initClient({ token: clientSessionToken });
|
|
17
24
|
*/
|
|
18
25
|
export class TatumWalletsSdk {
|
|
19
26
|
config;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
custodian;
|
|
24
|
-
portalProvider;
|
|
25
|
-
constructor(config) {
|
|
27
|
+
_api;
|
|
28
|
+
_custodian;
|
|
29
|
+
constructor(config = {}) {
|
|
26
30
|
this.config = config;
|
|
27
|
-
this.api = new WalletsApiClient(config);
|
|
28
|
-
this.portalProvider = new PortalTatumProvider(this.api, config);
|
|
29
|
-
this.custodian = new CustodianApi(this.api);
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* Low-level Tatum API client (`x-api-key` auth). Escape hatch for raw,
|
|
34
|
+
* not-yet-modeled Tatum calls. Requires a Tatum `apiKey` — throws if absent.
|
|
35
|
+
*/
|
|
36
|
+
get api() {
|
|
37
|
+
this._api ??= new WalletsApiClient(this.config);
|
|
38
|
+
return this._api;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Custodian-scoped operations, authenticated with your Tatum
|
|
42
|
+
* `x-api-key`. Backend only — requires a Tatum `apiKey` and throws if absent.
|
|
43
|
+
*/
|
|
44
|
+
get custodian() {
|
|
45
|
+
this._custodian ??= new CustodianApi(this.api);
|
|
46
|
+
return this._custodian;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a client-scoped API for a single client. Needs no Tatum
|
|
50
|
+
* `apiKey` — authenticates with the client's own token.
|
|
33
51
|
*
|
|
34
|
-
* @param config - Holds the client's
|
|
52
|
+
* @param config - Holds the client's API key or Client Session Token (CST).
|
|
35
53
|
* @returns A {@link WalletsClient} bound to that token.
|
|
36
54
|
*/
|
|
37
55
|
initClient(config) {
|
|
38
|
-
return new WalletsClient(config, this.
|
|
56
|
+
return new WalletsClient(config, this.config);
|
|
39
57
|
}
|
|
40
58
|
}
|
|
41
59
|
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,eAAe;IAIG;IAHrB,IAAI,CAAoB;IACxB,UAAU,CAAgB;IAElC,YAA6B,SAA2B,EAAE;QAA7B,WAAM,GAAN,MAAM,CAAuB;IAAG,CAAC;IAE9D;;;OAGG;IACH,IAAI,GAAG;QACL,IAAI,CAAC,IAAI,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACX,IAAI,CAAC,UAAU,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,MAAwB;QACjC,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;CACF"}
|
package/dist/tatum/api-client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpClient } from '../http.js';
|
|
|
3
3
|
export class WalletsApiClient extends HttpClient {
|
|
4
4
|
constructor(config) {
|
|
5
5
|
if (!config.apiKey) {
|
|
6
|
-
throw new Error('apiKey is required');
|
|
6
|
+
throw new Error('apiKey is required for custodian / sdk.api operations');
|
|
7
7
|
}
|
|
8
8
|
const apiKey = config.apiKey;
|
|
9
9
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/tatum/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,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IAED,GAAG,CACD,IAAY,EACZ,IAAc,EACd,UAA+D,EAAE;QAEjE,OAAO,IAAI,CAAC,OAAO,CAAY,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CACH,IAAY,EACZ,IAAc,EACd,UAA+D,EAAE;QAEjE,OAAO,IAAI,CAAC,OAAO,CAAY,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,CACJ,IAAY,EACZ,UAA+D,EAAE;QAEjE,OAAO,IAAI,CAAC,OAAO,CAAY,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export type QueryValue = string | number | boolean | null | undefined;
|
|
|
4
4
|
export type QueryParams = Record<string, QueryValue | readonly QueryValue[]>;
|
|
5
5
|
export interface WalletsSDKConfig {
|
|
6
6
|
baseUrl?: string;
|
|
7
|
-
|
|
7
|
+
/** Tatum API key (`x-api-key`). Required only for custodian / `sdk.api` operations. */
|
|
8
|
+
apiKey?: string;
|
|
8
9
|
headers?: Record<string, string>;
|
|
9
10
|
fetch?: typeof fetch;
|
|
10
11
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SA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AM,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tatumio/wallet-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "TypeScript SDK for Tatum-hosted MPC wallets — wallet generation, signing, sending, backup/recovery, and custodian/client management.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Tatum",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Tatum usage-metering endpoint hit once per wallet generation. */
|
|
2
|
-
export declare const USAGE_WALLET_PATH = "/v4/wallets/usage/wallet";
|
|
3
|
-
/** Tatum usage-metering endpoint hit once per signing operation (sign/rawSign/sendAssets). */
|
|
4
|
-
export declare const USAGE_TRANSACTION_PATH = "/v4/wallets/usage/transaction";
|
|
5
|
-
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/constants/paths.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,6BAA6B,CAAC;AAE5D,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,kCAAkC,CAAC"}
|
package/dist/constants/paths.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Tatum usage-metering endpoint hit once per wallet generation. */
|
|
2
|
-
export const USAGE_WALLET_PATH = '/v4/wallets/usage/wallet';
|
|
3
|
-
/** Tatum usage-metering endpoint hit once per signing operation (sign/rawSign/sendAssets). */
|
|
4
|
-
export const USAGE_TRANSACTION_PATH = '/v4/wallets/usage/transaction';
|
|
5
|
-
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/constants/paths.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAE5D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAA+B,CAAC"}
|
package/dist/tatum/provider.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { WalletsApiClient } from './api-client.js';
|
|
2
|
-
import type { WalletsSDKConfig } from '../types.js';
|
|
3
|
-
export declare class PortalTatumProvider {
|
|
4
|
-
private readonly tatumClient;
|
|
5
|
-
private readonly config;
|
|
6
|
-
constructor(tatumClient: WalletsApiClient, config: WalletsSDKConfig);
|
|
7
|
-
/**
|
|
8
|
-
* Report a wallet generation to Tatum's usage meter. Best-effort: authenticated
|
|
9
|
-
* with the client's Portal token (bearer) on top of the SDK's `x-api-key`, and
|
|
10
|
-
* any failure is swallowed so metering never breaks the underlying operation.
|
|
11
|
-
*/
|
|
12
|
-
trackWalletCreation(clientToken: string): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Report a signing operation (sign/rawSign/sendAssets) to Tatum's usage meter.
|
|
15
|
-
* Best-effort — see {@link trackWalletCreation}.
|
|
16
|
-
*/
|
|
17
|
-
trackTransaction(clientToken: string): Promise<void>;
|
|
18
|
-
private meterUsage;
|
|
19
|
-
/**
|
|
20
|
-
* Resolve the Tatum RPC gateway URL for a supported chain, in the form
|
|
21
|
-
* `https://<network>.gateway.tatum.io/<apiKey>`. `chain` is the Portal
|
|
22
|
-
* CAIP-2 id (the {@link WalletChain} value). Throws for unsupported chains.
|
|
23
|
-
*/
|
|
24
|
-
getRpcUrl(chain: string): Promise<string>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/tatum/provider.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EAAE,gBAAgB;IAG3C;;;;OAIG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;;OAGG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAItC,UAAU;IAQxB;;;;OAIG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAShD"}
|