@insforge/react 0.6.0 → 0.6.1

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/dist/index.d.cts CHANGED
@@ -3,69 +3,17 @@ export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPa
3
3
  export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps } from './atoms.cjs';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ReactNode } from 'react';
6
- import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.cjs';
7
- export { AuthConfig, EmailVerificationMethod } from './types.cjs';
8
- import { UserSchema } from '@insforge/sdk';
9
- import { CreateSessionResponse, CreateUserResponse, ResetPasswordResponse, GetPublicAuthConfigResponse } from '@insforge/shared-schemas';
6
+ import { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
7
+ export { InsforgeContextValue, InsforgeUser, OAuthProvider } from '@insforge/shared';
10
8
  export { useAuth, usePublicAuthConfig, useUser } from './hooks.cjs';
11
9
  export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword } from './lib.cjs';
10
+ import { OAuthProviderConfig } from './types.cjs';
11
+ export { AuthConfig, EmailVerificationMethod } from './types.cjs';
12
12
  export { BrowserNavigationAdapter, NavigationAdapter, NavigationProvider, NavigationProviderProps, useNavigationAdapter, useSearchParams } from './navigation.cjs';
13
+ import '@insforge/sdk';
14
+ import '@insforge/shared-schemas';
13
15
  import 'zod';
14
16
 
15
- interface InsforgeContextValue {
16
- user: InsforgeUser | null;
17
- isLoaded: boolean;
18
- isSignedIn: boolean;
19
- setUser: (user: InsforgeUser | null) => void;
20
- signIn: (email: string, password: string) => Promise<CreateSessionResponse | {
21
- error: string;
22
- statusCode?: number;
23
- errorCode?: string;
24
- }>;
25
- signUp: (email: string, password: string) => Promise<CreateUserResponse | {
26
- error: string;
27
- statusCode?: number;
28
- errorCode?: string;
29
- }>;
30
- signOut: () => Promise<void>;
31
- updateUser: (data: Partial<InsforgeUser>) => Promise<{
32
- error: string;
33
- } | null>;
34
- reloadAuth: () => Promise<{
35
- success: boolean;
36
- error?: string;
37
- }>;
38
- sendVerificationEmail: (email: string) => Promise<{
39
- success: boolean;
40
- message: string;
41
- } | null>;
42
- sendResetPasswordEmail: (email: string) => Promise<{
43
- success: boolean;
44
- message: string;
45
- } | null>;
46
- resetPassword: (token: string, newPassword: string) => Promise<ResetPasswordResponse | null>;
47
- verifyEmail: (otp: string, email?: string) => Promise<{
48
- accessToken: string;
49
- user?: UserSchema;
50
- redirectTo?: string;
51
- error?: {
52
- message: string;
53
- };
54
- } | null>;
55
- exchangeResetPasswordToken: (email: string, code: string) => Promise<{
56
- token: string;
57
- expiresAt?: string;
58
- } | {
59
- error: {
60
- message: string;
61
- };
62
- }>;
63
- loginWithOAuth: (provider: OAuthProvider, redirectTo: string) => Promise<void>;
64
- getPublicAuthConfig: () => Promise<GetPublicAuthConfigResponse | null>;
65
- baseUrl: string;
66
- afterSignInUrl: string;
67
- }
68
-
69
17
  interface InsforgeProviderProps {
70
18
  children: ReactNode;
71
19
  baseUrl: string;
@@ -152,4 +100,4 @@ declare function getProviderConfig(provider: OAuthProvider): OAuthProviderConfig
152
100
  */
153
101
  declare function getAllProviderConfigs(): Partial<Record<OAuthProvider, OAuthProviderConfig>>;
154
102
 
155
- export { type InsforgeContextValue, InsforgeProvider, InsforgeProviderCore, type InsforgeProviderProps, InsforgeUser, OAUTH_PROVIDER_CONFIG, OAuthProvider, OAuthProviderConfig, getAllProviderConfigs, getProviderConfig, useInsforge };
103
+ export { InsforgeProvider, InsforgeProviderCore, type InsforgeProviderProps, OAUTH_PROVIDER_CONFIG, OAuthProviderConfig, getAllProviderConfigs, getProviderConfig, useInsforge };
package/dist/index.d.ts CHANGED
@@ -3,69 +3,17 @@ export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPa
3
3
  export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps } from './atoms.js';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ReactNode } from 'react';
