@coinbase/cdp-core 0.0.31 → 0.0.33

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 (274) hide show
  1. package/dist/esm/index.native.js +40 -38
  2. package/dist/esm/index.native10.js +115 -21
  3. package/dist/esm/index.native100.js +6 -9
  4. package/dist/esm/index.native101.js +11 -13
  5. package/dist/esm/index.native102.js +11 -8
  6. package/dist/esm/index.native103.js +7 -14
  7. package/dist/esm/index.native104.js +16 -80
  8. package/dist/esm/index.native105.js +79 -11
  9. package/dist/esm/index.native106.js +12 -35
  10. package/dist/esm/index.native107.js +35 -41
  11. package/dist/esm/index.native108.js +38 -75
  12. package/dist/esm/index.native109.js +81 -0
  13. package/dist/esm/index.native11.js +20 -30
  14. package/dist/esm/index.native12.js +30 -7
  15. package/dist/esm/index.native13.js +9 -15
  16. package/dist/esm/index.native14.js +14 -15
  17. package/dist/esm/index.native15.js +13 -116
  18. package/dist/esm/index.native16.js +116 -11
  19. package/dist/esm/index.native17.js +14 -42
  20. package/dist/esm/index.native18.js +42 -20
  21. package/dist/esm/index.native19.js +20 -172
  22. package/dist/esm/index.native2.js +3 -3
  23. package/dist/esm/index.native20.js +170 -39
  24. package/dist/esm/index.native21.js +41 -49
  25. package/dist/esm/index.native22.js +47 -70
  26. package/dist/esm/index.native23.js +69 -23
  27. package/dist/esm/index.native24.js +22 -156
  28. package/dist/esm/index.native25.js +157 -45
  29. package/dist/esm/index.native26.js +43 -245
  30. package/dist/esm/index.native27.js +247 -53
  31. package/dist/esm/index.native28.js +56 -17
  32. package/dist/esm/index.native29.js +15 -21
  33. package/dist/esm/index.native3.js +40 -30
  34. package/dist/esm/index.native30.js +21 -49
  35. package/dist/esm/index.native31.js +50 -8
  36. package/dist/esm/index.native32.js +8 -17
  37. package/dist/esm/index.native33.js +16 -44
  38. package/dist/esm/index.native34.js +45 -13
  39. package/dist/esm/index.native35.js +13 -55
  40. package/dist/esm/index.native36.js +55 -6
  41. package/dist/esm/index.native37.js +6 -21
  42. package/dist/esm/index.native38.js +21 -11
  43. package/dist/esm/index.native39.js +11 -3
  44. package/dist/esm/index.native4.js +67 -21
  45. package/dist/esm/index.native40.js +3 -3
  46. package/dist/esm/index.native41.js +3 -34
  47. package/dist/esm/index.native42.js +32 -10
  48. package/dist/esm/index.native43.js +12 -4
  49. package/dist/esm/index.native44.js +4 -28
  50. package/dist/esm/index.native45.js +28 -6
  51. package/dist/esm/index.native46.js +6 -24
  52. package/dist/esm/index.native47.js +24 -16
  53. package/dist/esm/index.native48.js +16 -54
  54. package/dist/esm/index.native49.js +53 -22
  55. package/dist/esm/index.native5.js +21 -254
  56. package/dist/esm/index.native50.js +23 -11
  57. package/dist/esm/index.native51.js +10 -26
  58. package/dist/esm/index.native52.js +26 -41
  59. package/dist/esm/index.native53.js +41 -54
  60. package/dist/esm/index.native54.js +54 -126
  61. package/dist/esm/index.native55.js +126 -11
  62. package/dist/esm/index.native56.js +9 -101
  63. package/dist/esm/index.native57.js +104 -6
  64. package/dist/esm/index.native58.js +7 -3
  65. package/dist/esm/index.native59.js +3 -15
  66. package/dist/esm/index.native6.js +262 -176
  67. package/dist/esm/index.native60.js +14 -42
  68. package/dist/esm/index.native61.js +38 -74
  69. package/dist/esm/index.native62.js +79 -2
  70. package/dist/esm/index.native63.js +2 -2
  71. package/dist/esm/index.native64.js +2 -13
  72. package/dist/esm/index.native65.js +8 -33
  73. package/dist/esm/index.native66.js +36 -5
  74. package/dist/esm/index.native67.js +5 -33
  75. package/dist/esm/index.native68.js +34 -8
  76. package/dist/esm/index.native69.js +8 -10
  77. package/dist/esm/index.native7.js +213 -115
  78. package/dist/esm/index.native70.js +10 -11
  79. package/dist/esm/index.native71.js +11 -13
  80. package/dist/esm/index.native72.js +13 -18
  81. package/dist/esm/index.native73.js +18 -5
  82. package/dist/esm/index.native74.js +6 -5
  83. package/dist/esm/index.native75.js +5 -11
  84. package/dist/esm/index.native76.js +10 -54
  85. package/dist/esm/index.native77.js +54 -10
  86. package/dist/esm/index.native78.js +11 -2
  87. package/dist/esm/index.native79.js +2 -45
  88. package/dist/esm/index.native8.js +115 -137
  89. package/dist/esm/index.native80.js +44 -13
  90. package/dist/esm/index.native81.js +14 -2
  91. package/dist/esm/index.native82.js +1 -1
  92. package/dist/esm/index.native83.js +2 -20
  93. package/dist/esm/index.native84.js +103 -79
  94. package/dist/esm/index.native85.js +18 -102
  95. package/dist/esm/index.native86.js +79 -32
  96. package/dist/esm/index.native87.js +32 -6
  97. package/dist/esm/index.native88.js +6 -78
  98. package/dist/esm/index.native89.js +2 -2
  99. package/dist/esm/index.native9.js +138 -113
  100. package/dist/esm/index.native90.js +3 -3
  101. package/dist/esm/index.native92.js +3 -3
  102. package/dist/esm/index.native93.js +1 -1
  103. package/dist/esm/index.native94.js +3 -3
  104. package/dist/esm/index.native95.js +79 -10
  105. package/dist/esm/index.native96.js +10 -5
  106. package/dist/esm/index.native97.js +5 -18
  107. package/dist/esm/index.native98.js +18 -28
  108. package/dist/esm/index.native99.js +26 -6
  109. package/dist/esm/index.web100.js +13 -28
  110. package/dist/esm/index.web101.js +10 -8
  111. package/dist/esm/index.web102.js +17 -11
  112. package/dist/esm/index.web103.js +80 -12
  113. package/dist/esm/index.web104.js +13 -10
  114. package/dist/esm/index.web105.js +36 -17
  115. package/dist/esm/index.web106.js +40 -79
  116. package/dist/esm/index.web26.js +1 -1
  117. package/dist/esm/index.web5.js +131 -109
  118. package/dist/esm/index.web6.js +65 -38
  119. package/dist/esm/index.web75.js +6 -6
  120. package/dist/esm/index.web84.js +1 -1
  121. package/dist/esm/index.web87.js +21 -10
  122. package/dist/esm/index.web88.js +10 -21
  123. package/dist/esm/index.web89.js +19 -9
  124. package/dist/esm/index.web90.js +89 -15
  125. package/dist/esm/index.web91.js +19 -92
  126. package/dist/esm/index.web92.js +115 -18
  127. package/dist/esm/index.web93.js +73 -112
  128. package/dist/esm/index.web94.js +10 -79
  129. package/dist/esm/index.web96.js +18 -13
  130. package/dist/esm/index.web97.js +27 -35
  131. package/dist/esm/index.web98.js +7 -41
  132. package/dist/esm/index.web99.js +11 -18
  133. package/dist/native/index.native.js +40 -38
  134. package/dist/native/index.native10.js +115 -21
  135. package/dist/native/index.native100.js +6 -9
  136. package/dist/native/index.native101.js +11 -13
  137. package/dist/native/index.native102.js +11 -8
  138. package/dist/native/index.native103.js +7 -14
  139. package/dist/native/index.native104.js +16 -80
  140. package/dist/native/index.native105.js +79 -11
  141. package/dist/native/index.native106.js +12 -35
  142. package/dist/native/index.native107.js +35 -41
  143. package/dist/native/index.native108.js +38 -75
  144. package/dist/native/index.native109.js +81 -0
  145. package/dist/native/index.native11.js +20 -30
  146. package/dist/native/index.native12.js +30 -7
  147. package/dist/native/index.native13.js +9 -15
  148. package/dist/native/index.native14.js +14 -15
  149. package/dist/native/index.native15.js +13 -116
  150. package/dist/native/index.native16.js +116 -11
  151. package/dist/native/index.native17.js +14 -42
  152. package/dist/native/index.native18.js +42 -20
  153. package/dist/native/index.native19.js +20 -172
  154. package/dist/native/index.native2.js +3 -3
  155. package/dist/native/index.native20.js +170 -39
  156. package/dist/native/index.native21.js +41 -49
  157. package/dist/native/index.native22.js +47 -70
  158. package/dist/native/index.native23.js +69 -23
  159. package/dist/native/index.native24.js +22 -156
  160. package/dist/native/index.native25.js +157 -45
  161. package/dist/native/index.native26.js +43 -245
  162. package/dist/native/index.native27.js +247 -53
  163. package/dist/native/index.native28.js +56 -17
  164. package/dist/native/index.native29.js +15 -21
  165. package/dist/native/index.native3.js +40 -30
  166. package/dist/native/index.native30.js +21 -49
  167. package/dist/native/index.native31.js +50 -8
  168. package/dist/native/index.native32.js +8 -17
  169. package/dist/native/index.native33.js +16 -44
  170. package/dist/native/index.native34.js +45 -13
  171. package/dist/native/index.native35.js +13 -55
  172. package/dist/native/index.native36.js +55 -6
  173. package/dist/native/index.native37.js +6 -21
  174. package/dist/native/index.native38.js +21 -11
  175. package/dist/native/index.native39.js +11 -3
  176. package/dist/native/index.native4.js +67 -21
  177. package/dist/native/index.native40.js +3 -3
  178. package/dist/native/index.native41.js +3 -34
  179. package/dist/native/index.native42.js +32 -10
  180. package/dist/native/index.native43.js +12 -4
  181. package/dist/native/index.native44.js +4 -28
  182. package/dist/native/index.native45.js +28 -6
  183. package/dist/native/index.native46.js +6 -24
  184. package/dist/native/index.native47.js +24 -16
  185. package/dist/native/index.native48.js +16 -54
  186. package/dist/native/index.native49.js +53 -22
  187. package/dist/native/index.native5.js +21 -254
  188. package/dist/native/index.native50.js +23 -11
  189. package/dist/native/index.native51.js +10 -26
  190. package/dist/native/index.native52.js +26 -41
  191. package/dist/native/index.native53.js +41 -54
  192. package/dist/native/index.native54.js +54 -126
  193. package/dist/native/index.native55.js +126 -11
  194. package/dist/native/index.native56.js +9 -101
  195. package/dist/native/index.native57.js +104 -6
  196. package/dist/native/index.native58.js +7 -3
  197. package/dist/native/index.native59.js +3 -15
  198. package/dist/native/index.native6.js +262 -176
  199. package/dist/native/index.native60.js +14 -42
  200. package/dist/native/index.native61.js +38 -74
  201. package/dist/native/index.native62.js +79 -2
  202. package/dist/native/index.native63.js +2 -2
  203. package/dist/native/index.native64.js +2 -13
  204. package/dist/native/index.native65.js +8 -33
  205. package/dist/native/index.native66.js +36 -5
  206. package/dist/native/index.native67.js +5 -33
  207. package/dist/native/index.native68.js +34 -8
  208. package/dist/native/index.native69.js +8 -10
  209. package/dist/native/index.native7.js +213 -115
  210. package/dist/native/index.native70.js +10 -11
  211. package/dist/native/index.native71.js +11 -13
  212. package/dist/native/index.native72.js +13 -18
  213. package/dist/native/index.native73.js +18 -5
  214. package/dist/native/index.native74.js +6 -5
  215. package/dist/native/index.native75.js +5 -11
  216. package/dist/native/index.native76.js +10 -54
  217. package/dist/native/index.native77.js +54 -10
  218. package/dist/native/index.native78.js +11 -2
  219. package/dist/native/index.native79.js +2 -45
  220. package/dist/native/index.native8.js +115 -137
  221. package/dist/native/index.native80.js +44 -13
  222. package/dist/native/index.native81.js +14 -2
  223. package/dist/native/index.native82.js +1 -1
  224. package/dist/native/index.native83.js +2 -20
  225. package/dist/native/index.native84.js +103 -79
  226. package/dist/native/index.native85.js +18 -102
  227. package/dist/native/index.native86.js +79 -32
  228. package/dist/native/index.native87.js +32 -6
  229. package/dist/native/index.native88.js +6 -78
  230. package/dist/native/index.native89.js +2 -2
  231. package/dist/native/index.native9.js +138 -113
  232. package/dist/native/index.native90.js +3 -3
  233. package/dist/native/index.native92.js +3 -3
  234. package/dist/native/index.native93.js +1 -1
  235. package/dist/native/index.native94.js +3 -3
  236. package/dist/native/index.native95.js +79 -10
  237. package/dist/native/index.native96.js +10 -5
  238. package/dist/native/index.native97.js +5 -18
  239. package/dist/native/index.native98.js +18 -28
  240. package/dist/native/index.native99.js +26 -6
  241. package/dist/native-types/auth/authManager.d.ts +3 -0
  242. package/dist/native-types/platform/native/secureStorage.d.ts +2 -0
  243. package/dist/native-types/platform/types.d.ts +7 -0
  244. package/dist/types/auth/authManager.d.ts +3 -0
  245. package/dist/types/platform/native/secureStorage.d.ts +2 -0
  246. package/dist/types/platform/types.d.ts +7 -0
  247. package/dist/web/index.web100.js +13 -28
  248. package/dist/web/index.web101.js +10 -8
  249. package/dist/web/index.web102.js +17 -11
  250. package/dist/web/index.web103.js +80 -12
  251. package/dist/web/index.web104.js +13 -10
  252. package/dist/web/index.web105.js +36 -17
  253. package/dist/web/index.web106.js +40 -79
  254. package/dist/web/index.web26.js +1 -1
  255. package/dist/web/index.web5.js +131 -109
  256. package/dist/web/index.web6.js +65 -38
  257. package/dist/web/index.web75.js +6 -6
  258. package/dist/web/index.web84.js +1 -1
  259. package/dist/web/index.web87.js +21 -10
  260. package/dist/web/index.web88.js +10 -21
  261. package/dist/web/index.web89.js +19 -9
  262. package/dist/web/index.web90.js +89 -15
  263. package/dist/web/index.web91.js +19 -92
  264. package/dist/web/index.web92.js +115 -18
  265. package/dist/web/index.web93.js +73 -112
  266. package/dist/web/index.web94.js +10 -79
  267. package/dist/web/index.web96.js +18 -13
  268. package/dist/web/index.web97.js +27 -35
  269. package/dist/web/index.web98.js +7 -41
  270. package/dist/web/index.web99.js +11 -18
  271. package/dist/web-types/auth/authManager.d.ts +3 -0
  272. package/dist/web-types/platform/native/secureStorage.d.ts +2 -0
  273. package/dist/web-types/platform/types.d.ts +7 -0
  274. package/package.json +8 -4
