@coinbase/cdp-core 0.0.48 → 0.0.49

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 (271) hide show
  1. package/dist/esm/index.native102.js +19 -77
  2. package/dist/esm/index.native103.js +9 -9
  3. package/dist/esm/index.native104.js +19 -20
  4. package/dist/esm/index.native105.js +93 -9
  5. package/dist/esm/index.native106.js +19 -18
  6. package/dist/esm/index.native107.js +105 -81
  7. package/dist/esm/index.native108.js +9 -20
  8. package/dist/esm/index.native109.js +73 -112
  9. package/dist/esm/index.native111.js +18 -13
  10. package/dist/esm/index.native112.js +27 -35
  11. package/dist/esm/index.native113.js +7 -41
  12. package/dist/esm/index.native114.js +11 -18
  13. package/dist/esm/index.native115.js +13 -28
  14. package/dist/esm/index.native116.js +10 -8
  15. package/dist/esm/index.native117.js +17 -11
  16. package/dist/esm/index.native118.js +80 -12
  17. package/dist/esm/index.native119.js +13 -10
  18. package/dist/esm/index.native12.js +4 -4
  19. package/dist/esm/index.native120.js +36 -17
  20. package/dist/esm/index.native121.js +40 -79
  21. package/dist/esm/index.native17.js +1 -1
  22. package/dist/esm/index.native18.js +33 -24
  23. package/dist/esm/index.native2.js +8 -6
  24. package/dist/esm/index.native22.js +1 -1
  25. package/dist/esm/index.native3.js +2 -2
  26. package/dist/esm/index.native32.js +940 -149
  27. package/dist/esm/index.native33.js +2 -48
  28. package/dist/esm/index.native34.js +43 -244
  29. package/dist/esm/index.native35.js +27 -55
  30. package/dist/esm/index.native36.js +149 -940
  31. package/dist/esm/index.native37.js +48 -2
  32. package/dist/esm/index.native38.js +244 -43
  33. package/dist/esm/index.native39.js +55 -27
  34. package/dist/esm/index.native4.js +4 -2
  35. package/dist/esm/index.native5.js +19 -17
  36. package/dist/esm/index.native6.js +10 -8
  37. package/dist/esm/index.native90.js +6 -6
  38. package/dist/esm/index.native99.js +1 -1
  39. package/dist/esm/index.web100.js +2 -7
  40. package/dist/esm/index.web101.js +17 -17
  41. package/dist/esm/index.web102.js +20 -10
  42. package/dist/esm/index.web103.js +80 -20
  43. package/dist/esm/index.web104.js +99 -89
  44. package/dist/esm/index.web105.js +32 -20
  45. package/dist/esm/index.web106.js +7 -118
  46. package/dist/esm/index.web107.js +10 -79
  47. package/dist/esm/index.web108.js +79 -10
  48. package/dist/esm/index.web109.js +18 -5
  49. package/dist/esm/index.web110.js +28 -18
  50. package/dist/esm/index.web111.js +6 -26
  51. package/dist/esm/index.web112.js +9 -6
  52. package/dist/esm/index.web113.js +13 -11
  53. package/dist/esm/index.web114.js +8 -11
  54. package/dist/esm/index.web115.js +14 -7
  55. package/dist/esm/index.web116.js +80 -16
  56. package/dist/esm/index.web117.js +5 -81
  57. package/dist/esm/index.web119.js +4 -4
  58. package/dist/esm/index.web120.js +5 -5
  59. package/dist/esm/index.web16.js +1 -1
  60. package/dist/esm/index.web17.js +33 -24
  61. package/dist/esm/index.web2.js +10 -8
  62. package/dist/esm/index.web21.js +1 -1
  63. package/dist/esm/index.web25.js +13 -13
  64. package/dist/esm/index.web27.js +3 -3
  65. package/dist/esm/index.web3.js +4 -2
  66. package/dist/esm/index.web30.js +2 -2
  67. package/dist/esm/index.web34.js +2 -2
  68. package/dist/esm/index.web35.js +16 -950
  69. package/dist/esm/index.web36.js +23 -2
  70. package/dist/esm/index.web37.js +50 -49
  71. package/dist/esm/index.web38.js +950 -27
  72. package/dist/esm/index.web39.js +2 -17
  73. package/dist/esm/index.web4.js +12 -12
  74. package/dist/esm/index.web40.js +48 -21
  75. package/dist/esm/index.web41.js +27 -50
  76. package/dist/esm/index.web44.js +54 -8
  77. package/dist/esm/index.web45.js +9 -16
  78. package/dist/esm/index.web46.js +2 -46
  79. package/dist/esm/index.web47.js +45 -14
  80. package/dist/esm/index.web48.js +12 -54
  81. package/dist/esm/index.web49.js +8 -6
  82. package/dist/esm/index.web5.js +4 -2
  83. package/dist/esm/index.web50.js +16 -20
  84. package/dist/esm/index.web51.js +45 -11
  85. package/dist/esm/index.web52.js +13 -3
  86. package/dist/esm/index.web53.js +55 -3
  87. package/dist/esm/index.web54.js +6 -34
  88. package/dist/esm/index.web55.js +19 -10
  89. package/dist/esm/index.web56.js +11 -4
  90. package/dist/esm/index.web57.js +3 -28
  91. package/dist/esm/index.web58.js +3 -6
  92. package/dist/esm/index.web59.js +34 -24
  93. package/dist/esm/index.web60.js +12 -16
  94. package/dist/esm/index.web61.js +4 -54
  95. package/dist/esm/index.web62.js +25 -20
  96. package/dist/esm/index.web63.js +6 -11
  97. package/dist/esm/index.web64.js +23 -26
  98. package/dist/esm/index.web65.js +16 -42
  99. package/dist/esm/index.web66.js +52 -53
  100. package/dist/esm/index.web67.js +23 -127
  101. package/dist/esm/index.web68.js +11 -12
  102. package/dist/esm/index.web69.js +27 -104
  103. package/dist/esm/index.web70.js +42 -6
  104. package/dist/esm/index.web71.js +56 -3
  105. package/dist/esm/index.web72.js +127 -14
  106. package/dist/esm/index.web73.js +9 -39
  107. package/dist/esm/index.web74.js +100 -74
  108. package/dist/esm/index.web75.js +7 -2
  109. package/dist/esm/index.web76.js +3 -2
  110. package/dist/esm/index.web77.js +14 -12
  111. package/dist/esm/index.web78.js +34 -29
  112. package/dist/esm/index.web79.js +77 -5
  113. package/dist/esm/index.web80.js +2 -35
  114. package/dist/esm/index.web81.js +2 -9
  115. package/dist/esm/index.web82.js +11 -9
  116. package/dist/esm/index.web83.js +37 -11
  117. package/dist/esm/index.web84.js +6 -13
  118. package/dist/esm/index.web85.js +33 -17
  119. package/dist/esm/index.web86.js +8 -5
  120. package/dist/esm/index.web87.js +11 -5
  121. package/dist/esm/index.web88.js +11 -10
  122. package/dist/esm/index.web89.js +13 -54
  123. package/dist/esm/index.web90.js +18 -10
  124. package/dist/esm/index.web91.js +6 -2
  125. package/dist/esm/index.web92.js +4 -44
  126. package/dist/esm/index.web93.js +10 -13
  127. package/dist/esm/index.web94.js +21 -2
  128. package/dist/esm/index.web95.js +10 -21
  129. package/dist/esm/index.web96.js +19 -19
  130. package/dist/esm/index.web97.js +94 -80
  131. package/dist/esm/index.web98.js +20 -103
  132. package/dist/esm/index.web99.js +115 -30
  133. package/dist/native/index.native102.js +19 -77
  134. package/dist/native/index.native103.js +9 -9
  135. package/dist/native/index.native104.js +19 -20
  136. package/dist/native/index.native105.js +93 -9
  137. package/dist/native/index.native106.js +19 -18
  138. package/dist/native/index.native107.js +105 -81
  139. package/dist/native/index.native108.js +9 -20
  140. package/dist/native/index.native109.js +73 -112
  141. package/dist/native/index.native111.js +18 -13
  142. package/dist/native/index.native112.js +27 -35
  143. package/dist/native/index.native113.js +7 -41
  144. package/dist/native/index.native114.js +11 -18
  145. package/dist/native/index.native115.js +13 -28
  146. package/dist/native/index.native116.js +10 -8
  147. package/dist/native/index.native117.js +17 -11
  148. package/dist/native/index.native118.js +80 -12
  149. package/dist/native/index.native119.js +13 -10
  150. package/dist/native/index.native12.js +4 -4
  151. package/dist/native/index.native120.js +36 -17
  152. package/dist/native/index.native121.js +40 -79
  153. package/dist/native/index.native17.js +1 -1
  154. package/dist/native/index.native18.js +33 -24
  155. package/dist/native/index.native2.js +8 -6
  156. package/dist/native/index.native22.js +1 -1
  157. package/dist/native/index.native3.js +2 -2
  158. package/dist/native/index.native32.js +940 -149
  159. package/dist/native/index.native33.js +2 -48
  160. package/dist/native/index.native34.js +43 -244
  161. package/dist/native/index.native35.js +27 -55
  162. package/dist/native/index.native36.js +149 -940
  163. package/dist/native/index.native37.js +48 -2
  164. package/dist/native/index.native38.js +244 -43
  165. package/dist/native/index.native39.js +55 -27
  166. package/dist/native/index.native4.js +4 -2
  167. package/dist/native/index.native5.js +19 -17
  168. package/dist/native/index.native6.js +10 -8
  169. package/dist/native/index.native90.js +6 -6
  170. package/dist/native/index.native99.js +1 -1
  171. package/dist/native-types/platform/types.d.ts +3 -3
  172. package/dist/native-types/types.d.ts +5 -7
  173. package/dist/types/platform/types.d.ts +3 -3
  174. package/dist/types/types.d.ts +5 -7
  175. package/dist/web/index.web100.js +2 -7
  176. package/dist/web/index.web101.js +17 -17
  177. package/dist/web/index.web102.js +20 -10
  178. package/dist/web/index.web103.js +80 -20
  179. package/dist/web/index.web104.js +99 -89
  180. package/dist/web/index.web105.js +32 -20
  181. package/dist/web/index.web106.js +7 -118
  182. package/dist/web/index.web107.js +10 -79
  183. package/dist/web/index.web108.js +79 -10
  184. package/dist/web/index.web109.js +18 -5
  185. package/dist/web/index.web110.js +28 -18
  186. package/dist/web/index.web111.js +6 -26
  187. package/dist/web/index.web112.js +9 -6
  188. package/dist/web/index.web113.js +13 -11
  189. package/dist/web/index.web114.js +8 -11
  190. package/dist/web/index.web115.js +14 -7
  191. package/dist/web/index.web116.js +80 -16
  192. package/dist/web/index.web117.js +5 -81
  193. package/dist/web/index.web119.js +4 -4
  194. package/dist/web/index.web120.js +5 -5
  195. package/dist/web/index.web16.js +1 -1
  196. package/dist/web/index.web17.js +33 -24
  197. package/dist/web/index.web2.js +10 -8
  198. package/dist/web/index.web21.js +1 -1
  199. package/dist/web/index.web25.js +13 -13
  200. package/dist/web/index.web27.js +3 -3
  201. package/dist/web/index.web3.js +4 -2
  202. package/dist/web/index.web30.js +2 -2
  203. package/dist/web/index.web34.js +2 -2
  204. package/dist/web/index.web35.js +16 -950
  205. package/dist/web/index.web36.js +23 -2
  206. package/dist/web/index.web37.js +50 -49
  207. package/dist/web/index.web38.js +950 -27
  208. package/dist/web/index.web39.js +2 -17
  209. package/dist/web/index.web4.js +12 -12
  210. package/dist/web/index.web40.js +48 -21
  211. package/dist/web/index.web41.js +27 -50
  212. package/dist/web/index.web44.js +54 -8
  213. package/dist/web/index.web45.js +9 -16
  214. package/dist/web/index.web46.js +2 -46
  215. package/dist/web/index.web47.js +45 -14
  216. package/dist/web/index.web48.js +12 -54
  217. package/dist/web/index.web49.js +8 -6
  218. package/dist/web/index.web5.js +4 -2
  219. package/dist/web/index.web50.js +16 -20
  220. package/dist/web/index.web51.js +45 -11
  221. package/dist/web/index.web52.js +13 -3
  222. package/dist/web/index.web53.js +55 -3
  223. package/dist/web/index.web54.js +6 -34
  224. package/dist/web/index.web55.js +19 -10
  225. package/dist/web/index.web56.js +11 -4
  226. package/dist/web/index.web57.js +3 -28
  227. package/dist/web/index.web58.js +3 -6
  228. package/dist/web/index.web59.js +34 -24
  229. package/dist/web/index.web60.js +12 -16
  230. package/dist/web/index.web61.js +4 -54
  231. package/dist/web/index.web62.js +25 -20
  232. package/dist/web/index.web63.js +6 -11
  233. package/dist/web/index.web64.js +23 -26
  234. package/dist/web/index.web65.js +16 -42
  235. package/dist/web/index.web66.js +52 -53
  236. package/dist/web/index.web67.js +23 -127
  237. package/dist/web/index.web68.js +11 -12
  238. package/dist/web/index.web69.js +27 -104
  239. package/dist/web/index.web70.js +42 -6
  240. package/dist/web/index.web71.js +56 -3
  241. package/dist/web/index.web72.js +127 -14
  242. package/dist/web/index.web73.js +9 -39
  243. package/dist/web/index.web74.js +100 -74
  244. package/dist/web/index.web75.js +7 -2
  245. package/dist/web/index.web76.js +3 -2
  246. package/dist/web/index.web77.js +14 -12
  247. package/dist/web/index.web78.js +34 -29
  248. package/dist/web/index.web79.js +77 -5
  249. package/dist/web/index.web80.js +2 -35
  250. package/dist/web/index.web81.js +2 -9
  251. package/dist/web/index.web82.js +11 -9
  252. package/dist/web/index.web83.js +37 -11
  253. package/dist/web/index.web84.js +6 -13
  254. package/dist/web/index.web85.js +33 -17
  255. package/dist/web/index.web86.js +8 -5
  256. package/dist/web/index.web87.js +11 -5
  257. package/dist/web/index.web88.js +11 -10
  258. package/dist/web/index.web89.js +13 -54
  259. package/dist/web/index.web90.js +18 -10
  260. package/dist/web/index.web91.js +6 -2
  261. package/dist/web/index.web92.js +4 -44
  262. package/dist/web/index.web93.js +10 -13
  263. package/dist/web/index.web94.js +21 -2
  264. package/dist/web/index.web95.js +10 -21
  265. package/dist/web/index.web96.js +19 -19
  266. package/dist/web/index.web97.js +94 -80
  267. package/dist/web/index.web98.js +20 -103
  268. package/dist/web/index.web99.js +115 -30
  269. package/dist/web-types/platform/types.d.ts +3 -3
  270. package/dist/web-types/types.d.ts +5 -7
  271. package/package.json +2 -2
