@valtimo/keycloak 4.15.2-next-main.8

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.
@@ -0,0 +1,619 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('keycloak-angular'), require('@angular/router'), require('ngx-logger'), require('@valtimo/config'), require('@angular/common'), require('rxjs'), require('@valtimo/contract')) :
3
+ typeof define === 'function' && define.amd ? define('@valtimo/keycloak', ['exports', '@angular/core', 'keycloak-angular', '@angular/router', 'ngx-logger', '@valtimo/config', '@angular/common', 'rxjs', '@valtimo/contract'], factory) :
4
+ (global = global || self, factory((global.valtimo = global.valtimo || {}, global.valtimo.keycloak = {}), global.ng.core, global.keycloakAngular, global.ng.router, global.ngxLogger, global.config, global.ng.common, global.rxjs, global.contract));
5
+ }(this, (function (exports, i0, i2, i1, i3, i1$1, common, rxjs, contract) { 'use strict';
6
+
7
+ var KeycloakOptionsService = /** @class */ (function () {
8
+ function KeycloakOptionsService(configService) {
9
+ this.configService = configService;
10
+ this.valtimoKeycloakOptions = configService.config.authentication.options;
11
+ }
12
+ Object.defineProperty(KeycloakOptionsService.prototype, "keycloakOptions", {
13
+ get: function () {
14
+ return this.valtimoKeycloakOptions.keycloakOptions;
15
+ },
16
+ enumerable: false,
17
+ configurable: true
18
+ });
19
+ Object.defineProperty(KeycloakOptionsService.prototype, "logoutRedirectUri", {
20
+ get: function () {
21
+ return this.valtimoKeycloakOptions.logoutRedirectUri;
22
+ },
23
+ enumerable: false,
24
+ configurable: true
25
+ });
26
+ return KeycloakOptionsService;
27
+ }());
28
+ KeycloakOptionsService.ɵprov = i0.ɵɵdefineInjectable({ factory: function KeycloakOptionsService_Factory() { return new KeycloakOptionsService(i0.ɵɵinject(i1$1.ConfigService)); }, token: KeycloakOptionsService, providedIn: "root" });
29
+ KeycloakOptionsService.decorators = [
30
+ { type: i0.Injectable, args: [{
31
+ providedIn: 'root'
32
+ },] }
33
+ ];
34
+ KeycloakOptionsService.ctorParameters = function () { return [
35
+ { type: i1$1.ConfigService }
36
+ ]; };
37
+
38
+ /*
39
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
40
+ *
41
+ * Licensed under EUPL, Version 1.2 (the "License");
42
+ * you may not use this file except in compliance with the License.
43
+ * You may obtain a copy of the License at
44
+ *
45
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
46
+ *
47
+ * Unless required by applicable law or agreed to in writing, software
48
+ * distributed under the License is distributed on an "AS IS" basis,
49
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50
+ * See the License for the specific language governing permissions and
51
+ * limitations under the License.
52
+ */
53
+ var CallbackComponent = /** @class */ (function () {
54
+ function CallbackComponent(router, keycloakOptionsService, logger) {
55
+ this.router = router;
56
+ this.keycloakOptionsService = keycloakOptionsService;
57
+ this.logger = logger;
58
+ logger.debug('callback');
59
+ var savedRedirectTo = window.sessionStorage.getItem('redirectTo');
60
+ var redirectTo;
61
+ if (savedRedirectTo !== null) {
62
+ redirectTo = window.sessionStorage.getItem('redirectTo');
63
+ }
64
+ else {
65
+ redirectTo = '/';
66
+ }
67
+ logger.debug('keycloak callback redirect =', redirectTo);
68
+ this.router.navigate([redirectTo]);
69
+ }
70
+ return CallbackComponent;
71
+ }());
72
+ CallbackComponent.decorators = [
73
+ { type: i0.Component, args: [{
74
+ selector: 'valtimo-keycloak-callback',
75
+ template: ''
76
+ },] }
77
+ ];
78
+ CallbackComponent.ctorParameters = function () { return [
79
+ { type: i1.Router },
80
+ { type: KeycloakOptionsService },
81
+ { type: i3.NGXLogger }
82
+ ]; };
83
+
84
+ /*
85
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
86
+ *
87
+ * Licensed under EUPL, Version 1.2 (the "License");
88
+ * you may not use this file except in compliance with the License.
89
+ * You may obtain a copy of the License at
90
+ *
91
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
92
+ *
93
+ * Unless required by applicable law or agreed to in writing, software
94
+ * distributed under the License is distributed on an "AS IS" basis,
95
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
96
+ * See the License for the specific language governing permissions and
97
+ * limitations under the License.
98
+ */
99
+ var ɵ0 = { title: 'Loading...' };
100
+ var routes = [
101
+ {
102
+ path: 'keycloak/callback',
103
+ component: CallbackComponent,
104
+ data: ɵ0
105
+ }
106
+ ];
107
+ var KeycloakRoutingModule = /** @class */ (function () {
108
+ function KeycloakRoutingModule() {
109
+ }
110
+ return KeycloakRoutingModule;
111
+ }());
112
+ KeycloakRoutingModule.decorators = [
113
+ { type: i0.NgModule, args: [{
114
+ imports: [common.CommonModule, i1.RouterModule.forChild(routes)],
115
+ exports: [i1.RouterModule]
116
+ },] }
117
+ ];
118
+
119
+ /*
120
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
121
+ *
122
+ * Licensed under EUPL, Version 1.2 (the "License");
123
+ * you may not use this file except in compliance with the License.
124
+ * You may obtain a copy of the License at
125
+ *
126
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
127
+ *
128
+ * Unless required by applicable law or agreed to in writing, software
129
+ * distributed under the License is distributed on an "AS IS" basis,
130
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131
+ * See the License for the specific language governing permissions and
132
+ * limitations under the License.
133
+ */
134
+ var KeycloakModule = /** @class */ (function () {
135
+ function KeycloakModule() {
136
+ }
137
+ return KeycloakModule;
138
+ }());
139
+ KeycloakModule.decorators = [
140
+ { type: i0.NgModule, args: [{
141
+ declarations: [CallbackComponent],
142
+ imports: [
143
+ KeycloakRoutingModule,
144
+ i2.KeycloakAngularModule
145
+ ],
146
+ exports: [CallbackComponent]
147
+ },] }
148
+ ];
149
+
150
+ /*! *****************************************************************************
151
+ Copyright (c) Microsoft Corporation.
152
+
153
+ Permission to use, copy, modify, and/or distribute this software for any
154
+ purpose with or without fee is hereby granted.
155
+
156
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
157
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
158
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
159
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
160
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
161
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
162
+ PERFORMANCE OF THIS SOFTWARE.
163
+ ***************************************************************************** */
164
+ /* global Reflect, Promise */
165
+ var extendStatics = function (d, b) {
166
+ extendStatics = Object.setPrototypeOf ||
167
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
168
+ function (d, b) { for (var p in b)
169
+ if (Object.prototype.hasOwnProperty.call(b, p))
170
+ d[p] = b[p]; };
171
+ return extendStatics(d, b);
172
+ };
173
+ function __extends(d, b) {
174
+ extendStatics(d, b);
175
+ function __() { this.constructor = d; }
176
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
177
+ }
178
+ var __assign = function () {
179
+ __assign = Object.assign || function __assign(t) {
180
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
181
+ s = arguments[i];
182
+ for (var p in s)
183
+ if (Object.prototype.hasOwnProperty.call(s, p))
184
+ t[p] = s[p];
185
+ }
186
+ return t;
187
+ };
188
+ return __assign.apply(this, arguments);
189
+ };
190
+ function __rest(s, e) {
191
+ var t = {};
192
+ for (var p in s)
193
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
194
+ t[p] = s[p];
195
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
196
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
197
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
198
+ t[p[i]] = s[p[i]];
199
+ }
200
+ return t;
201
+ }
202
+ function __decorate(decorators, target, key, desc) {
203
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
204
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
205
+ r = Reflect.decorate(decorators, target, key, desc);
206
+ else
207
+ for (var i = decorators.length - 1; i >= 0; i--)
208
+ if (d = decorators[i])
209
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
210
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
211
+ }
212
+ function __param(paramIndex, decorator) {
213
+ return function (target, key) { decorator(target, key, paramIndex); };
214
+ }
215
+ function __metadata(metadataKey, metadataValue) {
216
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
217
+ return Reflect.metadata(metadataKey, metadataValue);
218
+ }
219
+ function __awaiter(thisArg, _arguments, P, generator) {
220
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
221
+ return new (P || (P = Promise))(function (resolve, reject) {
222
+ function fulfilled(value) { try {
223
+ step(generator.next(value));
224
+ }
225
+ catch (e) {
226
+ reject(e);
227
+ } }
228
+ function rejected(value) { try {
229
+ step(generator["throw"](value));
230
+ }
231
+ catch (e) {
232
+ reject(e);
233
+ } }
234
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
235
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
236
+ });
237
+ }
238
+ function __generator(thisArg, body) {
239
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
240
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
241
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
242
+ function verb(n) { return function (v) { return step([n, v]); }; }
243
+ function step(op) {
244
+ if (f)
245
+ throw new TypeError("Generator is already executing.");
246
+ while (_)
247
+ try {
248
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
249
+ return t;
250
+ if (y = 0, t)
251
+ op = [op[0] & 2, t.value];
252
+ switch (op[0]) {
253
+ case 0:
254
+ case 1:
255
+ t = op;
256
+ break;
257
+ case 4:
258
+ _.label++;
259
+ return { value: op[1], done: false };
260
+ case 5:
261
+ _.label++;
262
+ y = op[1];
263
+ op = [0];
264
+ continue;
265
+ case 7:
266
+ op = _.ops.pop();
267
+ _.trys.pop();
268
+ continue;
269
+ default:
270
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
271
+ _ = 0;
272
+ continue;
273
+ }
274
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
275
+ _.label = op[1];
276
+ break;
277
+ }
278
+ if (op[0] === 6 && _.label < t[1]) {
279
+ _.label = t[1];
280
+ t = op;
281
+ break;
282
+ }
283
+ if (t && _.label < t[2]) {
284
+ _.label = t[2];
285
+ _.ops.push(op);
286
+ break;
287
+ }
288
+ if (t[2])
289
+ _.ops.pop();
290
+ _.trys.pop();
291
+ continue;
292
+ }
293
+ op = body.call(thisArg, _);
294
+ }
295
+ catch (e) {
296
+ op = [6, e];
297
+ y = 0;
298
+ }
299
+ finally {
300
+ f = t = 0;
301
+ }
302
+ if (op[0] & 5)
303
+ throw op[1];
304
+ return { value: op[0] ? op[1] : void 0, done: true };
305
+ }
306
+ }
307
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
308
+ if (k2 === undefined)
309
+ k2 = k;
310
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
311
+ }) : (function (o, m, k, k2) {
312
+ if (k2 === undefined)
313
+ k2 = k;
314
+ o[k2] = m[k];
315
+ });
316
+ function __exportStar(m, o) {
317
+ for (var p in m)
318
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
319
+ __createBinding(o, m, p);
320
+ }
321
+ function __values(o) {
322
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
323
+ if (m)
324
+ return m.call(o);
325
+ if (o && typeof o.length === "number")
326
+ return {
327
+ next: function () {
328
+ if (o && i >= o.length)
329
+ o = void 0;
330
+ return { value: o && o[i++], done: !o };
331
+ }
332
+ };
333
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
334
+ }
335
+ function __read(o, n) {
336
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
337
+ if (!m)
338
+ return o;
339
+ var i = m.call(o), r, ar = [], e;
340
+ try {
341
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
342
+ ar.push(r.value);
343
+ }
344
+ catch (error) {
345
+ e = { error: error };
346
+ }
347
+ finally {
348
+ try {
349
+ if (r && !r.done && (m = i["return"]))
350
+ m.call(i);
351
+ }
352
+ finally {
353
+ if (e)
354
+ throw e.error;
355
+ }
356
+ }
357
+ return ar;
358
+ }
359
+ function __spread() {
360
+ for (var ar = [], i = 0; i < arguments.length; i++)
361
+ ar = ar.concat(__read(arguments[i]));
362
+ return ar;
363
+ }
364
+ function __spreadArrays() {
365
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
366
+ s += arguments[i].length;
367
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
368
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
369
+ r[k] = a[j];
370
+ return r;
371
+ }
372
+ ;
373
+ function __await(v) {
374
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
375
+ }
376
+ function __asyncGenerator(thisArg, _arguments, generator) {
377
+ if (!Symbol.asyncIterator)
378
+ throw new TypeError("Symbol.asyncIterator is not defined.");
379
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
380
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
381
+ function verb(n) { if (g[n])
382
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
383
+ function resume(n, v) { try {
384
+ step(g[n](v));
385
+ }
386
+ catch (e) {
387
+ settle(q[0][3], e);
388
+ } }
389
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
390
+ function fulfill(value) { resume("next", value); }
391
+ function reject(value) { resume("throw", value); }
392
+ function settle(f, v) { if (f(v), q.shift(), q.length)
393
+ resume(q[0][0], q[0][1]); }
394
+ }
395
+ function __asyncDelegator(o) {
396
+ var i, p;
397
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
398
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
399
+ }
400
+ function __asyncValues(o) {
401
+ if (!Symbol.asyncIterator)
402
+ throw new TypeError("Symbol.asyncIterator is not defined.");
403
+ var m = o[Symbol.asyncIterator], i;
404
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
405
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
406
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
407
+ }
408
+ function __makeTemplateObject(cooked, raw) {
409
+ if (Object.defineProperty) {
410
+ Object.defineProperty(cooked, "raw", { value: raw });
411
+ }
412
+ else {
413
+ cooked.raw = raw;
414
+ }
415
+ return cooked;
416
+ }
417
+ ;
418
+ var __setModuleDefault = Object.create ? (function (o, v) {
419
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
420
+ }) : function (o, v) {
421
+ o["default"] = v;
422
+ };
423
+ function __importStar(mod) {
424
+ if (mod && mod.__esModule)
425
+ return mod;
426
+ var result = {};
427
+ if (mod != null)
428
+ for (var k in mod)
429
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
430
+ __createBinding(result, mod, k);
431
+ __setModuleDefault(result, mod);
432
+ return result;
433
+ }
434
+ function __importDefault(mod) {
435
+ return (mod && mod.__esModule) ? mod : { default: mod };
436
+ }
437
+ function __classPrivateFieldGet(receiver, privateMap) {
438
+ if (!privateMap.has(receiver)) {
439
+ throw new TypeError("attempted to get private field on non-instance");
440
+ }
441
+ return privateMap.get(receiver);
442
+ }
443
+ function __classPrivateFieldSet(receiver, privateMap, value) {
444
+ if (!privateMap.has(receiver)) {
445
+ throw new TypeError("attempted to set private field on non-instance");
446
+ }
447
+ privateMap.set(receiver, value);
448
+ return value;
449
+ }
450
+
451
+ var KeycloakAuthGuardService = /** @class */ (function (_super) {
452
+ __extends(KeycloakAuthGuardService, _super);
453
+ function KeycloakAuthGuardService(router, keycloakAngular, logger) {
454
+ var _this = _super.call(this, router, keycloakAngular) || this;
455
+ _this.router = router;
456
+ _this.keycloakAngular = keycloakAngular;
457
+ _this.logger = logger;
458
+ _this.logger.debug('KeycloakAuthGuardService: ctor');
459
+ return _this;
460
+ }
461
+ KeycloakAuthGuardService.prototype.isAccessAllowed = function (route, state) {
462
+ var _this = this;
463
+ this.logger.debug('KeycloakAuthGuardService: isAccessAllowed');
464
+ return new Promise(function (resolve, reject) {
465
+ _this.logger.debug('KeycloakAuthGuardService: isAccessAllowed checking access');
466
+ if (!_this.authenticated) {
467
+ _this.keycloakAngular.login().catch(function (e) { return "KeycloakAuthGuardService error: " + _this.logger.error(e); });
468
+ return reject(false);
469
+ }
470
+ var requiredRoles = route.data.roles;
471
+ if (!requiredRoles || requiredRoles.length === 0) {
472
+ return resolve(true);
473
+ }
474
+ else {
475
+ if (!_this.roles || _this.roles.length === 0) {
476
+ resolve(false);
477
+ }
478
+ resolve(requiredRoles.some(function (role) { return _this.roles.includes(role); }));
479
+ }
480
+ });
481
+ };
482
+ return KeycloakAuthGuardService;
483
+ }(i2.KeycloakAuthGuard));
484
+ KeycloakAuthGuardService.ɵprov = i0.ɵɵdefineInjectable({ factory: function KeycloakAuthGuardService_Factory() { return new KeycloakAuthGuardService(i0.ɵɵinject(i1.Router), i0.ɵɵinject(i2.KeycloakService), i0.ɵɵinject(i3.NGXLogger)); }, token: KeycloakAuthGuardService, providedIn: "root" });
485
+ KeycloakAuthGuardService.decorators = [
486
+ { type: i0.Injectable, args: [{
487
+ providedIn: 'root'
488
+ },] }
489
+ ];
490
+ KeycloakAuthGuardService.ctorParameters = function () { return [
491
+ { type: i1.Router },
492
+ { type: i2.KeycloakService },
493
+ { type: i3.NGXLogger }
494
+ ]; };
495
+
496
+ var KeycloakUserService = /** @class */ (function () {
497
+ function KeycloakUserService(keycloakService, keycloakOptionsService, logger) {
498
+ this.keycloakService = keycloakService;
499
+ this.keycloakOptionsService = keycloakOptionsService;
500
+ this.logger = logger;
501
+ }
502
+ KeycloakUserService.prototype.init = function () {
503
+ var _this = this;
504
+ this.userIdentity = new rxjs.ReplaySubject();
505
+ this.keycloakService.loadUserProfile().then(function (user) {
506
+ _this.logger.debug('KeycloakUserService: loadUserProfile = ', user);
507
+ var roles = [];
508
+ _this.keycloakService.getUserRoles(true).forEach(function (role) { return roles.push(role); });
509
+ var valtimoUserIdentity = new contract.ValtimoUserIdentity(user.email, user.firstName, user.lastName, roles, user.username);
510
+ _this.logger.debug('KeycloakUserService: loaded user identity', valtimoUserIdentity);
511
+ _this.userIdentity.next(valtimoUserIdentity);
512
+ });
513
+ };
514
+ KeycloakUserService.prototype.getUserSubject = function () {
515
+ this.logger.debug('KeycloakUserService: getUserIdentity');
516
+ return this.userIdentity;
517
+ };
518
+ KeycloakUserService.prototype.logout = function () {
519
+ this.logger.debug('KeycloakUserService: logout');
520
+ this.keycloakService.logout(this.keycloakOptionsService.logoutRedirectUri);
521
+ };
522
+ KeycloakUserService.prototype.getToken = function () {
523
+ return __awaiter(this, void 0, void 0, function () {
524
+ return __generator(this, function (_a) {
525
+ this.logger.debug('KeycloakUserService: getToken');
526
+ return [2 /*return*/, this.keycloakService.getToken()];
527
+ });
528
+ });
529
+ };
530
+ KeycloakUserService.prototype.updateToken = function (minValidity) {
531
+ return __awaiter(this, void 0, void 0, function () {
532
+ return __generator(this, function (_a) {
533
+ this.logger.debug('KeycloakUserService: updateToken');
534
+ return [2 /*return*/, this.keycloakService.updateToken(minValidity)];
535
+ });
536
+ });
537
+ };
538
+ return KeycloakUserService;
539
+ }());
540
+ KeycloakUserService.ɵprov = i0.ɵɵdefineInjectable({ factory: function KeycloakUserService_Factory() { return new KeycloakUserService(i0.ɵɵinject(i2.KeycloakService), i0.ɵɵinject(KeycloakOptionsService), i0.ɵɵinject(i3.NGXLogger)); }, token: KeycloakUserService, providedIn: "root" });
541
+ KeycloakUserService.decorators = [
542
+ { type: i0.Injectable, args: [{
543
+ providedIn: 'root'
544
+ },] }
545
+ ];
546
+ KeycloakUserService.ctorParameters = function () { return [
547
+ { type: i2.KeycloakService },
548
+ { type: KeycloakOptionsService },
549
+ { type: i3.NGXLogger }
550
+ ]; };
551
+
552
+ function keycloakInitializer(injector) {
553
+ var _this = this;
554
+ var keycloakService = injector.get(i2.KeycloakService);
555
+ var keycloakUserService = injector.get(KeycloakUserService);
556
+ var optionsService = injector.get(KeycloakOptionsService); // TODO possible removal of abstraction
557
+ var logger = injector.get(i3.NGXLogger);
558
+ return function () { return __awaiter(_this, void 0, void 0, function () {
559
+ var keycloakOptions, currentUrl, redirectTo, initResult, error_1;
560
+ return __generator(this, function (_a) {
561
+ switch (_a.label) {
562
+ case 0:
563
+ _a.trys.push([0, 2, , 3]);
564
+ logger.debug('Keycloak initializer before init');
565
+ keycloakOptions = optionsService.keycloakOptions;
566
+ currentUrl = window.location.href.split('#')[0];
567
+ if (keycloakOptions.initOptions.redirectUri !== currentUrl) {
568
+ redirectTo = window.location.pathname;
569
+ logger.debug('Setting redirectTo =', redirectTo);
570
+ window.sessionStorage.setItem('redirectTo', redirectTo);
571
+ }
572
+ return [4 /*yield*/, keycloakService.init(keycloakOptions)];
573
+ case 1:
574
+ initResult = _a.sent();
575
+ logger.debug('Keycloak initializer after init');
576
+ keycloakUserService.init();
577
+ return [2 /*return*/, initResult];
578
+ case 2:
579
+ error_1 = _a.sent();
580
+ logger.debug('Keycloak initializer error', error_1);
581
+ throw error_1;
582
+ case 3: return [2 /*return*/];
583
+ }
584
+ });
585
+ }); };
586
+ }
587
+
588
+ /*
589
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
590
+ *
591
+ * Licensed under EUPL, Version 1.2 (the "License");
592
+ * you may not use this file except in compliance with the License.
593
+ * You may obtain a copy of the License at
594
+ *
595
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
596
+ *
597
+ * Unless required by applicable law or agreed to in writing, software
598
+ * distributed under the License is distributed on an "AS IS" basis,
599
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
600
+ * See the License for the specific language governing permissions and
601
+ * limitations under the License.
602
+ */
603
+
604
+ /**
605
+ * Generated bundle index. Do not edit.
606
+ */
607
+
608
+ exports.KeycloakAuthGuardService = KeycloakAuthGuardService;
609
+ exports.KeycloakModule = KeycloakModule;
610
+ exports.KeycloakOptionsService = KeycloakOptionsService;
611
+ exports.KeycloakUserService = KeycloakUserService;
612
+ exports.keycloakInitializer = keycloakInitializer;
613
+ exports.ɵa = CallbackComponent;
614
+ exports.ɵb = KeycloakRoutingModule;
615
+
616
+ Object.defineProperty(exports, '__esModule', { value: true });
617
+
618
+ })));
619
+ //# sourceMappingURL=valtimo-keycloak.umd.js.map