@@ -1,14 +1,13 @@
1
- import { commitmentToVersionedHash as i } from "./index.native87.js";
2
- function r(o) {
3
- const { commitments: t, version: n } = o, e = o.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
4
- for (const m of t)
5
- s.push(i({
6
- commitment: m,
7
- to: e,
8
- version: n
9
- }));
10
- return s;
1
+ import { hexToBytes as b } from "./index.native36.js";
2
+ import { bytesToHex as y } from "./index.native34.js";
3
+ function h(t) {
4
+ const { kzg: m } = t, c = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), s = typeof t.blobs[0] == "string" ? t.blobs.map((o) => b(o)) : t.blobs, i = typeof t.commitments[0] == "string" ? t.commitments.map((o) => b(o)) : t.commitments, n = [];
5
+ for (let o = 0; o < s.length; o++) {
6
+ const f = s[o], l = i[o];
7
+ n.push(Uint8Array.from(m.computeBlobKzgProof(f, l)));
8
+ }
9
+ return c === "bytes" ? n : n.map((o) => y(o));
11
10
  }
12
11
  export {
13
- r as commitmentsToVersionedHashes
12
+ h as blobsToProofs
14
13
  };
@@ -1,16 +1,14 @@
1
- import { blobsToCommitments as f } from "./index.native68.js";
2
- import { blobsToProofs as l } from "./index.native69.js";
3
- import { toBlobs as p } from "./index.native86.js";
4
- function k(t) {
5
- const { data: i, kzg: n, to: m } = t, s = t.blobs ?? p({ data: i, to: m }), b = t.commitments ?? f({ blobs: s, kzg: n, to: m }), r = t.proofs ?? l({ blobs: s, commitments: b, kzg: n, to: m }), c = [];
6
- for (let o = 0; o < s.length; o++)
7
- c.push({
8
- blob: s[o],
9
- commitment: b[o],
10
- proof: r[o]
11
- });
12
- return c;
1
+ import { commitmentToVersionedHash as i } from "./index.native88.js";
2
+ function r(o) {
3
+ const { commitments: t, version: n } = o, e = o.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
4
+ for (const m of t)
5
+ s.push(i({
6
+ commitment: m,
7
+ to: e,
8
+ version: n
9
+ }));
10
+ return s;
13
11
  }
14
12
  export {
15
- k as toBlobSidecars
13
+ r as commitmentsToVersionedHashes
16
14
  };
@@ -1,21 +1,16 @@
1
- import { InvalidAddressError as s } from "./index.native64.js";
2
- import { InvalidStorageKeySizeError as l } from "./index.native60.js";
3
- import { isAddress as f } from "./index.native38.js";
4
- function a(r) {
5
- if (!r || r.length === 0)
6
- return [];
7
- const n = [];
8
- for (let o = 0; o < r.length; o++) {
9
- const { address: i, storageKeys: e } = r[o];
10
- for (let t = 0; t < e.length; t++)
11
- if (e[t].length - 2 !== 64)
12
- throw new l({ storageKey: e[t] });
13
- if (!f(i, { strict: !1 }))
14
- throw new s({ address: i });
15
- n.push([i, e]);
16
- }
17
- return n;
1
+ import { blobsToCommitments as f } from "./index.native69.js";
2
+ import { blobsToProofs as l } from "./index.native70.js";
3
+ import { toBlobs as p } from "./index.native87.js";
4
+ function k(t) {
5
+ const { data: i, kzg: n, to: m } = t, s = t.blobs ?? p({ data: i, to: m }), b = t.commitments ?? f({ blobs: s, kzg: n, to: m }), r = t.proofs ?? l({ blobs: s, commitments: b, kzg: n, to: m }), c = [];
6
+ for (let o = 0; o < s.length; o++)
7
+ c.push({
8
+ blob: s[o],
9
+ commitment: b[o],
10
+ proof: r[o]
11
+ });
12
+ return c;
18
13
  }
19
14
  export {
20
- a as serializeAccessList
15
+ k as toBlobSidecars
21
16
  };
@@ -1,8 +1,21 @@
1
- import { gweiUnits as i } from "./index.native74.js";
2
- import { formatUnits as o } from "./index.native75.js";
3
- function f(r, t = "wei") {
4
- return o(r, i[t]);
1
+ import { InvalidAddressError as s } from "./index.native65.js";
2
+ import { InvalidStorageKeySizeError as l } from "./index.native61.js";
3
+ import { isAddress as f } from "./index.native39.js";
4
+ function a(r) {
5
+ if (!r || r.length === 0)
6
+ return [];
7
+ const n = [];
8
+ for (let o = 0; o < r.length; o++) {
9
+ const { address: i, storageKeys: e } = r[o];
10
+ for (let t = 0; t < e.length; t++)
11
+ if (e[t].length - 2 !== 64)
12
+ throw new l({ storageKey: e[t] });
13
+ if (!f(i, { strict: !1 }))
14
+ throw new s({ address: i });
15
+ n.push([i, e]);
16
+ }
17
+ return n;
5
18
  }
6
19
  export {
7
- f as formatGwei
20
+ a as serializeAccessList
8
21
  };
@@ -1,7 +1,8 @@
1
- const e = {
2
- ether: -9,
3
- wei: 9
4
- };
1
+ import { gweiUnits as i } from "./index.native75.js";
2
+ import { formatUnits as o } from "./index.native76.js";
3
+ function f(r, t = "wei") {
4
+ return o(r, i[t]);
5
+ }
5
6
  export {
6
- e as gweiUnits
7
+ f as formatGwei
7
8
  };
@@ -1,13 +1,7 @@
1
- function a(r, n) {
2
- let t = r.toString();
3
- const i = t.startsWith("-");
4
- i && (t = t.slice(1)), t = t.padStart(n, "0");
5
- let [l, e] = [
6
- t.slice(0, t.length - n),
7
- t.slice(t.length - n)
8
- ];
9
- return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
10
- }
1
+ const e = {
2
+ ether: -9,
3
+ wei: 9
4
+ };
11
5
  export {
12
- a as formatUnits
6
+ e as gweiUnits
13
7
  };
@@ -1,57 +1,13 @@
1
- import { encode as d } from "./index.native89.js";
2
- import y from "./index.native90.js";
3
- import b from "./index.native91.js";
4
- import { JWSInvalid as r } from "./index.native29.js";
5
- import { encoder as s, concat as u, decoder as h } from "./index.native77.js";
6
- import g from "./index.native92.js";
7
- import H from "./index.native93.js";
8
- import P from "./index.native94.js";
9
- class x {
10
- #r;
11
- #e;
12
- #t;
13
- constructor(e) {
14
- if (!(e instanceof Uint8Array))
15
- throw new TypeError("payload must be an instance of Uint8Array");
16
- this.#r = e;
17
- }
18
- setProtectedHeader(e) {
19
- if (this.#e)
20
- throw new TypeError("setProtectedHeader can only be called once");
21
- return this.#e = e, this;
22
- }
23
- setUnprotectedHeader(e) {
24
- if (this.#t)
25
- throw new TypeError("setUnprotectedHeader can only be called once");
26
- return this.#t = e, this;
27
- }
28
- async sign(e, l) {
29
- if (!this.#e && !this.#t)
30
- throw new r("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
31
- if (!b(this.#e, this.#t))
32
- throw new r("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
33
- const c = {
34
- ...this.#e,
35
- ...this.#t
36
- }, p = H(r, /* @__PURE__ */ new Map([["b64", !0]]), l?.crit, this.#e, c);
37
- let o = !0;
38
- if (p.has("b64") && (o = this.#e.b64, typeof o != "boolean"))
39
- throw new r('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
40
- const { alg: t } = c;
41
- if (typeof t != "string" || !t)
42
- throw new r('JWS "alg" (Algorithm) Header Parameter missing or invalid');
43
- g(t, e, "sign");
44
- let i = this.#r;
45
- o && (i = s.encode(d(i)));
46
- let n;
47
- this.#e ? n = s.encode(d(JSON.stringify(this.#e))) : n = s.encode("");
48
- const f = u(n, s.encode("."), i), m = await P(e, t), w = await y(t, m, f), a = {
49
- signature: d(w),
50
- payload: ""
51
- };
52
- return o && (a.payload = h.decode(i)), this.#t && (a.header = this.#t), this.#e && (a.protected = h.decode(n)), a;
53
- }
1
+ function a(r, n) {
2
+ let t = r.toString();
3
+ const i = t.startsWith("-");
4
+ i && (t = t.slice(1)), t = t.padStart(n, "0");
5
+ let [l, e] = [
6
+ t.slice(0, t.length - n),
7
+ t.slice(t.length - n)
8
+ ];
9
+ return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
54
10
  }
55
11
  export {
56
- x as FlattenedSign
12
+ a as formatUnits
57
13
  };
@@ -1,13 +1,57 @@
1
- const d = new TextEncoder(), s = new TextDecoder();
2
- function f(...n) {
3
- const c = n.reduce((e, { length: r }) => e + r, 0), t = new Uint8Array(c);
4
- let o = 0;
5
- for (const e of n)
6
- t.set(e, o), o += e.length;
7
- return t;
1
+ import { encode as d } from "./index.native89.js";
2
+ import y from "./index.native90.js";
3
+ import b from "./index.native91.js";
4
+ import { JWSInvalid as r } from "./index.native30.js";
5
+ import { encoder as s, concat as u, decoder as h } from "./index.native78.js";
6
+ import g from "./index.native92.js";
7
+ import H from "./index.native93.js";
8
+ import P from "./index.native94.js";
9
+ class x {
10
+ #r;
11
+ #e;
12
+ #t;
13
+ constructor(e) {
14
+ if (!(e instanceof Uint8Array))
15
+ throw new TypeError("payload must be an instance of Uint8Array");
16
+ this.#r = e;
17
+ }
18
+ setProtectedHeader(e) {
19
+ if (this.#e)
20
+ throw new TypeError("setProtectedHeader can only be called once");
21
+ return this.#e = e, this;
22
+ }
23
+ setUnprotectedHeader(e) {
24
+ if (this.#t)
25
+ throw new TypeError("setUnprotectedHeader can only be called once");
26
+ return this.#t = e, this;
27
+ }
28
+ async sign(e, l) {
29
+ if (!this.#e && !this.#t)
30
+ throw new r("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
31
+ if (!b(this.#e, this.#t))
32
+ throw new r("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
33
+ const c = {
34
+ ...this.#e,
35
+ ...this.#t
36
+ }, p = H(r, /* @__PURE__ */ new Map([["b64", !0]]), l?.crit, this.#e, c);
37
+ let o = !0;
38
+ if (p.has("b64") && (o = this.#e.b64, typeof o != "boolean"))
39
+ throw new r('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
40
+ const { alg: t } = c;
41
+ if (typeof t != "string" || !t)
42
+ throw new r('JWS "alg" (Algorithm) Header Parameter missing or invalid');
43
+ g(t, e, "sign");
44
+ let i = this.#r;
45
+ o && (i = s.encode(d(i)));
46
+ let n;
47
+ this.#e ? n = s.encode(d(JSON.stringify(this.#e))) : n = s.encode("");
48
+ const f = u(n, s.encode("."), i), m = await P(e, t), w = await y(t, m, f), a = {
49
+ signature: d(w),
50
+ payload: ""
51
+ };
52
+ return o && (a.payload = h.decode(i)), this.#t && (a.header = this.#t), this.#e && (a.protected = h.decode(n)), a;
53
+ }
8
54
  }
9
55
  export {
10
- f as concat,
11
- s as decoder,
12
- d as encoder
56
+ x as FlattenedSign
13
57
  };
@@ -1,4 +1,13 @@
1
- const o = (e) => Math.floor(e.getTime() / 1e3);
1
+ const d = new TextEncoder(), s = new TextDecoder();
2
+ function f(...n) {
3
+ const c = n.reduce((e, { length: r }) => e + r, 0), t = new Uint8Array(c);
4
+ let o = 0;
5
+ for (const e of n)
6
+ t.set(e, o), o += e.length;
7
+ return t;
8
+ }
2
9
  export {
3
- o as default
10
+ f as concat,
11
+ s as decoder,
12
+ d as encoder
4
13
  };
@@ -1,47 +1,4 @@
1
- const o = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, t = (c) => {
2
- const s = o.exec(c);
3
- if (!s || s[4] && s[1])
4
- throw new TypeError("Invalid time period format");
5
- const a = parseFloat(s[2]), r = s[3].toLowerCase();
6
- let e;
7
- switch (r) {
8
- case "sec":
9
- case "secs":
10
- case "second":
11
- case "seconds":
12
- case "s":
13
- e = Math.round(a);
14
- break;
15
- case "minute":
16
- case "minutes":
17
- case "min":
18
- case "mins":
19
- case "m":
20
- e = Math.round(a * 60);
21
- break;
22
- case "hour":
23
- case "hours":
24
- case "hr":
25
- case "hrs":
26
- case "h":
27
- e = Math.round(a * 3600);
28
- break;
29
- case "day":
30
- case "days":
31
- case "d":
32
- e = Math.round(a * 86400);
33
- break;
34
- case "week":
35
- case "weeks":
36
- case "w":
37
- e = Math.round(a * 604800);
38
- break;
39
- default:
40
- e = Math.round(a * 31557600);
41
- break;
42
- }
43
- return s[1] === "-" || s[4] === "ago" ? -e : e;
44
- };
1
+ const o = (e) => Math.floor(e.getTime() / 1e3);
45
2
  export {
46
- t as default
3
+ o as default
47
4
  };
@@ -1,143 +1,121 @@
1
- import "ox";
2
- import "viem";
3
- import "zustand";
1
+ import { Provider as h } from "ox";
2
+ import { http as m } from "viem";
3
+ import { create as p } from "zustand";
4
+ import { subscribeWithSelector as g, persist as f } from "./index.native25.js";
5
+ import { validateRequest as I, EIP1193ProviderError as S, STANDARD_ERROR_CODES as w } from "./index.native9.js";
6
+ import { EventEmitter as C } from "./index.native26.js";
7
+ import { getPlatformStorage as b } from "./index.native5.js";
4
8
  import "@coinbase/cdp-api-client";
5
- import { getCurrentUser as u } from "./index.native5.js";
6
- import "./index.native7.js";
7
- const r = {
8
- rpc: {
9
- invalidInput: -32e3,
10
- resourceNotFound: -32001,
11
- resourceUnavailable: -32002,
12
- transactionRejected: -32003,
13
- methodNotSupported: -32004,
14
- limitExceeded: -32005,
15
- parse: -32700,
16
- invalidRequest: -32600,
17
- methodNotFound: -32601,
18
- invalidParams: -32602,
19
- internal: -32603
20
- },
21
- provider: {
22
- userRejectedRequest: 4001,
23
- unauthorized: 4100,
24
- unsupportedMethod: 4200,
25
- disconnected: 4900,
26
- chainDisconnected: 4901,
27
- unsupportedChain: 4902
28
- }
29
- };
30
- class o extends Error {
31
- /**
32
- * The error code from EIP1193ErrorCode enum.
33
- */
34
- code;
35
- /**
36
- * Creates a new EIP-1193 Provider error.
37
- *
38
- * @param code - The error code from EIP1193ErrorCode enum.
39
- * @param message - The error message.
40
- */
41
- constructor(t, n) {
42
- super(n), this.code = t;
43
- }
9
+ import { handleGetCapabilities as _, handleGetCallsStatus as A, handleSendCalls as v, handleChainId as D, handleSignTypedData as P, handleEthSign as E, handleSwitchEthereumChain as R, handleDisconnect as y, handleSendTransaction as T, handlePersonalSign as q, handleRequestAccounts as G, handleAccounts as L } from "./index.native27.js";
10
+ import { onAuthStateChange as M } from "./index.native6.js";
11
+ import { baseSepolia as l } from "./index.native28.js";
12
+ function N(r, n, s) {
13
+ n.subscribe(
14
+ (e) => e.chainId,
15
+ (e, t) => {
16
+ e !== t && r.emit("chainChanged", e);
17
+ }
18
+ ), n.subscribe(
19
+ (e) => e.user,
20
+ (e, t) => {
21
+ if (!(e?.userId === t?.userId && e?.evmAccounts?.length === t?.evmAccounts?.length)) {
22
+ if (!e && t) {
23
+ r.emit("disconnect", new h.DisconnectedError());
24
+ return;
25
+ }
26
+ if (e && e.evmAccounts?.length && (!t || t.evmAccounts?.length === 0)) {
27
+ const a = n.getState().chainId;
28
+ r.emit("connect", { chainId: a });
29
+ return;
30
+ }
31
+ }
32
+ }
33
+ );
34
+ const { chainId: i, setChainId: o } = n.getState(), d = i || s.chains[0].id;
35
+ return i || o(d), h.from({
36
+ request: async (e) => {
37
+ I(e, s);
38
+ const t = e;
39
+ switch (t.method) {
40
+ case "eth_accounts":
41
+ return L();
42
+ case "eth_requestAccounts":
43
+ return G(r, n);
44
+ case "personal_sign":
45
+ return q(t.params);
46
+ case "eth_sendTransaction":
47
+ return T(t.params, n, s.transports);
48
+ case "wallet_disconnect":
49
+ return y();
50
+ case "wallet_switchEthereumChain":
51
+ return R(t.params, n);
52
+ case "eth_sign":
53
+ return E(t.params);
54
+ case "eth_signTypedData_v4":
55
+ return P(t.params);
56
+ case "eth_chainId":
57
+ return D(n);
58
+ case "wallet_sendCalls":
59
+ return v(t.params, n);
60
+ case "wallet_getCallsStatus":
61
+ return A(t.params, n);
62
+ case "wallet_getCapabilities":
63
+ return _();
64
+ // Catch-all for any unknown method
65
+ default:
66
+ throw new S(
67
+ w.provider.unsupportedMethod,
68
+ `Method ${t.method} not supported`
69
+ );
70
+ }
71
+ },
72
+ // Event emitter methods - only the ones required by the interface
73
+ on: r.on.bind(r),
74
+ removeListener: r.removeListener.bind(r)
75
+ });
44
76
  }
45
- class c extends Error {
46
- /**
47
- * The error code from RPCErrorCode type.
48
- */
49
- code;
50
- /**
51
- * Creates a new RPC Invalid Params error.
52
- *
53
- * @param code - The error code from RPCErrorCode type.
54
- * @param message - The error message.
55
- */
56
- constructor(t, n) {
57
- super(n), this.code = t;
77
+ const u = {
78
+ chains: [l],
79
+ transports: {
80
+ [l.id]: m()
58
81
  }
59
- }
60
- const p = /* @__PURE__ */ new Set([
61
- "eth_accounts",
62
- "eth_requestAccounts",
63
- "personal_sign",
64
- "eth_sendTransaction",
65
- "eth_signTypedData_v4",
66
- "eth_chainId",
67
- "eth_sign",
68
- "wallet_disconnect",
69
- "wallet_switchEthereumChain",
70
- "wallet_sendCalls",
71
- "wallet_getCallsStatus",
72
- "wallet_getCapabilities"
73
- ]);
74
- function _(e, { chains: t }) {
75
- const { method: n, params: a } = e;
76
- if (typeof n != "string" || n.length === 0)
77
- throw new c(
78
- r.rpc.invalidParams,
79
- "'method' must be a non-empty string."
80
- );
81
- const s = (a ?? [])[0]?.chainId;
82
- if (typeof s == "string" && !t.some((d) => d.id === Number.parseInt(s, 16)))
83
- throw new o(
84
- r.provider.unsupportedChain,
85
- `Chain ${s} not supported - make sure the provider is configured with the correct chains.`
86
- );
87
- if (a !== void 0 && !Array.isArray(a))
88
- throw new c(
89
- r.rpc.invalidParams,
90
- "'params' must be an array if provided."
91
- );
92
- if (!p.has(n))
93
- throw new o(
94
- r.provider.unsupportedMethod,
95
- `Method ${e.method} not supported`
96
- );
97
- }
98
- async function i() {
99
- const e = await u();
100
- if (!e)
101
- throw new o(
102
- r.provider.unauthorized,
103
- "User not connected"
104
- );
105
- return e;
106
- }
107
- async function E(e) {
108
- const t = await i();
109
- if (!t.evmAccounts?.includes(e))
110
- throw new o(
111
- r.provider.unauthorized,
112
- "Address not owned by user"
113
- );
114
- return t;
115
- }
116
- async function y() {
117
- const e = await i();
118
- if (!e.evmAccounts?.[0])
119
- throw new o(
120
- r.provider.unauthorized,
121
- "No EVM accounts available"
122
- );
123
- return e;
124
- }
125
- async function A() {
126
- const e = await i();
127
- if (!e.evmSmartAccounts?.[0])
128
- throw new o(
129
- r.provider.unauthorized,
130
- "No EVM smart accounts available"
131
- );
132
- return e;
82
+ };
83
+ function K(r) {
84
+ if (r?.chains.length === 0)
85
+ throw new Error("At least one chain must be configured");
86
+ const n = r?.chains ?? u.chains, s = r?.transports ?? u.transports;
87
+ if (n.length === 0)
88
+ throw new Error("No chains found in configuration");
89
+ const i = new C(), o = b(), d = {
90
+ getItem: (t) => o.getItem(t),
91
+ setItem: (t, a) => o.setItem(t, a),
92
+ removeItem: (t) => o.removeItem(t)
93
+ }, c = p()(
94
+ g(
95
+ f(
96
+ (t) => ({
97
+ chainId: n[0].id,
98
+ setChainId: (a) => t({ chainId: a }),
99
+ chains: n,
100
+ user: null,
101
+ setUser: (a) => t({ user: a })
102
+ }),
103
+ {
104
+ name: "cdp-provider-store",
105
+ storage: d
106
+ }
107
+ )
108
+ )
109
+ );
110
+ return c.persist.rehydrate(), M((t) => {
111
+ c.getState().setUser(t);
112
+ }), {
113
+ provider: N(i, c, {
114
+ chains: n,
115
+ transports: s
116
+ })
117
+ };
133
118
  }
134
119
  export {
135
- o as EIP1193ProviderError,
136
- c as RPCRequestError,
137
- r as STANDARD_ERROR_CODES,
138
- _ as validateRequest,
139
- i as validateUserConnected,
140
- y as validateUserHasEvmAccount,
141
- A as validateUserHasEvmSmartAccount,
142
- E as validateUserOwnsAddress
120
+ K as createCDPEmbeddedWallet
143
121
  };