@multiplatform.one/keycloak 0.7.1 → 0.7.3

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 (125) hide show
  1. package/lib/@types/coreJsPure.d.d.mts +2 -0
  2. package/lib/@types/coreJsPure.d.d.ts +2 -0
  3. package/lib/@types/coreJsPure.d.js +1 -0
  4. package/lib/@types/coreJsPure.d.mjs +0 -0
  5. package/lib/@types/expoKeycloakAuth.d.d.mts +28 -0
  6. package/lib/@types/expoKeycloakAuth.d.d.ts +28 -0
  7. package/lib/@types/expoKeycloakAuth.d.js +1 -0
  8. package/lib/@types/expoKeycloakAuth.d.mjs +0 -0
  9. package/lib/Authenticated.d.mts +36 -0
  10. package/lib/Authenticated.d.ts +36 -0
  11. package/lib/Authenticated.js +19 -0
  12. package/lib/Authenticated.mjs +20 -0
  13. package/lib/authConfig.d.mts +37 -0
  14. package/lib/authConfig.d.ts +37 -0
  15. package/lib/authConfig.js +8 -0
  16. package/lib/authConfig.mjs +9 -0
  17. package/lib/chunk-2GUOEPFY.mjs +0 -0
  18. package/lib/chunk-3ZPHNEJL.js +11 -0
  19. package/lib/chunk-64PPU7Q3.mjs +13 -0
  20. package/lib/chunk-6NDWOV55.js +1 -0
  21. package/lib/chunk-7MTPH6XK.mjs +26 -0
  22. package/lib/chunk-A7UBOIAL.js +13 -0
  23. package/lib/chunk-AD6VPMID.mjs +20 -0
  24. package/lib/chunk-AOKVCTMY.mjs +76 -0
  25. package/lib/chunk-AYKQVWMR.mjs +0 -0
  26. package/lib/chunk-BJ2OPIMW.js +78 -0
  27. package/lib/chunk-BTCP7NB3.js +443 -0
  28. package/lib/chunk-C2FNSVJO.js +17 -0
  29. package/lib/chunk-DKRUDENY.mjs +265 -0
  30. package/lib/chunk-E2X33LSD.js +460 -0
  31. package/lib/chunk-FXGWERIA.js +161 -0
  32. package/lib/chunk-HDNHCVXT.js +33 -0
  33. package/lib/chunk-KLLABHIC.js +13 -0
  34. package/lib/chunk-KMAXXKJT.js +22 -0
  35. package/lib/chunk-L5HMOY4M.mjs +18 -0
  36. package/lib/chunk-NU2SJ3ST.mjs +84 -0
  37. package/lib/chunk-NWRANDZ6.js +98 -0
  38. package/lib/chunk-NXTVYIBR.mjs +11 -0
  39. package/lib/chunk-OYWAYMFN.js +17 -0
  40. package/lib/chunk-S237YNYQ.mjs +10 -0
  41. package/lib/chunk-SK4YK6KE.mjs +50 -0
  42. package/lib/chunk-UBCNCE73.js +56 -0
  43. package/lib/chunk-UBVYEZI3.js +1 -0
  44. package/lib/chunk-UOKDJT5L.mjs +16 -0
  45. package/lib/chunk-VLUTEDDM.mjs +41 -0
  46. package/lib/chunk-Y4XMF3R6.mjs +13 -0
  47. package/lib/chunk-YGNNHTFE.js +12 -0
  48. package/lib/chunk-ZVG3OFME.mjs +52 -0
  49. package/lib/hooks/index.d.mts +9 -0
  50. package/lib/hooks/index.d.ts +9 -0
  51. package/lib/hooks/index.js +23 -0
  52. package/lib/hooks/index.mjs +34 -0
  53. package/lib/hooks/useAuthConfig.d.mts +29 -0
  54. package/lib/hooks/useAuthConfig.d.ts +29 -0
  55. package/lib/hooks/useAuthConfig.js +8 -0
  56. package/lib/hooks/useAuthConfig.mjs +8 -0
  57. package/lib/hooks/useCurrentRouteName/index.d.mts +26 -0
  58. package/lib/hooks/useCurrentRouteName/index.d.ts +26 -0
  59. package/lib/hooks/useCurrentRouteName/index.js +7 -0
  60. package/lib/hooks/useCurrentRouteName/index.mjs +7 -0
  61. package/lib/hooks/useCurrentRouteName/index.native.d.mts +26 -0
  62. package/lib/hooks/useCurrentRouteName/index.native.d.ts +26 -0
  63. package/lib/hooks/useCurrentRouteName/index.native.js +14 -0
  64. package/lib/hooks/useCurrentRouteName/index.native.mjs +14 -0
  65. package/lib/hooks/useKeycloak/index.d.mts +70 -0
  66. package/lib/hooks/useKeycloak/index.d.ts +70 -0
  67. package/lib/hooks/useKeycloak/index.js +11 -0
  68. package/lib/hooks/useKeycloak/index.mjs +12 -0
  69. package/lib/hooks/useKeycloak/useKeycloak.d.mts +2 -0
  70. package/lib/hooks/useKeycloak/useKeycloak.d.ts +2 -0
  71. package/lib/hooks/useKeycloak/useKeycloak.js +10 -0
  72. package/lib/hooks/useKeycloak/useKeycloak.mjs +11 -0
  73. package/lib/hooks/useKeycloak/useKeycloak.native.d.mts +44 -0
  74. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +44 -0
  75. package/lib/hooks/useKeycloak/useKeycloak.native.js +80 -0
  76. package/lib/hooks/useKeycloak/useKeycloak.native.mjs +69 -0
  77. package/lib/hooks/useLogin.d.mts +26 -0
  78. package/lib/hooks/useLogin.d.ts +26 -0
  79. package/lib/hooks/useLogin.js +11 -0
  80. package/lib/hooks/useLogin.mjs +11 -0
  81. package/lib/hooks/useTokensFromQuery/index.d.mts +26 -0
  82. package/lib/hooks/useTokensFromQuery/index.d.ts +26 -0
  83. package/lib/hooks/useTokensFromQuery/index.js +7 -0
  84. package/lib/hooks/useTokensFromQuery/index.mjs +7 -0
  85. package/lib/hooks/useTokensFromQuery/index.native.d.mts +26 -0
  86. package/lib/hooks/useTokensFromQuery/index.native.d.ts +26 -0
  87. package/lib/hooks/useTokensFromQuery/index.native.js +10 -0
  88. package/lib/hooks/useTokensFromQuery/index.native.mjs +7 -0
  89. package/lib/hooks/useTokensFromState.d.mts +26 -0
  90. package/lib/hooks/useTokensFromState.d.ts +26 -0
  91. package/lib/hooks/useTokensFromState.js +9 -0
  92. package/lib/hooks/useTokensFromState.mjs +9 -0
  93. package/lib/index.d.mts +13 -0
  94. package/lib/index.d.ts +13 -0
  95. package/lib/index.js +15 -15
  96. package/lib/index.mjs +56 -0
  97. package/lib/provider/afterAuth.d.mts +32 -0
  98. package/lib/provider/afterAuth.d.ts +32 -0
  99. package/lib/provider/afterAuth.js +18 -0
  100. package/lib/provider/afterAuth.mjs +18 -0
  101. package/lib/provider/index.d.mts +42 -0
  102. package/lib/provider/index.d.ts +42 -0
  103. package/lib/provider/index.js +22 -0
  104. package/lib/provider/index.mjs +25 -0
  105. package/lib/provider/keycloakProvider.d.mts +45 -0
  106. package/lib/provider/keycloakProvider.d.ts +45 -0
  107. package/lib/provider/keycloakProvider.js +20 -0
  108. package/lib/provider/keycloakProvider.mjs +21 -0
  109. package/lib/provider/keycloakProvider.native.d.mts +32 -0
  110. package/lib/provider/keycloakProvider.native.d.ts +32 -0
  111. package/lib/provider/keycloakProvider.native.js +87 -0
  112. package/lib/provider/keycloakProvider.native.mjs +30 -0
  113. package/lib/state/index.d.mts +34 -0
  114. package/lib/state/index.d.ts +34 -0
  115. package/lib/state/index.js +7 -0
  116. package/lib/state/index.mjs +7 -0
  117. package/lib/types.d.mts +40 -0
  118. package/lib/types.d.ts +40 -0
  119. package/lib/types.js +8 -0
  120. package/lib/types.mjs +7 -0
  121. package/lib/util.d.mts +27 -0
  122. package/lib/util.d.ts +27 -0
  123. package/lib/util.js +8 -0
  124. package/lib/util.mjs +9 -0
  125. package/package.json +30 -30
