@multiplatform.one/keycloak 0.0.1 → 0.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 (116) hide show
  1. package/esm/Authenticated.js +8 -19
  2. package/esm/Authenticated.js.map +1 -1
  3. package/esm/authConfig.js +2 -2
  4. package/esm/authConfig.js.map +1 -1
  5. package/esm/expo/ExpoKeycloakContext.js +28 -0
  6. package/esm/expo/ExpoKeycloakContext.js.map +1 -0
  7. package/esm/expo/ExpoKeycloakProvider.js +113 -0
  8. package/esm/expo/ExpoKeycloakProvider.js.map +1 -0
  9. package/esm/expo/KeycloakContext.js +28 -0
  10. package/esm/expo/KeycloakContext.js.map +1 -0
  11. package/esm/expo/KeycloakProvider.js +142 -0
  12. package/esm/expo/KeycloakProvider.js.map +1 -0
  13. package/esm/expo/const.js +42 -0
  14. package/esm/expo/const.js.map +1 -0
  15. package/esm/expo/helpers.js +56 -0
  16. package/esm/expo/helpers.js.map +1 -0
  17. package/esm/expo/index.js +28 -0
  18. package/esm/expo/index.js.map +1 -0
  19. package/esm/expo/useExpoKeycloak.js +44 -0
  20. package/esm/expo/useExpoKeycloak.js.map +1 -0
  21. package/esm/expo/useTokenStorage.js +153 -0
  22. package/esm/expo/useTokenStorage.js.map +1 -0
  23. package/esm/hooks/useCurrentRouteName.js +2 -3
  24. package/esm/hooks/useCurrentRouteName.js.map +1 -1
  25. package/esm/hooks/useKeycloak/index.js +1 -1
  26. package/esm/hooks/useKeycloak/index.js.map +1 -1
  27. package/esm/hooks/useKeycloak/useKeycloak.js +17 -24
  28. package/esm/hooks/useKeycloak/useKeycloak.js.map +1 -1
  29. package/esm/hooks/useKeycloak/useKeycloak.native.js +60 -19
  30. package/esm/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
  31. package/esm/hooks/useLogin.js +12 -30
  32. package/esm/hooks/useLogin.js.map +1 -1
  33. package/esm/provider/afterAuth.js +21 -39
  34. package/esm/provider/afterAuth.js.map +1 -1
  35. package/esm/provider/index.js +11 -28
  36. package/esm/provider/index.js.map +1 -1
  37. package/esm/provider/keycloakProvider.js +55 -100
  38. package/esm/provider/keycloakProvider.js.map +1 -1
  39. package/esm/provider/keycloakProvider.native.js +12 -11
  40. package/esm/provider/keycloakProvider.native.js.map +1 -1
  41. package/esm/state/index.js +2 -2
  42. package/esm/state/index.js.map +1 -1
  43. package/lib/Authenticated.js +38 -26
  44. package/lib/Authenticated.js.map +1 -1
  45. package/lib/authConfig.js +2 -4
  46. package/lib/authConfig.js.map +1 -1
  47. package/lib/expo/ExpoKeycloakContext.d.ts +32 -0
  48. package/lib/expo/ExpoKeycloakContext.js +47 -0
  49. package/lib/expo/ExpoKeycloakContext.js.map +1 -0
  50. package/lib/expo/ExpoKeycloakProvider.d.ts +37 -0
  51. package/lib/expo/ExpoKeycloakProvider.js +130 -0
  52. package/lib/expo/ExpoKeycloakProvider.js.map +1 -0
  53. package/lib/expo/KeycloakContext.d.ts +32 -0
  54. package/lib/expo/KeycloakContext.js +49 -0
  55. package/lib/expo/KeycloakContext.js.map +1 -0
  56. package/lib/expo/KeycloakProvider.d.ts +37 -0
  57. package/lib/expo/KeycloakProvider.js +138 -0
  58. package/lib/expo/KeycloakProvider.js.map +1 -0
  59. package/lib/expo/const.d.ts +33 -0
  60. package/lib/expo/const.js +66 -0
  61. package/lib/expo/const.js.map +1 -0
  62. package/lib/expo/helpers.d.ts +41 -0
  63. package/lib/expo/helpers.js +77 -0
  64. package/lib/expo/helpers.js.map +1 -0
  65. package/lib/expo/index.d.ts +26 -0
  66. package/lib/expo/index.js +50 -0
  67. package/lib/expo/index.js.map +1 -0
  68. package/lib/expo/useExpoKeycloak.d.ts +31 -0
  69. package/lib/expo/useExpoKeycloak.js +62 -0
  70. package/lib/expo/useExpoKeycloak.js.map +1 -0
  71. package/lib/expo/useTokenStorage.d.ts +36 -0
  72. package/lib/expo/useTokenStorage.js +166 -0
  73. package/lib/expo/useTokenStorage.js.map +1 -0
  74. package/lib/hooks/index.js +3 -9
  75. package/lib/hooks/index.js.map +1 -1
  76. package/lib/hooks/useAuthConfig.js +0 -2
  77. package/lib/hooks/useAuthConfig.js.map +1 -1
  78. package/lib/hooks/useCurrentRouteName.js +6 -8
  79. package/lib/hooks/useCurrentRouteName.js.map +1 -1
  80. package/lib/hooks/useKeycloak/index.d.ts +7 -4
  81. package/lib/hooks/useKeycloak/index.js +1 -7
  82. package/lib/hooks/useKeycloak/index.js.map +1 -1
  83. package/lib/hooks/useKeycloak/useKeycloak.js +45 -30
  84. package/lib/hooks/useKeycloak/useKeycloak.js.map +1 -1
  85. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +13 -3
  86. package/lib/hooks/useKeycloak/useKeycloak.native.js +61 -25
  87. package/lib/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
  88. package/lib/hooks/useLogin.js +16 -25
  89. package/lib/hooks/useLogin.js.map +1 -1
  90. package/lib/index.js +4 -10
  91. package/lib/index.js.map +1 -1
  92. package/lib/provider/afterAuth.js +52 -52
  93. package/lib/provider/afterAuth.js.map +1 -1
  94. package/lib/provider/index.js +44 -43
  95. package/lib/provider/index.js.map +1 -1
  96. package/lib/provider/keycloakProvider.js +93 -114
  97. package/lib/provider/keycloakProvider.js.map +1 -1
  98. package/lib/provider/keycloakProvider.native.js +39 -15
  99. package/lib/provider/keycloakProvider.native.js.map +1 -1
  100. package/lib/state/index.js +3 -5
  101. package/lib/state/index.js.map +1 -1
  102. package/lib/tsconfig.build.tsbuildinfo +1 -1
  103. package/lib/types.js +2 -4
  104. package/lib/types.js.map +1 -1
  105. package/package.json +5 -4
  106. package/src/expo/ExpoKeycloakContext.ts +41 -0
  107. package/src/expo/ExpoKeycloakProvider.tsx +139 -0
  108. package/src/expo/NOTES +1 -0
  109. package/src/expo/const.ts +42 -0
  110. package/src/expo/helpers.ts +74 -0
  111. package/src/{@types/expoKeycloakAuth.d.ts → expo/index.ts} +6 -7
  112. package/src/expo/useExpoKeycloak.ts +44 -0
  113. package/src/expo/useTokenStorage.ts +168 -0
  114. package/src/hooks/useKeycloak/index.ts +11 -4
  115. package/src/hooks/useKeycloak/useKeycloak.native.ts +72 -8
  116. package/src/provider/keycloakProvider.native.tsx +8 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExpoKeycloak.js","names":["useContext","ExpoKeycloakContext","useExpoKeycloak","isLoggedIn","login","logout","ready","token","accessToken","refreshToken"],"sources":["../../src/expo/useExpoKeycloak.ts"],"sourcesContent":["/**\n * File: /src/expo/useExpoKeycloak.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 26-11-2022 06:58:16\n * Author: Clay Risser\n * -----\n * Last Modified: 26-11-2022 08:38:57\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useContext } from \"react\";\nimport { ExpoKeycloakContext } from \"./ExpoKeycloakContext\";\n\nexport function useExpoKeycloak() {\n const {\n isLoggedIn,\n login,\n logout,\n ready = false,\n token = null,\n } = useContext(ExpoKeycloakContext);\n return {\n isLoggedIn,\n login,\n logout,\n ready,\n token: token?.accessToken ?? null,\n refreshToken: token?.refreshToken ?? null,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,mBAAmB;AAE5B,OAAO,SAASC,eAAe,GAAG;EAChC,MAAM;IACJC,UAAU;IACVC,KAAK;IACLC,MAAM;IACNC,KAAK,GAAG,KAAK;IACbC,KAAK,GAAG;EACV,CAAC,GAAGP,UAAU,CAACC,mBAAmB,CAAC;EACnC,OAAO;IACLE,UAAU;IACVC,KAAK;IACLC,MAAM;IACNC,KAAK;IACLC,KAAK,EAAE,CAAAA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,WAAW,KAAI,IAAI;IACjCC,YAAY,EAAE,CAAAF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,YAAY,KAAI;EACvC,CAAC;AACH"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * File: /src/expo/useTokenStorage.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 26-11-2022 06:58:16
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 26-11-2022 08:08:00
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+
25
+ import { AppState, Platform } from "react-native";
26
+ import { refreshAsync } from "expo-auth-session";
27
+ import { REFRESH_TIME_BUFFER, TOKEN_STORAGE_KEY } from "./const";
28
+ import { dismiss, revokeAsync, TokenResponse } from "expo-auth-session";
29
+ import { getCurrentTimeInSeconds } from "./helpers";
30
+ import { useAsyncStorage } from "@react-native-async-storage/async-storage";
31
+ import { useEffect, useRef, useState } from "react";
32
+ const logger = console;
33
+ export function useTokenStorage(_ref, config, discovery) {
34
+ let {
35
+ disableAutoRefresh = false,
36
+ refreshTimeBuffer = REFRESH_TIME_BUFFER,
37
+ tokenStorageKey = TOKEN_STORAGE_KEY
38
+ } = _ref;
39
+ const [token, setToken] = useState();
40
+ const {
41
+ getItem,
42
+ setItem,
43
+ removeItem
44
+ } = useAsyncStorage(tokenStorageKey);
45
+ const refreshHandler = useRef(null);
46
+ const appState = useRef(AppState.currentState);
47
+ const refreshTime = useRef(null);
48
+ const tokenData = useRef(null);
49
+ async function updateAndSaveToken(newToken) {
50
+ try {
51
+ setToken(newToken);
52
+ if (newToken !== null) {
53
+ const stringifiedValue = JSON.stringify(newToken);
54
+ await setItem(stringifiedValue);
55
+ } else {
56
+ await removeItem();
57
+ }
58
+ } catch (error) {
59
+ logger.error(error);
60
+ }
61
+ }
62
+ async function handleTokenRefresh(token) {
63
+ try {
64
+ const tokenResponse = await refreshAsync({
65
+ refreshToken: token === null || token === void 0 ? void 0 : token.refreshToken,
66
+ ...config
67
+ }, discovery);
68
+ updateAndSaveToken(tokenResponse);
69
+ } catch (err) {
70
+ updateAndSaveToken(null);
71
+ }
72
+ }
73
+ useEffect(() => {
74
+ function handleAppState(nextAppState) {
75
+ if (appState.current.match(/inactive|background/) && nextAppState === "active") {
76
+ if (refreshHandler.current !== null) {
77
+ clearTimeout(refreshHandler.current);
78
+ const now = getCurrentTimeInSeconds();
79
+ if (Number(refreshTime.current) <= now) {
80
+ setToken(null);
81
+ } else {
82
+ const timeout = 1000 * (Number(refreshTime.current) - now);
83
+ // @ts-ignore
84
+ refreshHandler.current = setTimeout(() => {
85
+ handleTokenRefresh(tokenData.current);
86
+ }, timeout);
87
+ }
88
+ }
89
+ }
90
+ appState.current = nextAppState;
91
+ }
92
+ const subscription = AppState.addEventListener("change", handleAppState);
93
+ return () => {
94
+ if (subscription) {
95
+ subscription.remove();
96
+ } else {
97
+ // @ts-ignore
98
+ AppState.removeEventListener("change", handleAppState);
99
+ }
100
+ };
101
+ }, []);
102
+ useEffect(() => {
103
+ async function getTokenFromStorage() {
104
+ try {
105
+ const tokenFromStorage = await getItem();
106
+ if (!tokenFromStorage) throw new Error("No token in storage");
107
+ const token = JSON.parse(tokenFromStorage);
108
+ if (!TokenResponse.isTokenFresh(token, -refreshTimeBuffer)) {
109
+ handleTokenRefresh(token);
110
+ } else {
111
+ setToken(token);
112
+ }
113
+ } catch (error) {
114
+ setToken(null);
115
+ }
116
+ }
117
+ if (discovery) getTokenFromStorage();
118
+ }, [discovery]);
119
+ useEffect(() => {
120
+ // trigger every token update
121
+ // @ts-ignore
122
+ tokenData.current = token || null;
123
+ if (token !== undefined && !disableAutoRefresh) {
124
+ if (refreshHandler.current !== null) {
125
+ clearTimeout(refreshHandler.current);
126
+ }
127
+ if (token !== null && token !== void 0 && token.expiresIn) {
128
+ const now = getCurrentTimeInSeconds();
129
+ // @ts-ignore
130
+ refreshTime.current = token.issuedAt + token.expiresIn - refreshTimeBuffer;
131
+ const timeout = 1000 * (refreshTime.current - now);
132
+ // @ts-ignore
133
+ refreshHandler.current = setTimeout(() => {
134
+ handleTokenRefresh(token);
135
+ }, timeout);
136
+ }
137
+ if (token === null && tokenData.current !== null) {
138
+ var _tokenData$current;
139
+ revokeAsync({
140
+ token: (_tokenData$current = tokenData.current) === null || _tokenData$current === void 0 ? void 0 : _tokenData$current.accessToken,
141
+ ...config
142
+ }, discovery);
143
+ Platform.OS === "ios" && dismiss();
144
+ // @ts-ignore
145
+ refreshTime.current = null;
146
+ // @ts-ignore
147
+ tokenData.current = null;
148
+ }
149
+ }
150
+ }, [token]);
151
+ return [token || null, updateAndSaveToken];
152
+ }
153
+ //# sourceMappingURL=useTokenStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTokenStorage.js","names":["AppState","Platform","refreshAsync","REFRESH_TIME_BUFFER","TOKEN_STORAGE_KEY","dismiss","revokeAsync","TokenResponse","getCurrentTimeInSeconds","useAsyncStorage","useEffect","useRef","useState","logger","console","useTokenStorage","config","discovery","disableAutoRefresh","refreshTimeBuffer","tokenStorageKey","token","setToken","getItem","setItem","removeItem","refreshHandler","appState","currentState","refreshTime","tokenData","updateAndSaveToken","newToken","stringifiedValue","JSON","stringify","error","handleTokenRefresh","tokenResponse","refreshToken","err","handleAppState","nextAppState","current","match","clearTimeout","now","Number","timeout","setTimeout","subscription","addEventListener","remove","removeEventListener","getTokenFromStorage","tokenFromStorage","Error","parse","isTokenFresh","undefined","expiresIn","issuedAt","accessToken","OS"],"sources":["../../src/expo/useTokenStorage.ts"],"sourcesContent":["/**\n * File: /src/expo/useTokenStorage.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 26-11-2022 06:58:16\n * Author: Clay Risser\n * -----\n * Last Modified: 26-11-2022 08:08:00\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AppState, AppStateStatus, Platform } from \"react-native\";\nimport { DiscoveryDocument, refreshAsync } from \"expo-auth-session\";\nimport { REFRESH_TIME_BUFFER, TOKEN_STORAGE_KEY } from \"./const\";\nimport { dismiss, revokeAsync, TokenResponse } from \"expo-auth-session\";\nimport { getCurrentTimeInSeconds } from \"./helpers\";\nimport { useAsyncStorage } from \"@react-native-async-storage/async-storage\";\nimport { useEffect, useRef, useState } from \"react\";\n\nconst logger = console;\n\nexport function useTokenStorage(\n {\n disableAutoRefresh = false,\n refreshTimeBuffer = REFRESH_TIME_BUFFER,\n tokenStorageKey = TOKEN_STORAGE_KEY,\n },\n config: {\n clientId: string;\n extraParams?: Record<string, string>;\n realm: string;\n redirectUri: string;\n url: string;\n },\n discovery: DiscoveryDocument\n): [TokenResponse | null, (token: TokenResponse | null) => Promise<void>] {\n const [token, setToken] = useState<TokenResponse | null>();\n const { getItem, setItem, removeItem } = useAsyncStorage(tokenStorageKey);\n const refreshHandler = useRef<NodeJS.Timeout>(null);\n const appState = useRef(AppState.currentState);\n const refreshTime = useRef<number>(null);\n const tokenData = useRef<TokenResponse>(null);\n\n async function updateAndSaveToken(newToken: TokenResponse | null) {\n try {\n setToken(newToken);\n if (newToken !== null) {\n const stringifiedValue = JSON.stringify(newToken);\n await setItem(stringifiedValue);\n } else {\n await removeItem();\n }\n } catch (error) {\n logger.error(error);\n }\n }\n\n async function handleTokenRefresh(token: TokenResponse | null) {\n try {\n const tokenResponse = await refreshAsync(\n { refreshToken: token?.refreshToken, ...config },\n discovery\n );\n updateAndSaveToken(tokenResponse);\n } catch (err) {\n updateAndSaveToken(null);\n }\n }\n\n useEffect(() => {\n function handleAppState(nextAppState: AppStateStatus) {\n if (\n appState.current.match(/inactive|background/) &&\n nextAppState === \"active\"\n ) {\n if (refreshHandler.current !== null) {\n clearTimeout(refreshHandler.current);\n const now = getCurrentTimeInSeconds();\n if (Number(refreshTime.current) <= now) {\n setToken(null);\n } else {\n const timeout = 1000 * (Number(refreshTime.current) - now);\n // @ts-ignore\n refreshHandler.current = setTimeout(() => {\n handleTokenRefresh(tokenData.current);\n }, timeout);\n }\n }\n }\n appState.current = nextAppState;\n }\n const subscription = AppState.addEventListener(\"change\", handleAppState);\n return () => {\n if (subscription) {\n subscription.remove();\n } else {\n // @ts-ignore\n AppState.removeEventListener(\"change\", handleAppState);\n }\n };\n }, []);\n\n useEffect(() => {\n async function getTokenFromStorage() {\n try {\n const tokenFromStorage = await getItem();\n if (!tokenFromStorage) throw new Error(\"No token in storage\");\n const token = JSON.parse(tokenFromStorage);\n if (!TokenResponse.isTokenFresh(token, -refreshTimeBuffer)) {\n handleTokenRefresh(token);\n } else {\n setToken(token);\n }\n } catch (error) {\n setToken(null);\n }\n }\n if (discovery) getTokenFromStorage();\n }, [discovery]);\n\n useEffect(() => {\n // trigger every token update\n // @ts-ignore\n tokenData.current = token || null;\n if (token !== undefined && !disableAutoRefresh) {\n if (refreshHandler.current !== null) {\n clearTimeout(refreshHandler.current);\n }\n if (token?.expiresIn) {\n const now = getCurrentTimeInSeconds();\n // @ts-ignore\n refreshTime.current =\n token.issuedAt + token.expiresIn - refreshTimeBuffer;\n const timeout = 1000 * (refreshTime.current - now);\n // @ts-ignore\n refreshHandler.current = setTimeout(() => {\n handleTokenRefresh(token);\n }, timeout);\n }\n if (token === null && tokenData.current !== null) {\n revokeAsync(\n { token: tokenData.current?.accessToken, ...config },\n discovery\n );\n Platform.OS === \"ios\" && dismiss();\n // @ts-ignore\n refreshTime.current = null;\n // @ts-ignore\n tokenData.current = null;\n }\n }\n }, [token]);\n\n return [token || null, updateAndSaveToken];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAkBC,QAAQ,QAAQ,cAAc;AACjE,SAA4BC,YAAY,QAAQ,mBAAmB;AACnE,SAASC,mBAAmB,EAAEC,iBAAiB;AAC/C,SAASC,OAAO,EAAEC,WAAW,EAAEC,aAAa,QAAQ,mBAAmB;AACvE,SAASC,uBAAuB;AAChC,SAASC,eAAe,QAAQ,2CAA2C;AAC3E,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,MAAMC,MAAM,GAAGC,OAAO;AAEtB,OAAO,SAASC,eAAe,OAM7BC,MAMC,EACDC,SAA4B,EAC4C;EAAA,IAbxE;IACEC,kBAAkB,GAAG,KAAK;IAC1BC,iBAAiB,GAAGhB,mBAAmB;IACvCiB,eAAe,GAAGhB;EACpB,CAAC;EAUD,MAAM,CAACiB,KAAK,EAAEC,QAAQ,CAAC,GAAGV,QAAQ,EAAwB;EAC1D,MAAM;IAAEW,OAAO;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGhB,eAAe,CAACW,eAAe,CAAC;E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"core-js/modules/es.function.name.js";
2
1
  /**
3
2
  * File: /src/hooks/useCurrentRouteName.ts
4
3
  * Project: app
@@ -29,10 +28,10 @@ import { useRouter } from "next/router";
29
28
  export function useCurrentRouteName() {
30
29
  if (MultiPlatform.isStorybook()) return null;
31
30
  if (MultiPlatform.isNext()) {
32
- var router = useRouter();
31
+ const router = useRouter();
33
32
  return router.route;
34
33
  }
35
- var route = useRoute();
34
+ const route = useRoute();
36
35
  return route.name;
37
36
  }
38
37
  //# sourceMappingURL=useCurrentRouteName.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentRouteName.js","names":["MultiPlatform","useRoute","useRouter","useCurrentRouteName","isStorybook","isNext","router","route","name"],"sources":["../../src/hooks/useCurrentRouteName.ts"],"sourcesContent":["/**\n * File: /src/hooks/useCurrentRouteName.ts\n * Project: app\n * File Created: 08-11-2022 08:38:23\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:24:27\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useRoute } from \"@react-navigation/native\";\nimport { useRouter } from \"next/router\";\n\nexport function useCurrentRouteName() {\n if (MultiPlatform.isStorybook()) return null;\n if (MultiPlatform.isNext()) {\n const router = useRouter();\n return router.route;\n }\n const route = useRoute();\n return route.name;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,mBAAmB;AACjD,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,SAAS,QAAQ,aAAa;AAEvC,OAAO,SAASC,mBAAmB,GAAG;EACpC,IAAIH,aAAa,CAACI,WAAW,EAAE,EAAE,OAAO,IAAI;EAC5C,IAAIJ,aAAa,CAACK,MAAM,EAAE,EAAE;IAC1B,IAAMC,MAAM,GAAGJ,SAAS,EAAE;IAC1B,OAAOI,MAAM,CAACC,KAAK;EACrB;EACA,IAAMA,KAAK,GAAGN,QAAQ,EAAE;EACxB,OAAOM,KAAK,CAACC,IAAI;AACnB"}
1
+ {"version":3,"file":"useCurrentRouteName.js","names":["MultiPlatform","useRoute","useRouter","useCurrentRouteName","isStorybook","isNext","router","route","name"],"sources":["../../src/hooks/useCurrentRouteName.ts"],"sourcesContent":["/**\n * File: /src/hooks/useCurrentRouteName.ts\n * Project: app\n * File Created: 08-11-2022 08:38:23\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:24:27\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useRoute } from \"@react-navigation/native\";\nimport { useRouter } from \"next/router\";\n\nexport function useCurrentRouteName() {\n if (MultiPlatform.isStorybook()) return null;\n if (MultiPlatform.isNext()) {\n const router = useRouter();\n return router.route;\n }\n const route = useRoute();\n return route.name;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,mBAAmB;AACjD,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,SAAS,QAAQ,aAAa;AAEvC,OAAO,SAASC,mBAAmB,GAAG;EACpC,IAAIH,aAAa,CAACI,WAAW,EAAE,EAAE,OAAO,IAAI;EAC5C,IAAIJ,aAAa,CAACK,MAAM,EAAE,EAAE;IAC1B,MAAMC,MAAM,GAAGJ,SAAS,EAAE;IAC1B,OAAOI,MAAM,CAACC,KAAK;EACrB;EACA,MAAMA,KAAK,GAAGN,QAAQ,EAAE;EACxB,OAAOM,KAAK,CAACC,IAAI;AACnB"}
@@ -4,7 +4,7 @@
4
4
  * File Created: 08-11-2022 14:10:44
5
5
  * Author: Clay Risser
6
6
  * -----
7
- * Last Modified: 25-11-2022 09:52:31
7
+ * Last Modified: 26-11-2022 08:31:01
8
8
  * Modified By: Clay Risser
9
9
  * -----
10
10
  * Risser Labs LLC (c) Copyright 2021 - 2022
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 09:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from \"./useKeycloak\";\n\nexport interface IKeycloak {\n authenticated?: boolean;\n token?: string;\n refreshToken?: string;\n tokenParsed?: any;\n login: () => unknown;\n logout: () => unknown;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAA8B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 26-11-2022 08:31:01\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nexport * from \"./useKeycloak\";\n\nexport interface IKeycloak {\n authenticated?: boolean;\n token?: string;\n refreshToken?: string;\n tokenParsed?: KeycloakTokenParsed;\n realmAccess?: KeycloakRoles;\n resourceAccess?: KeycloakResourceAccess;\n login: () => Promise<unknown> | unknown;\n logout: () => Promise<unknown> | unknown;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AAA8B"}
@@ -1,16 +1,3 @@
1
- import "core-js/modules/es.object.keys.js";
2
- import "core-js/modules/es.symbol.js";
3
- import "core-js/modules/es.array.filter.js";
4
- import "core-js/modules/es.object.to-string.js";
5
- import "core-js/modules/es.object.get-own-property-descriptor.js";
6
- import "core-js/modules/es.array.for-each.js";
7
- import "core-js/modules/web.dom-collections.for-each.js";
8
- import "core-js/modules/es.object.get-own-property-descriptors.js";
9
- import "core-js/modules/es.object.define-properties.js";
10
- import "core-js/modules/es.object.define-property.js";
11
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
1
  /**
15
2
  * File: /src/hooks/useKeycloak/useKeycloak.ts
16
3
  * Project: app
@@ -40,22 +27,28 @@ import { useKeycloak as useReactKeycloak } from "@react-keycloak/web";
40
27
  import { useKeycloak as useSsrKeycloak } from "@react-keycloak/ssr";
41
28
  import { useAuthConfig } from "../useAuthConfig";
42
29
  export function useKeycloak() {
43
- var authConfig = useAuthConfig();
30
+ const authConfig = useAuthConfig();
44
31
  if (MultiPlatform.isStorybook()) return {
45
32
  authenticated: true
46
33
  };
47
34
  if (MultiPlatform.isNext() && authConfig.ssr) {
48
- var _useSsrKeycloak = useSsrKeycloak(),
49
- ssrKeycloak = _useSsrKeycloak.keycloak,
50
- _initialized = _useSsrKeycloak.initialized;
51
- var _keycloak = _objectSpread({}, ssrKeycloak);
52
- if (!_initialized) _keycloak.authenticated = undefined;
53
- return _keycloak;
35
+ const {
36
+ keycloak: ssrKeycloak,
37
+ initialized
38
+ } = useSsrKeycloak();
39
+ const keycloak = {
40
+ ...ssrKeycloak
41
+ };
42
+ if (!initialized) keycloak.authenticated = undefined;
43
+ return keycloak;
54
44
  }
55
- var _useReactKeycloak = useReactKeycloak(),
56
- reactKeycloak = _useReactKeycloak.keycloak,
57
- initialized = _useReactKeycloak.initialized;
58
- var keycloak = _objectSpread({}, reactKeycloak);
45
+ const {
46
+ keycloak: reactKeycloak,
47
+ initialized
48
+ } = useReactKeycloak();
49
+ const keycloak = {
50
+ ...reactKeycloak
51
+ };
59
52
  if (!initialized) keycloak.authenticated = undefined;
60
53
  return keycloak;
61
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useKeycloak.js","names":["MultiPlatform","useKeycloak","useReactKeycloak","useSsrKeycloak","useAuthConfig","authConfig","isStorybook","authenticated","isNext","ssr","ssrKeycloak","keycloak","initialized","undefined","reactKeycloak"],"sources":["../../../src/hooks/useKeycloak/useKeycloak.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/useKeycloak.ts\n * Project: app\n * File Created: 08-11-2022 06:04:59\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:22:57\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Keycloak from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useKeycloak as useReactKeycloak } from \"@react-keycloak/web\";\nimport { useKeycloak as useSsrKeycloak } from \"@react-keycloak/ssr\";\nimport { IKeycloak } from \"./index\";\nimport { useAuthConfig } from \"../useAuthConfig\";\n\nexport function useKeycloak() {\n const authConfig = useAuthConfig();\n if (MultiPlatform.isStorybook()) return { authenticated: true } as IKeycloak;\n if (MultiPlatform.isNext() && authConfig.ssr) {\n const { keycloak: ssrKeycloak, initialized } = useSsrKeycloak();\n const keycloak = { ...ssrKeycloak } as Keycloak;\n if (!initialized) keycloak.authenticated = undefined;\n return keycloak as IKeycloak;\n }\n const { keycloak: reactKeycloak, initialized } = useReactKeycloak();\n const keycloak = { ...reactKeycloak } as Keycloak;\n if (!initialized) keycloak.authenticated = undefined;\n return keycloak as IKeycloak;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,aAAa,QAAQ,mBAAmB;AACjD,SAASC,WAAW,IAAIC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASD,WAAW,IAAIE,cAAc,QAAQ,qBAAqB;AAEnE,SAASC,aAAa;AAEtB,OAAO,SAASH,WAAW,GAAG;EAC5B,IAAMI,UAAU,GAAGD,aAAa,EAAE;EAClC,IAAIJ,aAAa,CAACM,WAAW,EAAE,EAAE,OAAO;IAAEC,aAAa,EAAE;EAAK,CAAC;EAC/D,IAAIP,aAAa,CAACQ,MAAM,EAAE,IAAIH,UAAU,CAACI,GAAG,EAAE;IAC5C,sBAA+CN,cAAc,EAAE;MAA7CO,WAAW,mBAArBC,QAAQ;MAAeC,YAAW,mBAAXA,WAAW;IAC1C,IAAMD,SAAQ,qBAAQD,WAAW,CAAc;IAC/C,IAAI,CAACE,YAAW,EAAED,SAAQ,CAACJ,aAAa,GAAGM,SAAS;IACpD,OAAOF,SAAQ;EACjB;EACA,wBAAiDT,gBAAgB,EAAE;IAAjDY,aAAa,qBAAvBH,QAAQ;IAAiBC,WAAW,qBAAXA,WAAW;EAC5C,IAAMD,QAAQ,qBAAQG,aAAa,CAAc;EACjD,IAAI,CAACF,WAAW,EAAED,QAAQ,CAACJ,aAAa,GAAGM,SAAS;EACpD,OAAOF,QAAQ;AACjB"}
1
+ {"version":3,"file":"useKeycloak.js","names":["MultiPlatform","useKeycloak","useReactKeycloak","useSsrKeycloak","useAuthConfig","authConfig","isStorybook","authenticated","isNext","ssr","keycloak","ssrKeycloak","initialized","undefined","reactKeycloak"],"sources":["../../../src/hooks/useKeycloak/useKeycloak.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/useKeycloak.ts\n * Project: app\n * File Created: 08-11-2022 06:04:59\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:22:57\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Keycloak from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useKeycloak as useReactKeycloak } from \"@react-keycloak/web\";\nimport { useKeycloak as useSsrKeycloak } from \"@react-keycloak/ssr\";\nimport { IKeycloak } from \"./index\";\nimport { useAuthConfig } from \"../useAuthConfig\";\n\nexport function useKeycloak() {\n const authConfig = useAuthConfig();\n if (MultiPlatform.isStorybook()) return { authenticated: true } as IKeycloak;\n if (MultiPlatform.isNext() && authConfig.ssr) {\n const { keycloak: ssrKeycloak, initialized } = useSsrKeycloak();\n const keycloak = { ...ssrKeycloak } as Keycloak;\n if (!initialized) keycloak.authenticated = undefined;\n return keycloak as IKeycloak;\n }\n const { keycloak: reactKeycloak, initialized } = useReactKeycloak();\n const keycloak = { ...reactKeycloak } as Keycloak;\n if (!initialized) keycloak.authenticated = undefined;\n return keycloak as IKeycloak;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,aAAa,QAAQ,mBAAmB;AACjD,SAASC,WAAW,IAAIC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASD,WAAW,IAAIE,cAAc,QAAQ,qBAAqB;AAEnE,SAASC,aAAa;AAEtB,OAAO,SAASH,WAAW,GAAG;EAC5B,MAAMI,UAAU,GAAGD,aAAa,EAAE;EAClC,IAAIJ,aAAa,CAACM,WAAW,EAAE,EAAE,OAAO;IAAEC,aAAa,EAAE;EAAK,CAAC;EAC/D,IAAIP,aAAa,CAACQ,MAAM,EAAE,IAAIH,UAAU,CAACI,GAAG,EAAE;IAC5C,MAAM;MAAEC,QAAQ,EAAEC,WAAW;MAAEC;IAAY,CAAC,GAAGT,cAAc,EAAE;IAC/D,MAAMO,QAAQ,GAAG;MAAE,GAAGC;IAAY,CAAa;IAC/C,IAAI,CAACC,WAAW,EAAEF,QAAQ,CAACH,aAAa,GAAGM,SAAS;IACpD,OAAOH,QAAQ;EACjB;EACA,MAAM;IAAEA,QAAQ,EAAEI,aAAa;IAAEF;EAAY,CAAC,GAAGV,gBAAgB,EAAE;EACnE,MAAMQ,QAAQ,GAAG;IAAE,GAAGI;EAAc,CAAa;EACjD,IAAI,CAACF,WAAW,EAAEF,QAAQ,CAACH,aAAa,GAAGM,SAAS;EACpD,OAAOH,QAAQ;AACjB"}
@@ -1,12 +1,10 @@
1
- import _createClass from "@babel/runtime/helpers/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
1
  /**
4
2
  * File: /src/hooks/useKeycloak/useKeycloak.native.ts
5
3
  * Project: app
6
4
  * File Created: 08-11-2022 14:10:25
7
5
  * Author: Clay Risser
8
6
  * -----
9
- * Last Modified: 25-11-2022 10:21:56
7
+ * Last Modified: 26-11-2022 09:05:23
10
8
  * Modified By: Clay Risser
11
9
  * -----
12
10
  * Risser Labs LLC (c) Copyright 2021 - 2022
@@ -24,27 +22,70 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
24
22
  * limitations under the License.
25
23
  */
