@openfort/react 0.0.34 → 0.1.0

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.
@@ -43,3 +43,6 @@ export declare const ShieldIcon: ({ ...props }: {
43
43
  export declare const FingerPrintIcon: ({ ...props }: {
44
44
  [x: string]: any;
45
45
  }) => import("react/jsx-runtime").JSX.Element;
46
+ export declare const PlusIcon: ({ ...props }: {
47
+ [x: string]: any;
48
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  type LoaderProps = {
2
2
  header: string;
3
- description?: string | undefined;
3
+ description?: string | undefined | false;
4
4
  isLoading?: boolean;
5
5
  icon?: React.ReactNode;
6
6
  isError?: boolean;
@@ -9,7 +9,6 @@ type ModalProps = {
9
9
  positionInside?: boolean;
10
10
  inline?: boolean;
11
11
  onClose?: () => void;
12
- onBack?: () => void;
13
12
  onInfo?: () => void;
14
13
  demo?: {
15
14
  theme: string;
@@ -1,5 +1,4 @@
1
1
  export declare const ErrorMessage: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
2
- export declare const PageContent: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
3
2
  export declare const TextWithHr: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {
4
3
  $disableHr?: boolean;
5
4
  }, never>;
@@ -8,6 +8,8 @@ declare const states: {
8
8
  NOTCONNECTED: string;
9
9
  UNAVAILABLE: string;
10
10
  DUPLICATED: string;
11
+ SIWE: string;
12
+ RECOVER_ADDRESS_MISMATCH: string;
11
13
  };
12
14
  declare const ConnectWithInjector: React.FC<{
13
15
  switchConnectMethod: (id?: string) => void;
@@ -1,17 +1,8 @@
1
- import type { OAuthProvider, SDKOverrides, ThirdPartyAuthConfiguration } from '@openfort/openfort-js';
1
+ import type { SDKOverrides, ThirdPartyAuthConfiguration } from '@openfort/openfort-js';
2
2
  import type React from 'react';
3
- import type { ValueOf } from 'viem/_types/types/utils';
4
3
  import type { useConnectCallbackProps } from '../../hooks/useConnectCallback';
5
4
  import type { CustomTheme, Languages, Mode, Theme } from '../../types';
6
- import type { OpenfortUIOptionsExtended, OpenfortWalletConfig, routes } from './types';
7
- type Connector = {
8
- id: string;
9
- type?: 'wallet';
10
- } | {
11
- id: OAuthProvider;
12
- type: 'oauth';
13
- };
14
- export type ErrorMessage = string | React.ReactNode | null;
5
+ import type { Connector, ErrorMessage, OpenfortUIOptionsExtended, OpenfortWalletConfig, RouteOptions, SetRouteOptions } from './types';
15
6
  export type ContextValue = {
16
7
  setTheme: React.Dispatch<React.SetStateAction<Theme>>;
17
8
  mode: Mode;
@@ -21,8 +12,14 @@ export type ContextValue = {
21
12
  setLang: React.Dispatch<React.SetStateAction<Languages>>;
22
13
  open: boolean;
23
14
  setOpen: React.Dispatch<React.SetStateAction<boolean>>;
24
- route: ValueOf<typeof routes>;
25
- setRoute: (r: ValueOf<typeof routes>) => void;
15
+ route: RouteOptions;
16
+ setRoute: (options: SetRouteOptions) => void;
17
+ onBack: (() => void) | null;
18
+ setOnBack: React.Dispatch<React.SetStateAction<(() => void) | null>>;
19
+ previousRoute: RouteOptions | null;
20
+ setPreviousRoute: () => void;
21
+ routeHistory: RouteOptions[];
22
+ setRouteHistory: React.Dispatch<React.SetStateAction<RouteOptions[]>>;
26
23
  connector: Connector;
27
24
  setConnector: React.Dispatch<React.SetStateAction<Connector>>;
28
25
  errorMessage: ErrorMessage;
@@ -37,4 +34,3 @@ export type ContextValue = {
37
34
  setEmailInput: React.Dispatch<React.SetStateAction<string>>;
38
35
  } & useConnectCallbackProps;
39
36
  export declare const Openfortcontext: React.Context<ContextValue | null>;
40
- export {};
@@ -1,12 +1,18 @@
1
- import type { AccountTypeEnum, RecoveryMethod } from '@openfort/openfort-js';
1
+ import type { AccountTypeEnum, OAuthProvider, RecoveryMethod } from '@openfort/openfort-js';
2
2
  import type React from 'react';
3
3
  import type { ReactNode } from 'react';
4
+ import type { UserWallet } from '../../hooks/openfort/useWallets';
4
5
  import type { CustomAvatarProps, CustomTheme, Languages, Mode, Theme } from '../../types';
5
6
  export declare const routes: {
6
7
  readonly PROVIDERS: "providers";
7
8
  readonly SOCIAL_PROVIDERS: "socialProviders";
8
9
  readonly LOADING: "loading";
9
- readonly RECOVER: "recover";
10
+ readonly LOAD_WALLETS: "loadWallets";
11
+ readonly RECOVER_WALLET: "recoverWallets";
12
+ readonly SELECT_WALLET_TO_RECOVER: "selectWalletToRecover";
13
+ readonly CREATE_WALLET: "createWallet";
14
+ readonly CONNECTED: "connected";
15
+ readonly CREATE_GUEST_USER: "createGuestUser";
10
16
  readonly EMAIL_LOGIN: "emailLogin";
11
17
  readonly FORGOT_PASSWORD: "forgotPassword";
12
18
  readonly EMAIL_VERIFICATION: "emailVerification";
@@ -21,6 +27,34 @@ export declare const routes: {
21
27
  readonly PROFILE: "profile";
22
28
  readonly SWITCHNETWORKS: "switchNetworks";
23
29
  };
30
+ type AllRoutes = (typeof routes)[keyof typeof routes];
31
+ export declare const notStoredInHistoryRoutes: AllRoutes[];
32
+ type ConnectOptions = {
33
+ connectType: 'link' | 'connect' | 'linkIfUserConnectIfNoUser';
34
+ } | {
35
+ connectType: 'recover';
36
+ wallet: UserWallet;
37
+ };
38
+ type RoutesWithOptions = ({
39
+ route: typeof routes.CONNECTORS;
40
+ } & ConnectOptions) | ({
41
+ route: typeof routes.CONNECT;
42
+ } & ConnectOptions) | {
43
+ route: typeof routes.RECOVER_WALLET;
44
+ wallet: UserWallet;
45
+ };
46
+ export type RoutesWithoutOptions = {
47
+ route: Exclude<AllRoutes, RoutesWithOptions['route']>;
48
+ };
49
+ export type RouteOptions = RoutesWithoutOptions | RoutesWithOptions;
50
+ export type SetRouteOptions = RouteOptions | RoutesWithoutOptions['route'];
51
+ export type Connector = {
52
+ id: string;
53
+ type?: 'wallet';
54
+ } | {
55
+ id: OAuthProvider;
56
+ type: 'oauth';
57
+ };
24
58
  export declare enum UIAuthProvider {
25
59
  GOOGLE = "google",
26
60
  TWITTER = "twitter",
@@ -31,7 +65,13 @@ export declare enum UIAuthProvider {
31
65
  WALLET = "wallet",
32
66
  GUEST = "guest"
33
67
  }
68
+ export type ErrorMessage = string | React.ReactNode | null;
34
69
  export declare const socialProviders: UIAuthProvider[];
70
+ export declare enum LinkWalletOnSignUpOption {
71
+ OPTIONAL = "optional",
72
+ REQUIRED = "required",
73
+ DISABLED = "disabled"
74
+ }
35
75
  type PolicyConfig = string | Record<number, string>;
36
76
  type CommonWalletConfig = {
37
77
  /** Publishable key for the Shield API. */
@@ -61,7 +101,7 @@ type EncryptionSession = {
61
101
  */
62
102
  export type OpenfortWalletConfig = CommonWalletConfig & EncryptionSession;
63
103
  type OpenfortUIOptions = {
64
- linkWalletOnSignUp?: boolean;
104
+ linkWalletOnSignUp?: LinkWalletOnSignUpOption;
65
105
  authProviders: UIAuthProvider[];
66
106
  skipEmailVerification?: boolean;
67
107
  termsOfServiceUrl?: string;
@@ -0,0 +1,10 @@
1
+ import type { SetRouteOptions } from '../Openfort/types';
2
+ export type SetOnBackFunction = (() => void) | null | 'inherit' | 'back' | SetRouteOptions;
3
+ type PageContentProps = {
4
+ children?: React.ReactNode;
5
+ width?: number | string;
6
+ onBack?: SetOnBackFunction;
7
+ logoutOnBack?: boolean;
8
+ };
9
+ export declare const PageContent: ({ children, width, onBack, logoutOnBack }: PageContentProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare const PageContentStyle: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {}, never>;
@@ -0,0 +1,2 @@
1
+ declare const Connected: React.FC;
2
+ export default Connected;
@@ -1,3 +1,4 @@
1
- import type React from 'react';
2
- declare const Wallets: React.FC;
3
- export default Wallets;
1
+ declare const Connectors: ({ logoutOnBack }: {
2
+ logoutOnBack?: boolean;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default Connectors;
@@ -0,0 +1,2 @@
1
+ declare const CreateGuestUserPage: () => import("react/jsx-runtime").JSX.Element;
2
+ export default CreateGuestUserPage;
@@ -0,0 +1,2 @@
1
+ declare const CreateWallet: React.FC;
2
+ export default CreateWallet;
@@ -0,0 +1,2 @@
1
+ declare const LoadWallets: React.FC;
2
+ export default LoadWallets;
@@ -0,0 +1,2 @@
1
+ declare const SelectWalletToRecover: React.FC;
2
+ export default SelectWalletToRecover;
@@ -1,6 +1,7 @@
1
+ import { type OpenfortErrorType } from '@openfort/openfort-js';
1
2
  export declare function useConnectWithSiwe(): ({ onError, onConnect, connectorType: propsConnectorType, walletClientType: propsWalletClientType, }?: {
2
3
  connectorType?: string;
3
4
  walletClientType?: string;
4
- onError?: (error: string, status?: number) => void;
5
+ onError?: (error: string, openfortError?: OpenfortErrorType) => void;
5
6
  onConnect?: () => void;
6
7
  }) => Promise<void>;
@@ -1 +1 @@
1
- export default function usePrevious(value: any, initial?: any): any;
1
+ export default function usePrevious<T>(value: T, initial: T): T;
@@ -0,0 +1,35 @@
1
+ import type { RouteOptions } from '../components/Openfort/types';
2
+ export declare const useRouteProps: <T extends RouteOptions["route"]>(currentRoute: T) => Extract<import("../components/Openfort/types").RoutesWithoutOptions, {
3
+ route: T;
4
+ }> | Extract<{
5
+ route: "connectors";
6
+ } & {
7
+ connectType: "link" | "connect" | "linkIfUserConnectIfNoUser";
8
+ }, {
9
+ route: T;
10
+ }> | Extract<{
11
+ route: "connectors";
12
+ } & {
13
+ connectType: "recover";
14
+ wallet: import("..").UserWallet;
15
+ }, {
16
+ route: T;
17
+ }> | Extract<{
18
+ route: "connect";
19
+ } & {
20
+ connectType: "link" | "connect" | "linkIfUserConnectIfNoUser";
21
+ }, {
22
+ route: T;
23
+ }> | Extract<{
24
+ route: "connect";
25
+ } & {
26
+ connectType: "recover";
27
+ wallet: import("..").UserWallet;
28
+ }, {
29
+ route: T;
30
+ }> | Extract<{
31
+ route: "recoverWallets";
32
+ wallet: import("..").UserWallet;
33
+ }, {
34
+ route: T;
35
+ }>;
package/build/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { default as Avatar } from './components/Common/Avatar';
3
3
  export { default as ChainIcon } from './components/Common/Chain';
4
4
  export { OpenfortButton } from './components/ConnectButton';
5
5
  export { OpenfortProvider } from './components/Openfort/OpenfortProvider';
6
- export { UIAuthProvider as AuthProvider } from './components/Openfort/types';
6
+ export { LinkWalletOnSignUpOption, UIAuthProvider as AuthProvider } from './components/Openfort/types';
7
7
  export { embeddedWalletId } from './constants/openfort';
8
8
  export { default as getDefaultConfig } from './defaultConfig';
9
9
  export { default as getDefaultConnectors } from './defaultConnectors';