@multiplatform.one/keycloak 0.3.31 → 0.3.33

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/hooks/useKeycloak/index.ts"],
4
- "sourcesContent": ["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 31-05-2023 12:41:37\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport * from \"./useKeycloak.mjs\";\nexport {};"],
4
+ "sourcesContent": ["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 01-06-2023 13:55:42\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport * from \"./useKeycloak.mjs\";\nexport {};"],
5
5
  "mappings": "AAuBA,cAAc;",
6
6
  "names": []
7
7
  }
@@ -6,35 +6,28 @@ function _typeof(obj) {
6
6
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
7
7
  }, _typeof(obj);
8
8
  }
9
- function ownKeys(object, enumerableOnly) {
10
- var keys = Object.keys(object);
11
- if (Object.getOwnPropertySymbols) {
12
- var symbols = Object.getOwnPropertySymbols(object);
13
- enumerableOnly && (symbols = symbols.filter(function(sym) {
14
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
15
- })), keys.push.apply(keys, symbols);
16
- }
17
- return keys;
18
- }
19
- function _objectSpread(target) {
20
- for (var i = 1; i < arguments.length; i++) {
21
- var source = null != arguments[i] ? arguments[i] : {};
22
- i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
23
- _defineProperty(target, key, source[key]);
24
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
25
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
26
- });
9
+ function _classCallCheck(instance, Constructor) {
10
+ if (!(instance instanceof Constructor)) {
11
+ throw new TypeError("Cannot call a class as a function");
27
12
  }
28
- return target;
29
13
  }
