@multiplatform.one/keycloak 1.0.1 → 1.0.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 (169) hide show
  1. package/package.json +32 -34
  2. package/routes/index.d.ts +1 -1
  3. package/routes/index.js +1 -1
  4. package/src/Authenticated.tsx +12 -13
  5. package/src/apollo.ts +1 -1
  6. package/src/authConfig.ts +2 -0
  7. package/src/hooks/useTokensFromQuery/index.ts +2 -0
  8. package/src/hooks/useTokensFromState.ts +2 -2
  9. package/{lib/@types/expoKeycloakAuth.d.d.mts → src/keycloak/config.ts} +17 -6
  10. package/src/keycloak/context.ts +3 -1
  11. package/src/keycloak/index.ts +1 -0
  12. package/src/keycloak/keycloak.native.ts +49 -15
  13. package/src/keycloak/keycloak.ts +66 -11
  14. package/src/provider/AfterAuth.tsx +2 -0
  15. package/src/provider/AuthProvider/AuthProvider.native.tsx +159 -6
  16. package/src/provider/AuthProvider/AuthProvider.tsx +66 -43
  17. package/src/provider/KeycloakProvider.tsx +12 -2
  18. package/src/routes.ts +54 -20
  19. package/src/session/session.ts +4 -15
  20. package/src/token.ts +13 -5
  21. package/lib/@types/expoKeycloakAuth.d.d.ts +0 -25
  22. package/lib/@types/expoKeycloakAuth.d.js +0 -1
  23. package/lib/@types/expoKeycloakAuth.d.mjs +0 -0
  24. package/lib/Authenticated.d.mts +0 -32
  25. package/lib/Authenticated.d.ts +0 -32
  26. package/lib/Authenticated.js +0 -20
  27. package/lib/Authenticated.mjs +0 -20
  28. package/lib/apollo.d.mts +0 -7
  29. package/lib/apollo.d.ts +0 -7
  30. package/lib/apollo.js +0 -15
  31. package/lib/apollo.mjs +0 -15
  32. package/lib/authConfig.d.mts +0 -12
  33. package/lib/authConfig.d.ts +0 -12
  34. package/lib/authConfig.js +0 -9
  35. package/lib/authConfig.mjs +0 -9
  36. package/lib/chunk-267L3NLO.mjs +0 -53
  37. package/lib/chunk-2L5TXBDK.mjs +0 -7
  38. package/lib/chunk-2VDDEPLF.js +0 -27
  39. package/lib/chunk-2VGMJ7WP.js +0 -34
  40. package/lib/chunk-32AVT4GA.js +0 -9
  41. package/lib/chunk-3KAZ37SK.mjs +0 -51
  42. package/lib/chunk-3ZTSLDX7.js +0 -13
  43. package/lib/chunk-5CWGWY74.mjs +0 -28
  44. package/lib/chunk-6F4PWJZI.js +0 -1
  45. package/lib/chunk-6FRYV4MK.mjs +0 -27
  46. package/lib/chunk-6Q4DC5JX.mjs +0 -50
  47. package/lib/chunk-7NZPJ2EN.mjs +0 -161
  48. package/lib/chunk-A2V2S4HP.js +0 -22
  49. package/lib/chunk-BUZONXAW.js +0 -1
  50. package/lib/chunk-HH32BME2.mjs +0 -0
  51. package/lib/chunk-HTWZLBA4.mjs +0 -13
  52. package/lib/chunk-I5FNGKQ6.js +0 -16
  53. package/lib/chunk-JAFUI2JQ.mjs +0 -9
  54. package/lib/chunk-JPQI72HR.mjs +0 -0
  55. package/lib/chunk-K2FTCH55.js +0 -50
  56. package/lib/chunk-KWNIT4G4.mjs +0 -34
  57. package/lib/chunk-L3HTVJ4B.mjs +0 -13
  58. package/lib/chunk-MDAAMGTE.js +0 -1
  59. package/lib/chunk-NCIQ66UP.js +0 -51
  60. package/lib/chunk-NWZCPYQP.js +0 -161
  61. package/lib/chunk-OAUYHIWG.mjs +0 -0
  62. package/lib/chunk-OBB23GPX.mjs +0 -0
  63. package/lib/chunk-P57PW2II.js +0 -11
  64. package/lib/chunk-S5HUGQLF.js +0 -28
  65. package/lib/chunk-TUJRPTZE.js +0 -13
  66. package/lib/chunk-UESWAK47.mjs +0 -0
  67. package/lib/chunk-UKSHA3X3.mjs +0 -16
  68. package/lib/chunk-VFQKAKK4.js +0 -245
  69. package/lib/chunk-VPYXLUMD.js +0 -53
  70. package/lib/chunk-VS4M7GMO.js +0 -1
  71. package/lib/chunk-W4PGLIAZ.mjs +0 -245
  72. package/lib/chunk-WBQAMGXK.mjs +0 -0
  73. package/lib/chunk-WMH347OL.mjs +0 -22
  74. package/lib/chunk-WS4IMGVL.js +0 -1
  75. package/lib/chunk-YACGLW5Q.js +0 -7
  76. package/lib/chunk-ZCBD6HWK.js +0 -1
  77. package/lib/chunk-ZFXKCRJC.mjs +0 -11
  78. package/lib/hooks/index.d.mts +0 -5
  79. package/lib/hooks/index.d.ts +0 -5
  80. package/lib/hooks/index.js +0 -19
  81. package/lib/hooks/index.mjs +0 -19
  82. package/lib/hooks/useAuthConfig.d.mts +0 -6
  83. package/lib/hooks/useAuthConfig.d.ts +0 -6
  84. package/lib/hooks/useAuthConfig.js +0 -8
  85. package/lib/hooks/useAuthConfig.mjs +0 -8
  86. package/lib/hooks/useTokensFromQuery/index.d.mts +0 -3
  87. package/lib/hooks/useTokensFromQuery/index.d.ts +0 -3
  88. package/lib/hooks/useTokensFromQuery/index.js +0 -7
  89. package/lib/hooks/useTokensFromQuery/index.mjs +0 -7
  90. package/lib/hooks/useTokensFromQuery/index.native.d.mts +0 -3
  91. package/lib/hooks/useTokensFromQuery/index.native.d.ts +0 -3
  92. package/lib/hooks/useTokensFromQuery/index.native.js +0 -7
  93. package/lib/hooks/useTokensFromQuery/index.native.mjs +0 -7
  94. package/lib/hooks/useTokensFromState.d.mts +0 -3
  95. package/lib/hooks/useTokensFromState.d.ts +0 -3
  96. package/lib/hooks/useTokensFromState.js +0 -9
  97. package/lib/hooks/useTokensFromState.mjs +0 -9
  98. package/lib/index.d.mts +0 -18
  99. package/lib/index.d.ts +0 -18
  100. package/lib/index.js +0 -70
  101. package/lib/index.mjs +0 -70
  102. package/lib/keycloak/context.d.mts +0 -12
  103. package/lib/keycloak/context.d.ts +0 -12
  104. package/lib/keycloak/context.js +0 -7
  105. package/lib/keycloak/context.mjs +0 -7
  106. package/lib/keycloak/index.d.mts +0 -7
  107. package/lib/keycloak/index.d.ts +0 -7
  108. package/lib/keycloak/index.js +0 -14
  109. package/lib/keycloak/index.mjs +0 -14
  110. package/lib/keycloak/keycloak.d.mts +0 -37
  111. package/lib/keycloak/keycloak.d.ts +0 -37
  112. package/lib/keycloak/keycloak.js +0 -13
  113. package/lib/keycloak/keycloak.mjs +0 -13
  114. package/lib/keycloak/keycloak.native.d.mts +0 -33
  115. package/lib/keycloak/keycloak.native.d.ts +0 -33
  116. package/lib/keycloak/keycloak.native.js +0 -134
  117. package/lib/keycloak/keycloak.native.mjs +0 -134
  118. package/lib/provider/AfterAuth.d.mts +0 -28
  119. package/lib/provider/AfterAuth.d.ts +0 -28
  120. package/lib/provider/AfterAuth.js +0 -18
  121. package/lib/provider/AfterAuth.mjs +0 -18
  122. package/lib/provider/AuthProvider/AuthProvider.d.mts +0 -37
  123. package/lib/provider/AuthProvider/AuthProvider.d.ts +0 -37
  124. package/lib/provider/AuthProvider/AuthProvider.js +0 -19
  125. package/lib/provider/AuthProvider/AuthProvider.mjs +0 -19
  126. package/lib/provider/AuthProvider/AuthProvider.native.d.mts +0 -29
  127. package/lib/provider/AuthProvider/AuthProvider.native.d.ts +0 -29
  128. package/lib/provider/AuthProvider/AuthProvider.native.js +0 -25
  129. package/lib/provider/AuthProvider/AuthProvider.native.mjs +0 -25
  130. package/lib/provider/AuthProvider/index.d.mts +0 -4
  131. package/lib/provider/AuthProvider/index.d.ts +0 -4
  132. package/lib/provider/AuthProvider/index.js +0 -20
  133. package/lib/provider/AuthProvider/index.mjs +0 -20
  134. package/lib/provider/KeycloakProvider.d.mts +0 -34
  135. package/lib/provider/KeycloakProvider.d.ts +0 -34
  136. package/lib/provider/KeycloakProvider.js +0 -21
  137. package/lib/provider/KeycloakProvider.mjs +0 -21
  138. package/lib/provider/index.d.mts +0 -8
  139. package/lib/provider/index.d.ts +0 -8
  140. package/lib/provider/index.js +0 -28
  141. package/lib/provider/index.mjs +0 -28
  142. package/lib/routes.d.mts +0 -27
  143. package/lib/routes.d.ts +0 -27
  144. package/lib/routes.js +0 -127
  145. package/lib/routes.mjs +0 -127
  146. package/lib/session/index.d.mts +0 -3
  147. package/lib/session/index.d.ts +0 -3
  148. package/lib/session/index.js +0 -10
  149. package/lib/session/index.mjs +0 -10
  150. package/lib/session/session.d.mts +0 -18
  151. package/lib/session/session.d.ts +0 -18
  152. package/lib/session/session.js +0 -9
  153. package/lib/session/session.mjs +0 -9
  154. package/lib/session/session.native.d.mts +0 -8
  155. package/lib/session/session.native.d.ts +0 -8
  156. package/lib/session/session.native.js +0 -13
  157. package/lib/session/session.native.mjs +0 -13
  158. package/lib/state.d.mts +0 -12
  159. package/lib/state.d.ts +0 -12
  160. package/lib/state.js +0 -9
  161. package/lib/state.mjs +0 -9
  162. package/lib/token.d.mts +0 -17
  163. package/lib/token.d.ts +0 -17
  164. package/lib/token.js +0 -9
  165. package/lib/token.mjs +0 -9
  166. package/lib/types.d.mts +0 -20
  167. package/lib/types.d.ts +0 -20
  168. package/lib/types.js +0 -1
  169. package/lib/types.mjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";
