@multiplatform.one/keycloak 0.0.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/README.md +3 -0
- package/esm/Authenticated.js +53 -0
- package/esm/Authenticated.js.map +1 -0
- package/esm/authConfig.js +30 -0
- package/esm/authConfig.js.map +1 -0
- package/esm/hooks/index.js +28 -0
- package/esm/hooks/index.js.map +1 -0
- package/esm/hooks/useAuthConfig.js +30 -0
- package/esm/hooks/useAuthConfig.js.map +1 -0
- package/esm/hooks/useCurrentRouteName.js +38 -0
- package/esm/hooks/useCurrentRouteName.js.map +1 -0
- package/esm/hooks/useKeycloak/index.js +27 -0
- package/esm/hooks/useKeycloak/index.js.map +1 -0
- package/esm/hooks/useKeycloak/useKeycloak.js +62 -0
- package/esm/hooks/useKeycloak/useKeycloak.js.map +1 -0
- package/esm/hooks/useKeycloak/useKeycloak.native.js +50 -0
- package/esm/hooks/useKeycloak/useKeycloak.native.js.map +1 -0
- package/esm/hooks/useLogin.js +68 -0
- package/esm/hooks/useLogin.js.map +1 -0
- package/esm/index.js +29 -0
- package/esm/index.js.map +1 -0
- package/esm/package.json +1 -0
- package/esm/provider/afterAuth.js +76 -0
- package/esm/provider/afterAuth.js.map +1 -0
- package/esm/provider/index.js +60 -0
- package/esm/provider/index.js.map +1 -0
- package/esm/provider/keycloakProvider.js +220 -0
- package/esm/provider/keycloakProvider.js.map +1 -0
- package/esm/provider/keycloakProvider.native.js +40 -0
- package/esm/provider/keycloakProvider.native.js.map +1 -0
- package/esm/state/index.js +35 -0
- package/esm/state/index.js.map +1 -0
- package/esm/types.js +26 -0
- package/esm/types.js.map +1 -0
- package/lib/Authenticated.d.ts +32 -0
- package/lib/Authenticated.js +52 -0
- package/lib/Authenticated.js.map +1 -0
- package/lib/authConfig.d.ts +32 -0
- package/lib/authConfig.js +53 -0
- package/lib/authConfig.js.map +1 -0
- package/lib/hooks/index.d.ts +26 -0
- package/lib/hooks/index.js +56 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useAuthConfig.d.ts +24 -0
- package/lib/hooks/useAuthConfig.js +50 -0
- package/lib/hooks/useAuthConfig.js.map +1 -0
- package/lib/hooks/useCurrentRouteName.d.ts +24 -0
- package/lib/hooks/useCurrentRouteName.js +56 -0
- package/lib/hooks/useCurrentRouteName.js.map +1 -0
- package/lib/hooks/useKeycloak/index.d.ts +32 -0
- package/lib/hooks/useKeycloak/index.js +36 -0
- package/lib/hooks/useKeycloak/index.js.map +1 -0
- package/lib/hooks/useKeycloak/useKeycloak.d.ts +25 -0
- package/lib/hooks/useKeycloak/useKeycloak.js +56 -0
- package/lib/hooks/useKeycloak/useKeycloak.js.map +1 -0
- package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +32 -0
- package/lib/hooks/useKeycloak/useKeycloak.native.js +73 -0
- package/lib/hooks/useKeycloak/useKeycloak.native.js.map +1 -0
- package/lib/hooks/useLogin.d.ts +24 -0
- package/lib/hooks/useLogin.js +74 -0
- package/lib/hooks/useLogin.js.map +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.js +66 -0
- package/lib/index.js.map +1 -0
- package/lib/package.json +1 -0
- package/lib/provider/afterAuth.d.ts +28 -0
- package/lib/provider/afterAuth.js +78 -0
- package/lib/provider/afterAuth.js.map +1 -0
- package/lib/provider/index.d.ts +31 -0
- package/lib/provider/index.js +76 -0
- package/lib/provider/index.js.map +1 -0
- package/lib/provider/keycloakProvider.d.ts +46 -0
- package/lib/provider/keycloakProvider.js +214 -0
- package/lib/provider/keycloakProvider.js.map +1 -0
- package/lib/provider/keycloakProvider.native.d.ts +26 -0
- package/lib/provider/keycloakProvider.native.js +37 -0
- package/lib/provider/keycloakProvider.native.js.map +1 -0
- package/lib/state/index.d.ts +34 -0
- package/lib/state/index.js +59 -0
- package/lib/state/index.js.map +1 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -0
- package/lib/types.d.ts +39 -0
- package/lib/types.js +48 -0
- package/lib/types.js.map +1 -0
- package/package.json +141 -0
- package/src/@types/expoKeycloakAuth.d.ts +28 -0
- package/src/Authenticated.tsx +56 -0
- package/src/authConfig.ts +38 -0
- package/src/hooks/index.ts +27 -0
- package/src/hooks/useAuthConfig.ts +30 -0
- package/src/hooks/useCurrentRouteName.ts +37 -0
- package/src/hooks/useKeycloak/index.ts +34 -0
- package/src/hooks/useKeycloak/useKeycloak.native.ts +48 -0
- package/src/hooks/useKeycloak/useKeycloak.ts +45 -0
- package/src/hooks/useLogin.ts +50 -0
- package/src/index.ts +28 -0
- package/src/provider/afterAuth.tsx +56 -0
- package/src/provider/index.tsx +57 -0
- package/src/provider/keycloakProvider.native.tsx +42 -0
- package/src/provider/keycloakProvider.tsx +220 -0
- package/src/state/index.ts +36 -0
- package/src/types.ts +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _newArrowCheck from "@babel/runtime/helpers/newArrowCheck";
|
|
2
|
+
var _this = this;
|
|
3
|
+
import "core-js/modules/es.function.bind.js";
|
|
4
|
+
/**
|
|
5
|
+
* File: /auth/Authenticated.tsx
|
|
6
|
+
* Project: app
|
|
7
|
+
* File Created: 08-11-2022 05:58:23
|
|
8
|
+
* Author: Clay Risser
|
|
9
|
+
* -----
|
|
10
|
+
* Last Modified: 22-11-2022 06:26:38
|
|
11
|
+
* Modified By: Clay Risser
|
|
12
|
+
* -----
|
|
13
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import React from "react";
|
|
29
|
+
import { useLogin, useKeycloak } from "./hooks";
|
|
30
|
+
export var Authenticated = function Authenticated(props) {
|
|
31
|
+
var _this2 = this;
|
|
32
|
+
_newArrowCheck(this, _this);
|
|
33
|
+
var _useKeycloak = useKeycloak(),
|
|
34
|
+
authenticated = _useKeycloak.authenticated;
|
|
35
|
+
var login = useLogin(props.loginRoute);
|
|
36
|
+
if (!props.disabled && !authenticated) {
|
|
37
|
+
if (authenticated === false) login();
|
|
38
|
+
var LoggedOutComponent = props.loggedOutComponent || function () {
|
|
39
|
+
_newArrowCheck(this, _this2);
|
|
40
|
+
return null;
|
|
41
|
+
}.bind(this);
|
|
42
|
+
return /*#__PURE__*/React.createElement(LoggedOutComponent, null);
|
|
43
|
+
}
|
|
44
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
|
|
45
|
+
}.bind(this);
|
|
46
|
+
export function withAuthenticated(Component) {
|
|
47
|
+
var _this3 = this;
|
|
48
|
+
return function (props) {
|
|
49
|
+
_newArrowCheck(this, _this3);
|
|
50
|
+
return /*#__PURE__*/React.createElement(Authenticated, null, /*#__PURE__*/React.createElement(Component, props));
|
|
51
|
+
}.bind(this);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=Authenticated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authenticated.js","names":["React","useLogin","useKeycloak","Authenticated","props","authenticated","login","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":";;;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,MAAwC,OAAO;AAC3D,SAASC,QAAQ,EAAEC,WAAW;AAS9B,OAAO,IAAMC,aAAqC,GAAG,uBACnDC,KAAyB,EACtB;EAAA;EAAA;EACH,mBAA0BF,WAAW,EAAE;IAA/BG,aAAa,gBAAbA,aAAa;EACrB,IAAMC,KAAK,GAAGL,QAAQ,CAACG,KAAK,CAACG,UAAU,CAAC;EACxC,IAAI,CAACH,KAAK,CAACI,QAAQ,IAAI,CAACH,aAAa,EAAE;IACrC,IAAIA,aAAa,KAAK,KAAK,EAAEC,KAAK,EAAE;IACpC,IAAMG,kBAAkB,GAAGL,KAAK,CAACM,kBAAkB,IAAK;MAAA;MAAA,OAAM,IAAI;IAAA,YAAC;IACnE,oBAAO,oBAAC,kBAAkB,OAAG;EAC/B;EACA,oBAAO,0CAAGN,KAAK,CAACO,QAAQ,CAAI;AAC9B,CAAC;AAED,OAAO,SAASC,iBAAiB,CAC/BC,SAA2B,EAC3B;EAAA;EACA,OAAO,UAACT,KAAQ;IAAA;IAAA,oBACd,oBAAC,aAAa,qBACZ,oBAAC,SAAS,EAAKA,KAAK,CAAI,CACV;EAAA,CACjB;AACH"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/authConfig.ts
|
|
3
|
+
* Project: app
|
|
4
|
+
* File Created: 08-11-2022 09:21:15
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 25-11-2022 10:29:29
|
|
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 { createContext } from "react";
|
|
26
|
+
export var defaultAuthConfig = {
|
|
27
|
+
ssr: true
|
|
28
|
+
};
|
|
29
|
+
export var AuthConfigContext = /*#__PURE__*/createContext(defaultAuthConfig);
|
|
30
|
+
//# sourceMappingURL=authConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authConfig.js","names":["createContext","defaultAuthConfig","ssr","AuthConfigContext"],"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":"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,OAAO;AAErC,OAAO,IAAMC,iBAA6B,GAAG;EAC3CC,GAAG,EAAE;AACP,CAAC;AAED,OAAO,IAAMC,iBAAiB,gBAAGH,aAAa,CAAaC,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/hooks/index.ts
|
|
3
|
+
* Project: app
|
|
4
|
+
* File Created: 08-11-2022 06:34:56
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 25-11-2022 09: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
|
+
export * from "./useCurrentRouteName";
|
|
26
|
+
export * from "./useKeycloak";
|
|
27
|
+
export * from "./useLogin";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/hooks/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/index.ts\n * Project: app\n * File Created: 08-11-2022 06:34:56\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 \"./useCurrentRouteName\";\nexport * from \"./useKeycloak\";\nexport * from \"./useLogin\";\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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/hooks/useAuthConfig.ts
|
|
3
|
+
* Project: app
|
|
4
|
+
* File Created: 08-11-2022 09:20:41
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 25-11-2022 09: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 { useContext } from "react";
|
|
26
|
+
import { AuthConfigContext } from "../authConfig";
|
|
27
|
+
export function useAuthConfig() {
|
|
28
|
+
return useContext(AuthConfigContext);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=useAuthConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthConfig.js","names":["useContext","AuthConfigContext","useAuthConfig"],"sources":["../../src/hooks/useAuthConfig.ts"],"sourcesContent":["/**\n * File: /src/hooks/useAuthConfig.ts\n * Project: app\n * File Created: 08-11-2022 09:20:41\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\nimport { useContext } from \"react\";\nimport { AuthConfigContext } from \"../authConfig\";\n\nexport function useAuthConfig() {\n return useContext(AuthConfigContext);\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,iBAAiB;AAE1B,OAAO,SAASC,aAAa,GAAG;EAC9B,OAAOF,UAAU,CAACC,iBAAiB,CAAC;AACtC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "core-js/modules/es.function.name.js";
|
|
2
|
+
/**
|
|
3
|
+
* File: /src/hooks/useCurrentRouteName.ts
|
|
4
|
+
* Project: app
|
|
5
|
+
* File Created: 08-11-2022 08:38:23
|
|
6
|
+
* Author: Clay Risser
|
|
7
|
+
* -----
|
|
8
|
+
* Last Modified: 25-11-2022 10:24:27
|
|
9
|
+
* Modified By: Clay Risser
|
|
10
|
+
* -----
|
|
11
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
27
|
+
import { useRoute } from "@react-navigation/native";
|
|
28
|
+
import { useRouter } from "next/router";
|
|
29
|
+
export function useCurrentRouteName() {
|
|
30
|
+
if (MultiPlatform.isStorybook()) return null;
|
|
31
|
+
if (MultiPlatform.isNext()) {
|
|
32
|
+
var router = useRouter();
|
|
33
|
+
return router.route;
|
|
34
|
+
}
|
|
35
|
+
var route = useRoute();
|
|
36
|
+
return route.name;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=useCurrentRouteName.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/hooks/useKeycloak/index.ts
|
|
3
|
+
* Project: app
|
|
4
|
+
* File Created: 08-11-2022 14:10:44
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 25-11-2022 09: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
|
+
export * from "./useKeycloak";
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* File: /src/hooks/useKeycloak/useKeycloak.ts
|
|
16
|
+
* Project: app
|
|
17
|
+
* File Created: 08-11-2022 06:04:59
|
|
18
|
+
* Author: Clay Risser
|
|
19
|
+
* -----
|
|
20
|
+
* Last Modified: 25-11-2022 10:22:57
|
|
21
|
+
* Modified By: Clay Risser
|
|
22
|
+
* -----
|
|
23
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
24
|
+
*
|
|
25
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License.
|
|
27
|
+
* You may obtain a copy of the License at
|
|
28
|
+
*
|
|
29
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
* See the License for the specific language governing permissions and
|
|
35
|
+
* limitations under the License.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
39
|
+
import { useKeycloak as useReactKeycloak } from "@react-keycloak/web";
|
|
40
|
+
import { useKeycloak as useSsrKeycloak } from "@react-keycloak/ssr";
|
|
41
|
+
import { useAuthConfig } from "../useAuthConfig";
|
|
42
|
+
export function useKeycloak() {
|
|
43
|
+
var authConfig = useAuthConfig();
|
|
44
|
+
if (MultiPlatform.isStorybook()) return {
|
|
45
|
+
authenticated: true
|
|
46
|
+
};
|
|
47
|
+
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;
|
|
54
|
+
}
|
|
55
|
+
var _useReactKeycloak = useReactKeycloak(),
|
|
56
|
+
reactKeycloak = _useReactKeycloak.keycloak,
|
|
57
|
+
initialized = _useReactKeycloak.initialized;
|
|
58
|
+
var keycloak = _objectSpread({}, reactKeycloak);
|
|
59
|
+
if (!initialized) keycloak.authenticated = undefined;
|
|
60
|
+
return keycloak;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=useKeycloak.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
/**
|
|
4
|
+
* File: /src/hooks/useKeycloak/useKeycloak.native.ts
|
|
5
|
+
* Project: app
|
|
6
|
+
* File Created: 08-11-2022 14:10:25
|
|
7
|
+
* Author: Clay Risser
|
|
8
|
+
* -----
|
|
9
|
+
* Last Modified: 25-11-2022 10:21:56
|
|
10
|
+
* Modified By: Clay Risser
|
|
11
|
+
* -----
|
|
12
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
13
|
+
*
|
|
14
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
* you may not use this file except in compliance with the License.
|
|
16
|
+
* You may obtain a copy of the License at
|
|
17
|
+
*
|
|
18
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
+
* See the License for the specific language governing permissions and
|
|
24
|
+
* limitations under the License.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { useKeycloak as useKeycloakExpo } from "expo-keycloak-auth";
|
|
28
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
29
|
+
export function useKeycloak() {
|
|
30
|
+
if (MultiPlatform.isStorybook()) return {
|
|
31
|
+
authenticated: true
|
|
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);
|
|
40
|
+
return keycloak;
|
|
41
|
+
}
|
|
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
|
+
});
|
|
50
|
+
//# sourceMappingURL=useKeycloak.native.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* File: /src/hooks/useLogin.ts
|
|
16
|
+
* Project: app
|
|
17
|
+
* File Created: 08-11-2022 08:49:14
|
|
18
|
+
* Author: Clay Risser
|
|
19
|
+
* -----
|
|
20
|
+
* Last Modified: 25-11-2022 10:36:32
|
|
21
|
+
* Modified By: Clay Risser
|
|
22
|
+
* -----
|
|
23
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
24
|
+
*
|
|
25
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License.
|
|
27
|
+
* You may obtain a copy of the License at
|
|
28
|
+
*
|
|
29
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
* See the License for the specific language governing permissions and
|
|
35
|
+
* limitations under the License.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import { useRouter } from "@risserlabs/solito/router";
|
|
39
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
40
|
+
import { useCurrentRouteName } from "./useCurrentRouteName";
|
|
41
|
+
import { useKeycloak } from "./useKeycloak/useKeycloak";
|
|
42
|
+
import { useAuthConfig } from "./useAuthConfig";
|
|
43
|
+
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);
|
|
55
|
+
if (!loginRoute) loginRoute = authConfig.loginRoute;
|
|
56
|
+
if (!loginRoute) {
|
|
57
|
+
keycloak.login();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var url = new URL("x://".concat(loginRoute));
|
|
61
|
+
var searchParams = new URLSearchParams(url.search);
|
|
62
|
+
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);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=useLogin.js.map
|
|
@@ -0,0 +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"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* File: /auth/provider/afterAuth.tsx
|
|
20
|
+
* Project: app
|
|
21
|
+
* File Created: 22-11-2022 17:49:58
|
|
22
|
+
* Author: Clay Risser
|
|
23
|
+
* -----
|
|
24
|
+
* Last Modified: 22-11-2022 18:00:39
|
|
25
|
+
* Modified By: Clay Risser
|
|
26
|
+
* -----
|
|
27
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
28
|
+
*
|
|
29
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
|
+
* you may not use this file except in compliance with the License.
|
|
31
|
+
* You may obtain a copy of the License at
|
|
32
|
+
*
|
|
33
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
*
|
|
35
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
36
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
37
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
|
+
* See the License for the specific language governing permissions and
|
|
39
|
+
* limitations under the License.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
import React, { useEffect } from "react";
|
|
43
|
+
import { useKeycloak } from "../hooks";
|
|
44
|
+
import { useAuthConfig } from "../hooks/useAuthConfig";
|
|
45
|
+
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);
|
|
61
|
+
if (!authenticated) return;
|
|
62
|
+
if (token) {
|
|
63
|
+
setAuth(_objectSpread({
|
|
64
|
+
token: token
|
|
65
|
+
}, refreshToken ? {
|
|
66
|
+
refreshToken: refreshToken
|
|
67
|
+
} : {}));
|
|
68
|
+
}
|
|
69
|
+
}.bind(this), [token, refreshToken]);
|
|
70
|
+
if (authConfig.debug) {
|
|
71
|
+
logger.debug("authenticated", authenticated);
|
|
72
|
+
logger.debug("token", token);
|
|
73
|
+
}
|
|
74
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
75
|
+
}.bind(this);
|
|
76
|
+
//# sourceMappingURL=afterAuth.js.map
|
|
@@ -0,0 +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"}
|