@coinbase/cdp-hooks 0.0.60 → 0.0.61

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
@@ -585,6 +585,85 @@ function LinkOAuthProvider() {
585
585
  }
586
586
  ```
587
587
 
588
+ ### Sign In with Custom Authentication
589
+
590
+ If you're using a third-party identity provider (Auth0, Firebase, AWS Cognito, or any OIDC-compliant provider), you can authenticate users with JWTs from your provider using the `useAuthenticateWithJWT` hook.
591
+
592
+ #### Prerequisites
593
+
594
+ Before using custom authentication:
595
+
596
+ 1. **Configure your identity provider in the CDP Portal**:
597
+ - Navigate to [Embedded Wallet Configuration](https://portal.cdp.coinbase.com/products/embedded-wallets)
598
+ - Click on the Custom auth tab
599
+ - Add your JWKS endpoint URL (e.g., `https://your-domain.auth0.com/.well-known/jwks.json`)
600
+ - Configure your JWT issuer and audience
601
+
602
+ 2. **Provide a `customAuth.getJwt` callback** in your provider configuration:
603
+
604
+ ```tsx lines
605
+ import { CDPHooksProvider } from "@coinbase/cdp-hooks";
606
+
607
+ function App() {
608
+ return (
609
+ <CDPHooksProvider
610
+ config={{
611
+ projectId: "your-project-id",
612
+ customAuth: {
613
+ // This callback should return a fresh JWT from your identity provider
614
+ getJwt: async () => {
615
+ // Return a JWT from your IDP (Auth0, Firebase, Cognito, etc.)
616
+ // This will be called automatically when the SDK needs a fresh token
617
+ const token = await yourAuthProvider.getAccessToken();
618
+ return token;
619
+ }
620
+ },
621
+ ethereum: {
622
+ createOnLogin: "eoa" // Optional: configure wallet creation
623
+ }
624
+ }}
625
+ >
626
+ <YourApp />
627
+ </CDPHooksProvider>
628
+ );
629
+ }
630
+ ```
631
+
632
+ #### Authenticate a User
633
+
634
+ ```tsx lines
635
+ import { useAuthenticateWithJWT, useCurrentUser } from "@coinbase/cdp-hooks";
636
+
637
+ function CustomAuthSignIn() {
638
+ const { authenticateWithJWT } = useAuthenticateWithJWT();
639
+ const { currentUser } = useCurrentUser();
640
+
641
+ const handleSignIn = async () => {
642
+ try {
643
+ // After your user has signed in to your IDP (Auth0, Firebase, etc.)
644
+ const result = await authenticateWithJWT();
645
+
646
+ console.log("User authenticated:", result.user);
647
+ console.log("Is new user:", result.isNewUser);
648
+
649
+ // The user is now signed in and wallets are created based on your config
650
+ if (result.user.evmAccounts?.[0]) {
651
+ console.log("EVM Address:", result.user.evmAccounts[0]);
652
+ }
653
+ } catch (error) {
654
+ console.error("Authentication failed:", error);
655
+ }
656
+ };
657
+
658
+ return (
659
+ <div>
660
+ <button onClick={handleSignIn}>Sign In with Custom Auth</button>
661
+ {currentUser && <p>Signed in as: {currentUser.userId}</p>}
662
+ </div>
663
+ );
664
+ }
665
+ ```
666
+
588
667
  ### View User Information
589
668
 
590
669
  Once the end user has signed in, you can display their information in your application:
package/dist/esm/index.js CHANGED
@@ -3,55 +3,56 @@ import { Analytics as e } from "./index2.js";
3
3
  import "react";
4
4
  import { VERSION as s } from "./index3.js";
5
5
  import { CDPContext as S, CDPHooksProvider as p } from "./index4.js";
6
- import { useConfig as d, useCurrentUser as g, useEnforceAuthenticated as c, useEnforceUnauthenticated as E, useEvmAddress as x, useExportEvmAccount as A, useExportSolanaAccount as l, useGetAccessToken as h, useIsInitialized as P, useIsSignedIn as k, useOAuthState as v, useSendEvmTransaction as O, useSendSolanaTransaction as I, useSendUserOperation as T, useSignEvmHash as C, useSignEvmMessage as L, useSignEvmTransaction as y, useSignEvmTypedData as U, useSignInWithEmail as V, useSignInWithOAuth as W, useSignInWithSms as D, useSignOut as G, useSignSolanaMessage as H, useSignSolanaTransaction as M, useSolanaAddress as R, useVerifyEmailOTP as z, useVerifySmsOTP as F, useWaitForUserOperation as N } from "./index5.js";
6
+ import { useAuthenticateWithJWT as c, useConfig as d, useCurrentUser as g, useEnforceAuthenticated as E, useEnforceUnauthenticated as x, useEvmAddress as A, useExportEvmAccount as h, useExportSolanaAccount as l, useGetAccessToken as P, useIsInitialized as k, useIsSignedIn as v, useOAuthState as O, useSendEvmTransaction as T, useSendSolanaTransaction as I, useSendUserOperation as C, useSignEvmHash as L, useSignEvmMessage as W, useSignEvmTransaction as y, useSignEvmTypedData as U, useSignInWithEmail as V, useSignInWithOAuth as D, useSignInWithSms as G, useSignOut as H, useSignSolanaMessage as M, useSignSolanaTransaction as R, useSolanaAddress as z, useVerifyEmailOTP as F, useVerifySmsOTP as J, useWaitForUserOperation as N } from "./index5.js";
7
7
  import { useCreateSpendPermission as j } from "./index6.js";
