ngx-sp-auth 4.23.11 → 4.23.12

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { importProvidersFrom, NgModule, InjectionToken, Inject, Injectable, inject, ViewContainerRef, ViewChild, Component, EventEmitter, Output, Input, TemplateRef, ContentChild } from '@angular/core';
2
+ import { importProvidersFrom, NgModule, InjectionToken, Inject, Injectable, inject, Component, EventEmitter, Output, Input, TemplateRef, ContentChild, ViewChild } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
4
  import { HTTP_INTERCEPTORS, HttpHeaders, HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
5
5
  import * as i1$2 from '@azure/msal-angular';
@@ -527,6 +527,7 @@ class AuthStorageService {
527
527
  this._BASE_URL = ''; // SpInfra2LoginWS
528
528
  this._LOGOUT_BASE_URL = ''; // SpInfra2LoginWS
529
529
  this._BASE_VERIFICATION_URL = ''; // SpInfra2LoginWS
530
+ this._BASE_USERTOKEN_URL = ''; // SpInfra2ErpWS
530
531
  this._HTTP_HEADERS = new HttpHeaders().set('Content-Type', 'application/json');
531
532
  this.__local_key = 'user_auth_v6';
532
533
  // indica se objeto já está marcado para salvar os dados no local storage.
@@ -604,6 +605,8 @@ class AuthStorageService {
604
605
  this._LOGOUT_BASE_URL = !_customEnvironmentService.production ? this._LOGOUT_BASE_URL : `${_customEnvironmentService.SpInfra2LoginWS}/LogoutSisproErp`; // SpInfra2LoginWS
605
606
  this._BASE_VERIFICATION_URL = `${_customEnvironmentService.SpInfra2LoginWS}/verify`; // SpInfra2LoginWS
606
607
  this._BASE_VERIFICATION_URL = !_customEnvironmentService.production ? this._BASE_VERIFICATION_URL : `${_customEnvironmentService.SpInfra2LoginWS}/verify`; // SpInfra2LoginWS
608
+ this._BASE_USERTOKEN_URL = `${_customEnvironmentService.SpInfra2ErpWS}/token`; // SpInfra2ErpWS
609
+ this._BASE_USERTOKEN_URL = !_customEnvironmentService.production ? this._BASE_USERTOKEN_URL : `${_customEnvironmentService.SpInfra2ErpWS}/token`; // SpInfra2ErpWS
607
610
  // Método com customizações para inicializações da storage
608
611
  this._customStorageService.storageConstructor();
609
612
  const expectedLocalAuthStorage = localStorage.getItem(this.__local_key);
@@ -851,6 +854,12 @@ class AuthStorageService {
851
854
  this._toastr.clear();
852
855
  }));
853
856
  }
857
+ getToken() {
858
+ const url = `${this._BASE_USERTOKEN_URL}/getusertoken`;
859
+ const headers = this._HTTP_HEADERS.set('x-application', this._customEnvironmentService.product);
860
+ return this._httpClient.get(url, { 'headers': headers, withCredentials: true })
861
+ .pipe(take(1));
862
+ }
854
863
  /** Verifica a cada diferença de tempo entre a data atual e a data do token. */
855
864
  // public async reCheckLogin(renew: boolean) {
856
865
  // if (this.__authToken === undefined || this.__authToken === '' || this.authToken === null || this.authToken === '') {
