@coinbase/cdp-core 0.0.33 → 0.0.35

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 (91) hide show
  1. package/README.md +74 -8
  2. package/dist/esm/index.native.js +40 -37
  3. package/dist/esm/index.native100.js +41 -7
  4. package/dist/esm/index.native101.js +18 -11
  5. package/dist/esm/index.native102.js +28 -13
  6. package/dist/esm/index.native103.js +8 -10
  7. package/dist/esm/index.native104.js +11 -17
  8. package/dist/esm/index.native105.js +12 -80
  9. package/dist/esm/index.native106.js +10 -13
  10. package/dist/esm/index.native107.js +17 -36
  11. package/dist/esm/index.native108.js +79 -40
  12. package/dist/esm/index.native14.js +6 -5
  13. package/dist/esm/index.native15.js +12 -10
  14. package/dist/esm/index.native17.js +1 -0
  15. package/dist/esm/index.native28.js +1 -1
  16. package/dist/esm/index.native54.js +1 -1
  17. package/dist/esm/index.native55.js +1 -1
  18. package/dist/esm/index.native57.js +2 -2
  19. package/dist/esm/index.native59.js +1 -1
  20. package/dist/esm/index.native6.js +188 -134
  21. package/dist/esm/index.native77.js +6 -6
  22. package/dist/esm/index.native82.js +2 -21
  23. package/dist/esm/index.native83.js +21 -2
  24. package/dist/esm/index.native84.js +18 -102
  25. package/dist/esm/index.native85.js +80 -20
  26. package/dist/esm/index.native86.js +103 -79
  27. package/dist/esm/index.native89.js +10 -21
  28. package/dist/esm/index.native90.js +21 -10
  29. package/dist/esm/index.native91.js +9 -19
  30. package/dist/esm/index.native92.js +15 -89
  31. package/dist/esm/index.native93.js +92 -19
  32. package/dist/esm/index.native94.js +18 -115
  33. package/dist/esm/index.native95.js +112 -73
  34. package/dist/esm/index.native96.js +79 -10
  35. package/dist/esm/index.native98.js +13 -18
  36. package/dist/esm/index.native99.js +35 -27
  37. package/dist/esm/index.web.js +41 -38
  38. package/dist/esm/index.web12.js +6 -5
  39. package/dist/esm/index.web13.js +12 -10
  40. package/dist/esm/index.web15.js +1 -0
  41. package/dist/esm/index.web5.js +188 -134
  42. package/dist/native/index.native.js +40 -37
  43. package/dist/native/index.native100.js +41 -7
  44. package/dist/native/index.native101.js +18 -11
  45. package/dist/native/index.native102.js +28 -13
  46. package/dist/native/index.native103.js +8 -10
  47. package/dist/native/index.native104.js +11 -17
  48. package/dist/native/index.native105.js +12 -80
  49. package/dist/native/index.native106.js +10 -13
  50. package/dist/native/index.native107.js +17 -36
  51. package/dist/native/index.native108.js +79 -40
  52. package/dist/native/index.native14.js +6 -5
  53. package/dist/native/index.native15.js +12 -10
  54. package/dist/native/index.native17.js +1 -0
  55. package/dist/native/index.native28.js +1 -1
  56. package/dist/native/index.native54.js +1 -1
  57. package/dist/native/index.native55.js +1 -1
  58. package/dist/native/index.native57.js +2 -2
  59. package/dist/native/index.native59.js +1 -1
  60. package/dist/native/index.native6.js +188 -134
  61. package/dist/native/index.native77.js +6 -6
  62. package/dist/native/index.native82.js +2 -21
  63. package/dist/native/index.native83.js +21 -2
  64. package/dist/native/index.native84.js +18 -102
  65. package/dist/native/index.native85.js +80 -20
  66. package/dist/native/index.native86.js +103 -79
  67. package/dist/native/index.native89.js +10 -21
  68. package/dist/native/index.native90.js +21 -10
  69. package/dist/native/index.native91.js +9 -19
  70. package/dist/native/index.native92.js +15 -89
  71. package/dist/native/index.native93.js +92 -19
  72. package/dist/native/index.native94.js +18 -115
  73. package/dist/native/index.native95.js +112 -73
  74. package/dist/native/index.native96.js +79 -10
  75. package/dist/native/index.native98.js +13 -18
  76. package/dist/native/index.native99.js +35 -27
  77. package/dist/native-types/auth/withAuth.d.ts +3 -1
  78. package/dist/native-types/core.d.ts +3 -1
  79. package/dist/native-types/types.d.ts +20 -3
  80. package/dist/types/auth/withAuth.d.ts +3 -1
  81. package/dist/types/core.d.ts +3 -1
  82. package/dist/types/types.d.ts +20 -3
  83. package/dist/web/index.web.js +41 -38
  84. package/dist/web/index.web12.js +6 -5
  85. package/dist/web/index.web13.js +12 -10
  86. package/dist/web/index.web15.js +1 -0
  87. package/dist/web/index.web5.js +188 -134
  88. package/dist/web-types/auth/withAuth.d.ts +3 -1
  89. package/dist/web-types/core.d.ts +3 -1
  90. package/dist/web-types/types.d.ts +20 -3
  91. package/package.json +2 -2
