@multiplatform.one/keycloak 0.7.15 → 0.7.17

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 (228) hide show
  1. package/lib/@types/expoKeycloakAuth.d.js +1 -1
  2. package/lib/Authenticated.d.mts +2 -2
  3. package/lib/Authenticated.d.ts +2 -2
  4. package/lib/Authenticated.js +20 -19
  5. package/lib/Authenticated.mjs +13 -13
  6. package/lib/authConfig.d.mts +2 -4
  7. package/lib/authConfig.d.ts +2 -4
  8. package/lib/authConfig.js +9 -8
  9. package/lib/authConfig.mjs +2 -2
  10. package/lib/chunk-2BKS6UM5.js +51 -0
  11. package/lib/chunk-2BSUCVXL.js +50 -0
  12. package/lib/chunk-2L5TXBDK.mjs +7 -0
  13. package/lib/chunk-2VDDEPLF.js +27 -0
  14. package/lib/chunk-32AVT4GA.js +9 -0
  15. package/lib/chunk-3ZTSLDX7.js +13 -0
  16. package/lib/chunk-6F4PWJZI.js +1 -0
  17. package/lib/{chunk-7MTPH6XK.mjs → chunk-6FRYV4MK.mjs} +10 -9
  18. package/lib/chunk-A2V2S4HP.js +22 -0
  19. package/lib/chunk-BUZONXAW.js +1 -0
  20. package/lib/{chunk-BVB33X7V.mjs → chunk-CGLMLNUS.mjs} +61 -81
  21. package/lib/chunk-FU4CT24B.mjs +32 -0
  22. package/lib/{chunk-Y4XMF3R6.mjs → chunk-HTWZLBA4.mjs} +1 -1
  23. package/lib/chunk-I5FNGKQ6.js +16 -0
  24. package/lib/{chunk-64PPU7Q3.mjs → chunk-JAFUI2JQ.mjs} +1 -5
  25. package/lib/{chunk-NXTVYIBR.mjs → chunk-L3HTVJ4B.mjs} +2 -0
  26. package/lib/chunk-MDAAMGTE.js +1 -0
  27. package/lib/chunk-NH335CDK.js +32 -0
  28. package/lib/chunk-OA5TSQWZ.mjs +50 -0
  29. package/lib/chunk-OBB23GPX.mjs +0 -0
  30. package/lib/chunk-OZLV3US5.js +245 -0
  31. package/lib/chunk-P57PW2II.js +11 -0
  32. package/lib/chunk-TUJRPTZE.js +13 -0
  33. package/lib/chunk-UESWAK47.mjs +0 -0
  34. package/lib/chunk-UH4K7HGE.mjs +163 -0
  35. package/lib/{chunk-UOKDJT5L.mjs → chunk-UKSHA3X3.mjs} +2 -2
  36. package/lib/chunk-VS4M7GMO.js +1 -0
  37. package/lib/chunk-WBQAMGXK.mjs +0 -0
  38. package/lib/{chunk-AD6VPMID.mjs → chunk-WMH347OL.mjs} +5 -3
  39. package/lib/chunk-WS4IMGVL.js +1 -0
  40. package/lib/chunk-X53FOCXA.js +28 -0
  41. package/lib/chunk-Y23BWOII.mjs +51 -0
  42. package/lib/chunk-Y5MS3XVZ.mjs +28 -0
  43. package/lib/chunk-YACGLW5Q.js +7 -0
  44. package/lib/chunk-ZCBD6HWK.js +1 -0
  45. package/lib/chunk-ZFXKCRJC.mjs +11 -0
  46. package/lib/chunk-ZW4GP2I5.js +163 -0
  47. package/lib/hooks/index.d.mts +0 -4
  48. package/lib/hooks/index.d.ts +0 -4
  49. package/lib/hooks/index.js +19 -23
  50. package/lib/hooks/index.mjs +8 -23
  51. package/lib/hooks/useAuthConfig.js +8 -8
  52. package/lib/hooks/useAuthConfig.mjs +3 -3
  53. package/lib/hooks/useTokensFromQuery/index.js +7 -7
  54. package/lib/hooks/useTokensFromQuery/index.mjs +2 -2
  55. package/lib/hooks/useTokensFromQuery/index.native.js +5 -8
  56. package/lib/hooks/useTokensFromQuery/index.native.mjs +1 -1
  57. package/lib/hooks/useTokensFromState.js +9 -9
  58. package/lib/hooks/useTokensFromState.mjs +4 -4
  59. package/lib/index.d.mts +10 -7
  60. package/lib/index.d.ts +10 -7
  61. package/lib/index.js +62 -34
  62. package/lib/index.mjs +32 -26
  63. package/lib/keycloak/context.d.mts +12 -0
  64. package/lib/keycloak/context.d.ts +12 -0
  65. package/lib/keycloak/context.js +7 -0
  66. package/lib/keycloak/context.mjs +7 -0
  67. package/lib/keycloak/index.d.mts +7 -0
  68. package/lib/keycloak/index.d.ts +7 -0
  69. package/lib/keycloak/index.js +14 -0
  70. package/lib/keycloak/index.mjs +14 -0
  71. package/lib/keycloak/keycloak.d.mts +37 -0
  72. package/lib/keycloak/keycloak.d.ts +37 -0
  73. package/lib/keycloak/keycloak.js +13 -0
  74. package/lib/keycloak/keycloak.mjs +13 -0
  75. package/lib/keycloak/keycloak.native.d.mts +33 -0
  76. package/lib/keycloak/keycloak.native.d.ts +33 -0
  77. package/lib/keycloak/keycloak.native.js +134 -0
  78. package/lib/keycloak/keycloak.native.mjs +134 -0
  79. package/lib/provider/{afterAuth.d.ts → AfterAuth.d.mts} +6 -7
  80. package/lib/provider/{afterAuth.d.mts → AfterAuth.d.ts} +6 -7
  81. package/lib/provider/AfterAuth.js +18 -0
  82. package/lib/provider/AfterAuth.mjs +18 -0
  83. package/lib/provider/AuthProvider/AuthProvider.d.mts +37 -0
  84. package/lib/provider/AuthProvider/AuthProvider.d.ts +37 -0
  85. package/lib/provider/AuthProvider/AuthProvider.js +19 -0
  86. package/lib/provider/AuthProvider/AuthProvider.mjs +19 -0
  87. package/lib/provider/{keycloakProvider.native.d.ts → AuthProvider/AuthProvider.native.d.mts} +9 -9
  88. package/lib/provider/{keycloakProvider.native.d.mts → AuthProvider/AuthProvider.native.d.ts} +9 -9
  89. package/lib/provider/AuthProvider/AuthProvider.native.js +25 -0
  90. package/lib/provider/AuthProvider/AuthProvider.native.mjs +25 -0
  91. package/lib/provider/AuthProvider/index.d.mts +4 -0
  92. package/lib/provider/AuthProvider/index.d.ts +4 -0
  93. package/lib/provider/AuthProvider/index.js +20 -0
  94. package/lib/provider/AuthProvider/index.mjs +20 -0
  95. package/lib/provider/KeycloakProvider.d.mts +34 -0
  96. package/lib/provider/KeycloakProvider.d.ts +34 -0
  97. package/lib/provider/KeycloakProvider.js +21 -0
  98. package/lib/provider/KeycloakProvider.mjs +21 -0
  99. package/lib/provider/index.d.mts +8 -39
  100. package/lib/provider/index.d.ts +8 -39
  101. package/lib/provider/index.js +28 -22
  102. package/lib/provider/index.mjs +22 -19
  103. package/lib/routes.d.mts +28 -0
  104. package/lib/routes.d.ts +28 -0
  105. package/lib/routes.js +127 -0
  106. package/lib/routes.mjs +127 -0
  107. package/lib/session/index.d.mts +3 -0
  108. package/lib/session/index.d.ts +3 -0
  109. package/lib/session/index.js +10 -0
  110. package/lib/session/index.mjs +10 -0
  111. package/lib/session/session.d.mts +18 -0
  112. package/lib/session/session.d.ts +18 -0
  113. package/lib/session/session.js +9 -0
  114. package/lib/session/session.mjs +9 -0
  115. package/lib/session/session.native.d.mts +8 -0
  116. package/lib/session/session.native.d.ts +8 -0
  117. package/lib/session/session.native.js +13 -0
  118. package/lib/session/session.native.mjs +13 -0
  119. package/lib/{state/index.d.ts → state.d.mts} +2 -1
  120. package/lib/{state/index.d.mts → state.d.ts} +2 -1
  121. package/lib/state.js +9 -0
  122. package/lib/state.mjs +9 -0
  123. package/lib/token.d.mts +17 -0
  124. package/lib/token.d.ts +17 -0
  125. package/lib/token.js +9 -0
  126. package/lib/{util.mjs → token.mjs} +2 -2
  127. package/lib/types.d.mts +5 -2
  128. package/lib/types.d.ts +5 -2
  129. package/lib/types.js +1 -8
  130. package/lib/types.mjs +1 -7
  131. package/package.json +28 -28
  132. package/routes/index.d.ts +22 -0
  133. package/routes/index.js +22 -0
  134. package/src/Authenticated.tsx +27 -17
  135. package/src/authConfig.ts +3 -9
  136. package/src/hooks/index.ts +0 -3
  137. package/src/hooks/useTokensFromQuery/index.ts +1 -0
  138. package/src/hooks/useTokensFromState.ts +1 -1
  139. package/src/index.ts +3 -0
  140. package/src/{@types/coreJsPure.d.ts → keycloak/context.ts} +6 -11
  141. package/src/{hooks/useCurrentRouteName/index.native.ts → keycloak/index.ts} +4 -11
  142. package/src/keycloak/keycloak.native.ts +148 -0
  143. package/src/keycloak/keycloak.ts +175 -0
  144. package/src/provider/AfterAuth.tsx +63 -0
  145. package/src/provider/{keycloakProvider.native.tsx → AuthProvider/AuthProvider.native.tsx} +8 -16
  146. package/src/provider/{keycloakProvider.tsx → AuthProvider/AuthProvider.tsx} +81 -94
  147. package/src/provider/AuthProvider/index.ts +22 -0
  148. package/src/provider/KeycloakProvider.tsx +53 -0
  149. package/src/provider/index.ts +24 -0
  150. package/src/routes.ts +163 -0
  151. package/src/session/index.ts +22 -0
  152. package/src/{hooks/useCurrentRouteName/index.ts → session/session.native.ts} +11 -14
  153. package/src/session/session.ts +68 -0
  154. package/src/{state/index.ts → state.ts} +5 -4
  155. package/src/{util.ts → token.ts} +25 -11
  156. package/src/types.ts +4 -1
  157. package/lib/@types/coreJsPure.d.d.mts +0 -2
  158. package/lib/@types/coreJsPure.d.d.ts +0 -2
  159. package/lib/@types/coreJsPure.d.js +0 -1
  160. package/lib/chunk-3ZPHNEJL.js +0 -11
  161. package/lib/chunk-6NDWOV55.js +0 -1
  162. package/lib/chunk-A7UBOIAL.js +0 -13
  163. package/lib/chunk-AUUZ6BI7.js +0 -78
  164. package/lib/chunk-C2FNSVJO.js +0 -17
  165. package/lib/chunk-J4CCMILN.mjs +0 -41
  166. package/lib/chunk-K33RKJZX.js +0 -443
  167. package/lib/chunk-KLLABHIC.js +0 -13
  168. package/lib/chunk-L5HMOY4M.mjs +0 -18
  169. package/lib/chunk-MZ6E62HK.js +0 -33
  170. package/lib/chunk-NWRANDZ6.js +0 -98
  171. package/lib/chunk-OYWAYMFN.js +0 -17
  172. package/lib/chunk-RPUOO7AV.mjs +0 -10
  173. package/lib/chunk-RYM7KERK.mjs +0 -52
  174. package/lib/chunk-UBVYEZI3.js +0 -1
  175. package/lib/chunk-UHTKOFS6.mjs +0 -84
  176. package/lib/chunk-UL6L5ONI.js +0 -460
  177. package/lib/chunk-W5DJLFTQ.js +0 -56
  178. package/lib/chunk-WT5W6BSZ.js +0 -161
  179. package/lib/chunk-XEO3YXBM.js +0 -22
  180. package/lib/chunk-XO4W2SMN.mjs +0 -50
  181. package/lib/chunk-XVPWAAZ4.mjs +0 -76
  182. package/lib/chunk-YGNNHTFE.js +0 -12
  183. package/lib/hooks/useCurrentRouteName/index.d.mts +0 -3
  184. package/lib/hooks/useCurrentRouteName/index.d.ts +0 -3
  185. package/lib/hooks/useCurrentRouteName/index.js +0 -7
  186. package/lib/hooks/useCurrentRouteName/index.mjs +0 -7
  187. package/lib/hooks/useCurrentRouteName/index.native.d.mts +0 -3
  188. package/lib/hooks/useCurrentRouteName/index.native.d.ts +0 -3
  189. package/lib/hooks/useCurrentRouteName/index.native.js +0 -14
  190. package/lib/hooks/useCurrentRouteName/index.native.mjs +0 -14
  191. package/lib/hooks/useKeycloak/index.d.mts +0 -46
  192. package/lib/hooks/useKeycloak/index.d.ts +0 -46
  193. package/lib/hooks/useKeycloak/index.js +0 -11
  194. package/lib/hooks/useKeycloak/index.mjs +0 -12
  195. package/lib/hooks/useKeycloak/useKeycloak.d.mts +0 -2
  196. package/lib/hooks/useKeycloak/useKeycloak.d.ts +0 -2
  197. package/lib/hooks/useKeycloak/useKeycloak.js +0 -10
  198. package/lib/hooks/useKeycloak/useKeycloak.mjs +0 -11
  199. package/lib/hooks/useKeycloak/useKeycloak.native.d.mts +0 -20
  200. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +0 -20
  201. package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -80
  202. package/lib/hooks/useKeycloak/useKeycloak.native.mjs +0 -69
  203. package/lib/hooks/useLogin.d.mts +0 -3
  204. package/lib/hooks/useLogin.d.ts +0 -3
  205. package/lib/hooks/useLogin.js +0 -11
  206. package/lib/hooks/useLogin.mjs +0 -11
  207. package/lib/provider/afterAuth.js +0 -18
  208. package/lib/provider/afterAuth.mjs +0 -18
  209. package/lib/provider/keycloakProvider.d.mts +0 -42
  210. package/lib/provider/keycloakProvider.d.ts +0 -42
  211. package/lib/provider/keycloakProvider.js +0 -20
  212. package/lib/provider/keycloakProvider.mjs +0 -21
  213. package/lib/provider/keycloakProvider.native.js +0 -87
  214. package/lib/provider/keycloakProvider.native.mjs +0 -30
  215. package/lib/state/index.js +0 -7
  216. package/lib/state/index.mjs +0 -7
  217. package/lib/util.d.mts +0 -4
  218. package/lib/util.d.ts +0 -4
  219. package/lib/util.js +0 -8
  220. package/src/hooks/useKeycloak/index.ts +0 -47
  221. package/src/hooks/useKeycloak/useKeycloak.native.ts +0 -95
  222. package/src/hooks/useKeycloak/useKeycloak.ts +0 -106
  223. package/src/hooks/useLogin.ts +0 -47
  224. package/src/provider/afterAuth.tsx +0 -65
  225. package/src/provider/index.tsx +0 -117
  226. /package/lib/{@types/coreJsPure.d.mjs → chunk-HH32BME2.mjs} +0 -0
  227. /package/lib/{chunk-2GUOEPFY.mjs → chunk-JPQI72HR.mjs} +0 -0
  228. /package/lib/{chunk-AYKQVWMR.mjs → chunk-OAUYHIWG.mjs} +0 -0
