@multiplatform.one/keycloak 0.1.10 → 0.2.1
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.
- package/dist/esm/Authenticated.mjs +25 -0
- package/dist/esm/Authenticated.mjs.map +7 -0
- package/dist/esm/authConfig.mjs +10 -0
- package/dist/esm/authConfig.mjs.map +7 -0
- package/dist/esm/hooks/index.mjs +4 -0
- package/dist/esm/hooks/index.mjs.map +7 -0
- package/dist/esm/hooks/useAuthConfig.mjs +9 -0
- package/dist/esm/hooks/useAuthConfig.mjs.map +7 -0
- package/dist/esm/hooks/useCurrentRouteName/index.mjs +17 -0
- package/dist/esm/hooks/useCurrentRouteName/index.mjs.map +7 -0
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs +12 -0
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/index.mjs +2 -0
- package/dist/esm/hooks/useKeycloak/index.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs +81 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs +108 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs.map +7 -0
- package/dist/esm/hooks/useLogin.mjs +35 -0
- package/dist/esm/hooks/useLogin.mjs.map +7 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/provider/afterAuth.mjs +29 -0
- package/dist/esm/provider/afterAuth.mjs.map +7 -0
- package/dist/esm/provider/index.mjs +73 -0
- package/dist/esm/provider/index.mjs.map +7 -0
- package/dist/esm/provider/keycloakProvider.mjs +273 -0
- package/dist/esm/provider/keycloakProvider.mjs.map +7 -0
- package/dist/esm/provider/keycloakProvider.native.mjs +69 -0
- package/dist/esm/provider/keycloakProvider.native.mjs.map +7 -0
- package/dist/esm/state/index.mjs +14 -0
- package/dist/esm/state/index.mjs.map +7 -0
- package/dist/esm/types.mjs +5 -0
- package/dist/esm/types.mjs.map +7 -0
- package/dist/jsx/Authenticated.mjs +20 -0
- package/dist/jsx/Authenticated.mjs.map +7 -0
- package/dist/jsx/authConfig.mjs +10 -0
- package/dist/jsx/authConfig.mjs.map +7 -0
- package/dist/jsx/hooks/index.mjs +4 -0
- package/dist/jsx/hooks/index.mjs.map +7 -0
- package/dist/jsx/hooks/useAuthConfig.mjs +9 -0
- package/dist/jsx/hooks/useAuthConfig.mjs.map +7 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs +17 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs.map +7 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs +12 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/index.mjs +2 -0
- package/dist/jsx/hooks/useKeycloak/index.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs +25 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs +58 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs.map +7 -0
- package/dist/jsx/hooks/useLogin.mjs +33 -0
- package/dist/jsx/hooks/useLogin.mjs.map +7 -0
- package/dist/jsx/index.mjs +5 -0
- package/dist/jsx/index.mjs.map +7 -0
- package/dist/jsx/provider/afterAuth.mjs +28 -0
- package/dist/jsx/provider/afterAuth.mjs.map +7 -0
- package/dist/jsx/provider/index.mjs +20 -0
- package/dist/jsx/provider/index.mjs.map +7 -0
- package/dist/jsx/provider/keycloakProvider.mjs +158 -0
- package/dist/jsx/provider/keycloakProvider.mjs.map +7 -0
- package/dist/jsx/provider/keycloakProvider.native.mjs +14 -0
- package/dist/jsx/provider/keycloakProvider.native.mjs.map +7 -0
- package/dist/jsx/state/index.mjs +17 -0
- package/dist/jsx/state/index.mjs.map +7 -0
- package/dist/jsx/types.mjs +5 -0
- package/dist/jsx/types.mjs.map +7 -0
- package/{lib → dist/lib}/Authenticated.d.ts +1 -1
- package/dist/lib/Authenticated.js +60 -0
- package/dist/lib/Authenticated.js.map +7 -0
- package/dist/lib/authConfig.js +35 -0
- package/dist/lib/authConfig.js.map +7 -0
- package/{lib → dist/lib}/hooks/index.d.ts +3 -3
- package/dist/lib/hooks/index.js +27 -0
- package/dist/lib/hooks/index.js.map +7 -0
- package/dist/lib/hooks/useAuthConfig.js +33 -0
- package/dist/lib/hooks/useAuthConfig.js.map +7 -0
- package/{lib/hooks/useCurrentRouteName.d.ts → dist/lib/hooks/useCurrentRouteName/index.d.ts} +5 -5
- package/dist/lib/hooks/useCurrentRouteName/index.js +41 -0
- package/dist/lib/hooks/useCurrentRouteName/index.js.map +7 -0
- package/{esm/types.js → dist/lib/hooks/useCurrentRouteName/index.native.d.ts} +5 -7
- package/dist/lib/hooks/useCurrentRouteName/index.native.js +36 -0
- package/dist/lib/hooks/useCurrentRouteName/index.native.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/index.d.ts +11 -4
- package/dist/lib/hooks/useKeycloak/index.js +23 -0
- package/dist/lib/hooks/useKeycloak/index.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/useKeycloak.d.ts +2 -2
- package/dist/lib/hooks/useKeycloak/useKeycloak.js +63 -0
- package/dist/lib/hooks/useKeycloak/useKeycloak.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/useKeycloak.native.d.ts +4 -4
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js +93 -0
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js.map +7 -0
- package/{lib → dist/lib}/hooks/useLogin.d.ts +1 -1
- package/dist/lib/hooks/useLogin.js +57 -0
- package/dist/lib/hooks/useLogin.js.map +7 -0
- package/{lib → dist/lib}/index.d.ts +4 -4
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.js.map +7 -0
- package/{lib → dist/lib}/provider/afterAuth.d.ts +1 -1
- package/dist/lib/provider/afterAuth.js +53 -0
- package/dist/lib/provider/afterAuth.js.map +7 -0
- package/{lib → dist/lib}/provider/index.d.ts +4 -4
- package/dist/lib/provider/index.js +62 -0
- package/dist/lib/provider/index.js.map +7 -0
- package/{lib → dist/lib}/provider/keycloakProvider.d.ts +2 -2
- package/dist/lib/provider/keycloakProvider.js +212 -0
- package/dist/lib/provider/keycloakProvider.js.map +7 -0
- package/{lib → dist/lib}/provider/keycloakProvider.native.d.ts +2 -2
- package/dist/lib/provider/keycloakProvider.native.js +55 -0
- package/dist/lib/provider/keycloakProvider.native.js.map +7 -0
- package/{esm/state/index.js → dist/lib/state/index.d.ts} +8 -13
- package/dist/lib/state/index.js +41 -0
- package/dist/lib/state/index.js.map +7 -0
- package/dist/lib/tsconfig.build.tsbuildinfo +1 -0
- package/dist/lib/types.js +25 -0
- package/dist/lib/types.js.map +7 -0
- package/package.json +44 -63
- package/src/@types/coreJsPure.d.ts +2 -2
- package/src/@types/expoKeycloakAuth.d.ts +1 -1
- package/src/Authenticated.tsx +5 -8
- package/src/authConfig.ts +1 -1
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useAuthConfig.ts +2 -2
- package/{esm/hooks/useCurrentRouteName.js → src/hooks/useCurrentRouteName/index.native.ts} +8 -13
- package/src/hooks/{useCurrentRouteName.ts → useCurrentRouteName/index.ts} +8 -8
- package/src/hooks/useKeycloak/index.ts +12 -8
- package/src/hooks/useKeycloak/useKeycloak.native.ts +18 -32
- package/src/hooks/useKeycloak/useKeycloak.ts +7 -7
- package/src/hooks/useLogin.ts +7 -7
- package/src/index.ts +4 -4
- package/src/provider/afterAuth.tsx +10 -11
- package/src/provider/index.tsx +9 -12
- package/src/provider/keycloakProvider.native.tsx +8 -10
- package/src/provider/keycloakProvider.tsx +44 -61
- package/src/state/index.ts +13 -10
- package/esm/Authenticated.js +0 -42
- package/esm/Authenticated.js.map +0 -1
- package/esm/authConfig.js +0 -30
- package/esm/authConfig.js.map +0 -1
- package/esm/hooks/index.js +0 -28
- package/esm/hooks/index.js.map +0 -1
- package/esm/hooks/useAuthConfig.js +0 -30
- package/esm/hooks/useAuthConfig.js.map +0 -1
- package/esm/hooks/useCurrentRouteName.js.map +0 -1
- package/esm/hooks/useKeycloak/index.js +0 -27
- package/esm/hooks/useKeycloak/index.js.map +0 -1
- package/esm/hooks/useKeycloak/useKeycloak.js +0 -55
- package/esm/hooks/useKeycloak/useKeycloak.js.map +0 -1
- package/esm/hooks/useKeycloak/useKeycloak.native.js +0 -91
- package/esm/hooks/useKeycloak/useKeycloak.native.js.map +0 -1
- package/esm/hooks/useLogin.js +0 -50
- package/esm/hooks/useLogin.js.map +0 -1
- package/esm/index.js +0 -29
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
- package/esm/provider/afterAuth.js +0 -58
- package/esm/provider/afterAuth.js.map +0 -1
- package/esm/provider/index.js +0 -43
- package/esm/provider/index.js.map +0 -1
- package/esm/provider/keycloakProvider.js +0 -175
- package/esm/provider/keycloakProvider.js.map +0 -1
- package/esm/provider/keycloakProvider.native.js +0 -41
- package/esm/provider/keycloakProvider.native.js.map +0 -1
- package/esm/state/index.js.map +0 -1
- package/esm/types.js.map +0 -1
- package/lib/Authenticated.js +0 -64
- package/lib/Authenticated.js.map +0 -1
- package/lib/authConfig.js +0 -51
- package/lib/authConfig.js.map +0 -1
- package/lib/hooks/index.js +0 -50
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useAuthConfig.js +0 -48
- package/lib/hooks/useAuthConfig.js.map +0 -1
- package/lib/hooks/useCurrentRouteName.js +0 -54
- package/lib/hooks/useCurrentRouteName.js.map +0 -1
- package/lib/hooks/useKeycloak/index.js +0 -30
- package/lib/hooks/useKeycloak/index.js.map +0 -1
- package/lib/hooks/useKeycloak/useKeycloak.js +0 -71
- package/lib/hooks/useKeycloak/useKeycloak.js.map +0 -1
- package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -112
- package/lib/hooks/useKeycloak/useKeycloak.native.js.map +0 -1
- package/lib/hooks/useLogin.js +0 -65
- package/lib/hooks/useLogin.js.map +0 -1
- package/lib/index.js +0 -60
- package/lib/index.js.map +0 -1
- package/lib/package.json +0 -1
- package/lib/provider/afterAuth.js +0 -78
- package/lib/provider/afterAuth.js.map +0 -1
- package/lib/provider/index.js +0 -77
- package/lib/provider/index.js.map +0 -1
- package/lib/provider/keycloakProvider.js +0 -193
- package/lib/provider/keycloakProvider.js.map +0 -1
- package/lib/provider/keycloakProvider.native.js +0 -61
- package/lib/provider/keycloakProvider.native.js.map +0 -1
- package/lib/state/index.d.ts +0 -34
- package/lib/state/index.js +0 -55
- package/lib/state/index.js.map +0 -1
- package/lib/tsconfig.build.tsbuildinfo +0 -1
- package/lib/types.js +0 -46
- package/lib/types.js.map +0 -1
- /package/{lib → dist/lib}/authConfig.d.ts +0 -0
- /package/{lib → dist/lib}/hooks/useAuthConfig.d.ts +0 -0
- /package/{lib → dist/lib}/types.d.ts +0 -0
package/esm/hooks/useLogin.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /src/hooks/useLogin.ts
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 08-11-2022 08:49:14
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 28-01-2023 13:47:42
|
|
8
|
-
* Modified By: Clay Risser
|
|
9
|
-
* -----
|
|
10
|
-
* Risser Labs LLC (c) Copyright 2021 - 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 { useRouter } from "solito/router";
|
|
26
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
27
|
-
import { useCurrentRouteName } from "./useCurrentRouteName";
|
|
28
|
-
import { useKeycloak } from "./useKeycloak/useKeycloak";
|
|
29
|
-
import { useAuthConfig } from "./useAuthConfig";
|
|
30
|
-
export function useLogin(loginRoute) {
|
|
31
|
-
if (MultiPlatform.isStorybook) return () => null;
|
|
32
|
-
const keycloak = useKeycloak();
|
|
33
|
-
const authConfig = useAuthConfig();
|
|
34
|
-
const currentRouteName = useCurrentRouteName();
|
|
35
|
-
const router = useRouter();
|
|
36
|
-
return () => {
|
|
37
|
-
if (!loginRoute) loginRoute = authConfig.loginRoute;
|
|
38
|
-
if (!loginRoute) {
|
|
39
|
-
keycloak.login();
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const url = new URL(`x://${loginRoute}`);
|
|
43
|
-
const searchParams = new URLSearchParams(url.search);
|
|
44
|
-
if (currentRouteName) searchParams.append("backTo", currentRouteName);
|
|
45
|
-
let query = searchParams.toString();
|
|
46
|
-
if (query.length) query = `?${query}`;
|
|
47
|
-
router.push(`${url.pathname.substring(2)}${query}`);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=useLogin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: 28-01-2023 13:47:42\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 \"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,eAAe;AACzC,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,OAAO,MAAM,IAAI;EAChD,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"}
|
package/esm/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /src/index.ts
|
|
3
|
-
* Project: @multiplatform.one/keycloak
|
|
4
|
-
* File Created: 25-11-2022 09:51:55
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 25-11-2022 09:52:06
|
|
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
|
-
export * from "./Authenticated";
|
|
26
|
-
export * from "./authConfig";
|
|
27
|
-
export * from "./hooks";
|
|
28
|
-
export * from "./provider";
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * File: /src/index.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 25-11-2022 09:51:55\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 09:52:06\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\nexport * from \"./Authenticated\";\nexport * from \"./authConfig\";\nexport * from \"./hooks\";\nexport * from \"./provider\";\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;AACA;AACA;AACA"}
|
package/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "module"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /auth/provider/afterAuth.tsx
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 22-11-2022 17:49:58
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 22-11-2022 18:00:39
|
|
8
|
-
* Modified By: Clay Risser
|
|
9
|
-
* -----
|
|
10
|
-
* Risser Labs LLC (c) Copyright 2021 - 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 React, { useEffect } from "react";
|
|
26
|
-
import { useKeycloak } from "../hooks";
|
|
27
|
-
import { useAuthConfig } from "../hooks/useAuthConfig";
|
|
28
|
-
import { useAuthState } from "../state";
|
|
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(() => {
|
|
42
|
-
if (!authenticated) return;
|
|
43
|
-
if (token) {
|
|
44
|
-
setAuth({
|
|
45
|
-
token,
|
|
46
|
-
...(refreshToken ? {
|
|
47
|
-
refreshToken
|
|
48
|
-
} : {})
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, [token, refreshToken]);
|
|
52
|
-
if (authConfig.debug) {
|
|
53
|
-
logger.debug("authenticated", authenticated);
|
|
54
|
-
logger.debug("token", token);
|
|
55
|
-
}
|
|
56
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=afterAuth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/esm/provider/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /auth/provider/index.tsx
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 08-11-2022 06:33:07
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 22-11-2022 18:00:13
|
|
8
|
-
* Modified By: Clay Risser
|
|
9
|
-
* -----
|
|
10
|
-
* Risser Labs LLC (c) Copyright 2021 - 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 React, { useMemo } from "react";
|
|
26
|
-
import { AuthConfigContext, defaultAuthConfig } from "../authConfig";
|
|
27
|
-
import { KeycloakProvider } from "./keycloakProvider";
|
|
28
|
-
export const AuthProvider = props => {
|
|
29
|
-
const {
|
|
30
|
-
authConfig,
|
|
31
|
-
debug
|
|
32
|
-
} = props;
|
|
33
|
-
const authConfigValue = useMemo(() => ({
|
|
34
|
-
...defaultAuthConfig,
|
|
35
|
-
...authConfig,
|
|
36
|
-
debug: !!debug
|
|
37
|
-
}), []);
|
|
38
|
-
return /*#__PURE__*/React.createElement(AuthConfigContext.Provider, {
|
|
39
|
-
value: authConfigValue
|
|
40
|
-
}, /*#__PURE__*/React.createElement(KeycloakProvider, props));
|
|
41
|
-
};
|
|
42
|
-
export * from "./keycloakProvider";
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","AuthConfigContext","defaultAuthConfig","KeycloakProvider","AuthProvider","props","authConfig","debug","authConfigValue"],"sources":["../../src/provider/index.tsx"],"sourcesContent":["/**\n * File: /auth/provider/index.tsx\n * Project: app\n * File Created: 08-11-2022 06:33:07\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:00:13\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, useMemo } from \"react\";\nimport {\n AuthConfig,\n AuthConfigContext,\n defaultAuthConfig,\n} from \"../authConfig\";\nimport { KeycloakProvider, KeycloakProviderProps } from \"./keycloakProvider\";\n\nexport interface AuthProviderProps extends KeycloakProviderProps {\n authConfig?: Partial<AuthConfig>;\n}\n\nexport const AuthProvider: FC<AuthProviderProps> = (\n props: AuthProviderProps\n) => {\n const { authConfig, debug } = props;\n const authConfigValue = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...authConfig,\n debug: !!debug,\n }),\n []\n );\n\n return (\n <AuthConfigContext.Provider value={authConfigValue}>\n <KeycloakProvider {...props} />\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from \"./keycloakProvider\";\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,IAAQC,OAAO,QAAQ,OAAO;AAC1C,SAEEC,iBAAiB,EACjBC,iBAAiB;AAEnB,SAASC,gBAAgB;AAMzB,OAAO,MAAMC,YAAmC,GAC9CC,KAAwB,IACrB;EACH,MAAM;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGF,KAAK;EACnC,MAAMG,eAAe,GAAGR,OAAO,CAC7B,OAAO;IACL,GAAGE,iBAAiB;IACpB,GAAGI,UAAU;IACbC,KAAK,EAAE,CAAC,CAACA;EACX,CAAC,CAAC,EACF,EAAE,CACH;EAED,oBACE,oBAAC,iBAAiB,CAAC,QAAQ;IAAC,KAAK,EAAEC;EAAgB,gBACjD,oBAAC,gBAAgB,EAAKH,KAAK,CAAI,CACJ;AAEjC,CAAC;AAED"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /auth/provider/keycloakProvider.tsx
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 08-11-2022 03:12:43
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 22-11-2022 18:07:46
|
|
8
|
-
* Modified By: Clay Risser
|
|
9
|
-
* -----
|
|
10
|
-
* Risser Labs LLC (c) Copyright 2021 - 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 Keycloak from "keycloak-js";
|
|
26
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
27
|
-
import { ReactKeycloakProvider } from "@react-keycloak/web";
|
|
28
|
-
import { SSRKeycloakProvider, SSRCookies } from "@react-keycloak/ssr";
|
|
29
|
-
import { useRouter } from "next/router";
|
|
30
|
-
import React, { useMemo, useEffect, useState } from "react";
|
|
31
|
-
import { useAuthConfig } from "../hooks/useAuthConfig";
|
|
32
|
-
import { useAuthState } from "../state";
|
|
33
|
-
import { AfterAuth } from "./afterAuth";
|
|
34
|
-
const logger = console;
|
|
35
|
-
export const KeycloakProvider = _ref => {
|
|
36
|
-
var _query$token, _query$refreshToken;
|
|
37
|
-
let {
|
|
38
|
-
children,
|
|
39
|
-
cookies,
|
|
40
|
-
debug,
|
|
41
|
-
keycloakConfig,
|
|
42
|
-
keycloakInitOptions,
|
|
43
|
-
loadingComponent
|
|
44
|
-
} = _ref;
|
|
45
|
-
const [auth] = useAuthState();
|
|
46
|
-
const LoadingComponent = loadingComponent || (() => /*#__PURE__*/React.createElement(React.Fragment, null, debug ? "authenticating" : null));
|
|
47
|
-
const {
|
|
48
|
-
query
|
|
49
|
-
} = MultiPlatform.isNext ? useRouter() : {
|
|
50
|
-
query: {}
|
|
51
|
-
};
|
|
52
|
-
const authConfig = useAuthConfig();
|
|
53
|
-
const [token, setToken] = useState("token" in query && (((_query$token = query.token) === null || _query$token === void 0 ? void 0 : _query$token.toString()) || true) || auth.token || false);
|
|
54
|
-
const [refreshToken, setRefreshToken] = useState("refreshToken" in query && (((_query$refreshToken = query.refreshToken) === null || _query$refreshToken === void 0 ? void 0 : _query$refreshToken.toString()) || true) || auth.refreshToken || false);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
var _window2, _window2$ReactNativeW, _window3, _window3$parent;
|
|
57
|
-
if (token !== true && refreshToken !== true) return;
|
|
58
|
-
if (debug) logger.debug("post message", {
|
|
59
|
-
type: "LOADED"
|
|
60
|
-
});
|
|
61
|
-
(authConfig.messageHandlerKeys || []).forEach(key => {
|
|
62
|
-
var _window, _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
63
|
-
(_window = window) === null || _window === void 0 ? void 0 : (_window$webkit = _window.webkit) === null || _window$webkit === void 0 ? void 0 : (_window$webkit$messag = _window$webkit.messageHandlers) === null || _window$webkit$messag === void 0 ? void 0 : (_window$webkit$messag2 = _window$webkit$messag[key]) === null || _window$webkit$messag2 === void 0 ? void 0 : _window$webkit$messag2.postMessage(JSON.stringify({
|
|
64
|
-
type: "LOADED"
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
(_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$ReactNativeW = _window2.ReactNativeWebView) === null || _window2$ReactNativeW === void 0 ? void 0 : _window2$ReactNativeW.postMessage(JSON.stringify({
|
|
68
|
-
type: "LOADED"
|
|
69
|
-
}));
|
|
70
|
-
(_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$parent = _window3.parent) === null || _window3$parent === void 0 ? void 0 : _window3$parent.postMessage(JSON.stringify({
|
|
71
|
-
type: "LOADED"
|
|
72
|
-
}));
|
|
73
|
-
}, []);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (token !== true) return;
|
|
76
|
-
const messageCallback = e => {
|
|
77
|
-
let data = e === null || e === void 0 ? void 0 : e.data;
|
|
78
|
-
if (typeof data === "string") {
|
|
79
|
-
try {
|
|
80
|
-
data = JSON.parse(data);
|
|
81
|
-
} catch (err) {}
|
|
82
|
-
}
|
|
83
|
-
if (debug) logger.debug("received message", data);
|
|
84
|
-
const message = data;
|
|
85
|
-
if (!message.type) return;
|
|
86
|
-
if (message.type.toUpperCase() === "TOKEN" && message.payload) {
|
|
87
|
-
if (debug) logger.debug("setting token", message.payload);
|
|
88
|
-
setToken(message.payload);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
if (debug) logger.debug("listening for message", {
|
|
92
|
-
type: "TOKEN",
|
|
93
|
-
payload: "<some_token>"
|
|
94
|
-
});
|
|
95
|
-
window.addEventListener("message", messageCallback);
|
|
96
|
-
return () => {
|
|
97
|
-
window.removeEventListener("message", messageCallback);
|
|
98
|
-
};
|
|
99
|
-
}, []);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (refreshToken !== true) return;
|
|
102
|
-
const messageCallback = e => {
|
|
103
|
-
let data = e === null || e === void 0 ? void 0 : e.data;
|
|
104
|
-
if (typeof data === "string") {
|
|
105
|
-
try {
|
|
106
|
-
data = JSON.parse(data);
|
|
107
|
-
} catch (err) {}
|
|
108
|
-
}
|
|
109
|
-
if (debug) logger.debug("received message", data);
|
|
110
|
-
const message = data;
|
|
111
|
-
if (!message.type) return;
|
|
112
|
-
if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
|
|
113
|
-
if (debug) logger.debug("setting refresh token", message.payload);
|
|
114
|
-
setRefreshToken(message.payload);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
if (debug) logger.debug("listening for message", {
|
|
118
|
-
type: "REFRESH_TOKEN",
|
|
119
|
-
payload: "<some_refresh_token>"
|
|
120
|
-
});
|
|
121
|
-
window.addEventListener("message", messageCallback);
|
|
122
|
-
return () => {
|
|
123
|
-
window.removeEventListener("message", messageCallback);
|
|
124
|
-
};
|
|
125
|
-
}, []);
|
|
126
|
-
const keycloak = useMemo(() => typeof window !== "undefined" && new Keycloak({
|
|
127
|
-
url: keycloakConfig.baseUrl,
|
|
128
|
-
realm: keycloakConfig.realm,
|
|
129
|
-
clientId: keycloakConfig.clientId
|
|
130
|
-
}), []);
|
|
131
|
-
const initOptions = useMemo(() => {
|
|
132
|
-
const initOptions = {
|
|
133
|
-
...defaultKeycloakInitOptions,
|
|
134
|
-
...keycloakInitOptions
|
|
135
|
-
};
|
|
136
|
-
if (token && typeof token === "string") {
|
|
137
|
-
initOptions.token = token;
|
|
138
|
-
if (refreshToken && typeof refreshToken === "string") initOptions.refreshToken = refreshToken;
|
|
139
|
-
initOptions.checkLoginIframe = false;
|
|
140
|
-
initOptions.onLoad = undefined;
|
|
141
|
-
}
|
|
142
|
-
return initOptions;
|
|
143
|
-
}, [keycloakInitOptions, token, refreshToken]);
|
|
144
|
-
if (token === true || refreshToken === true) return /*#__PURE__*/React.createElement(LoadingComponent, null);
|
|
145
|
-
if (cookies && authConfig.ssr) {
|
|
146
|
-
return (
|
|
147
|
-
/*#__PURE__*/
|
|
148
|
-
// @ts-ignore
|
|
149
|
-
React.createElement(SSRKeycloakProvider, {
|
|
150
|
-
initOptions: initOptions,
|
|
151
|
-
keycloakConfig: {
|
|
152
|
-
url: keycloakConfig.baseUrl,
|
|
153
|
-
realm: keycloakConfig.realm,
|
|
154
|
-
clientId: keycloakConfig.clientId
|
|
155
|
-
},
|
|
156
|
-
persistor: SSRCookies(cookies),
|
|
157
|
-
LoadingComponent: /*#__PURE__*/React.createElement(LoadingComponent, null)
|
|
158
|
-
}, /*#__PURE__*/React.createElement(AfterAuth, null, children))
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
if (!keycloak) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
162
|
-
return /*#__PURE__*/React.createElement(ReactKeycloakProvider, {
|
|
163
|
-
initOptions: initOptions,
|
|
164
|
-
authClient: keycloak,
|
|
165
|
-
LoadingComponent: /*#__PURE__*/React.createElement(LoadingComponent, null)
|
|
166
|
-
}, /*#__PURE__*/React.createElement(AfterAuth, null, children));
|
|
167
|
-
};
|
|
168
|
-
export const defaultKeycloakInitOptions = {
|
|
169
|
-
checkLoginIframe: true,
|
|
170
|
-
checkLoginIframeInterval: 5,
|
|
171
|
-
enableLogging: false,
|
|
172
|
-
onLoad: "check-sso",
|
|
173
|
-
pkceMethod: "S256"
|
|
174
|
-
};
|
|
175
|
-
//# sourceMappingURL=keycloakProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keycloakProvider.js","names":["Keycloak","MultiPlatform","ReactKeycloakProvider","SSRKeycloakProvider","SSRCookies","useRouter","React","useMemo","useEffect","useState","useAuthConfig","useAuthState","AfterAuth","logger","console","KeycloakProvider","children","cookies","debug","keycloakConfig","keycloakInitOptions","loadingComponent","auth","LoadingComponent","query","isNext","authConfig","token","setToken","toString","refreshToken","setRefreshToken","type","messageHandlerKeys","forEach","key","window","webkit","messageHandlers","postMessage","JSON","stringify","ReactNativeWebView","parent","messageCallback","e","data","parse","err","message","toUpperCase","payload","addEventListener","removeEventListener","keycloak","url","baseUrl","realm","clientId","initOptions","defaultKeycloakInitOptions","checkLoginIframe","onLoad","undefined","ssr","checkLoginIframeInterval","enableLogging","pkceMethod"],"sources":["../../src/provider/keycloakProvider.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:43\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:07:46\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, { KeycloakInitOptions } from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { ReactKeycloakProvider } from \"@react-keycloak/web\";\nimport { SSRKeycloakProvider, SSRCookies } from \"@react-keycloak/ssr\";\nimport { useRouter } from \"next/router\";\nimport React, {\n FC,\n ReactNode,\n useMemo,\n useEffect,\n useState,\n ComponentType,\n} from \"react\";\nimport { useAuthConfig } from \"../hooks/useAuthConfig\";\nimport { useAuthState } from \"../state\";\nimport { AfterAuth } from \"./afterAuth\";\n\nexport interface KeycloakProviderProps {\n children: ReactNode;\n cookies?: unknown;\n debug?: boolean;\n disabled?: boolean;\n keycloakConfig: KeycloakConfig;\n keycloakInitOptions?: KeycloakInitOptions;\n loadingComponent?: ComponentType;\n}\n\nconst logger = console;\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n cookies,\n debug,\n keycloakConfig,\n keycloakInitOptions,\n loadingComponent,\n}: KeycloakProviderProps) => {\n const [auth] = useAuthState();\n const LoadingComponent =\n loadingComponent || (() => <>{debug ? \"authenticating\" : null}</>);\n const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };\n const authConfig = useAuthConfig();\n const [token, setToken] = useState<string | boolean>(\n (\"token\" in query && (query.token?.toString() || true)) ||\n auth.token ||\n false\n );\n const [refreshToken, setRefreshToken] = useState<string | boolean>(\n (\"refreshToken\" in query && (query.refreshToken?.toString() || true)) ||\n auth.refreshToken ||\n false\n );\n\n useEffect(() => {\n if (token !== true && refreshToken !== true) return;\n if (debug) logger.debug(\"post message\", { type: \"LOADED\" });\n (authConfig.messageHandlerKeys || []).forEach((key: string) => {\n window?.webkit?.messageHandlers?.[key]?.postMessage(\n JSON.stringify({ type: \"LOADED\" })\n );\n });\n window?.ReactNativeWebView?.postMessage(JSON.stringify({ type: \"LOADED\" }));\n window?.parent?.postMessage(JSON.stringify({ type: \"LOADED\" }));\n }, []);\n\n useEffect(() => {\n if (token !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data;\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug(\"received message\", data);\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === \"TOKEN\" && message.payload) {\n if (debug) logger.debug(\"setting token\", message.payload);\n setToken(message.payload);\n }\n };\n if (debug)\n logger.debug(\"listening for message\", {\n type: \"TOKEN\",\n payload: \"<some_token>\",\n });\n window.addEventListener(\"message\", messageCallback);\n return () => {\n window.removeEventListener(\"message\", messageCallback);\n };\n }, []);\n\n useEffect(() => {\n if (refreshToken !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data;\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug(\"received message\", data);\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === \"REFRESH_TOKEN\" && message.payload) {\n if (debug) logger.debug(\"setting refresh token\", message.payload);\n setRefreshToken(message.payload);\n }\n };\n if (debug)\n logger.debug(\"listening for message\", {\n type: \"REFRESH_TOKEN\",\n payload: \"<some_refresh_token>\",\n });\n window.addEventListener(\"message\", messageCallback);\n return () => {\n window.removeEventListener(\"message\", messageCallback);\n };\n }, []);\n\n const keycloak = useMemo(\n () =>\n typeof window !== \"undefined\" &&\n new Keycloak({\n url: keycloakConfig.baseUrl,\n realm: keycloakConfig.realm,\n clientId: keycloakConfig.clientId,\n }),\n []\n );\n\n const initOptions = useMemo(() => {\n const initOptions = {\n ...defaultKeycloakInitOptions,\n ...keycloakInitOptions,\n };\n if (token && typeof token === \"string\") {\n initOptions.token = token;\n if (refreshToken && typeof refreshToken === \"string\")\n initOptions.refreshToken = refreshToken;\n initOptions.checkLoginIframe = false;\n initOptions.onLoad = undefined;\n }\n return initOptions;\n }, [keycloakInitOptions, token, refreshToken]);\n\n if (token === true || refreshToken === true) return <LoadingComponent />;\n if (cookies && authConfig.ssr) {\n return (\n // @ts-ignore\n <SSRKeycloakProvider\n initOptions={initOptions}\n keycloakConfig={{\n url: keycloakConfig.baseUrl,\n realm: keycloakConfig.realm,\n clientId: keycloakConfig.clientId,\n }}\n persistor={SSRCookies(cookies)}\n LoadingComponent={<LoadingComponent />}\n >\n <AfterAuth>{children}</AfterAuth>\n </SSRKeycloakProvider>\n );\n }\n if (!keycloak) return <>{children}</>;\n return (\n <ReactKeycloakProvider\n initOptions={initOptions}\n authClient={keycloak}\n LoadingComponent={<LoadingComponent />}\n >\n <AfterAuth>{children}</AfterAuth>\n </ReactKeycloakProvider>\n );\n};\n\nexport interface KeycloakConfig {\n clientId: string;\n realm: string;\n scheme?: string;\n baseUrl: string;\n}\n\nexport const defaultKeycloakInitOptions: KeycloakInitOptions = {\n checkLoginIframe: true,\n checkLoginIframeInterval: 5,\n enableLogging: false,\n onLoad: \"check-sso\",\n pkceMethod: \"S256\",\n};\n\nexport interface MessageSchema {\n type: string;\n payload?: string;\n}\n"],"mappings":"AAAA;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EAAEG,YAAY,CAAC,CAAC;EAE9C,IAAIH,KAAK,KAAK,IAAI,IAAIG,YAAY,KAAK,IAAI,EAAE,oBAAO,oBAAC,gBAAgB,OAAG;EACxE,IAAIb,OAAO,IAAIS,UAAU,CAACsC,GAAG,EAAE;IAC7B;MAAA;MACE;MACA,oBAAC,mBAAmB;QAClB,WAAW,EAAEL,WAAY;QACzB,cAAc,EAAE;UACdJ,GAAG,EAAEpC,cAAc,CAACqC,OAAO;UAC3BC,KAAK,EAAEtC,cAAc,CAACsC,KAAK;UAC3BC,QAAQ,EAAEvC,cAAc,CAACuC;QAC3B,CAAE;QACF,SAAS,EAAEtD,UAAU,CAACa,OAAO,CAAE;QAC/B,gBAAgB,eAAE,oBAAC,gBAAgB;MAAI,gBAEvC,oBAAC,SAAS,QAAED,QAAQ,CAAa;IACb;EAE1B;EACA,IAAI,CAACsC,QAAQ,EAAE,oBAAO,0CAAGtC,QAAQ,CAAI;EACrC,oBACE,oBAAC,qBAAqB;IACpB,WAAW,EAAE2C,WAAY;IACzB,UAAU,EAAEL,QAAS;IACrB,gBAAgB,eAAE,oBAAC,gBAAgB;EAAI,gBAEvC,oBAAC,SAAS,QAAEtC,QAAQ,CAAa,CACX;AAE5B,CAAC;AASD,OAAO,MAAM4C,0BAA+C,GAAG;EAC7DC,gBAAgB,EAAE,IAAI;EACtBI,wBAAwB,EAAE,CAAC;EAC3BC,aAAa,EAAE,KAAK;EACpBJ,MAAM,EAAE,WAAW;EACnBK,UAAU,EAAE;AACd,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /auth/provider/keycloakProvider.native.tsx
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 08-11-2022 03:12:37
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 22-11-2022 17:52:31
|
|
8
|
-
* Modified By: Clay Risser
|
|
9
|
-
* -----
|
|
10
|
-
* Risser Labs LLC (c) Copyright 2021 - 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 React from "react";
|
|
26
|
-
import { AfterAuth } from "./afterAuth";
|
|
27
|
-
import { KeycloakProvider as ExpoKeycloakProvider } from "expo-keycloak-auth";
|
|
28
|
-
export const KeycloakProvider = _ref => {
|
|
29
|
-
let {
|
|
30
|
-
children,
|
|
31
|
-
keycloakConfig
|
|
32
|
-
} = _ref;
|
|
33
|
-
const clonedKeycloakConfig = {
|
|
34
|
-
...keycloakConfig,
|
|
35
|
-
url: keycloakConfig.baseUrl
|
|
36
|
-
};
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
delete keycloakConfig.baseUrl;
|
|
39
|
-
return /*#__PURE__*/React.createElement(ExpoKeycloakProvider, clonedKeycloakConfig, /*#__PURE__*/React.createElement(AfterAuth, null, children));
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=keycloakProvider.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keycloakProvider.native.js","names":["React","AfterAuth","KeycloakProvider","ExpoKeycloakProvider","children","keycloakConfig","clonedKeycloakConfig","url","baseUrl"],"sources":["../../src/provider/keycloakProvider.native.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.native.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:37\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 17: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\nimport React, { FC } from \"react\";\nimport type { KeycloakProviderProps } from \"./keycloakProvider\";\nimport { AfterAuth } from \"./afterAuth\";\nimport { KeycloakConfig } from \"keycloak-js\";\nimport { KeycloakProvider as ExpoKeycloakProvider } from \"expo-keycloak-auth\";\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n keycloakConfig,\n}: KeycloakProviderProps) => {\n const clonedKeycloakConfig = {\n ...(keycloakConfig as Omit<KeycloakConfig, \"baseUrl\">),\n url: keycloakConfig.baseUrl,\n };\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return (\n <ExpoKeycloakProvider {...clonedKeycloakConfig}>\n <AfterAuth>{children}</AfterAuth>\n </ExpoKeycloakProvider>\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,OAAOA,KAAK,MAAc,OAAO;AAEjC,SAASC,SAAS;AAElB,SAASC,gBAAgB,IAAIC,oBAAoB,QAAQ,oBAAoB;AAE7E,OAAO,MAAMD,gBAA2C,GAAG,QAG9B;EAAA,IAH+B;IAC1DE,QAAQ;IACRC;EACqB,CAAC;EACtB,MAAMC,oBAAoB,GAAG;IAC3B,GAAID,cAAkD;IACtDE,GAAG,EAAEF,cAAc,CAACG;EACtB,CAAC;EACD;EACA,OAAOH,cAAc,CAACG,OAAO;EAC7B,oBACE,oBAAC,oBAAoB,EAAKF,oBAAoB,eAC5C,oBAAC,SAAS,QAAEF,QAAQ,CAAa,CACZ;AAE3B,CAAC"}
|
package/esm/state/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["atom","useRecoilState","persistAtom","useAuthState","authState","key","default","effects"],"sources":["../../src/state/index.ts"],"sourcesContent":["/**\n * File: /src/state/index.ts\n * Project: app\n * File Created: 22-11-2022 17:40:53\n * Author: Clay Risser\n * -----\n * Last Modified: 01-02-2023 14:38:51\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 { atom, useRecoilState } from \"recoil\";\nimport { persistAtom } from \"multiplatform.one/recoil\";\n\nexport function useAuthState() {\n return useRecoilState(authState);\n}\n\nexport const authState = atom<{ token?: string; refreshToken?: string }>({\n key: \"auth\",\n default: {},\n effects: [persistAtom],\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,IAAI,EAAEC,cAAc,QAAQ,QAAQ;AAC7C,SAASC,WAAW,QAAQ,0BAA0B;AAEtD,OAAO,SAASC,YAAY,GAAG;EAC7B,OAAOF,cAAc,CAACG,SAAS,CAAC;AAClC;AAEA,OAAO,MAAMA,SAAS,GAAGJ,IAAI,CAA4C;EACvEK,GAAG,EAAE,MAAM;EACXC,OAAO,EAAE,CAAC,CAAC;EACXC,OAAO,EAAE,CAACL,WAAW;AACvB,CAAC,CAAC"}
|
package/esm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * File: /src/types.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 25-11-2022 10:27:53\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:28:25\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\ndeclare global {\n interface Window {\n ReactNativeWebView: {\n postMessage: (body: string) => unknown;\n };\n webkit: {\n messageHandlers: {\n [key: string]: {\n postMessage: (body: string) => unknown;\n };\n };\n };\n }\n}\n\nexport default null;\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;;AAiBA,eAAe,IAAI"}
|
package/lib/Authenticated.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "react", "./hooks"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("react"), require("./hooks"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.react, global.hooks);
|
|
11
|
-
global.Authenticated = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _hooks) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
17
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
});
|
|
20
|
-
_exports.Authenticated = void 0;
|
|
21
|
-
_exports.withAuthenticated = withAuthenticated;
|
|
22
|
-
_react = _interopRequireDefault(_react);
|
|
23
|
-
/**
|
|
24
|
-
* File: /auth/Authenticated.tsx
|
|
25
|
-
* Project: app
|
|
26
|
-
* File Created: 08-11-2022 05:58:23
|
|
27
|
-
* Author: Clay Risser
|
|
28
|
-
* -----
|
|
29
|
-
* Last Modified: 22-11-2022 06:26:38
|
|
30
|
-
* Modified By: Clay Risser
|
|
31
|
-
* -----
|
|
32
|
-
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
33
|
-
*
|
|
34
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
35
|
-
* you may not use this file except in compliance with the License.
|
|
36
|
-
* You may obtain a copy of the License at
|
|
37
|
-
*
|
|
38
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
-
*
|
|
40
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
41
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
42
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
43
|
-
* See the License for the specific language governing permissions and
|
|
44
|
-
* limitations under the License.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
const Authenticated = props => {
|
|
48
|
-
const {
|
|
49
|
-
authenticated
|
|
50
|
-
} = (0, _hooks.useKeycloak)();
|
|
51
|
-
const login = (0, _hooks.useLogin)(props.loginRoute);
|
|
52
|
-
if (!props.disabled && !authenticated) {
|
|
53
|
-
if (authenticated === false) login();
|
|
54
|
-
const LoggedOutComponent = props.loggedOutComponent || (() => null);
|
|
55
|
-
return /*#__PURE__*/_react.default.createElement(LoggedOutComponent, null);
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
|
|
58
|
-
};
|
|
59
|
-
_exports.Authenticated = Authenticated;
|
|
60
|
-
function withAuthenticated(Component) {
|
|
61
|
-
return props => /*#__PURE__*/_react.default.createElement(Authenticated, null, /*#__PURE__*/_react.default.createElement(Component, props));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=Authenticated.js.map
|
package/lib/Authenticated.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Authenticated.js","names":["Authenticated","props","authenticated","useKeycloak","login","useLogin","loginRoute","disabled","LoggedOutComponent","loggedOutComponent","children","withAuthenticated","Component"],"sources":["../src/Authenticated.tsx"],"sourcesContent":["/**\n * File: /auth/Authenticated.tsx\n * Project: app\n * File Created: 08-11-2022 05:58:23\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 06:26:38\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, { ComponentType, FC, ReactNode } from \"react\";\nimport { useLogin, useKeycloak } from \"./hooks\";\n\nexport interface AuthenticatedProps {\n children: ReactNode;\n disabled?: boolean;\n loggedOutComponent?: ComponentType;\n loginRoute?: string;\n}\n\nexport const Authenticated: FC<AuthenticatedProps> = (\n props: AuthenticatedProps\n) => {\n const { authenticated } = useKeycloak();\n const login = useLogin(props.loginRoute);\n if (!props.disabled && !authenticated) {\n if (authenticated === false) login();\n const LoggedOutComponent = props.loggedOutComponent || (() => null);\n return <LoggedOutComponent />;\n }\n return <>{props.children}</>;\n};\n\nexport function withAuthenticated<P extends object>(\n Component: ComponentType<P>\n) {\n return (props: P) => (\n <Authenticated>\n <Component {...props} />\n </Authenticated>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAYO,MAAMA,aAAqC,GAChDC,KAAyB,IACtB;IACH,MAAM;MAAEC;IAAc,CAAC,GAAG,IAAAC,kBAAW,GAAE;IACvC,MAAMC,KAAK,GAAG,IAAAC,eAAQ,EAACJ,KAAK,CAACK,UAAU,CAAC;IACxC,IAAI,CAACL,KAAK,CAACM,QAAQ,IAAI,CAACL,aAAa,EAAE;MACrC,IAAIA,aAAa,KAAK,KAAK,EAAEE,KAAK,EAAE;MACpC,MAAMI,kBAAkB,GAAGP,KAAK,CAACQ,kBAAkB,KAAK,MAAM,IAAI,CAAC;MACnE,oBAAO,6BAAC,kBAAkB,OAAG;IAC/B;IACA,oBAAO,4DAAGR,KAAK,CAACS,QAAQ,CAAI;EAC9B,CAAC;EAAC;EAEK,SAASC,iBAAiB,CAC/BC,SAA2B,EAC3B;IACA,OAAQX,KAAQ,iBACd,6BAAC,aAAa,qBACZ,6BAAC,SAAS,EAAKA,KAAK,CAAI,CAE3B;EACH;AAAC"}
|
package/lib/authConfig.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "react"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("react"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.react);
|
|
11
|
-
global.authConfig = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
_exports.defaultAuthConfig = _exports.AuthConfigContext = void 0;
|
|
20
|
-
/**
|
|
21
|
-
* File: /src/authConfig.ts
|
|
22
|
-
* Project: app
|
|
23
|
-
* File Created: 08-11-2022 09:21:15
|
|
24
|
-
* Author: Clay Risser
|
|
25
|
-
* -----
|
|
26
|
-
* Last Modified: 25-11-2022 10:29:29
|
|
27
|
-
* Modified By: Clay Risser
|
|
28
|
-
* -----
|
|
29
|
-
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
30
|
-
*
|
|
31
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
-
* you may not use this file except in compliance with the License.
|
|
33
|
-
* You may obtain a copy of the License at
|
|
34
|
-
*
|
|
35
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
-
*
|
|
37
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
-
* See the License for the specific language governing permissions and
|
|
41
|
-
* limitations under the License.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
const defaultAuthConfig = {
|
|
45
|
-
ssr: true
|
|
46
|
-
};
|
|
47
|
-
_exports.defaultAuthConfig = defaultAuthConfig;
|
|
48
|
-
const AuthConfigContext = /*#__PURE__*/(0, _react.createContext)(defaultAuthConfig);
|
|
49
|
-
_exports.AuthConfigContext = AuthConfigContext;
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=authConfig.js.map
|
package/lib/authConfig.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authConfig.js","names":["defaultAuthConfig","ssr","AuthConfigContext","createContext"],"sources":["../src/authConfig.ts"],"sourcesContent":["/**\n * File: /src/authConfig.ts\n * Project: app\n * File Created: 08-11-2022 09:21:15\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:29:29\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 { createContext } from \"react\";\n\nexport const defaultAuthConfig: AuthConfig = {\n ssr: true,\n};\n\nexport const AuthConfigContext = createContext<AuthConfig>(defaultAuthConfig);\n\nexport interface AuthConfig {\n debug?: boolean;\n loginRoute?: string;\n messageHandlerKeys?: string[];\n ssr?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAIO,MAAMA,iBAA6B,GAAG;IAC3CC,GAAG,EAAE;EACP,CAAC;EAAC;EAEK,MAAMC,iBAAiB,gBAAG,IAAAC,oBAAa,EAAaH,iBAAiB,CAAC;EAAC;AAAA"}
|