8
8
  import { useListSpendPermissions as w } from "./index7.js";
9
- import { useRevokeSpendPermission as J } from "./index8.js";
10
- import { useLinkGoogle as Q } from "./index9.js";
11
- import { useLinkApple as Y } from "./index10.js";
12
- import { useLinkSms as _ } from "./index11.js";
13
- import { useLinkEmail as ee } from "./index12.js";
14
- import { useLinkOAuth as oe } from "./index13.js";
9
+ import { useRevokeSpendPermission as K } from "./index8.js";
10
+ import { useLinkGoogle as X } from "./index9.js";
11
+ import { useLinkApple as Z } from "./index10.js";
12
+ import { useLinkSms as $ } from "./index11.js";
13
+ import { useLinkEmail as se } from "./index12.js";
14
+ import { useLinkOAuth as re } from "./index13.js";
15
15
  e.registerPackageVersion("hooks", s);
16
16
  export {
17
17
  u as APIError,
18
18
  S as CDPContext,
19
19
  p as CDPHooksProvider,
20
20
  a as OAuth2ProviderType,
21
+ c as useAuthenticateWithJWT,
21
22
  d as useConfig,
22
23
  j as useCreateSpendPermission,
23
24
  g as useCurrentUser,
24
- c as useEnforceAuthenticated,
25
- E as useEnforceUnauthenticated,
26
- x as useEvmAddress,
27
- A as useExportEvmAccount,
25
+ E as useEnforceAuthenticated,
26
+ x as useEnforceUnauthenticated,
27
+ A as useEvmAddress,
28
+ h as useExportEvmAccount,
28
29
  l as useExportSolanaAccount,
29
- h as useGetAccessToken,
30
- P as useIsInitialized,
31
- k as useIsSignedIn,
32
- Y as useLinkApple,
33
- ee as useLinkEmail,
34
- Q as useLinkGoogle,
35
- oe as useLinkOAuth,
36
- _ as useLinkSms,
30
+ P as useGetAccessToken,
31
+ k as useIsInitialized,
32
+ v as useIsSignedIn,
33
+ Z as useLinkApple,
34
+ se as useLinkEmail,
35
+ X as useLinkGoogle,
36
+ re as useLinkOAuth,
37
+ $ as useLinkSms,
37
38
  w as useListSpendPermissions,
38
- v as useOAuthState,
39
- J as useRevokeSpendPermission,
40
- O as useSendEvmTransaction,
39
+ O as useOAuthState,
40
+ K as useRevokeSpendPermission,
41
+ T as useSendEvmTransaction,
41
42
  I as useSendSolanaTransaction,
42
- T as useSendUserOperation,
43
- C as useSignEvmHash,
44
- L as useSignEvmMessage,
43
+ C as useSendUserOperation,
44
+ L as useSignEvmHash,
45
+ W as useSignEvmMessage,
45
46
  y as useSignEvmTransaction,
46
47
  U as useSignEvmTypedData,
47
48
  V as useSignInWithEmail,
48
- W as useSignInWithOAuth,
49
- D as useSignInWithSms,
50
- G as useSignOut,
51
- H as useSignSolanaMessage,
52
- M as useSignSolanaTransaction,
53
- R as useSolanaAddress,
54
- z as useVerifyEmailOTP,
55
- F as useVerifySmsOTP,
49
+ D as useSignInWithOAuth,
50
+ G as useSignInWithSms,
51
+ H as useSignOut,
52
+ M as useSignSolanaMessage,
53
+ R as useSignSolanaTransaction,
54
+ z as useSolanaAddress,
55
+ F as useVerifyEmailOTP,
56
+ J as useVerifySmsOTP,
56
57
  N as useWaitForUserOperation
57
58
  };
@@ -1,7 +1,6 @@
1
1
  import { sha256 as v } from "./index251.js";
2
2
  import { createCurve as G } from "./index252.js";