26
24
 
27
- import { useKeycloak as useKeycloakExpo } from "expo-keycloak-auth";
25
+ import "core-js/actual/atob";
26
+ import "core-js/actual/escape";
28
27
  import { MultiPlatform } from "multiplatform.one";
28
+ import { useExpoKeycloak } from "../../expo";
29
29
  export function useKeycloak() {
30
30
  if (MultiPlatform.isStorybook()) return {
31
31
  authenticated: true
32
32
  };
33
- var _useKeycloakExpo = useKeycloakExpo(),
34
- ready = _useKeycloakExpo.ready,
35
- login = _useKeycloakExpo.login,
36
- isLoggedIn = _useKeycloakExpo.isLoggedIn,
37
- token = _useKeycloakExpo.token,
38
- logout = _useKeycloakExpo.logout;
39
- var keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token);
33
+ const {
34
+ ready,
35
+ login,
36
+ isLoggedIn,
37
+ token,
38
+ logout,
39
+ refreshToken
40
+ } = useExpoKeycloak();
41
+ const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || undefined, refreshToken || undefined);
40
42
  return keycloak;
41
43
  }
42
- export var ExpoKeycloak = /*#__PURE__*/_createClass(function ExpoKeycloak(ready, isLoggedIn, login, logout, token) {
43
- _classCallCheck(this, ExpoKeycloak);
44
- this.login = login;
45
- this.logout = logout;
46
- this.token = token;
47
- this.authenticated = void 0;
48
- if (ready) this.authenticated = isLoggedIn;
49
- });
44
+ export class ExpoKeycloak {
45
+ constructor(ready, isLoggedIn, login, logout, token, refreshToken) {
46
+ this.logout = logout;
47
+ this.token = token;
48
+ this.refreshToken = refreshToken;
49
+ this.authenticated = void 0;
50
+ this.tokenParsed = void 0;
51
+ this.refreshTokenParsed = void 0;
52
+ this.subject = void 0;
53
+ this.realmAccess = void 0;
54
+ this.resourceAccess = void 0;
55
+ this.login = void 0;
56
+ if (ready) this.authenticated = isLoggedIn;
57
+ if (this.authenticated) {
58
+ if (this.token) this.tokenParsed = decodeToken(this.token);
59
+ if (this.refreshToken) {
60
+ this.refreshTokenParsed = decodeToken(this.refreshToken);
61
+ }
62
+ if (this.tokenParsed) {
63
+ this.subject = this.tokenParsed.sub;
64
+ this.realmAccess = this.tokenParsed.realm_access;
65
+ this.resourceAccess = this.tokenParsed.resource_access;
66
+ }
67
+ }
68
+ this.login = () => login();
69
+ }
70
+ }
71
+ function decodeToken(str) {
72
+ str = str.split(".")[1];
73
+ str = str.replace(/-/g, "+");
74
+ str = str.replace(/_/g, "/");
75
+ switch (str.length % 4) {
76
+ case 0:
77
+ break;
78
+ case 2:
79
+ str += "==";
80
+ break;
81
+ case 3:
82
+ str += "=";
83
+ break;
84
+ default:
85
+ throw "Invalid token";
86
+ }
87
+ str = decodeURIComponent(escape(atob(str)));
88
+ str = JSON.parse(str);
89
+ return str;
90
+ }
50
91
  //# sourceMappingURL=useKeycloak.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKeycloak.native.js","names":["useKeycloak","useKeycloakExpo","MultiPlatform","isStorybook","authenticated","ready","login","isLoggedIn","token","logout","keycloak","ExpoKeycloak"],"sources":["../../../src/hooks/useKeycloak/useKeycloak.native.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/useKeycloak.native.ts\n * Project: app\n * File Created: 08-11-2022 14:10:25\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:21:56\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useKeycloak as useKeycloakExpo } from \"expo-keycloak-auth\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { IKeycloak } from \"./index\";\n\nexport function useKeycloak() {\n if (MultiPlatform.isStorybook()) return { authenticated: true } as IKeycloak;\n const { ready, login, isLoggedIn, token, logout } = useKeycloakExpo();\n const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token);\n return keycloak as IKeycloak;\n}\n\nexport class ExpoKeycloak implements IKeycloak {\n authenticated?: boolean;\n\n constructor(\n ready: boolean,\n isLoggedIn: boolean,\n public login: () => unknown,\n public logout: () => unknown,\n public token?: string\n ) {\n if (ready) this.authenticated = isLoggedIn;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,IAAIC,eAAe,QAAQ,oBAAoB;AACnE,SAASC,aAAa,QAAQ,mBAAmB;AAGjD,OAAO,SAASF,WAAW,GAAG;EAC5B,IAAIE,aAAa,CAACC,WAAW,EAAE,EAAE,OAAO;IAAEC,aAAa,EAAE;EAAK,CAAC;EAC/D,uBAAoDH,eAAe,EAAE;IAA7DI,KAAK,oBAALA,KAAK;IAAEC,KAAK,oBAALA,KAAK;IAAEC,UAAU,oBAAVA,UAAU;IAAEC,KAAK,oBAALA,KAAK;IAAEC,MAAM,oBAANA,MAAM;EAC/C,IAAMC,QAAQ,GAAG,IAAIC,YAAY,CAACN,KAAK,EAAEE,UAAU,EAAED,KAAK,EAAEG,MAAM,EAAED,KAAK,CAAC;EAC1E,OAAOE,QAAQ;AACjB;AAEA,WAAaC,YAAY,6BAGvB,sBACEN,KAAc,EACdE,UAAmB,EACZD,KAAoB,EACpBG,MAAqB,EACrBD,KAAc,EACrB;EAAA;EAAA,KAHOF,KAAoB,GAApBA,KAAoB;EAAA,KACpBG,MAAqB,GAArBA,MAAqB;EAAA,KACrBD,KAAc,GAAdA,KAAc;EAAA,KAPvBJ,aAAa;EASX,IAAIC,KAAK,EAAE,IAAI,CAACD,aAAa,GAAGG,UAAU;AAC5C,CAAC"}
