@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,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.web2.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.web2.js";
3
3
  import "./index.web3.js";
4
4
  import "jose";
5
- import { SignJWT as w } from "./index.web107.js";
6
- import { toAuthState as y } from "./index.web101.js";
5
+ import { SignJWT as _ } from "./index.web107.js";
6
+ import { toAuthState as k } from "./index.web101.js";
7
7
  import "viem";
8
8
  import { getPlatformCrypto as c } from "./index.web5.js";
9
9
  import { sortKeys as p } from "./index.web98.js";
10
- import { getCoreOAuthManager as g } from "./index.web74.js";
11
- const l = 60 * 1e3, k = {
10
+ import { getCoreOAuthManager as T } from "./index.web74.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
  };
@@ -1,4 +1,4 @@
1
- const o = "0.0.118";
1
+ const o = "0.0.120";
2
2
  export {
3
3
  o as VERSION
4
4
  };
@@ -1,6 +1,6 @@
1
- import { CompactSign as i } from "./index.native135.js";
2
- import { JWTInvalid as r } from "./index.native136.js";
3
- import { JWTClaimsBuilder as n } from "./index.native137.js";
1
+ import { CompactSign as i } from "./index.native134.js";
2
+ import { JWTInvalid as r } from "./index.native135.js";
3
+ import { JWTClaimsBuilder as n } from "./index.native136.js";
4
4
  class d {
5
5
  #s;
6
6
  #t;
@@ -1,4 +1,4 @@
1
- const o = "0.0.118";
1
+ const o = "0.0.120";
2
2
  export {
3
3
  o as VERSION
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { DisconnectedError as l, from as d } from "./index.native129.js";
2
2
  import { validateRequest as h, EIP1193ProviderError as m, STANDARD_ERROR_CODES as _ } from "./index.native93.js";
3
- import { createEOAHandlers as p } from "./index.native133.js";
4
- import { createSmartAccountHandlers as g } from "./index.native134.js";
3
+ import { createEOAHandlers as p } from "./index.native137.js";
4
+ import { createSmartAccountHandlers as g } from "./index.native138.js";
5
5
  import "viem";
6
6
  import "zustand";
7
7
  import "@coinbase/cdp-api-client";
@@ -1,26 +1,26 @@
1
- import { configureCdpApiClient as j, setAuthManager as v, getMfaConfig as C, APIError as g, getProjectConfig as M } from "@coinbase/cdp-api-client";
2
- import { Analytics as c } from "./index.native2.js";
1
+ import { configureCdpApiClient as C, setAuthManager as M, getMfaConfig as v, APIError as m, getProjectConfig as S } from "@coinbase/cdp-api-client";
2
+ import { Analytics as d } from "./index.native2.js";
3
3
  import "./index.native3.js";
4
- import { createAuthManager as S } from "./index.native117.js";
5
- import { OAuthManager as y } from "./index.native118.js";
6
- import { MockAuthManager as w } from "./index.native119.js";
7
- import { MockOAuthManager as P } from "./index.native120.js";
8
- import { getAttestationModule as _ } from "./index.native95.js";
9
- import { getPlatformServices as m } from "./index.native10.js";
10
- import { getConfig as i, setCoreAuthManager as h, setCoreOAuthManager as I, setMfaConfig as A, setProjectConfig as k, getCoreAuthManager as O, setConfig as R } from "./index.native76.js";
4
+ import { createAuthManager as y } from "./index.native117.js";
5
+ import { OAuthManager as w } from "./index.native118.js";
6
+ import { MockAuthManager as P } from "./index.native119.js";
7
+ import { MockOAuthManager as _ } from "./index.native120.js";
8
+ import { getAttestationModule as O } from "./index.native95.js";
9
+ import { getPlatformServices as h } from "./index.native10.js";
10
+ import { getConfig as i, setCoreAuthManager as I, setCoreOAuthManager as A, setMfaConfig as k, setProjectConfig as b, getCoreAuthManager as R, setConfig as E } from "./index.native76.js";
11
11
  import "viem";
12
- const U = async (t) => {
12
+ const V = async (t) => {
13
13
  if (!t.projectId)
14
14
  throw new Error("Project ID is required");
15
- t.disableAnalytics === void 0 || t.disableAnalytics === !1 ? (c.developerIdentifier = t.projectId, c.isUsingMocks = t.useMock === !0, c.isProduction = !t.basePath || t.basePath === "https://api.cdp.coinbase.com/platform") : c.enabled = !1;
15
+ t.disableAnalytics === void 0 || t.disableAnalytics === !1 ? (d.developerIdentifier = t.projectId, d.isUsingMocks = t.useMock === !0, d.isProduction = !t.basePath || t.basePath === "https://api.cdp.coinbase.com/platform") : d.enabled = !1;
16
16
  let a;
17
17
  try {
18
18
  a = i().projectId !== t.projectId;
19
19
  } catch {
20
20
  a = !0;
21
21
  }
22
- if (R(t), i().useMock) {
23
- h(new w(i().projectId)), I(new P()), A({
22
+ if (E(t), i().useMock) {
23
+ I(new P(i().projectId)), A(new _()), k({
24
24
  projectId: i().projectId,
25
25
  enabled: !1,
26
26
  totpConfig: { enabled: !1 },
@@ -30,7 +30,7 @@ const U = async (t) => {
30
30
  requireVerificationOnLogin: !1,
31
31
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
33
- }), k({
33
+ }), b({
34
34
  projectId: i().projectId,
35
35
  name: "Mock Project",
36
36
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -38,87 +38,88 @@ const U = async (t) => {
38
38
  });
39
39
  return;
40
40
  }
41
- let o, s = !1;
41
+ let o, c = !1, s = !1;
42
42
  try {
43
- const e = m();
44
- e.secureStorage ? (s = !0, o = {
43
+ const e = h();
44
+ e.secureStorage ? (c = !0, s = !0, o = {
45
45
  getRefreshToken: () => e.secureStorage.getItem("cdp_refresh_token"),
46
- getRefreshTokenWithOutcome: () => b(e.secureStorage),
46
+ getRefreshTokenWithOutcome: () => j(e.secureStorage),
47
47
  setRefreshToken: (n) => e.secureStorage.setItem("cdp_refresh_token", n),
48
48
  removeRefreshToken: () => e.secureStorage.removeItem("cdp_refresh_token")
49
49
  }) : o = {
50
50
  getRefreshToken: () => e.storage.getItem("cdp_refresh_token"),
51
- getRefreshTokenWithOutcome: () => b(e.storage),
51
+ getRefreshTokenWithOutcome: () => j(e.storage),
52
52
  setRefreshToken: (n) => e.storage.setItem("cdp_refresh_token", n),
53
53
  removeRefreshToken: () => e.storage.removeItem("cdp_refresh_token")
54
54
  };
55
55
  } catch {
56
- c.sendSessionRefreshEvent({
56
+ d.sendSessionRefreshEvent({
57
57
  name: "refresh_token_storage_not_initialized"
58
58
  }), o = void 0;
59
59
  }
60
- let r, d, p;
60
+ let r, f, p;
61
61
  try {
62
- const e = m();
63
- p = e.deviceInfo?.getPlatform?.(), e.attestation && (r = e.attestation, d = e.deviceInfo?.getAppBundleId?.());
62
+ const e = h();
63
+ p = e.deviceInfo?.getPlatform?.(), e.attestation && (r = e.attestation, f = e.deviceInfo?.getAppBundleId?.());
64
64
  } catch {
65
65
  r = void 0;
66
66
  }
67
- if (j({
67
+ if (C({
68
68
  debugging: i().debugging,
69
69
  basePath: i().basePath,
70
70
  refreshTokenStorage: o,
71
- retryTokenReads: s,
71
+ retryTokenReads: c,
72
+ failClosedOnMissingToken: s,
72
73
  platform: p,
73
74
  appAttestation: r && {
74
75
  isEnabled: () => r.isEnabled,
75
- appIdentifier: d,
76
+ appIdentifier: f,
76
77
  generateAssertion: r.generateAssertion.bind(r)
77
78
  }
78
79
  }), a) {
79
- const e = new y();
80
- I(e);
81
- const n = S(i().projectId);
82
- h(n), v(n);
80
+ const e = new w();
81
+ A(e);
82
+ const n = y(i().projectId);
83
+ I(n), M(n);
83
84
  }
84
- const [, f, l] = await Promise.allSettled([
85
- O().ensureInitialized(),
85
+ const [, l, u] = await Promise.allSettled([
86
+ R().ensureInitialized(),
86
87
  (async () => {
87
88
  try {
88
- return await C(t.projectId);
89
+ return await v(t.projectId);
89
90
  } catch (e) {
90
- return (!(e instanceof g) || e.statusCode !== 404) && console.warn("Failed to get MFA config", e), null;
91
+ return (!(e instanceof m) || e.statusCode !== 404) && console.warn("Failed to get MFA config", e), null;
91
92
  }
92
93
  })(),
93
94
  (async () => {
94
95
  try {
95
- return await M(t.projectId);
96
+ return await S(t.projectId);
96
97
  } catch (e) {
97
- return (!(e instanceof g) || e.statusCode !== 404) && console.warn("Failed to get project config", e), null;
98
+ return (!(e instanceof m) || e.statusCode !== 404) && console.warn("Failed to get project config", e), null;
98
99
  }
99
100
  })()
100
101
  ]);
101
- if (f.status === "fulfilled" && f.value && A(f.value), l.status === "fulfilled" && l.value) {
102
- const e = l.value;
103
- if (k(e), e.appAttestation && r && d) {
104
- const n = E(e.appAttestation, d);
105
- n !== null && (_() || console.warn(
102
+ if (l.status === "fulfilled" && l.value && k(l.value), u.status === "fulfilled" && u.value) {
103
+ const e = u.value;
104
+ if (b(e), e.appAttestation && r && f) {
105
+ const n = T(e.appAttestation, f);
106
+ n !== null && (O() || console.warn(
106
107
  "[Attestation] Project config has attestation enabled for this app, but no attestation provider is registered. Install @coinbase/cdp-app-attest and add `import '@coinbase/cdp-app-attest'` to your app's entry point."
107
- ), r.isEnabled = !0, r.cloudProjectNumber = n.cloudProjectNumber, r.initialize().catch((u) => {
108
+ ), r.isEnabled = !0, r.cloudProjectNumber = n.cloudProjectNumber, r.initialize().catch((g) => {
108
109
  console.error(
109
110
  "[Attestation] Background initialization failed:",
110
- u instanceof Error ? u.message : String(u)
111
+ g instanceof Error ? g.message : String(g)
111
112
  );
112
113
  }));
113
114
  }
114
115
  }
115
- }, b = async (t) => {
116
- const { value: a, outcome: o, errorMessage: s } = await t.getItemWithOutcome("cdp_refresh_token");
117
- return { token: a, outcome: o, errorMessage: s };
118
- }, E = (t, a) => {
119
- const o = t.android?.find((r) => r.identifier === a);
120
- return o ? { cloudProjectNumber: o.googleProjectNumber } : t.ios?.find((r) => r.identifier === a) ? {} : null;
116
+ }, j = async (t) => {
117
+ const { value: a, outcome: o, errorMessage: c } = await t.getItemWithOutcome("cdp_refresh_token");
118
+ return { token: a, outcome: o, errorMessage: c };
119
+ }, T = (t, a) => {
120
+ const o = t.android?.find((s) => s.identifier === a);
121
+ return o ? { cloudProjectNumber: o.googleProjectNumber } : t.ios?.find((s) => s.identifier === a) ? {} : null;
121
122
  };
122
123
  export {
123
- U as initialize
124
+ V as initialize
124
125
  };
@@ -1,15 +1,15 @@
1
- import { serializeAuthorizationList as v } from "./index.native182.js";
2
- import { blobsToCommitments as H } from "./index.native208.js";
3
- import { blobsToProofs as V } from "./index.native209.js";
4
- import { commitmentsToVersionedHashes as k } from "./index.native210.js";
5
- import { toBlobSidecars as B } from "./index.native211.js";
6
- import { concatHex as T } from "./index.native184.js";
7
- import { trim as F } from "./index.native190.js";
8
- import { numberToHex as s, bytesToHex as S } from "./index.native183.js";
9
- import { toRlp as b } from "./index.native194.js";
10
- import { assertTransactionEIP1559 as _, assertTransactionEIP2930 as C, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./index.native199.js";
11
- import { getTransactionType as q } from "./index.native205.js";
12
- import { serializeAccessList as h } from "./index.native207.js";
1
+ import { serializeAuthorizationList as v } from "./index.native159.js";
2
+ import { blobsToCommitments as H } from "./index.native185.js";
3
+ import { blobsToProofs as V } from "./index.native186.js";
4
+ import { commitmentsToVersionedHashes as k } from "./index.native187.js";
5
+ import { toBlobSidecars as B } from "./index.native188.js";
6
+ import { concatHex as T } from "./index.native161.js";
7
+ import { trim as F } from "./index.native167.js";
8
+ import { numberToHex as s, bytesToHex as S } from "./index.native160.js";
9
+ import { toRlp as b } from "./index.native171.js";
10
+ import { assertTransactionEIP1559 as _, assertTransactionEIP2930 as C, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./index.native176.js";
11
+ import { getTransactionType as q } from "./index.native182.js";
12
+ import { serializeAccessList as h } from "./index.native184.js";
13
13
  function re(e, t) {
14
14
  const i = q(e);
15
15
  return i === "eip1559" ? J(e, t) : i === "eip2930" ? K(e, t) : i === "eip4844" ? D(e, t) : i === "eip7702" ? w(e, t) : M(e);
@@ -1,31 +1,108 @@
1
- import { handleAccounts as t } from "./index.native155.js";
2
- import { handleEthSign as e } from "./index.native156.js";
3
- import { handleGetCallsStatus as a } from "./index.native157.js";
4
- import { handleGetCapabilities as n } from "./index.native158.js";
5
- import { handlePersonalSign as o } from "./index.native159.js";
6
- import { handleRequestAccounts as r } from "./index.native160.js";
7
- import { handleSendCalls as i } from "./index.native161.js";
8
- import { handleSendTransaction as l } from "./index.native162.js";
9
- import { handleSignTypedData as h } from "./index.native163.js";
10
- import { handleChainId as s } from "./index.native164.js";
11
- import { handleDisconnect as m } from "./index.native165.js";
12
- import { handleSwitchEthereumChain as d } from "./index.native166.js";
13
- function D() {
14
- return {
15
- eth_accounts: t,
16
- eth_requestAccounts: r,
17
- personal_sign: o,
18
- eth_sendTransaction: l,
19
- eth_signTypedData_v4: h,
20
- wallet_disconnect: m,
21
- wallet_switchEthereumChain: d,
22
- eth_sign: e,
23
- eth_chainId: s,
24
- wallet_sendCalls: i,
25
- wallet_getCallsStatus: a,
26
- wallet_getCapabilities: n
1
+ import { Analytics as u } from "./index.native2.js";
2
+ import "./index.native3.js";
3
+ import { getCurrentUserSync as b } from "./index.native46.js";
4
+ import "@coinbase/cdp-api-client";
5
+ import "jose";
6
+ import "viem";
7
+ import "./index.native100.js";
8
+ import { getConfig as S } from "./index.native76.js";
9
+ import { getAccessToken as A } from "./index.native26.js";
10
+ import { getAccessTokenExpiration as j } from "./index.native27.js";
11
+ import { ensureMfaVerified as y } from "./index.native85.js";
12
+ import { DEFAULT_SECURE_IFRAME_BASE_PATH as w, SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE as n, DEFAULT_SECURE_IFRAME_THEME as k } from "./index.native148.js";
13
+ import { validateSecureIframeEnvironment as g, createIframe as x, calculateSecureIframeHeight as U, buildKeyExportIframeUrl as L, getSecureIframeOrigin as v, isSecureIframeKeyExportMessage as R, sendSecureIframeMessage as l } from "./index.native149.js";
14
+ import "./index.native101.js";
15
+ import "@solana/web3.js";
16
+ import "bs58";
17
+ let c = null;
18
+ const C = async () => (c || (c = A({ forceRefresh: !0 }).finally(() => {
19
+ c = null;
20
+ })), c);
21
+ async function h(e) {
22
+ const r = x(e.target), I = U(e.theme), m = S().secureIframeBasePath || w;
23
+ r.setAttribute("allow", "clipboard-read; clipboard-write"), r.style.border = "none", r.style.display = "none", r.style.height = `${I}px`, r.src = L({ projectId: e.projectId, basePath: m });
24
+ const d = v(m);
25
+ let f = !1;
26
+ const E = () => {
27
+ f || (f = !0, window.removeEventListener("message", p), r.parentNode && r.parentNode.removeChild(r));
28
+ }, p = async (a) => {
29
+ if (a.source !== r.contentWindow || !d || a.origin !== d) return;
30
+ const i = a.data;
31
+ if (R(i))
32
+ switch (i.type) {
33
+ case n.LISTENING: {
34
+ try {
35
+ const t = b();
36
+ if (!t) {
37
+ e.onStatusUpdate?.("error", "User not authenticated");
38
+ return;
39
+ }
40
+ const o = await C(), s = await j();
41
+ l(r, {
42
+ type: n.GET_PRIVATE_KEY,
43
+ payload: {
44
+ address: e.address,
45
+ type: e.type,
46
+ authState: {
47
+ accessToken: o || "",
48
+ expiresAt: s || 0,
49
+ user: t
50
+ },
51
+ theme: {
52
+ ...k,
53
+ ...e.theme || {}
54
+ },
55
+ config: {
56
+ action: e.action,
57
+ label: e.label,
58
+ copiedLabel: e.copiedLabel,
59
+ ejectLabel: e.ejectLabel ?? "Eject wallet",
60
+ ejectingLabel: e.ejectingLabel ?? "Ejecting…",
61
+ ejectedLabel: e.ejectedLabel ?? "Ejected",
62
+ icon: e.icon,
63
+ ejectIcon: e.ejectIcon,
64
+ fullWidth: e.fullWidth
65
+ }
66
+ }
67
+ });
68
+ } catch (t) {
69
+ e.onStatusUpdate?.(
70
+ "error",
71
+ t instanceof Error ? "Error requesting private key: " + t.message : "Error requesting private key"
72
+ );
73
+ }
74
+ break;
75
+ }
76
+ case n.STATUS: {
77
+ const { status: t, message: o, operation: s, errorType: T, correlationId: _ } = i.payload;
78
+ t === "ready" && (r.style.display = "block"), t === "expired" && (r.style.display = "none", E()), e.onStatusUpdate?.(t, o, { operation: s, errorType: T, correlationId: _ });
79
+ break;
80
+ }
81
+ }
27
82
  };
83
+ return window.addEventListener("message", p), {
84
+ iframe: r,
85
+ cleanup: E,
86
+ updateTheme: (a) => {
87
+ l(r, {
88
+ type: n.THEME,
89
+ payload: { theme: a }
90
+ });
91
+ },
92
+ showEject: () => {
93
+ l(r, {
94
+ type: n.SHOW_EJECT
95
+ });
96
+ }
97
+ };
98
+ }
99
+ async function Q(e) {
100
+ return u.sendActionCallEvent({ name: "create_evm_key_export_iframe" }), g(), await y(), h({ ...e, type: "evm" });
101
+ }
102
+ async function Z(e) {
103
+ return u.sendActionCallEvent({ name: "create_solana_key_export_iframe" }), g(), await y(), h({ ...e, type: "solana" });
28
104
  }
29
105
  export {
30
- D as createEOAHandlers
106
+ Q as createEvmKeyExportIframe,
107
+ Z as createSolanaKeyExportIframe
31
108
  };