@@ -1,82 +1,96 @@
1
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- function o(e) {
3
- return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
4
- }
5
- function w(e) {
6
- if (!Number.isSafeInteger(e) || e < 0)
7
- throw new Error("positive integer expected, got " + e);
8
- }
9
- function r(e, ...t) {
10
- if (!o(e))
11
- throw new Error("Uint8Array expected");
12
- if (t.length > 0 && !t.includes(e.length))
13
- throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
14
- }
15
- function h(e, t = !0) {
16
- if (e.destroyed)
17
- throw new Error("Hash instance has been destroyed");
18
- if (t && e.finished)
19
- throw new Error("Hash#digest() has already been called");
20
- }
21
- function l(e, t) {
22
- r(e);
23
- const n = t.outputLen;
24
- if (e.length < n)
25
- throw new Error("digestInto() expects output buffer of length at least " + n);
26
- }
27
- function a(e) {
28
- return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
29
- }
30
- function g(...e) {
31
- for (let t = 0; t < e.length; t++)
32
- e[t].fill(0);
33
- }
34
- function p(e) {
35
- return new DataView(e.buffer, e.byteOffset, e.byteLength);
36
- }
37
- function b(e, t) {
38
- return e << 32 - t | e >>> t;
39
- }
40
- const i = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
41
- function u(e) {
42
- return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
43
- }
44
- function c(e) {
45
- for (let t = 0; t < e.length; t++)
46
- e[t] = u(e[t]);
47
- return e;
48
- }
49
- const x = i ? (e) => e : c;
50
- function s(e) {
51
- if (typeof e != "string")
52
- throw new Error("string expected");
53
- return new Uint8Array(new TextEncoder().encode(e));
54
- }
55
- function y(e) {
56
- return typeof e == "string" && (e = s(e)), r(e), e;
57
- }
58
- class d {
59
- }
60
- function E(e) {
61
- const t = (f) => e().update(y(f)).digest(), n = e();
62
- return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
63
- }
1
+ import { withAlg as n } from "./index.web113.js";
2
+ import c from "./index.web114.js";
3
+ import { isJWK as p, isSecretJWK as a, isPublicJWK as y, isPrivateJWK as f } from "./index.web115.js";
4
+ const s = (r) => r?.[Symbol.toStringTag], o = (r, e, t) => {
5
+ if (e.use !== void 0) {
6
+ let i;
7
+ switch (t) {
8
+ case "sign":
9
+ case "verify":
10
+ i = "sig";
11
+ break;
12
+ case "encrypt":
13
+ case "decrypt":
14
+ i = "enc";
15
+ break;
16
+ }
17
+ if (e.use !== i)
18
+ throw new TypeError(`Invalid key for this operation, its "use" must be "${i}" when present`);
19
+ }
20
+ if (e.alg !== void 0 && e.alg !== r)
21
+ throw new TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);
22
+ if (Array.isArray(e.key_ops)) {
23
+ let i;
24
+ switch (!0) {
25
+ case t === "sign":
26
+ case r === "dir":
27
+ case r.includes("CBC-HS"):
28
+ i = t;
29
+ break;
30
+ case r.startsWith("PBES2"):
31
+ i = "deriveBits";
32
+ break;
33
+ case /^A\d{3}(?:GCM)?(?:KW)?$/.test(r):
34
+ !r.includes("GCM") && r.endsWith("KW") ? i = "unwrapKey" : i = t;
35
+ break;
36
+ case t === "encrypt":
37
+ i = "wrapKey";
38
+ break;
39
+ case t === "decrypt":
40
+ i = r.startsWith("RSA") ? "unwrapKey" : "deriveBits";
41
+ break;
42
+ }
43
+ if (i && e.key_ops?.includes?.(i) === !1)
44
+ throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${i}" when present`);
45
+ }
46
+ return !0;
47
+ }, h = (r, e, t) => {
48
+ if (!(e instanceof Uint8Array)) {
49
+ if (p(e)) {
50
+ if (a(e) && o(r, e, t))
51
+ return;
52
+ throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
53
+ }
54
+ if (!c(e))
55
+ throw new TypeError(n(r, e, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
56
+ if (e.type !== "secret")
57
+ throw new TypeError(`${s(e)} instances for symmetric algorithms must be of type "secret"`);
58
+ }
59
+ }, m = (r, e, t) => {
60
+ if (p(e))
61
+ switch (t) {
62
+ case "decrypt":
63
+ case "sign":
64
+ if (f(e) && o(r, e, t))
65
+ return;
66
+ throw new TypeError("JSON Web Key for this operation be a private JWK");
67
+ case "encrypt":
68
+ case "verify":
69
+ if (y(e) && o(r, e, t))
70
+ return;
71
+ throw new TypeError("JSON Web Key for this operation be a public JWK");
72
+ }
73
+ if (!c(e))
74
+ throw new TypeError(n(r, e, "CryptoKey", "KeyObject", "JSON Web Key"));
75
+ if (e.type === "secret")
76
+ throw new TypeError(`${s(e)} instances for asymmetric algorithms must not be of type "secret"`);
77
+ if (e.type === "public")
78
+ switch (t) {
79
+ case "sign":
80
+ throw new TypeError(`${s(e)} instances for asymmetric algorithm signing must be of type "private"`);
81
+ case "decrypt":
82
+ throw new TypeError(`${s(e)} instances for asymmetric algorithm decryption must be of type "private"`);
83
+ }
84
+ if (e.type === "private")
85
+ switch (t) {
86
+ case "verify":
87
+ throw new TypeError(`${s(e)} instances for asymmetric algorithm verifying must be of type "public"`);
88
+ case "encrypt":
89
+ throw new TypeError(`${s(e)} instances for asymmetric algorithm encryption must be of type "public"`);
90
+ }
91
+ }, d = (r, e, t) => {
92
+ r.startsWith("HS") || r === "dir" || r.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(r) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(r) ? h(r, e, t) : m(r, e, t);
93
+ };
64
94
  export {
65
- d as Hash,
66
- r as abytes,
67
- h as aexists,
68
- w as anumber,
69
- l as aoutput,
70
- u as byteSwap,
71
- c as byteSwap32,
72
- g as clean,
73
- E as createHasher,
74
- p as createView,
75
- o as isBytes,
76
- i as isLE,
77
- b as rotr,
78
- x as swap32IfBE,
79
- y as toBytes,
80
- a as u32,
81
- s as utf8ToBytes
95
+ d as default
82
96
  };
@@ -1,106 +1,23 @@
1
- import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index.web107.js";
2
- import { createHasher as u, clean as C, rotr as i } from "./index.web97.js";
3
- const B = /* @__PURE__ */ Uint32Array.from([
4
- 1116352408,
5
- 1899447441,
6
- 3049323471,
7
- 3921009573,
8
- 961987163,
9
- 1508970993,
10
- 2453635748,
11
- 2870763221,
12
- 3624381080,
13
- 310598401,
14
- 607225278,
15
- 1426881987,
16
- 1925078388,
17
- 2162078206,
18
- 2614888103,
19
- 3248222580,
20
- 3835390401,
21
- 4022224774,
22
- 264347078,
23
- 604807628,
24
- 770255983,
25
- 1249150122,
26
- 1555081692,
27
- 1996064986,
28
- 2554220882,
29
- 2821834349,
30
- 2952996808,
31
- 3210313671,
32
- 3336571891,
33
- 3584528711,
34
- 113926993,
35
- 338241895,
36
- 666307205,
37
- 773529912,
38
- 1294757372,
39
- 1396182291,
40
- 1695183700,
41
- 1986661051,
42
- 2177026350,
43
- 2456956037,
44
- 2730485921,
45
- 2820302411,
46
- 3259730800,
47
- 3345764771,
48
- 3516065817,
49
- 3600352804,
50
- 4094571909,
51
- 275423344,
52
- 430227734,
53
- 506948616,
54
- 659060556,
55
- 883997877,
56
- 958139571,
57
- 1322822218,
58
- 1537002063,
59
- 1747873779,
60
- 1955562222,
61
- 2024104815,
62
- 2227730452,
63
- 2361852424,
64
- 2428436474,
65
- 2756734187,
66
- 3204031479,
67
- 3329325298
68
- ]), h = /* @__PURE__ */ new Uint32Array(64);
69
- class E extends D {
70
- constructor(o = 32) {
71
- super(64, o, 8, !1), this.A = b[0] | 0, this.B = b[1] | 0, this.C = b[2] | 0, this.D = b[3] | 0, this.E = b[4] | 0, this.F = b[5] | 0, this.G = b[6] | 0, this.H = b[7] | 0;
1
+ import { JOSENotSupported as f } from "./index.web36.js";
2
+ const w = (n, r, a, e, s) => {
3
+ if (s.crit !== void 0 && e?.crit === void 0)
4
+ throw new n('"crit" (Critical) Header Parameter MUST be integrity protected');
5
+ if (!e || e.crit === void 0)
6
+ return /* @__PURE__ */ new Set();
7
+ if (!Array.isArray(e.crit) || e.crit.length === 0 || e.crit.some((i) => typeof i != "string" || i.length === 0))
8
+ throw new n('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
9
+ let t;
10
+ a !== void 0 ? t = new Map([...Object.entries(a), ...r.entries()]) : t = r;
11
+ for (const i of e.crit) {
12
+ if (!t.has(i))
13
+ throw new f(`Extension Header Parameter "${i}" is not recognized`);
14
+ if (s[i] === void 0)
15
+ throw new n(`Extension Header Parameter "${i}" is missing`);
16
+ if (t.get(i) && e[i] === void 0)
17
+ throw new n(`Extension Header Parameter "${i}" MUST be integrity protected`);
72
18
  }
73
- get() {
74
- const { A: o, B: r, C: t, D: s, E: a, F: f, G: c, H: e } = this;
75
- return [o, r, t, s, a, f, c, e];
76
- }
77
- // prettier-ignore
78
- set(o, r, t, s, a, f, c, e) {
79
- this.A = o | 0, this.B = r | 0, this.C = t | 0, this.D = s | 0, this.E = a | 0, this.F = f | 0, this.G = c | 0, this.H = e | 0;
80
- }
81
- process(o, r) {
82
- for (let x = 0; x < 16; x++, r += 4)
83
- h[x] = o.getUint32(r, !1);
84
- for (let x = 16; x < 64; x++) {
85
- const H = h[x - 15], d = h[x - 2], m = i(H, 7) ^ i(H, 18) ^ H >>> 3, l = i(d, 17) ^ i(d, 19) ^ d >>> 10;
86
- h[x] = l + h[x - 7] + m + h[x - 16] | 0;
87
- }
88
- let { A: t, B: s, C: a, D: f, E: c, F: e, G: n, H: A } = this;
89
- for (let x = 0; x < 64; x++) {
90
- const H = i(c, 6) ^ i(c, 11) ^ i(c, 25), d = A + H + g(c, e, n) + B[x] + h[x] | 0, l = (i(t, 2) ^ i(t, 13) ^ i(t, 22)) + p(t, s, a) | 0;
91
- A = n, n = e, e = c, c = f + d | 0, f = a, a = s, s = t, t = d + l | 0;
92
- }
93
- t = t + this.A | 0, s = s + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, c = c + this.E | 0, e = e + this.F | 0, n = n + this.G | 0, A = A + this.H | 0, this.set(t, s, a, f, c, e, n, A);
94
- }
95
- roundClean() {
96
- C(h);
97
- }
98
- destroy() {
99
- this.set(0, 0, 0, 0, 0, 0, 0, 0), C(this.buffer);
100
- }
101
- }
102
- const y = /* @__PURE__ */ u(() => new E());
19
+ return new Set(e.crit);
20
+ };
103
21
  export {
104
- E as SHA256,
105
- y as sha256
22
+ w as default
106
23
  };
@@ -1,35 +1,120 @@
1
- import { maxBytesPerTransaction as y, bytesPerBlob as a, fieldElementsPerBlob as f, bytesPerFieldElement as p } from "./index.web109.js";
2
- import { EmptyBlobError as c, BlobSizeTooLargeError as h } from "./index.web78.js";
3
- import { createCursor as B } from "./index.web67.js";
4
- import { size as u } from "./index.web56.js";
5
- import { hexToBytes as x } from "./index.web48.js";
6
- import { bytesToHex as d } from "./index.web46.js";
7
- function S(e) {
8
- const m = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), i = typeof e.data == "string" ? x(e.data) : e.data, o = u(i);
9
- if (!o)
10
- throw new c();
11
- if (o > y)
12
- throw new h({
13
- maxSize: y,
14
- size: o
15
- });
16
- const s = [];
17
- let n = !0, r = 0;
18
- for (; n; ) {
19
- const t = B(new Uint8Array(a));
20
- let l = 0;
21
- for (; l < f; ) {
22
- const b = i.slice(r, r + (p - 1));
23
- if (t.pushByte(0), t.pushBytes(b), b.length < 31) {
24
- t.pushByte(128), n = !1;
1
+ import { isJWK as p } from "./index.web115.js";
2
+ import { decode as m } from "./index.web94.js";
3
+ import y from "./index.web116.js";
4
+ import { isCryptoKey as S, isKeyObject as K } from "./index.web114.js";
5
+ let c;
6
+ const f = async (e, r, s, i = !1) => {
7
+ c ||= /* @__PURE__ */ new WeakMap();
8
+ let n = c.get(e);
9
+ if (n?.[s])
10
+ return n[s];
11
+ const t = await y({ ...r, alg: s });
12
+ return i && Object.freeze(e), n ? n[s] = t : c.set(e, { [s]: t }), t;
13
+ }, E = (e, r) => {
14
+ c ||= /* @__PURE__ */ new WeakMap();
15
+ let s = c.get(e);
16
+ if (s?.[r])
17
+ return s[r];
18
+ const i = e.type === "public", n = !!i;
19
+ let t;
20
+ if (e.asymmetricKeyType === "x25519") {
21
+ switch (r) {
22
+ case "ECDH-ES":
23
+ case "ECDH-ES+A128KW":
24
+ case "ECDH-ES+A192KW":
25
+ case "ECDH-ES+A256KW":
25
26
  break;
26
- }
27
- l++, r += 31;
27
+ default:
28
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
29
+ }
30
+ t = e.toCryptoKey(e.asymmetricKeyType, n, i ? [] : ["deriveBits"]);
31
+ }
32
+ if (e.asymmetricKeyType === "ed25519") {
33
+ if (r !== "EdDSA" && r !== "Ed25519")
34
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
35
+ t = e.toCryptoKey(e.asymmetricKeyType, n, [
36
+ i ? "verify" : "sign"
37
+ ]);
38
+ }
39
+ if (e.asymmetricKeyType === "rsa") {
40
+ let a;
41
+ switch (r) {
42
+ case "RSA-OAEP":
43
+ a = "SHA-1";
44
+ break;
45
+ case "RS256":
46
+ case "PS256":
47
+ case "RSA-OAEP-256":
48
+ a = "SHA-256";
49
+ break;
50
+ case "RS384":
51
+ case "PS384":
52
+ case "RSA-OAEP-384":
53
+ a = "SHA-384";
54
+ break;
55
+ case "RS512":
56
+ case "PS512":
57
+ case "RSA-OAEP-512":
58
+ a = "SHA-512";
59
+ break;
60
+ default:
61
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
28
62
  }
29
- s.push(t);
63
+ if (r.startsWith("RSA-OAEP"))
64
+ return e.toCryptoKey({
65
+ name: "RSA-OAEP",
66
+ hash: a
67
+ }, n, i ? ["encrypt"] : ["decrypt"]);
68
+ t = e.toCryptoKey({
69
+ name: r.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
70
+ hash: a
71
+ }, n, [i ? "verify" : "sign"]);
72
+ }
73
+ if (e.asymmetricKeyType === "ec") {
74
+ const o = (/* @__PURE__ */ new Map([
75
+ ["prime256v1", "P-256"],
76
+ ["secp384r1", "P-384"],
77
+ ["secp521r1", "P-521"]
78
+ ])).get(e.asymmetricKeyDetails?.namedCurve);
79
+ if (!o)
80
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
81
+ r === "ES256" && o === "P-256" && (t = e.toCryptoKey({
82
+ name: "ECDSA",
83
+ namedCurve: o
84
+ }, n, [i ? "verify" : "sign"])), r === "ES384" && o === "P-384" && (t = e.toCryptoKey({
85
+ name: "ECDSA",
86
+ namedCurve: o
87
+ }, n, [i ? "verify" : "sign"])), r === "ES512" && o === "P-521" && (t = e.toCryptoKey({
88
+ name: "ECDSA",
89
+ namedCurve: o
90
+ }, n, [i ? "verify" : "sign"])), r.startsWith("ECDH-ES") && (t = e.toCryptoKey({
91
+ name: "ECDH",
92
+ namedCurve: o
93
+ }, n, i ? [] : ["deriveBits"]));
30
94
  }
31
- return m === "bytes" ? s.map((t) => t.bytes) : s.map((t) => d(t.bytes));
32
- }
95
+ if (!t)
96
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
97
+ return s ? s[r] = t : c.set(e, { [r]: t }), t;
98
+ }, d = async (e, r) => {
99
+ if (e instanceof Uint8Array || S(e))
100
+ return e;
101
+ if (K(e)) {
102
+ if (e.type === "secret")
103
+ return e.export();
104
+ if ("toCryptoKey" in e && typeof e.toCryptoKey == "function")
105
+ try {
106
+ return E(e, r);
107
+ } catch (i) {
108
+ if (i instanceof TypeError)
109
+ throw i;
110
+ }
111
+ let s = e.export({ format: "jwk" });
112
+ return f(e, s, r);
113
+ }
114
+ if (p(e))
115
+ return e.k ? m(e.k) : f(e, e, r, !0);
116
+ throw new Error("unreachable");
117
+ };
33
118
  export {
34
- S as toBlobs
119
+ d as default
35
120
  };
@@ -1,5 +1,5 @@
1
1
  import { KeyPair } from '../shared/types.js';
2
- import { OAuthInfo } from '../types.js';
2
+ import { OAuthFlowState } from '../types.js';
3
3
  export interface PlatformCrypto {
4
4
  createKeyPair(): Promise<KeyPair>;
5
5
  createExportKeyPair(): Promise<KeyPair>;
@@ -23,8 +23,8 @@ export interface PlatformSecureStorage {
23
23
  export interface PlatformOAuth {
24
24
  initiateOAuthFlow(authUrl: string): void;
25
25
  getRedirectUrl(): string;
26
- getOAuthCode(): OAuthInfo | null;
27
- cleanupOAuthCode(): void;
26
+ getOAuthParams(): OAuthFlowState | null;
27
+ cleanupOAuthParams(): void;
28
28
  }
29
29
  export interface PlatformServices {
30
30
  crypto: PlatformCrypto;
@@ -206,13 +206,11 @@ export type ExportSolanaAccountResult = {
206
206
  privateKey: string;
207
207
  };
208
208
  export type OAuthFlowStatus = "pending" | "success" | "error";
209
- export type OAuthInfo = {
210
- code: string | null;
211
- providerType: OAuth2ProviderType | null;
212
- flowId: string | null;
213
- };
214
- export interface OAuthFlowState extends OAuthInfo {
215
- status: OAuthFlowStatus;
209
+ export interface OAuthFlowState {
210
+ status?: OAuthFlowStatus;
211
+ code?: string;
212
+ providerType?: OAuth2ProviderType;
213
+ flowId?: string;
216
214
  error?: string;
217
215
  errorDescription?: string;
218
216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-core",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",
@@ -28,7 +28,7 @@
28
28
  "ox": "0.8.1",
29
29
  "viem": "^2.33.0",
30
30
  "zustand": "^5.0.6",
31
- "@coinbase/cdp-api-client": "^0.0.48"
31
+ "@coinbase/cdp-api-client": "^0.0.49"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@react-native-async-storage/async-storage": "^2.0.0",