@multiplatform.one/keycloak 0.7.15 → 0.7.16

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 (155) hide show
  1. package/package.json +26 -26
  2. package/routes/index.d.ts +22 -0
  3. package/routes/index.js +22 -0
  4. package/src/Authenticated.tsx +27 -17
  5. package/src/authConfig.ts +3 -9
  6. package/src/hooks/index.ts +0 -3
  7. package/src/hooks/useTokensFromQuery/index.ts +1 -0
  8. package/src/hooks/useTokensFromState.ts +1 -1
  9. package/src/index.ts +3 -0
  10. package/src/{@types/coreJsPure.d.ts → keycloak/context.ts} +6 -11
  11. package/{lib/@types/expoKeycloakAuth.d.d.mts → src/keycloak/index.ts} +4 -7
  12. package/src/keycloak/keycloak.native.ts +148 -0
  13. package/src/keycloak/keycloak.ts +175 -0
  14. package/src/provider/AfterAuth.tsx +63 -0
  15. package/src/provider/{keycloakProvider.native.tsx → AuthProvider/AuthProvider.native.tsx} +8 -16
  16. package/src/provider/{keycloakProvider.tsx → AuthProvider/AuthProvider.tsx} +81 -94
  17. package/{lib/@types/expoKeycloakAuth.d.d.ts → src/provider/AuthProvider/index.ts} +4 -7
  18. package/src/provider/KeycloakProvider.tsx +53 -0
  19. package/src/{hooks/useCurrentRouteName/index.native.ts → provider/index.ts} +6 -11
  20. package/src/routes.ts +163 -0
  21. package/src/session/index.ts +22 -0
  22. package/src/session/session.native.ts +31 -0
  23. package/src/session/session.ts +68 -0
  24. package/src/{state/index.ts → state.ts} +5 -4
  25. package/src/{util.ts → token.ts} +25 -11
  26. package/src/types.ts +4 -1
  27. package/lib/@types/coreJsPure.d.d.mts +0 -2
  28. package/lib/@types/coreJsPure.d.d.ts +0 -2
  29. package/lib/@types/coreJsPure.d.js +0 -1
  30. package/lib/@types/coreJsPure.d.mjs +0 -0
  31. package/lib/@types/expoKeycloakAuth.d.js +0 -1
  32. package/lib/@types/expoKeycloakAuth.d.mjs +0 -0
  33. package/lib/Authenticated.d.mts +0 -33
  34. package/lib/Authenticated.d.ts +0 -33
  35. package/lib/Authenticated.js +0 -19
  36. package/lib/Authenticated.mjs +0 -20
  37. package/lib/authConfig.d.mts +0 -14
  38. package/lib/authConfig.d.ts +0 -14
  39. package/lib/authConfig.js +0 -8
  40. package/lib/authConfig.mjs +0 -9
  41. package/lib/chunk-2GUOEPFY.mjs +0 -0
  42. package/lib/chunk-3ZPHNEJL.js +0 -11
  43. package/lib/chunk-64PPU7Q3.mjs +0 -13
  44. package/lib/chunk-6NDWOV55.js +0 -1
  45. package/lib/chunk-7MTPH6XK.mjs +0 -26
  46. package/lib/chunk-A7UBOIAL.js +0 -13
  47. package/lib/chunk-AD6VPMID.mjs +0 -20
  48. package/lib/chunk-AUUZ6BI7.js +0 -78
  49. package/lib/chunk-AYKQVWMR.mjs +0 -0
  50. package/lib/chunk-BVB33X7V.mjs +0 -265
  51. package/lib/chunk-C2FNSVJO.js +0 -17
  52. package/lib/chunk-J4CCMILN.mjs +0 -41
  53. package/lib/chunk-K33RKJZX.js +0 -443
  54. package/lib/chunk-KLLABHIC.js +0 -13
  55. package/lib/chunk-L5HMOY4M.mjs +0 -18
  56. package/lib/chunk-MZ6E62HK.js +0 -33
  57. package/lib/chunk-NWRANDZ6.js +0 -98
  58. package/lib/chunk-NXTVYIBR.mjs +0 -11
  59. package/lib/chunk-OYWAYMFN.js +0 -17
  60. package/lib/chunk-RPUOO7AV.mjs +0 -10
  61. package/lib/chunk-RYM7KERK.mjs +0 -52
  62. package/lib/chunk-UBVYEZI3.js +0 -1
  63. package/lib/chunk-UHTKOFS6.mjs +0 -84
  64. package/lib/chunk-UL6L5ONI.js +0 -460
  65. package/lib/chunk-UOKDJT5L.mjs +0 -16
  66. package/lib/chunk-W5DJLFTQ.js +0 -56
  67. package/lib/chunk-WT5W6BSZ.js +0 -161
  68. package/lib/chunk-XEO3YXBM.js +0 -22
  69. package/lib/chunk-XO4W2SMN.mjs +0 -50
  70. package/lib/chunk-XVPWAAZ4.mjs +0 -76
  71. package/lib/chunk-Y4XMF3R6.mjs +0 -13
  72. package/lib/chunk-YGNNHTFE.js +0 -12
  73. package/lib/hooks/index.d.mts +0 -9
  74. package/lib/hooks/index.d.ts +0 -9
  75. package/lib/hooks/index.js +0 -23
  76. package/lib/hooks/index.mjs +0 -34
  77. package/lib/hooks/useAuthConfig.d.mts +0 -6
  78. package/lib/hooks/useAuthConfig.d.ts +0 -6
  79. package/lib/hooks/useAuthConfig.js +0 -8
  80. package/lib/hooks/useAuthConfig.mjs +0 -8
  81. package/lib/hooks/useCurrentRouteName/index.d.mts +0 -3
  82. package/lib/hooks/useCurrentRouteName/index.d.ts +0 -3
  83. package/lib/hooks/useCurrentRouteName/index.js +0 -7
  84. package/lib/hooks/useCurrentRouteName/index.mjs +0 -7
  85. package/lib/hooks/useCurrentRouteName/index.native.d.mts +0 -3
  86. package/lib/hooks/useCurrentRouteName/index.native.d.ts +0 -3
  87. package/lib/hooks/useCurrentRouteName/index.native.js +0 -14
  88. package/lib/hooks/useCurrentRouteName/index.native.mjs +0 -14
  89. package/lib/hooks/useKeycloak/index.d.mts +0 -46
  90. package/lib/hooks/useKeycloak/index.d.ts +0 -46
  91. package/lib/hooks/useKeycloak/index.js +0 -11
  92. package/lib/hooks/useKeycloak/index.mjs +0 -12
  93. package/lib/hooks/useKeycloak/useKeycloak.d.mts +0 -2
  94. package/lib/hooks/useKeycloak/useKeycloak.d.ts +0 -2
  95. package/lib/hooks/useKeycloak/useKeycloak.js +0 -10
  96. package/lib/hooks/useKeycloak/useKeycloak.mjs +0 -11
  97. package/lib/hooks/useKeycloak/useKeycloak.native.d.mts +0 -20
  98. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +0 -20
  99. package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -80
  100. package/lib/hooks/useKeycloak/useKeycloak.native.mjs +0 -69
  101. package/lib/hooks/useLogin.d.mts +0 -3
  102. package/lib/hooks/useLogin.d.ts +0 -3
  103. package/lib/hooks/useLogin.js +0 -11
  104. package/lib/hooks/useLogin.mjs +0 -11
  105. package/lib/hooks/useTokensFromQuery/index.d.mts +0 -3
  106. package/lib/hooks/useTokensFromQuery/index.d.ts +0 -3
  107. package/lib/hooks/useTokensFromQuery/index.js +0 -7
  108. package/lib/hooks/useTokensFromQuery/index.mjs +0 -7
  109. package/lib/hooks/useTokensFromQuery/index.native.d.mts +0 -3
  110. package/lib/hooks/useTokensFromQuery/index.native.d.ts +0 -3
  111. package/lib/hooks/useTokensFromQuery/index.native.js +0 -10
  112. package/lib/hooks/useTokensFromQuery/index.native.mjs +0 -7
  113. package/lib/hooks/useTokensFromState.d.mts +0 -3
  114. package/lib/hooks/useTokensFromState.d.ts +0 -3
  115. package/lib/hooks/useTokensFromState.js +0 -9
  116. package/lib/hooks/useTokensFromState.mjs +0 -9
  117. package/lib/index.d.mts +0 -13
  118. package/lib/index.d.ts +0 -13
  119. package/lib/index.js +0 -34
  120. package/lib/index.mjs +0 -56
  121. package/lib/provider/afterAuth.d.mts +0 -29
  122. package/lib/provider/afterAuth.d.ts +0 -29
  123. package/lib/provider/afterAuth.js +0 -18
  124. package/lib/provider/afterAuth.mjs +0 -18
  125. package/lib/provider/index.d.mts +0 -39
  126. package/lib/provider/index.d.ts +0 -39
  127. package/lib/provider/index.js +0 -22
  128. package/lib/provider/index.mjs +0 -25
  129. package/lib/provider/keycloakProvider.d.mts +0 -42
  130. package/lib/provider/keycloakProvider.d.ts +0 -42
  131. package/lib/provider/keycloakProvider.js +0 -20
  132. package/lib/provider/keycloakProvider.mjs +0 -21
  133. package/lib/provider/keycloakProvider.native.d.mts +0 -29
  134. package/lib/provider/keycloakProvider.native.d.ts +0 -29
  135. package/lib/provider/keycloakProvider.native.js +0 -87
  136. package/lib/provider/keycloakProvider.native.mjs +0 -30
  137. package/lib/state/index.d.mts +0 -11
  138. package/lib/state/index.d.ts +0 -11
  139. package/lib/state/index.js +0 -7
  140. package/lib/state/index.mjs +0 -7
  141. package/lib/types.d.mts +0 -17
  142. package/lib/types.d.ts +0 -17
  143. package/lib/types.js +0 -8
  144. package/lib/types.mjs +0 -7
  145. package/lib/util.d.mts +0 -4
  146. package/lib/util.d.ts +0 -4
  147. package/lib/util.js +0 -8
  148. package/lib/util.mjs +0 -9
  149. package/src/hooks/useCurrentRouteName/index.ts +0 -34
  150. package/src/hooks/useKeycloak/index.ts +0 -47
  151. package/src/hooks/useKeycloak/useKeycloak.native.ts +0 -95
  152. package/src/hooks/useKeycloak/useKeycloak.ts +0 -106
  153. package/src/hooks/useLogin.ts +0 -47
  154. package/src/provider/afterAuth.tsx +0 -65
  155. package/src/provider/index.tsx +0 -117
