@openfort/react 0.0.1 → 0.0.2

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 (29) hide show
  1. package/README.md +4 -8
  2. package/build/components/{OpenfortKit → Openfort}/OpenfortKit.d.ts +6 -6
  3. package/build/components/{OpenfortKit → Openfort}/context.d.ts +2 -2
  4. package/build/components/{OpenfortKit → Openfort}/types.d.ts +4 -4
  5. package/build/components/Pages/Providers/index.d.ts +1 -1
  6. package/build/hooks/openfort/auth/status.d.ts +3 -3
  7. package/build/hooks/openfort/auth/useAuthCallback.d.ts +5 -5
  8. package/build/hooks/openfort/auth/useCreateWalletPostAuth.d.ts +1 -1
  9. package/build/hooks/openfort/auth/useEmailAuth.d.ts +3 -3
  10. package/build/hooks/openfort/auth/useGuestAuth.d.ts +3 -3
  11. package/build/hooks/openfort/auth/useOAuth.d.ts +4 -4
  12. package/build/hooks/openfort/auth/useSignOut.d.ts +2 -2
  13. package/build/hooks/openfort/auth/useWalletAuth.d.ts +4 -4
  14. package/build/hooks/openfort/hookConsistency.d.ts +3 -3
  15. package/build/hooks/openfort/useProviders.d.ts +1 -1
  16. package/build/hooks/openfort/useStatus.d.ts +6 -9
  17. package/build/hooks/openfort/useUser.d.ts +1 -0
  18. package/build/hooks/openfort/useWallet.d.ts +1 -0
  19. package/build/hooks/openfort/useWallets.d.ts +20 -9
  20. package/build/index.d.ts +5 -4
  21. package/build/index.es.js +356 -245
  22. package/build/index.es.js.map +1 -1
  23. package/build/openfort/OpenfortProvider.d.ts +2 -2
  24. package/build/openfort/useOpenfort.d.ts +1 -1
  25. package/build/types.d.ts +10 -9
  26. package/build/version.d.ts +1 -1
  27. package/package.json +3 -3
  28. package/build/openfort/OpenfortProvider_old.d.ts +0 -0
  29. /package/build/components/{OpenfortKit → Openfort}/useOpenfortKit.d.ts +0 -0
