@riligar/auth-react 1.20.4 → 1.20.6

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 CHANGED
@@ -22,10 +22,7 @@ import { AuthProvider, useAuth, useSignIn, Protect, SignedIn, SignedOut, SignIn
22
22
  // 1. Wrap your app with AuthProvider
23
23
  function App() {
24
24
  return (
25
- <AuthProvider
26
- apiUrl="https://your-api.com"
27
- apiKey="your-api-key"
28
- >
25
+ <AuthProvider apiKey="your-api-key">
29
26
  <Routes>
30
27
  <Route
31
28
  path="/login"
package/dist/index.esm.js CHANGED
@@ -8,29 +8,16 @@ import { useForm } from '@mantine/form';
8
8
  import { IconMail, IconLock, IconArrowRight, IconBrandGoogle, IconBrandGithub, IconUser, IconSend, IconCheck, IconX, IconRefresh, IconPhoto, IconTrash, IconPencil, IconShield, IconKey, IconDevices, IconDeviceMobile, IconLogout, IconUserCircle } from '@tabler/icons-react';
9
9
  import { notifications } from '@mantine/notifications';
10
10
 
11
- // Config - pode ser sobrescrita pelo AuthProvider
12
- // Tenta detectar ambiente Vite, mas falha graciosamente se não existir
13
- const getEnvVar = key => {
14
- try {
15
- if (typeof import.meta !== 'undefined' && import.meta.env && import.meta.env[key]) {
16
- return import.meta.env[key];
17
- }
18
- } catch (e) {
19
- // ignore
20
- }
21
- return null;
22
- };
23
- let API_BASE = (typeof window !== 'undefined' && window?.location ? getEnvVar('VITE_API_BASE') : null) || 'http://localhost:3000';
11
+ // Config - API Base URL fixa para o serviço de autenticação
12
+ const API_BASE = 'https://manager.myauth.click';
24
13
  let API_KEY = null;
25
14
  let INTERNAL_MODE = false; // Modo interno: não exige API Key (para aplicações same-domain)
26
15
 
27
- // Permite configurar a API base, key e modo interno externamente (chamado pelo AuthProvider)
16
+ // Permite configurar API key e modo interno externamente (chamado pelo AuthProvider)
28
17
  function configure({
29
- apiUrl,
30
18
  apiKey,
31
19
  internal = false
32
20
  }) {
33
- if (apiUrl) API_BASE = apiUrl.replace(/\/$/, ''); // Remove trailing slash
34
21
  if (apiKey) API_KEY = apiKey;
35
22
  INTERNAL_MODE = internal;
36
23
  }
@@ -881,8 +868,6 @@ const AuthContext = /*#__PURE__*/createContext(); // só para ter o Provider em
881
868
 
882
869
  function AuthProvider({
883
870
  children,
884
- apiUrl,
885
- // URL base da API (OBRIGATÓRIA)
886
871
  apiKey,
887
872
  // API Key para header X-API-Key (obrigatória exceto em modo internal)
888
873
  internal = false,
@@ -894,22 +879,18 @@ function AuthProvider({
894
879
  if (!internal && !apiKey) {
895
880
  throw new Error('[@riligar/auth-react] apiKey é obrigatória no AuthProvider. ' + 'Obtenha sua API Key no dashboard em https://dashboard.myauth.click');
896
881
  }
897
- if (!apiUrl) {
898
- throw new Error('[@riligar/auth-react] apiUrl é obrigatória no AuthProvider. ' + 'Use a URL do seu servidor de autenticação.');
899
- }
900
882
  const init = useAuthStore(s => s.init);
901
883
  const startRefresh = useAuthStore(s => s.startRefresh);
902
884
  const checkTokenValidity = useAuthStore(s => s.checkTokenValidity);
903
885
 
904
- // Configura SDK com apiUrl, apiKey e modo interno
886
+ // Configura SDK com apiKey e modo interno
905
887
  // Usamos useMemo para garantir que a configuração ocorra ANTES dos efeitos dos componentes filhos
906
888
  useMemo(() => {
907
889
  configure({
908
- apiUrl,
909
890
  apiKey,
910
891
  internal
911
892
  });
912
- }, [apiUrl, apiKey, internal]);
893
+ }, [apiKey, internal]);
913
894
  useEffect(() => {
914
895
  init();
915
896
  startRefresh();