@frak-labs/react-sdk 1.0.2-beta.9985efe7 → 1.0.2-beta.9d4f564a
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/package.json +4 -4
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -467
- package/dist/index.d.ts +0 -467
- package/dist/index.js +0 -1
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "1.0.2-beta.
|
|
14
|
+
"version": "1.0.2-beta.9d4f564a",
|
|
15
15
|
"description": "React SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"publish": "echo 'Publishing react...'"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@frak-labs/core-sdk": "1.0.2-beta.
|
|
71
|
-
"@frak-labs/frame-connector": "0.2.0-beta.
|
|
70
|
+
"@frak-labs/core-sdk": "1.0.2-beta.9d4f564a",
|
|
71
|
+
"@frak-labs/frame-connector": "0.2.0-beta.9d4f564a"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"viem": "^2.x",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@vitest/ui": "^4.1.0",
|
|
92
92
|
"jsdom": "^29.0.0",
|
|
93
93
|
"react": "^19.2.4",
|
|
94
|
-
"tsdown": "^0.
|
|
94
|
+
"tsdown": "^0.22.0",
|
|
95
95
|
"typescript": "^6.0.2",
|
|
96
96
|
"viem": "^2.47.16",
|
|
97
97
|
"vitest": "^4.1.4"
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@frak-labs/core-sdk/actions`),t=require(`@frak-labs/frame-connector`),n=require(`@tanstack/react-query`),r=require(`react`),i=require(`@frak-labs/core-sdk`);const a=(0,r.createContext)(void 0);function o(e){let{children:t,config:n}=e;return(0,r.createElement)(a.Provider,{value:{...n,walletUrl:n.walletUrl??`https://wallet.frak.id`,domain:n.domain??(typeof window<`u`?window?.location?.host:void 0)??`not-found`}},t)}const s=(0,r.createContext)(void 0);function c({style:e,children:t}){let n=p(),[a,o]=(0,r.useState)(void 0);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(`iframe`,{...i.baseIframeProps,src:`${n.walletUrl}/listener`,style:e??i.baseIframeProps.style,ref:e=>{!e||a||o((0,i.createIFrameFrakClient)({iframe:e,config:n}))}}),(0,r.createElement)(s.Provider,{value:a},t))}function l(){return(0,r.useContext)(s)}function u({options:i}={}){let a=l(),{data:o,error:s,status:c}=(0,n.useQuery)({queryKey:[`frak-sdk`,`auto-referral-interaction`],queryFn:async()=>{if(!a)throw new t.ClientNotFound;return await(0,e.referralInteraction)(a,{options:i})??null},enabled:!!a,staleTime:1/0});return(0,r.useMemo)(()=>c===`pending`?`processing`:c===`error`?s:o||`idle`,[o,c,s])}function d({mutations:r}={}){let i=l();return(0,n.useMutation)({...r,mutationKey:[`frak-sdk`,`display-modal`],mutationFn:async({placement:n,...r})=>{if(!i)throw new t.ClientNotFound;return(0,e.displayModal)(i,r,n)}})}function f({mutations:r}={}){let i=l();return(0,n.useMutation)({...r,mutationKey:[`frak-sdk`,`display-sharing-page`],mutationFn:async({placement:n,...r})=>{if(!i)throw new t.ClientNotFound;return(0,e.displaySharingPage)(i,r,n)}})}function p(){let e=(0,r.useContext)(a);if(!e)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`Frak config not found`);return e}function m({query:r,cacheTime:i}={}){let a=l();return(0,n.useQuery)({...r,queryKey:[`frak-sdk`,`get-merchant-information`],queryFn:async()=>{if(!a)throw new t.ClientNotFound;return(0,e.getMerchantInformation)(a,{cacheTime:i})}})}function h({query:r,cacheTime:i}={}){let a=l();return(0,n.useQuery)({...r,queryKey:[`frak-sdk`,`get-merge-token`],queryFn:async()=>{if(!a)throw new t.ClientNotFound;return(0,e.getMergeToken)(a,{cacheTime:i})}})}function g({query:r,cacheTime:i}={}){let a=l();return(0,n.useQuery)({...r,queryKey:[`frak-sdk`,`get-user-referral-status`],queryFn:async()=>{if(!a)throw new t.ClientNotFound;return(0,e.getUserReferralStatus)(a,{cacheTime:i})}})}function _({mutations:r}={}){let i=l();return(0,n.useMutation)({...r,mutationKey:[`frak-sdk`,`open-sso`],mutationFn:async n=>{if(!i)throw new t.ClientNotFound;return(0,e.openSso)(i,n)}})}function v(r){let i=l();return(0,n.useQuery)({queryKey:[`frak-sdk`,`prepare-sso`,r],queryFn:async()=>{if(!i)throw new t.ClientNotFound;return(0,e.prepareSso)(i,r)}})}function y({mutations:r}={}){let i=l();return(0,n.useMutation)({...r,mutationKey:[`frak-sdk`,`send-transaction`],mutationFn:async n=>{if(!i)throw new t.ClientNotFound;return(0,e.sendTransaction)(i,n)}})}function b(){let r=l();return(0,n.useQuery)({queryKey:[`frak-sdk`,`setup-referral`],queryFn:async()=>{if(!r)throw new t.ClientNotFound;return await(0,e.setupReferral)(r),null},enabled:!!r,staleTime:1/0})}function x({mutations:r}={}){let i=l();return(0,n.useMutation)({...r,mutationKey:[`frak-sdk`,`siwe-authenticate`,i?.config.domain??`no-domain`],mutationFn:async n=>{if(!i)throw new t.ClientNotFound;return(0,e.siweAuthenticate)(i,n)}})}function S(){let i=(0,n.useQueryClient)(),a=l(),o=(0,r.useCallback)(e=>{i.setQueryData([`frak-sdk`,`wallet-status-listener`],e)},[i]);return(0,n.useQuery)({gcTime:0,staleTime:0,queryKey:[`frak-sdk`,`wallet-status-listener`],queryFn:async()=>{if(!a)throw new t.ClientNotFound;return(0,e.watchWalletStatus)(a,o)},enabled:!!a})}exports.FrakConfigContext=a,exports.FrakConfigProvider=o,exports.FrakIFrameClientContext=s,exports.FrakIFrameClientProvider=c,exports.useDisplayModal=d,exports.useDisplaySharingPage=f,exports.useFrakClient=l,exports.useFrakConfig=p,exports.useGetMerchantInformation=m,exports.useGetMergeToken=h,exports.useGetUserReferralStatus=g,exports.useOpenSso=_,exports.usePrepareSso=v,exports.useReferralInteraction=u,exports.useSendTransactionAction=y,exports.useSetupReferral=b,exports.useSiweAuthenticate=x,exports.useWalletStatus=S;
|
package/dist/index.d.cts
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
import { ProcessReferralOptions, SendTransactionParams, SiweAuthenticateModalParams } from "@frak-labs/core-sdk/actions";
|
|
2
|
-
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
3
|
-
import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
-
import * as _$_frak_labs_core_sdk0 from "@frak-labs/core-sdk";
|
|
5
|
-
import { DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, FrakClient, FrakWalletSdkConfig, GetMerchantInformationReturnType, ModalRpcStepsResultType, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, SendTransactionReturnType, SiweAuthenticateReturnType, UserReferralStatusType, WalletStatusReturnType } from "@frak-labs/core-sdk";
|
|
6
|
-
import { FrakRpcError } from "@frak-labs/frame-connector";
|
|
7
|
-
import * as _$react from "react";
|
|
8
|
-
import { CSSProperties, PropsWithChildren, ReactNode } from "react";
|
|
9
|
-
|
|
10
|
-
//#region src/hook/helper/useReferralInteraction.d.ts
|
|
11
|
-
/**
|
|
12
|
-
* Helper hook to automatically submit a referral interaction when detected
|
|
13
|
-
*
|
|
14
|
-
* Runs once when the Frak client becomes available.
|
|
15
|
-
*
|
|
16
|
-
* @group hooks
|
|
17
|
-
*
|
|
18
|
-
* @param args
|
|
19
|
-
* @param args.options - Some options for the referral interaction
|
|
20
|
-
*
|
|
21
|
-
* @returns The resulting referral state, or a potential error
|
|
22
|
-
*
|
|
23
|
-
* @description This function will automatically handle the referral interaction process
|
|
24
|
-
*
|
|
25
|
-
* @see {@link @frak-labs/core-sdk!actions.referralInteraction | `referralInteraction()`} for more details on the automatic referral handling process
|
|
26
|
-
*/
|
|
27
|
-
declare function useReferralInteraction({
|
|
28
|
-
options
|
|
29
|
-
}?: {
|
|
30
|
-
options?: ProcessReferralOptions;
|
|
31
|
-
}): "processing" | Error | "idle" | "success" | "no-referrer" | "self-referral";
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/hook/useDisplayModal.d.ts
|
|
34
|
-
/** @ignore */
|
|
35
|
-
type MutationOptions$4<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T> & {
|
|
36
|
-
placement?: string;
|
|
37
|
-
}>, "mutationFn" | "mutationKey">;
|
|
38
|
-
/** @inline */
|
|
39
|
-
interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
|
|
40
|
-
/**
|
|
41
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
42
|
-
*/
|
|
43
|
-
mutations?: MutationOptions$4<T>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Hook that return a mutation helping to display a modal to the user
|
|
47
|
-
*
|
|
48
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
|
|
49
|
-
*
|
|
50
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
51
|
-
*
|
|
52
|
-
* @typeParam T
|
|
53
|
-
* The modal steps types to display (the result will correspond to the steps types asked in params)
|
|
54
|
-
* An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
|
|
55
|
-
* If not provided, it will default to a generic array of `ModalStepTypes`
|
|
56
|
-
*
|
|
57
|
-
* @group hooks
|
|
58
|
-
*
|
|
59
|
-
* @returns
|
|
60
|
-
* The mutation hook wrapping the `displayModal()` action
|
|
61
|
-
* 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
|
|
62
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
|
|
63
|
-
*
|
|
64
|
-
* @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
|
|
65
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
66
|
-
*/
|
|
67
|
-
declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({
|
|
68
|
-
mutations
|
|
69
|
-
}?: UseDisplayModalParams<T>): _$_tanstack_react_query0.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T> & {
|
|
70
|
-
placement?: string;
|
|
71
|
-
}, unknown>;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/hook/useDisplaySharingPage.d.ts
|
|
74
|
-
/** @ignore */
|
|
75
|
-
type MutationOptions$3 = Omit<UseMutationOptions<DisplaySharingPageResultType, FrakRpcError, DisplaySharingPageParamsType & {
|
|
76
|
-
placement?: string;
|
|
77
|
-
}>, "mutationFn" | "mutationKey">;
|
|
78
|
-
/** @inline */
|
|
79
|
-
interface UseDisplaySharingPageParams {
|
|
80
|
-
/**
|
|
81
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
82
|
-
*/
|
|
83
|
-
mutations?: MutationOptions$3;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Hook that return a mutation helping to display a sharing page to the user
|
|
87
|
-
*
|
|
88
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} action
|
|
89
|
-
*
|
|
90
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
91
|
-
*
|
|
92
|
-
* @group hooks
|
|
93
|
-
*
|
|
94
|
-
* @returns
|
|
95
|
-
* The mutation hook wrapping the `displaySharingPage()` action
|
|
96
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.DisplaySharingPageParamsType | `DisplaySharingPageParamsType`} with optional `placement`
|
|
97
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.DisplaySharingPageResultType | `DisplaySharingPageResultType`}
|
|
98
|
-
*
|
|
99
|
-
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the underlying action
|
|
100
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
101
|
-
*/
|
|
102
|
-
declare function useDisplaySharingPage({
|
|
103
|
-
mutations
|
|
104
|
-
}?: UseDisplaySharingPageParams): _$_tanstack_react_query0.UseMutationResult<DisplaySharingPageResultType, FrakRpcError<undefined>, DisplaySharingPageParamsType & {
|
|
105
|
-
placement?: string;
|
|
106
|
-
}, unknown>;
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/hook/useFrakClient.d.ts
|
|
109
|
-
/**
|
|
110
|
-
* Get the current Frak client
|
|
111
|
-
*
|
|
112
|
-
* @group hooks
|
|
113
|
-
*/
|
|
114
|
-
declare function useFrakClient(): _$_frak_labs_core_sdk0.FrakClient | undefined;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/hook/useFrakConfig.d.ts
|
|
117
|
-
/**
|
|
118
|
-
* Get the current Frak config
|
|
119
|
-
* @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
|
|
120
|
-
* @group hooks
|
|
121
|
-
*
|
|
122
|
-
* @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
|
|
123
|
-
* @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
|
|
124
|
-
*/
|
|
125
|
-
declare function useFrakConfig(): _$_frak_labs_core_sdk0.FrakWalletSdkConfig;
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/hook/useGetMerchantInformation.d.ts
|
|
128
|
-
/** @ignore */
|
|
129
|
-
type QueryOptions$2 = Omit<UseQueryOptions<GetMerchantInformationReturnType, FrakRpcError, GetMerchantInformationReturnType>, "queryKey" | "queryFn">;
|
|
130
|
-
/** @inline */
|
|
131
|
-
interface UseGetMerchantInformationParams {
|
|
132
|
-
/**
|
|
133
|
-
* Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
|
|
134
|
-
*/
|
|
135
|
-
query?: QueryOptions$2;
|
|
136
|
-
/**
|
|
137
|
-
* Time in ms to cache the result at the core SDK level. Default: 30_000 (30s). Set to 0 to disable.
|
|
138
|
-
*/
|
|
139
|
-
cacheTime?: number;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Hook that return a query helping to get the current merchant information
|
|
143
|
-
*
|
|
144
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} action
|
|
145
|
-
*
|
|
146
|
-
* @param args - Optional config object with `query` for customizing the underlying {@link @tanstack/react-query!useQuery | `useQuery()`}
|
|
147
|
-
*
|
|
148
|
-
* @group hooks
|
|
149
|
-
*
|
|
150
|
-
* @returns
|
|
151
|
-
* The query hook wrapping the `getMerchantInformation()` action
|
|
152
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`}
|
|
153
|
-
*
|
|
154
|
-
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the underlying action
|
|
155
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
|
|
156
|
-
*/
|
|
157
|
-
declare function useGetMerchantInformation({
|
|
158
|
-
query,
|
|
159
|
-
cacheTime
|
|
160
|
-
}?: UseGetMerchantInformationParams): _$_tanstack_react_query0.UseQueryResult<GetMerchantInformationReturnType, FrakRpcError<undefined>>;
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/hook/useGetMergeToken.d.ts
|
|
163
|
-
/** @ignore */
|
|
164
|
-
type QueryOptions$1 = Omit<UseQueryOptions<string | null, FrakRpcError, string | null>, "queryKey" | "queryFn">;
|
|
165
|
-
/** @inline */
|
|
166
|
-
interface UseGetMergeTokenParams {
|
|
167
|
-
/**
|
|
168
|
-
* Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
|
|
169
|
-
*/
|
|
170
|
-
query?: QueryOptions$1;
|
|
171
|
-
/**
|
|
172
|
-
* Time in ms to cache the result at the core SDK level. Default: 30_000 (30s). Set to 0 to disable.
|
|
173
|
-
*/
|
|
174
|
-
cacheTime?: number;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Hook that return a query to fetch a merge token for the current anonymous identity
|
|
178
|
-
*
|
|
179
|
-
* Used by in-app browser redirect flows to preserve identity
|
|
180
|
-
* when switching from a WebView to the system browser.
|
|
181
|
-
*
|
|
182
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getMergeToken | `getMergeToken()`} action
|
|
183
|
-
*
|
|
184
|
-
* @param args - Optional config object with `query` for customizing the underlying {@link @tanstack/react-query!useQuery | `useQuery()`}
|
|
185
|
-
*
|
|
186
|
-
* @group hooks
|
|
187
|
-
*
|
|
188
|
-
* @returns
|
|
189
|
-
* The query hook wrapping the `getMergeToken()` action
|
|
190
|
-
* The `data` result is a `string | null`
|
|
191
|
-
*
|
|
192
|
-
* @see {@link @frak-labs/core-sdk!actions.getMergeToken | `getMergeToken()`} for more info about the underlying action
|
|
193
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
|
|
194
|
-
*/
|
|
195
|
-
declare function useGetMergeToken({
|
|
196
|
-
query,
|
|
197
|
-
cacheTime
|
|
198
|
-
}?: UseGetMergeTokenParams): _$_tanstack_react_query0.UseQueryResult<string | null, FrakRpcError<undefined>>;
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/hook/useGetUserReferralStatus.d.ts
|
|
201
|
-
/** @ignore */
|
|
202
|
-
type QueryOptions = Omit<UseQueryOptions<UserReferralStatusType | null, FrakRpcError, UserReferralStatusType | null>, "queryKey" | "queryFn">;
|
|
203
|
-
/** @inline */
|
|
204
|
-
interface UseGetUserReferralStatusParams {
|
|
205
|
-
/**
|
|
206
|
-
* Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
|
|
207
|
-
*/
|
|
208
|
-
query?: QueryOptions;
|
|
209
|
-
/**
|
|
210
|
-
* Time in ms to cache the result at the core SDK level. Default: 30_000 (30s). Set to 0 to disable.
|
|
211
|
-
*/
|
|
212
|
-
cacheTime?: number;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Hook that return a query to fetch the current user's referral status on the current merchant
|
|
216
|
-
*
|
|
217
|
-
* Returns `null` when the user's identity cannot be resolved.
|
|
218
|
-
*
|
|
219
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getUserReferralStatus | `getUserReferralStatus()`} action
|
|
220
|
-
*
|
|
221
|
-
* @param args - Optional config object with `query` for customizing the underlying {@link @tanstack/react-query!useQuery | `useQuery()`}
|
|
222
|
-
*
|
|
223
|
-
* @group hooks
|
|
224
|
-
*
|
|
225
|
-
* @returns
|
|
226
|
-
* The query hook wrapping the `getUserReferralStatus()` action
|
|
227
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.UserReferralStatusType | `UserReferralStatusType`} or `null`
|
|
228
|
-
*
|
|
229
|
-
* @see {@link @frak-labs/core-sdk!actions.getUserReferralStatus | `getUserReferralStatus()`} for more info about the underlying action
|
|
230
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
|
|
231
|
-
*/
|
|
232
|
-
declare function useGetUserReferralStatus({
|
|
233
|
-
query,
|
|
234
|
-
cacheTime
|
|
235
|
-
}?: UseGetUserReferralStatusParams): _$_tanstack_react_query0.UseQueryResult<UserReferralStatusType | null, FrakRpcError<undefined>>;
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/hook/useOpenSso.d.ts
|
|
238
|
-
/** @ignore */
|
|
239
|
-
type MutationOptions$2 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
|
|
240
|
-
/** @inline */
|
|
241
|
-
interface UseOpenSsoParams {
|
|
242
|
-
/**
|
|
243
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
244
|
-
*/
|
|
245
|
-
mutations?: MutationOptions$2;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Hook that return a mutation helping to open the SSO page
|
|
249
|
-
*
|
|
250
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
|
|
251
|
-
*
|
|
252
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
253
|
-
*
|
|
254
|
-
* @group hooks
|
|
255
|
-
*
|
|
256
|
-
* @returns
|
|
257
|
-
* The mutation hook wrapping the `openSso()` action
|
|
258
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
|
|
259
|
-
* The mutation doesn't output any value
|
|
260
|
-
*
|
|
261
|
-
* @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
|
|
262
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
263
|
-
*/
|
|
264
|
-
declare function useOpenSso({
|
|
265
|
-
mutations
|
|
266
|
-
}?: UseOpenSsoParams): _$_tanstack_react_query0.UseMutationResult<OpenSsoReturnType, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/hook/usePrepareSso.d.ts
|
|
269
|
-
/**
|
|
270
|
-
* Hook that generates SSO URL for popup flow
|
|
271
|
-
*
|
|
272
|
-
* This is a **synchronous** hook (no async calls) that generates the SSO URL
|
|
273
|
-
* client-side without communicating with the wallet iframe.
|
|
274
|
-
*
|
|
275
|
-
* @param params - SSO parameters for URL generation
|
|
276
|
-
*
|
|
277
|
-
* @group hooks
|
|
278
|
-
*
|
|
279
|
-
* @returns
|
|
280
|
-
* Object containing:
|
|
281
|
-
* - `ssoUrl`: Generated SSO URL (or undefined if client not ready)
|
|
282
|
-
* - `isReady`: Boolean indicating if URL is available
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```tsx
|
|
286
|
-
* function MyComponent() {
|
|
287
|
-
* const { data } = usePrepareSso({
|
|
288
|
-
* metadata: { logoUrl: "..." },
|
|
289
|
-
* directExit: true
|
|
290
|
-
* });
|
|
291
|
-
*
|
|
292
|
-
* const handleClick = () => {
|
|
293
|
-
* if (ssoUrl) {
|
|
294
|
-
* window.open(data?.ssoUrl, "_blank");
|
|
295
|
-
* }
|
|
296
|
-
* };
|
|
297
|
-
*
|
|
298
|
-
* return <button onClick={handleClick} disabled={!isReady}>Login</button>;
|
|
299
|
-
* }
|
|
300
|
-
* ```
|
|
301
|
-
*
|
|
302
|
-
* @see {@link @frak-labs/core-sdk!actions.prepareSso | `prepareSso()`} for the underlying action
|
|
303
|
-
* @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for the recommended high-level API
|
|
304
|
-
*/
|
|
305
|
-
declare function usePrepareSso(params: PrepareSsoParamsType): _$_tanstack_react_query0.UseQueryResult<_$_frak_labs_core_sdk0.PrepareSsoReturnType, Error>;
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region src/hook/useSendTransaction.d.ts
|
|
308
|
-
/** @ignore */
|
|
309
|
-
type MutationOptions$1 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
|
|
310
|
-
/** @inline */
|
|
311
|
-
interface UseSendTransactionParams {
|
|
312
|
-
/**
|
|
313
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
314
|
-
*/
|
|
315
|
-
mutations?: MutationOptions$1;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Hook that return a mutation helping to send a transaction
|
|
319
|
-
*
|
|
320
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
|
|
321
|
-
*
|
|
322
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
323
|
-
*
|
|
324
|
-
* @group hooks
|
|
325
|
-
*
|
|
326
|
-
* @returns
|
|
327
|
-
* The mutation hook wrapping the `sendTransaction()` action
|
|
328
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
|
|
329
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
|
|
330
|
-
*
|
|
331
|
-
* @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
|
|
332
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
333
|
-
*/
|
|
334
|
-
declare function useSendTransactionAction({
|
|
335
|
-
mutations
|
|
336
|
-
}?: UseSendTransactionParams): _$_tanstack_react_query0.UseMutationResult<SendTransactionReturnType, FrakRpcError<undefined>, SendTransactionParams, unknown>;
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/hook/useSetupReferral.d.ts
|
|
339
|
-
/**
|
|
340
|
-
* Hook that automatically processes referral context and emits a DOM event on success
|
|
341
|
-
*
|
|
342
|
-
* Runs once when the Frak client becomes available. Fire-and-forget — the referral
|
|
343
|
-
* result is tracked via a `"frak:referral-success"` DOM event on `window`, not via
|
|
344
|
-
* the returned query data.
|
|
345
|
-
*
|
|
346
|
-
* @group hooks
|
|
347
|
-
*
|
|
348
|
-
* @returns The query handle (data is not meaningful — listen for `REFERRAL_SUCCESS_EVENT` on `window` instead)
|
|
349
|
-
*
|
|
350
|
-
* @see {@link @frak-labs/core-sdk!actions.setupReferral | `setupReferral()`} for more info about the underlying action
|
|
351
|
-
* @see {@link @frak-labs/core-sdk!actions.REFERRAL_SUCCESS_EVENT | `REFERRAL_SUCCESS_EVENT`} for the event name constant
|
|
352
|
-
*/
|
|
353
|
-
declare function useSetupReferral(): _$_tanstack_react_query0.UseQueryResult<null, Error>;
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/hook/useSiweAuthenticate.d.ts
|
|
356
|
-
/** @inline */
|
|
357
|
-
type MutationOptions = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
|
|
358
|
-
/** @ignore */
|
|
359
|
-
interface UseSiweAuthenticateParams {
|
|
360
|
-
/**
|
|
361
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
362
|
-
*/
|
|
363
|
-
mutations?: MutationOptions;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Hook that return a mutation helping to send perform a SIWE authentication
|
|
367
|
-
*
|
|
368
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} action
|
|
369
|
-
*
|
|
370
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
371
|
-
*
|
|
372
|
-
* @group hooks
|
|
373
|
-
*
|
|
374
|
-
* @returns
|
|
375
|
-
* The mutation hook wrapping the `siweAuthenticate()` action
|
|
376
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
|
|
377
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
|
|
378
|
-
*
|
|
379
|
-
* @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
|
|
380
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
381
|
-
*/
|
|
382
|
-
declare function useSiweAuthenticate({
|
|
383
|
-
mutations
|
|
384
|
-
}?: UseSiweAuthenticateParams): _$_tanstack_react_query0.UseMutationResult<SiweAuthenticateReturnType, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region src/hook/useWalletStatus.d.ts
|
|
387
|
-
/**
|
|
388
|
-
* Hook that return a query helping to get the current wallet status.
|
|
389
|
-
*
|
|
390
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
|
|
391
|
-
*
|
|
392
|
-
* @group hooks
|
|
393
|
-
*
|
|
394
|
-
* @returns
|
|
395
|
-
* The query hook wrapping the `watchWalletStatus()` action
|
|
396
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
|
|
397
|
-
*
|
|
398
|
-
* @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
|
|
399
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
|
|
400
|
-
*/
|
|
401
|
-
declare function useWalletStatus(): _$_tanstack_react_query0.UseQueryResult<WalletStatusReturnType, Error>;
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/provider/FrakConfigProvider.d.ts
|
|
404
|
-
/**
|
|
405
|
-
* The context that will keep the Frak Wallet SDK configuration
|
|
406
|
-
* @ignore
|
|
407
|
-
*/
|
|
408
|
-
declare const FrakConfigContext: _$react.Context<FrakWalletSdkConfig | undefined>;
|
|
409
|
-
/**
|
|
410
|
-
* Props to instantiate the Frak Wallet SDK configuration provider
|
|
411
|
-
*
|
|
412
|
-
* @group provider
|
|
413
|
-
*/
|
|
414
|
-
type FrakConfigProviderProps = {
|
|
415
|
-
/**
|
|
416
|
-
* The wanted Frak configuration
|
|
417
|
-
* @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
|
|
418
|
-
*/
|
|
419
|
-
config: FrakWalletSdkConfig;
|
|
420
|
-
};
|
|
421
|
-
/**
|
|
422
|
-
* Simple config provider for the Frak Wallet SDK
|
|
423
|
-
*
|
|
424
|
-
* Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
|
|
425
|
-
*
|
|
426
|
-
* @group provider
|
|
427
|
-
*
|
|
428
|
-
* @param parameters
|
|
429
|
-
*/
|
|
430
|
-
declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): _$react.FunctionComponentElement<_$react.ProviderProps<FrakWalletSdkConfig | undefined>>;
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region src/provider/FrakIFrameClientProvider.d.ts
|
|
433
|
-
/**
|
|
434
|
-
* The context that will keep the Frak Wallet SDK client
|
|
435
|
-
* @ignore
|
|
436
|
-
*/
|
|
437
|
-
declare const FrakIFrameClientContext: _$react.Context<FrakClient | undefined>;
|
|
438
|
-
/**
|
|
439
|
-
* Props to instantiate the Frak Wallet SDK configuration provider
|
|
440
|
-
*
|
|
441
|
-
* @group provider
|
|
442
|
-
*/
|
|
443
|
-
type FrakIFrameClientProps = {
|
|
444
|
-
config: FrakWalletSdkConfig;
|
|
445
|
-
};
|
|
446
|
-
/**
|
|
447
|
-
* IFrame client provider for the Frak Wallet SDK
|
|
448
|
-
* It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
|
|
449
|
-
*
|
|
450
|
-
* @group provider
|
|
451
|
-
*
|
|
452
|
-
* @remarks
|
|
453
|
-
* This provider must be wrapped within a {@link FrakConfigProvider} to work properly
|
|
454
|
-
*
|
|
455
|
-
* @param args
|
|
456
|
-
* @param args.style - Some custom styles to apply to the iFrame
|
|
457
|
-
* @param args.children - Descedant components that will have access to the Frak Client
|
|
458
|
-
*/
|
|
459
|
-
declare function FrakIFrameClientProvider({
|
|
460
|
-
style,
|
|
461
|
-
children
|
|
462
|
-
}: {
|
|
463
|
-
style?: CSSProperties;
|
|
464
|
-
children?: ReactNode;
|
|
465
|
-
}): _$react.FunctionComponentElement<_$react.FragmentProps>;
|
|
466
|
-
//#endregion
|
|
467
|
-
export { FrakConfigContext, FrakConfigProvider, type FrakConfigProviderProps, FrakIFrameClientContext, type FrakIFrameClientProps, FrakIFrameClientProvider, useDisplayModal, useDisplaySharingPage, useFrakClient, useFrakConfig, useGetMerchantInformation, useGetMergeToken, useGetUserReferralStatus, useOpenSso, usePrepareSso, useReferralInteraction, useSendTransactionAction, useSetupReferral, useSiweAuthenticate, useWalletStatus };
|
package/dist/index.d.ts
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
import { ProcessReferralOptions, SendTransactionParams, SiweAuthenticateModalParams } from "@frak-labs/core-sdk/actions";
|
|
2
|
-
import { FrakRpcError } from "@frak-labs/frame-connector";
|
|
3
|
-
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
4
|
-
import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
5
|
-
import * as _$react from "react";
|
|
6
|
-
import { CSSProperties, PropsWithChildren, ReactNode } from "react";
|
|
7
|
-
import * as _$_frak_labs_core_sdk0 from "@frak-labs/core-sdk";
|
|
8
|
-
import { DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, FrakClient, FrakWalletSdkConfig, GetMerchantInformationReturnType, ModalRpcStepsResultType, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, SendTransactionReturnType, SiweAuthenticateReturnType, UserReferralStatusType, WalletStatusReturnType } from "@frak-labs/core-sdk";
|
|
9
|
-
|
|
10
|
-
//#region src/hook/helper/useReferralInteraction.d.ts
|
|
11
|
-
/**
|
|
12
|
-
* Helper hook to automatically submit a referral interaction when detected
|
|
13
|
-
*
|
|
14
|
-
* Runs once when the Frak client becomes available.
|
|
15
|
-
*
|
|
16
|
-
* @group hooks
|
|
17
|
-
*
|
|
18
|
-
* @param args
|
|
19
|
-
* @param args.options - Some options for the referral interaction
|
|
20
|
-
*
|
|
21
|
-
* @returns The resulting referral state, or a potential error
|
|
22
|
-
*
|
|
23
|
-
* @description This function will automatically handle the referral interaction process
|
|
24
|
-
*
|
|
25
|
-
* @see {@link @frak-labs/core-sdk!actions.referralInteraction | `referralInteraction()`} for more details on the automatic referral handling process
|
|
26
|
-
*/
|
|
27
|
-
declare function useReferralInteraction({
|
|
28
|
-
options
|
|
29
|
-
}?: {
|
|
30
|
-
options?: ProcessReferralOptions;
|
|
31
|
-
}): "processing" | Error | "idle" | "success" | "no-referrer" | "self-referral";
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/hook/useDisplayModal.d.ts
|
|
34
|
-
/** @ignore */
|
|
35
|
-
type MutationOptions$4<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T> & {
|
|
36
|
-
placement?: string;
|
|
37
|
-
}>, "mutationFn" | "mutationKey">;
|
|
38
|
-
/** @inline */
|
|
39
|
-
interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
|
|
40
|
-
/**
|
|
41
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
42
|
-
*/
|
|
43
|
-
mutations?: MutationOptions$4<T>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Hook that return a mutation helping to display a modal to the user
|
|
47
|
-
*
|
|
48
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
|
|
49
|
-
*
|
|
50
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
51
|
-
*
|
|
52
|
-
* @typeParam T
|
|
53
|
-
* The modal steps types to display (the result will correspond to the steps types asked in params)
|
|
54
|
-
* An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
|
|
55
|
-
* If not provided, it will default to a generic array of `ModalStepTypes`
|
|
56
|
-
*
|
|
57
|
-
* @group hooks
|
|
58
|
-
*
|
|
59
|
-
* @returns
|
|
60
|
-
* The mutation hook wrapping the `displayModal()` action
|
|
61
|
-
* 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
|
|
62
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
|
|
63
|
-
*
|
|
64
|
-
* @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
|
|
65
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
66
|
-
*/
|
|
67
|
-
declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({
|
|
68
|
-
mutations
|
|
69
|
-
}?: UseDisplayModalParams<T>): _$_tanstack_react_query0.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T> & {
|
|
70
|
-
placement?: string;
|
|
71
|
-
}, unknown>;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/hook/useDisplaySharingPage.d.ts
|
|
74
|
-
/** @ignore */
|
|
75
|
-
type MutationOptions$3 = Omit<UseMutationOptions<DisplaySharingPageResultType, FrakRpcError, DisplaySharingPageParamsType & {
|
|
76
|
-
placement?: string;
|
|
77
|
-
}>, "mutationFn" | "mutationKey">;
|
|
78
|
-
/** @inline */
|
|
79
|
-
interface UseDisplaySharingPageParams {
|
|
80
|
-
/**
|
|
81
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
82
|
-
*/
|
|
83
|
-
mutations?: MutationOptions$3;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Hook that return a mutation helping to display a sharing page to the user
|
|
87
|
-
*
|
|
88
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} action
|
|
89
|
-
*
|
|
90
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
91
|
-
*
|
|
92
|
-
* @group hooks
|
|
93
|
-
*
|
|
94
|
-
* @returns
|
|
95
|
-
* The mutation hook wrapping the `displaySharingPage()` action
|
|
96
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.DisplaySharingPageParamsType | `DisplaySharingPageParamsType`} with optional `placement`
|
|
97
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.DisplaySharingPageResultType | `DisplaySharingPageResultType`}
|
|
98
|
-
*
|
|
99
|
-
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the underlying action
|
|
100
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
101
|
-
*/
|
|
102
|
-
declare function useDisplaySharingPage({
|
|
103
|
-
mutations
|
|
104
|
-
}?: UseDisplaySharingPageParams): _$_tanstack_react_query0.UseMutationResult<DisplaySharingPageResultType, FrakRpcError<undefined>, DisplaySharingPageParamsType & {
|
|
105
|
-
placement?: string;
|
|
106
|
-
}, unknown>;
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/hook/useFrakClient.d.ts
|
|
109
|
-
/**
|
|
110
|
-
* Get the current Frak client
|
|
111
|
-
*
|
|
112
|
-
* @group hooks
|
|
113
|
-
*/
|
|
114
|
-
declare function useFrakClient(): _$_frak_labs_core_sdk0.FrakClient | undefined;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/hook/useFrakConfig.d.ts
|
|
117
|
-
/**
|
|
118
|
-
* Get the current Frak config
|
|
119
|
-
* @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
|
|
120
|
-
* @group hooks
|
|
121
|
-
*
|
|
122
|
-
* @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
|
|
123
|
-
* @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
|
|
124
|
-
*/
|
|
125
|
-
declare function useFrakConfig(): _$_frak_labs_core_sdk0.FrakWalletSdkConfig;
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/hook/useGetMerchantInformation.d.ts
|
|
128
|
-
/** @ignore */
|
|
129
|
-
type QueryOptions$2 = Omit<UseQueryOptions<GetMerchantInformationReturnType, FrakRpcError, GetMerchantInformationReturnType>, "queryKey" | "queryFn">;
|
|
130
|
-
/** @inline */
|
|
131
|
-
interface UseGetMerchantInformationParams {
|
|
132
|
-
/**
|
|
133
|
-
* Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
|
|
134
|
-
*/
|
|
135
|
-
query?: QueryOptions$2;
|
|
136
|
-
/**
|
|
137
|
-
* Time in ms to cache the result at the core SDK level. Default: 30_000 (30s). Set to 0 to disable.
|
|
138
|
-
*/
|
|
139
|
-
cacheTime?: number;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Hook that return a query helping to get the current merchant information
|
|
143
|
-
*
|
|
144
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} action
|
|
145
|
-
*
|
|
146
|
-
* @param args - Optional config object with `query` for customizing the underlying {@link @tanstack/react-query!useQuery | `useQuery()`}
|
|
147
|
-
*
|
|
148
|
-
* @group hooks
|
|
149
|
-
*
|
|
150
|
-
* @returns
|
|
151
|
-
* The query hook wrapping the `getMerchantInformation()` action
|
|
152
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`}
|
|
153
|
-
*
|
|
154
|
-
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the underlying action
|
|
155
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
|
|
156
|
-
*/
|
|
157
|
-
declare function useGetMerchantInformation({
|
|
158
|
-
query,
|
|
159
|
-
cacheTime
|
|
160
|
-
}?: UseGetMerchantInformationParams): _$_tanstack_react_query0.UseQueryResult<GetMerchantInformationReturnType, FrakRpcError<undefined>>;
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/hook/useGetMergeToken.d.ts
|
|
163
|
-
/** @ignore */
|
|
164
|
-
type QueryOptions$1 = Omit<UseQueryOptions<string | null, FrakRpcError, string | null>, "queryKey" | "queryFn">;
|
|
165
|
-
/** @inline */
|
|
166
|
-
interface UseGetMergeTokenParams {
|
|
167
|
-
/**
|
|
168
|
-
* Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
|
|
169
|
-
*/
|
|
170
|
-
query?: QueryOptions$1;
|
|
171
|
-
/**
|
|
172
|
-
* Time in ms to cache the result at the core SDK level. Default: 30_000 (30s). Set to 0 to disable.
|
|
173
|
-
*/
|
|
174
|
-
cacheTime?: number;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Hook that return a query to fetch a merge token for the current anonymous identity
|
|
178
|
-
*
|
|
179
|
-
* Used by in-app browser redirect flows to preserve identity
|
|
180
|
-
* when switching from a WebView to the system browser.
|
|
181
|
-
*
|
|
182
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getMergeToken | `getMergeToken()`} action
|
|
183
|
-
*
|
|
184
|
-
* @param args - Optional config object with `query` for customizing the underlying {@link @tanstack/react-query!useQuery | `useQuery()`}
|
|
185
|
-
*
|
|
186
|
-
* @group hooks
|
|
187
|
-
*
|
|
188
|
-
* @returns
|
|
189
|
-
* The query hook wrapping the `getMergeToken()` action
|
|
190
|
-
* The `data` result is a `string | null`
|
|
191
|
-
*
|
|
192
|
-
* @see {@link @frak-labs/core-sdk!actions.getMergeToken | `getMergeToken()`} for more info about the underlying action
|
|
193
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
|
|
194
|
-
*/
|
|
195
|
-
declare function useGetMergeToken({
|
|
196
|
-
query,
|
|
197
|
-
cacheTime
|
|
198
|
-
}?: UseGetMergeTokenParams): _$_tanstack_react_query0.UseQueryResult<string | null, FrakRpcError<undefined>>;
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/hook/useGetUserReferralStatus.d.ts
|
|
201
|
-
/** @ignore */
|
|
202
|
-
type QueryOptions = Omit<UseQueryOptions<UserReferralStatusType | null, FrakRpcError, UserReferralStatusType | null>, "queryKey" | "queryFn">;
|
|
203
|
-
/** @inline */
|
|
204
|
-
interface UseGetUserReferralStatusParams {
|
|
205
|
-
/**
|
|
206
|
-
* Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
|
|
207
|
-
*/
|
|
208
|
-
query?: QueryOptions;
|
|
209
|
-
/**
|
|
210
|
-
* Time in ms to cache the result at the core SDK level. Default: 30_000 (30s). Set to 0 to disable.
|
|
211
|
-
*/
|
|
212
|
-
cacheTime?: number;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Hook that return a query to fetch the current user's referral status on the current merchant
|
|
216
|
-
*
|
|
217
|
-
* Returns `null` when the user's identity cannot be resolved.
|
|
218
|
-
*
|
|
219
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getUserReferralStatus | `getUserReferralStatus()`} action
|
|
220
|
-
*
|
|
221
|
-
* @param args - Optional config object with `query` for customizing the underlying {@link @tanstack/react-query!useQuery | `useQuery()`}
|
|
222
|
-
*
|
|
223
|
-
* @group hooks
|
|
224
|
-
*
|
|
225
|
-
* @returns
|
|
226
|
-
* The query hook wrapping the `getUserReferralStatus()` action
|
|
227
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.UserReferralStatusType | `UserReferralStatusType`} or `null`
|
|
228
|
-
*
|
|
229
|
-
* @see {@link @frak-labs/core-sdk!actions.getUserReferralStatus | `getUserReferralStatus()`} for more info about the underlying action
|
|
230
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
|
|
231
|
-
*/
|
|
232
|
-
declare function useGetUserReferralStatus({
|
|
233
|
-
query,
|
|
234
|
-
cacheTime
|
|
235
|
-
}?: UseGetUserReferralStatusParams): _$_tanstack_react_query0.UseQueryResult<UserReferralStatusType | null, FrakRpcError<undefined>>;
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/hook/useOpenSso.d.ts
|
|
238
|
-
/** @ignore */
|
|
239
|
-
type MutationOptions$2 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
|
|
240
|
-
/** @inline */
|
|
241
|
-
interface UseOpenSsoParams {
|
|
242
|
-
/**
|
|
243
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
244
|
-
*/
|
|
245
|
-
mutations?: MutationOptions$2;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Hook that return a mutation helping to open the SSO page
|
|
249
|
-
*
|
|
250
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
|
|
251
|
-
*
|
|
252
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
253
|
-
*
|
|
254
|
-
* @group hooks
|
|
255
|
-
*
|
|
256
|
-
* @returns
|
|
257
|
-
* The mutation hook wrapping the `openSso()` action
|
|
258
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
|
|
259
|
-
* The mutation doesn't output any value
|
|
260
|
-
*
|
|
261
|
-
* @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
|
|
262
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
263
|
-
*/
|
|
264
|
-
declare function useOpenSso({
|
|
265
|
-
mutations
|
|
266
|
-
}?: UseOpenSsoParams): _$_tanstack_react_query0.UseMutationResult<OpenSsoReturnType, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/hook/usePrepareSso.d.ts
|
|
269
|
-
/**
|
|
270
|
-
* Hook that generates SSO URL for popup flow
|
|
271
|
-
*
|
|
272
|
-
* This is a **synchronous** hook (no async calls) that generates the SSO URL
|
|
273
|
-
* client-side without communicating with the wallet iframe.
|
|
274
|
-
*
|
|
275
|
-
* @param params - SSO parameters for URL generation
|
|
276
|
-
*
|
|
277
|
-
* @group hooks
|
|
278
|
-
*
|
|
279
|
-
* @returns
|
|
280
|
-
* Object containing:
|
|
281
|
-
* - `ssoUrl`: Generated SSO URL (or undefined if client not ready)
|
|
282
|
-
* - `isReady`: Boolean indicating if URL is available
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```tsx
|
|
286
|
-
* function MyComponent() {
|
|
287
|
-
* const { data } = usePrepareSso({
|
|
288
|
-
* metadata: { logoUrl: "..." },
|
|
289
|
-
* directExit: true
|
|
290
|
-
* });
|
|
291
|
-
*
|
|
292
|
-
* const handleClick = () => {
|
|
293
|
-
* if (ssoUrl) {
|
|
294
|
-
* window.open(data?.ssoUrl, "_blank");
|
|
295
|
-
* }
|
|
296
|
-
* };
|
|
297
|
-
*
|
|
298
|
-
* return <button onClick={handleClick} disabled={!isReady}>Login</button>;
|
|
299
|
-
* }
|
|
300
|
-
* ```
|
|
301
|
-
*
|
|
302
|
-
* @see {@link @frak-labs/core-sdk!actions.prepareSso | `prepareSso()`} for the underlying action
|
|
303
|
-
* @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for the recommended high-level API
|
|
304
|
-
*/
|
|
305
|
-
declare function usePrepareSso(params: PrepareSsoParamsType): _$_tanstack_react_query0.UseQueryResult<_$_frak_labs_core_sdk0.PrepareSsoReturnType, Error>;
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region src/hook/useSendTransaction.d.ts
|
|
308
|
-
/** @ignore */
|
|
309
|
-
type MutationOptions$1 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
|
|
310
|
-
/** @inline */
|
|
311
|
-
interface UseSendTransactionParams {
|
|
312
|
-
/**
|
|
313
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
314
|
-
*/
|
|
315
|
-
mutations?: MutationOptions$1;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Hook that return a mutation helping to send a transaction
|
|
319
|
-
*
|
|
320
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
|
|
321
|
-
*
|
|
322
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
323
|
-
*
|
|
324
|
-
* @group hooks
|
|
325
|
-
*
|
|
326
|
-
* @returns
|
|
327
|
-
* The mutation hook wrapping the `sendTransaction()` action
|
|
328
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
|
|
329
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
|
|
330
|
-
*
|
|
331
|
-
* @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
|
|
332
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
333
|
-
*/
|
|
334
|
-
declare function useSendTransactionAction({
|
|
335
|
-
mutations
|
|
336
|
-
}?: UseSendTransactionParams): _$_tanstack_react_query0.UseMutationResult<SendTransactionReturnType, FrakRpcError<undefined>, SendTransactionParams, unknown>;
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/hook/useSetupReferral.d.ts
|
|
339
|
-
/**
|
|
340
|
-
* Hook that automatically processes referral context and emits a DOM event on success
|
|
341
|
-
*
|
|
342
|
-
* Runs once when the Frak client becomes available. Fire-and-forget — the referral
|
|
343
|
-
* result is tracked via a `"frak:referral-success"` DOM event on `window`, not via
|
|
344
|
-
* the returned query data.
|
|
345
|
-
*
|
|
346
|
-
* @group hooks
|
|
347
|
-
*
|
|
348
|
-
* @returns The query handle (data is not meaningful — listen for `REFERRAL_SUCCESS_EVENT` on `window` instead)
|
|
349
|
-
*
|
|
350
|
-
* @see {@link @frak-labs/core-sdk!actions.setupReferral | `setupReferral()`} for more info about the underlying action
|
|
351
|
-
* @see {@link @frak-labs/core-sdk!actions.REFERRAL_SUCCESS_EVENT | `REFERRAL_SUCCESS_EVENT`} for the event name constant
|
|
352
|
-
*/
|
|
353
|
-
declare function useSetupReferral(): _$_tanstack_react_query0.UseQueryResult<null, Error>;
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/hook/useSiweAuthenticate.d.ts
|
|
356
|
-
/** @inline */
|
|
357
|
-
type MutationOptions = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
|
|
358
|
-
/** @ignore */
|
|
359
|
-
interface UseSiweAuthenticateParams {
|
|
360
|
-
/**
|
|
361
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
362
|
-
*/
|
|
363
|
-
mutations?: MutationOptions;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Hook that return a mutation helping to send perform a SIWE authentication
|
|
367
|
-
*
|
|
368
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} action
|
|
369
|
-
*
|
|
370
|
-
* @param args - Optional config object with `mutations` for customizing the underlying {@link @tanstack/react-query!useMutation | `useMutation()`}
|
|
371
|
-
*
|
|
372
|
-
* @group hooks
|
|
373
|
-
*
|
|
374
|
-
* @returns
|
|
375
|
-
* The mutation hook wrapping the `siweAuthenticate()` action
|
|
376
|
-
* The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
|
|
377
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
|
|
378
|
-
*
|
|
379
|
-
* @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
|
|
380
|
-
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
381
|
-
*/
|
|
382
|
-
declare function useSiweAuthenticate({
|
|
383
|
-
mutations
|
|
384
|
-
}?: UseSiweAuthenticateParams): _$_tanstack_react_query0.UseMutationResult<SiweAuthenticateReturnType, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region src/hook/useWalletStatus.d.ts
|
|
387
|
-
/**
|
|
388
|
-
* Hook that return a query helping to get the current wallet status.
|
|
389
|
-
*
|
|
390
|
-
* It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
|
|
391
|
-
*
|
|
392
|
-
* @group hooks
|
|
393
|
-
*
|
|
394
|
-
* @returns
|
|
395
|
-
* The query hook wrapping the `watchWalletStatus()` action
|
|
396
|
-
* The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
|
|
397
|
-
*
|
|
398
|
-
* @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
|
|
399
|
-
* @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
|
|
400
|
-
*/
|
|
401
|
-
declare function useWalletStatus(): _$_tanstack_react_query0.UseQueryResult<WalletStatusReturnType, Error>;
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/provider/FrakConfigProvider.d.ts
|
|
404
|
-
/**
|
|
405
|
-
* The context that will keep the Frak Wallet SDK configuration
|
|
406
|
-
* @ignore
|
|
407
|
-
*/
|
|
408
|
-
declare const FrakConfigContext: _$react.Context<FrakWalletSdkConfig | undefined>;
|
|
409
|
-
/**
|
|
410
|
-
* Props to instantiate the Frak Wallet SDK configuration provider
|
|
411
|
-
*
|
|
412
|
-
* @group provider
|
|
413
|
-
*/
|
|
414
|
-
type FrakConfigProviderProps = {
|
|
415
|
-
/**
|
|
416
|
-
* The wanted Frak configuration
|
|
417
|
-
* @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
|
|
418
|
-
*/
|
|
419
|
-
config: FrakWalletSdkConfig;
|
|
420
|
-
};
|
|
421
|
-
/**
|
|
422
|
-
* Simple config provider for the Frak Wallet SDK
|
|
423
|
-
*
|
|
424
|
-
* Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
|
|
425
|
-
*
|
|
426
|
-
* @group provider
|
|
427
|
-
*
|
|
428
|
-
* @param parameters
|
|
429
|
-
*/
|
|
430
|
-
declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): _$react.FunctionComponentElement<_$react.ProviderProps<FrakWalletSdkConfig | undefined>>;
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region src/provider/FrakIFrameClientProvider.d.ts
|
|
433
|
-
/**
|
|
434
|
-
* The context that will keep the Frak Wallet SDK client
|
|
435
|
-
* @ignore
|
|
436
|
-
*/
|
|
437
|
-
declare const FrakIFrameClientContext: _$react.Context<FrakClient | undefined>;
|
|
438
|
-
/**
|
|
439
|
-
* Props to instantiate the Frak Wallet SDK configuration provider
|
|
440
|
-
*
|
|
441
|
-
* @group provider
|
|
442
|
-
*/
|
|
443
|
-
type FrakIFrameClientProps = {
|
|
444
|
-
config: FrakWalletSdkConfig;
|
|
445
|
-
};
|
|
446
|
-
/**
|
|
447
|
-
* IFrame client provider for the Frak Wallet SDK
|
|
448
|
-
* It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
|
|
449
|
-
*
|
|
450
|
-
* @group provider
|
|
451
|
-
*
|
|
452
|
-
* @remarks
|
|
453
|
-
* This provider must be wrapped within a {@link FrakConfigProvider} to work properly
|
|
454
|
-
*
|
|
455
|
-
* @param args
|
|
456
|
-
* @param args.style - Some custom styles to apply to the iFrame
|
|
457
|
-
* @param args.children - Descedant components that will have access to the Frak Client
|
|
458
|
-
*/
|
|
459
|
-
declare function FrakIFrameClientProvider({
|
|
460
|
-
style,
|
|
461
|
-
children
|
|
462
|
-
}: {
|
|
463
|
-
style?: CSSProperties;
|
|
464
|
-
children?: ReactNode;
|
|
465
|
-
}): _$react.FunctionComponentElement<_$react.FragmentProps>;
|
|
466
|
-
//#endregion
|
|
467
|
-
export { FrakConfigContext, FrakConfigProvider, type FrakConfigProviderProps, FrakIFrameClientContext, type FrakIFrameClientProps, FrakIFrameClientProvider, useDisplayModal, useDisplaySharingPage, useFrakClient, useFrakConfig, useGetMerchantInformation, useGetMergeToken, useGetUserReferralStatus, useOpenSso, usePrepareSso, useReferralInteraction, useSendTransactionAction, useSetupReferral, useSiweAuthenticate, useWalletStatus };
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{displayModal as e,displaySharingPage as t,getMerchantInformation as n,getMergeToken as r,getUserReferralStatus as i,openSso as a,prepareSso as o,referralInteraction as s,sendTransaction as c,setupReferral as l,siweAuthenticate as u,watchWalletStatus as d}from"@frak-labs/core-sdk/actions";import{ClientNotFound as f,FrakRpcError as p,RpcErrorCodes as m}from"@frak-labs/frame-connector";import{useMutation as h,useQuery as g,useQueryClient as _}from"@tanstack/react-query";import{Fragment as v,createContext as y,createElement as b,useCallback as x,useContext as S,useMemo as C,useState as w}from"react";import{baseIframeProps as T,createIFrameFrakClient as E}from"@frak-labs/core-sdk";const D=y(void 0);function O(e){let{children:t,config:n}=e;return b(D.Provider,{value:{...n,walletUrl:n.walletUrl??`https://wallet.frak.id`,domain:n.domain??(typeof window<`u`?window?.location?.host:void 0)??`not-found`}},t)}const k=y(void 0);function A({style:e,children:t}){let n=F(),[r,i]=w(void 0);return b(v,null,b(`iframe`,{...T,src:`${n.walletUrl}/listener`,style:e??T.style,ref:e=>{!e||r||i(E({iframe:e,config:n}))}}),b(k.Provider,{value:r},t))}function j(){return S(k)}function M({options:e}={}){let t=j(),{data:n,error:r,status:i}=g({queryKey:[`frak-sdk`,`auto-referral-interaction`],queryFn:async()=>{if(!t)throw new f;return await s(t,{options:e})??null},enabled:!!t,staleTime:1/0});return C(()=>i===`pending`?`processing`:i===`error`?r:n||`idle`,[n,i,r])}function N({mutations:t}={}){let n=j();return h({...t,mutationKey:[`frak-sdk`,`display-modal`],mutationFn:async({placement:t,...r})=>{if(!n)throw new f;return e(n,r,t)}})}function P({mutations:e}={}){let n=j();return h({...e,mutationKey:[`frak-sdk`,`display-sharing-page`],mutationFn:async({placement:e,...r})=>{if(!n)throw new f;return t(n,r,e)}})}function F(){let e=S(D);if(!e)throw new p(m.configError,`Frak config not found`);return e}function I({query:e,cacheTime:t}={}){let r=j();return g({...e,queryKey:[`frak-sdk`,`get-merchant-information`],queryFn:async()=>{if(!r)throw new f;return n(r,{cacheTime:t})}})}function L({query:e,cacheTime:t}={}){let n=j();return g({...e,queryKey:[`frak-sdk`,`get-merge-token`],queryFn:async()=>{if(!n)throw new f;return r(n,{cacheTime:t})}})}function R({query:e,cacheTime:t}={}){let n=j();return g({...e,queryKey:[`frak-sdk`,`get-user-referral-status`],queryFn:async()=>{if(!n)throw new f;return i(n,{cacheTime:t})}})}function z({mutations:e}={}){let t=j();return h({...e,mutationKey:[`frak-sdk`,`open-sso`],mutationFn:async e=>{if(!t)throw new f;return a(t,e)}})}function B(e){let t=j();return g({queryKey:[`frak-sdk`,`prepare-sso`,e],queryFn:async()=>{if(!t)throw new f;return o(t,e)}})}function V({mutations:e}={}){let t=j();return h({...e,mutationKey:[`frak-sdk`,`send-transaction`],mutationFn:async e=>{if(!t)throw new f;return c(t,e)}})}function H(){let e=j();return g({queryKey:[`frak-sdk`,`setup-referral`],queryFn:async()=>{if(!e)throw new f;return await l(e),null},enabled:!!e,staleTime:1/0})}function U({mutations:e}={}){let t=j();return h({...e,mutationKey:[`frak-sdk`,`siwe-authenticate`,t?.config.domain??`no-domain`],mutationFn:async e=>{if(!t)throw new f;return u(t,e)}})}function W(){let e=_(),t=j(),n=x(t=>{e.setQueryData([`frak-sdk`,`wallet-status-listener`],t)},[e]);return g({gcTime:0,staleTime:0,queryKey:[`frak-sdk`,`wallet-status-listener`],queryFn:async()=>{if(!t)throw new f;return d(t,n)},enabled:!!t})}export{D as FrakConfigContext,O as FrakConfigProvider,k as FrakIFrameClientContext,A as FrakIFrameClientProvider,N as useDisplayModal,P as useDisplaySharingPage,j as useFrakClient,F as useFrakConfig,I as useGetMerchantInformation,L as useGetMergeToken,R as useGetUserReferralStatus,z as useOpenSso,B as usePrepareSso,M as useReferralInteraction,V as useSendTransactionAction,H as useSetupReferral,U as useSiweAuthenticate,W as useWalletStatus};
|