@coinbase/cdp-core 0.0.118 → 0.0.120

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.
Files changed (288) hide show
  1. package/dist/esm/index.web10.js +52 -51
  2. package/dist/esm/index.web107.js +3 -3
  3. package/dist/esm/index.web110.js +2 -2
  4. package/dist/esm/index.web114.js +3 -3
  5. package/dist/esm/index.web127.js +13 -373
  6. package/dist/esm/index.web128.js +22 -28
  7. package/dist/esm/index.web129.js +50 -28
  8. package/dist/esm/index.web130.js +373 -13
  9. package/dist/esm/index.web131.js +28 -22
  10. package/dist/esm/index.web132.js +28 -50
  11. package/dist/esm/index.web133.js +1 -1
  12. package/dist/esm/index.web134.js +1 -1
  13. package/dist/esm/index.web138.js +1 -1
  14. package/dist/esm/index.web139.js +1 -1
  15. package/dist/esm/index.web142.js +13 -2
  16. package/dist/esm/index.web143.js +12 -2
  17. package/dist/esm/index.web144.js +54 -14
  18. package/dist/esm/index.web145.js +10 -28
  19. package/dist/esm/index.web146.js +2 -8
  20. package/dist/esm/index.web147.js +45 -4
  21. package/dist/esm/index.web148.js +13 -28
  22. package/dist/esm/index.web149.js +4 -8
  23. package/dist/esm/index.web150.js +2 -8
  24. package/dist/esm/index.web151.js +2 -81
  25. package/dist/esm/index.web152.js +4 -18
  26. package/dist/esm/index.web153.js +28 -3
  27. package/dist/esm/index.web154.js +7 -15
  28. package/dist/esm/index.web155.js +3 -4
  29. package/dist/esm/index.web156.js +19 -5
  30. package/dist/esm/index.web157.js +8 -19
  31. package/dist/esm/index.web158.js +7 -61
  32. package/dist/esm/index.web159.js +79 -16
  33. package/dist/esm/index.web160.js +24 -19
  34. package/dist/esm/index.web161.js +3 -8
  35. package/dist/esm/index.web162.js +6 -33
  36. package/dist/esm/index.web163.js +4 -7
  37. package/dist/esm/index.web164.js +14 -20
  38. package/dist/esm/index.web165.js +18 -53
  39. package/dist/esm/index.web166.js +61 -10
  40. package/dist/esm/index.web167.js +18 -2
  41. package/dist/esm/index.web168.js +23 -44
  42. package/dist/esm/index.web169.js +8 -13
  43. package/dist/esm/index.web170.js +41 -11
  44. package/dist/esm/index.web171.js +7 -11
  45. package/dist/esm/index.web172.js +20 -4
  46. package/dist/esm/index.web191.js +1 -1
  47. package/dist/esm/index.web193.js +1 -1
  48. package/dist/esm/index.web194.js +2 -2
  49. package/dist/esm/index.web202.js +2 -2
  50. package/dist/esm/index.web21.js +16 -5
  51. package/dist/esm/index.web219.js +102 -19
  52. package/dist/esm/index.web220.js +79 -10
  53. package/dist/esm/index.web221.js +79 -20
  54. package/dist/esm/index.web222.js +20 -93
  55. package/dist/esm/index.web223.js +9 -20
  56. package/dist/esm/index.web224.js +16 -114
  57. package/dist/esm/index.web225.js +89 -99
  58. package/dist/esm/index.web226.js +20 -78
  59. package/dist/esm/index.web227.js +118 -79
  60. package/dist/esm/index.web228.js +2 -109
  61. package/dist/esm/index.web229.js +109 -2
  62. package/dist/esm/index.web230.js +2 -2
  63. package/dist/esm/index.web237.js +1 -1
  64. package/dist/esm/index.web242.js +1 -1
  65. package/dist/esm/index.web244.js +1 -1
  66. package/dist/esm/index.web247.js +1 -1
  67. package/dist/esm/index.web248.js +1 -1
  68. package/dist/esm/index.web250.js +78 -14
  69. package/dist/esm/index.web251.js +14 -78
  70. package/dist/esm/index.web64.js +24 -22
  71. package/dist/esm/index.web65.js +13 -17
  72. package/dist/esm/index.web85.js +85 -64
  73. package/dist/esm/index.web9.js +1 -1
  74. package/dist/native/index.native109.js +3 -3
  75. package/dist/native/index.native11.js +1 -1
  76. package/dist/native/index.native116.js +2 -2
  77. package/dist/native/index.native12.js +51 -50
  78. package/dist/native/index.native128.js +12 -12
  79. package/dist/native/index.native133.js +104 -27
  80. package/dist/native/index.native134.js +16 -28
  81. package/dist/native/index.native135.js +21 -15
  82. package/dist/native/index.native136.js +49 -21
  83. package/dist/native/index.native137.js +28 -50
  84. package/dist/native/index.native138.js +27 -104
  85. package/dist/native/index.native141.js +1 -1
  86. package/dist/native/index.native142.js +1 -1
  87. package/dist/native/index.native144.js +1 -1
  88. package/dist/native/index.native145.js +2 -2
  89. package/dist/native/index.native146.js +5 -55
  90. package/dist/native/index.native147.js +47 -10
  91. package/dist/native/index.native148.js +36 -2
  92. package/dist/native/index.native149.js +66 -43
  93. package/dist/native/index.native150.js +54 -13
  94. package/dist/native/index.native151.js +11 -5
  95. package/dist/native/index.native152.js +2 -48
  96. package/dist/native/index.native153.js +44 -35
  97. package/dist/native/index.native154.js +12 -66
  98. package/dist/native/index.native155.js +13 -13
  99. package/dist/native/index.native156.js +54 -26
  100. package/dist/native/index.native157.js +6 -7
  101. package/dist/native/index.native158.js +21 -3
  102. package/dist/native/index.native159.js +16 -26
  103. package/dist/native/index.native160.js +45 -8
  104. package/dist/native/index.native161.js +3 -7
  105. package/dist/native/index.native162.js +3 -79
  106. package/dist/native/index.native163.js +32 -25
  107. package/dist/native/index.native164.js +12 -3
  108. package/dist/native/index.native165.js +4 -14
  109. package/dist/native/index.native166.js +28 -4
  110. package/dist/native/index.native167.js +6 -13
  111. package/dist/native/index.native168.js +31 -18
  112. package/dist/native/index.native169.js +9 -57
  113. package/dist/native/index.native170.js +55 -17
  114. package/dist/native/index.native171.js +41 -22
  115. package/dist/native/index.native172.js +127 -8
  116. package/dist/native/index.native173.js +102 -39
  117. package/dist/native/index.native174.js +6 -7
  118. package/dist/native/index.native175.js +3 -21
  119. package/dist/native/index.native176.js +79 -2
  120. package/dist/native/index.native177.js +2 -2
  121. package/dist/native/index.native178.js +2 -14
  122. package/dist/native/index.native179.js +33 -51
  123. package/dist/native/index.native180.js +6 -6
  124. package/dist/native/index.native181.js +32 -19
  125. package/dist/native/index.native182.js +14 -17
  126. package/dist/native/index.native183.js +30 -41
  127. package/dist/native/index.native184.js +18 -3
  128. package/dist/native/index.native185.js +8 -3
  129. package/dist/native/index.native186.js +9 -33
  130. package/dist/native/index.native187.js +11 -12
  131. package/dist/native/index.native188.js +13 -4
  132. package/dist/native/index.native189.js +5 -28
  133. package/dist/native/index.native190.js +5 -7
  134. package/dist/native/index.native191.js +10 -32
  135. package/dist/native/index.native192.js +2 -13
  136. package/dist/native/index.native193.js +2 -56
  137. package/dist/native/index.native194.js +13 -42
  138. package/dist/native/index.native195.js +26 -126
  139. package/dist/native/index.native196.js +7 -104
  140. package/dist/native/index.native197.js +3 -6
  141. package/dist/native/index.native198.js +28 -3
  142. package/dist/native/index.native199.js +8 -78
  143. package/dist/native/index.native2.js +2 -2
  144. package/dist/native/index.native200.js +8 -2
  145. package/dist/native/index.native201.js +80 -2
  146. package/dist/native/index.native202.js +25 -35
  147. package/dist/native/index.native203.js +3 -6
  148. package/dist/native/index.native204.js +14 -34
  149. package/dist/native/index.native205.js +4 -14
  150. package/dist/native/index.native206.js +13 -34
  151. package/dist/native/index.native207.js +18 -17
  152. package/dist/native/index.native208.js +60 -8
  153. package/dist/native/index.native209.js +17 -10
  154. package/dist/native/index.native210.js +23 -11
  155. package/dist/native/index.native211.js +8 -13
  156. package/dist/native/index.native212.js +41 -5
  157. package/dist/native/index.native213.js +8 -5
  158. package/dist/native/index.native214.js +20 -10
  159. package/dist/native/index.native221.js +2 -2
  160. package/dist/native/index.native222.js +3 -3
  161. package/dist/native/index.native224.js +3 -3
  162. package/dist/native/index.native225.js +1 -1
  163. package/dist/native/index.native226.js +3 -3
  164. package/dist/native/index.native227.js +38 -7
  165. package/dist/native/index.native229.js +67 -358
  166. package/dist/native/index.native23.js +16 -5
  167. package/dist/native/index.native230.js +34 -852
  168. package/dist/native/index.native231.js +14 -38
  169. package/dist/native/index.native232.js +8 -2
  170. package/dist/native/index.native233.js +2 -70
  171. package/dist/native/index.native234.js +355 -29
  172. package/dist/native/index.native235.js +852 -14
  173. package/dist/native/index.native236.js +14 -40
  174. package/dist/native/index.native237.js +2 -21
  175. package/dist/native/index.native238.js +20 -2
  176. package/dist/native/index.native239.js +31 -18
  177. package/dist/native/index.native240.js +6 -32
  178. package/dist/native/index.native241.js +3 -6
  179. package/dist/native/index.native242.js +45 -16
  180. package/dist/native/index.native243.js +2 -28
  181. package/dist/native/index.native244.js +2 -8
  182. package/dist/native/index.native245.js +2 -11
  183. package/dist/native/index.native246.js +16 -11
  184. package/dist/native/index.native247.js +28 -10
  185. package/dist/native/index.native248.js +8 -17
  186. package/dist/native/index.native249.js +9 -79
  187. package/dist/native/index.native250.js +13 -2
  188. package/dist/native/index.native251.js +10 -2
  189. package/dist/native/index.native252.js +15 -2
  190. package/dist/native/index.native253.js +81 -2
  191. package/dist/native/index.native256.js +1 -1
  192. package/dist/native/index.native3.js +1 -1
  193. package/dist/native/index.native66.js +24 -22
  194. package/dist/native/index.native67.js +15 -19
  195. package/dist/native/index.native86.js +1 -1
  196. package/dist/native/index.native87.js +85 -64
  197. package/dist/native-types/actions/createBitcoinAccount.d.ts +5 -2
  198. package/dist/native-types/actions/getCurrentUser.d.ts +18 -1
  199. package/dist/native-types/actions/signBitcoinHash.d.ts +7 -5
  200. package/dist/native-types/core.d.ts +1 -1
  201. package/dist/native-types/types.d.ts +2 -2
  202. package/dist/native-types/version.d.ts +1 -1
  203. package/dist/types/actions/createBitcoinAccount.d.ts +5 -2
  204. package/dist/types/actions/getCurrentUser.d.ts +18 -1
  205. package/dist/types/actions/signBitcoinHash.d.ts +7 -5
  206. package/dist/types/core.d.ts +1 -1
  207. package/dist/types/types.d.ts +2 -2
  208. package/dist/types/version.d.ts +1 -1
  209. package/dist/web/index.web10.js +52 -51
  210. package/dist/web/index.web107.js +3 -3
  211. package/dist/web/index.web110.js +2 -2
  212. package/dist/web/index.web114.js +3 -3
  213. package/dist/web/index.web127.js +13 -373
  214. package/dist/web/index.web128.js +22 -28
  215. package/dist/web/index.web129.js +50 -28
  216. package/dist/web/index.web130.js +373 -13
  217. package/dist/web/index.web131.js +28 -22
  218. package/dist/web/index.web132.js +28 -50
  219. package/dist/web/index.web133.js +1 -1
  220. package/dist/web/index.web134.js +1 -1
  221. package/dist/web/index.web138.js +1 -1
  222. package/dist/web/index.web139.js +1 -1
  223. package/dist/web/index.web142.js +13 -2
  224. package/dist/web/index.web143.js +12 -2
  225. package/dist/web/index.web144.js +54 -14
  226. package/dist/web/index.web145.js +10 -28
  227. package/dist/web/index.web146.js +2 -8
  228. package/dist/web/index.web147.js +45 -4
  229. package/dist/web/index.web148.js +13 -28
  230. package/dist/web/index.web149.js +4 -8
  231. package/dist/web/index.web150.js +2 -8
  232. package/dist/web/index.web151.js +2 -81
  233. package/dist/web/index.web152.js +4 -18
  234. package/dist/web/index.web153.js +28 -3
  235. package/dist/web/index.web154.js +7 -15
  236. package/dist/web/index.web155.js +3 -4
  237. package/dist/web/index.web156.js +19 -5
  238. package/dist/web/index.web157.js +8 -19
  239. package/dist/web/index.web158.js +7 -61
  240. package/dist/web/index.web159.js +79 -16
  241. package/dist/web/index.web160.js +24 -19
  242. package/dist/web/index.web161.js +3 -8
  243. package/dist/web/index.web162.js +6 -33
  244. package/dist/web/index.web163.js +4 -7
  245. package/dist/web/index.web164.js +14 -20
  246. package/dist/web/index.web165.js +18 -53
  247. package/dist/web/index.web166.js +61 -10
  248. package/dist/web/index.web167.js +18 -2
  249. package/dist/web/index.web168.js +23 -44
  250. package/dist/web/index.web169.js +8 -13
  251. package/dist/web/index.web170.js +41 -11
  252. package/dist/web/index.web171.js +7 -11
  253. package/dist/web/index.web172.js +20 -4
  254. package/dist/web/index.web191.js +1 -1
  255. package/dist/web/index.web193.js +1 -1
  256. package/dist/web/index.web194.js +2 -2
  257. package/dist/web/index.web202.js +2 -2
  258. package/dist/web/index.web21.js +16 -5
  259. package/dist/web/index.web219.js +102 -19
  260. package/dist/web/index.web220.js +79 -10
  261. package/dist/web/index.web221.js +79 -20
  262. package/dist/web/index.web222.js +20 -93
  263. package/dist/web/index.web223.js +9 -20
  264. package/dist/web/index.web224.js +16 -114
  265. package/dist/web/index.web225.js +89 -99
  266. package/dist/web/index.web226.js +20 -78
  267. package/dist/web/index.web227.js +118 -79
  268. package/dist/web/index.web228.js +2 -109
  269. package/dist/web/index.web229.js +109 -2
  270. package/dist/web/index.web230.js +2 -2
  271. package/dist/web/index.web237.js +1 -1
  272. package/dist/web/index.web242.js +1 -1
  273. package/dist/web/index.web244.js +1 -1
  274. package/dist/web/index.web247.js +1 -1
  275. package/dist/web/index.web248.js +1 -1
  276. package/dist/web/index.web250.js +78 -14
  277. package/dist/web/index.web251.js +14 -78
  278. package/dist/web/index.web64.js +24 -22
  279. package/dist/web/index.web65.js +13 -17
  280. package/dist/web/index.web85.js +85 -64
  281. package/dist/web/index.web9.js +1 -1
  282. package/dist/web-types/actions/createBitcoinAccount.d.ts +5 -2
  283. package/dist/web-types/actions/getCurrentUser.d.ts +18 -1
  284. package/dist/web-types/actions/signBitcoinHash.d.ts +7 -5
  285. package/dist/web-types/core.d.ts +1 -1
  286. package/dist/web-types/types.d.ts +2 -2
  287. package/dist/web-types/version.d.ts +1 -1
  288. package/package.json +3 -3
