@daffodil/auth 0.94.1 → 0.95.0

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 (34) hide show
  1. package/fesm2022/daffodil-auth-driver-in-memory.mjs +356 -249
  2. package/fesm2022/daffodil-auth-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-auth-driver-magento-2.4.7.mjs +459 -0
  4. package/fesm2022/daffodil-auth-driver-magento-2.4.7.mjs.map +1 -0
  5. package/fesm2022/daffodil-auth-driver-magento-auto.mjs +7 -0
  6. package/fesm2022/daffodil-auth-driver-magento-auto.mjs.map +1 -0
  7. package/fesm2022/daffodil-auth-driver-testing.mjs +220 -126
  8. package/fesm2022/daffodil-auth-driver-testing.mjs.map +1 -1
  9. package/fesm2022/daffodil-auth-driver.mjs +99 -126
  10. package/fesm2022/daffodil-auth-driver.mjs.map +1 -1
  11. package/fesm2022/daffodil-auth-routing.mjs +392 -257
  12. package/fesm2022/daffodil-auth-routing.mjs.map +1 -1
  13. package/fesm2022/daffodil-auth-state-testing.mjs +209 -106
  14. package/fesm2022/daffodil-auth-state-testing.mjs.map +1 -1
  15. package/fesm2022/daffodil-auth-state.mjs +867 -852
  16. package/fesm2022/daffodil-auth-state.mjs.map +1 -1
  17. package/fesm2022/daffodil-auth-testing.mjs +132 -76
  18. package/fesm2022/daffodil-auth-testing.mjs.map +1 -1
  19. package/fesm2022/daffodil-auth.mjs +65 -57
  20. package/fesm2022/daffodil-auth.mjs.map +1 -1
  21. package/package.json +1 -1
  22. package/types/daffodil-auth-driver-in-memory.d.ts +62 -62
  23. package/types/daffodil-auth-driver-magento-2.4.7.d.ts +119 -0
  24. package/types/daffodil-auth-driver-magento-auto.d.ts +1 -0
  25. package/types/daffodil-auth-driver-testing.d.ts +37 -36
  26. package/types/daffodil-auth-driver.d.ts +93 -112
  27. package/types/daffodil-auth-routing.d.ts +100 -104
  28. package/types/daffodil-auth-state-testing.d.ts +44 -43
  29. package/types/daffodil-auth-state.d.ts +265 -306
  30. package/types/daffodil-auth-testing.d.ts +28 -33
  31. package/types/daffodil-auth.d.ts +51 -62
  32. package/fesm2022/daffodil-auth-driver-magento.mjs +0 -385
  33. package/fesm2022/daffodil-auth-driver-magento.mjs.map +0 -1
  34. package/types/daffodil-auth-driver-magento.d.ts +0 -135
