@frak-labs/react-sdk 0.1.0-beta.267778ad → 0.1.0-beta.278e9605

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/package.json +25 -15
  2. package/dist/hook/helper/useReferralInteraction.d.cts +0 -24
  3. package/dist/hook/helper/useReferralInteraction.d.ts +0 -24
  4. package/dist/hook/index.d.cts +0 -11
  5. package/dist/hook/index.d.ts +0 -11
  6. package/dist/hook/useDisplayModal.d.cts +0 -38
  7. package/dist/hook/useDisplayModal.d.ts +0 -38
  8. package/dist/hook/useFrakClient.d.cts +0 -6
  9. package/dist/hook/useFrakClient.d.ts +0 -6
  10. package/dist/hook/useFrakConfig.d.cts +0 -9
  11. package/dist/hook/useFrakConfig.d.ts +0 -9
  12. package/dist/hook/useGetProductInformation.d.cts +0 -30
  13. package/dist/hook/useGetProductInformation.d.ts +0 -30
  14. package/dist/hook/useOpenSso.d.cts +0 -33
  15. package/dist/hook/useOpenSso.d.ts +0 -33
  16. package/dist/hook/usePrepareSso.d.cts +0 -40
  17. package/dist/hook/usePrepareSso.d.ts +0 -40
  18. package/dist/hook/useSendInteraction.d.cts +0 -33
  19. package/dist/hook/useSendInteraction.d.ts +0 -33
  20. package/dist/hook/useSendTransaction.d.cts +0 -34
  21. package/dist/hook/useSendTransaction.d.ts +0 -34
  22. package/dist/hook/useSiweAuthenticate.d.cts +0 -35
  23. package/dist/hook/useSiweAuthenticate.d.ts +0 -35
  24. package/dist/hook/useWalletStatus.d.cts +0 -16
  25. package/dist/hook/useWalletStatus.d.ts +0 -16
  26. package/dist/hook/utils/useFrakContext.d.cts +0 -9
  27. package/dist/hook/utils/useFrakContext.d.ts +0 -9
  28. package/dist/hook/utils/useMounted.d.cts +0 -2
  29. package/dist/hook/utils/useMounted.d.ts +0 -2
  30. package/dist/hook/utils/useWindowLocation.d.cts +0 -8
  31. package/dist/hook/utils/useWindowLocation.d.ts +0 -8
  32. package/dist/index.cjs +0 -1
  33. package/dist/index.d.cts +0 -3
  34. package/dist/index.d.ts +0 -3
  35. package/dist/index.js +0 -1
  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/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.1.0-beta.267778ad",
14
+ "version": "0.1.0-beta.278e9605",
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",
@@ -39,6 +39,7 @@
39
39
  "types": "./dist/index.d.cts",
40
40
  "exports": {
41
41
  ".": {
42
+ "development": "./src/index.ts",
42
43
  "import": {
43
44
  "types": "./dist/index.d.ts",
44
45
  "default": "./dist/index.js"
@@ -54,10 +55,13 @@
54
55
  "format:check": "biome check .",
55
56
  "format": "biome check --write .",
56
57
  "clean": "rimraf dist",
57
- "build": "rslib build",
58
- "build:watch": "rslib build --watch",
58
+ "build": "tsdown",
59
+ "build:watch": "tsdown --watch",
59
60
  "check-exports": "attw --pack .",
60
61
  "typecheck": "tsc --noEmit",
62
+ "test": "vitest",
63
+ "test:ui": "vitest --ui",
64
+ "test:coverage": "vitest --coverage",
61
65
  "prepublish": "bun run lint && bun run build",
62
66
  "publish": "echo 'Publishing react...'"
63
67
  },
@@ -72,17 +76,23 @@
72
76
  },
73
77
  "devDependencies": {
74
78
  "@arethetypeswrong/cli": "^0.18.2",
75
- "@frak-labs/browserslist-config": "0.0.1",
76
- "@microsoft/api-extractor": "^7.52.8",
77
- "@rsbuild/plugin-react": "^1.3.2",
78
- "@rslib/core": "^0.9.2",
79
- "@types/node": "^24",
80
- "@types/react": "^19.1.8",
81
- "react": "^19.1.8",
79
+ "@frak-labs/dev-tooling": "0.0.0",
80
+ "@frak-labs/wallet-shared": "0.0.0",
81
+ "@tanstack/react-query": "^5.90.7",
82
+ "@testing-library/jest-dom": "^6.9.1",
83
+ "@testing-library/react": "^16.3.0",
84
+ "@testing-library/react-hooks": "^8.0.1",
85
+ "@testing-library/user-event": "^14.6.1",
86
+ "@types/jsdom": "^27.0.0",
87
+ "@types/node": "^24.10.0",
88
+ "@types/react": "19.2.2",
89
+ "@vitest/coverage-v8": "^4.0.8",
90
+ "@vitest/ui": "^4.0.8",
91
+ "jsdom": "^27.1.0",
92
+ "react": "^19.2.0",
93
+ "tsdown": "^0.16.1",
82
94
  "typescript": "^5",
83
- "@frak-labs/dev-tooling": "0.0.0"
84
- },
85
- "browserslist": [
86
- "extends @frak-labs/browserslist-config"
87
- ]
95
+ "viem": "^2.38.6",
96
+ "vitest": "^4.0.8"
97
+ }
88
98
  }