@@ -0,0 +1,460 @@
1
+ "use strict";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_without_holes(arr) {
8
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
9
+ }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
+ try {
12
+ var info = gen[key](arg);
13
+ var value = info.value;
14
+ } catch (error) {
15
+ reject(error);
16
+ return;
17
+ }
18
+ if (info.done) {
19
+ resolve(value);
20
+ } else {
21
+ Promise.resolve(value).then(_next, _throw);
22
+ }
23
+ }
24
+ function _async_to_generator(fn) {
25
+ return function() {
26
+ var self = this, args = arguments;
27
+ return new Promise(function(resolve, reject) {
28
+ var gen = fn.apply(self, args);
29
+ function _next(value) {
30
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
31
+ }
32
+ function _throw(err) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
+ }
35
+ _next(undefined);
36
+ });
37
+ };
38
+ }
39
+ function _class_call_check(instance, Constructor) {
40
+ if (!(instance instanceof Constructor)) {
41
+ throw new TypeError("Cannot call a class as a function");
42
+ }
43
+ }
44
+ function _defineProperties(target, props) {
45
+ for(var i = 0; i < props.length; i++){
46
+ var descriptor = props[i];
47
+ descriptor.enumerable = descriptor.enumerable || false;
48
+ descriptor.configurable = true;
49
+ if ("value" in descriptor) descriptor.writable = true;
50
+ Object.defineProperty(target, descriptor.key, descriptor);
51
+ }
52
+ }
53
+ function _create_class(Constructor, protoProps, staticProps) {
54
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
55
+ if (staticProps) _defineProperties(Constructor, staticProps);
56
+ return Constructor;
57
+ }
58
+ function _iterable_to_array(iter) {
59
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
60
+ }
61
+ function _non_iterable_spread() {
62
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
63
+ }
64
+ function _to_consumable_array(arr) {
65
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
66
+ }
67
+ function _unsupported_iterable_to_array(o, minLen) {
68
+ if (!o) return;
69
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
70
+ var n = Object.prototype.toString.call(o).slice(8, -1);
71
+ if (n === "Object" && o.constructor) n = o.constructor.name;
72
+ if (n === "Map" || n === "Set") return Array.from(n);
73
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
74
+ }
75
+ function _ts_generator(thisArg, body) {
76
+ var f, y, t, g, _ = {
77
+ label: 0,
78
+ sent: function() {
79
+ if (t[0] & 1) throw t[1];
80
+ return t[1];
81
+ },
82
+ trys: [],
83
+ ops: []
84
+ };
85
+ return g = {
86
+ next: verb(0),
87
+ "throw": verb(1),
88
+ "return": verb(2)
89
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
90
+ return this;
91
+ }), g;
92
+ function verb(n) {
93
+ return function(v) {
94
+ return step([
95
+ n,
96
+ v
97
+ ]);
98
+ };
99
+ }
100
+ function step(op) {
101
+ if (f) throw new TypeError("Generator is already executing.");
102
+ while(_)try {
103
+ 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) return t;
104
+ if (y = 0, t) op = [
105
+ op[0] & 2,
106
+ t.value
107
+ ];
108
+ switch(op[0]){
109
+ case 0:
110
+ case 1:
111
+ t = op;
112
+ break;
113
+ case 4:
114
+ _.label++;
115
+ return {
116
+ value: op[1],
117
+ done: false
118
+ };
119
+ case 5:
120
+ _.label++;
121
+ y = op[1];
122
+ op = [
123
+ 0
124
+ ];
125
+ continue;
126
+ case 7:
127
+ op = _.ops.pop();
128
+ _.trys.pop();
129
+ continue;
130
+ default:
131
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
132
+ _ = 0;
133
+ continue;
134
+ }
135
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
136
+ _.label = op[1];
137
+ break;
138
+ }
139
+ if (op[0] === 6 && _.label < t[1]) {
140
+ _.label = t[1];
141
+ t = op;
142
+ break;
143
+ }
144
+ if (t && _.label < t[2]) {
145
+ _.label = t[2];
146
+ _.ops.push(op);
147
+ break;
148
+ }
149
+ if (t[2]) _.ops.pop();
150
+ _.trys.pop();
151
+ continue;
152
+ }
153
+ op = body.call(thisArg, _);
154
+ } catch (e) {
155
+ op = [
156
+ 6,
157
+ e
158
+ ];
159
+ y = 0;
160
+ } finally{
161
+ f = t = 0;
162
+ }
163
+ if (op[0] & 5) throw op[1];
164
+ return {
165
+ value: op[0] ? op[1] : void 0,
166
+ done: true
167
+ };
168
+ }
169
+ }
170
+ Object.defineProperty(exports, "__esModule", {
171
+ value: true
172
+ });
173
+ function _optionalChain(ops) {
174
+ var lastAccessLHS = undefined;
175
+ var value = ops[0];
176
+ var i = 1;
177
+ while(i < ops.length){
178
+ var op = ops[i];
179
+ var fn = ops[i + 1];
180
+ i += 2;
181
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
182
+ return undefined;
183
+ }
184
+ if (op === "access" || op === "optionalAccess") {
185
+ lastAccessLHS = value;
186
+ value = fn(value);
187
+ } else if (op === "call" || op === "optionalCall") {
188
+ var _value;
189
+ value = fn(function() {
190
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
191
+ args[_key] = arguments[_key];
192
+ }
193
+ return (_value = value).call.apply(_value, [
194
+ lastAccessLHS
195
+ ].concat(_to_consumable_array(args)));
196
+ });
197
+ lastAccessLHS = undefined;
198
+ }
199
+ }
200
+ return value;
201
+ }
202
+ var _chunk3ZPHNEJLjs = require("./chunk-3ZPHNEJL.js");
203
+ var _chunkKMAXXKJTjs = require("./chunk-KMAXXKJT.js");
204
+ // src/hooks/useKeycloak/useKeycloak.ts
205
+ var _multiplatformone = require("multiplatform.one");
206
+ var _reactkeycloakweb = require("@bitspur/react-keycloak-web");
207
+ var _reactkeycloakssr = require("@bitspur/react-keycloak-ssr");
208
+ function useKeycloak() {
209
+ var authConfig = _chunk3ZPHNEJLjs.useAuthConfig.call(void 0);
210
+ if (_multiplatformone.MultiPlatform.isStorybook) {
211
+ return new Keycloak({
212
+ email: "storybook@example.com",
213
+ login: /*#__PURE__*/ _async_to_generator(function() {
214
+ return _ts_generator(this, function(_state) {
215
+ return [
216
+ 2,
217
+ void 0
218
+ ];
219
+ });
220
+ }),
221
+ logout: /*#__PURE__*/ _async_to_generator(function() {
222
+ return _ts_generator(this, function(_state) {
223
+ return [
224
+ 2,
225
+ void 0
226
+ ];
227
+ });
228
+ }),
229
+ subject: "0",
230
+ username: "storybook"
231
+ }, true);
232
+ }
233
+ if (_multiplatformone.MultiPlatform.isNext && authConfig.ssr) {
234
+ var _reactkeycloakssr_useKeycloak_call = _reactkeycloakssr.useKeycloak.call(void 0), keycloak2 = _reactkeycloakssr_useKeycloak_call.keycloak, initialized2 = _reactkeycloakssr_useKeycloak_call.initialized;
235
+ return new Keycloak(keycloak2, initialized2);
236
+ }
237
+ var _reactkeycloakweb_useKeycloak_call = _reactkeycloakweb.useKeycloak.call(void 0), keycloak = _reactkeycloakweb_useKeycloak_call.keycloak, initialized = _reactkeycloakweb_useKeycloak_call.initialized;
238
+ return new Keycloak(keycloak, initialized);
239
+ }
240
+ var Keycloak = /*#__PURE__*/ function() {
241
+ function Keycloak(keycloak, initialized) {
242
+ _class_call_check(this, Keycloak);
243
+ this.keycloak = keycloak;
244
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "authenticated");
245
+ this.authenticated = initialized ? _optionalChain([
246
+ keycloak,
247
+ "optionalAccess",
248
+ function(_) {
249
+ return _.authenticated;
250
+ }
251
+ ]) : void 0;
252
+ }
253
+ _create_class(Keycloak, [
254
+ {
255
+ key: "idToken",
256
+ get: function get() {
257
+ return _optionalChain([
258
+ this,
259
+ "access",
260
+ function(_2) {
261
+ return _2.keycloak;
262
+ },
263
+ "optionalAccess",
264
+ function(_3) {
265
+ return _3.idToken;
266
+ }
267
+ ]);
268
+ }
269
+ },
270
+ {
271
+ key: "realmAccess",
272
+ get: function get() {
273
+ return _optionalChain([
274
+ this,
275
+ "access",
276
+ function(_4) {
277
+ return _4.keycloak;
278
+ },
279
+ "optionalAccess",
280
+ function(_5) {
281
+ return _5.realmAccess;
282
+ }
283
+ ]);
284
+ }
285
+ },
286
+ {
287
+ key: "refreshToken",
288
+ get: function get() {
289
+ return _optionalChain([
290
+ this,
291
+ "access",
292
+ function(_6) {
293
+ return _6.keycloak;
294
+ },
295
+ "optionalAccess",
296
+ function(_7) {
297
+ return _7.refreshToken;
298
+ }
299
+ ]);
300
+ }
301
+ },
302
+ {
303
+ key: "refreshTokenParsed",
304
+ get: function get() {
305
+ return _optionalChain([
306
+ this,
307
+ "access",
308
+ function(_8) {
309
+ return _8.keycloak;
310
+ },
311
+ "optionalAccess",
312
+ function(_9) {
313
+ return _9.refreshTokenParsed;
314
+ }
315
+ ]);
316
+ }
317
+ },
318
+ {
319
+ key: "resourceAccess",
320
+ get: function get() {
321
+ return _optionalChain([
322
+ this,
323
+ "access",
324
+ function(_10) {
325
+ return _10.keycloak;
326
+ },
327
+ "optionalAccess",
328
+ function(_11) {
329
+ return _11.resourceAccess;
330
+ }
331
+ ]);
332
+ }
333
+ },
334
+ {
335
+ key: "subject",
336
+ get: function get() {
337
+ return _optionalChain([
338
+ this,
339
+ "access",
340
+ function(_12) {
341
+ return _12.keycloak;
342
+ },
343
+ "optionalAccess",
344
+ function(_13) {
345
+ return _13.subject;
346
+ }
347
+ ]);
348
+ }
349
+ },
350
+ {
351
+ key: "token",
352
+ get: function get() {
353
+ return _optionalChain([
354
+ this,
355
+ "access",
356
+ function(_14) {
357
+ return _14.keycloak;
358
+ },
359
+ "optionalAccess",
360
+ function(_15) {
361
+ return _15.token;
362
+ }
363
+ ]);
364
+ }
365
+ },
366
+ {
367
+ key: "tokenParsed",
368
+ get: function get() {
369
+ return _optionalChain([
370
+ this,
371
+ "access",
372
+ function(_16) {
373
+ return _16.keycloak;
374
+ },
375
+ "optionalAccess",
376
+ function(_17) {
377
+ return _17.tokenParsed;
378
+ }
379
+ ]);
380
+ }
381
+ },
382
+ {
383
+ key: "email",
384
+ get: function get() {
385
+ return _optionalChain([
386
+ this,
387
+ "access",
388
+ function(_18) {
389
+ return _18.keycloak;
390
+ },
391
+ "optionalAccess",
392
+ function(_19) {
393
+ return _19.tokenParsed;
394
+ },
395
+ "optionalAccess",
396
+ function(_20) {
397
+ return _20.email;
398
+ }
399
+ ]);
400
+ }
401
+ },
402
+ {
403
+ key: "username",
404
+ get: function get() {
405
+ return _optionalChain([
406
+ this,
407
+ "access",
408
+ function(_21) {
409
+ return _21.keycloak;
410
+ },
411
+ "optionalAccess",
412
+ function(_22) {
413
+ return _22.tokenParsed;
414
+ },
415
+ "optionalAccess",
416
+ function(_23) {
417
+ return _23.preferred_username;
418
+ }
419
+ ]);
420
+ }
421
+ },
422
+ {
423
+ key: "login",
424
+ value: function login() {
425
+ var _this = this;
426
+ return _async_to_generator(function() {
427
+ return _ts_generator(this, function(_state) {
428
+ if (!_this.keycloak) return [
429
+ 2
430
+ ];
431
+ return [
432
+ 2,
433
+ _this.keycloak.login()
434
+ ];
435
+ });
436
+ })();
437
+ }
438
+ },
439
+ {
440
+ key: "logout",
441
+ value: function logout() {
442
+ var _this = this;
443
+ return _async_to_generator(function() {
444
+ return _ts_generator(this, function(_state) {
445
+ if (!_this.keycloak) return [
446
+ 2
447
+ ];
448
+ return [
449
+ 2,
450
+ _this.keycloak.logout()
451
+ ];
452
+ });
453
+ })();
454
+ }
455
+ }
456
+ ]);
457
+ return Keycloak;
458
+ }();
459
+ exports.useKeycloak = useKeycloak;
460
+ exports.Keycloak = Keycloak;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) {
4
+ Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ } else {
11
+ obj[key] = value;
12
+ }
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = arguments[i] != null ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if (typeof Object.getOwnPropertySymbols === "function") {
20
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
21
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
22
+ }));
23
+ }
24
+ ownKeys.forEach(function(key) {
25
+ _define_property(target, key, source[key]);
26
+ });
27
+ }
28
+ return target;
29
+ }
30
+ function ownKeys(object, enumerableOnly) {
31
+ var keys = Object.keys(object);
32
+ if (Object.getOwnPropertySymbols) {
33
+ var symbols = Object.getOwnPropertySymbols(object);
34
+ if (enumerableOnly) {
35
+ symbols = symbols.filter(function(sym) {
36
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
37
+ });
38
+ }
39
+ keys.push.apply(keys, symbols);
40
+ }
41
+ return keys;
42
+ }
43
+ function _object_spread_props(target, source) {
44
+ source = source != null ? source : {};
45
+ if (Object.getOwnPropertyDescriptors) {
46
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
47
+ } else {
48
+ ownKeys(Object(source)).forEach(function(key) {
49
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
50
+ });
51
+ }
52
+ return target;
53
+ }
54
+ function _object_without_properties(source, excluded) {
55
+ if (source == null) return {};
56
+ var target = _object_without_properties_loose(source, excluded);
57
+ var key, i;
58
+ if (Object.getOwnPropertySymbols) {
59
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
60
+ for(i = 0; i < sourceSymbolKeys.length; i++){
61
+ key = sourceSymbolKeys[i];
62
+ if (excluded.indexOf(key) >= 0) continue;
63
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
64
+ target[key] = source[key];
65
+ }
66
+ }
67
+ return target;
68
+ }
69
+ function _object_without_properties_loose(source, excluded) {
70
+ if (source == null) return {};
71
+ var target = {};
72
+ var sourceKeys = Object.keys(source);
73
+ var key, i;
74
+ for(i = 0; i < sourceKeys.length; i++){
75
+ key = sourceKeys[i];
76
+ if (excluded.indexOf(key) >= 0) continue;
77
+ target[key] = source[key];
78
+ }
79
+ return target;
80
+ }
81
+ Object.defineProperty(exports, "__esModule", {
82
+ value: true
83
+ });
84
+ function _interopRequireDefault(obj) {
85
+ return obj && obj.__esModule ? obj : {
86
+ default: obj
87
+ };
88
+ }
89
+ var _chunkBTCP7NB3js = require("./chunk-BTCP7NB3.js");
90
+ var _chunkKLLABHICjs = require("./chunk-KLLABHIC.js");
91
+ var _chunkYGNNHTFEjs = require("./chunk-YGNNHTFE.js");
92
+ var _chunkA7UBOIALjs = require("./chunk-A7UBOIAL.js");
93
+ // src/provider/index.tsx
94
+ var _react = require("react");
95
+ var _react2 = _interopRequireDefault(_react);
96
+ var _config = require("app/config");
97
+ var persist = _config.config.get("KEYCLOAK_PERSIST") === "1";
98
+ var AuthProvider = function(_param) {
99
+ var // keycloak config
100
+ realm = _param.realm, clientId = _param.clientId, baseUrl = _param.baseUrl, // auth config
101
+ debug = _param.debug, ensureFreshness = _param.ensureFreshness, loginRoute = _param.loginRoute, messageHandlerKeys = _param.messageHandlerKeys, ssr = _param.ssr, // props
102
+ children = _param.children, cookies = _param.cookies, disabled = _param.disabled, loadingComponent = _param.loadingComponent, onEvent = _param.onEvent, onTokens = _param.onTokens, keycloakInitOptions = _object_without_properties(_param, [
103
+ "realm",
104
+ "clientId",
105
+ "baseUrl",
106
+ "debug",
107
+ "ensureFreshness",
108
+ "loginRoute",
109
+ "messageHandlerKeys",
110
+ "ssr",
111
+ "children",
112
+ "cookies",
113
+ "disabled",
114
+ "loadingComponent",
115
+ "onEvent",
116
+ "onTokens"
117
+ ]);
118
+ var tokensFromQuery = _chunkKLLABHICjs.useTokensFromQuery.call(void 0);
119
+ var tokensFromState = _chunkYGNNHTFEjs.useTokensFromState.call(void 0);
120
+ var authConfig = _react.useMemo.call(void 0, function() {
121
+ return _object_spread_props(_object_spread({}, _chunkA7UBOIALjs.defaultAuthConfig, typeof debug !== "undefined" ? {
122
+ debug: debug
123
+ } : {}, typeof ensureFreshness !== "undefined" ? {
124
+ ensureFreshness: ensureFreshness
125
+ } : {}, typeof loginRoute !== "undefined" ? {
126
+ loginRoute: loginRoute
127
+ } : {}, typeof messageHandlerKeys !== "undefined" ? {
128
+ messageHandlerKeys: messageHandlerKeys
129
+ } : {}), {
130
+ persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : _chunkA7UBOIALjs.defaultAuthConfig.persist,
131
+ ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : _chunkA7UBOIALjs.defaultAuthConfig.ssr : false
132
+ });
133
+ }, [
134
+ debug,
135
+ ensureFreshness,
136
+ loginRoute,
137
+ messageHandlerKeys,
138
+ persist,
139
+ ssr
140
+ ]);
141
+ if (disabled) {
142
+ return /* @__PURE__ */ _react2.default.createElement(_chunkA7UBOIALjs.AuthConfigContext.Provider, {
143
+ value: authConfig
144
+ }, children);
145
+ }
146
+ return /* @__PURE__ */ _react2.default.createElement(_chunkA7UBOIALjs.AuthConfigContext.Provider, {
147
+ value: authConfig
148
+ }, /* @__PURE__ */ _react2.default.createElement(_chunkBTCP7NB3js.KeycloakProvider, {
149
+ cookies: cookies,
150
+ keycloakConfig: {
151
+ realm: realm || "main",
152
+ clientId: clientId || "app",
153
+ url: baseUrl
154
+ },
155
+ keycloakInitOptions: keycloakInitOptions,
156
+ loadingComponent: loadingComponent,
157
+ onEvent: onEvent,
158
+ onTokens: onTokens
159
+ }, children));
160
+ };
161
+ exports.AuthProvider = AuthProvider;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkOYWAYMFNjs = require("./chunk-OYWAYMFN.js");
6
+ var _chunkE2X33LSDjs = require("./chunk-E2X33LSD.js");
7
+ var _chunk3ZPHNEJLjs = require("./chunk-3ZPHNEJL.js");
8
+ // src/hooks/useLogin.ts
9
+ var _multiplatformone = require("multiplatform.one");
10
+ var _router = require("solito/router");
11
+ function useLogin(loginRoute) {
12
+ if (_multiplatformone.MultiPlatform.isStorybook) return function() {
13
+ return null;
14
+ };
15
+ var keycloak = _chunkE2X33LSDjs.useKeycloak.call(void 0);
16
+ var authConfig = _chunk3ZPHNEJLjs.useAuthConfig.call(void 0);
17
+ var currentRouteName = _chunkOYWAYMFNjs.useCurrentRouteName.call(void 0);
18
+ var router = _router.useRouter.call(void 0);
19
+ return function() {
20
+ if (!loginRoute) loginRoute = authConfig.loginRoute;
21
+ if (!loginRoute) {
22
+ keycloak.login();
23
+ return;
24
+ }
25
+ var url = new URL("x://".concat(loginRoute));
26
+ var searchParams = new URLSearchParams(url.search);
27
+ if (currentRouteName) searchParams.append("backTo", currentRouteName);
28
+ var query = searchParams.toString();
29
+ if (query.length) query = "?".concat(query);
30
+ router.push("".concat(url.pathname.substring(2)).concat(query));
31
+ };
32
+ }
33
+ exports.useLogin = useLogin;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ }); // src/hooks/useTokensFromQuery/index.ts
5
+ var _multiplatformone = require("multiplatform.one");
6
+ var _router = require("next/router");
7
+ function useTokensFromQuery() {
8
+ var query = (_multiplatformone.MultiPlatform.isNext ? _router.useRouter.call(void 0) : {
9
+ query: {}
10
+ }).query;
11
+ return "idToken" in query || "token" in query || "refreshToken" in query;
12
+ }
13
+ exports.useTokensFromQuery = useTokensFromQuery;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ function _type_of(obj) {
3
+ "@swc/helpers - typeof";
4
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5
+ }
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ var __defProp = Object.defineProperty;
10
+ var __defNormalProp = function(obj, key, value) {
11
+ return key in obj ? __defProp(obj, key, {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: value
16
+ }) : obj[key] = value;
17
+ };
18
+ var __publicField = function(obj, key, value) {
19
+ __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
20
+ return value;
21
+ };
22
+ exports.__publicField = __publicField;