@openfort/react 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -30
- package/build/components/{OpenfortKit → Openfort}/OpenfortKit.d.ts +6 -6
- package/build/components/{OpenfortKit → Openfort}/context.d.ts +2 -2
- package/build/components/{OpenfortKit → Openfort}/types.d.ts +4 -4
- package/build/components/Pages/Providers/index.d.ts +1 -1
- package/build/hooks/openfort/auth/status.d.ts +3 -3
- package/build/hooks/openfort/auth/useAuthCallback.d.ts +17 -32
- package/build/hooks/openfort/auth/useCreateWalletPostAuth.d.ts +13 -2
- package/build/hooks/openfort/auth/useEmailAuth.d.ts +16 -6
- package/build/hooks/openfort/auth/useGuestAuth.d.ts +5 -4
- package/build/hooks/openfort/auth/useOAuth.d.ts +21 -7
- package/build/hooks/openfort/auth/useSignOut.d.ts +2 -2
- package/build/hooks/openfort/auth/useWalletAuth.d.ts +4 -4
- package/build/hooks/openfort/hookConsistency.d.ts +3 -3
- package/build/hooks/openfort/useProviders.d.ts +1 -1
- package/build/hooks/openfort/useStatus.d.ts +6 -9
- package/build/hooks/openfort/useUser.d.ts +1 -0
- package/build/hooks/openfort/useWallet.d.ts +1 -0
- package/build/hooks/openfort/useWallets.d.ts +34 -12
- package/build/index.d.ts +5 -4
- package/build/index.es.js +615 -433
- package/build/index.es.js.map +1 -1
- package/build/openfort/OpenfortProvider.d.ts +2 -2
- package/build/openfort/useOpenfort.d.ts +1 -1
- package/build/types.d.ts +10 -9
- package/build/version.d.ts +1 -1
- package/package.json +3 -3
- package/build/openfort/OpenfortProvider_old.d.ts +0 -0
- /package/build/components/{OpenfortKit → Openfort}/useOpenfortKit.d.ts +0 -0
package/README.md
CHANGED
|
@@ -10,22 +10,18 @@
|
|
|
10
10
|
Documentation
|
|
11
11
|
</a>
|
|
12
12
|
<span> | </span>
|
|
13
|
-
<a href="https://www.openfort.io/docs/reference/api/authentication">
|
|
14
|
-
API Docs
|
|
15
|
-
</a>
|
|
16
|
-
<span> | </span>
|
|
17
13
|
<a href="https://x.com/openfort_hq">
|
|
18
14
|
X
|
|
19
15
|
</a>
|
|
20
|
-
|
|
21
|
-
<a href="https://
|
|
16
|
+
<span> | </span>
|
|
17
|
+
<a href="https://playground.openfort.io/">
|
|
22
18
|
Demo
|
|
23
19
|
</a>
|
|
24
20
|
</h4>
|
|
25
21
|
</div>
|
|
26
22
|
|
|
27
23
|
|
|
28
|
-
# Openfort
|
|
24
|
+
# Openfort React SDK
|
|
29
25
|
|
|
30
26
|
[](https://www.npmjs.com/package/@openfort/react)
|
|
31
27
|
[](LICENSE)
|
|
@@ -33,18 +29,14 @@
|
|
|
33
29
|
[](https://www.npmjs.org/package/@openfort/react)
|
|
34
30
|
|
|
35
31
|
|
|
36
|
-
The easiest way to
|
|
37
|
-
|
|
38
|
-
It offers a simple, customizable UI. Supports authentication providers like Google, X, or Facebook out of the box. Access your address through Openfort’s [invisible wallet](https://www.openfort.io/docs/products/embedded-wallet/javascript) or connect their own wallet provider effortlessly.
|
|
39
|
-
|
|
40
|
-
Docs: https://www.openfort.io/docs/products/embedded-wallet/react/kit
|
|
32
|
+
The easiest way to use embedded wallets, with built-in authentication and payments capabilities.
|
|
41
33
|
|
|
42
34
|
## Features
|
|
43
35
|
|
|
44
36
|
- 💡 TypeScript Ready — Get types straight out of the box.
|
|
45
|
-
- 🌱 Ecosystem
|
|
46
|
-
-
|
|
47
|
-
-
|
|
37
|
+
- 🌱 Ecosystem Friendly — Uses top libraries such as [wagmi](https://github.com/wagmi-dev/wagmi) for hooks.
|
|
38
|
+
- 🎨 Simple UI — Use prebuilt elements for authenticaiton and wallet connection.
|
|
39
|
+
- 🖥️ React Hooks - To interact directly with embedded wallet capabilities.
|
|
48
40
|
|
|
49
41
|
and much more...
|
|
50
42
|
|
|
@@ -57,24 +49,24 @@ Get started with `create` Openfortkit + [wagmi](https://wagmi.sh/) + [viem](http
|
|
|
57
49
|
#### npm
|
|
58
50
|
|
|
59
51
|
```sh
|
|
60
|
-
npx create
|
|
52
|
+
npx create openfort
|
|
61
53
|
```
|
|
62
54
|
|
|
63
55
|
#### yarn
|
|
64
56
|
|
|
65
57
|
```sh
|
|
66
|
-
yarn create
|
|
58
|
+
yarn create openfort
|
|
67
59
|
```
|
|
68
60
|
|
|
69
61
|
#### pnpm
|
|
70
62
|
|
|
71
63
|
```sh
|
|
72
|
-
pnpm create
|
|
64
|
+
pnpm create openfort
|
|
73
65
|
```
|
|
74
66
|
|
|
75
|
-
### Import `
|
|
67
|
+
### Import `Openfort` to your project
|
|
76
68
|
|
|
77
|
-
Add
|
|
69
|
+
Add Openfort to your already existing project.
|
|
78
70
|
|
|
79
71
|
#### npm
|
|
80
72
|
|
|
@@ -94,25 +86,21 @@ yarn add @openfort/react @tanstack/react-query wagmi viem
|
|
|
94
86
|
pnpm add @openfort/react @tanstack/react-query wagmi viem
|
|
95
87
|
```
|
|
96
88
|
|
|
97
|
-
## Documentation
|
|
98
|
-
|
|
99
|
-
You can find the full OpenfortKit documentation in the Family docs [here]().
|
|
100
|
-
|
|
101
89
|
## Examples
|
|
102
90
|
|
|
103
|
-
There are various runnable examples included in this repository in the [examples folder](https://github.com/openfort-xyz/openfort-
|
|
91
|
+
There are various runnable examples included in this repository in the [examples folder](https://github.com/openfort-xyz/openfort-react/tree/main/examples):
|
|
104
92
|
|
|
105
|
-
- [Create React App Example (TypeScript)](https://github.com/openfort-xyz/openfort-
|
|
106
|
-
- [Next.js Example (TypeScript)](https://github.com/openfort-xyz/openfort-
|
|
107
|
-
- [Vite Example (TypeScript)](https://github.com/openfort-xyz/openfort-
|
|
93
|
+
- [Create React App Example (TypeScript)](https://github.com/openfort-xyz/openfort-react/tree/main/examples/cra)
|
|
94
|
+
- [Next.js Example (TypeScript)](https://github.com/openfort-xyz/openfort-react/tree/main/examples/nextjs)
|
|
95
|
+
- [Vite Example (TypeScript)](https://github.com/openfort-xyz/openfort-react/tree/main/examples/vite)
|
|
108
96
|
|
|
109
97
|
### Running Examples Locally
|
|
110
98
|
|
|
111
|
-
Clone the
|
|
99
|
+
Clone the project and install the necessary dependencies:
|
|
112
100
|
|
|
113
101
|
```sh
|
|
114
102
|
$ git clone git@github.com:openfort-xyz/openfort-kit.git
|
|
115
|
-
$ cd openfort
|
|
103
|
+
$ cd openfort
|
|
116
104
|
$ yarn install
|
|
117
105
|
```
|
|
118
106
|
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useConnectCallbackProps } from '../../hooks/useConnectCallback';
|
|
3
3
|
import { ContextValue } from './context';
|
|
4
|
-
import {
|
|
5
|
-
type
|
|
4
|
+
import { ConnectUIOptions, OpenfortWalletConfig } from './types';
|
|
5
|
+
type OpenfortProviderProps = {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
debugMode?: boolean;
|
|
8
8
|
publishableKey: string;
|
|
9
|
-
uiConfig?:
|
|
9
|
+
uiConfig?: ConnectUIOptions;
|
|
10
10
|
walletConfig?: OpenfortWalletConfig;
|
|
11
11
|
} & useConnectCallbackProps;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* OpenfortProvider component provides context and configuration for OpenfortKit.
|
|
14
14
|
* It must be used within a WagmiProvider.
|
|
15
15
|
*
|
|
16
16
|
* @param {React.ReactNode} children - The child components to be wrapped by the provider.
|
|
17
17
|
* @param {string} [theme='auto'] - The theme to be used, default is 'auto'.
|
|
18
18
|
* @param {string} [mode='auto'] - The mode to be used, default is 'auto'.
|
|
19
19
|
* @param {CustomTheme} [customTheme] - Custom theme configuration.
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {ConnectUIOptions} [options] - Additional configuration options.
|
|
21
21
|
* @param {Function} [onConnect] - Callback function to be called on connect.
|
|
22
22
|
* @param {Function} [onDisconnect] - Callback function to be called on disconnect.
|
|
23
23
|
* @param {boolean} [debugMode=false] - Enable or disable debug mode, default is false.
|
|
24
24
|
* @param {OpenfortOptions} [openfortOptions] - Options for Openfort integration.
|
|
25
25
|
* @throws Will throw an error if used outside of a WagmiProvider or if nested usages are detected.
|
|
26
26
|
*/
|
|
27
|
-
export declare const
|
|
27
|
+
export declare const OpenfortProvider: ({ children, uiConfig, onConnect, onDisconnect, debugMode, publishableKey, walletConfig, }: OpenfortProviderProps) => React.FunctionComponentElement<React.ProviderProps<ContextValue | null>>;
|
|
28
28
|
export {};
|
|
@@ -3,7 +3,7 @@ import { CustomTheme, Languages, Mode, Theme } from '../../types';
|
|
|
3
3
|
import { OAuthProvider } from '@openfort/openfort-js';
|
|
4
4
|
import { ValueOf } from 'viem/_types/types/utils';
|
|
5
5
|
import { useConnectCallbackProps } from '../../hooks/useConnectCallback';
|
|
6
|
-
import {
|
|
6
|
+
import { OpenfortUIOptionsExtended, OpenfortWalletConfig, routes } from './types';
|
|
7
7
|
type Connector = {
|
|
8
8
|
id: string;
|
|
9
9
|
type?: "wallet";
|
|
@@ -31,7 +31,7 @@ export type ContextValue = {
|
|
|
31
31
|
displayError: (message: string | React.ReactNode | null, code?: any) => void;
|
|
32
32
|
resize: number;
|
|
33
33
|
triggerResize: () => void;
|
|
34
|
-
uiConfig?:
|
|
34
|
+
uiConfig?: OpenfortUIOptionsExtended;
|
|
35
35
|
walletConfig?: OpenfortWalletConfig;
|
|
36
36
|
} & useConnectCallbackProps;
|
|
37
37
|
export declare const OpenfortKitContext: React.Context<ContextValue | null>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { CustomAvatarProps, CustomTheme, Languages, Mode, Theme } from '../../types';
|
|
3
3
|
import { RecoveryMethod } from '@openfort/openfort-js';
|
|
4
|
-
import {
|
|
4
|
+
import { CoreOpenfortProviderProps } from '../../openfort/OpenfortProvider';
|
|
5
5
|
export declare const routes: {
|
|
6
6
|
readonly PROVIDERS: "providers";
|
|
7
7
|
readonly SOCIAL_PROVIDERS: "socialProviders";
|
|
@@ -84,9 +84,9 @@ export type OpenfortOptions = {
|
|
|
84
84
|
termsOfServiceUrl?: string;
|
|
85
85
|
privacyPolicyUrl?: string;
|
|
86
86
|
logo?: React.ReactNode;
|
|
87
|
-
openfortUrlOverrides?:
|
|
87
|
+
openfortUrlOverrides?: CoreOpenfortProviderProps['overrides'];
|
|
88
88
|
};
|
|
89
|
-
export type
|
|
89
|
+
export type ConnectUIOptions = {
|
|
90
90
|
theme?: Theme;
|
|
91
91
|
mode?: Mode;
|
|
92
92
|
customTheme?: CustomTheme;
|
|
@@ -107,7 +107,7 @@ export type ConnectKitOptions = {
|
|
|
107
107
|
enforceSupportedChains?: boolean;
|
|
108
108
|
overlayBlur?: number;
|
|
109
109
|
} & OpenfortOptions;
|
|
110
|
-
export type
|
|
110
|
+
export type OpenfortUIOptionsExtended = {
|
|
111
111
|
theme: Theme;
|
|
112
112
|
mode: Mode;
|
|
113
113
|
customTheme?: CustomTheme;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenfortError } from "../../../types";
|
|
2
2
|
export type BaseFlowState = {
|
|
3
3
|
status: "idle" | 'awaiting-input' | 'loading' | 'success';
|
|
4
4
|
error?: never;
|
|
5
5
|
} | {
|
|
6
6
|
status: 'error';
|
|
7
|
-
error:
|
|
7
|
+
error: OpenfortError | null;
|
|
8
8
|
};
|
|
9
9
|
export declare const mapStatus: (status: BaseFlowState) => {
|
|
10
10
|
isLoading: boolean;
|
|
11
11
|
isError: boolean;
|
|
12
12
|
isSuccess: boolean;
|
|
13
|
-
error:
|
|
13
|
+
error: OpenfortError | null | undefined;
|
|
14
14
|
};
|
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import { OpenfortHookOptions,
|
|
2
|
-
import { AuthProvider } from "../../../components/
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
type: "verifyEmail";
|
|
8
|
-
email?: string;
|
|
9
|
-
error?: OpenfortKitError;
|
|
10
|
-
};
|
|
11
|
-
type StoreCredentialsResult = {
|
|
1
|
+
import { OpenfortHookOptions, OpenfortError } from "../../../types";
|
|
2
|
+
import { AuthProvider } from "../../../components/Openfort/types";
|
|
3
|
+
import { CreateWalletPostAuthOptions } from "./useCreateWalletPostAuth";
|
|
4
|
+
import { EmailVerificationResult } from "./useEmailAuth";
|
|
5
|
+
import { StoreCredentialsResult } from "./useOAuth";
|
|
6
|
+
type CallbackResult = (StoreCredentialsResult & {
|
|
12
7
|
type: "storeCredentials";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
type VerifyEmailOptions = {
|
|
18
|
-
email: string;
|
|
19
|
-
state: string;
|
|
20
|
-
} & OpenfortHookOptions<EmailVerificationResult>;
|
|
21
|
-
type StoreCredentialsOptions = {
|
|
22
|
-
player: string;
|
|
23
|
-
accessToken: string;
|
|
24
|
-
refreshToken: string;
|
|
25
|
-
} & OpenfortHookOptions<StoreCredentialsResult>;
|
|
8
|
+
}) | (EmailVerificationResult & {
|
|
9
|
+
type: "verifyEmail";
|
|
10
|
+
});
|
|
26
11
|
type UseAuthCallbackOptions = {
|
|
27
|
-
|
|
28
|
-
} & OpenfortHookOptions<CallbackResult
|
|
29
|
-
export declare const useAuthCallback: ({
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
} & OpenfortHookOptions<CallbackResult> & CreateWalletPostAuthOptions;
|
|
14
|
+
export declare const useAuthCallback: ({ enabled, ...hookOptions }?: UseAuthCallbackOptions) => {
|
|
15
|
+
email: string | null;
|
|
16
|
+
provider: AuthProvider | null;
|
|
17
|
+
verifyEmail: ({ email, state, ...options }: import("./useEmailAuth").VerifyEmailOptions) => Promise<EmailVerificationResult>;
|
|
18
|
+
storeCredentials: ({ player, accessToken, refreshToken, ...options }: import("./useOAuth").StoreCredentialsOptions) => Promise<StoreCredentialsResult>;
|
|
30
19
|
isLoading: boolean;
|
|
31
20
|
isError: boolean;
|
|
32
21
|
isSuccess: boolean;
|
|
33
|
-
error:
|
|
34
|
-
email: string | null;
|
|
35
|
-
provider: AuthProvider | null;
|
|
36
|
-
verifyEmail: ({ email, state, ...options }: VerifyEmailOptions) => Promise<EmailVerificationResult>;
|
|
37
|
-
storeCredentials: ({ player, accessToken, refreshToken, ...options }: StoreCredentialsOptions) => Promise<StoreCredentialsResult>;
|
|
22
|
+
error: OpenfortError | null | undefined;
|
|
38
23
|
};
|
|
39
24
|
export {};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
export type CreateWalletPostAuthOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* @default true
|
|
4
|
+
* It will log out the user if there is an error while trying to create a wallet (automatic recovery).
|
|
5
|
+
*/
|
|
6
|
+
logoutOnError?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
automaticRecovery?: boolean;
|
|
11
|
+
};
|
|
1
12
|
export declare const useCreateWalletPostAuth: () => {
|
|
2
|
-
tryUseWallet: () => Promise<{
|
|
3
|
-
error?:
|
|
13
|
+
tryUseWallet: ({ logoutOnError: signOutOnError, automaticRecovery }: CreateWalletPostAuthOptions) => Promise<{
|
|
14
|
+
error?: import("../../..").OpenfortError;
|
|
4
15
|
wallet?: import("../useWallets").UserWallet;
|
|
5
16
|
}>;
|
|
6
17
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
|
|
2
|
-
import { OpenfortHookOptions,
|
|
2
|
+
import { OpenfortHookOptions, OpenfortError } from "../../../types";
|
|
3
|
+
import { CreateWalletPostAuthOptions } from './useCreateWalletPostAuth';
|
|
3
4
|
import { UserWallet } from '../useWallets';
|
|
4
5
|
export type EmailAuthResult = {
|
|
5
|
-
error?:
|
|
6
|
+
error?: OpenfortError;
|
|
6
7
|
user?: OpenfortUser;
|
|
7
8
|
wallet?: UserWallet;
|
|
8
9
|
requiresEmailVerification?: boolean;
|
|
@@ -11,13 +12,13 @@ export type SignInEmailOptions = {
|
|
|
11
12
|
email: string;
|
|
12
13
|
password: string;
|
|
13
14
|
emailVerificationRedirectTo?: string;
|
|
14
|
-
} & OpenfortHookOptions<EmailAuthResult
|
|
15
|
+
} & OpenfortHookOptions<EmailAuthResult> & CreateWalletPostAuthOptions;
|
|
15
16
|
export type SignUpEmailOptions = {
|
|
16
17
|
email: string;
|
|
17
18
|
password: string;
|
|
18
19
|
name?: string;
|
|
19
20
|
emailVerificationRedirectTo?: string;
|
|
20
|
-
} & OpenfortHookOptions<EmailAuthResult
|
|
21
|
+
} & OpenfortHookOptions<EmailAuthResult> & CreateWalletPostAuthOptions;
|
|
21
22
|
export type RequestResetPasswordOptions = {
|
|
22
23
|
email: string;
|
|
23
24
|
emailVerificationRedirectTo?: string;
|
|
@@ -32,18 +33,27 @@ export type LinkEmailOptions = {
|
|
|
32
33
|
password: string;
|
|
33
34
|
emailVerificationRedirectTo?: string;
|
|
34
35
|
} & OpenfortHookOptions<EmailAuthResult>;
|
|
36
|
+
export type VerifyEmailOptions = {
|
|
37
|
+
email: string;
|
|
38
|
+
state: string;
|
|
39
|
+
} & OpenfortHookOptions<EmailVerificationResult>;
|
|
40
|
+
export type EmailVerificationResult = {
|
|
41
|
+
email?: string;
|
|
42
|
+
error?: OpenfortError;
|
|
43
|
+
};
|
|
35
44
|
export type UseEmailHookOptions = {
|
|
36
45
|
emailVerificationRedirectTo?: string;
|
|
37
|
-
} & OpenfortHookOptions<EmailAuthResult
|
|
46
|
+
} & OpenfortHookOptions<EmailAuthResult | EmailVerificationResult> & CreateWalletPostAuthOptions;
|
|
38
47
|
export declare const useEmailAuth: (hookOptions?: UseEmailHookOptions) => {
|
|
39
48
|
requiresEmailVerification: boolean;
|
|
40
49
|
isAwaitingInput: boolean;
|
|
41
50
|
isLoading: boolean;
|
|
42
51
|
isError: boolean;
|
|
43
52
|
isSuccess: boolean;
|
|
44
|
-
error:
|
|
53
|
+
error: OpenfortError | null | undefined;
|
|
45
54
|
signInEmail: (options: SignInEmailOptions) => Promise<EmailAuthResult>;
|
|
46
55
|
signUpEmail: (options: SignUpEmailOptions) => Promise<EmailAuthResult>;
|
|
56
|
+
verifyEmail: ({ email, state, ...options }: VerifyEmailOptions) => Promise<EmailVerificationResult>;
|
|
47
57
|
linkEmail: (options: LinkEmailOptions) => Promise<EmailAuthResult>;
|
|
48
58
|
requestResetPassword: (options: RequestResetPasswordOptions) => Promise<EmailAuthResult>;
|
|
49
59
|
resetPassword: (options: ResetPasswordOptions) => Promise<EmailAuthResult>;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
|
|
2
|
-
import { OpenfortHookOptions,
|
|
2
|
+
import { OpenfortHookOptions, OpenfortError } from "../../../types";
|
|
3
|
+
import { CreateWalletPostAuthOptions } from "./useCreateWalletPostAuth";
|
|
3
4
|
import { UserWallet } from "../useWallets";
|
|
4
5
|
export type GuestHookResult = {
|
|
5
|
-
error?:
|
|
6
|
+
error?: OpenfortError;
|
|
6
7
|
user?: OpenfortUser;
|
|
7
8
|
wallet?: UserWallet;
|
|
8
9
|
};
|
|
9
|
-
export type GuestHookOptions = OpenfortHookOptions<OpenfortUser
|
|
10
|
+
export type GuestHookOptions = OpenfortHookOptions<OpenfortUser> & CreateWalletPostAuthOptions;
|
|
10
11
|
export declare const useGuestAuth: (hookOptions?: GuestHookOptions) => {
|
|
11
12
|
isLoading: boolean;
|
|
12
13
|
isError: boolean;
|
|
13
14
|
isSuccess: boolean;
|
|
14
|
-
error:
|
|
15
|
+
error: OpenfortError | null | undefined;
|
|
15
16
|
signUpGuest: (options?: GuestHookOptions) => Promise<GuestHookResult>;
|
|
16
17
|
};
|
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
import { AuthProvider } from '../../../components/
|
|
2
|
-
import { OpenfortHookOptions,
|
|
1
|
+
import { AuthProvider } from '../../../components/Openfort/types';
|
|
2
|
+
import { OpenfortHookOptions, OpenfortError } from '../../../types';
|
|
3
|
+
import { CreateWalletPostAuthOptions } from './useCreateWalletPostAuth';
|
|
4
|
+
import { UserWallet } from "../useWallets";
|
|
5
|
+
import { type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
|
|
3
6
|
export type InitializeOAuthOptions = {
|
|
4
7
|
provider: AuthProvider;
|
|
5
8
|
redirectTo?: string;
|
|
6
9
|
} & OpenfortHookOptions;
|
|
7
|
-
export type AuthHookOptions = {
|
|
8
|
-
redirectTo?: string;
|
|
9
|
-
} & OpenfortHookOptions;
|
|
10
10
|
export type InitOAuthReturnType = {
|
|
11
|
-
error?:
|
|
11
|
+
error?: OpenfortError;
|
|
12
12
|
};
|
|
13
|
+
export type StoreCredentialsResult = {
|
|
14
|
+
user?: OpenfortUser;
|
|
15
|
+
wallet?: UserWallet;
|
|
16
|
+
error?: OpenfortError;
|
|
17
|
+
};
|
|
18
|
+
export type StoreCredentialsOptions = {
|
|
19
|
+
player: string;
|
|
20
|
+
accessToken: string;
|
|
21
|
+
refreshToken: string;
|
|
22
|
+
} & OpenfortHookOptions<StoreCredentialsResult> & CreateWalletPostAuthOptions;
|
|
23
|
+
export type AuthHookOptions = {
|
|
24
|
+
redirectTo?: string;
|
|
25
|
+
} & OpenfortHookOptions<StoreCredentialsResult> & CreateWalletPostAuthOptions;
|
|
13
26
|
export declare const useOAuth: (hookOptions?: AuthHookOptions) => {
|
|
14
27
|
isLoading: boolean;
|
|
15
28
|
isError: boolean;
|
|
16
29
|
isSuccess: boolean;
|
|
17
|
-
error:
|
|
30
|
+
error: OpenfortError | null | undefined;
|
|
18
31
|
initOAuth: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
|
|
19
32
|
linkOauth: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
|
|
33
|
+
storeCredentials: ({ player, accessToken, refreshToken, ...options }: StoreCredentialsOptions) => Promise<StoreCredentialsResult>;
|
|
20
34
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { OpenfortHookOptions,
|
|
1
|
+
import { OpenfortHookOptions, OpenfortError } from '../../../types';
|
|
2
2
|
export declare function useSignOut(hookOptions?: OpenfortHookOptions): {
|
|
3
3
|
signOut: (options?: OpenfortHookOptions) => Promise<{} | undefined>;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
isError: boolean;
|
|
6
6
|
isSuccess: boolean;
|
|
7
|
-
error:
|
|
7
|
+
error: OpenfortError | null | undefined;
|
|
8
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connector } from "wagmi";
|
|
2
|
-
import { OpenfortHookOptions,
|
|
2
|
+
import { OpenfortHookOptions, OpenfortError } from "../../../types";
|
|
3
3
|
type ConnectWalletOptions = {
|
|
4
4
|
connector: Connector | string;
|
|
5
5
|
};
|
|
@@ -7,13 +7,13 @@ export declare const useWalletAuth: (hookOptions?: OpenfortHookOptions) => {
|
|
|
7
7
|
isLoading: boolean;
|
|
8
8
|
isError: boolean;
|
|
9
9
|
isSuccess: boolean;
|
|
10
|
-
error:
|
|
10
|
+
error: OpenfortError | null | undefined;
|
|
11
11
|
walletConnectingTo: string | null;
|
|
12
12
|
connectWallet: (options: ConnectWalletOptions) => Promise<{
|
|
13
|
-
error:
|
|
13
|
+
error: OpenfortError;
|
|
14
14
|
} | undefined>;
|
|
15
15
|
linkWallet: (options: ConnectWalletOptions) => Promise<{
|
|
16
|
-
error:
|
|
16
|
+
error: OpenfortError;
|
|
17
17
|
} | undefined>;
|
|
18
18
|
availableWallets: import("../../../wallets/useWallets").WalletProps[];
|
|
19
19
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OpenfortHookOptions,
|
|
1
|
+
import { OpenfortHookOptions, OpenfortError } from "../../types";
|
|
2
2
|
export declare const onSuccess: <T>({ hookOptions, options, data, }: {
|
|
3
3
|
hookOptions?: OpenfortHookOptions<T>;
|
|
4
4
|
options?: OpenfortHookOptions<T>;
|
|
@@ -7,7 +7,7 @@ export declare const onSuccess: <T>({ hookOptions, options, data, }: {
|
|
|
7
7
|
export declare const onError: <T>({ hookOptions, options, error, }: {
|
|
8
8
|
hookOptions?: OpenfortHookOptions<T>;
|
|
9
9
|
options?: OpenfortHookOptions<T>;
|
|
10
|
-
error:
|
|
10
|
+
error: OpenfortError;
|
|
11
11
|
}) => {
|
|
12
|
-
error:
|
|
12
|
+
error: OpenfortError;
|
|
13
13
|
};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
export declare enum OpenfortKitStatus {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
CONNECTED_WITHOUT_USER = 4
|
|
2
|
+
DISCONNECTED = 0,
|
|
3
|
+
NEEDS_RECOVERY = 1,
|
|
4
|
+
LOADING = 2,
|
|
5
|
+
CONNECTED = 3
|
|
7
6
|
}
|
|
8
7
|
export declare function useStatus(): {
|
|
9
|
-
status: OpenfortKitStatus;
|
|
10
8
|
isLoading: boolean;
|
|
11
|
-
hasUser: boolean;
|
|
12
9
|
isConnected: boolean;
|
|
13
10
|
isDisconnected: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
isConnecting: boolean;
|
|
12
|
+
isAuthenticated: boolean;
|
|
16
13
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useWallet(): import("./useWallets").UserWallet | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Hex } from "viem";
|
|
1
2
|
import { Connector } from "wagmi";
|
|
2
3
|
import { embeddedWalletId } from "../../constants/openfort";
|
|
3
|
-
import {
|
|
4
|
-
import { OpenfortKitError } from "../../types";
|
|
4
|
+
import { OpenfortError, OpenfortHookOptions } from "../../types";
|
|
5
5
|
export type UserWallet = {
|
|
6
6
|
address?: `0x${string}`;
|
|
7
7
|
connectorType?: string;
|
|
@@ -9,9 +9,14 @@ export type UserWallet = {
|
|
|
9
9
|
connector?: Connector;
|
|
10
10
|
id: string;
|
|
11
11
|
isAvailable: boolean;
|
|
12
|
-
isActive
|
|
12
|
+
isActive?: boolean;
|
|
13
|
+
isConnecting?: boolean;
|
|
13
14
|
};
|
|
14
|
-
type
|
|
15
|
+
type SetActiveWalletResult = {
|
|
16
|
+
error?: OpenfortError;
|
|
17
|
+
wallet?: UserWallet;
|
|
18
|
+
};
|
|
19
|
+
type SetActiveWalletOptions = ({
|
|
15
20
|
showUI?: boolean;
|
|
16
21
|
address?: Hex | undefined;
|
|
17
22
|
} & ({
|
|
@@ -19,19 +24,36 @@ type SetActiveWalletOptions = {
|
|
|
19
24
|
} | {
|
|
20
25
|
connector: typeof embeddedWalletId;
|
|
21
26
|
password?: string;
|
|
22
|
-
})
|
|
23
|
-
|
|
27
|
+
})) & OpenfortHookOptions<SetActiveWalletResult>;
|
|
28
|
+
type CreateWalletResult = SetActiveWalletResult;
|
|
29
|
+
type CreateWalletOptions = {
|
|
30
|
+
password?: string;
|
|
31
|
+
} & OpenfortHookOptions<CreateWalletResult>;
|
|
32
|
+
type WalletOptions = OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
|
|
33
|
+
export declare function useWallets(hookOptions?: WalletOptions): {
|
|
24
34
|
exportPrivateKey: () => Promise<string>;
|
|
25
|
-
|
|
35
|
+
error: OpenfortError | null | undefined;
|
|
26
36
|
isError: boolean;
|
|
27
37
|
isSuccess: boolean;
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
isCreating: boolean;
|
|
39
|
+
isConnecting: boolean;
|
|
40
|
+
wallets: {
|
|
41
|
+
isConnecting: boolean;
|
|
42
|
+
isActive: boolean;
|
|
43
|
+
address?: `0x${string}`;
|
|
44
|
+
connectorType?: string;
|
|
45
|
+
walletClientType?: string;
|
|
46
|
+
connector?: Connector;
|
|
47
|
+
id: string;
|
|
48
|
+
isAvailable: boolean;
|
|
49
|
+
}[];
|
|
30
50
|
availableWallets: import("../../wallets/useWallets").WalletProps[];
|
|
31
51
|
activeWallet: UserWallet | undefined;
|
|
32
|
-
setActiveWallet: (options: SetActiveWalletOptions | string) => Promise<
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
setActiveWallet: (options: SetActiveWalletOptions | string) => Promise<SetActiveWalletResult>;
|
|
53
|
+
createWallet: ({ password, ...options }?: CreateWalletOptions) => Promise<{
|
|
54
|
+
error: OpenfortError;
|
|
55
|
+
} | {
|
|
56
|
+
wallet: UserWallet;
|
|
35
57
|
}>;
|
|
36
58
|
};
|
|
37
59
|
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ export * from './types';
|
|
|
3
3
|
export { default as getDefaultConfig } from './defaultConfig';
|
|
4
4
|
export { default as getDefaultConnectors } from './defaultConnectors';
|
|
5
5
|
export { wallets } from './wallets';
|
|
6
|
-
export { AuthProvider, } from './components/
|
|
7
|
-
export { OpenfortKitContext, } from './components/
|
|
8
|
-
export {
|
|
6
|
+
export { AuthProvider, } from './components/Openfort/types';
|
|
7
|
+
export { OpenfortKitContext, } from './components/Openfort/context';
|
|
8
|
+
export { OpenfortProvider, } from './components/Openfort/OpenfortKit';
|
|
9
9
|
export { OpenfortKitButton } from './components/ConnectButton';
|
|
10
10
|
export { default as Avatar } from './components/Common/Avatar';
|
|
11
11
|
export { default as ChainIcon } from './components/Common/Chain';
|
|
@@ -15,8 +15,9 @@ export { useStatus, OpenfortKitStatus } from './hooks/openfort/useStatus';
|
|
|
15
15
|
export { useUser } from './hooks/openfort/useUser';
|
|
16
16
|
export { useUI } from "./hooks/openfort/useUI";
|
|
17
17
|
export { useWallets, UserWallet } from "./hooks/openfort/useWallets";
|
|
18
|
+
export { useWallet } from "./hooks/openfort/useWallet";
|
|
18
19
|
export { RecoveryMethod, AuthPlayerResponse } from "@openfort/openfort-js";
|
|
19
|
-
export { useOpenfort } from './openfort/useOpenfort';
|
|
20
|
+
export { useOpenfortCore as useOpenfort } from './openfort/useOpenfort';
|
|
20
21
|
export { useConnectWithSiwe } from './hooks/openfort/useConnectWithSiwe';
|
|
21
22
|
export { embeddedWalletId } from './constants/openfort';
|
|
22
23
|
export { useEmailAuth } from './hooks/openfort/auth/useEmailAuth';
|