@multiplatform.one/keycloak 1.0.13 → 1.0.14

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 (167) hide show
  1. package/dist/cjs/Authenticated.js +3 -5
  2. package/dist/cjs/Authenticated.js.map +1 -1
  3. package/dist/cjs/Authenticated.native.js +7 -9
  4. package/dist/cjs/Authenticated.native.js.map +2 -2
  5. package/dist/cjs/authConfig.native.js.map +1 -1
  6. package/dist/cjs/hooks/index.native.js.map +1 -1
  7. package/dist/cjs/hooks/useAuthConfig.native.js.map +1 -1
  8. package/dist/cjs/hooks/useTokensFromQuery/index.js +1 -2
  9. package/dist/cjs/hooks/useTokensFromQuery/index.js.map +1 -1
  10. package/dist/cjs/hooks/useTokensFromQuery/index.native.js.map +1 -1
  11. package/dist/cjs/hooks/useTokensFromState.native.js.map +1 -1
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/keycloak/config.native.js.map +1 -1
  14. package/dist/cjs/keycloak/context.native.js.map +1 -1
  15. package/dist/cjs/keycloak/index.native.js.map +1 -1
  16. package/dist/cjs/keycloak/keycloak.js +4 -19
  17. package/dist/cjs/keycloak/keycloak.js.map +1 -1
  18. package/dist/cjs/keycloak/keycloak.native.js +59 -61
  19. package/dist/cjs/keycloak/keycloak.native.js.map +2 -2
  20. package/dist/cjs/provider/AfterAuth.native.js.map +1 -1
  21. package/dist/cjs/provider/AuthProvider/AuthProvider.js +10 -10
  22. package/dist/cjs/provider/AuthProvider/AuthProvider.js.map +1 -1
  23. package/dist/cjs/provider/AuthProvider/AuthProvider.native.js +61 -74
  24. package/dist/cjs/provider/AuthProvider/AuthProvider.native.js.map +2 -2
  25. package/dist/cjs/provider/AuthProvider/index.native.js.map +1 -1
  26. package/dist/cjs/provider/KeycloakProvider.native.js.map +1 -1
  27. package/dist/cjs/provider/index.native.js.map +1 -1
  28. package/dist/cjs/routes.js +4 -6
  29. package/dist/cjs/routes.js.map +1 -1
  30. package/dist/cjs/routes.native.js +71 -81
  31. package/dist/cjs/routes.native.js.map +3 -3
  32. package/dist/cjs/session/index.native.js.map +1 -1
  33. package/dist/cjs/session/session.js +3 -22
  34. package/dist/cjs/session/session.js.map +2 -2
  35. package/dist/cjs/session/session.native.js +53 -58
  36. package/dist/cjs/session/session.native.js.map +2 -2
  37. package/dist/cjs/state.native.js.map +1 -1
  38. package/dist/cjs/token.native.js.map +1 -1
  39. package/dist/cjs/types.native.js.map +1 -1
  40. package/dist/esm/Authenticated.js +3 -5
  41. package/dist/esm/Authenticated.js.map +1 -1
  42. package/dist/esm/Authenticated.mjs +1 -1
  43. package/dist/esm/Authenticated.native.js +7 -9
  44. package/dist/esm/Authenticated.native.js.map +3 -3
  45. package/dist/esm/authConfig.native.js.map +1 -1
  46. package/dist/esm/hooks/index.native.js.map +1 -1
  47. package/dist/esm/hooks/useAuthConfig.native.js.map +1 -1
  48. package/dist/esm/hooks/useTokensFromQuery/index.js +1 -2
  49. package/dist/esm/hooks/useTokensFromQuery/index.js.map +1 -1
  50. package/dist/esm/hooks/useTokensFromQuery/index.native.js.map +1 -1
  51. package/dist/esm/hooks/useTokensFromState.native.js.map +1 -1
  52. package/dist/esm/index.native.js.map +1 -1
  53. package/dist/esm/keycloak/config.native.js.map +1 -1
  54. package/dist/esm/keycloak/context.native.js.map +1 -1
  55. package/dist/esm/keycloak/index.native.js.map +1 -1
  56. package/dist/esm/keycloak/keycloak.js +5 -20
  57. package/dist/esm/keycloak/keycloak.js.map +1 -1
  58. package/dist/esm/keycloak/keycloak.mjs +2 -13
  59. package/dist/esm/keycloak/keycloak.native.js +59 -61
  60. package/dist/esm/keycloak/keycloak.native.js.map +2 -2
  61. package/dist/esm/provider/AfterAuth.native.js.map +1 -1
  62. package/dist/esm/provider/AuthProvider/AuthProvider.js +10 -10
  63. package/dist/esm/provider/AuthProvider/AuthProvider.js.map +1 -1
  64. package/dist/esm/provider/AuthProvider/AuthProvider.mjs +9 -5
  65. package/dist/esm/provider/AuthProvider/AuthProvider.native.js +61 -74
  66. package/dist/esm/provider/AuthProvider/AuthProvider.native.js.map +2 -2
  67. package/dist/esm/provider/AuthProvider/index.native.js.map +1 -1
  68. package/dist/esm/provider/KeycloakProvider.native.js.map +1 -1
  69. package/dist/esm/provider/index.native.js.map +1 -1
  70. package/dist/esm/routes.js +4 -6
  71. package/dist/esm/routes.js.map +1 -1
  72. package/dist/esm/routes.mjs +2 -2
  73. package/dist/esm/routes.native.js +71 -81
  74. package/dist/esm/routes.native.js.map +3 -3
  75. package/dist/esm/session/index.native.js.map +1 -1
  76. package/dist/esm/session/session.js +2 -13
  77. package/dist/esm/session/session.js.map +2 -2
  78. package/dist/esm/session/session.mjs +3 -12
  79. package/dist/esm/session/session.native.js +53 -58
  80. package/dist/esm/session/session.native.js.map +2 -2
  81. package/dist/esm/state.native.js.map +1 -1
  82. package/dist/esm/token.native.js.map +1 -1
  83. package/dist/jsx/Authenticated.js +3 -5
  84. package/dist/jsx/Authenticated.js.map +1 -1
  85. package/dist/jsx/Authenticated.mjs +1 -1
  86. package/dist/jsx/Authenticated.native.js +7 -9
  87. package/dist/jsx/Authenticated.native.js.map +3 -3
  88. package/dist/jsx/authConfig.native.js.map +1 -1
  89. package/dist/jsx/hooks/index.native.js.map +1 -1
  90. package/dist/jsx/hooks/useAuthConfig.native.js.map +1 -1
  91. package/dist/jsx/hooks/useTokensFromQuery/index.js +1 -2
  92. package/dist/jsx/hooks/useTokensFromQuery/index.js.map +1 -1
  93. package/dist/jsx/hooks/useTokensFromQuery/index.native.js.map +1 -1
  94. package/dist/jsx/hooks/useTokensFromState.native.js.map +1 -1
  95. package/dist/jsx/index.native.js.map +1 -1
  96. package/dist/jsx/keycloak/config.native.js.map +1 -1
  97. package/dist/jsx/keycloak/context.native.js.map +1 -1
  98. package/dist/jsx/keycloak/index.native.js.map +1 -1
  99. package/dist/jsx/keycloak/keycloak.js +5 -20
  100. package/dist/jsx/keycloak/keycloak.js.map +1 -1
  101. package/dist/jsx/keycloak/keycloak.mjs +2 -13
  102. package/dist/jsx/keycloak/keycloak.native.js +59 -61
  103. package/dist/jsx/keycloak/keycloak.native.js.map +2 -2
  104. package/dist/jsx/provider/AfterAuth.native.js.map +1 -1
  105. package/dist/jsx/provider/AuthProvider/AuthProvider.js +10 -10
  106. package/dist/jsx/provider/AuthProvider/AuthProvider.js.map +1 -1
  107. package/dist/jsx/provider/AuthProvider/AuthProvider.mjs +9 -5
  108. package/dist/jsx/provider/AuthProvider/AuthProvider.native.js +61 -74
  109. package/dist/jsx/provider/AuthProvider/AuthProvider.native.js.map +2 -2
  110. package/dist/jsx/provider/AuthProvider/index.native.js.map +1 -1
  111. package/dist/jsx/provider/KeycloakProvider.native.js.map +1 -1
  112. package/dist/jsx/provider/index.native.js.map +1 -1
  113. package/dist/jsx/routes.js +4 -6
  114. package/dist/jsx/routes.js.map +1 -1
  115. package/dist/jsx/routes.mjs +2 -2
  116. package/dist/jsx/routes.native.js +71 -81
  117. package/dist/jsx/routes.native.js.map +3 -3
  118. package/dist/jsx/session/index.native.js.map +1 -1
  119. package/dist/jsx/session/session.js +2 -13
  120. package/dist/jsx/session/session.js.map +2 -2
  121. package/dist/jsx/session/session.mjs +3 -12
  122. package/dist/jsx/session/session.native.js +53 -58
  123. package/dist/jsx/session/session.native.js.map +2 -2
  124. package/dist/jsx/state.native.js.map +1 -1
  125. package/dist/jsx/token.native.js.map +1 -1
  126. package/package.json +11 -13
  127. package/routes/index.d.ts +15 -15
  128. package/routes/index.js +15 -15
  129. package/src/@types/expoKeycloakAuth.d.ts +16 -16
  130. package/src/Authenticated.tsx +1 -2
  131. package/src/authConfig.ts +15 -15
  132. package/src/hooks/index.ts +15 -15
  133. package/src/hooks/useAuthConfig.ts +15 -15
  134. package/src/hooks/useTokensFromQuery/index.native.ts +15 -15
  135. package/src/hooks/useTokensFromQuery/index.ts +15 -15
  136. package/src/hooks/useTokensFromState.ts +15 -15
  137. package/src/index.ts +15 -15
  138. package/src/keycloak/config.ts +15 -15
  139. package/src/keycloak/context.ts +15 -15
  140. package/src/keycloak/index.ts +15 -15
  141. package/src/keycloak/keycloak.native.ts +15 -15
  142. package/src/keycloak/keycloak.ts +16 -36
  143. package/src/provider/AuthProvider/AuthProvider.tsx +7 -4
  144. package/src/provider/AuthProvider/index.ts +15 -15
  145. package/src/provider/index.ts +15 -15
  146. package/src/routes.ts +18 -21
  147. package/src/session/index.ts +15 -15
  148. package/src/session/session.native.ts +15 -15
  149. package/src/session/session.ts +18 -32
  150. package/src/state.ts +15 -15
  151. package/src/token.ts +15 -15
  152. package/src/types.ts +15 -15
  153. package/types/Authenticated.d.ts.map +1 -1
  154. package/types/keycloak/keycloak.d.ts +0 -2
  155. package/types/keycloak/keycloak.d.ts.map +1 -1
  156. package/types/provider/AuthProvider/AuthProvider.d.ts.map +1 -1
  157. package/types/routes.d.ts.map +1 -1
  158. package/types/session/session.d.ts +1 -2
  159. package/types/session/session.d.ts.map +1 -1
  160. package/dist/esm/hooks/useTokensFromQuery/index.native.mjs +0 -2
  161. package/dist/esm/keycloak/keycloak.native.mjs +0 -84
  162. package/dist/esm/provider/AuthProvider/AuthProvider.native.mjs +0 -111
  163. package/dist/esm/session/session.native.mjs +0 -7
  164. package/dist/jsx/hooks/useTokensFromQuery/index.native.mjs +0 -2
  165. package/dist/jsx/keycloak/keycloak.native.mjs +0 -84
  166. package/dist/jsx/provider/AuthProvider/AuthProvider.native.mjs +0 -111
  167. package/dist/jsx/session/session.native.mjs +0 -7
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/keycloak/config.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 27-04-2024 10:53:19
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/keycloak/config.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 27-04-2024 10:53:19
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  'use client';
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/keycloak/context.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 04-04-2024 15:50:39
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/keycloak/context.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  'use client';
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/keycloak/index.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 09-01-2024 11:59:25
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/keycloak/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  export * from './config';
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/keycloak/keycloak.native.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 09-01-2024 11:59:37
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/keycloak/keycloak.native.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  import type KeycloakClient from 'keycloak-js';
@@ -1,36 +1,33 @@
1
1
  /*
2
- * File: /src/keycloak/keycloak.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 09-01-2024 11:59:37
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/keycloak/keycloak.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  import type KeycloakClient from 'keycloak-js';
23
23
  import type { AccessTokenParsed, TokenParsed } from '../token';
24
- import type { AuthOptions } from 'next-auth';
25
24
  import type { AuthRequestPromptOptions } from 'expo-auth-session';
26
25
  import type { KeycloakMock } from '../types';
27
- import type { KeycloakProfile } from 'next-auth/providers/keycloak';
28
- import type { OAuthConfig } from 'next-auth/providers';
29
26
  import type { Session } from '../session/session';
30
27
  import { KeycloakConfigContext, type KeycloakConfig } from './config';
31
28
  import { KeycloakContext } from './context';
32
29
  import { MultiPlatform } from 'multiplatform.one';
33
- import { getSession, useSession } from '../session/session';
30
+ import { useSession } from '../session/session';
34
31
  import { jwtDecode } from 'jwt-decode';
35
32
  import { signIn, signOut } from 'next-auth/react';
36
33
  import { useAuthConfig } from '../hooks';
@@ -215,20 +212,3 @@ export function useKeycloak() {
215
212
  return new Keycloak(keycloakConfig, session as Session);
216
213
  }
217
214
  }
218
-
219
- export async function getKeycloak(options?: AuthOptions, req?: any, res?: any) {
220
- const keycloakProvider: OAuthConfig<KeycloakProfile> | undefined = options?.providers.find(
221
- (provider) => provider.id === 'keycloak',
222
- )?.options;
223
- const parts = keycloakProvider?.issuer?.split('/realms/');
224
- const keycloakConfig: KeycloakConfig = {
225
- realm: parts?.[1]?.split('/')[0] || '',
226
- url: parts?.[0] || '',
227
- clientId: keycloakProvider?.clientId || '',
228
- };
229
- const session = await getSession(options, req, res);
230
- if (session?.accessToken) {
231
- return new Keycloak(keycloakConfig, session as Session);
232
- }
233
- return new Keycloak(keycloakConfig);
234
- }
@@ -264,15 +264,18 @@ export function AuthProvider({ children, sessionProvider, keycloakInitOptions, k
264
264
  }
265
265
  }, []);
266
266
 
267
- return (
268
- <SessionProvider {...sessionProvider}>
267
+ function render() {
268
+ return (
269
269
  <KeycloakConfigContext.Provider value={keycloakConfig}>
270
270
  <KeycloakContext.Provider value={keycloak}>
271
271
  <AfterAuth>{children}</AfterAuth>
272
272
  </KeycloakContext.Provider>
273
273
  </KeycloakConfigContext.Provider>
274
- </SessionProvider>
275
- );
274
+ );
275
+ }
276
+
277
+ if (MultiPlatform.isElectron) return render();
278
+ return <SessionProvider {...sessionProvider}>{render()}</SessionProvider>;
276
279
  }
277
280
 
278
281
  const defaultKeycloakInitOptions: KeycloakInitOptions = {
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/provider/AuthProvider/index.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 10-01-2024 13:43:20
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/provider/AuthProvider/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  export * from './AuthProvider';
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/provider/index.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 09-01-2024 11:29:13
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/provider/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  export * from './AfterAuth';
package/src/routes.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/routes.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 09-01-2024 11:32:46
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/routes.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 23-04-2024 05:52:22
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  import type { AccessTokenParsed } from './token';
@@ -27,15 +27,12 @@ import type { Session } from './session';
27
27
  import { getServerSession } from 'next-auth';
28
28
  import { jwtDecode } from 'jwt-decode';
29
29
 
30
- const KeycloakProvider = require('next-auth/providers/keycloak')
31
- .default as typeof import('next-auth/providers/keycloak').default;
32
-
33
- let _nextAuth: AuthOptions | undefined;
34
-
35
30
  const NextAuth = require('next-auth').default as typeof import('next-auth').default;
36
31
  const NextResponse = require('next/server').NextResponse as typeof import('next/server').NextResponse;
37
-
38
32
  const logger = console;
33
+ let _nextAuth: AuthOptions | undefined;
34
+ const KeycloakProvider = require('next-auth/providers/keycloak')
35
+ .default as typeof import('next-auth/providers/keycloak').default;
39
36
 
40
37
  export function createAuthHandler(options: AuthHandlerOptions) {
41
38
  return NextAuth(createNextAuthOptions(options));
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/session/index.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 11-01-2024 02:47:42
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/session/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  export * from './session';
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/session/session.native.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 10-01-2024 02:31:26
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/session/session.native.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  import type { SessionContextValue } from './session';
@@ -1,42 +1,28 @@
1
1
  /*
2
- * File: /src/session/session.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 10-01-2024 02:31:26
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/session/session.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
- import type { AuthOptions, Session as NextSession } from 'next-auth';
22
+ import type { Session as NextSession } from 'next-auth';
23
23
  import type { SessionContextValue as NextSessionContextValue, UseSessionOptions } from 'next-auth/react';
24
24
  import { MultiPlatform } from 'multiplatform.one';
25
- import { useSession as useNextSession, getSession as getNextSession } from 'next-auth/react';
26
-
27
- let _getServerSession: ((options?: AuthOptions, req?: any, res?: any) => Promise<Session | null>) | undefined;
28
-
29
- export async function getSession(options?: AuthOptions, req?: any, res?: any): Promise<Session | null> {
30
- if (MultiPlatform.isServer) {
31
- if (typeof _getServerSession === 'function') return _getServerSession(options as AuthOptions, req, res);
32
- const getSession = (await import('next-auth')).getServerSession;
33
- _getServerSession = (options?: AuthOptions, req?: any, res?: any) => {
34
- return req && res ? getSession(req, res, options as any) : getSession(options as any);
35
- };
36
- return _getServerSession(options as AuthOptions, req, res);
37
- }
38
- return getNextSession();
39
- }
25
+ import { useSession as useNextSession } from 'next-auth/react';
40
26
 
41
27
  export type SessionContextValue<R extends boolean> = Partial<
42
28
  Omit<NextSessionContextValue<R> & { session: Session }, 'data'>
@@ -46,7 +32,7 @@ let useSession = <R extends boolean>(_options?: UseSessionOptions<R>): SessionCo
46
32
  return {};
47
33
  };
48
34
 
49
- if (MultiPlatform.isNext) {
35
+ if (MultiPlatform.isNext && !MultiPlatform.isElectron) {
50
36
  useSession = <R extends boolean>(options?: UseSessionOptions<R>): SessionContextValue<R> => {
51
37
  const nextSession = useNextSession(options);
52
38
  return {
package/src/state.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/state.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 22-06-2023 10:07:56
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2023
2
+ * File: /src/state.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  import { MultiPlatform } from 'multiplatform.one';
package/src/token.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  /*
2
- * File: /src/token.ts
3
- * Project: @multiplatform.one/keycloak
4
- * File Created: 10-01-2024 16:19:33
5
- * Author: Clay Risser
6
- * -----
7
- * BitSpur (c) Copyright 2021 - 2024
2
+ * File: /src/token.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 04-04-2024 15:50:39
5
+ * Author: Clay Risser
6
+ * -----
7
+ * BitSpur (c) Copyright 2021 - 2024
8
8
  *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
12
  *
13
- * http://www.apache.org/licenses/LICENSE-2.0
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
14
  *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
20
  */
21
21
 
22
22
  import type { KeycloakTokenParsed } from 'keycloak-js';