@multiplatform.one/keycloak 0.7.15 → 0.7.17

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 (228) hide show
  1. package/lib/@types/expoKeycloakAuth.d.js +1 -1
  2. package/lib/Authenticated.d.mts +2 -2
  3. package/lib/Authenticated.d.ts +2 -2
  4. package/lib/Authenticated.js +20 -19
  5. package/lib/Authenticated.mjs +13 -13
  6. package/lib/authConfig.d.mts +2 -4
  7. package/lib/authConfig.d.ts +2 -4
  8. package/lib/authConfig.js +9 -8
  9. package/lib/authConfig.mjs +2 -2
  10. package/lib/chunk-2BKS6UM5.js +51 -0
  11. package/lib/chunk-2BSUCVXL.js +50 -0
  12. package/lib/chunk-2L5TXBDK.mjs +7 -0
  13. package/lib/chunk-2VDDEPLF.js +27 -0
  14. package/lib/chunk-32AVT4GA.js +9 -0
  15. package/lib/chunk-3ZTSLDX7.js +13 -0
  16. package/lib/chunk-6F4PWJZI.js +1 -0
  17. package/lib/{chunk-7MTPH6XK.mjs → chunk-6FRYV4MK.mjs} +10 -9
  18. package/lib/chunk-A2V2S4HP.js +22 -0
  19. package/lib/chunk-BUZONXAW.js +1 -0
  20. package/lib/{chunk-BVB33X7V.mjs → chunk-CGLMLNUS.mjs} +61 -81
  21. package/lib/chunk-FU4CT24B.mjs +32 -0
  22. package/lib/{chunk-Y4XMF3R6.mjs → chunk-HTWZLBA4.mjs} +1 -1
  23. package/lib/chunk-I5FNGKQ6.js +16 -0
  24. package/lib/{chunk-64PPU7Q3.mjs → chunk-JAFUI2JQ.mjs} +1 -5
  25. package/lib/{chunk-NXTVYIBR.mjs → chunk-L3HTVJ4B.mjs} +2 -0
  26. package/lib/chunk-MDAAMGTE.js +1 -0
  27. package/lib/chunk-NH335CDK.js +32 -0
  28. package/lib/chunk-OA5TSQWZ.mjs +50 -0
  29. package/lib/chunk-OBB23GPX.mjs +0 -0
  30. package/lib/chunk-OZLV3US5.js +245 -0
  31. package/lib/chunk-P57PW2II.js +11 -0
  32. package/lib/chunk-TUJRPTZE.js +13 -0
  33. package/lib/chunk-UESWAK47.mjs +0 -0
  34. package/lib/chunk-UH4K7HGE.mjs +163 -0
  35. package/lib/{chunk-UOKDJT5L.mjs → chunk-UKSHA3X3.mjs} +2 -2
  36. package/lib/chunk-VS4M7GMO.js +1 -0
  37. package/lib/chunk-WBQAMGXK.mjs +0 -0
  38. package/lib/{chunk-AD6VPMID.mjs → chunk-WMH347OL.mjs} +5 -3
  39. package/lib/chunk-WS4IMGVL.js +1 -0
  40. package/lib/chunk-X53FOCXA.js +28 -0
  41. package/lib/chunk-Y23BWOII.mjs +51 -0
  42. package/lib/chunk-Y5MS3XVZ.mjs +28 -0
  43. package/lib/chunk-YACGLW5Q.js +7 -0
  44. package/lib/chunk-ZCBD6HWK.js +1 -0
  45. package/lib/chunk-ZFXKCRJC.mjs +11 -0
  46. package/lib/chunk-ZW4GP2I5.js +163 -0
  47. package/lib/hooks/index.d.mts +0 -4
  48. package/lib/hooks/index.d.ts +0 -4
  49. package/lib/hooks/index.js +19 -23
  50. package/lib/hooks/index.mjs +8 -23
  51. package/lib/hooks/useAuthConfig.js +8 -8
  52. package/lib/hooks/useAuthConfig.mjs +3 -3
  53. package/lib/hooks/useTokensFromQuery/index.js +7 -7
  54. package/lib/hooks/useTokensFromQuery/index.mjs +2 -2
  55. package/lib/hooks/useTokensFromQuery/index.native.js +5 -8
  56. package/lib/hooks/useTokensFromQuery/index.native.mjs +1 -1
  57. package/lib/hooks/useTokensFromState.js +9 -9
  58. package/lib/hooks/useTokensFromState.mjs +4 -4
  59. package/lib/index.d.mts +10 -7
  60. package/lib/index.d.ts +10 -7
  61. package/lib/index.js +62 -34
  62. package/lib/index.mjs +32 -26
  63. package/lib/keycloak/context.d.mts +12 -0
  64. package/lib/keycloak/context.d.ts +12 -0
  65. package/lib/keycloak/context.js +7 -0
  66. package/lib/keycloak/context.mjs +7 -0
  67. package/lib/keycloak/index.d.mts +7 -0
  68. package/lib/keycloak/index.d.ts +7 -0
  69. package/lib/keycloak/index.js +14 -0
  70. package/lib/keycloak/index.mjs +14 -0
  71. package/lib/keycloak/keycloak.d.mts +37 -0
  72. package/lib/keycloak/keycloak.d.ts +37 -0
  73. package/lib/keycloak/keycloak.js +13 -0
  74. package/lib/keycloak/keycloak.mjs +13 -0
  75. package/lib/keycloak/keycloak.native.d.mts +33 -0
  76. package/lib/keycloak/keycloak.native.d.ts +33 -0
  77. package/lib/keycloak/keycloak.native.js +134 -0
  78. package/lib/keycloak/keycloak.native.mjs +134 -0
  79. package/lib/provider/{afterAuth.d.ts → AfterAuth.d.mts} +6 -7
  80. package/lib/provider/{afterAuth.d.mts → AfterAuth.d.ts} +6 -7
  81. package/lib/provider/AfterAuth.js +18 -0
  82. package/lib/provider/AfterAuth.mjs +18 -0
  83. package/lib/provider/AuthProvider/AuthProvider.d.mts +37 -0
  84. package/lib/provider/AuthProvider/AuthProvider.d.ts +37 -0
  85. package/lib/provider/AuthProvider/AuthProvider.js +19 -0
  86. package/lib/provider/AuthProvider/AuthProvider.mjs +19 -0
  87. package/lib/provider/{keycloakProvider.native.d.ts → AuthProvider/AuthProvider.native.d.mts} +9 -9
  88. package/lib/provider/{keycloakProvider.native.d.mts → AuthProvider/AuthProvider.native.d.ts} +9 -9
  89. package/lib/provider/AuthProvider/AuthProvider.native.js +25 -0
  90. package/lib/provider/AuthProvider/AuthProvider.native.mjs +25 -0
  91. package/lib/provider/AuthProvider/index.d.mts +4 -0
  92. package/lib/provider/AuthProvider/index.d.ts +4 -0
  93. package/lib/provider/AuthProvider/index.js +20 -0
  94. package/lib/provider/AuthProvider/index.mjs +20 -0
  95. package/lib/provider/KeycloakProvider.d.mts +34 -0
  96. package/lib/provider/KeycloakProvider.d.ts +34 -0
  97. package/lib/provider/KeycloakProvider.js +21 -0
  98. package/lib/provider/KeycloakProvider.mjs +21 -0
  99. package/lib/provider/index.d.mts +8 -39
  100. package/lib/provider/index.d.ts +8 -39
  101. package/lib/provider/index.js +28 -22
  102. package/lib/provider/index.mjs +22 -19
  103. package/lib/routes.d.mts +28 -0
  104. package/lib/routes.d.ts +28 -0
  105. package/lib/routes.js +127 -0
  106. package/lib/routes.mjs +127 -0
  107. package/lib/session/index.d.mts +3 -0
  108. package/lib/session/index.d.ts +3 -0
  109. package/lib/session/index.js +10 -0
  110. package/lib/session/index.mjs +10 -0
  111. package/lib/session/session.d.mts +18 -0
  112. package/lib/session/session.d.ts +18 -0
  113. package/lib/session/session.js +9 -0
  114. package/lib/session/session.mjs +9 -0
  115. package/lib/session/session.native.d.mts +8 -0
  116. package/lib/session/session.native.d.ts +8 -0
  117. package/lib/session/session.native.js +13 -0
  118. package/lib/session/session.native.mjs +13 -0
  119. package/lib/{state/index.d.ts → state.d.mts} +2 -1
  120. package/lib/{state/index.d.mts → state.d.ts} +2 -1
  121. package/lib/state.js +9 -0
  122. package/lib/state.mjs +9 -0
  123. package/lib/token.d.mts +17 -0
  124. package/lib/token.d.ts +17 -0
  125. package/lib/token.js +9 -0
  126. package/lib/{util.mjs → token.mjs} +2 -2
  127. package/lib/types.d.mts +5 -2
  128. package/lib/types.d.ts +5 -2
  129. package/lib/types.js +1 -8
  130. package/lib/types.mjs +1 -7
  131. package/package.json +28 -28
  132. package/routes/index.d.ts +22 -0
  133. package/routes/index.js +22 -0
  134. package/src/Authenticated.tsx +27 -17
  135. package/src/authConfig.ts +3 -9
  136. package/src/hooks/index.ts +0 -3
  137. package/src/hooks/useTokensFromQuery/index.ts +1 -0
  138. package/src/hooks/useTokensFromState.ts +1 -1
  139. package/src/index.ts +3 -0
  140. package/src/{@types/coreJsPure.d.ts → keycloak/context.ts} +6 -11
  141. package/src/{hooks/useCurrentRouteName/index.native.ts → keycloak/index.ts} +4 -11
  142. package/src/keycloak/keycloak.native.ts +148 -0
  143. package/src/keycloak/keycloak.ts +175 -0
  144. package/src/provider/AfterAuth.tsx +63 -0
  145. package/src/provider/{keycloakProvider.native.tsx → AuthProvider/AuthProvider.native.tsx} +8 -16
  146. package/src/provider/{keycloakProvider.tsx → AuthProvider/AuthProvider.tsx} +81 -94
  147. package/src/provider/AuthProvider/index.ts +22 -0
  148. package/src/provider/KeycloakProvider.tsx +53 -0
  149. package/src/provider/index.ts +24 -0
  150. package/src/routes.ts +163 -0
  151. package/src/session/index.ts +22 -0
  152. package/src/{hooks/useCurrentRouteName/index.ts → session/session.native.ts} +11 -14
  153. package/src/session/session.ts +68 -0
  154. package/src/{state/index.ts → state.ts} +5 -4
  155. package/src/{util.ts → token.ts} +25 -11
  156. package/src/types.ts +4 -1
  157. package/lib/@types/coreJsPure.d.d.mts +0 -2
  158. package/lib/@types/coreJsPure.d.d.ts +0 -2
  159. package/lib/@types/coreJsPure.d.js +0 -1
  160. package/lib/chunk-3ZPHNEJL.js +0 -11
  161. package/lib/chunk-6NDWOV55.js +0 -1
  162. package/lib/chunk-A7UBOIAL.js +0 -13
  163. package/lib/chunk-AUUZ6BI7.js +0 -78
  164. package/lib/chunk-C2FNSVJO.js +0 -17
  165. package/lib/chunk-J4CCMILN.mjs +0 -41
  166. package/lib/chunk-K33RKJZX.js +0 -443
  167. package/lib/chunk-KLLABHIC.js +0 -13
  168. package/lib/chunk-L5HMOY4M.mjs +0 -18
  169. package/lib/chunk-MZ6E62HK.js +0 -33
  170. package/lib/chunk-NWRANDZ6.js +0 -98
  171. package/lib/chunk-OYWAYMFN.js +0 -17
  172. package/lib/chunk-RPUOO7AV.mjs +0 -10
  173. package/lib/chunk-RYM7KERK.mjs +0 -52
  174. package/lib/chunk-UBVYEZI3.js +0 -1
  175. package/lib/chunk-UHTKOFS6.mjs +0 -84
  176. package/lib/chunk-UL6L5ONI.js +0 -460
  177. package/lib/chunk-W5DJLFTQ.js +0 -56
  178. package/lib/chunk-WT5W6BSZ.js +0 -161
  179. package/lib/chunk-XEO3YXBM.js +0 -22
  180. package/lib/chunk-XO4W2SMN.mjs +0 -50
  181. package/lib/chunk-XVPWAAZ4.mjs +0 -76
  182. package/lib/chunk-YGNNHTFE.js +0 -12
  183. package/lib/hooks/useCurrentRouteName/index.d.mts +0 -3
  184. package/lib/hooks/useCurrentRouteName/index.d.ts +0 -3
  185. package/lib/hooks/useCurrentRouteName/index.js +0 -7
  186. package/lib/hooks/useCurrentRouteName/index.mjs +0 -7
  187. package/lib/hooks/useCurrentRouteName/index.native.d.mts +0 -3
  188. package/lib/hooks/useCurrentRouteName/index.native.d.ts +0 -3
  189. package/lib/hooks/useCurrentRouteName/index.native.js +0 -14
  190. package/lib/hooks/useCurrentRouteName/index.native.mjs +0 -14
  191. package/lib/hooks/useKeycloak/index.d.mts +0 -46
  192. package/lib/hooks/useKeycloak/index.d.ts +0 -46
  193. package/lib/hooks/useKeycloak/index.js +0 -11
  194. package/lib/hooks/useKeycloak/index.mjs +0 -12
  195. package/lib/hooks/useKeycloak/useKeycloak.d.mts +0 -2
  196. package/lib/hooks/useKeycloak/useKeycloak.d.ts +0 -2
  197. package/lib/hooks/useKeycloak/useKeycloak.js +0 -10
  198. package/lib/hooks/useKeycloak/useKeycloak.mjs +0 -11
  199. package/lib/hooks/useKeycloak/useKeycloak.native.d.mts +0 -20
  200. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +0 -20
  201. package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -80
  202. package/lib/hooks/useKeycloak/useKeycloak.native.mjs +0 -69
  203. package/lib/hooks/useLogin.d.mts +0 -3
  204. package/lib/hooks/useLogin.d.ts +0 -3
  205. package/lib/hooks/useLogin.js +0 -11
  206. package/lib/hooks/useLogin.mjs +0 -11
  207. package/lib/provider/afterAuth.js +0 -18
  208. package/lib/provider/afterAuth.mjs +0 -18
  209. package/lib/provider/keycloakProvider.d.mts +0 -42
  210. package/lib/provider/keycloakProvider.d.ts +0 -42
  211. package/lib/provider/keycloakProvider.js +0 -20
  212. package/lib/provider/keycloakProvider.mjs +0 -21
  213. package/lib/provider/keycloakProvider.native.js +0 -87
  214. package/lib/provider/keycloakProvider.native.mjs +0 -30
  215. package/lib/state/index.js +0 -7
  216. package/lib/state/index.mjs +0 -7
  217. package/lib/util.d.mts +0 -4
  218. package/lib/util.d.ts +0 -4
  219. package/lib/util.js +0 -8
  220. package/src/hooks/useKeycloak/index.ts +0 -47
  221. package/src/hooks/useKeycloak/useKeycloak.native.ts +0 -95
  222. package/src/hooks/useKeycloak/useKeycloak.ts +0 -106
  223. package/src/hooks/useLogin.ts +0 -47
  224. package/src/provider/afterAuth.tsx +0 -65
  225. package/src/provider/index.tsx +0 -117
  226. /package/lib/{@types/coreJsPure.d.mjs → chunk-HH32BME2.mjs} +0 -0
  227. /package/lib/{chunk-2GUOEPFY.mjs → chunk-JPQI72HR.mjs} +0 -0
  228. /package/lib/{chunk-AYKQVWMR.mjs → chunk-OAUYHIWG.mjs} +0 -0
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";
@@ -24,10 +24,10 @@ import React__default, { ReactNode, ComponentType } from 'react';
24
24
  interface AuthenticatedProps {
25
25
  children: ReactNode;
26
26
  disabled?: boolean;
27
+ loadingComponent?: ComponentType;
27
28
  loggedOutComponent?: ComponentType;
28
- loginRoute?: string;
29
29
  }
