@daffodil/auth 0.61.0 → 0.62.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/driver/constants/public_api.d.ts +1 -0
  2. package/driver/constants/unauthenticated-error-codes.d.ts +11 -0
  3. package/driver/in-memory/package.json +1 -1
  4. package/driver/magento/package.json +1 -1
  5. package/driver/package.json +1 -1
  6. package/driver/public_api.d.ts +1 -0
  7. package/driver/testing/package.json +1 -1
  8. package/esm2020/driver/constants/public_api.mjs +2 -0
  9. package/esm2020/driver/constants/unauthenticated-error-codes.mjs +14 -0
  10. package/esm2020/driver/public_api.mjs +2 -1
  11. package/esm2020/routing/effects/redirect.effects.mjs +2 -8
  12. package/esm2020/routing/guards/guest-only.guard.mjs +3 -4
  13. package/esm2020/routing/guards/member-only.guard.mjs +3 -4
  14. package/esm2020/routing/helpers/public_api.mjs +2 -0
  15. package/esm2020/routing/helpers/redirect-unauthenticated-hook-factory.mjs +16 -0
  16. package/esm2020/routing/public_api.mjs +2 -1
  17. package/esm2020/routing/redirect.module.mjs +20 -3
  18. package/esm2020/state/actions/auth.actions.mjs +3 -2
  19. package/esm2020/state/auth-state.module.mjs +41 -3
  20. package/esm2020/state/effects/auth.effects.mjs +12 -20
  21. package/esm2020/state/effects/login.effects.mjs +2 -2
  22. package/esm2020/state/injection-tokens/unauthenticated/hook.token.mjs +6 -5
  23. package/esm2020/state/injection-tokens/unauthenticated/hook.type.mjs +2 -0
  24. package/esm2020/state/injection-tokens/unauthenticated/hooks.token.mjs +2 -3
  25. package/esm2020/state/injection-tokens/unauthenticated/public_api.mjs +1 -1
  26. package/fesm2015/daffodil-auth-driver.mjs +14 -2
  27. package/fesm2015/daffodil-auth-driver.mjs.map +1 -1
  28. package/fesm2015/daffodil-auth-routing.mjs +36 -16
  29. package/fesm2015/daffodil-auth-routing.mjs.map +1 -1
  30. package/fesm2015/daffodil-auth-state.mjs +59 -32
  31. package/fesm2015/daffodil-auth-state.mjs.map +1 -1
  32. package/fesm2020/daffodil-auth-driver.mjs +14 -2
  33. package/fesm2020/daffodil-auth-driver.mjs.map +1 -1
  34. package/fesm2020/daffodil-auth-routing.mjs +36 -16
  35. package/fesm2020/daffodil-auth-routing.mjs.map +1 -1
  36. package/fesm2020/daffodil-auth-state.mjs +58 -31
  37. package/fesm2020/daffodil-auth-state.mjs.map +1 -1
  38. package/package.json +1 -1
  39. package/routing/effects/redirect.effects.d.ts +0 -2
  40. package/routing/helpers/public_api.d.ts +1 -0
  41. package/routing/helpers/redirect-unauthenticated-hook-factory.d.ts +4 -0
  42. package/routing/package.json +1 -1
  43. package/routing/public_api.d.ts +1 -0
  44. package/state/actions/auth.actions.d.ts +2 -0
  45. package/state/effects/auth.effects.d.ts +2 -2
  46. package/state/injection-tokens/unauthenticated/hook.token.d.ts +2 -1
  47. package/state/injection-tokens/unauthenticated/hook.type.d.ts +9 -0
  48. package/state/injection-tokens/unauthenticated/hooks.token.d.ts +4 -4
  49. package/state/injection-tokens/unauthenticated/public_api.d.ts +1 -0
  50. package/state/package.json +1 -1
  51. package/state/testing/package.json +1 -1
  52. package/testing/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import { inject, InjectionToken, } from '@angular/core';
2
+ import { combineLatest } from 'rxjs';
2
3
  import { DAFF_AUTH_UNAUTHENTICATED_HOOKS } from './hooks.token';
3
4
  /**
4
5
  * An internal token to hold the unauthenticated hook.
@@ -7,9 +8,9 @@ import { DAFF_AUTH_UNAUTHENTICATED_HOOKS } from './hooks.token';
7
8
  * @docs-private
8
9
  */
9
10
  export const DAFF_AUTH_UNAUTHENTICATED_HOOK = new InjectionToken('DAFF_AUTH_UNAUTHENTICATED_HOOK', {
10
- factory: () => inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS).reduce((acc, hook) => () => {
11
- acc();
12
- hook();
13
- }, () => { }),
11
+ factory: () => {
12
+ const hooks = inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS);
13
+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GhVbmF1dGhlbnRpY2F0ZWRIb29rID0gKHRyaWdnZXI6IEFjdGlvblsndHlwZSddKSA9PiBPYnNlcnZhYmxlPHVua25vd24+O1xuIl19
@@ -1,8 +1,7 @@
1
1
  import { InjectionToken, } from '@angular/core';
2
2
  /**
3
3
  * A token to hold the unauthenticated hooks.
4
- * When a logged-in user is unauthenticated, various packages may perform cleanup tasks.
5
- * These are guaranteed to run synchronously before the client driver state is fully reset.
4
+ * See {@link DaffAuthUnauthenticatedHook}.
6
5
  *
7
6
  * Prefer using {@link daffAuthProvideUnauthenticatedHooks}.
8
7
  */
@@ -26,4 +25,4 @@ export function daffAuthProvideUnauthenticatedHooks(...hooks) {
26
25
  multi: true,
27
26
  }));
28
27
  }
29
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9va3MudG9rZW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2F1dGgvc3RhdGUvc3JjL2luamVjdGlvbi10b2tlbnMvdW5hdXRoZW50aWNhdGVkL2hvb2tzLnRva2VuLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxjQUFjLEdBRWYsTUFBTSxlQUFlLENBQUM7QUFFdkI7Ozs7OztHQU1HO0FBQ0gsTUFBTSxDQUFDLE1BQU0sK0JBQStCLEdBQUcsSUFBSSxjQUFjLENBQy9ELGlDQUFpQyxFQUNuQyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsQ0FBQyxFQUFFLEVBQUMsQ0FDbkIsQ0FBQztBQUVGOzs7Ozs7Ozs7OztHQVdHO0FBQ0gsTUFBTSxVQUFVLG1DQUFtQyxDQUNqRCxHQUFHLEtBQXFCO0lBRXhCLE9BQU8sS0FBSyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7UUFDeEIsT0FBTyxFQUFFLC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HJvdmlkZXJbXSB7XG4gIHJldHVybiBob29rcy5tYXAoaG9vayA9PiAoe1xuICAgIHByb3ZpZGU6IERBRkZfQVVUSF9VTkFVVEhFTlRJQ0FURURfSE9PS1MsXG4gICAgdXNlVmFsdWU6IGhvb2ssXG4gICAgbXVsdGk6IHRydWUsXG4gIH0pKTtcbn1cbiJdfQ==
@@ -1,2 +1,2 @@
1
1
  export { daffAuthProvideUnauthenticatedHooks, DAFF_AUTH_UNAUTHENTICATED_HOOKS, } from './hooks.token';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvYXV0aC9zdGF0ZS9zcmMvaW5qZWN0aW9uLXRva2Vucy91bmF1dGhlbnRpY2F0ZWQvcHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsbUNBQW1DLEVBQ25DLCtCQUErQixHQUNoQyxNQUFNLGVBQWUsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7XG4gIGRhZmZBdXRoUHJvdmlkZVVuYXV0aGVudGljYXRlZEhvb2tzLFxuICBEQUZGX0FVVEhfVU5BVVRIRU5USUNBVEVEX0hPT0tTLFxufSBmcm9tICcuL2hvb2tzLnRva2VuJztcbiJdfQ==
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvYXV0aC9zdGF0ZS9zcmMvaW5qZWN0aW9uLXRva2Vucy91bmF1dGhlbnRpY2F0ZWQvcHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsbUNBQW1DLEVBQ25DLCtCQUErQixHQUNoQyxNQUFNLGVBQWUsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7XG4gIGRhZmZBdXRoUHJvdmlkZVVuYXV0aGVudGljYXRlZEhvb2tzLFxuICBEQUZGX0FVVEhfVU5BVVRIRU5USUNBVEVEX0hPT0tTLFxufSBmcm9tICcuL2hvb2tzLnRva2VuJztcbmV4cG9ydCB7IERhZmZBdXRoVW5hdXRoZW50aWNhdGVkSG9vayB9IGZyb20gJy4vaG9vay50eXBlJztcbiJdfQ==
@@ -3,7 +3,7 @@ import { InjectionToken, Injectable, Inject } from '@angular/core';
3
3
  import { DaffInheritableError } from '@daffodil/core';
