@multiplatform.one/keycloak 0.3.3 → 0.3.4

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 (40) hide show
  1. package/dist/esm/hooks/index.mjs +1 -0
  2. package/dist/esm/hooks/index.mjs.map +2 -2
  3. package/dist/esm/hooks/useIsPassedInToken/index.mjs +12 -0
  4. package/dist/esm/hooks/useIsPassedInToken/index.mjs.map +7 -0
  5. package/dist/esm/hooks/useIsPassedInToken/index.native.mjs +7 -0
  6. package/dist/esm/hooks/useIsPassedInToken/index.native.mjs.map +7 -0
  7. package/dist/esm/provider/index.mjs +3 -1
  8. package/dist/esm/provider/index.mjs.map +2 -2
  9. package/dist/esm/provider/keycloakProvider.mjs +3 -2
  10. package/dist/esm/provider/keycloakProvider.mjs.map +2 -2
  11. package/dist/jsx/hooks/index.mjs +1 -0
  12. package/dist/jsx/hooks/index.mjs.map +2 -2
  13. package/dist/jsx/hooks/useIsPassedInToken/index.mjs +10 -0
  14. package/dist/jsx/hooks/useIsPassedInToken/index.mjs.map +7 -0
  15. package/dist/jsx/hooks/useIsPassedInToken/index.native.mjs +5 -0
  16. package/dist/jsx/hooks/useIsPassedInToken/index.native.mjs.map +7 -0
  17. package/dist/jsx/provider/index.mjs +3 -1
  18. package/dist/jsx/provider/index.mjs.map +2 -2
  19. package/dist/jsx/provider/keycloakProvider.mjs +3 -2
  20. package/dist/jsx/provider/keycloakProvider.mjs.map +2 -2
  21. package/dist/lib/hooks/index.d.ts +2 -1
  22. package/dist/lib/hooks/index.js +2 -0
  23. package/dist/lib/hooks/index.js.map +2 -2
  24. package/dist/lib/hooks/useIsPassedInToken/index.d.ts +24 -0
  25. package/dist/lib/hooks/useIsPassedInToken/index.js +34 -0
  26. package/dist/lib/hooks/useIsPassedInToken/index.js.map +7 -0
  27. package/dist/lib/hooks/useIsPassedInToken/index.native.d.ts +24 -0
  28. package/dist/lib/hooks/useIsPassedInToken/index.native.js +29 -0
  29. package/dist/lib/hooks/useIsPassedInToken/index.native.js.map +7 -0
  30. package/dist/lib/provider/index.js +3 -1
  31. package/dist/lib/provider/index.js.map +2 -2
  32. package/dist/lib/provider/keycloakProvider.js +3 -2
  33. package/dist/lib/provider/keycloakProvider.js.map +2 -2
  34. package/dist/lib/tsconfig.build.tsbuildinfo +1 -1
  35. package/package.json +1 -1
  36. package/src/hooks/index.ts +2 -1
  37. package/src/hooks/useIsPassedInToken/index.native.ts +25 -0
  38. package/src/hooks/useIsPassedInToken/index.ts +31 -0
  39. package/src/provider/index.tsx +3 -1
  40. package/src/provider/keycloakProvider.tsx +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/keycloak",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "keycloak client for multiplatform.one ecosystem",
5
5
  "main": "dist/lib",
6
6
  "module": "dist/esm",
@@ -4,7 +4,7 @@
4
4
  * File Created: 08-11-2022 06:34:56
5
5
  * Author: Clay Risser
6
6
  * -----
7
- * Last Modified: 25-11-2022 09:52:31
7
+ * Last Modified: 15-05-2023 01:58:05
8
8
  * Modified By: Clay Risser
9
9
  * -----
10
10
  * Risser Labs LLC (c) Copyright 2021 - 2022
@@ -23,5 +23,6 @@
23
23
  */
24
24
 
25
25
  export * from './useCurrentRouteName';
26
+ export * from './useIsPassedInToken';
26
27
  export * from './useKeycloak';
27
28
  export * from './useLogin';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * File: /src/hooks/useIsPassedInToken/index.native.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 15-05-2023 01:54:48
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 15-05-2023 01:55:27
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022 - 2023
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
+ export const useIsPassedInToken = () => false;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * File: /src/hooks/useIsPassedInToken/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 15-05-2023 01:54:44
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 15-05-2023 01:56:30
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022 - 2023
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
+ import { MultiPlatform } from 'multiplatform.one';
26
+ import { useRouter } from 'next/router';
27
+
28
+ export function useIsPassedInToken() {
29
+ const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };
30
+ return 'idToken' in query || 'token' in query || 'refreshToken' in query;
31
+ }
@@ -29,6 +29,7 @@ import type { FC, ComponentType, ReactNode } from 'react';
29
29
  import type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';
30
30
  import { AuthConfigContext, defaultAuthConfig } from '../authConfig';
31
31
  import { KeycloakProvider } from './keycloakProvider';
32
+ import { useIsPassedInToken } from '../hooks';
32
33
  // @ts-ignore
33
34
  import { config } from 'app/config';
34
35
 
@@ -67,6 +68,7 @@ export const AuthProvider: FC<AuthProviderProps> = ({
67
68
  onTokens,
68
69
  ...keycloakInitOptions
69
70
  }: AuthProviderProps) => {
71
+ const isPassedInToken = useIsPassedInToken();
70
72
  const authConfig = useMemo(
71
73
  () => ({
72
74
  ...defaultAuthConfig,
@@ -74,7 +76,7 @@ export const AuthProvider: FC<AuthProviderProps> = ({
74
76
  ensureFreshness,
75
77
  loginRoute,
76
78
  messageHandlerKeys,
77
- persist: ssr ? false : persist,
79
+ persist: ssr || isPassedInToken ? false : persist,
78
80
  ssr,
79
81
  }),
80
82
  [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr],
@@ -33,6 +33,7 @@ import { ReactKeycloakProvider } from '@bitspur/react-keycloak-web';
33
33
  import { SSRKeycloakProvider, SSRCookies } from '@bitspur/react-keycloak-ssr';
34
34
  import { useAuthConfig } from '../hooks/useAuthConfig';
35
35
  import { useAuthState } from '../state';
36
+ import { useIsPassedInToken } from '../hooks';
36
37
  import { useRouter } from 'next/router';
37
38
 
38
39
  export interface KeycloakProviderProps {
@@ -80,7 +81,7 @@ export function KeycloakProvider({
80
81
  refreshToken,
81
82
  ),
82
83
  );
83
- const explicitToken = 'idToken' in query || 'token' in query || 'refreshToken' in query;
84
+ const isPassedInToken = useIsPassedInToken();
84
85
 
85
86
  useEffect(() => {
86
87
  if (token !== true && refreshToken !== true && idToken !== true) return;
@@ -210,7 +211,7 @@ export function KeycloakProvider({
210
211
  initOptions.token = token;
211
212
  if (idToken && typeof idToken === 'string') initOptions.idToken = idToken;
212
213
  if (refreshToken && typeof refreshToken === 'string') initOptions.refreshToken = refreshToken;
213
- if (explicitToken) {
214
+ if (isPassedInToken) {
214
215
  initOptions.checkLoginIframe = false;
215
216
  initOptions.onLoad = undefined;
216
217
  }