30
- declare function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps): React__default.JSX.Element;
30
+ declare function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }: AuthenticatedProps): React__default.JSX.Element;
31
31
  declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
32
32
 
33
33
  export { Authenticated, type AuthenticatedProps, withAuthenticated };
@@ -24,10 +24,10 @@ import React__default, { ReactNode, ComponentType } from 'react';
24
24
  interface AuthenticatedProps {
25
25
  children: ReactNode;
26
26
  disabled?: boolean;
27
+ loadingComponent?: ComponentType;
27
28
  loggedOutComponent?: ComponentType;
28
- loginRoute?: string;
29
29
  }
30
- declare function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps): React__default.JSX.Element;
30
+ declare function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }: AuthenticatedProps): React__default.JSX.Element;
31
31
  declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
32
32
 
33
33
  export { Authenticated, type AuthenticatedProps, withAuthenticated };
@@ -1,19 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkAUUZ6BI7js = require("./chunk-AUUZ6BI7.js");
6
- require("./chunk-UBVYEZI3.js");
7
- require("./chunk-6NDWOV55.js");
8
- require("./chunk-KLLABHIC.js");
9
- require("./chunk-MZ6E62HK.js");
10
- require("./chunk-OYWAYMFN.js");
11
- require("./chunk-UL6L5ONI.js");
12
- require("./chunk-3ZPHNEJL.js");
13
- require("./chunk-YGNNHTFE.js");
14
- require("./chunk-C2FNSVJO.js");
15
- require("./chunk-A7UBOIAL.js");
16
- require("./chunk-NWRANDZ6.js");
17
- require("./chunk-XEO3YXBM.js");
18
- exports.Authenticated = _chunkAUUZ6BI7js.Authenticated;
19
- exports.withAuthenticated = _chunkAUUZ6BI7js.withAuthenticated;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunk2BSUCVXLjs = require('./chunk-2BSUCVXL.js');
5
+ require('./chunk-ZCBD6HWK.js');
6
+ require('./chunk-TUJRPTZE.js');
7
+ require('./chunk-3ZTSLDX7.js');
8
+ require('./chunk-I5FNGKQ6.js');
9
+ require('./chunk-VS4M7GMO.js');
10
+ require('./chunk-ZW4GP2I5.js');
11
+ require('./chunk-YACGLW5Q.js');
12
+ require('./chunk-NH335CDK.js');
13
+ require('./chunk-32AVT4GA.js');
14
+ require('./chunk-A2V2S4HP.js');
15
+ require('./chunk-2VDDEPLF.js');
16
+ require('./chunk-P57PW2II.js');
17
+
18
+
19
+
20
+ exports.Authenticated = _chunk2BSUCVXLjs.Authenticated; exports.withAuthenticated = _chunk2BSUCVXLjs.withAuthenticated;
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  Authenticated,
3
3
  withAuthenticated
