@coinbase/cdp-core 0.0.53 → 0.0.54

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 (299) hide show
  1. package/dist/esm/index.native10.js +4 -4
  2. package/dist/esm/index.native100.js +13 -19
  3. package/dist/esm/index.native101.js +4 -8
  4. package/dist/esm/index.native102.js +2 -8
  5. package/dist/esm/index.native103.js +4 -71
  6. package/dist/esm/index.native104.js +12 -12
  7. package/dist/esm/index.native105.js +7 -3
  8. package/dist/esm/index.native106.js +3 -4
  9. package/dist/esm/index.native107.js +19 -4
  10. package/dist/esm/index.native108.js +8 -4
  11. package/dist/esm/index.native109.js +7 -19
  12. package/dist/esm/index.native11.js +3 -3
  13. package/dist/esm/index.native110.js +66 -47
  14. package/dist/esm/index.native111.js +18 -17
  15. package/dist/esm/index.native112.js +3 -20
  16. package/dist/esm/index.native113.js +4 -8
  17. package/dist/esm/index.native114.js +4 -30
  18. package/dist/esm/index.native115.js +4 -7
  19. package/dist/esm/index.native116.js +10 -11
  20. package/dist/esm/index.native117.js +50 -52
  21. package/dist/esm/index.native118.js +17 -10
  22. package/dist/esm/index.native119.js +21 -2
  23. package/dist/esm/index.native12.js +3 -3
  24. package/dist/esm/index.native120.js +9 -45
  25. package/dist/esm/index.native121.js +30 -13
  26. package/dist/esm/index.native122.js +7 -4
  27. package/dist/esm/index.native123.js +21 -2
  28. package/dist/esm/index.native125.js +1 -1
  29. package/dist/esm/index.native13.js +3 -3
  30. package/dist/esm/index.native132.js +3 -46
  31. package/dist/esm/index.native133.js +20 -3
  32. package/dist/esm/index.native134.js +10 -21
  33. package/dist/esm/index.native135.js +19 -9
  34. package/dist/esm/index.native136.js +89 -15
  35. package/dist/esm/index.native137.js +19 -92
  36. package/dist/esm/index.native138.js +115 -18
  37. package/dist/esm/index.native139.js +2 -118
  38. package/dist/esm/index.native14.js +3 -3
  39. package/dist/esm/index.native140.js +109 -2
  40. package/dist/esm/index.native141.js +2 -109
  41. package/dist/esm/index.native142.js +47 -2
  42. package/dist/esm/index.native15.js +3 -3
  43. package/dist/esm/index.native153.js +17 -14
  44. package/dist/esm/index.native154.js +28 -18
  45. package/dist/esm/index.native155.js +6 -26
  46. package/dist/esm/index.native156.js +9 -6
  47. package/dist/esm/index.native157.js +13 -11
  48. package/dist/esm/index.native158.js +8 -11
  49. package/dist/esm/index.native159.js +14 -7
  50. package/dist/esm/index.native16.js +3 -3
  51. package/dist/esm/index.native160.js +80 -16
  52. package/dist/esm/index.native161.js +14 -80
  53. package/dist/esm/index.native19.js +1 -1
  54. package/dist/esm/index.native22.js +28 -3
  55. package/dist/esm/index.native23.js +3 -51
  56. package/dist/esm/index.native24.js +53 -2
  57. package/dist/esm/index.native25.js +2 -86
  58. package/dist/esm/index.native26.js +87 -15
  59. package/dist/esm/index.native27.js +15 -17
  60. package/dist/esm/index.native28.js +15 -116
  61. package/dist/esm/index.native29.js +92 -34
  62. package/dist/esm/index.native3.js +48 -6
  63. package/dist/esm/index.native30.js +58 -12
  64. package/dist/esm/index.native31.js +15 -42
  65. package/dist/esm/index.native32.js +42 -28
  66. package/dist/esm/index.native44.js +1 -1
  67. package/dist/esm/index.native45.js +1 -1
  68. package/dist/esm/index.native46.js +3 -3
  69. package/dist/esm/index.native47.js +12 -12
  70. package/dist/esm/index.native48.js +12 -12
  71. package/dist/esm/index.native49.js +1 -1
  72. package/dist/esm/index.native51.js +4 -4
  73. package/dist/esm/index.native52.js +4 -2
  74. package/dist/esm/index.native53.js +2 -66
  75. package/dist/esm/index.native54.js +2 -367
  76. package/dist/esm/index.native55.js +66 -2
  77. package/dist/esm/index.native56.js +365 -2
  78. package/dist/esm/index.native7.js +11 -11
  79. package/dist/esm/index.native72.js +1 -1
  80. package/dist/esm/index.native8.js +4 -4
  81. package/dist/esm/index.native9.js +4 -4
  82. package/dist/esm/index.native96.js +54 -4
  83. package/dist/esm/index.native97.js +10 -18
  84. package/dist/esm/index.native98.js +2 -8
  85. package/dist/esm/index.native99.js +45 -4
  86. package/dist/esm/index.web100.js +8 -4
  87. package/dist/esm/index.web101.js +8 -2
  88. package/dist/esm/index.web102.js +71 -4
  89. package/dist/esm/index.web103.js +12 -12
  90. package/dist/esm/index.web104.js +3 -7
  91. package/dist/esm/index.web105.js +4 -3
  92. package/dist/esm/index.web106.js +4 -19
  93. package/dist/esm/index.web107.js +4 -8
  94. package/dist/esm/index.web108.js +19 -7
  95. package/dist/esm/index.web109.js +47 -66
  96. package/dist/esm/index.web110.js +17 -18
  97. package/dist/esm/index.web111.js +20 -3
  98. package/dist/esm/index.web112.js +8 -4
  99. package/dist/esm/index.web113.js +30 -4
  100. package/dist/esm/index.web114.js +7 -4
  101. package/dist/esm/index.web115.js +11 -10
  102. package/dist/esm/index.web116.js +4 -52
  103. package/dist/esm/index.web117.js +54 -17
  104. package/dist/esm/index.web118.js +10 -20
  105. package/dist/esm/index.web119.js +2 -9
  106. package/dist/esm/index.web120.js +44 -30
  107. package/dist/esm/index.web121.js +13 -7
  108. package/dist/esm/index.web122.js +2 -21
  109. package/dist/esm/index.web124.js +1 -1
  110. package/dist/esm/index.web127.js +1 -1
  111. package/dist/esm/index.web130.js +77 -19
  112. package/dist/esm/index.web131.js +4 -10
  113. package/dist/esm/index.web132.js +2 -20
  114. package/dist/esm/index.web133.js +104 -89
  115. package/dist/esm/index.web134.js +2 -21
  116. package/dist/esm/index.web135.js +20 -117
  117. package/dist/esm/index.web136.js +10 -2
  118. package/dist/esm/index.web137.js +18 -107
  119. package/dist/esm/index.web138.js +94 -2
  120. package/dist/esm/index.web139.js +20 -78
  121. package/dist/esm/index.web140.js +118 -4
  122. package/dist/esm/index.web141.js +1 -1
  123. package/dist/esm/index.web153.js +1 -1
  124. package/dist/esm/index.web158.js +1 -1
  125. package/dist/esm/index.web159.js +1 -1
  126. package/dist/esm/index.web24.js +33 -29
  127. package/dist/esm/index.web34.js +3 -3
  128. package/dist/esm/index.web40.js +2 -2
  129. package/dist/esm/index.web45.js +3 -3
  130. package/dist/esm/index.web46.js +31 -2
  131. package/dist/esm/index.web47.js +28 -65
  132. package/dist/esm/index.web48.js +2 -367
  133. package/dist/esm/index.web49.js +63 -14
  134. package/dist/esm/index.web50.js +360 -18
  135. package/dist/esm/index.web51.js +13 -47
  136. package/dist/esm/index.web52.js +22 -28
  137. package/dist/esm/index.web53.js +50 -28
  138. package/dist/esm/index.web71.js +1 -1
  139. package/dist/esm/index.web95.js +4 -54
  140. package/dist/esm/index.web96.js +18 -10
  141. package/dist/esm/index.web97.js +8 -2
  142. package/dist/esm/index.web98.js +4 -45
  143. package/dist/esm/index.web99.js +19 -13
  144. package/dist/native/index.native10.js +4 -4
  145. package/dist/native/index.native100.js +13 -19
  146. package/dist/native/index.native101.js +4 -8
  147. package/dist/native/index.native102.js +2 -8
  148. package/dist/native/index.native103.js +4 -71
  149. package/dist/native/index.native104.js +12 -12
  150. package/dist/native/index.native105.js +7 -3
  151. package/dist/native/index.native106.js +3 -4
  152. package/dist/native/index.native107.js +19 -4
  153. package/dist/native/index.native108.js +8 -4
  154. package/dist/native/index.native109.js +7 -19
  155. package/dist/native/index.native11.js +3 -3
  156. package/dist/native/index.native110.js +66 -47
  157. package/dist/native/index.native111.js +18 -17
  158. package/dist/native/index.native112.js +3 -20
  159. package/dist/native/index.native113.js +4 -8
  160. package/dist/native/index.native114.js +4 -30
  161. package/dist/native/index.native115.js +4 -7
  162. package/dist/native/index.native116.js +10 -11
  163. package/dist/native/index.native117.js +50 -52
  164. package/dist/native/index.native118.js +17 -10
  165. package/dist/native/index.native119.js +21 -2
  166. package/dist/native/index.native12.js +3 -3
  167. package/dist/native/index.native120.js +9 -45
  168. package/dist/native/index.native121.js +30 -13
  169. package/dist/native/index.native122.js +7 -4
  170. package/dist/native/index.native123.js +21 -2
  171. package/dist/native/index.native125.js +1 -1
  172. package/dist/native/index.native13.js +3 -3
  173. package/dist/native/index.native132.js +3 -46
  174. package/dist/native/index.native133.js +20 -3
  175. package/dist/native/index.native134.js +10 -21
  176. package/dist/native/index.native135.js +19 -9
  177. package/dist/native/index.native136.js +89 -15
  178. package/dist/native/index.native137.js +19 -92
  179. package/dist/native/index.native138.js +115 -18
  180. package/dist/native/index.native139.js +2 -118
  181. package/dist/native/index.native14.js +3 -3
  182. package/dist/native/index.native140.js +109 -2
  183. package/dist/native/index.native141.js +2 -109
  184. package/dist/native/index.native142.js +47 -2
  185. package/dist/native/index.native15.js +3 -3
  186. package/dist/native/index.native153.js +17 -14
  187. package/dist/native/index.native154.js +28 -18
  188. package/dist/native/index.native155.js +6 -26
  189. package/dist/native/index.native156.js +9 -6
  190. package/dist/native/index.native157.js +13 -11
  191. package/dist/native/index.native158.js +8 -11
  192. package/dist/native/index.native159.js +14 -7
  193. package/dist/native/index.native16.js +3 -3
  194. package/dist/native/index.native160.js +80 -16
  195. package/dist/native/index.native161.js +14 -80
  196. package/dist/native/index.native19.js +1 -1
  197. package/dist/native/index.native22.js +28 -3
  198. package/dist/native/index.native23.js +3 -51
  199. package/dist/native/index.native24.js +53 -2
  200. package/dist/native/index.native25.js +2 -86
  201. package/dist/native/index.native26.js +87 -15
  202. package/dist/native/index.native27.js +15 -17
  203. package/dist/native/index.native28.js +15 -116
  204. package/dist/native/index.native29.js +92 -34
  205. package/dist/native/index.native3.js +48 -6
  206. package/dist/native/index.native30.js +58 -12
  207. package/dist/native/index.native31.js +15 -42
  208. package/dist/native/index.native32.js +42 -28
  209. package/dist/native/index.native44.js +1 -1
  210. package/dist/native/index.native45.js +1 -1
  211. package/dist/native/index.native46.js +3 -3
  212. package/dist/native/index.native47.js +12 -12
  213. package/dist/native/index.native48.js +12 -12
  214. package/dist/native/index.native49.js +1 -1
  215. package/dist/native/index.native51.js +4 -4
  216. package/dist/native/index.native52.js +4 -2
  217. package/dist/native/index.native53.js +2 -66
  218. package/dist/native/index.native54.js +2 -367
  219. package/dist/native/index.native55.js +66 -2
  220. package/dist/native/index.native56.js +365 -2
  221. package/dist/native/index.native7.js +11 -11
  222. package/dist/native/index.native72.js +1 -1
  223. package/dist/native/index.native8.js +4 -4
  224. package/dist/native/index.native9.js +4 -4
  225. package/dist/native/index.native96.js +54 -4
  226. package/dist/native/index.native97.js +10 -18
  227. package/dist/native/index.native98.js +2 -8
  228. package/dist/native/index.native99.js +45 -4
  229. package/dist/native-types/auth/oAuthManager.d.ts +1 -1
  230. package/dist/native-types/auth/types.d.ts +1 -1
  231. package/dist/native-types/platform/types.d.ts +1 -1
  232. package/dist/native-types/types.d.ts +1 -0
  233. package/dist/types/auth/oAuthManager.d.ts +1 -1
  234. package/dist/types/auth/types.d.ts +1 -1
  235. package/dist/types/platform/types.d.ts +1 -1
  236. package/dist/types/types.d.ts +1 -0
  237. package/dist/web/index.web100.js +8 -4
  238. package/dist/web/index.web101.js +8 -2
  239. package/dist/web/index.web102.js +71 -4
  240. package/dist/web/index.web103.js +12 -12
  241. package/dist/web/index.web104.js +3 -7
  242. package/dist/web/index.web105.js +4 -3
  243. package/dist/web/index.web106.js +4 -19
  244. package/dist/web/index.web107.js +4 -8
  245. package/dist/web/index.web108.js +19 -7
  246. package/dist/web/index.web109.js +47 -66
  247. package/dist/web/index.web110.js +17 -18
  248. package/dist/web/index.web111.js +20 -3
  249. package/dist/web/index.web112.js +8 -4
  250. package/dist/web/index.web113.js +30 -4
  251. package/dist/web/index.web114.js +7 -4
  252. package/dist/web/index.web115.js +11 -10
  253. package/dist/web/index.web116.js +4 -52
  254. package/dist/web/index.web117.js +54 -17
  255. package/dist/web/index.web118.js +10 -20
  256. package/dist/web/index.web119.js +2 -9
  257. package/dist/web/index.web120.js +44 -30
  258. package/dist/web/index.web121.js +13 -7
  259. package/dist/web/index.web122.js +2 -21
  260. package/dist/web/index.web124.js +1 -1
  261. package/dist/web/index.web127.js +1 -1
  262. package/dist/web/index.web130.js +77 -19
  263. package/dist/web/index.web131.js +4 -10
  264. package/dist/web/index.web132.js +2 -20
  265. package/dist/web/index.web133.js +104 -89
  266. package/dist/web/index.web134.js +2 -21
  267. package/dist/web/index.web135.js +20 -117
  268. package/dist/web/index.web136.js +10 -2
  269. package/dist/web/index.web137.js +18 -107
  270. package/dist/web/index.web138.js +94 -2
  271. package/dist/web/index.web139.js +20 -78
  272. package/dist/web/index.web140.js +118 -4
  273. package/dist/web/index.web141.js +1 -1
  274. package/dist/web/index.web153.js +1 -1
  275. package/dist/web/index.web158.js +1 -1
  276. package/dist/web/index.web159.js +1 -1
  277. package/dist/web/index.web24.js +33 -29
  278. package/dist/web/index.web34.js +3 -3
  279. package/dist/web/index.web40.js +2 -2
  280. package/dist/web/index.web45.js +3 -3
  281. package/dist/web/index.web46.js +31 -2
  282. package/dist/web/index.web47.js +28 -65
  283. package/dist/web/index.web48.js +2 -367
  284. package/dist/web/index.web49.js +63 -14
  285. package/dist/web/index.web50.js +360 -18
  286. package/dist/web/index.web51.js +13 -47
  287. package/dist/web/index.web52.js +22 -28
  288. package/dist/web/index.web53.js +50 -28
  289. package/dist/web/index.web71.js +1 -1
  290. package/dist/web/index.web95.js +4 -54
  291. package/dist/web/index.web96.js +18 -10
  292. package/dist/web/index.web97.js +8 -2
  293. package/dist/web/index.web98.js +4 -45
  294. package/dist/web/index.web99.js +19 -13
  295. package/dist/web-types/auth/oAuthManager.d.ts +1 -1
  296. package/dist/web-types/auth/types.d.ts +1 -1
  297. package/dist/web-types/platform/types.d.ts +1 -1
  298. package/dist/web-types/types.d.ts +1 -0
  299. package/package.json +7 -3
