@multiplatform.one/keycloak 0.3.19 → 0.3.21

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/keycloak",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
4
4
  "description": "keycloak client for multiplatform.one ecosystem",
5
5
  "main": "dist/lib",
6
6
  "module": "dist/esm",
@@ -26,7 +26,7 @@ import React, { useEffect } from 'react';
26
26
  import type { ComponentType, ReactNode } from 'react';
27
27
  import { useLogin, useKeycloak } from './hooks';
28
28
  import { useAuthState } from './state';
29
- import { useAuthConfig } from './hooks/useAuthConfig';
29
+ import { useAuthConfig, useTokensFromQuery, useTokensFromState } from './hooks';
30
30
 
31
31
  export interface AuthenticatedProps {
32
32
  children: ReactNode;
@@ -39,6 +39,8 @@ export function Authenticated({ children, disabled, loginRoute, loggedOutCompone
39
39
  const authConfig = useAuthConfig();
40
40
  const authState = useAuthState();
41
41
  const login = useLogin(loginRoute);
42
+ const tokensFromQuery = useTokensFromQuery();
43
+ const tokensFromState = useTokensFromState();
42
44
  const { authenticated } = useKeycloak();
43
45
 
44
46
  useEffect(() => {
@@ -48,11 +50,11 @@ export function Authenticated({ children, disabled, loginRoute, loggedOutCompone
48
50
  authState.setRefreshToken('');
49
51
  authState.setToken('');
50
52
  }
51
- login();
53
+ if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();
52
54
  }, [authenticated]);
53
55
 
54
56
  if (disabled || authenticated) return <>{children}</>;
55
- const LoggedOutComponent = loggedOutComponent || (() => null);
57
+ const LoggedOutComponent = loggedOutComponent || (() => <>{authState.debug ? 'not authenticated' : null}</>);
56
58
  return <LoggedOutComponent />;
57
59
  }
58
60
 
@@ -4,7 +4,7 @@
4
4
  * File Created: 08-11-2022 06:34:56
5
5
  * Author: Clay Risser
6
6
  * -----
7
- * Last Modified: 16-05-2023 07:40:57
7
+ * Last Modified: 26-05-2023 07:00:31
8
8
  * Modified By: Clay Risser
9
9
  * -----
10
10
  * Risser Labs LLC (c) Copyright 2021 - 2022
@@ -22,6 +22,7 @@
22
22
  * limitations under the License.
23
23
  */
24
24
 
25
+ export * from './useAuthConfig';
25
26
  export * from './useCurrentRouteName';
26
27
  export * from './useKeycloak';
27
28
  export * from './useLogin';
@@ -224,12 +224,12 @@ export function KeycloakProvider({
224
224
  initOptions.token = token;
225
225
  if (idToken && typeof idToken === 'string') initOptions.idToken = idToken;
226
226
  if (refreshToken && typeof refreshToken === 'string') initOptions.refreshToken = refreshToken;
227
- if (tokensFromQuery) {
228
- initOptions.checkLoginIframe = false;
229
- initOptions.flow = 'implicit';
230
- initOptions.onLoad = undefined;
231
- initOptions.timeSkew = 0;
232
- }
227
+ }
228
+ if (tokensFromQuery) {
229
+ initOptions.checkLoginIframe = false;
230
+ initOptions.flow = 'implicit';
231
+ initOptions.onLoad = undefined;
232
+ initOptions.timeSkew = 0;
233
233
  }
234
234
  return initOptions;
235
235
  }, [keycloakInitOptions, token, refreshToken, idToken]);