@@ -1,69 +0,0 @@
1
- import {
2
- __publicField
3
- } from "../../chunk-RPUOO7AV.mjs";
4
-
5
- // src/hooks/useKeycloak/useKeycloak.native.ts
6
- import atob from "core-js-pure/stable/atob";
7
- import escape from "core-js-pure/stable/escape";
8
- import { MultiPlatform } from "multiplatform.one";
9
- import { useKeycloak as useExpoKeycloak } from "expo-keycloak-auth";
10
- function useKeycloak() {
11
- if (MultiPlatform.isStorybook)
12
- return { authenticated: true };
13
- const { ready, login, isLoggedIn, token, logout, refreshToken } = useExpoKeycloak();
14
- const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || void 0, refreshToken || void 0);
15
- return keycloak;
16
- }
17
- var ExpoKeycloak = class {
18
- constructor(ready, isLoggedIn, login, logout, token, refreshToken) {
19
- this.logout = logout;
20
- this.token = token;
21
- this.refreshToken = refreshToken;
22
- __publicField(this, "authenticated");
23
- __publicField(this, "tokenParsed");
24
- __publicField(this, "refreshTokenParsed");
25
- __publicField(this, "subject");
26
- __publicField(this, "realmAccess");
27
- __publicField(this, "resourceAccess");
28
- __publicField(this, "login");
29
- if (ready)
30
- this.authenticated = isLoggedIn;
31
- if (this.authenticated) {
32
- if (this.token)
33
- this.tokenParsed = decodeToken(this.token);
34
- if (this.refreshToken) {
35
- this.refreshTokenParsed = decodeToken(this.refreshToken);
36
- }
37
- if (this.tokenParsed) {
38
- this.subject = this.tokenParsed.sub;
39
- this.realmAccess = this.tokenParsed.realm_access;
40
- this.resourceAccess = this.tokenParsed.resource_access;
41
- }
42
- }
43
- this.login = () => login();
44
- }
45
- };
46
- function decodeToken(str) {
47
- str = str.split(".")[1];
48
- str = str.replace(/-/g, "+");
49
- str = str.replace(/_/g, "/");
50
- switch (str.length % 4) {
51
- case 0:
52
- break;
53
- case 2:
54
- str += "==";
55
- break;
56
- case 3:
57
- str += "=";
58
- break;
59
- default:
60
- throw "Invalid token";
61
- }
62
- str = decodeURIComponent(escape(atob(str)));
63
- str = JSON.parse(str);
64
- return str;
65
- }
66
- export {
67
- ExpoKeycloak,
68
- useKeycloak
69
- };
@@ -1,3 +0,0 @@
1
- declare function useLogin(loginRoute?: string): () => void;
2
-
3
- export { useLogin };
@@ -1,3 +0,0 @@
1
- declare function useLogin(loginRoute?: string): () => void;
2
-
3
- export { useLogin };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkMZ6E62HKjs = require("../chunk-MZ6E62HK.js");
6
- require("../chunk-OYWAYMFN.js");
7
- require("../chunk-UL6L5ONI.js");
8
- require("../chunk-3ZPHNEJL.js");
9
- require("../chunk-A7UBOIAL.js");
10
- require("../chunk-XEO3YXBM.js");
11
- exports.useLogin = _chunkMZ6E62HKjs.useLogin;
@@ -1,11 +0,0 @@
1
- import {
2
- useLogin
3
- } from "../chunk-J4CCMILN.mjs";
4
- import "../chunk-L5HMOY4M.mjs";
5
- import "../chunk-UHTKOFS6.mjs";
6
- import "../chunk-Y4XMF3R6.mjs";
7
- import "../chunk-64PPU7Q3.mjs";
8
- import "../chunk-RPUOO7AV.mjs";
9
- export {
10
- useLogin
11
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkW5DJLFTQjs = require("../chunk-W5DJLFTQ.js");
6
- require("../chunk-UBVYEZI3.js");
7
- require("../chunk-6NDWOV55.js");
8
- require("../chunk-KLLABHIC.js");
9
- require("../chunk-MZ6E62HK.js");
10
- require("../chunk-OYWAYMFN.js");
11
- require("../chunk-UL6L5ONI.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-XEO3YXBM.js");
18
- exports.AfterAuth = _chunkW5DJLFTQjs.AfterAuth;
@@ -1,18 +0,0 @@
1
- import {
2
- AfterAuth
3
- } from "../chunk-XO4W2SMN.mjs";
4
- import "../chunk-AYKQVWMR.mjs";
5
- import "../chunk-2GUOEPFY.mjs";
6
- import "../chunk-NXTVYIBR.mjs";
7
- import "../chunk-J4CCMILN.mjs";
8
- import "../chunk-L5HMOY4M.mjs";
9
- import "../chunk-UHTKOFS6.mjs";
10
- import "../chunk-Y4XMF3R6.mjs";
11
- import "../chunk-UOKDJT5L.mjs";
12
- import "../chunk-AD6VPMID.mjs";
13
- import "../chunk-64PPU7Q3.mjs";
14
- import "../chunk-7MTPH6XK.mjs";
15
- import "../chunk-RPUOO7AV.mjs";
16
- export {
17
- AfterAuth
18
- };
@@ -1,42 +0,0 @@
1
- import React__default, { ReactNode, ComponentType } from 'react';
2
- import { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';
3
- import { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';
4
-
5
- /**
6
- * File: /src/provider/keycloakProvider.tsx
7
- * Project: @multiplatform.one/keycloak
8
- * File Created: 22-06-2023 10:07:56
9
- * Author: Clay Risser
10
- * -----
11
- * BitSpur (c) Copyright 2021 - 2023
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
-
26
- interface KeycloakProviderProps {
27
- children: ReactNode;
28
- cookies?: unknown;
29
- keycloakConfig: KeycloakConfig;
30
- keycloakInitOptions?: KeycloakInitOptions;
31
- loadingComponent?: ComponentType;
32
- onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;
33
- onTokens?: (tokens: AuthClientTokens) => void;
34
- }
35
- declare function KeycloakProvider({ children, cookies, keycloakConfig, keycloakInitOptions, loadingComponent, onEvent, onTokens, }: KeycloakProviderProps): React__default.JSX.Element;
36
- declare const defaultKeycloakInitOptions: KeycloakInitOptions;
37
- interface MessageSchema {
38
- type: string;
39
- payload?: string;
40
- }
41
-
42
- export { KeycloakProvider, type KeycloakProviderProps, type MessageSchema, defaultKeycloakInitOptions };
@@ -1,42 +0,0 @@
1
- import React__default, { ReactNode, ComponentType } from 'react';
2
- import { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';
3
- import { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';
4
-
5
- /**
6
- * File: /src/provider/keycloakProvider.tsx
7
- * Project: @multiplatform.one/keycloak
8
- * File Created: 22-06-2023 10:07:56
9
- * Author: Clay Risser
10
- * -----
11
- * BitSpur (c) Copyright 2021 - 2023
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
-
26
- interface KeycloakProviderProps {
27
- children: ReactNode;
28
- cookies?: unknown;
29
- keycloakConfig: KeycloakConfig;
30
- keycloakInitOptions?: KeycloakInitOptions;
31
- loadingComponent?: ComponentType;
32
- onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;
33
- onTokens?: (tokens: AuthClientTokens) => void;
34
- }
35
- declare function KeycloakProvider({ children, cookies, keycloakConfig, keycloakInitOptions, loadingComponent, onEvent, onTokens, }: KeycloakProviderProps): React__default.JSX.Element;
36
- declare const defaultKeycloakInitOptions: KeycloakInitOptions;
37
- interface MessageSchema {
38
- type: string;
39
- payload?: string;
40
- }
41
-
42
- export { KeycloakProvider, type KeycloakProviderProps, type MessageSchema, defaultKeycloakInitOptions };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkK33RKJZXjs = require("../chunk-K33RKJZX.js");
6
- require("../chunk-W5DJLFTQ.js");
7
- require("../chunk-UBVYEZI3.js");
8
- require("../chunk-6NDWOV55.js");
9
- require("../chunk-KLLABHIC.js");
10
- require("../chunk-MZ6E62HK.js");
11
- require("../chunk-OYWAYMFN.js");
12
- require("../chunk-UL6L5ONI.js");
13
- require("../chunk-3ZPHNEJL.js");
14
- require("../chunk-YGNNHTFE.js");
15
- require("../chunk-C2FNSVJO.js");
16
- require("../chunk-A7UBOIAL.js");
17
- require("../chunk-NWRANDZ6.js");
18
- require("../chunk-XEO3YXBM.js");
19
- exports.KeycloakProvider = _chunkK33RKJZXjs.KeycloakProvider;
20
- exports.defaultKeycloakInitOptions = _chunkK33RKJZXjs.defaultKeycloakInitOptions;
@@ -1,21 +0,0 @@
1
- import {
2
- KeycloakProvider,
3
- defaultKeycloakInitOptions
4
- } from "../chunk-BVB33X7V.mjs";
5
- import "../chunk-XO4W2SMN.mjs";
6
- import "../chunk-AYKQVWMR.mjs";
7
- import "../chunk-2GUOEPFY.mjs";
8
- import "../chunk-NXTVYIBR.mjs";
9
- import "../chunk-J4CCMILN.mjs";
10
- import "../chunk-L5HMOY4M.mjs";
11
- import "../chunk-UHTKOFS6.mjs";
12
- import "../chunk-Y4XMF3R6.mjs";
13
- import "../chunk-UOKDJT5L.mjs";
14
- import "../chunk-AD6VPMID.mjs";
15
- import "../chunk-64PPU7Q3.mjs";
16
- import "../chunk-7MTPH6XK.mjs";
17
- import "../chunk-RPUOO7AV.mjs";
18
- export {
19
- KeycloakProvider,
20
- defaultKeycloakInitOptions
21
- };
@@ -1,87 +0,0 @@
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
- function ownKeys(object, enumerableOnly) {
31
- var keys = Object.keys(object);
32
- if (Object.getOwnPropertySymbols) {
33
- var symbols = Object.getOwnPropertySymbols(object);
34
- if (enumerableOnly) {
35
- symbols = symbols.filter(function(sym) {
36
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
37
- });
38
- }
39
- keys.push.apply(keys, symbols);
40
- }
41
- return keys;
42
- }
43
- function _object_spread_props(target, source) {
44
- source = source != null ? source : {};
45
- if (Object.getOwnPropertyDescriptors) {
46
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
47
- } else {
48
- ownKeys(Object(source)).forEach(function(key) {
49
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
50
- });
51
- }
52
- return target;
53
- }
54
- Object.defineProperty(exports, "__esModule", {
55
- value: true
56
- });
57
- function _interopRequireDefault(obj) {
58
- return obj && obj.__esModule ? obj : {
59
- default: obj
60
- };
61
- }
62
- var _chunkW5DJLFTQjs = require("../chunk-W5DJLFTQ.js");
63
- require("../chunk-UBVYEZI3.js");
64
- require("../chunk-6NDWOV55.js");
65
- require("../chunk-KLLABHIC.js");
66
- require("../chunk-MZ6E62HK.js");
67
- require("../chunk-OYWAYMFN.js");
68
- require("../chunk-UL6L5ONI.js");
69
- require("../chunk-3ZPHNEJL.js");
70
- require("../chunk-YGNNHTFE.js");
71
- require("../chunk-C2FNSVJO.js");
72
- require("../chunk-A7UBOIAL.js");
73
- require("../chunk-NWRANDZ6.js");
74
- require("../chunk-XEO3YXBM.js");
75
- // src/provider/keycloakProvider.native.tsx
76
- var _react = require("react");
77
- var _react2 = _interopRequireDefault(_react);
78
- var _expokeycloakauth = require("expo-keycloak-auth");
79
- var KeycloakProvider = function(param) {
80
- var children = param.children, keycloakConfig = param.keycloakConfig;
81
- var clonedKeycloakConfig = _object_spread_props(_object_spread({}, keycloakConfig), {
82
- url: keycloakConfig.url
83
- });
84
- delete keycloakConfig.baseUrl;
85
- return /* @__PURE__ */ _react2.default.createElement(_expokeycloakauth.KeycloakProvider, _object_spread({}, clonedKeycloakConfig), /* @__PURE__ */ _react2.default.createElement(_chunkW5DJLFTQjs.AfterAuth, null, children));
86
- };
87
- exports.KeycloakProvider = KeycloakProvider;
@@ -1,30 +0,0 @@
1
- import {
2
- AfterAuth
3
- } from "../chunk-XO4W2SMN.mjs";
4
- import "../chunk-AYKQVWMR.mjs";
5
- import "../chunk-2GUOEPFY.mjs";
6
- import "../chunk-NXTVYIBR.mjs";
7
- import "../chunk-J4CCMILN.mjs";
8
- import "../chunk-L5HMOY4M.mjs";
9
- import "../chunk-UHTKOFS6.mjs";
10
- import "../chunk-Y4XMF3R6.mjs";
11
- import "../chunk-UOKDJT5L.mjs";
12
- import "../chunk-AD6VPMID.mjs";
13
- import "../chunk-64PPU7Q3.mjs";
14
- import "../chunk-7MTPH6XK.mjs";
15
- import "../chunk-RPUOO7AV.mjs";
16
-
17
- // src/provider/keycloakProvider.native.tsx
18
- import React from "react";
19
- import { KeycloakProvider as ExpoKeycloakProvider } from "expo-keycloak-auth";
20
- var KeycloakProvider = ({ children, keycloakConfig }) => {
21
- const clonedKeycloakConfig = {
22
- ...keycloakConfig,
23
- url: keycloakConfig.url
24
- };
25
- delete keycloakConfig.baseUrl;
26
- return /* @__PURE__ */ React.createElement(ExpoKeycloakProvider, { ...clonedKeycloakConfig }, /* @__PURE__ */ React.createElement(AfterAuth, null, children));
27
- };
28
- export {
29
- KeycloakProvider
30
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkC2FNSVJOjs = require("../chunk-C2FNSVJO.js");
6
- require("../chunk-XEO3YXBM.js");
7
- exports.useAuthState = _chunkC2FNSVJOjs.useAuthState;
@@ -1,7 +0,0 @@
1
- import {
2
- useAuthState
3
- } from "../chunk-AD6VPMID.mjs";
4
- import "../chunk-RPUOO7AV.mjs";
5
- export {
6
- useAuthState
7
- };
package/lib/util.d.mts DELETED
@@ -1,4 +0,0 @@
1
- declare function validToken(token: string | boolean, refreshToken?: string | boolean): string | boolean;
2
- declare function isTokenValid(token: string): boolean;
3
-
4
- export { isTokenValid, validToken };
package/lib/util.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare function validToken(token: string | boolean, refreshToken?: string | boolean): string | boolean;
2
- declare function isTokenValid(token: string): boolean;
3
-
4
- export { isTokenValid, validToken };
package/lib/util.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- var _chunkNWRANDZ6js = require("./chunk-NWRANDZ6.js");
6
- require("./chunk-XEO3YXBM.js");
7
- exports.isTokenValid = _chunkNWRANDZ6js.isTokenValid;
8
- exports.validToken = _chunkNWRANDZ6js.validToken;
@@ -1,47 +0,0 @@
1
- /*
2
- * File: /src/hooks/useKeycloak/index.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
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
12
- *
13
- * http://www.apache.org/licenses/LICENSE-2.0
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.
20
- */
21
-
22
- import type { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from '@bitspur/keycloak-js';
23
- export * from './useKeycloak';
24
-
25
- export interface IKeycloak {
26
- authenticated?: boolean;
27
- idToken?: string;
28
- realmAccess?: KeycloakRoles;
29
- refreshToken?: string;
30
- refreshTokenParsed?: KeycloakTokenParsed;
31
- resourceAccess?: KeycloakResourceAccess;
32
- subject?: string;
33
- token?: string;
34
- tokenParsed?: ITokenParsed;
35
- email?: string;
36
- username?: string;
37
- login: () => Promise<unknown>;
38
- logout: () => Promise<unknown>;
39
- }
40
-
41
- export interface ITokenParsed extends KeycloakTokenParsed {
42
- 'allowed-origins'?: string[];
43
- email_verified?: boolean;
44
- preferred_username?: string;
45
- scope?: string;
46
- sid?: string;
47
- }
@@ -1,95 +0,0 @@
1
- /*
2
- * File: /src/hooks/useKeycloak/useKeycloak.native.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
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
12
- *
13
- * http://www.apache.org/licenses/LICENSE-2.0
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.
20
- */
21
-
22
- import atob from 'core-js-pure/stable/atob';
23
- import escape from 'core-js-pure/stable/escape';
24
- import type { AuthRequestPromptOptions, AuthSessionResult } from 'expo-auth-session';
25
- import type { IKeycloak } from './index';
26
- import type { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from '@bitspur/keycloak-js';
27
- import { MultiPlatform } from 'multiplatform.one';
28
- import { useKeycloak as useExpoKeycloak } from 'expo-keycloak-auth';
29
-
30
- export function useKeycloak() {
31
- if (MultiPlatform.isStorybook) return { authenticated: true } as IKeycloak;
32
- const { ready, login, isLoggedIn, token, logout, refreshToken } = useExpoKeycloak();
33
- const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || undefined, refreshToken || undefined);
34
- return keycloak as IKeycloak;
35
- }
36
-
37
- export class ExpoKeycloak implements IKeycloak {
38
- authenticated?: boolean;
39
-
40
- tokenParsed?: KeycloakTokenParsed;
41
-
42
- refreshTokenParsed?: KeycloakTokenParsed;
43
-
44
- subject?: string;
45
-
46
- realmAccess?: KeycloakRoles;
47
-
48
- resourceAccess?: KeycloakResourceAccess;
49
-
50
- login: () => Promise<unknown>;
51
-
52
- constructor(
53
- ready: boolean,
54
- isLoggedIn: boolean | undefined,
55
- login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>,
56
- public logout: () => Promise<unknown>,
57
- public token?: string,
58
- public refreshToken?: string,
59
- ) {
60
- if (ready) this.authenticated = isLoggedIn;
61
- if (this.authenticated) {
62
- if (this.token) this.tokenParsed = decodeToken(this.token);
63
- if (this.refreshToken) {
64
- this.refreshTokenParsed = decodeToken(this.refreshToken);
65
- }
66
- if (this.tokenParsed) {
67
- this.subject = this.tokenParsed.sub;
68
- this.realmAccess = this.tokenParsed.realm_access;
69
- this.resourceAccess = this.tokenParsed.resource_access;
70
- }
71
- }
72
- this.login = () => login();
73
- }
74
- }
75
-
76
- function decodeToken(str: string) {
77
- str = str.split('.')[1];
78
- str = str.replace(/-/g, '+');
79
- str = str.replace(/_/g, '/');
80
- switch (str.length % 4) {
81
- case 0:
82
- break;
83
- case 2:
84
- str += '==';
85
- break;
86
- case 3:
87
- str += '=';
88
- break;
89
- default:
90
- throw 'Invalid token';
91
- }
92
- str = decodeURIComponent(escape(atob(str)));
93
- str = JSON.parse(str);
94
- return str as unknown as KeycloakTokenParsed;
95
- }
@@ -1,106 +0,0 @@
1
- /*
2
- * File: /src/hooks/useKeycloak/useKeycloak.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
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
12
- *
13
- * http://www.apache.org/licenses/LICENSE-2.0
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.
20
- */
21
-
22
- import type { IKeycloak } from './index';
23
- import { MultiPlatform } from 'multiplatform.one';
24
- import { useAuthConfig } from '../useAuthConfig';
25
- import { useKeycloak as useReactKeycloak } from '@bitspur/react-keycloak-web';
26
- import { useKeycloak as useSsrKeycloak } from '@bitspur/react-keycloak-ssr';
27
-
28
- export function useKeycloak() {
29
- const authConfig = useAuthConfig();
30
- if (MultiPlatform.isStorybook) {
31
- return new Keycloak(
32
- {
33
- email: 'storybook@example.com',
34
- login: async () => undefined,
35
- logout: async () => undefined,
36
- subject: '0',
37
- username: 'storybook',
38
- },
39
- true,
40
- );
41
- }
42
- if (MultiPlatform.isNext && authConfig.ssr) {
43
- const { keycloak, initialized } = useSsrKeycloak();
44
- return new Keycloak(keycloak, initialized);
45
- }
46
- const { keycloak, initialized } = useReactKeycloak();
47
- return new Keycloak(keycloak, initialized);
48
- }
49
-
50
- export class Keycloak implements IKeycloak {
51
- authenticated?: boolean;
52
-
53
- constructor(private readonly keycloak: IKeycloak | undefined, initialized: boolean) {
54
- this.authenticated = initialized ? keycloak?.authenticated : undefined;
55
- }
56
-
57
- get idToken() {
58
- return this.keycloak?.idToken;
59
- }
60
-
61
- get realmAccess() {
62
- return this.keycloak?.realmAccess;
63
- }
64
-
65
- get refreshToken() {
66
- return this.keycloak?.refreshToken;
67
- }
68
-
69
- get refreshTokenParsed() {
70
- return this.keycloak?.refreshTokenParsed;
71
- }
72
-
73
- get resourceAccess() {
74
- return this.keycloak?.resourceAccess;
75
- }
76
-
77
- get subject() {
78
- return this.keycloak?.subject;
79
- }
80
-
81
- get token() {
82
- return this.keycloak?.token;
83
- }
84
-
85
- get tokenParsed() {
86
- return this.keycloak?.tokenParsed;
87
- }
88
-
89
- get email() {
90
- return this.keycloak?.tokenParsed?.email;
91
- }
92
-
93
- get username() {
94
- return this.keycloak?.tokenParsed?.preferred_username;
95
- }
96
-
97
- async login() {
98
- if (!this.keycloak) return;
99
- return this.keycloak.login();
100
- }
101
-
102
- async logout() {
103
- if (!this.keycloak) return;
104
- return this.keycloak.logout();
105
- }
106
- }