@daffodil/auth 0.94.1-rc.0 → 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,893 +1,908 @@
1
- import { daffOperationInitialState, daffOperationFailed, daffCompleteOperation, daffStartResolution, daffStartMutation, daffOperationStateSelectorFactory, daffTransformErrorToStateError, daffComposeReducers } from '@daffodil/core/state';
2
- import { createMultiInjectionToken, createConfigInjectionToken, createSingleInjectionToken, DaffStorageServiceError, DaffServerSideStorageError } from '@daffodil/core';
3
- import * as i1 from '@ngrx/store';
4
- import { defaultMemoize, createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
5
- import * as i0 from '@angular/core';
6
- import { Injectable, inject, Inject, NgModule } from '@angular/core';
7
- import * as i1$1 from '@ngrx/effects';
8
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
9
- import { combineLatest, of, Observable, EMPTY, iif, defer } from 'rxjs';
10
- import * as i2$1 from '@daffodil/auth';
11
- import { DaffAuthStorageService } from '@daffodil/auth';
12
- import { switchMap, map, catchError, filter, tap } from 'rxjs/operators';
13
- import * as i2 from '@daffodil/auth/driver';
14
- import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES, DaffLoginDriver, DaffRegisterDriver, DaffResetPasswordDriver } from '@daffodil/auth/driver';
15
- import { DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE } from '@daffodil/driver';
16
-
1
+ import { daffCompleteOperation, daffComposeReducers, daffOperationFailed, daffOperationInitialState, daffOperationStateSelectorFactory, daffStartMutation, daffStartResolution, daffTransformErrorToStateError } from "@daffodil/core/state";
2
+ import { DaffServerSideStorageError, DaffStorageServiceError, createConfigInjectionToken, createMultiInjectionToken, createSingleInjectionToken } from "@daffodil/core";
3
+ import * as i1$1 from "@ngrx/store";
4
+ import { StoreModule, combineReducers, createFeatureSelector, createSelector, defaultMemoize, provideState, select } from "@ngrx/store";
5
+ import * as i0 from "@angular/core";
6
+ import { Inject, Injectable, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
7
+ import * as i1 from "@ngrx/effects";
8
+ import { EffectsModule, createEffect, ofType, provideEffects } from "@ngrx/effects";
9
+ import { EMPTY, Observable, combineLatest, defer, iif, of } from "rxjs";
10
+ import * as i3 from "@daffodil/auth";
11
+ import { DaffAuthStorageService } from "@daffodil/auth";
12
+ import { catchError, filter, map, switchMap, tap } from "rxjs/operators";
13
+ import * as i2 from "@daffodil/auth/driver";
14
+ import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES, DaffLoginDriver, DaffRegisterDriver, DaffResetPasswordDriver } from "@daffodil/auth/driver";
15
+ import { DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE } from "@daffodil/driver";
17
16
  var DaffAuthActionTypes;
