@coinbase/cdp-core 0.0.9 → 0.0.10

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 (95) hide show
  1. package/dist/esm/index100.js +7 -14
  2. package/dist/esm/index101.js +16 -80
  3. package/dist/esm/index102.js +72 -70
  4. package/dist/esm/index103.js +81 -0
  5. package/dist/esm/index13.js +18 -172
  6. package/dist/esm/index14.js +170 -39
  7. package/dist/esm/index15.js +158 -15
  8. package/dist/esm/index16.js +47 -4
  9. package/dist/esm/index17.js +146 -5
  10. package/dist/esm/index18.js +50 -154
  11. package/dist/esm/index19.js +39 -46
  12. package/dist/esm/index2.js +72 -68
  13. package/dist/esm/index20.js +16 -145
  14. package/dist/esm/index21.js +5 -56
  15. package/dist/esm/index22.js +5 -9
  16. package/dist/esm/index23.js +8 -17
  17. package/dist/esm/index24.js +16 -44
  18. package/dist/esm/index25.js +45 -13
  19. package/dist/esm/index26.js +13 -55
  20. package/dist/esm/index27.js +55 -6
  21. package/dist/esm/index28.js +6 -21
  22. package/dist/esm/index29.js +21 -11
  23. package/dist/esm/index3.js +4 -4
  24. package/dist/esm/index30.js +11 -3
  25. package/dist/esm/index31.js +3 -3
  26. package/dist/esm/index32.js +3 -34
  27. package/dist/esm/index33.js +32 -10
  28. package/dist/esm/index34.js +12 -4
  29. package/dist/esm/index35.js +4 -28
  30. package/dist/esm/index36.js +28 -6
  31. package/dist/esm/index37.js +6 -24
  32. package/dist/esm/index38.js +24 -16
  33. package/dist/esm/index39.js +16 -54
  34. package/dist/esm/index40.js +53 -22
  35. package/dist/esm/index41.js +23 -11
  36. package/dist/esm/index42.js +10 -26
  37. package/dist/esm/index43.js +26 -41
  38. package/dist/esm/index44.js +41 -54
  39. package/dist/esm/index45.js +54 -126
  40. package/dist/esm/index46.js +126 -11
  41. package/dist/esm/index47.js +9 -101
  42. package/dist/esm/index48.js +104 -6
  43. package/dist/esm/index49.js +7 -3
  44. package/dist/esm/index5.js +4 -4
  45. package/dist/esm/index50.js +3 -15
  46. package/dist/esm/index51.js +14 -42
  47. package/dist/esm/index52.js +38 -74
  48. package/dist/esm/index53.js +79 -2
  49. package/dist/esm/index54.js +2 -2
  50. package/dist/esm/index55.js +2 -13
  51. package/dist/esm/index56.js +8 -33
  52. package/dist/esm/index57.js +36 -5
  53. package/dist/esm/index58.js +5 -33
  54. package/dist/esm/index59.js +34 -8
  55. package/dist/esm/index60.js +8 -10
  56. package/dist/esm/index61.js +10 -11
  57. package/dist/esm/index62.js +11 -13
  58. package/dist/esm/index63.js +13 -18
  59. package/dist/esm/index64.js +18 -5
  60. package/dist/esm/index65.js +6 -5
  61. package/dist/esm/index66.js +5 -11
  62. package/dist/esm/index67.js +11 -2
  63. package/dist/esm/index68.js +13 -17
  64. package/dist/esm/index69.js +21 -15
  65. package/dist/esm/index70.js +49 -21
  66. package/dist/esm/index71.js +2 -51
  67. package/dist/esm/index72.js +18 -17
  68. package/dist/esm/index73.js +20 -80
  69. package/dist/esm/index74.js +79 -103
  70. package/dist/esm/index75.js +101 -30
  71. package/dist/esm/index76.js +32 -6
  72. package/dist/esm/index77.js +6 -54
  73. package/dist/esm/index78.js +10 -11
  74. package/dist/esm/index79.js +55 -2
  75. package/dist/esm/index80.js +11 -45
  76. package/dist/esm/index81.js +2 -14
  77. package/dist/esm/index82.js +44 -9
  78. package/dist/esm/index83.js +13 -78
  79. package/dist/esm/index84.js +79 -5
  80. package/dist/esm/index85.js +5 -21
  81. package/dist/esm/index86.js +12 -9
  82. package/dist/esm/index87.js +33 -17
  83. package/dist/esm/index88.js +41 -93
  84. package/dist/esm/index89.js +20 -20
  85. package/dist/esm/index90.js +9 -117
  86. package/dist/esm/index91.js +18 -11
  87. package/dist/esm/index92.js +90 -32
  88. package/dist/esm/index93.js +20 -41
  89. package/dist/esm/index94.js +118 -18
  90. package/dist/esm/index95.js +18 -28
  91. package/dist/esm/index96.js +26 -6
  92. package/dist/esm/index97.js +6 -9
  93. package/dist/esm/index98.js +11 -13
  94. package/dist/esm/index99.js +11 -8
  95. package/package.json +3 -3
