@coinbase/cdp-core 0.0.122 → 0.0.123

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 (300) hide show
  1. package/dist/esm/index.web10.js +66 -65
  2. package/dist/esm/index.web104.js +1 -1
  3. package/dist/esm/index.web113.js +3 -3
  4. package/dist/esm/index.web116.js +2 -2
  5. package/dist/esm/index.web120.js +3 -3
  6. package/dist/esm/index.web122.js +6 -6
  7. package/dist/esm/index.web134.js +13 -373
  8. package/dist/esm/index.web135.js +22 -28
  9. package/dist/esm/index.web136.js +50 -28
  10. package/dist/esm/index.web137.js +379 -2
  11. package/dist/esm/index.web138.js +28 -65
  12. package/dist/esm/index.web139.js +28 -364
  13. package/dist/esm/index.web140.js +2 -19
  14. package/dist/esm/index.web141.js +63 -20
  15. package/dist/esm/index.web142.js +351 -37
  16. package/dist/esm/index.web143.js +944 -4
  17. package/dist/esm/index.web144.js +2 -945
  18. package/dist/esm/index.web145.js +50 -2
  19. package/dist/esm/index.web146.js +26 -49
  20. package/dist/esm/index.web147.js +54 -26
  21. package/dist/esm/index.web148.js +11 -5
  22. package/dist/esm/index.web149.js +2 -48
  23. package/dist/esm/index.web150.js +44 -54
  24. package/dist/esm/index.web151.js +13 -10
  25. package/dist/esm/index.web152.js +13 -2
  26. package/dist/esm/index.web153.js +12 -45
  27. package/dist/esm/index.web154.js +5 -14
  28. package/dist/esm/index.web155.js +47 -14
  29. package/dist/esm/index.web156.js +4 -18
  30. package/dist/esm/index.web157.js +28 -7
  31. package/dist/esm/index.web158.js +7 -3
  32. package/dist/esm/index.web159.js +3 -28
  33. package/dist/esm/index.web160.js +28 -8
  34. package/dist/esm/index.web161.js +8 -7
  35. package/dist/esm/index.web162.js +7 -80
  36. package/dist/esm/index.web163.js +71 -19
  37. package/dist/esm/index.web164.js +28 -3
  38. package/dist/esm/index.web165.js +3 -15
  39. package/dist/esm/index.web166.js +15 -4
  40. package/dist/esm/index.web167.js +4 -14
  41. package/dist/esm/index.web168.js +14 -19
  42. package/dist/esm/index.web169.js +15 -57
  43. package/dist/esm/index.web170.js +60 -16
  44. package/dist/esm/index.web171.js +17 -23
  45. package/dist/esm/index.web172.js +23 -8
  46. package/dist/esm/index.web173.js +8 -42
  47. package/dist/esm/index.web174.js +42 -7
  48. package/dist/esm/index.web175.js +7 -20
  49. package/dist/esm/index.web176.js +18 -10
  50. package/dist/esm/index.web177.js +4 -11
  51. package/dist/esm/index.web198.js +1 -1
  52. package/dist/esm/index.web2.js +2 -2
  53. package/dist/esm/index.web200.js +1 -1
  54. package/dist/esm/index.web201.js +2 -2
  55. package/dist/esm/index.web209.js +2 -2
  56. package/dist/esm/index.web217.js +20 -108
  57. package/dist/esm/index.web218.js +10 -2
  58. package/dist/esm/index.web219.js +20 -2
  59. package/dist/esm/index.web220.js +93 -20
  60. package/dist/esm/index.web221.js +20 -9
  61. package/dist/esm/index.web222.js +114 -16
  62. package/dist/esm/index.web223.js +99 -89
  63. package/dist/esm/index.web224.js +78 -20
  64. package/dist/esm/index.web225.js +79 -118
  65. package/dist/esm/index.web226.js +106 -101
  66. package/dist/esm/index.web227.js +2 -79
  67. package/dist/esm/index.web228.js +2 -79
  68. package/dist/esm/index.web231.js +1 -1
  69. package/dist/esm/index.web238.js +1 -1
  70. package/dist/esm/index.web244.js +3 -17
  71. package/dist/esm/index.web245.js +18 -28
  72. package/dist/esm/index.web246.js +26 -6
  73. package/dist/esm/index.web247.js +6 -9
  74. package/dist/esm/index.web248.js +11 -13
  75. package/dist/esm/index.web249.js +11 -8
  76. package/dist/esm/index.web250.js +7 -14
  77. package/dist/esm/index.web251.js +16 -80
  78. package/dist/esm/index.web252.js +81 -2
  79. package/dist/esm/index.web253.js +2 -4
  80. package/dist/esm/index.web89.js +46 -48
  81. package/dist/esm/index.web9.js +1 -1
  82. package/dist/native/index.native101.js +1 -1
  83. package/dist/native/index.native11.js +1 -1
  84. package/dist/native/index.native110.js +3 -3
  85. package/dist/native/index.native113.js +2 -2
  86. package/dist/native/index.native117.js +3 -3
  87. package/dist/native/index.native118.js +6 -6
  88. package/dist/native/index.native12.js +62 -61
  89. package/dist/native/index.native129.js +12 -12
  90. package/dist/native/index.native130.js +2 -2
  91. package/dist/native/index.native131.js +373 -13
  92. package/dist/native/index.native132.js +2 -25
  93. package/dist/native/index.native133.js +63 -48
  94. package/dist/native/index.native134.js +177 -189
  95. package/dist/native/index.native135.js +31 -2
  96. package/dist/native/index.native136.js +28 -65
  97. package/dist/native/index.native137.js +12 -360
  98. package/dist/native/index.native138.js +22 -28
  99. package/dist/native/index.native139.js +50 -28
  100. package/dist/native/index.native140.js +11 -943
  101. package/dist/native/index.native141.js +12 -2
  102. package/dist/native/index.native142.js +4 -49
  103. package/dist/native/index.native143.js +944 -26
  104. package/dist/native/index.native144.js +2 -5
  105. package/dist/native/index.native145.js +45 -43
  106. package/dist/native/index.native146.js +26 -12
  107. package/dist/native/index.native147.js +5 -12
  108. package/dist/native/index.native148.js +48 -36
  109. package/dist/native/index.native149.js +35 -67
  110. package/dist/native/index.native150.js +67 -4
  111. package/dist/native/index.native151.js +13 -54
  112. package/dist/native/index.native152.js +27 -10
  113. package/dist/native/index.native153.js +8 -2
  114. package/dist/native/index.native154.js +4 -45
  115. package/dist/native/index.native155.js +27 -13
  116. package/dist/native/index.native156.js +9 -2
  117. package/dist/native/index.native157.js +8 -2
  118. package/dist/native/index.native158.js +79 -13
  119. package/dist/native/index.native159.js +26 -54
  120. package/dist/native/index.native160.js +3 -6
  121. package/dist/native/index.native161.js +14 -21
  122. package/dist/native/index.native162.js +4 -17
  123. package/dist/native/index.native163.js +13 -45
  124. package/dist/native/index.native164.js +19 -3
  125. package/dist/native/index.native165.js +60 -3
  126. package/dist/native/index.native166.js +17 -34
  127. package/dist/native/index.native167.js +21 -10
  128. package/dist/native/index.native168.js +8 -4
  129. package/dist/native/index.native169.js +40 -27
  130. package/dist/native/index.native170.js +7 -6
  131. package/dist/native/index.native171.js +19 -31
  132. package/dist/native/index.native172.js +52 -10
  133. package/dist/native/index.native173.js +10 -55
  134. package/dist/native/index.native174.js +2 -43
  135. package/dist/native/index.native175.js +43 -126
  136. package/dist/native/index.native176.js +13 -104
  137. package/dist/native/index.native177.js +13 -6
  138. package/dist/native/index.native178.js +56 -3
  139. package/dist/native/index.native179.js +6 -78
  140. package/dist/native/index.native180.js +22 -2
  141. package/dist/native/index.native181.js +18 -2
  142. package/dist/native/index.native182.js +40 -32
  143. package/dist/native/index.native183.js +3 -6
  144. package/dist/native/index.native184.js +3 -34
  145. package/dist/native/index.native185.js +34 -14
  146. package/dist/native/index.native186.js +9 -31
  147. package/dist/native/index.native187.js +4 -18
  148. package/dist/native/index.native188.js +28 -8
  149. package/dist/native/index.native189.js +6 -10
  150. package/dist/native/index.native190.js +32 -11
  151. package/dist/native/index.native191.js +12 -13
  152. package/dist/native/index.native192.js +55 -5
  153. package/dist/native/index.native193.js +43 -5
  154. package/dist/native/index.native194.js +127 -10
  155. package/dist/native/index.native195.js +104 -13
  156. package/dist/native/index.native196.js +6 -27
  157. package/dist/native/index.native197.js +3 -8
  158. package/dist/native/index.native198.js +78 -3
  159. package/dist/native/index.native199.js +2 -28
  160. package/dist/native/index.native2.js +2 -2
  161. package/dist/native/index.native200.js +2 -9
  162. package/dist/native/index.native201.js +37 -7
  163. package/dist/native/index.native202.js +6 -79
  164. package/dist/native/index.native203.js +32 -25
  165. package/dist/native/index.native204.js +14 -3
  166. package/dist/native/index.native205.js +34 -14
  167. package/dist/native/index.native206.js +18 -4
  168. package/dist/native/index.native207.js +8 -13
  169. package/dist/native/index.native208.js +9 -18
  170. package/dist/native/index.native209.js +11 -60
  171. package/dist/native/index.native210.js +13 -17
  172. package/dist/native/index.native211.js +5 -23
  173. package/dist/native/index.native212.js +5 -9
  174. package/dist/native/index.native213.js +10 -41
  175. package/dist/native/index.native214.js +2 -8
  176. package/dist/native/index.native215.js +2 -21
  177. package/dist/native/index.native222.js +7 -20
  178. package/dist/native/index.native223.js +2 -10
  179. package/dist/native/index.native224.js +361 -20
  180. package/dist/native/index.native225.js +852 -93
  181. package/dist/native/index.native226.js +39 -21
  182. package/dist/native/index.native227.js +2 -118
  183. package/dist/native/index.native228.js +67 -36
  184. package/dist/native/index.native229.js +35 -2
  185. package/dist/native/index.native230.js +14 -69
  186. package/dist/native/index.native231.js +20 -34
  187. package/dist/native/index.native232.js +10 -15
  188. package/dist/native/index.native233.js +20 -8
  189. package/dist/native/index.native234.js +94 -2
  190. package/dist/native/index.native235.js +21 -361
  191. package/dist/native/index.native236.js +118 -853
  192. package/dist/native/index.native237.js +40 -14
  193. package/dist/native/index.native238.js +21 -2
  194. package/dist/native/index.native239.js +2 -20
  195. package/dist/native/index.native240.js +18 -31
  196. package/dist/native/index.native241.js +32 -6
  197. package/dist/native/index.native242.js +6 -3
  198. package/dist/native/index.native243.js +2 -47
  199. package/dist/native/index.native244.js +2 -2
  200. package/dist/native/index.native245.js +2 -2
  201. package/dist/native/index.native246.js +4 -2
  202. package/dist/native/index.native248.js +1 -1
  203. package/dist/native/index.native250.js +1 -1
  204. package/dist/native/index.native253.js +1 -1
  205. package/dist/native/index.native254.js +1 -1
  206. package/dist/native/index.native256.js +14 -78
  207. package/dist/native/index.native257.js +78 -14
  208. package/dist/native/index.native3.js +1 -1
  209. package/dist/native/index.native87.js +46 -48
  210. package/dist/native-types/auth/authManager.d.ts +6 -2
  211. package/dist/native-types/auth/createAuthManager.d.ts +5 -1
  212. package/dist/native-types/version.d.ts +1 -1
  213. package/dist/types/auth/authManager.d.ts +6 -2
  214. package/dist/types/auth/createAuthManager.d.ts +5 -1
  215. package/dist/types/version.d.ts +1 -1
  216. package/dist/web/index.web10.js +66 -65
  217. package/dist/web/index.web104.js +1 -1
  218. package/dist/web/index.web113.js +3 -3
  219. package/dist/web/index.web116.js +2 -2
  220. package/dist/web/index.web120.js +3 -3
  221. package/dist/web/index.web122.js +6 -6
  222. package/dist/web/index.web134.js +13 -373
  223. package/dist/web/index.web135.js +22 -28
  224. package/dist/web/index.web136.js +50 -28
  225. package/dist/web/index.web137.js +379 -2
  226. package/dist/web/index.web138.js +28 -65
  227. package/dist/web/index.web139.js +28 -364
  228. package/dist/web/index.web140.js +2 -19
  229. package/dist/web/index.web141.js +63 -20
  230. package/dist/web/index.web142.js +351 -37
  231. package/dist/web/index.web143.js +944 -4
  232. package/dist/web/index.web144.js +2 -945
  233. package/dist/web/index.web145.js +50 -2
  234. package/dist/web/index.web146.js +26 -49
  235. package/dist/web/index.web147.js +54 -26
  236. package/dist/web/index.web148.js +11 -5
  237. package/dist/web/index.web149.js +2 -48
  238. package/dist/web/index.web150.js +44 -54
  239. package/dist/web/index.web151.js +13 -10
  240. package/dist/web/index.web152.js +13 -2
  241. package/dist/web/index.web153.js +12 -45
  242. package/dist/web/index.web154.js +5 -14
  243. package/dist/web/index.web155.js +47 -14
  244. package/dist/web/index.web156.js +4 -18
  245. package/dist/web/index.web157.js +28 -7
  246. package/dist/web/index.web158.js +7 -3
  247. package/dist/web/index.web159.js +3 -28
  248. package/dist/web/index.web160.js +28 -8
  249. package/dist/web/index.web161.js +8 -7
  250. package/dist/web/index.web162.js +7 -80
  251. package/dist/web/index.web163.js +71 -19
  252. package/dist/web/index.web164.js +28 -3
  253. package/dist/web/index.web165.js +3 -15
  254. package/dist/web/index.web166.js +15 -4
  255. package/dist/web/index.web167.js +4 -14
  256. package/dist/web/index.web168.js +14 -19
  257. package/dist/web/index.web169.js +15 -57
  258. package/dist/web/index.web170.js +60 -16
  259. package/dist/web/index.web171.js +17 -23
  260. package/dist/web/index.web172.js +23 -8
  261. package/dist/web/index.web173.js +8 -42
  262. package/dist/web/index.web174.js +42 -7
  263. package/dist/web/index.web175.js +7 -20
  264. package/dist/web/index.web176.js +18 -10
  265. package/dist/web/index.web177.js +4 -11
  266. package/dist/web/index.web198.js +1 -1
  267. package/dist/web/index.web2.js +2 -2
  268. package/dist/web/index.web200.js +1 -1
  269. package/dist/web/index.web201.js +2 -2
  270. package/dist/web/index.web209.js +2 -2
  271. package/dist/web/index.web217.js +20 -108
  272. package/dist/web/index.web218.js +10 -2
  273. package/dist/web/index.web219.js +20 -2
  274. package/dist/web/index.web220.js +93 -20
  275. package/dist/web/index.web221.js +20 -9
  276. package/dist/web/index.web222.js +114 -16
  277. package/dist/web/index.web223.js +99 -89
  278. package/dist/web/index.web224.js +78 -20
  279. package/dist/web/index.web225.js +79 -118
  280. package/dist/web/index.web226.js +106 -101
  281. package/dist/web/index.web227.js +2 -79
  282. package/dist/web/index.web228.js +2 -79
  283. package/dist/web/index.web231.js +1 -1
  284. package/dist/web/index.web238.js +1 -1
  285. package/dist/web/index.web244.js +3 -17
  286. package/dist/web/index.web245.js +18 -28
  287. package/dist/web/index.web246.js +26 -6
  288. package/dist/web/index.web247.js +6 -9
  289. package/dist/web/index.web248.js +11 -13
  290. package/dist/web/index.web249.js +11 -8
  291. package/dist/web/index.web250.js +7 -14
  292. package/dist/web/index.web251.js +16 -80
  293. package/dist/web/index.web252.js +81 -2
  294. package/dist/web/index.web253.js +2 -4
  295. package/dist/web/index.web89.js +46 -48
  296. package/dist/web/index.web9.js +1 -1
  297. package/dist/web-types/auth/authManager.d.ts +6 -2
  298. package/dist/web-types/auth/createAuthManager.d.ts +5 -1
  299. package/dist/web-types/version.d.ts +1 -1
  300. package/package.json +2 -2