@@ -2063,12 +2072,16 @@ class PesquisaTelasGlobalService {
2063
2072
  // #region PUBLIC
2064
2073
  // #endregion PUBLIC
2065
2074
  // #endregion ==========> PROPERTIES <==========
2066
- constructor(_appRef, _injector, _httpClient, _customEnvironmentService, _authUtils) {
2075
+ constructor(_componentFactoryResolver, _appRef, _injector, _httpClient, _customEnvironmentService, _authUtils) {
2076
+ this._componentFactoryResolver = _componentFactoryResolver;
2067
2077
  this._appRef = _appRef;
2068
2078
  this._injector = _injector;
2069
2079
  this._httpClient = _httpClient;
2070
2080
  this._customEnvironmentService = _customEnvironmentService;
2071
2081
  this._authUtils = _authUtils;
2082
+ // #region ==========> PROPERTIES <==========
2083
+ // #region PRIVATE
2084
+ // #region GERENCIAMENTO DINÂMICO DO COMPONENTE
2072
2085
  /**
2073
2086
  * Referência ao componente dinâmico criado.
2074
2087
  * Usado para gerenciar o ciclo de vida e estado do componente.
@@ -2190,7 +2203,7 @@ class PesquisaTelasGlobalService {
2190
2203
  *
2191
2204
  * Este método utiliza a API baixo nível do Angular para criar um componente dinamicamente e anexá-lo ao DOM. O processo envolve:
2192
2205
  *
2193
- * 1. Criar o componente via `container.createComponent()`
2206
+ * 1. Criar o componente via ComponentFactoryResolver
2194
2207
  * 2. Configurar suas propriedades iniciais
2195
2208
  * 3. Registrá-lo no mecanismo de detecção de mudanças do Angular
2196
2209
  * 4. Anexá-lo ao DOM (fora da hierarquia normal de componentes)
@@ -2206,18 +2219,24 @@ class PesquisaTelasGlobalService {
2206
2219
  if (this._componentRef) {
2207
2220
  return;
2208
2221
  }
2209
- // 1. Cria uma nova instância do componente
2210
- this._componentRef = this._container.createComponent(SearchInputComponent);
2211
- // 2. Registra a view do componente no ApplicationRef
2222
+ // 1. Resolve a fábrica do componente - primeiro passo para criar
2223
+ // um componente dinamicamente no Angular. A fábrica contém os metadados
2224
+ // necessários para instanciar o componente.
2225
+ const componentFactory = this._componentFactoryResolver.resolveComponentFactory(SearchInputComponent);
2226
+ // 2. Cria uma nova instância do componente usando o injector raiz
2227
+ // Isso garante que o componente tenha acesso aos mesmos serviços
2228
+ // que componentes criados normalmente via template
2229
+ this._componentRef = componentFactory.create(this._injector);
2230
+ // 3. Registra a view do componente no ApplicationRef
2212
2231
  // Isso é CRÍTICO: sem este passo, o componente não participaria
2213
2232
  // do ciclo de detecção de mudanças do Angular
2214
2233
  this._appRef.attachView(this._componentRef.hostView);
2215
- // 3. Obtém o elemento DOM raiz do componente e o anexa ao body
2234
+ // 4. Obtém o elemento DOM raiz do componente e o anexa ao body
2216
2235
  // Como este componente é criado fora da hierarquia normal,
2217
2236
  // precisamos anexá-lo manualmente ao DOM
2218
2237
  const domElem = this._componentRef.hostView.rootNodes[0];
2219
2238
  document.body.appendChild(domElem);
2220
- // 4. Configura os listeners dos eventos do componente
2239
+ // 5. Configura os listeners dos eventos do componente
2221
2240
  // Em vez de tratar o hide() diretamente aqui, encaminhamos o evento para o Subject _onClose$ e guardamos a subscription para poder removê-la quando escondermos o componente.
2222
2241
  this._componentCloseSub = this._componentRef.instance.onClose.subscribe(() => this._onClose$.next());
2223
2242
  // Em vez de tratar o getTelas() diretamente aqui, encaminhamos o evento para o Subject _onSearch$ e guardamos a subscription para poder removê-la quando escondermos o componente.
@@ -2261,16 +2280,13 @@ class PesquisaTelasGlobalService {
2261
2280
  // #endregion GERENCIAMENTO DO COMPONENTE
2262
2281
  showErrorMessage(response) { if (response.Error)
2263
2282
  throw Error(response.ErrorMessage); }
2264
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, deps: [{ token: i0.ApplicationRef }, { token: i0.Injector }, { token: i1.HttpClient }, { token: LibCustomEnvironmentService }, { token: AuthUtilService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2283
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.ApplicationRef }, { token: i0.Injector }, { token: i1.HttpClient }, { token: LibCustomEnvironmentService }, { token: AuthUtilService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2265
2284
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, providedIn: 'root' }); }
2266
2285
  }
2267
2286
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, decorators: [{
2268
2287
  type: Injectable,
2269
2288
  args: [{ providedIn: 'root' }]
2270
- }], ctorParameters: () => [{ type: i0.ApplicationRef }, { type: i0.Injector }, { type: i1.HttpClient }, { type: LibCustomEnvironmentService }, { type: AuthUtilService }], propDecorators: { _container: [{
2271
- type: ViewChild,
2272
- args: ['container', { read: ViewContainerRef, static: true }]
2273
- }] } });
2289
+ }], ctorParameters: () => [{ type: i0.ComponentFactoryResolver }, { type: i0.ApplicationRef }, { type: i0.Injector }, { type: i1.HttpClient }, { type: LibCustomEnvironmentService }, { type: AuthUtilService }] });
2274
2290
 
2275
2291
  class ErrorMenuNotAllowed {
2276
2292
  constructor(router, authStorageService) {