@@ -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 "./index101.js";
2
+ import { decode as m } from "./index89.js";
3
+ import y from "./index102.js";
4
+ import { isCryptoKey as S, isKeyObject as K } from "./index100.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 "./index70.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 "./index69.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,13 +1,10 @@
1
- import { checkSigCryptoKey as i } from "./index102.js";
2
- import o from "./index98.js";
3
- const s = async (t, r, e) => {
4
- if (r instanceof Uint8Array) {
5
- if (!t.startsWith("HS"))
6
- throw new TypeError(o(r, "CryptoKey", "KeyObject", "JSON Web Key"));
7
- return crypto.subtle.importKey("raw", r, { hash: `SHA-${t.slice(-3)}`, name: "HMAC" }, !1, [e]);
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`);
8
6
  }
9
- return i(r, t, e), r;
10
7
  };
11
8
  export {
12
- s as default
9
+ o as default
13
10
  };
@@ -1,15 +1,13 @@
1
- function i(n, e, ...o) {
2
- if (o = o.filter(Boolean), o.length > 2) {
3
- const f = o.pop();
4
- n += `one of type ${o.join(", ")}, or ${f}.`;
5
- } else o.length === 2 ? n += `one of type ${o[0]} or ${o[1]}.` : n += `of type ${o[0]}.`;
6
- return e == null ? n += ` Received ${e}` : typeof e == "function" && e.name ? n += ` Received function ${e.name}` : typeof e == "object" && e != null && e.constructor?.name && (n += ` Received an instance of ${e.constructor.name}`), n;
7
- }
8
- const r = (n, ...e) => i("Key must be ", n, ...e);
9
- function t(n, e, ...o) {
10
- return i(`Key for the ${n} algorithm must be `, e, ...o);
11
- }
1
+ import { checkSigCryptoKey as i } from "./index103.js";
2
+ import o from "./index99.js";
3
+ const s = async (t, r, e) => {
4
+ if (r instanceof Uint8Array) {
5
+ if (!t.startsWith("HS"))
6
+ throw new TypeError(o(r, "CryptoKey", "KeyObject", "JSON Web Key"));
7
+ return crypto.subtle.importKey("raw", r, { hash: `SHA-${t.slice(-3)}`, name: "HMAC" }, !1, [e]);
8
+ }
9
+ return i(r, t, e), r;
10
+ };
12
11
  export {
13
- r as default,
14
- t as withAlg
12
+ s as default
15
13
  };
@@ -1,12 +1,15 @@
1
- function e(t) {
2
- return t?.[Symbol.toStringTag] === "CryptoKey";
1
+ function i(n, e, ...o) {
2
+ if (o = o.filter(Boolean), o.length > 2) {
3
+ const f = o.pop();
4
+ n += `one of type ${o.join(", ")}, or ${f}.`;
5
+ } else o.length === 2 ? n += `one of type ${o[0]} or ${o[1]}.` : n += `of type ${o[0]}.`;
6
+ return e == null ? n += ` Received ${e}` : typeof e == "function" && e.name ? n += ` Received function ${e.name}` : typeof e == "object" && e != null && e.constructor?.name && (n += ` Received an instance of ${e.constructor.name}`), n;
3
7
  }
4
- function r(t) {
5
- return t?.[Symbol.toStringTag] === "KeyObject";
8
+ const r = (n, ...e) => i("Key must be ", n, ...e);
9
+ function t(n, e, ...o) {
10
+ return i(`Key for the ${n} algorithm must be `, e, ...o);
6
11
  }
7
- const n = (t) => e(t) || r(t);
8
12
  export {
9
- n as default,
10
- e as isCryptoKey,
11
- r as isKeyObject
13
+ r as default,
14
+ t as withAlg
12
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-core",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
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.9"
20
+ "@coinbase/cdp-api-client": "^0.0.10"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@size-limit/preset-big-lib": "^11.2.0",
@@ -38,7 +38,7 @@
38
38
  "path": "./dist/esm/index.js",
39
39
  "running": false,
40
40
  "import": "{ signInWithEmail, verifyEmailOTP, getCurrentUser, isSignedIn, signOut }",
41
- "limit": "25 KB"
41
+ "limit": "30 KB"
42
42
  },
43
43
  {
44
44
  "name": "evm-only",