ngx-sp-auth 4.3.9 → 4.3.10
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/fesm2022/ngx-sp-auth.mjs
CHANGED
|
@@ -236,7 +236,7 @@ class IndexedDBService {
|
|
|
236
236
|
if (!window.indexedDB) {
|
|
237
237
|
alert("Seu navegador não suporta uma versão estável do IndexedDB. Salvamento de filtros em sessão não estará disponível.");
|
|
238
238
|
}
|
|
239
|
-
this._dbName = `Sp_${_customEnvironment.product}_Filtros`;
|
|
239
|
+
this._dbName = `Sp_${_customEnvironment.product ?? 'Modelo'}_Filtros`;
|
|
240
240
|
}
|
|
241
241
|
// #region ==========> ACTIONS <==========
|
|
242
242
|
// #region ADD
|
|
@@ -248,7 +248,15 @@ class IndexedDBService {
|
|
|
248
248
|
*/
|
|
249
249
|
async add(value) {
|
|
250
250
|
const db = await openDB(this._dbName, 1);
|
|
251
|
-
|
|
251
|
+
try {
|
|
252
|
+
await db.add('filters', value);
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
try {
|
|
256
|
+
db.close();
|
|
257
|
+
}
|
|
258
|
+
catch (e) { /* não faz nada */ }
|
|
259
|
+
}
|
|
252
260
|
}
|
|
253
261
|
// #endregion ADD
|
|
254
262
|
// #region GET
|
|
@@ -261,7 +269,15 @@ class IndexedDBService {
|
|
|
261
269
|
*/
|
|
262
270
|
async get(key) {
|
|
263
271
|
const db = await openDB(this._dbName, 1);
|
|
264
|
-
|
|
272
|
+
try {
|
|
273
|
+
return await db.get('filters', key);
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
try {
|
|
277
|
+
db.close();
|
|
278
|
+
}
|
|
279
|
+
catch (e) { /* não faz nada */ }
|
|
280
|
+
}
|
|
265
281
|
}
|
|
266
282
|
// #endregion GET
|
|
267
283
|
// #region UPDATE
|
|
@@ -272,7 +288,15 @@ class IndexedDBService {
|
|
|
272
288
|
*/
|
|
273
289
|
async update(value) {
|
|
274
290
|
const db = await openDB(this._dbName, 1);
|
|
275
|
-
|
|
291
|
+
try {
|
|
292
|
+
await db.put('filters', value);
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
try {
|
|
296
|
+
db.close();
|
|
297
|
+
}
|
|
298
|
+
catch (e) { /* não faz nada */ }
|
|
299
|
+
}
|
|
276
300
|
}
|
|
277
301
|
// #endregion UPDATE
|
|
278
302
|
// #region DELETE
|
|
@@ -283,7 +307,15 @@ class IndexedDBService {
|
|
|
283
307
|
*/
|
|
284
308
|
async delete(key) {
|
|
285
309
|
const db = await openDB(this._dbName, 1);
|
|
286
|
-
|
|
310
|
+
try {
|
|
311
|
+
await db.delete('filters', key);
|
|
312
|
+
}
|
|
313
|
+
finally {
|
|
314
|
+
try {
|
|
315
|
+
db.close();
|
|
316
|
+
}
|
|
317
|
+
catch (e) { /* não faz nada */ }
|
|
318
|
+
}
|
|
287
319
|
}
|
|
288
320
|
// #endregion DELETE
|
|
289
321
|
// #endregion ==========> ACTIONS <==========
|
|
@@ -321,8 +353,33 @@ class IndexedDBService {
|
|
|
321
353
|
* @param name Nome da database
|
|
322
354
|
*/
|
|
323
355
|
async deleteDatabase() {
|
|
356
|
+
// Fecha a conexão persistente local, se existir, antes de tentar excluir a DB
|
|
357
|
+
if (this.request) {
|
|
358
|
+
try {
|
|
359
|
+
this.request.close();
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
console.warn('deleteDatabase() => erro ao fechar conexão local', err);
|
|
363
|
+
}
|
|
364
|
+
this.request = undefined;
|
|
365
|
+
}
|
|
324
366
|
return await deleteDB(this._dbName);
|
|
325
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Fecha a conexão persistente (se existir) sem excluir a database.
|
|
370
|
+
* Útil para cenários onde se precisa liberar a conexão antes de chamar `deleteDatabase()`.
|
|
371
|
+
*/
|
|
372
|
+
async closeOpenConnection() {
|
|
373
|
+
if (this.request) {
|
|
374
|
+
try {
|
|
375
|
+
this.request.close();
|
|
376
|
+
}
|
|
377
|
+
catch (err) {
|
|
378
|
+
console.warn('closeOpenConnection() => erro ao fechar conexão', err);
|
|
379
|
+
}
|
|
380
|
+
this.request = undefined;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
326
383
|
/**
|
|
327
384
|
* Valida se já existe um valor cadastrado na base com a chave-única que foi informada, se houver retorna ele, caso contrário cria um registro placeholder para poder atualizar depois.
|
|
328
385
|
*
|
|
@@ -700,8 +757,11 @@ class AuthStorageService {
|
|
|
700
757
|
this.__azureTenantId = "";
|
|
701
758
|
this.__azureClientId = "";
|
|
702
759
|
localStorage.removeItem(this.__local_key);
|
|
703
|
-
//
|
|
704
|
-
|
|
760
|
+
// Limpa o armazenamento local do navegador que contém os filtros de um produto específico
|
|
761
|
+
// Fecha a conexão local (se houver) antes de excluir a database para evitar o callback 'blocking'
|
|
762
|
+
this._indexedDBService.closeOpenConnection()
|
|
763
|
+
.then(() => this._indexedDBService.deleteDatabase())
|
|
764
|
+
.catch((err) => console.warn('logout() => falha ao limpar conexão', err));
|
|
705
765
|
// Método com customizações para finalizações da storage
|
|
706
766
|
this._customStorageService.storageLogout();
|
|
707
767
|
}
|
|
@@ -1061,7 +1121,9 @@ class AuthService {
|
|
|
1061
1121
|
.post(url, login, { 'params': params, 'headers': headers })
|
|
1062
1122
|
.pipe(take$1(1), tap$1((response) => {
|
|
1063
1123
|
// Limnpa o armazenamento local do navegador que contém os filtros de um produto específico (com base na prop 'product' do environment)
|
|
1064
|
-
this._indexedDBService.
|
|
1124
|
+
this._indexedDBService.closeOpenConnection()
|
|
1125
|
+
.then(() => this._indexedDBService.deleteDatabase())
|
|
1126
|
+
.catch((err) => console.warn('login() => falha ao limpar conexão', err));
|
|
1065
1127
|
if (response.FeedbackMessage != "") {
|
|
1066
1128
|
return;
|
|
1067
1129
|
}
|