@coinbase/cdp-core 0.0.12 → 0.0.14

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.
package/README.md CHANGED
@@ -85,6 +85,10 @@ if (signedIn) {
85
85
  const user = await getCurrentUser();
86
86
  console.log("User ID:", user.userId);
87
87
  console.log("EVM Accounts:", user.evmAccounts);
88
+
89
+ // Find the user's email address (if they logged in with email/otp)
90
+ const email = user.authenticationMethods.email?.email;
91
+ console.log("Email Address": email)
88
92
  }
89
93
  ```
90
94
 
@@ -1,4 +1,4 @@
1
- import n from "./index84.js";
1
+ import n from "./index85.js";
2
2
  function r(t) {
3
3
  return n(t) && typeof t.kty == "string";
4
4
  }
@@ -1,8 +1,14 @@
1
- const s = "0x0000000000000000000000000000000000000000", c = {
1
+ const e = "0x0000000000000000000000000000000000000000", t = {
2
2
  userId: "mock-user-id",
3
- evmAccounts: [s]
3
+ evmAccounts: [e],
4
+ authenticationMethods: {
5
+ email: {
6
+ type: "email",
7
+ email: "test@test.com"
8
+ }
9
+ }
4
10
  };
5
11
  export {
6
- s as mockAddress,
7
- c as mockUser
12
+ e as mockAddress,
13
+ t as mockUser
8
14
  };
@@ -1,4 +1,4 @@
1
- import { configureCdpApiClient as p, setAuthManager as w, initiateAuthentication as h, verifyEmailAuthentication as y, createEndUserEvmAccount as f, signEvmHashWithEndUserAccount as I, signEvmTransactionWithEndUserAccount as l, sendEvmTransactionWithEndUserAccount as E, signEvmMessageWithEndUserAccount as v, signEvmTypedDataWithEndUserAccount as A, exportEndUserEvmAccount as k } from "@coinbase/cdp-api-client";
1
+ import { configureCdpApiClient as p, setAuthManager as w, initiateAuthentication as h, verifyEmailAuthentication as y, createEndUserEvmAccount as f, signEvmHashWithEndUserAccount as I, signEvmTransactionWithEndUserAccount as l, sendEvmTransactionWithEndUserAccount as v, signEvmMessageWithEndUserAccount as A, signEvmTypedDataWithEndUserAccount as E, exportEndUserEvmAccount as k } from "@coinbase/cdp-api-client";
2
2
  import { AuthManager as M } from "./index6.js";
3
3
  import { toAuthState as u } from "./index7.js";
4
4
  import { withAuth as i } from "./index8.js";
@@ -64,7 +64,7 @@ const $ = async (e) => {
64
64
  otp: e.otp
65
65
  });
66
66
  let a = u(t.accessToken, t.validUntil, t.endUser);
67
- if (a.user.evmAccounts.length === 0)
67
+ if (!a.user.evmAccounts || a.user.evmAccounts.length === 0)
68
68
  try {
69
69
  const o = await f(r().projectId, a.user.userId, {
70
70
  walletSecretId: await n().getWalletSecretId(a)
@@ -116,7 +116,7 @@ const $ = async (e) => {
116
116
  return { transactionHash: "0x0" };
117
117
  const s = m(e.transaction);
118
118
  return i(e, n(), async ({ user: t, walletSecretId: a }) => ({
119
- transactionHash: (await E(
119
+ transactionHash: (await v(
120
120
  r().projectId,
121
121
  t.userId,
122
122
  {
@@ -128,13 +128,13 @@ const $ = async (e) => {
128
128
  )).transactionHash
129
129
  }));
130
130
  }, Y = async (e) => r().useMock ? { signature: "0x0" } : i(e, n(), async ({ user: s, walletSecretId: t }) => ({
131
- signature: (await v(r().projectId, s.userId, {
131
+ signature: (await A(r().projectId, s.userId, {
132
132
  message: e.message,
133
133
  address: e.evmAccount,
134
134
  walletSecretId: t
135
135
  })).signature
136
136
  })), Z = async (e) => r().useMock ? { signature: "0x0" } : i(e, n(), async ({ user: s, walletSecretId: t }) => ({
137
- signature: (await A(r().projectId, s.userId, {
137
+ signature: (await E(r().projectId, s.userId, {
138
138
  typedData: e.typedData,
139
139
  address: e.evmAccount,
140
140
  walletSecretId: t
@@ -1,8 +1,8 @@
1
1
  import { Provider as y, Hex as I } from "ox";
2
2
  import { createWalletClient as E } from "viem";
3
- import { signEvmTypedData as S, signEvmHash as P, getCurrentUser as f, signOut as R, sendEvmTransaction as T, signEvmTransaction as A, signEvmMessage as x } from "./index2.js";
3
+ import { signEvmTypedData as P, signEvmHash as S, getCurrentUser as f, signOut as R, sendEvmTransaction as T, signEvmTransaction as A, signEvmMessage as x } from "./index2.js";
4
4
  import "./index3.js";
5
- import { validateUserOwnsAddress as m, EIP1193ProviderError as l, STANDARD_ERROR_CODES as s, RPCRequestError as c, validateUserHasEvmAccount as C, validateUserConnected as D } from "./index4.js";
5
+ import { validateUserOwnsAddress as m, EIP1193ProviderError as l, STANDARD_ERROR_CODES as s, RPCRequestError as o, validateUserHasEvmAccount as C, validateUserConnected as D } from "./index4.js";
6
6
  import { isChainIdSupportedForCDPSends as b, chainIdToNameMapping as j } from "./index13.js";
7
7
  function g(e) {
8
8
  return {
@@ -16,14 +16,14 @@ function g(e) {
16
16
  type: "eip1559"
17
17
  };
18
18
  }
19
- async function U() {
19
+ async function H() {
20
20
  return (await f())?.evmAccounts || [];
21
21
  }
22
22
  async function M(e, n) {
23
23
  const a = await D();
24
24
  return e.emit("connect", {
25
25
  chainId: I.fromNumber(n.getState().chainId)
26
- }), a.evmAccounts;
26
+ }), a.evmAccounts || [];
27
27
  }
28
28
  async function _(e) {
29
29
  const [n, a] = e;
@@ -34,10 +34,10 @@ async function _(e) {
34
34
  evmAccount: a,
35
35
  message: t
36
36
  })).signature;
37
- } catch (o) {
37
+ } catch (c) {
38
38
  throw new l(
39
39
  s.provider.userRejectedRequest,
40
- o instanceof Error ? o.message : "Signing failed"
40
+ c instanceof Error ? c.message : "Signing failed"
41
41
  );
42
42
  }
43
43
  }
@@ -45,7 +45,7 @@ async function k(e) {
45
45
  const [n, a] = e;
46
46
  await m(n);
47
47
  try {
48
- return (await S({
48
+ return (await P({
49
49
  evmAccount: n,
50
50
  typedData: JSON.parse(a)
51
51
  })).signature;
@@ -59,16 +59,21 @@ async function k(e) {
59
59
  async function z(e, n, a) {
60
60
  const [t] = e;
61
61
  if (!t || typeof t != "object")
62
- throw new c(
62
+ throw new o(
63
63
  s.rpc.invalidParams,
64
64
  "Transaction parameter must be an object"
65
65
  );
66
66
  if (!t.to)
67
- throw new c(
67
+ throw new o(
68
68
  s.rpc.invalidParams,
69
69
  "Transaction must include 'to' field"
70
70
  );
71
- const d = (await C()).evmAccounts[0], u = n.getState(), i = t.chainId ? Number(t.chainId) : u.chainId;
71
+ const d = (await C()).evmAccounts?.[0], u = n.getState(), i = t.chainId ? Number(t.chainId) : u.chainId;
72
+ if (!d)
73
+ throw new o(
74
+ s.rpc.invalidParams,
75
+ "User does not have an EVM account"
76
+ );
72
77
  if (b(i))
73
78
  try {
74
79
  return (await T({
@@ -77,7 +82,7 @@ async function z(e, n, a) {
77
82
  network: j[i]
78
83
  })).transactionHash;
79
84
  } catch (r) {
80
- throw console.log("Transaction failed", r), new c(
85
+ throw console.log("Transaction failed", r), new o(
81
86
  s.rpc.transactionRejected,
82
87
  r instanceof Error ? r.message : "Transaction failed"
83
88
  );
@@ -89,13 +94,13 @@ async function z(e, n, a) {
89
94
  chain: u.chains.find((h) => h.id === i),
90
95
  transport: a[i],
91
96
  account: d
92
- }), p = u.chains.find((h) => h.id === i), w = await r.prepareTransactionRequest({
97
+ }), w = u.chains.find((h) => h.id === i), p = await r.prepareTransactionRequest({
93
98
  ...g(t),
94
- chain: p
99
+ chain: w
95
100
  }), v = await A({
96
101
  evmAccount: d,
97
102
  transaction: {
98
- ...w,
103
+ ...p,
99
104
  type: "eip1559"
100
105
  }
101
106
  });
@@ -103,7 +108,7 @@ async function z(e, n, a) {
103
108
  serializedTransaction: v.signedTransaction
104
109
  });
105
110
  } catch (r) {
106
- throw new c(
111
+ throw new o(
107
112
  s.rpc.transactionRejected,
108
113
  r instanceof Error ? r.message : "Transaction failed"
109
114
  );
@@ -113,7 +118,7 @@ async function J(e) {
113
118
  const [n, a] = e;
114
119
  await m(a);
115
120
  try {
116
- return (await P({
121
+ return (await S({
117
122
  evmAccount: a,
118
123
  hash: n
119
124
  })).signature;
@@ -124,25 +129,25 @@ async function J(e) {
124
129
  );
125
130
  }
126
131
  }
127
- async function W(e) {
132
+ async function V(e) {
128
133
  return `0x${e.getState().chainId.toString(16)}`;
129
134
  }
130
- async function $(e) {
135
+ async function W(e) {
131
136
  await f() && await R(), e.emit("disconnect", new y.DisconnectedError());
132
137
  }
133
- function K(e, n) {
138
+ function $(e, n) {
134
139
  const a = Number.parseInt(e[0].chainId, 16);
135
140
  n.getState().setChainId(a);
136
141
  }
137
142
  export {
138
- U as handleAccounts,
139
- W as handleChainId,
140
- $ as handleDisconnect,
143
+ H as handleAccounts,
144
+ V as handleChainId,
145
+ W as handleDisconnect,
141
146
  J as handleEthSign,
142
147
  _ as handlePersonalSign,
143
148
  M as handleRequestAccounts,
144
149
  z as handleSendTransaction,
145
150
  k as handleSignTypedData,
146
- K as handleSwitchEthereumChain,
151
+ $ as handleSwitchEthereumChain,
147
152
  g as shimProviderTxRequest
148
153
  };
@@ -1,4 +1,4 @@
1
- import { chainConfig as a } from "./index85.js";
1
+ import { chainConfig as a } from "./index86.js";
2
2
  import { defineChain as t } from "./index25.js";
3
3
  const e = 11155111, r = /* @__PURE__ */ t({
4
4
  ...a,
@@ -100,7 +100,7 @@ async function d() {
100
100
  }
101
101
  async function w(e) {
102
102
  const t = await d();
103
- if (!t.evmAccounts.includes(e))
103
+ if (!t.evmAccounts?.includes(e))
104
104
  throw new o(
105
105
  n.provider.unauthorized,
106
106
  "Address not owned by user"
@@ -109,7 +109,7 @@ async function w(e) {
109
109
  }
110
110
  async function f() {
111
111
  const e = await d();
112
- if (!e.evmAccounts[0])
112
+ if (!e.evmAccounts?.[0])
113
113
  throw new o(
114
114
  n.provider.unauthorized,
115
115
  "No EVM accounts available"
@@ -1,14 +1,15 @@
1
- const u = (e, s, t) => {
2
- const c = new Date(s).getTime(), o = {
3
- userId: t.userId,
4
- evmAccounts: t.evmAccounts?.map((r) => r) ?? []
1
+ const c = (u, n, e) => {
2
+ const o = new Date(n).getTime(), r = {
3
+ userId: e.userId,
4
+ evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
5
+ authenticationMethods: e.authenticationMethods.reduce((t, s) => (t[s.type] = s, t), {})
5
6
  };
6
7
  return {
7
- accessToken: e,
8
- expiresAt: c,
9
- user: o
8
+ accessToken: u,
9
+ expiresAt: o,
10
+ user: r
10
11
  };
11
12
  };
12
13
  export {
13
- u as toAuthState
14
+ c as toAuthState
14
15
  };
@@ -1,4 +1,4 @@
1
- import { FlattenedSign as n } from "./index80.js";
1
+ import { FlattenedSign as n } from "./index81.js";
2
2
  class o {
3
3
  #e;
4
4
  constructor(e) {
@@ -1,7 +1,7 @@
1
- import { encoder as n } from "./index81.js";
2
- import e from "./index82.js";
3
- import i from "./index83.js";
4
- import o from "./index84.js";
1
+ import { encoder as n } from "./index82.js";
2
+ import e from "./index83.js";
3
+ import i from "./index84.js";
4
+ import o from "./index85.js";
5
5
  function s(r, t) {
6
6
  if (!Number.isFinite(t))
7
7
  throw new TypeError(`Invalid ${r} input`);
@@ -1,4 +1,4 @@
1
- import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index86.js";
1
+ import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index80.js";
2
2
  import { createHasher as u, clean as C, rotr as i } from "./index76.js";
3
3
  const B = /* @__PURE__ */ Uint32Array.from([
4
4
  1116352408,
@@ -3,7 +3,7 @@ async function s(t, n, r) {
3
3
  if (!await o(n))
4
4
  throw new Error("User not signed in");
5
5
  const e = await n.getUser();
6
- if (!e.evmAccounts.find((i) => i === t.evmAccount))
6
+ if (!e.evmAccounts?.find((i) => i === t.evmAccount))
7
7
  throw new Error("EVM account not found");
8
8
  const c = await n.getWalletSecretId();
9
9
  return r({ ...t, user: e, walletSecretId: c });
@@ -1,57 +1,81 @@
1
- import { encode as d } from "./index88.js";
2
- import y from "./index89.js";
3
- import b from "./index90.js";
4
- import { JWSInvalid as r } from "./index71.js";
5
- import { encoder as s, concat as u, decoder as h } from "./index81.js";
6
- import g from "./index91.js";
7
- import H from "./index92.js";
8
- import P from "./index93.js";
9
- class x {
10
- #r;
11
- #e;
12
- #t;
13
- constructor(e) {
14
- if (!(e instanceof Uint8Array))
15
- throw new TypeError("payload must be an instance of Uint8Array");
16
- this.#r = e;
1
+ import { Hash as g, createView as l, aexists as b, toBytes as a, abytes as d, aoutput as x, clean as w } from "./index76.js";
2
+ function y(o, t, s, n) {
3
+ if (typeof o.setBigUint64 == "function")
4
+ return o.setBigUint64(t, s, n);
5
+ const i = BigInt(32), h = BigInt(4294967295), e = Number(s >> i & h), r = Number(s & h), c = n ? 4 : 0, u = n ? 0 : 4;
6
+ o.setUint32(t + c, e, n), o.setUint32(t + u, r, n);
7
+ }
8
+ function U(o, t, s) {
9
+ return o & t ^ ~o & s;
10
+ }
11
+ function _(o, t, s) {
12
+ return o & t ^ o & s ^ t & s;
13
+ }
14
+ class m extends g {
15
+ constructor(t, s, n, i) {
16
+ super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = l(this.buffer);
17
+ }
18
+ update(t) {
19
+ b(this), t = a(t), d(t);
20
+ const { view: s, buffer: n, blockLen: i } = this, h = t.length;
21
+ for (let e = 0; e < h; ) {
22
+ const r = Math.min(i - this.pos, h - e);
23
+ if (r === i) {
24
+ const c = l(t);
25
+ for (; i <= h - e; e += i)
26
+ this.process(c, e);
27
+ continue;
28
+ }
29
+ n.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === i && (this.process(s, 0), this.pos = 0);
30
+ }
31
+ return this.length += t.length, this.roundClean(), this;
32
+ }
33
+ digestInto(t) {
34
+ b(this), x(t, this), this.finished = !0;
35
+ const { buffer: s, view: n, blockLen: i, isLE: h } = this;
36
+ let { pos: e } = this;
37
+ s[e++] = 128, w(this.buffer.subarray(e)), this.padOffset > i - e && (this.process(n, 0), e = 0);
38
+ for (let f = e; f < i; f++)
39
+ s[f] = 0;
40
+ y(n, i - 8, BigInt(this.length * 8), h), this.process(n, 0);
41
+ const r = l(t), c = this.outputLen;
42
+ if (c % 4)
43
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
44
+ const u = c / 4, p = this.get();
45
+ if (u > p.length)
46
+ throw new Error("_sha2: outputLen bigger than state");
47
+ for (let f = 0; f < u; f++)
48
+ r.setUint32(4 * f, p[f], h);
17
49
  }
18
- setProtectedHeader(e) {
19
- if (this.#e)
20
- throw new TypeError("setProtectedHeader can only be called once");
21
- return this.#e = e, this;
50
+ digest() {
51
+ const { buffer: t, outputLen: s } = this;
52
+ this.digestInto(t);
53
+ const n = t.slice(0, s);
54
+ return this.destroy(), n;
22
55
  }
23
- setUnprotectedHeader(e) {
24
- if (this.#t)
25
- throw new TypeError("setUnprotectedHeader can only be called once");
26
- return this.#t = e, this;
56
+ _cloneInto(t) {
57
+ t || (t = new this.constructor()), t.set(...this.get());
58
+ const { blockLen: s, buffer: n, length: i, finished: h, destroyed: e, pos: r } = this;
59
+ return t.destroyed = e, t.finished = h, t.length = i, t.pos = r, i % s && t.buffer.set(n), t;
27
60
  }
28
- async sign(e, l) {
29
- if (!this.#e && !this.#t)
30
- throw new r("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
31
- if (!b(this.#e, this.#t))
32
- throw new r("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
33
- const c = {
34
- ...this.#e,
35
- ...this.#t
36
- }, p = H(r, /* @__PURE__ */ new Map([["b64", !0]]), l?.crit, this.#e, c);
37
- let o = !0;
38
- if (p.has("b64") && (o = this.#e.b64, typeof o != "boolean"))
39
- throw new r('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
40
- const { alg: t } = c;
41
- if (typeof t != "string" || !t)
42
- throw new r('JWS "alg" (Algorithm) Header Parameter missing or invalid');
43
- g(t, e, "sign");
44
- let i = this.#r;
45
- o && (i = s.encode(d(i)));
46
- let n;
47
- this.#e ? n = s.encode(d(JSON.stringify(this.#e))) : n = s.encode("");
48
- const f = u(n, s.encode("."), i), m = await P(e, t), w = await y(t, m, f), a = {
49
- signature: d(w),
50
- payload: ""
51
- };
52
- return o && (a.payload = h.decode(i)), this.#t && (a.header = this.#t), this.#e && (a.protected = h.decode(n)), a;
61
+ clone() {
62
+ return this._cloneInto();
53
63
  }
54
64
  }
65
+ const B = /* @__PURE__ */ Uint32Array.from([
66
+ 1779033703,
67
+ 3144134277,
68
+ 1013904242,
69
+ 2773480762,
70
+ 1359893119,
71
+ 2600822924,
72
+ 528734635,
73
+ 1541459225
74
+ ]);
55
75
  export {
56
- x as FlattenedSign
76
+ U as Chi,
77
+ m as HashMD,
78
+ _ as Maj,
79
+ B as SHA256_IV,
80
+ y as setBigUint64
57
81
  };
@@ -1,13 +1,57 @@
1
- const d = new TextEncoder(), s = new TextDecoder();
2
- function f(...n) {
3
- const c = n.reduce((e, { length: r }) => e + r, 0), t = new Uint8Array(c);
4
- let o = 0;
5
- for (const e of n)
6
- t.set(e, o), o += e.length;
7
- return t;
1
+ import { encode as d } from "./index88.js";
2
+ import y from "./index89.js";
3
+ import b from "./index90.js";
4
+ import { JWSInvalid as r } from "./index71.js";
5
+ import { encoder as s, concat as u, decoder as h } from "./index82.js";
6
+ import g from "./index91.js";
7
+ import H from "./index92.js";
8
+ import P from "./index93.js";
9
+ class x {
10
+ #r;
11
+ #e;
12
+ #t;
13
+ constructor(e) {
14
+ if (!(e instanceof Uint8Array))
15
+ throw new TypeError("payload must be an instance of Uint8Array");
16
+ this.#r = e;
17
+ }
18
+ setProtectedHeader(e) {
19
+ if (this.#e)
20
+ throw new TypeError("setProtectedHeader can only be called once");
21
+ return this.#e = e, this;
22
+ }
23
+ setUnprotectedHeader(e) {
24
+ if (this.#t)
25
+ throw new TypeError("setUnprotectedHeader can only be called once");
26
+ return this.#t = e, this;
27
+ }
28
+ async sign(e, l) {
29
+ if (!this.#e && !this.#t)
30
+ throw new r("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
31
+ if (!b(this.#e, this.#t))
32
+ throw new r("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
33
+ const c = {
34
+ ...this.#e,
35
+ ...this.#t
36
+ }, p = H(r, /* @__PURE__ */ new Map([["b64", !0]]), l?.crit, this.#e, c);
37
+ let o = !0;
38
+ if (p.has("b64") && (o = this.#e.b64, typeof o != "boolean"))
39
+ throw new r('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
40
+ const { alg: t } = c;
41
+ if (typeof t != "string" || !t)
42
+ throw new r('JWS "alg" (Algorithm) Header Parameter missing or invalid');
43
+ g(t, e, "sign");
44
+ let i = this.#r;
45
+ o && (i = s.encode(d(i)));
46
+ let n;
47
+ this.#e ? n = s.encode(d(JSON.stringify(this.#e))) : n = s.encode("");
48
+ const f = u(n, s.encode("."), i), m = await P(e, t), w = await y(t, m, f), a = {
49
+ signature: d(w),
50
+ payload: ""
51
+ };
52
+ return o && (a.payload = h.decode(i)), this.#t && (a.header = this.#t), this.#e && (a.protected = h.decode(n)), a;
53
+ }
8
54
  }
9
55
  export {
10
- f as concat,
11
- s as decoder,
12
- d as encoder
56
+ x as FlattenedSign
13
57
  };
@@ -1,4 +1,13 @@
1
- const o = (e) => Math.floor(e.getTime() / 1e3);
1
+ const d = new TextEncoder(), s = new TextDecoder();
2
+ function f(...n) {
3
+ const c = n.reduce((e, { length: r }) => e + r, 0), t = new Uint8Array(c);
4
+ let o = 0;
5
+ for (const e of n)
6
+ t.set(e, o), o += e.length;
7
+ return t;
8
+ }
2
9
  export {
3
- o as default
10
+ f as concat,
11
+ s as decoder,
12
+ d as encoder
4
13
  };
@@ -1,47 +1,4 @@
1
- const o = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, t = (c) => {
2
- const s = o.exec(c);
3
- if (!s || s[4] && s[1])
4
- throw new TypeError("Invalid time period format");
5
- const a = parseFloat(s[2]), r = s[3].toLowerCase();
6
- let e;
7
- switch (r) {
8
- case "sec":
9
- case "secs":
10
- case "second":
11
- case "seconds":
12
- case "s":
13
- e = Math.round(a);
14
- break;
15
- case "minute":
16
- case "minutes":
17
- case "min":
18
- case "mins":
19
- case "m":
20
- e = Math.round(a * 60);
21
- break;
22
- case "hour":
23
- case "hours":
24
- case "hr":
25
- case "hrs":
26
- case "h":
27
- e = Math.round(a * 3600);
28
- break;
29
- case "day":
30
- case "days":
31
- case "d":
32
- e = Math.round(a * 86400);
33
- break;
34
- case "week":
35
- case "weeks":
36
- case "w":
37
- e = Math.round(a * 604800);
38
- break;
39
- default:
40
- e = Math.round(a * 31557600);
41
- break;
42
- }
43
- return s[1] === "-" || s[4] === "ago" ? -e : e;
44
- };
1
+ const o = (e) => Math.floor(e.getTime() / 1e3);
45
2
  export {
46
- t as default
3
+ o as default
47
4
  };
@@ -1,16 +1,47 @@
1
- function o(t) {
2
- return typeof t == "object" && t !== null;
3
- }
4
- const r = (t) => {
5
- if (!o(t) || Object.prototype.toString.call(t) !== "[object Object]")
6
- return !1;
7
- if (Object.getPrototypeOf(t) === null)
8
- return !0;
9
- let e = t;
10
- for (; Object.getPrototypeOf(e) !== null; )
11
- e = Object.getPrototypeOf(e);
12
- return Object.getPrototypeOf(t) === e;
1
+ const o = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, t = (c) => {
2
+ const s = o.exec(c);
3
+ if (!s || s[4] && s[1])
4
+ throw new TypeError("Invalid time period format");
5
+ const a = parseFloat(s[2]), r = s[3].toLowerCase();
6
+ let e;
7
+ switch (r) {
8
+ case "sec":
9
+ case "secs":
10
+ case "second":
11
+ case "seconds":
12
+ case "s":
13
+ e = Math.round(a);
14
+ break;
15
+ case "minute":
16
+ case "minutes":
17
+ case "min":
18
+ case "mins":
19
+ case "m":
20
+ e = Math.round(a * 60);
21
+ break;
22
+ case "hour":
23
+ case "hours":
24
+ case "hr":
25
+ case "hrs":
26
+ case "h":
27
+ e = Math.round(a * 3600);
28
+ break;
29
+ case "day":
30
+ case "days":
31
+ case "d":
32
+ e = Math.round(a * 86400);
33
+ break;
34
+ case "week":
35
+ case "weeks":
36
+ case "w":
37
+ e = Math.round(a * 604800);
38
+ break;
39
+ default:
40
+ e = Math.round(a * 31557600);
41
+ break;
42
+ }
43
+ return s[1] === "-" || s[4] === "ago" ? -e : e;
13
44
  };
14
45
  export {
15
- r as default
46
+ t as default
16
47
  };
@@ -1,12 +1,16 @@
1
- import { contracts as o } from "./index94.js";
2
- import { formatters as r } from "./index95.js";
3
- import { serializers as t } from "./index96.js";
4
- const e = {
5
- blockTime: 2e3,
6
- contracts: o,
7
- formatters: r,
8
- serializers: t
1
+ function o(t) {
2
+ return typeof t == "object" && t !== null;
3
+ }
4
+ const r = (t) => {
5
+ if (!o(t) || Object.prototype.toString.call(t) !== "[object Object]")
6
+ return !1;
7
+ if (Object.getPrototypeOf(t) === null)
8
+ return !0;
9
+ let e = t;
10
+ for (; Object.getPrototypeOf(e) !== null; )
11
+ e = Object.getPrototypeOf(e);
12
+ return Object.getPrototypeOf(t) === e;
9
13
  };
10
14
  export {
11
- e as chainConfig
15
+ r as default
12
16
  };
@@ -1,81 +1,12 @@
1
- import { Hash as g, createView as l, aexists as b, toBytes as a, abytes as d, aoutput as x, clean as w } from "./index76.js";
2
- function y(o, t, s, n) {
3
- if (typeof o.setBigUint64 == "function")
4
- return o.setBigUint64(t, s, n);
5
- const i = BigInt(32), h = BigInt(4294967295), e = Number(s >> i & h), r = Number(s & h), c = n ? 4 : 0, u = n ? 0 : 4;
6
- o.setUint32(t + c, e, n), o.setUint32(t + u, r, n);
7
- }
8
- function U(o, t, s) {
9
- return o & t ^ ~o & s;
10
- }
11
- function _(o, t, s) {
12
- return o & t ^ o & s ^ t & s;
13
- }
14
- class m extends g {
15
- constructor(t, s, n, i) {
16
- super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = l(this.buffer);
17
- }
18
- update(t) {
19
- b(this), t = a(t), d(t);
20
- const { view: s, buffer: n, blockLen: i } = this, h = t.length;
21
- for (let e = 0; e < h; ) {
22
- const r = Math.min(i - this.pos, h - e);
23
- if (r === i) {
24
- const c = l(t);
25
- for (; i <= h - e; e += i)
26
- this.process(c, e);
27
- continue;
28
- }
29
- n.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === i && (this.process(s, 0), this.pos = 0);
30
- }
31
- return this.length += t.length, this.roundClean(), this;
32
- }
33
- digestInto(t) {
34
- b(this), x(t, this), this.finished = !0;
35
- const { buffer: s, view: n, blockLen: i, isLE: h } = this;
36
- let { pos: e } = this;
37
- s[e++] = 128, w(this.buffer.subarray(e)), this.padOffset > i - e && (this.process(n, 0), e = 0);
38
- for (let f = e; f < i; f++)
39
- s[f] = 0;
40
- y(n, i - 8, BigInt(this.length * 8), h), this.process(n, 0);
41
- const r = l(t), c = this.outputLen;
42
- if (c % 4)
43
- throw new Error("_sha2: outputLen should be aligned to 32bit");
44
- const u = c / 4, p = this.get();
45
- if (u > p.length)
46
- throw new Error("_sha2: outputLen bigger than state");
47
- for (let f = 0; f < u; f++)
48
- r.setUint32(4 * f, p[f], h);
49
- }
50
- digest() {
51
- const { buffer: t, outputLen: s } = this;
52
- this.digestInto(t);
53
- const n = t.slice(0, s);
54
- return this.destroy(), n;
55
- }
56
- _cloneInto(t) {
57
- t || (t = new this.constructor()), t.set(...this.get());
58
- const { blockLen: s, buffer: n, length: i, finished: h, destroyed: e, pos: r } = this;
59
- return t.destroyed = e, t.finished = h, t.length = i, t.pos = r, i % s && t.buffer.set(n), t;
60
- }
61
- clone() {
62
- return this._cloneInto();
63
- }
64
- }
65
- const B = /* @__PURE__ */ Uint32Array.from([
66
- 1779033703,
67
- 3144134277,
68
- 1013904242,
69
- 2773480762,
70
- 1359893119,
71
- 2600822924,
72
- 528734635,
73
- 1541459225
74
- ]);
1
+ import { contracts as o } from "./index94.js";
2
+ import { formatters as r } from "./index95.js";
3
+ import { serializers as t } from "./index96.js";
4
+ const e = {
5
+ blockTime: 2e3,
6
+ contracts: o,
7
+ formatters: r,
8
+ serializers: t
9
+ };
75
10
  export {
76
- U as Chi,
77
- m as HashMD,
78
- _ as Maj,
79
- B as SHA256_IV,
80
- y as setBigUint64
11
+ e as chainConfig
81
12
  };
@@ -1,4 +1,4 @@
1
- import { encoder as t, decoder as o } from "./index81.js";
1
+ import { encoder as t, decoder as o } from "./index82.js";
2
2
  import { encodeBase64 as c, decodeBase64 as a } from "./index97.js";
3
3
  function i(r) {
4
4
  if (Uint8Array.fromBase64)
@@ -16,6 +16,12 @@ export declare type AccountsRequest = {
16
16
 
17
17
  export declare type AllowedEvmTransactionType = TransactionSerializableEIP1559;
18
18
 
19
+ export declare type AuthenticationMethod = EmailAuthentication;
20
+
21
+ export declare type AuthenticationMethods = {
22
+ email?: EmailAuthentication;
23
+ };
24
+
19
25
  export declare type CDPEmbeddedWallet = {
20
26
  provider: EIP1193Provider;
21
27
  };
@@ -73,6 +79,11 @@ export declare interface EIP712Types {
73
79
  [key: string]: unknown;
74
80
  }
75
81
 
82
+ export declare type EmailAuthentication = {
83
+ type: "email";
84
+ email: string;
85
+ };
86
+
76
87
  export declare type EthSignRequest = {
77
88
  method: "eth_sign";
78
89
  params: [Hex, EvmAddress];
@@ -267,7 +278,8 @@ export declare type UnknownRequest = {
267
278
 
268
279
  export declare type User = {
269
280
  userId: string;
270
- evmAccounts: EvmAddress[];
281
+ authenticationMethods: AuthenticationMethods;
282
+ evmAccounts?: EvmAddress[];
271
283
  };
272
284
 
273
285
  export declare const verifyEmailOTP: (options: VerifyEmailOTPOptions) => Promise<VerifyEmailOTPResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-core",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
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.12"
20
+ "@coinbase/cdp-api-client": "^0.0.14"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@size-limit/preset-big-lib": "^11.2.0",