package/README.md CHANGED
@@ -48,10 +48,11 @@ const config: Config = {
48
48
  await initialize(config);
49
49
  ```
50
50
 
51
- #### Smart Account Configuration
51
+ #### Account Configuration
52
52
 
53
- You can configure the SDK to automatically create Smart Accounts for new users by setting `createAccountOnLogin` to `"evm-smart"`:
53
+ You can configure the SDK to create different types of accounts for new users:
54
54
 
55
+ **Smart Account Configuration:**
55
56
  ```ts lines
56
57
  const config: Config = {
57
58
  projectId: "your-project-id",
@@ -66,6 +67,20 @@ When `createAccountOnLogin` is set to `"evm-smart"`, the SDK will:
66
67
  2. Use that EOA as the owner to create a Smart Account
67
68
  3. Both accounts will be available on the user object
68
69
 
70
+ **Solana Account Configuration:**
71
+ ```ts lines
72
+ const config: Config = {
73
+ projectId: "your-project-id",
74
+ createAccountOnLogin: "solana", // Creates Solana accounts instead of EVM accounts
75
+ }
76
+
77
+ await initialize(config);
78
+ ```
79
+
80
+ When `createAccountOnLogin` is set to `"solana"`, the SDK will:
81
+ 1. Create a Solana account for new users
82
+ 2. The Solana account will be available on the `solanaAccounts` property
83
+
69
84
  ### Sign In a User
70
85
 
71
86
  You're now ready to start calling the APIs provided by the package!
@@ -102,17 +117,27 @@ if (signedIn) {
102
117
  // Get the user's information
103
118
  const user = await getCurrentUser();
104
119
  console.log("User ID:", user.userId);
105
- console.log("EVM Accounts (EOAs):", user.evmAccounts);
106
- console.log("EVM Smart Accounts:", user.evmSmartAccounts);
120
+
121
+ // Display different account types based on configuration
122
+ if (user.evmAccounts?.length > 0) {
123
+ console.log("EVM Accounts (EOAs):", user.evmAccounts);
124
+ }
125
+ if (user.evmSmartAccounts?.length > 0) {
126
+ console.log("EVM Smart Accounts:", user.evmSmartAccounts);
127
+ }
128
+ if (user.solanaAccounts?.length > 0) {
129
+ console.log("Solana Accounts:", user.solanaAccounts);
130
+ }
107
131
 
108
132
  // Find the user's email address (if they logged in with email/otp)
109
133
  const email = user.authenticationMethods.email?.email;
110
- console.log("Email Address": email)
134
+ console.log("Email Address:", email);
111
135
  }
112
136
  ```
113
137
 
114
- ### Send a Transaction
115
- We support signing and sending a Blockchain transaction in a single call on the following networks:
138
+ ### Send an EVM Transaction
139
+
140
+ We support signing and sending an EVM transaction in a single call on the following networks:
116
141
  - Base
117
142
  - Base Sepolia
118
143
  - Ethereum
@@ -145,7 +170,7 @@ const result = await sendEvmTransaction({
145
170
  console.log("Transaction Hash:", result.transactionHash);
146
171
  ```
147
172
 
148
- For networks other than those supported by the CDP APIs, your end user must sign the transaction, and then
173
+ For EVM networks other than those supported by the CDP APIs, your end user must sign the transaction, and then
149
174
  you must broadcast the transaction yourself. This example uses the public client from `viem` to broadcast the transaction.
150
175
 
151
176
  ```typescript lines
@@ -186,6 +211,47 @@ const hash = await client.sendRawTransaction({
186
211
 
187
212
  Smart Accounts provide advanced account abstraction features, including user operations and paymaster support.
188
213
 
214
+ ### Sign a Solana Transaction
215
+
216
+ When your application is configured with `createAccountOnLogin: "solana"`, you can sign Solana transactions:
217
+
218
+ ```typescript lines
219
+ import { signSolanaTransaction, getCurrentUser } from "@coinbase/cdp-core";
220
+
221
+ const user = await getCurrentUser();
222
+ const solanaAccount = user.solanaAccounts[0];
223
+
224
+ const result = await signSolanaTransaction({
225
+ solanaAccount,
226
+ transaction: "base64-encoded-solana-transaction" // Your Solana transaction here
227
+ });
228
+
229
+ console.log("Signed Transaction:", result.signedTransaction);
230
+ // The signedTransaction can now be broadcast to the Solana network
231
+ ```
232
+
233
+ ### Send a Solana Transaction
234
+
235
+ You can sign and send a Solana transaction in a single call on the following Solana networks:
236
+ - Solana Mainnet
237
+ - Solana Devnet
238
+
239
+ ```typescript lines
240
+ import { sendSolanaTransaction, getCurrentUser } from "@coinbase/cdp-core";
241
+
242
+ const user = await getCurrentUser();
243
+ const solanaAccount = user.solanaAccounts[0];
244
+
245
+ const result = await sendSolanaTransaction({
246
+ solanaAccount,
247
+ network: "solana-devnet", // or "solana" for mainnet
248
+ transaction: "base64-encoded-solana-transaction" // Your Solana transaction here
249
+ });
250
+
251
+ console.log("Transaction Signature:", result.transactionSignature);
252
+ // The transaction has been broadcast to the Solana network
253
+ ```
254
+
189
255
  #### Send User Operations
190
256
 
191
257
  Send user operations from a Smart Account:
@@ -1,49 +1,52 @@
1
1
  import { nativeCrypto as r } from "./index.native2.js";
2
- import { nativeSecureStorage as e } from "./index.native3.js";
3
- import { nativeStorage as o } from "./index.native4.js";
2
+ import { nativeSecureStorage as o } from "./index.native3.js";
3
+ import { nativeStorage as e } from "./index.native4.js";
4
4
  import { setPlatformServices as t } from "./index.native5.js";
5
- import { exportEvmAccount as f, getAccessToken as v, getCurrentUser as d, getUserOperation as S, initialize as u, isSignedIn as T, onAuthStateChange as A, sendEvmTransaction as l, sendUserOperation as x, signEvmHash as y, signEvmMessage as h, signEvmTransaction as O, signEvmTypedData as P, signInWithEmail as C, signInWithSms as D, signOut as I, verifyEmailOTP as R, verifySmsOTP as U } from "./index.native6.js";
6
- import { AuthManager as M } from "./index.native7.js";
7
- import { APIError as H, ErrorType as N, HttpErrorType as _, SendEvmTransactionWithEndUserAccountBodyNetwork as b } from "@coinbase/cdp-api-client";
5
+ import { exportEvmAccount as d, getAccessToken as S, getCurrentUser as f, getUserOperation as v, initialize as T, isSignedIn as u, onAuthStateChange as l, sendEvmTransaction as A, sendSolanaTransaction as y, sendUserOperation as h, signEvmHash as x, signEvmMessage as O, signEvmTransaction as P, signEvmTypedData as C, signInWithEmail as D, signInWithSms as I, signOut as R, signSolanaTransaction as U, verifyEmailOTP as W, verifySmsOTP as k } from "./index.native6.js";
6
+ import { AuthManager as N } from "./index.native7.js";
7
+ import { APIError as B, ErrorType as H, HttpErrorType as _, SendEvmTransactionWithEndUserAccountBodyNetwork as b, SendSolanaTransactionWithEndUserAccountBodyNetwork as z } from "@coinbase/cdp-api-client";
8
8
  import "viem";
9
- import { createCDPEmbeddedWallet as z } from "./index.native8.js";
10
- import { EIP1193ProviderError as V, STANDARD_ERROR_CODES as j } from "./index.native9.js";
9
+ import { createCDPEmbeddedWallet as j } from "./index.native8.js";
10
+ import { EIP1193ProviderError as F, STANDARD_ERROR_CODES as G } from "./index.native9.js";
11
11
  import "ox";
12
12
  import "zustand";
13
- import { toViemAccount as F } from "./index.native10.js";
14
- import { ModuleResolutionError as J } from "./index.native11.js";
13
+ import { toViemAccount as K } from "./index.native10.js";
14
+ import { ModuleResolutionError as Q } from "./index.native11.js";
15
15
  t({
16
16
  crypto: r,
17
- storage: o,
18
- secureStorage: e
17
+ storage: e,
18
+ secureStorage: o
19
19
  });
20
20
  export {
21
- H as APIError,
22
- M as AuthManager,
23
- V as EIP1193ProviderError,
24
- N as ErrorType,
21
+ B as APIError,
22
+ N as AuthManager,
23
+ F as EIP1193ProviderError,
24
+ H as ErrorType,
25
25
  _ as HttpErrorType,
26
- J as ModuleResolutionError,
27
- j as STANDARD_ERROR_CODES,
26
+ Q as ModuleResolutionError,
27
+ G as STANDARD_ERROR_CODES,
28
28
  b as SendEvmTransactionWithEndUserAccountBodyNetwork,
29
- z as createCDPEmbeddedWallet,
30
- f as exportEvmAccount,
31
- v as getAccessToken,
32
- d as getCurrentUser,
33
- S as getUserOperation,
34
- u as initialize,
35
- T as isSignedIn,
36
- A as onAuthStateChange,
37
- l as sendEvmTransaction,
38
- x as sendUserOperation,
39
- y as signEvmHash,
40
- h as signEvmMessage,
41
- O as signEvmTransaction,
42
- P as signEvmTypedData,
43
- C as signInWithEmail,
44
- D as signInWithSms,
45
- I as signOut,
46
- F as toViemAccount,
47
- R as verifyEmailOTP,
48
- U as verifySmsOTP
29
+ z as SendSolanaTransactionWithEndUserAccountBodyNetwork,
30
+ j as createCDPEmbeddedWallet,
31
+ d as exportEvmAccount,
32
+ S as getAccessToken,
33
+ f as getCurrentUser,
34
+ v as getUserOperation,
35
+ T as initialize,
36
+ u as isSignedIn,
37
+ l as onAuthStateChange,
38
+ A as sendEvmTransaction,
39
+ y as sendSolanaTransaction,
40
+ h as sendUserOperation,
41
+ x as signEvmHash,
42
+ O as signEvmMessage,
43
+ P as signEvmTransaction,
44
+ C as signEvmTypedData,
45
+ D as signInWithEmail,
46
+ I as signInWithSms,
47
+ R as signOut,
48
+ U as signSolanaTransaction,
49
+ K as toViemAccount,
50
+ W as verifyEmailOTP,
51
+ k as verifySmsOTP
49
52
  };
@@ -1,10 +1,44 @@
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`);
6
- }
1
+ import { InvalidAddressError as a } from "./index.native65.js";
2
+ import { isAddress as f } from "./index.native39.js";
3
+ import { concatHex as p } from "./index.native40.js";
4
+ import { toHex as i } from "./index.native34.js";
5
+ import { toRlp as x } from "./index.native53.js";
6
+ import { serializeTransaction as l } from "./index.native20.js";
7
+ function T(r, e) {
8
+ return h(r) ? z(r) : l(r, e);
9
+ }
10
+ const E = {
11
+ transaction: T
7
12
  };