@@ -1,262 +1,397 @@
1
- import * as i0 from '@angular/core';
2
- import { Inject, Injectable, inject, PLATFORM_ID, NgModule } from '@angular/core';
3
- import * as i3 from '@angular/router';
4
- import { Router, ActivatedRoute } from '@angular/router';
5
- import * as i4 from '@ngrx/store';
6
- import { of, from, EMPTY } from 'rxjs';
7
- import { tap, map, catchError, filter, switchMap } from 'rxjs/operators';
8
- import * as i2 from '@daffodil/auth';
9
- import * as i1 from '@daffodil/auth/driver';
10
- import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES } from '@daffodil/auth/driver';
11
- import { DaffAuthGuardLogout, DAFF_AUTH_ERROR_MATCHER, DaffAuthFacade, DaffResetPasswordLanding, DaffAuthActionTypes, DaffAuthLoginActionTypes, DaffAuthRegisterActionTypes, DaffAuthResetPasswordActionTypes, DAFF_AUTH_UNAUTHENTICATED_HOOKS } from '@daffodil/auth/state';
12
- import { createSingleInjectionToken, createConfigInjectionToken } from '@daffodil/core';
13
- import { isPlatformServer } from '@angular/common';
14
- import * as i1$1 from '@ngrx/effects';
15
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
16
-
17
- const { token: DaffAuthMemberOnlyGuardRedirectUrl,
18
- /**
19
- * Provider function for {@link DaffAuthMemberOnlyGuardRedirectUrl}.
20
- */
21
- provider: provideDaffAuthMemberOnlyGuardRedirectUrl, } = createSingleInjectionToken('DaffAuthMemberOnlyGuardRedirectUrl', { factory: () => '/' });
22
-
23
- class MemberOnlyGuard {
24
- constructor(tokenCheck, storage, router, store, errorMatcher, redirectUrl) {
25
- this.tokenCheck = tokenCheck;
26
- this.storage = storage;
27
- this.router = router;
28
- this.store = store;
29
- this.errorMatcher = errorMatcher;
30
- this.redirectUrl = redirectUrl;
31
- }
32
- canActivate() {
33
- return this.isAuthenticated().pipe(tap(result => {
34
- if (!result) {
35
- this.router.navigateByUrl(this.redirectUrl);
36
- }
37
- }));
38
- }
39
- isAuthenticated() {
40
- return this.tokenCheck.check().pipe(map(() => true), catchError((error) => {
41
- if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) {
42
- this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));
43
- }
44
- return of(false);
45
- }));
46
- }
47
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: MemberOnlyGuard, deps: [{ token: i1.DaffAuthDriverTokenCheck }, { token: i2.DaffAuthStorageService }, { token: i3.Router }, { token: i4.Store }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: DaffAuthMemberOnlyGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
48
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: MemberOnlyGuard, providedIn: 'any' }); }
49
- }
50
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: MemberOnlyGuard, decorators: [{
51
- type: Injectable,
52
- args: [{
53
- providedIn: 'any',
54
- }]
55
- }], ctorParameters: () => [{ type: i1.DaffAuthDriverTokenCheck }, { type: i2.DaffAuthStorageService }, { type: i3.Router }, { type: i4.Store }, { type: undefined, decorators: [{
56
- type: Inject,
57
- args: [DAFF_AUTH_ERROR_MATCHER]
58
- }] }, { type: undefined, decorators: [{
59
- type: Inject,
60
- args: [DaffAuthMemberOnlyGuardRedirectUrl]
61
- }] }] });
62
-
63
- const { token: DaffAuthGuestOnlyGuardRedirectUrl,
64
- /**
65
- * Provider function for {@link DaffAuthGuestOnlyGuardRedirectUrl}.
66
- */
67
- provider: provideDaffAuthGuestOnlyGuardRedirectUrl, } = createSingleInjectionToken('DaffAuthGuestOnlyGuardRedirectUrl', { factory: () => '/' });
68
-
69
- class GuestOnlyGuard {
70
- constructor(tokenCheck, storage, router, store, errorMatcher, redirectUrl) {
71
- this.tokenCheck = tokenCheck;
72
- this.storage = storage;
73
- this.router = router;
74
- this.store = store;
75
- this.errorMatcher = errorMatcher;
76
- this.redirectUrl = redirectUrl;
77
- }
78
- canActivate() {
79
- return this.isUnauthenticated().pipe(tap(result => {
80
- if (!result) {
81
- this.router.navigateByUrl(this.redirectUrl);
82
- }
83
- }));
84
- }
85
- isUnauthenticated() {
86
- return this.tokenCheck.check().pipe(map(() => false), catchError((error) => {
87
- if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) {
88
- this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));
89
- }
90
- return of(true);
91
- }));
92
- }
93
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GuestOnlyGuard, deps: [{ token: i1.DaffAuthDriverTokenCheck }, { token: i2.DaffAuthStorageService }, { token: i3.Router }, { token: i4.Store }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: DaffAuthGuestOnlyGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
94
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GuestOnlyGuard, providedIn: 'any' }); }
95
- }
96
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: GuestOnlyGuard, decorators: [{
97
- type: Injectable,
98
- args: [{
99
- providedIn: 'any',
100
- }]
101
- }], ctorParameters: () => [{ type: i1.DaffAuthDriverTokenCheck }, { type: i2.DaffAuthStorageService }, { type: i3.Router }, { type: i4.Store }, { type: undefined, decorators: [{
102
- type: Inject,
103
- args: [DAFF_AUTH_ERROR_MATCHER]
104
- }] }, { type: undefined, decorators: [{
105
- type: Inject,
106
- args: [DaffAuthGuestOnlyGuardRedirectUrl]
107
- }] }] });
108
-
1
+ import * as i0 from "@angular/core";
2
+ import { Inject, Injectable, NgModule, PLATFORM_ID, inject, makeEnvironmentProviders } from "@angular/core";
3
+ import * as i3 from "@angular/router";
4
+ import { ActivatedRoute, Router } from "@angular/router";
5
+ import * as i4 from "@ngrx/store";
6
+ import { EMPTY, from, of } from "rxjs";
7
+ import { catchError, filter, map, switchMap, tap } from "rxjs/operators";
8
+ import * as i2 from "@daffodil/auth";
9
+ import * as i1$1 from "@daffodil/auth/driver";
10
+ import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES } from "@daffodil/auth/driver";
11
+ import { DAFF_AUTH_ERROR_MATCHER, DAFF_AUTH_UNAUTHENTICATED_HOOKS, DaffAuthActionTypes, DaffAuthFacade, DaffAuthGuardLogout, DaffAuthLoginActionTypes, DaffAuthRegisterActionTypes, DaffAuthResetPasswordActionTypes, DaffResetPasswordLanding } from "@daffodil/auth/state";
12
+ import { createConfigInjectionToken, createSingleInjectionToken } from "@daffodil/core";
13
+ import { isPlatformServer } from "@angular/common";
14
+ import * as i1 from "@ngrx/effects";
15
+ import { EffectsModule, createEffect, ofType, provideEffects } from "@ngrx/effects";
16
+ const { token: DaffAuthMemberOnlyGuardRedirectUrl, provider: provideDaffAuthMemberOnlyGuardRedirectUrl } = createSingleInjectionToken("DaffAuthMemberOnlyGuardRedirectUrl", { factory: () => "/" });
17
+ var MemberOnlyGuard = class MemberOnlyGuard {
18
+ constructor(tokenCheck, storage, router, store, errorMatcher, redirectUrl) {
19
+ this.tokenCheck = tokenCheck;
20
+ this.storage = storage;
21
+ this.router = router;
22
+ this.store = store;
23
+ this.errorMatcher = errorMatcher;
24
+ this.redirectUrl = redirectUrl;
25
+ }
26
+ canActivate() {
27
+ return this.isAuthenticated().pipe(tap((result) => {
28
+ if (!result) this.router.navigateByUrl(this.redirectUrl);
29
+ }));
30
+ }
31
+ isAuthenticated() {
32
+ return this.tokenCheck.check().pipe(map(() => true), catchError((error) => {
33
+ if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));
34
+ return of(false);
35
+ }));
36
+ }
37
+ static {
38
+ this.ɵfac = i0.ɵɵngDeclareFactory({
39
+ minVersion: "12.0.0",
40
+ version: "22.2.4",
41
+ ngImport: i0,
42
+ type: MemberOnlyGuard,
43
+ deps: [
44
+ { token: i1$1.DaffAuthDriverTokenCheck },
45
+ { token: i2.DaffAuthStorageService },
46
+ { token: i3.Router },
47
+ { token: i4.Store },
48
+ { token: DAFF_AUTH_ERROR_MATCHER },
49
+ { token: DaffAuthMemberOnlyGuardRedirectUrl }
50
+ ],
51
+ target: i0.ɵɵFactoryTarget.Injectable
52
+ });
53
+ }
54
+ static {
55
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
56
+ minVersion: "12.0.0",
57
+ version: "22.2.4",
58
+ ngImport: i0,
59
+ type: MemberOnlyGuard,
60
+ providedIn: "any"
61
+ });
62
+ }
63
+ };
64
+ i0.ɵɵngDeclareClassMetadata({
65
+ minVersion: "12.0.0",
66
+ version: "22.2.4",
67
+ ngImport: i0,
68
+ type: MemberOnlyGuard,
69
+ decorators: [{
70
+ type: Injectable,
71
+ args: [{ providedIn: "any" }]
72
+ }],
73
+ ctorParameters: () => [
74
+ { type: i1$1.DaffAuthDriverTokenCheck },
75
+ { type: i2.DaffAuthStorageService },
76
+ { type: i3.Router },
77
+ { type: i4.Store },
78
+ {
79
+ type: void 0,
80
+ decorators: [{
81
+ type: Inject,
82
+ args: [DAFF_AUTH_ERROR_MATCHER]
83
+ }]
84
+ },
85
+ {
86
+ type: void 0,
87
+ decorators: [{
88
+ type: Inject,
89
+ args: [DaffAuthMemberOnlyGuardRedirectUrl]
90
+ }]
91
+ }
92
+ ]
93
+ });
94
+ const { token: DaffAuthGuestOnlyGuardRedirectUrl, provider: provideDaffAuthGuestOnlyGuardRedirectUrl } = createSingleInjectionToken("DaffAuthGuestOnlyGuardRedirectUrl", { factory: () => "/" });
95
+ var GuestOnlyGuard = class GuestOnlyGuard {
96
+ constructor(tokenCheck, storage, router, store, errorMatcher, redirectUrl) {
97
+ this.tokenCheck = tokenCheck;
98
+ this.storage = storage;
99
+ this.router = router;
100
+ this.store = store;
101
+ this.errorMatcher = errorMatcher;
102
+ this.redirectUrl = redirectUrl;
103
+ }
104
+ canActivate() {
105
+ return this.isUnauthenticated().pipe(tap((result) => {
106
+ if (!result) this.router.navigateByUrl(this.redirectUrl);
107
+ }));
108
+ }
109
+ isUnauthenticated() {
110
+ return this.tokenCheck.check().pipe(map(() => false), catchError((error) => {
111
+ if (DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[error.code]) this.store.dispatch(new DaffAuthGuardLogout(this.errorMatcher(error)));
112
+ return of(true);
113
+ }));
114
+ }
115
+ static {
116
+ this.ɵfac = i0.ɵɵngDeclareFactory({
117
+ minVersion: "12.0.0",
118
+ version: "22.2.4",
119
+ ngImport: i0,
120
+ type: GuestOnlyGuard,
121
+ deps: [
122
+ { token: i1$1.DaffAuthDriverTokenCheck },
123
+ { token: i2.DaffAuthStorageService },
124
+ { token: i3.Router },
125
+ { token: i4.Store },
126
+ { token: DAFF_AUTH_ERROR_MATCHER },
127
+ { token: DaffAuthGuestOnlyGuardRedirectUrl }
128
+ ],
129
+ target: i0.ɵɵFactoryTarget.Injectable
130
+ });
131
+ }
132
+ static {
133
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
134
+ minVersion: "12.0.0",
135
+ version: "22.2.4",
136
+ ngImport: i0,
137
+ type: GuestOnlyGuard,
138
+ providedIn: "any"
139
+ });
140
+ }
141
+ };
142
+ i0.ɵɵngDeclareClassMetadata({
143
+ minVersion: "12.0.0",
144
+ version: "22.2.4",
145
+ ngImport: i0,
146
+ type: GuestOnlyGuard,
147
+ decorators: [{
148
+ type: Injectable,
149
+ args: [{ providedIn: "any" }]
150
+ }],
151
+ ctorParameters: () => [
152
+ { type: i1$1.DaffAuthDriverTokenCheck },
153
+ { type: i2.DaffAuthStorageService },
154
+ { type: i3.Router },
155
+ { type: i4.Store },
156
+ {
157
+ type: void 0,
158
+ decorators: [{
159
+ type: Inject,
160
+ args: [DAFF_AUTH_ERROR_MATCHER]
161
+ }]
162
+ },
163
+ {
164
+ type: void 0,
165
+ decorators: [{
166
+ type: Inject,
167
+ args: [DaffAuthGuestOnlyGuardRedirectUrl]
168
+ }]
169
+ }
170
+ ]
171
+ });
109
172
  const DAFF_AUTH_ROUTING_CONFIG_DEFAULT = {
110
- resetPasswordTokenParam: 'token',
111
- redirectUrlParam: 'redirect',
112
- authCompleteRedirectPath: '/',
113
- logoutRedirectPath: '/',
114
- tokenExpirationRedirectPath: '/',
115
- resetPasswordRedirectPath: '/',
173
+ resetPasswordTokenParam: "token",
174
+ redirectUrlParam: "redirect",
175
+ authCompleteRedirectPath: "/",
176
+ logoutRedirectPath: "/",
177
+ tokenExpirationRedirectPath: "/",
178
+ resetPasswordRedirectPath: "/"
116
179
  };