4
4
  import { of, switchMap, throwError } from 'rxjs';
5
5
  import * as i1 from '@daffodil/auth';
6
- import { DaffAuthMissingTokenError } from '@daffodil/auth';
6
+ import { DaffAuthMissingTokenError, DaffAuthErrorCodes } from '@daffodil/auth';
7
7
 
8
8
  const DaffAuthDriver = new InjectionToken('DaffAuthDriver');
9
9
 
@@ -100,9 +100,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
100
100
  }] }];
101
101
  } });
102
102
 
103
+ /**
104
+ * The error codes that indicate that the user definitely should not be in an unauthenticated state
105
+ * and if an auth token exists in storage, it is invalid.
106
+ * These are contrasted to network failures and other sporadic and generic errors that aren't
107
+ * a guarantee of the token's invalidity.
108
+ */
109
+ const DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES = {
110
+ [DaffAuthDriverErrorCodes.UNAUTHORIZED]: true,
111
+ [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: true,
112
+ [DaffAuthErrorCodes.MISSING_TOKEN]: true,
113
+ };
114
+
103
115
  /**
104
116
  * Generated bundle index. Do not edit.
105
117
  */
106
118
 
107
- export { DaffAuthDriver, DaffAuthDriverErrorCodes, DaffAuthDriverErrorMap, DaffAuthDriverTokenCheck, DaffAuthInvalidAPIResponseError, DaffAuthenticationFailedError, DaffLoginDriver, DaffRegisterDriver, DaffRegistrationFailedError, DaffResetPasswordDriver, DaffUnauthorizedError };
119
+ export { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES, DaffAuthDriver, DaffAuthDriverErrorCodes, DaffAuthDriverErrorMap, DaffAuthDriverTokenCheck, DaffAuthInvalidAPIResponseError, DaffAuthenticationFailedError, DaffLoginDriver, DaffRegisterDriver, DaffRegistrationFailedError, DaffResetPasswordDriver, DaffUnauthorizedError };
108
120
  //# sourceMappingURL=daffodil-auth-driver.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-auth-driver.mjs","sources":["../../../libs/auth/driver/src/interfaces/auth-service.interface.ts","../../../libs/auth/driver/src/interfaces/login-service.interface.ts","../../../libs/auth/driver/src/interfaces/register-service.interface.ts","../../../libs/auth/driver/src/interfaces/reset-password-service.interface.ts","../../../libs/auth/driver/src/errors/codes.enum.ts","../../../libs/auth/driver/src/errors/unauthorized.ts","../../../libs/auth/driver/src/errors/authentication-failed.ts","../../../libs/auth/driver/src/errors/registration-failed.ts","../../../libs/auth/driver/src/errors/invalid-api-response.ts","../../../libs/auth/driver/src/errors/map.ts","../../../libs/auth/driver/src/services/auth-check.service.ts","../../../libs/auth/driver/src/daffodil-auth-driver.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport interface DaffAuthServiceInterface {\n /**\n * Checks the validity of an auth token.\n */\n check(): Observable<void>;\n}\n\nexport const DaffAuthDriver = new InjectionToken<DaffAuthServiceInterface>('DaffAuthDriver');\n","import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport {\n DaffLoginInfo,\n DaffAuthToken,\n} from '@daffodil/auth';\n\nexport interface DaffLoginServiceInterface<\n TRequest extends DaffLoginInfo = DaffLoginInfo,\n TResponse extends DaffAuthToken = DaffAuthToken\n> {\n /**\n * Logs the user in.\n *\n * @returns An access token.\n */\n login(loginInfo: TRequest): Observable<TResponse>;\n\n /**\n * Logs the user out by revoking their access token.\n */\n logout(): Observable<void>;\n}\n\nexport const DaffLoginDriver = new InjectionToken<DaffLoginServiceInterface>('DaffLoginDriver');\n","import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport { DaffAccountRegistration } from '@daffodil/auth';\n\nexport interface DaffRegisterServiceInterface<\n TRequest extends DaffAccountRegistration = DaffAccountRegistration,\n> {\n\n /**\n * Registers an account for the specified customer and logs the customer in.\n *\n * @param registration The account registration info.\n * @return The authentication token.\n */\n register(registration: TRequest): Observable<string>;\n\n /**\n * Registers an account for the specified customer but does not log the customer in.\n *\n * @param registration The account registration info.\n */\n registerOnly(registration: TRequest): Observable<void>;\n}\n\nexport const DaffRegisterDriver = new InjectionToken<DaffRegisterServiceInterface>('DaffRegisterDriver');\n","import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport { DaffAuthResetPasswordInfo } from '@daffodil/auth';\n\nexport interface DaffResetPasswordServiceInterface<\n T extends DaffAuthResetPasswordInfo = DaffAuthResetPasswordInfo,\n> {\n\n /**\n * Resets password for the specified customer and logs in.\n */\n resetPassword(info: T): Observable<string>;\n\n /**\n * Resets password for the specified customer.\n */\n resetPasswordOnly(info: T): Observable<void>;\n\n /**\n * Send a password reset email to the specified email address.\n */\n sendResetEmail(email: string): Observable<void>;\n}\n\nexport const DaffResetPasswordDriver = new InjectionToken<DaffResetPasswordServiceInterface>('DaffResetPasswordDriver');\n","export enum DaffAuthDriverErrorCodes {\n AUTHENTICATION_FAILED = 'DAFF_AUTH_AUTHENTICATION_FAILED',\n INVALID_API_RESPONSE = 'DAFF_AUTH_INVALID_API_RESPONSE',\n REGISTRATION_FAILED = 'DAFF_AUTH_REGISTRATION_FAILED',\n UNAUTHORIZED = 'DAFF_AUTH_UNAUTHORIZED',\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffUnauthorizedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.UNAUTHORIZED;\n\n constructor(public message: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthenticationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED;\n\n constructor(public message: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\n/**\n * An error thrown when registration failed.\n */\nexport class DaffRegistrationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.REGISTRATION_FAILED;\n\n constructor(public message: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthInvalidAPIResponseError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.INVALID_API_RESPONSE;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { DaffAuthenticationFailedError } from './authentication-failed';\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\nimport { DaffAuthInvalidAPIResponseError } from './invalid-api-response';\nimport { DaffRegistrationFailedError } from './registration-failed';\nimport { DaffUnauthorizedError } from './unauthorized';\n\n/**\n * A mapping from error codes to error class constructors.\n */\nexport const DaffAuthDriverErrorMap = {\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: DaffAuthenticationFailedError,\n [DaffAuthDriverErrorCodes.INVALID_API_RESPONSE]: DaffAuthInvalidAPIResponseError,\n [DaffAuthDriverErrorCodes.REGISTRATION_FAILED]: DaffRegistrationFailedError,\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: DaffUnauthorizedError,\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n Observable,\n map,\n of,\n switchMap,\n throwError,\n} from 'rxjs';\n\nimport {\n DaffAuthStorageService,\n DaffAuthMissingTokenError,\n} from '@daffodil/auth';\n\nimport {\n DaffAuthDriver,\n DaffAuthServiceInterface,\n} from '../interfaces/public_api';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffAuthDriverTokenCheck {\n constructor(\n private storage: DaffAuthStorageService,\n @Inject(DaffAuthDriver) private driver: DaffAuthServiceInterface,\n ) {}\n\n /**\n * Checks if the auth token in storage is valid.\n * If there is not an auth token in storage, the driver is not called\n * and an error is immediately thrown.\n */\n check(): Observable<void> {\n return of(null).pipe(\n switchMap(() => {\n const token = this.storage.getAuthToken();\n\n if (!token) {\n return throwError(() => new DaffAuthMissingTokenError('There is not an auth token in storage'));\n }\n\n return this.driver.check();\n }),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,cAAc,GAAG,IAAI,cAAc,CAA2B,gBAAgB;;MCe9E,eAAe,GAAG,IAAI,cAAc,CAA4B,iBAAiB;;MCAjF,kBAAkB,GAAG,IAAI,cAAc,CAA+B,oBAAoB;;MCA1F,uBAAuB,GAAG,IAAI,cAAc,CAAoC,yBAAyB;;ACzB1G,IAAA,yBAKX;AALD,CAAA,UAAY,wBAAwB,EAAA;AAClC,IAAA,wBAAA,CAAA,uBAAA,CAAA,GAAA,iCAAyD,CAAA;AACzD,IAAA,wBAAA,CAAA,sBAAA,CAAA,GAAA,gCAAuD,CAAA;AACvD,IAAA,wBAAA,CAAA,qBAAA,CAAA,GAAA,+BAAqD,CAAA;AACrD,IAAA,wBAAA,CAAA,cAAA,CAAA,GAAA,wBAAuC,CAAA;AACzC,CAAC,EALW,wBAAwB,KAAxB,wBAAwB,GAKnC,EAAA,CAAA,CAAA;;ACEK,MAAO,qBAAsB,SAAQ,oBAAoB,CAAA;AAG7D,IAAA,WAAA,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interfaces/login-service.interface.ts","../../../libs/auth/driver/src/interfaces/register-service.interface.ts","../../../libs/auth/driver/src/interfaces/reset-password-service.interface.ts","../../../libs/auth/driver/src/errors/codes.enum.ts","../../../libs/auth/driver/src/errors/unauthorized.ts","../../../libs/auth/driver/src/errors/authentication-failed.ts","../../../libs/auth/driver/src/errors/registration-failed.ts","../../../libs/auth/driver/src/errors/invalid-api-response.ts","../../../libs/auth/driver/src/errors/map.ts","../../../libs/auth/driver/src/services/auth-check.service.ts","../../../libs/auth/driver/src/constants/unauthenticated-error-codes.ts","../../../libs/auth/driver/src/daffodil-auth-driver.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport interface DaffAuthServiceInterface {\n /**\n * Checks the validity of an auth token.\n */\n check(): Observable<void>;\n}\n\nexport const DaffAuthDriver = new InjectionToken<DaffAuthServiceInterface>('DaffAuthDriver');\n","import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport {\n DaffLoginInfo,\n DaffAuthToken,\n} from '@daffodil/auth';\n\nexport interface DaffLoginServiceInterface<\n TRequest extends DaffLoginInfo = DaffLoginInfo,\n TResponse extends DaffAuthToken = DaffAuthToken\n> {\n /**\n * Logs the user in.\n *\n * @returns An access token.\n */\n login(loginInfo: TRequest): Observable<TResponse>;\n\n /**\n * Logs the user out by revoking their access token.\n */\n logout(): Observable<void>;\n}\n\nexport const DaffLoginDriver = new InjectionToken<DaffLoginServiceInterface>('DaffLoginDriver');\n","import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport { DaffAccountRegistration } from '@daffodil/auth';\n\nexport interface DaffRegisterServiceInterface<\n TRequest extends DaffAccountRegistration = DaffAccountRegistration,\n> {\n\n /**\n * Registers an account for the specified customer and logs the customer in.\n *\n * @param registration The account registration info.\n * @return The authentication token.\n */\n register(registration: TRequest): Observable<string>;\n\n /**\n * Registers an account for the specified customer but does not log the customer in.\n *\n * @param registration The account registration info.\n */\n registerOnly(registration: TRequest): Observable<void>;\n}\n\nexport const DaffRegisterDriver = new InjectionToken<DaffRegisterServiceInterface>('DaffRegisterDriver');\n","import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport { DaffAuthResetPasswordInfo } from '@daffodil/auth';\n\nexport interface DaffResetPasswordServiceInterface<\n T extends DaffAuthResetPasswordInfo = DaffAuthResetPasswordInfo,\n> {\n\n /**\n * Resets password for the specified customer and logs in.\n */\n resetPassword(info: T): Observable<string>;\n\n /**\n * Resets password for the specified customer.\n */\n resetPasswordOnly(info: T): Observable<void>;\n\n /**\n * Send a password reset email to the specified email address.\n */\n sendResetEmail(email: string): Observable<void>;\n}\n\nexport const DaffResetPasswordDriver = new InjectionToken<DaffResetPasswordServiceInterface>('DaffResetPasswordDriver');\n","export enum DaffAuthDriverErrorCodes {\n AUTHENTICATION_FAILED = 'DAFF_AUTH_AUTHENTICATION_FAILED',\n INVALID_API_RESPONSE = 'DAFF_AUTH_INVALID_API_RESPONSE',\n REGISTRATION_FAILED = 'DAFF_AUTH_REGISTRATION_FAILED',\n UNAUTHORIZED = 'DAFF_AUTH_UNAUTHORIZED',\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffUnauthorizedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.UNAUTHORIZED;\n\n constructor(public message: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthenticationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED;\n\n constructor(public message: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\n/**\n * An error thrown when registration failed.\n */\nexport class DaffRegistrationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.REGISTRATION_FAILED;\n\n constructor(public message: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthInvalidAPIResponseError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.INVALID_API_RESPONSE;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { DaffAuthenticationFailedError } from './authentication-failed';\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\nimport { DaffAuthInvalidAPIResponseError } from './invalid-api-response';\nimport { DaffRegistrationFailedError } from './registration-failed';\nimport { DaffUnauthorizedError } from './unauthorized';\n\n/**\n * A mapping from error codes to error class constructors.\n */\nexport const DaffAuthDriverErrorMap = {\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: DaffAuthenticationFailedError,\n [DaffAuthDriverErrorCodes.INVALID_API_RESPONSE]: DaffAuthInvalidAPIResponseError,\n [DaffAuthDriverErrorCodes.REGISTRATION_FAILED]: DaffRegistrationFailedError,\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: DaffUnauthorizedError,\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n Observable,\n map,\n of,\n switchMap,\n throwError,\n} from 'rxjs';\n\nimport {\n DaffAuthStorageService,\n DaffAuthMissingTokenError,\n} from '@daffodil/auth';\n\nimport {\n DaffAuthDriver,\n DaffAuthServiceInterface,\n} from '../interfaces/public_api';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffAuthDriverTokenCheck {\n constructor(\n private storage: DaffAuthStorageService,\n @Inject(DaffAuthDriver) private driver: DaffAuthServiceInterface,\n ) {}\n\n /**\n * Checks if the auth token in storage is valid.\n * If there is not an auth token in storage, the driver is not called\n * and an error is immediately thrown.\n */\n check(): Observable<void> {\n return of(null).pipe(\n switchMap(() => {\n const token = this.storage.getAuthToken();\n\n if (!token) {\n return throwError(() => new DaffAuthMissingTokenError('There is not an auth token in storage'));\n }\n\n return this.driver.check();\n }),\n );\n }\n}\n","import { DaffAuthErrorCodes } from '@daffodil/auth';\n\nimport { DaffAuthDriverErrorCodes } from '../errors/public_api';\n\n/**\n * The error codes that indicate that the user definitely should not be in an unauthenticated state\n * and if an auth token exists in storage, it is invalid.\n * These are contrasted to network failures and other sporadic and generic errors that aren't\n * a guarantee of the token's invalidity.\n */\nexport const DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES = {\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: true,\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: true,\n [DaffAuthErrorCodes.MISSING_TOKEN]: true,\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,cAAc,GAAG,IAAI,cAAc,CAA2B,gBAAgB;;MCe9E,eAAe,GAAG,IAAI,cAAc,CAA4B,iBAAiB;;MCAjF,kBAAkB,GAAG,IAAI,cAAc,CAA+B,oBAAoB;;MCA1F,uBAAuB,GAAG,IAAI,cAAc,CAAoC,yBAAyB;;ACzB1G,IAAA,yBAKX;AALD,CAAA,UAAY,wBAAwB,EAAA;AAClC,IAAA,wBAAA,CAAA,uBAAA,CAAA,GAAA,iCAAyD,CAAA;AACzD,IAAA,wBAAA,CAAA,sBAAA,CAAA,GAAA,gCAAuD,CAAA;AACvD,IAAA,wBAAA,CAAA,qBAAA,CAAA,GAAA,+BAAqD,CAAA;AACrD,IAAA,wBAAA,CAAA,cAAA,CAAA,GAAA,wBAAuC,CAAA;AACzC,CAAC,EALW,wBAAwB,KAAxB,wBAAwB,GAKnC,EAAA,CAAA,CAAA;;ACEK,MAAO,qBAAsB,SAAQ,oBAAoB,CAAA;AAG7D,IAAA,WAAA,CAAmB,OAAe,EAAA;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;AADG,Q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AAC,aAAa,GAAG,IAAI;;;ACb1C;;AAEG;;;;"}
@@ -1,14 +1,15 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
3
- import { of, EMPTY } from 'rxjs';
2
+ import { InjectionToken, Injectable, Inject, NgModule, inject } from '@angular/core';
3
+ import { of, from, EMPTY } from 'rxjs';
4
4
  import { tap, map, catchError, filter, switchMap } from 'rxjs/operators';
5
5
  import * as i2 from '@daffodil/auth';
6
6
  import { DAFF_AUTH_ERROR_MATCHER } from '@daffodil/auth';
7
7
  import * as i1 from '@daffodil/auth/driver';
8
- import { DaffAuthDriverErrorCodes } from '@daffodil/auth/driver';
8
+ import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES } from '@daffodil/auth/driver';
9
9
  import * as i1$1 from '@daffodil/auth/state';
