@frak-labs/react-sdk 0.1.0-beta.dd44738a → 0.1.0-beta.ebc9d3a3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.cts +386 -3
  3. package/dist/index.d.ts +386 -3
  4. package/dist/index.js +1 -1
  5. package/package.json +9 -8
  6. package/dist/hook/helper/useReferralInteraction.d.cts +0 -24
  7. package/dist/hook/helper/useReferralInteraction.d.ts +0 -24
  8. package/dist/hook/index.d.cts +0 -11
  9. package/dist/hook/index.d.ts +0 -11
  10. package/dist/hook/useDisplayModal.d.cts +0 -38
  11. package/dist/hook/useDisplayModal.d.ts +0 -38
  12. package/dist/hook/useFrakClient.d.cts +0 -6
  13. package/dist/hook/useFrakClient.d.ts +0 -6
  14. package/dist/hook/useFrakConfig.d.cts +0 -9
  15. package/dist/hook/useFrakConfig.d.ts +0 -9
  16. package/dist/hook/useGetProductInformation.d.cts +0 -30
  17. package/dist/hook/useGetProductInformation.d.ts +0 -30
  18. package/dist/hook/useOpenSso.d.cts +0 -33
  19. package/dist/hook/useOpenSso.d.ts +0 -33
  20. package/dist/hook/usePrepareSso.d.cts +0 -40
  21. package/dist/hook/usePrepareSso.d.ts +0 -40
  22. package/dist/hook/useSendInteraction.d.cts +0 -33
  23. package/dist/hook/useSendInteraction.d.ts +0 -33
  24. package/dist/hook/useSendTransaction.d.cts +0 -34
  25. package/dist/hook/useSendTransaction.d.ts +0 -34
  26. package/dist/hook/useSiweAuthenticate.d.cts +0 -35
  27. package/dist/hook/useSiweAuthenticate.d.ts +0 -35
  28. package/dist/hook/useWalletStatus.d.cts +0 -16
  29. package/dist/hook/useWalletStatus.d.ts +0 -16
  30. package/dist/hook/utils/useFrakContext.d.cts +0 -9
  31. package/dist/hook/utils/useFrakContext.d.ts +0 -9
  32. package/dist/hook/utils/useMounted.d.cts +0 -2
  33. package/dist/hook/utils/useMounted.d.ts +0 -2
  34. package/dist/hook/utils/useWindowLocation.d.cts +0 -8
  35. package/dist/hook/utils/useWindowLocation.d.ts +0 -8
  36. package/dist/provider/FrakConfigProvider.d.cts +0 -29
  37. package/dist/provider/FrakConfigProvider.d.ts +0 -29
  38. package/dist/provider/FrakIFrameClientProvider.d.cts +0 -32
  39. package/dist/provider/FrakIFrameClientProvider.d.ts +0 -32
  40. package/dist/provider/index.d.cts +0 -4
  41. package/dist/provider/index.d.ts +0 -4
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useOpenSso:()=>useOpenSso,useWalletStatus:()=>useWalletStatus,useReferralInteraction:()=>useReferralInteraction,useSendTransactionAction:()=>useSendTransactionAction,FrakConfigProvider:()=>FrakConfigProvider,useSendInteraction:()=>useSendInteraction,useGetProductInformation:()=>useGetProductInformation,FrakConfigContext:()=>FrakConfigContext,useDisplayModal:()=>useDisplayModal,useFrakClient:()=>useFrakClient,FrakIFrameClientProvider:()=>FrakIFrameClientProvider,useFrakConfig:()=>useFrakConfig,usePrepareSso:()=>usePrepareSso,useSiweAuthenticate:()=>useSiweAuthenticate,FrakIFrameClientContext:()=>FrakIFrameClientContext});let external_react_namespaceObject=require("react"),FrakConfigContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakConfigProvider(e){let{children:t,config:r}=e;return(0,external_react_namespaceObject.createElement)(FrakConfigContext.Provider,{value:{...r,walletUrl:r.walletUrl??"https://wallet.frak.id",domain:r.domain??("undefined"!=typeof window?window?.location?.host:void 0)??"not-found"}},t)}let core_sdk_namespaceObject=require("@frak-labs/core-sdk"),frame_connector_namespaceObject=require("@frak-labs/frame-connector");function useFrakConfig(){let e=(0,external_react_namespaceObject.useContext)(FrakConfigContext);if(!e)throw new frame_connector_namespaceObject.FrakRpcError(frame_connector_namespaceObject.RpcErrorCodes.configError,"Frak config not found");return e}let FrakIFrameClientContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakIFrameClientProvider({style:e,children:t}){let r=useFrakConfig(),[a,n]=(0,external_react_namespaceObject.useState)(void 0),o=(0,external_react_namespaceObject.createElement)("iframe",{...core_sdk_namespaceObject.baseIframeProps,src:`${r.walletUrl}/listener`,style:e??core_sdk_namespaceObject.baseIframeProps.style,ref:e=>{e&&!a&&n((0,core_sdk_namespaceObject.createIFrameFrakClient)({iframe:e,config:r}))}}),c=(0,external_react_namespaceObject.createElement)(FrakIFrameClientContext.Provider,{value:a},t);return(0,external_react_namespaceObject.createElement)(external_react_namespaceObject.Fragment,null,o,c)}function useFrakClient(){return(0,external_react_namespaceObject.useContext)(FrakIFrameClientContext)}let actions_namespaceObject=require("@frak-labs/core-sdk/actions"),react_query_namespaceObject=require("@tanstack/react-query");function useWalletStatus(){let e=(0,react_query_namespaceObject.useQueryClient)(),t=useFrakClient(),r=(0,external_react_namespaceObject.useCallback)(t=>{e.setQueryData(["frak-sdk","wallet-status-listener"],t)},[e]);return(0,react_query_namespaceObject.useQuery)({gcTime:0,staleTime:0,queryKey:["frak-sdk","wallet-status-listener"],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.watchWalletStatus)(t,r)},enabled:!!t})}function useSendTransactionAction({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","send-transaction"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.sendTransaction)(t,e)}})}function useSendInteraction({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","send-interaction"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.sendInteraction)(t,e)}})}function useSiweAuthenticate({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","siwe-authenticate",t?.config.domain??"no-domain"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.siweAuthenticate)(t,e)}})}function useMounted(){let[e,t]=(0,external_react_namespaceObject.useState)(!1);return(0,external_react_namespaceObject.useEffect)(()=>{t(!0)},[]),e}function useWindowLocation(){let e=useMounted(),[t,r]=(0,external_react_namespaceObject.useState)(e?window.location:void 0);(0,external_react_namespaceObject.useEffect)(()=>{if(e)return t||a(),window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)};function a(){r(window.location)}},[e,t]);let a=(0,external_react_namespaceObject.useMemo)(()=>t?.href,[t?.href]);return{location:t,href:a}}function useFrakContext(){let{location:e}=useWindowLocation();return{frakContext:(0,external_react_namespaceObject.useMemo)(()=>e?.href?core_sdk_namespaceObject.FrakContextManager.parse({url:e.href}):null,[e?.href]),updateContext:(0,external_react_namespaceObject.useCallback)(t=>{console.log("Updating context",{newContext:t}),core_sdk_namespaceObject.FrakContextManager.replaceUrl({url:e?.href,context:t})},[e?.href])}}function useReferralInteraction({productId:e,modalConfig:t,options:r}={}){let a=useFrakClient(),{frakContext:n}=useFrakContext(),{data:o}=useWalletStatus(),{data:c,error:s,status:_}=(0,react_query_namespaceObject.useQuery)({gcTime:0,staleTime:0,queryKey:["frak-sdk","auto-referral-interaction",n?.r??"no-referrer",o?.key??"no-wallet-status",e??"no-product-id"],queryFn:()=>{if(!a)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.processReferral)(a,{walletStatus:o,frakContext:n,modalConfig:t,productId:e,options:r})},enabled:!!o});return(0,external_react_namespaceObject.useMemo)(()=>"pending"===_?"processing":"error"===_?s:c||"idle",[c,_,s])}function useDisplayModal({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","display-modal"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.displayModal)(t,e)}})}function useOpenSso({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","open-sso"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.openSso)(t,e)}})}function usePrepareSso(e){let t=useFrakClient();return(0,react_query_namespaceObject.useQuery)({queryKey:["frak-sdk","prepare-sso",e],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.prepareSso)(t,e)}})}function useGetProductInformation({query:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useQuery)({...e,queryKey:["frak-sdk","get-product-information"],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.getProductInformation)(t)}})}for(var __webpack_i__ in exports.FrakConfigContext=__webpack_exports__.FrakConfigContext,exports.FrakConfigProvider=__webpack_exports__.FrakConfigProvider,exports.FrakIFrameClientContext=__webpack_exports__.FrakIFrameClientContext,exports.FrakIFrameClientProvider=__webpack_exports__.FrakIFrameClientProvider,exports.useDisplayModal=__webpack_exports__.useDisplayModal,exports.useFrakClient=__webpack_exports__.useFrakClient,exports.useFrakConfig=__webpack_exports__.useFrakConfig,exports.useGetProductInformation=__webpack_exports__.useGetProductInformation,exports.useOpenSso=__webpack_exports__.useOpenSso,exports.usePrepareSso=__webpack_exports__.usePrepareSso,exports.useReferralInteraction=__webpack_exports__.useReferralInteraction,exports.useSendInteraction=__webpack_exports__.useSendInteraction,exports.useSendTransactionAction=__webpack_exports__.useSendTransactionAction,exports.useSiweAuthenticate=__webpack_exports__.useSiweAuthenticate,exports.useWalletStatus=__webpack_exports__.useWalletStatus,__webpack_exports__)-1===["FrakConfigContext","FrakConfigProvider","FrakIFrameClientContext","FrakIFrameClientProvider","useDisplayModal","useFrakClient","useFrakConfig","useGetProductInformation","useOpenSso","usePrepareSso","useReferralInteraction","useSendInteraction","useSendTransactionAction","useSiweAuthenticate","useWalletStatus"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useOpenSso:()=>useOpenSso,useWalletStatus:()=>useWalletStatus,useReferralInteraction:()=>useReferralInteraction,useSendTransactionAction:()=>useSendTransactionAction,FrakConfigProvider:()=>FrakConfigProvider,useSendInteraction:()=>useSendInteraction,useGetProductInformation:()=>useGetProductInformation,FrakConfigContext:()=>FrakConfigContext,useDisplayModal:()=>useDisplayModal,useFrakClient:()=>useFrakClient,FrakIFrameClientProvider:()=>FrakIFrameClientProvider,useFrakConfig:()=>useFrakConfig,usePrepareSso:()=>usePrepareSso,useSiweAuthenticate:()=>useSiweAuthenticate,FrakIFrameClientContext:()=>FrakIFrameClientContext});const actions_namespaceObject=require("@frak-labs/core-sdk/actions"),frame_connector_namespaceObject=require("@frak-labs/frame-connector"),react_query_namespaceObject=require("@tanstack/react-query"),external_react_namespaceObject=require("react"),core_sdk_namespaceObject=require("@frak-labs/core-sdk"),FrakConfigContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakConfigProvider(e){let{children:t,config:r}=e;return(0,external_react_namespaceObject.createElement)(FrakConfigContext.Provider,{value:{...r,walletUrl:r.walletUrl??"https://wallet.frak.id",domain:r.domain??("undefined"!=typeof window?window?.location?.host:void 0)??"not-found"}},t)}function useFrakConfig(){let e=(0,external_react_namespaceObject.useContext)(FrakConfigContext);if(!e)throw new frame_connector_namespaceObject.FrakRpcError(frame_connector_namespaceObject.RpcErrorCodes.configError,"Frak config not found");return e}const FrakIFrameClientContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakIFrameClientProvider({style:e,children:t}){let r=useFrakConfig(),[a,n]=(0,external_react_namespaceObject.useState)(void 0),o=(0,external_react_namespaceObject.createElement)("iframe",{...core_sdk_namespaceObject.baseIframeProps,src:`${r.walletUrl}/listener`,style:e??core_sdk_namespaceObject.baseIframeProps.style,ref:e=>{e&&!a&&n((0,core_sdk_namespaceObject.createIFrameFrakClient)({iframe:e,config:r}))}}),c=(0,external_react_namespaceObject.createElement)(FrakIFrameClientContext.Provider,{value:a},t);return(0,external_react_namespaceObject.createElement)(external_react_namespaceObject.Fragment,null,o,c)}function useFrakClient(){return(0,external_react_namespaceObject.useContext)(FrakIFrameClientContext)}function useDisplayModal({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","display-modal"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.displayModal)(t,e)}})}function useGetProductInformation({query:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useQuery)({...e,queryKey:["frak-sdk","get-product-information"],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.getProductInformation)(t)}})}function useOpenSso({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","open-sso"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.openSso)(t,e)}})}function usePrepareSso(e){let t=useFrakClient();return(0,react_query_namespaceObject.useQuery)({queryKey:["frak-sdk","prepare-sso",e],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.prepareSso)(t,e)}})}function useWalletStatus(){let e=(0,react_query_namespaceObject.useQueryClient)(),t=useFrakClient(),r=(0,external_react_namespaceObject.useCallback)(t=>{e.setQueryData(["frak-sdk","wallet-status-listener"],t)},[e]);return(0,react_query_namespaceObject.useQuery)({gcTime:0,staleTime:0,queryKey:["frak-sdk","wallet-status-listener"],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.watchWalletStatus)(t,r)},enabled:!!t})}function useMounted(){let[e,t]=(0,external_react_namespaceObject.useState)(!1);return(0,external_react_namespaceObject.useEffect)(()=>{t(!0)},[]),e}function useWindowLocation(){let e=useMounted(),[t,r]=(0,external_react_namespaceObject.useState)(e?window.location:void 0);(0,external_react_namespaceObject.useEffect)(()=>{if(e)return t||a(),window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)};function a(){r(window.location)}},[e,t]);let a=(0,external_react_namespaceObject.useMemo)(()=>t?.href,[t?.href]);return{location:t,href:a}}function useFrakContext(){let{location:e}=useWindowLocation();return{frakContext:(0,external_react_namespaceObject.useMemo)(()=>e?.href?core_sdk_namespaceObject.FrakContextManager.parse({url:e.href}):null,[e?.href]),updateContext:(0,external_react_namespaceObject.useCallback)(t=>{console.log("Updating context",{newContext:t}),core_sdk_namespaceObject.FrakContextManager.replaceUrl({url:e?.href,context:t})},[e?.href])}}function useReferralInteraction({productId:e,modalConfig:t,options:r}={}){let a=useFrakClient(),{frakContext:n}=useFrakContext(),{data:o}=useWalletStatus(),{data:c,error:s,status:_}=(0,react_query_namespaceObject.useQuery)({gcTime:0,staleTime:0,queryKey:["frak-sdk","auto-referral-interaction",n?.r??"no-referrer",o?.key??"no-wallet-status",e??"no-product-id"],queryFn:()=>{if(!a)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.processReferral)(a,{walletStatus:o,frakContext:n,modalConfig:t,productId:e,options:r})},enabled:!!o});return(0,external_react_namespaceObject.useMemo)(()=>"pending"===_?"processing":"error"===_?s:c||"idle",[c,_,s])}function useSendInteraction({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","send-interaction"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.sendInteraction)(t,e)}})}function useSendTransactionAction({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","send-transaction"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.sendTransaction)(t,e)}})}function useSiweAuthenticate({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","siwe-authenticate",t?.config.domain??"no-domain"],mutationFn:async e=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.siweAuthenticate)(t,e)}})}for(var __webpack_i__ in exports.FrakConfigContext=__webpack_exports__.FrakConfigContext,exports.FrakConfigProvider=__webpack_exports__.FrakConfigProvider,exports.FrakIFrameClientContext=__webpack_exports__.FrakIFrameClientContext,exports.FrakIFrameClientProvider=__webpack_exports__.FrakIFrameClientProvider,exports.useDisplayModal=__webpack_exports__.useDisplayModal,exports.useFrakClient=__webpack_exports__.useFrakClient,exports.useFrakConfig=__webpack_exports__.useFrakConfig,exports.useGetProductInformation=__webpack_exports__.useGetProductInformation,exports.useOpenSso=__webpack_exports__.useOpenSso,exports.usePrepareSso=__webpack_exports__.usePrepareSso,exports.useReferralInteraction=__webpack_exports__.useReferralInteraction,exports.useSendInteraction=__webpack_exports__.useSendInteraction,exports.useSendTransactionAction=__webpack_exports__.useSendTransactionAction,exports.useSiweAuthenticate=__webpack_exports__.useSiweAuthenticate,exports.useWalletStatus=__webpack_exports__.useWalletStatus,__webpack_exports__)-1===["FrakConfigContext","FrakConfigProvider","FrakIFrameClientContext","FrakIFrameClientProvider","useDisplayModal","useFrakClient","useFrakConfig","useGetProductInformation","useOpenSso","usePrepareSso","useReferralInteraction","useSendInteraction","useSendTransactionAction","useSiweAuthenticate","useWalletStatus"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.cts CHANGED
@@ -1,3 +1,386 @@
1
- export { FrakConfigContext, FrakConfigProvider, FrakIFrameClientContext, FrakIFrameClientProvider, } from "./provider";
2
- export type { FrakConfigProviderProps, FrakIFrameClientProps, } from "./provider";
3
- export { useFrakConfig, useFrakClient, useWalletStatus, useSendTransactionAction, useSendInteraction, useSiweAuthenticate, useReferralInteraction, useDisplayModal, useOpenSso, usePrepareSso, useGetProductInformation, } from "./hook";
1
+ import { Context } from 'react';
2
+ import { CSSProperties } from 'react';
3
+ import type { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
4
+ import type { DisplayModalParamsType } from '@frak-labs/core-sdk';
5
+ import { FragmentProps } from 'react';
6
+ import { FrakClient } from '@frak-labs/core-sdk';
7
+ import { FrakRpcError } from '@frak-labs/frame-connector';
8
+ import { FrakWalletSdkConfig } from '@frak-labs/core-sdk';
9
+ import { FunctionComponentElement } from 'react';
10
+ import type { GetProductInformationReturnType } from '@frak-labs/core-sdk';
11
+ import { Hex } from 'viem';
12
+ import type { ModalRpcStepsResultType } from '@frak-labs/core-sdk';
13
+ import type { ModalStepTypes } from '@frak-labs/core-sdk';
14
+ import type { OpenSsoParamsType } from '@frak-labs/core-sdk';
15
+ import type { OpenSsoReturnType } from '@frak-labs/core-sdk';
16
+ import type { PrepareSsoParamsType } from '@frak-labs/core-sdk';
17
+ import { ProcessReferralOptions } from '@frak-labs/core-sdk/actions';
18
+ import { PropsWithChildren } from 'react';
19
+ import { ProviderProps } from 'react';
20
+ import { ReactNode } from 'react';
21
+ import type { SendInteractionParamsType } from '@frak-labs/core-sdk';
22
+ import type { SendInteractionReturnType } from '@frak-labs/core-sdk';
23
+ import { SendTransactionParams } from '@frak-labs/core-sdk/actions';
24
+ import type { SendTransactionReturnType } from '@frak-labs/core-sdk';
25
+ import { SiweAuthenticateModalParams } from '@frak-labs/core-sdk/actions';
26
+ import type { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
27
+ import { UseMutationOptions } from '@tanstack/react-query';
28
+ import { UseMutationResult } from '@tanstack/react-query';
29
+ import { UseQueryOptions } from '@tanstack/react-query';
30
+ import { UseQueryResult } from '@tanstack/react-query';
31
+ import type { WalletStatusReturnType } from '@frak-labs/core-sdk';
32
+
33
+ /**
34
+ * The context that will keep the Frak Wallet SDK configuration
35
+ * @ignore
36
+ */
37
+ export declare const FrakConfigContext: Context<FrakWalletSdkConfig | undefined>;
38
+
39
+ /**
40
+ * Simple config provider for the Frak Wallet SDK
41
+ *
42
+ * Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
43
+ *
44
+ * @group provider
45
+ *
46
+ * @param parameters
47
+ */
48
+ export declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): FunctionComponentElement<ProviderProps<FrakWalletSdkConfig | undefined>>;
49
+
50
+ /**
51
+ * Props to instantiate the Frak Wallet SDK configuration provider
52
+ *
53
+ * @group provider
54
+ */
55
+ export declare type FrakConfigProviderProps = {
56
+ /**
57
+ * The wanted Frak configuration
58
+ * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
59
+ */
60
+ config: FrakWalletSdkConfig;
61
+ };
62
+
63
+ /**
64
+ * The context that will keep the Frak Wallet SDK client
65
+ * @ignore
66
+ */
67
+ export declare const FrakIFrameClientContext: Context<FrakClient | undefined>;
68
+
69
+ /**
70
+ * Props to instantiate the Frak Wallet SDK configuration provider
71
+ *
72
+ * @group provider
73
+ */
74
+ export declare type FrakIFrameClientProps = {
75
+ config: FrakWalletSdkConfig;
76
+ };
77
+
78
+ /**
79
+ * IFrame client provider for the Frak Wallet SDK
80
+ * It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
81
+ *
82
+ * @group provider
83
+ *
84
+ * @remarks
85
+ * This provider must be wrapped within a {@link FrakConfigProvider} to work properly
86
+ *
87
+ * @param args
88
+ * @param args.style - Some custom styles to apply to the iFrame
89
+ * @param args.children - Descedant components that will have access to the Frak Client
90
+ */
91
+ export declare function FrakIFrameClientProvider({ style, children, }: {
92
+ style?: CSSProperties;
93
+ children?: ReactNode;
94
+ }): FunctionComponentElement<FragmentProps>;
95
+
96
+ /** @ignore */
97
+ declare type MutationOptions<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
98
+
99
+ /** @ignore */
100
+ declare type MutationOptions_2 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
101
+
102
+ /** @ignore */
103
+ declare type MutationOptions_3 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
104
+
105
+ /** @ignore */
106
+ declare type MutationOptions_4 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
107
+
108
+ /** @inline */
109
+ declare type MutationOptions_5 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
110
+
111
+ /** @ignore */
112
+ declare type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
113
+
114
+ /**
115
+ * Hook that return a mutation helping to display a modal to the user
116
+ *
117
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
118
+ *
119
+ * @param args
120
+ *
121
+ * @typeParam T
122
+ * The modal steps types to display (the result will correspond to the steps types asked in params)
123
+ * An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
124
+ * If not provided, it will default to a generic array of `ModalStepTypes`
125
+ *
126
+ * @group hooks
127
+ *
128
+ * @returns
129
+ * The mutation hook wrapping the `displayModal()` action
130
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.DisplayModalParamsType | `DisplayModalParamsType<T>`}, with type params `T` being the modal steps types to display
131
+ * The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
132
+ *
133
+ * @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
134
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
135
+ */
136
+ export declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): UseMutationResult< { [K in T[number]["key"]]: Extract<T[number], {
137
+ key: K;
138
+ }>["returns"]; }, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
139
+
140
+ /** @inline */
141
+ declare interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
142
+ /**
143
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
144
+ */
145
+ mutations?: MutationOptions<T>;
146
+ }
147
+
148
+ /**
149
+ * Get the current Frak client
150
+ *
151
+ * @group hooks
152
+ */
153
+ export declare function useFrakClient(): FrakClient | undefined;
154
+
155
+ /**
156
+ * Get the current Frak config
157
+ * @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
158
+ * @group hooks
159
+ *
160
+ * @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
161
+ * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
162
+ */
163
+ export declare function useFrakConfig(): FrakWalletSdkConfig;
164
+
165
+ /**
166
+ * Hook that return a query helping to get the current product information
167
+ *
168
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} action
169
+ *
170
+ * @param args
171
+ *
172
+ * @group hooks
173
+ *
174
+ * @returns
175
+ * The query hook wrapping the `getProductInformation()` action
176
+ * The `data` result is a {@link @frak-labs/core-sdk!index.GetProductInformationReturnType | `GetProductInformationReturnType`}
177
+ *
178
+ * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the underlying action
179
+ * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
180
+ */
181
+ export declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): UseQueryResult<undefined, FrakRpcError<undefined>>;
182
+
183
+ /** @inline */
184
+ declare interface UseGetProductInformationParams {
185
+ /**
186
+ * Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
187
+ */
188
+ query?: QueryOptions;
189
+ }
190
+
191
+ /**
192
+ * Hook that return a mutation helping to open the SSO page
193
+ *
194
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
195
+ *
196
+ * @param args
197
+ *
198
+ * @group hooks
199
+ *
200
+ * @returns
201
+ * The mutation hook wrapping the `openSso()` action
202
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
203
+ * The mutation doesn't output any value
204
+ *
205
+ * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
206
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
207
+ */
208
+ export declare function useOpenSso({ mutations }?: UseOpenSsoParams): UseMutationResult< {
209
+ wallet?: Hex;
210
+ }, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
211
+
212
+ /** @inline */
213
+ declare interface UseOpenSsoParams {
214
+ /**
215
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
216
+ */
217
+ mutations?: MutationOptions_2;
218
+ }
219
+
220
+ /**
221
+ * Hook that generates SSO URL for popup flow
222
+ *
223
+ * This is a **synchronous** hook (no async calls) that generates the SSO URL
224
+ * client-side without communicating with the wallet iframe.
225
+ *
226
+ * @param params - SSO parameters for URL generation
227
+ *
228
+ * @group hooks
229
+ *
230
+ * @returns
231
+ * Object containing:
232
+ * - `ssoUrl`: Generated SSO URL (or undefined if client not ready)
233
+ * - `isReady`: Boolean indicating if URL is available
234
+ *
235
+ * @example
236
+ * ```tsx
237
+ * function MyComponent() {
238
+ * const { data } = usePrepareSso({
239
+ * metadata: { logoUrl: "..." },
240
+ * directExit: true
241
+ * });
242
+ *
243
+ * const handleClick = () => {
244
+ * if (ssoUrl) {
245
+ * window.open(data?.ssoUrl, "_blank");
246
+ * }
247
+ * };
248
+ *
249
+ * return <button onClick={handleClick} disabled={!isReady}>Login</button>;
250
+ * }
251
+ * ```
252
+ *
253
+ * @see {@link @frak-labs/core-sdk!actions.prepareSso | `prepareSso()`} for the underlying action
254
+ * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for the recommended high-level API
255
+ */
256
+ export declare function usePrepareSso(params: PrepareSsoParamsType): UseQueryResult< {
257
+ ssoUrl: string;
258
+ }, Error>;
259
+
260
+ /**
261
+ * Helper hook to automatically submit a referral interaction when detected
262
+ *
263
+ * @group hooks
264
+ *
265
+ * @param args
266
+ * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
267
+ * @param args.modalConfig - The modal configuration to display if the user is not logged in
268
+ * @param args.options - Some options for the referral interaction
269
+ *
270
+ * @returns The resulting referral state, or a potential error
271
+ *
272
+ * @description This function will automatically handle the referral interaction process
273
+ *
274
+ * @see {@link @frak-labs/core-sdk!actions.processReferral | `processReferral()`} for more details on the automatic referral handling process
275
+ */
276
+ export declare function useReferralInteraction({ productId, modalConfig, options, }?: {
277
+ productId?: Hex;
278
+ modalConfig?: DisplayEmbeddedWalletParamsType;
279
+ options?: ProcessReferralOptions;
280
+ }): Error | ("error" | "no-referrer" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "self-referral");
281
+
282
+ /**
283
+ * Hook that return a mutation helping to send a user interaction
284
+ *
285
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} action
286
+ *
287
+ * @param args
288
+ *
289
+ * @group hooks
290
+ *
291
+ * @returns
292
+ * The mutation hook wrapping the `sendInteraction()` action
293
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.SendInteractionParamsType | `SendInteractionParamsType`}
294
+ * The `data` result is a {@link @frak-labs/core-sdk!index.SendInteractionReturnType | `SendInteractionReturnType`}
295
+ *
296
+ * @see {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} for more info about the underlying action
297
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
298
+ */
299
+ export declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): UseMutationResult< {
300
+ delegationId: string;
301
+ }, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
302
+
303
+ /** @inline */
304
+ declare interface UseSendInteractionParams {
305
+ /**
306
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
307
+ */
308
+ mutations?: MutationOptions_3;
309
+ }
310
+
311
+ /**
312
+ * Hook that return a mutation helping to send a transaction
313
+ *
314
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
315
+ *
316
+ * @param args
317
+ *
318
+ * @group hooks
319
+ *
320
+ * @returns
321
+ * The mutation hook wrapping the `sendTransaction()` action
322
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
323
+ * The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
324
+ *
325
+ * @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
326
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
327
+ */
328
+ export declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): UseMutationResult< {
329
+ hash: Hex;
330
+ }, FrakRpcError<undefined>, SendTransactionParams, unknown>;
331
+
332
+ /** @inline */
333
+ declare interface UseSendTransactionParams {
334
+ /**
335
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
336
+ */
337
+ mutations?: MutationOptions_4;
338
+ }
339
+
340
+ /**
341
+ * Hook that return a mutation helping to send perform a SIWE authentication
342
+ *
343
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
344
+ *
345
+ * @param args
346
+ *
347
+ * @group hooks
348
+ *
349
+ * @returns
350
+ * The mutation hook wrapping the `siweAuthenticate()` action
351
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
352
+ * The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
353
+ *
354
+ * @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
355
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
356
+ */
357
+ export declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): UseMutationResult< {
358
+ signature: Hex;
359
+ message: string;
360
+ }, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
361
+
362
+ /** @ignore */
363
+ declare interface UseSiweAuthenticateParams {
364
+ /**
365
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
366
+ */
367
+ mutations?: MutationOptions_5;
368
+ }
369
+
370
+ /**
371
+ * Hook that return a query helping to get the current wallet status.
372
+ *
373
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
374
+ *
375
+ * @group hooks
376
+ *
377
+ * @returns
378
+ * The query hook wrapping the `watchWalletStatus()` action
379
+ * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
380
+ *
381
+ * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
382
+ * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
383
+ */
384
+ export declare function useWalletStatus(): UseQueryResult<WalletStatusReturnType, Error>;
385
+
386
+ export { }