6
- import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.js';
7
- export { AuthConfig, EmailVerificationMethod } from './types.js';
8
- import { UserSchema } from '@insforge/sdk';
9
- import { CreateSessionResponse, CreateUserResponse, ResetPasswordResponse, GetPublicAuthConfigResponse } from '@insforge/shared-schemas';
6
+ import { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
7
+ export { InsforgeContextValue, InsforgeUser, OAuthProvider } from '@insforge/shared';
10
8
  export { useAuth, usePublicAuthConfig, useUser } from './hooks.js';
11
9
  export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword } from './lib.js';
10
+ import { OAuthProviderConfig } from './types.js';
11
+ export { AuthConfig, EmailVerificationMethod } from './types.js';
12
12
  export { BrowserNavigationAdapter, NavigationAdapter, NavigationProvider, NavigationProviderProps, useNavigationAdapter, useSearchParams } from './navigation.js';
13
+ import '@insforge/sdk';
14
+ import '@insforge/shared-schemas';
13
15
  import 'zod';
14
16
 
15
- interface InsforgeContextValue {
16
- user: InsforgeUser | null;
17
- isLoaded: boolean;
18
- isSignedIn: boolean;
19
- setUser: (user: InsforgeUser | null) => void;
20
- signIn: (email: string, password: string) => Promise<CreateSessionResponse | {
21
- error: string;
22
- statusCode?: number;
23
- errorCode?: string;
24
- }>;
25
- signUp: (email: string, password: string) => Promise<CreateUserResponse | {
26
- error: string;
27
- statusCode?: number;
28
- errorCode?: string;
29
- }>;
30
- signOut: () => Promise<void>;
31
- updateUser: (data: Partial<InsforgeUser>) => Promise<{
32
- error: string;
33
- } | null>;
34
- reloadAuth: () => Promise<{
35
- success: boolean;
36
- error?: string;
37
- }>;
38
- sendVerificationEmail: (email: string) => Promise<{
39
- success: boolean;
40
- message: string;
41
- } | null>;
42
- sendResetPasswordEmail: (email: string) => Promise<{
43
- success: boolean;
44
- message: string;
45
- } | null>;
46
- resetPassword: (token: string, newPassword: string) => Promise<ResetPasswordResponse | null>;
47
- verifyEmail: (otp: string, email?: string) => Promise<{
48
- accessToken: string;
49
- user?: UserSchema;
50
- redirectTo?: string;
51
- error?: {
52
- message: string;
53
- };
54
- } | null>;
55
- exchangeResetPasswordToken: (email: string, code: string) => Promise<{
56
- token: string;
57
- expiresAt?: string;
58
- } | {
59
- error: {
60
- message: string;
61
- };
62
- }>;
63
- loginWithOAuth: (provider: OAuthProvider, redirectTo: string) => Promise<void>;
64
- getPublicAuthConfig: () => Promise<GetPublicAuthConfigResponse | null>;
65
- baseUrl: string;
66
- afterSignInUrl: string;
67
- }
68
-
69
17
  interface InsforgeProviderProps {
70
18
  children: ReactNode;
71
19
  baseUrl: string;
@@ -152,4 +100,4 @@ declare function getProviderConfig(provider: OAuthProvider): OAuthProviderConfig
152
100
  */
153
101
  declare function getAllProviderConfigs(): Partial<Record<OAuthProvider, OAuthProviderConfig>>;
154
102
 
155
- export { type InsforgeContextValue, InsforgeProvider, InsforgeProviderCore, type InsforgeProviderProps, InsforgeUser, OAUTH_PROVIDER_CONFIG, OAuthProvider, OAuthProviderConfig, getAllProviderConfigs, getProviderConfig, useInsforge };
103
+ export { InsforgeProvider, InsforgeProviderCore, type InsforgeProviderProps, OAUTH_PROVIDER_CONFIG, OAuthProviderConfig, getAllProviderConfigs, getProviderConfig, useInsforge };
package/dist/index.js CHANGED
@@ -15,12 +15,11 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
15
15
  import { createContext, useContext, useState, useMemo, useEffect, useRef, useCallback, isValidElement, cloneElement } from 'react';
16
16
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
17
17
  import { createClient } from '@insforge/sdk';
18
+ import { InsforgeContext } from '@insforge/shared/react';
18
19
  import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck, LogOut } from 'lucide-react';
19
20
  import { z } from 'zod';
