witspry-auth-ng-client 1.2.1 → 1.3.2
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/README.md +7 -0
- package/fesm2022/witspry-auth-ng-client.mjs +34 -20
- package/fesm2022/witspry-auth-ng-client.mjs.map +1 -1
- package/package.json +7 -9
- package/types/witspry-auth-ng-client.d.ts +510 -0
- package/esm2022/lib/components/oauth2-callback/oauth2-callback.component.mjs +0 -189
- package/esm2022/lib/guards/oauth2-auth.guard.mjs +0 -159
- package/esm2022/lib/interceptors/oauth2.interceptor.mjs +0 -192
- package/esm2022/lib/models/index.mjs +0 -4
- package/esm2022/lib/models/oauth2-config.model.mjs +0 -2
- package/esm2022/lib/models/oauth2-types.model.mjs +0 -15
- package/esm2022/lib/models/witsauth-types.model.mjs +0 -10
- package/esm2022/lib/ng-oauth2-pkce.service.mjs +0 -64
- package/esm2022/lib/services/oauth2-storage.service.mjs +0 -213
- package/esm2022/lib/services/oauth2.service.mjs +0 -881
- package/esm2022/lib/tokens/index.mjs +0 -2
- package/esm2022/lib/tokens/oauth2-config.token.mjs +0 -6
- package/esm2022/public-api.mjs +0 -20
- package/esm2022/witspry-auth-ng-client.mjs +0 -5
- package/index.d.ts +0 -5
- package/lib/components/oauth2-callback/oauth2-callback.component.d.ts +0 -26
- package/lib/guards/oauth2-auth.guard.d.ts +0 -34
- package/lib/interceptors/oauth2.interceptor.d.ts +0 -6
- package/lib/models/index.d.ts +0 -3
- package/lib/models/oauth2-config.model.d.ts +0 -52
- package/lib/models/oauth2-types.model.d.ts +0 -132
- package/lib/models/witsauth-types.model.d.ts +0 -8
- package/lib/ng-oauth2-pkce.service.d.ts +0 -25
- package/lib/services/oauth2-storage.service.d.ts +0 -67
- package/lib/services/oauth2.service.d.ts +0 -173
- package/lib/tokens/index.d.ts +0 -1
- package/lib/tokens/oauth2-config.token.d.ts +0 -6
- package/public-api.d.ts +0 -9
package/README.md
CHANGED
|
@@ -304,3 +304,10 @@ MIT License - see LICENSE file for details.
|
|
|
304
304
|
|
|
305
305
|
### 1.2.0
|
|
306
306
|
- Automatic token refresh with intervals based on access token expiry
|
|
307
|
+
|
|
308
|
+
### 1.3.0
|
|
309
|
+
- Updated Angular dependencies to Angular v21
|
|
310
|
+
|
|
311
|
+
### 1.3.3
|
|
312
|
+
- Fixed issue where on exception, the loading screen stucks
|
|
313
|
+
- Added user friendly error message
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, PLATFORM_ID,
|
|
2
|
+
import { InjectionToken, PLATFORM_ID, Inject, Injectable, signal, inject, Component, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
3
3
|
import * as i3 from '@angular/common';
|
|
4
4
|
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
5
5
|
import { BehaviorSubject, throwError } from 'rxjs';
|
|
@@ -231,10 +231,10 @@ class OAuth2StorageService {
|
|
|
231
231
|
console.error(`[OAuth2StorageService] ${message}`, error);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
235
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
234
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2StorageService, deps: [{ token: OAUTH2_CONFIG_TOKEN }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
235
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2StorageService, providedIn: 'root' });
|
|
236
236
|
}
|
|
237
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
237
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2StorageService, decorators: [{
|
|
238
238
|
type: Injectable,
|
|
239
239
|
args: [{
|
|
240
240
|
providedIn: 'root'
|
|
@@ -260,7 +260,7 @@ class OAuth2Service {
|
|
|
260
260
|
_authState = signal({
|
|
261
261
|
isAuthenticated: false,
|
|
262
262
|
isLoading: false
|
|
263
|
-
});
|
|
263
|
+
}, { ...(ngDevMode ? { debugName: "_authState" } : {}) });
|
|
264
264
|
_authStateSubject = new BehaviorSubject({
|
|
265
265
|
isAuthenticated: false,
|
|
266
266
|
isLoading: false
|
|
@@ -1102,10 +1102,10 @@ class OAuth2Service {
|
|
|
1102
1102
|
ngOnDestroy() {
|
|
1103
1103
|
this.clearAutoRefreshTimer();
|
|
1104
1104
|
}
|
|
1105
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1106
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1105
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2Service, deps: [{ token: OAUTH2_CONFIG_TOKEN }, { token: PLATFORM_ID }, { token: i1.HttpClient }, { token: i2.Router }, { token: OAuth2StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1106
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2Service, providedIn: 'root' });
|
|
1107
1107
|
}
|
|
1108
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1108
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2Service, decorators: [{
|
|
1109
1109
|
type: Injectable,
|
|
1110
1110
|
args: [{
|
|
1111
1111
|
providedIn: 'root'
|
|
@@ -1311,16 +1311,18 @@ class OAuth2CallbackComponent {
|
|
|
1311
1311
|
router;
|
|
1312
1312
|
platformId;
|
|
1313
1313
|
config;
|
|
1314
|
+
cdr;
|
|
1314
1315
|
isLoading = true;
|
|
1315
1316
|
error = null;
|
|
1316
1317
|
success = false;
|
|
1317
1318
|
isWitsAuthMessageApplicable = false;
|
|
1318
1319
|
witsAuthMessage = null;
|
|
1319
|
-
constructor(oauth2Service, router, platformId, config) {
|
|
1320
|
+
constructor(oauth2Service, router, platformId, config, cdr) {
|
|
1320
1321
|
this.oauth2Service = oauth2Service;
|
|
1321
1322
|
this.router = router;
|
|
1322
1323
|
this.platformId = platformId;
|
|
1323
1324
|
this.config = config;
|
|
1325
|
+
this.cdr = cdr;
|
|
1324
1326
|
}
|
|
1325
1327
|
async ngOnInit() {
|
|
1326
1328
|
// Only handle callback in browser environment
|
|
@@ -1366,8 +1368,20 @@ class OAuth2CallbackComponent {
|
|
|
1366
1368
|
}
|
|
1367
1369
|
catch (error) {
|
|
1368
1370
|
console.error('OAuth2 callback error:', error);
|
|
1371
|
+
this.success = false;
|
|
1369
1372
|
this.isLoading = false;
|
|
1370
|
-
this.error =
|
|
1373
|
+
this.error = 'Authentication failed. Contact support or try again later.';
|
|
1374
|
+
// DIAGNOSTIC: Log property values to confirm they're set correctly
|
|
1375
|
+
console.debug('[DIAGNOSTIC] Error state set:', {
|
|
1376
|
+
success: this.success,
|
|
1377
|
+
isLoading: this.isLoading,
|
|
1378
|
+
error: this.error,
|
|
1379
|
+
shouldShowError: (!!this.error && !this.isLoading && !this.success)
|
|
1380
|
+
});
|
|
1381
|
+
// DIAGNOSTIC: Manually trigger change detection
|
|
1382
|
+
console.debug('[DIAGNOSTIC] Triggering manual change detection...');
|
|
1383
|
+
this.cdr.detectChanges();
|
|
1384
|
+
console.debug('[DIAGNOSTIC] Change detection triggered');
|
|
1371
1385
|
}
|
|
1372
1386
|
}, 100);
|
|
1373
1387
|
}
|
|
@@ -1390,8 +1404,8 @@ class OAuth2CallbackComponent {
|
|
|
1390
1404
|
const redirectRoute = this.config.redirectRoute || '/';
|
|
1391
1405
|
this.router.navigate([redirectRoute]);
|
|
1392
1406
|
}
|
|
1393
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1394
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1407
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2CallbackComponent, deps: [{ token: OAuth2Service }, { token: i2.Router }, { token: PLATFORM_ID }, { token: OAUTH2_CONFIG_TOKEN }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1408
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.2", type: OAuth2CallbackComponent, isStandalone: true, selector: "lib-oauth2-callback", ngImport: i0, template: `
|
|
1395
1409
|
<div class="oauth2-callback-container">
|
|
1396
1410
|
<div class="oauth2-callback-content">
|
|
1397
1411
|
<div *ngIf="isLoading" class="loading-section">
|
|
@@ -1431,9 +1445,9 @@ class OAuth2CallbackComponent {
|
|
|
1431
1445
|
</div>
|
|
1432
1446
|
</div>
|
|
1433
1447
|
</div>
|
|
1434
|
-
`, isInline: true, styles: [".oauth2-callback-container{display:flex;justify-content:center;align-items:center;min-height:100vh;background-color:#f5f5f5;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.oauth2-callback-content{background:#fff;border-radius:8px;padding:2rem;box-shadow:0 4px 6px #0000001a;text-align:center;max-width:400px;width:100%;margin:1rem}.loading-section h2,.success-section h2,.error-section h2{margin:1rem 0 .5rem;color:#333}.loading-section p,.success-section p{color:#666;margin-bottom:0}.spinner{border:3px solid #f3f3f3;border-top:3px solid #007bff;border-radius:50%;width:40px;height:40px;animation:spin 1s linear infinite;margin:0 auto 1rem}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.success-icon{width:60px;height:60px;border-radius:50%;background-color:#28a745;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-icon{width:60px;height:60px;border-radius:50%;background-color:#dc3545;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-message{color:#dc3545;margin:1rem 0;padding:.5rem;background-color:#f8d7da;border:1px solid #f5c6cb;border-radius:4px;font-size:.9rem}.error-actions{display:flex;gap:1rem;justify-content:center;margin-top:1.5rem}.retry-button,.home-button{padding:.75rem 1.5rem;border:none;border-radius:4px;cursor:pointer;font-size:.9rem;font-weight:500;transition:background-color .2s}.retry-button{background-color:#007bff;color:#fff}.retry-button:hover{background-color:#0056b3}.home-button{background-color:#6c757d;color:#fff}.home-button:hover{background-color:#545b62}@media
|
|
1448
|
+
`, isInline: true, styles: [".oauth2-callback-container{display:flex;justify-content:center;align-items:center;min-height:100vh;background-color:#f5f5f5;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.oauth2-callback-content{background:#fff;border-radius:8px;padding:2rem;box-shadow:0 4px 6px #0000001a;text-align:center;max-width:400px;width:100%;margin:1rem}.loading-section h2,.success-section h2,.error-section h2{margin:1rem 0 .5rem;color:#333}.loading-section p,.success-section p{color:#666;margin-bottom:0}.spinner{border:3px solid #f3f3f3;border-top:3px solid #007bff;border-radius:50%;width:40px;height:40px;animation:spin 1s linear infinite;margin:0 auto 1rem}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.success-icon{width:60px;height:60px;border-radius:50%;background-color:#28a745;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-icon{width:60px;height:60px;border-radius:50%;background-color:#dc3545;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-message{color:#dc3545;margin:1rem 0;padding:.5rem;background-color:#f8d7da;border:1px solid #f5c6cb;border-radius:4px;font-size:.9rem}.error-actions{display:flex;gap:1rem;justify-content:center;margin-top:1.5rem}.retry-button,.home-button{padding:.75rem 1.5rem;border:none;border-radius:4px;cursor:pointer;font-size:.9rem;font-weight:500;transition:background-color .2s}.retry-button{background-color:#007bff;color:#fff}.retry-button:hover{background-color:#0056b3}.home-button{background-color:#6c757d;color:#fff}.home-button:hover{background-color:#545b62}@media(max-width:480px){.oauth2-callback-content{margin:.5rem;padding:1.5rem}.error-actions{flex-direction:column}.retry-button,.home-button{width:100%}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
1435
1449
|
}
|
|
1436
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1450
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: OAuth2CallbackComponent, decorators: [{
|
|
1437
1451
|
type: Component,
|
|
1438
1452
|
args: [{ selector: 'lib-oauth2-callback', standalone: true, imports: [CommonModule], template: `
|
|
1439
1453
|
<div class="oauth2-callback-container">
|
|
@@ -1475,14 +1489,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
1475
1489
|
</div>
|
|
1476
1490
|
</div>
|
|
1477
1491
|
</div>
|
|
1478
|
-
`, styles: [".oauth2-callback-container{display:flex;justify-content:center;align-items:center;min-height:100vh;background-color:#f5f5f5;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.oauth2-callback-content{background:#fff;border-radius:8px;padding:2rem;box-shadow:0 4px 6px #0000001a;text-align:center;max-width:400px;width:100%;margin:1rem}.loading-section h2,.success-section h2,.error-section h2{margin:1rem 0 .5rem;color:#333}.loading-section p,.success-section p{color:#666;margin-bottom:0}.spinner{border:3px solid #f3f3f3;border-top:3px solid #007bff;border-radius:50%;width:40px;height:40px;animation:spin 1s linear infinite;margin:0 auto 1rem}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.success-icon{width:60px;height:60px;border-radius:50%;background-color:#28a745;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-icon{width:60px;height:60px;border-radius:50%;background-color:#dc3545;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-message{color:#dc3545;margin:1rem 0;padding:.5rem;background-color:#f8d7da;border:1px solid #f5c6cb;border-radius:4px;font-size:.9rem}.error-actions{display:flex;gap:1rem;justify-content:center;margin-top:1.5rem}.retry-button,.home-button{padding:.75rem 1.5rem;border:none;border-radius:4px;cursor:pointer;font-size:.9rem;font-weight:500;transition:background-color .2s}.retry-button{background-color:#007bff;color:#fff}.retry-button:hover{background-color:#0056b3}.home-button{background-color:#6c757d;color:#fff}.home-button:hover{background-color:#545b62}@media
|
|
1492
|
+
`, styles: [".oauth2-callback-container{display:flex;justify-content:center;align-items:center;min-height:100vh;background-color:#f5f5f5;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.oauth2-callback-content{background:#fff;border-radius:8px;padding:2rem;box-shadow:0 4px 6px #0000001a;text-align:center;max-width:400px;width:100%;margin:1rem}.loading-section h2,.success-section h2,.error-section h2{margin:1rem 0 .5rem;color:#333}.loading-section p,.success-section p{color:#666;margin-bottom:0}.spinner{border:3px solid #f3f3f3;border-top:3px solid #007bff;border-radius:50%;width:40px;height:40px;animation:spin 1s linear infinite;margin:0 auto 1rem}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.success-icon{width:60px;height:60px;border-radius:50%;background-color:#28a745;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-icon{width:60px;height:60px;border-radius:50%;background-color:#dc3545;color:#fff;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;margin:0 auto 1rem}.error-message{color:#dc3545;margin:1rem 0;padding:.5rem;background-color:#f8d7da;border:1px solid #f5c6cb;border-radius:4px;font-size:.9rem}.error-actions{display:flex;gap:1rem;justify-content:center;margin-top:1.5rem}.retry-button,.home-button{padding:.75rem 1.5rem;border:none;border-radius:4px;cursor:pointer;font-size:.9rem;font-weight:500;transition:background-color .2s}.retry-button{background-color:#007bff;color:#fff}.retry-button:hover{background-color:#0056b3}.home-button{background-color:#6c757d;color:#fff}.home-button:hover{background-color:#545b62}@media(max-width:480px){.oauth2-callback-content{margin:.5rem;padding:1.5rem}.error-actions{flex-direction:column}.retry-button,.home-button{width:100%}}\n"] }]
|
|
1479
1493
|
}], ctorParameters: () => [{ type: OAuth2Service }, { type: i2.Router }, { type: Object, decorators: [{
|
|
1480
1494
|
type: Inject,
|
|
1481
1495
|
args: [PLATFORM_ID]
|
|
1482
1496
|
}] }, { type: undefined, decorators: [{
|
|
1483
1497
|
type: Inject,
|
|
1484
1498
|
args: [OAUTH2_CONFIG_TOKEN]
|
|
1485
|
-
}] }] });
|
|
1499
|
+
}] }, { type: i0.ChangeDetectorRef }] });
|
|
1486
1500
|
|
|
1487
1501
|
/**
|
|
1488
1502
|
* OAuth2 Authentication Guard Function
|
|
@@ -1677,11 +1691,11 @@ class NgOAuth2PkceModule {
|
|
|
1677
1691
|
]
|
|
1678
1692
|
};
|
|
1679
1693
|
}
|
|
1680
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1681
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
1682
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
1694
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: NgOAuth2PkceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1695
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.2", ngImport: i0, type: NgOAuth2PkceModule, imports: [CommonModule] });
|
|
1696
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: NgOAuth2PkceModule, imports: [CommonModule] });
|
|
1683
1697
|
}
|
|
1684
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1698
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: NgOAuth2PkceModule, decorators: [{
|
|
1685
1699
|
type: NgModule,
|
|
1686
1700
|
args: [{
|
|
1687
1701
|
imports: [CommonModule],
|