10
- import { DaffAuthGuardLogout, DaffResetPasswordLanding, DaffAuthLoginActionTypes, DaffAuthRegisterActionTypes, DaffAuthResetPasswordActionTypes, DaffAuthActionTypes } from '@daffodil/auth/state';
10
+ import { DaffAuthGuardLogout, DaffResetPasswordLanding, DaffAuthActionTypes, DaffAuthLoginActionTypes, DaffAuthRegisterActionTypes, DaffAuthResetPasswordActionTypes, DAFF_AUTH_UNAUTHENTICATED_HOOKS } from '@daffodil/auth/state';
11
11
  import * as i3 from '@angular/router';
12
+ import { Router, ActivatedRoute } from '@angular/router';
12
13
  import * as i4 from '@ngrx/store';
13
14
  import * as i1$2 from '@ngrx/effects';
14
15
  import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
@@ -33,8 +34,7 @@ class MemberOnlyGuard {
33
34
  }
34
35
  isAuthenticated() {
35
36
  return this.tokenCheck.check().pipe(map(() => true), catchError((error) => {
36
- if (error.code === DaffAuthDriverErrorCodes.UNAUTHORIZED) {
37
- this.storage.removeAuthToken();
37
+ if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) {
38
38
  this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));
39
39
  }
40
40
  return of(false);
@@ -78,8 +78,7 @@ class GuestOnlyGuard {
78
78
  }
79
79
  isUnauthenticated() {
80
80
  return this.tokenCheck.check().pipe(map(() => false), catchError((error) => {
81
- if (error.code === DaffAuthDriverErrorCodes.UNAUTHORIZED) {
82
- this.storage.removeAuthToken();
81
+ if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) {
83
82
  this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));
84
83
  }
85
84
  return of(true);
@@ -153,6 +152,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
153
152
  }] }];