@@ -1,86 +1,2 @@
1
- import { verifyOAuth as u } from "./index.native7.js";
2
- import { getPlatformOAuth as s } from "./index.native6.js";
3
- import "@coinbase/cdp-api-client";
4
- import "viem";
5
- class S {
6
- oauthFlowState = null;
7
- oauthStateChangeCallbacks = [];
8
- /**
9
- * Adds a callback to be called when the OAuth state changes.
10
- *
11
- * @param callback - The function to call when the OAuth state changes.
12
- */
13
- async addOAuthStateChangeCallback(t) {
14
- this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
15
- }
16
- /**
17
- * Sets the OAuth flow state.
18
- *
19
- * @param oauthFlowState - The OAuth flow state.
20
- */
21
- async setOAuthFlowState(t) {
22
- this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
23
- }
24
- /**
25
- * Clears the OAuth flow state.
26
- */
27
- async clearOAuthFlowState() {
28
- this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
29
- }
30
- /**
31
- * Gets the OAuth flow state.
32
- *
33
- * @returns The OAuth flow state.
34
- */
35
- async getOAuthFlowState() {
36
- return this.oauthFlowState;
37
- }
38
- /**
39
- * Handles the OAuth code.
40
- */
41
- async handleOAuthCode() {
42
- try {
43
- const t = await s().getOAuthParams();
44
- if (await s().cleanupOAuthParams(), !t)
45
- return;
46
- const { providerType: a, code: e, flowId: r, error: o, errorDescription: h } = t;
47
- if (o || h) {
48
- await this.setOAuthFlowState({
49
- providerType: a,
50
- status: "error",
51
- errorDescription: o ?? h,
52
- code: e,
53
- flowId: r,
54
- error: o
55
- });
56
- return;
57
- }
58
- if (!e || !a || !r)
59
- return;
60
- await this.setOAuthFlowState({
61
- providerType: a,
62
- status: "pending",
63
- code: e,
64
- flowId: r
65
- }), await u({
66
- code: e,
67
- providerType: a,
68
- flowId: r
69
- }), await this.setOAuthFlowState({
70
- providerType: a,
71
- status: "success",
72
- code: e,
73
- flowId: r
74
- });
75
- } catch (t) {
76
- const a = t instanceof Error ? t.message : "Unknown error";
77
- await s().cleanupOAuthParams(), await this.setOAuthFlowState({
78
- status: "error",
79
- errorDescription: a
80
- });
81
- }
82
- }
83
- }
84
- export {
85
- S as OAuthManager
86
- };
1
+ import { __require as r } from "./index.native148.js";
2
+ r();
@@ -1,18 +1,90 @@
1
+ import { verifyOAuth as i } from "./index.native7.js";
2
+ import { getPlatformOAuth as h } from "./index.native6.js";
1
3
  import "@coinbase/cdp-api-client";