18
- (function (DaffAuthActionTypes) {
19
- DaffAuthActionTypes["ResetToUnauthenticatedAction"] = "[@daffodil/auth] Reset To Unauthenticated Action";
20
- DaffAuthActionTypes["AuthStorageFailureAction"] = "[@daffodil/auth] Auth Storage Failure Action";
21
- DaffAuthActionTypes["AuthGuardLogoutAction"] = "[@daffodil/auth] Auth Guard Logout Action";
22
- DaffAuthActionTypes["AuthServerSideAction"] = "[@daffodil/auth] Auth Server Side Action";
23
- DaffAuthActionTypes["AuthCheckAction"] = "[@daffodil/auth] Auth Check Action";
24
- DaffAuthActionTypes["AuthCheckSuccessAction"] = "[@daffodil/auth] Auth Check Success Action";
25
- DaffAuthActionTypes["AuthCheckFailureAction"] = "[@daffodil/auth] Auth Check Failure Action";
17
+ (function(DaffAuthActionTypes) {
18
+ DaffAuthActionTypes["ResetToUnauthenticatedAction"] = "[@daffodil/auth] Reset To Unauthenticated Action";
19
+ DaffAuthActionTypes["AuthStorageFailureAction"] = "[@daffodil/auth] Auth Storage Failure Action";
20
+ DaffAuthActionTypes["AuthGuardLogoutAction"] = "[@daffodil/auth] Auth Guard Logout Action";
21
+ DaffAuthActionTypes["AuthServerSideAction"] = "[@daffodil/auth] Auth Server Side Action";
22
+ DaffAuthActionTypes["AuthCheckAction"] = "[@daffodil/auth] Auth Check Action";
23
+ DaffAuthActionTypes["AuthCheckSuccessAction"] = "[@daffodil/auth] Auth Check Success Action";
24
+ DaffAuthActionTypes["AuthCheckFailureAction"] = "[@daffodil/auth] Auth Check Failure Action";
26
25
  })(DaffAuthActionTypes || (DaffAuthActionTypes = {}));
27
- /*
28
- * An action triggered when the authenicated status of the user is invalidated for some reason.
29
- * That reason could be a logout, auth token check failure, or an unauthorized error.
30
- */
31
- class DaffAuthResetToUnauthenticated {
32
- constructor(reason) {
33
- this.reason = reason;
34
- this.type = DaffAuthActionTypes.ResetToUnauthenticatedAction;
35
- }
36
- }
37
- /*
38
- * An action triggered upon a failed auth storage operation.
39
- */
40
- class DaffAuthStorageFailure {
41
- constructor(errorMessage) {
42
- this.errorMessage = errorMessage;
43
- this.type = DaffAuthActionTypes.AuthStorageFailureAction;
44
- }
45
- }
46
- /*
47
- * An action triggered when an auth token is cleared from storage by a routing guard.
48
- */
49
- class DaffAuthGuardLogout {
50
- constructor(errorMessage) {
51
- this.errorMessage = errorMessage;
52
- this.type = DaffAuthActionTypes.AuthGuardLogoutAction;
53
- }
54
- }
55
- /*
56
- * An action triggered when an invalid operation is performed in the server environment.
57
- * A common example is trying to access the auth token from storage.
58
- */
59
- class DaffAuthServerSide {
60
- constructor(errorMessage) {
61
- this.errorMessage = errorMessage;
62
- this.type = DaffAuthActionTypes.AuthServerSideAction;
63
- }
64
- }
65
- /**
66
- * An action triggered to initialize an auth check request.
67
- */
68
- class DaffAuthCheck {
69
- constructor() {
70
- this.type = DaffAuthActionTypes.AuthCheckAction;
71
- }
72
- }
73
- /**
74
- * An action triggered upon a successful auth check.
75
- *
76
- * @param token - the customer access token
77
- */
78
- class DaffAuthCheckSuccess {
79
- constructor() {
80
- this.type = DaffAuthActionTypes.AuthCheckSuccessAction;
81
- }
82
- }
83
- /**
84
- * An action triggered upon a failed auth check request.
85
- *
86
- * @param errorMessage - an error message
87
- */
88
- class DaffAuthCheckFailure {
89
- constructor(errorMessage) {
90
- this.errorMessage = errorMessage;
91
- this.type = DaffAuthActionTypes.AuthCheckFailureAction;
92
- }
93
- }
94
-
26
+ var DaffAuthResetToUnauthenticated = class {
27
+ constructor(reason) {
28
+ this.reason = reason;
29
+ this.type = DaffAuthActionTypes.ResetToUnauthenticatedAction;
30
+ }
31
+ };
32
+ var DaffAuthStorageFailure = class {
33
+ constructor(errorMessage) {
34
+ this.errorMessage = errorMessage;
35
+ this.type = DaffAuthActionTypes.AuthStorageFailureAction;
36
+ }
37
+ };
38
+ var DaffAuthGuardLogout = class {
39
+ constructor(errorMessage) {
40
+ this.errorMessage = errorMessage;
41
+ this.type = DaffAuthActionTypes.AuthGuardLogoutAction;
42
+ }
43
+ };
44
+ var DaffAuthServerSide = class {
45
+ constructor(errorMessage) {
46
+ this.errorMessage = errorMessage;
47
+ this.type = DaffAuthActionTypes.AuthServerSideAction;
48
+ }
49
+ };
50
+ var DaffAuthCheck = class {
51
+ constructor() {
52
+ this.type = DaffAuthActionTypes.AuthCheckAction;
53
+ }
54
+ };
55
+ var DaffAuthCheckSuccess = class {
56
+ constructor() {
57
+ this.type = DaffAuthActionTypes.AuthCheckSuccessAction;
58
+ }
59
+ };
60
+ var DaffAuthCheckFailure = class {
61
+ constructor(errorMessage) {
62
+ this.errorMessage = errorMessage;
63
+ this.type = DaffAuthActionTypes.AuthCheckFailureAction;
64
+ }
65
+ };
95
66
  var DaffAuthLoginActionTypes;
96
- (function (DaffAuthLoginActionTypes) {
97
- DaffAuthLoginActionTypes["LoginAction"] = "[@daffodil/auth] Login Action";
98
- DaffAuthLoginActionTypes["LoginSuccessAction"] = "[@daffodil/auth] Login Success Action";
99
- DaffAuthLoginActionTypes["LoginFailureAction"] = "[@daffodil/auth] Login Failure Action";
100
- DaffAuthLoginActionTypes["LogoutAction"] = "[@daffodil/auth] Logout Action";
101
- DaffAuthLoginActionTypes["LogoutSuccessAction"] = "[@daffodil/auth] Logout Success Action";
102
- DaffAuthLoginActionTypes["LogoutFailureAction"] = "[@daffodil/auth] Logout Failure Action";
67
+ (function(DaffAuthLoginActionTypes) {
68
+ DaffAuthLoginActionTypes["LoginAction"] = "[@daffodil/auth] Login Action";
69
+ DaffAuthLoginActionTypes["LoginSuccessAction"] = "[@daffodil/auth] Login Success Action";
70
+ DaffAuthLoginActionTypes["LoginFailureAction"] = "[@daffodil/auth] Login Failure Action";
71
+ DaffAuthLoginActionTypes["LogoutAction"] = "[@daffodil/auth] Logout Action";
72
+ DaffAuthLoginActionTypes["LogoutSuccessAction"] = "[@daffodil/auth] Logout Success Action";
73
+ DaffAuthLoginActionTypes["LogoutFailureAction"] = "[@daffodil/auth] Logout Failure Action";
103
74
  })(DaffAuthLoginActionTypes || (DaffAuthLoginActionTypes = {}));
104
- /**
105
- * An action triggered to initialize a auth login request.
106
- */
107
- class DaffAuthLogin {
108
- constructor(loginInfo) {
109
- this.loginInfo = loginInfo;
110
- this.type = DaffAuthLoginActionTypes.LoginAction;
111
- }
112
- }
113
- /**
114
- * An action triggered upon a successful auth login.
115
- *
116
- * @param token - the customer access token
117
- */
118
- class DaffAuthLoginSuccess {
119
- constructor(auth) {
120
- this.auth = auth;
121
- this.type = DaffAuthLoginActionTypes.LoginSuccessAction;
122
- }
123
- }
124
- /**
125
- * An action triggered upon a failed auth login request.
126
- *
127
- * @param errorMessage - an error message
128
- */
129
- class DaffAuthLoginFailure {
130
- constructor(errorMessage) {
131
- this.errorMessage = errorMessage;
132
- this.type = DaffAuthLoginActionTypes.LoginFailureAction;
133
- }
134
- }
135
- /**
136
- * An action triggered to initialize a logout request.
137
- */
138
- class DaffAuthLogout {
139
- constructor() {
140
- this.type = DaffAuthLoginActionTypes.LogoutAction;
141
- }
142
- }
143
- /**
144
- * An action triggered upon a successful logout.
145
- *
146
- * @param token - the customer access token
147
- */
148
- class DaffAuthLogoutSuccess {
149
- constructor() {
150
- this.type = DaffAuthLoginActionTypes.LogoutSuccessAction;
151
- }
152
- }
153
- /**
154
- * An action triggered upon a failed logout request.
155
- *
156
- * @param errorMessage - an error message
157
- */
158
- class DaffAuthLogoutFailure {
159
- constructor(errorMessage) {
160
- this.errorMessage = errorMessage;
161
- this.type = DaffAuthLoginActionTypes.LogoutFailureAction;
162
- }
163
- }
164
-
75
+ var DaffAuthLogin = class {
76
+ constructor(loginInfo) {
77
+ this.loginInfo = loginInfo;
78
+ this.type = DaffAuthLoginActionTypes.LoginAction;
79
+ }
80
+ };
81
+ var DaffAuthLoginSuccess = class {
82
+ constructor(auth) {
83
+ this.auth = auth;
84
+ this.type = DaffAuthLoginActionTypes.LoginSuccessAction;
85
+ }
86
+ };
87
+ var DaffAuthLoginFailure = class {
88
+ constructor(errorMessage) {
89
+ this.errorMessage = errorMessage;
90
+ this.type = DaffAuthLoginActionTypes.LoginFailureAction;
91
+ }
92
+ };
93
+ var DaffAuthLogout = class {
94
+ constructor() {
95
+ this.type = DaffAuthLoginActionTypes.LogoutAction;
96
+ }
97
+ };
98
+ var DaffAuthLogoutSuccess = class {
99
+ constructor() {
100
+ this.type = DaffAuthLoginActionTypes.LogoutSuccessAction;
101
+ }
102
+ };
103
+ var DaffAuthLogoutFailure = class {
104
+ constructor(errorMessage) {
105
+ this.errorMessage = errorMessage;
106
+ this.type = DaffAuthLoginActionTypes.LogoutFailureAction;
107
+ }
108
+ };
165
109
  var DaffAuthRegisterActionTypes;
166
- (function (DaffAuthRegisterActionTypes) {
167
- DaffAuthRegisterActionTypes["RegisterAction"] = "[@daffodil/auth] Register Action";
168
- DaffAuthRegisterActionTypes["RegisterSuccessAction"] = "[@daffodil/auth] Register Success Action";
169
- DaffAuthRegisterActionTypes["RegisterFailureAction"] = "[@daffodil/auth] Register Failure Action";
110
+ (function(DaffAuthRegisterActionTypes) {
111
+ DaffAuthRegisterActionTypes["RegisterAction"] = "[@daffodil/auth] Register Action";
112
+ DaffAuthRegisterActionTypes["RegisterSuccessAction"] = "[@daffodil/auth] Register Success Action";
113
+ DaffAuthRegisterActionTypes["RegisterFailureAction"] = "[@daffodil/auth] Register Failure Action";
170
114
  })(DaffAuthRegisterActionTypes || (DaffAuthRegisterActionTypes = {}));
171
- /**
172
- * An action triggered to initialize a auth register request.
173
- *
174
- * @param registration
175
- */
176
- class DaffAuthRegister {
177
- constructor(registration, autoLogin = true) {
178
- this.registration = registration;
179
- this.autoLogin = autoLogin;
180
- this.type = DaffAuthRegisterActionTypes.RegisterAction;
181
- }
182
- }
183
- /**
184
- * An action triggered upon a successful auth register request.
185
- *
186
- * @param token - the customer access token
187
- */
188
- class DaffAuthRegisterSuccess {
189
- constructor(token) {
190
- this.token = token;
191
- this.type = DaffAuthRegisterActionTypes.RegisterSuccessAction;
192
- }
193
- }
194
- /**
195
- * An action triggered upon a failed auth request.
196
- *
197
- * @param errorMessage - an error message
198
- */
199
- class DaffAuthRegisterFailure {
200
- constructor(errorMessage) {
201
- this.errorMessage = errorMessage;
202
- this.type = DaffAuthRegisterActionTypes.RegisterFailureAction;
203
- }
204
- }
205
-
115
+ var DaffAuthRegister = class {
116
+ constructor(registration, autoLogin = true) {
117
+ this.registration = registration;
118
+ this.autoLogin = autoLogin;
119
+ this.type = DaffAuthRegisterActionTypes.RegisterAction;
120
+ }
121
+ };
122
+ var DaffAuthRegisterSuccess = class {
123
+ constructor(token) {
124
+ this.token = token;
125
+ this.type = DaffAuthRegisterActionTypes.RegisterSuccessAction;
126
+ }
127
+ };
128
+ var DaffAuthRegisterFailure = class {
129
+ constructor(errorMessage) {
130
+ this.errorMessage = errorMessage;
131
+ this.type = DaffAuthRegisterActionTypes.RegisterFailureAction;
132
+ }
133
+ };
206
134
  var DaffAuthResetPasswordActionTypes;
207
- (function (DaffAuthResetPasswordActionTypes) {
208
- DaffAuthResetPasswordActionTypes["SendResetEmailAction"] = "[@daffodil/auth] Send Reset Email Action";
209
- DaffAuthResetPasswordActionTypes["SendResetEmailSuccessAction"] = "[@daffodil/auth] Send Reset Email Success Action";
210
- DaffAuthResetPasswordActionTypes["SendResetEmailFailureAction"] = "[@daffodil/auth] Send Reset Email Failure Action";
211
- DaffAuthResetPasswordActionTypes["ResetPasswordAction"] = "[@daffodil/auth] Reset Password Action";
212
- DaffAuthResetPasswordActionTypes["ResetPasswordSuccessAction"] = "[@daffodil/auth] Reset Password Success Action";
213
- DaffAuthResetPasswordActionTypes["ResetPasswordFailureAction"] = "[@daffodil/auth] Reset Password Failure Action";
214
- DaffAuthResetPasswordActionTypes["ResetPasswordLandingAction"] = "[@daffodil/auth] Reset Password Landing Action";
135
+ (function(DaffAuthResetPasswordActionTypes) {
136
+ DaffAuthResetPasswordActionTypes["SendResetEmailAction"] = "[@daffodil/auth] Send Reset Email Action";
137
+ DaffAuthResetPasswordActionTypes["SendResetEmailSuccessAction"] = "[@daffodil/auth] Send Reset Email Success Action";
138
+ DaffAuthResetPasswordActionTypes["SendResetEmailFailureAction"] = "[@daffodil/auth] Send Reset Email Failure Action";
139
+ DaffAuthResetPasswordActionTypes["ResetPasswordAction"] = "[@daffodil/auth] Reset Password Action";
140
+ DaffAuthResetPasswordActionTypes["ResetPasswordSuccessAction"] = "[@daffodil/auth] Reset Password Success Action";
141
+ DaffAuthResetPasswordActionTypes["ResetPasswordFailureAction"] = "[@daffodil/auth] Reset Password Failure Action";
142
+ DaffAuthResetPasswordActionTypes["ResetPasswordLandingAction"] = "[@daffodil/auth] Reset Password Landing Action";
215
143
  })(DaffAuthResetPasswordActionTypes || (DaffAuthResetPasswordActionTypes = {}));
216
- /**
217
- * An action triggered to send the specified customer an email to reset their password.
218
- */
219
- class DaffSendResetEmail {
220
- constructor(email) {
221
- this.email = email;
222
- this.type = DaffAuthResetPasswordActionTypes.SendResetEmailAction;
223
- }
224
- }
225
- /**
226
- * An action triggered upon a successfully sent reset password email.
227
- */
228
- class DaffSendResetEmailSuccess {
229
- constructor() {
230
- this.type = DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction;
231
- }
232
- }
233
- /**
234
- * An action triggered upon a failure to send the reset password email.
235
- *
236
- * @param errorMessage - an error message
237
- */
238
- class DaffSendResetEmailFailure {
239
- constructor(errorMessage) {
240
- this.errorMessage = errorMessage;
241
- this.type = DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction;
242
- }
243
- }
244
- /**
245
- * An action triggered to initialize a logout request.
246
- */
247
- class DaffResetPassword {
248
- constructor(info, autoLogin = true) {
249
- this.info = info;
250
- this.autoLogin = autoLogin;
251
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordAction;
252
- }
253
- }
254
- /**
255
- * An action triggered upon a successful logout.
256
- */
257
- class DaffResetPasswordSuccess {
258
- constructor(token) {
259
- this.token = token;
260
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction;
261
- }
262
- }
263
- /**
264
- * An action triggered upon a failed logout request.
265
- *
266
- * @param errorMessage - an error message
267
- */
268
- class DaffResetPasswordFailure {
269
- constructor(errorMessage) {
270
- this.errorMessage = errorMessage;
271
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction;
272
- }
273
- }
274
- /**
275
- * An action triggered upon the user navigating to the reset password page from the link in their email.
276
- *
277
- * @param token - The token with which the password can be reset
278
- */
279
- class DaffResetPasswordLanding {
280
- constructor(token) {
281
- this.token = token;
282
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction;
283
- }
284
- }
285
-
144
+ var DaffSendResetEmail = class {
145
+ constructor(email) {
146
+ this.email = email;
147
+ this.type = DaffAuthResetPasswordActionTypes.SendResetEmailAction;
148
+ }
149
+ };
150
+ var DaffSendResetEmailSuccess = class {
151
+ constructor() {
152
+ this.type = DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction;
153
+ }
154
+ };
155
+ var DaffSendResetEmailFailure = class {
156
+ constructor(errorMessage) {
157
+ this.errorMessage = errorMessage;
158
+ this.type = DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction;
159
+ }
160
+ };
161
+ var DaffResetPassword = class {
162
+ constructor(info, autoLogin = true) {
163
+ this.info = info;
164
+ this.autoLogin = autoLogin;
165
+ this.type = DaffAuthResetPasswordActionTypes.ResetPasswordAction;
166
+ }
167
+ };
168
+ var DaffResetPasswordSuccess = class {
169
+ constructor(token) {
170
+ this.token = token;
171
+ this.type = DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction;
172
+ }
173
+ };
174
+ var DaffResetPasswordFailure = class {
175
+ constructor(errorMessage) {
176
+ this.errorMessage = errorMessage;
177
+ this.type = DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction;
178
+ }
179
+ };
180
+ var DaffResetPasswordLanding = class {
181
+ constructor(token) {
182
+ this.token = token;
183
+ this.type = DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction;
184
+ }
185
+ };
286
186
  const daffAuthInitialState = {
287
- ...daffOperationInitialState,
288
- loggedIn: false,
187
+ ...daffOperationInitialState,
188
+ loggedIn: false
289
189
  };
290
-
291
190
  function daffAuthReducer(state = daffAuthInitialState, action) {
292
- switch (action.type) {
293
- case DaffAuthActionTypes.AuthCheckAction:
294
- return daffStartResolution(state);
295
- case DaffAuthActionTypes.AuthCheckSuccessAction:
296
- return {
297
- ...daffCompleteOperation(state),
298
- loggedIn: true,
299
- };
300
- case DaffAuthActionTypes.AuthCheckFailureAction:
301
- return {
302
- ...daffOperationFailed([action.errorMessage], state),
303
- loggedIn: false,
304
- };
305
- case DaffAuthActionTypes.AuthGuardLogoutAction:
306
- return {
307
- ...daffCompleteOperation(state),
308
- daffErrors: [action.errorMessage],
309
- loggedIn: false,
310
- };
311
- case DaffAuthActionTypes.AuthServerSideAction:
312
- case DaffAuthActionTypes.AuthStorageFailureAction:
313
- return daffOperationFailed([action.errorMessage], state);
314
- case DaffAuthLoginActionTypes.LoginSuccessAction:
315
- return {
316
- ...state,
317
- loggedIn: true,
318
- };
319
- case DaffAuthRegisterActionTypes.RegisterSuccessAction:
320
- case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction:
321
- return action.token ? {
322
- ...state,
323
- loggedIn: true,
324
- } : state;
325
- case DaffAuthLoginActionTypes.LogoutSuccessAction:
326
- return {
327
- ...state,
328
- loggedIn: false,
329
- };
330
- default:
331
- return state;
332
- }
191
+ switch (action.type) {
192
+ case DaffAuthActionTypes.AuthCheckAction: return daffStartResolution(state);
193
+ case DaffAuthActionTypes.AuthCheckSuccessAction: return {
194
+ ...daffCompleteOperation(state),
195
+ loggedIn: true
196
+ };
197
+ case DaffAuthActionTypes.AuthCheckFailureAction: return {
198
+ ...daffOperationFailed([action.errorMessage], state),
199
+ loggedIn: false
200
+ };
201
+ case DaffAuthActionTypes.AuthGuardLogoutAction: return {
202
+ ...daffCompleteOperation(state),
203
+ daffErrors: [action.errorMessage],
204
+ loggedIn: false
205
+ };
206
+ case DaffAuthActionTypes.AuthServerSideAction:
207
+ case DaffAuthActionTypes.AuthStorageFailureAction: return daffOperationFailed([action.errorMessage], state);
208
+ case DaffAuthLoginActionTypes.LoginSuccessAction: return {
209
+ ...state,
210
+ loggedIn: true
211
+ };
212
+ case DaffAuthRegisterActionTypes.RegisterSuccessAction:
213
+ case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction: return action.token ? {
214
+ ...state,
215
+ loggedIn: true
216
+ } : state;
217
+ case DaffAuthLoginActionTypes.LogoutSuccessAction: return {
218
+ ...state,
219
+ loggedIn: false
220
+ };
221
+ default: return state;
222
+ }
333
223
  }
334
-
335
224
  const daffAuthLoginInitialState = daffOperationInitialState;
336
-
337
225
  function daffAuthLoginReducer(state = daffAuthLoginInitialState, action) {
338
- switch (action.type) {
339
- case DaffAuthLoginActionTypes.LoginAction:
340
- case DaffAuthLoginActionTypes.LogoutAction:
341
- return daffStartMutation(state);
342
- case DaffAuthLoginActionTypes.LoginSuccessAction:
343
- case DaffAuthLoginActionTypes.LogoutSuccessAction:
344
- return daffCompleteOperation(state);
345
- case DaffAuthLoginActionTypes.LoginFailureAction:
346
- case DaffAuthLoginActionTypes.LogoutFailureAction:
347
- return daffOperationFailed([action.errorMessage], state);
348
- default:
349
- return state;
350
- }
226
+ switch (action.type) {
227
+ case DaffAuthLoginActionTypes.LoginAction:
228
+ case DaffAuthLoginActionTypes.LogoutAction: return daffStartMutation(state);
229
+ case DaffAuthLoginActionTypes.LoginSuccessAction:
230
+ case DaffAuthLoginActionTypes.LogoutSuccessAction: return daffCompleteOperation(state);
231
+ case DaffAuthLoginActionTypes.LoginFailureAction:
232
+ case DaffAuthLoginActionTypes.LogoutFailureAction: return daffOperationFailed([action.errorMessage], state);
233
+ default: return state;
234
+ }
351
235
  }
352
-
353
236
  const daffAuthRegisterInitialState = daffOperationInitialState;
354
-
355
237
  function daffAuthRegisterReducer(state = daffAuthRegisterInitialState, action) {
356
- switch (action.type) {
357
- case DaffAuthRegisterActionTypes.RegisterAction:
358
- return daffStartMutation(state);
359
- case DaffAuthRegisterActionTypes.RegisterSuccessAction:
360
- return daffCompleteOperation(state);
361
- case DaffAuthRegisterActionTypes.RegisterFailureAction:
362
- return daffOperationFailed([action.errorMessage], state);
363
- default:
364
- return state;
365
- }
238
+ switch (action.type) {
239
+ case DaffAuthRegisterActionTypes.RegisterAction: return daffStartMutation(state);
240
+ case DaffAuthRegisterActionTypes.RegisterSuccessAction: return daffCompleteOperation(state);
241
+ case DaffAuthRegisterActionTypes.RegisterFailureAction: return daffOperationFailed([action.errorMessage], state);
242
+ default: return state;
243
+ }
366
244
  }
367
-
368
245
  const daffAuthResetPasswordInitialState = {
369
- ...daffOperationInitialState,
370
- token: null,
246
+ ...daffOperationInitialState,
247
+ token: null
371
248
  };
372
-
373
249
  function daffAuthResetPasswordReducer(state = daffAuthResetPasswordInitialState, action) {
374
- switch (action.type) {
375
- case DaffAuthResetPasswordActionTypes.ResetPasswordAction:
376
- case DaffAuthResetPasswordActionTypes.SendResetEmailAction:
377
- return daffStartMutation(state);
378
- case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction:
379
- case DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction:
380
- return daffCompleteOperation(state);
381
- case DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction:
382
- case DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction:
383
- return daffOperationFailed([action.errorMessage], state);
384
- case DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction:
385
- return {
386
- ...state,
387
- token: action.token,
388
- };
389
- default:
390
- return state;
391
- }
392
- }
393
-
394
- const {
395
- /**
396
- * A token to hold the injectable extra reducers.
397
- *
398
- * Prefer using {@link daffAuthProvideExtraReducers}.
399
- */
400
- token: DAFF_AUTH_EXTRA_REDUCERS,
401
- /**
402
- * Provides additional reducers that run after the standard Daffodil auth reducers.
403
- *
404
- * @example
405
- * ```ts
406
- * providers: [
407
- * ...daffAuthProvideExtraReducers(
408
- * myReducer1,
409
- * myReducer2
410
- * )
411
- * ]
412
- * ```
413
- */
414
- provider: daffAuthProvideExtraReducers, } = createMultiInjectionToken('DAFF_AUTH_EXTRA_REDUCERS');
415
-
416
- const DAFF_AUTH_STORE_FEATURE_KEY = 'daffAuth';
417
-
250
+ switch (action.type) {
251
+ case DaffAuthResetPasswordActionTypes.ResetPasswordAction:
252
+ case DaffAuthResetPasswordActionTypes.SendResetEmailAction: return daffStartMutation(state);
253
+ case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction:
254
+ case DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction: return daffCompleteOperation(state);
255
+ case DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction:
256
+ case DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction: return daffOperationFailed([action.errorMessage], state);
257
+ case DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction: return {
258
+ ...state,
259
+ token: action.token
260
+ };
261
+ default: return state;
262
+ }
263
+ }
264
+ const { token: DAFF_AUTH_EXTRA_REDUCERS, provider: daffAuthProvideExtraReducers } = createMultiInjectionToken("DAFF_AUTH_EXTRA_REDUCERS");
265
+ const DAFF_AUTH_STORE_FEATURE_KEY = "daffAuth";
418
266
  const daffAuthReducers = {
419
- auth: daffAuthReducer,
420
- login: daffAuthLoginReducer,
421
- register: daffAuthRegisterReducer,
422
- resetPassword: daffAuthResetPasswordReducer,
267
+ auth: daffAuthReducer,
268
+ login: daffAuthLoginReducer,
269
+ register: daffAuthRegisterReducer,
270
+ resetPassword: daffAuthResetPasswordReducer
423
271
  };
424
-
425
- /**
426
- * Feature State Selector
427
- */
428
272
  const getDaffAuthFeatureStateSelector = defaultMemoize(() => createFeatureSelector(DAFF_AUTH_STORE_FEATURE_KEY)).memoized;
429
-
430
273
  const createAuthSelectors = () => {
431
- const selectAuthState = createSelector(getDaffAuthFeatureStateSelector(), state => state.auth);
432
- const selectAuthLoggedIn = createSelector(selectAuthState, state => state.loggedIn);
433
- return {
434
- ...daffOperationStateSelectorFactory(selectAuthState),
435
- selectAuthState,
436
- selectAuthLoggedIn,
437
- };
274
+ const selectAuthState = createSelector(getDaffAuthFeatureStateSelector(), (state) => state.auth);
275
+ const selectAuthLoggedIn = createSelector(selectAuthState, (state) => state.loggedIn);
276
+ return {
277
+ ...daffOperationStateSelectorFactory(selectAuthState),
278
+ selectAuthState,
279
+ selectAuthLoggedIn
280
+ };
438
281
  };
439
282
  const daffAuthSelectorFactory = defaultMemoize(() => createAuthSelectors()).memoized;
440
-
441
283
  const createLoginSelectors = () => {
442
- const selectAuthLoginState = createSelector(getDaffAuthFeatureStateSelector(), state => state.login);
443
- return {
444
- ...daffOperationStateSelectorFactory(selectAuthLoginState),
445
- selectAuthLoginState,
446
- };
284
+ const selectAuthLoginState = createSelector(getDaffAuthFeatureStateSelector(), (state) => state.login);
285
+ return {
286
+ ...daffOperationStateSelectorFactory(selectAuthLoginState),
287
+ selectAuthLoginState
288
+ };
447
289
  };
448
290
  const daffAuthLoginSelectorFactory = defaultMemoize(() => createLoginSelectors()).memoized;
449
-
450
291
  const createRegisterSelectors = () => {
451
- const selectAuthRegisterState = createSelector(getDaffAuthFeatureStateSelector(), state => state.register);
452
- return {
453
- ...daffOperationStateSelectorFactory(selectAuthRegisterState),
454
- selectAuthRegisterState,
455
- };
292
+ const selectAuthRegisterState = createSelector(getDaffAuthFeatureStateSelector(), (state) => state.register);
293
+ return {
294
+ ...daffOperationStateSelectorFactory(selectAuthRegisterState),
295
+ selectAuthRegisterState
296
+ };
456
297
  };
457
298
  const daffAuthRegisterSelectorFactory = defaultMemoize(() => createRegisterSelectors()).memoized;
458
-
459
299
  const createResetPasswordSelectors = () => {
460
- const selectAuthResetPasswordState = createSelector(getDaffAuthFeatureStateSelector(), state => state.resetPassword);
461
- const selectAuthResetPasswordToken = createSelector(selectAuthResetPasswordState, state => state.token);
462
- return {
463
- ...daffOperationStateSelectorFactory(selectAuthResetPasswordState),
464
- selectAuthResetPasswordState,
465
- selectAuthResetPasswordToken,
466
- };
300
+ const selectAuthResetPasswordState = createSelector(getDaffAuthFeatureStateSelector(), (state) => state.resetPassword);
301
+ const selectAuthResetPasswordToken = createSelector(selectAuthResetPasswordState, (state) => state.token);
302
+ return {
303
+ ...daffOperationStateSelectorFactory(selectAuthResetPasswordState),
304
+ selectAuthResetPasswordState,
305
+ selectAuthResetPasswordToken
306
+ };
467
307
  };
468
308
  const daffAuthResetPasswordSelectorFactory = defaultMemoize(() => createResetPasswordSelectors()).memoized;
469
-
470
309
  const getDaffAuthSelectors = defaultMemoize(() => ({
471
- ...daffAuthSelectorFactory(),
472
- ...daffAuthLoginSelectorFactory(),
473
- ...daffAuthRegisterSelectorFactory(),
474
- ...daffAuthResetPasswordSelectorFactory(),
475
- selectAuthFeatureState: getDaffAuthFeatureStateSelector(),
310
+ ...daffAuthSelectorFactory(),
311
+ ...daffAuthLoginSelectorFactory(),
312
+ ...daffAuthRegisterSelectorFactory(),
313
+ ...daffAuthResetPasswordSelectorFactory(),
314
+ selectAuthFeatureState: getDaffAuthFeatureStateSelector()
476
315
  })).memoized;
477
-
478
- /**
479
- * @inheritdoc
480
- */
481
- class DaffAuthFacade {
482
- constructor(store) {
483
- this.store = store;
484
- const { selectLoading, selectErrors, selectAuthLoggedIn, } = daffAuthSelectorFactory();
485
- this.loading$ = this.store.pipe(select(selectLoading));
486
- this.errors$ = this.store.pipe(select(selectErrors));
487
- this.loggedIn$ = this.store.pipe(select(selectAuthLoggedIn));
488
- }
489
- dispatch(action) {
490
- this.store.dispatch(action);
491
- }
492
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
493
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthFacade, providedIn: 'root' }); }
494
- }
495
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthFacade, decorators: [{
496
- type: Injectable,
497
- args: [{
498
- providedIn: 'root',
499
- }]
500
- }], ctorParameters: () => [{ type: i1.Store }] });
501
-
502
- /**
503
- * @inheritdoc
504
- */
505
- class DaffAuthLoginFacade {
506
- constructor(store) {
507
- this.store = store;
508
- const { selectLoading, selectErrors, } = daffAuthLoginSelectorFactory();
509
- this.loading$ = this.store.pipe(select(selectLoading));
510
- this.errors$ = this.store.pipe(select(selectErrors));
511
- }
512
- dispatch(action) {
513
- this.store.dispatch(action);
514
- }
515
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthLoginFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
516
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthLoginFacade, providedIn: 'root' }); }
517
- }
518
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthLoginFacade, decorators: [{
519
- type: Injectable,
520
- args: [{
521
- providedIn: 'root',
522
- }]
523
- }], ctorParameters: () => [{ type: i1.Store }] });
524
-
525
- /**
526
- * @inheritdoc
527
- */
528
- class DaffAuthRegisterFacade {
529
- constructor(store) {
530
- this.store = store;
531
- const { selectLoading, selectErrors, } = daffAuthRegisterSelectorFactory();
532
- this.loading$ = this.store.pipe(select(selectLoading));
533
- this.errors$ = this.store.pipe(select(selectErrors));
534
- }
535
- dispatch(action) {
536
- this.store.dispatch(action);
537
- }
538
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRegisterFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
539
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRegisterFacade, providedIn: 'root' }); }
540
- }
541
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRegisterFacade, decorators: [{
542
- type: Injectable,
543
- args: [{
544
- providedIn: 'root',
545
- }]
546
- }], ctorParameters: () => [{ type: i1.Store }] });
547
-
548
- /**
549
- * @inheritdoc
550
- */
551
- class DaffAuthResetPasswordFacade {
552
- constructor(store) {
553
- this.store = store;
554
- const { selectLoading, selectErrors, selectAuthResetPasswordToken, } = daffAuthResetPasswordSelectorFactory();
555
- this.token$ = this.store.pipe(select(selectAuthResetPasswordToken));
556
- this.loading$ = this.store.pipe(select(selectLoading));
557
- this.errors$ = this.store.pipe(select(selectErrors));
558
- }
559
- dispatch(action) {
560
- this.store.dispatch(action);
561
- }
562
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
563
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordFacade, providedIn: 'root' }); }
564
- }
565
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordFacade, decorators: [{
566
- type: Injectable,
567
- args: [{
568
- providedIn: 'root',
569
- }]
570
- }], ctorParameters: () => [{ type: i1.Store }] });
571
-
572
- const TWENTY_MINUTES = 1.2e6;
573
- const daffAuthStateDefaultConfig = {
574
- checkInterval: TWENTY_MINUTES,
316
+ var DaffAuthFacade = class DaffAuthFacade {
317
+ constructor(store) {
318
+ this.store = store;
319
+ const { selectLoading, selectErrors, selectAuthLoggedIn } = daffAuthSelectorFactory();
320
+ this.loading$ = this.store.pipe(select(selectLoading));
321
+ this.errors$ = this.store.pipe(select(selectErrors));
322
+ this.loggedIn$ = this.store.pipe(select(selectAuthLoggedIn));
323
+ }
324
+ dispatch(action) {
325
+ this.store.dispatch(action);
326
+ }
327
+ static {
328
+ this.ɵfac = i0.ɵɵngDeclareFactory({
329
+ minVersion: "12.0.0",
330
+ version: "22.2.4",
331
+ ngImport: i0,
332
+ type: DaffAuthFacade,
333
+ deps: [{ token: i1$1.Store }],
334
+ target: i0.ɵɵFactoryTarget.Injectable
335
+ });
336
+ }
337
+ static {
338
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
339
+ minVersion: "12.0.0",
340
+ version: "22.2.4",
341
+ ngImport: i0,
342
+ type: DaffAuthFacade,
343
+ providedIn: "root"
344
+ });
345
+ }
575
346
  };
