@cleavelandprice/ngx-lib 4.8.2 → 4.8.4

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.
@@ -2,7 +2,7 @@ import { AuthenticationServiceOptionsToken } from '@cleavelandprice/ngx-lib/auth
2
2
  export * from '@cleavelandprice/ngx-lib/authentication';
3
3
  import { HttpClient } from '@angular/common/http';
4
4
  import * as i0 from '@angular/core';
5
- import { inject, EventEmitter, Output, Optional, Inject, Injectable, SkipSelf, NgModule } from '@angular/core';
5
+ import { inject, signal, EventEmitter, Output, Optional, Inject, Injectable, SkipSelf, NgModule } from '@angular/core';
6
6
  import { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';
7
7
  import { CommonModule } from '@angular/common';
8
8
 
@@ -29,8 +29,12 @@ class AuthenticationObjectService extends NgxLibServiceBase {
29
29
  //config: inject(ServiceConfig, { optional: true }) ?? new ServiceConfig(),
30
30
  http: inject(HttpClient)
31
31
  };
32
- this.authenticating = false; // Flag set to true while the service is attempting to authenticate the user
33
- this.authenticated = false; // Flag set to true when the user is successfully authenticated
32
+ this.authenticating = signal(false, /* @ts-ignore */
33
+ ...(ngDevMode ? [{ debugName: "authenticating" }] : /* istanbul ignore next */ [])); // Flag set to true while the service is attempting to authenticate the user
34
+ this.authenticated = signal(false, /* @ts-ignore */
35
+ ...(ngDevMode ? [{ debugName: "authenticated" }] : /* istanbul ignore next */ [])); // Flag set to true when the user is successfully authenticated
36
+ this.authenticatedUser = signal(undefined, /* @ts-ignore */
37
+ ...(ngDevMode ? [{ debugName: "authenticatedUser" }] : /* istanbul ignore next */ [])); // Object representing the authenticated user
34
38
  // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.
35
39
  /*authenticatedChanged = output<boolean>();
36
40
  authenticatingChanged = output<boolean>();
@@ -56,8 +60,8 @@ class AuthenticationObjectService extends NgxLibServiceBase {
56
60
  additionalInfo,
57
61
  appName: this.options.appName
58
62
  };
59
- this.authenticating = true;
60
- this.authenticatingChanged.emit(this.authenticating);
63
+ this.authenticating.set(true);
64
+ this.authenticatingChanged.emit(this.authenticating());
61
65
  this.#services.http.post(`${this.apiUrl}${this.options.authenticationEndpoint}`, request)
62
66
  .subscribe({
63
67
  next: (user) => {
@@ -69,8 +73,8 @@ class AuthenticationObjectService extends NgxLibServiceBase {
69
73
  }
70
74
  },
71
75
  error: (err) => {
72
- this.authenticating = false;
73
- this.authenticatingChanged.emit(this.authenticating);
76
+ this.authenticating.set(false);
77
+ this.authenticatingChanged.emit(this.authenticating());
74
78
  this.authenticationError.emit(err);
75
79
  }
76
80
  });
@@ -80,12 +84,12 @@ class AuthenticationObjectService extends NgxLibServiceBase {
80
84
  if (this.storage.getItem(this.options.tokenName)) {
81
85
  this.storage.removeItem(this.options.tokenName);
82
86
  }
83
- this.authenticatedUser = undefined;
84
- this.authenticated = false;
87
+ this.authenticatedUser.set(undefined);
88
+ this.authenticated.set(false);
85
89
  this.authenticatedChanged.emit(false);
86
90
  }
87
91
  validateUser(token) {
88
- this.authenticatedUser = {
92
+ this.authenticatedUser.set({
89
93
  accountName: token.sAMAccountName,
90
94
  admin: false, // This type of authentication has no concept of Admin
91
95
  department: token.department,
@@ -103,14 +107,14 @@ class AuthenticationObjectService extends NgxLibServiceBase {
103
107
  sid: token.objectSid,
104
108
  title: token.title,
105
109
  workShift: token.workShift
106
- };
110
+ });
107
111
  if (this.options.tokenName) {
108
112
  this.storage.setItem(this.options.tokenName, JSON.stringify(token));
109
113
  }
110
- this.authenticated = true;
111
- this.authenticatedChanged.emit(this.authenticated);
112
- this.authenticating = false;
113
- this.authenticatingChanged.emit(this.authenticating);
114
+ this.authenticated.set(true);
115
+ this.authenticatedChanged.emit(this.authenticated());
116
+ this.authenticating.set(false);
117
+ this.authenticatingChanged.emit(this.authenticating());
114
118
  }
115
119
  checkForExistingToken() {
116
120
  if (this.options.tokenName) {
@@ -1 +1 @@
1
- {"version":3,"file":"cleavelandprice-ngx-lib-authentication-object.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/services/authentication-object.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/authentication-object.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/cleavelandprice-ngx-lib-authentication-object.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\r\nimport { EventEmitter, Inject, inject, Injectable, Optional, Output } from '@angular/core';\r\n\r\nimport { CleavelandPriceUser, User } from '@cleavelandprice/ngx-lib/active-directory';\r\n\r\nimport { AbstractAuthenticationService, AuthenticatedUser, AuthenticationRequest, AuthenticationServiceOptions, AuthenticationServiceOptionsToken } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationObjectService extends NgxLibServiceBase implements AbstractAuthenticationService {\r\n //#region Fields\r\n #services = {\r\n //config: inject(ServiceConfig, { optional: true }) ?? new ServiceConfig(),\r\n http: inject(HttpClient)\r\n };\r\n \r\n authenticating = false; // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = false; // Flag set to true when the user is successfully authenticated\r\n authenticatedUser?: AuthenticatedUser; // Object representing the authenticated user\r\n \r\n // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.\r\n /*authenticatedChanged = output<boolean>();\r\n authenticatingChanged = output<boolean>();\r\n authenticationError = output();*/\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() @Inject(AuthenticationServiceOptionsToken) private options: AuthenticationServiceOptions) {\r\n super(options);\r\n\r\n this.options = {\r\n ...options,\r\n\r\n tokenName: 'userObject',\r\n authenticationEndpoint: '/authenticate'\r\n };\r\n\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n //Authenticate the user and store the token in Local Storage\r\n login(username: string, password: string, adminGroup?: string, additionalInfo?: string): void {\r\n const request: AuthenticationRequest = {\r\n username,\r\n password,\r\n adminGroup,\r\n additionalInfo,\r\n appName: this.options.appName\r\n };\r\n\r\n this.authenticating = true;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n\r\n this.#services.http.post(`${this.apiUrl}${this.options.authenticationEndpoint}`, request)\r\n .subscribe({\r\n next: (user) => {\r\n if (user) {\r\n this.validateUser(user as CleavelandPriceUser);\r\n } else {\r\n this.logout();\r\n }\r\n },\r\n error: (err) => {\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n this.authenticationError.emit(err);\r\n }\r\n });\r\n }\r\n \r\n //Logout the user and delete the token from Local Storage\r\n logout(): void {\r\n if (this.storage.getItem(this.options.tokenName!)) {\r\n this.storage.removeItem(this.options.tokenName!);\r\n }\r\n\r\n this.authenticatedUser = undefined;\r\n this.authenticated = false;\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: CleavelandPriceUser): void {\r\n this.authenticatedUser = {\r\n accountName: token.sAMAccountName,\r\n admin: false, // This type of authentication has no concept of Admin\r\n department: token.department,\r\n displayName: token.displayName ?? token.name,\r\n distinguishedName: token.distinguishedName,\r\n email: token.mail,\r\n employeeNumber: token.employeeNumber,\r\n firstName: token.givenName,\r\n hireDate: token.hireDate,\r\n lastName: token.sn,\r\n manager: token.manager,\r\n memberOf: token.memberOf.join(','),\r\n phone: token.telephoneNumber,\r\n photoUrl: undefined,\r\n sid: token.objectSid,\r\n title: token.title,\r\n workShift: token.workShift\r\n };\r\n\r\n if (this.options.tokenName) {\r\n this.storage.setItem(this.options.tokenName, JSON.stringify(token));\r\n }\r\n \r\n this.authenticated = true;\r\n this.authenticatedChanged.emit(this.authenticated);\r\n\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n }\r\n\r\n checkForExistingToken(): void {\r\n if (this.options.tokenName) {\r\n const token = this.storage.getItem(this.options.tokenName);\r\n\r\n if (token) {\r\n this.validateUser(JSON.parse(token) as CleavelandPriceUser);\r\n }\r\n }\r\n }\r\n //#endregion\r\n}\r\n ","import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\nimport { AuthenticationServiceOptions, AuthenticationServiceOptionsToken } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationObjectModule {\r\n static forRoot(options: AuthenticationServiceOptions): ModuleWithProviders<AuthenticationObjectModule> {\r\n return {\r\n ngModule: AuthenticationObjectModule,\r\n providers: [\r\n {\r\n provide: AuthenticationServiceOptionsToken,\r\n useValue: options\r\n }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationObjectModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationObjectModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './authentication-object.api';\n"],"names":[],"mappings":";;;;;;;;AAYM,MAAO,2BAA4B,SAAQ,iBAAiB,CAAA;;AAEhE,IAAA,SAAS;;;AAmBT,IAAA,IAAI,iBAAiB,GAAA;QACnB,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACtD;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,iBAAiB;AAC3B,YAAA,cAAc;AACd,YAAA,YAAY;IAChB;;;AAIA,IAAA,WAAA,CAA2E,OAAqC,EAA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AA,CAAA;;2FAIH,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAPtC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP;AACD,qBAAA;AACD,oBAAA,OAAO,EAAE;AACV,iBAAA;;0BAcc;;0BAAY;;;ACxB3B;;AAEG;;;;"}
1
+ {"version":3,"file":"cleavelandprice-ngx-lib-authentication-object.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/services/authentication-object.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/authentication-object.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/cleavelandprice-ngx-lib-authentication-object.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\r\nimport { EventEmitter, Inject, inject, Injectable, Optional, Output, signal } from '@angular/core';\r\n\r\nimport { CleavelandPriceUser, User } from '@cleavelandprice/ngx-lib/active-directory';\r\n\r\nimport { AbstractAuthenticationService, AuthenticatedUser, AuthenticationRequest, AuthenticationServiceOptions, AuthenticationServiceOptionsToken } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationObjectService extends NgxLibServiceBase implements AbstractAuthenticationService {\r\n //#region Fields\r\n #services = {\r\n //config: inject(ServiceConfig, { optional: true }) ?? new ServiceConfig(),\r\n http: inject(HttpClient)\r\n };\r\n \r\n authenticating = signal(false); // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = signal(false); // Flag set to true when the user is successfully authenticated\r\n authenticatedUser = signal<AuthenticatedUser | undefined>(undefined); // Object representing the authenticated user\r\n \r\n // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.\r\n /*authenticatedChanged = output<boolean>();\r\n authenticatingChanged = output<boolean>();\r\n authenticationError = output();*/\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() @Inject(AuthenticationServiceOptionsToken) private options: AuthenticationServiceOptions) {\r\n super(options);\r\n\r\n this.options = {\r\n ...options,\r\n\r\n tokenName: 'userObject',\r\n authenticationEndpoint: '/authenticate'\r\n };\r\n\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n //Authenticate the user and store the token in Local Storage\r\n login(username: string, password: string, adminGroup?: string, additionalInfo?: string): void {\r\n const request: AuthenticationRequest = {\r\n username,\r\n password,\r\n adminGroup,\r\n additionalInfo,\r\n appName: this.options.appName\r\n };\r\n\r\n this.authenticating.set(true);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n\r\n this.#services.http.post(`${this.apiUrl}${this.options.authenticationEndpoint}`, request)\r\n .subscribe({\r\n next: (user) => {\r\n if (user) {\r\n this.validateUser(user as CleavelandPriceUser);\r\n } else {\r\n this.logout();\r\n }\r\n },\r\n error: (err) => {\r\n this.authenticating.set(false);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n this.authenticationError.emit(err);\r\n }\r\n });\r\n }\r\n \r\n //Logout the user and delete the token from Local Storage\r\n logout(): void {\r\n if (this.storage.getItem(this.options.tokenName!)) {\r\n this.storage.removeItem(this.options.tokenName!);\r\n }\r\n\r\n this.authenticatedUser.set(undefined);\r\n this.authenticated.set(false);\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: CleavelandPriceUser): void {\r\n this.authenticatedUser.set({\r\n accountName: token.sAMAccountName,\r\n admin: false, // This type of authentication has no concept of Admin\r\n department: token.department,\r\n displayName: token.displayName ?? token.name,\r\n distinguishedName: token.distinguishedName,\r\n email: token.mail,\r\n employeeNumber: token.employeeNumber,\r\n firstName: token.givenName,\r\n hireDate: token.hireDate,\r\n lastName: token.sn,\r\n manager: token.manager,\r\n memberOf: token.memberOf.join(','),\r\n phone: token.telephoneNumber,\r\n photoUrl: undefined,\r\n sid: token.objectSid,\r\n title: token.title,\r\n workShift: token.workShift\r\n });\r\n\r\n if (this.options.tokenName) {\r\n this.storage.setItem(this.options.tokenName, JSON.stringify(token));\r\n }\r\n \r\n this.authenticated.set(true);\r\n this.authenticatedChanged.emit(this.authenticated());\r\n\r\n this.authenticating.set(false);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n }\r\n\r\n checkForExistingToken(): void {\r\n if (this.options.tokenName) {\r\n const token = this.storage.getItem(this.options.tokenName);\r\n\r\n if (token) {\r\n this.validateUser(JSON.parse(token) as CleavelandPriceUser);\r\n }\r\n }\r\n }\r\n //#endregion\r\n}\r\n ","import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\nimport { AuthenticationServiceOptions, AuthenticationServiceOptionsToken } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationObjectModule {\r\n static forRoot(options: AuthenticationServiceOptions): ModuleWithProviders<AuthenticationObjectModule> {\r\n return {\r\n ngModule: AuthenticationObjectModule,\r\n providers: [\r\n {\r\n provide: AuthenticationServiceOptionsToken,\r\n useValue: options\r\n }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationObjectModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationObjectModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './authentication-object.api';\n"],"names":[],"mappings":";;;;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A,QAAQ,EAAE,0BAA0B;AACpC,YAAA,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,iCAAiC;AAC1C,oBAAA,QAAQ,EAAE;AACX;AACF;SACF;IACH;AAEA,IAAA,WAAA,CAAoC,YAAwC,EAAA;QAC1E,IAAI,YAAY,EAAE;AAChB,YAAA,MAAM,IAAI,KAAK,CACb,+EAA+E,CAAC;QACpF;IACF;8GAlBW,0BAA0B,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,0BAAA,EAAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAA1B,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,0BAA0B,YAJnC,YAAY,CAAA,EAAA,CAAA,CAAA;AAIH,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,0BAA0B,YAJnC,YAAY,CAAA,EAAA,CAAA,CAAA;;2FAIH,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAPtC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP;AACD,qBAAA;AACD,oBAAA,OAAO,EAAE;AACV,iBAAA;;0BAcc;;0BAAY;;;ACxB3B;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, signal, Output, Optional, Inject, Injectable, ChangeDetectionStrategy, Component, SkipSelf, NgModule, inject } from '@angular/core';
2
+ import { InjectionToken, signal, EventEmitter, Output, Optional, Inject, Injectable, ChangeDetectionStrategy, Component, SkipSelf, NgModule, inject } from '@angular/core';
3
3
  import { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';
4
4
  import { BrowserCacheLocation, PublicClientApplication } from '@azure/msal-browser';
5
5
  import { CommonModule } from '@angular/common';
@@ -57,8 +57,12 @@ class AuthenticationSSOService extends NgxLibServiceBase {
57
57
  super(options);
58
58
  this.options = options;
59
59
  //#region Fields
60
- this.authenticating = false; // Flag set to true while the service is attempting to authenticate the user
61
- this.authenticated = false; // Flag set to true when the user is successfully authenticated
60
+ this.authenticating = signal(false, /* @ts-ignore */
61
+ ...(ngDevMode ? [{ debugName: "authenticating" }] : /* istanbul ignore next */ [])); // Flag set to true while the service is attempting to authenticate the user
62
+ this.authenticated = signal(false, /* @ts-ignore */
63
+ ...(ngDevMode ? [{ debugName: "authenticated" }] : /* istanbul ignore next */ [])); // Flag set to true when the user is successfully authenticated
64
+ this.authenticatedUser = signal(undefined, /* @ts-ignore */
65
+ ...(ngDevMode ? [{ debugName: "authenticatedUser" }] : /* istanbul ignore next */ [])); // Object representing the authenticated user
62
66
  // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.
63
67
  /*authenticatedChanged = output<boolean>();
64
68
  authenticatingChanged = output<boolean>();
@@ -116,8 +120,8 @@ class AuthenticationSSOService extends NgxLibServiceBase {
116
120
  // This is a workaround to ensure that the item is removed after logout.
117
121
  if (typeof sessionStorage !== 'undefined' && sessionStorage.getItem("msal.interaction.status"))
118
122
  sessionStorage.removeItem("msal.interaction.status");
119
- this.authenticating = true;
120
- this.authenticatingChanged.emit(this.authenticating);
123
+ this.authenticating.set(true);
124
+ this.authenticatingChanged.emit(this.authenticating());
121
125
  console.log('AuthenticationSSOService: login() called. Authenticating user...');
122
126
  // Initialize MSAL and then perform login via popup, followed by user validation.
123
127
  this.#initializeMsal()
@@ -128,8 +132,8 @@ class AuthenticationSSOService extends NgxLibServiceBase {
128
132
  }))
129
133
  .then((result) => this.validateUser(result))
130
134
  .catch((error) => {
131
- this.authenticating = false;
132
- this.authenticatingChanged.emit(this.authenticating);
135
+ this.authenticating.set(false);
136
+ this.authenticatingChanged.emit(this.authenticating());
133
137
  this.authenticationError.emit(error);
134
138
  });
135
139
  }
@@ -196,7 +200,7 @@ class AuthenticationSSOService extends NgxLibServiceBase {
196
200
  const preferredUsername = String(claims.preferred_username ?? resolvedAccount.username ?? claims.upn ?? claims.email ?? '');
197
201
  const accountName = preferredUsername.includes('@') ? preferredUsername.split('@')[0] : preferredUsername;
198
202
  // Map Entra claims to the app's authenticated user shape.
199
- this.authenticatedUser = {
203
+ this.authenticatedUser.set({
200
204
  admin: false,
201
205
  accountName: claims.accountName ?? accountName,
202
206
  department: claims.department ?? '',
@@ -214,7 +218,7 @@ class AuthenticationSSOService extends NgxLibServiceBase {
214
218
  sid: claims.securityIdentifier ?? '',
215
219
  title: claims.title,
216
220
  workShift: claims.workShift
217
- };
221
+ });
218
222
  // Persist the most recent id token from the auth result first.
219
223
  // account.idToken can lag behind after silent refresh in some MSAL flows.
220
224
  if (this.options.tokenName) {
@@ -231,12 +235,12 @@ class AuthenticationSSOService extends NgxLibServiceBase {
231
235
  this.#scheduleTokenRefresh(expirationEpochSeconds, resolvedAccount);
232
236
  // Publish authenticated state only when it changes.
233
237
  const wasAuthenticated = this.authenticated;
234
- this.authenticated = true;
238
+ this.authenticated.set(true);
235
239
  if (wasAuthenticated !== this.authenticated) {
236
- this.authenticatedChanged.emit(this.authenticated);
240
+ this.authenticatedChanged.emit(this.authenticated());
237
241
  }
238
- this.authenticating = false;
239
- this.authenticatingChanged.emit(this.authenticating);
242
+ this.authenticating.set(false);
243
+ this.authenticatingChanged.emit(this.authenticating());
240
244
  }
241
245
  // Rehydrates auth state from existing cached account on startup.
242
246
  // We intentionally avoid handleRedirectPromise() because this service uses popup login.
@@ -336,9 +340,9 @@ class AuthenticationSSOService extends NgxLibServiceBase {
336
340
  this.storage.removeItem(this.options.tokenName);
337
341
  }
338
342
  const wasAuthenticated = this.authenticated;
339
- this.authenticatedUser = undefined;
340
- this.authenticated = false;
341
- if (wasAuthenticated !== this.authenticated) {
343
+ this.authenticatedUser.set(undefined);
344
+ this.authenticated.set(false);
345
+ if (wasAuthenticated() !== this.authenticated()) {
342
346
  this.authenticatedChanged.emit(false);
343
347
  }
344
348
  try {
@@ -504,14 +508,14 @@ const authenticationSSOGuard = (_route, _state) => {
504
508
  const authenticationService = inject(AuthenticationSSOService);
505
509
  const router = inject(Router);
506
510
  // if the user is already authenticated, allow access to the route
507
- if (authenticationService.authenticated) {
511
+ if (authenticationService.authenticated()) {
508
512
  return true;
509
513
  }
510
514
  if (authenticationService.tokenExists()) {
511
515
  // we're doing this because we could've opened a new tab and the user is already logged in, so we need to check for an existing token
512
516
  authenticationService.checkForExistingToken();
513
517
  return authenticationService.authenticatedChanged.pipe(take(1), map(() => {
514
- if (!authenticationService.authenticated) {
518
+ if (!authenticationService.authenticated()) {
515
519
  router.navigate(['']);
516
520
  return false;
517
521
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cleavelandprice-ngx-lib-authentication-sso.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/model/authentication-sso-service-options-token.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/services/authentication-sso.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/components/redirect/authentication-sso-redirect.component.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/authentication-sso.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/guards/authentication-sso.guard.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/cleavelandprice-ngx-lib-authentication-sso.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\r\nimport { AuthenticationSSOServiceOptions } from \"./authentication-sso-service-options\";\r\n\r\n// What is a InjectionToken?\r\n// An InjectionToken is a way to create a token that can be used to inject a dependency into an Angular service or component.\r\n// It allows you to define a unique identifier for a dependency, which can then be used to retrieve the dependency from the Angular dependency injection system.\r\n// This is particularly useful when you want to inject a value that is not a class, such as a configuration object or a string.\r\n// Great explaination of InjectionToken: https://youtu.be/GvA7xnBmEto?si=_Nc2DTzdsb0jdvuk\r\nexport const AuthenticationSSOServiceOptionsToken = new InjectionToken<AuthenticationSSOServiceOptions>('AuthenticationSSOServiceOptions');\r\n","import { EventEmitter, Inject, Injectable, Optional, Output, signal } from '@angular/core';\r\n\r\nimport { AbstractAuthenticationService, AuthenticatedUser } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';\r\n\r\nimport { AuthenticationSSOServiceOptions } from '../model/authentication-sso-service-options';\r\nimport { AuthenticationSSOServiceOptionsToken } from './../model/authentication-sso-service-options-token';\r\nimport { AuthenticationSSOClaims } from '../model/authentication-sso-claims';\r\n\r\nimport {\r\n AccountInfo,\r\n AuthenticationResult,\r\n BrowserCacheLocation,\r\n PublicClientApplication,\r\n type Configuration\r\n} from '@azure/msal-browser';\r\n\r\n// This service implements authentication using Microsoft Entra ID (formerly Azure AD) via the Microsoft Authentication Library (MSAL).\r\n// It provides methods for logging in, logging out, and validating the authenticated user, while managing token storage and refresh.\r\n// It also supports cross-tab synchronization of authentication state using the BroadcastChannel API.\r\n// It also supports revalidating authentication state when the user returns to a tab after it has been backgrounded for a period of time.\r\n// It also supports storing the token in either localStorage or sessionStorage, based on the user's preference.\r\n// It also supports determining if the token is expired and refreshing it if necessary, or logging the user out if the token cannot be refreshed.\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationSSOService extends NgxLibServiceBase implements AbstractAuthenticationService {\r\n //#region Fields\r\n authenticating = false; // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = false; // Flag set to true when the user is successfully authenticated\r\n authenticatedUser?: AuthenticatedUser; // Object representing the authenticated user\r\n\r\n // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.\r\n /*authenticatedChanged = output<boolean>();\r\n authenticatingChanged = output<boolean>();\r\n authenticationError = output();*/\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n\r\n // Microsoft Authentication Library (MSAL) instance for handling authentication\r\n #msal: PublicClientApplication;\r\n // Tracks one-time MSAL initialize() completion.\r\n #initialized = false;\r\n\r\n // Cross-tab messaging channel (same-origin tabs only).\r\n #channel?: BroadcastChannel;\r\n // Broadcast payload sent between tabs to synchronize logout.\r\n #logoutMessage = 'logout';\r\n\r\n // Coalescing flags used when syncing auth after tab visibility/focus resumes.\r\n #resumeCheckInProgress = false;\r\n #lastResumeCheckAt = 0;\r\n\r\n // Timer id used to refresh tokens before expiry.\r\n #tokenRefreshTimeoutId?: ReturnType<typeof setTimeout>;\r\n // Treat near-expiry tokens as expired to avoid race conditions during downstream API calls.\r\n #expirationSkewMilliseconds = 30000;\r\n\r\n #expirationEpochSeconds = signal<number | undefined>(undefined);\r\n //#endregion\r\n\r\n //#region Properties\r\n\r\n // I don't agree with these properties being required in the AbstractAuthenticationService interface\r\n // I think this should be set in the options passed to the service.\r\n // I know this is used in the login components under material but a developer who wants to use their own login with sessionStorage would need to know that they need to create a localStorage item called 'storeTokenInSession' and set it to true\r\n // I have added a cacheLocation option to the AuthenticationSSOServiceOptions interface but if the users don't set it, they can use these properties to set the storage location\r\n\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() @Inject(AuthenticationSSOServiceOptionsToken) protected options: AuthenticationSSOServiceOptions) {\r\n super(options);\r\n\r\n const authenticationEndpoint = options.authenticationEndpoint ?? `https://login.microsoftonline.com/${options.tenantId}`;\r\n\r\n this.options = {\r\n ...options,\r\n\r\n tokenName: options.tokenName ?? options.clientId + '-token',\r\n authenticationEndpoint\r\n };\r\n\r\n // if the user didn't set the cacheLocation in the options, we will set it to sessionStorage if useSessionStorage is true, otherwise we will set it to localStorage\r\n this.options.cacheLocation = this.options.cacheLocation ?? (this.useSessionStorage ? 'sessionStorage' : 'localStorage');\r\n\r\n // MSAL configuration for this SPA.\r\n // Cache remains in sessionStorage so each tab has isolated auth cache.\r\n const msalConfig: Configuration = {\r\n auth: {\r\n clientId: this.options.clientId,\r\n authority: this.options.authenticationEndpoint,\r\n redirectUri: this.options.redirectUri,\r\n postLogoutRedirectUri: this.options.postLogoutRedirectUri\r\n },\r\n cache: {\r\n cacheLocation: this.options.cacheLocation === 'sessionStorage' ? BrowserCacheLocation.SessionStorage : BrowserCacheLocation.LocalStorage\r\n }\r\n };\r\n\r\n // Create MSAL client based on the configuration.\r\n // We still need to call initialize() before using it, but this ensures that we only create one instance of the client.\r\n this.#msal = new PublicClientApplication(msalConfig);\r\n\r\n // Initialize the BroadcastChannel for cross-tab communication\r\n this.#initializeBroadcastChannel();\r\n\r\n // Register resume listeners so returning to a tab revalidates auth state.\r\n this.#registerResumeListeners();\r\n\r\n // Attempt to restore authenticated state from any existing Microsoft session.\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n\r\n //Authenticate the user and store the token in Local Storage or Session Storage\r\n login(): void {\r\n // There are times this item is left in sessionStorage after logout, which can cause MSAL to think a login is in progress and block future logins.\r\n // This is a workaround to ensure that the item is removed after logout.\r\n if (typeof sessionStorage !== 'undefined' && sessionStorage.getItem(\"msal.interaction.status\"))\r\n sessionStorage.removeItem(\"msal.interaction.status\");\r\n\r\n this.authenticating = true;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n\r\n console.log('AuthenticationSSOService: login() called. Authenticating user...');\r\n\r\n // Initialize MSAL and then perform login via popup, followed by user validation.\r\n this.#initializeMsal()\r\n .then(() => this.#msal.loginPopup({\r\n scopes: this.options.scopes,\r\n authority: this.options.authenticationEndpoint,\r\n prompt: 'select_account'\r\n }))\r\n .then((result) => this.validateUser(result))\r\n .catch((error: unknown) => {\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n this.authenticationError.emit(error);\r\n });\r\n }\r\n\r\n // Primary logout flow:\r\n // 1) clear local state in this tab,\r\n // 2) notify other tabs to clear their local state,\r\n // 3) initiate Entra sign-out redirect from this initiating tab.\r\n logout(): void {\r\n this.#logoutLocalOnly(false);\r\n this.#publishLogout();\r\n\r\n // Only the initiating tab should call identity-provider logout.\r\n this.#clearTokenRefreshTimer();\r\n\r\n this.#initializeMsal()\r\n .then(() => this.#msal.logoutRedirect({\r\n postLogoutRedirectUri: this.options.postLogoutRedirectUri\r\n }))\r\n .catch((error) => {\r\n console.log('ERROR: Microsoft logout failed.', error);\r\n });\r\n }\r\n\r\n tokenExists(): boolean {\r\n const token = this.storage.getItem(this.options.tokenName ?? '');\r\n return !!token;\r\n }\r\n\r\n // validateUser() = setAuthenticatedUser()\r\n // Resolves current user and token claims into the app's authenticated model.\r\n // Also validates/refreshes token when needed and schedules proactive refresh.\r\n async validateUser(result?: AuthenticationResult, account?: AccountInfo): Promise<void> {\r\n // Resolve account from auth result or fallback account.\r\n let resolvedAccount = result?.account ?? account;\r\n\r\n console.log('AuthenticationSSOService: Validating user. Result:', result, 'Account:', account, 'ResolvedAccount:', resolvedAccount);\r\n\r\n // No account means app should be considered logged out.\r\n if (!resolvedAccount) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n // Keep MSAL active account in sync with resolved account context.\r\n this.#msal.setActiveAccount(resolvedAccount);\r\n\r\n let resolvedResult = result;\r\n let claims = (resolvedResult?.idTokenClaims ?? resolvedAccount.idTokenClaims ?? {}) as AuthenticationSSOClaims;\r\n\r\n // expiresOn comes over as a Date object if it exists, but exp is a number of seconds since epoch.\r\n // therefore, if expiresOn exists convert it to seconds since epoch, otherwise use exp if it exists, otherwise undefined.\r\n // expiresOn is only present when the token is acquired via acquireTokenSilent or acquireTokenPopup, but not when the token is acquired via loginPopup or loginRedirect.\r\n let expirationEpochSeconds = resolvedResult?.expiresOn ? Math.floor(resolvedResult.expiresOn.getTime() / 1000) : claims.exp ?? undefined;\r\n\r\n // If token appears expired, attempt silent refresh before setting user state.\r\n if (this.#isTokenExpired(expirationEpochSeconds)) {\r\n const refreshedResult = await this.#refreshToken(resolvedAccount);\r\n\r\n // Refresh failure means we should end the session.\r\n if (!refreshedResult?.account) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n resolvedResult = refreshedResult;\r\n resolvedAccount = refreshedResult.account;\r\n claims = (resolvedResult.idTokenClaims ?? resolvedAccount.idTokenClaims ?? {}) as AuthenticationSSOClaims;\r\n expirationEpochSeconds = resolvedResult?.expiresOn ? Math.floor(resolvedResult.expiresOn.getTime() / 1000) : claims.exp ?? undefined;\r\n\r\n // Still expired after refresh; terminate session to avoid stale auth.\r\n if (this.#isTokenExpired(expirationEpochSeconds)) {\r\n this.logout();\r\n return;\r\n }\r\n }\r\n\r\n // Derive a stable account name from available claims.\r\n const preferredUsername = String(claims.preferred_username ?? resolvedAccount.username ?? claims.upn ?? claims.email ?? '');\r\n const accountName = preferredUsername.includes('@') ? preferredUsername.split('@')[0] : preferredUsername;\r\n\r\n // Map Entra claims to the app's authenticated user shape.\r\n this.authenticatedUser = {\r\n admin: false,\r\n accountName: claims.accountName ?? accountName,\r\n department: claims.department ?? '',\r\n displayName: claims.displayName ?? '',\r\n distinguishedName: claims.distinguishedName ?? '',\r\n email: claims.mail,\r\n employeeNumber: claims.employeeNumber,\r\n firstName: claims.firstName ?? '',\r\n hireDate: claims.hireDate ?? '',\r\n lastName: claims.lastName ?? '',\r\n manager: claims.manager,\r\n memberOf: claims.memberOf,\r\n phone: claims.phone,\r\n photoUrl: claims.photoUrl,\r\n sid: claims.securityIdentifier ?? '',\r\n title: claims.title,\r\n workShift: claims.workShift\r\n } as AuthenticatedUser;\r\n\r\n // Persist the most recent id token from the auth result first.\r\n // account.idToken can lag behind after silent refresh in some MSAL flows.\r\n if (this.options.tokenName) {\r\n const token = this.#getLatestIdToken(resolvedResult, resolvedAccount);\r\n if (token) {\r\n this.storage.setItem(this.options.tokenName, token);\r\n } else {\r\n this.storage.removeItem(this.options.tokenName);\r\n }\r\n }\r\n\r\n this.#expirationEpochSeconds.set(expirationEpochSeconds);\r\n\r\n // Schedule refresh before expiration to keep session uninterrupted.\r\n this.#scheduleTokenRefresh(expirationEpochSeconds, resolvedAccount);\r\n\r\n // Publish authenticated state only when it changes.\r\n const wasAuthenticated = this.authenticated;\r\n this.authenticated = true;\r\n if (wasAuthenticated !== this.authenticated) {\r\n this.authenticatedChanged.emit(this.authenticated);\r\n }\r\n\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n }\r\n\r\n // Rehydrates auth state from existing cached account on startup.\r\n // We intentionally avoid handleRedirectPromise() because this service uses popup login.\r\n checkForExistingToken(): void {\r\n this.#initializeMsal()\r\n .then(() => {\r\n const account = this.#msal.getActiveAccount() ?? this.#msal.getAllAccounts()[0];\r\n if (account)\r\n return this.validateUser(undefined, account);\r\n\r\n // Ensure stale app token is removed when MSAL has no cached account.\r\n return this.#logoutLocalOnly(false);\r\n })\r\n .catch((error: unknown) => {\r\n console.log('ERROR: Failed to hydrate Microsoft auth state.', error);\r\n });\r\n }\r\n\r\n // Initialize MSAL if it hasn't been initialized yet\r\n // This ensures that we only initialize MSAL once, even if multiple login attempts are made\r\n // This is important because there is startup work that must be completed by MSAL before it can be used, and we don't want to repeat that work unnecessarily\r\n async #initializeMsal(): Promise<void> {\r\n if (this.#initialized) {\r\n return;\r\n }\r\n\r\n\r\n await this.#msal.initialize();\r\n this.#initialized = true;\r\n }\r\n\r\n // Sets up same-origin cross-tab messaging used to fan out logout events.\r\n #initializeBroadcastChannel(): void {\r\n if (typeof BroadcastChannel === 'undefined') {\r\n // Some runtimes may not support BroadcastChannel.\r\n return;\r\n }\r\n\r\n // Create a new BroadcastChannel for cross-tab communication\r\n this.#channel = new BroadcastChannel('sso-authentication-channel');\r\n\r\n // Listen for messages from other tabs for logout events.\r\n // When a logout message is received, the current tab will clear its local state and reload the page.\r\n this.#channel.onmessage = (event) => {\r\n if (event.data === this.#logoutMessage) {\r\n console.log('Received logout message from another tab.');\r\n // Receiving tabs clear local state and reload so route guards re-evaluate immediately.\r\n this.#logoutLocalOnly(true);\r\n }\r\n };\r\n }\r\n\r\n // Registers visibility/focus listeners to re-check auth when user returns to the tab.\r\n // Tabs can be backgrounded for long periods, and the user may have logged out in another tab or session.\r\n #registerResumeListeners(): void {\r\n const handleResume = () => {\r\n void this.#syncAuthOnResume();\r\n };\r\n\r\n if (typeof document !== 'undefined') {\r\n document.addEventListener('visibilitychange', () => {\r\n if (document.visibilityState === 'visible') {\r\n handleResume();\r\n }\r\n });\r\n }\r\n\r\n if (typeof window !== 'undefined') {\r\n window.addEventListener('focus', handleResume);\r\n }\r\n }\r\n\r\n // Syncs auth state after resume while preventing duplicate checks from rapid events.\r\n async #syncAuthOnResume(): Promise<void> {\r\n const now = Date.now();\r\n\r\n // visibilitychange and focus often fire back-to-back; coalesce to one check.\r\n // if now was less than 1 second since last check, skip this one.\r\n if (this.#resumeCheckInProgress || now - this.#lastResumeCheckAt < 1000) {\r\n return;\r\n }\r\n\r\n this.#resumeCheckInProgress = true;\r\n this.#lastResumeCheckAt = now;\r\n\r\n try {\r\n await this.#initializeMsal();\r\n\r\n const account = this.#msal.getActiveAccount() ?? this.#msal.getAllAccounts()[0];\r\n\r\n if (!account) {\r\n await this.#logoutLocalOnly(false);\r\n return;\r\n }\r\n\r\n await this.validateUser(undefined, account);\r\n }\r\n catch (error) {\r\n console.log('Error: Resume auth sync failed.', error);\r\n }\r\n finally {\r\n this.#resumeCheckInProgress = false;\r\n }\r\n }\r\n\r\n // Sends logout signal to other open tabs.\r\n #publishLogout(): void {\r\n this.#channel?.postMessage(this.#logoutMessage);\r\n }\r\n\r\n // Clears app/MSAL state in current tab without invoking provider-side logout.\r\n // reloadAfterLogout is intended for non-initiating tabs to force UI reset to auth route.\r\n async #logoutLocalOnly(reloadAfterLogout: boolean): Promise<void> {\r\n this.#clearTokenRefreshTimer();\r\n\r\n if (this.options.tokenName && this.storage.getItem(this.options.tokenName)) {\r\n this.storage.removeItem(this.options.tokenName);\r\n }\r\n\r\n const wasAuthenticated = this.authenticated;\r\n this.authenticatedUser = undefined;\r\n this.authenticated = false;\r\n if (wasAuthenticated !== this.authenticated) {\r\n this.authenticatedChanged.emit(false);\r\n }\r\n\r\n try {\r\n await this.#initializeMsal();\r\n await this.#msal.clearCache();\r\n this.#msal.setActiveAccount(null);\r\n\r\n // There are times this item is left in sessionStorage after logout, which can cause MSAL to think a login is in progress and block future logins.\r\n // This is a workaround to ensure that the item is removed after logout.\r\n sessionStorage.removeItem(\"msal.interaction.status\");\r\n\r\n // Secondary tabs should hard-refresh to guarantee route guards and app state reset.\r\n if (reloadAfterLogout && typeof window !== 'undefined') {\r\n window.location.reload();\r\n }\r\n } catch (error) {\r\n console.log('WARN: Local MSAL cache clear failed.', error);\r\n }\r\n }\r\n\r\n // Returns true when token expiration is absent or in the past.\r\n #isTokenExpired(expirationEpochSeconds?: number): boolean {\r\n if (expirationEpochSeconds == null || expirationEpochSeconds == undefined || expirationEpochSeconds <= 0) {\r\n return true;\r\n }\r\n\r\n return Date.now() + this.#expirationSkewMilliseconds >= expirationEpochSeconds * 1000;\r\n }\r\n\r\n // Attempts silent token acquisition for the current account.\r\n async #refreshToken(account: AccountInfo): Promise<AuthenticationResult | undefined> {\r\n try {\r\n return await this.#msal.acquireTokenSilent({\r\n account,\r\n scopes: this.options.scopes\r\n });\r\n }\r\n catch (error) {\r\n console.log('Error: Silent token refresh failed.', error);\r\n return undefined;\r\n }\r\n }\r\n\r\n // Prefers the token returned from the most recent auth result.\r\n #getLatestIdToken(result?: AuthenticationResult, account?: AccountInfo): string | undefined {\r\n return result?.idToken ?? account?.idToken;\r\n }\r\n\r\n // Schedules token refresh shortly before expiration.\r\n // If refresh fails, session is terminated to avoid inconsistent auth state.\r\n #scheduleTokenRefresh(expirationEpochSeconds: number | undefined, account: AccountInfo): void {\r\n this.#clearTokenRefreshTimer();\r\n\r\n if (!expirationEpochSeconds) {\r\n return;\r\n }\r\n\r\n // Convert Unix epoch seconds to milliseconds for Date.now() comparison\r\n const expirationEpochMilliseconds = expirationEpochSeconds * 1000;\r\n // Schedule refresh 1 minute before expiration\r\n const refreshLeadTimeMs = 60000;\r\n // Calculate the delay until the refresh should occur, ensuring it's not negative\r\n const millisecondsUntilRefresh = expirationEpochMilliseconds - Date.now() - refreshLeadTimeMs;\r\n const delay = Math.max(millisecondsUntilRefresh, 0);\r\n\r\n this.#tokenRefreshTimeoutId = setTimeout(() => {\r\n this.#refreshToken(account)\r\n .then((result) => {\r\n console.log('AuthenticationSSOService: Token refresh result.', result);\r\n if (result?.account) {\r\n return this.validateUser(result, result.account);\r\n }\r\n\r\n // No account after refresh implies invalid session.\r\n this.logout();\r\n return undefined;\r\n })\r\n .catch(() => {\r\n // Any refresh exception falls back to logout for safety.\r\n this.logout();\r\n });\r\n }, delay);\r\n }\r\n\r\n // Cancels any pending token refresh timer.\r\n #clearTokenRefreshTimer(): void {\r\n if (!this.#tokenRefreshTimeoutId) {\r\n return;\r\n }\r\n\r\n clearTimeout(this.#tokenRefreshTimeoutId);\r\n this.#tokenRefreshTimeoutId = undefined;\r\n }\r\n //#endregion\r\n}\r\n","import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';\nimport { broadcastResponseToMainFrame } from '@azure/msal-browser/redirect-bridge';\n\n@Component({\n selector: 'app-authentication-sso-redirect',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.Eager,\n template: '<p>Processing authentication...</p>',\n})\nexport class AuthenticationSSORedirectComponent implements OnInit {\n ngOnInit(): void {\n broadcastResponseToMainFrame().catch((error: Error) => {\n console.error('Error broadcasting response to main frame:', error);\n });\n }\n}\n","import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\n\r\nimport { AuthenticationSSOServiceOptions } from './model/authentication-sso-service-options';\r\nimport { AuthenticationSSOServiceOptionsToken } from './model/authentication-sso-service-options-token';\r\nimport { AuthenticationSSORedirectComponent } from './components/redirect/authentication-sso-redirect.component';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule,\r\n AuthenticationSSORedirectComponent\r\n ],\r\n exports: [\r\n AuthenticationSSORedirectComponent\r\n ]\r\n})\r\nexport class AuthenticationSSOModule {\r\n static forRoot(options: AuthenticationSSOServiceOptions): ModuleWithProviders<AuthenticationSSOModule> {\r\n return {\r\n ngModule: AuthenticationSSOModule,\r\n providers: [\r\n {\r\n provide: AuthenticationSSOServiceOptionsToken,\r\n useValue: options\r\n }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationSSOModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationSSOModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}\r\n","import { inject } from '@angular/core';\r\nimport { CanActivateFn, Router } from '@angular/router';\r\nimport { map, take } from 'rxjs/operators';\r\nimport { AuthenticationSSOService } from '../authentication-sso.api';\r\n\r\nexport const authenticationSSOGuard: CanActivateFn = (_route, _state) => {\r\n const authenticationService = inject(AuthenticationSSOService);\r\n const router = inject(Router);\r\n\r\n // if the user is already authenticated, allow access to the route\r\n if (authenticationService.authenticated) {\r\n return true;\r\n }\r\n\r\n if (authenticationService.tokenExists()) {\r\n // we're doing this because we could've opened a new tab and the user is already logged in, so we need to check for an existing token\r\n authenticationService.checkForExistingToken();\r\n\r\n return authenticationService.authenticatedChanged.pipe(\r\n take(1),\r\n map(() => {\r\n if (!authenticationService.authenticated) {\r\n router.navigate(['']);\r\n return false;\r\n }\r\n\r\n return true;\r\n })\r\n );\r\n }\r\n else {\r\n router.navigate(['']);\r\n return false;\r\n }\r\n};\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './authentication-sso.api';\n"],"names":[],"mappings":";;;;;;;;;AAGA;AACA;AACA;AACA;AACA;MACa,oCAAoC,GAAG,IAAI,cAAc,CAAkC,iCAAiC;;ACUzI;AACA;AACA;AACA;AACA;AACA;AAIM,MAAO,wBAAyB,SAAQ,iBAAiB,CAAA;;AAe7D,IAAA,KAAK;;AAEL,IAAA,YAAY;;AAGZ,IAAA,QAAQ;;AAER,IAAA,cAAc;;AAGd,IAAA,sBAAsB;AACtB,IAAA,kBAAkB;;AAGlB,IAAA,sBAAsB;;AAEtB,IAAA,2BAA2B;AAE3B,IAAA,uBAAuB;;;;;;;AAUvB,IAAA,IAAI,iBAAiB,GAAA;QACnB,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACtD;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,iBAAiB;AAC3B,YAAA,cAAc;AACd,YAAA,YAAY;IAChB;;;AAKA,IAAA,WAAA,CAAgF,OAAwC,EAAA;QACtH,KAAK,CAAC,OAAO,CAAC;QADgE,IAAA,CAAA,OAAO,GAAP,OAAO;;AAtDvF,QAAA,IAAA,CAAA,cAAc,GAAG,KAAK,CAAC;AACvB,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAC;;AAItB;;AAEiC;AACvB,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,YAAY,EAAW;AAClD,QAAA,IAAA,CAAA,qBAAqB,GAAG,IAAI,YAAY,EAAW;AACnD,QAAA,IAAA,CAAA,mBAAmB,GAAG,IAAI,YAAY,EAAE;;QAKlD,IAAA,CAAA,YAAY,GAAG,KAAK;;QAKpB,IAAA,CAAA,cAAc,GAAG,QAAQ;;QAGzB,IAAA,CAAA,sBAAsB,GAAG,KAAK;QAC9B,IAAA,CAAA,kBAAkB,GAAG,CAAC;;QAKtB,IAAA,CAAA,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AA,CAAA;kBAVnC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ;AACD,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP;AACD;AACF,iBAAA;;0BAcc;;0BAAY;;;MCzBd,sBAAsB,GAAkB,CAAC,MAAM,EAAE,MAAM,KAAI;AACtE,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAC9D,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;;AAG7B,IAAA,IAAI,qBAAqB,CAAC,aAAa,EAAE;AACvC,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,qBAAqB,CAAC,WAAW,EAAE,EAAE;;QAEvC,qBAAqB,CAAC,qBAAqB,EAAE;AAE7C,QAAA,OAAO,qBAAqB,CAAC,oBAAoB,CAAC,IAAI,CACpD,IAAI,CAAC,CAAC,CAAC,EACP,GAAG,CAAC,MAAK;AACP,YAAA,IAAI,CAAC,qBAAqB,CAAC,aAAa,EAAE;AACxC,gBAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACrB,gBAAA,OAAO,KAAK;YACd;AAEA,YAAA,OAAO,IAAI;QACb,CAAC,CAAC,CACH;IACH;SACK;AACH,QAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACrB,QAAA,OAAO,KAAK;IACd;AACF;;AClCA;;AAEG;;;;"}
1
+ {"version":3,"file":"cleavelandprice-ngx-lib-authentication-sso.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/model/authentication-sso-service-options-token.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/services/authentication-sso.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/components/redirect/authentication-sso-redirect.component.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/authentication-sso.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/guards/authentication-sso.guard.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/sso/src/cleavelandprice-ngx-lib-authentication-sso.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\r\nimport { AuthenticationSSOServiceOptions } from \"./authentication-sso-service-options\";\r\n\r\n// What is a InjectionToken?\r\n// An InjectionToken is a way to create a token that can be used to inject a dependency into an Angular service or component.\r\n// It allows you to define a unique identifier for a dependency, which can then be used to retrieve the dependency from the Angular dependency injection system.\r\n// This is particularly useful when you want to inject a value that is not a class, such as a configuration object or a string.\r\n// Great explaination of InjectionToken: https://youtu.be/GvA7xnBmEto?si=_Nc2DTzdsb0jdvuk\r\nexport const AuthenticationSSOServiceOptionsToken = new InjectionToken<AuthenticationSSOServiceOptions>('AuthenticationSSOServiceOptions');\r\n","import { EventEmitter, Inject, Injectable, Optional, Output, signal } from '@angular/core';\r\n\r\nimport { AbstractAuthenticationService, AuthenticatedUser } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';\r\n\r\nimport { AuthenticationSSOServiceOptions } from '../model/authentication-sso-service-options';\r\nimport { AuthenticationSSOServiceOptionsToken } from './../model/authentication-sso-service-options-token';\r\nimport { AuthenticationSSOClaims } from '../model/authentication-sso-claims';\r\n\r\nimport {\r\n AccountInfo,\r\n AuthenticationResult,\r\n BrowserCacheLocation,\r\n PublicClientApplication,\r\n type Configuration\r\n} from '@azure/msal-browser';\r\n\r\n// This service implements authentication using Microsoft Entra ID (formerly Azure AD) via the Microsoft Authentication Library (MSAL).\r\n// It provides methods for logging in, logging out, and validating the authenticated user, while managing token storage and refresh.\r\n// It also supports cross-tab synchronization of authentication state using the BroadcastChannel API.\r\n// It also supports revalidating authentication state when the user returns to a tab after it has been backgrounded for a period of time.\r\n// It also supports storing the token in either localStorage or sessionStorage, based on the user's preference.\r\n// It also supports determining if the token is expired and refreshing it if necessary, or logging the user out if the token cannot be refreshed.\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationSSOService extends NgxLibServiceBase implements AbstractAuthenticationService {\r\n //#region Fields\r\n authenticating = signal(false); // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = signal(false); // Flag set to true when the user is successfully authenticated\r\n authenticatedUser = signal<AuthenticatedUser | undefined>(undefined); // Object representing the authenticated user\r\n\r\n // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.\r\n /*authenticatedChanged = output<boolean>();\r\n authenticatingChanged = output<boolean>();\r\n authenticationError = output();*/\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n\r\n // Microsoft Authentication Library (MSAL) instance for handling authentication\r\n #msal: PublicClientApplication;\r\n // Tracks one-time MSAL initialize() completion.\r\n #initialized = false;\r\n\r\n // Cross-tab messaging channel (same-origin tabs only).\r\n #channel?: BroadcastChannel;\r\n // Broadcast payload sent between tabs to synchronize logout.\r\n #logoutMessage = 'logout';\r\n\r\n // Coalescing flags used when syncing auth after tab visibility/focus resumes.\r\n #resumeCheckInProgress = false;\r\n #lastResumeCheckAt = 0;\r\n\r\n // Timer id used to refresh tokens before expiry.\r\n #tokenRefreshTimeoutId?: ReturnType<typeof setTimeout>;\r\n // Treat near-expiry tokens as expired to avoid race conditions during downstream API calls.\r\n #expirationSkewMilliseconds = 30000;\r\n\r\n #expirationEpochSeconds = signal<number | undefined>(undefined);\r\n //#endregion\r\n\r\n //#region Properties\r\n\r\n // I don't agree with these properties being required in the AbstractAuthenticationService interface\r\n // I think this should be set in the options passed to the service.\r\n // I know this is used in the login components under material but a developer who wants to use their own login with sessionStorage would need to know that they need to create a localStorage item called 'storeTokenInSession' and set it to true\r\n // I have added a cacheLocation option to the AuthenticationSSOServiceOptions interface but if the users don't set it, they can use these properties to set the storage location\r\n\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() @Inject(AuthenticationSSOServiceOptionsToken) protected options: AuthenticationSSOServiceOptions) {\r\n super(options);\r\n\r\n const authenticationEndpoint = options.authenticationEndpoint ?? `https://login.microsoftonline.com/${options.tenantId}`;\r\n\r\n this.options = {\r\n ...options,\r\n\r\n tokenName: options.tokenName ?? options.clientId + '-token',\r\n authenticationEndpoint\r\n };\r\n\r\n // if the user didn't set the cacheLocation in the options, we will set it to sessionStorage if useSessionStorage is true, otherwise we will set it to localStorage\r\n this.options.cacheLocation = this.options.cacheLocation ?? (this.useSessionStorage ? 'sessionStorage' : 'localStorage');\r\n\r\n // MSAL configuration for this SPA.\r\n // Cache remains in sessionStorage so each tab has isolated auth cache.\r\n const msalConfig: Configuration = {\r\n auth: {\r\n clientId: this.options.clientId,\r\n authority: this.options.authenticationEndpoint,\r\n redirectUri: this.options.redirectUri,\r\n postLogoutRedirectUri: this.options.postLogoutRedirectUri\r\n },\r\n cache: {\r\n cacheLocation: this.options.cacheLocation === 'sessionStorage' ? BrowserCacheLocation.SessionStorage : BrowserCacheLocation.LocalStorage\r\n }\r\n };\r\n\r\n // Create MSAL client based on the configuration.\r\n // We still need to call initialize() before using it, but this ensures that we only create one instance of the client.\r\n this.#msal = new PublicClientApplication(msalConfig);\r\n\r\n // Initialize the BroadcastChannel for cross-tab communication\r\n this.#initializeBroadcastChannel();\r\n\r\n // Register resume listeners so returning to a tab revalidates auth state.\r\n this.#registerResumeListeners();\r\n\r\n // Attempt to restore authenticated state from any existing Microsoft session.\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n\r\n //Authenticate the user and store the token in Local Storage or Session Storage\r\n login(): void {\r\n // There are times this item is left in sessionStorage after logout, which can cause MSAL to think a login is in progress and block future logins.\r\n // This is a workaround to ensure that the item is removed after logout.\r\n if (typeof sessionStorage !== 'undefined' && sessionStorage.getItem(\"msal.interaction.status\"))\r\n sessionStorage.removeItem(\"msal.interaction.status\");\r\n\r\n this.authenticating.set(true);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n\r\n console.log('AuthenticationSSOService: login() called. Authenticating user...');\r\n\r\n // Initialize MSAL and then perform login via popup, followed by user validation.\r\n this.#initializeMsal()\r\n .then(() => this.#msal.loginPopup({\r\n scopes: this.options.scopes,\r\n authority: this.options.authenticationEndpoint,\r\n prompt: 'select_account'\r\n }))\r\n .then((result) => this.validateUser(result))\r\n .catch((error: unknown) => {\r\n this.authenticating.set(false);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n this.authenticationError.emit(error);\r\n });\r\n }\r\n\r\n // Primary logout flow:\r\n // 1) clear local state in this tab,\r\n // 2) notify other tabs to clear their local state,\r\n // 3) initiate Entra sign-out redirect from this initiating tab.\r\n logout(): void {\r\n this.#logoutLocalOnly(false);\r\n this.#publishLogout();\r\n\r\n // Only the initiating tab should call identity-provider logout.\r\n this.#clearTokenRefreshTimer();\r\n\r\n this.#initializeMsal()\r\n .then(() => this.#msal.logoutRedirect({\r\n postLogoutRedirectUri: this.options.postLogoutRedirectUri\r\n }))\r\n .catch((error) => {\r\n console.log('ERROR: Microsoft logout failed.', error);\r\n });\r\n }\r\n\r\n tokenExists(): boolean {\r\n const token = this.storage.getItem(this.options.tokenName ?? '');\r\n return !!token;\r\n }\r\n\r\n // validateUser() = setAuthenticatedUser()\r\n // Resolves current user and token claims into the app's authenticated model.\r\n // Also validates/refreshes token when needed and schedules proactive refresh.\r\n async validateUser(result?: AuthenticationResult, account?: AccountInfo): Promise<void> {\r\n // Resolve account from auth result or fallback account.\r\n let resolvedAccount = result?.account ?? account;\r\n\r\n console.log('AuthenticationSSOService: Validating user. Result:', result, 'Account:', account, 'ResolvedAccount:', resolvedAccount);\r\n\r\n // No account means app should be considered logged out.\r\n if (!resolvedAccount) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n // Keep MSAL active account in sync with resolved account context.\r\n this.#msal.setActiveAccount(resolvedAccount);\r\n\r\n let resolvedResult = result;\r\n let claims = (resolvedResult?.idTokenClaims ?? resolvedAccount.idTokenClaims ?? {}) as AuthenticationSSOClaims;\r\n\r\n // expiresOn comes over as a Date object if it exists, but exp is a number of seconds since epoch.\r\n // therefore, if expiresOn exists convert it to seconds since epoch, otherwise use exp if it exists, otherwise undefined.\r\n // expiresOn is only present when the token is acquired via acquireTokenSilent or acquireTokenPopup, but not when the token is acquired via loginPopup or loginRedirect.\r\n let expirationEpochSeconds = resolvedResult?.expiresOn ? Math.floor(resolvedResult.expiresOn.getTime() / 1000) : claims.exp ?? undefined;\r\n\r\n // If token appears expired, attempt silent refresh before setting user state.\r\n if (this.#isTokenExpired(expirationEpochSeconds)) {\r\n const refreshedResult = await this.#refreshToken(resolvedAccount);\r\n\r\n // Refresh failure means we should end the session.\r\n if (!refreshedResult?.account) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n resolvedResult = refreshedResult;\r\n resolvedAccount = refreshedResult.account;\r\n claims = (resolvedResult.idTokenClaims ?? resolvedAccount.idTokenClaims ?? {}) as AuthenticationSSOClaims;\r\n expirationEpochSeconds = resolvedResult?.expiresOn ? Math.floor(resolvedResult.expiresOn.getTime() / 1000) : claims.exp ?? undefined;\r\n\r\n // Still expired after refresh; terminate session to avoid stale auth.\r\n if (this.#isTokenExpired(expirationEpochSeconds)) {\r\n this.logout();\r\n return;\r\n }\r\n }\r\n\r\n // Derive a stable account name from available claims.\r\n const preferredUsername = String(claims.preferred_username ?? resolvedAccount.username ?? claims.upn ?? claims.email ?? '');\r\n const accountName = preferredUsername.includes('@') ? preferredUsername.split('@')[0] : preferredUsername;\r\n\r\n // Map Entra claims to the app's authenticated user shape.\r\n this.authenticatedUser.set({\r\n admin: false,\r\n accountName: claims.accountName ?? accountName,\r\n department: claims.department ?? '',\r\n displayName: claims.displayName ?? '',\r\n distinguishedName: claims.distinguishedName ?? '',\r\n email: claims.mail,\r\n employeeNumber: claims.employeeNumber,\r\n firstName: claims.firstName ?? '',\r\n hireDate: claims.hireDate ?? '',\r\n lastName: claims.lastName ?? '',\r\n manager: claims.manager,\r\n memberOf: claims.memberOf,\r\n phone: claims.phone,\r\n photoUrl: claims.photoUrl,\r\n sid: claims.securityIdentifier ?? '',\r\n title: claims.title,\r\n workShift: claims.workShift\r\n });\r\n\r\n // Persist the most recent id token from the auth result first.\r\n // account.idToken can lag behind after silent refresh in some MSAL flows.\r\n if (this.options.tokenName) {\r\n const token = this.#getLatestIdToken(resolvedResult, resolvedAccount);\r\n if (token) {\r\n this.storage.setItem(this.options.tokenName, token);\r\n } else {\r\n this.storage.removeItem(this.options.tokenName);\r\n }\r\n }\r\n\r\n this.#expirationEpochSeconds.set(expirationEpochSeconds);\r\n\r\n // Schedule refresh before expiration to keep session uninterrupted.\r\n this.#scheduleTokenRefresh(expirationEpochSeconds, resolvedAccount);\r\n\r\n // Publish authenticated state only when it changes.\r\n const wasAuthenticated = this.authenticated;\r\n this.authenticated.set(true);\r\n if (wasAuthenticated !== this.authenticated) {\r\n this.authenticatedChanged.emit(this.authenticated());\r\n }\r\n\r\n this.authenticating.set(false);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n }\r\n\r\n // Rehydrates auth state from existing cached account on startup.\r\n // We intentionally avoid handleRedirectPromise() because this service uses popup login.\r\n checkForExistingToken(): void {\r\n this.#initializeMsal()\r\n .then(() => {\r\n const account = this.#msal.getActiveAccount() ?? this.#msal.getAllAccounts()[0];\r\n if (account)\r\n return this.validateUser(undefined, account);\r\n\r\n // Ensure stale app token is removed when MSAL has no cached account.\r\n return this.#logoutLocalOnly(false);\r\n })\r\n .catch((error: unknown) => {\r\n console.log('ERROR: Failed to hydrate Microsoft auth state.', error);\r\n });\r\n }\r\n\r\n // Initialize MSAL if it hasn't been initialized yet\r\n // This ensures that we only initialize MSAL once, even if multiple login attempts are made\r\n // This is important because there is startup work that must be completed by MSAL before it can be used, and we don't want to repeat that work unnecessarily\r\n async #initializeMsal(): Promise<void> {\r\n if (this.#initialized) {\r\n return;\r\n }\r\n\r\n\r\n await this.#msal.initialize();\r\n this.#initialized = true;\r\n }\r\n\r\n // Sets up same-origin cross-tab messaging used to fan out logout events.\r\n #initializeBroadcastChannel(): void {\r\n if (typeof BroadcastChannel === 'undefined') {\r\n // Some runtimes may not support BroadcastChannel.\r\n return;\r\n }\r\n\r\n // Create a new BroadcastChannel for cross-tab communication\r\n this.#channel = new BroadcastChannel('sso-authentication-channel');\r\n\r\n // Listen for messages from other tabs for logout events.\r\n // When a logout message is received, the current tab will clear its local state and reload the page.\r\n this.#channel.onmessage = (event) => {\r\n if (event.data === this.#logoutMessage) {\r\n console.log('Received logout message from another tab.');\r\n // Receiving tabs clear local state and reload so route guards re-evaluate immediately.\r\n this.#logoutLocalOnly(true);\r\n }\r\n };\r\n }\r\n\r\n // Registers visibility/focus listeners to re-check auth when user returns to the tab.\r\n // Tabs can be backgrounded for long periods, and the user may have logged out in another tab or session.\r\n #registerResumeListeners(): void {\r\n const handleResume = () => {\r\n void this.#syncAuthOnResume();\r\n };\r\n\r\n if (typeof document !== 'undefined') {\r\n document.addEventListener('visibilitychange', () => {\r\n if (document.visibilityState === 'visible') {\r\n handleResume();\r\n }\r\n });\r\n }\r\n\r\n if (typeof window !== 'undefined') {\r\n window.addEventListener('focus', handleResume);\r\n }\r\n }\r\n\r\n // Syncs auth state after resume while preventing duplicate checks from rapid events.\r\n async #syncAuthOnResume(): Promise<void> {\r\n const now = Date.now();\r\n\r\n // visibilitychange and focus often fire back-to-back; coalesce to one check.\r\n // if now was less than 1 second since last check, skip this one.\r\n if (this.#resumeCheckInProgress || now - this.#lastResumeCheckAt < 1000) {\r\n return;\r\n }\r\n\r\n this.#resumeCheckInProgress = true;\r\n this.#lastResumeCheckAt = now;\r\n\r\n try {\r\n await this.#initializeMsal();\r\n\r\n const account = this.#msal.getActiveAccount() ?? this.#msal.getAllAccounts()[0];\r\n\r\n if (!account) {\r\n await this.#logoutLocalOnly(false);\r\n return;\r\n }\r\n\r\n await this.validateUser(undefined, account);\r\n }\r\n catch (error) {\r\n console.log('Error: Resume auth sync failed.', error);\r\n }\r\n finally {\r\n this.#resumeCheckInProgress = false;\r\n }\r\n }\r\n\r\n // Sends logout signal to other open tabs.\r\n #publishLogout(): void {\r\n this.#channel?.postMessage(this.#logoutMessage);\r\n }\r\n\r\n // Clears app/MSAL state in current tab without invoking provider-side logout.\r\n // reloadAfterLogout is intended for non-initiating tabs to force UI reset to auth route.\r\n async #logoutLocalOnly(reloadAfterLogout: boolean): Promise<void> {\r\n this.#clearTokenRefreshTimer();\r\n\r\n if (this.options.tokenName && this.storage.getItem(this.options.tokenName)) {\r\n this.storage.removeItem(this.options.tokenName);\r\n }\r\n\r\n const wasAuthenticated = this.authenticated;\r\n this.authenticatedUser.set(undefined);\r\n this.authenticated.set(false);\r\n if (wasAuthenticated() !== this.authenticated()) {\r\n this.authenticatedChanged.emit(false);\r\n }\r\n\r\n try {\r\n await this.#initializeMsal();\r\n await this.#msal.clearCache();\r\n this.#msal.setActiveAccount(null);\r\n\r\n // There are times this item is left in sessionStorage after logout, which can cause MSAL to think a login is in progress and block future logins.\r\n // This is a workaround to ensure that the item is removed after logout.\r\n sessionStorage.removeItem(\"msal.interaction.status\");\r\n\r\n // Secondary tabs should hard-refresh to guarantee route guards and app state reset.\r\n if (reloadAfterLogout && typeof window !== 'undefined') {\r\n window.location.reload();\r\n }\r\n } catch (error) {\r\n console.log('WARN: Local MSAL cache clear failed.', error);\r\n }\r\n }\r\n\r\n // Returns true when token expiration is absent or in the past.\r\n #isTokenExpired(expirationEpochSeconds?: number): boolean {\r\n if (expirationEpochSeconds == null || expirationEpochSeconds == undefined || expirationEpochSeconds <= 0) {\r\n return true;\r\n }\r\n\r\n return Date.now() + this.#expirationSkewMilliseconds >= expirationEpochSeconds * 1000;\r\n }\r\n\r\n // Attempts silent token acquisition for the current account.\r\n async #refreshToken(account: AccountInfo): Promise<AuthenticationResult | undefined> {\r\n try {\r\n return await this.#msal.acquireTokenSilent({\r\n account,\r\n scopes: this.options.scopes\r\n });\r\n }\r\n catch (error) {\r\n console.log('Error: Silent token refresh failed.', error);\r\n return undefined;\r\n }\r\n }\r\n\r\n // Prefers the token returned from the most recent auth result.\r\n #getLatestIdToken(result?: AuthenticationResult, account?: AccountInfo): string | undefined {\r\n return result?.idToken ?? account?.idToken;\r\n }\r\n\r\n // Schedules token refresh shortly before expiration.\r\n // If refresh fails, session is terminated to avoid inconsistent auth state.\r\n #scheduleTokenRefresh(expirationEpochSeconds: number | undefined, account: AccountInfo): void {\r\n this.#clearTokenRefreshTimer();\r\n\r\n if (!expirationEpochSeconds) {\r\n return;\r\n }\r\n\r\n // Convert Unix epoch seconds to milliseconds for Date.now() comparison\r\n const expirationEpochMilliseconds = expirationEpochSeconds * 1000;\r\n // Schedule refresh 1 minute before expiration\r\n const refreshLeadTimeMs = 60000;\r\n // Calculate the delay until the refresh should occur, ensuring it's not negative\r\n const millisecondsUntilRefresh = expirationEpochMilliseconds - Date.now() - refreshLeadTimeMs;\r\n const delay = Math.max(millisecondsUntilRefresh, 0);\r\n\r\n this.#tokenRefreshTimeoutId = setTimeout(() => {\r\n this.#refreshToken(account)\r\n .then((result) => {\r\n console.log('AuthenticationSSOService: Token refresh result.', result);\r\n if (result?.account) {\r\n return this.validateUser(result, result.account);\r\n }\r\n\r\n // No account after refresh implies invalid session.\r\n this.logout();\r\n return undefined;\r\n })\r\n .catch(() => {\r\n // Any refresh exception falls back to logout for safety.\r\n this.logout();\r\n });\r\n }, delay);\r\n }\r\n\r\n // Cancels any pending token refresh timer.\r\n #clearTokenRefreshTimer(): void {\r\n if (!this.#tokenRefreshTimeoutId) {\r\n return;\r\n }\r\n\r\n clearTimeout(this.#tokenRefreshTimeoutId);\r\n this.#tokenRefreshTimeoutId = undefined;\r\n }\r\n //#endregion\r\n}\r\n","import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';\nimport { broadcastResponseToMainFrame } from '@azure/msal-browser/redirect-bridge';\n\n@Component({\n selector: 'app-authentication-sso-redirect',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.Eager,\n template: '<p>Processing authentication...</p>',\n})\nexport class AuthenticationSSORedirectComponent implements OnInit {\n ngOnInit(): void {\n broadcastResponseToMainFrame().catch((error: Error) => {\n console.error('Error broadcasting response to main frame:', error);\n });\n }\n}\n","import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\n\r\nimport { AuthenticationSSOServiceOptions } from './model/authentication-sso-service-options';\r\nimport { AuthenticationSSOServiceOptionsToken } from './model/authentication-sso-service-options-token';\r\nimport { AuthenticationSSORedirectComponent } from './components/redirect/authentication-sso-redirect.component';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule,\r\n AuthenticationSSORedirectComponent\r\n ],\r\n exports: [\r\n AuthenticationSSORedirectComponent\r\n ]\r\n})\r\nexport class AuthenticationSSOModule {\r\n static forRoot(options: AuthenticationSSOServiceOptions): ModuleWithProviders<AuthenticationSSOModule> {\r\n return {\r\n ngModule: AuthenticationSSOModule,\r\n providers: [\r\n {\r\n provide: AuthenticationSSOServiceOptionsToken,\r\n useValue: options\r\n }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationSSOModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationSSOModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}\r\n","import { inject } from '@angular/core';\r\nimport { CanActivateFn, Router } from '@angular/router';\r\nimport { map, take } from 'rxjs/operators';\r\nimport { AuthenticationSSOService } from '../authentication-sso.api';\r\n\r\nexport const authenticationSSOGuard: CanActivateFn = (_route, _state) => {\r\n const authenticationService = inject(AuthenticationSSOService);\r\n const router = inject(Router);\r\n\r\n // if the user is already authenticated, allow access to the route\r\n if (authenticationService.authenticated()) {\r\n return true;\r\n }\r\n\r\n if (authenticationService.tokenExists()) {\r\n // we're doing this because we could've opened a new tab and the user is already logged in, so we need to check for an existing token\r\n authenticationService.checkForExistingToken();\r\n\r\n return authenticationService.authenticatedChanged.pipe(\r\n take(1),\r\n map(() => {\r\n if (!authenticationService.authenticated()) {\r\n router.navigate(['']);\r\n return false;\r\n }\r\n\r\n return true;\r\n })\r\n );\r\n }\r\n else {\r\n router.navigate(['']);\r\n return false;\r\n }\r\n};\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './authentication-sso.api';\n"],"names":[],"mappings":";;;;;;;;;AAGA;AACA;AACA;AACA;AACA;MACa,oCAAoC,GAAG,IAAI,cAAc,CAAkC,iCAAiC;;ACUzI;AACA;AACA;AACA;AACA;AACA;AAIM,MAAO,wBAAyB,SAAQ,iBAAiB,CAAA;;AAe7D,IAAA,KAAK;;AAEL,IAAA,YAAY;;AAGZ,IAAA,QAAQ;;AAER,IAAA,cAAc;;AAGd,IAAA,sBAAsB;AACtB,IAAA,kBAAkB;;AAGlB,IAAA,sBAAsB;;AAEtB,IAAA,2BAA2B;AAE3B,IAAA,uBAAuB;;;;;;;AAUvB,IAAA,IAAI,iBAAiB,GAAA;QACnB,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACtD;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,iBAAiB;AAC3B,YAAA,cAAc;AACd,YAAA,YAAY;IAChB;;;AAKA,IAAA,WAAA,CAAgF,OAAwC,EAAA;QACtH,KAAK,CAAC,OAAO,CAAC;QADgE,IAAA,CAAA,OAAO,GAAP,OAAO;;QAtDvF,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,KAAK;AAAC,QAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAA,CAAC;QAC/B,IAAA,CA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qB,CAAC,aAAa,EAAE,EAAE;AACzC,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,qBAAqB,CAAC,WAAW,EAAE,EAAE;;QAEvC,qBAAqB,CAAC,qBAAqB,EAAE;AAE7C,QAAA,OAAO,qBAAqB,CAAC,oBAAoB,CAAC,IAAI,CACpD,IAAI,CAAC,CAAC,CAAC,EACP,GAAG,CAAC,MAAK;AACP,YAAA,IAAI,CAAC,qBAAqB,CAAC,aAAa,EAAE,EAAE;AAC1C,gBAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACrB,gBAAA,OAAO,KAAK;YACd;AAEA,YAAA,OAAO,IAAI;QACb,CAAC,CAAC,CACH;IACH;SACK;AACH,QAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACrB,QAAA,OAAO,KAAK;IACd;AACF;;AClCA;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, EventEmitter, Output, Optional, Inject, Injectable, SkipSelf, NgModule } from '@angular/core';
2
+ import { InjectionToken, inject, signal, EventEmitter, Output, Optional, Inject, Injectable, SkipSelf, NgModule } from '@angular/core';
3
3
  import { HttpClient } from '@angular/common/http';
4
4
  import { JwtHelperService } from '@auth0/angular-jwt';
5
5
  import { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';
@@ -27,8 +27,12 @@ class AuthenticationTokenService extends NgxLibServiceBase {
27
27
  this.options = options;
28
28
  //#region Fields
29
29
  this.#http = inject(HttpClient);
30
- this.authenticating = false; // Flag set to true while the service is attempting to authenticate the user
31
- this.authenticated = false; // Flag set to true when the user is successfully authenticated
30
+ this.authenticating = signal(false, /* @ts-ignore */
31
+ ...(ngDevMode ? [{ debugName: "authenticating" }] : /* istanbul ignore next */ [])); // Flag set to true while the service is attempting to authenticate the user
32
+ this.authenticated = signal(false, /* @ts-ignore */
33
+ ...(ngDevMode ? [{ debugName: "authenticated" }] : /* istanbul ignore next */ [])); // Flag set to true when the user is successfully authenticated
34
+ this.authenticatedUser = signal(undefined, /* @ts-ignore */
35
+ ...(ngDevMode ? [{ debugName: "authenticatedUser" }] : /* istanbul ignore next */ [])); // Object representing the authenticated user
32
36
  // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.
33
37
  /*authenticatedChanged = output<boolean>();
34
38
  authenticatingChanged = output<boolean>();
@@ -57,8 +61,8 @@ class AuthenticationTokenService extends NgxLibServiceBase {
57
61
  additionalInfo,
58
62
  appName: this.options.appName
59
63
  };
60
- this.authenticating = true;
61
- this.authenticatingChanged.emit(this.authenticating);
64
+ this.authenticating.set(true);
65
+ this.authenticatingChanged.emit(this.authenticating());
62
66
  // Sending a 'raw' POST request so that we can tell HttpClient that we are expecting text instead of Json
63
67
  // Otherwise, it would throw an error trying to decode Json from the response
64
68
  this.#http.request('POST', `${this.apiUrl}${this.options.authenticationEndpoint}`, { body: request, responseType: 'text' })
@@ -72,8 +76,8 @@ class AuthenticationTokenService extends NgxLibServiceBase {
72
76
  }
73
77
  },
74
78
  error: (err) => {
75
- this.authenticating = false;
76
- this.authenticatingChanged.emit(this.authenticating);
79
+ this.authenticating.set(false);
80
+ this.authenticatingChanged.emit(this.authenticating());
77
81
  this.authenticationError.emit(err);
78
82
  }
79
83
  });
@@ -83,8 +87,8 @@ class AuthenticationTokenService extends NgxLibServiceBase {
83
87
  if (this.options.tokenName && this.storage.getItem(this.options.tokenName)) {
84
88
  this.storage.removeItem(this.options.tokenName);
85
89
  }
86
- this.authenticatedUser = undefined;
87
- this.authenticated = false;
90
+ this.authenticatedUser.set(undefined);
91
+ this.authenticated.set(false);
88
92
  this.authenticatedChanged.emit(false);
89
93
  }
90
94
  validateUser(token) {
@@ -94,7 +98,7 @@ class AuthenticationTokenService extends NgxLibServiceBase {
94
98
  this.logout();
95
99
  return;
96
100
  }
97
- this.authenticatedUser = {
101
+ this.authenticatedUser.set({
98
102
  admin: decoded.role === 'Admin',
99
103
  accountName: decoded.winaccountname,
100
104
  department: decoded.department,
@@ -110,14 +114,14 @@ class AuthenticationTokenService extends NgxLibServiceBase {
110
114
  sid: decoded.sid,
111
115
  title: decoded.title,
112
116
  workShift: decoded.workShift
113
- };
117
+ });
114
118
  if (this.options.tokenName) {
115
119
  this.storage.setItem(this.options.tokenName, token);
116
120
  }
117
- this.authenticated = true;
118
- this.authenticatedChanged.emit(this.authenticated);
119
- this.authenticating = false;
120
- this.authenticatingChanged.emit(this.authenticating);
121
+ this.authenticated.set(true);
122
+ this.authenticatedChanged.emit(this.authenticated());
123
+ this.authenticating.set(false);
124
+ this.authenticatingChanged.emit(this.authenticating());
121
125
  }
122
126
  checkForExistingToken() {
123
127
  if (this.options.tokenName) {
@@ -1 +1 @@
1
- {"version":3,"file":"cleavelandprice-ngx-lib-authentication-token.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/model/authentication-token-service-options-token.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/services/authentication-token.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/authetiction-token.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/cleavelandprice-ngx-lib-authentication-token.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\r\nimport { AuthenticationTokenServiceOptions } from \"./authentication-token-service-options\";\r\n\r\nexport const AuthenticationTokenServiceOptionsToken = new InjectionToken<AuthenticationTokenServiceOptions>('');","import { HttpClient } from '@angular/common/http';\r\nimport { EventEmitter, Inject, Injectable, Optional, Output, inject } from '@angular/core';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\n\r\nimport {\r\n AbstractAuthenticationService,\r\n AuthenticatedUser,\r\n AuthenticationRequest\r\n} from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';\r\nimport { AuthenticationToken } from '../model/authentication-token';\r\nimport { AuthenticationTokenServiceOptions } from '../model/authentication-token-service-options';\r\nimport { AuthenticationTokenServiceOptionsToken } from '../model/authentication-token-service-options-token';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationTokenService extends NgxLibServiceBase implements AbstractAuthenticationService {\r\n //#region Fields\r\n #http = inject(HttpClient);\r\n \r\n authenticating = false; // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = false; // Flag set to true when the user is successfully authenticated\r\n authenticatedUser?: AuthenticatedUser; // Object representing the authenticated user\r\n\r\n // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.\r\n /*authenticatedChanged = output<boolean>();\r\n authenticatingChanged = output<boolean>();\r\n authenticationError = output();*/\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() @Inject(AuthenticationTokenServiceOptionsToken) protected options: AuthenticationTokenServiceOptions) {\r\n super(options);\r\n \r\n this.options = {\r\n ...options,\r\n\r\n tokenName: 'token',\r\n authenticationEndpoint: '/authenticate/token',\r\n deferTokenValidation: options?.deferTokenValidation ?? false\r\n };\r\n\r\n if (!this.options.deferTokenValidation) {\r\n this.checkForExistingToken();\r\n }\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n //Authenticate the user and store the token in Local Storage\r\n login(username: string, password: string, adminGroup?: string, additionalInfo?: string): void {\r\n const request: AuthenticationRequest = {\r\n username,\r\n password,\r\n adminGroup,\r\n additionalInfo,\r\n appName: this.options.appName\r\n };\r\n\r\n this.authenticating = true;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n\r\n // Sending a 'raw' POST request so that we can tell HttpClient that we are expecting text instead of Json\r\n // Otherwise, it would throw an error trying to decode Json from the response\r\n \r\n this.#http.request('POST', `${this.apiUrl}${this.options.authenticationEndpoint}`, { body: request, responseType: 'text' })\r\n .subscribe({\r\n next: (token) => {\r\n if (token) {\r\n this.validateUser(token);\r\n } else {\r\n this.logout();\r\n }\r\n },\r\n error: (err) => {\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n this.authenticationError.emit(err);\r\n }\r\n });\r\n }\r\n \r\n //Logout the user and delete the token from Local Storage\r\n logout(): void {\r\n if (this.options.tokenName && this.storage.getItem(this.options.tokenName)) {\r\n this.storage.removeItem(this.options.tokenName);\r\n }\r\n\r\n this.authenticatedUser = undefined;\r\n this.authenticated = false;\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: string): void {\r\n const jwtHelper = new JwtHelperService();\r\n const decoded = jwtHelper.decodeToken(token) as AuthenticationToken;\r\n\r\n if (jwtHelper.isTokenExpired(token)) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n this.authenticatedUser = {\r\n admin: decoded.role === 'Admin',\r\n accountName: decoded.winaccountname,\r\n department: decoded.department,\r\n displayName: decoded.displayName,\r\n distinguishedName: decoded.distinguishedName,\r\n employeeNumber: decoded.employeeNumber,\r\n firstName: decoded.firstName,\r\n hireDate: decoded.hireDate,\r\n lastName: decoded.lastName,\r\n manager: decoded.manager,\r\n memberOf: decoded.memberOf,\r\n phone: decoded.manager,\r\n sid: decoded.sid,\r\n title: decoded.title,\r\n workShift: decoded.workShift\r\n };\r\n\r\n if (this.options.tokenName) {\r\n this.storage.setItem(this.options.tokenName, token);\r\n }\r\n \r\n this.authenticated = true;\r\n this.authenticatedChanged.emit(this.authenticated);\r\n\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n }\r\n\r\n checkForExistingToken(): void {\r\n if (this.options.tokenName) {\r\n const token = this.storage.getItem(this.options.tokenName!);\r\n if (token) {\r\n this.validateUser(token);\r\n }\r\n }\r\n }\r\n //#endregion\r\n}","import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\n\r\nimport { AuthenticationTokenServiceOptions } from './model/authentication-token-service-options';\r\nimport { AuthenticationTokenServiceOptionsToken } from './model/authentication-token-service-options-token';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationTokenModule {\r\n static forRoot(options: AuthenticationTokenServiceOptions): ModuleWithProviders<AuthenticationTokenModule> {\r\n return {\r\n ngModule: AuthenticationTokenModule,\r\n providers: [\r\n {\r\n provide: AuthenticationTokenServiceOptionsToken,\r\n useValue: options\r\n }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationTokenModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationTokenModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './authentication-token.api';\n"],"names":[],"mappings":";;;;;;;MAGa,sCAAsC,GAAG,IAAI,cAAc,CAAoC,EAAE;;ACexG,MAAO,0BAA2B,SAAQ,iBAAiB,CAAA;;AAE/D,IAAA,KAAK;;;AAiBL,IAAA,IAAI,iBAAiB,GAAA;QACnB,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACtD;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,iBAAiB;AAC3B,YAAA,cAAc;AACd,YAAA,YAAY;IAChB;;;AAIA,IAAA,WAAA,CAAkF,OAA0C,EAAA;QAC1H,KAAK,CAAC,OAAO,CAAC;QADkE,IAAA,CAAA,OAAO,GAAP,OAAO;;AA7BzF,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;AAE1B,QAAA,IAAA,CAAA,cAAc,GAAG,KAAK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A,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,YAJlC,YAAY,CAAA,EAAA,CAAA,CAAA;;2FAIH,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAPrC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP;AACD,qBAAA;AACD,oBAAA,OAAO,EAAE;AACV,iBAAA;;0BAcc;;0BAAY;;;AC1B3B;;AAEG;;;;"}
1
+ {"version":3,"file":"cleavelandprice-ngx-lib-authentication-token.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/model/authentication-token-service-options-token.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/services/authentication-token.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/authetiction-token.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/cleavelandprice-ngx-lib-authentication-token.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\r\nimport { AuthenticationTokenServiceOptions } from \"./authentication-token-service-options\";\r\n\r\nexport const AuthenticationTokenServiceOptionsToken = new InjectionToken<AuthenticationTokenServiceOptions>('');","import { HttpClient } from '@angular/common/http';\r\nimport { EventEmitter, Inject, Injectable, Optional, Output, inject, output, signal } from '@angular/core';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\n\r\nimport {\r\n AbstractAuthenticationService,\r\n AuthenticatedUser,\r\n AuthenticationRequest\r\n} from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { NgxLibServiceBase } from '@cleavelandprice/ngx-lib';\r\nimport { AuthenticationToken } from '../model/authentication-token';\r\nimport { AuthenticationTokenServiceOptions } from '../model/authentication-token-service-options';\r\nimport { AuthenticationTokenServiceOptionsToken } from '../model/authentication-token-service-options-token';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationTokenService extends NgxLibServiceBase implements AbstractAuthenticationService {\r\n //#region Fields\r\n #http = inject(HttpClient);\r\n \r\n authenticating = signal(false); // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = signal(false); // Flag set to true when the user is successfully authenticated\r\n authenticatedUser = signal<AuthenticatedUser|undefined>(undefined); // Object representing the authenticated user\r\n\r\n // error NG8110: Unsupported call to the output function. This function can only be used as the initializer of a property on a @Component or @Directive class.\r\n /*authenticatedChanged = output<boolean>();\r\n authenticatingChanged = output<boolean>();\r\n authenticationError = output();*/\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() @Inject(AuthenticationTokenServiceOptionsToken) protected options: AuthenticationTokenServiceOptions) {\r\n super(options);\r\n \r\n this.options = {\r\n ...options,\r\n\r\n tokenName: 'token',\r\n authenticationEndpoint: '/authenticate/token',\r\n deferTokenValidation: options?.deferTokenValidation ?? false\r\n };\r\n\r\n if (!this.options.deferTokenValidation) {\r\n this.checkForExistingToken();\r\n }\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n //Authenticate the user and store the token in Local Storage\r\n login(username: string, password: string, adminGroup?: string, additionalInfo?: string): void {\r\n const request: AuthenticationRequest = {\r\n username,\r\n password,\r\n adminGroup,\r\n additionalInfo,\r\n appName: this.options.appName\r\n };\r\n\r\n this.authenticating.set(true);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n\r\n // Sending a 'raw' POST request so that we can tell HttpClient that we are expecting text instead of Json\r\n // Otherwise, it would throw an error trying to decode Json from the response\r\n \r\n this.#http.request('POST', `${this.apiUrl}${this.options.authenticationEndpoint}`, { body: request, responseType: 'text' })\r\n .subscribe({\r\n next: (token) => {\r\n if (token) {\r\n this.validateUser(token);\r\n } else {\r\n this.logout();\r\n }\r\n },\r\n error: (err) => {\r\n this.authenticating.set(false);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n this.authenticationError.emit(err);\r\n }\r\n });\r\n }\r\n \r\n //Logout the user and delete the token from Local Storage\r\n logout(): void {\r\n if (this.options.tokenName && this.storage.getItem(this.options.tokenName)) {\r\n this.storage.removeItem(this.options.tokenName);\r\n }\r\n\r\n this.authenticatedUser.set(undefined);\r\n this.authenticated.set(false);\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: string): void {\r\n const jwtHelper = new JwtHelperService();\r\n const decoded = jwtHelper.decodeToken(token) as AuthenticationToken;\r\n\r\n if (jwtHelper.isTokenExpired(token)) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n this.authenticatedUser.set({\r\n admin: decoded.role === 'Admin',\r\n accountName: decoded.winaccountname,\r\n department: decoded.department,\r\n displayName: decoded.displayName,\r\n distinguishedName: decoded.distinguishedName,\r\n employeeNumber: decoded.employeeNumber,\r\n firstName: decoded.firstName,\r\n hireDate: decoded.hireDate,\r\n lastName: decoded.lastName,\r\n manager: decoded.manager,\r\n memberOf: decoded.memberOf,\r\n phone: decoded.manager,\r\n sid: decoded.sid,\r\n title: decoded.title,\r\n workShift: decoded.workShift\r\n });\r\n\r\n if (this.options.tokenName) {\r\n this.storage.setItem(this.options.tokenName, token);\r\n }\r\n \r\n this.authenticated.set(true);\r\n this.authenticatedChanged.emit(this.authenticated());\r\n\r\n this.authenticating.set(false);\r\n this.authenticatingChanged.emit(this.authenticating());\r\n }\r\n\r\n checkForExistingToken(): void {\r\n if (this.options.tokenName) {\r\n const token = this.storage.getItem(this.options.tokenName!);\r\n if (token) {\r\n this.validateUser(token);\r\n }\r\n }\r\n }\r\n //#endregion\r\n}","import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\n\r\nimport { AuthenticationTokenServiceOptions } from './model/authentication-token-service-options';\r\nimport { AuthenticationTokenServiceOptionsToken } from './model/authentication-token-service-options-token';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationTokenModule {\r\n static forRoot(options: AuthenticationTokenServiceOptions): ModuleWithProviders<AuthenticationTokenModule> {\r\n return {\r\n ngModule: AuthenticationTokenModule,\r\n providers: [\r\n {\r\n provide: AuthenticationTokenServiceOptionsToken,\r\n useValue: options\r\n }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationTokenModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationTokenModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './authentication-token.api';\n"],"names":[],"mappings":";;;;;;;MAGa,sCAAsC,GAAG,IAAI,cAAc,CAAoC,EAAE;;ACexG,MAAO,0BAA2B,SAAQ,iBAAiB,CAAA;;AAE/D,IAAA,KAAK;;;AAiBL,IAAA,IAAI,iBAAiB,GAAA;QACnB,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACtD;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,iBAAiB;AAC3B,YAAA,cAAc;AACd,YAAA,YAAY;IAChB;;;AAIA,IAAA,WAAA,CAAkF,OAA0C,EAAA;QAC1H,KAAK,CAAC,OAAO,CAAC;QADkE,IAAA,CAAA,OAAO,GAAP,OAAO;;AA7BzF,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAE1B,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,KAAK;AAAC,QAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAA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AAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAzB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,YAJlC,YAAY,CAAA,EAAA,CAAA,CAAA;AAIH,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,YAJlC,YAAY,CAAA,EAAA,CAAA,CAAA;;2FAIH,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAPrC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP;AACD,qBAAA;AACD,oBAAA,OAAO,EAAE;AACV,iBAAA;;0BAcc;;0BAAY;;;AC1B3B;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "comment": "NGX-LIB primary entry point package.json",
3
3
  "name": "@cleavelandprice/ngx-lib",
4
- "version": "4.8.2",
4
+ "version": "4.8.4",
5
5
  "description": "Angular library providing foundational functionality to Cleaveland-Price applications",
6
6
  "peerDependencies": {
7
7
  "@angular/common": "^22.1.1",