154
153
  } });
155
154
 
155
+ function daffAuthRoutingRedirectUnauthenticatedHookFactory(router, route, config) {
156
+ return (trigger) => {
157
+ switch (trigger) {
158
+ case DaffAuthLoginActionTypes.LogoutSuccessAction:
159
+ return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.logoutRedirectPath));
160
+ case DaffAuthActionTypes.AuthCheckFailureAction:
161
+ case DaffAuthActionTypes.AuthGuardLogoutAction:
162
+ return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.tokenExpirationRedirectPath));
163
+ default:
164
+ return of(null);
165
+ }
166
+ };
167
+ }
168
+
156
169
  class DaffAuthRoutingModule {
157
170
  static withConfig(config) {
158
171
  return {
@@ -198,12 +211,6 @@ class DaffAuthRedirectEffects {
198
211
  }), tap((action) => {
199
212
  this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.authCompleteRedirectPath);
200
213
  }), switchMap(() => EMPTY)), { dispatch: false });
201
- this.redirectAfterLogout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutSuccessAction), tap((action) => {
202
- this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.logoutRedirectPath);
203
- }), switchMap(() => EMPTY)), { dispatch: false });
204
- this.redirectAfterExpiration$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction, DaffAuthActionTypes.AuthGuardLogoutAction), tap(() => {
205
- this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.tokenExpirationRedirectPath);
206
- }), switchMap(() => EMPTY)), { dispatch: false });
207
214
  }
208
215
  }
209
216
  /** @nocollapse */ DaffAuthRedirectEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthRedirectEffects, deps: [{ token: i1$2.Actions }, { token: i3.Router }, { token: i3.ActivatedRoute }, { token: DAFF_AUTH_ROUTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -221,7 +228,13 @@ class DaffAuthRoutingRedirectModule {
221
228
  }
222
229
  /** @nocollapse */ DaffAuthRoutingRedirectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthRoutingRedirectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
223
230
  /** @nocollapse */ DaffAuthRoutingRedirectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthRoutingRedirectModule, imports: [i1$2.EffectsFeatureModule] });
224
- /** @nocollapse */ DaffAuthRoutingRedirectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthRoutingRedirectModule, imports: [[
231
+ /** @nocollapse */ DaffAuthRoutingRedirectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthRoutingRedirectModule, providers: [
232
+ {
233
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
234
+ multi: true,
235
+ useFactory: (() => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG))),
236
+ },
237
+ ], imports: [[
225
238
  EffectsModule.forFeature([
226
239
  DaffAuthRedirectEffects,
227
240
  ]),
@@ -234,6 +247,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
234
247
  DaffAuthRedirectEffects,
235
248
  ]),
236
249
  ],
250
+ providers: [
251
+ {
252
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
253
+ multi: true,
254
+ useFactory: (() => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG))),
255
+ },
256
+ ],
237
257
  }]
238
258
  }] });
239
259
 
@@ -241,5 +261,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
241
261
  * Generated bundle index. Do not edit.
242
262
  */
243
263
 
