@navservice/usuario 1.15.0 → 1.16.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.
Files changed (2) hide show
  1. package/build/es/index.js +11 -14
  2. package/package.json +1 -1
package/build/es/index.js CHANGED
@@ -2184,16 +2184,6 @@ axios.getAdapter = adapters_adapters.getAdapter;
2184
2184
  axios.HttpStatusCode = helpers_HttpStatusCode;
2185
2185
  axios.default = axios;
2186
2186
  const lib_axios = axios;
2187
- class es_config_env {
2188
- static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
2189
- static init(config) {
2190
- es_config_env.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL = config.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
2191
- }
2192
- static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL() {
2193
- return this.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL?.trim();
2194
- }
2195
- }
2196
- const es_src_config_env = es_config_env;
2197
2187
  (function(TypeControllerUsuario) {
2198
2188
  TypeControllerUsuario.AppEnum = [
2199
2189
  "service-usuario",
@@ -2345,13 +2335,20 @@ const utils_session_storage = _session_storage;
2345
2335
  const _api_api = class _api {
2346
2336
  static servidor_pricipal = class {
2347
2337
  static get #axios() {
2348
- console.log(es_src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL, 'config_env_core.PUBLIC_BASE_URL_BACKEND_PRINCIPAL');
2349
- const baseURL = new URL(es_src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL).toString().replace(/\/?$/, "/");
2350
- console.log(baseURL, 'baseURL');
2351
2338
  return lib_axios.create({
2352
- baseURL
2339
+ baseURL: this.resolve_base_url()
2353
2340
  });
2354
2341
  }
2342
+ static resolve_base_url() {
2343
+ if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
2344
+ const { hostname } = window.location;
2345
+ if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
2346
+ const isNavSoftware = hostname.includes("navsoftware");
2347
+ const isSandbox = hostname.includes("sandbox");
2348
+ if (isNavSoftware && isSandbox) return "https://api-sandbox.navsoftware.com.br";
2349
+ if (isNavSoftware) return "https://api.navsoftware.com.br";
2350
+ throw new Error(`Ambiente não reconhecido: ${hostname}`);
2351
+ }
2355
2352
  static async post({ url, data, setToken = true }) {
2356
2353
  return await this.#axios.post(url, data, _api.headers({
2357
2354
  setToken: setToken
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/usuario",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Service de autenticação de usuários unificado",
5
5
  "type": "module",
6
6
  "main": "./build/lib/index.js",