2
- const m = (c, a, e) => {
3
- const s = new Date(a).getTime(), u = {
4
- userId: e.userId,
5
- evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
6
- evmSmartAccounts: e.evmSmartAccounts?.map((t) => t) ?? [],
7
- solanaAccounts: e.solanaAccounts?.map((t) => t) ?? [],
8
- authenticationMethods: e.authenticationMethods.reduce((t, o) => (t[o.type] = o, t), {})
9
- };
10
- return {
11
- accessToken: c,
12
- expiresAt: s,
13
- user: u
14
- };
15
- };
4
+ import "viem";
5
+ class A {
6
+ oauthFlowState = null;
7
+ oauthStateChangeCallbacks = [];
8
+ /**
9
+ * Adds a callback to be called when the OAuth state changes.
10
+ *
11
+ * @param callback - The function to call when the OAuth state changes.
12
+ */
13
+ async addOAuthStateChangeCallback(t) {
14
+ this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
15
+ }
16
+ /**
17
+ * Sets the OAuth flow state.
18
+ *
19
+ * @param oauthFlowState - The OAuth flow state.
20
+ */
21
+ async setOAuthFlowState(t) {
22
+ this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
23
+ }
24
+ /**
25
+ * Clears the OAuth flow state.
26
+ */
27
+ async clearOAuthFlowState() {
28
+ this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
29
+ }
30
+ /**
31
+ * Gets the OAuth flow state.
32
+ *
33
+ * @returns The OAuth flow state.
34
+ */
35
+ async getOAuthFlowState() {
36
+ return this.oauthFlowState;
37
+ }
38
+ /**
39
+ * Handles the OAuth code.
40
+ *
41
+ * @param url - The URL to handle.
42
+ * @returns A promise that resolves when the OAuth code is handled.
43
+ * @throws An error if the URL is required and not provided.
44
+ */
45
+ async handleOAuthCode(t) {
46
+ try {
47
+ const a = await h().getOAuthParams(t);
48
+ if (await h().cleanupOAuthParams(), !a)
49
+ return;
50
+ const { providerType: e, code: r, flowId: o, error: s, errorDescription: u } = a;
51
+ if (s || u) {
52
+ await this.setOAuthFlowState({
53
+ providerType: e,
54
+ status: "error",
55
+ errorDescription: s ?? u,
56
+ code: r,
57
+ flowId: o,
58
+ error: s
59
+ });
60
+ return;
61
+ }
62
+ if (!r || !e || !o)
63
+ return;
64
+ await this.setOAuthFlowState({
65
+ providerType: e,
66
+ status: "pending",
67
+ code: r,
68
+ flowId: o
69
+ }), await i({
70
+ code: r,
71
+ providerType: e,
72
+ flowId: o
73
+ }), await this.setOAuthFlowState({
74
+ providerType: e,
75
+ status: "success",
76
+ code: r,
77
+ flowId: o
78
+ });
79
+ } catch (a) {
80
+ const e = a instanceof Error ? a.message : "Unknown error";
81
+ await h().cleanupOAuthParams(), await this.setOAuthFlowState({
82
+ status: "error",
83
+ errorDescription: e
84
+ });
85
+ }
86
+ }
87
+ }
16
88
  export {
17
- m as toAuthState
89
+ A as OAuthManager
18
90
  };
