@coinbase/cdp-core 0.0.23 → 0.0.25

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 (109) hide show
  1. package/README.md +12 -12
  2. package/dist/esm/index.js +17 -15
  3. package/dist/esm/index10.js +20 -14
  4. package/dist/esm/index100.js +6 -9
  5. package/dist/esm/index101.js +11 -13
  6. package/dist/esm/index102.js +11 -8
  7. package/dist/esm/index103.js +7 -14
  8. package/dist/esm/index104.js +16 -80
  9. package/dist/esm/index105.js +72 -70
  10. package/dist/esm/index106.js +81 -0
  11. package/dist/esm/index11.js +13 -117
  12. package/dist/esm/index12.js +116 -11
  13. package/dist/esm/index13.js +14 -22
  14. package/dist/esm/index14.js +42 -20
  15. package/dist/esm/index15.js +20 -172
  16. package/dist/esm/index16.js +170 -24
  17. package/dist/esm/index17.js +22 -156
  18. package/dist/esm/index18.js +157 -45
  19. package/dist/esm/index19.js +44 -149
  20. package/dist/esm/index2.js +10 -10
  21. package/dist/esm/index20.js +247 -53
  22. package/dist/esm/index21.js +56 -41
  23. package/dist/esm/index22.js +40 -16
  24. package/dist/esm/index23.js +16 -4
  25. package/dist/esm/index24.js +5 -5
  26. package/dist/esm/index25.js +5 -9
  27. package/dist/esm/index26.js +8 -17
  28. package/dist/esm/index27.js +16 -44
  29. package/dist/esm/index28.js +45 -13
  30. package/dist/esm/index29.js +13 -55
  31. package/dist/esm/index3.js +66 -60
  32. package/dist/esm/index30.js +55 -6
  33. package/dist/esm/index31.js +6 -21
  34. package/dist/esm/index32.js +21 -11
  35. package/dist/esm/index33.js +11 -3
  36. package/dist/esm/index34.js +3 -3
  37. package/dist/esm/index35.js +3 -34
  38. package/dist/esm/index36.js +32 -10
  39. package/dist/esm/index37.js +12 -4
  40. package/dist/esm/index38.js +4 -28
  41. package/dist/esm/index39.js +28 -6
  42. package/dist/esm/index4.js +48 -35
  43. package/dist/esm/index40.js +6 -24
  44. package/dist/esm/index41.js +24 -16
  45. package/dist/esm/index42.js +16 -54
  46. package/dist/esm/index43.js +53 -22
  47. package/dist/esm/index44.js +23 -11
  48. package/dist/esm/index45.js +10 -26
  49. package/dist/esm/index46.js +26 -41
  50. package/dist/esm/index47.js +41 -54
  51. package/dist/esm/index48.js +54 -126
  52. package/dist/esm/index49.js +126 -11
  53. package/dist/esm/index5.js +1 -1
  54. package/dist/esm/index50.js +9 -101
  55. package/dist/esm/index51.js +104 -6
  56. package/dist/esm/index52.js +7 -3
  57. package/dist/esm/index53.js +3 -15
  58. package/dist/esm/index54.js +14 -42
  59. package/dist/esm/index55.js +38 -74
  60. package/dist/esm/index56.js +79 -2
  61. package/dist/esm/index57.js +2 -2
  62. package/dist/esm/index58.js +2 -13
  63. package/dist/esm/index59.js +8 -33
  64. package/dist/esm/index6.js +13 -183
  65. package/dist/esm/index60.js +36 -5
  66. package/dist/esm/index61.js +5 -33
  67. package/dist/esm/index62.js +34 -8
  68. package/dist/esm/index63.js +8 -10
  69. package/dist/esm/index64.js +10 -11
  70. package/dist/esm/index65.js +11 -13
  71. package/dist/esm/index66.js +13 -18
  72. package/dist/esm/index67.js +18 -5
  73. package/dist/esm/index68.js +6 -5
  74. package/dist/esm/index69.js +5 -11
  75. package/dist/esm/index7.js +192 -15
  76. package/dist/esm/index70.js +10 -16
  77. package/dist/esm/index71.js +15 -21
  78. package/dist/esm/index72.js +21 -49
  79. package/dist/esm/index73.js +51 -2
  80. package/dist/esm/index74.js +1 -1
  81. package/dist/esm/index75.js +2 -20
  82. package/dist/esm/index76.js +20 -80
  83. package/dist/esm/index77.js +79 -103
  84. package/dist/esm/index78.js +101 -30
  85. package/dist/esm/index79.js +32 -6
  86. package/dist/esm/index8.js +14 -15
  87. package/dist/esm/index80.js +6 -78
  88. package/dist/esm/index81.js +79 -10
  89. package/dist/esm/index82.js +10 -55
  90. package/dist/esm/index83.js +54 -10
  91. package/dist/esm/index84.js +11 -2
  92. package/dist/esm/index85.js +2 -45
  93. package/dist/esm/index86.js +44 -13
  94. package/dist/esm/index87.js +14 -5
  95. package/dist/esm/index88.js +5 -13
  96. package/dist/esm/index89.js +12 -35
  97. package/dist/esm/index9.js +15 -20
  98. package/dist/esm/index90.js +35 -41
  99. package/dist/esm/index91.js +40 -19
  100. package/dist/esm/index92.js +21 -10
  101. package/dist/esm/index93.js +9 -19
  102. package/dist/esm/index94.js +15 -89
  103. package/dist/esm/index95.js +92 -19
  104. package/dist/esm/index96.js +18 -115
  105. package/dist/esm/index97.js +118 -18
  106. package/dist/esm/index98.js +18 -28
  107. package/dist/esm/index99.js +26 -6
  108. package/dist/types/index.d.ts +36 -1
  109. package/package.json +2 -2