@@ -1,83 +1,19 @@
1
- import { JOSENotSupported as s } from "./index.web141.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 };
1
+ import n from "./index.web151.js";
2
+ function r(t) {
3
+ return n(t) && typeof t.kty == "string";
4
+ }
5
+ function o(t) {
6
+ return t.kty !== "oct" && typeof t.d == "string";
7
+ }
8
+ function e(t) {
9
+ return t.kty !== "oct" && typeof t.d > "u";
10
+ }
11
+ function c(t) {
12
+ return t.kty === "oct" && typeof t.k == "string";
74
13
  }
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
- };
81
14
  export {
82
- i as default
15
+ r as isJWK,
16
+ o as isPrivateJWK,
17
+ e as isPublicJWK,
18
+ c as isSecretJWK
83
19
  };
@@ -1,4 +1,83 @@
1
- var r = { exports: {} };
1
+ import { JOSENotSupported as s } from "./index.web135.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,6 +1,4 @@
1
- function e(t) {
2
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3
- }
1
+ var r = { exports: {} };
4
2
  export {
5
- e as getDefaultExportFromCjs
3
+ r as __module
6
4
  };
@@ -13,24 +13,24 @@ const l = 60 * 1e3, R = {
13
13
  baseDelayMs: 1e3,
14
14
  maxDelayMs: 1e4
15
15
  };
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);
16
+ function g(r, e, t) {
17
+ const n = e * Math.pow(2, r), o = Math.random() * 0.3 * n;
18
+ return Math.min(n + o, t);
19
19
  }