244
- export { DAFF_AUTH_ROUTING_CONFIG, DAFF_AUTH_ROUTING_CONFIG_DEFAULT, DaffAuthGuestOnlyGuardRedirectUrl, DaffAuthMemberOnlyGuardRedirectUrl, DaffAuthResetPasswordGuard, DaffAuthRoutingModule, DaffAuthRoutingRedirectModule, GuestOnlyGuard, MemberOnlyGuard, provideDaffAuthRoutingConfig };
264
+ export { DAFF_AUTH_ROUTING_CONFIG, DAFF_AUTH_ROUTING_CONFIG_DEFAULT, DaffAuthGuestOnlyGuardRedirectUrl, DaffAuthMemberOnlyGuardRedirectUrl, DaffAuthResetPasswordGuard, DaffAuthRoutingModule, DaffAuthRoutingRedirectModule, GuestOnlyGuard, MemberOnlyGuard, daffAuthRoutingRedirectUnauthenticatedHookFactory, provideDaffAuthRoutingConfig };
245
265
  //# sourceMappingURL=daffodil-auth-routing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-auth-routing.mjs","sources":["../../../libs/auth/routing/src/guards/member-only-guard-redirect.token.ts","../../../libs/auth/routing/src/guards/member-only.guard.ts","../../../libs/auth/routing/src/guards/guest-only-guard-redirect.token.ts","../../../libs/auth/routing/src/guards/guest-only.guard.ts","../../../libs/auth/routing/src/config/default.ts","../../../libs/auth/routing/src/config/token.ts","../../../libs/auth/routing/src/guards/reset-password.guard.ts","../../../libs/auth/routing/src/module.ts","../../../libs/auth/routing/src/effects/redirect.effects.ts","../../../libs/auth/routing/src/redirect.module.ts","../../../libs/auth/routing/src/daffodil-auth-routing.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const DaffAuthMemberOnlyGuardRedirectUrl = new InjectionToken<string>('DaffAuthMemberOnlyGuardRedirectUrl', { factory: () => '/' });\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n CanActivate,\n Router,\n} from '@angular/router';\nimport { Store } from '@ngrx/store';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n tap,\n} from 'rxjs/operators';\n\nimport {\n DAFF_AUTH_ERROR_MATCHER,\n DaffAuthStorageService,\n} from '@daffodil/auth';\nimport {\n DaffAuthDriverErrorCodes,\n DaffAuthDriverTokenCheck,\n} from '@daffodil/auth/driver';\nimport { DaffAuthGuardLogout } from '@daffodil/auth/state';\nimport { DaffError } from '@daffodil/core';\nimport { ErrorTransformer } from '@daffodil/core/state';\n\nimport { DaffAuthMemberOnlyGuardRedirectUrl } from './member-only-guard-redirect.token';\n\n\n@Injectable({\n providedIn: 'any',\n})\nexport class MemberOnlyGuard implements CanActivate {\n constructor(\n private tokenCheck: DaffAuthDriverTokenCheck,\n private storage: DaffAuthStorageService,\n private router: Router,\n private store: Store,\n @Inject(DAFF_AUTH_ERROR_MATCHER) private errorMatcher: ErrorTransformer,\n @Inject(DaffAuthMemberOnlyGuardRedirectUrl) private redirectUrl: string,\n ) {}\n\n canActivate(): Observable<boolean> {\n return this.isAuthenticated().pipe(\n tap(result => {\n if (!result) {\n this.router.navigateByUrl(this.redirectUrl);\n }\n }),\n );\n }\n\n private isAuthenticated(): Observable<boolean> {\n return this.tokenCheck.check().pipe(\n map(() => true),\n catchError((error: DaffError) => {\n if (error.code === DaffAuthDriverErrorCodes.UNAUTHORIZED) {\n this.storage.removeAuthToken();\n this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));\n }\n return of(false);\n }),\n );\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const DaffAuthGuestOnlyGuardRedirectUrl = new InjectionToken<string>('DaffAuthGuestOnlyGuardRedirectUrl', { factory: () => '/' });\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n CanActivate,\n Router,\n} from '@angular/router';\nimport { Store } from '@ngrx/store';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n tap,\n} from 'rxjs/operators';\n\nimport {\n DAFF_AUTH_ERROR_MATCHER,\n DaffAuthStorageService,\n} from '@daffodil/auth';\nimport {\n DaffAuthDriverErrorCodes,\n DaffAuthDriverTokenCheck,\n} from '@daffodil/auth/driver';\nimport { DaffAuthGuardLogout } from '@daffodil/auth/state';\nimport { DaffError } from '@daffodil/core';\nimport { ErrorTransformer } from '@daffodil/core/state';\n\nimport { DaffAuthGuestOnlyGuardRedirectUrl } from './guest-only-guard-redirect.token';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class GuestOnlyGuard implements CanActivate {\n constructor(\n private tokenCheck: DaffAuthDriverTokenCheck,\n private storage: DaffAuthStorageService,\n private router: Router,\n private store: Store,\n @Inject(DAFF_AUTH_ERROR_MATCHER) private errorMatcher: ErrorTransformer,\n @Inject(DaffAuthGuestOnlyGuardRedirectUrl) private redirectUrl: string,\n ) {}\n\n canActivate(): Observable<boolean> {\n return this.isUnauthenticated().pipe(\n tap(result => {\n if (!result) {\n this.router.navigateByUrl(this.redirectUrl);\n }\n }),\n );\n }\n\n private isUnauthenticated(): Observable<boolean> {\n return this.tokenCheck.check().pipe(\n map(() => false),\n catchError((error: DaffError) => {\n if (error.code === DaffAuthDriverErrorCodes.UNAUTHORIZED) {\n this.storage.removeAuthToken();\n this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));\n }\n return of(true);\n }),\n );\n }\n}\n","import { DaffAuthRoutingConfig } from './interface';\n\nexport const DAFF_AUTH_ROUTING_CONFIG_DEFAULT: DaffAuthRoutingConfig = {\n resetPasswordTokenParam: 'token',\n redirectUrlParam: 'redirect',\n authCompleteRedirectPath: '/',\n logoutRedirectPath: '/',\n tokenExpirationRedirectPath: '/',\n};\n","import {\n InjectionToken,\n ValueProvider,\n} from '@angular/core';\n\nimport { DAFF_AUTH_ROUTING_CONFIG_DEFAULT } from './default';\nimport { DaffAuthRoutingConfig } from './interface';\n\n/**\n * The token used to provide @daffodil/auth/routing config data.\n */\nexport const DAFF_AUTH_ROUTING_CONFIG = new InjectionToken<DaffAuthRoutingConfig>('DAFF_AUTH_ROUTING_CONFIG', {\n factory: () => DAFF_AUTH_ROUTING_CONFIG_DEFAULT,\n});\n\nexport function provideDaffAuthRoutingConfig(config?: Partial<DaffAuthRoutingConfig>): ValueProvider {\n return {\n provide: DAFF_AUTH_ROUTING_CONFIG,\n useValue: {\n ...DAFF_AUTH_ROUTING_CONFIG_DEFAULT,\n ...config || {},\n },\n };\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n CanActivate,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\n\nimport {\n DaffAuthFacade,\n DaffResetPasswordLanding,\n} from '@daffodil/auth/state';\n\nimport {\n DaffAuthRoutingConfig,\n DAFF_AUTH_ROUTING_CONFIG,\n} from '../config/public_api';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class DaffAuthResetPasswordGuard implements CanActivate {\n constructor(\n private facade: DaffAuthFacade,\n @Inject(DAFF_AUTH_ROUTING_CONFIG) private config: DaffAuthRoutingConfig,\n ) {}\n\n canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {\n const token = route.queryParamMap.get(this.config.resetPasswordTokenParam);\n\n if (!token) {\n return of(false);\n }\n\n this.facade.dispatch(new DaffResetPasswordLanding(token));\n\n return of(true);\n }\n}\n","import {\n ModuleWithProviders,\n NgModule,\n} from '@angular/core';\n\nimport {\n DaffAuthRoutingConfig,\n DAFF_AUTH_ROUTING_CONFIG,\n DAFF_AUTH_ROUTING_CONFIG_DEFAULT,\n provideDaffAuthRoutingConfig,\n} from './config/public_api';\nimport {\n DaffAuthResetPasswordGuard,\n GuestOnlyGuard,\n MemberOnlyGuard,\n} from './guards/public_api';\n\n@NgModule({\n providers: [\n DaffAuthResetPasswordGuard,\n MemberOnlyGuard,\n GuestOnlyGuard,\n ],\n})\nexport class DaffAuthRoutingModule {\n static withConfig(config?: Partial<DaffAuthRoutingConfig>): ModuleWithProviders<DaffAuthRoutingModule> {\n return {\n ngModule: DaffAuthRoutingModule,\n providers: [\n provideDaffAuthRoutingConfig(config),\n ],\n };\n }\n}\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n ActivatedRoute,\n Router,\n} from '@angular/router';\nimport {\n Actions,\n createEffect,\n ofType,\n} from '@ngrx/effects';\nimport { EMPTY } from 'rxjs';\nimport {\n filter,\n switchMap,\n tap,\n} from 'rxjs/operators';\n\nimport {\n DaffAuthActionTypes,\n DaffAuthActions,\n DaffAuthLoginActionTypes,\n DaffAuthLoginActions,\n DaffAuthRegisterActionTypes,\n DaffAuthRegisterActions,\n DaffAuthResetPasswordActionTypes,\n DaffAuthResetPasswordActions,\n} from '@daffodil/auth/state';\n\nimport {\n DaffAuthRoutingConfig,\n DAFF_AUTH_ROUTING_CONFIG,\n} from '../config/public_api';\n\n/**\n * Redirects the user to certain pages based on certain auth actions.\n */\n@Injectable()\nexport class DaffAuthRedirectEffects {\n constructor(\n private actions$: Actions<DaffAuthLoginActions | DaffAuthActions | DaffAuthRegisterActions | DaffAuthResetPasswordActions>,\n private router: Router,\n private route: ActivatedRoute,\n @Inject(DAFF_AUTH_ROUTING_CONFIG) private config: DaffAuthRoutingConfig,\n ) {}\n\n redirectAfterLoginOrRegister$ = createEffect(() => this.actions$.pipe(\n ofType(\n DaffAuthLoginActionTypes.LoginSuccessAction,\n DaffAuthRegisterActionTypes.RegisterSuccessAction,\n DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction,\n ),\n filter((action) => {\n if ((action.type === DaffAuthRegisterActionTypes.RegisterSuccessAction || action.type === DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction) && !action.token) {\n return false;\n }\n return true;\n }),\n tap((action) => {\n this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.authCompleteRedirectPath);\n }),\n switchMap(() => EMPTY),\n ), { dispatch: false });\n\n redirectAfterLogout$ = createEffect(() => this.actions$.pipe(\n ofType(DaffAuthLoginActionTypes.LogoutSuccessAction),\n tap((action) => {\n this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.logoutRedirectPath);\n }),\n switchMap(() => EMPTY),\n ), { dispatch: false });\n\n redirectAfterExpiration$ = createEffect(() => this.actions$.pipe(\n ofType(\n DaffAuthActionTypes.AuthCheckFailureAction,\n DaffAuthActionTypes.AuthGuardLogoutAction,\n ),\n tap(() => {\n this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.tokenExpirationRedirectPath);\n }),\n switchMap(() => EMPTY),\n ), { dispatch: false });\n}\n","import { NgModule } from '@angular/core';\nimport { EffectsModule } from '@ngrx/effects';\n\nimport { DaffAuthRedirectEffects } from './effects/redirect.effects';\n\n@NgModule({\n imports: [\n EffectsModule.forFeature([\n DaffAuthRedirectEffects,\n ]),\n ],\n})\nexport class DaffAuthRoutingRedirectModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;;;AAEa,MAAA,kCAAkC,GAAG,IAAI,cAAc,CAAS,oCAAoC,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,EAAE;;MCmC5H,eAAe,CAAA;IAC1B,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MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;2IALvB,uBAAuB,EAAA,CAAA,CAAA;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;;;8BAMN,MAAM;+BAAC,wBAAwB,CAAA;;;;MCjCvB,6BAA6B,CAAA;;6IAA7B,6BAA6B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;8IAA7B,6BAA6B,EAAA,OAAA,EAAA,CAAAA,IAAA,CAAA,oBAAA,CAAA,EAAA,CAAA,CAAA;AAA7B,mBAAA,6BAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,6BAA6B,EAN/B,OAAA,EAAA,CAAA;YACP,aAAa,CAAC,UAAU,CAAC;gBACvB,uBAAuB;aACxB,CAAC;SACH,CAAA,EAAA,CAAA,CAAA;2FAEU,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBAPzC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,aAAa,CAAC,UAAU,CAAC;4BACvB,uBAAuB;yBACxB,CAAC;AACH,qBAAA;iBACF,CAAA;;;ACXD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-auth-routing.mjs","sources":["../../../libs/auth/routing/src/guards/member-only-guard-redirect.token.ts","../../../libs/auth/routing/src/guards/member-only.guard.ts","../../../libs/auth/routing/src/guards/guest-only-guard-redirect.token.ts","../../../libs/auth/routing/src/guards/guest-only.guard.ts","../../../libs/auth/routing/src/config/default.ts","../../../libs/auth/routing/src/config/token.ts","../../../libs/auth/routing/src/guards/reset-password.guard.ts","../../../libs/auth/routing/src/helpers/redirect-unauthenticated-hook-factory.ts","../../../libs/auth/routing/src/module.ts","../../../libs/auth/routing/src/effects/redirect.effects.ts","../../../libs/auth/routing/src/redirect.module.ts","../../../libs/auth/routing/src/daffodil-auth-routing.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const DaffAuthMemberOnlyGuardRedirectUrl = new InjectionToken<string>('DaffAuthMemberOnlyGuardRedirectUrl', { factory: () => '/' });\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n CanActivate,\n Router,\n} from '@angular/router';\nimport { Store } from '@ngrx/store';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n tap,\n} from 'rxjs/operators';\n\nimport {\n DAFF_AUTH_ERROR_MATCHER,\n DaffAuthStorageService,\n} from '@daffodil/auth';\nimport {\n DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES,\n DaffAuthDriverErrorCodes,\n DaffAuthDriverTokenCheck,\n} from '@daffodil/auth/driver';\nimport { DaffAuthGuardLogout } from '@daffodil/auth/state';\nimport { DaffError } from '@daffodil/core';\nimport { ErrorTransformer } from '@daffodil/core/state';\n\nimport { DaffAuthMemberOnlyGuardRedirectUrl } from './member-only-guard-redirect.token';\n\n\n@Injectable({\n providedIn: 'any',\n})\nexport class MemberOnlyGuard implements CanActivate {\n constructor(\n private tokenCheck: DaffAuthDriverTokenCheck,\n private storage: DaffAuthStorageService,\n private router: Router,\n private store: Store,\n @Inject(DAFF_AUTH_ERROR_MATCHER) private errorMatcher: ErrorTransformer,\n @Inject(DaffAuthMemberOnlyGuardRedirectUrl) private redirectUrl: string,\n ) {}\n\n canActivate(): Observable<boolean> {\n return this.isAuthenticated().pipe(\n tap(result => {\n if (!result) {\n this.router.navigateByUrl(this.redirectUrl);\n }\n }),\n );\n }\n\n private isAuthenticated(): Observable<boolean> {\n return this.tokenCheck.check().pipe(\n map(() => true),\n catchError((error: DaffError) => {\n if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) {\n this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));\n }\n return of(false);\n }),\n );\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const DaffAuthGuestOnlyGuardRedirectUrl = new InjectionToken<string>('DaffAuthGuestOnlyGuardRedirectUrl', { factory: () => '/' });\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n CanActivate,\n Router,\n} from '@angular/router';\nimport { Store } from '@ngrx/store';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n tap,\n} from 'rxjs/operators';\n\nimport {\n DAFF_AUTH_ERROR_MATCHER,\n DaffAuthStorageService,\n} from '@daffodil/auth';\nimport {\n DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES,\n DaffAuthDriverErrorCodes,\n DaffAuthDriverTokenCheck,\n} from '@daffodil/auth/driver';\nimport { DaffAuthGuardLogout } from '@daffodil/auth/state';\nimport { DaffError } from '@daffodil/core';\nimport { ErrorTransformer } from '@daffodil/core/state';\n\nimport { DaffAuthGuestOnlyGuardRedirectUrl } from './guest-only-guard-redirect.token';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class GuestOnlyGuard implements CanActivate {\n constructor(\n private tokenCheck: DaffAuthDriverTokenCheck,\n private storage: DaffAuthStorageService,\n private router: Router,\n private store: Store,\n @Inject(DAFF_AUTH_ERROR_MATCHER) private errorMatcher: ErrorTransformer,\n @Inject(DaffAuthGuestOnlyGuardRedirectUrl) private redirectUrl: string,\n ) {}\n\n canActivate(): Observable<boolean> {\n return this.isUnauthenticated().pipe(\n tap(result => {\n if (!result) {\n this.router.navigateByUrl(this.redirectUrl);\n }\n }),\n );\n }\n\n private isUnauthenticated(): Observable<boolean> {\n return this.tokenCheck.check().pipe(\n map(() => false),\n catchError((error: DaffError) => {\n if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) {\n this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));\n }\n return of(true);\n }),\n );\n }\n}\n","import { DaffAuthRoutingConfig } from './interface';\n\nexport const DAFF_AUTH_ROUTING_CONFIG_DEFAULT: DaffAuthRoutingConfig = {\n resetPasswordTokenParam: 'token',\n redirectUrlParam: 'redirect',\n authCompleteRedirectPath: '/',\n logoutRedirectPath: '/',\n tokenExpirationRedirectPath: '/',\n};\n","import {\n InjectionToken,\n ValueProvider,\n} from '@angular/core';\n\nimport { DAFF_AUTH_ROUTING_CONFIG_DEFAULT } from './default';\nimport { DaffAuthRoutingConfig } from './interface';\n\n/**\n * The token used to provide @daffodil/auth/routing config data.\n */\nexport const DAFF_AUTH_ROUTING_CONFIG = new InjectionToken<DaffAuthRoutingConfig>('DAFF_AUTH_ROUTING_CONFIG', {\n factory: () => DAFF_AUTH_ROUTING_CONFIG_DEFAULT,\n});\n\nexport function provideDaffAuthRoutingConfig(config?: Partial<DaffAuthRoutingConfig>): ValueProvider {\n return {\n provide: DAFF_AUTH_ROUTING_CONFIG,\n useValue: {\n ...DAFF_AUTH_ROUTING_CONFIG_DEFAULT,\n ...config || {},\n },\n };\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n CanActivate,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\n\nimport {\n DaffAuthFacade,\n DaffResetPasswordLanding,\n} from '@daffodil/auth/state';\n\nimport {\n DaffAuthRoutingConfig,\n DAFF_AUTH_ROUTING_CONFIG,\n} from '../config/public_api';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class DaffAuthResetPasswordGuard implements CanActivate {\n constructor(\n private facade: DaffAuthFacade,\n @Inject(DAFF_AUTH_ROUTING_CONFIG) private config: DaffAuthRoutingConfig,\n ) {}\n\n canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {\n const token = route.queryParamMap.get(this.config.resetPasswordTokenParam);\n\n if (!token) {\n return of(false);\n }\n\n this.facade.dispatch(new DaffResetPasswordLanding(token));\n\n return of(true);\n }\n}\n","import {\n ActivatedRoute,\n Router,\n} from '@angular/router';\nimport {\n from,\n of,\n} from 'rxjs';\n\nimport {\n DaffAuthActionTypes,\n DaffAuthLoginActionTypes,\n DaffAuthUnauthenticatedHook,\n} from '@daffodil/auth/state';\n\nimport { DaffAuthRoutingConfig } from '../config/public_api';\n\nexport function daffAuthRoutingRedirectUnauthenticatedHookFactory(router: Router, route: ActivatedRoute, config: DaffAuthRoutingConfig): DaffAuthUnauthenticatedHook {\n return (trigger) => {\n switch (trigger) {\n case DaffAuthLoginActionTypes.LogoutSuccessAction:\n return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.logoutRedirectPath));\n\n case DaffAuthActionTypes.AuthCheckFailureAction:\n case DaffAuthActionTypes.AuthGuardLogoutAction:\n return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.tokenExpirationRedirectPath));\n\n default:\n return of(null);\n }\n };\n}\n","import {\n ModuleWithProviders,\n NgModule,\n} from '@angular/core';\n\nimport {\n DaffAuthRoutingConfig,\n DAFF_AUTH_ROUTING_CONFIG,\n DAFF_AUTH_ROUTING_CONFIG_DEFAULT,\n provideDaffAuthRoutingConfig,\n} from './config/public_api';\nimport {\n DaffAuthResetPasswordGuard,\n GuestOnlyGuard,\n MemberOnlyGuard,\n} from './guards/public_api';\n\n@NgModule({\n providers: [\n DaffAuthResetPasswordGuard,\n MemberOnlyGuard,\n GuestOnlyGuard,\n ],\n})\nexport class DaffAuthRoutingModule {\n static withConfig(config?: Partial<DaffAuthRoutingConfig>): ModuleWithProviders<DaffAuthRoutingModule> {\n return {\n ngModule: DaffAuthRoutingModule,\n providers: [\n provideDaffAuthRoutingConfig(config),\n ],\n };\n }\n}\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n ActivatedRoute,\n Router,\n} from '@angular/router';\nimport {\n Actions,\n createEffect,\n ofType,\n} from '@ngrx/effects';\nimport { EMPTY } from 'rxjs';\nimport {\n filter,\n switchMap,\n tap,\n} from 'rxjs/operators';\n\nimport {\n DaffAuthActionTypes,\n DaffAuthActions,\n DaffAuthLoginActionTypes,\n DaffAuthLoginActions,\n DaffAuthRegisterActionTypes,\n DaffAuthRegisterActions,\n DaffAuthResetPasswordActionTypes,\n DaffAuthResetPasswordActions,\n} from '@daffodil/auth/state';\n\nimport {\n DaffAuthRoutingConfig,\n DAFF_AUTH_ROUTING_CONFIG,\n} from '../config/public_api';\n\n/**\n * Redirects the user to certain pages based on certain auth actions.\n */\n@Injectable()\nexport class DaffAuthRedirectEffects {\n constructor(\n private actions$: Actions<DaffAuthLoginActions | DaffAuthActions | DaffAuthRegisterActions | DaffAuthResetPasswordActions>,\n private router: Router,\n private route: ActivatedRoute,\n @Inject(DAFF_AUTH_ROUTING_CONFIG) private config: DaffAuthRoutingConfig,\n ) {}\n\n redirectAfterLoginOrRegister$ = createEffect(() => this.actions$.pipe(\n ofType(\n DaffAuthLoginActionTypes.LoginSuccessAction,\n DaffAuthRegisterActionTypes.RegisterSuccessAction,\n DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction,\n ),\n filter((action) => {\n if ((action.type === DaffAuthRegisterActionTypes.RegisterSuccessAction || action.type === DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction) && !action.token) {\n return false;\n }\n return true;\n }),\n tap((action) => {\n this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.authCompleteRedirectPath);\n }),\n switchMap(() => EMPTY),\n ), { dispatch: false });\n}\n","import {\n NgModule,\n inject,\n} from '@angular/core';\nimport {\n ActivatedRoute,\n Router,\n} from '@angular/router';\nimport { EffectsModule } from '@ngrx/effects';\nimport {\n from,\n of,\n} from 'rxjs';\n\nimport {\n DAFF_AUTH_UNAUTHENTICATED_HOOKS,\n DaffAuthActionTypes,\n DaffAuthLoginActionTypes,\n DaffAuthUnauthenticatedHook,\n} from '@daffodil/auth/state';\n\nimport { DAFF_AUTH_ROUTING_CONFIG } from './config/public_api';\nimport { DaffAuthRedirectEffects } from './effects/redirect.effects';\nimport { daffAuthRoutingRedirectUnauthenticatedHookFactory } from './helpers/public_api';\n\n\n@NgModule({\n imports: [\n EffectsModule.forFeature([\n DaffAuthRedirectEffects,\n ]),\n ],\n providers: [\n {\n provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,\n multi: true,\n useFactory: () =>\n daffAuthRoutingRedirectUnauthenticatedHookFactory(\n inject(Router),\n inject(ActivatedRoute),\n inject(DAFF_AUTH_ROUTING_CONFIG),\n ),\n },\n ],\n})\nexport class DaffAuthRoutingRedirectModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;;;;AAEa,MAAA,kCAAkC,GAAG,IAAI,cAAc,CAAS,oCAAoC,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,EAAE;;MCoC5H,eAAe,CAAA;IAC1B,WACU,CAAA,UAAoC,EACpC,OAA+B,EAC/B,MAAc,EACd,KAAY,EACqB,YAA8B,EACnB,WAAmB,EAAA;AAL/D,QAAA,IAAU,CAAA,UAAA,GAAV,UAAU,CAA0B;AACpC,QAAA,IAAO,CAAA,OAAA,GAAP,OAAO,CAAwB;AAC/B,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;AACd,QAAA,IAAK,CAAA,KAAA,GAAL,KAAK,CAAO;AACqB,QAAA,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAkB;AACnB,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAQ;KACrE;IAEJ,WAAW,GAAA;QACT,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAChC,GAAG,CAAC,MAAM,IAAG;YACX,IAAI,CAAC,MAAM,EAAE;gBACX,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7C,aAAA;SACF,CAAC,CACH,CAAC;KACH;IAEO,eAAe,GAAA;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,IAAI,CACjC,GAAG,CAAC,M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AAO,EAAE,+BAA+B;AACxC,4BAAA,KAAK,EAAE,IAAI;4BACX,UAAU,GAAE,MACV,iDAAiD,CAC/C,MAAM,CAAC,MAAM,CAAC,EACd,MAAM,CAAC,cAAc,CAAC,EACtB,MAAM,CAAC,wBAAwB,CAAC,CACjC,CAAA;AACJ,yBAAA;AACF,qBAAA;iBACF,CAAA;;;AC5CD;;AAEG;;;;"}