20
21
 
21
- var __defProp = Object.defineProperty;
22
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
23
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ // src/components/SignIn.tsx
24
23
  var NavigationContext = createContext(null);
25
24
  function NavigationProvider({ adapter, children }) {
26
25
  return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: adapter, children });
@@ -64,18 +63,20 @@ function useSearchParams() {
64
63
  const adapter = useNavigationAdapter();
65
64
  return adapter.useSearchParams();
66
65
  }
67
- var _InsforgeManager = class _InsforgeManager {
66
+ var InsforgeManager = class _InsforgeManager {
67
+ // Static private instance
68
+ static instance = null;
69
+ // State storage
70
+ user = null;
71
+ isLoaded = false;
72
+ sdk;
73
+ listeners = /* @__PURE__ */ new Set();
74
+ // Config
75
+ config;
76
+ refreshIntervalRef = null;
77
+ hasProcessedCallbackRef = false;
68
78
  // Private constructor (prevents external instantiation)
69
79
  constructor(config) {
70
- // State storage
71
- __publicField(this, "user", null);
72
- __publicField(this, "isLoaded", false);
73
- __publicField(this, "sdk");
74
- __publicField(this, "listeners", /* @__PURE__ */ new Set());
75
- // Config
76
- __publicField(this, "config");
77
- __publicField(this, "refreshIntervalRef", null);
78
- __publicField(this, "hasProcessedCallbackRef", false);
79
80
  this.config = config;
80
81
  this.sdk = createClient({ baseUrl: config.baseUrl });
81
82
  }
@@ -328,9 +329,9 @@ var _InsforgeManager = class _InsforgeManager {
328
329
  this.notifyListeners();
329
330
  }
330
331
  return null;
331
- } else {
332
- return { error: result.error?.message || "Failed to update user" };
333
332
  }
333
+ const error = result.error;
334
+ return { error: error?.message || "Failed to update user" };
334
335
  }
335
336
  async reloadAuth() {
336
337
  return await this.loadAuthState();
@@ -439,11 +440,6 @@ var _InsforgeManager = class _InsforgeManager {
439
440
  this.listeners.clear();
440
441
  }
441
442
  };
442
- // Static private instance
443
- __publicField(_InsforgeManager, "instance", null);
444
- var InsforgeManager = _InsforgeManager;
445
- var InsforgeContext = createContext(void 0);
446
- InsforgeContext.displayName = "InsforgeContext";
447
443
  function InsforgeProviderCore({
448
444
  children,
449
445
  baseUrl,
@@ -467,7 +463,7 @@ function InsforgeProviderCore({
467
463
  const unsubscribe = manager.subscribe((newState) => {
468
464
  setState(newState);
469
465
  });
470
- manager.initialize();
466
+ void manager.initialize();
471
467
  return unsubscribe;
472
468
  }, [manager]);
473
469
  useEffect(() => {
@@ -515,20 +511,18 @@ function useInsforge() {
515
511
  isSignedIn: false,
516
512
  setUser: () => {
517
513
  },
518
- signIn: async () => ({ error: "SSR mode" }),
519
- signUp: async () => ({ error: "SSR mode" }),
520
- signOut: async () => {
521
- },
522
- updateUser: async () => ({ error: "SSR mode" }),
523
- reloadAuth: async () => ({ success: false, error: "SSR mode" }),
524
- sendVerificationEmail: async () => null,
525
- sendResetPasswordEmail: async () => null,
526
- resetPassword: async () => null,
527
- verifyEmail: async () => null,
528
- exchangeResetPasswordToken: async () => ({ error: { message: "SSR mode" } }),
529
- loginWithOAuth: async () => {
530
- },
531
- getPublicAuthConfig: async () => null,
514
+ signIn: () => Promise.resolve({ error: "SSR mode" }),
515
+ signUp: () => Promise.resolve({ error: "SSR mode" }),
516
+ signOut: () => Promise.resolve(),
517
+ updateUser: () => Promise.resolve({ error: "SSR mode" }),
518
+ reloadAuth: () => Promise.resolve({ success: false, error: "SSR mode" }),
519
+ sendVerificationEmail: () => Promise.resolve(null),
520
+ sendResetPasswordEmail: () => Promise.resolve(null),
521
+ resetPassword: () => Promise.resolve(null),
522
+ verifyEmail: () => Promise.resolve(null),
523
+ exchangeResetPasswordToken: () => Promise.resolve({ error: { message: "SSR mode" } }),
524
+ loginWithOAuth: () => Promise.resolve(),
525
+ getPublicAuthConfig: () => Promise.resolve(null),
532
526
  baseUrl: "",
533
527
  afterSignInUrl: "/"
534
528
  };
@@ -550,7 +544,7 @@ function usePublicAuthConfig() {
550
544
  }
551
545
  setIsLoaded(true);
552
546
  }
553
- fetchConfig();
547
+ void fetchConfig();
554
548
  }, [getPublicAuthConfig]);
555
549
  return { authConfig, isLoaded };
556
550
  }
