mitra-interactions-sdk 1.0.60-beta.5 → 1.0.60-beta.7

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
@@ -449,7 +449,12 @@ async function emailLoginMitra2(options) {
449
449
  });
450
450
  const response = {
451
451
  token: data.token,
452
- baseURL: data.baseURL || authUrl,
452
+ // baseURL = authUrl usado (o gateway). NÃO usar data.baseURL da resposta:
453
+ // no novo Mitra o BFF pode devolver outro backURL e isso reescreveria a base
454
+ // (quebra no F5 quando o app persiste). authUrl e baseURL são o mesmo gateway.
455
+ baseURL: authUrl,
456
+ // Guarda o refreshToken do login — é ele que vai no body do refresh depois.
457
+ ...data.refreshToken ? { refreshToken: data.refreshToken } : {},
453
458
  ...data.integrationURL ? { integrationURL: data.integrationURL } : {}
454
459
  };
455
460
  autoConfigureFromLogin2(response, authUrl, projectId);
@@ -475,10 +480,18 @@ async function refreshTokenSilently2(authUrl, _projectId) {
475
480
  if (_refreshPromise2) return _refreshPromise2;
476
481
  _refreshPromise2 = (async () => {
477
482
  try {
478
- const data = await postBffAuth(buildBffAuthEndpoint(authUrl, "/refresh-token"), {});
483
+ const config = isConfigured() ? getConfig() : null;
484
+ const refreshToken = config == null ? void 0 : config.refreshToken;
485
+ if (!refreshToken) {
486
+ throw new Error("refreshToken n\xE3o dispon\xEDvel para renova\xE7\xE3o. Fa\xE7a login novamente.");
487
+ }
488
+ const data = await postBffAuth(buildBffAuthEndpoint(authUrl, "/refresh-token"), { refreshToken });
479
489
  return {
480
490
  token: data.token,
481
- baseURL: data.baseURL || authUrl,
491
+ // Refresh NÃO muda a base — devolve o authUrl usado (gateway), nunca o
492
+ // data.baseURL da resposta (que reescreveria a base e quebra no F5).
493
+ baseURL: authUrl,
494
+ ...data.refreshToken ? { refreshToken: data.refreshToken } : {},
482
495
  ...data.integrationURL ? { integrationURL: data.integrationURL } : {}
483
496
  };
484
497
  } finally {