@@ -5,14 +5,14 @@ import * as i1 from '@ngrx/store';
5
5
  import { createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
6
6
  import * as i1$1 from '@ngrx/effects';
7
7
  import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
8
- import { of, EMPTY, iif, defer } from 'rxjs';
9
- import { switchMap, map, catchError, tap, repeat, filter } from 'rxjs/operators';
8
+ import { combineLatest, of, EMPTY, iif, defer } from 'rxjs';
10
9
  import * as i2$1 from '@daffodil/auth';
11
- import { DAFF_AUTH_ERROR_MATCHER } from '@daffodil/auth';
10
+ import { DAFF_AUTH_ERROR_MATCHER, DaffAuthStorageService } from '@daffodil/auth';
11
+ import { switchMap, map, catchError, repeat, filter, tap } from 'rxjs/operators';
12
+ import * as i2 from '@daffodil/auth/driver';
13
+ import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES, DaffLoginDriver, DaffRegisterDriver, DaffResetPasswordDriver } from '@daffodil/auth/driver';
12
14
  import { DaffStorageServiceError, DaffServerSideStorageError } from '@daffodil/core';
13
15
  import { DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE } from '@daffodil/driver';
14
- import * as i2 from '@daffodil/auth/driver';
15
- import { DaffLoginDriver, DaffRegisterDriver, DaffResetPasswordDriver } from '@daffodil/auth/driver';
16
16
 