@@ -1,23 +1,96 @@
1
- import { JOSENotSupported as f } from "./index71.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`);
1
+ import { withAlg as n } from "./index102.js";
2
+ import c from "./index103.js";
3
+ import { isJWK as p, isSecretJWK as a, isPublicJWK as y, isPrivateJWK as f } from "./index104.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`);
18
19
  }
19
- return new Set(e.crit);
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);
20
93
  };
21
94
  export {
22
- w as default
95
+ d as default
23
96
  };
@@ -1,120 +1,23 @@
1
- import { isJWK as p } from "./index103.js";
2
- import { decode as m } from "./index91.js";
3
- import y from "./index104.js";
4
- import { isCryptoKey as S, isKeyObject as K } from "./index102.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;
1
+ import { JOSENotSupported as f } from "./index72.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');
19
9
  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":
26
- break;
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"]);
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`);
31
18
  }
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");
62
- }
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"]));
94
- }
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");
19
+ return new Set(e.crit);
117
20
  };
118
21
  export {
119
- d as default
22
+ w as default
120
23
  };
@@ -1,20 +1,120 @@
1
- function o(t) {
2
- if (Uint8Array.prototype.toBase64)
3
- return t.toBase64();
4
- const e = 32768, n = [];
5
- for (let r = 0; r < t.length; r += e)
6
- n.push(String.fromCharCode.apply(null, t.subarray(r, r + e)));
7
- return btoa(n.join(""));
8
- }
9
- function a(t) {
10
- if (Uint8Array.fromBase64)
11
- return Uint8Array.fromBase64(t);
12
- const e = atob(t), n = new Uint8Array(e.length);
13
- for (let r = 0; r < e.length; r++)
14
- n[r] = e.charCodeAt(r);
15
- return n;
16
- }
1
+ import { isJWK as p } from "./index104.js";
2
+ import { decode as m } from "./index92.js";
3
+ import y from "./index105.js";
4
+ import { isCryptoKey as S, isKeyObject as K } from "./index103.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":
26
+ break;
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");
62
+ }
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"]));
94
+ }
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
+ };
17
118
  export {
18
- a as decodeBase64,
19
- o as encodeBase64
119
+ d as default
20
120
  };
@@ -1,30 +1,20 @@
1
- import { JOSENotSupported as r } from "./index71.js";
2
- const S = (e, s) => {
3
- const a = `SHA-${e.slice(-3)}`;
4
- switch (e) {
5
- case "HS256":
6
- case "HS384":
7
- case "HS512":
8
- return { hash: a, name: "HMAC" };
9
- case "PS256":
10
- case "PS384":
11
- case "PS512":
12
- return { hash: a, name: "RSA-PSS", saltLength: parseInt(e.slice(-3), 10) >> 3 };
13
- case "RS256":
14
- case "RS384":
15
- case "RS512":
16
- return { hash: a, name: "RSASSA-PKCS1-v1_5" };
17
- case "ES256":
18
- case "ES384":
19
- case "ES512":
20
- return { hash: a, name: "ECDSA", namedCurve: s.namedCurve };
21
- case "Ed25519":
22
- case "EdDSA":
23
- return { name: "Ed25519" };
24
- default:
25
- throw new r(`alg ${e} is not supported either by JOSE or your javascript runtime`);
26
- }
27
- };
1
+ function o(t) {
2
+ if (Uint8Array.prototype.toBase64)
3
+ return t.toBase64();
4
+ const e = 32768, n = [];
5
+ for (let r = 0; r < t.length; r += e)
6
+ n.push(String.fromCharCode.apply(null, t.subarray(r, r + e)));
7
+ return btoa(n.join(""));
8
+ }
9
+ function a(t) {
10
+ if (Uint8Array.fromBase64)
11
+ return Uint8Array.fromBase64(t);
12
+ const e = atob(t), n = new Uint8Array(e.length);
13
+ for (let r = 0; r < e.length; r++)
14
+ n[r] = e.charCodeAt(r);
15
+ return n;
16
+ }
28
17
  export {
29
- S as default
18
+ a as decodeBase64,
19
+ o as encodeBase64
30
20
  };
@@ -1,10 +1,30 @@
1
- const o = (t, r) => {
2
- if (t.startsWith("RS") || t.startsWith("PS")) {
3
- const { modulusLength: e } = r.algorithm;
4
- if (typeof e != "number" || e < 2048)
5
- throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`);
1
+ import { JOSENotSupported as r } from "./index72.js";
2
+ const S = (e, s) => {
3
+ const a = `SHA-${e.slice(-3)}`;
4
+ switch (e) {
5
+ case "HS256":
6
+ case "HS384":
7
+ case "HS512":
8
+ return { hash: a, name: "HMAC" };
9
+ case "PS256":
10
+ case "PS384":
11
+ case "PS512":
12
+ return { hash: a, name: "RSA-PSS", saltLength: parseInt(e.slice(-3), 10) >> 3 };
13
+ case "RS256":
14
+ case "RS384":
15
+ case "RS512":
16
+ return { hash: a, name: "RSASSA-PKCS1-v1_5" };
17
+ case "ES256":
18
+ case "ES384":
19
+ case "ES512":
20
+ return { hash: a, name: "ECDSA", namedCurve: s.namedCurve };
21
+ case "Ed25519":
22
+ case "EdDSA":
23
+ return { name: "Ed25519" };
24
+ default:
25
+ throw new r(`alg ${e} is not supported either by JOSE or your javascript runtime`);
6
26
  }
7
27
  };
