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