30
- function _defineProperty(obj, key, value) {
31
- key = _toPropertyKey(key);
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
34
- } else {
35
- obj[key] = value;
14
+ function _defineProperties(target, props) {
15
+ for (var i = 0; i < props.length; i++) {
16
+ var descriptor = props[i];
17
+ descriptor.enumerable = descriptor.enumerable || false;
18
+ descriptor.configurable = true;
19
+ if ("value" in descriptor)
20
+ descriptor.writable = true;
21
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
36
22
  }
37
- return obj;
23
+ }
24
+ function _createClass(Constructor, protoProps, staticProps) {
25
+ if (protoProps)
26
+ _defineProperties(Constructor.prototype, protoProps);
27
+ if (staticProps)
28
+ _defineProperties(Constructor, staticProps);
29
+ Object.defineProperty(Constructor, "prototype", { writable: false });
30
+ return Constructor;
38
31
  }
39
32
  function _toPropertyKey(arg) {
40
33
  var key = _toPrimitive(arg, "string");
@@ -52,40 +45,483 @@ function _toPrimitive(input, hint) {
52
45
  }
53
46
  return (hint === "string" ? String : Number)(input);
54
47
  }
48
+ function _regeneratorRuntime() {
49
+ "use strict";
50
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
51
+ _regeneratorRuntime = function _regeneratorRuntime2() {
52
+ return exports;
53
+ };
54
+ var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function(obj, key, desc) {
55
+ obj[key] = desc.value;
56
+ }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
57
+ function define(obj, key, value) {
58
+ return Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }), obj[key];
59
+ }
60
+ try {
61
+ define({}, "");
62
+ } catch (err) {
63
+ define = function define2(obj, key, value) {
64
+ return obj[key] = value;
65
+ };
66
+ }
67
+ function wrap(innerFn, outerFn, self, tryLocsList) {
68
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
69
+ return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator;
70
+ }
71
+ function tryCatch(fn, obj, arg) {
72
+ try {
73
+ return { type: "normal", arg: fn.call(obj, arg) };
74
+ } catch (err) {
75
+ return { type: "throw", arg: err };
76
+ }
77
+ }
78
+ exports.wrap = wrap;
79
+ var ContinueSentinel = {};
80
+ function Generator() {
81
+ }
82
+ function GeneratorFunction() {
83
+ }
84
+ function GeneratorFunctionPrototype() {
85
+ }
86
+ var IteratorPrototype = {};
87
+ define(IteratorPrototype, iteratorSymbol, function() {
88
+ return this;
89
+ });
90
+ var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
91
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
92
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
93
+ function defineIteratorMethods(prototype) {
94
+ ["next", "throw", "return"].forEach(function(method) {
95
+ define(prototype, method, function(arg) {
96
+ return this._invoke(method, arg);
97
+ });
98
+ });
99
+ }
100
+ function AsyncIterator(generator, PromiseImpl) {
101
+ function invoke(method, arg, resolve, reject) {
102
+ var record = tryCatch(generator[method], generator, arg);
103
+ if ("throw" !== record.type) {
104
+ var result = record.arg, value = result.value;
105
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value2) {
106
+ invoke("next", value2, resolve, reject);
107
+ }, function(err) {
108
+ invoke("throw", err, resolve, reject);
109
+ }) : PromiseImpl.resolve(value).then(function(unwrapped) {
110
+ result.value = unwrapped, resolve(result);
111
+ }, function(error) {
112
+ return invoke("throw", error, resolve, reject);
113
+ });
114
+ }
115
+ reject(record.arg);
116
+ }
117
+ var previousPromise;
118
+ defineProperty(this, "_invoke", { value: function value(method, arg) {
119
+ function callInvokeWithMethodAndArg() {
120
+ return new PromiseImpl(function(resolve, reject) {
121
+ invoke(method, arg, resolve, reject);
122
+ });
123
+ }
124
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
125
+ } });
126
+ }
127
+ function makeInvokeMethod(innerFn, self, context) {
128
+ var state = "suspendedStart";
129
+ return function(method, arg) {
130
+ if ("executing" === state)
131
+ throw new Error("Generator is already running");
132
+ if ("completed" === state) {
133
+ if ("throw" === method)
134
+ throw arg;
135
+ return doneResult();
136
+ }
137
+ for (context.method = method, context.arg = arg; ; ) {
138
+ var delegate = context.delegate;
139
+ if (delegate) {
140
+ var delegateResult = maybeInvokeDelegate(delegate, context);
141
+ if (delegateResult) {
142
+ if (delegateResult === ContinueSentinel)
143
+ continue;
144
+ return delegateResult;
145
+ }
146
+ }
147
+ if ("next" === context.method)
148
+ context.sent = context._sent = context.arg;
149
+ else if ("throw" === context.method) {
150
+ if ("suspendedStart" === state)
151
+ throw state = "completed", context.arg;
152
+ context.dispatchException(context.arg);
153
+ } else
154
+ "return" === context.method && context.abrupt("return", context.arg);
155
+ state = "executing";
156
+ var record = tryCatch(innerFn, self, context);
157
+ if ("normal" === record.type) {
158
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel)
159
+ continue;
160
+ return { value: record.arg, done: context.done };
161
+ }
162
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
163
+ }
164
+ };
165
+ }
166
+ function maybeInvokeDelegate(delegate, context) {
167
+ var methodName = context.method, method = delegate.iterator[methodName];
168
+ if (void 0 === method)
169
+ return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = void 0, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
170
+ var record = tryCatch(method, delegate.iterator, context.arg);
171
+ if ("throw" === record.type)
172
+ return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
173
+ var info = record.arg;
174
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = void 0), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
175
+ }
176
+ function pushTryEntry(locs) {
177
+ var entry = { tryLoc: locs[0] };
178
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
179
+ }
180
+ function resetTryEntry(entry) {
181
+ var record = entry.completion || {};
182
+ record.type = "normal", delete record.arg, entry.completion = record;
183
+ }
184
+ function Context(tryLocsList) {
185
+ this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(true);
186
+ }
187
+ function values(iterable) {
188
+ if (iterable) {
189
+ var iteratorMethod = iterable[iteratorSymbol];
190
+ if (iteratorMethod)
191
+ return iteratorMethod.call(iterable);
192
+ if ("function" == typeof iterable.next)
193
+ return iterable;
194
+ if (!isNaN(iterable.length)) {
195
+ var i = -1, next = function next2() {
196
+ for (; ++i < iterable.length; )
197
+ if (hasOwn.call(iterable, i))
198
+ return next2.value = iterable[i], next2.done = false, next2;
199
+ return next2.value = void 0, next2.done = true, next2;
200
+ };
201
+ return next.next = next;
202
+ }
203
+ }
204
+ return { next: doneResult };
205
+ }
206
+ function doneResult() {
207
+ return { value: void 0, done: true };
208
+ }
209
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function(genFun) {
210
+ var ctor = "function" == typeof genFun && genFun.constructor;
211
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
212
+ }, exports.mark = function(genFun) {
213
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
214
+ }, exports.awrap = function(arg) {
215
+ return { __await: arg };
216
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
217
+ return this;
218
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
219
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
220
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
221
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
222
+ return result.done ? result.value : iter.next();
223
+ });
224
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
225
+ return this;
226
+ }), define(Gp, "toString", function() {
227
+ return "[object Generator]";
228
+ }), exports.keys = function(val) {
229
+ var object = Object(val), keys = [];
230
+ for (var key in object)
231
+ keys.push(key);
232
+ return keys.reverse(), function next() {
233
+ for (; keys.length; ) {
234
+ var key2 = keys.pop();
235
+ if (key2 in object)
236
+ return next.value = key2, next.done = false, next;
237
+ }
238
+ return next.done = true, next;
239
+ };
240
+ }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) {
241
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = false, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(resetTryEntry), !skipTempReset)
242
+ for (var name in this)
243
+ "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = void 0);
244
+ }, stop: function stop() {
245
+ this.done = true;
246
+ var rootRecord = this.tryEntries[0].completion;
247
+ if ("throw" === rootRecord.type)
248
+ throw rootRecord.arg;
249
+ return this.rval;
250
+ }, dispatchException: function dispatchException(exception) {
251
+ if (this.done)
252
+ throw exception;
253
+ var context = this;
254
+ function handle(loc, caught) {
255
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = void 0), !!caught;
256
+ }
257
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
258
+ var entry = this.tryEntries[i], record = entry.completion;
259
+ if ("root" === entry.tryLoc)
260
+ return handle("end");
261
+ if (entry.tryLoc <= this.prev) {
262
+ var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
263
+ if (hasCatch && hasFinally) {
264
+ if (this.prev < entry.catchLoc)
265
+ return handle(entry.catchLoc, true);
266
+ if (this.prev < entry.finallyLoc)
267
+ return handle(entry.finallyLoc);
268
+ } else if (hasCatch) {
269
+ if (this.prev < entry.catchLoc)
270
+ return handle(entry.catchLoc, true);
271
+ } else {
272
+ if (!hasFinally)
273
+ throw new Error("try statement without catch or finally");
274
+ if (this.prev < entry.finallyLoc)
275
+ return handle(entry.finallyLoc);
276
+ }
277
+ }
278
+ }
279
+ }, abrupt: function abrupt(type, arg) {
280
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
281
+ var entry = this.tryEntries[i];
282
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
283
+ var finallyEntry = entry;
284
+ break;
285
+ }
286
+ }
287
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
288
+ var record = finallyEntry ? finallyEntry.completion : {};
289
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
290
+ }, complete: function complete(record, afterLoc) {
291
+ if ("throw" === record.type)
292
+ throw record.arg;
293
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
294
+ }, finish: function finish(finallyLoc) {
295
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
296
+ var entry = this.tryEntries[i];
297
+ if (entry.finallyLoc === finallyLoc)
298
+ return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
299
+ }
300
+ }, "catch": function _catch(tryLoc) {
301
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
302
+ var entry = this.tryEntries[i];
303
+ if (entry.tryLoc === tryLoc) {
304
+ var record = entry.completion;
305
+ if ("throw" === record.type) {
306
+ var thrown = record.arg;
307
+ resetTryEntry(entry);
308
+ }
309
+ return thrown;
310
+ }
311
+ }
312
+ throw new Error("illegal catch attempt");
313
+ }, delegateYield: function delegateYield(iterable, resultName, nextLoc) {
314
+ return this.delegate = { iterator: values(iterable), resultName, nextLoc }, "next" === this.method && (this.arg = void 0), ContinueSentinel;
315
+ } }, exports;
316
+ }
317
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
318
+ try {
319
+ var info = gen[key](arg);
320
+ var value = info.value;
321
+ } catch (error) {
322
+ reject(error);
323
+ return;
324
+ }
325
+ if (info.done) {
326
+ resolve(value);
327
+ } else {
328
+ Promise.resolve(value).then(_next, _throw);
329
+ }
330
+ }
331
+ function _asyncToGenerator(fn) {
332
+ return function() {
333
+ var self = this, args = arguments;
334
+ return new Promise(function(resolve, reject) {
335
+ var gen = fn.apply(self, args);
336
+ function _next(value) {
337
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
338
+ }
339
+ function _throw(err) {
340
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
341
+ }
342
+ _next(void 0);
343
+ });
344
+ };
345
+ }
55
346
  import { MultiPlatform } from "multiplatform.one";