@@ -1,4 +1,83 @@
1
- var r = { exports: {} };
1
+ import { JOSENotSupported as s } from "./index.native135.js";
2
+ function n(e) {
3
+ let a, r;
4
+ switch (e.kty) {
5
+ case "RSA": {
6
+ switch (e.alg) {
7
+ case "PS256":
8
+ case "PS384":
9
+ case "PS512":
10
+ a = { name: "RSA-PSS", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
11
+ break;
12
+ case "RS256":
13
+ case "RS384":
14
+ case "RS512":
15
+ a = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
16
+ break;
17
+ case "RSA-OAEP":
18
+ case "RSA-OAEP-256":
19
+ case "RSA-OAEP-384":
20
+ case "RSA-OAEP-512":
21
+ a = {
22
+ name: "RSA-OAEP",
23
+ hash: `SHA-${parseInt(e.alg.slice(-3), 10) || 1}`
24
+ }, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
25
+ break;
26
+ default:
27
+ throw new s('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
28
+ }
29
+ break;
30
+ }
31
+ case "EC": {
32
+ switch (e.alg) {
33
+ case "ES256":
34
+ a = { name: "ECDSA", namedCurve: "P-256" }, r = e.d ? ["sign"] : ["verify"];
35
+ break;
36
+ case "ES384":
37
+ a = { name: "ECDSA", namedCurve: "P-384" }, r = e.d ? ["sign"] : ["verify"];
38
+ break;
39
+ case "ES512":
40
+ a = { name: "ECDSA", namedCurve: "P-521" }, r = e.d ? ["sign"] : ["verify"];
41
+ break;
42
+ case "ECDH-ES":
43
+ case "ECDH-ES+A128KW":
44
+ case "ECDH-ES+A192KW":
45
+ case "ECDH-ES+A256KW":
46
+ a = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
47
+ break;
48
+ default:
49
+ throw new s('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
50
+ }
51
+ break;
52
+ }
53
+ case "OKP": {
54
+ switch (e.alg) {
55
+ case "Ed25519":
56
+ case "EdDSA":
57
+ a = { name: "Ed25519" }, r = e.d ? ["sign"] : ["verify"];
58
+ break;
59
+ case "ECDH-ES":
60
+ case "ECDH-ES+A128KW":
61
+ case "ECDH-ES+A192KW":
62
+ case "ECDH-ES+A256KW":
63
+ a = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
64
+ break;
65
+ default:
66
+ throw new s('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
67
+ }
68
+ break;
69
+ }
70
+ default:
71
+ throw new s('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
72
+ }
73
+ return { algorithm: a, keyUsages: r };
74
+ }
75
+ const i = async (e) => {
76
+ if (!e.alg)
77
+ throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
78
+ const { algorithm: a, keyUsages: r } = n(e), t = { ...e };
79
+ return delete t.alg, delete t.use, crypto.subtle.importKey("jwk", t, a, e.ext ?? !e.d, e.key_ops ?? r);
80
+ };
2
81
  export {
3
- r as __module
82
+ i as default
4
83
  };
@@ -1,4 +1,4 @@
1
- import { SizeExceedsPaddingSizeError as a } from "./index.native236.js";
1
+ import { SizeExceedsPaddingSizeError as a } from "./index.native242.js";
2
2
  function o(r, i = {}) {
3
3
  const { dir: n, size: e = 32 } = i;
4
4
  if (e === 0)
@@ -1,2 +1,2 @@
1
- import { __require as r } from "./index.native227.js";
1
+ import { __require as r } from "./index.native232.js";
2
2
  r();
@@ -1,37 +1,39 @@
1
- import { createEndUserBtcAccount as u } from "@coinbase/cdp-api-client";
2
- import { Analytics as d } from "./index.native2.js";
1
+ import { createEndUserBtcAccount as h } from "@coinbase/cdp-api-client";
2
+ import { Analytics as p } from "./index.native2.js";
3
3
  import "./index.native3.js";
4
4
  import { toAuthStateUser as m } from "./index.native103.js";
5
- import { InternalError as l } from "./index.native90.js";
6
- import { validateUserAuthState as p } from "./index.native104.js";
7
- import { getCoreAuthManager as w, getConfig as h } from "./index.native76.js";
8
- async function U(e) {
9
- d.sendActionCallEvent({ name: "create_bitcoin_account" });
10
- const t = w(), { user: c, authState: a } = p(
5
+ import { InternalError as o } from "./index.native90.js";
6
+ import { validateUserAuthState as w } from "./index.native104.js";
7
+ import { getCoreAuthManager as b, getConfig as A } from "./index.native76.js";
8
+ async function U(r) {
9
+ p.sendActionCallEvent({ name: "create_bitcoin_account" });
10
+ const t = b(), { user: c, authState: s } = w(
11
11
  t.getUser(),
12
12
  t.getAuthState()
13
- ), i = await u(
13
+ ), n = await h(
14
14
  c.userId,
15
15
  {
16
16
  walletSecretId: await t.getWalletSecretId(),
17
- addressType: e?.addressType ?? "segwit",
18
- network: e?.network ?? "bitcoin-testnet"
17
+ addressType: r?.addressType ?? "segwit",
18
+ network: r?.network ?? "bitcoin-testnet"
19
19
  },
20
- { projectID: h().projectId },
21
- e?.idempotencyKey
22
- ), n = m(i);
20
+ { projectID: A().projectId },
21
+ r?.idempotencyKey
22
+ ), i = m(n), u = t.getAuthState() ?? s;
23
23
  await t.setAuthState({
24
- ...a,
25
- user: n
24
+ ...u,
25
+ user: i
26
26
  });
27
- const s = new Set(c.btcAccountObjects?.map((r) => r.extendedPublicKey) ?? []), o = n.btcAccountObjects?.find(
28
- (r) => !s.has(r.extendedPublicKey)
29
- );
30
- if (!o)
31
- throw new l(
27
+ const d = new Set(c.btcAccountObjects?.map((a) => a.xpubHash) ?? []), e = (n.btcAccountObjects ?? []).find((a) => !d.has(a.xpubHash));
28
+ if (!e)
29
+ throw new o(
32
30
  "Bitcoin account was not created. Check the network log for more details."
33
31
  );
34
- return o;
32
+ if (!e.xpub)
33
+ throw new o(
34
+ "Bitcoin account was created but the server did not return its extended public key (xpub)."
35
+ );
36
+ return { ...e, xpub: e.xpub };
35
37
  }
36
38
  export {
37
39
  U as createBitcoinAccount
@@ -1,41 +1,37 @@
1
- import { signBtcHashWithEndUserAccount as i } from "@coinbase/cdp-api-client";
2
- import { Analytics as c } from "./index.native2.js";
1
+ import { signBtcHashWithEndUserAccount as c } from "@coinbase/cdp-api-client";
2
+ import { Analytics as s } from "./index.native2.js";
3
3
  import "./index.native3.js";
4
- import { withAuth as h } from "./index.native99.js";
5
- import { getConfig as o, getCoreAuthManager as d } from "./index.native76.js";
4
+ import { withAuth as i } from "./index.native99.js";
5
+ import { getConfig as e, getCoreAuthManager as o } from "./index.native76.js";
6
6
  import "viem";
7
- import { withMfa as m } from "./index.native85.js";
7
+ import { withMfa as h } from "./index.native85.js";
8
8
  import "jose";
9
9
  import "./index.native100.js";
10
10
  import "./index.native101.js";
11
11
  import "@solana/web3.js";
12
12
  import "bs58";
13
- const T = async (t) => {
14
- if (c.sendActionCallEvent({ name: "sign_bitcoin_hash" }), !/^[0-9a-fA-F]{64}$/.test(t.hash))
13
+ const E = async (t) => {
14
+ if (s.sendActionCallEvent({ name: "sign_bitcoin_hash" }), !/^[0-9a-fA-F]{64}$/.test(t.hash))
15
15
  throw new Error("hash must be a 64-character hex string with no 0x prefix");
16
- return o().useMock ? { signature: "3045022100" + "a".repeat(64) + "0220" + "b".repeat(64) } : m(
17
- () => h(t, d(), async ({ user: e, walletSecretId: a }) => {
18
- const r = t.network ?? "bitcoin-testnet", n = t.addressType ?? "segwit";
19
- if (!e.btcAccountObjects?.find(
20
- (s) => s.network === r && s.addressType === n
21
- ))
16
+ return e().useMock ? { signature: "3045022100" + "a".repeat(64) + "0220" + "b".repeat(64) } : h(
17
+ () => i(t, o(), async ({ user: r, walletSecretId: a }) => {
18
+ if (!r.btcAccountObjects?.find((n) => n.xpubHash === t.xpubHash))
22
19
  throw new Error("Bitcoin account not found");
23
- return { signature: (await i(
24
- e.userId,
20
+ return { signature: (await c(
21
+ r.userId,
25
22
  {
26
23
  walletSecretId: a,
27
- addressType: n,
28
- network: r,
24
+ xpubHash: t.xpubHash,
29
25
  change: t.change,
30
26
  addressIndex: t.addressIndex,
31
27
  hash: t.hash
32
28
  },
33
- { projectID: o().projectId },
29
+ { projectID: e().projectId },
34
30
  t.idempotencyKey
35
31
  )).signature };
36
32
  })
37
33
  );
38
34
  };
39
35
  export {
40
- T as signBitcoinHash
36
+ E as signBitcoinHash
41
37
  };
@@ -1,4 +1,4 @@
1
- import { createSolanaKeyExportIframe as t, createEvmKeyExportIframe as m } from "./index.native138.js";
1
+ import { createSolanaKeyExportIframe as t, createEvmKeyExportIframe as m } from "./index.native133.js";
2
2
  import { signBitcoinHash as i } from "./index.native67.js";
3
3
  import "@coinbase/cdp-api-client";
4
4
  import "./index.native2.js";
@@ -1,42 +1,42 @@
1
- import { logOutEndUser as f, refreshAccessToken as d, registerTemporaryWalletSecret as S, APIError as m } from "@coinbase/cdp-api-client";
2
- import { Analytics as h } from "./index.native2.js";
1
+ import { logOutEndUser as f, refreshAccessToken as d, isRefreshTokenUnavailableError as m, isTransientTokenReadError as S, registerTemporaryWalletSecret as w, APIError as y } from "@coinbase/cdp-api-client";
2
+ import { Analytics as i } from "./index.native2.js";
3
3
  import "./index.native3.js";
4
4
  import "jose";
5
- import { SignJWT as w } from "./index.native109.js";
6
- import { toAuthState as y } from "./index.native103.js";
5
+ import { SignJWT as _ } from "./index.native109.js";
6
+ import { toAuthState as k } from "./index.native103.js";
7
7
  import "viem";
8
8
  import { getPlatformCrypto as c } from "./index.native10.js";
9
9
  import { sortKeys as p } from "./index.native100.js";
10
- import { getCoreOAuthManager as g } from "./index.native76.js";
11
- const l = 60 * 1e3, k = {
10
+ import { getCoreOAuthManager as T } from "./index.native76.js";
11
+ const l = 60 * 1e3, R = {
12
12
  maxRetries: 3,
13
13
  baseDelayMs: 1e3,
14
14
  maxDelayMs: 1e4
15
15
  };
16
- function T(t, e, s) {
17
- const n = e * Math.pow(2, t), i = Math.random() * 0.3 * n;
18
- return Math.min(n + i, s);
16
+ function g(s, e, r) {
17
+ const n = e * Math.pow(2, s), o = Math.random() * 0.3 * n;
18
+ return Math.min(n + o, r);
19
19
  }
20
- function R(t) {
21
- return new Promise((e) => setTimeout(e, t));
20
+ function A(s) {
21
+ return new Promise((e) => setTimeout(e, s));
22
22
  }
23
- function _(t) {
24
- if (t instanceof TypeError && t.message.includes("fetch"))
23
+ function E(s) {
24
+ if (s instanceof TypeError && s.message.includes("fetch"))
25
25
  return !0;
26
- if (t instanceof m) {
27
- if (t.statusCode >= 500 && t.statusCode < 600 || t.statusCode === 408 || t.statusCode === 429)
26
+ if (s instanceof y) {
27
+ if (s.statusCode >= 500 && s.statusCode < 600 || s.statusCode === 408 || s.statusCode === 429)
28
28
  return !0;
29
- if (t.statusCode === 401)
29
+ if (s.statusCode === 401)
30
30
  return !1;
31
31
  }
32
- if (t instanceof Error) {
33
- const e = t.message.toLowerCase();
32
+ if (s instanceof Error) {
33
+ const e = s.message.toLowerCase();
34
34
  if (e.includes("network") || e.includes("timeout") || e.includes("econnrefused") || e.includes("enotfound") || e.includes("socket"))
35
35
  return !0;
36
36
  }
37
37
  return !1;
38
38
  }
39
- class v {
39
+ class j {
40
40
  projectId;
41
41
  authState = null;
42
42
  walletSecret = null;
@@ -139,14 +139,14 @@ class v {
139
139
  if (!await this.isSignedIn())
140
140
  throw new Error("Cannot get X-Wallet-Auth header if the user is not signed in");
141
141
  this.shouldRefreshWalletSecret() && await this.refreshWalletSecret();
142
- const s = `${e.requestMethod} ${e.requestHost}${e.requestPath}`, n = Math.floor(Date.now() / 1e3), i = c(), r = {
143
- uris: [s]
142
+ const r = `${e.requestMethod} ${e.requestHost}${e.requestPath}`, n = Math.floor(Date.now() / 1e3), o = c(), a = {
143
+ uris: [r]
144
144
  };
145
145
  if (e.requestData && Object.keys(e.requestData).length > 0) {
146
- const a = p(e.requestData);
147
- r.reqHash = await i.hash(new TextEncoder().encode(JSON.stringify(a)));
146
+ const t = p(e.requestData);
147
+ a.reqHash = await o.hash(new TextEncoder().encode(JSON.stringify(t)));
148
148
  }
149
- return await new w(r).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuedAt(n).setNotBefore(n).setJti(i.generateRandomId()).sign(this.walletSecret.keyPair.privateKey);
149
+ return await new _(a).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuedAt(n).setNotBefore(n).setJti(o.generateRandomId()).sign(this.walletSecret.keyPair.privateKey);
150
150
  }
151
151
  /**
152
152
  * Gets the authentication state.
@@ -162,13 +162,13 @@ class v {
162
162
  * @param authState - The authentication state.
163
163
  */
164
164
  async setAuthState(e) {
165
- this.authState = e, h.endUserIdentifier = e.user.userId, this.authStateChangeCallbacks.forEach((s) => s(this.authState?.user ?? null)), this.scheduleTokenRefresh();
165
+ this.authState = e, i.endUserIdentifier = e.user.userId, this.authStateChangeCallbacks.forEach((r) => r(this.authState?.user ?? null)), this.scheduleTokenRefresh();
166
166
  }
167
167
  /**
168
168
  * Clears the authentication state.
169
169
  */
170
170
  async clearAuthState() {
171
- this.authState = null, this.walletSecret = null, h.endUserIdentifier = "", this.cancelTokenRefresh(), this.authStateChangeCallbacks.forEach((e) => e(null));
171
+ this.authState = null, this.walletSecret = null, i.endUserIdentifier = "", this.cancelTokenRefresh(), this.authStateChangeCallbacks.forEach((e) => e(null));
172
172
  }
173
173
  /**
174
174
  * Ensures the AuthManager is initialized before proceeding.
@@ -186,7 +186,7 @@ class v {
186
186
  */
187
187
  async _doInitialize() {
188
188
  try {
189
- await this.refreshAccessToken("init"), await g().handleOAuthCode();
189
+ await this.refreshAccessToken("init"), await T().handleOAuthCode();
190
190
  } catch (e) {
191
191
  console.warn("Failed to refresh access token during initialization:", e);
192
192
  }
@@ -210,57 +210,78 @@ class v {
210
210
  * @returns The new access token.
211
211
  */
212
212
  async refreshAccessToken(e = "on_demand") {
213
- const { maxRetries: s, baseDelayMs: n, maxDelayMs: i } = k;
214
- h.sendSessionRefreshEvent({
213
+ const { maxRetries: r, baseDelayMs: n, maxDelayMs: o } = R;
214
+ i.sendSessionRefreshEvent({
215
215
  name: "refresh_token_start",
216
216
  trigger: e
217
217
  });
218
- for (let r = 0; r <= s; r++)
218
+ for (let a = 0; a <= r; a++)
219
219
  try {
220
- const a = await d(this.projectId, {
220
+ const t = await d(this.projectId, {
221
221
  grantType: "refresh_token"
222
- }), o = y(
223
- a.accessToken,
224
- a.validUntil,
225
- a.endUser
222
+ }), h = k(
223
+ t.accessToken,
224
+ t.validUntil,
225
+ t.endUser
226
226
  );
227
- await this.setAuthState(o), h.sendSessionRefreshEvent({
227
+ await this.setAuthState(h), i.sendSessionRefreshEvent({
228
228
  name: "refresh_token_success",
229
229
  trigger: e,
230
- attempt: r
230
+ attempt: a
231
231
  });
232
232
  return;
233
- } catch (a) {
234
- const o = a instanceof Error ? a.message : String(a);
235
- if (!_(a)) {
236
- h.sendSessionRefreshEvent({
233
+ } catch (t) {
234
+ const h = t instanceof Error ? t.message : String(t);
235
+ if (m(t)) {
236
+ if (S(t)) {
237
+ i.sendSessionRefreshEvent({
238
+ name: "refresh_token_skipped_transient",
239
+ trigger: e,
240
+ attempt: a,
241
+ read_outcome: t.outcome,
242
+ error_message: h
243
+ });
244
+ return;
245
+ }
246
+ i.sendSessionRefreshEvent({
237
247
  name: "refresh_token_failure",
238
248
  trigger: e,
239
- attempt: r,
249
+ attempt: a,
240
250
  error_type: "non_transient",
241
- error_message: o
251
+ read_outcome: t.outcome,
252
+ error_message: h
242
253
  }), await this.signOut();
243
254
  return;
244
255
  }
245
- if (r === s) {
246
- h.sendSessionRefreshEvent({
256
+ if (!E(t)) {
257
+ i.sendSessionRefreshEvent({
258
+ name: "refresh_token_failure",
259
+ trigger: e,
260
+ attempt: a,
261
+ error_type: "non_transient",
262
+ error_message: h
263
+ }), await this.signOut();
264
+ return;
265
+ }
266
+ if (a === r) {
267
+ i.sendSessionRefreshEvent({
247
268
  name: "refresh_token_exhausted",
248
269
  trigger: e,
249
- attempt: r,
270
+ attempt: a,
250
271
  error_type: "transient",
251
- error_message: o
272
+ error_message: h
252
273
  });
253
274
  return;
254
275
  }
255
- h.sendSessionRefreshEvent({
276
+ i.sendSessionRefreshEvent({
256
277
  name: "refresh_token_retry",
257
278
  trigger: e,
258
- attempt: r,
279
+ attempt: a,
259
280
  error_type: "transient",
260
- error_message: o
281
+ error_message: h
261
282
  });
262
- const u = T(r, n, i);
263
- await R(u);
283
+ const u = g(a, n, o);
284
+ await A(u);
264
285
  }
265
286
  }
266
287
  /**
@@ -270,13 +291,13 @@ class v {
270
291
  scheduleTokenRefresh() {
271
292
  if (this.cancelTokenRefresh(), !this.authState)
272
293
  return;
273
- const s = this.authState.expiresAt - l - Date.now();
274
- s <= 0 || (h.sendSessionRefreshEvent({
294
+ const r = this.authState.expiresAt - l - Date.now();
295
+ r <= 0 || (i.sendSessionRefreshEvent({
275
296
  name: "refresh_token_scheduled",
276
- time_until_refresh_ms: s
297
+ time_until_refresh_ms: r
277
298
  }), this.refreshTimeout = setTimeout(async () => {
278
299
  await this.refreshAccessToken("scheduled"), this.scheduleTokenRefresh();
279
- }, s));
300
+ }, r));
280
301
  }
281
302
  /**
282
303
  * Cancels any scheduled token refresh.
@@ -313,23 +334,23 @@ class v {
313
334
  * Internal wallet secret refresh logic.
314
335
  */
315
336
  async _doRefreshWalletSecret() {
316
- const e = c(), s = this.walletSecret?.walletSecretId ?? e.generateRandomId(), n = this.walletSecret?.keyPair ?? await e.createKeyPair(), i = this.authState.expiresAt, r = new Date(i).toISOString();
317
- this.walletSecret = { walletSecretId: s, keyPair: n, expiresAt: i };
337
+ const e = c(), r = this.walletSecret?.walletSecretId ?? e.generateRandomId(), n = this.walletSecret?.keyPair ?? await e.createKeyPair(), o = this.authState.expiresAt, a = new Date(o).toISOString();
338
+ this.walletSecret = { walletSecretId: r, keyPair: n, expiresAt: o };
318
339
  try {
319
- await S(
340
+ await w(
320
341
  this.authState.user.userId,
321
342
  {
322
- walletSecretId: s,
343
+ walletSecretId: r,
323
344
  publicKey: n.publicKeyBase64,
324
- validUntil: r
345
+ validUntil: a
325
346
  },
326
347
  { projectID: this.projectId }
327
348
  );
328
- } catch (a) {
329
- throw this.walletSecret = null, a;
349
+ } catch (t) {
350
+ throw this.walletSecret = null, t;
330
351
  }
331
352
  }
332
353
  }
333
354
  export {
334
- v as AuthManager
355
+ j as AuthManager
335
356
  };
@@ -11,9 +11,12 @@ export type CreateBitcoinAccountOptions = {
11
11
  idempotencyKey?: string;
12
12
  };
13
13
  /**
14
- * The result of creating a Bitcoin HD account.
14
+ * The result of creating a Bitcoin HD account. The extended public key (xpub) is always present,
15
+ * since the create response includes it and the caller needs it to derive child addresses.
15
16
  */
16
- export type CreateBitcoinAccountResult = EndUserBtcAccount;
17
+ export type CreateBitcoinAccountResult = EndUserBtcAccount & {
18
+ xpub: string;
19
+ };
17
20
  /**
18
21
  * Creates a Bitcoin HD (Hierarchical Deterministic) account for the current user.
19
22
  * The account uses BIP-84 derivation (segwit) and returns an extended public key (xpub)
@@ -1,11 +1,28 @@
1
1
  import { User } from '../types.js';
2
+ /**
3
+ * Options for getting the current user.
4
+ */
5
+ export type GetCurrentUserOptions = {
6
+ /**
7
+ * When true, re-fetches the user from the API with each Bitcoin account's raw extended public
8
+ * key (xpub) included in `btcAccountObjects`. By default the xpubs are omitted (hash-only), so
9
+ * request this when you need to derive child addresses. Ignored if no user is signed in.
10
+ */
11
+ includeBtcXpubs?: boolean;
12
+ };
2
13
  /**
3
14
  * Gets the currently signed-in user, if any.
4
15
  *
5
16
  * @example
6
17
  * ```typescript lines
7
18
  * const user = await getCurrentUser();
19
+ *
20
+ * // Include Bitcoin xpubs so addresses can be derived:
21
+ * const userWithXpubs = await getCurrentUser({ includeBtcXpubs: true });
8
22
  * ```
23
+ * @param options - Optional settings controlling what is returned.
9
24
  * @returns The currently signed-in user, or null if no user is signed in.
25
+ * @throws When `includeBtcXpubs` is true and the network request to re-fetch the user fails.
26
+ * The default (cached) read never throws.
10
27
  */
11
- export declare const getCurrentUser: () => Promise<User | null>;
28
+ export declare const getCurrentUser: (options?: GetCurrentUserOptions) => Promise<User | null>;
@@ -1,12 +1,14 @@
1
- import { SignBtcHashWithEndUserAccountBodyAddressType, SignBtcHashWithEndUserAccountBodyNetwork, SignBtcHashWithEndUserAccountBodyChange } from '@coinbase/cdp-api-client';
1
+ import { SignBtcHashWithEndUserAccountBodyChange } from '@coinbase/cdp-api-client';
2
2
  /**
3
3
  * Options for signing a Bitcoin sighash.
4
4
  */
5
5
  export type SignBitcoinHashOptions = {
6
- /** The Bitcoin network. Defaults to "bitcoin-testnet". */
7
- network?: SignBtcHashWithEndUserAccountBodyNetwork;
8
- /** The Bitcoin address type. Defaults to "segwit". */
9
- addressType?: SignBtcHashWithEndUserAccountBodyAddressType;
6
+ /**
7
+ * Selects which Bitcoin account to sign with, as the `xpubHash` from the account's entry in
8
+ * `btcAccountObjects`. Resolved server-side against the user's own accounts; an unmatched hash
9
+ * fails with a not-found error (there is no fallback to a default account).
10
+ */
11
+ xpubHash: string;
10
12
  /** BIP-32 change level: 0 for external (receive) addresses, 1 for internal (change) addresses. */
11
13
  change: SignBtcHashWithEndUserAccountBodyChange;
12
14
  /** BIP-32 address index — must match the index used to derive the address controlling the UTXO. */
@@ -9,7 +9,7 @@ export { verifyOAuth } from './actions/verifyOAuth.js';
9
9
  export { verifySiweSignature, type VerifySiweSignatureOptions, type VerifySiweSignatureResult, } from './actions/verifySiweSignature.js';
10
10
  export { verifyTelegramOAuth } from './actions/verifyTelegramOAuth.js';
11
11
  export { authenticateWithJWT } from './actions/authenticateWithJWT.js';
12
- export { getCurrentUser } from './actions/getCurrentUser.js';
12
+ export { getCurrentUser, type GetCurrentUserOptions } from './actions/getCurrentUser.js';
13
13
  export { isSignedIn } from './actions/isSignedIn.js';
14
14
  export { signOut } from './actions/signOut.js';
15
15
  export { getAccessToken } from './actions/getAccessToken.js';
@@ -23,7 +23,7 @@ type MFAMethods,
23
23
  type EndUserEvmAccount,
24
24
  /** Solana account object with address and createdAt */
25
25
  type EndUserSolanaAccount,
26
- /** Bitcoin HD account object with extendedPublicKey (xpub), network, and addressType */
26
+ /** Bitcoin HD account object with xpubHash, network, addressType, and optional xpub */
27
27
  type EndUserBtcAccount,
28
28
  /** Bitcoin network for account creation */
29
29
  type CreateEndUserBtcAccountBodyNetwork,
@@ -203,7 +203,7 @@ export type User = {
203
203
  evmSmartAccountObjects?: EndUserEvmSmartAccount[];
204
204
  /** The Solana account objects associated with the user. Users can have up to 10 Solana accounts. */
205
205
  solanaAccountObjects?: EndUserSolanaAccount[];
206
- /** The Bitcoin HD account objects associated with the user. One per addressType+network combination. */
206
+ /** The Bitcoin HD account objects associated with the user. Up to 10 per user. */
207
207
  btcAccountObjects?: EndUserBtcAccount[];
208
208
  /** The MFA methods enrolled for the user. */
209
209
  mfaMethods?: MFAMethods;
@@ -2,4 +2,4 @@
2
2
  * Current version of @coinbase/cdp-core package.
3
3
  * This file is auto-generated by scripts/sync-versions.js
4
4
  */
5
- export declare const VERSION = "0.0.118";
5
+ export declare const VERSION = "0.0.120";
@@ -11,9 +11,12 @@ export type CreateBitcoinAccountOptions = {
11
11
  idempotencyKey?: string;
12
12
  };
13
13
  /**
14
- * The result of creating a Bitcoin HD account.
14
+ * The result of creating a Bitcoin HD account. The extended public key (xpub) is always present,
15
+ * since the create response includes it and the caller needs it to derive child addresses.
15
16
  */
16
- export type CreateBitcoinAccountResult = EndUserBtcAccount;
17
+ export type CreateBitcoinAccountResult = EndUserBtcAccount & {
18
+ xpub: string;
19
+ };
17
20
  /**
18
21
  * Creates a Bitcoin HD (Hierarchical Deterministic) account for the current user.
19
22
  * The account uses BIP-84 derivation (segwit) and returns an extended public key (xpub)
@@ -1,11 +1,28 @@
1
1
  import { User } from '../types.js';
2
+ /**
3
+ * Options for getting the current user.
4
+ */
5
+ export type GetCurrentUserOptions = {
6
+ /**
7
+ * When true, re-fetches the user from the API with each Bitcoin account's raw extended public
8
+ * key (xpub) included in `btcAccountObjects`. By default the xpubs are omitted (hash-only), so
9
+ * request this when you need to derive child addresses. Ignored if no user is signed in.
10
+ */
11
+ includeBtcXpubs?: boolean;
12
+ };
2
13
  /**
3
14
  * Gets the currently signed-in user, if any.
4
15
  *
5
16
  * @example
6
17
  * ```typescript lines
7
18
  * const user = await getCurrentUser();
19
+ *
20
+ * // Include Bitcoin xpubs so addresses can be derived:
21
+ * const userWithXpubs = await getCurrentUser({ includeBtcXpubs: true });
8
22
  * ```
23
+ * @param options - Optional settings controlling what is returned.
9
24
  * @returns The currently signed-in user, or null if no user is signed in.
25
+ * @throws When `includeBtcXpubs` is true and the network request to re-fetch the user fails.
26
+ * The default (cached) read never throws.
10
27
  */
11
- export declare const getCurrentUser: () => Promise<User | null>;
28
+ export declare const getCurrentUser: (options?: GetCurrentUserOptions) => Promise<User | null>;