@@ -1519,7 +1513,7 @@ function SignIn({ onError, ...uiProps }) {
1519
1513
  }
1520
1514
  function handleOAuth(provider) {
1521
1515
  try {
1522
- loginWithOAuth(provider, redirectUrl || "");
1516
+ void loginWithOAuth(provider, redirectUrl || "");
1523
1517
  } catch (err) {
1524
1518
  const errorMessage = err instanceof Error ? err.message : "OAuth login failed";
1525
1519
  setError(errorMessage);
@@ -1538,7 +1532,7 @@ function SignIn({ onError, ...uiProps }) {
1538
1532
  password,
1539
1533
  onEmailChange: setEmail,
1540
1534
  onPasswordChange: setPassword,
1541
- onSubmit: handleSubmit,
1535
+ onSubmit: (e) => void handleSubmit(e),
1542
1536
  error,
1543
1537
  loading,
1544
1538
  oauthLoading,
@@ -1796,7 +1790,7 @@ function SignUp({ onError, ...uiProps }) {
1796
1790
  }
1797
1791
  function handleOAuth(provider) {
1798
1792
  try {
1799
- loginWithOAuth(provider, redirectUrl || "");
1793
+ void loginWithOAuth(provider, redirectUrl || "");
1800
1794
  } catch (err) {
1801
1795
  const errorMessage = err instanceof Error ? err.message : "OAuth login failed";
1802
1796
  setError(errorMessage);
@@ -1815,7 +1809,7 @@ function SignUp({ onError, ...uiProps }) {
1815
1809
  password,
1816
1810
  onEmailChange: setEmail,
1817
1811
  onPasswordChange: setPassword,
1818
- onSubmit: handleSubmit,
1812
+ onSubmit: (e) => void handleSubmit(e),
1819
1813
  error,
1820
1814
  loading,
1821
1815
  oauthLoading,
@@ -2125,7 +2119,7 @@ function ForgotPassword({ onError, ...uiProps }) {
2125
2119
  confirmPassword,
2126
2120
  onNewPasswordChange: setNewPassword,
2127
2121
  onConfirmPasswordChange: setConfirmPassword,
2128
- onSubmit: handleResetPasswordSubmit,
2122
+ onSubmit: (e) => void handleResetPasswordSubmit(e),
2129
2123
  error,
2130
2124
  loading,
2131
2125
  success,
@@ -2300,7 +2294,7 @@ function ResetPassword({ onError, ...uiProps }) {
2300
2294
  confirmPassword,
2301
2295
  onNewPasswordChange: setNewPassword,
2302
2296
  onConfirmPasswordChange: setConfirmPassword,
2303
- onSubmit: handleSubmit,
2297
+ onSubmit: (e) => void handleSubmit(e),
2304
2298
  error,
2305
2299
  loading,
2306
2300
  success: false,
@@ -2424,7 +2418,7 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
2424
2418
  setImageError(true);
2425
2419
  }
2426
2420
  };
2427
- checkImageUrl();
2421
+ void checkImageUrl();
2428
2422
  }, [user?.avatarUrl]);
2429
2423
  useEffect(() => {
2430
2424
  function handleClickOutside(event) {
@@ -2477,7 +2471,7 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
2477
2471
  isOpen && /* @__PURE__ */ jsx("div", { className: "if-userButton-menu", children: /* @__PURE__ */ jsxs(
2478
2472
  "button",
2479
2473
  {
2480
- onClick: handleSignOut,
2474
+ onClick: () => void handleSignOut(),
2481
2475
  className: "if-userButton-menuItem if-userButton-menuItem-signout",
2482
2476
  children: [
2483
2477
  /* @__PURE__ */ jsx(LogOut, { className: "if-userButton-menuItem-icon" }),