4
- } from "./chunk-RYM7KERK.mjs";
5
- import "./chunk-AYKQVWMR.mjs";
6
- import "./chunk-2GUOEPFY.mjs";
7
- import "./chunk-NXTVYIBR.mjs";
8
- import "./chunk-J4CCMILN.mjs";
9
- import "./chunk-L5HMOY4M.mjs";
10
- import "./chunk-UHTKOFS6.mjs";
11
- import "./chunk-Y4XMF3R6.mjs";
12
- import "./chunk-UOKDJT5L.mjs";
13
- import "./chunk-AD6VPMID.mjs";
14
- import "./chunk-64PPU7Q3.mjs";
15
- import "./chunk-7MTPH6XK.mjs";
16
- import "./chunk-RPUOO7AV.mjs";
4
+ } from "./chunk-OA5TSQWZ.mjs";
5
+ import "./chunk-HH32BME2.mjs";
6
+ import "./chunk-L3HTVJ4B.mjs";
7
+ import "./chunk-HTWZLBA4.mjs";
8
+ import "./chunk-UKSHA3X3.mjs";
9
+ import "./chunk-OBB23GPX.mjs";
10
+ import "./chunk-UH4K7HGE.mjs";
11
+ import "./chunk-2L5TXBDK.mjs";
12
+ import "./chunk-FU4CT24B.mjs";
13
+ import "./chunk-JAFUI2JQ.mjs";
14
+ import "./chunk-WMH347OL.mjs";
15
+ import "./chunk-6FRYV4MK.mjs";
16
+ import "./chunk-ZFXKCRJC.mjs";
17
17
  export {
18
18
  Authenticated,
19
19
  withAuthenticated
@@ -4,11 +4,9 @@ declare const defaultAuthConfig: AuthConfig;
4
4
  declare const AuthConfigContext: React.Context<AuthConfig>;
5
5
  interface AuthConfig {
6
6
  debug?: boolean;
7
- ensureFreshness?: boolean;
8
- loginRoute?: string;
7
+ disabled?: boolean;
8
+ loginRedirectUri?: string;
9
9
  messageHandlerKeys?: string[];
10
- persist?: boolean;
11
- ssr?: boolean;
12
10
  }
13
11
 
14
12
  export { type AuthConfig, AuthConfigContext, defaultAuthConfig };
@@ -4,11 +4,9 @@ declare const defaultAuthConfig: AuthConfig;
4
4
  declare const AuthConfigContext: React.Context<AuthConfig>;
5
5
  interface AuthConfig {
6
6
  debug?: boolean;
7
- ensureFreshness?: boolean;
8
- loginRoute?: string;
7
+ disabled?: boolean;
8
+ loginRedirectUri?: string;
9
9
  messageHandlerKeys?: string[];
10
- persist?: boolean;
11
- ssr?: boolean;
12
10
  }
13
11
 
14
12
  export { type AuthConfig, AuthConfigContext, defaultAuthConfig };
package/lib/authConfig.js CHANGED
@@ -1,8 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkA7UBOIALjs = require("./chunk-A7UBOIAL.js");
6
- require("./chunk-XEO3YXBM.js");
7
- exports.AuthConfigContext = _chunkA7UBOIALjs.AuthConfigContext;
8
- exports.defaultAuthConfig = _chunkA7UBOIALjs.defaultAuthConfig;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunk32AVT4GAjs = require('./chunk-32AVT4GA.js');
5
+ require('./chunk-P57PW2II.js');
6
+
7
+
8
+
9
+ exports.AuthConfigContext = _chunk32AVT4GAjs.AuthConfigContext; exports.defaultAuthConfig = _chunk32AVT4GAjs.defaultAuthConfig;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AuthConfigContext,
3
3
  defaultAuthConfig
4
- } from "./chunk-64PPU7Q3.mjs";
5
- import "./chunk-RPUOO7AV.mjs";
4
+ } from "./chunk-JAFUI2JQ.mjs";
5
+ import "./chunk-ZFXKCRJC.mjs";
6
6
  export {
7
7
  AuthConfigContext,
8
8
  defaultAuthConfig
@@ -0,0 +1,51 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
4
+
5
+
6
+ var _chunkZW4GP2I5js = require('./chunk-ZW4GP2I5.js');
7
+
8
+
9
+
10
+ var _chunkA2V2S4HPjs = require('./chunk-A2V2S4HP.js');
11
+
12
+ // src/provider/AfterAuth.tsx
13
+ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
14
+ var logger = console;
15
+ function AfterAuth({ children }) {
16
+ const authConfig = _chunk3ZTSLDX7js.useAuthConfig.call(void 0, );
17
+ const authState = _chunkA2V2S4HPjs.useAuthState.call(void 0, );
18
+ const keycloak = _chunkZW4GP2I5js.useKeycloak.call(void 0, );
19
+ _react.useEffect.call(void 0, () => {
20
+ if (!_chunkA2V2S4HPjs.persist || !_optionalChain([keycloak, 'optionalAccess', _ => _.authenticated]))
21
+ return;
22
+ if (keycloak.token) {
23
+ authState.setToken(keycloak.token);
24
+ if (keycloak.idToken)
25
+ authState.setIdToken(keycloak.idToken);
26
+ if (keycloak.refreshToken)
27
+ authState.setRefreshToken(keycloak.refreshToken);
28
+ }
29
+ }, [_optionalChain([keycloak, 'optionalAccess', _2 => _2.authenticated]), _optionalChain([keycloak, 'optionalAccess', _3 => _3.token]), _optionalChain([keycloak, 'optionalAccess', _4 => _4.idToken]), _optionalChain([keycloak, 'optionalAccess', _5 => _5.refreshToken])]);
30
+ _react.useEffect.call(void 0, () => {
31
+ if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _6 => _6.token]))
32
+ logger.debug("token", keycloak.token);
33
+ }, [_optionalChain([keycloak, 'optionalAccess', _7 => _7.token])]);
34
+ _react.useEffect.call(void 0, () => {
35
+ if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _8 => _8.idToken]))
36
+ logger.debug("idToken", keycloak.idToken);
37
+ }, [_optionalChain([keycloak, 'optionalAccess', _9 => _9.idToken])]);
38
+ _react.useEffect.call(void 0, () => {
39
+ if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _10 => _10.refreshToken]))
40
+ logger.debug("refreshToken", keycloak.refreshToken);
41
+ }, [_optionalChain([keycloak, 'optionalAccess', _11 => _11.refreshToken])]);
42
+ _react.useEffect.call(void 0, () => {
43
+ if (_optionalChain([keycloak, 'optionalAccess', _12 => _12.authenticated]))
44
+ logger.debug("authenticated", keycloak.authenticated);
45
+ }, [_optionalChain([keycloak, 'optionalAccess', _13 => _13.authenticated])]);
46
+ return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
47
+ }
48
+
49
+
50
+
51
+ exports.AfterAuth = AfterAuth;
@@ -0,0 +1,50 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunkTUJRPTZEjs = require('./chunk-TUJRPTZE.js');
4
+
5
+
6
+ var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
7
+
8
+
9
+ var _chunkI5FNGKQ6js = require('./chunk-I5FNGKQ6.js');
10
+
11
+
12
+ var _chunkZW4GP2I5js = require('./chunk-ZW4GP2I5.js');
13
+
14
+ // src/Authenticated.tsx
15
+ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
16
+ var _multiplatformone = require('multiplatform.one');
17
+ function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }) {
18
+ const authConfig = _chunk3ZTSLDX7js.useAuthConfig.call(void 0, );
19
+ const keycloak = _chunkZW4GP2I5js.useKeycloak.call(void 0, );
20
+ const tokensFromQuery = _chunkTUJRPTZEjs.useTokensFromQuery.call(void 0, );
21
+ const tokensFromState = _chunkI5FNGKQ6js.useTokensFromState.call(void 0, );
22
+ _react.useEffect.call(void 0, () => {
23
+ if (!keycloak || _multiplatformone.MultiPlatform.isIframe || _multiplatformone.MultiPlatform.isServer || keycloak.authenticated || tokensFromQuery || tokensFromState) {
24
+ return;
25
+ }
26
+ keycloak.login({
27
+ redirectUri: authConfig.loginRedirectUri
28
+ });
29
+ }, [keycloak]);
30
+ if (typeof disabled === "undefined")
31
+ disabled = authConfig.disabled;
32
+ if (disabled)
33
+ return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
34
+ if (typeof keycloak === "undefined") {
35
+ const LoadingComponent = loadingComponent;
36
+ return LoadingComponent ? /* @__PURE__ */ _react2.default.createElement(LoadingComponent, null) : /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, authConfig.debug ? "loading" : null);
37
+ }
38
+ if (keycloak.authenticated)
39
+ return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
40
+ const LoggedOutComponent = loggedOutComponent;
41
+ return LoggedOutComponent ? /* @__PURE__ */ _react2.default.createElement(LoggedOutComponent, null) : /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, authConfig.debug ? "not authenticated" : null);
42
+ }
43
+ function withAuthenticated(Component) {
44
+ return (props) => /* @__PURE__ */ _react2.default.createElement(Authenticated, null, /* @__PURE__ */ _react2.default.createElement(Component, { ...props }));
45
+ }
46
+
47
+
48
+
49
+
50
+ exports.Authenticated = Authenticated; exports.withAuthenticated = withAuthenticated;
@@ -0,0 +1,7 @@
1
+ // src/keycloak/context.ts
2
+ import { createContext } from "react";
3
+ var KeycloakContext = createContext(void 0);
4
+
5
+ export {
6
+ KeycloakContext
7
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/token.ts
2
+ var _jwtdecode = require('jwt-decode');
3
+ function validToken(token, refreshToken) {
4
+ if (typeof token === "undefined")
5
+ return;
6
+ if (!token)
7
+ return false;
8
+ if (typeof token !== "string")
9
+ return token;
10
+ if (refreshToken) {
11
+ if (refreshToken === true || isTokenValid(refreshToken))
12
+ return token;
13
+ return false;
14
+ }
15
+ return isTokenValid(token) ? token : false;
16
+ }
17
+ function isTokenValid(token) {
18
+ const { exp } = _jwtdecode.jwtDecode.call(void 0, token);
19
+ if (!exp)
20
+ return false;
21
+ return Math.floor(Date.now() / 1e3) <= exp;
22
+ }
23
+
24
+
25
+
26
+
27
+ exports.validToken = validToken; exports.isTokenValid = isTokenValid;
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/authConfig.ts
2
+ var _react = require('react');
3
+ var defaultAuthConfig = {};
4
+ var AuthConfigContext = _react.createContext.call(void 0, defaultAuthConfig);
5
+
6
+
7
+
8
+
9
+ exports.defaultAuthConfig = defaultAuthConfig; exports.AuthConfigContext = AuthConfigContext;
@@ -0,0 +1,13 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk32AVT4GAjs = require('./chunk-32AVT4GA.js');
4
+
5
+ // src/hooks/useAuthConfig.ts
6
+ var _react = require('react');
7
+ function useAuthConfig() {
8
+ return _react.useContext.call(void 0, _chunk32AVT4GAjs.AuthConfigContext);
9
+ }
10
+
11
+
12
+
13
+ exports.useAuthConfig = useAuthConfig;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,5 +1,10 @@
1
- // src/util.ts
1
+ // src/token.ts
2
+ import { jwtDecode } from "jwt-decode";
2
3
  function validToken(token, refreshToken) {
4
+ if (typeof token === "undefined")
5
+ return;
6
+ if (!token)
7
+ return false;
3
8
  if (typeof token !== "string")
4
9
  return token;
5
10
  if (refreshToken) {
@@ -10,14 +15,10 @@ function validToken(token, refreshToken) {
10
15
  return isTokenValid(token) ? token : false;
11
16
  }
12
17
  function isTokenValid(token) {
13
- try {
14
- const { exp } = JSON.parse(Buffer.from(token.split(".")?.[1] || "", "base64").toString() || "{}");
15
- return Math.floor(Date.now() / 1e3) <= exp;
16
- } catch (err) {
17
- if (err instanceof SyntaxError)
18
- return false;
19
- throw err;
20
- }
18
+ const { exp } = jwtDecode(token);
19
+ if (!exp)
20
+ return false;
21
+ return Math.floor(Date.now() / 1e3) <= exp;
21
22
  }
22
23
 
23
24
  export {
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/state.ts
2
+ var _zustand = require('multiplatform.one/zustand');
3
+ var _multiplatformone = require('multiplatform.one');
4
+ var persist = _multiplatformone.MultiPlatform.isIframe || !_multiplatformone.MultiPlatform.isNext && !_multiplatformone.MultiPlatform.isServer;
5
+ var { useStore } = _zustand.createStateStore.call(void 0,
6
+ "auth",
7
+ {
8
+ idToken: "",
9
+ refreshToken: "",
10
+ token: ""
11
+ },
12
+ void 0,
13
+ { persist }
14
+ );
15
+ function useAuthState() {
16
+ return useStore();
17
+ }
18
+
19
+
20
+
21
+
22
+ exports.persist = persist; exports.useAuthState = useAuthState;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,51 +1,49 @@
1
1
  import {
2
2
  AfterAuth
3
- } from "./chunk-XO4W2SMN.mjs";
3
+ } from "./chunk-Y23BWOII.mjs";
4
4
  import {
5
5
  useAuthConfig
6
- } from "./chunk-Y4XMF3R6.mjs";
6
+ } from "./chunk-HTWZLBA4.mjs";
7
7
  import {
8
+ Keycloak
9
+ } from "./chunk-UH4K7HGE.mjs";
10
+ import {
11
+ KeycloakContext
12
+ } from "./chunk-2L5TXBDK.mjs";
13
+ import {
14
+ persist,
8
15
  useAuthState
9
- } from "./chunk-AD6VPMID.mjs";
16
+ } from "./chunk-WMH347OL.mjs";
10
17
  import {
11
18
  validToken
12
- } from "./chunk-7MTPH6XK.mjs";
19
+ } from "./chunk-6FRYV4MK.mjs";
13
20
 