576
-
577
- const { token: DAFF_AUTH_STATE_CONFIG,
578
- /**
579
- * Provider function for {@link DAFF_AUTH_STATE_CONFIG}.
580
- */
581
- provider: provideDaffAuthStateConfig, } = createConfigInjectionToken(daffAuthStateDefaultConfig, 'DAFF_AUTH_STATE_CONFIG');
582
-
583
- const {
584
- /**
585
- * A token to hold the unauthenticated hooks.
586
- * See {@link DaffAuthUnauthenticatedHook}.
587
- *
588
- * Prefer using {@link daffAuthProvideUnauthenticatedHooks}.
589
- */
590
- token: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
591
- /**
592
- * Provides {@link DAFF_AUTH_UNAUTHENTICATED_HOOKS}.
593
- *
594
- * @example
595
- * ```ts
596
- * providers: [
597
- * ...daffAuthProvideUnauthenticatedHooks(
598
- * myHook1,
599
- * myHook2
600
- * )
601
- * ]
602
- * ```
603
- */
604
- provider: daffAuthProvideUnauthenticatedHooks, } = createMultiInjectionToken('DAFF_AUTH_UNAUTHENTICATED_HOOKS');
605
-
606
- const {
607
- /**
608
- * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
609
- * Can be used to further refine Daffodil errors into more specific app errors.
610
- */
611
- token: DAFF_AUTH_ERROR_MATCHER,
612
- /**
613
- * Provider function for {@link DAFF_AUTH_ERROR_MATCHER}.
614
- */
615
- provider: provideDaffAuthErrorMatcher, } = createSingleInjectionToken('DAFF_AUTH_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
616
-
617
- const {
618
- /**
619
- * An internal token to hold the unauthenticated hook.
620
- * Combines the multi provided hooks into a single function.
621
- *
622
- * @docs-private
623
- */
624
- token: DAFF_AUTH_UNAUTHENTICATED_HOOK,
625
- /**
626
- * Provider function for {@link DAFF_AUTH_UNAUTHENTICATED_HOOK}.
627
- */
628
- provider: provideDaffAuthUnauthenticatedHook, } = createSingleInjectionToken('DAFF_AUTH_UNAUTHENTICATED_HOOK', {
629
- factory: () => {
630
- const hooks = inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS);
631
- return (action) => combineLatest(hooks.map((hook) => hook(action)));
632
- },
347
+ i0.ɵɵngDeclareClassMetadata({
348
+ minVersion: "12.0.0",
349
+ version: "22.2.4",
350
+ ngImport: i0,
351
+ type: DaffAuthFacade,
352
+ decorators: [{
353
+ type: Injectable,
354
+ args: [{ providedIn: "root" }]
355
+ }],
356
+ ctorParameters: () => [{ type: i1$1.Store }]
633
357
  });
634
-
635
- class DaffAuthEffects {
636
- constructor(actions$, tokenCheck, errorMatcher, storage, config, clientCache, unauthenticatedHook, zone) {
637
- this.actions$ = actions$;
638
- this.tokenCheck = tokenCheck;
639
- this.errorMatcher = errorMatcher;
640
- this.storage = storage;
641
- this.config = config;
642
- this.clientCache = clientCache;
643
- this.unauthenticatedHook = unauthenticatedHook;
644
- this.zone = zone;
645
- 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))))))));
646
- // this needs to be defined after `check$` or else the driver call won't be run
647
- this.authCheckInterval$ = createEffect(() => new Observable((subscriber) => {
648
- const intervalId = this.zone.runOutsideAngular(() => setInterval(() => {
649
- subscriber.next(new DaffAuthCheck());
650
- }, this.config.checkInterval));
651
- subscriber.next(new DaffAuthCheck());
652
- return () => {
653
- clearInterval(intervalId);
654
- };
655
- }).pipe(filter(() => !!this.storage.getAuthToken()), catchError((error) => {
656
- switch (true) {
657
- case error instanceof DaffServerSideStorageError:
658
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
659
- case error instanceof DaffStorageServiceError:
660
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
661
- default:
662
- return EMPTY;
663
- }
664
- })));
665
- this.resetToUnauthenticated$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction, DaffAuthActionTypes.AuthGuardLogoutAction, DaffAuthLoginActionTypes.LogoutSuccessAction), filter((action) => {
666
- // if the auth check failure is for any reason other than auth failure,
667
- // such as a network failure, don't reset
668
- if (action.type === DaffAuthActionTypes.AuthCheckFailureAction
669
- && !DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[action.errorMessage.code]) {
670
- return false;
671
- }
672
- return true;
673
- }), map((action) => new DaffAuthResetToUnauthenticated(action.type))));
674
- this.clearClientCache$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.ResetToUnauthenticatedAction), switchMap((action) => this.unauthenticatedHook(action.reason)), tap(() => {
675
- this.clientCache.reset();
676
- }), switchMap(() => EMPTY)), { dispatch: false });
677
- }
678
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthEffects, deps: [{ token: i1$1.Actions }, { token: i2.DaffAuthDriverTokenCheck }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }, { token: DAFF_AUTH_STATE_CONFIG }, { token: DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE }, { token: DAFF_AUTH_UNAUTHENTICATED_HOOK }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
679
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthEffects }); }
680
- }
681
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthEffects, decorators: [{
682
- type: Injectable
683
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: i2.DaffAuthDriverTokenCheck }, { type: undefined, decorators: [{
684
- type: Inject,
685
- args: [DAFF_AUTH_ERROR_MATCHER]
686
- }] }, { type: i2$1.DaffAuthStorageService }, { type: undefined, decorators: [{
687
- type: Inject,
688
- args: [DAFF_AUTH_STATE_CONFIG]
689
- }] }, { type: undefined, decorators: [{
690
- type: Inject,
691
- args: [DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE]
692
- }] }, { type: undefined, decorators: [{
693
- type: Inject,
694
- args: [DAFF_AUTH_UNAUTHENTICATED_HOOK]
695
- }] }, { type: i0.NgZone }] });
696
-
697
- class DaffAuthLoginEffects {
698
- constructor(actions$, loginDriver, errorMatcher, storage) {
699
- this.actions$ = actions$;
700
- this.loginDriver = loginDriver;
701
- this.errorMatcher = errorMatcher;
702
- this.storage = storage;
703
- this.login$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginAction), switchMap((action) => this.loginDriver.login(action.loginInfo)
704
- .pipe(map((resp) => new DaffAuthLoginSuccess(resp)), tap((success) => this.storage.setAuthToken(success.auth.token)), catchError((error) => {
705
- switch (true) {
706
- case error instanceof DaffServerSideStorageError:
707
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
708
- case error instanceof DaffStorageServiceError:
709
- default:
710
- return of(new DaffAuthLoginFailure(this.errorMatcher(error)));
711
- }
712
- })))));
713
- this.logout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutAction), switchMap((action) => this.loginDriver.logout().pipe(map(() => new DaffAuthLogoutSuccess()), catchError((error) => {
714
- switch (true) {
715
- case error instanceof DaffServerSideStorageError:
716
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
717
- case error instanceof DaffStorageServiceError:
718
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
719
- default:
720
- return of(new DaffAuthLogoutFailure(this.errorMatcher(error)));
721
- }
722
- })))));
723
- }
724
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthLoginEffects, deps: [{ token: i1$1.Actions }, { token: DaffLoginDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
725
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthLoginEffects }); }
726
- }
727
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthLoginEffects, decorators: [{
728
- type: Injectable
729
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
730
- type: Inject,
731
- args: [DaffLoginDriver]
732
- }] }, { type: undefined, decorators: [{
733
- type: Inject,
734
- args: [DAFF_AUTH_ERROR_MATCHER]
735
- }] }, { type: i2$1.DaffAuthStorageService }] });
736
-
737
- class DaffAuthRegisterEffects {
738
- constructor(actions$, registerDriver, errorMatcher, storage) {
739
- this.actions$ = actions$;
740
- this.registerDriver = registerDriver;
741
- this.errorMatcher = errorMatcher;
742
- this.storage = storage;
743
- this.register$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthRegisterActionTypes.RegisterAction), switchMap((action) => iif(() => action.autoLogin, defer(() => this.registerDriver.register(action.registration).pipe(tap(token => this.storage.setAuthToken(token)), map((token) => new DaffAuthRegisterSuccess(token)))), defer(() => this.registerDriver.registerOnly(action.registration).pipe(map(() => new DaffAuthRegisterSuccess())))).pipe(catchError((error) => {
744
- switch (true) {
745
- case error instanceof DaffServerSideStorageError:
746
- return of(new DaffAuthServerSide(this.errorMatcher(error)), new DaffAuthRegisterFailure(this.errorMatcher(error)));
747
- case error instanceof DaffStorageServiceError:
748
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)), new DaffAuthRegisterFailure(this.errorMatcher(error)));
749
- default:
750
- return of(new DaffAuthRegisterFailure(this.errorMatcher(error)));
751
- }
752
- })))));
753
- }
754
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRegisterEffects, deps: [{ token: i1$1.Actions }, { token: DaffRegisterDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
755
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRegisterEffects }); }
756
- }
757
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthRegisterEffects, decorators: [{
758
- type: Injectable
759
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
760
- type: Inject,
761
- args: [DaffRegisterDriver]
762
- }] }, { type: undefined, decorators: [{
763
- type: Inject,
764
- args: [DAFF_AUTH_ERROR_MATCHER]
765
- }] }, { type: i2$1.DaffAuthStorageService }] });
766
-
767
- class DaffAuthResetPasswordEffects {
768
- constructor(actions$, driver, errorMatcher, storage) {
769
- this.actions$ = actions$;
770
- this.driver = driver;
771
- this.errorMatcher = errorMatcher;
772
- this.storage = storage;
773
- this.sendResetEmail$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthResetPasswordActionTypes.SendResetEmailAction), switchMap((action) => this.driver.sendResetEmail(action.email).pipe(map(() => new DaffSendResetEmailSuccess()), catchError((error) => of(new DaffSendResetEmailFailure(this.errorMatcher(error))))))));
774
- this.resetPassword$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthResetPasswordActionTypes.ResetPasswordAction), switchMap((action) => iif(() => action.autoLogin, defer(() => this.driver.resetPassword(action.info).pipe(tap(token => this.storage.setAuthToken(token)), map((token) => new DaffResetPasswordSuccess(token)))), defer(() => this.driver.resetPasswordOnly(action.info).pipe(map(() => new DaffResetPasswordSuccess())))).pipe(catchError((error) => {
775
- switch (true) {
776
- case error instanceof DaffServerSideStorageError:
777
- return of(new DaffAuthServerSide(this.errorMatcher(error)), new DaffResetPasswordFailure(this.errorMatcher(error)));
778
- case error instanceof DaffStorageServiceError:
779
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)), new DaffResetPasswordFailure(this.errorMatcher(error)));
780
- default:
781
- return of(new DaffResetPasswordFailure(this.errorMatcher(error)));
782
- }
783
- })))));
784
- }
785
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordEffects, deps: [{ token: i1$1.Actions }, { token: DaffResetPasswordDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
786
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordEffects }); }
787
- }
788
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthResetPasswordEffects, decorators: [{
789
- type: Injectable
790
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
791
- type: Inject,
792
- args: [DaffResetPasswordDriver]
793
- }] }, { type: undefined, decorators: [{
794
- type: Inject,
795
- args: [DAFF_AUTH_ERROR_MATCHER]
796
- }] }, { type: i2$1.DaffAuthStorageService }] });
797
-
798
- const {
799
- /**
800
- * An internal token to hold the Daffodil auth reducers.
801
- * Includes the extra and standard reducers.
802
- *
803
- * @docs-private
804
- */
805
- token: DAFF_AUTH_REDUCERS,
806
- /**
807
- * Provider function for {@link DAFF_AUTH_REDUCERS}.
808
- */
809
- provider: provideDaffAuthReducers, } = createSingleInjectionToken('DAFF_AUTH_REDUCERS', {
810
- factory: () => daffComposeReducers([
811
- combineReducers(daffAuthReducers),
812
- ...inject(DAFF_AUTH_EXTRA_REDUCERS),
813
- ]),
358
+ var DaffAuthLoginFacade = class DaffAuthLoginFacade {
359
+ constructor(store) {
360
+ this.store = store;
361
+ const { selectLoading, selectErrors } = daffAuthLoginSelectorFactory();
362
+ this.loading$ = this.store.pipe(select(selectLoading));
363
+ this.errors$ = this.store.pipe(select(selectErrors));
364
+ }
365
+ dispatch(action) {
366
+ this.store.dispatch(action);
367
+ }
368
+ static {
369
+ this.ɵfac = i0.ɵɵngDeclareFactory({
370
+ minVersion: "12.0.0",
371
+ version: "22.2.4",
372
+ ngImport: i0,
373
+ type: DaffAuthLoginFacade,
374
+ deps: [{ token: i1$1.Store }],
375
+ target: i0.ɵɵFactoryTarget.Injectable
376
+ });
377
+ }
378
+ static {
379
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
380
+ minVersion: "12.0.0",
381
+ version: "22.2.4",
382
+ ngImport: i0,
383
+ type: DaffAuthLoginFacade,
384
+ providedIn: "root"
385
+ });
386
+ }
387
+ };
388
+ i0.ɵɵngDeclareClassMetadata({
389
+ minVersion: "12.0.0",
390
+ version: "22.2.4",
391
+ ngImport: i0,
392
+ type: DaffAuthLoginFacade,
393
+ decorators: [{
394
+ type: Injectable,
395
+ args: [{ providedIn: "root" }]
396
+ }],
397
+ ctorParameters: () => [{ type: i1$1.Store }]
814
398
  });