@@ -1,20 +1,18 @@
1
1
  import "@coinbase/cdp-api-client";
2
- import "viem";
3
- const i = async (n) => await n.isSignedIn();
4
- async function f(n, r, o) {
5
- if (!await i(r))
6
- throw new Error("User not signed in");
7
- const c = await r.getUser();
8
- if ("evmAccount" in n && !c.evmAccounts?.find((t) => t === n.evmAccount))
9
- throw new Error("EVM account not found");
10
- if ("evmSmartAccount" in n && !c.evmSmartAccounts?.find((t) => t === n.evmSmartAccount))
11
- throw new Error("EVM Smart Account not found");
12
- if ("solanaAccount" in n && !c.solanaAccounts?.find((t) => t === n.solanaAccount))
13
- throw new Error("Solana account not found");
14
- const e = await r.getWalletSecretId();
15
- return o({ ...n, user: c, walletSecretId: e });
16
- }
2
+ const m = (c, a, e) => {
3
+ const s = new Date(a).getTime(), u = {
4
+ userId: e.userId,
5
+ evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
6
+ evmSmartAccounts: e.evmSmartAccounts?.map((t) => t) ?? [],
7
+ solanaAccounts: e.solanaAccounts?.map((t) => t) ?? [],
8
+ authenticationMethods: e.authenticationMethods.reduce((t, o) => (t[o.type] = o, t), {})
9
+ };
10
+ return {
11
+ accessToken: c,
12
+ expiresAt: s,
13
+ user: u
14
+ };
15
+ };
17
16
  export {
18
- i as isSignedIn,
19
- f as withAuth
17
+ m as toAuthState
20
18
  };