@@ -1,24 +0,0 @@
1
- import type { DisplayEmbeddedWalletParamsType } from "@frak-labs/core-sdk";
2
- import { type ProcessReferralOptions } from "@frak-labs/core-sdk/actions";
3
- import type { Hex } from "viem";
4
- /**
5
- * Helper hook to automatically submit a referral interaction when detected
6
- *
7
- * @group hooks
8
- *
9
- * @param args
10
- * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
11
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
12
- * @param args.options - Some options for the referral interaction
13
- *
14
- * @returns The resulting referral state, or a potential error
15
- *
16
- * @description This function will automatically handle the referral interaction process
17
- *
18
- * @see {@link @frak-labs/core-sdk!actions.processReferral | `processReferral()`} for more details on the automatic referral handling process
19
- */
20
- export declare function useReferralInteraction({ productId, modalConfig, options, }?: {
21
- productId?: Hex;
22
- modalConfig?: DisplayEmbeddedWalletParamsType;
23
- options?: ProcessReferralOptions;
24
- }): Error | ("error" | "no-referrer" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "self-referral");
@@ -1,24 +0,0 @@
1
- import type { DisplayEmbeddedWalletParamsType } from "@frak-labs/core-sdk";
2
- import { type ProcessReferralOptions } from "@frak-labs/core-sdk/actions";
3
- import type { Hex } from "viem";
4
- /**
5
- * Helper hook to automatically submit a referral interaction when detected
6
- *
7
- * @group hooks
8
- *
9
- * @param args
10
- * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
11
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
12
- * @param args.options - Some options for the referral interaction
13
- *
14
- * @returns The resulting referral state, or a potential error
15
- *
16
- * @description This function will automatically handle the referral interaction process
17
- *
18
- * @see {@link @frak-labs/core-sdk!actions.processReferral | `processReferral()`} for more details on the automatic referral handling process
19
- */
20
- export declare function useReferralInteraction({ productId, modalConfig, options, }?: {
21
- productId?: Hex;
22
- modalConfig?: DisplayEmbeddedWalletParamsType;
23
- options?: ProcessReferralOptions;
24
- }): Error | ("error" | "no-referrer" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "self-referral");
@@ -1,11 +0,0 @@
1
- export { useFrakConfig } from "./useFrakConfig";
2
- export { useFrakClient } from "./useFrakClient";
3
- export { useWalletStatus } from "./useWalletStatus";
4
- export { useSendTransactionAction } from "./useSendTransaction";
5
- export { useSiweAuthenticate } from "./useSiweAuthenticate";
6
- export { useReferralInteraction } from "./helper/useReferralInteraction";
7
- export { useSendInteraction } from "./useSendInteraction";
8
- export { useDisplayModal } from "./useDisplayModal";
9
- export { useOpenSso } from "./useOpenSso";
10
- export { usePrepareSso } from "./usePrepareSso";
11
- export { useGetProductInformation } from "./useGetProductInformation";
@@ -1,11 +0,0 @@
1
- export { useFrakConfig } from "./useFrakConfig";
2
- export { useFrakClient } from "./useFrakClient";
3
- export { useWalletStatus } from "./useWalletStatus";
4
- export { useSendTransactionAction } from "./useSendTransaction";
5
- export { useSiweAuthenticate } from "./useSiweAuthenticate";
6
- export { useReferralInteraction } from "./helper/useReferralInteraction";
7
- export { useSendInteraction } from "./useSendInteraction";
8
- export { useDisplayModal } from "./useDisplayModal";
9
- export { useOpenSso } from "./useOpenSso";
10
- export { usePrepareSso } from "./usePrepareSso";
11
- export { useGetProductInformation } from "./useGetProductInformation";
@@ -1,38 +0,0 @@
1
- import type { DisplayModalParamsType, ModalRpcStepsResultType, ModalStepTypes } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseMutationOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type MutationOptions<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
6
- /** @inline */
7
- interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
8
- /**
9
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
10
- */
11
- mutations?: MutationOptions<T>;
12
- }
13
- /**
14
- * Hook that return a mutation helping to display a modal to the user
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
17
- *
18
- * @param args
19
- *
20
- * @typeParam T
21
- * The modal steps types to display (the result will correspond to the steps types asked in params)
22
- * An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
23
- * If not provided, it will default to a generic array of `ModalStepTypes`
24
- *
25
- * @group hooks
26
- *
27
- * @returns
28
- * The mutation hook wrapping the `displayModal()` action
29
- * 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
30
- * The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
31
- *
32
- * @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
33
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
34
- */
35
- export declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): import("@tanstack/react-query").UseMutationResult<{ [K in T[number]["key"]]: Extract<T[number], {
36
- key: K;
37
- }>["returns"]; }, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
38
- export {};
@@ -1,38 +0,0 @@
1
- import type { DisplayModalParamsType, ModalRpcStepsResultType, ModalStepTypes } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseMutationOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type MutationOptions<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
6
- /** @inline */
7
- interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
8
- /**
9
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
10
- */
11
- mutations?: MutationOptions<T>;
12
- }
13
- /**
14
- * Hook that return a mutation helping to display a modal to the user
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
17
- *
18
- * @param args
19
- *
20
- * @typeParam T
21
- * The modal steps types to display (the result will correspond to the steps types asked in params)
22
- * An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
23
- * If not provided, it will default to a generic array of `ModalStepTypes`
24
- *
25
- * @group hooks
26
- *
27
- * @returns
28
- * The mutation hook wrapping the `displayModal()` action
29
- * 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
30
- * The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
31
- *
32
- * @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
33
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
34
- */
35
- export declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): import("@tanstack/react-query").UseMutationResult<{ [K in T[number]["key"]]: Extract<T[number], {
36
- key: K;
37
- }>["returns"]; }, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
38
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Get the current Frak client
3
- *
4
- * @group hooks
5
- */
6
- export declare function useFrakClient(): import("@frak-labs/core-sdk").FrakClient | undefined;
@@ -1,6 +0,0 @@
1
- /**
2
- * Get the current Frak client
3
- *
4
- * @group hooks
5
- */
6
- export declare function useFrakClient(): import("@frak-labs/core-sdk").FrakClient | undefined;
@@ -1,9 +0,0 @@
1
- /**
2
- * Get the current Frak config
3
- * @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
4
- * @group hooks
5
- *
6
- * @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
7
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
8
- */
9
- export declare function useFrakConfig(): import("@frak-labs/core-sdk").FrakWalletSdkConfig;
@@ -1,9 +0,0 @@
1
- /**
2
- * Get the current Frak config
3
- * @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
4
- * @group hooks
5
- *
6
- * @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
7
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
8
- */
9
- export declare function useFrakConfig(): import("@frak-labs/core-sdk").FrakWalletSdkConfig;
@@ -1,30 +0,0 @@
1
- import type { GetProductInformationReturnType } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseQueryOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
6
- /** @inline */
7
- interface UseGetProductInformationParams {
8
- /**
9
- * Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
10
- */
11
- query?: QueryOptions;
12
- }
13
- /**
14
- * Hook that return a query helping to get the current product information
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} action
17
- *
18
- * @param args
19
- *
20
- * @group hooks
21
- *
22
- * @returns
23
- * The query hook wrapping the `getProductInformation()` action
24
- * The `data` result is a {@link @frak-labs/core-sdk!index.GetProductInformationReturnType | `GetProductInformationReturnType`}
25
- *
26
- * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the underlying action
27
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
28
- */
29
- export declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): import("@tanstack/react-query").UseQueryResult<undefined, FrakRpcError<undefined>>;
30
- export {};
@@ -1,30 +0,0 @@
1
- import type { GetProductInformationReturnType } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseQueryOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
6
- /** @inline */
7
- interface UseGetProductInformationParams {
8
- /**
9
- * Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
10
- */
11
- query?: QueryOptions;
12
- }
13
- /**
14
- * Hook that return a query helping to get the current product information
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} action
17
- *
18
- * @param args
19
- *
20
- * @group hooks
21
- *
22
- * @returns
23
- * The query hook wrapping the `getProductInformation()` action
24
- * The `data` result is a {@link @frak-labs/core-sdk!index.GetProductInformationReturnType | `GetProductInformationReturnType`}
25
- *
26
- * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the underlying action
27
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
28
- */
29
- export declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): import("@tanstack/react-query").UseQueryResult<undefined, FrakRpcError<undefined>>;
30
- export {};
@@ -1,33 +0,0 @@
1
- import type { OpenSsoParamsType, OpenSsoReturnType } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseMutationOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type MutationOptions = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
6
- /** @inline */
7
- interface UseOpenSsoParams {
8
- /**
9
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
10
- */
11
- mutations?: MutationOptions;
12
- }
13
- /**
14
- * Hook that return a mutation helping to open the SSO page
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
17
- *
18
- * @param args
19
- *
20
- * @group hooks
21
- *
22
- * @returns
23
- * The mutation hook wrapping the `openSso()` action
24
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
25
- * The mutation doesn't output any value
26
- *
27
- * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
28
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
29
- */
30
- export declare function useOpenSso({ mutations }?: UseOpenSsoParams): import("@tanstack/react-query").UseMutationResult<{
31
- wallet?: import("viem").Hex;
32
- }, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
33
- export {};
@@ -1,33 +0,0 @@
1
- import type { OpenSsoParamsType, OpenSsoReturnType } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseMutationOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type MutationOptions = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
6
- /** @inline */
7
- interface UseOpenSsoParams {
8
- /**
9
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
10
- */
11
- mutations?: MutationOptions;
12
- }
13
- /**
14
- * Hook that return a mutation helping to open the SSO page
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
17
- *
18
- * @param args
19
- *
20
- * @group hooks
21
- *
22
- * @returns
23
- * The mutation hook wrapping the `openSso()` action
24
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
25
- * The mutation doesn't output any value
26
- *
27
- * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
28
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
29
- */
30
- export declare function useOpenSso({ mutations }?: UseOpenSsoParams): import("@tanstack/react-query").UseMutationResult<{
31
- wallet?: import("viem").Hex;
32
- }, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
33
- export {};
@@ -1,40 +0,0 @@
1
- import type { PrepareSsoParamsType } from "@frak-labs/core-sdk";
2
- /**
3
- * Hook that generates SSO URL for popup flow
4
- *
5
- * This is a **synchronous** hook (no async calls) that generates the SSO URL
6
- * client-side without communicating with the wallet iframe.
7
- *
8
- * @param params - SSO parameters for URL generation
9
- *
10
- * @group hooks
11
- *
12
- * @returns
13
- * Object containing:
14
- * - `ssoUrl`: Generated SSO URL (or undefined if client not ready)
15
- * - `isReady`: Boolean indicating if URL is available
16
- *
17
- * @example
18
- * ```tsx
19
- * function MyComponent() {
20
- * const { data } = usePrepareSso({
21
- * metadata: { logoUrl: "..." },
22
- * directExit: true
23
- * });
24
- *
25
- * const handleClick = () => {
26
- * if (ssoUrl) {
27
- * window.open(data?.ssoUrl, "_blank");
28
- * }
29
- * };
30
- *
31
- * return <button onClick={handleClick} disabled={!isReady}>Login</button>;
32
- * }
33
- * ```
34
- *
35
- * @see {@link @frak-labs/core-sdk!actions.prepareSso | `prepareSso()`} for the underlying action
36
- * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for the recommended high-level API
37
- */
38
- export declare function usePrepareSso(params: PrepareSsoParamsType): import("@tanstack/react-query").UseQueryResult<{
39
- ssoUrl: string;
40
- }, Error>;
@@ -1,40 +0,0 @@
1
- import type { PrepareSsoParamsType } from "@frak-labs/core-sdk";
2
- /**
3
- * Hook that generates SSO URL for popup flow
4
- *
5
- * This is a **synchronous** hook (no async calls) that generates the SSO URL
6
- * client-side without communicating with the wallet iframe.
7
- *
8
- * @param params - SSO parameters for URL generation
9
- *
10
- * @group hooks
11
- *
12
- * @returns
13
- * Object containing:
14
- * - `ssoUrl`: Generated SSO URL (or undefined if client not ready)
15
- * - `isReady`: Boolean indicating if URL is available
16
- *
17
- * @example
18
- * ```tsx
19
- * function MyComponent() {
20
- * const { data } = usePrepareSso({
21
- * metadata: { logoUrl: "..." },
22
- * directExit: true
23
- * });
24
- *
25
- * const handleClick = () => {
26
- * if (ssoUrl) {
27
- * window.open(data?.ssoUrl, "_blank");
28
- * }
29
- * };
30
- *
31
- * return <button onClick={handleClick} disabled={!isReady}>Login</button>;
32
- * }
33
- * ```
34
- *
35
- * @see {@link @frak-labs/core-sdk!actions.prepareSso | `prepareSso()`} for the underlying action
36
- * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for the recommended high-level API
37
- */
38
- export declare function usePrepareSso(params: PrepareSsoParamsType): import("@tanstack/react-query").UseQueryResult<{
39
- ssoUrl: string;
40
- }, Error>;
@@ -1,33 +0,0 @@
1
- import type { SendInteractionParamsType, SendInteractionReturnType } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseMutationOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type MutationOptions = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
6
- /** @inline */
7
- interface UseSendInteractionParams {
8
- /**
9
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
10
- */
11
- mutations?: MutationOptions;
12
- }
13
- /**
14
- * Hook that return a mutation helping to send a user interaction
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} action
17
- *
18
- * @param args
19
- *
20
- * @group hooks
21
- *
22
- * @returns
23
- * The mutation hook wrapping the `sendInteraction()` action
24
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.SendInteractionParamsType | `SendInteractionParamsType`}
25
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendInteractionReturnType | `SendInteractionReturnType`}
26
- *
27
- * @see {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} for more info about the underlying action
28
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
29
- */
30
- export declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): import("@tanstack/react-query").UseMutationResult<{
31
- delegationId: string;
32
- }, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
33
- export {};
@@ -1,33 +0,0 @@
1
- import type { SendInteractionParamsType, SendInteractionReturnType } from "@frak-labs/core-sdk";
2
- import { type FrakRpcError } from "@frak-labs/frame-connector";
3
- import { type UseMutationOptions } from "@tanstack/react-query";
4
- /** @ignore */
5
- type MutationOptions = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
6
- /** @inline */
7
- interface UseSendInteractionParams {
8
- /**
9
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
10
- */
11
- mutations?: MutationOptions;
12
- }
13
- /**
14
- * Hook that return a mutation helping to send a user interaction
15
- *
16
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} action
17
- *
18
- * @param args
19
- *
20
- * @group hooks
21
- *
22
- * @returns
23
- * The mutation hook wrapping the `sendInteraction()` action
24
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.SendInteractionParamsType | `SendInteractionParamsType`}
25
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendInteractionReturnType | `SendInteractionReturnType`}
26
- *
27
- * @see {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} for more info about the underlying action
28
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
29
- */
30
- export declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): import("@tanstack/react-query").UseMutationResult<{
31
- delegationId: string;
32
- }, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
33
- export {};
@@ -1,34 +0,0 @@
1
- import type { SendTransactionReturnType } from "@frak-labs/core-sdk";
2
- import { type SendTransactionParams } from "@frak-labs/core-sdk/actions";
3
- import { type FrakRpcError } from "@frak-labs/frame-connector";
4
- import { type UseMutationOptions } from "@tanstack/react-query";
5
- /** @ignore */
6
- type MutationOptions = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
7
- /** @inline */
8
- interface UseSendTransactionParams {
9
- /**
10
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
11
- */
12
- mutations?: MutationOptions;
13
- }
14
- /**
15
- * Hook that return a mutation helping to send a transaction
16
- *
17
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
18
- *
19
- * @param args
20
- *
21
- * @group hooks
22
- *
23
- * @returns
24
- * The mutation hook wrapping the `sendTransaction()` action
25
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
26
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
27
- *
28
- * @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
29
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
30
- */
31
- export declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): import("@tanstack/react-query").UseMutationResult<{
32
- hash: import("viem").Hex;
33
- }, FrakRpcError<undefined>, SendTransactionParams, unknown>;
34
- export {};
@@ -1,34 +0,0 @@
1
- import type { SendTransactionReturnType } from "@frak-labs/core-sdk";
2
- import { type SendTransactionParams } from "@frak-labs/core-sdk/actions";
3
- import { type FrakRpcError } from "@frak-labs/frame-connector";
4
- import { type UseMutationOptions } from "@tanstack/react-query";
5
- /** @ignore */
6
- type MutationOptions = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
7
- /** @inline */
8
- interface UseSendTransactionParams {
9
- /**
10
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
11
- */
12
- mutations?: MutationOptions;
13
- }
14
- /**
15
- * Hook that return a mutation helping to send a transaction
16
- *
17
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
18
- *
19
- * @param args
20
- *
21
- * @group hooks
22
- *
23
- * @returns
24
- * The mutation hook wrapping the `sendTransaction()` action
25
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
26
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
27
- *
28
- * @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
29
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
30
- */
31
- export declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): import("@tanstack/react-query").UseMutationResult<{
32
- hash: import("viem").Hex;
33
- }, FrakRpcError<undefined>, SendTransactionParams, unknown>;
34
- export {};
@@ -1,35 +0,0 @@
1
- import type { SiweAuthenticateReturnType } from "@frak-labs/core-sdk";
2
- import { type SiweAuthenticateModalParams } from "@frak-labs/core-sdk/actions";
3
- import { type FrakRpcError } from "@frak-labs/frame-connector";
4
- import { type UseMutationOptions } from "@tanstack/react-query";
5
- /** @inline */
6
- type MutationOptions = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
7
- /** @ignore */
8
- interface UseSiweAuthenticateParams {
9
- /**
10
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
11
- */
12
- mutations?: MutationOptions;
13
- }
14
- /**
15
- * Hook that return a mutation helping to send perform a SIWE authentication
16
- *
17
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
18
- *
19
- * @param args
20
- *
21
- * @group hooks
22
- *
23
- * @returns
24
- * The mutation hook wrapping the `siweAuthenticate()` action
25
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
26
- * The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
27
- *
28
- * @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
29
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
30
- */
31
- export declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): import("@tanstack/react-query").UseMutationResult<{
32
- signature: import("viem").Hex;
33
- message: string;
34
- }, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
35
- export {};
@@ -1,35 +0,0 @@
1
- import type { SiweAuthenticateReturnType } from "@frak-labs/core-sdk";
2
- import { type SiweAuthenticateModalParams } from "@frak-labs/core-sdk/actions";
3
- import { type FrakRpcError } from "@frak-labs/frame-connector";
4
- import { type UseMutationOptions } from "@tanstack/react-query";
5
- /** @inline */
6
- type MutationOptions = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
7
- /** @ignore */
8
- interface UseSiweAuthenticateParams {
9
- /**
10
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
11
- */
12
- mutations?: MutationOptions;
13
- }
14
- /**
15
- * Hook that return a mutation helping to send perform a SIWE authentication
16
- *
17
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
18
- *
19
- * @param args
20
- *
21
- * @group hooks
22
- *
23
- * @returns
24
- * The mutation hook wrapping the `siweAuthenticate()` action
25
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
26
- * The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
27
- *
28
- * @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
29
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
30
- */
31
- export declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): import("@tanstack/react-query").UseMutationResult<{
32
- signature: import("viem").Hex;
33
- message: string;
34
- }, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
35
- export {};
@@ -1,16 +0,0 @@
1
- import type { WalletStatusReturnType } from "@frak-labs/core-sdk";
2
- /**
3
- * Hook that return a query helping to get the current wallet status.
4
- *
5
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
6
- *
7
- * @group hooks
8
- *
9
- * @returns
10
- * The query hook wrapping the `watchWalletStatus()` action
11
- * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
12
- *
13
- * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
14
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
15
- */
16
- export declare function useWalletStatus(): import("@tanstack/react-query").UseQueryResult<WalletStatusReturnType, Error>;
@@ -1,16 +0,0 @@
1
- import type { WalletStatusReturnType } from "@frak-labs/core-sdk";
2
- /**
3
- * Hook that return a query helping to get the current wallet status.
4
- *
5
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
6
- *
7
- * @group hooks
8
- *
9
- * @returns
10
- * The query hook wrapping the `watchWalletStatus()` action
11
- * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
12
- *
13
- * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
14
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
15
- */
16
- export declare function useWalletStatus(): import("@tanstack/react-query").UseQueryResult<WalletStatusReturnType, Error>;
@@ -1,9 +0,0 @@
1
- import { type FrakContext } from "@frak-labs/core-sdk";
2
- /**
3
- * Extract the current frak context from the url
4
- * @ignore
5
- */
6
- export declare function useFrakContext(): {
7
- frakContext: FrakContext | null | undefined;
8
- updateContext: (newContext: Partial<FrakContext>) => void;
9
- };
@@ -1,9 +0,0 @@
1
- import { type FrakContext } from "@frak-labs/core-sdk";
2
- /**
3
- * Extract the current frak context from the url
4
- * @ignore
5
- */
6
- export declare function useFrakContext(): {
7
- frakContext: FrakContext | null | undefined;
8
- updateContext: (newContext: Partial<FrakContext>) => void;
9
- };
@@ -1,2 +0,0 @@
1
- /** @ignore */
2
- export declare function useMounted(): boolean;
@@ -1,2 +0,0 @@
1
- /** @ignore */
2
- export declare function useMounted(): boolean;
@@ -1,8 +0,0 @@
1
- /**
2
- * Returns the current window location and href
3
- * @ignore
4
- */
5
- export declare function useWindowLocation(): {
6
- location: Location | undefined;
7
- href: string | undefined;
8
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Returns the current window location and href
3
- * @ignore
4
- */
5
- export declare function useWindowLocation(): {
6
- location: Location | undefined;
7
- href: string | undefined;
8
- };
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
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});
package/dist/index.d.cts DELETED
@@ -1,3 +0,0 @@
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";
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
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";
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- import{Fragment as e,createContext as t,createElement as n,useCallback as r,useContext as o,useEffect as a,useMemo as i,useState as u}from"react";import{FrakContextManager as s,baseIframeProps as l,createIFrameFrakClient as f}from"@frak-labs/core-sdk";import{ClientNotFound as c,FrakRpcError as d,RpcErrorCodes as w}from"@frak-labs/frame-connector";import{displayModal as k,getProductInformation as m,openSso as y,prepareSso as p,processReferral as h,sendInteraction as F,sendTransaction as v,siweAuthenticate as g,watchWalletStatus as C}from"@frak-labs/core-sdk/actions";import{useMutation as q,useQuery as K,useQueryClient as x}from"@tanstack/react-query";let P=t(void 0);function S(e){let{children:t,config:r}=e;return n(P.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 b(){let e=o(P);if(!e)throw new d(w.configError,"Frak config not found");return e}let I=t(void 0);function T({style:t,children:r}){let o=b(),[a,i]=u(void 0),s=n("iframe",{...l,src:`${o.walletUrl}/listener`,style:t??l.style,ref:e=>{e&&!a&&i(f({iframe:e,config:o}))}}),c=n(I.Provider,{value:a},r);return n(e,null,s,c)}function U(){return o(I)}function E(){let e=x(),t=U(),n=r(t=>{e.setQueryData(["frak-sdk","wallet-status-listener"],t)},[e]);return K({gcTime:0,staleTime:0,queryKey:["frak-sdk","wallet-status-listener"],queryFn:async()=>{if(!t)throw new c;return C(t,n)},enabled:!!t})}function A({mutations:e}={}){let t=U();return q({...e,mutationKey:["frak-sdk","send-transaction"],mutationFn:async e=>{if(!t)throw new c;return v(t,e)}})}function D({mutations:e}={}){let t=U();return q({...e,mutationKey:["frak-sdk","send-interaction"],mutationFn:async e=>{if(!t)throw new c;return F(t,e)}})}function L({mutations:e}={}){let t=U();return q({...e,mutationKey:["frak-sdk","siwe-authenticate",t?.config.domain??"no-domain"],mutationFn:async e=>{if(!t)throw new c;return g(t,e)}})}function G({productId:e,modalConfig:t,options:n}={}){let o=U(),{frakContext:l}=function(){let{location:e}=function(){let e=function(){let[e,t]=u(!1);return a(()=>{t(!0)},[]),e}(),[t,n]=u(e?window.location:void 0);a(()=>{if(e)return t||r(),window.addEventListener("popstate",r),()=>{window.removeEventListener("popstate",r)};function r(){n(window.location)}},[e,t]);let r=i(()=>t?.href,[t?.href]);return{location:t,href:r}}();return{frakContext:i(()=>e?.href?s.parse({url:e.href}):null,[e?.href]),updateContext:r(t=>{console.log("Updating context",{newContext:t}),s.replaceUrl({url:e?.href,context:t})},[e?.href])}}(),{data:f}=E(),{data:d,error:w,status:k}=K({gcTime:0,staleTime:0,queryKey:["frak-sdk","auto-referral-interaction",l?.r??"no-referrer",f?.key??"no-wallet-status",e??"no-product-id"],queryFn:()=>{if(!o)throw new c;return h(o,{walletStatus:f,frakContext:l,modalConfig:t,productId:e,options:n})},enabled:!!f});return i(()=>"pending"===k?"processing":"error"===k?w:d||"idle",[d,k,w])}function M({mutations:e}={}){let t=U();return q({...e,mutationKey:["frak-sdk","display-modal"],mutationFn:async e=>{if(!t)throw new c;return k(t,e)}})}function O({mutations:e}={}){let t=U();return q({...e,mutationKey:["frak-sdk","open-sso"],mutationFn:async e=>{if(!t)throw new c;return y(t,e)}})}function Q(e){let t=U();return K({queryKey:["frak-sdk","prepare-sso",e],queryFn:async()=>{if(!t)throw new c;return p(t,e)}})}function R({query:e}={}){let t=U();return K({...e,queryKey:["frak-sdk","get-product-information"],queryFn:async()=>{if(!t)throw new c;return m(t)}})}export{P as FrakConfigContext,S as FrakConfigProvider,I as FrakIFrameClientContext,T as FrakIFrameClientProvider,M as useDisplayModal,U as useFrakClient,b as useFrakConfig,R as useGetProductInformation,O as useOpenSso,Q as usePrepareSso,G as useReferralInteraction,D as useSendInteraction,A as useSendTransactionAction,L as useSiweAuthenticate,E as useWalletStatus};
@@ -1,29 +0,0 @@
1
- import type { FrakWalletSdkConfig } from "@frak-labs/core-sdk";
2
- import { type PropsWithChildren } from "react";
3
- /**
4
- * The context that will keep the Frak Wallet SDK configuration
5
- * @ignore
6
- */
7
- export declare const FrakConfigContext: import("react").Context<FrakWalletSdkConfig | undefined>;
8
- /**
9
- * Props to instantiate the Frak Wallet SDK configuration provider
10
- *
11
- * @group provider
12
- */
13
- export type FrakConfigProviderProps = {
14
- /**
15
- * The wanted Frak configuration
16
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
17
- */
18
- config: FrakWalletSdkConfig;
19
- };
20
- /**
21
- * Simple config provider for the Frak Wallet SDK
22
- *
23
- * Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
24
- *
25
- * @group provider
26
- *
27
- * @param parameters
28
- */
29
- export declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): import("react").FunctionComponentElement<import("react").ProviderProps<FrakWalletSdkConfig | undefined>>;
@@ -1,29 +0,0 @@
1
- import type { FrakWalletSdkConfig } from "@frak-labs/core-sdk";
2
- import { type PropsWithChildren } from "react";
3
- /**
4
- * The context that will keep the Frak Wallet SDK configuration
5
- * @ignore
6
- */
7
- export declare const FrakConfigContext: import("react").Context<FrakWalletSdkConfig | undefined>;
8
- /**
9
- * Props to instantiate the Frak Wallet SDK configuration provider
10
- *
11
- * @group provider
12
- */
13
- export type FrakConfigProviderProps = {
14
- /**
15
- * The wanted Frak configuration
16
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
17
- */
18
- config: FrakWalletSdkConfig;
19
- };
20
- /**
21
- * Simple config provider for the Frak Wallet SDK
22
- *
23
- * Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
24
- *
25
- * @group provider
26
- *
27
- * @param parameters
28
- */
29
- export declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): import("react").FunctionComponentElement<import("react").ProviderProps<FrakWalletSdkConfig | undefined>>;
@@ -1,32 +0,0 @@
1
- import { type FrakClient, type FrakWalletSdkConfig } from "@frak-labs/core-sdk";
2
- import { type CSSProperties, type ReactNode } from "react";
3
- /**
4
- * The context that will keep the Frak Wallet SDK client
5
- * @ignore
6
- */
7
- export declare const FrakIFrameClientContext: import("react").Context<FrakClient | undefined>;
8
- /**
9
- * Props to instantiate the Frak Wallet SDK configuration provider
10
- *
11
- * @group provider
12
- */
13
- export type FrakIFrameClientProps = {
14
- config: FrakWalletSdkConfig;
15
- };
16
- /**
17
- * IFrame client provider for the Frak Wallet SDK
18
- * It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
19
- *
20
- * @group provider
21
- *
22
- * @remarks
23
- * This provider must be wrapped within a {@link FrakConfigProvider} to work properly
24
- *
25
- * @param args
26
- * @param args.style - Some custom styles to apply to the iFrame
27
- * @param args.children - Descedant components that will have access to the Frak Client
28
- */
29
- export declare function FrakIFrameClientProvider({ style, children, }: {
30
- style?: CSSProperties;
31
- children?: ReactNode;
32
- }): import("react").FunctionComponentElement<import("react").FragmentProps>;
@@ -1,32 +0,0 @@
1
- import { type FrakClient, type FrakWalletSdkConfig } from "@frak-labs/core-sdk";
2
- import { type CSSProperties, type ReactNode } from "react";
3
- /**
4
- * The context that will keep the Frak Wallet SDK client
5
- * @ignore
6
- */
7
- export declare const FrakIFrameClientContext: import("react").Context<FrakClient | undefined>;
8
- /**
9
- * Props to instantiate the Frak Wallet SDK configuration provider
10
- *
11
- * @group provider
12
- */
13
- export type FrakIFrameClientProps = {
14
- config: FrakWalletSdkConfig;
15
- };
16
- /**
17
- * IFrame client provider for the Frak Wallet SDK
18
- * It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
19
- *
20
- * @group provider
21
- *
22
- * @remarks
23
- * This provider must be wrapped within a {@link FrakConfigProvider} to work properly
24
- *
25
- * @param args
26
- * @param args.style - Some custom styles to apply to the iFrame
27
- * @param args.children - Descedant components that will have access to the Frak Client
28
- */
29
- export declare function FrakIFrameClientProvider({ style, children, }: {
30
- style?: CSSProperties;
31
- children?: ReactNode;
32
- }): import("react").FunctionComponentElement<import("react").FragmentProps>;
@@ -1,4 +0,0 @@
1
- export { FrakConfigProvider, FrakConfigContext } from "./FrakConfigProvider";
2
- export type { FrakConfigProviderProps } from "./FrakConfigProvider";
3
- export { FrakIFrameClientContext, FrakIFrameClientProvider, } from "./FrakIFrameClientProvider";
4
- export type { FrakIFrameClientProps } from "./FrakIFrameClientProvider";
@@ -1,4 +0,0 @@
1
- export { FrakConfigProvider, FrakConfigContext } from "./FrakConfigProvider";
2
- export type { FrakConfigProviderProps } from "./FrakConfigProvider";
3
- export { FrakIFrameClientContext, FrakIFrameClientProvider, } from "./FrakIFrameClientProvider";
4
- export type { FrakIFrameClientProps } from "./FrakIFrameClientProvider";