117
-
118
- const {
119
- /**
120
- * The token used to provide @daffodil/auth/routing config data.
121
- */
122
- token: DAFF_AUTH_ROUTING_CONFIG,
123
- /**
124
- * Provider function for {@link DAFF_AUTH_ROUTING_CONFIG}.
125
- */
126
- provider: provideDaffAuthRoutingConfig, } = createConfigInjectionToken(DAFF_AUTH_ROUTING_CONFIG_DEFAULT, 'DAFF_AUTH_ROUTING_CONFIG');
127
-
128
- class DaffAuthResetPasswordGuard {
129
- constructor() {
130
- this.facade = inject(DaffAuthFacade);
131
- this.config = inject(DAFF_AUTH_ROUTING_CONFIG);
132
- this.platformId = inject(PLATFORM_ID);
133
- this.router = inject(Router);
134
- }
135
- canActivate(route) {
136
- if (isPlatformServer(this.platformId)) {
137
- return true;
138
- }
139
- const token = route.queryParamMap.get(this.config.resetPasswordTokenParam);
140
- if (!token) {
141
- return this.router.parseUrl(this.config.resetPasswordRedirectPath);
142
- }
143
- this.facade.dispatch(new DaffResetPasswordLanding(token));
144
- return true;
145
- }
146
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
147
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordGuard, providedIn: 'any' }); }
148
- }
149
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordGuard, decorators: [{
150
- type: Injectable,
151
- args: [{
152
- providedIn: 'any',
153
- }]
154
- }] });
155
-
180
+ const { token: DAFF_AUTH_ROUTING_CONFIG, provider: provideDaffAuthRoutingConfig } = createConfigInjectionToken(DAFF_AUTH_ROUTING_CONFIG_DEFAULT, "DAFF_AUTH_ROUTING_CONFIG");
181
+ var DaffAuthResetPasswordGuard = class DaffAuthResetPasswordGuard {
182
+ constructor() {
183
+ this.facade = inject(DaffAuthFacade);
184
+ this.config = inject(DAFF_AUTH_ROUTING_CONFIG);
185
+ this.platformId = inject(PLATFORM_ID);
186
+ this.router = inject(Router);
187
+ }
188
+ canActivate(route) {
189
+ if (isPlatformServer(this.platformId)) return true;
190
+ const token = route.queryParamMap.get(this.config.resetPasswordTokenParam);
191
+ if (!token) return this.router.parseUrl(this.config.resetPasswordRedirectPath);
192
+ this.facade.dispatch(new DaffResetPasswordLanding(token));
193
+ return true;
194
+ }
195
+ static {
196
+ this.ɵfac = i0.ɵɵngDeclareFactory({
197
+ minVersion: "12.0.0",
198
+ version: "22.2.4",
199
+ ngImport: i0,
200
+ type: DaffAuthResetPasswordGuard,
201
+ deps: [],
202
+ target: i0.ɵɵFactoryTarget.Injectable
203
+ });
204
+ }
205
+ static {
206
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
207
+ minVersion: "12.0.0",
208
+ version: "22.2.4",
209
+ ngImport: i0,
210
+ type: DaffAuthResetPasswordGuard,
211
+ providedIn: "any"
212
+ });
213
+ }
214
+ };
215
+ i0.ɵɵngDeclareClassMetadata({
216
+ minVersion: "12.0.0",
217
+ version: "22.2.4",
218
+ ngImport: i0,
219
+ type: DaffAuthResetPasswordGuard,
220
+ decorators: [{
221
+ type: Injectable,
222
+ args: [{ providedIn: "any" }]
223
+ }]
224
+ });
156
225
  function daffAuthRoutingRedirectUnauthenticatedHookFactory(router, route, config) {
157
- return (trigger) => {
158
- switch (trigger) {
159
- case DaffAuthLoginActionTypes.LogoutSuccessAction:
160
- return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.logoutRedirectPath));
161
- case DaffAuthActionTypes.AuthCheckFailureAction:
162
- case DaffAuthActionTypes.AuthGuardLogoutAction:
163
- return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.tokenExpirationRedirectPath));
164
- default:
165
- return of(null);
166
- }
167
- };
168
- }
169
-
170
- class DaffAuthRoutingModule {
171
- static withConfig(config) {
172
- return {
173
- ngModule: DaffAuthRoutingModule,
174
- providers: [
175
- provideDaffAuthRoutingConfig(config),
176
- ],
177
- };
178
- }
179
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
180
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingModule }); }
181
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingModule, providers: [
182
- DaffAuthResetPasswordGuard,
183
- MemberOnlyGuard,
184
- GuestOnlyGuard,
185
- ] }); }
186
- }
187
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingModule, decorators: [{
188
- type: NgModule,
189
- args: [{
190
- providers: [
191
- DaffAuthResetPasswordGuard,
192
- MemberOnlyGuard,
193
- GuestOnlyGuard,
194
- ],
195
- }]
196
- }] });
197
-
198
- /**
199
- * Redirects the user to certain pages based on certain auth actions.
200
- */
201
- class DaffAuthRedirectEffects {
202
- constructor(actions$, router, route, config) {
203
- this.actions$ = actions$;
204
- this.router = router;
205
- this.route = route;
206
- this.config = config;
207
- this.redirectAfterLoginOrRegister$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginSuccessAction, DaffAuthRegisterActionTypes.RegisterSuccessAction, DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction), filter((action) => {
208
- if ((action.type === DaffAuthRegisterActionTypes.RegisterSuccessAction || action.type === DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction) && !action.token) {
209
- return false;
210
- }
211
- return true;
212
- }), tap((action) => {
213
- this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.authCompleteRedirectPath);
214
- }), switchMap(() => EMPTY)), { dispatch: false });
215
- }
216
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRedirectEffects, deps: [{ token: i1$1.Actions }, { token: i3.Router }, { token: i3.ActivatedRoute }, { token: DAFF_AUTH_ROUTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
217
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRedirectEffects }); }
226
+ return (trigger) => {
227
+ switch (trigger) {
228
+ case DaffAuthLoginActionTypes.LogoutSuccessAction: return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.logoutRedirectPath));
229
+ case DaffAuthActionTypes.AuthCheckFailureAction:
230
+ case DaffAuthActionTypes.AuthGuardLogoutAction: return from(router.navigateByUrl(route.snapshot.queryParamMap.get(config.redirectUrlParam) || config.tokenExpirationRedirectPath));
231
+ default: return of(null);
232
+ }
233
+ };
218
234
  }