815
-
816
- class DaffAuthStateModule {
817
- static withConfig(config = {}) {
818
- return {
819
- ngModule: DaffAuthStateModule,
820
- providers: [
821
- provideDaffAuthStateConfig({
822
- ...daffAuthStateDefaultConfig,
823
- ...config,
824
- }),
825
- ],
826
- };
827
- }
828
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
829
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthStateModule, imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule] }); }
830
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthStateModule, providers: [
831
- {
832
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
833
- useFactory: (() => {
834
- const storage = inject(DaffAuthStorageService);
835
- const hook = (() => {
836
- try {
837
- return of(storage.removeAuthToken());
838
- }
839
- catch {
840
- return of(null);
841
- }
842
- });
843
- return hook;
844
- }),
845
- multi: true,
846
- },
847
- ], imports: [StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
848
- EffectsModule.forFeature([
849
- DaffAuthEffects,
850
- DaffAuthLoginEffects,
851
- DaffAuthRegisterEffects,
852
- DaffAuthResetPasswordEffects,
853
- ])] }); }
854
- }
855
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthStateModule, decorators: [{
856
- type: NgModule,
857
- args: [{
858
- imports: [
859
- StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
860
- EffectsModule.forFeature([
861
- DaffAuthEffects,
862
- DaffAuthLoginEffects,
863
- DaffAuthRegisterEffects,
864
- DaffAuthResetPasswordEffects,
865
- ]),
866
- ],
867
- providers: [
868
- {
869
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
870
- useFactory: (() => {
871
- const storage = inject(DaffAuthStorageService);
872
- const hook = (() => {
873
- try {
874
- return of(storage.removeAuthToken());
875
- }
876
- catch {
877
- return of(null);
878
- }
879
- });
880
- return hook;
881
- }),
882
- multi: true,
883
- },
884
- ],
885
- }]
886
- }] });
887
-
888
- /**
889
- * Generated bundle index. Do not edit.
890
- */
891
-
892
- export { DAFF_AUTH_ERROR_MATCHER, DAFF_AUTH_EXTRA_REDUCERS, DAFF_AUTH_STATE_CONFIG, DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_UNAUTHENTICATED_HOOKS, DaffAuthActionTypes, DaffAuthCheck, DaffAuthCheckFailure, DaffAuthCheckSuccess, DaffAuthFacade, DaffAuthGuardLogout, DaffAuthLogin, DaffAuthLoginActionTypes, DaffAuthLoginFacade, DaffAuthLoginFailure, DaffAuthLoginSuccess, DaffAuthLogout, DaffAuthLogoutFailure, DaffAuthLogoutSuccess, DaffAuthRegister, DaffAuthRegisterActionTypes, DaffAuthRegisterFacade, DaffAuthRegisterFailure, DaffAuthRegisterSuccess, DaffAuthResetPasswordActionTypes, DaffAuthResetPasswordFacade, DaffAuthResetToUnauthenticated, DaffAuthServerSide, DaffAuthStateModule, DaffAuthStorageFailure, DaffResetPassword, DaffResetPasswordFailure, DaffResetPasswordLanding, DaffResetPasswordSuccess, DaffSendResetEmail, DaffSendResetEmailFailure, DaffSendResetEmailSuccess, daffAuthInitialState, daffAuthLoginInitialState, daffAuthLoginReducer, daffAuthLoginSelectorFactory, daffAuthProvideExtraReducers, daffAuthProvideUnauthenticatedHooks, daffAuthReducer, daffAuthReducers, daffAuthRegisterInitialState, daffAuthRegisterReducer, daffAuthRegisterSelectorFactory, daffAuthResetPasswordInitialState, daffAuthResetPasswordReducer, daffAuthResetPasswordSelectorFactory, daffAuthSelectorFactory, daffAuthStateDefaultConfig, getDaffAuthSelectors, provideDaffAuthErrorMatcher, provideDaffAuthStateConfig };
893
- //# sourceMappingURL=daffodil-auth-state.mjs.map
399
+ var DaffAuthRegisterFacade = class DaffAuthRegisterFacade {
400
+ constructor(store) {
401
+ this.store = store;
402
+ const { selectLoading, selectErrors } = daffAuthRegisterSelectorFactory();
403
+ this.loading$ = this.store.pipe(select(selectLoading));
404
+ this.errors$ = this.store.pipe(select(selectErrors));
405
+ }
406
+ dispatch(action) {
407
+ this.store.dispatch(action);
408
+ }
409
+ static {
410
+ this.ɵfac = i0.ɵɵngDeclareFactory({
411
+ minVersion: "12.0.0",
412
+ version: "22.2.4",
413
+ ngImport: i0,
414
+ type: DaffAuthRegisterFacade,
415
+ deps: [{ token: i1$1.Store }],
416
+ target: i0.ɵɵFactoryTarget.Injectable
417
+ });
418
+ }
419
+ static {
420
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
421
+ minVersion: "12.0.0",
422
+ version: "22.2.4",
423
+ ngImport: i0,
424
+ type: DaffAuthRegisterFacade,
425
+ providedIn: "root"
426
+ });
427
+ }
428
+ };
429
+ i0.ɵɵngDeclareClassMetadata({
430
+ minVersion: "12.0.0",
431
+ version: "22.2.4",
432
+ ngImport: i0,
433
+ type: DaffAuthRegisterFacade,
434
+ decorators: [{
435
+ type: Injectable,
436
+ args: [{ providedIn: "root" }]
437
+ }],
438
+ ctorParameters: () => [{ type: i1$1.Store }]
439
+ });
440
+ var DaffAuthResetPasswordFacade = class DaffAuthResetPasswordFacade {
441
+ constructor(store) {
442
+ this.store = store;
443
+ const { selectLoading, selectErrors, selectAuthResetPasswordToken } = daffAuthResetPasswordSelectorFactory();
444
+ this.token$ = this.store.pipe(select(selectAuthResetPasswordToken));
445
+ this.loading$ = this.store.pipe(select(selectLoading));
446
+ this.errors$ = this.store.pipe(select(selectErrors));
447
+ }
448
+ dispatch(action) {
449
+ this.store.dispatch(action);
450
+ }
451
+ static {
452
+ this.ɵfac = i0.ɵɵngDeclareFactory({
453
+ minVersion: "12.0.0",
454
+ version: "22.2.4",
455
+ ngImport: i0,
456
+ type: DaffAuthResetPasswordFacade,
457
+ deps: [{ token: i1$1.Store }],
458
+ target: i0.ɵɵFactoryTarget.Injectable
459
+ });
460
+ }
461
+ static {
462
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
463
+ minVersion: "12.0.0",
464
+ version: "22.2.4",
465
+ ngImport: i0,
466
+ type: DaffAuthResetPasswordFacade,
467
+ providedIn: "root"
468
+ });
469
+ }
470
+ };
471
+ i0.ɵɵngDeclareClassMetadata({
472
+ minVersion: "12.0.0",
473
+ version: "22.2.4",
474
+ ngImport: i0,
475
+ type: DaffAuthResetPasswordFacade,
476
+ decorators: [{
477
+ type: Injectable,
478
+ args: [{ providedIn: "root" }]
479
+ }],
480
+ ctorParameters: () => [{ type: i1$1.Store }]
481
+ });
482
+ const daffAuthStateDefaultConfig = { checkInterval: 12e5 };
483
+ const { token: DAFF_AUTH_STATE_CONFIG, provider: provideDaffAuthStateConfig } = createConfigInjectionToken(daffAuthStateDefaultConfig, "DAFF_AUTH_STATE_CONFIG");
484
+ const { token: DAFF_AUTH_UNAUTHENTICATED_HOOKS, provider: daffAuthProvideUnauthenticatedHooks } = createMultiInjectionToken("DAFF_AUTH_UNAUTHENTICATED_HOOKS");
485
+ const { token: DAFF_AUTH_ERROR_MATCHER, provider: provideDaffAuthErrorMatcher } = createSingleInjectionToken("DAFF_AUTH_ERROR_MATCHER", { factory: () => daffTransformErrorToStateError });
486
+ const { token: DAFF_AUTH_UNAUTHENTICATED_HOOK, provider: provideDaffAuthUnauthenticatedHook } = createSingleInjectionToken("DAFF_AUTH_UNAUTHENTICATED_HOOK", { factory: () => {
487
+ const hooks = inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS);
488
+ return (action) => combineLatest(hooks.map((hook) => hook(action)));
489
+ } });
490
+ var DaffAuthEffects = class DaffAuthEffects {
491
+ constructor(actions$, tokenCheck, errorMatcher, storage, config, clientCache, unauthenticatedHook, zone) {
492
+ this.actions$ = actions$;
493
+ this.tokenCheck = tokenCheck;
494
+ this.errorMatcher = errorMatcher;
495
+ this.storage = storage;
496
+ this.config = config;
497
+ this.clientCache = clientCache;
498
+ this.unauthenticatedHook = unauthenticatedHook;
499
+ this.zone = zone;
500
+ 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))))))));
501
+ this.authCheckInterval$ = createEffect(() => new Observable((subscriber) => {
502
+ const intervalId = this.zone.runOutsideAngular(() => setInterval(() => {
503
+ subscriber.next(new DaffAuthCheck());
504
+ }, this.config.checkInterval));
505
+ subscriber.next(new DaffAuthCheck());
506
+ return () => {
507
+ clearInterval(intervalId);
508
+ };
509
+ }).pipe(filter(() => !!this.storage.getAuthToken()), catchError((error) => {
510
+ switch (true) {
511
+ case error instanceof DaffServerSideStorageError: return of(new DaffAuthServerSide(this.errorMatcher(error)));
512
+ case error instanceof DaffStorageServiceError: return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
513
+ default: return EMPTY;
514
+ }
515
+ })));
516
+ this.resetToUnauthenticated$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction, DaffAuthActionTypes.AuthGuardLogoutAction, DaffAuthLoginActionTypes.LogoutSuccessAction), filter((action) => {
517
+ if (action.type === DaffAuthActionTypes.AuthCheckFailureAction && !DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[action.errorMessage.code]) return false;
518
+ return true;
519
+ }), map((action) => new DaffAuthResetToUnauthenticated(action.type))));
520
+ this.clearClientCache$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.ResetToUnauthenticatedAction), switchMap((action) => this.unauthenticatedHook(action.reason)), tap(() => {
521
+ this.clientCache.reset();
522
+ }), switchMap(() => EMPTY)), { dispatch: false });
523
+ }
524
+ static {
525
+ this.ɵfac = i0.ɵɵngDeclareFactory({
526
+ minVersion: "12.0.0",
527
+ version: "22.2.4",
528
+ ngImport: i0,
529
+ type: DaffAuthEffects,
530
+ deps: [
531
+ { token: i1.Actions },
532
+ { token: i2.DaffAuthDriverTokenCheck },
533
+ { token: DAFF_AUTH_ERROR_MATCHER },
534
+ { token: i3.DaffAuthStorageService },
535
+ { token: DAFF_AUTH_STATE_CONFIG },
536
+ { token: DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE },
537
+ { token: DAFF_AUTH_UNAUTHENTICATED_HOOK },
538
+ { token: i0.NgZone }
539
+ ],
540
+ target: i0.ɵɵFactoryTarget.Injectable
541
+ });
542
+ }
543
+ static {
544
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
545
+ minVersion: "12.0.0",
546
+ version: "22.2.4",
547
+ ngImport: i0,
548
+ type: DaffAuthEffects
549
+ });
550
+ }
551
+ };
552
+ i0.ɵɵngDeclareClassMetadata({
553
+ minVersion: "12.0.0",
554
+ version: "22.2.4",
555
+ ngImport: i0,
556
+ type: DaffAuthEffects,
557
+ decorators: [{ type: Injectable }],
558
+ ctorParameters: () => [
559
+ { type: i1.Actions },
560
+ { type: i2.DaffAuthDriverTokenCheck },
561
+ {
562
+ type: void 0,
563
+ decorators: [{
564
+ type: Inject,
565
+ args: [DAFF_AUTH_ERROR_MATCHER]
566
+ }]
567
+ },
568
+ { type: i3.DaffAuthStorageService },
569
+ {
570
+ type: void 0,
571
+ decorators: [{
572
+ type: Inject,
573
+ args: [DAFF_AUTH_STATE_CONFIG]
574
+ }]
575
+ },
576
+ {
577
+ type: void 0,
578
+ decorators: [{
579
+ type: Inject,
580
+ args: [DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE]
581
+ }]
582
+ },
583
+ {
584
+ type: void 0,
585
+ decorators: [{
586
+ type: Inject,
587
+ args: [DAFF_AUTH_UNAUTHENTICATED_HOOK]
588
+ }]
589
+ },
590
+ { type: i0.NgZone }
591
+ ]
592
+ });
593
+ var DaffAuthLoginEffects = class DaffAuthLoginEffects {
594
+ constructor(actions$, loginDriver, errorMatcher, storage) {
595
+ this.actions$ = actions$;
596
+ this.loginDriver = loginDriver;
597
+ this.errorMatcher = errorMatcher;
598
+ this.storage = storage;
599
+ this.login$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginAction), switchMap((action) => this.loginDriver.login(action.loginInfo).pipe(map((resp) => new DaffAuthLoginSuccess(resp)), tap((success) => this.storage.setAuthToken(success.auth.token)), catchError((error) => {
600
+ switch (true) {
601
+ case error instanceof DaffServerSideStorageError: return of(new DaffAuthServerSide(this.errorMatcher(error)));
602
+ case error instanceof DaffStorageServiceError:
603
+ default: return of(new DaffAuthLoginFailure(this.errorMatcher(error)));
604
+ }
605
+ })))));
606
+ this.logout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutAction), switchMap((action) => this.loginDriver.logout().pipe(map(() => new DaffAuthLogoutSuccess()), catchError((error) => {
607
+ switch (true) {
608
+ case error instanceof DaffServerSideStorageError: return of(new DaffAuthServerSide(this.errorMatcher(error)));
609
+ case error instanceof DaffStorageServiceError: return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
610
+ default: return of(new DaffAuthLogoutFailure(this.errorMatcher(error)));
611
+ }
612
+ })))));
613
+ }
614
+ static {
615
+ this.ɵfac = i0.ɵɵngDeclareFactory({
616
+ minVersion: "12.0.0",
617
+ version: "22.2.4",
618
+ ngImport: i0,
619
+ type: DaffAuthLoginEffects,
620
+ deps: [
621
+ { token: i1.Actions },
622
+ { token: DaffLoginDriver },
623
+ { token: DAFF_AUTH_ERROR_MATCHER },
624
+ { token: i3.DaffAuthStorageService }
625
+ ],
626
+ target: i0.ɵɵFactoryTarget.Injectable
627
+ });
628
+ }
629
+ static {
630
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
631
+ minVersion: "12.0.0",
632
+ version: "22.2.4",
633
+ ngImport: i0,
634
+ type: DaffAuthLoginEffects
635
+ });
636
+ }
637
+ };
638
+ i0.ɵɵngDeclareClassMetadata({
639
+ minVersion: "12.0.0",
640
+ version: "22.2.4",
641
+ ngImport: i0,
642
+ type: DaffAuthLoginEffects,
643
+ decorators: [{ type: Injectable }],
644
+ ctorParameters: () => [
645
+ { type: i1.Actions },
646
+ {
647
+ type: void 0,
648
+ decorators: [{
649
+ type: Inject,
650
+ args: [DaffLoginDriver]
651
+ }]
652
+ },
653
+ {
654
+ type: void 0,
655
+ decorators: [{
656
+ type: Inject,
657
+ args: [DAFF_AUTH_ERROR_MATCHER]
658
+ }]
659
+ },
660
+ { type: i3.DaffAuthStorageService }
661
+ ]
662
+ });
663
+ var DaffAuthRegisterEffects = class DaffAuthRegisterEffects {
664
+ constructor(actions$, registerDriver, errorMatcher, storage) {
665
+ this.actions$ = actions$;
666
+ this.registerDriver = registerDriver;
667
+ this.errorMatcher = errorMatcher;
668
+ this.storage = storage;
669
+ this.register$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthRegisterActionTypes.RegisterAction), switchMap((action) => iif(() => action.autoLogin, defer(() => this.registerDriver.register(action.registration).pipe(tap((token) => this.storage.setAuthToken(token)), map((token) => new DaffAuthRegisterSuccess(token)))), defer(() => this.registerDriver.registerOnly(action.registration).pipe(map(() => new DaffAuthRegisterSuccess())))).pipe(catchError((error) => {
670
+ switch (true) {
671
+ case error instanceof DaffServerSideStorageError: return of(new DaffAuthServerSide(this.errorMatcher(error)), new DaffAuthRegisterFailure(this.errorMatcher(error)));
672
+ case error instanceof DaffStorageServiceError: return of(new DaffAuthStorageFailure(this.errorMatcher(error)), new DaffAuthRegisterFailure(this.errorMatcher(error)));
673
+ default: return of(new DaffAuthRegisterFailure(this.errorMatcher(error)));
674
+ }
675
+ })))));
676
+ }
677
+ static {
678
+ this.ɵfac = i0.ɵɵngDeclareFactory({
679
+ minVersion: "12.0.0",
680
+ version: "22.2.4",
681
+ ngImport: i0,
682
+ type: DaffAuthRegisterEffects,
683
+ deps: [
684
+ { token: i1.Actions },
685
+ { token: DaffRegisterDriver },
686
+ { token: DAFF_AUTH_ERROR_MATCHER },
687
+ { token: i3.DaffAuthStorageService }
688
+ ],
689
+ target: i0.ɵɵFactoryTarget.Injectable
690
+ });
691
+ }
692
+ static {
693
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
694
+ minVersion: "12.0.0",
695
+ version: "22.2.4",
696
+ ngImport: i0,
697
+ type: DaffAuthRegisterEffects
698
+ });
699
+ }
700
+ };
701
+ i0.ɵɵngDeclareClassMetadata({
702
+ minVersion: "12.0.0",
703
+ version: "22.2.4",
704
+ ngImport: i0,
705
+ type: DaffAuthRegisterEffects,
706
+ decorators: [{ type: Injectable }],
707
+ ctorParameters: () => [
708
+ { type: i1.Actions },
709
+ {
710
+ type: void 0,
711
+ decorators: [{
712
+ type: Inject,
713
+ args: [DaffRegisterDriver]
714
+ }]
715
+ },
716
+ {
717
+ type: void 0,
718
+ decorators: [{
719
+ type: Inject,
720
+ args: [DAFF_AUTH_ERROR_MATCHER]
721
+ }]
722
+ },
723
+ { type: i3.DaffAuthStorageService }
724
+ ]
725
+ });
726
+ var DaffAuthResetPasswordEffects = class DaffAuthResetPasswordEffects {
727
+ constructor(actions$, driver, errorMatcher, storage) {
728
+ this.actions$ = actions$;
729
+ this.driver = driver;
730
+ this.errorMatcher = errorMatcher;
731
+ this.storage = storage;
732
+ this.sendResetEmail$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthResetPasswordActionTypes.SendResetEmailAction), switchMap((action) => this.driver.sendResetEmail(action.email).pipe(map(() => new DaffSendResetEmailSuccess()), catchError((error) => of(new DaffSendResetEmailFailure(this.errorMatcher(error))))))));
733
+ this.resetPassword$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthResetPasswordActionTypes.ResetPasswordAction), switchMap((action) => iif(() => action.autoLogin, defer(() => this.driver.resetPassword(action.info).pipe(tap((token) => this.storage.setAuthToken(token)), map((token) => new DaffResetPasswordSuccess(token)))), defer(() => this.driver.resetPasswordOnly(action.info).pipe(map(() => new DaffResetPasswordSuccess())))).pipe(catchError((error) => {
734
+ switch (true) {
735
+ case error instanceof DaffServerSideStorageError: return of(new DaffAuthServerSide(this.errorMatcher(error)), new DaffResetPasswordFailure(this.errorMatcher(error)));
736
+ case error instanceof DaffStorageServiceError: return of(new DaffAuthStorageFailure(this.errorMatcher(error)), new DaffResetPasswordFailure(this.errorMatcher(error)));
737
+ default: return of(new DaffResetPasswordFailure(this.errorMatcher(error)));
738
+ }
739
+ })))));
740
+ }
741
+ static {
742
+ this.ɵfac = i0.ɵɵngDeclareFactory({
743
+ minVersion: "12.0.0",
744
+ version: "22.2.4",
745
+ ngImport: i0,
746
+ type: DaffAuthResetPasswordEffects,
747
+ deps: [
748
+ { token: i1.Actions },
749
+ { token: DaffResetPasswordDriver },
750
+ { token: DAFF_AUTH_ERROR_MATCHER },
751
+ { token: i3.DaffAuthStorageService }
752
+ ],
753
+ target: i0.ɵɵFactoryTarget.Injectable
754
+ });
755
+ }
756
+ static {
757
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
758
+ minVersion: "12.0.0",
759
+ version: "22.2.4",
760
+ ngImport: i0,
761
+ type: DaffAuthResetPasswordEffects
762
+ });
763
+ }
764
+ };
765
+ i0.ɵɵngDeclareClassMetadata({
766
+ minVersion: "12.0.0",
767
+ version: "22.2.4",
768
+ ngImport: i0,
769
+ type: DaffAuthResetPasswordEffects,
770
+ decorators: [{ type: Injectable }],
771
+ ctorParameters: () => [
772
+ { type: i1.Actions },
773
+ {
774
+ type: void 0,
775
+ decorators: [{
776
+ type: Inject,
777
+ args: [DaffResetPasswordDriver]
778
+ }]
779
+ },
780
+ {
781
+ type: void 0,
782
+ decorators: [{
783
+ type: Inject,
784
+ args: [DAFF_AUTH_ERROR_MATCHER]
785
+ }]
786
+ },
787
+ { type: i3.DaffAuthStorageService }
788
+ ]
789
+ });
790
+ const { token: DAFF_AUTH_REDUCERS, provider: provideDaffAuthReducers, factoryProvider: provideDaffAuthReducersFactory } = createSingleInjectionToken("DAFF_AUTH_REDUCERS");
791
+ var DaffAuthStateModule = class DaffAuthStateModule {
792
+ static withConfig(config = {}) {
793
+ return {
794
+ ngModule: DaffAuthStateModule,
795
+ providers: [provideDaffAuthStateConfig({
796
+ ...daffAuthStateDefaultConfig,
797
+ ...config
798
+ })]
799
+ };
800
+ }
801
+ static {
802
+ this.ɵfac = i0.ɵɵngDeclareFactory({
803
+ minVersion: "12.0.0",
804
+ version: "22.2.4",
805
+ ngImport: i0,
806
+ type: DaffAuthStateModule,
807
+ deps: [],
808
+ target: i0.ɵɵFactoryTarget.NgModule
809
+ });
810
+ }
811
+ static {
812
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
813
+ minVersion: "14.0.0",
814
+ version: "22.2.4",
815
+ ngImport: i0,
816
+ type: DaffAuthStateModule,
817
+ imports: [i1$1.StoreFeatureModule, i1.EffectsFeatureModule]
818
+ });
819
+ }
820
+ static {
821
+ this.ɵinj = i0.ɵɵngDeclareInjector({
822
+ minVersion: "12.0.0",
823
+ version: "22.2.4",
824
+ ngImport: i0,
825
+ type: DaffAuthStateModule,
826
+ providers: [{
827
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
828
+ useFactory: (() => {
829
+ const storage = inject(DaffAuthStorageService);
830
+ const hook = (() => {
831
+ try {
832
+ return of(storage.removeAuthToken());
833
+ } catch {
834
+ return of(null);
835
+ }
836
+ });
837
+ return hook;
838
+ }),
839
+ multi: true
840
+ }, provideDaffAuthReducersFactory((() => daffComposeReducers([combineReducers(daffAuthReducers), ...inject(DAFF_AUTH_EXTRA_REDUCERS)])))],
841
+ imports: [StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS), EffectsModule.forFeature([
842
+ DaffAuthEffects,
843
+ DaffAuthLoginEffects,
844
+ DaffAuthRegisterEffects,
845
+ DaffAuthResetPasswordEffects
846
+ ])]
847
+ });
848
+ }
849
+ };
850
+ i0.ɵɵngDeclareClassMetadata({
851
+ minVersion: "12.0.0",
852
+ version: "22.2.4",
853
+ ngImport: i0,
854
+ type: DaffAuthStateModule,
855
+ decorators: [{
856
+ type: NgModule,
857
+ args: [{
858
+ imports: [StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS), EffectsModule.forFeature([
859
+ DaffAuthEffects,
860
+ DaffAuthLoginEffects,
861
+ DaffAuthRegisterEffects,
862
+ DaffAuthResetPasswordEffects
863
+ ])],
864
+ providers: [{
865
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
866
+ useFactory: (() => {
867
+ const storage = inject(DaffAuthStorageService);
868
+ const hook = (() => {
869
+ try {
870
+ return of(storage.removeAuthToken());
871
+ } catch {
872
+ return of(null);
873
+ }
874
+ });
875
+ return hook;
876
+ }),
877
+ multi: true
878
+ }, provideDaffAuthReducersFactory((() => daffComposeReducers([combineReducers(daffAuthReducers), ...inject(DAFF_AUTH_EXTRA_REDUCERS)])))]
879
+ }]
880
+ }]
881
+ });
882
+ const provideDaffAuthState = (config = {}) => makeEnvironmentProviders([
883
+ provideState(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
884
+ provideEffects(DaffAuthEffects, DaffAuthLoginEffects, DaffAuthRegisterEffects, DaffAuthResetPasswordEffects),
885
+ {
886
+ provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
887
+ useFactory: () => {
888
+ const storage = inject(DaffAuthStorageService);
889
+ const hook = () => {
890
+ try {
891
+ return of(storage.removeAuthToken());
892
+ } catch {
893
+ return of(null);
894
+ }
895
+ };
896
+ return hook;
897
+ },
898
+ multi: true
899
+ },
900
+ provideDaffAuthReducersFactory(() => daffComposeReducers([combineReducers(daffAuthReducers), ...inject(DAFF_AUTH_EXTRA_REDUCERS)])),
901
+ provideDaffAuthStateConfig({
902
+ ...daffAuthStateDefaultConfig,
903
+ ...config
904
+ })
905
+ ]);
906
+ export { DAFF_AUTH_ERROR_MATCHER, DAFF_AUTH_EXTRA_REDUCERS, DAFF_AUTH_STATE_CONFIG, DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_UNAUTHENTICATED_HOOKS, DaffAuthActionTypes, DaffAuthCheck, DaffAuthCheckFailure, DaffAuthCheckSuccess, DaffAuthFacade, DaffAuthGuardLogout, DaffAuthLogin, DaffAuthLoginActionTypes, DaffAuthLoginFacade, DaffAuthLoginFailure, DaffAuthLoginSuccess, DaffAuthLogout, DaffAuthLogoutFailure, DaffAuthLogoutSuccess, DaffAuthRegister, DaffAuthRegisterActionTypes, DaffAuthRegisterFacade, DaffAuthRegisterFailure, DaffAuthRegisterSuccess, DaffAuthResetPasswordActionTypes, DaffAuthResetPasswordFacade, DaffAuthResetToUnauthenticated, DaffAuthServerSide, DaffAuthStateModule, DaffAuthStorageFailure, DaffResetPassword, DaffResetPasswordFailure, DaffResetPasswordLanding, DaffResetPasswordSuccess, DaffSendResetEmail, DaffSendResetEmailFailure, DaffSendResetEmailSuccess, daffAuthInitialState, daffAuthLoginInitialState, daffAuthLoginReducer, daffAuthLoginSelectorFactory, daffAuthProvideExtraReducers, daffAuthProvideUnauthenticatedHooks, daffAuthReducer, daffAuthReducers, daffAuthRegisterInitialState, daffAuthRegisterReducer, daffAuthRegisterSelectorFactory, daffAuthResetPasswordInitialState, daffAuthResetPasswordReducer, daffAuthResetPasswordSelectorFactory, daffAuthSelectorFactory, daffAuthStateDefaultConfig, getDaffAuthSelectors, provideDaffAuthErrorMatcher, provideDaffAuthState, provideDaffAuthStateConfig };
907
+
908
+ //# sourceMappingURL=daffodil-auth-state.mjs.map