17
17
  var DaffAuthActionTypes;
18
18
  (function (DaffAuthActionTypes) {
@@ -29,7 +29,8 @@ var DaffAuthActionTypes;
29
29
  * That reason could be a logout, auth token check failure, or an unauthorized error.
30
30
  */
31
31
  class DaffAuthResetToUnauthenticated {
32
- constructor() {
32
+ constructor(reason) {
33
+ this.reason = reason;
33
34
  this.type = DaffAuthActionTypes.ResetToUnauthenticatedAction;
34
35
  }
35
36
  }
@@ -556,8 +557,7 @@ const provideDaffAuthStateConfig = (config) => ({
556
557
 
557
558
  /**
558
559
  * A token to hold the unauthenticated hooks.
559
- * When a logged-in user is unauthenticated, various packages may perform cleanup tasks.
560
- * These are guaranteed to run synchronously before the client driver state is fully reset.
560
+ * See {@link DaffAuthUnauthenticatedHook}.
561
561
  *
562
562
  * Prefer using {@link daffAuthProvideUnauthenticatedHooks}.
563
563
  */
@@ -589,10 +589,10 @@ function daffAuthProvideUnauthenticatedHooks(...hooks) {
589
589
  * @docs-private
590
590
  */
591
591
  const DAFF_AUTH_UNAUTHENTICATED_HOOK = new InjectionToken('DAFF_AUTH_UNAUTHENTICATED_HOOK', {
592
- factory: () => inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS).reduce((acc, hook) => () => {
593
- acc();
594
- hook();
595
- }, () => { }),
592
+ factory: () => {
593
+ const hooks = inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS);
594
+ return (action) => combineLatest(hooks.map((hook) => hook(action)));
595
+ },
596
596
  });
597
597
 
598
598
  class DaffAuthEffects {
@@ -605,17 +605,6 @@ class DaffAuthEffects {
605
605
  this.clientCache = clientCache;
606
606
  this.unauthenticatedHook = unauthenticatedHook;
607
607
  this.check$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckAction), switchMap((action) => this.tokenCheck.check().pipe(map(() => new DaffAuthCheckSuccess()), catchError((error) => of(new DaffAuthCheckFailure(this.errorMatcher(error))))))));
608
- this.removeAuthToken$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction), tap(() => {
609
- this.storage.removeAuthToken();
610
- }), switchMap(() => EMPTY), catchError((error) => {
611
- switch (true) {
612
- case error instanceof DaffServerSideStorageError:
613
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
614
- case error instanceof DaffStorageServiceError:
615
- default:
616
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
617
- }
618
- })), { dispatch: false });
619
608
  // this needs to be defined after `check$` or else the driver call won't be run