219
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRedirectEffects, decorators: [{
220
- type: Injectable
221
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: i3.Router }, { type: i3.ActivatedRoute }, { type: undefined, decorators: [{
222
- type: Inject,
223
- args: [DAFF_AUTH_ROUTING_CONFIG]
224
- }] }] });
225
-
226
- class DaffAuthRoutingRedirectModule {
227
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingRedirectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
228
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingRedirectModule, imports: [i1$1.EffectsFeatureModule] }); }
229
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingRedirectModule, providers: [
230
- {
231
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
232
- multi: true,
233
- useFactory: (() => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG))),
234
- },
235
- ], imports: [EffectsModule.forFeature([
236
- DaffAuthRedirectEffects,
237
- ])] }); }
238
- }
239
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRoutingRedirectModule, decorators: [{
240
- type: NgModule,
241
- args: [{
242
- imports: [
243
- EffectsModule.forFeature([
244
- DaffAuthRedirectEffects,
245
- ]),
246
- ],
247
- providers: [
248
- {
249
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
250
- multi: true,
251
- useFactory: (() => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG))),
252
- },
253
- ],
254
- }]
255
- }] });
256
-
257
- /**
258
- * Generated bundle index. Do not edit.
259
- */
235
+ var DaffAuthRedirectEffects = class DaffAuthRedirectEffects {
236
+ constructor(actions$, router, route, config) {
237
+ this.actions$ = actions$;
238
+ this.router = router;
239
+ this.route = route;
240
+ this.config = config;
241
+ this.redirectAfterLoginOrRegister$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginSuccessAction, DaffAuthRegisterActionTypes.RegisterSuccessAction, DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction), filter((action) => {
242
+ if ((action.type === DaffAuthRegisterActionTypes.RegisterSuccessAction || action.type === DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction) && !action.token) return false;
243
+ return true;
244
+ }), tap((action) => {
245
+ this.router.navigateByUrl(this.route.snapshot.queryParamMap.get(this.config.redirectUrlParam) || this.config.authCompleteRedirectPath);
246
+ }), switchMap(() => EMPTY)), { dispatch: false });
247
+ }
248
+ static {
249
+ this.ɵfac = i0.ɵɵngDeclareFactory({
250
+ minVersion: "12.0.0",
251
+ version: "22.2.4",
252
+ ngImport: i0,
253
+ type: DaffAuthRedirectEffects,
254
+ deps: [
255
+ { token: i1.Actions },
256
+ { token: i3.Router },
257
+ { token: i3.ActivatedRoute },
258
+ { token: DAFF_AUTH_ROUTING_CONFIG }
259
+ ],
260
+ target: i0.ɵɵFactoryTarget.Injectable
261
+ });
262
+ }
263
+ static {
264
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
265
+ minVersion: "12.0.0",
266
+ version: "22.2.4",
267
+ ngImport: i0,
268
+ type: DaffAuthRedirectEffects
269
+ });
270
+ }
271
+ };
272
+ i0.ɵɵngDeclareClassMetadata({
273
+ minVersion: "12.0.0",
274
+ version: "22.2.4",
275
+ ngImport: i0,
276
+ type: DaffAuthRedirectEffects,
277
+ decorators: [{ type: Injectable }],
278
+ ctorParameters: () => [
279
+ { type: i1.Actions },
280
+ { type: i3.Router },
281
+ { type: i3.ActivatedRoute },
282
+ {
283
+ type: void 0,
284
+ decorators: [{
285
+ type: Inject,
286
+ args: [DAFF_AUTH_ROUTING_CONFIG]
287
+ }]
288
+ }
289
+ ]
290
+ });
291
+ const provideDaffAuthRouting = (config) => makeEnvironmentProviders([
292
+ DaffAuthResetPasswordGuard,
293
+ MemberOnlyGuard,
294
+ GuestOnlyGuard,
295
+ provideDaffAuthRoutingConfig(config)
296
+ ]);
297
+ const provideDaffAuthRoutingRedirect = () => makeEnvironmentProviders([provideEffects(DaffAuthRedirectEffects), {
298
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
299
+ multi: true,
300
+ useFactory: () => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG))
301
+ }]);
302
+ var DaffAuthRoutingModule = class DaffAuthRoutingModule {
303
+ static withConfig(config) {
304
+ return {
305
+ ngModule: DaffAuthRoutingModule,
306
+ providers: [provideDaffAuthRouting(config)]
307
+ };
308
+ }
309
+ static {
310
+ this.ɵfac = i0.ɵɵngDeclareFactory({
311
+ minVersion: "12.0.0",
312
+ version: "22.2.4",
313
+ ngImport: i0,
314
+ type: DaffAuthRoutingModule,
315
+ deps: [],
316
+ target: i0.ɵɵFactoryTarget.NgModule
317
+ });
318
+ }
319
+ static {
320
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
321
+ minVersion: "14.0.0",
322
+ version: "22.2.4",
323
+ ngImport: i0,
324
+ type: DaffAuthRoutingModule
325
+ });
326
+ }
327
+ static {
328
+ this.ɵinj = i0.ɵɵngDeclareInjector({
329
+ minVersion: "12.0.0",
330
+ version: "22.2.4",
331
+ ngImport: i0,
332
+ type: DaffAuthRoutingModule
333
+ });
334
+ }
335
+ };
336
+ i0.ɵɵngDeclareClassMetadata({
337
+ minVersion: "12.0.0",
338
+ version: "22.2.4",
339
+ ngImport: i0,
340
+ type: DaffAuthRoutingModule,
341
+ decorators: [{ type: NgModule }]
342
+ });
343
+ var DaffAuthRoutingRedirectModule = class DaffAuthRoutingRedirectModule {
344
+ static {
345
+ this.ɵfac = i0.ɵɵngDeclareFactory({
346
+ minVersion: "12.0.0",
347
+ version: "22.2.4",
348
+ ngImport: i0,
349
+ type: DaffAuthRoutingRedirectModule,
350
+ deps: [],
351
+ target: i0.ɵɵFactoryTarget.NgModule
352
+ });
353
+ }
354
+ static {
355
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
356
+ minVersion: "14.0.0",
357
+ version: "22.2.4",
358
+ ngImport: i0,
359
+ type: DaffAuthRoutingRedirectModule,
360
+ imports: [i1.EffectsFeatureModule]
361
+ });
362
+ }
363
+ static {
364
+ this.ɵinj = i0.ɵɵngDeclareInjector({
365
+ minVersion: "12.0.0",
366
+ version: "22.2.4",
367
+ ngImport: i0,
368
+ type: DaffAuthRoutingRedirectModule,
369
+ providers: [{
370
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
371
+ multi: true,
372
+ useFactory: (() => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG)))
373
+ }],
374
+ imports: [EffectsModule.forFeature([DaffAuthRedirectEffects])]
375
+ });
376
+ }
377
+ };
378
+ i0.ɵɵngDeclareClassMetadata({
379
+ minVersion: "12.0.0",
380
+ version: "22.2.4",
381
+ ngImport: i0,
382
+ type: DaffAuthRoutingRedirectModule,
383
+ decorators: [{
384
+ type: NgModule,
385
+ args: [{
386
+ imports: [EffectsModule.forFeature([DaffAuthRedirectEffects])],
387
+ providers: [{
388
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
389
+ multi: true,
390
+ useFactory: (() => daffAuthRoutingRedirectUnauthenticatedHookFactory(inject(Router), inject(ActivatedRoute), inject(DAFF_AUTH_ROUTING_CONFIG)))
391
+ }]
392
+ }]
393
+ }]
394
+ });
395
+ export { DAFF_AUTH_ROUTING_CONFIG, DAFF_AUTH_ROUTING_CONFIG_DEFAULT, DaffAuthGuestOnlyGuardRedirectUrl, DaffAuthMemberOnlyGuardRedirectUrl, DaffAuthResetPasswordGuard, DaffAuthRoutingModule, DaffAuthRoutingRedirectModule, GuestOnlyGuard, MemberOnlyGuard, daffAuthRoutingRedirectUnauthenticatedHookFactory, provideDaffAuthGuestOnlyGuardRedirectUrl, provideDaffAuthMemberOnlyGuardRedirectUrl, provideDaffAuthRouting, provideDaffAuthRoutingConfig, provideDaffAuthRoutingRedirect };
260
396
 
261
- export { DAFF_AUTH_ROUTING_CONFIG, DAFF_AUTH_ROUTING_CONFIG_DEFAULT, DaffAuthGuestOnlyGuardRedirectUrl, DaffAuthMemberOnlyGuardRedirectUrl, DaffAuthResetPasswordGuard, DaffAuthRoutingModule, DaffAuthRoutingRedirectModule, GuestOnlyGuard, MemberOnlyGuard, daffAuthRoutingRedirectUnauthenticatedHookFactory, provideDaffAuthGuestOnlyGuardRedirectUrl, provideDaffAuthMemberOnlyGuardRedirectUrl, provideDaffAuthRoutingConfig };
262
- //# sourceMappingURL=daffodil-auth-routing.mjs.map
397
+ //# sourceMappingURL=daffodil-auth-routing.mjs.map