@dangl/angular-dangl-identity-client 6.2.0 → 6.2.1-beta0010
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/api-client.d.ts +178 -178
- package/dangl-identity.module.d.ts +6 -7
- package/{esm2020 → esm2022}/api-client.mjs +551 -551
- package/{esm2020 → esm2022}/dangl-angular-dangl-identity-client.mjs +4 -4
- package/esm2022/dangl-identity.module.mjs +30 -0
- package/{esm2020 → esm2022}/interceptors/dangl-identity-request-validator.mjs +1 -1
- package/{esm2020 → esm2022}/interceptors/jwt-interceptor.service.mjs +47 -47
- package/esm2022/messengers/authentication.messenger.mjs +170 -0
- package/{esm2020 → esm2022}/models/jwt-storage.mjs +1 -1
- package/{esm2020 → esm2022}/models/user-info.mjs +1 -1
- package/{esm2020 → esm2022}/public_api.mjs +11 -11
- package/{esm2020 → esm2022}/services/authentication.service.mjs +39 -39
- package/{esm2020 → esm2022}/services/jwt-token.service.mjs +101 -101
- package/{fesm2020 → fesm2022}/dangl-angular-dangl-identity-client.mjs +905 -873
- package/fesm2022/dangl-angular-dangl-identity-client.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/interceptors/dangl-identity-request-validator.d.ts +4 -4
- package/interceptors/jwt-interceptor.service.d.ts +16 -16
- package/messengers/authentication.messenger.d.ts +28 -26
- package/models/jwt-storage.d.ts +5 -5
- package/models/user-info.d.ts +11 -11
- package/package.json +7 -13
- package/public_api.d.ts +8 -8
- package/services/authentication.service.d.ts +14 -14
- package/services/jwt-token.service.d.ts +28 -28
- package/esm2020/dangl-identity.module.mjs +0 -29
- package/esm2020/messengers/authentication.messenger.mjs +0 -146
- package/fesm2015/dangl-angular-dangl-identity-client.mjs +0 -896
- package/fesm2015/dangl-angular-dangl-identity-client.mjs.map +0 -1
- package/fesm2020/dangl-angular-dangl-identity-client.mjs.map +0 -1
|
@@ -1,891 +1,923 @@
|
|
|
1
1
|
import * as i1 from '@angular/common/http';
|
|
2
|
-
import { HttpHeaders, HttpResponseBase, HttpResponse, HttpClient,
|
|
2
|
+
import { HttpHeaders, HttpResponseBase, HttpResponse, HttpClient, provideHttpClient, withInterceptorsFromDi, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken,
|
|
4
|
+
import { InjectionToken, Inject, Optional, Injectable, NgModule, inject } from '@angular/core';
|
|
5
5
|
import { mergeMap, catchError, first, tap, map, takeUntil } from 'rxjs/operators';
|
|
6
|
-
import { throwError, Observable, of, Subject, ReplaySubject } from 'rxjs';
|
|
6
|
+
import { throwError, Observable, of, Subject, ReplaySubject, timer } from 'rxjs';
|
|
7
7
|
import { JwtHelperService } from '@auth0/angular-jwt';
|
|
8
8
|
|
|
9
|
-
//----------------------
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
return
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
else if (status ===
|
|
171
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
229
|
-
let
|
|
230
|
-
|
|
231
|
-
return
|
|
232
|
-
}));
|
|
233
|
-
}
|
|
234
|
-
else if (status ===
|
|
235
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return
|
|
293
|
-
}));
|
|
294
|
-
}
|
|
295
|
-
else if (status
|
|
296
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return
|
|
349
|
-
}));
|
|
350
|
-
}
|
|
351
|
-
else if (status
|
|
352
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
402
|
-
let
|
|
403
|
-
|
|
404
|
-
return
|
|
405
|
-
}));
|
|
406
|
-
}
|
|
407
|
-
else if (status
|
|
408
|
-
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
HttpStatusCode["
|
|
441
|
-
HttpStatusCode["
|
|
442
|
-
HttpStatusCode["
|
|
443
|
-
HttpStatusCode["
|
|
444
|
-
HttpStatusCode["
|
|
445
|
-
HttpStatusCode["
|
|
446
|
-
HttpStatusCode["
|
|
447
|
-
HttpStatusCode["
|
|
448
|
-
HttpStatusCode["
|
|
449
|
-
HttpStatusCode["
|
|
450
|
-
HttpStatusCode["
|
|
451
|
-
HttpStatusCode["
|
|
452
|
-
HttpStatusCode["
|
|
453
|
-
HttpStatusCode["
|
|
454
|
-
HttpStatusCode["
|
|
455
|
-
HttpStatusCode["
|
|
456
|
-
HttpStatusCode["
|
|
457
|
-
HttpStatusCode["
|
|
458
|
-
HttpStatusCode["
|
|
459
|
-
HttpStatusCode["
|
|
460
|
-
HttpStatusCode["
|
|
461
|
-
HttpStatusCode["
|
|
462
|
-
HttpStatusCode["
|
|
463
|
-
HttpStatusCode["
|
|
464
|
-
HttpStatusCode["
|
|
465
|
-
HttpStatusCode["
|
|
466
|
-
HttpStatusCode["
|
|
467
|
-
HttpStatusCode["
|
|
468
|
-
HttpStatusCode["
|
|
469
|
-
HttpStatusCode["
|
|
470
|
-
HttpStatusCode["
|
|
471
|
-
HttpStatusCode["
|
|
472
|
-
HttpStatusCode["
|
|
473
|
-
HttpStatusCode["
|
|
474
|
-
HttpStatusCode["
|
|
475
|
-
HttpStatusCode["
|
|
476
|
-
HttpStatusCode["
|
|
477
|
-
HttpStatusCode["
|
|
478
|
-
HttpStatusCode["
|
|
479
|
-
HttpStatusCode["
|
|
480
|
-
HttpStatusCode["
|
|
481
|
-
HttpStatusCode["
|
|
482
|
-
HttpStatusCode["
|
|
483
|
-
HttpStatusCode["
|
|
484
|
-
HttpStatusCode["
|
|
485
|
-
HttpStatusCode["
|
|
486
|
-
HttpStatusCode["
|
|
487
|
-
HttpStatusCode["
|
|
488
|
-
HttpStatusCode["
|
|
489
|
-
HttpStatusCode["
|
|
490
|
-
HttpStatusCode["
|
|
491
|
-
HttpStatusCode["
|
|
492
|
-
HttpStatusCode["
|
|
493
|
-
HttpStatusCode["
|
|
494
|
-
HttpStatusCode["
|
|
495
|
-
HttpStatusCode["
|
|
496
|
-
HttpStatusCode["
|
|
497
|
-
HttpStatusCode["
|
|
498
|
-
HttpStatusCode["
|
|
499
|
-
HttpStatusCode["
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
return
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
9
|
+
//----------------------
|
|
10
|
+
// <auto-generated>
|
|
11
|
+
// Generated using the NSwag toolchain v14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
|
|
12
|
+
// </auto-generated>
|
|
13
|
+
//----------------------
|
|
14
|
+
/* tslint:disable */
|
|
15
|
+
/* eslint-disable */
|
|
16
|
+
// ReSharper disable InconsistentNaming
|
|
17
|
+
const DANGL_IDENTITY_CLIENT_API_BASE_URL = new InjectionToken('DANGL_IDENTITY_CLIENT_API_BASE_URL');
|
|
18
|
+
class DanglIdentityClient {
|
|
19
|
+
constructor(http, baseUrl) {
|
|
20
|
+
this.jsonParseReviver = undefined;
|
|
21
|
+
this.http = http;
|
|
22
|
+
this.baseUrl = baseUrl ?? "";
|
|
23
|
+
}
|
|
24
|
+
loginWithCookie(model, redirectUrl) {
|
|
25
|
+
let url_ = this.baseUrl + "/identity/login?";
|
|
26
|
+
if (redirectUrl !== undefined && redirectUrl !== null)
|
|
27
|
+
url_ += "redirectUrl=" + encodeURIComponent("" + redirectUrl) + "&";
|
|
28
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
29
|
+
const content_ = JSON.stringify(model);
|
|
30
|
+
let options_ = {
|
|
31
|
+
body: content_,
|
|
32
|
+
observe: "response",
|
|
33
|
+
responseType: "blob",
|
|
34
|
+
headers: new HttpHeaders({
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
return this.http.request("post", url_, options_).pipe(mergeMap((response_) => {
|
|
39
|
+
return this.processLoginWithCookie(response_);
|
|
40
|
+
})).pipe(catchError((response_) => {
|
|
41
|
+
if (response_ instanceof HttpResponseBase) {
|
|
42
|
+
try {
|
|
43
|
+
return this.processLoginWithCookie(response_);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
return throwError(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
return throwError(response_);
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
processLoginWithCookie(response) {
|
|
54
|
+
const status = response.status;
|
|
55
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
56
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
57
|
+
let _headers = {};
|
|
58
|
+
if (response.headers) {
|
|
59
|
+
for (let key of response.headers.keys()) {
|
|
60
|
+
_headers[key] = response.headers.get(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (status === 204) {
|
|
64
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
65
|
+
return of(null);
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
else if (status === 401) {
|
|
69
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
70
|
+
return throwException("A server side error occurred.", status, _responseText, _headers);
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
else if (status !== 200 && status !== 204) {
|
|
74
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
75
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return of(null);
|
|
79
|
+
}
|
|
80
|
+
signOutWithSignInManager() {
|
|
81
|
+
let url_ = this.baseUrl + "/identity/login";
|
|
82
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
83
|
+
let options_ = {
|
|
84
|
+
observe: "response",
|
|
85
|
+
responseType: "blob",
|
|
86
|
+
headers: new HttpHeaders({})
|
|
87
|
+
};
|
|
88
|
+
return this.http.request("delete", url_, options_).pipe(mergeMap((response_) => {
|
|
89
|
+
return this.processSignOutWithSignInManager(response_);
|
|
90
|
+
})).pipe(catchError((response_) => {
|
|
91
|
+
if (response_ instanceof HttpResponseBase) {
|
|
92
|
+
try {
|
|
93
|
+
return this.processSignOutWithSignInManager(response_);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
return throwError(e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
return throwError(response_);
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
processSignOutWithSignInManager(response) {
|
|
104
|
+
const status = response.status;
|
|
105
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
106
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
107
|
+
let _headers = {};
|
|
108
|
+
if (response.headers) {
|
|
109
|
+
for (let key of response.headers.keys()) {
|
|
110
|
+
_headers[key] = response.headers.get(key);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (status === 204) {
|
|
114
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
115
|
+
return of(null);
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
else if (status !== 200 && status !== 204) {
|
|
119
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
120
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
return of(null);
|
|
124
|
+
}
|
|
125
|
+
loginAndReturnToken(model) {
|
|
126
|
+
let url_ = this.baseUrl + "/identity/token-login";
|
|
127
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
128
|
+
const content_ = JSON.stringify(model);
|
|
129
|
+
let options_ = {
|
|
130
|
+
body: content_,
|
|
131
|
+
observe: "response",
|
|
132
|
+
responseType: "blob",
|
|
133
|
+
headers: new HttpHeaders({
|
|
134
|
+
"Content-Type": "application/json",
|
|
135
|
+
"Accept": "application/json"
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
return this.http.request("post", url_, options_).pipe(mergeMap((response_) => {
|
|
139
|
+
return this.processLoginAndReturnToken(response_);
|
|
140
|
+
})).pipe(catchError((response_) => {
|
|
141
|
+
if (response_ instanceof HttpResponseBase) {
|
|
142
|
+
try {
|
|
143
|
+
return this.processLoginAndReturnToken(response_);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
return throwError(e);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else
|
|
150
|
+
return throwError(response_);
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
processLoginAndReturnToken(response) {
|
|
154
|
+
const status = response.status;
|
|
155
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
156
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
157
|
+
let _headers = {};
|
|
158
|
+
if (response.headers) {
|
|
159
|
+
for (let key of response.headers.keys()) {
|
|
160
|
+
_headers[key] = response.headers.get(key);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (status === 200) {
|
|
164
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
165
|
+
let result200 = null;
|
|
166
|
+
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
167
|
+
return of(result200);
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
else if (status === 400) {
|
|
171
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
172
|
+
let result400 = null;
|
|
173
|
+
result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
174
|
+
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
else if (status === 401) {
|
|
178
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
179
|
+
return throwException("A server side error occurred.", status, _responseText, _headers);
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
else if (status !== 200 && status !== 204) {
|
|
183
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
184
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
return of(null);
|
|
188
|
+
}
|
|
189
|
+
refreshToken(model) {
|
|
190
|
+
let url_ = this.baseUrl + "/identity/token-refresh";
|
|
191
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
192
|
+
const content_ = JSON.stringify(model);
|
|
193
|
+
let options_ = {
|
|
194
|
+
body: content_,
|
|
195
|
+
observe: "response",
|
|
196
|
+
responseType: "blob",
|
|
197
|
+
headers: new HttpHeaders({
|
|
198
|
+
"Content-Type": "application/json",
|
|
199
|
+
"Accept": "application/json"
|
|
200
|
+
})
|
|
201
|
+
};
|
|
202
|
+
return this.http.request("post", url_, options_).pipe(mergeMap((response_) => {
|
|
203
|
+
return this.processRefreshToken(response_);
|
|
204
|
+
})).pipe(catchError((response_) => {
|
|
205
|
+
if (response_ instanceof HttpResponseBase) {
|
|
206
|
+
try {
|
|
207
|
+
return this.processRefreshToken(response_);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
return throwError(e);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
return throwError(response_);
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
processRefreshToken(response) {
|
|
218
|
+
const status = response.status;
|
|
219
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
220
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
221
|
+
let _headers = {};
|
|
222
|
+
if (response.headers) {
|
|
223
|
+
for (let key of response.headers.keys()) {
|
|
224
|
+
_headers[key] = response.headers.get(key);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (status === 200) {
|
|
228
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
229
|
+
let result200 = null;
|
|
230
|
+
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
231
|
+
return of(result200);
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
else if (status === 400) {
|
|
235
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
236
|
+
let result400 = null;
|
|
237
|
+
result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
238
|
+
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
else if (status === 401) {
|
|
242
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
243
|
+
return throwException("A server side error occurred.", status, _responseText, _headers);
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
else if (status !== 200 && status !== 204) {
|
|
247
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
248
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
return of(null);
|
|
252
|
+
}
|
|
253
|
+
register(registerModel) {
|
|
254
|
+
let url_ = this.baseUrl + "/identity/register";
|
|
255
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
256
|
+
const content_ = JSON.stringify(registerModel);
|
|
257
|
+
let options_ = {
|
|
258
|
+
body: content_,
|
|
259
|
+
observe: "response",
|
|
260
|
+
responseType: "blob",
|
|
261
|
+
headers: new HttpHeaders({
|
|
262
|
+
"Content-Type": "application/json",
|
|
263
|
+
})
|
|
264
|
+
};
|
|
265
|
+
return this.http.request("post", url_, options_).pipe(mergeMap((response_) => {
|
|
266
|
+
return this.processRegister(response_);
|
|
267
|
+
})).pipe(catchError((response_) => {
|
|
268
|
+
if (response_ instanceof HttpResponseBase) {
|
|
269
|
+
try {
|
|
270
|
+
return this.processRegister(response_);
|
|
271
|
+
}
|
|
272
|
+
catch (e) {
|
|
273
|
+
return throwError(e);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else
|
|
277
|
+
return throwError(response_);
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
processRegister(response) {
|
|
281
|
+
const status = response.status;
|
|
282
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
283
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
284
|
+
let _headers = {};
|
|
285
|
+
if (response.headers) {
|
|
286
|
+
for (let key of response.headers.keys()) {
|
|
287
|
+
_headers[key] = response.headers.get(key);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (status === 204) {
|
|
291
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
292
|
+
return of(null);
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
else if (status === 400) {
|
|
296
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
297
|
+
let result400 = null;
|
|
298
|
+
result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
299
|
+
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
else if (status !== 200 && status !== 204) {
|
|
303
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
304
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
return of(null);
|
|
308
|
+
}
|
|
309
|
+
requestPasswordReset(forgotPasswordModel) {
|
|
310
|
+
let url_ = this.baseUrl + "/identity/password-forgotten";
|
|
311
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
312
|
+
const content_ = JSON.stringify(forgotPasswordModel);
|
|
313
|
+
let options_ = {
|
|
314
|
+
body: content_,
|
|
315
|
+
observe: "response",
|
|
316
|
+
responseType: "blob",
|
|
317
|
+
headers: new HttpHeaders({
|
|
318
|
+
"Content-Type": "application/json",
|
|
319
|
+
})
|
|
320
|
+
};
|
|
321
|
+
return this.http.request("post", url_, options_).pipe(mergeMap((response_) => {
|
|
322
|
+
return this.processRequestPasswordReset(response_);
|
|
323
|
+
})).pipe(catchError((response_) => {
|
|
324
|
+
if (response_ instanceof HttpResponseBase) {
|
|
325
|
+
try {
|
|
326
|
+
return this.processRequestPasswordReset(response_);
|
|
327
|
+
}
|
|
328
|
+
catch (e) {
|
|
329
|
+
return throwError(e);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else
|
|
333
|
+
return throwError(response_);
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
processRequestPasswordReset(response) {
|
|
337
|
+
const status = response.status;
|
|
338
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
339
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
340
|
+
let _headers = {};
|
|
341
|
+
if (response.headers) {
|
|
342
|
+
for (let key of response.headers.keys()) {
|
|
343
|
+
_headers[key] = response.headers.get(key);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (status === 204) {
|
|
347
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
348
|
+
return of(null);
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
else if (status === 400) {
|
|
352
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
353
|
+
let result400 = null;
|
|
354
|
+
result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
355
|
+
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
358
|
+
else if (status !== 200 && status !== 204) {
|
|
359
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
360
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
return of(null);
|
|
364
|
+
}
|
|
365
|
+
getUserInfo() {
|
|
366
|
+
let url_ = this.baseUrl + "/identity/user-info";
|
|
367
|
+
url_ = url_.replace(/[?&]$/, "");
|
|
368
|
+
let options_ = {
|
|
369
|
+
observe: "response",
|
|
370
|
+
responseType: "blob",
|
|
371
|
+
headers: new HttpHeaders({
|
|
372
|
+
"Accept": "application/json"
|
|
373
|
+
})
|
|
374
|
+
};
|
|
375
|
+
return this.http.request("get", url_, options_).pipe(mergeMap((response_) => {
|
|
376
|
+
return this.processGetUserInfo(response_);
|
|
377
|
+
})).pipe(catchError((response_) => {
|
|
378
|
+
if (response_ instanceof HttpResponseBase) {
|
|
379
|
+
try {
|
|
380
|
+
return this.processGetUserInfo(response_);
|
|
381
|
+
}
|
|
382
|
+
catch (e) {
|
|
383
|
+
return throwError(e);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else
|
|
387
|
+
return throwError(response_);
|
|
388
|
+
}));
|
|
389
|
+
}
|
|
390
|
+
processGetUserInfo(response) {
|
|
391
|
+
const status = response.status;
|
|
392
|
+
const responseBlob = response instanceof HttpResponse ? response.body :
|
|
393
|
+
response.error instanceof Blob ? response.error : undefined;
|
|
394
|
+
let _headers = {};
|
|
395
|
+
if (response.headers) {
|
|
396
|
+
for (let key of response.headers.keys()) {
|
|
397
|
+
_headers[key] = response.headers.get(key);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (status === 200) {
|
|
401
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
402
|
+
let result200 = null;
|
|
403
|
+
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
404
|
+
return of(result200);
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
407
|
+
else if (status === 400) {
|
|
408
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
409
|
+
let result400 = null;
|
|
410
|
+
result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
411
|
+
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
else if (status !== 200 && status !== 204) {
|
|
415
|
+
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
|
|
416
|
+
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
return of(null);
|
|
420
|
+
}
|
|
421
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityClient, deps: [{ token: HttpClient }, { token: DANGL_IDENTITY_CLIENT_API_BASE_URL, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
422
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityClient, providedIn: 'root' }); }
|
|
423
|
+
}
|
|
424
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityClient, decorators: [{
|
|
425
|
+
type: Injectable,
|
|
426
|
+
args: [{
|
|
427
|
+
providedIn: 'root'
|
|
428
|
+
}]
|
|
429
|
+
}], ctorParameters: () => [{ type: i1.HttpClient, decorators: [{
|
|
430
|
+
type: Inject,
|
|
431
|
+
args: [HttpClient]
|
|
432
|
+
}] }, { type: undefined, decorators: [{
|
|
433
|
+
type: Optional
|
|
434
|
+
}, {
|
|
435
|
+
type: Inject,
|
|
436
|
+
args: [DANGL_IDENTITY_CLIENT_API_BASE_URL]
|
|
437
|
+
}] }] });
|
|
438
|
+
var HttpStatusCode;
|
|
439
|
+
(function (HttpStatusCode) {
|
|
440
|
+
HttpStatusCode["Continue"] = "Continue";
|
|
441
|
+
HttpStatusCode["SwitchingProtocols"] = "SwitchingProtocols";
|
|
442
|
+
HttpStatusCode["Processing"] = "Processing";
|
|
443
|
+
HttpStatusCode["EarlyHints"] = "EarlyHints";
|
|
444
|
+
HttpStatusCode["OK"] = "OK";
|
|
445
|
+
HttpStatusCode["Created"] = "Created";
|
|
446
|
+
HttpStatusCode["Accepted"] = "Accepted";
|
|
447
|
+
HttpStatusCode["NonAuthoritativeInformation"] = "NonAuthoritativeInformation";
|
|
448
|
+
HttpStatusCode["NoContent"] = "NoContent";
|
|
449
|
+
HttpStatusCode["ResetContent"] = "ResetContent";
|
|
450
|
+
HttpStatusCode["PartialContent"] = "PartialContent";
|
|
451
|
+
HttpStatusCode["MultiStatus"] = "MultiStatus";
|
|
452
|
+
HttpStatusCode["AlreadyReported"] = "AlreadyReported";
|
|
453
|
+
HttpStatusCode["IMUsed"] = "IMUsed";
|
|
454
|
+
HttpStatusCode["MultipleChoices"] = "MultipleChoices";
|
|
455
|
+
HttpStatusCode["Ambiguous"] = "MultipleChoices";
|
|
456
|
+
HttpStatusCode["MovedPermanently"] = "MovedPermanently";
|
|
457
|
+
HttpStatusCode["Moved"] = "MovedPermanently";
|
|
458
|
+
HttpStatusCode["Found"] = "Found";
|
|
459
|
+
HttpStatusCode["Redirect"] = "Found";
|
|
460
|
+
HttpStatusCode["SeeOther"] = "SeeOther";
|
|
461
|
+
HttpStatusCode["RedirectMethod"] = "SeeOther";
|
|
462
|
+
HttpStatusCode["NotModified"] = "NotModified";
|
|
463
|
+
HttpStatusCode["UseProxy"] = "UseProxy";
|
|
464
|
+
HttpStatusCode["Unused"] = "Unused";
|
|
465
|
+
HttpStatusCode["TemporaryRedirect"] = "TemporaryRedirect";
|
|
466
|
+
HttpStatusCode["RedirectKeepVerb"] = "TemporaryRedirect";
|
|
467
|
+
HttpStatusCode["PermanentRedirect"] = "PermanentRedirect";
|
|
468
|
+
HttpStatusCode["BadRequest"] = "BadRequest";
|
|
469
|
+
HttpStatusCode["Unauthorized"] = "Unauthorized";
|
|
470
|
+
HttpStatusCode["PaymentRequired"] = "PaymentRequired";
|
|
471
|
+
HttpStatusCode["Forbidden"] = "Forbidden";
|
|
472
|
+
HttpStatusCode["NotFound"] = "NotFound";
|
|
473
|
+
HttpStatusCode["MethodNotAllowed"] = "MethodNotAllowed";
|
|
474
|
+
HttpStatusCode["NotAcceptable"] = "NotAcceptable";
|
|
475
|
+
HttpStatusCode["ProxyAuthenticationRequired"] = "ProxyAuthenticationRequired";
|
|
476
|
+
HttpStatusCode["RequestTimeout"] = "RequestTimeout";
|
|
477
|
+
HttpStatusCode["Conflict"] = "Conflict";
|
|
478
|
+
HttpStatusCode["Gone"] = "Gone";
|
|
479
|
+
HttpStatusCode["LengthRequired"] = "LengthRequired";
|
|
480
|
+
HttpStatusCode["PreconditionFailed"] = "PreconditionFailed";
|
|
481
|
+
HttpStatusCode["RequestEntityTooLarge"] = "RequestEntityTooLarge";
|
|
482
|
+
HttpStatusCode["RequestUriTooLong"] = "RequestUriTooLong";
|
|
483
|
+
HttpStatusCode["UnsupportedMediaType"] = "UnsupportedMediaType";
|
|
484
|
+
HttpStatusCode["RequestedRangeNotSatisfiable"] = "RequestedRangeNotSatisfiable";
|
|
485
|
+
HttpStatusCode["ExpectationFailed"] = "ExpectationFailed";
|
|
486
|
+
HttpStatusCode["MisdirectedRequest"] = "MisdirectedRequest";
|
|
487
|
+
HttpStatusCode["UnprocessableEntity"] = "UnprocessableEntity";
|
|
488
|
+
HttpStatusCode["UnprocessableContent"] = "UnprocessableEntity";
|
|
489
|
+
HttpStatusCode["Locked"] = "Locked";
|
|
490
|
+
HttpStatusCode["FailedDependency"] = "FailedDependency";
|
|
491
|
+
HttpStatusCode["UpgradeRequired"] = "UpgradeRequired";
|
|
492
|
+
HttpStatusCode["PreconditionRequired"] = "PreconditionRequired";
|
|
493
|
+
HttpStatusCode["TooManyRequests"] = "TooManyRequests";
|
|
494
|
+
HttpStatusCode["RequestHeaderFieldsTooLarge"] = "RequestHeaderFieldsTooLarge";
|
|
495
|
+
HttpStatusCode["UnavailableForLegalReasons"] = "UnavailableForLegalReasons";
|
|
496
|
+
HttpStatusCode["InternalServerError"] = "InternalServerError";
|
|
497
|
+
HttpStatusCode["NotImplemented"] = "NotImplemented";
|
|
498
|
+
HttpStatusCode["BadGateway"] = "BadGateway";
|
|
499
|
+
HttpStatusCode["ServiceUnavailable"] = "ServiceUnavailable";
|
|
500
|
+
HttpStatusCode["GatewayTimeout"] = "GatewayTimeout";
|
|
501
|
+
HttpStatusCode["HttpVersionNotSupported"] = "HttpVersionNotSupported";
|
|
502
|
+
HttpStatusCode["VariantAlsoNegotiates"] = "VariantAlsoNegotiates";
|
|
503
|
+
HttpStatusCode["InsufficientStorage"] = "InsufficientStorage";
|
|
504
|
+
HttpStatusCode["LoopDetected"] = "LoopDetected";
|
|
505
|
+
HttpStatusCode["NotExtended"] = "NotExtended";
|
|
506
|
+
HttpStatusCode["NetworkAuthenticationRequired"] = "NetworkAuthenticationRequired";
|
|
507
|
+
})(HttpStatusCode || (HttpStatusCode = {}));
|
|
508
|
+
/** Various reasons for a protocol endpoint error */
|
|
509
|
+
var ResponseErrorType;
|
|
510
|
+
(function (ResponseErrorType) {
|
|
511
|
+
ResponseErrorType["None"] = "None";
|
|
512
|
+
ResponseErrorType["Protocol"] = "Protocol";
|
|
513
|
+
ResponseErrorType["Http"] = "Http";
|
|
514
|
+
ResponseErrorType["Exception"] = "Exception";
|
|
515
|
+
ResponseErrorType["PolicyViolation"] = "PolicyViolation";
|
|
516
|
+
})(ResponseErrorType || (ResponseErrorType = {}));
|
|
517
|
+
class SwaggerException extends Error {
|
|
518
|
+
constructor(message, status, response, headers, result) {
|
|
519
|
+
super();
|
|
520
|
+
this.isSwaggerException = true;
|
|
521
|
+
this.message = message;
|
|
522
|
+
this.status = status;
|
|
523
|
+
this.response = response;
|
|
524
|
+
this.headers = headers;
|
|
525
|
+
this.result = result;
|
|
526
|
+
}
|
|
527
|
+
static isSwaggerException(obj) {
|
|
528
|
+
return obj.isSwaggerException === true;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function throwException(message, status, response, headers, result) {
|
|
532
|
+
if (result !== null && result !== undefined)
|
|
533
|
+
return throwError(result);
|
|
534
|
+
else
|
|
535
|
+
return throwError(new SwaggerException(message, status, response, headers, null));
|
|
536
|
+
}
|
|
537
|
+
function blobToText(blob) {
|
|
538
|
+
return new Observable((observer) => {
|
|
539
|
+
if (!blob) {
|
|
540
|
+
observer.next("");
|
|
541
|
+
observer.complete();
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
let reader = new FileReader();
|
|
545
|
+
reader.onload = event => {
|
|
546
|
+
observer.next(event.target.result);
|
|
547
|
+
observer.complete();
|
|
548
|
+
};
|
|
549
|
+
reader.readAsText(blob);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
545
552
|
}
|
|
546
553
|
|
|
547
|
-
class JwtTokenService {
|
|
548
|
-
constructor(danglIdentityClient) {
|
|
549
|
-
this.danglIdentityClient = danglIdentityClient;
|
|
550
|
-
this.storage_identifier = 'dangl_identity_integration_jwt_token';
|
|
551
|
-
this.isRefreshing = false;
|
|
552
|
-
this.refreshTokenSource = new Subject();
|
|
553
|
-
this.tokenStoredSource = new ReplaySubject(1);
|
|
554
|
-
this.tokenStored = this.tokenStoredSource.asObservable();
|
|
555
|
-
this.tokenRefreshStartedSource = new Subject();
|
|
556
|
-
this.tokenRefreshStarted = this.tokenRefreshStartedSource.asObservable();
|
|
557
|
-
this.tokenRefreshFinishedSource = new Subject();
|
|
558
|
-
this.tokenRefreshFinished = this.tokenRefreshFinishedSource.asObservable();
|
|
559
|
-
}
|
|
560
|
-
ngOnDestroy() {
|
|
561
|
-
this.tokenRefreshStartedSource.complete();
|
|
562
|
-
this.tokenRefreshFinishedSource.complete();
|
|
563
|
-
this.tokenStoredSource.complete();
|
|
564
|
-
this.refreshTokenSource.complete();
|
|
565
|
-
}
|
|
566
|
-
deleteToken() {
|
|
567
|
-
localStorage.removeItem(this.storage_identifier);
|
|
568
|
-
this.tokenStoredSource.next(null);
|
|
569
|
-
}
|
|
570
|
-
storeCustomToken(tokenToStore) {
|
|
571
|
-
localStorage.setItem(this.storage_identifier, JSON.stringify(tokenToStore));
|
|
572
|
-
this.tokenStoredSource.next(tokenToStore);
|
|
573
|
-
}
|
|
574
|
-
storeToken(token) {
|
|
575
|
-
const tokenToStore = this.transformTokenResponse(token);
|
|
576
|
-
localStorage.setItem(this.storage_identifier, JSON.stringify(tokenToStore));
|
|
577
|
-
this.tokenStoredSource.next(tokenToStore);
|
|
578
|
-
}
|
|
579
|
-
getTokenFromStorage() {
|
|
580
|
-
const storedString = localStorage.getItem(this.storage_identifier);
|
|
581
|
-
if (storedString) {
|
|
582
|
-
const storedToken = JSON.parse(storedString);
|
|
583
|
-
return storedToken;
|
|
584
|
-
}
|
|
585
|
-
return null;
|
|
586
|
-
}
|
|
587
|
-
refreshToken() {
|
|
588
|
-
if (this.isRefreshing) {
|
|
589
|
-
return this.refreshTokenSource.pipe(first());
|
|
590
|
-
}
|
|
591
|
-
this.isRefreshing = true;
|
|
592
|
-
this.tokenRefreshStartedSource.next();
|
|
593
|
-
const refreshToken = this.getTokenFromStorage().refreshToken;
|
|
594
|
-
if (!refreshToken) {
|
|
595
|
-
this.isRefreshing = false;
|
|
596
|
-
return of(null);
|
|
597
|
-
}
|
|
598
|
-
this.danglIdentityClient
|
|
599
|
-
.refreshToken({
|
|
600
|
-
refreshToken: refreshToken,
|
|
601
|
-
})
|
|
602
|
-
.pipe(tap((r) => this.storeToken(r)), map((r) => this.transformTokenResponse(r)))
|
|
603
|
-
.subscribe((refreshTokenResponse) => {
|
|
604
|
-
this.isRefreshing = false;
|
|
605
|
-
this.tokenRefreshFinishedSource.next(true);
|
|
606
|
-
this.refreshTokenSource.next(refreshTokenResponse);
|
|
607
|
-
}, (error) => {
|
|
608
|
-
this.isRefreshing = false;
|
|
609
|
-
this.tokenRefreshFinishedSource.next(false);
|
|
610
|
-
this.refreshTokenSource.next(null);
|
|
611
|
-
console.error('Internal error while refreshing Dangl.Identity token', error);
|
|
612
|
-
});
|
|
613
|
-
return this.refreshTokenSource.pipe(first());
|
|
614
|
-
}
|
|
615
|
-
getToken() {
|
|
616
|
-
const token = this.getTokenFromStorage();
|
|
617
|
-
if (!token) {
|
|
618
|
-
return of(null);
|
|
619
|
-
}
|
|
620
|
-
const isValidToken = token.expiresAt > new Date().getTime() / 1000;
|
|
621
|
-
if (isValidToken) {
|
|
622
|
-
return of(token);
|
|
623
|
-
}
|
|
624
|
-
return this.refreshToken();
|
|
625
|
-
}
|
|
626
|
-
transformTokenResponse(token) {
|
|
627
|
-
return {
|
|
628
|
-
accessToken: token.accessToken,
|
|
629
|
-
refreshToken: token.refreshToken,
|
|
630
|
-
expiresAt: new Date().getTime() / 1000 + token.expiresIn,
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
637
|
-
type: Injectable,
|
|
638
|
-
args: [{
|
|
639
|
-
providedIn: 'root',
|
|
640
|
-
}]
|
|
641
|
-
}], ctorParameters:
|
|
554
|
+
class JwtTokenService {
|
|
555
|
+
constructor(danglIdentityClient) {
|
|
556
|
+
this.danglIdentityClient = danglIdentityClient;
|
|
557
|
+
this.storage_identifier = 'dangl_identity_integration_jwt_token';
|
|
558
|
+
this.isRefreshing = false;
|
|
559
|
+
this.refreshTokenSource = new Subject();
|
|
560
|
+
this.tokenStoredSource = new ReplaySubject(1);
|
|
561
|
+
this.tokenStored = this.tokenStoredSource.asObservable();
|
|
562
|
+
this.tokenRefreshStartedSource = new Subject();
|
|
563
|
+
this.tokenRefreshStarted = this.tokenRefreshStartedSource.asObservable();
|
|
564
|
+
this.tokenRefreshFinishedSource = new Subject();
|
|
565
|
+
this.tokenRefreshFinished = this.tokenRefreshFinishedSource.asObservable();
|
|
566
|
+
}
|
|
567
|
+
ngOnDestroy() {
|
|
568
|
+
this.tokenRefreshStartedSource.complete();
|
|
569
|
+
this.tokenRefreshFinishedSource.complete();
|
|
570
|
+
this.tokenStoredSource.complete();
|
|
571
|
+
this.refreshTokenSource.complete();
|
|
572
|
+
}
|
|
573
|
+
deleteToken() {
|
|
574
|
+
localStorage.removeItem(this.storage_identifier);
|
|
575
|
+
this.tokenStoredSource.next(null);
|
|
576
|
+
}
|
|
577
|
+
storeCustomToken(tokenToStore) {
|
|
578
|
+
localStorage.setItem(this.storage_identifier, JSON.stringify(tokenToStore));
|
|
579
|
+
this.tokenStoredSource.next(tokenToStore);
|
|
580
|
+
}
|
|
581
|
+
storeToken(token) {
|
|
582
|
+
const tokenToStore = this.transformTokenResponse(token);
|
|
583
|
+
localStorage.setItem(this.storage_identifier, JSON.stringify(tokenToStore));
|
|
584
|
+
this.tokenStoredSource.next(tokenToStore);
|
|
585
|
+
}
|
|
586
|
+
getTokenFromStorage() {
|
|
587
|
+
const storedString = localStorage.getItem(this.storage_identifier);
|
|
588
|
+
if (storedString) {
|
|
589
|
+
const storedToken = JSON.parse(storedString);
|
|
590
|
+
return storedToken;
|
|
591
|
+
}
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
refreshToken() {
|
|
595
|
+
if (this.isRefreshing) {
|
|
596
|
+
return this.refreshTokenSource.pipe(first());
|
|
597
|
+
}
|
|
598
|
+
this.isRefreshing = true;
|
|
599
|
+
this.tokenRefreshStartedSource.next();
|
|
600
|
+
const refreshToken = this.getTokenFromStorage().refreshToken;
|
|
601
|
+
if (!refreshToken) {
|
|
602
|
+
this.isRefreshing = false;
|
|
603
|
+
return of(null);
|
|
604
|
+
}
|
|
605
|
+
this.danglIdentityClient
|
|
606
|
+
.refreshToken({
|
|
607
|
+
refreshToken: refreshToken,
|
|
608
|
+
})
|
|
609
|
+
.pipe(tap((r) => this.storeToken(r)), map((r) => this.transformTokenResponse(r)))
|
|
610
|
+
.subscribe((refreshTokenResponse) => {
|
|
611
|
+
this.isRefreshing = false;
|
|
612
|
+
this.tokenRefreshFinishedSource.next(true);
|
|
613
|
+
this.refreshTokenSource.next(refreshTokenResponse);
|
|
614
|
+
}, (error) => {
|
|
615
|
+
this.isRefreshing = false;
|
|
616
|
+
this.tokenRefreshFinishedSource.next(false);
|
|
617
|
+
this.refreshTokenSource.next(null);
|
|
618
|
+
console.error('Internal error while refreshing Dangl.Identity token', error);
|
|
619
|
+
});
|
|
620
|
+
return this.refreshTokenSource.pipe(first());
|
|
621
|
+
}
|
|
622
|
+
getToken() {
|
|
623
|
+
const token = this.getTokenFromStorage();
|
|
624
|
+
if (!token) {
|
|
625
|
+
return of(null);
|
|
626
|
+
}
|
|
627
|
+
const isValidToken = token.expiresAt > new Date().getTime() / 1000;
|
|
628
|
+
if (isValidToken) {
|
|
629
|
+
return of(token);
|
|
630
|
+
}
|
|
631
|
+
return this.refreshToken();
|
|
632
|
+
}
|
|
633
|
+
transformTokenResponse(token) {
|
|
634
|
+
return {
|
|
635
|
+
accessToken: token.accessToken,
|
|
636
|
+
refreshToken: token.refreshToken,
|
|
637
|
+
expiresAt: new Date().getTime() / 1000 + token.expiresIn,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: JwtTokenService, deps: [{ token: DanglIdentityClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
641
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: JwtTokenService, providedIn: 'root' }); }
|
|
642
|
+
}
|
|
643
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: JwtTokenService, decorators: [{
|
|
644
|
+
type: Injectable,
|
|
645
|
+
args: [{
|
|
646
|
+
providedIn: 'root',
|
|
647
|
+
}]
|
|
648
|
+
}], ctorParameters: () => [{ type: DanglIdentityClient }] });
|
|
642
649
|
|
|
643
|
-
const DANGL_IDENTITY_REQUEST_VALIDATOR = new InjectionToken('Validator to decide whether to include JWT tokens in requests');
|
|
644
|
-
class JwtInterceptorService {
|
|
645
|
-
constructor(jwtTokenService, requestValidator) {
|
|
646
|
-
this.jwtTokenService = jwtTokenService;
|
|
647
|
-
this.requestValidator = requestValidator;
|
|
648
|
-
}
|
|
649
|
-
intercept(request, next) {
|
|
650
|
-
if (request.url.startsWith('/identity')) {
|
|
651
|
-
// Requests to the authentication endpoint should not be intercepted
|
|
652
|
-
return next.handle(request.clone());
|
|
653
|
-
}
|
|
654
|
-
if (this.requestValidator &&
|
|
655
|
-
!this.requestValidator.validateRequest(request)) {
|
|
656
|
-
// In case a request validator is provided but doesn't return true for the
|
|
657
|
-
// current request, we're not appending a token
|
|
658
|
-
return next.handle(request);
|
|
659
|
-
}
|
|
660
|
-
return this.jwtTokenService
|
|
661
|
-
.getToken()
|
|
662
|
-
.pipe(mergeMap((f) => next.handle(this.getHttpRequestWithToken(request, f && f.accessToken))));
|
|
663
|
-
}
|
|
664
|
-
getHttpRequestWithToken(request, token) {
|
|
665
|
-
if (token) {
|
|
666
|
-
return request.clone({
|
|
667
|
-
setHeaders: {
|
|
668
|
-
Authorization: `Bearer ${token}`,
|
|
669
|
-
},
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
|
-
return request.clone();
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
678
|
-
type: Injectable
|
|
679
|
-
}], ctorParameters:
|
|
680
|
-
type: Optional
|
|
681
|
-
}, {
|
|
682
|
-
type: Inject,
|
|
683
|
-
args: [DANGL_IDENTITY_REQUEST_VALIDATOR]
|
|
684
|
-
}] }]
|
|
650
|
+
const DANGL_IDENTITY_REQUEST_VALIDATOR = new InjectionToken('Validator to decide whether to include JWT tokens in requests');
|
|
651
|
+
class JwtInterceptorService {
|
|
652
|
+
constructor(jwtTokenService, requestValidator) {
|
|
653
|
+
this.jwtTokenService = jwtTokenService;
|
|
654
|
+
this.requestValidator = requestValidator;
|
|
655
|
+
}
|
|
656
|
+
intercept(request, next) {
|
|
657
|
+
if (request.url.startsWith('/identity')) {
|
|
658
|
+
// Requests to the authentication endpoint should not be intercepted
|
|
659
|
+
return next.handle(request.clone());
|
|
660
|
+
}
|
|
661
|
+
if (this.requestValidator &&
|
|
662
|
+
!this.requestValidator.validateRequest(request)) {
|
|
663
|
+
// In case a request validator is provided but doesn't return true for the
|
|
664
|
+
// current request, we're not appending a token
|
|
665
|
+
return next.handle(request);
|
|
666
|
+
}
|
|
667
|
+
return this.jwtTokenService
|
|
668
|
+
.getToken()
|
|
669
|
+
.pipe(mergeMap((f) => next.handle(this.getHttpRequestWithToken(request, f && f.accessToken))));
|
|
670
|
+
}
|
|
671
|
+
getHttpRequestWithToken(request, token) {
|
|
672
|
+
if (token) {
|
|
673
|
+
return request.clone({
|
|
674
|
+
setHeaders: {
|
|
675
|
+
Authorization: `Bearer ${token}`,
|
|
676
|
+
},
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
return request.clone();
|
|
680
|
+
}
|
|
681
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: JwtInterceptorService, deps: [{ token: JwtTokenService }, { token: DANGL_IDENTITY_REQUEST_VALIDATOR, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
682
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: JwtInterceptorService }); }
|
|
683
|
+
}
|
|
684
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: JwtInterceptorService, decorators: [{
|
|
685
|
+
type: Injectable
|
|
686
|
+
}], ctorParameters: () => [{ type: JwtTokenService }, { type: undefined, decorators: [{
|
|
687
|
+
type: Optional
|
|
688
|
+
}, {
|
|
689
|
+
type: Inject,
|
|
690
|
+
args: [DANGL_IDENTITY_REQUEST_VALIDATOR]
|
|
691
|
+
}] }] });
|
|
685
692
|
|
|
686
|
-
class DanglIdentityModule {
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
providers: [
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
693
|
+
class DanglIdentityModule {
|
|
694
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
695
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityModule }); }
|
|
696
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityModule, providers: [
|
|
697
|
+
provideHttpClient(withInterceptorsFromDi()),
|
|
698
|
+
{
|
|
699
|
+
provide: HTTP_INTERCEPTORS,
|
|
700
|
+
useClass: JwtInterceptorService,
|
|
701
|
+
multi: true,
|
|
702
|
+
},
|
|
703
|
+
] }); }
|
|
704
|
+
}
|
|
705
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DanglIdentityModule, decorators: [{
|
|
706
|
+
type: NgModule,
|
|
707
|
+
args: [{
|
|
708
|
+
providers: [
|
|
709
|
+
provideHttpClient(withInterceptorsFromDi()),
|
|
710
|
+
{
|
|
711
|
+
provide: HTTP_INTERCEPTORS,
|
|
712
|
+
useClass: JwtInterceptorService,
|
|
713
|
+
multi: true,
|
|
714
|
+
},
|
|
715
|
+
],
|
|
716
|
+
}]
|
|
709
717
|
}] });
|
|
710
718
|
|
|
711
|
-
class AuthenticationService {
|
|
712
|
-
constructor(danglIdentityClient, jwtTokenService) {
|
|
713
|
-
this.danglIdentityClient = danglIdentityClient;
|
|
714
|
-
this.jwtTokenService = jwtTokenService;
|
|
715
|
-
}
|
|
716
|
-
loginWithToken(identifier, password) {
|
|
717
|
-
return this.danglIdentityClient
|
|
718
|
-
.loginAndReturnToken({
|
|
719
|
-
identifier: identifier,
|
|
720
|
-
password: password,
|
|
721
|
-
})
|
|
722
|
-
.pipe(map((r) => this.storeJwtTokenIfValid(r)), catchError((e) => of(false)));
|
|
723
|
-
}
|
|
724
|
-
storeJwtTokenIfValid(token) {
|
|
725
|
-
if (!token.accessToken || !token.refreshToken || !token.expiresIn) {
|
|
726
|
-
return false;
|
|
727
|
-
}
|
|
728
|
-
this.jwtTokenService.storeToken(token);
|
|
729
|
-
return true;
|
|
730
|
-
}
|
|
731
|
-
logout() {
|
|
732
|
-
this.jwtTokenService.deleteToken();
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
738
|
-
type: Injectable,
|
|
739
|
-
args: [{
|
|
740
|
-
providedIn: 'root',
|
|
741
|
-
}]
|
|
742
|
-
}], ctorParameters:
|
|
719
|
+
class AuthenticationService {
|
|
720
|
+
constructor(danglIdentityClient, jwtTokenService) {
|
|
721
|
+
this.danglIdentityClient = danglIdentityClient;
|
|
722
|
+
this.jwtTokenService = jwtTokenService;
|
|
723
|
+
}
|
|
724
|
+
loginWithToken(identifier, password) {
|
|
725
|
+
return this.danglIdentityClient
|
|
726
|
+
.loginAndReturnToken({
|
|
727
|
+
identifier: identifier,
|
|
728
|
+
password: password,
|
|
729
|
+
})
|
|
730
|
+
.pipe(map((r) => this.storeJwtTokenIfValid(r)), catchError((e) => of(false)));
|
|
731
|
+
}
|
|
732
|
+
storeJwtTokenIfValid(token) {
|
|
733
|
+
if (!token.accessToken || !token.refreshToken || !token.expiresIn) {
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
this.jwtTokenService.storeToken(token);
|
|
737
|
+
return true;
|
|
738
|
+
}
|
|
739
|
+
logout() {
|
|
740
|
+
this.jwtTokenService.deleteToken();
|
|
741
|
+
}
|
|
742
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: AuthenticationService, deps: [{ token: DanglIdentityClient }, { token: JwtTokenService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
743
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: AuthenticationService, providedIn: 'root' }); }
|
|
744
|
+
}
|
|
745
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: AuthenticationService, decorators: [{
|
|
746
|
+
type: Injectable,
|
|
747
|
+
args: [{
|
|
748
|
+
providedIn: 'root',
|
|
749
|
+
}]
|
|
750
|
+
}], ctorParameters: () => [{ type: DanglIdentityClient }, { type: JwtTokenService }] });
|
|
743
751
|
|
|
744
|
-
class AuthenticationMessenger {
|
|
745
|
-
constructor(
|
|
746
|
-
this.
|
|
747
|
-
this
|
|
748
|
-
this.
|
|
749
|
-
this
|
|
750
|
-
this.
|
|
751
|
-
this.
|
|
752
|
-
this.
|
|
753
|
-
this.
|
|
754
|
-
this.
|
|
755
|
-
this.
|
|
756
|
-
this.
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
.
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
.
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
.
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
this.
|
|
774
|
-
this.
|
|
775
|
-
this.
|
|
776
|
-
this.
|
|
777
|
-
this.
|
|
778
|
-
this
|
|
779
|
-
this
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
this.
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
userInfo.
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
userInfo.claims[claim.type]
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
this.
|
|
809
|
-
this.
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
this.
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
this.
|
|
816
|
-
this.
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
this.lastBroadcastAccessToken
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
this.
|
|
833
|
-
this.
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
this.
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
this.
|
|
870
|
-
this.
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
752
|
+
class AuthenticationMessenger {
|
|
753
|
+
constructor() {
|
|
754
|
+
this.jwtHelperService = new JwtHelperService();
|
|
755
|
+
this.$destroyed = new Subject();
|
|
756
|
+
this.isAuthenticated = new ReplaySubject(1);
|
|
757
|
+
this.username = new ReplaySubject(1);
|
|
758
|
+
this.email = new ReplaySubject(1);
|
|
759
|
+
this.identiconId = new ReplaySubject(1);
|
|
760
|
+
this.userInfo = new ReplaySubject(1);
|
|
761
|
+
this.tokenRefreshStarted = new Subject();
|
|
762
|
+
this.tokenRefreshFinished = new Subject();
|
|
763
|
+
this.jwtTokenService = inject(JwtTokenService);
|
|
764
|
+
this.danglIdentityClient = inject(DanglIdentityClient);
|
|
765
|
+
}
|
|
766
|
+
ngOnInit() {
|
|
767
|
+
this.jwtTokenService.tokenRefreshStarted
|
|
768
|
+
.pipe(takeUntil(this.$destroyed))
|
|
769
|
+
.subscribe(() => this.tokenRefreshStarted.next());
|
|
770
|
+
this.jwtTokenService.tokenRefreshFinished
|
|
771
|
+
.pipe(takeUntil(this.$destroyed))
|
|
772
|
+
.subscribe((successfulRefresh) => this.tokenRefreshFinished.next(successfulRefresh));
|
|
773
|
+
this.jwtTokenService.tokenStored
|
|
774
|
+
.pipe(takeUntil(this.$destroyed))
|
|
775
|
+
.subscribe((jwtToken) => this.refreshAuthenticationStatus(jwtToken));
|
|
776
|
+
this.jwtTokenService
|
|
777
|
+
.getToken()
|
|
778
|
+
.subscribe((token) => this.refreshAuthenticationStatus(token));
|
|
779
|
+
}
|
|
780
|
+
ngOnDestroy() {
|
|
781
|
+
this.isAuthenticated.complete();
|
|
782
|
+
this.username.complete();
|
|
783
|
+
this.email.complete();
|
|
784
|
+
this.identiconId.complete();
|
|
785
|
+
this.userInfo.complete();
|
|
786
|
+
this.tokenRefreshStarted.complete();
|
|
787
|
+
this.tokenRefreshFinished.complete();
|
|
788
|
+
this.$destroyed.next();
|
|
789
|
+
this.$destroyed.complete();
|
|
790
|
+
this.clearLogoutTimer();
|
|
791
|
+
}
|
|
792
|
+
refreshUserInfoFromServer() {
|
|
793
|
+
this.danglIdentityClient.getUserInfo().subscribe({
|
|
794
|
+
next: (serverUserInfo) => {
|
|
795
|
+
if (serverUserInfo.userIsAuthenticated) {
|
|
796
|
+
const userInfo = {
|
|
797
|
+
deserializedToken: null,
|
|
798
|
+
email: serverUserInfo.currentUserEmail,
|
|
799
|
+
id: serverUserInfo.currentUserId,
|
|
800
|
+
identiconId: serverUserInfo.currentUserIdenticonId,
|
|
801
|
+
roles: [],
|
|
802
|
+
claims: {},
|
|
803
|
+
username: serverUserInfo.currentUserName,
|
|
804
|
+
};
|
|
805
|
+
serverUserInfo.userClaims.forEach((claim) => {
|
|
806
|
+
if (claim.type === 'role') {
|
|
807
|
+
userInfo.roles.push(claim.value);
|
|
808
|
+
}
|
|
809
|
+
else if (userInfo.claims[claim.type] === undefined) {
|
|
810
|
+
userInfo.claims[claim.type] = [claim.value];
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
userInfo.claims[claim.type].push(claim.value);
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
this.isAuthenticated.next(true);
|
|
817
|
+
this.username.next(serverUserInfo.currentUserName);
|
|
818
|
+
this.email.next(serverUserInfo.currentUserEmail);
|
|
819
|
+
this.identiconId.next(serverUserInfo.currentUserIdenticonId);
|
|
820
|
+
this.userInfo.next(userInfo);
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
this.isAuthenticated.next(false);
|
|
824
|
+
this.username.next(null);
|
|
825
|
+
this.email.next(null);
|
|
826
|
+
this.identiconId.next(null);
|
|
827
|
+
this.userInfo.next(null);
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
refreshAuthenticationStatus(jwtToken) {
|
|
833
|
+
if (jwtToken) {
|
|
834
|
+
const isValidToken = jwtToken.expiresAt > new Date().getTime() / 1000;
|
|
835
|
+
if (this.lastBroadcastAccessToken === jwtToken.accessToken) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
this.lastBroadcastAccessToken = jwtToken.accessToken;
|
|
839
|
+
if (isValidToken) {
|
|
840
|
+
this.isAuthenticated.next(true);
|
|
841
|
+
this.startTokenExpirationWatcher(jwtToken);
|
|
842
|
+
const decodedToken = this.jwtHelperService.decodeToken(jwtToken.accessToken);
|
|
843
|
+
this.username.next(decodedToken['name']);
|
|
844
|
+
this.email.next(decodedToken['email']);
|
|
845
|
+
this.identiconId.next(decodedToken['identicon_id']);
|
|
846
|
+
const tokenClaims = {};
|
|
847
|
+
for (const tokenProp in decodedToken) {
|
|
848
|
+
if (decodedToken.hasOwnProperty(tokenProp)) {
|
|
849
|
+
const property = decodedToken[tokenProp];
|
|
850
|
+
if (typeof property === 'string') {
|
|
851
|
+
if (tokenClaims[tokenProp] === undefined) {
|
|
852
|
+
tokenClaims[tokenProp] = [];
|
|
853
|
+
}
|
|
854
|
+
tokenClaims[tokenProp].push(property);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
this.userInfo.next({
|
|
859
|
+
id: decodedToken['sub'],
|
|
860
|
+
claims: tokenClaims,
|
|
861
|
+
deserializedToken: decodedToken,
|
|
862
|
+
email: decodedToken['email'],
|
|
863
|
+
identiconId: decodedToken['identicon_id'],
|
|
864
|
+
username: decodedToken['name'],
|
|
865
|
+
roles: decodedToken['role'],
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
this.isAuthenticated.next(false);
|
|
870
|
+
this.jwtTokenService.refreshToken().subscribe(() => { });
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
if (this.lastBroadcastAccessToken === null) {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
this.lastBroadcastAccessToken = null;
|
|
878
|
+
this.isAuthenticated.next(false);
|
|
879
|
+
this.username.next(null);
|
|
880
|
+
this.email.next(null);
|
|
881
|
+
this.identiconId.next(null);
|
|
882
|
+
this.userInfo.next(null);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
startTokenExpirationWatcher(jwtToken) {
|
|
886
|
+
const expirationTime = jwtToken.expiresAt * 1000;
|
|
887
|
+
const currentTime = Date.now();
|
|
888
|
+
const timeUntilExpiration = expirationTime - currentTime;
|
|
889
|
+
this.clearLogoutTimer();
|
|
890
|
+
if (timeUntilExpiration > 0) {
|
|
891
|
+
this.expirationSubscription = timer(timeUntilExpiration).subscribe(() => {
|
|
892
|
+
this.isAuthenticated.next(false);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
this.isAuthenticated.next(false);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
clearLogoutTimer() {
|
|
900
|
+
if (this.expirationSubscription) {
|
|
901
|
+
this.expirationSubscription.unsubscribe();
|
|
902
|
+
this.expirationSubscription = undefined;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: AuthenticationMessenger, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
906
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: AuthenticationMessenger, providedIn: 'root' }); }
|
|
907
|
+
}
|
|
908
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: AuthenticationMessenger, decorators: [{
|
|
909
|
+
type: Injectable,
|
|
910
|
+
args: [{
|
|
911
|
+
providedIn: 'root',
|
|
912
|
+
}]
|
|
913
|
+
}], ctorParameters: () => [] });
|
|
882
914
|
|
|
883
|
-
/*
|
|
884
|
-
* Public API Surface of angular-dangl-identity-client
|
|
915
|
+
/*
|
|
916
|
+
* Public API Surface of angular-dangl-identity-client
|
|
885
917
|
*/
|
|
886
918
|
|
|
887
|
-
/**
|
|
888
|
-
* Generated bundle index. Do not edit.
|
|
919
|
+
/**
|
|
920
|
+
* Generated bundle index. Do not edit.
|
|
889
921
|
*/
|
|
890
922
|
|
|
891
923
|
export { AuthenticationMessenger, AuthenticationService, DANGL_IDENTITY_CLIENT_API_BASE_URL, DANGL_IDENTITY_REQUEST_VALIDATOR, DanglIdentityClient, DanglIdentityModule, HttpStatusCode, JwtInterceptorService, JwtTokenService, ResponseErrorType, SwaggerException };
|