@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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _newArrowCheck from "@babel/runtime/helpers/newArrowCheck";
|
|
3
|
+
var _this = this;
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
import "core-js/modules/es.function.bind.js";
|
|
7
|
+
import "core-js/modules/es.object.keys.js";
|
|
8
|
+
import "core-js/modules/es.symbol.js";
|
|
9
|
+
import "core-js/modules/es.array.filter.js";
|
|
10
|
+
import "core-js/modules/es.object.to-string.js";
|
|
11
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
12
|
+
import "core-js/modules/es.array.for-each.js";
|
|
13
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
14
|
+
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
15
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
16
|
+
import "core-js/modules/es.object.define-property.js";
|
|
17
|
+
/**
|
|
18
|
+
* File: /auth/provider/index.tsx
|
|
19
|
+
* Project: app
|
|
20
|
+
* File Created: 08-11-2022 06:33:07
|
|
21
|
+
* Author: Clay Risser
|
|
22
|
+
* -----
|
|
23
|
+
* Last Modified: 22-11-2022 18:00:13
|
|
24
|
+
* Modified By: Clay Risser
|
|
25
|
+
* -----
|
|
26
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
27
|
+
*
|
|
28
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
29
|
+
* you may not use this file except in compliance with the License.
|
|
30
|
+
* You may obtain a copy of the License at
|
|
31
|
+
*
|
|
32
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
35
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
36
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
37
|
+
* See the License for the specific language governing permissions and
|
|
38
|
+
* limitations under the License.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
import React, { useMemo } from "react";
|
|
42
|
+
import { AuthConfigContext, defaultAuthConfig } from "../authConfig";
|
|
43
|
+
import { KeycloakProvider } from "./keycloakProvider";
|
|
44
|
+
export var AuthProvider = function AuthProvider(props) {
|
|
45
|
+
var _this2 = this;
|
|
46
|
+
_newArrowCheck(this, _this);
|
|
47
|
+
var authConfig = props.authConfig,
|
|
48
|
+
debug = props.debug;
|
|
49
|
+
var authConfigValue = useMemo(function () {
|
|
50
|
+
_newArrowCheck(this, _this2);
|
|
51
|
+
return _objectSpread(_objectSpread(_objectSpread({}, defaultAuthConfig), authConfig), {}, {
|
|
52
|
+
debug: !!debug
|
|
53
|
+
});
|
|
54
|
+
}.bind(this), []);
|
|
55
|
+
return /*#__PURE__*/React.createElement(AuthConfigContext.Provider, {
|
|
56
|
+
value: authConfigValue
|
|
57
|
+
}, /*#__PURE__*/React.createElement(KeycloakProvider, props));
|
|
58
|
+
}.bind(this);
|
|
59
|
+
export * from "./keycloakProvider";
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAMC,YAAmC,GAAG,sBACjDC,KAAwB,EACrB;EAAA;EAAA;EACH,IAAQC,UAAU,GAAYD,KAAK,CAA3BC,UAAU;IAAEC,KAAK,GAAKF,KAAK,CAAfE,KAAK;EACzB,IAAMC,eAAe,GAAGR,OAAO,CAC7B;IAAA;IAAA,qDACKE,iBAAiB,GACjBI,UAAU;MACbC,KAAK,EAAE,CAAC,CAACA;IAAK;EAAA,CACd,aACF,EAAE,CACH;EAED,oBACE,oBAAC,iBAAiB,CAAC,QAAQ;IAAC,KAAK,EAAEC;EAAgB,gBACjD,oBAAC,gBAAgB,EAAKH,KAAK,CAAI,CACJ;AAEjC,CAAC;AAED"}
|
|
@@ -0,0 +1,220 @@
|
|
|
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.date.to-string.js";
|
|
9
|
+
import "core-js/modules/es.object.to-string.js";
|
|
10
|
+
import "core-js/modules/es.regexp.to-string.js";
|
|
11
|
+
import "core-js/modules/es.array.for-each.js";
|
|
12
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
13
|
+
import "core-js/modules/es.object.keys.js";
|
|
14
|
+
import "core-js/modules/es.symbol.js";
|
|
15
|
+
import "core-js/modules/es.array.filter.js";
|
|
16
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
17
|
+
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
18
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
19
|
+
import "core-js/modules/es.object.define-property.js";
|
|
20
|
+
/**
|
|
21
|
+
* File: /auth/provider/keycloakProvider.tsx
|
|
22
|
+
* Project: app
|
|
23
|
+
* File Created: 08-11-2022 03:12:43
|
|
24
|
+
* Author: Clay Risser
|
|
25
|
+
* -----
|
|
26
|
+
* Last Modified: 22-11-2022 18:07:46
|
|
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
|
+
import Keycloak from "keycloak-js";
|
|
45
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
46
|
+
import { ReactKeycloakProvider } from "@react-keycloak/web";
|
|
47
|
+
import { SSRKeycloakProvider, SSRCookies } from "@react-keycloak/ssr";
|
|
48
|
+
import { useRouter } from "next/router";
|
|
49
|
+
import React, { useMemo, useEffect, useState } from "react";
|
|
50
|
+
import { useAuthConfig } from "../hooks/useAuthConfig";
|
|
51
|
+
import { useAuthState } from "../state";
|
|
52
|
+
import { AfterAuth } from "./afterAuth";
|
|
53
|
+
var logger = console;
|
|
54
|
+
export var KeycloakProvider = function KeycloakProvider(_ref) {
|
|
55
|
+
var _this2 = this,
|
|
56
|
+
_query$token,
|
|
57
|
+
_query$refreshToken;
|
|
58
|
+
_newArrowCheck(this, _this);
|
|
59
|
+
var children = _ref.children,
|
|
60
|
+
cookies = _ref.cookies,
|
|
61
|
+
debug = _ref.debug,
|
|
62
|
+
keycloakConfig = _ref.keycloakConfig,
|
|
63
|
+
keycloakInitOptions = _ref.keycloakInitOptions,
|
|
64
|
+
loadingComponent = _ref.loadingComponent;
|
|
65
|
+
var _useAuthState = useAuthState(),
|
|
66
|
+
_useAuthState2 = _slicedToArray(_useAuthState, 1),
|
|
67
|
+
auth = _useAuthState2[0];
|
|
68
|
+
var LoadingComponent = loadingComponent || function () {
|
|
69
|
+
_newArrowCheck(this, _this2);
|
|
70
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, debug ? "authenticating" : null);
|
|
71
|
+
}.bind(this);
|
|
72
|
+
var _ref2 = MultiPlatform.isNext() ? useRouter() : {
|
|
73
|
+
query: {}
|
|
74
|
+
},
|
|
75
|
+
query = _ref2.query;
|
|
76
|
+
var authConfig = useAuthConfig();
|
|
77
|
+
var _useState = useState("token" in query && (((_query$token = query.token) === null || _query$token === void 0 ? void 0 : _query$token.toString()) || true) || auth.token || false),
|
|
78
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
79
|
+
token = _useState2[0],
|
|
80
|
+
setToken = _useState2[1];
|
|
81
|
+
var _useState3 = useState("refreshToken" in query && (((_query$refreshToken = query.refreshToken) === null || _query$refreshToken === void 0 ? void 0 : _query$refreshToken.toString()) || true) || auth.refreshToken || false),
|
|
82
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
83
|
+
refreshToken = _useState4[0],
|
|
84
|
+
setRefreshToken = _useState4[1];
|
|
85
|
+
useEffect(function () {
|
|
86
|
+
var _this3 = this,
|
|
87
|
+
_window2,
|
|
88
|
+
_window2$ReactNativeW,
|
|
89
|
+
_window3,
|
|
90
|
+
_window3$parent;
|
|
91
|
+
_newArrowCheck(this, _this2);
|
|
92
|
+
if (token !== true && refreshToken !== true) return;
|
|
93
|
+
if (debug) logger.debug("post message", {
|
|
94
|
+
type: "LOADED"
|
|
95
|
+
});
|
|
96
|
+
(authConfig.messageHandlerKeys || []).forEach(function (key) {
|
|
97
|
+
var _window, _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
98
|
+
_newArrowCheck(this, _this3);
|
|
99
|
+
(_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({
|
|
100
|
+
type: "LOADED"
|
|
101
|
+
}));
|
|
102
|
+
}.bind(this));
|
|
103
|
+
(_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$ReactNativeW = _window2.ReactNativeWebView) === null || _window2$ReactNativeW === void 0 ? void 0 : _window2$ReactNativeW.postMessage(JSON.stringify({
|
|
104
|
+
type: "LOADED"
|
|
105
|
+
}));
|
|
106
|
+
(_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$parent = _window3.parent) === null || _window3$parent === void 0 ? void 0 : _window3$parent.postMessage(JSON.stringify({
|
|
107
|
+
type: "LOADED"
|
|
108
|
+
}));
|
|
109
|
+
}.bind(this), []);
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
var _this4 = this;
|
|
112
|
+
_newArrowCheck(this, _this2);
|
|
113
|
+
if (token !== true) return;
|
|
114
|
+
var messageCallback = function messageCallback(e) {
|
|
115
|
+
_newArrowCheck(this, _this4);
|
|
116
|
+
var data = e === null || e === void 0 ? void 0 : e.data;
|
|
117
|
+
if (typeof data === "string") {
|
|
118
|
+
try {
|
|
119
|
+
data = JSON.parse(data);
|
|
120
|
+
} catch (err) {}
|
|
121
|
+
}
|
|
122
|
+
if (debug) logger.debug("received message", data);
|
|
123
|
+
var message = data;
|
|
124
|
+
if (!message.type) return;
|
|
125
|
+
if (message.type.toUpperCase() === "TOKEN" && message.payload) {
|
|
126
|
+
if (debug) logger.debug("setting token", message.payload);
|
|
127
|
+
setToken(message.payload);
|
|
128
|
+
}
|
|
129
|
+
}.bind(this);
|
|
130
|
+
if (debug) logger.debug("listening for message", {
|
|
131
|
+
type: "TOKEN",
|
|
132
|
+
payload: "<some_token>"
|
|
133
|
+
});
|
|
134
|
+
window.addEventListener("message", messageCallback);
|
|
135
|
+
return function () {
|
|
136
|
+
_newArrowCheck(this, _this4);
|
|
137
|
+
window.removeEventListener("message", messageCallback);
|
|
138
|
+
}.bind(this);
|
|
139
|
+
}.bind(this), []);
|
|
140
|
+
useEffect(function () {
|
|
141
|
+
var _this5 = this;
|
|
142
|
+
_newArrowCheck(this, _this2);
|
|
143
|
+
if (refreshToken !== true) return;
|
|
144
|
+
var messageCallback = function messageCallback(e) {
|
|
145
|
+
_newArrowCheck(this, _this5);
|
|
146
|
+
var data = e === null || e === void 0 ? void 0 : e.data;
|
|
147
|
+
if (typeof data === "string") {
|
|
148
|
+
try {
|
|
149
|
+
data = JSON.parse(data);
|
|
150
|
+
} catch (err) {}
|
|
151
|
+
}
|
|
152
|
+
if (debug) logger.debug("received message", data);
|
|
153
|
+
var message = data;
|
|
154
|
+
if (!message.type) return;
|
|
155
|
+
if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
|
|
156
|
+
if (debug) logger.debug("setting refresh token", message.payload);
|
|
157
|
+
setRefreshToken(message.payload);
|
|
158
|
+
}
|
|
159
|
+
}.bind(this);
|
|
160
|
+
if (debug) logger.debug("listening for message", {
|
|
161
|
+
type: "REFRESH_TOKEN",
|
|
162
|
+
payload: "<some_refresh_token>"
|
|
163
|
+
});
|
|
164
|
+
window.addEventListener("message", messageCallback);
|
|
165
|
+
return function () {
|
|
166
|
+
_newArrowCheck(this, _this5);
|
|
167
|
+
window.removeEventListener("message", messageCallback);
|
|
168
|
+
}.bind(this);
|
|
169
|
+
}.bind(this), []);
|
|
170
|
+
var keycloak = useMemo(function () {
|
|
171
|
+
_newArrowCheck(this, _this2);
|
|
172
|
+
return typeof window !== "undefined" && new Keycloak({
|
|
173
|
+
url: keycloakConfig.baseUrl,
|
|
174
|
+
realm: keycloakConfig.realm,
|
|
175
|
+
clientId: keycloakConfig.clientId
|
|
176
|
+
});
|
|
177
|
+
}.bind(this), []);
|
|
178
|
+
var initOptions = useMemo(function () {
|
|
179
|
+
_newArrowCheck(this, _this2);
|
|
180
|
+
var initOptions = _objectSpread(_objectSpread({}, defaultKeycloakInitOptions), keycloakInitOptions);
|
|
181
|
+
if (token && typeof token === "string") {
|
|
182
|
+
initOptions.token = token;
|
|
183
|
+
if (refreshToken && typeof refreshToken === "string") initOptions.refreshToken = refreshToken;
|
|
184
|
+
initOptions.checkLoginIframe = false;
|
|
185
|
+
initOptions.onLoad = undefined;
|
|
186
|
+
}
|
|
187
|
+
return initOptions;
|
|
188
|
+
}.bind(this), [keycloakInitOptions, token, refreshToken]);
|
|
189
|
+
if (token === true || refreshToken === true) return /*#__PURE__*/React.createElement(LoadingComponent, null);
|
|
190
|
+
if (cookies && authConfig.ssr) {
|
|
191
|
+
return (
|
|
192
|
+
/*#__PURE__*/
|
|
193
|
+
// @ts-ignore
|
|
194
|
+
React.createElement(SSRKeycloakProvider, {
|
|
195
|
+
initOptions: initOptions,
|
|
196
|
+
keycloakConfig: {
|
|
197
|
+
url: keycloakConfig.baseUrl,
|
|
198
|
+
realm: keycloakConfig.realm,
|
|
199
|
+
clientId: keycloakConfig.clientId
|
|
200
|
+
},
|
|
201
|
+
persistor: SSRCookies(cookies),
|
|
202
|
+
LoadingComponent: /*#__PURE__*/React.createElement(LoadingComponent, null)
|
|
203
|
+
}, /*#__PURE__*/React.createElement(AfterAuth, null, children))
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
if (!keycloak) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
207
|
+
return /*#__PURE__*/React.createElement(ReactKeycloakProvider, {
|
|
208
|
+
initOptions: initOptions,
|
|
209
|
+
authClient: keycloak,
|
|
210
|
+
LoadingComponent: /*#__PURE__*/React.createElement(LoadingComponent, null)
|
|
211
|
+
}, /*#__PURE__*/React.createElement(AfterAuth, null, children));
|
|
212
|
+
}.bind(this);
|
|
213
|
+
export var defaultKeycloakInitOptions = {
|
|
214
|
+
checkLoginIframe: true,
|
|
215
|
+
checkLoginIframeInterval: 5,
|
|
216
|
+
enableLogging: false,
|
|
217
|
+
onLoad: "check-sso",
|
|
218
|
+
pkceMethod: "S256"
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=keycloakProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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","isNext","query","authConfig","token","toString","setToken","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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,QAAQ,MAA+B,aAAa;AAC3D,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,qBAAqB,QAAQ,qBAAqB;AAC3D,SAASC,mBAAmB,EAAEC,UAAU,QAAQ,qBAAqB;AACrE,SAASC,SAAS,QAAQ,aAAa;AACvC,OAAOC,KAAK,IAGVC,OAAO,EACPC,SAAS,EACTC,QAAQ,QAEH,OAAO;AACd,SAASC,aAAa;AACtB,SAASC,YAAY;AACrB,SAASC,SAAS;AAYlB,IAAMC,MAAM,GAAGC,OAAO;AAEtB,OAAO,IAAMC,gBAA2C,GAAG,gCAO9B;EAAA;IAAA;IAAA;EAAA;EAAA,IAN3BC,QAAQ,QAARA,QAAQ;IACRC,OAAO,QAAPA,OAAO;IACPC,KAAK,QAALA,KAAK;IACLC,cAAc,QAAdA,cAAc;IACdC,mBAAmB,QAAnBA,mBAAmB;IACnBC,gBAAgB,QAAhBA,gBAAgB;EAEhB,oBAAeV,YAAY,EAAE;IAAA;IAAtBW,IAAI;EACX,IAAMC,gBAAgB,GACpBF,gBAAgB,IAAK;IAAA;IAAA,oBAAM,0CAAGH,KAAK,GAAG,gBAAgB,GAAG,IAAI,CAAI;EAAA,YAAC;EACpE,YAAkBjB,aAAa,CAACuB,MAAM,EAAE,GAAGnB,SAAS,EAAE,GAAG;MAAEoB,KAAK,EAAE,CAAC;IAAE,CAAC;IAA9DA,KAAK,SAALA,KAAK;EACb,IAAMC,UAAU,GAAGhB,aAAa,EAAE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EAC7DC,gBAAgB,EAAE,IAAI;EACtBI,wBAAwB,EAAE,CAAC;EAC3BC,aAAa,EAAE,KAAK;EACpBJ,MAAM,EAAE,WAAW;EACnBK,UAAU,EAAE;AACd,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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/provider/keycloakProvider.native.tsx
|
|
6
|
+
* Project: app
|
|
7
|
+
* File Created: 08-11-2022 03:12:37
|
|
8
|
+
* Author: Clay Risser
|
|
9
|
+
* -----
|
|
10
|
+
* Last Modified: 22-11-2022 17:52:31
|
|
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 { KeycloakProvider as ExpoKeycloakProvider } from "expo-keycloak-auth";
|
|
29
|
+
import React from "react";
|
|
30
|
+
import { AfterAuth } from "./afterAuth";
|
|
31
|
+
export var KeycloakProvider = function KeycloakProvider(_ref) {
|
|
32
|
+
_newArrowCheck(this, _this);
|
|
33
|
+
var children = _ref.children,
|
|
34
|
+
keycloakConfig = _ref.keycloakConfig;
|
|
35
|
+
keycloakConfig.url = keycloakConfig.baseUrl;
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
delete keycloakConfig.baseUrl;
|
|
38
|
+
return /*#__PURE__*/React.createElement(ExpoKeycloakProvider, keycloakConfig, /*#__PURE__*/React.createElement(AfterAuth, null, children));
|
|
39
|
+
}.bind(this);
|
|
40
|
+
//# sourceMappingURL=keycloakProvider.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloakProvider.native.js","names":["KeycloakProvider","ExpoKeycloakProvider","React","AfterAuth","children","keycloakConfig","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 { KeycloakProvider as ExpoKeycloakProvider } from \"expo-keycloak-auth\";\nimport React, { FC } from \"react\";\nimport type { KeycloakProviderProps } from \"./keycloakProvider\";\nimport { AfterAuth } from \"./afterAuth\";\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n keycloakConfig,\n}: KeycloakProviderProps & { keycloakConfig: { url?: string } }) => {\n keycloakConfig.url = keycloakConfig.baseUrl;\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return (\n <ExpoKeycloakProvider {...keycloakConfig}>\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,SAASA,gBAAgB,IAAIC,oBAAoB,QAAQ,oBAAoB;AAC7E,OAAOC,KAAK,MAAc,OAAO;AAEjC,SAASC,SAAS;AAElB,OAAO,IAAMH,gBAA2C,GAAG,gCAGS;EAAA;EAAA,IAFlEI,QAAQ,QAARA,QAAQ;IACRC,cAAc,QAAdA,cAAc;EAEdA,cAAc,CAACC,GAAG,GAAGD,cAAc,CAACE,OAAO;EAC3C;EACA,OAAOF,cAAc,CAACE,OAAO;EAC7B,oBACE,oBAAC,oBAAoB,EAAKF,cAAc,eACtC,oBAAC,SAAS,QAAED,QAAQ,CAAa,CACZ;AAE3B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/state/index.ts
|
|
3
|
+
* Project: app
|
|
4
|
+
* File Created: 22-11-2022 17:40:53
|
|
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 { atom, useRecoilState } from "recoil";
|
|
26
|
+
import persist from "react-native-recoil-persist";
|
|
27
|
+
export function useAuthState() {
|
|
28
|
+
return useRecoilState(authState);
|
|
29
|
+
}
|
|
30
|
+
export var authState = atom({
|
|
31
|
+
key: "auth",
|
|
32
|
+
"default": {},
|
|
33
|
+
effects: [persist.persistAtom]
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["atom","useRecoilState","persist","useAuthState","authState","key","effects","persistAtom"],"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: 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 { atom, useRecoilState } from \"recoil\";\nimport persist from \"react-native-recoil-persist\";\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: [persist.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,OAAOC,OAAO,MAAM,6BAA6B;AAEjD,OAAO,SAASC,YAAY,GAAG;EAC7B,OAAOF,cAAc,CAACG,SAAS,CAAC;AAClC;AAEA,OAAO,IAAMA,SAAS,GAAGJ,IAAI,CAA4C;EACvEK,GAAG,EAAE,MAAM;EACX,WAAS,CAAC,CAAC;EACXC,OAAO,EAAE,CAACJ,OAAO,CAACK,WAAW;AAC/B,CAAC,CAAC"}
|
package/esm/types.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/types.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 25-11-2022 10:27:53
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 25-11-2022 10:28:25
|
|
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 default null;
|
|
26
|
+
//# sourceMappingURL=types.js.map
|
package/esm/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /auth/Authenticated.tsx
|
|
3
|
+
* Project: app
|
|
4
|
+
* File Created: 08-11-2022 05:58:23
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 22-11-2022 06:26:38
|
|
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
|
+
import { ComponentType, FC, ReactNode } from "react";
|
|
25
|
+
export interface AuthenticatedProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
loggedOutComponent?: ComponentType;
|
|
29
|
+
loginRoute?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const Authenticated: FC<AuthenticatedProps>;
|
|
32
|
+
export declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require("core-js/modules/esnext.global-this.js");
|
|
2
|
+
require("core-js/modules/es.object.define-property.js");
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
if (typeof define === "function" && define.amd) {
|
|
5
|
+
define(["exports", "core-js/modules/es.function.bind.js", "@babel/runtime/helpers/newArrowCheck", "react", "./hooks"], factory);
|
|
6
|
+
} else if (typeof exports !== "undefined") {
|
|
7
|
+
factory(exports, require("core-js/modules/es.function.bind.js"), require("@babel/runtime/helpers/newArrowCheck"), require("react"), require("./hooks"));
|
|
8
|
+
} else {
|
|
9
|
+
var mod = {
|
|
10
|
+
exports: {}
|
|
11
|
+
};
|
|
12
|
+
factory(mod.exports, global.esFunctionBind, global.newArrowCheck, global.react, global.hooks);
|
|
13
|
+
global.Authenticated = mod.exports;
|
|
14
|
+
}
|
|
15
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _esFunctionBind, _newArrowCheck2, _react, _hooks) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
19
|
+
Object.defineProperty(_exports, "__esModule", {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
_exports.Authenticated = void 0;
|
|
23
|
+
_exports.withAuthenticated = withAuthenticated;
|
|
24
|
+
_newArrowCheck2 = _interopRequireDefault(_newArrowCheck2);
|
|
25
|
+
_react = _interopRequireDefault(_react);
|
|
26
|
+
var _this = void 0;
|
|
27
|
+
var Authenticated = function Authenticated(props) {
|
|
28
|
+
var _this2 = this;
|
|
29
|
+
(0, _newArrowCheck2["default"])(this, _this);
|
|
30
|
+
var _useKeycloak = (0, _hooks.useKeycloak)(),
|
|
31
|
+
authenticated = _useKeycloak.authenticated;
|
|
32
|
+
var login = (0, _hooks.useLogin)(props.loginRoute);
|
|
33
|
+
if (!props.disabled && !authenticated) {
|
|
34
|
+
if (authenticated === false) login();
|
|
35
|
+
var LoggedOutComponent = props.loggedOutComponent || function () {
|
|
36
|
+
(0, _newArrowCheck2["default"])(this, _this2);
|
|
37
|
+
return null;
|
|
38
|
+
}.bind(this);
|
|
39
|
+
return /*#__PURE__*/_react["default"].createElement(LoggedOutComponent, null);
|
|
40
|
+
}
|
|
41
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, props.children);
|
|
42
|
+
}.bind(void 0);
|
|
43
|
+
_exports.Authenticated = Authenticated;
|
|
44
|
+
function withAuthenticated(Component) {
|
|
45
|
+
var _this3 = this;
|
|
46
|
+
return function (props) {
|
|
47
|
+
(0, _newArrowCheck2["default"])(this, _this3);
|
|
48
|
+
return /*#__PURE__*/_react["default"].createElement(Authenticated, null, /*#__PURE__*/_react["default"].createElement(Component, props));
|
|
49
|
+
}.bind(this);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=Authenticated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authenticated.js","names":["Authenticated","props","useKeycloak","authenticated","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":";;;;;;;;;;;;;;;;;;;;;;;;;;EAkCO,IAAMA,aAAqC,GAAG,uBACnDC,KAAyB,EACtB;IAAA;IAAA;IACH,mBAA0B,IAAAC,kBAAW,GAAE;MAA/BC,aAAa,gBAAbA,aAAa;IACrB,IAAMC,KAAK,GAAG,IAAAC,eAAQ,EAACJ,KAAK,CAACK,UAAU,CAAC;IACxC,IAAI,CAACL,KAAK,CAACM,QAAQ,IAAI,CAACJ,aAAa,EAAE;MACrC,IAAIA,aAAa,KAAK,KAAK,EAAEC,KAAK,EAAE;MACpC,IAAMI,kBAAkB,GAAGP,KAAK,CAACQ,kBAAkB,IAAK;QAAA;QAAA,OAAM,IAAI;MAAA,YAAC;MACnE,oBAAO,gCAAC,kBAAkB,OAAG;IAC/B;IACA,oBAAO,kEAAGR,KAAK,CAACS,QAAQ,CAAI;EAC9B,CAAC;EAAC;EAEK,SAASC,iBAAiB,CAC/BC,SAA2B,EAC3B;IAAA;IACA,OAAO,UAACX,KAAQ;MAAA;MAAA,oBACd,gCAAC,aAAa,qBACZ,gCAAC,SAAS,EAAKA,KAAK,CAAI,CACV;IAAA,CACjB;EACH;AAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
25
|
+
export declare const defaultAuthConfig: AuthConfig;
|
|
26
|
+
export declare const AuthConfigContext: import("react").Context<AuthConfig>;
|
|
27
|
+
export interface AuthConfig {
|
|
28
|
+
debug?: boolean;
|
|
29
|
+
loginRoute?: string;
|
|
30
|
+
messageHandlerKeys?: string[];
|
|
31
|
+
ssr?: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require("core-js/modules/esnext.global-this.js");
|
|
2
|
+
require("core-js/modules/es.object.define-property.js");
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
if (typeof define === "function" && define.amd) {
|
|
5
|
+
define(["exports", "react"], factory);
|
|
6
|
+
} else if (typeof exports !== "undefined") {
|
|
7
|
+
factory(exports, require("react"));
|
|
8
|
+
} else {
|
|
9
|
+
var mod = {
|
|
10
|
+
exports: {}
|
|
11
|
+
};
|
|
12
|
+
factory(mod.exports, global.react);
|
|
13
|
+
global.authConfig = mod.exports;
|
|
14
|
+
}
|
|
15
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(_exports, "__esModule", {
|
|
19
|
+
value: true
|
|
20
|
+
});
|
|
21
|
+
_exports.defaultAuthConfig = _exports.AuthConfigContext = void 0;
|
|
22
|
+
/**
|
|
23
|
+
* File: /src/authConfig.ts
|
|
24
|
+
* Project: app
|
|
25
|
+
* File Created: 08-11-2022 09:21:15
|
|
26
|
+
* Author: Clay Risser
|
|
27
|
+
* -----
|
|
28
|
+
* Last Modified: 25-11-2022 10:29:29
|
|
29
|
+
* Modified By: Clay Risser
|
|
30
|
+
* -----
|
|
31
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
32
|
+
*
|
|
33
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
34
|
+
* you may not use this file except in compliance with the License.
|
|
35
|
+
* You may obtain a copy of the License at
|
|
36
|
+
*
|
|
37
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
38
|
+
*
|
|
39
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
40
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
41
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
42
|
+
* See the License for the specific language governing permissions and
|
|
43
|
+
* limitations under the License.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
var defaultAuthConfig = {
|
|
47
|
+
ssr: true
|
|
48
|
+
};
|
|
49
|
+
_exports.defaultAuthConfig = defaultAuthConfig;
|
|
50
|
+
var AuthConfigContext = /*#__PURE__*/(0, _react.createContext)(defaultAuthConfig);
|
|
51
|
+
_exports.AuthConfigContext = AuthConfigContext;
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=authConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAMA,iBAA6B,GAAG;IAC3CC,GAAG,EAAE;EACP,CAAC;EAAC;EAEK,IAAMC,iBAAiB,gBAAG,IAAAC,oBAAa,EAAaH,iBAAiB,CAAC;EAAC;AAAA"}
|