13
+ function z(r) {
14
+ w(r);
15
+ const { sourceHash: e, data: o, from: m, gas: t, isSystemTx: u, mint: s, to: c, value: n } = r, d = [
16
+ e,
17
+ m,
18
+ c ?? "0x",
19
+ s ? i(s) : "0x",
20
+ n ? i(n) : "0x",
21
+ t ? i(t) : "0x",
22
+ u ? "0x1" : "0x",
23
+ o ?? "0x"
24
+ ];
25
+ return p([
26
+ "0x7e",
27
+ x(d)
28
+ ]);
29
+ }
30
+ function h(r) {
31
+ return r.type === "deposit" || typeof r.sourceHash < "u";
32
+ }
33
+ function w(r) {
34
+ const { from: e, to: o } = r;
35
+ if (e && !f(e))
36
+ throw new a({ address: e });
37
+ if (o && !f(o))
38
+ throw new a({ address: o });
39
+ }
8
40
  export {
9
- o as default
41
+ w as assertTransactionDeposit,
42
+ T as serializeTransaction,
43
+ E as serializers
10
44
  };
@@ -1,13 +1,20 @@
1
- import { checkSigCryptoKey as i } from "./index.native109.js";
2
- import o from "./index.native102.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
- };
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
+ }
11
17
  export {
12
- s as default
18
+ a as decodeBase64,
19
+ o as encodeBase64
13
20
  };