8
28
  export {
9
- o as default
29
+ S as default
10
30
  };
@@ -1,6 +1,7 @@
1
1
  import { Address } from 'viem';
2
2
  import { APIError } from '@coinbase/cdp-api-client';
3
3
  import { APIErrorType } from '@coinbase/cdp-api-client';
4
+ import { Call } from 'viem';
4
5
  import { Chain } from 'viem/chains';
5
6
  import { Chain as Chain_2 } from 'viem';
6
7
  import { ErrorType } from '@coinbase/cdp-api-client';
@@ -124,6 +125,16 @@ export declare type ExportEvmAccountResult = {
124
125
 
125
126
  export declare const getAccessToken: () => Promise<string | null>;
126
127
 
128
+ export declare type GetCallsStatusRequest = {
129
+ method: "wallet_getCallsStatus";
130
+ params: [`0x${string}`];
131
+ };
132
+
133
+ export declare type GetCapabilitiesRequest = {
134
+ method: "wallet_getCapabilities";
135
+ params: [];
136
+ };
137
+
127
138
  export declare const getCurrentUser: () => Promise<User | null>;
128
139
 
129
140
  export declare const getUserOperation: (options: GetUserOperationOptions) => Promise<GetUserOperationResult>;
@@ -144,6 +155,12 @@ export declare const initialize: (cfg: Config) => Promise<void>;
144
155
 
145
156
  export declare const isSignedIn: () => Promise<boolean>;
146
157
 
158
+ export declare class ModuleResolutionError extends Error {
159
+ moduleName: string;
160
+ requiredFor: string;
161
+ constructor(moduleName: string, requiredFor: string, message?: string);
162
+ }
163
+
147
164
  export declare const onAuthStateChange: (callback: OnAuthStateChangeFn) => void;
148
165
 
149
166
  export declare type OnAuthStateChangeFn = (user: User | null) => void;
@@ -153,7 +170,7 @@ export declare type PersonalSignRequest = {
153
170
  params: [`0x${string}`, `0x${string}`];
154
171
  };
155
172
 
156
- export declare type ProviderRequest = AccountsRequest | RequestAccountsRequest | PersonalSignRequest | SendTransactionRequest | SignTypedDataRequest | EthSignRequest | ChainIdRequest | WalletDisconnectRequest | SwitchEthereumChainRequest;
173
+ export declare type ProviderRequest = AccountsRequest | RequestAccountsRequest | PersonalSignRequest | SendTransactionRequest | SignTypedDataRequest | EthSignRequest | ChainIdRequest | WalletDisconnectRequest | SwitchEthereumChainRequest | SendCallsRequest | GetCallsStatusRequest | GetCapabilitiesRequest;
157
174
 
158
175
  export declare type ProviderState = {
159
176
  chainId: number;
@@ -175,6 +192,13 @@ export declare type RequestAccountsRequest = {
175
192
 
176
193
  export declare type RPCErrorCode = (typeof STANDARD_ERROR_CODES)["rpc"][keyof (typeof STANDARD_ERROR_CODES)["rpc"]];
177
194
 
195
+ export declare type SendCallsRequest = {
196
+ method: "wallet_sendCalls";
197
+ params: [{
198
+ calls: Call[];
199
+ }];
200
+ };
201
+
178
202
  export declare const sendEvmTransaction: (options: SendEvmTransactionOptions) => Promise<SendEvmTransactionResult>;
179
203
 
180
204
  export declare type SendEvmTransactionOptions = {
@@ -372,6 +396,17 @@ export declare type VerifySmsOTPResult = {
372
396
  isNewUser: boolean;
373
397
  };
374
398
 
399
+ export declare type WalletCapabilities = {
400
+ [chainId: Hex]: {
401
+ atomic: {
402
+ status: "supported" | "unsupported";
403
+ };
404
+ paymasterService: {
405
+ supported: boolean;
406
+ };
407
+ };
408
+ };
409
+
375
410
  export declare type WalletDisconnectRequest = {
376
411
  method: "wallet_disconnect";
377
412
  params: [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-core",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",
@@ -17,7 +17,7 @@
17
17
  "ox": "0.8.1",
18
18
  "viem": "^2.33.0",
19
19
  "zustand": "^5.0.6",
20
- "@coinbase/cdp-api-client": "^0.0.23"
20
+ "@coinbase/cdp-api-client": "^0.0.25"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@size-limit/preset-big-lib": "^11.2.0",