@coinbase/cdp-core 0.0.41 → 0.0.42

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 (61) hide show
  1. package/dist/esm/index.native101.js +10 -79
  2. package/dist/esm/index.native102.js +79 -10
  3. package/dist/esm/index.native13.js +1 -1
  4. package/dist/esm/index.native25.js +149 -940
  5. package/dist/esm/index.native26.js +48 -2
  6. package/dist/esm/index.native27.js +244 -43
  7. package/dist/esm/index.native28.js +55 -27
  8. package/dist/esm/index.native29.js +940 -149
  9. package/dist/esm/index.native30.js +2 -48
  10. package/dist/esm/index.native31.js +43 -243
  11. package/dist/esm/index.native32.js +27 -55
  12. package/dist/esm/index.native8.js +4 -4
  13. package/dist/esm/index.native9.js +49 -31
  14. package/dist/esm/index.native92.js +1 -1
  15. package/dist/esm/index.web100.js +9 -117
  16. package/dist/esm/index.web101.js +79 -10
  17. package/dist/esm/index.web26.js +156 -155
  18. package/dist/esm/index.web27.js +1 -1
  19. package/dist/esm/index.web8.js +49 -31
  20. package/dist/esm/index.web82.js +6 -6
  21. package/dist/esm/index.web91.js +1 -1
  22. package/dist/esm/index.web94.js +19 -77
  23. package/dist/esm/index.web95.js +10 -21
  24. package/dist/esm/index.web96.js +19 -9
  25. package/dist/esm/index.web97.js +89 -15
  26. package/dist/esm/index.web98.js +19 -92
  27. package/dist/esm/index.web99.js +115 -18
  28. package/dist/native/index.native101.js +10 -79
  29. package/dist/native/index.native102.js +79 -10
  30. package/dist/native/index.native13.js +1 -1
  31. package/dist/native/index.native25.js +149 -940
  32. package/dist/native/index.native26.js +48 -2
  33. package/dist/native/index.native27.js +244 -43
  34. package/dist/native/index.native28.js +55 -27
  35. package/dist/native/index.native29.js +940 -149
  36. package/dist/native/index.native30.js +2 -48
  37. package/dist/native/index.native31.js +43 -243
  38. package/dist/native/index.native32.js +27 -55
  39. package/dist/native/index.native8.js +4 -4
  40. package/dist/native/index.native9.js +49 -31
  41. package/dist/native/index.native92.js +1 -1
  42. package/dist/native-types/eip1193/errors.d.ts +6 -0
  43. package/dist/native-types/eip1193/internal.d.ts +3 -1
  44. package/dist/types/eip1193/errors.d.ts +6 -0
  45. package/dist/types/eip1193/internal.d.ts +3 -1
  46. package/dist/web/index.web100.js +9 -117
  47. package/dist/web/index.web101.js +79 -10
  48. package/dist/web/index.web26.js +156 -155
  49. package/dist/web/index.web27.js +1 -1
  50. package/dist/web/index.web8.js +49 -31
  51. package/dist/web/index.web82.js +6 -6
  52. package/dist/web/index.web91.js +1 -1
  53. package/dist/web/index.web94.js +19 -77
  54. package/dist/web/index.web95.js +10 -21
  55. package/dist/web/index.web96.js +19 -9
  56. package/dist/web/index.web97.js +89 -15
  57. package/dist/web/index.web98.js +19 -92
  58. package/dist/web/index.web99.js +115 -18
  59. package/dist/web-types/eip1193/errors.d.ts +6 -0
  60. package/dist/web-types/eip1193/internal.d.ts +3 -1
  61. package/package.json +2 -2
@@ -1,23 +1,120 @@
1
- import { JOSENotSupported as f } from "./index.web33.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');
1
+ import { isJWK as p } from "./index.web109.js";
2
+ import { decode as m } from "./index.web94.js";
3
+ import y from "./index.web110.js";
4
+ import { isCryptoKey as S, isKeyObject as K } from "./index.web108.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;
9
19
  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`);
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"]);
18
31
  }
19
- return new Set(e.crit);
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");
20
117
  };
21
118
  export {
22
- w as default
119
+ d as default
23
120
  };
@@ -39,6 +39,9 @@ export declare class RPCRequestError extends Error {
39
39
  code: RPCErrorCode;
40
40
  constructor(code: RPCErrorCode, message: string);
41
41
  }
42
+ export declare class AccountTypeMismatchError extends Error {
43
+ constructor(message: string);
44
+ }
42
45
  export declare function validateRequest(request: Parameters<ReturnType<typeof ox_Provider.from>["request"]>[0], { chains }: {
43
46
  chains: readonly [Chain, ...Chain[]];
44
47
  }): void;
@@ -46,3 +49,6 @@ export declare function validateUserConnected(): Promise<import('../types.js').U
46
49
  export declare function validateUserOwnsAddress(address: EvmAddress): Promise<import('../types.js').User>;
47
50
  export declare function validateUserHasEvmAccount(): Promise<import('../types.js').User>;
48
51
  export declare function validateUserHasEvmSmartAccount(): Promise<import('../types.js').User>;
52
+ export declare function validateIsUsingEOA({ errorMessage }?: {
53
+ errorMessage?: string;
54
+ }): Promise<import('../types.js').User>;
@@ -27,5 +27,7 @@ export declare function handleChainId(store: ProviderStoreInstance): Promise<Hex
27
27
  export declare function handleDisconnect(): Promise<void>;
28
28
  export declare function handleSwitchEthereumChain(params: SwitchEthereumChainRequest["params"], store: ProviderStoreInstance): void;
29
29
  export declare function handleSendCalls(params: SendCallsRequest["params"], store: ProviderStoreInstance): Promise<`0x${string}`>;
30
- export declare function handleGetCallsStatus(params: GetCallsStatusRequest["params"], store: ProviderStoreInstance): Promise<WalletGetCallsStatusReturnType>;
30
+ export declare function handleGetCallsStatus(params: GetCallsStatusRequest["params"], store: ProviderStoreInstance): Promise<WalletGetCallsStatusReturnType<{
31
+ [key: string]: any;
32
+ }, number, bigint | undefined, string | undefined>>;
31
33
  export declare function handleGetCapabilities(): Promise<WalletCapabilities>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-core",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",
@@ -27,7 +27,7 @@
27
27
  "ox": "0.8.1",
28
28
  "viem": "^2.33.0",
29
29
  "zustand": "^5.0.6",
30
- "@coinbase/cdp-api-client": "^0.0.41"
30
+ "@coinbase/cdp-api-client": "^0.0.42"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@react-native-async-storage/async-storage": "^2.0.0",