56
347
  import { useAuthConfig } from "../useAuthConfig.mjs";
57
348
  import { useKeycloak as useReactKeycloak } from "@bitspur/react-keycloak-web";
58
349
  import { useKeycloak as useSsrKeycloak } from "@bitspur/react-keycloak-ssr";
59
350
  function useKeycloak() {
60
- var _keycloak$tokenParsed4, _keycloak$tokenParsed5, _keycloak$tokenParsed6;
61
351
  var authConfig = useAuthConfig();
62
352
  if (MultiPlatform.isStorybook) {
63
- return {
64
- authenticated: true,
65
- username: "storybook",
353
+ return new Keycloak({
66
354
  email: "storybook@example.com",
67
- userId: "0"
68
- };
355
+ login: function() {
356
+ var _login = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
357
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
358
+ while (1)
359
+ switch (_context.prev = _context.next) {
360
+ case 0:
361
+ return _context.abrupt("return", void 0);
362
+ case 1:
363
+ case "end":
364
+ return _context.stop();
365
+ }
366
+ }, _callee);
367
+ }));
368
+ function login() {
369
+ return _login.apply(this, arguments);
370
+ }
371
+ return login;
372
+ }(),
373
+ logout: function() {
374
+ var _logout = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2() {
375
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
376
+ while (1)
377
+ switch (_context2.prev = _context2.next) {
378
+ case 0:
379
+ return _context2.abrupt("return", void 0);
380
+ case 1:
381
+ case "end":
382
+ return _context2.stop();
383
+ }
384
+ }, _callee2);
385
+ }));
386
+ function logout() {
387
+ return _logout.apply(this, arguments);
388
+ }
389
+ return logout;
390
+ }(),
391
+ subject: "0",
392
+ username: "storybook"
393
+ }, true);
69
394
  }