@@ -1,15 +1,30 @@
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 { JOSENotSupported as r } from "./index.native30.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
+ };
12
28
  export {
13
- r as default,
14
- t as withAlg
29
+ S as default
15
30
  };
@@ -1,12 +1,10 @@
1
- function e(t) {
2
- return t?.[Symbol.toStringTag] === "CryptoKey";
3
- }
4
- function r(t) {
5
- return t?.[Symbol.toStringTag] === "KeyObject";
6
- }
7
- const n = (t) => e(t) || r(t);
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`);
6
+ }
7
+ };
8
8
  export {
9
- n as default,
10
- e as isCryptoKey,
11
- r as isKeyObject
9
+ o as default
12
10
  };
@@ -1,19 +1,13 @@
1
- import n from "./index.native81.js";
2
- function r(t) {
3
- return n(t) && typeof t.kty == "string";
4
- }
5
- function o(t) {
6
- return t.kty !== "oct" && typeof t.d == "string";
7
- }
8
- function e(t) {
9
- return t.kty !== "oct" && typeof t.d > "u";
10
- }
11
- function c(t) {
12
- return t.kty === "oct" && typeof t.k == "string";
13
- }
1
+ import { checkSigCryptoKey as i } from "./index.native109.js";
2
+ import o from "./index.native105.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
+ };
14
11
  export {
15
- r as isJWK,
16
- o as isPrivateJWK,
17
- e as isPublicJWK,
18
- c as isSecretJWK
12
+ s as default
19
13
  };
@@ -1,83 +1,15 @@
1
- import { JOSENotSupported as s } from "./index.native30.js";
2
- function n(e) {
3
- let a, r;
4
- switch (e.kty) {
5
- case "RSA": {
6
- switch (e.alg) {
7
- case "PS256":
8
- case "PS384":
9
- case "PS512":
10
- a = { name: "RSA-PSS", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
11
- break;
12
- case "RS256":
13
- case "RS384":
14
- case "RS512":
15
- a = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
16
- break;
17
- case "RSA-OAEP":
18
- case "RSA-OAEP-256":
19
- case "RSA-OAEP-384":
20
- case "RSA-OAEP-512":
21
- a = {
22
- name: "RSA-OAEP",
23
- hash: `SHA-${parseInt(e.alg.slice(-3), 10) || 1}`
24
- }, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
25
- break;
26
- default:
27
- throw new s('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
28
- }
29
- break;
30
- }
31
- case "EC": {
32
- switch (e.alg) {
33
- case "ES256":
34
- a = { name: "ECDSA", namedCurve: "P-256" }, r = e.d ? ["sign"] : ["verify"];
35
- break;
36
- case "ES384":
37
- a = { name: "ECDSA", namedCurve: "P-384" }, r = e.d ? ["sign"] : ["verify"];
38
- break;
39
- case "ES512":
40
- a = { name: "ECDSA", namedCurve: "P-521" }, r = e.d ? ["sign"] : ["verify"];
41
- break;
42
- case "ECDH-ES":
43
- case "ECDH-ES+A128KW":
44
- case "ECDH-ES+A192KW":
45
- case "ECDH-ES+A256KW":
46
- a = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
47
- break;
48
- default:
49
- throw new s('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
50
- }
51
- break;
52
- }
53
- case "OKP": {
54
- switch (e.alg) {
55
- case "Ed25519":
56
- case "EdDSA":
57
- a = { name: "Ed25519" }, r = e.d ? ["sign"] : ["verify"];
58
- break;
59
- case "ECDH-ES":
60
- case "ECDH-ES+A128KW":
61
- case "ECDH-ES+A192KW":
62
- case "ECDH-ES+A256KW":
63
- a = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
64
- break;
65
- default:
66
- throw new s('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
67
- }
68
- break;
69
- }
70
- default:
71
- throw new s('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
72
- }
73
- return { algorithm: a, keyUsages: r };
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);
74
11
  }
75
- const i = async (e) => {
76
- if (!e.alg)
77
- throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
78
- const { algorithm: a, keyUsages: r } = n(e), t = { ...e };
79
- return delete t.alg, delete t.use, crypto.subtle.importKey("jwk", t, a, e.ext ?? !e.d, e.key_ops ?? r);
80
- };
81
12
  export {
82
- i as default
13
+ r as default,
14
+ t as withAlg
83
15
  };
@@ -1,15 +1,12 @@
1
- const s = {
2
- gasPriceOracle: { address: "0x420000000000000000000000000000000000000F" },
3
- l1Block: { address: "0x4200000000000000000000000000000000000015" },
4
- l2CrossDomainMessenger: {
5
- address: "0x4200000000000000000000000000000000000007"
6
- },
7
- l2Erc721Bridge: { address: "0x4200000000000000000000000000000000000014" },
8
- l2StandardBridge: { address: "0x4200000000000000000000000000000000000010" },
9
- l2ToL1MessagePasser: {
10
- address: "0x4200000000000000000000000000000000000016"
11
- }
12
- };
1
+ function e(t) {
2
+ return t?.[Symbol.toStringTag] === "CryptoKey";
3
+ }
4
+ function r(t) {
5
+ return t?.[Symbol.toStringTag] === "KeyObject";
6
+ }
7
+ const n = (t) => e(t) || r(t);
13
8
  export {
14
- s as contracts
9
+ n as default,
10
+ e as isCryptoKey,
11
+ r as isKeyObject
15
12
  };
@@ -1,38 +1,19 @@
1
- import { hexToBigInt as n } from "./index.native50.js";
2
- import { defineBlock as r } from "./index.native47.js";
3
- import { defineTransaction as s, formatTransaction as m } from "./index.native49.js";
4
- import { defineTransactionReceipt as l } from "./index.native52.js";
5
- const p = {
6
- block: /* @__PURE__ */ r({
7
- format(e) {
8
- return {
9
- transactions: e.transactions?.map((t) => {
10
- if (typeof t == "string")
11
- return t;
12
- const i = m(t);
13
- return i.typeHex === "0x7e" && (i.isSystemTx = t.isSystemTx, i.mint = t.mint ? n(t.mint) : void 0, i.sourceHash = t.sourceHash, i.type = "deposit"), i;
14
- }),
15
- stateRoot: e.stateRoot
16
- };
17
- }
18
- }),
19
- transaction: /* @__PURE__ */ s({
20
- format(e) {
21
- const o = {};
22
- return e.type === "0x7e" && (o.isSystemTx = e.isSystemTx, o.mint = e.mint ? n(e.mint) : void 0, o.sourceHash = e.sourceHash, o.type = "deposit"), o;
23
- }
24
- }),
25
- transactionReceipt: /* @__PURE__ */ l({
26
- format(e) {
27
- return {
28
- l1GasPrice: e.l1GasPrice ? n(e.l1GasPrice) : null,
29
- l1GasUsed: e.l1GasUsed ? n(e.l1GasUsed) : null,
30
- l1Fee: e.l1Fee ? n(e.l1Fee) : null,
31
- l1FeeScalar: e.l1FeeScalar ? Number(e.l1FeeScalar) : null
32
- };
33
- }
34
- })
35
- };
1
+ import n from "./index.native81.js";
2
+ function r(t) {
3
+ return n(t) && typeof t.kty == "string";
4
+ }
5
+ function o(t) {
6
+ return t.kty !== "oct" && typeof t.d == "string";
7
+ }
8
+ function e(t) {
9
+ return t.kty !== "oct" && typeof t.d > "u";
10
+ }
11
+ function c(t) {
12
+ return t.kty === "oct" && typeof t.k == "string";
13
+ }
36
14
  export {
37
- p as formatters
15
+ r as isJWK,
16
+ o as isPrivateJWK,
17
+ e as isPublicJWK,
18
+ c as isSecretJWK
38
19
  };