@@ -1,52 +0,0 @@
1
- import {
2
- useTokensFromQuery
3
- } from "./chunk-NXTVYIBR.mjs";
4
- import {
5
- useLogin
6
- } from "./chunk-J4CCMILN.mjs";
7
- import {
8
- useKeycloak
9
- } from "./chunk-UHTKOFS6.mjs";
10
- import {
11
- useAuthConfig
12
- } from "./chunk-Y4XMF3R6.mjs";
13
- import {
14
- useTokensFromState
15
- } from "./chunk-UOKDJT5L.mjs";
16
- import {
17
- useAuthState
18
- } from "./chunk-AD6VPMID.mjs";
19
-
20
- // src/Authenticated.tsx
21
- import React, { useEffect } from "react";
22
- function Authenticated({ children, disabled, loginRoute, loggedOutComponent }) {
23
- const authConfig = useAuthConfig();
24
- const authState = useAuthState();
25
- const login = useLogin(loginRoute);
26
- const tokensFromQuery = useTokensFromQuery();
27
- const tokensFromState = useTokensFromState();
28
- const { authenticated } = useKeycloak();
29
- useEffect(() => {
30
- if (authenticated !== false)
31
- return;
32
- if (authConfig.persist) {
33
- authState.setIdToken("");
34
- authState.setRefreshToken("");
35
- authState.setToken("");
36
- }
37
- if (typeof window !== "undefined" && !tokensFromQuery && !tokensFromState && window.self === window.top)
38
- login();
39
- }, [authenticated]);
40
- if (disabled || authenticated)
41
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
42
- const LoggedOutComponent = loggedOutComponent || (() => /* @__PURE__ */ React.createElement(React.Fragment, null, authConfig.debug ? "not authenticated" : null));
43
- return /* @__PURE__ */ React.createElement(LoggedOutComponent, null);
44
- }
45
- function withAuthenticated(Component) {
46
- return (props) => /* @__PURE__ */ React.createElement(Authenticated, null, /* @__PURE__ */ React.createElement(Component, { ...props }));
47
- }
48
-
49
- export {
50
- Authenticated,
51
- withAuthenticated
52
- };
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,84 +0,0 @@
1
- import {
2
- useAuthConfig
3
- } from "./chunk-Y4XMF3R6.mjs";
4
- import {
5
- __publicField
6
- } from "./chunk-RPUOO7AV.mjs";
7
-
8
- // src/hooks/useKeycloak/useKeycloak.ts
9
- import { MultiPlatform } from "multiplatform.one";
10
- import { useKeycloak as useReactKeycloak } from "@bitspur/react-keycloak-web";
11
- import { useKeycloak as useSsrKeycloak } from "@bitspur/react-keycloak-ssr";
12
- function useKeycloak() {
13
- const authConfig = useAuthConfig();
14
- if (MultiPlatform.isStorybook) {
15
- return new Keycloak(
16
- {
17
- email: "storybook@example.com",
18
- login: async () => void 0,
19
- logout: async () => void 0,
20
- subject: "0",
21
- username: "storybook"
22
- },
23
- true
24
- );
25
- }
26
- if (MultiPlatform.isNext && authConfig.ssr) {
27
- const { keycloak: keycloak2, initialized: initialized2 } = useSsrKeycloak();
28
- return new Keycloak(keycloak2, initialized2);
29
- }
30
- const { keycloak, initialized } = useReactKeycloak();
31
- return new Keycloak(keycloak, initialized);
32
- }
33
- var Keycloak = class {
34
- constructor(keycloak, initialized) {
35
- this.keycloak = keycloak;
36
- __publicField(this, "authenticated");
37
- this.authenticated = initialized ? keycloak?.authenticated : void 0;
38
- }
39
- get idToken() {
40
- return this.keycloak?.idToken;
41
- }
42
- get realmAccess() {
43
- return this.keycloak?.realmAccess;
44
- }
45
- get refreshToken() {
46
- return this.keycloak?.refreshToken;
47
- }
48
- get refreshTokenParsed() {
49
- return this.keycloak?.refreshTokenParsed;
50
- }
51
- get resourceAccess() {
52
- return this.keycloak?.resourceAccess;
53
- }
54
- get subject() {
55
- return this.keycloak?.subject;
56
- }
57
- get token() {
58
- return this.keycloak?.token;
59
- }
60
- get tokenParsed() {
61
- return this.keycloak?.tokenParsed;
62
- }
63
- get email() {
64
- return this.keycloak?.tokenParsed?.email;
65
- }
66
- get username() {
67
- return this.keycloak?.tokenParsed?.preferred_username;
68
- }
69
- async login() {
70
- if (!this.keycloak)
71
- return;
72
- return this.keycloak.login();
73
- }
74
- async logout() {
75
- if (!this.keycloak)
76
- return;
77
- return this.keycloak.logout();
78
- }
79
- };
80
-
81
- export {
82
- useKeycloak,
83
- Keycloak
84
- };
@@ -1,460 +0,0 @@
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 _chunkXEO3YXBMjs = require("./chunk-XEO3YXBM.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
- _chunkXEO3YXBMjs.__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;
@@ -1,16 +0,0 @@
1
- import {
2
- useAuthState
3
- } from "./chunk-AD6VPMID.mjs";
4
- import {
5
- validToken
6
- } from "./chunk-7MTPH6XK.mjs";
7
-
8
- // src/hooks/useTokensFromState.ts
9
- function useTokensFromState() {
10
- const authState = useAuthState();
11
- return !!validToken(authState.token, authState.refreshToken);
12
- }
13
-
14
- export {
15
- useTokensFromState
16
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _interopRequireDefault(obj) {
6
- return obj && obj.__esModule ? obj : {
7
- default: obj
8
- };
9
- }
10
- var _chunkUL6L5ONIjs = require("./chunk-UL6L5ONI.js");
11
- var _chunk3ZPHNEJLjs = require("./chunk-3ZPHNEJL.js");
12
- var _chunkC2FNSVJOjs = require("./chunk-C2FNSVJO.js");
13
- // src/provider/afterAuth.tsx
14
- var _react = require("react");
15
- var _react2 = _interopRequireDefault(_react);
16
- var logger = console;
17
- var AfterAuth = function(param) {
18
- var children = param.children;
19
- var authConfig = _chunk3ZPHNEJLjs.useAuthConfig.call(void 0);
20
- var authState = _chunkC2FNSVJOjs.useAuthState.call(void 0);
21
- var _chunkUL6L5ONIjs_useKeycloak_call = _chunkUL6L5ONIjs.useKeycloak.call(void 0), token = _chunkUL6L5ONIjs_useKeycloak_call.token, refreshToken = _chunkUL6L5ONIjs_useKeycloak_call.refreshToken, authenticated = _chunkUL6L5ONIjs_useKeycloak_call.authenticated, idToken = _chunkUL6L5ONIjs_useKeycloak_call.idToken;
22
- _react.useEffect.call(void 0, function() {
23
- if (!authenticated) return;
24
- if (authConfig.persist && token) {
25
- authState.setToken(token);
26
- if (idToken) authState.setIdToken(idToken);
27
- if (authConfig.ensureFreshness && refreshToken) authState.setRefreshToken(refreshToken);
28
- }
29
- }, [
30
- token,
31
- refreshToken,
32
- idToken
33
- ]);
34
- _react.useEffect.call(void 0, function() {
35
- if (authConfig.debug && authState.token) logger.debug("token", authState.token);
36
- }, [
37
- authState.token
38
- ]);
39
- _react.useEffect.call(void 0, function() {
40
- if (authConfig.debug && authState.idToken) logger.debug("idToken", authState.idToken);
41
- }, [
42
- authState.idToken
43
- ]);
44
- _react.useEffect.call(void 0, function() {
45
- if (authConfig.debug && authState.refreshToken) logger.debug("refreshToken", authState.refreshToken);
46
- }, [
47
- authState.refreshToken
48
- ]);
49
- _react.useEffect.call(void 0, function() {
50
- if (authConfig.debug) logger.debug("authenticated", authenticated);
51
- }, [
52
- authenticated
53
- ]);
54
- return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
55
- };
56
- exports.AfterAuth = AfterAuth;