@valtimo/keycloak 4.23.0 → 5.2.0

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