@riligar/auth-react 1.20.13 → 1.21.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.
package/dist/index.esm.js CHANGED
@@ -9,18 +9,21 @@ import { IconMail, IconLock, IconArrowRight, IconBrandGoogle, IconBrandGithub, I
9
9
  import { notifications } from '@mantine/notifications';
10
10
 
11
11
  // Config - API Base URL fixa para o serviço de autenticação
12
- const API_BASE = 'https://manager.myauth.click';
12
+ let API_BASE = 'https://manager.myauth.click';
13
13
  let API_KEY = null;
14
14
  let INTERNAL_MODE = false; // Modo interno: não exige API Key (para aplicações same-domain)
15
15
 
16
16
  // Permite configurar API key e modo interno externamente (chamado pelo AuthProvider)
17
17
  function configure({
18
18
  apiKey,
19
+ apiUrl,
19
20
  internal = false
20
21
  }) {
21
22
  if (apiKey) API_KEY = apiKey;
23
+ if (apiUrl) API_BASE = apiUrl.endsWith('/') ? apiUrl.slice(0, -1) : apiUrl;
22
24
  INTERNAL_MODE = internal;
23
25
  }
26
+ const isInternal = () => INTERNAL_MODE;
24
27
 
25
28
  // helper fetch pré-configurado
26
29
  async function api(route, opts = {}) {
@@ -369,7 +372,10 @@ const useAuthStore = create((set, get) => ({
369
372
  } = get();
370
373
  try {
371
374
  // Buscar application info primeiro (não bloqueia o init)
372
- fetchApplicationInfo();
375
+ // Apenas se não estiver em modo interno (dashboard)
376
+ if (!isInternal()) {
377
+ fetchApplicationInfo();
378
+ }
373
379
  let user = null;
374
380
 
375
381
  // PRIMEIRO: Tenta buscar sessão do servidor (funciona com cookies)
@@ -870,6 +876,8 @@ function AuthProvider({
870
876
  children,
871
877
  apiKey,
872
878
  // API Key para header X-API-Key (obrigatória exceto em modo internal)
879
+ apiUrl,
880
+ // URL do manager (opcional, padrão: https://manager.myauth.click)
873
881
  internal = false,
874
882
  // Modo interno: não exige API Key (para aplicações same-domain como dashboard)
875
883
  onError // Callback de erro global
@@ -883,14 +891,15 @@ function AuthProvider({
883
891
  const startRefresh = useAuthStore(s => s.startRefresh);
884
892
  const checkTokenValidity = useAuthStore(s => s.checkTokenValidity);
885
893
 
886
- // Configura SDK com apiKey e modo interno
894
+ // Configura SDK com apiKey, apiUrl e modo interno
887
895
  // Usamos useMemo para garantir que a configuração ocorra ANTES dos efeitos dos componentes filhos
888
896
  useMemo(() => {
889
897
  configure({
890
898
  apiKey,
899
+ apiUrl,
891
900
  internal
892
901
  });
893
- }, [apiKey, internal]);
902
+ }, [apiKey, apiUrl, internal]);
894
903
  useEffect(() => {
895
904
  init();
896
905
  startRefresh();
@@ -3107,5 +3116,5 @@ function SignOutButton({
3107
3116
  });
3108
3117
  }
3109
3118
 
3110
- export { UserProfile as AccountModal, AuthCard, AuthLoaded, AuthLoading, AuthProvider, ForgotPassword, ForgotPassword as ForgotPasswordForm, MagicLink, MagicLinkCallback, MagicLink as MagicLinkForm, MagicLinkCallback as MagicLinkVerify, Protect, Protect as ProtectedRoute, ResetPassword, ResetPassword as ResetPasswordForm, SignIn, SignInButton, SignIn as SignInForm, SignOutButton, SignUp, SignUpButton, SignUp as SignUpForm, SignedIn, SignedOut, UserProfile, VerifyEmail, VerifyEmail as VerifyEmailCard, changeEmail, changePassword, configure, decodeJWT, forgotPassword, getApplicationInfo, getCurrentUser, getSession, isAuthenticated, listSessions, refreshToken, resendVerification, resetPassword, revokeOtherSessions, revokeSession, sendMagicLink, signIn, signOut, signUp, socialRedirect, updateProfile, useApplicationLogo, useAuth, useAuthLoading, useAuthStore, useCheckToken, useEmailVerification, useMagicLink, usePasswordReset, useUser as useProfile, useSession, useSessions, useSignIn, useSignOut, useSignUp, useUser, verifyEmail, verifyMagicLink };
3119
+ export { UserProfile as AccountModal, AuthCard, AuthLoaded, AuthLoading, AuthProvider, ForgotPassword, ForgotPassword as ForgotPasswordForm, MagicLink, MagicLinkCallback, MagicLink as MagicLinkForm, MagicLinkCallback as MagicLinkVerify, Protect, Protect as ProtectedRoute, ResetPassword, ResetPassword as ResetPasswordForm, SignIn, SignInButton, SignIn as SignInForm, SignOutButton, SignUp, SignUpButton, SignUp as SignUpForm, SignedIn, SignedOut, UserProfile, VerifyEmail, VerifyEmail as VerifyEmailCard, changeEmail, changePassword, configure, decodeJWT, forgotPassword, getApplicationInfo, getCurrentUser, getSession, isAuthenticated, isInternal, listSessions, refreshToken, resendVerification, resetPassword, revokeOtherSessions, revokeSession, sendMagicLink, signIn, signOut, signUp, socialRedirect, updateProfile, useApplicationLogo, useAuth, useAuthLoading, useAuthStore, useCheckToken, useEmailVerification, useMagicLink, usePasswordReset, useUser as useProfile, useSession, useSessions, useSignIn, useSignOut, useSignUp, useUser, verifyEmail, verifyMagicLink };
3111
3120
  //# sourceMappingURL=index.esm.js.map