@dakota-xyz/ts-sdk 1.3.0 → 1.4.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.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 === "POST") {
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 === "POST" && init.headers) {
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 === "POST" && init.headers) {
404
+ if (IDEMPOTENT_METHODS.has(method) && init.headers) {
404
405
  const headers = init.headers;
405
406
  return !!headers["x-idempotency-key"];
406
407
  }
@@ -1269,7 +1270,7 @@ var WalletsResource = class extends BaseResource {
1269
1270
  method: "GET",
1270
1271
  path: `/wallets/${walletId}/balances`
1271
1272
  });
1272
- return response.data;
1273
+ return response.balances ? [...response.balances] : [];
1273
1274
  }
1274
1275
  /**
1275
1276
  * Create a wallet transaction.
@@ -1684,12 +1685,19 @@ var PoliciesResource = class extends BaseResource {
1684
1685
  /**
1685
1686
  * Delete a policy.
1686
1687
  *
1688
+ * Endorsed endpoint — `options.endorsement` must contain a signed
1689
+ * `DeletePolicyIntent`. The server rejects requests without a valid
1690
+ * endorsement body.
1691
+ *
1687
1692
  * @param policyId - Policy ID
1693
+ * @param options - Request options (must include `endorsement`)
1688
1694
  */
1689
- async delete(policyId) {
1695
+ async delete(policyId, options) {
1690
1696
  await this.transport.request({
1691
1697
  method: "DELETE",
1692
- path: `/policies/${policyId}`
1698
+ path: `/policies/${policyId}`,
1699
+ body: options?.endorsement,
1700
+ idempotencyKey: options?.idempotencyKey
1693
1701
  });
1694
1702
  }
1695
1703
  /**
@@ -1703,7 +1711,7 @@ var PoliciesResource = class extends BaseResource {
1703
1711
  return this.transport.request({
1704
1712
  method: "POST",
1705
1713
  path: `/policies/${policyId}/rules`,
1706
- body: data,
1714
+ body: options?.endorsement ?? data,
1707
1715
  idempotencyKey: options?.idempotencyKey
1708
1716
  });
1709
1717
  }
@@ -1719,20 +1727,27 @@ var PoliciesResource = class extends BaseResource {
1719
1727
  return this.transport.request({
1720
1728
  method: "PATCH",
1721
1729
  path: `/policies/${policyId}/rules/${ruleId}`,
1722
- body: data,
1730
+ body: options?.endorsement ?? data,
1723
1731
  idempotencyKey: options?.idempotencyKey
1724
1732
  });
1725
1733
  }
1726
1734
  /**
1727
1735
  * Delete a policy rule.
1728
1736
  *
1737
+ * Endorsed endpoint — `options.endorsement` must contain a signed
1738
+ * `RemovePolicyRuleIntent`. The server rejects requests without a valid
1739
+ * endorsement body.
1740
+ *
1729
1741
  * @param policyId - Policy ID
1730
1742
  * @param ruleId - Rule ID
1743
+ * @param options - Request options (must include `endorsement`)
1731
1744
  */
1732
- async deleteRule(policyId, ruleId) {
1745
+ async deleteRule(policyId, ruleId, options) {
1733
1746
  await this.transport.request({
1734
1747
  method: "DELETE",
1735
- path: `/policies/${policyId}/rules/${ruleId}`
1748
+ path: `/policies/${policyId}/rules/${ruleId}`,
1749
+ body: options?.endorsement,
1750
+ idempotencyKey: options?.idempotencyKey
1736
1751
  });
1737
1752
  }
1738
1753
  /**
@@ -1752,26 +1767,39 @@ var PoliciesResource = class extends BaseResource {
1752
1767
  /**
1753
1768
  * Attach a policy to a wallet.
1754
1769
  *
1770
+ * Endorsed endpoint — `options.endorsement` must contain a signed
1771
+ * `AttachPolicyToWalletIntent`. The server rejects requests without a
1772
+ * valid endorsement body.
1773
+ *
1755
1774
  * @param policyId - Policy ID
1756
1775
  * @param walletId - Wallet ID
1776
+ * @param options - Request options (must include `endorsement`)
1757
1777
  */
1758
1778
  async attachToWallet(policyId, walletId, options) {
1759
1779
  await this.transport.request({
1760
1780
  method: "PUT",
1761
1781
  path: `/policies/${policyId}/wallets/${walletId}`,
1782
+ body: options?.endorsement,
1762
1783
  idempotencyKey: options?.idempotencyKey
1763
1784
  });
1764
1785
  }
1765
1786
  /**
1766
1787
  * Detach a policy from a wallet.
1767
1788
  *
1789
+ * Endorsed endpoint — `options.endorsement` must contain a signed
1790
+ * `DetachPolicyFromWalletIntent`. The server rejects requests without a
1791
+ * valid endorsement body.
1792
+ *
1768
1793
  * @param policyId - Policy ID
1769
1794
  * @param walletId - Wallet ID
1795
+ * @param options - Request options (must include `endorsement`)
1770
1796
  */
1771
- async detachFromWallet(policyId, walletId) {
1797
+ async detachFromWallet(policyId, walletId, options) {
1772
1798
  await this.transport.request({
1773
1799
  method: "DELETE",
1774
- path: `/policies/${policyId}/wallets/${walletId}`
1800
+ path: `/policies/${policyId}/wallets/${walletId}`,
1801
+ body: options?.endorsement,
1802
+ idempotencyKey: options?.idempotencyKey
1775
1803
  });
1776
1804
  }
1777
1805
  };
@@ -1857,26 +1885,39 @@ var SignerGroupsResource = class extends BaseResource {
1857
1885
  /**
1858
1886
  * Attach a signer group to a wallet.
1859
1887
  *
1888
+ * Endorsed endpoint — `options.endorsement` must contain a signed
1889
+ * `AttachGroupToWalletIntent`. The server rejects requests without a
1890
+ * valid endorsement body.
1891
+ *
1860
1892
  * @param walletId - Wallet ID
1861
1893
  * @param signerGroupId - Signer group ID
1894
+ * @param options - Request options (must include `endorsement`)
1862
1895
  */
1863
1896
  async attachToWallet(walletId, signerGroupId, options) {
1864
1897
  await this.transport.request({
1865
1898
  method: "PUT",
1866
1899
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
1900
+ body: options?.endorsement,
1867
1901
  idempotencyKey: options?.idempotencyKey
1868
1902
  });
1869
1903
  }
1870
1904
  /**
1871
1905
  * Detach a signer group from a wallet.
1872
1906
  *
1907
+ * Endorsed endpoint — `options.endorsement` must contain a signed
1908
+ * `DetachGroupFromWalletIntent`. The server rejects requests without a
1909
+ * valid endorsement body.
1910
+ *
1873
1911
  * @param walletId - Wallet ID
1874
1912
  * @param signerGroupId - Signer group ID
1913
+ * @param options - Request options (must include `endorsement`)
1875
1914
  */
1876
- async detachFromWallet(walletId, signerGroupId) {
1915
+ async detachFromWallet(walletId, signerGroupId, options) {
1877
1916
  await this.transport.request({
1878
1917
  method: "DELETE",
1879
- path: `/wallets/${walletId}/signer-groups/${signerGroupId}`
1918
+ path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
1919
+ body: options?.endorsement,
1920
+ idempotencyKey: options?.idempotencyKey
1880
1921
  });
1881
1922
  }
1882
1923
  /**
@@ -2183,11 +2224,10 @@ var InfoResource = class extends BaseResource {
2183
2224
  * ```
2184
2225
  */
2185
2226
  async getCountries() {
2186
- const response = await this.transport.request({
2227
+ return this.transport.request({
2187
2228
  method: "GET",
2188
2229
  path: "/capabilities/countries"
2189
2230
  });
2190
- return response.data;
2191
2231
  }
2192
2232
  /**
2193
2233
  * Get supported networks.
@@ -2203,11 +2243,10 @@ var InfoResource = class extends BaseResource {
2203
2243
  * ```
2204
2244
  */
2205
2245
  async getNetworks() {
2206
- const response = await this.transport.request({
2246
+ return this.transport.request({
2207
2247
  method: "GET",
2208
2248
  path: "/capabilities/networks"
2209
2249
  });
2210
- return response.data;
2211
2250
  }
2212
2251
  };
2213
2252