@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.js CHANGED
@@ -11,18 +11,21 @@ var iconsReact = require('@tabler/icons-react');
11
11
  var notifications = require('@mantine/notifications');
12
12
 
13
13
  // Config - API Base URL fixa para o serviço de autenticação
14
- const API_BASE = 'https://manager.myauth.click';
14
+ let API_BASE = 'https://manager.myauth.click';
15
15
  let API_KEY = null;
16
16
  let INTERNAL_MODE = false; // Modo interno: não exige API Key (para aplicações same-domain)
17
17
 
18
18
  // Permite configurar API key e modo interno externamente (chamado pelo AuthProvider)
19
19
  function configure({
20
20
  apiKey,
21
+ apiUrl,
21
22
  internal = false
22
23
  }) {
23
24
  if (apiKey) API_KEY = apiKey;
25
+ if (apiUrl) API_BASE = apiUrl.endsWith('/') ? apiUrl.slice(0, -1) : apiUrl;
24
26
  INTERNAL_MODE = internal;
25
27
  }
28
+ const isInternal = () => INTERNAL_MODE;
26
29
 
27
30
  // helper fetch pré-configurado
28
31
  async function api(route, opts = {}) {
@@ -371,7 +374,10 @@ const useAuthStore = zustand.create((set, get) => ({
371
374
  } = get();
372
375
  try {
373
376
  // Buscar application info primeiro (não bloqueia o init)
374
- fetchApplicationInfo();
377
+ // Apenas se não estiver em modo interno (dashboard)
378
+ if (!isInternal()) {
379
+ fetchApplicationInfo();
380
+ }
375
381
  let user = null;
376
382
 
377
383
  // PRIMEIRO: Tenta buscar sessão do servidor (funciona com cookies)
@@ -872,6 +878,8 @@ function AuthProvider({
872
878
  children,
873
879
  apiKey,
874
880
  // API Key para header X-API-Key (obrigatória exceto em modo internal)
881
+ apiUrl,
882
+ // URL do manager (opcional, padrão: https://manager.myauth.click)
875
883
  internal = false,
876
884
  // Modo interno: não exige API Key (para aplicações same-domain como dashboard)
877
885
  onError // Callback de erro global
@@ -885,14 +893,15 @@ function AuthProvider({
885
893
  const startRefresh = useAuthStore(s => s.startRefresh);
886
894
  const checkTokenValidity = useAuthStore(s => s.checkTokenValidity);
887
895
 
888
- // Configura SDK com apiKey e modo interno
896
+ // Configura SDK com apiKey, apiUrl e modo interno
889
897
  // Usamos useMemo para garantir que a configuração ocorra ANTES dos efeitos dos componentes filhos
890
898
  react.useMemo(() => {
891
899
  configure({
892
900
  apiKey,
901
+ apiUrl,
893
902
  internal
894
903
  });
895
- }, [apiKey, internal]);
904
+ }, [apiKey, apiUrl, internal]);
896
905
  react.useEffect(() => {
897
906
  init();
898
907
  startRefresh();
@@ -3145,6 +3154,7 @@ exports.getApplicationInfo = getApplicationInfo;
3145
3154
  exports.getCurrentUser = getCurrentUser;
3146
3155
  exports.getSession = getSession;
3147
3156
  exports.isAuthenticated = isAuthenticated;
3157
+ exports.isInternal = isInternal;
3148
3158
  exports.listSessions = listSessions;
3149
3159
  exports.refreshToken = refreshToken;
3150
3160
  exports.resendVerification = resendVerification;