3
3
  import { Field as P, mod as h, pow2 as t } from "./index253.js";
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
4
  const B = {
6
5
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
7
6
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
@@ -1,9 +1,3 @@
1
- /*!
2
- * Determine if an object is a Buffer
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */
7
1
  var f, e;
8
2
  function t() {
9
3
  if (e) return f;
@@ -1,5 +1,5 @@
1
1
  import { stringToBytes as i } from "./index122.js";
2
- import { encodeLabelhash as h } from "./index264.js";
2
+ import { encodeLabelhash as h } from "./index265.js";
3
3
  import { labelhash as f } from "./index121.js";
4
4
  function y(s) {
5
5
  const o = s.replace(/^\.|\.$/gm, "");
@@ -1,4 +1,4 @@
1
- import { parseAvatarUri as o, parseNftUri as f, getNftTokenUri as v, resolveAvatarUri as l, getJsonImage as A, getMetadataAvatarUri as N } from "./index265.js";
1
+ import { parseAvatarUri as o, parseNftUri as f, getNftTokenUri as v, resolveAvatarUri as l, getJsonImage as A, getMetadataAvatarUri as N } from "./index264.js";
2
2
  async function b(r, { gatewayUrls: t, record: e }) {
3
3
  return /eip155:/i.test(e) ? U(r, { gatewayUrls: t, record: e }) : o({ uri: e, gatewayUrls: t });
4
4
  }
@@ -1,5 +1,4 @@
1
1
  import { weierstrass as s } from "./index273.js";
2
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
2
  function c(e, t) {
4
3
  const r = (o) => s({ ...e, hash: o });
5
4
  return { ...r(t), create: r };
@@ -1,6 +1,5 @@
1
1
  import { numberToBytesLE as y, numberToBytesBE as I, bitMask as Z, bytesToNumberLE as S, bytesToNumberBE as _, _validateObject as j } from "./index274.js";
2
2
  import { anumber as z } from "./index258.js";
3
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
3
  const g = BigInt(0), d = BigInt(1), q = /* @__PURE__ */ BigInt(2), V = /* @__PURE__ */ BigInt(3), x = /* @__PURE__ */ BigInt(4), T = /* @__PURE__ */ BigInt(5), L = /* @__PURE__ */ BigInt(8);
5
4
  function h(t, n) {
6
5
  const o = t % n;
@@ -1,5 +1,4 @@
1
1
  import { crypto as u } from "./index272.js";
2
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
2
  function w(t) {
4
3
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
5
4
  }
@@ -1,6 +1,139 @@
1
- function n(e) {
2
- return `[${e.slice(2)}]`;
1
+ import { readContract as w } from "./index69.js";
2
+ import { EnsAvatarUriResolutionError as d, EnsAvatarInvalidNftUriError as p, EnsAvatarUnsupportedNamespaceError as I, EnsAvatarInvalidMetadataError as y } from "./index113.js";
3
+ const v = /(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/, A = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/, b = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/, E = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
4
+ async function k(e) {
5
+ try {
6
+ const t = await fetch(e, { method: "HEAD" });
7
+ return t.status === 200 ? t.headers.get("content-type")?.startsWith("image/") : !1;
8
+ } catch (t) {
9
+ return typeof t == "object" && typeof t.response < "u" || !globalThis.hasOwnProperty("Image") ? !1 : new Promise((n) => {
10
+ const a = new Image();
11
+ a.onload = () => {
12
+ n(!0);
13
+ }, a.onerror = () => {
14
+ n(!1);
15
+ }, a.src = e;
16
+ });
17
+ }
18
+ }
19
+ function l(e, t) {
20
+ return e ? e.endsWith("/") ? e.slice(0, -1) : e : t;
21
+ }
22
+ function C({ uri: e, gatewayUrls: t }) {
23
+ const n = b.test(e);
24
+ if (n)
25
+ return { uri: e, isOnChain: !0, isEncoded: n };
26
+ const a = l(t?.ipfs, "https://ipfs.io"), r = l(t?.arweave, "https://arweave.net"), f = e.match(v), { protocol: i, subpath: c, target: s, subtarget: h = "" } = f?.groups || {}, u = i === "ipns:/" || c === "ipns/", m = i === "ipfs:/" || c === "ipfs/" || A.test(e);
27
+ if (e.startsWith("http") && !u && !m) {
28
+ let g = e;
29
+ return t?.arweave && (g = e.replace(/https:\/\/arweave.net/g, t?.arweave)), { uri: g, isOnChain: !1, isEncoded: !1 };
30
+ }
31
+ if ((u || m) && s)
32
+ return {
33
+ uri: `${a}/${u ? "ipns" : "ipfs"}/${s}${h}`,
34
+ isOnChain: !1,
35
+ isEncoded: !1
36
+ };
37
+ if (i === "ar:/" && s)
38
+ return {
39
+ uri: `${r}/${s}${h || ""}`,
40
+ isOnChain: !1,
41
+ isEncoded: !1
42
+ };
43
+ let o = e.replace(E, "");
44
+ if (o.startsWith("<svg") && (o = `data:image/svg+xml;base64,${btoa(o)}`), o.startsWith("data:") || o.startsWith("{"))
45
+ return {
46
+ uri: o,
47
+ isOnChain: !0,
48
+ isEncoded: !1
49
+ };
50
+ throw new d({ uri: e });
51
+ }
52
+ function U(e) {
53
+ if (typeof e != "object" || !("image" in e) && !("image_url" in e) && !("image_data" in e))
54
+ throw new y({ data: e });
55
+ return e.image || e.image_url || e.image_data;
56
+ }
57
+ async function $({ gatewayUrls: e, uri: t }) {
58
+ try {
59
+ const n = await fetch(t).then((r) => r.json());
60
+ return await R({
61
+ gatewayUrls: e,
62
+ uri: U(n)
63
+ });
64
+ } catch {
65
+ throw new d({ uri: t });
66
+ }
67
+ }
68
+ async function R({ gatewayUrls: e, uri: t }) {
69
+ const { uri: n, isOnChain: a } = C({ uri: t, gatewayUrls: e });
70
+ if (a || await k(n))
71
+ return n;
72
+ throw new d({ uri: t });
73
+ }
74
+ function D(e) {
75
+ let t = e;
76
+ t.startsWith("did:nft:") && (t = t.replace("did:nft:", "").replace(/_/g, "/"));
77
+ const [n, a, r] = t.split("/"), [f, i] = n.split(":"), [c, s] = a.split(":");
78
+ if (!f || f.toLowerCase() !== "eip155")
79
+ throw new p({ reason: "Only EIP-155 supported" });
80
+ if (!i)
81
+ throw new p({ reason: "Chain ID not found" });
82
+ if (!s)
83
+ throw new p({
84
+ reason: "Contract address not found"
85
+ });
86
+ if (!r)
87
+ throw new p({ reason: "Token ID not found" });
88
+ if (!c)
89
+ throw new p({ reason: "ERC namespace not found" });
90
+ return {
91
+ chainID: Number.parseInt(i),
92
+ namespace: c.toLowerCase(),
93
+ contractAddress: s,
94
+ tokenID: r
95
+ };
96
+ }
97
+ async function O(e, { nft: t }) {
98
+ if (t.namespace === "erc721")
99
+ return w(e, {
100
+ address: t.contractAddress,
101
+ abi: [
102
+ {
103
+ name: "tokenURI",
104
+ type: "function",
105
+ stateMutability: "view",
106
+ inputs: [{ name: "tokenId", type: "uint256" }],
107
+ outputs: [{ name: "", type: "string" }]
108
+ }
109
+ ],
110
+ functionName: "tokenURI",
111
+ args: [BigInt(t.tokenID)]
112
+ });
113
+ if (t.namespace === "erc1155")
114
+ return w(e, {
115
+ address: t.contractAddress,
116
+ abi: [
117
+ {
118
+ name: "uri",
119
+ type: "function",
120
+ stateMutability: "view",
121
+ inputs: [{ name: "_id", type: "uint256" }],
122
+ outputs: [{ name: "", type: "string" }]
123
+ }
124
+ ],
125
+ functionName: "uri",
126
+ args: [BigInt(t.tokenID)]
127
+ });
128
+ throw new I({ namespace: t.namespace });
3
129
  }
4
130
  export {
5
- n as encodeLabelhash
131
+ l as getGateway,
132
+ U as getJsonImage,
133
+ $ as getMetadataAvatarUri,
134
+ O as getNftTokenUri,
135
+ k as isImageUri,
136
+ R as parseAvatarUri,
137
+ D as parseNftUri,
138
+ C as resolveAvatarUri
6
139
  };
@@ -1,139 +1,6 @@
1
- import { readContract as w } from "./index69.js";
2
- import { EnsAvatarUriResolutionError as d, EnsAvatarInvalidNftUriError as p, EnsAvatarUnsupportedNamespaceError as I, EnsAvatarInvalidMetadataError as y } from "./index113.js";
3
- const v = /(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/, A = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/, b = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/, E = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
4
- async function k(e) {
5
- try {
6
- const t = await fetch(e, { method: "HEAD" });
7
- return t.status === 200 ? t.headers.get("content-type")?.startsWith("image/") : !1;
8
- } catch (t) {
9
- return typeof t == "object" && typeof t.response < "u" || !globalThis.hasOwnProperty("Image") ? !1 : new Promise((n) => {
10
- const a = new Image();
11
- a.onload = () => {
12
- n(!0);
13
- }, a.onerror = () => {
14
- n(!1);
15
- }, a.src = e;
16
- });
17
- }
18
- }
19
- function l(e, t) {
20
- return e ? e.endsWith("/") ? e.slice(0, -1) : e : t;
21
- }
22
- function C({ uri: e, gatewayUrls: t }) {
23
- const n = b.test(e);
24
- if (n)
25
- return { uri: e, isOnChain: !0, isEncoded: n };
26
- const a = l(t?.ipfs, "https://ipfs.io"), r = l(t?.arweave, "https://arweave.net"), f = e.match(v), { protocol: i, subpath: c, target: s, subtarget: h = "" } = f?.groups || {}, u = i === "ipns:/" || c === "ipns/", m = i === "ipfs:/" || c === "ipfs/" || A.test(e);
27
- if (e.startsWith("http") && !u && !m) {
28
- let g = e;
29
- return t?.arweave && (g = e.replace(/https:\/\/arweave.net/g, t?.arweave)), { uri: g, isOnChain: !1, isEncoded: !1 };
30
- }
31
- if ((u || m) && s)
32
- return {
33
- uri: `${a}/${u ? "ipns" : "ipfs"}/${s}${h}`,
34
- isOnChain: !1,
35
- isEncoded: !1
36
- };
37
- if (i === "ar:/" && s)
38
- return {
39
- uri: `${r}/${s}${h || ""}`,
40
- isOnChain: !1,
41
- isEncoded: !1
42
- };
43
- let o = e.replace(E, "");
44
- if (o.startsWith("<svg") && (o = `data:image/svg+xml;base64,${btoa(o)}`), o.startsWith("data:") || o.startsWith("{"))
45
- return {
46
- uri: o,
47
- isOnChain: !0,
48
- isEncoded: !1
49
- };
50
- throw new d({ uri: e });
51
- }
52
- function U(e) {
53
- if (typeof e != "object" || !("image" in e) && !("image_url" in e) && !("image_data" in e))
54
- throw new y({ data: e });
55
- return e.image || e.image_url || e.image_data;
56
- }
57
- async function $({ gatewayUrls: e, uri: t }) {
58
- try {
59
- const n = await fetch(t).then((r) => r.json());
60
- return await R({
61
- gatewayUrls: e,
62
- uri: U(n)
63
- });
64
- } catch {
65
- throw new d({ uri: t });
66
- }
67
- }
68
- async function R({ gatewayUrls: e, uri: t }) {
69
- const { uri: n, isOnChain: a } = C({ uri: t, gatewayUrls: e });
70
- if (a || await k(n))
71
- return n;
72
- throw new d({ uri: t });
73
- }
74
- function D(e) {
75
- let t = e;
76
- t.startsWith("did:nft:") && (t = t.replace("did:nft:", "").replace(/_/g, "/"));
77
- const [n, a, r] = t.split("/"), [f, i] = n.split(":"), [c, s] = a.split(":");
78
- if (!f || f.toLowerCase() !== "eip155")
79
- throw new p({ reason: "Only EIP-155 supported" });
80
- if (!i)
81
- throw new p({ reason: "Chain ID not found" });
82
- if (!s)
83
- throw new p({
84
- reason: "Contract address not found"
85
- });
86
- if (!r)
87
- throw new p({ reason: "Token ID not found" });
88
- if (!c)
89
- throw new p({ reason: "ERC namespace not found" });
90
- return {
91
- chainID: Number.parseInt(i),
92
- namespace: c.toLowerCase(),
93
- contractAddress: s,
94
- tokenID: r
95
- };
96
- }
97
- async function O(e, { nft: t }) {
98
- if (t.namespace === "erc721")
99
- return w(e, {
100
- address: t.contractAddress,
101
- abi: [
102
- {
103
- name: "tokenURI",
104
- type: "function",
105
- stateMutability: "view",
106
- inputs: [{ name: "tokenId", type: "uint256" }],
107
- outputs: [{ name: "", type: "string" }]
108
- }
109
- ],
110
- functionName: "tokenURI",
111
- args: [BigInt(t.tokenID)]
112
- });
113
- if (t.namespace === "erc1155")
114
- return w(e, {
115
- address: t.contractAddress,
116
- abi: [
117
- {
118
- name: "uri",
119
- type: "function",
120
- stateMutability: "view",
121
- inputs: [{ name: "_id", type: "uint256" }],
122
- outputs: [{ name: "", type: "string" }]
123
- }
124
- ],
125
- functionName: "uri",
126
- args: [BigInt(t.tokenID)]
127
- });
128
- throw new I({ namespace: t.namespace });
1
+ function n(e) {
2
+ return `[${e.slice(2)}]`;
129
3
  }
130
4
  export {
131
- l as getGateway,
132
- U as getJsonImage,
133
- $ as getMetadataAvatarUri,
134
- O as getNftTokenUri,
135
- k as isImageUri,
136
- R as parseAvatarUri,
137
- D as parseNftUri,
138
- C as resolveAvatarUri
5
+ n as encodeLabelhash
139
6
  };
@@ -3,7 +3,6 @@ import { _validateObject as at, bitMask as ft, abool as Q, ensureBytes as z, mem
3
3
  import { _createCurveFields as wt, wNAF as yt, normalizeZ as pt, pippenger as gt, mulEndoUnsafe as Et, negateCt as ot } from "./index276.js";
4
4
  import { Field as bt, mapHashToField as vt, getMinHashLength as Bt } from "./index253.js";
5
5
  import { concatBytes as I, abytes as it, bytesToHex as rt, hexToBytes as xt, randomBytes as St, isBytes as Rt } from "./index258.js";
6
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7
6
  function st(e) {
8
7
  e.lowS !== void 0 && Q("lowS", e.lowS), e.prehash !== void 0 && Q("prehash", e.prehash);
9
8
  }
@@ -1,6 +1,5 @@
1
1
  import { hexToBytes as p, isBytes as B, abytes as v, bytesToHex as d, concatBytes as U } from "./index258.js";
2
2
  import { anumber as W, randomBytes as C, utf8ToBytes as G } from "./index258.js";
3
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
3
  const y = /* @__PURE__ */ BigInt(0), g = /* @__PURE__ */ BigInt(1);
5
4
  function k(t, r) {
6
5
  if (typeof r != "boolean")
@@ -1,6 +1,5 @@
1
1
  import { bitLen as B, bitMask as z } from "./index274.js";
2
2
  import { validateField as Z, Field as O, FpInvertBatch as R } from "./index253.js";
3
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
3
  const g = BigInt(0), h = BigInt(1);
5
4
  function b(t, r) {
6
5
  const e = r.negate();
@@ -1,4 +1,4 @@
1
- const o = "0.0.59";
1
+ const o = "0.0.61";
2
2
  export {
3
3
  o as VERSION
4
4
  };
@@ -1,62 +1,62 @@
1
- import { verifyEmailOTP as A, verifySmsOTP as y, signInWithOAuth as I, getAccessToken as U, sendUserOperation as O, signInWithEmail as x, signInWithSms as k, signOut as W, signEvmHash as C, signEvmTransaction as M, sendEvmTransaction as H, signEvmMessage as P, signSolanaMessage as b, signEvmTypedData as D, exportEvmAccount as F, exportSolanaAccount as z, signSolanaTransaction as V, sendSolanaTransaction as G, getUserOperation as j } from "@coinbase/cdp-core";
1
+ import { verifyEmailOTP as A, verifySmsOTP as y, authenticateWithJWT as I, signInWithOAuth as U, getAccessToken as O, sendUserOperation as W, signInWithEmail as x, signInWithSms as k, signOut as C, signEvmHash as M, signEvmTransaction as H, sendEvmTransaction as P, signEvmMessage as b, signSolanaMessage as D, signEvmTypedData as F, exportEvmAccount as z, exportSolanaAccount as J, signSolanaTransaction as V, sendSolanaTransaction as j, getUserOperation as G } from "@coinbase/cdp-core";
2
2
  import "./index2.js";
3
3
  import { useSendHookCallOnce as e } from "./index14.js";
4
- import { useState as d, useEffect as h, useMemo as q, useCallback as v } from "react";
4
+ import { useState as d, useEffect as E, useMemo as q, useCallback as v } from "react";
5
5
  import { useCDP as p } from "./index4.js";
6
6
  import { useAutoPolling as B } from "./index15.js";
7
- import { getPublicClient as J } from "./index16.js";
8
- const nn = () => {
7
+ import { getPublicClient as K } from "./index16.js";
8
+ const en = () => {
9
9
  e("use_config");
10
10
  const { config: n } = p();
11
11
  return { config: n };
12
- }, en = () => {
12
+ }, sn = () => {
13
13
  e("use_is_initialized");
14
14
  const { isInitialized: n } = p();
15
15
  return { isInitialized: n };
16
- }, sn = () => (e("use_sign_in_with_email"), { signInWithEmail: f(x) }), tn = () => (e("use_sign_in_with_sms"), { signInWithSms: f(k) }), rn = () => (e("use_verify_email_otp"), { verifyEmailOTP: A }), an = () => (e("use_verify_sms_otp"), { verifySmsOTP: y }), on = () => {
16
+ }, tn = () => (e("use_sign_in_with_email"), { signInWithEmail: f(x) }), rn = () => (e("use_sign_in_with_sms"), { signInWithSms: f(k) }), an = () => (e("use_verify_email_otp"), { verifyEmailOTP: A }), on = () => (e("use_verify_sms_otp"), { verifySmsOTP: y }), cn = () => (e("use_authenticate_with_jwt"), { authenticateWithJWT: I }), un = () => {
17
17
  e("use_sign_in_with_oauth");
18
- const { oauthState: n } = K();
19
- return { signInWithOAuth: I, oauthState: n };
20
- }, K = () => {
18
+ const { oauthState: n } = L();
19
+ return { signInWithOAuth: U, oauthState: n };
20
+ }, L = () => {
21
21
  e("use_oauth_state");
22
22
  const { oauthState: n } = p();
23
23
  return { oauthState: n };
24
- }, cn = () => {
24
+ }, pn = () => {
25
25
  e("use_is_signed_in");
26
26
  const { isSignedIn: n } = p();
27
27
  return { isSignedIn: n };
28
- }, E = () => {
28
+ }, h = () => {
29
29
  e("use_current_user");
30
30
  const { currentUser: n } = p();
31
31
  return { currentUser: n };
32
- }, un = () => (e("use_sign_out"), { signOut: c(W) }), pn = () => (e("use_get_access_token"), { getAccessToken: U }), dn = () => {
32
+ }, dn = () => (e("use_sign_out"), { signOut: c(C) }), gn = () => (e("use_get_access_token"), { getAccessToken: O }), ln = () => {
33
33
  e("use_evm_address");
34
- const { currentUser: n } = E();
34
+ const { currentUser: n } = h();
35
35
  return {
36
36
  evmAddress: n?.evmSmartAccounts?.[0] ?? n?.evmAccounts?.[0] ?? null
37
37
  };
38
- }, gn = () => {
38
+ }, mn = () => {
39
39
  e("use_solana_address");
40
- const { currentUser: n } = E();
40
+ const { currentUser: n } = h();
41
41
  return {
42
42
  solanaAddress: n?.solanaAccounts?.[0] ?? null
43
43
  };
44
- }, ln = () => (e("use_sign_evm_hash"), { signEvmHash: c(C) }), mn = () => (e("use_sign_evm_transaction"), { signEvmTransaction: c(M) }), Sn = () => {
44
+ }, _n = () => (e("use_sign_evm_hash"), { signEvmHash: c(M) }), Sn = () => (e("use_sign_evm_transaction"), { signEvmTransaction: c(H) }), hn = () => {
45
45
  e("use_send_evm_transaction");
46
46
  const [n, s] = d(null), [a, r] = d(null), [u, m] = d(null), { config: o } = p(), g = c(
47
- async (S) => {
48
- const i = await H(S);
49
- return s({ hash: i.transactionHash, network: S.network }), m(null), r(null), i;
47
+ async (_) => {
48
+ const i = await P(_);
49
+ return s({ hash: i.transactionHash, network: _.network }), m(null), r(null), i;
50
50
  }
51
51
  );
52
- h(() => {
52
+ E(() => {
53
53
  if (!n) return;
54
54
  (async () => {
55
55
  try {
56
- const _ = await J(n.network, o).waitForTransactionReceipt({
56
+ const S = await K(n.network, o).waitForTransactionReceipt({
57
57
  hash: n.hash
58
58
  });
59
- r(_);
59
+ r(S);
60
60
  } catch (i) {
61
61
  m(i instanceof Error ? i : new Error(String(i)));
62
62
  }
@@ -67,8 +67,8 @@ const nn = () => {
67
67
  sendEvmTransaction: g,
68
68
  data: l
69
69
  };
70
- }, _n = () => (e("use_sign_evm_message"), { signEvmMessage: c(P) }), En = () => (e("use_sign_solana_message"), { signSolanaMessage: c(b) }), wn = () => (e("use_sign_evm_typed_data"), { signEvmTypedData: c(D) }), hn = () => (e("use_export_evm_account"), { exportEvmAccount: c(F) }), vn = () => (e("use_export_solana_account"), { exportSolanaAccount: c(z) }), fn = () => (e("use_sign_solana_transaction"), { signSolanaTransaction: c(V) }), Tn = () => (e("use_send_solana_transaction"), {
71
- sendSolanaTransaction: c(G)
70
+ }, wn = () => (e("use_sign_evm_message"), { signEvmMessage: c(b) }), En = () => (e("use_sign_solana_message"), { signSolanaMessage: c(D) }), vn = () => (e("use_sign_evm_typed_data"), { signEvmTypedData: c(F) }), fn = () => (e("use_export_evm_account"), { exportEvmAccount: c(z) }), Tn = () => (e("use_export_solana_account"), { exportSolanaAccount: c(J) }), An = () => (e("use_sign_solana_transaction"), { signSolanaTransaction: c(V) }), yn = () => (e("use_send_solana_transaction"), {
71
+ sendSolanaTransaction: c(j)
72
72
  }), c = (n) => {
73
73
  const { isSignedIn: s } = p();
74
74
  return v(
@@ -89,13 +89,13 @@ const nn = () => {
89
89
  },
90
90
  [s, n]
91
91
  );
92
- }, An = () => {
92
+ }, In = () => {
93
93
  e("use_send_user_operation");
94
- const [n, s] = d(void 0), { status: a, data: r, error: u } = L(n);
94
+ const [n, s] = d(void 0), { status: a, data: r, error: u } = N(n);
95
95
  return {
96
96
  sendUserOperation: c(
97
97
  async (o) => {
98
- const g = await O(o);
98
+ const g = await W(o);
99
99
  return s({
100
100
  userOperationHash: g.userOperationHash,
101
101
  evmSmartAccount: o.evmSmartAccount,
@@ -107,17 +107,17 @@ const nn = () => {
107
107
  error: u,
108
108
  status: a
109
109
  };
110
- }, L = (n = {}) => {
110
+ }, N = (n = {}) => {
111
111
  e("use_wait_for_user_operation");
112
- const { userOperationHash: s, evmSmartAccount: a, network: r, enabled: u } = n, [m, o] = d("idle"), [g, l] = d(void 0), [S, i] = d(void 0), { currentUser: _ } = E();
113
- h(() => {
112
+ const { userOperationHash: s, evmSmartAccount: a, network: r, enabled: u } = n, [m, o] = d("idle"), [g, l] = d(void 0), [_, i] = d(void 0), { currentUser: S } = h();
113
+ E(() => {
114
114
  s && a && r && (o(u !== !1 ? "pending" : "idle"), l(void 0), i(void 0));
115
115
  }, [s, a, r, u]);
116
- const w = u !== !1 && !!(s && a && r && _);
116
+ const w = u !== !1 && !!(s && a && r && S);
117
117
  return B(
118
118
  {
119
119
  pollFn: async () => {
120
- const t = await j({
120
+ const t = await G({
121
121
  userOperationHash: s,
122
122
  evmSmartAccount: a,
123
123
  network: r
@@ -142,36 +142,37 @@ const nn = () => {
142
142
  ), {
143
143
  status: m,
144
144
  data: g,
145
- error: S
145
+ error: _
146
146
  };
147
147
  };
148
148
  export {
149
- nn as useConfig,
150
- E as useCurrentUser,
149
+ cn as useAuthenticateWithJWT,
150
+ en as useConfig,
151
+ h as useCurrentUser,
151
152
  c as useEnforceAuthenticated,
152
153
  f as useEnforceUnauthenticated,
153
- dn as useEvmAddress,
154
- hn as useExportEvmAccount,
155
- vn as useExportSolanaAccount,
156
- pn as useGetAccessToken,
157
- en as useIsInitialized,
158
- cn as useIsSignedIn,
159
- K as useOAuthState,
160
- Sn as useSendEvmTransaction,
161
- Tn as useSendSolanaTransaction,
162
- An as useSendUserOperation,
163
- ln as useSignEvmHash,
164
- _n as useSignEvmMessage,
165
- mn as useSignEvmTransaction,
166
- wn as useSignEvmTypedData,
167
- sn as useSignInWithEmail,
168
- on as useSignInWithOAuth,
169
- tn as useSignInWithSms,
170
- un as useSignOut,
154
+ ln as useEvmAddress,
155
+ fn as useExportEvmAccount,
156
+ Tn as useExportSolanaAccount,
157
+ gn as useGetAccessToken,
158
+ sn as useIsInitialized,
159
+ pn as useIsSignedIn,
160
+ L as useOAuthState,
161
+ hn as useSendEvmTransaction,
162
+ yn as useSendSolanaTransaction,
163
+ In as useSendUserOperation,
164
+ _n as useSignEvmHash,
165
+ wn as useSignEvmMessage,
166
+ Sn as useSignEvmTransaction,
167
+ vn as useSignEvmTypedData,
168
+ tn as useSignInWithEmail,
169
+ un as useSignInWithOAuth,
170
+ rn as useSignInWithSms,
171
+ dn as useSignOut,
171
172
  En as useSignSolanaMessage,
172
- fn as useSignSolanaTransaction,
173
- gn as useSolanaAddress,
174
- rn as useVerifyEmailOTP,
175
- an as useVerifySmsOTP,
176
- L as useWaitForUserOperation
173
+ An as useSignSolanaTransaction,
174
+ mn as useSolanaAddress,
175
+ an as useVerifyEmailOTP,
176
+ on as useVerifySmsOTP,
177
+ N as useWaitForUserOperation
177
178
  };
@@ -1,6 +1,7 @@
1
1
  import { AllowedEvmTransactionType } from '@coinbase/cdp-core';
2
2
  import { APIError } from '@coinbase/cdp-core';
3
3
  import { APIErrorType } from '@coinbase/cdp-core';
4
+ import { AuthenticateWithJWTResult } from '@coinbase/cdp-core';
4
5
  import { base } from 'viem/chains';
5
6
  import { baseSepolia } from 'viem/chains';
6
7
  import { Config as Config_2 } from '@coinbase/cdp-core';
@@ -164,6 +165,10 @@ export declare type TransactionState = {
164
165
  error: Error;
165
166
  };
166
167
 
168
+ export declare const useAuthenticateWithJWT: () => {
169
+ authenticateWithJWT: () => Promise<AuthenticateWithJWTResult>;
170
+ };
171
+
167
172
  export declare const useConfig: () => {
168
173
  config: Config_2;
169
174
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-hooks",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "peerDependencies": {
17
17
  "react": ">=18.2.0",
18
- "@coinbase/cdp-core": "^0.0.60"
18
+ "@coinbase/cdp-core": "^0.0.61"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@testing-library/jest-dom": "^6.6.3",
@@ -30,7 +30,7 @@
30
30
  "@size-limit/webpack": "^11.2.0",
31
31
  "@size-limit/webpack-why": "^11.2.0",
32
32
  "size-limit": "^11.2.0",
33
- "@coinbase/cdp-core": "^0.0.60"
33
+ "@coinbase/cdp-core": "^0.0.61"
34
34
  },
35
35
  "size-limit": [
36
36
  {