1
+ {"version":3,"file":"useKeycloak.native.js","names":["MultiPlatform","useExpoKeycloak","useKeycloak","isStorybook","authenticated","ready","login","isLoggedIn","token","logout","refreshToken","keycloak","ExpoKeycloak","undefined","constructor","tokenParsed","refreshTokenParsed","subject","realmAccess","resourceAccess","decodeToken","sub","realm_access","resource_access","str","split","replace","length","decodeURIComponent","escape","atob","JSON","parse"],"sources":["../../../src/hooks/useKeycloak/useKeycloak.native.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/useKeycloak.native.ts\n * Project: app\n * File Created: 08-11-2022 14:10:25\n * Author: Clay Risser\n * -----\n * Last Modified: 26-11-2022 09:05:23\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"core-js/actual/atob\";\nimport \"core-js/actual/escape\";\nimport { AuthRequestPromptOptions, AuthSessionResult } from \"expo-auth-session\";\nimport { IKeycloak } from \"./index\";\nimport {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useExpoKeycloak } from \"../../expo\";\n\nexport function useKeycloak() {\n if (MultiPlatform.isStorybook()) return { authenticated: true } as IKeycloak;\n const { ready, login, isLoggedIn, token, logout, refreshToken } =\n useExpoKeycloak();\n const keycloak = new ExpoKeycloak(\n ready,\n isLoggedIn,\n login,\n logout,\n token || undefined,\n refreshToken || undefined\n );\n return keycloak as IKeycloak;\n}\n\nexport class ExpoKeycloak implements IKeycloak {\n authenticated?: boolean;\n\n tokenParsed?: KeycloakTokenParsed;\n\n refreshTokenParsed?: KeycloakTokenParsed;\n\n subject?: string;\n\n realmAccess?: KeycloakRoles;\n\n resourceAccess?: KeycloakResourceAccess;\n\n login: () => Promise<unknown> | unknown;\n\n constructor(\n ready: boolean,\n isLoggedIn: boolean | undefined,\n login: (\n options?: AuthRequestPromptOptions\n ) => Promise<AuthSessionResult | undefined>,\n public logout: () => unknown,\n public token?: string,\n public refreshToken?: string\n ) {\n if (ready) this.authenticated = isLoggedIn;\n if (this.authenticated) {\n if (this.token) this.tokenParsed = decodeToken(this.token);\n if (this.refreshToken) {\n this.refreshTokenParsed = decodeToken(this.refreshToken);\n }\n if (this.tokenParsed) {\n this.subject = this.tokenParsed.sub;\n this.realmAccess = this.tokenParsed.realm_access;\n this.resourceAccess = this.tokenParsed.resource_access;\n }\n }\n this.login = () => login();\n }\n}\n\nfunction decodeToken(str: string) {\n str = str.split(\".\")[1];\n str = str.replace(/-/g, \"+\");\n str = str.replace(/_/g, \"/\");\n switch (str.length % 4) {\n case 0:\n break;\n case 2:\n str += \"==\";\n break;\n case 3:\n str += \"=\";\n break;\n default:\n throw \"Invalid token\";\n }\n str = decodeURIComponent(escape(atob(str)));\n str = JSON.parse(str);\n return str as unknown as KeycloakTokenParsed;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,qBAAqB;AAC5B,OAAO,uBAAuB;AAQ9B,SAASA,aAAa,QAAQ,mBAAmB;AACjD,SAASC,eAAe;AAExB,OAAO,SAASC,WAAW,GAAG;EAC5B,IAAIF,aAAa,CAACG,WAAW,EAAE,EAAE,OAAO;IAAEC,aAAa,EAAE;EAAK,CAAC;EAC/D,MAAM;IAAEC,KAA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5B;AACF;AAEA,SAASc,WAAW,CAACI,GAAW,EAAE;EAChCA,GAAG,GAAGA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EACvBD,GAAG,GAAGA,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EAC5BF,GAAG,GAAGA,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EAC5B,QAAQF,GAAG,CAACG,MAAM,GAAG,CAAC;IACpB,KAAK,CAAC;MACJ;IACF,KAAK,CAAC;MACJH,GAAG,IAAI,IAAI;MACX;IACF,KAAK,CAAC;MACJA,GAAG,IAAI,GAAG;MACV;IACF;MACE,MAAM,eAAe;EAAC;EAE1BA,GAAG,GAAGI,kBAAkB,CAACC,MAAM,CAACC,IAAI,CAACN,GAAG,CAAC,CAAC,CAAC;EAC3CA,GAAG,GAAGO,IAAI,CAACC,KAAK,CAACR,GAAG,CAAC;EACrB,OAAOA,GAAG;AACZ"}
@@ -1,16 +1,3 @@
1
- import _newArrowCheck from "@babel/runtime/helpers/newArrowCheck";
2
- import "core-js/modules/es.function.bind.js";
3
- import "core-js/modules/es.array.iterator.js";
4
- import "core-js/modules/es.object.to-string.js";
5
- import "core-js/modules/es.string.iterator.js";
6
- import "core-js/modules/web.dom-collections.iterator.js";
7
- import "core-js/modules/web.url.js";
8
- import "core-js/modules/web.url-search-params.js";
9
- import "core-js/modules/es.regexp.exec.js";
10
- import "core-js/modules/es.string.search.js";
11
- import "core-js/modules/es.date.to-string.js";
12
- import "core-js/modules/es.regexp.to-string.js";
13
- import "core-js/modules/es.array.concat.js";
14
1
  /**
15
2
  * File: /src/hooks/useLogin.ts
16
3
  * Project: app
@@ -41,28 +28,23 @@ import { useCurrentRouteName } from "./useCurrentRouteName";
41
28
  import { useKeycloak } from "./useKeycloak/useKeycloak";
42
29
  import { useAuthConfig } from "./useAuthConfig";
43
30
  export function useLogin(loginRoute) {
44
- var _this = this;
45
- if (MultiPlatform.isStorybook()) return function () {
46
- _newArrowCheck(this, _this);
47
- return null;
48
- }.bind(this);
49
- var keycloak = useKeycloak();
50
- var authConfig = useAuthConfig();
51
- var currentRouteName = useCurrentRouteName();
52
- var router = useRouter();
53
- return function () {
54
- _newArrowCheck(this, _this);
31
+ if (MultiPlatform.isStorybook()) return () => null;
32
+ const keycloak = useKeycloak();
33
+ const authConfig = useAuthConfig();
34
+ const currentRouteName = useCurrentRouteName();
35
+ const router = useRouter();
36
+ return () => {
55
37
  if (!loginRoute) loginRoute = authConfig.loginRoute;
56
38
  if (!loginRoute) {
57
39
  keycloak.login();
58
40
  return;
59
41
  }
60
- var url = new URL("x://".concat(loginRoute));
61
- var searchParams = new URLSearchParams(url.search);
42
+ const url = new URL(`x://${loginRoute}`);
43
+ const searchParams = new URLSearchParams(url.search);
62
44
  if (currentRouteName) searchParams.append("backTo", currentRouteName);
63
- var query = searchParams.toString();
64
- if (query.length) query = "?".concat(query);
65
- router.push("".concat(url.pathname.substring(2)).concat(query));
66
- }.bind(this);
45
+ let query = searchParams.toString();
46
+ if (query.length) query = `?${query}`;
47
+ router.push(`${url.pathname.substring(2)}${query}`);
48
+ };
67
49
  }
68
50
  //# sourceMappingURL=useLogin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLogin.js","names":["useRouter","MultiPlatform","useCurrentRouteName","useKeycloak","useAuthConfig","useLogin","loginRoute","isStorybook","keycloak","authConfig","currentRouteName","router","login","url","URL","searchParams","URLSearchParams","search","append","query","toString","length","push","pathname","substring"],"sources":["../../src/hooks/useLogin.ts"],"sourcesContent":["/**\n * File: /src/hooks/useLogin.ts\n * Project: app\n * File Created: 08-11-2022 08:49:14\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:36:32\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useRouter } from \"@risserlabs/solito/router\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useCurrentRouteName } from \"./useCurrentRouteName\";\nimport { useKeycloak } from \"./useKeycloak/useKeycloak\";\nimport { useAuthConfig } from \"./useAuthConfig\";\n\nexport function useLogin(loginRoute?: string) {\n if (MultiPlatform.isStorybook()) return () => null;\n const keycloak = useKeycloak();\n const authConfig = useAuthConfig();\n const currentRouteName = useCurrentRouteName();\n const router = useRouter();\n return () => {\n if (!loginRoute) loginRoute = authConfig.loginRoute;\n if (!loginRoute) {\n keycloak.login();\n return;\n }\n const url = new URL(`x://${loginRoute}`);\n const searchParams = new URLSearchParams(url.search);\n if (currentRouteName) searchParams.append(\"backTo\", currentRouteName);\n let query = searchParams.toString();\n if (query.length) query = `?${query}`;\n router.push(`${url.pathname.substring(2)}${query}`);\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,2BAA2B;AACrD,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,mBAAmB;AAC5B,SAASC,WAAW;AACpB,SAASC,aAAa;AAEtB,OAAO,SAASC,QAAQ,CAACC,UAAmB,EAAE;EAAA;EAC5C,IAAIL,aAAa,CAACM,WAAW,EAAE,EAAE,OAAO;IAAA;IAAA,OAAM,IAAI;EAAA;EAClD,IAAMC,QAAQ,GAAGL,WAAW,EAAE;EAC9B,IAAMM,UAAU,GAAGL,aAAa,EAAE;EAClC,IAAMM,gBAAgB,GAAGR,mBAAmB,EAAE;EAC9C,IAAMS,MAAM,GAAGX,SAAS,EAAE;EAC1B,OAAO,YAAM;IAAA;IACX,IAAI,CAACM,UAAU,EAAEA,UAAU,GAAGG,UAAU,CAACH,UAAU;IACnD,IAAI,CAACA,UAAU,EAAE;MACfE,QAAQ,CAACI,KAAK,EAAE;MAChB;IACF;IACA,IAAMC,GAAG,GAAG,IAAIC,GAAG,eAAQR,UAAU,EAAG;IACxC,IAAMS,YAAY,GAAG,IAAIC,eAAe,CAACH,GAAG,CAACI,MAAM,CAAC;IACpD,IAAIP,gBAAgB,EAAEK,YAAY,CAACG,MAAM,CAAC,QAAQ,EAAER,gBAAgB,CAAC;IACrE,IAAIS,KAAK,GAAGJ,YAAY,CAACK,QAAQ,EAAE;IACnC,IAAID,KAAK,CAACE,MAAM,EAAEF,KAAK,cAAOA,KAAK,CAAE;IACrCR,MAAM,CAACW,IAAI,WAAIT,GAAG,CAACU,QAAQ,CAACC,SAAS,CAAC,CAAC,CAAC,SAAGL,KAAK,EAAG;EACrD,CAAC;AACH"}
1
+ {"version":3,"file":"useLogin.js","names":["useRouter","MultiPlatform","useCurrentRouteName","useKeycloak","useAuthConfig","useLogin","loginRoute","isStorybook","keycloak","authConfig","currentRouteName","router","login","url","URL","searchParams","URLSearchParams","search","append","query","toString","length","push","pathname","substring"],"sources":["../../src/hooks/useLogin.ts"],"sourcesContent":["/**\n * File: /src/hooks/useLogin.ts\n * Project: app\n * File Created: 08-11-2022 08:49:14\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:36:32\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useRouter } from \"@risserlabs/solito/router\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useCurrentRouteName } from \"./useCurrentRouteName\";\nimport { useKeycloak } from \"./useKeycloak/useKeycloak\";\nimport { useAuthConfig } from \"./useAuthConfig\";\n\nexport function useLogin(loginRoute?: string) {\n if (MultiPlatform.isStorybook()) return () => null;\n const keycloak = useKeycloak();\n const authConfig = useAuthConfig();\n const currentRouteName = useCurrentRouteName();\n const router = useRouter();\n return () => {\n if (!loginRoute) loginRoute = authConfig.loginRoute;\n if (!loginRoute) {\n keycloak.login();\n return;\n }\n const url = new URL(`x://${loginRoute}`);\n const searchParams = new URLSearchParams(url.search);\n if (currentRouteName) searchParams.append(\"backTo\", currentRouteName);\n let query = searchParams.toString();\n if (query.length) query = `?${query}`;\n router.push(`${url.pathname.substring(2)}${query}`);\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,2BAA2B;AACrD,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,mBAAmB;AAC5B,SAASC,WAAW;AACpB,SAASC,aAAa;AAEtB,OAAO,SAASC,QAAQ,CAACC,UAAmB,EAAE;EAC5C,IAAIL,aAAa,CAACM,WAAW,EAAE,EAAE,OAAO,MAAM,IAAI;EAClD,MAAMC,QAAQ,GAAGL,WAAW,EAAE;EAC9B,MAAMM,UAAU,GAAGL,aAAa,EAAE;EAClC,MAAMM,gBAAgB,GAAGR,mBAAmB,EAAE;EAC9C,MAAMS,MAAM,GAAGX,SAAS,EAAE;EAC1B,OAAO,MAAM;IACX,IAAI,CAACM,UAAU,EAAEA,UAAU,GAAGG,UAAU,CAACH,UAAU;IACnD,IAAI,CAACA,UAAU,EAAE;MACfE,QAAQ,CAACI,KAAK,EAAE;MAChB;IACF;IACA,MAAMC,GAAG,GAAG,IAAIC,GAAG,CAAE,OAAMR,UAAW,EAAC,CAAC;IACxC,MAAMS,YAAY,GAAG,IAAIC,eAAe,CAACH,GAAG,CAACI,MAAM,CAAC;IACpD,IAAIP,gBAAgB,EAAEK,YAAY,CAACG,MAAM,CAAC,QAAQ,EAAER,gBAAgB,CAAC;IACrE,IAAIS,KAAK,GAAGJ,YAAY,CAACK,QAAQ,EAAE;IACnC,IAAID,KAAK,CAACE,MAAM,EAAEF,KAAK,GAAI,IAAGA,KAAM,EAAC;IACrCR,MAAM,CAACW,IAAI,CAAE,GAAET,GAAG,CAACU,QAAQ,CAACC,SAAS,CAAC,CAAC,CAAE,GAAEL,KAAM,EAAC,CAAC;EACrD,CAAC;AACH"}
@@ -1,20 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _newArrowCheck from "@babel/runtime/helpers/newArrowCheck";
4
- var _this = this;
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- import "core-js/modules/es.function.bind.js";
8
- import "core-js/modules/es.object.keys.js";
9
- import "core-js/modules/es.symbol.js";
10
- import "core-js/modules/es.array.filter.js";
11
- import "core-js/modules/es.object.to-string.js";
12
- import "core-js/modules/es.object.get-own-property-descriptor.js";
13
- import "core-js/modules/es.array.for-each.js";
14
- import "core-js/modules/web.dom-collections.for-each.js";
15
- import "core-js/modules/es.object.get-own-property-descriptors.js";
16
- import "core-js/modules/es.object.define-properties.js";
17
- import "core-js/modules/es.object.define-property.js";
18
1
  /**
19
2
  * File: /auth/provider/afterAuth.tsx
20
3
  * Project: app
@@ -43,34 +26,33 @@ import React, { useEffect } from "react";
43
26
  import { useKeycloak } from "../hooks";
44
27
  import { useAuthConfig } from "../hooks/useAuthConfig";
45
28
  import { useAuthState } from "../state";
46
- var logger = console;
47
- export var AfterAuth = function AfterAuth(_ref) {
48
- var _this2 = this;
49
- _newArrowCheck(this, _this);
50
- var children = _ref.children;
51
- var authConfig = useAuthConfig();
52
- var _useKeycloak = useKeycloak(),
53
- token = _useKeycloak.token,
54
- refreshToken = _useKeycloak.refreshToken,
55
- authenticated = _useKeycloak.authenticated;
56
- var _useAuthState = useAuthState(),
57
- _useAuthState2 = _slicedToArray(_useAuthState, 2),
58
- setAuth = _useAuthState2[1];
59
- useEffect(function () {
60
- _newArrowCheck(this, _this2);
29
+ const logger = console;
30
+ export const AfterAuth = _ref => {
31
+ let {
32
+ children
33
+ } = _ref;
34
+ const authConfig = useAuthConfig();
35
+ const {
36
+ token,
37
+ refreshToken,
38
+ authenticated
39
+ } = useKeycloak();
40
+ const [, setAuth] = useAuthState();
41
+ useEffect(() => {
61
42
  if (!authenticated) return;
62
43
  if (token) {
63
- setAuth(_objectSpread({
64
- token: token
65
- }, refreshToken ? {
66
- refreshToken: refreshToken
67
- } : {}));
44
+ setAuth({
45
+ token,
46
+ ...(refreshToken ? {
47
+ refreshToken
48
+ } : {})
49
+ });
68
50
  }
69
- }.bind(this), [token, refreshToken]);
51
+ }, [token, refreshToken]);
70
52
  if (authConfig.debug) {
71
53
  logger.debug("authenticated", authenticated);
72
54
  logger.debug("token", token);
73
55
  }
74
56
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
75
- }.bind(this);
57
+ };
76
58
  //# sourceMappingURL=afterAuth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"afterAuth.js","names":["React","useEffect","useKeycloak","useAuthConfig","useAuthState","logger","console","AfterAuth","children","authConfig","token","refreshToken","authenticated","setAuth","debug"],"sources":["../../src/provider/afterAuth.tsx"],"sourcesContent":["/**\n * File: /auth/provider/afterAuth.tsx\n * Project: app\n * File Created: 22-11-2022 17:49:58\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:00:39\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC, ReactNode, useEffect } from \"react\";\nimport { useKeycloak } from \"../hooks\";\nimport { useAuthConfig } from \"../hooks/useAuthConfig\";\nimport { useAuthState } from \"../state\";\n\nexport interface AfterAuthProps {\n children: ReactNode;\n}\n\nconst logger = console;\n\nexport const AfterAuth: FC<AfterAuthProps> = ({ children }: AfterAuthProps) => {\n const authConfig = useAuthConfig();\n const { token, refreshToken, authenticated } = useKeycloak();\n const [, setAuth] = useAuthState();\n\n useEffect(() => {\n if (!authenticated) return;\n if (token) {\n setAuth({\n token,\n ...(refreshToken ? { refreshToken } : {}),\n });\n }\n }, [token, refreshToken]);\n\n if (authConfig.debug) {\n logger.debug(\"authenticated\", authenticated);\n logger.debug(\"token\", token);\n }\n return <>{children}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAmBC,SAAS,QAAQ,OAAO;AACvD,SAASC,WAAW;AACpB,SAASC,aAAa;AACtB,SAASC,YAAY;AAMrB,IAAMC,MAAM,GAAGC,OAAO;AAEtB,OAAO,IAAMC,SAA6B,GAAG,yBAAkC;EAAA;EAAA;EAAA,IAA/BC,QAAQ,QAARA,QAAQ;EACtD,IAAMC,UAAU,GAAGN,aAAa,EAAE;EAClC,mBAA+CD,WAAW,EAAE;IAApDQ,KAAK,gBAALA,KAAK;IAAEC,YAAY,gBAAZA,YAAY;IAAEC,aAAa,gBAAbA,aAAa;EAC1C,oBAAoBR,YAAY,EAAE;IAAA;IAAzBS,OAAO;EAEhBZ,SAAS,CAAC,YAAM;IAAA;IACd,IAAI,CAACW,aAAa,EAAE;IACpB,IAAIF,KAAK,EAAE;MACTG,OAAO;QACLH,KAAK,EAALA;MAAK,GACDC,YAAY,GAAG;QAAEA,YAAY,EAAZA;MAAa,CAAC,GAAG,CAAC,CAAC,EACxC;IACJ;EACF,CAAC,aAAE,CAACD,KAAK,EAAEC,YAAY,CAAC,CAAC;EAEzB,IAAIF,UAAU,CAACK,KAAK,EAAE;IACpBT,MAAM,CAACS,KAAK,CAAC,eAAe,EAAEF,aAAa,CAAC;IAC5CP,MAAM,CAACS,KAAK,CAAC,OAAO,EAAEJ,KAAK,CAAC;EAC9B;EACA,oBAAO,0CAAGF,QAAQ,CAAI;AACxB,CAAC"}
1
+ {"version":3,"file":"afterAuth.js","names":["React","useEffect","useKeycloak","useAuthConfig","useAuthState","logger","console","AfterAuth","children","authConfig","token","refreshToken","authenticated","setAuth","debug"],"sources":["../../src/provider/afterAuth.tsx"],"sourcesContent":["/**\n * File: /auth/provider/afterAuth.tsx\n * Project: app\n * File Created: 22-11-2022 17:49:58\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:00:39\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC, ReactNode, useEffect } from \"react\";\nimport { useKeycloak } from \"../hooks\";\nimport { useAuthConfig } from \"../hooks/useAuthConfig\";\nimport { useAuthState } from \"../state\";\n\nexport interface AfterAuthProps {\n children: ReactNode;\n}\n\nconst logger = console;\n\nexport const AfterAuth: FC<AfterAuthProps> = ({ children }: AfterAuthProps) => {\n const authConfig = useAuthConfig();\n const { token, refreshToken, authenticated } = useKeycloak();\n const [, setAuth] = useAuthState();\n\n useEffect(() => {\n if (!authenticated) return;\n if (token) {\n setAuth({\n token,\n ...(refreshToken ? { refreshToken } : {}),\n });\n }\n }, [token, refreshToken]);\n\n if (authConfig.debug) {\n logger.debug(\"authenticated\", authenticated);\n logger.debug(\"token\", token);\n }\n return <>{children}</>;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAmBC,SAAS,QAAQ,OAAO;AACvD,SAASC,WAAW;AACpB,SAASC,aAAa;AACtB,SAASC,YAAY;AAMrB,MAAMC,MAAM,GAAGC,OAAO;AAEtB,OAAO,MAAMC,SAA6B,GAAG,QAAkC;EAAA,IAAjC;IAAEC;EAAyB,CAAC;EACxE,MAAMC,UAAU,GAAGN,aAAa,EAAE;EAClC,MAAM;IAAEO,KAAK;IAAEC,YAAY;IAAEC;EAAc,CAAC,GAAGV,WAAW,EAAE;EAC5D,MAAM,GAAGW,OAAO,CAAC,GAAGT,YAAY,EAAE;EAElCH,SAAS,CAAC,MAAM;IACd,IAAI,CAACW,aAAa,EAAE;IACpB,IAAIF,KAAK,EAAE;MACTG,OAAO,CAAC;QACNH,KAAK;QACL,IAAIC,YAAY,GAAG;UAAEA;QAAa,CAAC,GAAG,CAAC,CAAC;MAC1C,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAACD,KAAK,EAAEC,YAAY,CAAC,CAAC;EAEzB,IAAIF,UAAU,CAACK,KAAK,EAAE;IACpBT,MAAM,CAACS,KAAK,CAAC,eAAe,EAAEF,aAAa,CAAC;IAC5CP,MAAM,CAACS,KAAK,CAAC,OAAO,EAAEJ,KAAK,CAAC;EAC9B;EACA,oBAAO,0CAAGF,QAAQ,CAAI;AACxB,CAAC"}