@dakota-xyz/ts-sdk 1.3.1 → 1.6.0
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/index.d.mts +219 -41
- package/dist/index.d.ts +219 -41
- package/dist/index.js +142 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -42
- package/dist/index.mjs.map +1 -1
- package/dist/webhook/index.d.mts +8 -2
- package/dist/webhook/index.d.ts +8 -2
- package/dist/webhook/index.js +1 -1
- package/dist/webhook/index.js.map +1 -1
- package/dist/webhook/index.mjs +1 -1
- package/dist/webhook/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -227,6 +227,7 @@ function resolveConfig(config) {
|
|
|
227
227
|
// src/client/transport.ts
|
|
228
228
|
var RETRYABLE_STATUS_CODES2 = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
229
229
|
var SAFE_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "PUT", "DELETE", "OPTIONS"]);
|
|
230
|
+
var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
|
|
230
231
|
var Transport = class {
|
|
231
232
|
config;
|
|
232
233
|
constructor(config) {
|
|
@@ -272,7 +273,7 @@ var Transport = class {
|
|
|
272
273
|
...customHeaders
|
|
273
274
|
};
|
|
274
275
|
this.addAuthHeader(headers, path);
|
|
275
|
-
if (method
|
|
276
|
+
if (IDEMPOTENT_METHODS.has(method)) {
|
|
276
277
|
const key = idempotencyKey ?? (this.config.automaticIdempotency ? this.config.idempotencyKeyGenerator() : void 0);
|
|
277
278
|
if (key) {
|
|
278
279
|
headers["x-idempotency-key"] = key;
|
|
@@ -384,7 +385,7 @@ var Transport = class {
|
|
|
384
385
|
if (SAFE_METHODS.has(method)) {
|
|
385
386
|
return true;
|
|
386
387
|
}
|
|
387
|
-
if (method
|
|
388
|
+
if (IDEMPOTENT_METHODS.has(method) && init.headers) {
|
|
388
389
|
const headers = init.headers;
|
|
389
390
|
return !!headers["x-idempotency-key"];
|
|
390
391
|
}
|
|
@@ -400,7 +401,7 @@ var Transport = class {
|
|
|
400
401
|
if (SAFE_METHODS.has(method)) {
|
|
401
402
|
return true;
|
|
402
403
|
}
|
|
403
|
-
if (method
|
|
404
|
+
if (IDEMPOTENT_METHODS.has(method) && init.headers) {
|
|
404
405
|
const headers = init.headers;
|
|
405
406
|
return !!headers["x-idempotency-key"];
|
|
406
407
|
}
|
|
@@ -611,6 +612,15 @@ var CustomersResource = class extends BaseResource {
|
|
|
611
612
|
* { idempotencyKey: 'create-acme-corp-001' }
|
|
612
613
|
* );
|
|
613
614
|
* console.log(customer.applicationUrl); // KYB onboarding URL
|
|
615
|
+
*
|
|
616
|
+
* // Designate as a sub-client at creation (ENG-2454).
|
|
617
|
+
* // `is_sub_client` can only be set here — a regular customer cannot
|
|
618
|
+
* // be promoted afterwards. Cannot be combined with `sub_client_id`.
|
|
619
|
+
* const subClient = await client.customers.create({
|
|
620
|
+
* name: 'Partner Corp',
|
|
621
|
+
* customer_type: 'business',
|
|
622
|
+
* is_sub_client: true,
|
|
623
|
+
* });
|
|
614
624
|
* ```
|
|
615
625
|
*/
|
|
616
626
|
async create(data, options) {
|
|
@@ -853,30 +863,39 @@ var DestinationsResource = class extends BaseResource {
|
|
|
853
863
|
/**
|
|
854
864
|
* Create a new destination for a recipient.
|
|
855
865
|
*
|
|
856
|
-
* Destinations can be bank accounts (fiat_us) or crypto
|
|
866
|
+
* Destinations can be bank accounts (fiat_us / fiat_iban) or crypto
|
|
867
|
+
* wallets (crypto).
|
|
868
|
+
*
|
|
869
|
+
* The platform returns just `{ id }` here (per `IDResponse`), not the
|
|
870
|
+
* full destination object. Call `destinations.list(recipientId)` if
|
|
871
|
+
* you need the rest of the fields.
|
|
857
872
|
*
|
|
858
873
|
* @param recipientId - Recipient ID
|
|
859
874
|
* @param data - Destination creation data
|
|
860
|
-
* @returns
|
|
875
|
+
* @returns `{ id }` of the newly-created destination
|
|
861
876
|
*
|
|
862
877
|
* @example
|
|
863
878
|
* ```typescript
|
|
864
|
-
* //
|
|
865
|
-
* const bankDest = await client.destinations.create(recipientId, {
|
|
866
|
-
* destination_type: 'fiat_us',
|
|
867
|
-
* bank_name: 'Chase Bank',
|
|
868
|
-
* account_holder_name: 'Acme Corp',
|
|
869
|
-
* account_number: '123456789',
|
|
870
|
-
* routing_number: '021000021',
|
|
871
|
-
* account_type: 'checking',
|
|
872
|
-
* });
|
|
873
|
-
*
|
|
874
|
-
* // Create a crypto destination (for on-ramp)
|
|
879
|
+
* // Crypto destination (for on-ramp)
|
|
875
880
|
* const cryptoDest = await client.destinations.create(recipientId, {
|
|
876
881
|
* destination_type: 'crypto',
|
|
882
|
+
* name: 'Treasury USDC',
|
|
877
883
|
* crypto_address: '0x742d35Cc6634C0532925a3b844Bc9e7595f...',
|
|
878
884
|
* network_id: 'ethereum-mainnet',
|
|
879
885
|
* });
|
|
886
|
+
* // → cryptoDest.id
|
|
887
|
+
*
|
|
888
|
+
* // Fiat US destination (for off-ramp)
|
|
889
|
+
* const bankDest = await client.destinations.create(recipientId, {
|
|
890
|
+
* destination_type: 'fiat_us',
|
|
891
|
+
* name: 'Acme Chase Checking',
|
|
892
|
+
* bank_name: 'JPMorgan Chase',
|
|
893
|
+
* account_holder_name: 'Acme Corp',
|
|
894
|
+
* account_number: '000123456789',
|
|
895
|
+
* aba_routing_number: '021000021',
|
|
896
|
+
* account_type: 'checking',
|
|
897
|
+
* });
|
|
898
|
+
* // → bankDest.id
|
|
880
899
|
* ```
|
|
881
900
|
*/
|
|
882
901
|
async create(recipientId, data, options) {
|
|
@@ -1112,6 +1131,13 @@ var TransactionsResource = class extends BaseResource {
|
|
|
1112
1131
|
* customer_id: customerId,
|
|
1113
1132
|
* status: 'completed',
|
|
1114
1133
|
* });
|
|
1134
|
+
*
|
|
1135
|
+
* // Wallet-scoped filters (require transaction_type: 'wallet')
|
|
1136
|
+
* const sent = client.transactions.list({
|
|
1137
|
+
* transaction_type: 'wallet',
|
|
1138
|
+
* wallet_id: walletId,
|
|
1139
|
+
* direction: 'out',
|
|
1140
|
+
* });
|
|
1115
1141
|
* ```
|
|
1116
1142
|
*/
|
|
1117
1143
|
list(params) {
|
|
@@ -1253,40 +1279,76 @@ var WalletsResource = class extends BaseResource {
|
|
|
1253
1279
|
/**
|
|
1254
1280
|
* Get wallet balances.
|
|
1255
1281
|
*
|
|
1282
|
+
* Returns the platform's full `WalletBalances` response: the wallet id,
|
|
1283
|
+
* its on-chain address, every per-asset balance, and a pre-computed
|
|
1284
|
+
* `total_amount_usd` across all assets. The previous return shape
|
|
1285
|
+
* (`WalletBalance[]`) silently dropped `address` and `total_amount_usd`,
|
|
1286
|
+
* forcing callers to do a second `wallets.get()` and sum the balances
|
|
1287
|
+
* by hand. This is a small breaking change with a one-line migration
|
|
1288
|
+
* (`balances` → `balances.balances`); the prior shape had been broken
|
|
1289
|
+
* since 1.3.x anyway.
|
|
1290
|
+
*
|
|
1256
1291
|
* @param walletId - Wallet ID
|
|
1257
|
-
* @returns
|
|
1292
|
+
* @returns `{ wallet_id, address, balances, total_amount_usd }`
|
|
1258
1293
|
*
|
|
1259
1294
|
* @example
|
|
1260
1295
|
* ```typescript
|
|
1261
|
-
* const balances =
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1296
|
+
* const { address, total_amount_usd, balances } =
|
|
1297
|
+
* await client.wallets.getBalances(walletId);
|
|
1298
|
+
* console.log(`${address} → $${total_amount_usd}`);
|
|
1299
|
+
* for (const b of balances) {
|
|
1300
|
+
* console.log(b.asset.id, b.amount_usd);
|
|
1264
1301
|
* }
|
|
1265
1302
|
* ```
|
|
1266
1303
|
*/
|
|
1267
1304
|
async getBalances(walletId) {
|
|
1268
|
-
|
|
1305
|
+
return this.transport.request({
|
|
1269
1306
|
method: "GET",
|
|
1270
1307
|
path: `/wallets/${walletId}/balances`
|
|
1271
1308
|
});
|
|
1272
|
-
return response.data;
|
|
1273
1309
|
}
|
|
1274
1310
|
/**
|
|
1275
|
-
*
|
|
1311
|
+
* Send a transaction from a wallet.
|
|
1312
|
+
*
|
|
1313
|
+
* The platform expects an **endorsed request** envelope —
|
|
1314
|
+
* `{ signatures, intent }` — at this endpoint. Build the
|
|
1315
|
+
* `SendTransactionIntent`, canonicalize it per RFC 8785 (JCS), sign
|
|
1316
|
+
* with the wallet's signer-group ECDSA P-256 key, base64-encode the
|
|
1317
|
+
* DER signature, then post the envelope.
|
|
1276
1318
|
*
|
|
1277
1319
|
* @param walletId - Wallet ID
|
|
1278
|
-
* @param data -
|
|
1320
|
+
* @param data - Endorsed wallet transaction request: `{ signatures, intent }`
|
|
1279
1321
|
* @returns Created transaction
|
|
1280
1322
|
*
|
|
1281
1323
|
* @example
|
|
1282
1324
|
* ```typescript
|
|
1325
|
+
* import canonicalize from 'canonicalize';
|
|
1326
|
+
* import { createSign, createPrivateKey, randomUUID } from 'node:crypto';
|
|
1327
|
+
*
|
|
1328
|
+
* const intent = {
|
|
1329
|
+
* wallet_id: walletId,
|
|
1330
|
+
* caip2: 'eip155:1', // 11155111 for sepolia
|
|
1331
|
+
* operation: {
|
|
1332
|
+
* kind: 'transfer',
|
|
1333
|
+
* from: wallet.address,
|
|
1334
|
+
* to: '0x...',
|
|
1335
|
+
* amount: '100.00',
|
|
1336
|
+
* asset_id: 'USDC',
|
|
1337
|
+
* },
|
|
1338
|
+
* idempotency_key: randomUUID(),
|
|
1339
|
+
* };
|
|
1340
|
+
* const canonical = canonicalize(intent)!;
|
|
1341
|
+
* const sig = createSign('SHA256').update(canonical).sign({
|
|
1342
|
+
* key: createPrivateKey({ key: privateKeyDer, format: 'der', type: 'pkcs8' }),
|
|
1343
|
+
* dsaEncoding: 'der',
|
|
1344
|
+
* });
|
|
1283
1345
|
* const tx = await client.wallets.createTransaction(walletId, {
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
* asset: 'USDC',
|
|
1287
|
-
* network_id: 'ethereum-mainnet',
|
|
1346
|
+
* signatures: [sig.toString('base64')],
|
|
1347
|
+
* intent,
|
|
1288
1348
|
* });
|
|
1289
1349
|
* ```
|
|
1350
|
+
*
|
|
1351
|
+
* @see https://docs.dakota.xyz/documentation/signing-guide
|
|
1290
1352
|
*/
|
|
1291
1353
|
async createTransaction(walletId, data, options) {
|
|
1292
1354
|
return this.transport.request({
|
|
@@ -1684,12 +1746,19 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1684
1746
|
/**
|
|
1685
1747
|
* Delete a policy.
|
|
1686
1748
|
*
|
|
1749
|
+
* Endorsed endpoint — `options.endorsement` must contain a signed
|
|
1750
|
+
* `DeletePolicyIntent`. The server rejects requests without a valid
|
|
1751
|
+
* endorsement body.
|
|
1752
|
+
*
|
|
1687
1753
|
* @param policyId - Policy ID
|
|
1754
|
+
* @param options - Request options (must include `endorsement`)
|
|
1688
1755
|
*/
|
|
1689
|
-
async delete(policyId) {
|
|
1756
|
+
async delete(policyId, options) {
|
|
1690
1757
|
await this.transport.request({
|
|
1691
1758
|
method: "DELETE",
|
|
1692
|
-
path: `/policies/${policyId}
|
|
1759
|
+
path: `/policies/${policyId}`,
|
|
1760
|
+
body: options?.endorsement,
|
|
1761
|
+
idempotencyKey: options?.idempotencyKey
|
|
1693
1762
|
});
|
|
1694
1763
|
}
|
|
1695
1764
|
/**
|
|
@@ -1703,7 +1772,7 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1703
1772
|
return this.transport.request({
|
|
1704
1773
|
method: "POST",
|
|
1705
1774
|
path: `/policies/${policyId}/rules`,
|
|
1706
|
-
body: data,
|
|
1775
|
+
body: options?.endorsement ?? data,
|
|
1707
1776
|
idempotencyKey: options?.idempotencyKey
|
|
1708
1777
|
});
|
|
1709
1778
|
}
|
|
@@ -1719,20 +1788,27 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1719
1788
|
return this.transport.request({
|
|
1720
1789
|
method: "PATCH",
|
|
1721
1790
|
path: `/policies/${policyId}/rules/${ruleId}`,
|
|
1722
|
-
body: data,
|
|
1791
|
+
body: options?.endorsement ?? data,
|
|
1723
1792
|
idempotencyKey: options?.idempotencyKey
|
|
1724
1793
|
});
|
|
1725
1794
|
}
|
|
1726
1795
|
/**
|
|
1727
1796
|
* Delete a policy rule.
|
|
1728
1797
|
*
|
|
1798
|
+
* Endorsed endpoint — `options.endorsement` must contain a signed
|
|
1799
|
+
* `RemovePolicyRuleIntent`. The server rejects requests without a valid
|
|
1800
|
+
* endorsement body.
|
|
1801
|
+
*
|
|
1729
1802
|
* @param policyId - Policy ID
|
|
1730
1803
|
* @param ruleId - Rule ID
|
|
1804
|
+
* @param options - Request options (must include `endorsement`)
|
|
1731
1805
|
*/
|
|
1732
|
-
async deleteRule(policyId, ruleId) {
|
|
1806
|
+
async deleteRule(policyId, ruleId, options) {
|
|
1733
1807
|
await this.transport.request({
|
|
1734
1808
|
method: "DELETE",
|
|
1735
|
-
path: `/policies/${policyId}/rules/${ruleId}
|
|
1809
|
+
path: `/policies/${policyId}/rules/${ruleId}`,
|
|
1810
|
+
body: options?.endorsement,
|
|
1811
|
+
idempotencyKey: options?.idempotencyKey
|
|
1736
1812
|
});
|
|
1737
1813
|
}
|
|
1738
1814
|
/**
|
|
@@ -1752,26 +1828,39 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1752
1828
|
/**
|
|
1753
1829
|
* Attach a policy to a wallet.
|
|
1754
1830
|
*
|
|
1831
|
+
* Endorsed endpoint — `options.endorsement` must contain a signed
|
|
1832
|
+
* `AttachPolicyToWalletIntent`. The server rejects requests without a
|
|
1833
|
+
* valid endorsement body.
|
|
1834
|
+
*
|
|
1755
1835
|
* @param policyId - Policy ID
|
|
1756
1836
|
* @param walletId - Wallet ID
|
|
1837
|
+
* @param options - Request options (must include `endorsement`)
|
|
1757
1838
|
*/
|
|
1758
1839
|
async attachToWallet(policyId, walletId, options) {
|
|
1759
1840
|
await this.transport.request({
|
|
1760
1841
|
method: "PUT",
|
|
1761
1842
|
path: `/policies/${policyId}/wallets/${walletId}`,
|
|
1843
|
+
body: options?.endorsement,
|
|
1762
1844
|
idempotencyKey: options?.idempotencyKey
|
|
1763
1845
|
});
|
|
1764
1846
|
}
|
|
1765
1847
|
/**
|
|
1766
1848
|
* Detach a policy from a wallet.
|
|
1767
1849
|
*
|
|
1850
|
+
* Endorsed endpoint — `options.endorsement` must contain a signed
|
|
1851
|
+
* `DetachPolicyFromWalletIntent`. The server rejects requests without a
|
|
1852
|
+
* valid endorsement body.
|
|
1853
|
+
*
|
|
1768
1854
|
* @param policyId - Policy ID
|
|
1769
1855
|
* @param walletId - Wallet ID
|
|
1856
|
+
* @param options - Request options (must include `endorsement`)
|
|
1770
1857
|
*/
|
|
1771
|
-
async detachFromWallet(policyId, walletId) {
|
|
1858
|
+
async detachFromWallet(policyId, walletId, options) {
|
|
1772
1859
|
await this.transport.request({
|
|
1773
1860
|
method: "DELETE",
|
|
1774
|
-
path: `/policies/${policyId}/wallets/${walletId}
|
|
1861
|
+
path: `/policies/${policyId}/wallets/${walletId}`,
|
|
1862
|
+
body: options?.endorsement,
|
|
1863
|
+
idempotencyKey: options?.idempotencyKey
|
|
1775
1864
|
});
|
|
1776
1865
|
}
|
|
1777
1866
|
};
|
|
@@ -1857,26 +1946,39 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
1857
1946
|
/**
|
|
1858
1947
|
* Attach a signer group to a wallet.
|
|
1859
1948
|
*
|
|
1949
|
+
* Endorsed endpoint — `options.endorsement` must contain a signed
|
|
1950
|
+
* `AttachGroupToWalletIntent`. The server rejects requests without a
|
|
1951
|
+
* valid endorsement body.
|
|
1952
|
+
*
|
|
1860
1953
|
* @param walletId - Wallet ID
|
|
1861
1954
|
* @param signerGroupId - Signer group ID
|
|
1955
|
+
* @param options - Request options (must include `endorsement`)
|
|
1862
1956
|
*/
|
|
1863
1957
|
async attachToWallet(walletId, signerGroupId, options) {
|
|
1864
1958
|
await this.transport.request({
|
|
1865
1959
|
method: "PUT",
|
|
1866
1960
|
path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
|
|
1961
|
+
body: options?.endorsement,
|
|
1867
1962
|
idempotencyKey: options?.idempotencyKey
|
|
1868
1963
|
});
|
|
1869
1964
|
}
|
|
1870
1965
|
/**
|
|
1871
1966
|
* Detach a signer group from a wallet.
|
|
1872
1967
|
*
|
|
1968
|
+
* Endorsed endpoint — `options.endorsement` must contain a signed
|
|
1969
|
+
* `DetachGroupFromWalletIntent`. The server rejects requests without a
|
|
1970
|
+
* valid endorsement body.
|
|
1971
|
+
*
|
|
1873
1972
|
* @param walletId - Wallet ID
|
|
1874
1973
|
* @param signerGroupId - Signer group ID
|
|
1974
|
+
* @param options - Request options (must include `endorsement`)
|
|
1875
1975
|
*/
|
|
1876
|
-
async detachFromWallet(walletId, signerGroupId) {
|
|
1976
|
+
async detachFromWallet(walletId, signerGroupId, options) {
|
|
1877
1977
|
await this.transport.request({
|
|
1878
1978
|
method: "DELETE",
|
|
1879
|
-
path: `/wallets/${walletId}/signer-groups/${signerGroupId}
|
|
1979
|
+
path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
|
|
1980
|
+
body: options?.endorsement,
|
|
1981
|
+
idempotencyKey: options?.idempotencyKey
|
|
1880
1982
|
});
|
|
1881
1983
|
}
|
|
1882
1984
|
/**
|
|
@@ -2183,11 +2285,10 @@ var InfoResource = class extends BaseResource {
|
|
|
2183
2285
|
* ```
|
|
2184
2286
|
*/
|
|
2185
2287
|
async getCountries() {
|
|
2186
|
-
|
|
2288
|
+
return this.transport.request({
|
|
2187
2289
|
method: "GET",
|
|
2188
2290
|
path: "/capabilities/countries"
|
|
2189
2291
|
});
|
|
2190
|
-
return response.data;
|
|
2191
2292
|
}
|
|
2192
2293
|
/**
|
|
2193
2294
|
* Get supported networks.
|
|
@@ -2203,11 +2304,10 @@ var InfoResource = class extends BaseResource {
|
|
|
2203
2304
|
* ```
|
|
2204
2305
|
*/
|
|
2205
2306
|
async getNetworks() {
|
|
2206
|
-
|
|
2307
|
+
return this.transport.request({
|
|
2207
2308
|
method: "GET",
|
|
2208
2309
|
path: "/capabilities/networks"
|
|
2209
2310
|
});
|
|
2210
|
-
return response.data;
|
|
2211
2311
|
}
|
|
2212
2312
|
};
|
|
2213
2313
|
|