620
609
  this.authCheckInterval$ = createEffect(() => of(new DaffAuthCheck()).pipe(repeat({ delay: this.config.checkInterval }), filter(() => !!this.storage.getAuthToken()), catchError((error) => {
621
610
  switch (true) {
@@ -627,13 +616,16 @@ class DaffAuthEffects {
627
616
  return EMPTY;
628
617
  }
629
618
  })));
630
- this.resetToUnauthenticated$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction, DaffAuthActionTypes.AuthGuardLogoutAction, DaffAuthLoginActionTypes.LogoutSuccessAction), map(() => new DaffAuthResetToUnauthenticated())));
631
- this.clearClientCache$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.ResetToUnauthenticatedAction),
632
- // map here to be sure that the stream waits for the hook to complete
633
- // tap is for side effects and might use setTimeout
634
- map(() => {
635
- this.unauthenticatedHook();
636
- }), tap(() => {
619
+ this.resetToUnauthenticated$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction, DaffAuthActionTypes.AuthGuardLogoutAction, DaffAuthLoginActionTypes.LogoutSuccessAction), filter((action) => {
620
+ // if the auth check failure is for any reason other than auth failure,
621
+ // such as a network failure, don't reset
622
+ if (action.type === DaffAuthActionTypes.AuthCheckFailureAction
623
+ && !DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[action.errorMessage.code]) {
624
+ return false;
625
+ }
626
+ return true;
627
+ }), map((action) => new DaffAuthResetToUnauthenticated(action.type))));
628
+ this.clearClientCache$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.ResetToUnauthenticatedAction), switchMap((action) => this.unauthenticatedHook(action.reason)), tap(() => {
637
629
  this.clientCache.reset();
638
630
  }), switchMap(() => EMPTY)), { dispatch: false });
639
631
  }
@@ -674,7 +666,7 @@ class DaffAuthLoginEffects {
674
666
  return of(new DaffAuthLoginFailure(this.errorMatcher(error)));
675
667
  }
676
668
  })))));
677
- this.logout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutAction), switchMap((action) => this.loginDriver.logout().pipe(map(() => new DaffAuthLogoutSuccess()), tap(() => this.storage.removeAuthToken()), catchError((error) => {
669
+ this.logout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutAction), switchMap((action) => this.loginDriver.logout().pipe(map(() => new DaffAuthLogoutSuccess()), catchError((error) => {
678
670
  switch (true) {
679
671
  case error instanceof DaffServerSideStorageError:
680
672
  return of(new DaffAuthServerSide(this.errorMatcher(error)));
@@ -790,7 +782,24 @@ class DaffAuthStateModule {
790
782
  }
791
783
  /** @nocollapse */ DaffAuthStateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
792
784
  /** @nocollapse */ DaffAuthStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule] });
793
- /** @nocollapse */ DaffAuthStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, imports: [[
785
+ /** @nocollapse */ DaffAuthStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, providers: [
786
+ {
787
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
788
+ useFactory: (() => {
789
+ const storage = inject(DaffAuthStorageService);
790
+ const hook = (() => {
791
+ try {
792
+ return of(storage.removeAuthToken());
793
+ }
794
+ catch (_a) {
795
+ return of(null);
796
+ }
797
+ });
798
+ return hook;
799
+ }),
800
+ multi: true,
801
+ },
802
+ ], imports: [[
794
803
  StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
795
804
  EffectsModule.forFeature([
796
805
  DaffAuthEffects,
@@ -811,6 +820,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
811
820
  DaffAuthResetPasswordEffects,
812
821
  ]),
813
822
  ],
823
+ providers: [
824
+ {
825
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
826
+ useFactory: (() => {
827
+ const storage = inject(DaffAuthStorageService);
828
+ const hook = (() => {
829
+ try {
830
+ return of(storage.removeAuthToken());
831
+ }
832
+ catch (_a) {
833
+ return of(null);
834
+ }
835
+ });
836
+ return hook;
837
+ }),
838
+ multi: true,
839
+ },
840
+ ],
814
841
  }]
815
842
  }] });
816
843