@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,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1,28 @@
1
+ /**
2
+ * File: /src/@types/expoKeycloakAuth.d.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 28-11-2022 14:56:57
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 28-11-2022 14:57:43
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+
25
+ declare module 'expo-keycloak-auth' {
26
+ export function useKeycloak(): any;
27
+ export const KeycloakProvider: any;
28
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * File: /src/@types/expoKeycloakAuth.d.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 28-11-2022 14:56:57
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 28-11-2022 14:57:43
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+
25
+ declare module 'expo-keycloak-auth' {
26
+ export function useKeycloak(): any;
27
+ export const KeycloakProvider: any;
28
+ }
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1,36 @@
1
+ import React__default, { ReactNode, ComponentType } from 'react';
2
+
3
+ /**
4
+ * File: /auth/Authenticated.tsx
5
+ * Project: app
6
+ * File Created: 08-11-2022 05:58:23
7
+ * Author: Clay Risser
8
+ * -----
9
+ * Last Modified: 22-11-2022 06:26:38
10
+ * Modified By: Clay Risser
11
+ * -----
12
+ * Risser Labs LLC (c) Copyright 2021 - 2022
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
27
+ interface AuthenticatedProps {
28
+ children: ReactNode;
29
+ disabled?: boolean;
30
+ loggedOutComponent?: ComponentType;
31
+ loginRoute?: string;
32
+ }
33
+ declare function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps): React__default.JSX.Element;
34
+ declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
35
+
36
+ export { Authenticated, AuthenticatedProps, withAuthenticated };
@@ -0,0 +1,36 @@
1
+ import React__default, { ReactNode, ComponentType } from 'react';
2
+
3
+ /**
4
+ * File: /auth/Authenticated.tsx
5
+ * Project: app
6
+ * File Created: 08-11-2022 05:58:23
7
+ * Author: Clay Risser
8
+ * -----
9
+ * Last Modified: 22-11-2022 06:26:38
10
+ * Modified By: Clay Risser
11
+ * -----
12
+ * Risser Labs LLC (c) Copyright 2021 - 2022
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
27
+ interface AuthenticatedProps {
28
+ children: ReactNode;
29
+ disabled?: boolean;
30
+ loggedOutComponent?: ComponentType;
31
+ loginRoute?: string;
32
+ }
33
+ declare function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps): React__default.JSX.Element;
34
+ declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
35
+
36
+ export { Authenticated, AuthenticatedProps, withAuthenticated };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkBJ2OPIMWjs = require("./chunk-BJ2OPIMW.js");
6
+ require("./chunk-UBVYEZI3.js");
7
+ require("./chunk-6NDWOV55.js");
8
+ require("./chunk-KLLABHIC.js");
9
+ require("./chunk-HDNHCVXT.js");
10
+ require("./chunk-OYWAYMFN.js");
11
+ require("./chunk-E2X33LSD.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-KMAXXKJT.js");
18
+ exports.Authenticated = _chunkBJ2OPIMWjs.Authenticated;
19
+ exports.withAuthenticated = _chunkBJ2OPIMWjs.withAuthenticated;
@@ -0,0 +1,20 @@
1
+ import {
2
+ Authenticated,
3
+ withAuthenticated
4
+ } from "./chunk-ZVG3OFME.mjs";
5
+ import "./chunk-AYKQVWMR.mjs";
6
+ import "./chunk-2GUOEPFY.mjs";
7
+ import "./chunk-NXTVYIBR.mjs";
8
+ import "./chunk-VLUTEDDM.mjs";
9
+ import "./chunk-L5HMOY4M.mjs";
10
+ import "./chunk-NU2SJ3ST.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-S237YNYQ.mjs";
17
+ export {
18
+ Authenticated,
19
+ withAuthenticated
20
+ };
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * File: /src/authConfig.ts
5
+ * Project: app
6
+ * File Created: 08-11-2022 09:21:15
7
+ * Author: Clay Risser
8
+ * -----
9
+ * Last Modified: 26-05-2023 08:07:00
10
+ * Modified By: Clay Risser
11
+ * -----
12
+ * Risser Labs LLC (c) Copyright 2021 - 2022
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+ declare const defaultAuthConfig: AuthConfig;
27
+ declare const AuthConfigContext: React.Context<AuthConfig>;
28
+ interface AuthConfig {
29
+ debug?: boolean;
30
+ ensureFreshness?: boolean;
31
+ loginRoute?: string;
32
+ messageHandlerKeys?: string[];
33
+ persist?: boolean;
34
+ ssr?: boolean;
35
+ }
36
+
37
+ export { AuthConfig, AuthConfigContext, defaultAuthConfig };
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * File: /src/authConfig.ts
5
+ * Project: app
6
+ * File Created: 08-11-2022 09:21:15
7
+ * Author: Clay Risser
8
+ * -----
9
+ * Last Modified: 26-05-2023 08:07:00
10
+ * Modified By: Clay Risser
11
+ * -----
12
+ * Risser Labs LLC (c) Copyright 2021 - 2022
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+ declare const defaultAuthConfig: AuthConfig;
27
+ declare const AuthConfigContext: React.Context<AuthConfig>;
28
+ interface AuthConfig {
29
+ debug?: boolean;
30
+ ensureFreshness?: boolean;
31
+ loginRoute?: string;
32
+ messageHandlerKeys?: string[];
33
+ persist?: boolean;
34
+ ssr?: boolean;
35
+ }
36
+
37
+ export { AuthConfig, AuthConfigContext, defaultAuthConfig };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkA7UBOIALjs = require("./chunk-A7UBOIAL.js");
6
+ require("./chunk-KMAXXKJT.js");
7
+ exports.AuthConfigContext = _chunkA7UBOIALjs.AuthConfigContext;
8
+ exports.defaultAuthConfig = _chunkA7UBOIALjs.defaultAuthConfig;
@@ -0,0 +1,9 @@
1
+ import {
2
+ AuthConfigContext,
3
+ defaultAuthConfig
4
+ } from "./chunk-64PPU7Q3.mjs";
5
+ import "./chunk-S237YNYQ.mjs";
6
+ export {
7
+ AuthConfigContext,
8
+ defaultAuthConfig
9
+ };
File without changes
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkA7UBOIALjs = require("./chunk-A7UBOIAL.js");
6
+ // src/hooks/useAuthConfig.ts
7
+ var _react = require("react");
8
+ function useAuthConfig() {
9
+ return _react.useContext.call(void 0, _chunkA7UBOIALjs.AuthConfigContext);
10
+ }
11
+ exports.useAuthConfig = useAuthConfig;
@@ -0,0 +1,13 @@
1
+ // src/authConfig.ts
2
+ import { createContext } from "react";
3
+ var defaultAuthConfig = {
4
+ ensureFreshness: true,
5
+ persist: false,
6
+ ssr: false
7
+ };
8
+ var AuthConfigContext = createContext(defaultAuthConfig);
9
+
10
+ export {
11
+ defaultAuthConfig,
12
+ AuthConfigContext
13
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,26 @@
1
+ // src/util.ts
2
+ function validToken(token, refreshToken) {
3
+ if (typeof token !== "string")
4
+ return token;
5
+ if (refreshToken) {
6
+ if (refreshToken === true || isTokenValid(refreshToken))
7
+ return token;
8
+ return false;
9
+ }
10
+ return isTokenValid(token) ? token : false;
11
+ }
12
+ 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
+ }
21
+ }
22
+
23
+ export {
24
+ validToken,
25
+ isTokenValid
26
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ }); // src/authConfig.ts
5
+ var _react = require("react");
6
+ var defaultAuthConfig = {
7
+ ensureFreshness: true,
8
+ persist: false,
9
+ ssr: false
10
+ };
11
+ var AuthConfigContext = _react.createContext.call(void 0, defaultAuthConfig);
12
+ exports.defaultAuthConfig = defaultAuthConfig;
13
+ exports.AuthConfigContext = AuthConfigContext;
@@ -0,0 +1,20 @@
1
+ // src/state/index.ts
2
+ import { createStateStore } from "multiplatform.one/zustand";
3
+ import { config } from "app/config";
4
+ var { useStore } = createStateStore(
5
+ "auth",
6
+ {
7
+ idToken: "",
8
+ refreshToken: "",
9
+ token: ""
10
+ },
11
+ void 0,
12
+ { persist: config.get("KEYCLOAK_PERSIST") === "1" }
13
+ );
14
+ function useAuthState() {
15
+ return useStore();
16
+ }
17
+
18
+ export {
19
+ useAuthState
20
+ };
@@ -0,0 +1,76 @@
1
+ import {
2
+ KeycloakProvider
3
+ } from "./chunk-DKRUDENY.mjs";
4
+ import {
5
+ useTokensFromQuery
6
+ } from "./chunk-NXTVYIBR.mjs";
7
+ import {
8
+ useTokensFromState
9
+ } from "./chunk-UOKDJT5L.mjs";
10
+ import {
11
+ AuthConfigContext,
12
+ defaultAuthConfig
13
+ } from "./chunk-64PPU7Q3.mjs";
14
+
15
+ // src/provider/index.tsx
16
+ import React, { useMemo } from "react";
17
+ import { config } from "app/config";
18
+ var persist = config.get("KEYCLOAK_PERSIST") === "1";
19
+ var AuthProvider = ({
20
+ // keycloak config
21
+ realm,
22
+ clientId,
23
+ baseUrl,
24
+ // auth config
25
+ debug,
26
+ ensureFreshness,
27
+ loginRoute,
28
+ messageHandlerKeys,
29
+ ssr,
30
+ // props
31
+ children,
32
+ cookies,
33
+ disabled,
34
+ loadingComponent,
35
+ onEvent,
36
+ onTokens,
37
+ ...keycloakInitOptions
38
+ }) => {
39
+ const tokensFromQuery = useTokensFromQuery();
40
+ const tokensFromState = useTokensFromState();
41
+ const authConfig = useMemo(
42
+ () => ({
43
+ ...defaultAuthConfig,
44
+ ...typeof debug !== "undefined" ? { debug } : {},
45
+ ...typeof ensureFreshness !== "undefined" ? { ensureFreshness } : {},
46
+ ...typeof loginRoute !== "undefined" ? { loginRoute } : {},
47
+ ...typeof messageHandlerKeys !== "undefined" ? { messageHandlerKeys } : {},
48
+ persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : defaultAuthConfig.persist,
49
+ ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : defaultAuthConfig.ssr : false
50
+ }),
51
+ [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]
52
+ );
53
+ if (disabled) {
54
+ return /* @__PURE__ */ React.createElement(AuthConfigContext.Provider, { value: authConfig }, children);
55
+ }
56
+ return /* @__PURE__ */ React.createElement(AuthConfigContext.Provider, { value: authConfig }, /* @__PURE__ */ React.createElement(
57
+ KeycloakProvider,
58
+ {
59
+ cookies,
60
+ keycloakConfig: {
61
+ realm: realm || "main",
62
+ clientId: clientId || "app",
63
+ url: baseUrl
64
+ },
65
+ keycloakInitOptions,
66
+ loadingComponent,
67
+ onEvent,
68
+ onTokens
69
+ },
70
+ children
71
+ ));
72
+ };
73
+
74
+ export {
75
+ AuthProvider
76
+ };
File without changes
@@ -0,0 +1,78 @@
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
+ Object.defineProperty(exports, "__esModule", {
31
+ value: true
32
+ });
33
+ function _interopRequireDefault(obj) {
34
+ return obj && obj.__esModule ? obj : {
35
+ default: obj
36
+ };
37
+ }
38
+ var _chunkKLLABHICjs = require("./chunk-KLLABHIC.js");
39
+ var _chunkHDNHCVXTjs = require("./chunk-HDNHCVXT.js");
40
+ var _chunkE2X33LSDjs = require("./chunk-E2X33LSD.js");
41
+ var _chunk3ZPHNEJLjs = require("./chunk-3ZPHNEJL.js");
42
+ var _chunkYGNNHTFEjs = require("./chunk-YGNNHTFE.js");
43
+ var _chunkC2FNSVJOjs = require("./chunk-C2FNSVJO.js");
44
+ // src/Authenticated.tsx
45
+ var _react = require("react");
46
+ var _react2 = _interopRequireDefault(_react);
47
+ function Authenticated(param) {
48
+ var children = param.children, disabled = param.disabled, loginRoute = param.loginRoute, loggedOutComponent = param.loggedOutComponent;
49
+ var authConfig = _chunk3ZPHNEJLjs.useAuthConfig.call(void 0);
50
+ var authState = _chunkC2FNSVJOjs.useAuthState.call(void 0);
51
+ var login = _chunkHDNHCVXTjs.useLogin.call(void 0, loginRoute);
52
+ var tokensFromQuery = _chunkKLLABHICjs.useTokensFromQuery.call(void 0);
53
+ var tokensFromState = _chunkYGNNHTFEjs.useTokensFromState.call(void 0);
54
+ var authenticated = _chunkE2X33LSDjs.useKeycloak.call(void 0).authenticated;
55
+ _react.useEffect.call(void 0, function() {
56
+ if (authenticated !== false) return;
57
+ if (authConfig.persist) {
58
+ authState.setIdToken("");
59
+ authState.setRefreshToken("");
60
+ authState.setToken("");
61
+ }
62
+ if (typeof window !== "undefined" && !tokensFromQuery && !tokensFromState && window.self === window.top) login();
63
+ }, [
64
+ authenticated
65
+ ]);
66
+ if (disabled || authenticated) return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
67
+ var LoggedOutComponent = loggedOutComponent || function() {
68
+ return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, authConfig.debug ? "not authenticated" : null);
69
+ };
70
+ return /* @__PURE__ */ _react2.default.createElement(LoggedOutComponent, null);
71
+ }
72
+ function withAuthenticated(Component) {
73
+ return function(props) {
74
+ return /* @__PURE__ */ _react2.default.createElement(Authenticated, null, /* @__PURE__ */ _react2.default.createElement(Component, _object_spread({}, props)));
75
+ };
76
+ }
77
+ exports.Authenticated = Authenticated;
78
+ exports.withAuthenticated = withAuthenticated;