@liberfi.io/wallet-connector 0.1.17 → 0.1.18
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -132,6 +132,6 @@ declare global {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
declare const _default: "0.1.
|
|
135
|
+
declare const _default: "0.1.18";
|
|
136
136
|
|
|
137
137
|
export { AuthProvider, type AuthProviderProps, type AuthenticatedUser, type Eip1193Provider, type EvmWalletAdapter, type WalletAdapter, WalletConnectorProvider, type WalletConnectorProviderProps, useAuth, useAuthCallback, useSwitchChain, useWalletConnector, useWallets, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,6 @@ declare global {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
declare const _default: "0.1.
|
|
135
|
+
declare const _default: "0.1.18";
|
|
136
136
|
|
|
137
137
|
export { AuthProvider, type AuthProviderProps, type AuthenticatedUser, type Eip1193Provider, type EvmWalletAdapter, type WalletAdapter, WalletConnectorProvider, type WalletConnectorProviderProps, useAuth, useAuthCallback, useSwitchChain, useWalletConnector, useWallets, _default as version };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var react=require('react'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),jsxRuntime=require('react/jsx-runtime');var n=react.createContext({});function s(){let t=react.useContext(n);if(!t)throw new Error("useAuth must be used within a AuthProvider");return t}function L(t,e){let{status:r,signIn:o}=s(),a=react.useRef(r);return a.current=r,react.useCallback(async(...c)=>{if(a.current!=="authenticated"){a.current==="unauthenticated"&&o();return}return t(...c)},[...e||[],o,t])}var i=react.createContext({});function u(){let t=react.useContext(i);if(!t)throw new Error("useWalletConnector must be used within a WalletConnectorProvider");return t}function l(){let{wallets:t}=u();return t}function K(){let t=l();return react.useCallback(async e=>{if(utils.chainToNamespace(e)===types.ChainNamespace.SOLANA)return;let r=t.filter(o=>"switchChain"in o&&o.isConnected);await Promise.all(r.map(o=>o.switchChain(e)));},[t])}function ot({children:t,...e}){return jsxRuntime.jsx(n.Provider,{value:e,children:t})}function st({children:t,...e}){return jsxRuntime.jsx(i.Provider,{value:e,children:t})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/wallet-connector"]="0.1.
|
|
1
|
+
'use strict';var react=require('react'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),jsxRuntime=require('react/jsx-runtime');var n=react.createContext({});function s(){let t=react.useContext(n);if(!t)throw new Error("useAuth must be used within a AuthProvider");return t}function L(t,e){let{status:r,signIn:o}=s(),a=react.useRef(r);return a.current=r,react.useCallback(async(...c)=>{if(a.current!=="authenticated"){a.current==="unauthenticated"&&o();return}return t(...c)},[...e||[],o,t])}var i=react.createContext({});function u(){let t=react.useContext(i);if(!t)throw new Error("useWalletConnector must be used within a WalletConnectorProvider");return t}function l(){let{wallets:t}=u();return t}function K(){let t=l();return react.useCallback(async e=>{if(utils.chainToNamespace(e)===types.ChainNamespace.SOLANA)return;let r=t.filter(o=>"switchChain"in o&&o.isConnected);await Promise.all(r.map(o=>o.switchChain(e)));},[t])}function ot({children:t,...e}){return jsxRuntime.jsx(n.Provider,{value:e,children:t})}function st({children:t,...e}){return jsxRuntime.jsx(i.Provider,{value:e,children:t})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/wallet-connector"]="0.1.18");var w="0.1.18";exports.AuthProvider=ot;exports.WalletConnectorProvider=st;exports.useAuth=s;exports.useAuthCallback=L;exports.useSwitchChain=K;exports.useWalletConnector=u;exports.useWallets=l;exports.version=w;//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/providers/AuthContext.ts","../src/hooks/useAuth.ts","../src/hooks/useAuthCallback.ts","../src/providers/WalletConnectorContext.ts","../src/hooks/useWalletConnector.ts","../src/hooks/useWallets.ts","../src/hooks/useSwitchChain.ts","../src/providers/AuthProvider.tsx","../src/providers/WalletConnectorProvider.tsx","../src/version.ts"],"names":["AuthContext","createContext","useAuth","context","useContext","useAuthCallback","callback","deps","status","signIn","statusRef","useRef","useCallback","args","WalletConnectorContext","useWalletConnector","useWallets","wallets","useSwitchChain","chain","chainToNamespace","ChainNamespace","evmWallets","w","AuthProvider","children","value","jsx","WalletConnectorProvider","version_default"],"mappings":"sJAgBO,IAAMA,CAAAA,CAAcC,mBAAAA,CACzB,EACF,CAAA,CCfO,SAASC,CAAAA,EAAU,CACxB,IAAMC,CAAAA,CAAUC,gBAAAA,CAAWJ,CAAW,CAAA,CACtC,GAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,4CAA4C,CAAA,CAE9D,OAAOA,CACT,CCLO,SAASE,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACG,CACH,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAQ,MAAA,CAAAC,CAAO,CAAA,CAAIP,CAAAA,EAAQ,CAI7BQ,CAAAA,CAAYC,YAAAA,CAAeH,CAAM,CAAA,CACvC,OAAAE,CAAAA,CAAU,OAAA,CAAUF,CAAAA,CAETI,kBACT,MAAA,GAAUC,CAAAA,GAA4D,CACpE,GAAIH,CAAAA,CAAU,OAAA,GAAY,eAAA,CAAiB,CAIrCA,CAAAA,CAAU,OAAA,GAAY,iBAAA,EACxBD,CAAAA,EAAO,CAET,MACF,CACA,OAAOH,CAAAA,CAAS,GAAGO,CAAI,CACzB,CAAA,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CAAgC,KAAA,CAAOY,CAAAA,CACrC,QAAA,CAAAD,CAAAA,CACH,CAEJ,CCXI,OAAO,MAAA,CAAW,GAAA,GACpB,MAAA,CAAO,mBAAA,CAAsB,MAAA,CAAO,mBAAA,EAAuB,EAAC,CAC5D,MAAA,CAAO,mBAAA,CAAoB,8BAA8B,CAAA,CAAI,QAAA,CAAA,KAGxDI,CAAAA,CAAQ","file":"index.js","sourcesContent":["import { createContext } from \"react\";\nimport { AuthenticatedUser } from \"../types\";\n\nexport interface AuthContextValue {\n /** authenticated user profile */\n user: AuthenticatedUser | null;\n /** authentication status */\n status: \"unauthenticated\" | \"authenticating\" | \"authenticated\";\n /** sign in to the IdP */\n signIn: () => void | Promise<void>;\n /** sign out from the IdP */\n signOut: () => void | Promise<void>;\n /** refresh the access token */\n refreshAccessToken: () => void | Promise<void>;\n}\n\nexport const AuthContext = createContext<AuthContextValue>(\n {} as AuthContextValue,\n);\n","import { useContext } from \"react\";\nimport { AuthContext } from \"../providers/AuthContext\";\n\nexport function useAuth() {\n const context = useContext(AuthContext);\n if (!context) {\n throw new Error(\"useAuth must be used within a AuthProvider\");\n }\n return context;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DependencyList, useCallback, useRef } from \"react\";\nimport { useAuth } from \"./useAuth\";\n\nexport function useAuthCallback<T extends (...args: any[]) => any>(\n callback: T,\n deps?: DependencyList,\n): T {\n const { status, signIn } = useAuth();\n\n // statusRef will be updated to the latest on each render\n // avoid callback rebuild on status changes\n const statusRef = useRef<string>(status);\n statusRef.current = status;\n\n const cb = useCallback(\n async (...args: Parameters<T>): Promise<ReturnType<T> | undefined> => {\n if (statusRef.current !== \"authenticated\") {\n // Only trigger sign-in when truly unauthenticated.\n // When \"authenticating\" (wallet detecting/connecting), just wait —\n // calling signIn() again may conflict with the in-progress auth flow.\n if (statusRef.current === \"unauthenticated\") {\n signIn();\n }\n return;\n }\n return callback(...args);\n },\n [...(deps || []), signIn, callback],\n );\n\n return cb as T;\n}\n","import { createContext } from \"react\";\nimport { WalletAdapter } from \"../types\";\n\nexport interface WalletConnectorContextValue {\n /**\n * detecting: is detecting connected wallets\n * connecting: is connecting to the first wallet\n * connected: is connected to at least one wallet\n * disconnecting: is disconnecting from the last connected wallet\n * disconnected: is disconnected from all wallets\n */\n status:\n | \"detecting\"\n | \"connecting\"\n | \"connected\"\n | \"disconnecting\"\n | \"disconnected\";\n // all wallets that can be used to take onchain actions when connected\n wallets: Array<WalletAdapter>;\n // if no wallets are connected, connect one or multiple wallets\n connect: () => Promise<void>;\n // disconnect all wallets\n disconnect: () => Promise<void>;\n}\n\nexport const WalletConnectorContext =\n createContext<WalletConnectorContextValue>({} as WalletConnectorContextValue);\n","import { useContext } from \"react\";\nimport { WalletConnectorContext } from \"../providers/WalletConnectorContext\";\n\n/**\n * use wallet connector hook\n * @returns wallet connector\n */\nexport function useWalletConnector() {\n const context = useContext(WalletConnectorContext);\n if (!context) {\n throw new Error(\n \"useWalletConnector must be used within a WalletConnectorProvider\",\n );\n }\n return context;\n}\n","import { useWalletConnector } from \"./useWalletConnector\";\n\n/**\n * use wallets hook\n * @returns all wallets that can be used to take onchain actions\n */\nexport function useWallets() {\n const { wallets } = useWalletConnector();\n return wallets;\n}\n","import { useCallback } from \"react\";\nimport { Chain, ChainNamespace } from \"@liberfi.io/types\";\nimport { chainToNamespace } from \"@liberfi.io/utils\";\nimport { EvmWalletAdapter } from \"../types\";\nimport { useWallets } from \"./useWallets\";\n\n/**\n * Returns a function that switches all connected EVM wallets to the given chain.\n * Solana chains are skipped.\n */\nexport function useSwitchChain() {\n const wallets = useWallets();\n\n return useCallback(\n async (chain: Chain) => {\n if (chainToNamespace(chain) === ChainNamespace.SOLANA) return;\n\n const evmWallets = wallets.filter(\n (w): w is EvmWalletAdapter => \"switchChain\" in w && w.isConnected,\n );\n await Promise.all(evmWallets.map((w) => w.switchChain(chain)));\n },\n [wallets],\n );\n}\n","import { PropsWithChildren } from \"react\";\nimport { AuthContext, AuthContextValue } from \"./AuthContext\";\n\nexport type AuthProviderProps = PropsWithChildren<AuthContextValue>;\n\nexport function AuthProvider({ children, ...value }: AuthProviderProps) {\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n","import { PropsWithChildren } from \"react\";\nimport {\n WalletConnectorContext,\n WalletConnectorContextValue,\n} from \"./WalletConnectorContext\";\n\nexport type WalletConnectorProviderProps =\n PropsWithChildren<WalletConnectorContextValue>;\n\nexport function WalletConnectorProvider({\n children,\n ...value\n}: WalletConnectorProviderProps) {\n return (\n <WalletConnectorContext.Provider value={value}>\n {children}\n </WalletConnectorContext.Provider>\n );\n}\n","declare global {\n interface Window {\n __LIBERFI_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif (typeof window !== \"undefined\") {\n window.__LIBERFI_VERSION__ = window.__LIBERFI_VERSION__ || {};\n window.__LIBERFI_VERSION__[\"@liberfi.io/wallet-connector\"] = \"0.1.
|
|
1
|
+
{"version":3,"sources":["../src/providers/AuthContext.ts","../src/hooks/useAuth.ts","../src/hooks/useAuthCallback.ts","../src/providers/WalletConnectorContext.ts","../src/hooks/useWalletConnector.ts","../src/hooks/useWallets.ts","../src/hooks/useSwitchChain.ts","../src/providers/AuthProvider.tsx","../src/providers/WalletConnectorProvider.tsx","../src/version.ts"],"names":["AuthContext","createContext","useAuth","context","useContext","useAuthCallback","callback","deps","status","signIn","statusRef","useRef","useCallback","args","WalletConnectorContext","useWalletConnector","useWallets","wallets","useSwitchChain","chain","chainToNamespace","ChainNamespace","evmWallets","w","AuthProvider","children","value","jsx","WalletConnectorProvider","version_default"],"mappings":"sJAgBO,IAAMA,CAAAA,CAAcC,mBAAAA,CACzB,EACF,CAAA,CCfO,SAASC,CAAAA,EAAU,CACxB,IAAMC,CAAAA,CAAUC,gBAAAA,CAAWJ,CAAW,CAAA,CACtC,GAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,4CAA4C,CAAA,CAE9D,OAAOA,CACT,CCLO,SAASE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,CAAKC,CAAAA,EAAMA,CAAAA,CAAE,WAAA,CAAYJ,CAAK,CAAC,CAAC,EAC/D,EACA,CAACF,CAAO,CACV,CACF,CCnBO,SAASO,EAAAA,CAAa,CAAE,QAAA,CAAAC,CAAAA,CAAU,GAAGC,CAAM,CAAA,CAAsB,CACtE,OAAOC,cAAAA,CAAC3B,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO0B,CAAAA,CAAQ,QAAA,CAAAD,CAAAA,CAAS,CACvD,CCEO,SAASG,GAAwB,CACtC,QAAA,CAAAH,CAAAA,CACA,GAAGC,CACL,CAAA,CAAiC,CAC/B,OACEC,cAAAA,CAACb,CAAAA,CAAuB,QAAA,CAAvB,CAAgC,KAAA,CAAOY,CAAAA,CACrC,QAAA,CAAAD,CAAAA,CACH,CAEJ,CCXI,OAAO,MAAA,CAAW,GAAA,GACpB,MAAA,CAAO,mBAAA,CAAsB,MAAA,CAAO,mBAAA,EAAuB,EAAC,CAC5D,MAAA,CAAO,mBAAA,CAAoB,8BAA8B,CAAA,CAAI,QAAA,CAAA,KAGxDI,CAAAA,CAAQ","file":"index.js","sourcesContent":["import { createContext } from \"react\";\nimport { AuthenticatedUser } from \"../types\";\n\nexport interface AuthContextValue {\n /** authenticated user profile */\n user: AuthenticatedUser | null;\n /** authentication status */\n status: \"unauthenticated\" | \"authenticating\" | \"authenticated\";\n /** sign in to the IdP */\n signIn: () => void | Promise<void>;\n /** sign out from the IdP */\n signOut: () => void | Promise<void>;\n /** refresh the access token */\n refreshAccessToken: () => void | Promise<void>;\n}\n\nexport const AuthContext = createContext<AuthContextValue>(\n {} as AuthContextValue,\n);\n","import { useContext } from \"react\";\nimport { AuthContext } from \"../providers/AuthContext\";\n\nexport function useAuth() {\n const context = useContext(AuthContext);\n if (!context) {\n throw new Error(\"useAuth must be used within a AuthProvider\");\n }\n return context;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DependencyList, useCallback, useRef } from \"react\";\nimport { useAuth } from \"./useAuth\";\n\nexport function useAuthCallback<T extends (...args: any[]) => any>(\n callback: T,\n deps?: DependencyList,\n): T {\n const { status, signIn } = useAuth();\n\n // statusRef will be updated to the latest on each render\n // avoid callback rebuild on status changes\n const statusRef = useRef<string>(status);\n statusRef.current = status;\n\n const cb = useCallback(\n async (...args: Parameters<T>): Promise<ReturnType<T> | undefined> => {\n if (statusRef.current !== \"authenticated\") {\n // Only trigger sign-in when truly unauthenticated.\n // When \"authenticating\" (wallet detecting/connecting), just wait —\n // calling signIn() again may conflict with the in-progress auth flow.\n if (statusRef.current === \"unauthenticated\") {\n signIn();\n }\n return;\n }\n return callback(...args);\n },\n [...(deps || []), signIn, callback],\n );\n\n return cb as T;\n}\n","import { createContext } from \"react\";\nimport { WalletAdapter } from \"../types\";\n\nexport interface WalletConnectorContextValue {\n /**\n * detecting: is detecting connected wallets\n * connecting: is connecting to the first wallet\n * connected: is connected to at least one wallet\n * disconnecting: is disconnecting from the last connected wallet\n * disconnected: is disconnected from all wallets\n */\n status:\n | \"detecting\"\n | \"connecting\"\n | \"connected\"\n | \"disconnecting\"\n | \"disconnected\";\n // all wallets that can be used to take onchain actions when connected\n wallets: Array<WalletAdapter>;\n // if no wallets are connected, connect one or multiple wallets\n connect: () => Promise<void>;\n // disconnect all wallets\n disconnect: () => Promise<void>;\n}\n\nexport const WalletConnectorContext =\n createContext<WalletConnectorContextValue>({} as WalletConnectorContextValue);\n","import { useContext } from \"react\";\nimport { WalletConnectorContext } from \"../providers/WalletConnectorContext\";\n\n/**\n * use wallet connector hook\n * @returns wallet connector\n */\nexport function useWalletConnector() {\n const context = useContext(WalletConnectorContext);\n if (!context) {\n throw new Error(\n \"useWalletConnector must be used within a WalletConnectorProvider\",\n );\n }\n return context;\n}\n","import { useWalletConnector } from \"./useWalletConnector\";\n\n/**\n * use wallets hook\n * @returns all wallets that can be used to take onchain actions\n */\nexport function useWallets() {\n const { wallets } = useWalletConnector();\n return wallets;\n}\n","import { useCallback } from \"react\";\nimport { Chain, ChainNamespace } from \"@liberfi.io/types\";\nimport { chainToNamespace } from \"@liberfi.io/utils\";\nimport { EvmWalletAdapter } from \"../types\";\nimport { useWallets } from \"./useWallets\";\n\n/**\n * Returns a function that switches all connected EVM wallets to the given chain.\n * Solana chains are skipped.\n */\nexport function useSwitchChain() {\n const wallets = useWallets();\n\n return useCallback(\n async (chain: Chain) => {\n if (chainToNamespace(chain) === ChainNamespace.SOLANA) return;\n\n const evmWallets = wallets.filter(\n (w): w is EvmWalletAdapter => \"switchChain\" in w && w.isConnected,\n );\n await Promise.all(evmWallets.map((w) => w.switchChain(chain)));\n },\n [wallets],\n );\n}\n","import { PropsWithChildren } from \"react\";\nimport { AuthContext, AuthContextValue } from \"./AuthContext\";\n\nexport type AuthProviderProps = PropsWithChildren<AuthContextValue>;\n\nexport function AuthProvider({ children, ...value }: AuthProviderProps) {\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n","import { PropsWithChildren } from \"react\";\nimport {\n WalletConnectorContext,\n WalletConnectorContextValue,\n} from \"./WalletConnectorContext\";\n\nexport type WalletConnectorProviderProps =\n PropsWithChildren<WalletConnectorContextValue>;\n\nexport function WalletConnectorProvider({\n children,\n ...value\n}: WalletConnectorProviderProps) {\n return (\n <WalletConnectorContext.Provider value={value}>\n {children}\n </WalletConnectorContext.Provider>\n );\n}\n","declare global {\n interface Window {\n __LIBERFI_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif (typeof window !== \"undefined\") {\n window.__LIBERFI_VERSION__ = window.__LIBERFI_VERSION__ || {};\n window.__LIBERFI_VERSION__[\"@liberfi.io/wallet-connector\"] = \"0.1.18\";\n}\n\nexport default \"0.1.18\";\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {createContext,useContext,useRef,useCallback}from'react';import {ChainNamespace}from'@liberfi.io/types';import {chainToNamespace}from'@liberfi.io/utils';import {jsx}from'react/jsx-runtime';var n=createContext({});function s(){let t=useContext(n);if(!t)throw new Error("useAuth must be used within a AuthProvider");return t}function L(t,e){let{status:r,signIn:o}=s(),a=useRef(r);return a.current=r,useCallback(async(...c)=>{if(a.current!=="authenticated"){a.current==="unauthenticated"&&o();return}return t(...c)},[...e||[],o,t])}var i=createContext({});function u(){let t=useContext(i);if(!t)throw new Error("useWalletConnector must be used within a WalletConnectorProvider");return t}function l(){let{wallets:t}=u();return t}function K(){let t=l();return useCallback(async e=>{if(chainToNamespace(e)===ChainNamespace.SOLANA)return;let r=t.filter(o=>"switchChain"in o&&o.isConnected);await Promise.all(r.map(o=>o.switchChain(e)));},[t])}function ot({children:t,...e}){return jsx(n.Provider,{value:e,children:t})}function st({children:t,...e}){return jsx(i.Provider,{value:e,children:t})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/wallet-connector"]="0.1.
|
|
1
|
+
import {createContext,useContext,useRef,useCallback}from'react';import {ChainNamespace}from'@liberfi.io/types';import {chainToNamespace}from'@liberfi.io/utils';import {jsx}from'react/jsx-runtime';var n=createContext({});function s(){let t=useContext(n);if(!t)throw new Error("useAuth must be used within a AuthProvider");return t}function L(t,e){let{status:r,signIn:o}=s(),a=useRef(r);return a.current=r,useCallback(async(...c)=>{if(a.current!=="authenticated"){a.current==="unauthenticated"&&o();return}return t(...c)},[...e||[],o,t])}var i=createContext({});function u(){let t=useContext(i);if(!t)throw new Error("useWalletConnector must be used within a WalletConnectorProvider");return t}function l(){let{wallets:t}=u();return t}function K(){let t=l();return useCallback(async e=>{if(chainToNamespace(e)===ChainNamespace.SOLANA)return;let r=t.filter(o=>"switchChain"in o&&o.isConnected);await Promise.all(r.map(o=>o.switchChain(e)));},[t])}function ot({children:t,...e}){return jsx(n.Provider,{value:e,children:t})}function st({children:t,...e}){return jsx(i.Provider,{value:e,children:t})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/wallet-connector"]="0.1.18");var w="0.1.18";export{ot as AuthProvider,st as WalletConnectorProvider,s as useAuth,L as useAuthCallback,K as useSwitchChain,u as useWalletConnector,l as useWallets,w as version};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/providers/AuthContext.ts","../src/hooks/useAuth.ts","../src/hooks/useAuthCallback.ts","../src/providers/WalletConnectorContext.ts","../src/hooks/useWalletConnector.ts","../src/hooks/useWallets.ts","../src/hooks/useSwitchChain.ts","../src/providers/AuthProvider.tsx","../src/providers/WalletConnectorProvider.tsx","../src/version.ts"],"names":["AuthContext","createContext","useAuth","context","useContext","useAuthCallback","callback","deps","status","signIn","statusRef","useRef","useCallback","args","WalletConnectorContext","useWalletConnector","useWallets","wallets","useSwitchChain","chain","chainToNamespace","ChainNamespace","evmWallets","w","AuthProvider","children","value","jsx","WalletConnectorProvider","version_default"],"mappings":"oMAgBO,IAAMA,CAAAA,CAAcC,aAAAA,CACzB,EACF,CAAA,CCfO,SAASC,CAAAA,EAAU,CACxB,IAAMC,CAAAA,CAAUC,UAAAA,CAAWJ,CAAW,CAAA,CACtC,GAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,4CAA4C,CAAA,CAE9D,OAAOA,CACT,CCLO,SAASE,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACG,CACH,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAQ,MAAA,CAAAC,CAAO,CAAA,CAAIP,CAAAA,EAAQ,CAI7BQ,CAAAA,CAAYC,MAAAA,CAAeH,CAAM,CAAA,CACvC,OAAAE,CAAAA,CAAU,OAAA,CAAUF,CAAAA,CAETI,YACT,MAAA,GAAUC,CAAAA,GAA4D,CACpE,GAAIH,CAAAA,CAAU,OAAA,GAAY,eAAA,CAAiB,CAIrCA,CAAAA,CAAU,OAAA,GAAY,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ACA,GAAGC,CACL,CAAA,CAAiC,CAC/B,OACEC,GAAAA,CAACb,CAAAA,CAAuB,QAAA,CAAvB,CAAgC,KAAA,CAAOY,CAAAA,CACrC,QAAA,CAAAD,CAAAA,CACH,CAEJ,CCXI,OAAO,MAAA,CAAW,GAAA,GACpB,MAAA,CAAO,mBAAA,CAAsB,MAAA,CAAO,mBAAA,EAAuB,EAAC,CAC5D,MAAA,CAAO,mBAAA,CAAoB,8BAA8B,CAAA,CAAI,QAAA,CAAA,KAGxDI,CAAAA,CAAQ","file":"index.mjs","sourcesContent":["import { createContext } from \"react\";\nimport { AuthenticatedUser } from \"../types\";\n\nexport interface AuthContextValue {\n /** authenticated user profile */\n user: AuthenticatedUser | null;\n /** authentication status */\n status: \"unauthenticated\" | \"authenticating\" | \"authenticated\";\n /** sign in to the IdP */\n signIn: () => void | Promise<void>;\n /** sign out from the IdP */\n signOut: () => void | Promise<void>;\n /** refresh the access token */\n refreshAccessToken: () => void | Promise<void>;\n}\n\nexport const AuthContext = createContext<AuthContextValue>(\n {} as AuthContextValue,\n);\n","import { useContext } from \"react\";\nimport { AuthContext } from \"../providers/AuthContext\";\n\nexport function useAuth() {\n const context = useContext(AuthContext);\n if (!context) {\n throw new Error(\"useAuth must be used within a AuthProvider\");\n }\n return context;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DependencyList, useCallback, useRef } from \"react\";\nimport { useAuth } from \"./useAuth\";\n\nexport function useAuthCallback<T extends (...args: any[]) => any>(\n callback: T,\n deps?: DependencyList,\n): T {\n const { status, signIn } = useAuth();\n\n // statusRef will be updated to the latest on each render\n // avoid callback rebuild on status changes\n const statusRef = useRef<string>(status);\n statusRef.current = status;\n\n const cb = useCallback(\n async (...args: Parameters<T>): Promise<ReturnType<T> | undefined> => {\n if (statusRef.current !== \"authenticated\") {\n // Only trigger sign-in when truly unauthenticated.\n // When \"authenticating\" (wallet detecting/connecting), just wait —\n // calling signIn() again may conflict with the in-progress auth flow.\n if (statusRef.current === \"unauthenticated\") {\n signIn();\n }\n return;\n }\n return callback(...args);\n },\n [...(deps || []), signIn, callback],\n );\n\n return cb as T;\n}\n","import { createContext } from \"react\";\nimport { WalletAdapter } from \"../types\";\n\nexport interface WalletConnectorContextValue {\n /**\n * detecting: is detecting connected wallets\n * connecting: is connecting to the first wallet\n * connected: is connected to at least one wallet\n * disconnecting: is disconnecting from the last connected wallet\n * disconnected: is disconnected from all wallets\n */\n status:\n | \"detecting\"\n | \"connecting\"\n | \"connected\"\n | \"disconnecting\"\n | \"disconnected\";\n // all wallets that can be used to take onchain actions when connected\n wallets: Array<WalletAdapter>;\n // if no wallets are connected, connect one or multiple wallets\n connect: () => Promise<void>;\n // disconnect all wallets\n disconnect: () => Promise<void>;\n}\n\nexport const WalletConnectorContext =\n createContext<WalletConnectorContextValue>({} as WalletConnectorContextValue);\n","import { useContext } from \"react\";\nimport { WalletConnectorContext } from \"../providers/WalletConnectorContext\";\n\n/**\n * use wallet connector hook\n * @returns wallet connector\n */\nexport function useWalletConnector() {\n const context = useContext(WalletConnectorContext);\n if (!context) {\n throw new Error(\n \"useWalletConnector must be used within a WalletConnectorProvider\",\n );\n }\n return context;\n}\n","import { useWalletConnector } from \"./useWalletConnector\";\n\n/**\n * use wallets hook\n * @returns all wallets that can be used to take onchain actions\n */\nexport function useWallets() {\n const { wallets } = useWalletConnector();\n return wallets;\n}\n","import { useCallback } from \"react\";\nimport { Chain, ChainNamespace } from \"@liberfi.io/types\";\nimport { chainToNamespace } from \"@liberfi.io/utils\";\nimport { EvmWalletAdapter } from \"../types\";\nimport { useWallets } from \"./useWallets\";\n\n/**\n * Returns a function that switches all connected EVM wallets to the given chain.\n * Solana chains are skipped.\n */\nexport function useSwitchChain() {\n const wallets = useWallets();\n\n return useCallback(\n async (chain: Chain) => {\n if (chainToNamespace(chain) === ChainNamespace.SOLANA) return;\n\n const evmWallets = wallets.filter(\n (w): w is EvmWalletAdapter => \"switchChain\" in w && w.isConnected,\n );\n await Promise.all(evmWallets.map((w) => w.switchChain(chain)));\n },\n [wallets],\n );\n}\n","import { PropsWithChildren } from \"react\";\nimport { AuthContext, AuthContextValue } from \"./AuthContext\";\n\nexport type AuthProviderProps = PropsWithChildren<AuthContextValue>;\n\nexport function AuthProvider({ children, ...value }: AuthProviderProps) {\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n","import { PropsWithChildren } from \"react\";\nimport {\n WalletConnectorContext,\n WalletConnectorContextValue,\n} from \"./WalletConnectorContext\";\n\nexport type WalletConnectorProviderProps =\n PropsWithChildren<WalletConnectorContextValue>;\n\nexport function WalletConnectorProvider({\n children,\n ...value\n}: WalletConnectorProviderProps) {\n return (\n <WalletConnectorContext.Provider value={value}>\n {children}\n </WalletConnectorContext.Provider>\n );\n}\n","declare global {\n interface Window {\n __LIBERFI_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif (typeof window !== \"undefined\") {\n window.__LIBERFI_VERSION__ = window.__LIBERFI_VERSION__ || {};\n window.__LIBERFI_VERSION__[\"@liberfi.io/wallet-connector\"] = \"0.1.
|
|
1
|
+
{"version":3,"sources":["../src/providers/AuthContext.ts","../src/hooks/useAuth.ts","../src/hooks/useAuthCallback.ts","../src/providers/WalletConnectorContext.ts","../src/hooks/useWalletConnector.ts","../src/hooks/useWallets.ts","../src/hooks/useSwitchChain.ts","../src/providers/AuthProvider.tsx","../src/providers/WalletConnectorProvider.tsx","../src/version.ts"],"names":["AuthContext","createContext","useAuth","context","useContext","useAuthCallback","callback","deps","status","signIn","statusRef","useRef","useCallback","args","WalletConnectorContext","useWalletConnector","useWallets","wallets","useSwitchChain","chain","chainToNamespace","ChainNamespace","evmWallets","w","AuthProvider","children","value","jsx","WalletConnectorProvider","version_default"],"mappings":"oMAgBO,IAAMA,CAAAA,CAAcC,aAAAA,CACzB,EACF,CAAA,CCfO,SAASC,CAAAA,EAAU,CACxB,IAAMC,CAAAA,CAAUC,UAAAA,CAAWJ,CAAW,CAAA,CACtC,GAAI,CAAC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AAA,CAAE,WACxD,CAAA,CACA,MAAM,OAAA,CAAQ,GAAA,CAAID,CAAAA,CAAW,GAAA,CAAKC,CAAAA,EAAMA,CAAAA,CAAE,WAAA,CAAYJ,CAAK,CAAC,CAAC,EAC/D,EACA,CAACF,CAAO,CACV,CACF,CCnBO,SAASO,EAAAA,CAAa,CAAE,QAAA,CAAAC,CAAAA,CAAU,GAAGC,CAAM,CAAA,CAAsB,CACtE,OAAOC,GAAAA,CAAC3B,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO0B,CAAAA,CAAQ,QAAA,CAAAD,CAAAA,CAAS,CACvD,CCEO,SAASG,GAAwB,CACtC,QAAA,CAAAH,CAAAA,CACA,GAAGC,CACL,CAAA,CAAiC,CAC/B,OACEC,GAAAA,CAACb,CAAAA,CAAuB,QAAA,CAAvB,CAAgC,KAAA,CAAOY,CAAAA,CACrC,QAAA,CAAAD,CAAAA,CACH,CAEJ,CCXI,OAAO,MAAA,CAAW,GAAA,GACpB,MAAA,CAAO,mBAAA,CAAsB,MAAA,CAAO,mBAAA,EAAuB,EAAC,CAC5D,MAAA,CAAO,mBAAA,CAAoB,8BAA8B,CAAA,CAAI,QAAA,CAAA,KAGxDI,CAAAA,CAAQ","file":"index.mjs","sourcesContent":["import { createContext } from \"react\";\nimport { AuthenticatedUser } from \"../types\";\n\nexport interface AuthContextValue {\n /** authenticated user profile */\n user: AuthenticatedUser | null;\n /** authentication status */\n status: \"unauthenticated\" | \"authenticating\" | \"authenticated\";\n /** sign in to the IdP */\n signIn: () => void | Promise<void>;\n /** sign out from the IdP */\n signOut: () => void | Promise<void>;\n /** refresh the access token */\n refreshAccessToken: () => void | Promise<void>;\n}\n\nexport const AuthContext = createContext<AuthContextValue>(\n {} as AuthContextValue,\n);\n","import { useContext } from \"react\";\nimport { AuthContext } from \"../providers/AuthContext\";\n\nexport function useAuth() {\n const context = useContext(AuthContext);\n if (!context) {\n throw new Error(\"useAuth must be used within a AuthProvider\");\n }\n return context;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DependencyList, useCallback, useRef } from \"react\";\nimport { useAuth } from \"./useAuth\";\n\nexport function useAuthCallback<T extends (...args: any[]) => any>(\n callback: T,\n deps?: DependencyList,\n): T {\n const { status, signIn } = useAuth();\n\n // statusRef will be updated to the latest on each render\n // avoid callback rebuild on status changes\n const statusRef = useRef<string>(status);\n statusRef.current = status;\n\n const cb = useCallback(\n async (...args: Parameters<T>): Promise<ReturnType<T> | undefined> => {\n if (statusRef.current !== \"authenticated\") {\n // Only trigger sign-in when truly unauthenticated.\n // When \"authenticating\" (wallet detecting/connecting), just wait —\n // calling signIn() again may conflict with the in-progress auth flow.\n if (statusRef.current === \"unauthenticated\") {\n signIn();\n }\n return;\n }\n return callback(...args);\n },\n [...(deps || []), signIn, callback],\n );\n\n return cb as T;\n}\n","import { createContext } from \"react\";\nimport { WalletAdapter } from \"../types\";\n\nexport interface WalletConnectorContextValue {\n /**\n * detecting: is detecting connected wallets\n * connecting: is connecting to the first wallet\n * connected: is connected to at least one wallet\n * disconnecting: is disconnecting from the last connected wallet\n * disconnected: is disconnected from all wallets\n */\n status:\n | \"detecting\"\n | \"connecting\"\n | \"connected\"\n | \"disconnecting\"\n | \"disconnected\";\n // all wallets that can be used to take onchain actions when connected\n wallets: Array<WalletAdapter>;\n // if no wallets are connected, connect one or multiple wallets\n connect: () => Promise<void>;\n // disconnect all wallets\n disconnect: () => Promise<void>;\n}\n\nexport const WalletConnectorContext =\n createContext<WalletConnectorContextValue>({} as WalletConnectorContextValue);\n","import { useContext } from \"react\";\nimport { WalletConnectorContext } from \"../providers/WalletConnectorContext\";\n\n/**\n * use wallet connector hook\n * @returns wallet connector\n */\nexport function useWalletConnector() {\n const context = useContext(WalletConnectorContext);\n if (!context) {\n throw new Error(\n \"useWalletConnector must be used within a WalletConnectorProvider\",\n );\n }\n return context;\n}\n","import { useWalletConnector } from \"./useWalletConnector\";\n\n/**\n * use wallets hook\n * @returns all wallets that can be used to take onchain actions\n */\nexport function useWallets() {\n const { wallets } = useWalletConnector();\n return wallets;\n}\n","import { useCallback } from \"react\";\nimport { Chain, ChainNamespace } from \"@liberfi.io/types\";\nimport { chainToNamespace } from \"@liberfi.io/utils\";\nimport { EvmWalletAdapter } from \"../types\";\nimport { useWallets } from \"./useWallets\";\n\n/**\n * Returns a function that switches all connected EVM wallets to the given chain.\n * Solana chains are skipped.\n */\nexport function useSwitchChain() {\n const wallets = useWallets();\n\n return useCallback(\n async (chain: Chain) => {\n if (chainToNamespace(chain) === ChainNamespace.SOLANA) return;\n\n const evmWallets = wallets.filter(\n (w): w is EvmWalletAdapter => \"switchChain\" in w && w.isConnected,\n );\n await Promise.all(evmWallets.map((w) => w.switchChain(chain)));\n },\n [wallets],\n );\n}\n","import { PropsWithChildren } from \"react\";\nimport { AuthContext, AuthContextValue } from \"./AuthContext\";\n\nexport type AuthProviderProps = PropsWithChildren<AuthContextValue>;\n\nexport function AuthProvider({ children, ...value }: AuthProviderProps) {\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n","import { PropsWithChildren } from \"react\";\nimport {\n WalletConnectorContext,\n WalletConnectorContextValue,\n} from \"./WalletConnectorContext\";\n\nexport type WalletConnectorProviderProps =\n PropsWithChildren<WalletConnectorContextValue>;\n\nexport function WalletConnectorProvider({\n children,\n ...value\n}: WalletConnectorProviderProps) {\n return (\n <WalletConnectorContext.Provider value={value}>\n {children}\n </WalletConnectorContext.Provider>\n );\n}\n","declare global {\n interface Window {\n __LIBERFI_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif (typeof window !== \"undefined\") {\n window.__LIBERFI_VERSION__ = window.__LIBERFI_VERSION__ || {};\n window.__LIBERFI_VERSION__[\"@liberfi.io/wallet-connector\"] = \"0.1.18\";\n}\n\nexport default \"0.1.18\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liberfi.io/wallet-connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Base Wallet Connector for Liberfi React SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@liberfi.io/types": "0.1.
|
|
18
|
-
"@liberfi.io/utils": "0.1.
|
|
17
|
+
"@liberfi.io/types": "0.1.27",
|
|
18
|
+
"@liberfi.io/utils": "0.1.24"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/react": "^19.1.13",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"rimraf": "^5.0.5",
|
|
26
26
|
"tsup": "^8.5.0",
|
|
27
27
|
"typescript": "^5.9.2",
|
|
28
|
-
"tsconfig": "0.1.
|
|
28
|
+
"tsconfig": "0.1.15"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=18",
|