20
- function A(s) {
21
- return new Promise((e) => setTimeout(e, s));
20
+ function A(r) {
21
+ return new Promise((e) => setTimeout(e, r));
22
22
  }
23
- function E(s) {
24
- if (s instanceof TypeError && s.message.includes("fetch"))
23
+ function E(r) {
24
+ if (r instanceof TypeError && r.message.includes("fetch"))
25
25
  return !0;
26
- if (s instanceof y) {
27
- if (s.statusCode >= 500 && s.statusCode < 600 || s.statusCode === 408 || s.statusCode === 429)
26
+ if (r instanceof y) {
27
+ if (r.statusCode >= 500 && r.statusCode < 600 || r.statusCode === 408 || r.statusCode === 429)
28
28
  return !0;
29
- if (s.statusCode === 401)
29
+ if (r.statusCode === 401)
30
30
  return !1;
31
31
  }
32
- if (s instanceof Error) {
33
- const e = s.message.toLowerCase();
32
+ if (r instanceof Error) {
33
+ const e = r.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
  }
@@ -48,9 +48,11 @@ class j {
48
48
  * Initializes the token manager.
49
49
  *
50
50
  * @param projectId - The project ID.
51
+ * @param options - Options that control initial session refresh behavior.
52
+ * @param options.deferInitialization - Whether to defer the initial session refresh until ensureInitialized is called.
51
53
  */
52
- constructor(e) {
53
- this.projectId = e, this.initPromise = this._doInitialize();
54
+ constructor(e, t = {}) {
55
+ this.projectId = e, t.deferInitialization || (this.initPromise = this._doInitialize());
54
56
  }
55
57
  /**
56
58
  * Gets the current user, or null if there is no user signed in.
@@ -139,12 +141,12 @@ class j {
139
141
  if (!await this.isSignedIn())
140
142
  throw new Error("Cannot get X-Wallet-Auth header if the user is not signed in");
141
143
  this.shouldRefreshWalletSecret() && await this.refreshWalletSecret();
142
- const r = `${e.requestMethod} ${e.requestHost}${e.requestPath}`, n = Math.floor(Date.now() / 1e3), o = c(), a = {
143
- uris: [r]
144
+ const t = `${e.requestMethod} ${e.requestHost}${e.requestPath}`, n = Math.floor(Date.now() / 1e3), o = c(), a = {
145
+ uris: [t]
144
146
  };
145
147
  if (e.requestData && Object.keys(e.requestData).length > 0) {
146
- const t = p(e.requestData);
147
- a.reqHash = await o.hash(new TextEncoder().encode(JSON.stringify(t)));
148
+ const s = p(e.requestData);
149
+ a.reqHash = await o.hash(new TextEncoder().encode(JSON.stringify(s)));
148
150
  }
149
151
  return await new _(a).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuedAt(n).setNotBefore(n).setJti(o.generateRandomId()).sign(this.walletSecret.keyPair.privateKey);
150
152
  }
@@ -162,7 +164,7 @@ class j {
162
164
  * @param authState - The authentication state.
163
165
  */
164
166
  async setAuthState(e) {
165
- this.authState = e, i.endUserIdentifier = e.user.userId, this.authStateChangeCallbacks.forEach((r) => r(this.authState?.user ?? null)), this.scheduleTokenRefresh();
167
+ this.authState = e, i.endUserIdentifier = e.user.userId, this.authStateChangeCallbacks.forEach((t) => t(this.authState?.user ?? null)), this.scheduleTokenRefresh();
166
168
  }
167
169
  /**
168
170
  * Clears the authentication state.
@@ -172,14 +174,10 @@ class j {
172
174
  }
173
175
  /**
174
176
  * Ensures the AuthManager is initialized before proceeding.
175
- * If initialization is already in progress, waits for it to complete.
177
+ * Starts deferred initialization when necessary, otherwise waits for initialization already in progress.
176
178
  */
177
179
  async ensureInitialized() {
178
- if (this.initPromise) {
179
- await this.initPromise;
180
- return;
181
- }
182
- throw new Error("AuthManager not initialized");
180
+ this.initPromise ??= this._doInitialize(), await this.initPromise;
183
181
  }
184
182
  /**
185
183
  * Internal async initialization logic.
@@ -210,19 +208,19 @@ class j {
210
208
  * @returns The new access token.
211
209
  */
212
210
  async refreshAccessToken(e = "on_demand") {
213
- const { maxRetries: r, baseDelayMs: n, maxDelayMs: o } = R;
211
+ const { maxRetries: t, baseDelayMs: n, maxDelayMs: o } = R;
214
212
  i.sendSessionRefreshEvent({
215
213
  name: "refresh_token_start",
216
214
  trigger: e
217
215
  });
218
- for (let a = 0; a <= r; a++)
216
+ for (let a = 0; a <= t; a++)
219
217
  try {
220
- const t = await d(this.projectId, {
218
+ const s = await d(this.projectId, {
221
219
  grantType: "refresh_token"
222
220
  }), h = k(
223
- t.accessToken,
224
- t.validUntil,
225
- t.endUser
221
+ s.accessToken,
222
+ s.validUntil,
223
+ s.endUser
226
224
  );
227
225
  await this.setAuthState(h), i.sendSessionRefreshEvent({
228
226
  name: "refresh_token_success",
@@ -230,15 +228,15 @@ class j {
230
228
  attempt: a
231
229
  });
232
230
  return;
233
- } catch (t) {
234
- const h = t instanceof Error ? t.message : String(t);
235
- if (m(t)) {
236
- if (S(t)) {
231
+ } catch (s) {
232
+ const h = s instanceof Error ? s.message : String(s);
233
+ if (m(s)) {
234
+ if (S(s)) {
237
235
  i.sendSessionRefreshEvent({
238
236
  name: "refresh_token_skipped_transient",
239
237
  trigger: e,
240
238
  attempt: a,
241
- read_outcome: t.outcome,
239
+ read_outcome: s.outcome,
242
240
  error_message: h
243
241
  });
244
242
  return;
@@ -248,12 +246,12 @@ class j {
248
246
  trigger: e,
249
247
  attempt: a,
250
248
  error_type: "non_transient",
251
- read_outcome: t.outcome,
249
+ read_outcome: s.outcome,
252
250
  error_message: h
253
251
  }), await this.signOut();
254
252
  return;
255
253
  }
256
- if (!E(t)) {
254
+ if (!E(s)) {
257
255
  i.sendSessionRefreshEvent({
258
256
  name: "refresh_token_failure",
259
257
  trigger: e,
@@ -263,7 +261,7 @@ class j {
263
261
  }), await this.signOut();
264
262
  return;
265
263
  }
266
- if (a === r) {
264
+ if (a === t) {
267
265
  i.sendSessionRefreshEvent({
268
266
  name: "refresh_token_exhausted",
269
267
  trigger: e,
@@ -291,13 +289,13 @@ class j {
291
289
  scheduleTokenRefresh() {
292
290
  if (this.cancelTokenRefresh(), !this.authState)
293
291
  return;
294
- const r = this.authState.expiresAt - l - Date.now();
295
- r <= 0 || (i.sendSessionRefreshEvent({
292
+ const t = this.authState.expiresAt - l - Date.now();
293
+ t <= 0 || (i.sendSessionRefreshEvent({
296
294
  name: "refresh_token_scheduled",
297
- time_until_refresh_ms: r
295
+ time_until_refresh_ms: t
298
296
  }), this.refreshTimeout = setTimeout(async () => {
299
297
  await this.refreshAccessToken("scheduled"), this.scheduleTokenRefresh();
300
- }, r));
298
+ }, t));
301
299
  }
302
300
  /**
303
301
  * Cancels any scheduled token refresh.
@@ -334,20 +332,20 @@ class j {
334
332
  * Internal wallet secret refresh logic.
335
333
  */
336
334
  async _doRefreshWalletSecret() {
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 };
335
+ const e = c(), t = this.walletSecret?.walletSecretId ?? e.generateRandomId(), n = this.walletSecret?.keyPair ?? await e.createKeyPair(), o = this.authState.expiresAt, a = new Date(o).toISOString();
336
+ this.walletSecret = { walletSecretId: t, keyPair: n, expiresAt: o };
339
337
  try {
340
338
  await w(
341
339
  this.authState.user.userId,
342
340
  {
343
- walletSecretId: r,
341
+ walletSecretId: t,
344
342
  publicKey: n.publicKeyBase64,
345
343
  validUntil: a
346
344
  },
347
345
  { projectID: this.projectId }
348
346
  );
349
- } catch (t) {
350
- throw this.walletSecret = null, t;
347
+ } catch (s) {
348
+ throw this.walletSecret = null, s;
351
349
  }
352
350
  }
353
351
  }
@@ -1,4 +1,4 @@
1
- const o = "0.0.122";
1
+ const o = "0.0.123";
2
2
  export {
3
3
  o as VERSION
4
4
  };
@@ -16,8 +16,12 @@ export declare class AuthManager implements IAuthManager {
16
16
  * Initializes the token manager.
17
17
  *
18
18
  * @param projectId - The project ID.
19
+ * @param options - Options that control initial session refresh behavior.
20
+ * @param options.deferInitialization - Whether to defer the initial session refresh until ensureInitialized is called.
19
21
  */
20
- constructor(projectId: string);
22
+ constructor(projectId: string, options?: {
23
+ deferInitialization?: boolean;
24
+ });
21
25
  /**
22
26
  * Gets the current user, or null if there is no user signed in.
23
27
  *
@@ -98,7 +102,7 @@ export declare class AuthManager implements IAuthManager {
98
102
  clearAuthState(): Promise<void>;
99
103
  /**
100
104
  * Ensures the AuthManager is initialized before proceeding.
101
- * If initialization is already in progress, waits for it to complete.
105
+ * Starts deferred initialization when necessary, otherwise waits for initialization already in progress.
102
106
  */
103
107
  ensureInitialized(): Promise<void>;
104
108
  /**
@@ -6,6 +6,10 @@ import { IAuthManager } from './types.js';
6
6
  * - Otherwise, returns an AuthManager for standard CDP authentication
7
7
  *
8
8
  * @param projectId - The project ID.
9
+ * @param options - Options that control initial session refresh behavior.
10
+ * @param options.deferInitialization - Whether to defer the initial session refresh until ensureInitialized is called.
9
11
  * @returns The appropriate AuthManager instance.
10
12
  */
11
- export declare function createAuthManager(projectId: string): IAuthManager;
13
+ export declare function createAuthManager(projectId: string, options?: {
14
+ deferInitialization?: boolean;
15
+ }): IAuthManager;
@@ -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.122";
5
+ export declare const VERSION = "0.0.123";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-core",
3
- "version": "0.0.122",
3
+ "version": "0.0.123",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",
@@ -29,7 +29,7 @@
29
29
  "ox": "0.8.1",
30
30
  "viem": "^2.47.0",
31
31
  "zustand": "^5.0.6",
32
- "@coinbase/cdp-api-client": "^0.0.122"
32
+ "@coinbase/cdp-api-client": "^0.0.123"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@react-native-async-storage/async-storage": "^2.0.0",