70
395
  if (MultiPlatform.isNext && authConfig.ssr) {
71
- var _keycloak$tokenParsed, _keycloak$tokenParsed2, _keycloak$tokenParsed3;
72
396
  var _useSsrKeycloak = useSsrKeycloak(), _keycloak = _useSsrKeycloak.keycloak, _initialized = _useSsrKeycloak.initialized;
73
- return _objectSpread(_objectSpread({}, _keycloak), {}, {
74
- authenticated: _initialized ? _keycloak === null || _keycloak === void 0 ? void 0 : _keycloak.authenticated : void 0,
75
- email: _keycloak === null || _keycloak === void 0 ? void 0 : (_keycloak$tokenParsed = _keycloak.tokenParsed) === null || _keycloak$tokenParsed === void 0 ? void 0 : _keycloak$tokenParsed.email,
76
- userId: _keycloak === null || _keycloak === void 0 ? void 0 : (_keycloak$tokenParsed2 = _keycloak.tokenParsed) === null || _keycloak$tokenParsed2 === void 0 ? void 0 : _keycloak$tokenParsed2.sub,
77
- username: _keycloak === null || _keycloak === void 0 ? void 0 : (_keycloak$tokenParsed3 = _keycloak.tokenParsed) === null || _keycloak$tokenParsed3 === void 0 ? void 0 : _keycloak$tokenParsed3.preferred_username
78
- });
397
+ return new Keycloak(_keycloak, _initialized);
79
398
  }
80
399
  var _useReactKeycloak = useReactKeycloak(), keycloak = _useReactKeycloak.keycloak, initialized = _useReactKeycloak.initialized;
81
- return _objectSpread(_objectSpread({}, keycloak), {}, {
82
- authenticated: initialized ? keycloak === null || keycloak === void 0 ? void 0 : keycloak.authenticated : void 0,
83
- email: keycloak === null || keycloak === void 0 ? void 0 : (_keycloak$tokenParsed4 = keycloak.tokenParsed) === null || _keycloak$tokenParsed4 === void 0 ? void 0 : _keycloak$tokenParsed4.email,
84
- userId: keycloak === null || keycloak === void 0 ? void 0 : (_keycloak$tokenParsed5 = keycloak.tokenParsed) === null || _keycloak$tokenParsed5 === void 0 ? void 0 : _keycloak$tokenParsed5.sub,
85
- username: keycloak === null || keycloak === void 0 ? void 0 : (_keycloak$tokenParsed6 = keycloak.tokenParsed) === null || _keycloak$tokenParsed6 === void 0 ? void 0 : _keycloak$tokenParsed6.preferred_username
86
- });
400
+ return new Keycloak(keycloak, initialized);
87
401
  }