package/README.md CHANGED
@@ -33,18 +33,14 @@
33
33
  [![Version](https://img.shields.io/npm/v/@openfort/react.svg)](https://www.npmjs.org/package/@openfort/react)
34
34
 
35
35
 
36
- The easiest way to integrate Openfort to your project, with built-in authentication and seamless wallet connectivity.
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
36
+ The easiest way to use embedded wallets, with built-in authentication and payments capabilities.
41
37
 
42
38
  ## Features
43
39
 
44
40
  - 💡 TypeScript Ready — Get types straight out of the box.
45
- - 🌱 Ecosystem Standards — Uses top libraries such as [wagmi](https://github.com/wagmi-dev/wagmi).
46
- - 🖥️ Simple UXGive users a simple, attractive experience.
47
- - 🎨 Beautiful Themes Predesigned themes or full customization.
41
+ - 🌱 Ecosystem Friendly — Uses top libraries such as [wagmi](https://github.com/wagmi-dev/wagmi) for hooks.
42
+ - 🎨 Simple UIUse prebuilt elements for authenticaiton and wallet connection.
43
+ - 🖥️ React Hooks - To interact directly with embedded wallet capabilities.
48
44
 
49
45
  and much more...
50
46
 
@@ -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 { ConnectKitOptions, OpenfortWalletConfig } from './types';
5
- type OpenfortKitProviderProps = {
4
+ import { ConnectUIOptions, OpenfortWalletConfig } from './types';
5
+ type OpenfortProviderProps = {
6
6
  children?: React.ReactNode;
7
7
  debugMode?: boolean;
8
8
  publishableKey: string;
9
- uiConfig?: ConnectKitOptions;
9
+ uiConfig?: ConnectUIOptions;
10
10
  walletConfig?: OpenfortWalletConfig;
11
11
  } & useConnectCallbackProps;
12
12
  /**
13
- * OpenfortKitProvider component provides context and configuration for OpenfortKit.
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 {ConnectKitOptions} [options] - Additional configuration options.
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 OpenfortKitProvider: ({ children, uiConfig, onConnect, onDisconnect, debugMode, publishableKey, walletConfig, }: OpenfortKitProviderProps) => React.FunctionComponentElement<React.ProviderProps<ContextValue | null>>;
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 { ConnectKitOptionsExtended, OpenfortWalletConfig, routes } from './types';
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?: ConnectKitOptionsExtended;
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 { OpenfortProviderProps } from '../../openfort/OpenfortProvider';
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?: OpenfortProviderProps['overrides'];
87
+ openfortUrlOverrides?: CoreOpenfortProviderProps['overrides'];
88
88
  };
89
- export type ConnectKitOptions = {
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 ConnectKitOptionsExtended = {
110
+ export type OpenfortUIOptionsExtended = {
111
111
  theme: Theme;
112
112
  mode: Mode;
113
113
  customTheme?: CustomTheme;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { AuthProvider } from "../../OpenfortKit/types";
2
+ import { AuthProvider } from "../../Openfort/types";
3
3
  export declare const ProviderButtonSwitch: React.FC<{
4
4
  provider: AuthProvider;
5
5
  }>;
@@ -1,14 +1,14 @@
1
- import { OpenfortKitError } from "../../../types";
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: OpenfortKitError | null;
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: OpenfortKitError | null | undefined;
13
+ error: OpenfortError | null | undefined;
14
14
  };
@@ -1,18 +1,18 @@
1
- import { OpenfortHookOptions, OpenfortKitError } from "../../../types";
2
- import { AuthProvider } from "../../../components/OpenfortKit/types";
1
+ import { OpenfortHookOptions, OpenfortError } from "../../../types";
2
+ import { AuthProvider } from "../../../components/Openfort/types";
3
3
  import { UserWallet } from "../useWallets";
4
4
  import { type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
5
5
  type CallbackResult = StoreCredentialsResult | EmailVerificationResult;
6
6
  type EmailVerificationResult = {
7
7
  type: "verifyEmail";
8
8
  email?: string;
9
- error?: OpenfortKitError;
9
+ error?: OpenfortError;
10
10
  };
11
11
  type StoreCredentialsResult = {
12
12
  type: "storeCredentials";
13
13
  user?: OpenfortUser;
14
14
  wallet?: UserWallet;
15
- error?: OpenfortKitError;
15
+ error?: OpenfortError;
16
16
  };
17
17
  type VerifyEmailOptions = {
18
18
  email: string;
@@ -30,7 +30,7 @@ export declare const useAuthCallback: ({ automaticallyHandleCallback, ...hookOpt
30
30
  isLoading: boolean;
31
31
  isError: boolean;
32
32
  isSuccess: boolean;
33
- error: OpenfortKitError | null | undefined;
33
+ error: OpenfortError | null | undefined;
34
34
  email: string | null;
35
35
  provider: AuthProvider | null;
36
36
  verifyEmail: ({ email, state, ...options }: VerifyEmailOptions) => Promise<EmailVerificationResult>;
@@ -1,6 +1,6 @@
1
1
  export declare const useCreateWalletPostAuth: () => {
2
2
  tryUseWallet: () => Promise<{
3
- error?: string;
3
+ error?: import("../../..").OpenfortError;
4
4
  wallet?: import("../useWallets").UserWallet;
5
5
  }>;
6
6
  };
@@ -1,8 +1,8 @@
1
1
  import { type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
2
- import { OpenfortHookOptions, OpenfortKitError } from "../../../types";
2
+ import { OpenfortHookOptions, OpenfortError } from "../../../types";
3
3
  import { UserWallet } from '../useWallets';
4
4
  export type EmailAuthResult = {
5
- error?: OpenfortKitError;
5
+ error?: OpenfortError;
6
6
  user?: OpenfortUser;
7
7
  wallet?: UserWallet;
8
8
  requiresEmailVerification?: boolean;
@@ -41,7 +41,7 @@ export declare const useEmailAuth: (hookOptions?: UseEmailHookOptions) => {
41
41
  isLoading: boolean;
42
42
  isError: boolean;
43
43
  isSuccess: boolean;
44
- error: OpenfortKitError | null | undefined;
44
+ error: OpenfortError | null | undefined;
45
45
  signInEmail: (options: SignInEmailOptions) => Promise<EmailAuthResult>;
46
46
  signUpEmail: (options: SignUpEmailOptions) => Promise<EmailAuthResult>;
47
47
  linkEmail: (options: LinkEmailOptions) => Promise<EmailAuthResult>;
@@ -1,8 +1,8 @@
1
1
  import { type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
2
- import { OpenfortHookOptions, OpenfortKitError } from "../../../types";
2
+ import { OpenfortHookOptions, OpenfortError } from "../../../types";
3
3
  import { UserWallet } from "../useWallets";
4
4
  export type GuestHookResult = {
5
- error?: OpenfortKitError;
5
+ error?: OpenfortError;
6
6
  user?: OpenfortUser;
7
7
  wallet?: UserWallet;
8
8
  };
@@ -11,6 +11,6 @@ export declare const useGuestAuth: (hookOptions?: GuestHookOptions) => {
11
11
  isLoading: boolean;
12
12
  isError: boolean;
13
13
  isSuccess: boolean;
14
- error: OpenfortKitError | null | undefined;
14
+ error: OpenfortError | null | undefined;
15
15
  signUpGuest: (options?: GuestHookOptions) => Promise<GuestHookResult>;
16
16
  };
@@ -1,5 +1,5 @@
1
- import { AuthProvider } from '../../../components/OpenfortKit/types';
2
- import { OpenfortHookOptions, OpenfortKitError } from '../../../types';
1
+ import { AuthProvider } from '../../../components/Openfort/types';
2
+ import { OpenfortHookOptions, OpenfortError } from '../../../types';
3
3
  export type InitializeOAuthOptions = {
4
4
  provider: AuthProvider;
5
5
  redirectTo?: string;
@@ -8,13 +8,13 @@ export type AuthHookOptions = {
8
8
  redirectTo?: string;
9
9
  } & OpenfortHookOptions;
10
10
  export type InitOAuthReturnType = {
11
- error?: OpenfortKitError;
11
+ error?: OpenfortError;
12
12
  };
13
13
  export declare const useOAuth: (hookOptions?: AuthHookOptions) => {
14
14
  isLoading: boolean;
15
15
  isError: boolean;
16
16
  isSuccess: boolean;
17
- error: OpenfortKitError | null | undefined;
17
+ error: OpenfortError | null | undefined;
18
18
  initOAuth: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
19
19
  linkOauth: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
20
20
  };
@@ -1,8 +1,8 @@
1
- import { OpenfortHookOptions, OpenfortKitError } from '../../../types';
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: OpenfortKitError | null | undefined;
7
+ error: OpenfortError | null | undefined;
8
8
  };
@@ -1,5 +1,5 @@
1
1
  import { Connector } from "wagmi";
2
- import { OpenfortHookOptions, OpenfortKitError } from "../../../types";
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: OpenfortKitError | null | undefined;
10
+ error: OpenfortError | null | undefined;
11
11
  walletConnectingTo: string | null;
12
12
  connectWallet: (options: ConnectWalletOptions) => Promise<{
13
- error: OpenfortKitError;
13
+ error: OpenfortError;
14
14
  } | undefined>;
15
15
  linkWallet: (options: ConnectWalletOptions) => Promise<{
16
- error: OpenfortKitError;
16
+ error: OpenfortError;
17
17
  } | undefined>;
18
18
  availableWallets: import("../../../wallets/useWallets").WalletProps[];
19
19
  };
@@ -1,4 +1,4 @@
1
- import { OpenfortHookOptions, OpenfortKitError } from "../../types";
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: OpenfortKitError;
10
+ error: OpenfortError;
11
11
  }) => {
12
- error: OpenfortKitError;
12
+ error: OpenfortError;
13
13
  };
@@ -1,4 +1,4 @@
1
- import { AuthProvider } from "../../components/OpenfortKit/types";
1
+ import { AuthProvider } from "../../components/Openfort/types";
2
2
  export declare function useProviders(): {
3
3
  availableProviders: AuthProvider[];
4
4
  linkedProviders: AuthProvider[];
@@ -1,16 +1,13 @@
1
1
  export declare enum OpenfortKitStatus {
2
- LOADING = 0,
3
- CONNECTED = 1,
4
- DISCONNECTED = 2,
5
- NEEDS_RECOVERY = 3,
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
- isConnectedWithoutUser: boolean;
15
- needsRecovery: boolean;
11
+ isConnecting: boolean;
12
+ isAuthenticated: boolean;
16
13
  };
@@ -1,5 +1,6 @@
1
1
  export declare function useUser(): {
2
2
  user: import("@openfort/openfort-js").AuthPlayerResponse | null;
3
+ isAuthenticated: boolean;
3
4
  getAccessToken: () => Promise<string | null>;
4
5
  validateAndRefreshToken: () => Promise<void>;
5
6
  };
@@ -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 { Hex } from "viem";
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;
@@ -11,7 +11,11 @@ export type UserWallet = {
11
11
  isAvailable: boolean;
12
12
  isActive: boolean;
13
13
  };
14
- type SetActiveWalletOptions = {
14
+ type SetActiveWalletResult = {
15
+ error?: OpenfortError;
16
+ wallet?: UserWallet;
17
+ };
18
+ type SetActiveWalletOptions = ({
15
19
  showUI?: boolean;
16
20
  address?: Hex | undefined;
17
21
  } & ({
@@ -19,19 +23,26 @@ type SetActiveWalletOptions = {
19
23
  } | {
20
24
  connector: typeof embeddedWalletId;
21
25
  password?: string;
22
- });
23
- export declare function useWallets(): {
26
+ })) & OpenfortHookOptions<SetActiveWalletResult>;
27
+ type CreateWalletResult = SetActiveWalletResult;
28
+ type CreateWalletOptions = {
29
+ password?: string;
30
+ } & OpenfortHookOptions<CreateWalletResult>;
31
+ type WalletOptions = OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
32
+ export declare function useWallets(hookOptions?: WalletOptions): {
24
33
  exportPrivateKey: () => Promise<string>;
25
34
  isLoading: boolean;
26
35
  isError: boolean;
27
36
  isSuccess: boolean;
28
- error: OpenfortKitError | null | undefined;
37
+ error: OpenfortError | null | undefined;
29
38
  wallets: UserWallet[];
30
39
  availableWallets: import("../../wallets/useWallets").WalletProps[];
31
40
  activeWallet: UserWallet | undefined;
32
- setActiveWallet: (options: SetActiveWalletOptions | string) => Promise<{
33
- error?: string;
34
- wallet?: UserWallet;
41
+ setActiveWallet: (options: SetActiveWalletOptions | string) => Promise<SetActiveWalletResult>;
42
+ createWallet: ({ password, ...options }?: CreateWalletOptions) => Promise<{
43
+ error: OpenfortError;
44
+ } | {
45
+ wallet: UserWallet;
35
46
  }>;
36
47
  };
37
48
  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/OpenfortKit/types';
7
- export { OpenfortKitContext, } from './components/OpenfortKit/context';
8
- export { OpenfortKitProvider, } from './components/OpenfortKit/OpenfortKit';
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';