File without changes
@@ -1,32 +0,0 @@
1
- import React__default, { PropsWithChildren, ComponentType } from 'react';
2
-
3
- /**
4
- * File: /src/Authenticated.tsx
5
- * Project: @multiplatform.one/keycloak
6
- * File Created: 22-06-2023 10:07:56
7
- * Author: Clay Risser
8
- * -----
9
- * BitSpur (c) Copyright 2021 - 2023
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
-
24
- interface AuthenticatedProps extends PropsWithChildren {
25
- disabled?: boolean;
26
- loadingComponent?: ComponentType;
27
- loggedOutComponent?: ComponentType;
28
- }
29
- declare function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }: AuthenticatedProps): React__default.JSX.Element;
30
- declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
31
-
32
- export { Authenticated, type AuthenticatedProps, withAuthenticated };
@@ -1,32 +0,0 @@
1
- import React__default, { PropsWithChildren, ComponentType } from 'react';
2
-
3
- /**
4
- * File: /src/Authenticated.tsx
5
- * Project: @multiplatform.one/keycloak
6
- * File Created: 22-06-2023 10:07:56
7
- * Author: Clay Risser
8
- * -----
9
- * BitSpur (c) Copyright 2021 - 2023
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
-
24
- interface AuthenticatedProps extends PropsWithChildren {
25
- disabled?: boolean;
26
- loadingComponent?: ComponentType;
27
- loggedOutComponent?: ComponentType;
28
- }
29
- declare function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }: AuthenticatedProps): React__default.JSX.Element;
30
- declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
31
-
32
- export { Authenticated, type AuthenticatedProps, withAuthenticated };
@@ -1,20 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkK2FTCH55js = require('./chunk-K2FTCH55.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-NWZCPYQP.js');
11
- require('./chunk-2VGMJ7WP.js');
12
- require('./chunk-YACGLW5Q.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 = _chunkK2FTCH55js.Authenticated; exports.withAuthenticated = _chunkK2FTCH55js.withAuthenticated;
@@ -1,20 +0,0 @@
1
- import {
2
- Authenticated,
3
- withAuthenticated
4
- } from "./chunk-6Q4DC5JX.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-7NZPJ2EN.mjs";
11
- import "./chunk-KWNIT4G4.mjs";
12
- import "./chunk-2L5TXBDK.mjs";
13
- import "./chunk-JAFUI2JQ.mjs";
14
- import "./chunk-WMH347OL.mjs";
15
- import "./chunk-6FRYV4MK.mjs";
16
- import "./chunk-ZFXKCRJC.mjs";
17
- export {
18
- Authenticated,
19
- withAuthenticated
20
- };
package/lib/apollo.d.mts DELETED
@@ -1,7 +0,0 @@
1
- import { OperationVariables, DocumentNode, TypedDocumentNode, QueryHookOptions, NoInfer, QueryResult, DefaultContext, ApolloCache, MutationHookOptions, MutationTuple, SubscriptionHookOptions, SubscriptionResult } from '@apollo/client';
2
-
3
- declare function useAuthQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): QueryResult<TData, TVariables>;
4
- declare function useAuthMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;
5
- declare function useAuthSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(subscription: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SubscriptionHookOptions<NoInfer<TData>, NoInfer<TVariables>>): SubscriptionResult<TData, TVariables>;
6
-
7
- export { useAuthMutation, useAuthQuery, useAuthSubscription };
package/lib/apollo.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { OperationVariables, DocumentNode, TypedDocumentNode, QueryHookOptions, NoInfer, QueryResult, DefaultContext, ApolloCache, MutationHookOptions, MutationTuple, SubscriptionHookOptions, SubscriptionResult } from '@apollo/client';
2
-
3
- declare function useAuthQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): QueryResult<TData, TVariables>;
4
- declare function useAuthMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;
5
- declare function useAuthSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(subscription: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SubscriptionHookOptions<NoInfer<TData>, NoInfer<TVariables>>): SubscriptionResult<TData, TVariables>;
6
-
7
- export { useAuthMutation, useAuthQuery, useAuthSubscription };
package/lib/apollo.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
- var _chunkVPYXLUMDjs = require('./chunk-VPYXLUMD.js');
6
- require('./chunk-VS4M7GMO.js');
7
- require('./chunk-NWZCPYQP.js');
8
- require('./chunk-2VGMJ7WP.js');
9
- require('./chunk-YACGLW5Q.js');
10
- require('./chunk-P57PW2II.js');
11
-
12
-
13
-
14
-
15
- exports.useAuthMutation = _chunkVPYXLUMDjs.useAuthMutation; exports.useAuthQuery = _chunkVPYXLUMDjs.useAuthQuery; exports.useAuthSubscription = _chunkVPYXLUMDjs.useAuthSubscription;
package/lib/apollo.mjs DELETED
@@ -1,15 +0,0 @@
1
- import {
2
- useAuthMutation,
3
- useAuthQuery,
4
- useAuthSubscription
5
- } from "./chunk-267L3NLO.mjs";
6
- import "./chunk-OBB23GPX.mjs";
7
- import "./chunk-7NZPJ2EN.mjs";
8
- import "./chunk-KWNIT4G4.mjs";
9
- import "./chunk-2L5TXBDK.mjs";
10
- import "./chunk-ZFXKCRJC.mjs";
11
- export {
12
- useAuthMutation,
13
- useAuthQuery,
14
- useAuthSubscription
15
- };
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
-
3
- declare const defaultAuthConfig: AuthConfig;
4
- declare const AuthConfigContext: React.Context<AuthConfig>;
5
- interface AuthConfig {
6
- debug?: boolean;
7
- disabled?: boolean;
8
- loginRedirectUri?: string;
9
- messageHandlerKeys?: string[];
10
- }
11
-
12
- export { type AuthConfig, AuthConfigContext, defaultAuthConfig };
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
-
3
- declare const defaultAuthConfig: AuthConfig;
4
- declare const AuthConfigContext: React.Context<AuthConfig>;
5
- interface AuthConfig {
6
- debug?: boolean;
7
- disabled?: boolean;
8
- loginRedirectUri?: string;
9
- messageHandlerKeys?: string[];
10
- }
11
-
12
- export { type AuthConfig, AuthConfigContext, defaultAuthConfig };
package/lib/authConfig.js DELETED
@@ -1,9 +0,0 @@
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,9 +0,0 @@
1
- import {
2
- AuthConfigContext,
3
- defaultAuthConfig
4
- } from "./chunk-JAFUI2JQ.mjs";
5
- import "./chunk-ZFXKCRJC.mjs";
6
- export {
7
- AuthConfigContext,
8
- defaultAuthConfig
9
- };
@@ -1,53 +0,0 @@
1
- import {
2
- useKeycloak
3
- } from "./chunk-7NZPJ2EN.mjs";
4
-
5
- // src/apollo.ts
6
- import { useQuery, useMutation, useSubscription } from "@apollo/client";
7
- function useAuthQuery(query, options) {
8
- const keycloak = useKeycloak();
9
- return useQuery(query, {
10
- ...options,
11
- skip: options?.skip || !keycloak?.authenticated || !keycloak.token,
12
- context: {
13
- ...options?.context,
14
- headers: {
15
- ...options?.context?.headers || {},
16
- authorization: `Bearer ${keycloak?.token}`
17
- }
18
- }
19
- });
20
- }
21
- function useAuthMutation(mutation, options) {
22
- const keycloak = useKeycloak();
23
- return useMutation(mutation, {
24
- ...options,
25
- context: {
26
- ...options?.context,
27
- headers: {
28
- ...options?.context?.headers || {},
29
- authorization: `Bearer ${keycloak?.token}`
30
- }
31
- }
32
- });
33
- }
34
- function useAuthSubscription(subscription, options) {
35
- const keycloak = useKeycloak();
36
- return useSubscription(subscription, {
37
- ...options,
38
- skip: options?.skip || !keycloak?.authenticated || !keycloak.token,
39
- context: {
40
- ...options?.context,
41
- headers: {
42
- ...options?.context?.headers || {},
43
- authorization: `Bearer ${keycloak?.token}`
44
- }
45
- }
46
- });
47
- }
48
-
49
- export {
50
- useAuthQuery,
51
- useAuthMutation,
52
- useAuthSubscription
53
- };
@@ -1,7 +0,0 @@
1
- // src/keycloak/context.ts
2
- import { createContext } from "react";
3
- var KeycloakContext = createContext(void 0);
4
-
5
- export {
6
- KeycloakContext
7
- };
@@ -1,27 +0,0 @@
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;
@@ -1,34 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/session/session.ts
2
- var _multiplatformone = require('multiplatform.one');
3
- var _react = require('next-auth/react');
4
- var _getServerSession;
5
- async function getSession(options, req, res) {
6
- if (_multiplatformone.MultiPlatform.isServer) {
7
- if (typeof _getServerSession === "function")
8
- return _getServerSession(options, req, res);
9
- const getSession2 = (await Promise.resolve().then(() => _interopRequireWildcard(require("next-auth")))).getServerSession;
10
- _getServerSession = (options2, req2, res2) => {
11
- return req2 && res2 ? getSession2(req2, res2, options2) : getSession2(options2);
12
- };
13
- return _getServerSession(options, req, res);
14
- }
15
- return _react.getSession.call(void 0, options);
16
- }
17
- var useSession = (options) => {
18
- return {};
19
- };
20
- if (_multiplatformone.MultiPlatform.isNext) {
21
- useSession = exports.useSession = (options) => {
22
- const nextSession = _react.useSession.call(void 0, options);
23
- return {
24
- update: nextSession.update,
25
- status: nextSession.status,
26
- session: nextSession.data
27
- };
28
- };
29
- }
30
-
31
-
32
-
33
-
34
- exports.getSession = getSession; exports.useSession = useSession;
@@ -1,9 +0,0 @@
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;
@@ -1,51 +0,0 @@
1
- import {
2
- useAuthConfig
3
- } from "./chunk-HTWZLBA4.mjs";
4
- import {
5
- useKeycloak
6
- } from "./chunk-7NZPJ2EN.mjs";
7
- import {
8
- persist,
9
- useAuthState
10
- } from "./chunk-WMH347OL.mjs";
11
-
12
- // src/provider/AfterAuth.tsx
13
- import React, { useEffect } from "react";
14
- var logger = console;
15
- function AfterAuth({ children }) {
16
- const authConfig = useAuthConfig();
17
- const authState = useAuthState();
18
- const keycloak = useKeycloak();
19
- useEffect(() => {
20
- if (!persist || !keycloak?.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
- }, [keycloak?.authenticated, keycloak?.token, keycloak?.idToken, keycloak?.refreshToken]);
30
- useEffect(() => {
31
- if (authConfig.debug && keycloak?.token)
32
- logger.debug("token", keycloak.token);
33
- }, [keycloak?.token]);
34
- useEffect(() => {
35
- if (authConfig.debug && keycloak?.idToken)
36
- logger.debug("idToken", keycloak.idToken);
37
- }, [keycloak?.idToken]);
38
- useEffect(() => {
39
- if (authConfig.debug && keycloak?.refreshToken)
40
- logger.debug("refreshToken", keycloak.refreshToken);
41
- }, [keycloak?.refreshToken]);
42
- useEffect(() => {
43
- if (authConfig.debug && keycloak?.authenticated)
44
- logger.debug("authenticated", keycloak.authenticated);
45
- }, [keycloak?.authenticated]);
46
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
47
- }
48
-
49
- export {
50
- AfterAuth
51
- };
@@ -1,13 +0,0 @@
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;
@@ -1,28 +0,0 @@
1
- import {
2
- AuthProvider
3
- } from "./chunk-W4PGLIAZ.mjs";
4
- import {
5
- AuthConfigContext
6
- } from "./chunk-JAFUI2JQ.mjs";
7
-
8
- // src/provider/KeycloakProvider.tsx
9
- import React, { useMemo } from "react";
10
- function KeycloakProvider({ children, debug, realm, clientId, baseUrl, session }) {
11
- const authConfig = useMemo(() => ({ debug }), [debug]);
12
- return /* @__PURE__ */ React.createElement(AuthConfigContext.Provider, { value: authConfig }, /* @__PURE__ */ React.createElement(
13
- AuthProvider,
14
- {
15
- sessionProvider: { session },
16
- keycloakConfig: {
17
- realm: realm || "main",
18
- clientId: clientId || "app",
19
- url: baseUrl
20
- }
21
- },
22
- children
23
- ));
24
- }
25
-
26
- export {
27
- KeycloakProvider
28
- };
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,27 +0,0 @@
1
- // src/token.ts
2
- import { jwtDecode } from "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(token);
19
- if (!exp)
20
- return false;
21
- return Math.floor(Date.now() / 1e3) <= exp;
22
- }
23
-
24
- export {
25
- validToken,
26
- isTokenValid
27
- };
@@ -1,50 +0,0 @@
1
- import {
2
- useTokensFromQuery
3
- } from "./chunk-L3HTVJ4B.mjs";
4
- import {
5
- useAuthConfig
6
- } from "./chunk-HTWZLBA4.mjs";
7
- import {
8
- useTokensFromState
9
- } from "./chunk-UKSHA3X3.mjs";
10
- import {
11
- useKeycloak
12
- } from "./chunk-7NZPJ2EN.mjs";
13
-
14
- // src/Authenticated.tsx
15
- import React, { useEffect } from "react";
16
- import { MultiPlatform } from "multiplatform.one";
17
- function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }) {
18
- const authConfig = useAuthConfig();
19
- const keycloak = useKeycloak();
20
- const tokensFromQuery = useTokensFromQuery();
21
- const tokensFromState = useTokensFromState();
22
- useEffect(() => {
23
- if (!keycloak || MultiPlatform.isIframe || 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__ */ React.createElement(React.Fragment, null, children);
34
- if (typeof keycloak === "undefined") {
35
- const LoadingComponent = loadingComponent;
36
- return LoadingComponent ? /* @__PURE__ */ React.createElement(LoadingComponent, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, authConfig.debug ? "loading" : null);
37
- }
38
- if (keycloak.authenticated)
39
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
40
- const LoggedOutComponent = loggedOutComponent;
41
- return LoggedOutComponent ? /* @__PURE__ */ React.createElement(LoggedOutComponent, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, authConfig.debug ? "not authenticated" : null);
42
- }
43
- function withAuthenticated(Component) {
44
- return (props) => /* @__PURE__ */ React.createElement(Authenticated, null, /* @__PURE__ */ React.createElement(Component, { ...props }));
45
- }
46
-
47
- export {
48
- Authenticated,
49
- withAuthenticated
50
- };