14
- // src/provider/keycloakProvider.tsx
15
- import Keycloak from "@bitspur/keycloak-js";
16
- import React, { useMemo, useEffect, useState, useCallback } from "react";
21
+ // src/provider/AuthProvider/AuthProvider.tsx
22
+ import KeycloakClient from "keycloak-js";
23
+ import React, { useEffect, useMemo, useState } from "react";
17
24
  import { MultiPlatform } from "multiplatform.one";
18
- import { ReactKeycloakProvider } from "@bitspur/react-keycloak-web";
19
- import { SSRKeycloakProvider, SSRCookies } from "@bitspur/react-keycloak-ssr";
25
+ import { SessionProvider } from "next-auth/react";
20
26
  import { useRouter } from "next/router";
21
27
  var logger = console;
22
- function KeycloakProvider({
23
- children,
24
- cookies,
25
- keycloakConfig,
26
- keycloakInitOptions,
27
- loadingComponent,
28
- onEvent,
29
- onTokens
30
- }) {
31
- const { debug, ensureFreshness, persist, messageHandlerKeys, ssr } = useAuthConfig();
32
- const authState = useAuthState();
33
- const LoadingComponent = loadingComponent || (() => /* @__PURE__ */ React.createElement(React.Fragment, null, debug ? "authenticating" : null));
28
+ function AuthProvider({ children, sessionProvider, keycloakInitOptions, keycloakConfig }) {
29
+ const { debug, messageHandlerKeys } = useAuthConfig();
34
30
  const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };
31
+ const authState = useAuthState();
32
+ const [keycloak, setKeycloak] = useState();
35
33
  const [refreshToken, setRefreshToken] = useState(
36
34
  validToken(
37
- ensureFreshness && ("refreshToken" in query && (query.refreshToken?.toString() || true) || persist && authState.refreshToken) || false
35
+ MultiPlatform.isIframe ? "refreshToken" in query && (query.refreshToken?.toString() || true) || persist && authState.refreshToken || false : void 0
38
36
  )
39
37
  );
40
- const [idToken, setIdToken] = useState(
38
+ const [token, setToken] = useState(
41
39
  validToken(
42
- "idToken" in query && (query.idToken?.toString() || true) || persist && authState.idToken || false,
40
+ MultiPlatform.isIframe ? "token" in query && (query.token?.toString() || true) || persist && authState.token || false : void 0,
43
41
  refreshToken
44
42
  )
45
43
  );
46
- const [token, setToken] = useState(
44
+ const [idToken, setIdToken] = useState(
47
45
  validToken(
48
- "token" in query && (query.token?.toString() || true) || persist && authState.token || false,
46
+ MultiPlatform.isIframe ? "idToken" in query && (query.idToken?.toString() || true) || persist && authState.idToken || false : void 0,
49
47
  refreshToken
50
48
  )
51
49
  );
@@ -171,26 +169,17 @@ function KeycloakProvider({
171
169
  window.removeEventListener("message", messageCallback);
172
170
  };
173
171
  }, []);
174
- const handleEvent = useCallback((eventType, error) => {
175
- if (error) {
176
- if (typeof error === "string")
177
- throw new Error(error);
178
- const err = new Error(error.error);
179
- err.errorDescription = error.error_description;
180
- throw err;
181
- }
182
- if (onEvent)
183
- onEvent(eventType, error);
184
- }, []);
185
- const keycloak = useMemo(
186
- () => typeof window !== "undefined" && new Keycloak({
172
+ const keycloakClient = useMemo(
173
+ () => MultiPlatform.isIframe && keycloakConfig ? new KeycloakClient({
187
174
  url: keycloakConfig.url,
188
175
  realm: keycloakConfig.realm,
189
176
  clientId: keycloakConfig.clientId
190
- }),
191
- [keycloakInitOptions, token, refreshToken, idToken]
177
+ }) : void 0,
178
+ [keycloakInitOptions, keycloakConfig, token, refreshToken, idToken]
192
179
  );
193
180
  const initOptions = useMemo(() => {
181
+ if (!MultiPlatform.isIframe)
182
+ return;
194
183
  const initOptions2 = {
195
184
  ...defaultKeycloakInitOptions,
196
185
  ...keycloakInitOptions
@@ -211,45 +200,37 @@ function KeycloakProvider({
211
200
  initOptions2.onLoad = void 0;
212
201
  }
213
202
  return initOptions2;
214
- }, [keycloakInitOptions, token, refreshToken, idToken]);
215
- if (token === true || idToken === true || refreshToken === true)
216
- return /* @__PURE__ */ React.createElement(LoadingComponent, null);
217
- if (cookies && ssr) {
218
- return (
219
- // @ts-ignore
220
- /* @__PURE__ */ React.createElement(
221
- SSRKeycloakProvider,
222
- {
223
- LoadingComponent: /* @__PURE__ */ React.createElement(LoadingComponent, null),
224
- autoRefreshToken: initOptions.checkLoginIframe,
225
- initOptions,
226
- onEvent: handleEvent,
227
- onTokens,
228
- persistor: SSRCookies(cookies),
229
- keycloakConfig: {
230
- clientId: keycloakConfig.clientId,
231
- realm: keycloakConfig.realm,
232
- url: keycloakConfig.url
203
+ }, [keycloakInitOptions, token, idToken, refreshToken]);
204
+ useEffect(() => {
205
+ function onError() {
206
+ if (keycloakClient && initOptions)
207
+ setKeycloak(new Keycloak(keycloakClient));
208
+ }
209
+ function onUpdate() {
210
+ if (keycloakClient && initOptions)
211
+ setKeycloak(new Keycloak(keycloakClient));
212
+ }
213
+ if (keycloakClient && initOptions) {
214
+ (async () => {
215
+ keycloakClient.onAuthError = onError;
216
+ keycloakClient.onAuthLogout = onUpdate;
217
+ keycloakClient.onAuthRefreshError = onError;
218
+ keycloakClient.onAuthRefreshSuccess = onUpdate;
219
+ keycloakClient.onAuthSuccess = onUpdate;
220
+ keycloakClient.onReady = onUpdate;
221
+ keycloakClient.onTokenExpired = async () => {
222
+ try {
223
+ await keycloakClient.updateToken(5);
224
+ } catch (err) {
225
+ setKeycloak(new Keycloak());
233
226
  }
234
- },
235
- /* @__PURE__ */ React.createElement(AfterAuth, null, children)
236
- )
237
- );
238
- }
239
- if (!keycloak)
240
- return /* @__PURE__ */ React.createElement(LoadingComponent, null);
241
- return /* @__PURE__ */ React.createElement(
242
- ReactKeycloakProvider,
243
- {
244
- LoadingComponent: /* @__PURE__ */ React.createElement(LoadingComponent, null),
245
- authClient: keycloak,
246
- autoRefreshToken: initOptions.checkLoginIframe,
247
- initOptions,
248
- onEvent: handleEvent,
249
- onTokens
250
- },
251
- /* @__PURE__ */ React.createElement(AfterAuth, null, children)
252
- );
227
+ };
228
+ const authenticated = await keycloakClient.init(initOptions);
229
+ setKeycloak(new Keycloak(authenticated ? keycloakClient : void 0));
230
+ })();
231
+ }
232
+ }, []);
233
+ return /* @__PURE__ */ React.createElement(SessionProvider, { ...sessionProvider }, /* @__PURE__ */ React.createElement(KeycloakContext.Provider, { value: keycloak }, /* @__PURE__ */ React.createElement(AfterAuth, null, children)));
253
234
  }
254
235
  var defaultKeycloakInitOptions = {
255
236
  checkLoginIframe: true,
@@ -260,6 +241,5 @@ var defaultKeycloakInitOptions = {
260
241
  };
261
242
 
262
243
  export {
263
- KeycloakProvider,
264
- defaultKeycloakInitOptions
244
+ AuthProvider
265
245
  };
@@ -0,0 +1,32 @@
1
+ // src/session/session.ts
2
+ import { MultiPlatform } from "multiplatform.one";
3
+ import { useSession as useNextSession, getSession as getNextSession } from "next-auth/react";
4
+ var _getServerSession;
5
+ async function getSession() {
6
+ if (MultiPlatform.isServer) {
7
+ if (typeof _getServerSession === "function")
8
+ return _getServerSession();
9
+ const getSession2 = (await import("next-auth")).getServerSession;
10
+ _getServerSession = () => getSession2();
11
+ return _getServerSession();
12
+ }
13
+ return getNextSession();
14
+ }
15
+ var useSession = (options) => {
16
+ return {};
17
+ };
18
+ if (MultiPlatform.isNext) {
19
+ useSession = (options) => {
20
+ const nextSession = useNextSession(options);
21
+ return {
22
+ update: nextSession.update,
23
+ status: nextSession.status,
24
+ session: nextSession.data
25
+ };
26
+ };
27
+ }
28
+
29
+ export {
30
+ getSession,
31
+ useSession
32
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthConfigContext
3
- } from "./chunk-64PPU7Q3.mjs";
3
+ } from "./chunk-JAFUI2JQ.mjs";
4
4
 
5
5
  // src/hooks/useAuthConfig.ts
6
6
  import { useContext } from "react";
@@ -0,0 +1,16 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkA2V2S4HPjs = require('./chunk-A2V2S4HP.js');
4
+
5
+
6
+ var _chunk2VDDEPLFjs = require('./chunk-2VDDEPLF.js');
7
+
8
+ // src/hooks/useTokensFromState.ts
9
+ function useTokensFromState() {
10
+ const authState = _chunkA2V2S4HPjs.useAuthState.call(void 0, );
11
+ return !!_chunk2VDDEPLFjs.validToken.call(void 0, authState.token, authState.refreshToken);
12
+ }
13
+
14
+
15
+
16
+ exports.useTokensFromState = useTokensFromState;