@@ -1,121 +1,20 @@
1
1
  import "@coinbase/cdp-api-client";
2
2
  import "viem";
3
- import { mockUser as e } from "./index.native30.js";
4
- class r {
5
- authState = null;
6
- authStateChangeCallback = null;
7
- /**
8
- * Initializes the mock auth manager.
9
- *
10
- * @param _projectId - The project ID (unused in mock implementation).
11
- */
12
- constructor(t) {
13
- }
14
- /**
15
- * Awaitable method whose promise only resolves when the auth manager is ready to be used.
16
- *
17
- * @returns A promise that resolves when the auth manager is ready to be used.
18
- */
19
- async ensureInitialized() {
20
- return Promise.resolve();
21
- }
22
- /**
23
- * Gets the current user, or null if there is no user signed in.
24
- *
25
- * @returns The current mock user if signed in, null otherwise.
26
- */
27
- async getUser() {
28
- return this.authState?.user ?? null;
29
- }
30
- /**
31
- * Returns whether the user is signed in - i.e., whether there is an unexpired
32
- * access token and user.
33
- *
34
- * @returns True if the mock user is signed in and token is not expired, false otherwise.
35
- */
36
- async isSignedIn() {
37
- return this.authState ? Promise.resolve(this.authState.expiresAt > Date.now()) : Promise.resolve(!1);
38
- }
39
- /**
40
- * Signs out the user, clearing all authentication state.
41
- * In the mock implementation, this simply clears the local auth state.
42
- */
43
- async signOut() {
44
- await this.clearAuthState();
45
- }
46
- /**
47
- * Sets a callback to be called when the auth state changes.
48
- * The callback is immediately called with the current auth state.
49
- *
50
- * @param callback - The function to call when the auth state changes.
51
- * Will be called with the current user or null.
52
- */
53
- addAuthStateChangeCallback(t) {
54
- this.authStateChangeCallback = t, t(this.authState?.user ?? null);
55
- }
56
- /**
57
- * Gets the access token. For mock, this always returns a valid token if signed in.
58
- * If the current token is expired, it will be refreshed automatically.
59
- *
60
- * @returns The mock access token if signed in, null otherwise.
61
- */
62
- async getToken() {
63
- return this.authState ? (this.authState.expiresAt <= Date.now() && await this.refreshToken(), this.authState?.accessToken ?? null) : null;
64
- }
65
- /**
66
- * Gets the currentlly registered wallet secret ID.
67
- *
68
- * @returns The wallet secret ID.
69
- */
70
- async getWalletSecretId() {
71
- return "mock-wallet-secret-id";
72
- }
73
- /**
74
- * Gets the X-Wallet-Auth header value.
75
- *
76
- * @param _options - The options for the request.
77
- * @param _options.requestMethod - The HTTP method of the request.
78
- * @param _options.requestHost - The host of the request.
79
- * @param _options.requestPath - The path of the request.
80
- * @param _options.requestData - The data of the request.
81
- * @returns The X-Wallet-Auth header value.
82
- */
83
- async getXWalletAuth(t) {
84
- if (!this.authState)
85
- throw new Error("User not signed in");
86
- return "x-wallet-auth";
87
- }
88
- /**
89
- * Sets the authentication state.
90
- * This will trigger the auth state change callback if one is registered.
91
- *
92
- * @param authState - The new authentication state to set.
93
- */
94
- async setAuthState(t) {
95
- this.authState = t, this.authStateChangeCallback && this.authStateChangeCallback(this.authState?.user ?? null);
96
- }
97
- /**
98
- * Clears the authentication state.
99
- * This will trigger the auth state change callback if one is registered.
100
- */
101
- async clearAuthState() {
102
- this.authState = null, this.authStateChangeCallback && this.authStateChangeCallback(null);
103
- }
104
- /**
105
- * Refreshes the mock token.
106
- * Only refreshes if there is an existing auth state (user is signed in).
107
- * Sets a new mock token with a 24-hour expiration.
108
- *
109
- * @private
110
- */
111
- async refreshToken() {
112
- this.authState && await this.setAuthState({
113
- accessToken: "mock-access-token",
114
- expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
115
- user: e
116
- });
117
- }
3
+ const i = async (n) => await n.isSignedIn();
4
+ async function f(n, r, o) {
5
+ if (!await i(r))
6
+ throw new Error("User not signed in");
7
+ const c = await r.getUser();
8
+ if ("evmAccount" in n && !c.evmAccounts?.find((t) => t === n.evmAccount))
9
+ throw new Error("EVM account not found");
10
+ if ("evmSmartAccount" in n && !c.evmSmartAccounts?.find((t) => t === n.evmSmartAccount))
11
+ throw new Error("EVM Smart Account not found");
12
+ if ("solanaAccount" in n && !c.solanaAccounts?.find((t) => t === n.solanaAccount))
13
+ throw new Error("Solana account not found");
14
+ const e = await r.getWalletSecretId();
15
+ return o({ ...n, user: c, walletSecretId: e });
118
16
  }
119
17
  export {
120
- r as MockAuthManager
18
+ i as isSignedIn,
19
+ f as withAuth
121
20
  };
@@ -1,63 +1,121 @@
1
1
  import "@coinbase/cdp-api-client";
2
2
  import "viem";
3
- import { verifyOAuth as o } from "./index.native7.js";
4
- import { getPlatformOAuth as e } from "./index.native6.js";
5
- class i {
6
- oauthFlowState = null;
7
- oauthStateChangeCallbacks = [];
3
+ import { mockUser as e } from "./index.native31.js";
4
+ class r {
5
+ authState = null;
6
+ authStateChangeCallback = null;
8
7
  /**
9
- * Initializes the mock OAuth manager.
8
+ * Initializes the mock auth manager.
9
+ *
10
+ * @param _projectId - The project ID (unused in mock implementation).
10
11
  */
11
- constructor() {
12
- this.handleOAuthCode();
12
+ constructor(t) {
13
+ }
14
+ /**
15
+ * Awaitable method whose promise only resolves when the auth manager is ready to be used.
16
+ *
17
+ * @returns A promise that resolves when the auth manager is ready to be used.
18
+ */
19
+ async ensureInitialized() {
20
+ return Promise.resolve();
13
21
  }
14
22
  /**
15
23
  * Gets the current user, or null if there is no user signed in.
16
24
  *
17
25
  * @returns The current mock user if signed in, null otherwise.
18
26
  */
19
- async getOAuthFlowState() {
20
- return this.oauthFlowState ?? null;
27
+ async getUser() {
28
+ return this.authState?.user ?? null;
21
29
  }
22
30
  /**
23
- * Sets the OAuth flow state.
31
+ * Returns whether the user is signed in - i.e., whether there is an unexpired
32
+ * access token and user.
24
33
  *
25
- * @param oauthFlowState - The OAuth flow state to set.
34
+ * @returns True if the mock user is signed in and token is not expired, false otherwise.
26
35
  */
27
- async setOAuthFlowState(t) {
28
- this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
36
+ async isSignedIn() {
37
+ return this.authState ? Promise.resolve(this.authState.expiresAt > Date.now()) : Promise.resolve(!1);
29
38
  }
30
39
  /**
31
- * Adds a callback to be called when the OAuth state changes.
40
+ * Signs out the user, clearing all authentication state.
41
+ * In the mock implementation, this simply clears the local auth state.
42
+ */
43
+ async signOut() {
44
+ await this.clearAuthState();
45
+ }
46
+ /**
47
+ * Sets a callback to be called when the auth state changes.
48
+ * The callback is immediately called with the current auth state.
49
+ *
50
+ * @param callback - The function to call when the auth state changes.
51
+ * Will be called with the current user or null.
52
+ */
53
+ addAuthStateChangeCallback(t) {
54
+ this.authStateChangeCallback = t, t(this.authState?.user ?? null);
55
+ }
56
+ /**
57
+ * Gets the access token. For mock, this always returns a valid token if signed in.
58
+ * If the current token is expired, it will be refreshed automatically.
32
59
  *
33
- * @param callback - The function to call when the OAuth state changes.
60
+ * @returns The mock access token if signed in, null otherwise.
34
61
  */
35
- async addOAuthStateChangeCallback(t) {
36
- this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
62
+ async getToken() {
63
+ return this.authState ? (this.authState.expiresAt <= Date.now() && await this.refreshToken(), this.authState?.accessToken ?? null) : null;
37
64
  }
38
65
  /**
39
- * Clears the OAuth flow state.
66
+ * Gets the currentlly registered wallet secret ID.
67
+ *
68
+ * @returns The wallet secret ID.
40
69
  */
41
- async clearOAuthFlowState() {
42
- this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
70
+ async getWalletSecretId() {
71
+ return "mock-wallet-secret-id";
43
72
  }
44
73
  /**
45
- * Awaitable method whose promise only resolves when the OAuth manager is ready to be used.
74
+ * Gets the X-Wallet-Auth header value.
75
+ *
76
+ * @param _options - The options for the request.
77
+ * @param _options.requestMethod - The HTTP method of the request.
78
+ * @param _options.requestHost - The host of the request.
79
+ * @param _options.requestPath - The path of the request.
80
+ * @param _options.requestData - The data of the request.
81
+ * @returns The X-Wallet-Auth header value.
82
+ */
83
+ async getXWalletAuth(t) {
84
+ if (!this.authState)
85
+ throw new Error("User not signed in");
86
+ return "x-wallet-auth";
87
+ }
88
+ /**
89
+ * Sets the authentication state.
90
+ * This will trigger the auth state change callback if one is registered.
91
+ *
92
+ * @param authState - The new authentication state to set.
93
+ */
94
+ async setAuthState(t) {
95
+ this.authState = t, this.authStateChangeCallback && this.authStateChangeCallback(this.authState?.user ?? null);
96
+ }
97
+ /**
98
+ * Clears the authentication state.
99
+ * This will trigger the auth state change callback if one is registered.
100
+ */
101
+ async clearAuthState() {
102
+ this.authState = null, this.authStateChangeCallback && this.authStateChangeCallback(null);
103
+ }
104
+ /**
105
+ * Refreshes the mock token.
106
+ * Only refreshes if there is an existing auth state (user is signed in).
107
+ * Sets a new mock token with a 24-hour expiration.
108
+ *
109
+ * @private
46
110
  */
47
- async handleOAuthCode() {
48
- await e()?.cleanupOAuthParams(), await this.setOAuthFlowState({
49
- providerType: "google",
50
- status: "pending",
51
- code: "mock-oauth-code",
52
- flowId: "mock-flow-id"
53
- }), await o({ code: "mock-oauth-code", providerType: "google", flowId: "mock-flow-id" }), await this.setOAuthFlowState({
54
- providerType: "google",
55
- status: "success",
56
- code: "mock-oauth-code",
57
- flowId: "mock-flow-id"
111
+ async refreshToken() {
112
+ this.authState && await this.setAuthState({
113
+ accessToken: "mock-access-token",
114
+ expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
115
+ user: e
58
116
  });
59
117
  }
60
118
  }
61
119
  export {
62
- i as MockOAuthManager
120
+ r as MockAuthManager
63
121
  };
@@ -1,14 +1,56 @@
1
- const t = {
1
+ import * as u from "expo-web-browser";
2
+ import { WebBrowserResultType as o } from "expo-web-browser";
3
+ import { getCoreOAuthManager as s, getConfig as l } from "./index.native22.js";
4
+ const d = {
2
5
  getRedirectUrl: () => {
3
- throw new Error("OAuth is not supported in this platform");
6
+ const e = l().nativeOAuthCallback;
7
+ if (!e)
8
+ throw new Error("nativeOAuthCallback must be configured in order to use native OAuth");
9
+ return e;
10
+ },
11
+ getOAuthParams: (e) => {
12
+ if (!e)
13
+ return null;
14
+ const r = new URL(e), t = r.searchParams.get("code") ?? void 0, a = r.searchParams.get("provider_type") ?? void 0, i = r.searchParams.get("flow_id") ?? void 0, c = r.searchParams.get("error") ?? void 0, n = r.searchParams.get("error_description") ?? void 0;
15
+ return (!t || !a || !i) && !c && !n ? null : { code: t, providerType: a, flowId: i, error: c, errorDescription: n };
4
16
  },
5
- getOAuthParams: () => null,
6
17
  cleanupOAuthParams: () => {
7
18
  },
8
- initiateOAuthFlow: () => {
9
- throw new Error("OAuth is not supported in this platform");
19
+ initiateOAuthFlow: async (e) => {
20
+ const r = d.getRedirectUrl(), t = await u.openAuthSessionAsync(e, r);
21
+ switch (t.type) {
22
+ case "success":
23
+ if (!t.url)
24
+ throw new Error("URL is required for success result");
25
+ s().handleOAuthCode(t.url);
26
+ break;
27
+ case o.CANCEL:
28
+ s().setOAuthFlowState({
29
+ status: "error",
30
+ errorDescription: "User cancelled the OAuth flow"
31
+ });
32
+ break;
33
+ case o.DISMISS:
34
+ s().setOAuthFlowState({
35
+ status: "error",
36
+ errorDescription: "User dismissed the OAuth flow"
37
+ });
38
+ break;
39
+ case o.LOCKED:
40
+ s().setOAuthFlowState({
41
+ status: "error",
42
+ errorDescription: "The browser was locked"
43
+ });
44
+ break;
45
+ case o.OPENED:
46
+ break;
47
+ default:
48
+ throw new Error(
49
+ `Unexpected WebBrowser result type: ${t.type}`
50
+ );
51
+ }
10
52
  }
11
53
  };
12
54
  export {
13
- t as nativeOAuth
55
+ d as nativeOAuth
14
56
  };
@@ -1,17 +1,63 @@
1
1
  import "@coinbase/cdp-api-client";
2
2
  import "viem";
3
- const t = "0x0000000000000000000000000000000000000000", s = {
4
- userId: "mock-user-id",
5
- evmAccounts: [t],
6
- solanaAccounts: ["5fNfvyp5f3BB9T24s6bC8QjDXuJqvU8WjziJpEQi9PWT"],
7
- authenticationMethods: {
8
- email: {
9
- type: "email",
10
- email: "test@test.com"
11
- }
3
+ import { verifyOAuth as o } from "./index.native7.js";
4
+ import { getPlatformOAuth as e } from "./index.native6.js";
5
+ class i {
6
+ oauthFlowState = null;
7
+ oauthStateChangeCallbacks = [];
8
+ /**
9
+ * Initializes the mock OAuth manager.
10
+ */
11
+ constructor() {
12
+ this.handleOAuthCode();
12
13
  }
13
- };
14
+ /**
15
+ * Gets the current user, or null if there is no user signed in.
16
+ *
17
+ * @returns The current mock user if signed in, null otherwise.
18
+ */
19
+ async getOAuthFlowState() {
20
+ return this.oauthFlowState ?? null;
21
+ }
22
+ /**
23
+ * Sets the OAuth flow state.
24
+ *
25
+ * @param oauthFlowState - The OAuth flow state to set.
26
+ */
27
+ async setOAuthFlowState(t) {
28
+ this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
29
+ }
30
+ /**
31
+ * Adds a callback to be called when the OAuth state changes.
32
+ *
33
+ * @param callback - The function to call when the OAuth state changes.
34
+ */
35
+ async addOAuthStateChangeCallback(t) {
36
+ this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
37
+ }
38
+ /**
39
+ * Clears the OAuth flow state.
40
+ */
41
+ async clearOAuthFlowState() {
42
+ this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
43
+ }
44
+ /**
45
+ * Awaitable method whose promise only resolves when the OAuth manager is ready to be used.
46
+ */
47
+ async handleOAuthCode() {
48
+ await e()?.cleanupOAuthParams(), await this.setOAuthFlowState({
49
+ providerType: "google",
50
+ status: "pending",
51
+ code: "mock-oauth-code",
52
+ flowId: "mock-flow-id"
53
+ }), await o({ code: "mock-oauth-code", providerType: "google", flowId: "mock-flow-id" }), await this.setOAuthFlowState({
54
+ providerType: "google",
55
+ status: "success",
56
+ code: "mock-oauth-code",
57
+ flowId: "mock-flow-id"
58
+ });
59
+ }
60
+ }
14
61
  export {
15
- t as mockAddress,
16
- s as mockUser
62
+ i as MockOAuthManager
17
63
  };