402
+ var Keycloak = /* @__PURE__ */ function() {
403
+ function Keycloak2(keycloak, initialized) {
404
+ _classCallCheck(this, Keycloak2);
405
+ this.keycloak = keycloak;
406
+ this.authenticated = initialized ? keycloak === null || keycloak === void 0 ? void 0 : keycloak.authenticated : void 0;
407
+ }
408
+ _createClass(Keycloak2, [{
409
+ key: "idToken",
410
+ get: function get() {
411
+ var _this$keycloak;
412
+ return (_this$keycloak = this.keycloak) === null || _this$keycloak === void 0 ? void 0 : _this$keycloak.idToken;
413
+ }
414
+ }, {
415
+ key: "realmAccess",
416
+ get: function get() {
417
+ var _this$keycloak2;
418
+ return (_this$keycloak2 = this.keycloak) === null || _this$keycloak2 === void 0 ? void 0 : _this$keycloak2.realmAccess;
419
+ }
420
+ }, {
421
+ key: "refreshToken",
422
+ get: function get() {
423
+ var _this$keycloak3;
424
+ return (_this$keycloak3 = this.keycloak) === null || _this$keycloak3 === void 0 ? void 0 : _this$keycloak3.refreshToken;
425
+ }
426
+ }, {
427
+ key: "refreshTokenParsed",
428
+ get: function get() {
429
+ var _this$keycloak4;
430
+ return (_this$keycloak4 = this.keycloak) === null || _this$keycloak4 === void 0 ? void 0 : _this$keycloak4.refreshTokenParsed;
431
+ }
432
+ }, {
433
+ key: "resourceAccess",
434
+ get: function get() {
435
+ var _this$keycloak5;
436
+ return (_this$keycloak5 = this.keycloak) === null || _this$keycloak5 === void 0 ? void 0 : _this$keycloak5.resourceAccess;
437
+ }
438
+ }, {
439
+ key: "subject",
440
+ get: function get() {
441
+ var _this$keycloak6;
442
+ return (_this$keycloak6 = this.keycloak) === null || _this$keycloak6 === void 0 ? void 0 : _this$keycloak6.subject;
443
+ }
444
+ }, {
445
+ key: "token",
446
+ get: function get() {
447
+ var _this$keycloak7;
448
+ return (_this$keycloak7 = this.keycloak) === null || _this$keycloak7 === void 0 ? void 0 : _this$keycloak7.token;
449
+ }
450
+ }, {
451
+ key: "tokenParsed",
452
+ get: function get() {
453
+ var _this$keycloak8;
454
+ return (_this$keycloak8 = this.keycloak) === null || _this$keycloak8 === void 0 ? void 0 : _this$keycloak8.tokenParsed;
455
+ }
456
+ }, {
457
+ key: "email",
458
+ get: function get() {
459
+ var _this$keycloak9, _this$keycloak9$token;
460
+ return (_this$keycloak9 = this.keycloak) === null || _this$keycloak9 === void 0 ? void 0 : (_this$keycloak9$token = _this$keycloak9.tokenParsed) === null || _this$keycloak9$token === void 0 ? void 0 : _this$keycloak9$token.email;
461
+ }
462
+ }, {
463
+ key: "username",
464
+ get: function get() {
465
+ var _this$keycloak10, _this$keycloak10$toke;
466
+ return (_this$keycloak10 = this.keycloak) === null || _this$keycloak10 === void 0 ? void 0 : (_this$keycloak10$toke = _this$keycloak10.tokenParsed) === null || _this$keycloak10$toke === void 0 ? void 0 : _this$keycloak10$toke.preferred_username;
467
+ }
468
+ }, {
469
+ key: "login",
470
+ value: function() {
471
+ var _login2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3() {
472
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
473
+ while (1)
474
+ switch (_context3.prev = _context3.next) {
475
+ case 0:
476
+ if (this.keycloak) {
477
+ _context3.next = 2;
478
+ break;
479
+ }
480
+ return _context3.abrupt("return");
481
+ case 2:
482
+ return _context3.abrupt("return", this.keycloak.login());
483
+ case 3:
484
+ case "end":
485
+ return _context3.stop();
486
+ }
487
+ }, _callee3, this);
488
+ }));
489
+ function login() {
490
+ return _login2.apply(this, arguments);
491
+ }
492
+ return login;
493
+ }()
494
+ }, {
495
+ key: "logout",
496
+ value: function() {
497
+ var _logout2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee4() {
498
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
499
+ while (1)
500
+ switch (_context4.prev = _context4.next) {
501
+ case 0:
502
+ if (this.keycloak) {
503
+ _context4.next = 2;
504
+ break;
505
+ }
506
+ return _context4.abrupt("return");
507
+ case 2:
508
+ return _context4.abrupt("return", this.keycloak.logout());
509
+ case 3:
510
+ case "end":
511
+ return _context4.stop();
512
+ }
513
+ }, _callee4, this);
514
+ }));
515
+ function logout() {
516
+ return _logout2.apply(this, arguments);
517
+ }
518
+ return logout;
519
+ }()
520
+ }]);
521
+ return Keycloak2;
522
+ }();
88
523
  export {
524
+ Keycloak,
89
525
  useKeycloak
90
526
  };
91
527
  //# sourceMappingURL=useKeycloak.mjs.map