@multiplatform.one/keycloak 0.3.21 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Authenticated.mjs +1 -1
- package/dist/esm/Authenticated.mjs.map +2 -2
- package/dist/esm/authConfig.mjs.map +1 -1
- package/dist/esm/provider/index.mjs +11 -7
- package/dist/esm/provider/index.mjs.map +2 -2
- package/dist/esm/state/index.mjs.map +1 -1
- package/dist/jsx/Authenticated.mjs +1 -1
- package/dist/jsx/Authenticated.mjs.map +2 -2
- package/dist/jsx/authConfig.mjs.map +1 -1
- package/dist/jsx/provider/index.mjs +6 -6
- package/dist/jsx/provider/index.mjs.map +2 -2
- package/dist/jsx/state/index.mjs.map +1 -1
- package/dist/lib/Authenticated.js +1 -1
- package/dist/lib/Authenticated.js.map +2 -2
- package/dist/lib/authConfig.d.ts +1 -1
- package/dist/lib/authConfig.js.map +1 -1
- package/dist/lib/provider/index.js +3 -7
- package/dist/lib/provider/index.js.map +2 -2
- package/dist/lib/state/index.d.ts +1 -1
- package/dist/lib/state/index.js.map +1 -1
- package/dist/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Authenticated.tsx +1 -1
- package/src/authConfig.ts +1 -1
- package/src/provider/index.tsx +16 -6
- package/src/state/index.ts +1 -1
|
@@ -24,7 +24,7 @@ function Authenticated(_ref) {
|
|
|
24
24
|
if (disabled || authenticated)
|
|
25
25
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
26
26
|
var LoggedOutComponent = loggedOutComponent || function() {
|
|
27
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null,
|
|
27
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, authConfig.debug ? "not authenticated" : null);
|
|
28
28
|
};
|
|
29
29
|
return /* @__PURE__ */ React.createElement(LoggedOutComponent, null);
|
|
30
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Authenticated.tsx"],
|
|
4
|
-
"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, { useEffect } from 'react';\nimport { useLogin, useKeycloak } from \"./hooks/index.mjs\";\nimport { useAuthState } from \"./state/index.mjs\";\nimport { useAuthConfig, useTokensFromQuery, useTokensFromState } from \"./hooks/index.mjs\";\nexport function Authenticated(_ref) {\n var children = _ref.children,\n disabled = _ref.disabled,\n loginRoute = _ref.loginRoute,\n loggedOutComponent = _ref.loggedOutComponent;\n var authConfig = useAuthConfig();\n var authState = useAuthState();\n var login = useLogin(loginRoute);\n var tokensFromQuery = useTokensFromQuery();\n var tokensFromState = useTokensFromState();\n var _useKeycloak = useKeycloak(),\n authenticated = _useKeycloak.authenticated;\n useEffect(function () {\n if (authenticated !== false) return;\n if (authConfig.persist) {\n authState.setIdToken('');\n authState.setRefreshToken('');\n authState.setToken('');\n }\n if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();\n }, [authenticated]);\n if (disabled || authenticated) return /*#__PURE__*/React.createElement(React.Fragment, null, children);\n var LoggedOutComponent = loggedOutComponent || function () {\n return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
5
|
-
"mappings": "AAwBA,OAAO,SAAS,iBAAiB;AACjC,SAAS,UAAU,mBAAmB;AACtC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,oBAAoB,0BAA0B;AAC/D,SAAS,cAAc,MAAM;AAClC,MAAI,WAAW,KAAK,UAClB,WAAW,KAAK,UAChB,aAAa,KAAK,YAClB,qBAAqB,KAAK;AAC5B,MAAI,aAAa,cAAc;AAC/B,MAAI,YAAY,aAAa;AAC7B,MAAI,QAAQ,SAAS,UAAU;AAC/B,MAAI,kBAAkB,mBAAmB;AACzC,MAAI,kBAAkB,mBAAmB;AACzC,MAAI,eAAe,YAAY,GAC7B,gBAAgB,aAAa;AAC/B,YAAU,WAAY;AACpB,QAAI,kBAAkB;AAAO;AAC7B,QAAI,WAAW,SAAS;AACtB,gBAAU,WAAW,EAAE;AACvB,gBAAU,gBAAgB,EAAE;AAC5B,gBAAU,SAAS,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,WAAW,eAAe,CAAC,mBAAmB,CAAC;AAAiB,YAAM;AAAA,EACnF,GAAG,CAAC,aAAa,CAAC;AAClB,MAAI,YAAY;AAAe,WAAoB,sBAAM,cAAc,MAAM,UAAU,MAAM,QAAQ;AACrG,MAAI,qBAAqB,sBAAsB,WAAY;AACzD,WAAoB,sBAAM,cAAc,MAAM,UAAU,MAAM,
|
|
4
|
+
"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, { useEffect } from 'react';\nimport { useLogin, useKeycloak } from \"./hooks/index.mjs\";\nimport { useAuthState } from \"./state/index.mjs\";\nimport { useAuthConfig, useTokensFromQuery, useTokensFromState } from \"./hooks/index.mjs\";\nexport function Authenticated(_ref) {\n var children = _ref.children,\n disabled = _ref.disabled,\n loginRoute = _ref.loginRoute,\n loggedOutComponent = _ref.loggedOutComponent;\n var authConfig = useAuthConfig();\n var authState = useAuthState();\n var login = useLogin(loginRoute);\n var tokensFromQuery = useTokensFromQuery();\n var tokensFromState = useTokensFromState();\n var _useKeycloak = useKeycloak(),\n authenticated = _useKeycloak.authenticated;\n useEffect(function () {\n if (authenticated !== false) return;\n if (authConfig.persist) {\n authState.setIdToken('');\n authState.setRefreshToken('');\n authState.setToken('');\n }\n if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();\n }, [authenticated]);\n if (disabled || authenticated) return /*#__PURE__*/React.createElement(React.Fragment, null, children);\n var LoggedOutComponent = loggedOutComponent || function () {\n return /*#__PURE__*/React.createElement(React.Fragment, null, authConfig.debug ? 'not authenticated' : null);\n };\n return /*#__PURE__*/React.createElement(LoggedOutComponent, null);\n}\nexport function withAuthenticated(Component) {\n return function (props) {\n return /*#__PURE__*/React.createElement(Authenticated, null, /*#__PURE__*/React.createElement(Component, props));\n };\n}"],
|
|
5
|
+
"mappings": "AAwBA,OAAO,SAAS,iBAAiB;AACjC,SAAS,UAAU,mBAAmB;AACtC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,oBAAoB,0BAA0B;AAC/D,SAAS,cAAc,MAAM;AAClC,MAAI,WAAW,KAAK,UAClB,WAAW,KAAK,UAChB,aAAa,KAAK,YAClB,qBAAqB,KAAK;AAC5B,MAAI,aAAa,cAAc;AAC/B,MAAI,YAAY,aAAa;AAC7B,MAAI,QAAQ,SAAS,UAAU;AAC/B,MAAI,kBAAkB,mBAAmB;AACzC,MAAI,kBAAkB,mBAAmB;AACzC,MAAI,eAAe,YAAY,GAC7B,gBAAgB,aAAa;AAC/B,YAAU,WAAY;AACpB,QAAI,kBAAkB;AAAO;AAC7B,QAAI,WAAW,SAAS;AACtB,gBAAU,WAAW,EAAE;AACvB,gBAAU,gBAAgB,EAAE;AAC5B,gBAAU,SAAS,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,WAAW,eAAe,CAAC,mBAAmB,CAAC;AAAiB,YAAM;AAAA,EACnF,GAAG,CAAC,aAAa,CAAC;AAClB,MAAI,YAAY;AAAe,WAAoB,sBAAM,cAAc,MAAM,UAAU,MAAM,QAAQ;AACrG,MAAI,qBAAqB,sBAAsB,WAAY;AACzD,WAAoB,sBAAM,cAAc,MAAM,UAAU,MAAM,WAAW,QAAQ,sBAAsB,IAAI;AAAA,EAC7G;AACA,SAAoB,sBAAM,cAAc,oBAAoB,IAAI;AAClE;AACO,SAAS,kBAAkB,WAAW;AAC3C,SAAO,SAAU,OAAO;AACtB,WAAoB,sBAAM,cAAc,eAAe,MAAmB,sBAAM,cAAc,WAAW,KAAK,CAAC;AAAA,EACjH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/authConfig.ts"],
|
|
4
|
-
"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:
|
|
4
|
+
"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: 26-05-2023 08:07:00\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';\nexport var defaultAuthConfig = {\n ensureFreshness: true,\n persist: false,\n ssr: false\n};\nexport var AuthConfigContext = /*#__PURE__*/createContext(defaultAuthConfig);"],
|
|
5
5
|
"mappings": "AAwBA,SAAS,qBAAqB;AACvB,IAAI,oBAAoB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,KAAK;AACP;AACO,IAAI,oBAAiC,8BAAc,iBAAiB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -96,13 +96,17 @@ var AuthProvider = function AuthProvider2(_ref) {
|
|
|
96
96
|
var tokensFromQuery = useTokensFromQuery();
|
|
97
97
|
var tokensFromState = useTokensFromState();
|
|
98
98
|
var authConfig = useMemo(function() {
|
|
99
|
-
return _objectSpread(_objectSpread({}, defaultAuthConfig),
|
|
100
|
-
debug
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultAuthConfig), typeof debug !== "undefined" ? {
|
|
100
|
+
debug
|
|
101
|
+
} : {}), typeof ensureFreshness !== "undefined" ? {
|
|
102
|
+
ensureFreshness
|
|
103
|
+
} : {}), typeof loginRoute !== "undefined" ? {
|
|
104
|
+
loginRoute
|
|
105
|
+
} : {}), typeof messageHandlerKeys !== "undefined" ? {
|
|
106
|
+
messageHandlerKeys
|
|
107
|
+
} : {}), {}, {
|
|
108
|
+
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : defaultAuthConfig.persist,
|
|
109
|
+
ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : defaultAuthConfig.ssr : false
|
|
106
110
|
});
|
|
107
111
|
}, [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]);
|
|
108
112
|
if (disabled) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/provider/index.tsx"],
|
|
4
|
-
"sourcesContent": ["function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _excluded = [\"realm\", \"clientId\", \"baseUrl\", \"debug\", \"ensureFreshness\", \"loginRoute\", \"messageHandlerKeys\", \"ssr\", \"children\", \"cookies\", \"disabled\", \"loadingComponent\", \"onEvent\", \"onTokens\"];\nfunction 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; }\nfunction _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; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n/**\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, { useMemo } from 'react';\nimport { AuthConfigContext, defaultAuthConfig } from \"../authConfig.mjs\";\nimport { KeycloakProvider } from \"./keycloakProvider.mjs\";\nimport { useTokensFromState, useTokensFromQuery } from \"../hooks/index.mjs\"; // @ts-ignore\nimport { config } from 'app/config';\nvar persist = config.get('KEYCLOAK_PERSIST') === '1';\nexport var AuthProvider = function AuthProvider(_ref) {\n var realm = _ref.realm,\n clientId = _ref.clientId,\n baseUrl = _ref.baseUrl,\n debug = _ref.debug,\n ensureFreshness = _ref.ensureFreshness,\n loginRoute = _ref.loginRoute,\n messageHandlerKeys = _ref.messageHandlerKeys,\n ssr = _ref.ssr,\n children = _ref.children,\n cookies = _ref.cookies,\n disabled = _ref.disabled,\n loadingComponent = _ref.loadingComponent,\n onEvent = _ref.onEvent,\n onTokens = _ref.onTokens,\n keycloakInitOptions = _objectWithoutProperties(_ref, _excluded);\n var tokensFromQuery = useTokensFromQuery();\n var tokensFromState = useTokensFromState();\n var authConfig = useMemo(function () {\n return _objectSpread(_objectSpread({}, defaultAuthConfig),
|
|
5
|
-
"mappings": "AAAA,SAAS,QAAQ,KAAK;AAAE;AAA2B,SAAO,UAAU,cAAc,OAAO,UAAU,YAAY,OAAO,OAAO,WAAW,SAAUA,MAAK;AAAE,WAAO,OAAOA;AAAA,EAAK,IAAI,SAAUA,MAAK;AAAE,WAAOA,QAAO,cAAc,OAAO,UAAUA,KAAI,gBAAgB,UAAUA,SAAQ,OAAO,YAAY,WAAW,OAAOA;AAAA,EAAK,GAAG,QAAQ,GAAG;AAAG;AAC/U,IAAI,YAAY,CAAC,SAAS,YAAY,WAAW,SAAS,mBAAmB,cAAc,sBAAsB,OAAO,YAAY,WAAW,YAAY,oBAAoB,WAAW,UAAU;AACpM,SAAS,QAAQ,QAAQ,gBAAgB;AAAE,MAAI,OAAO,OAAO,KAAK,MAAM;AAAG,MAAI,OAAO,uBAAuB;AAAE,QAAI,UAAU,OAAO,sBAAsB,MAAM;AAAG,uBAAmB,UAAU,QAAQ,OAAO,SAAU,KAAK;AAAE,aAAO,OAAO,yBAAyB,QAAQ,GAAG,EAAE;AAAA,IAAY,CAAC,IAAI,KAAK,KAAK,MAAM,MAAM,OAAO;AAAA,EAAG;AAAE,SAAO;AAAM;AACpV,SAAS,cAAc,QAAQ;AAAE,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AAAE,QAAI,SAAS,QAAQ,UAAU,CAAC,IAAI,UAAU,CAAC,IAAI,CAA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,WAAY;AACnC,WAAO,cAAc,cAAc,CAAC,GAAG,iBAAiB,GAAG,CAAC,GAAG;AAAA,
|
|
4
|
+
"sourcesContent": ["function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _excluded = [\"realm\", \"clientId\", \"baseUrl\", \"debug\", \"ensureFreshness\", \"loginRoute\", \"messageHandlerKeys\", \"ssr\", \"children\", \"cookies\", \"disabled\", \"loadingComponent\", \"onEvent\", \"onTokens\"];\nfunction 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; }\nfunction _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; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n/**\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, { useMemo } from 'react';\nimport { AuthConfigContext, defaultAuthConfig } from \"../authConfig.mjs\";\nimport { KeycloakProvider } from \"./keycloakProvider.mjs\";\nimport { useTokensFromState, useTokensFromQuery } from \"../hooks/index.mjs\"; // @ts-ignore\nimport { config } from 'app/config';\nvar persist = config.get('KEYCLOAK_PERSIST') === '1';\nexport var AuthProvider = function AuthProvider(_ref) {\n var realm = _ref.realm,\n clientId = _ref.clientId,\n baseUrl = _ref.baseUrl,\n debug = _ref.debug,\n ensureFreshness = _ref.ensureFreshness,\n loginRoute = _ref.loginRoute,\n messageHandlerKeys = _ref.messageHandlerKeys,\n ssr = _ref.ssr,\n children = _ref.children,\n cookies = _ref.cookies,\n disabled = _ref.disabled,\n loadingComponent = _ref.loadingComponent,\n onEvent = _ref.onEvent,\n onTokens = _ref.onTokens,\n keycloakInitOptions = _objectWithoutProperties(_ref, _excluded);\n var tokensFromQuery = useTokensFromQuery();\n var tokensFromState = useTokensFromState();\n var authConfig = useMemo(function () {\n return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultAuthConfig), typeof debug !== 'undefined' ? {\n debug: debug\n } : {}), typeof ensureFreshness !== 'undefined' ? {\n ensureFreshness: ensureFreshness\n } : {}), typeof loginRoute !== 'undefined' ? {\n loginRoute: loginRoute\n } : {}), typeof messageHandlerKeys !== 'undefined' ? {\n messageHandlerKeys: messageHandlerKeys\n } : {}), {}, {\n persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== 'undefined' ? persist : defaultAuthConfig.persist,\n ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== 'undefined' ? ssr : defaultAuthConfig.ssr : false\n });\n }, [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]);\n if (disabled) {\n return /*#__PURE__*/React.createElement(AuthConfigContext.Provider, {\n value: authConfig\n }, children);\n }\n return /*#__PURE__*/React.createElement(AuthConfigContext.Provider, {\n value: authConfig\n }, /*#__PURE__*/React.createElement(KeycloakProvider, {\n cookies: cookies,\n keycloakConfig: {\n realm: realm || 'main',\n clientId: clientId || 'app',\n url: baseUrl\n },\n keycloakInitOptions: keycloakInitOptions,\n loadingComponent: loadingComponent,\n onEvent: onEvent,\n onTokens: onTokens\n }, children));\n};\nexport * from \"./keycloakProvider.mjs\";"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,KAAK;AAAE;AAA2B,SAAO,UAAU,cAAc,OAAO,UAAU,YAAY,OAAO,OAAO,WAAW,SAAUA,MAAK;AAAE,W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,CAAC,mBAAmB,UAAU,OAAO,QAAQ,cAAc,MAAM,kBAAkB,MAAM;AAAA,IACpH,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,iBAAiB,YAAY,oBAAoB,SAAS,GAAG,CAAC;AACzE,MAAI,UAAU;AACZ,WAAoB,sBAAM,cAAc,kBAAkB,UAAU;AAAA,MAClE,OAAO;AAAA,IACT,GAAG,QAAQ;AAAA,EACb;AACA,SAAoB,sBAAM,cAAc,kBAAkB,UAAU;AAAA,IAClE,OAAO;AAAA,EACT,GAAgB,sBAAM,cAAc,kBAAkB;AAAA,IACpD;AAAA,IACA,gBAAgB;AAAA,MACd,OAAO,SAAS;AAAA,MAChB,UAAU,YAAY;AAAA,MACtB,KAAK;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAG,QAAQ,CAAC;AACd;AACA,cAAc;",
|
|
6
6
|
"names": ["obj", "AuthProvider"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/state/index.ts"],
|
|
4
|
-
"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:
|
|
4
|
+
"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: 26-05-2023 07:31:04\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 { createStateStore } from 'multiplatform.one/zustand';\n// @ts-ignore\nimport { config } from 'app/config';\nvar _createStateStore = createStateStore('auth', {\n idToken: '',\n refreshToken: '',\n token: ''\n }, undefined, {\n persist: config.get('KEYCLOAK_PERSIST') === '1'\n }),\n useStore = _createStateStore.useStore;\nexport function useAuthState() {\n return useStore();\n}"],
|
|
5
5
|
"mappings": "AAwBA,SAAS,wBAAwB;AAEjC,SAAS,cAAc;AACvB,IAAI,oBAAoB,iBAAiB,QAAQ;AAAA,EAC7C,SAAS;AAAA,EACT,cAAc;AAAA,EACd,OAAO;AACT,GAAG,QAAW;AAAA,EACZ,SAAS,OAAO,IAAI,kBAAkB,MAAM;AAC9C,CAAC,GACD,WAAW,kBAAkB;AACxB,SAAS,eAAe;AAC7B,SAAO,SAAS;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,7 +22,7 @@ function Authenticated({ children, disabled, loginRoute, loggedOutComponent }) {
|
|
|
22
22
|
}, [authenticated]);
|
|
23
23
|
if (disabled || authenticated)
|
|
24
24
|
return <>{children}</>;
|
|
25
|
-
const LoggedOutComponent = loggedOutComponent || (() => <>{
|
|
25
|
+
const LoggedOutComponent = loggedOutComponent || (() => <>{authConfig.debug ? "not authenticated" : null}</>);
|
|
26
26
|
return <LoggedOutComponent />;
|
|
27
27
|
}
|
|
28
28
|
function withAuthenticated(Component) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Authenticated.tsx"],
|
|
4
|
-
"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, { useEffect } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport { useLogin, useKeycloak } from './hooks';\nimport { useAuthState } from './state';\nimport { useAuthConfig, useTokensFromQuery, useTokensFromState } from './hooks';\n\nexport interface AuthenticatedProps {\n children: ReactNode;\n disabled?: boolean;\n loggedOutComponent?: ComponentType;\n loginRoute?: string;\n}\n\nexport function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps) {\n const authConfig = useAuthConfig();\n const authState = useAuthState();\n const login = useLogin(loginRoute);\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const { authenticated } = useKeycloak();\n\n useEffect(() => {\n if (authenticated !== false) return;\n if (authConfig.persist) {\n authState.setIdToken('');\n authState.setRefreshToken('');\n authState.setToken('');\n }\n if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();\n }, [authenticated]);\n\n if (disabled || authenticated) return <>{children}</>;\n const LoggedOutComponent = loggedOutComponent || (() => <>{
|
|
5
|
-
"mappings": "AAwBA,SAAgB,iBAAiB;AAEjC,SAAS,UAAU,mBAAmB;AACtC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,oBAAoB,0BAA0B;AAS/D,SAAS,cAAc,EAAE,UAAU,UAAU,YAAY,mBAAmB,GAAuB;AACxG,QAAM,aAAa,cAAc;AACjC,QAAM,YAAY,aAAa;AAC/B,QAAM,QAAQ,SAAS,UAAU;AACjC,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,EAAE,cAAc,IAAI,YAAY;AAEtC,YAAU,MAAM;AACd,QAAI,kBAAkB;AAAO;AAC7B,QAAI,WAAW,SAAS;AACtB,gBAAU,WAAW,EAAE;AACvB,gBAAU,gBAAgB,EAAE;AAC5B,gBAAU,SAAS,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,WAAW,eAAe,CAAC,mBAAmB,CAAC;AAAiB,YAAM;AAAA,EACnF,GAAG,CAAC,aAAa,CAAC;AAElB,MAAI,YAAY;AAAe,WAAO,GAAG,SAAS;AAClD,QAAM,qBAAqB,uBAAuB,MAAM,GAAG,
|
|
4
|
+
"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, { useEffect } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport { useLogin, useKeycloak } from './hooks';\nimport { useAuthState } from './state';\nimport { useAuthConfig, useTokensFromQuery, useTokensFromState } from './hooks';\n\nexport interface AuthenticatedProps {\n children: ReactNode;\n disabled?: boolean;\n loggedOutComponent?: ComponentType;\n loginRoute?: string;\n}\n\nexport function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps) {\n const authConfig = useAuthConfig();\n const authState = useAuthState();\n const login = useLogin(loginRoute);\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const { authenticated } = useKeycloak();\n\n useEffect(() => {\n if (authenticated !== false) return;\n if (authConfig.persist) {\n authState.setIdToken('');\n authState.setRefreshToken('');\n authState.setToken('');\n }\n if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();\n }, [authenticated]);\n\n if (disabled || authenticated) return <>{children}</>;\n const LoggedOutComponent = loggedOutComponent || (() => <>{authConfig.debug ? 'not authenticated' : null}</>);\n return <LoggedOutComponent />;\n}\n\nexport function withAuthenticated<P extends object>(Component: ComponentType<P>) {\n return (props: P) => (\n <Authenticated>\n <Component {...props} />\n </Authenticated>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAwBA,SAAgB,iBAAiB;AAEjC,SAAS,UAAU,mBAAmB;AACtC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,oBAAoB,0BAA0B;AAS/D,SAAS,cAAc,EAAE,UAAU,UAAU,YAAY,mBAAmB,GAAuB;AACxG,QAAM,aAAa,cAAc;AACjC,QAAM,YAAY,aAAa;AAC/B,QAAM,QAAQ,SAAS,UAAU;AACjC,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,EAAE,cAAc,IAAI,YAAY;AAEtC,YAAU,MAAM;AACd,QAAI,kBAAkB;AAAO;AAC7B,QAAI,WAAW,SAAS;AACtB,gBAAU,WAAW,EAAE;AACvB,gBAAU,gBAAgB,EAAE;AAC5B,gBAAU,SAAS,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,WAAW,eAAe,CAAC,mBAAmB,CAAC;AAAiB,YAAM;AAAA,EACnF,GAAG,CAAC,aAAa,CAAC;AAElB,MAAI,YAAY;AAAe,WAAO,GAAG,SAAS;AAClD,QAAM,qBAAqB,uBAAuB,MAAM,GAAG,WAAW,QAAQ,sBAAsB,KAAK;AACzG,SAAO,CAAC,mBAAmB;AAC7B;AAEO,SAAS,kBAAoC,WAA6B;AAC/E,SAAO,CAAC,UACN,CAAC,cACC,CAAC,cAAc,OAAO,EACxB,EAFC;AAIL;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/authConfig.ts"],
|
|
4
|
-
"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:
|
|
4
|
+
"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: 26-05-2023 08:07:00\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 ensureFreshness: true,\n persist: false,\n ssr: false,\n};\n\nexport const AuthConfigContext = createContext<AuthConfig>(defaultAuthConfig);\n\nexport interface AuthConfig {\n debug?: boolean;\n ensureFreshness?: boolean;\n loginRoute?: string;\n messageHandlerKeys?: string[];\n persist?: boolean;\n ssr?: boolean;\n}\n"],
|
|
5
5
|
"mappings": "AAwBA,SAAS,qBAAqB;AAEvB,MAAM,oBAAgC;AAAA,EAC3C,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,KAAK;AACP;AAEO,MAAM,oBAAoB,cAA0B,iBAAiB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,12 +29,12 @@ const AuthProvider = ({
|
|
|
29
29
|
const authConfig = useMemo(
|
|
30
30
|
() => ({
|
|
31
31
|
...defaultAuthConfig,
|
|
32
|
-
debug,
|
|
33
|
-
ensureFreshness,
|
|
34
|
-
loginRoute,
|
|
35
|
-
messageHandlerKeys,
|
|
36
|
-
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : persist,
|
|
37
|
-
ssr: !tokensFromState && !tokensFromQuery && cookies ? ssr : false
|
|
32
|
+
...typeof debug !== "undefined" ? { debug } : {},
|
|
33
|
+
...typeof ensureFreshness !== "undefined" ? { ensureFreshness } : {},
|
|
34
|
+
...typeof loginRoute !== "undefined" ? { loginRoute } : {},
|
|
35
|
+
...typeof messageHandlerKeys !== "undefined" ? { messageHandlerKeys } : {},
|
|
36
|
+
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : defaultAuthConfig.persist,
|
|
37
|
+
ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : defaultAuthConfig.ssr : false
|
|
38
38
|
}),
|
|
39
39
|
[debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]
|
|
40
40
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/provider/index.tsx"],
|
|
4
|
-
"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, { useMemo } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { AuthConfig } from '../authConfig';\nimport type { FC, ComponentType, ReactNode } from 'react';\nimport type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';\nimport { AuthConfigContext, defaultAuthConfig } from '../authConfig';\nimport { KeycloakProvider } from './keycloakProvider';\nimport { useTokensFromState, useTokensFromQuery } from '../hooks';\n// @ts-ignore\nimport { config } from 'app/config';\n\nexport interface AuthProviderProps\n extends Partial<Omit<AuthConfig, 'persist'>>,\n Partial<Omit<KeycloakConfig, 'url'>>,\n KeycloakInitOptions {\n children: ReactNode;\n cookies?: unknown;\n disabled?: boolean;\n baseUrl?: string;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst persist = config.get('KEYCLOAK_PERSIST') === '1';\n\nexport const AuthProvider: FC<AuthProviderProps> = ({\n // keycloak config\n realm,\n clientId,\n baseUrl,\n // auth config\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n ssr,\n // props\n children,\n cookies,\n disabled,\n loadingComponent,\n onEvent,\n onTokens,\n ...keycloakInitOptions\n}: AuthProviderProps) => {\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const authConfig = useMemo(\n () => ({\n ...defaultAuthConfig,\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n persist
|
|
5
|
-
"mappings": "AAwBA,SAAgB,eAAe;AAK/B,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,wBAAwB;AACjC,SAAS,oBAAoB,0BAA0B;AAEvD,SAAS,cAAc;AAevB,MAAM,UAAU,OAAO,IAAI,kBAAkB,MAAM;AAE5C,MAAM,eAAsC,CAAC;AAAA;AAAA,EAElD;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,aAAa;AAAA,IACjB,OAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,
|
|
4
|
+
"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, { useMemo } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { AuthConfig } from '../authConfig';\nimport type { FC, ComponentType, ReactNode } from 'react';\nimport type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';\nimport { AuthConfigContext, defaultAuthConfig } from '../authConfig';\nimport { KeycloakProvider } from './keycloakProvider';\nimport { useTokensFromState, useTokensFromQuery } from '../hooks';\n// @ts-ignore\nimport { config } from 'app/config';\n\nexport interface AuthProviderProps\n extends Partial<Omit<AuthConfig, 'persist'>>,\n Partial<Omit<KeycloakConfig, 'url'>>,\n KeycloakInitOptions {\n children: ReactNode;\n cookies?: unknown;\n disabled?: boolean;\n baseUrl?: string;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst persist = config.get('KEYCLOAK_PERSIST') === '1';\n\nexport const AuthProvider: FC<AuthProviderProps> = ({\n // keycloak config\n realm,\n clientId,\n baseUrl,\n // auth config\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n ssr,\n // props\n children,\n cookies,\n disabled,\n loadingComponent,\n onEvent,\n onTokens,\n ...keycloakInitOptions\n}: AuthProviderProps) => {\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const authConfig = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...(typeof debug !== 'undefined' ? { debug } : {}),\n ...(typeof ensureFreshness !== 'undefined' ? { ensureFreshness } : {}),\n ...(typeof loginRoute !== 'undefined' ? { loginRoute } : {}),\n ...(typeof messageHandlerKeys !== 'undefined' ? { messageHandlerKeys } : {}),\n persist:\n !tokensFromState && !tokensFromQuery && cookies && ssr\n ? false\n : typeof persist !== 'undefined'\n ? persist\n : defaultAuthConfig.persist,\n ssr:\n !tokensFromState && !tokensFromQuery && cookies\n ? typeof ssr !== 'undefined'\n ? ssr\n : defaultAuthConfig.ssr\n : false,\n }),\n [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr],\n );\n\n if (disabled) {\n return <AuthConfigContext.Provider value={authConfig}>{children}</AuthConfigContext.Provider>;\n }\n\n return (\n <AuthConfigContext.Provider value={authConfig}>\n <KeycloakProvider\n cookies={cookies}\n keycloakConfig={{\n realm: realm || 'main',\n clientId: clientId || 'app',\n url: baseUrl,\n }}\n keycloakInitOptions={keycloakInitOptions}\n loadingComponent={loadingComponent}\n onEvent={onEvent}\n onTokens={onTokens}\n >\n {children}\n </KeycloakProvider>\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from './keycloakProvider';\n"],
|
|
5
|
+
"mappings": "AAwBA,SAAgB,eAAe;AAK/B,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,wBAAwB;AACjC,SAAS,oBAAoB,0BAA0B;AAEvD,SAAS,cAAc;AAevB,MAAM,UAAU,OAAO,IAAI,kBAAkB,MAAM;AAE5C,MAAM,eAAsC,CAAC;AAAA;AAAA,EAElD;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAA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
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/state/index.ts"],
|
|
4
|
-
"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:
|
|
4
|
+
"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: 26-05-2023 07:31:04\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 { createStateStore } from 'multiplatform.one/zustand';\n// @ts-ignore\nimport { config } from 'app/config';\n\nconst { useStore } = createStateStore(\n 'auth',\n {\n idToken: '',\n refreshToken: '',\n token: '',\n },\n undefined,\n { persist: config.get('KEYCLOAK_PERSIST') === '1' },\n);\n\nexport function useAuthState() {\n return useStore();\n}\n"],
|
|
5
5
|
"mappings": "AAwBA,SAAS,wBAAwB;AAEjC,SAAS,cAAc;AAEvB,MAAM,EAAE,SAAS,IAAI;AAAA,EACnB;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,cAAc;AAAA,IACd,OAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,EAAE,SAAS,OAAO,IAAI,kBAAkB,MAAM,IAAI;AACpD;AAEO,SAAS,eAAe;AAC7B,SAAO,SAAS;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -61,7 +61,7 @@ function Authenticated({ children, disabled, loginRoute, loggedOutComponent }) {
|
|
|
61
61
|
}, [authenticated]);
|
|
62
62
|
if (disabled || authenticated)
|
|
63
63
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
64
|
-
const LoggedOutComponent = loggedOutComponent || (() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children:
|
|
64
|
+
const LoggedOutComponent = loggedOutComponent || (() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: authConfig.debug ? "not authenticated" : null }));
|
|
65
65
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoggedOutComponent, {});
|
|
66
66
|
}
|
|
67
67
|
function withAuthenticated(Component) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Authenticated.tsx"],
|
|
4
|
-
"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, { useEffect } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport { useLogin, useKeycloak } from './hooks';\nimport { useAuthState } from './state';\nimport { useAuthConfig, useTokensFromQuery, useTokensFromState } from './hooks';\n\nexport interface AuthenticatedProps {\n children: ReactNode;\n disabled?: boolean;\n loggedOutComponent?: ComponentType;\n loginRoute?: string;\n}\n\nexport function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps) {\n const authConfig = useAuthConfig();\n const authState = useAuthState();\n const login = useLogin(loginRoute);\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const { authenticated } = useKeycloak();\n\n useEffect(() => {\n if (authenticated !== false) return;\n if (authConfig.persist) {\n authState.setIdToken('');\n authState.setRefreshToken('');\n authState.setToken('');\n }\n if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();\n }, [authenticated]);\n\n if (disabled || authenticated) return <>{children}</>;\n const LoggedOutComponent = loggedOutComponent || (() => <>{
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuDwC;AA/BxC,mBAAiC;AAEjC,mBAAsC;AACtC,mBAA6B;AAC7B,IAAAA,gBAAsE;AAS/D,SAAS,cAAc,EAAE,UAAU,UAAU,YAAY,mBAAmB,GAAuB;AACxG,QAAM,iBAAa,6BAAc;AACjC,QAAM,gBAAY,2BAAa;AAC/B,QAAM,YAAQ,uBAAS,UAAU;AACjC,QAAM,sBAAkB,kCAAmB;AAC3C,QAAM,sBAAkB,kCAAmB;AAC3C,QAAM,EAAE,cAAc,QAAI,0BAAY;AAEtC,8BAAU,MAAM;AACd,QAAI,kBAAkB;AAAO;AAC7B,QAAI,WAAW,SAAS;AACtB,gBAAU,WAAW,EAAE;AACvB,gBAAU,gBAAgB,EAAE;AAC5B,gBAAU,SAAS,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,WAAW,eAAe,CAAC,mBAAmB,CAAC;AAAiB,YAAM;AAAA,EACnF,GAAG,CAAC,aAAa,CAAC;AAElB,MAAI,YAAY;AAAe,WAAO,2EAAG,UAAS;AAClD,QAAM,qBAAqB,uBAAuB,MAAM,2EAAG,
|
|
4
|
+
"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, { useEffect } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport { useLogin, useKeycloak } from './hooks';\nimport { useAuthState } from './state';\nimport { useAuthConfig, useTokensFromQuery, useTokensFromState } from './hooks';\n\nexport interface AuthenticatedProps {\n children: ReactNode;\n disabled?: boolean;\n loggedOutComponent?: ComponentType;\n loginRoute?: string;\n}\n\nexport function Authenticated({ children, disabled, loginRoute, loggedOutComponent }: AuthenticatedProps) {\n const authConfig = useAuthConfig();\n const authState = useAuthState();\n const login = useLogin(loginRoute);\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const { authenticated } = useKeycloak();\n\n useEffect(() => {\n if (authenticated !== false) return;\n if (authConfig.persist) {\n authState.setIdToken('');\n authState.setRefreshToken('');\n authState.setToken('');\n }\n if (typeof window !== 'undefined' && !tokensFromQuery && !tokensFromState) login();\n }, [authenticated]);\n\n if (disabled || authenticated) return <>{children}</>;\n const LoggedOutComponent = loggedOutComponent || (() => <>{authConfig.debug ? 'not authenticated' : null}</>);\n return <LoggedOutComponent />;\n}\n\nexport function withAuthenticated<P extends object>(Component: ComponentType<P>) {\n return (props: P) => (\n <Authenticated>\n <Component {...props} />\n </Authenticated>\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuDwC;AA/BxC,mBAAiC;AAEjC,mBAAsC;AACtC,mBAA6B;AAC7B,IAAAA,gBAAsE;AAS/D,SAAS,cAAc,EAAE,UAAU,UAAU,YAAY,mBAAmB,GAAuB;AACxG,QAAM,iBAAa,6BAAc;AACjC,QAAM,gBAAY,2BAAa;AAC/B,QAAM,YAAQ,uBAAS,UAAU;AACjC,QAAM,sBAAkB,kCAAmB;AAC3C,QAAM,sBAAkB,kCAAmB;AAC3C,QAAM,EAAE,cAAc,QAAI,0BAAY;AAEtC,8BAAU,MAAM;AACd,QAAI,kBAAkB;AAAO;AAC7B,QAAI,WAAW,SAAS;AACtB,gBAAU,WAAW,EAAE;AACvB,gBAAU,gBAAgB,EAAE;AAC5B,gBAAU,SAAS,EAAE;AAAA,IACvB;AACA,QAAI,OAAO,WAAW,eAAe,CAAC,mBAAmB,CAAC;AAAiB,YAAM;AAAA,EACnF,GAAG,CAAC,aAAa,CAAC;AAElB,MAAI,YAAY;AAAe,WAAO,2EAAG,UAAS;AAClD,QAAM,qBAAqB,uBAAuB,MAAM,2EAAG,qBAAW,QAAQ,sBAAsB,MAAK;AACzG,SAAO,4CAAC,sBAAmB;AAC7B;AAEO,SAAS,kBAAoC,WAA6B;AAC/E,SAAO,CAAC,UACN,4CAAC,iBACC,sDAAC,8BAAc,MAAO,GACxB;AAEJ;",
|
|
6
6
|
"names": ["import_hooks"]
|
|
7
7
|
}
|
package/dist/lib/authConfig.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/authConfig.ts"],
|
|
4
|
-
"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:
|
|
4
|
+
"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: 26-05-2023 08:07:00\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 ensureFreshness: true,\n persist: false,\n ssr: false,\n};\n\nexport const AuthConfigContext = createContext<AuthConfig>(defaultAuthConfig);\n\nexport interface AuthConfig {\n debug?: boolean;\n ensureFreshness?: boolean;\n loginRoute?: string;\n messageHandlerKeys?: string[];\n persist?: boolean;\n ssr?: boolean;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBA,mBAA8B;AAEvB,MAAM,oBAAgC;AAAA,EAC3C,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,KAAK;AACP;AAEO,MAAM,wBAAoB,4BAA0B,iBAAiB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -97,13 +97,9 @@ const AuthProvider = (_a) => {
|
|
|
97
97
|
const tokensFromQuery = (0, import_hooks.useTokensFromQuery)();
|
|
98
98
|
const tokensFromState = (0, import_hooks.useTokensFromState)();
|
|
99
99
|
const authConfig = (0, import_react.useMemo)(
|
|
100
|
-
() => __spreadProps(__spreadValues({}, import_authConfig.defaultAuthConfig), {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
loginRoute,
|
|
104
|
-
messageHandlerKeys,
|
|
105
|
-
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : persist,
|
|
106
|
-
ssr: !tokensFromState && !tokensFromQuery && cookies ? ssr : false
|
|
100
|
+
() => __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, import_authConfig.defaultAuthConfig), typeof debug !== "undefined" ? { debug } : {}), typeof ensureFreshness !== "undefined" ? { ensureFreshness } : {}), typeof loginRoute !== "undefined" ? { loginRoute } : {}), typeof messageHandlerKeys !== "undefined" ? { messageHandlerKeys } : {}), {
|
|
101
|
+
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : import_authConfig.defaultAuthConfig.persist,
|
|
102
|
+
ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : import_authConfig.defaultAuthConfig.ssr : false
|
|
107
103
|
}),
|
|
108
104
|
[debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]
|
|
109
105
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/provider/index.tsx"],
|
|
4
|
-
"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, { useMemo } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { AuthConfig } from '../authConfig';\nimport type { FC, ComponentType, ReactNode } from 'react';\nimport type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';\nimport { AuthConfigContext, defaultAuthConfig } from '../authConfig';\nimport { KeycloakProvider } from './keycloakProvider';\nimport { useTokensFromState, useTokensFromQuery } from '../hooks';\n// @ts-ignore\nimport { config } from 'app/config';\n\nexport interface AuthProviderProps\n extends Partial<Omit<AuthConfig, 'persist'>>,\n Partial<Omit<KeycloakConfig, 'url'>>,\n KeycloakInitOptions {\n children: ReactNode;\n cookies?: unknown;\n disabled?: boolean;\n baseUrl?: string;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst persist = config.get('KEYCLOAK_PERSIST') === '1';\n\nexport const AuthProvider: FC<AuthProviderProps> = ({\n // keycloak config\n realm,\n clientId,\n baseUrl,\n // auth config\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n ssr,\n // props\n children,\n cookies,\n disabled,\n loadingComponent,\n onEvent,\n onTokens,\n ...keycloakInitOptions\n}: AuthProviderProps) => {\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const authConfig = useMemo(\n () => ({\n ...defaultAuthConfig,\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n persist
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"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, { useMemo } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { AuthConfig } from '../authConfig';\nimport type { FC, ComponentType, ReactNode } from 'react';\nimport type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';\nimport { AuthConfigContext, defaultAuthConfig } from '../authConfig';\nimport { KeycloakProvider } from './keycloakProvider';\nimport { useTokensFromState, useTokensFromQuery } from '../hooks';\n// @ts-ignore\nimport { config } from 'app/config';\n\nexport interface AuthProviderProps\n extends Partial<Omit<AuthConfig, 'persist'>>,\n Partial<Omit<KeycloakConfig, 'url'>>,\n KeycloakInitOptions {\n children: ReactNode;\n cookies?: unknown;\n disabled?: boolean;\n baseUrl?: string;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst persist = config.get('KEYCLOAK_PERSIST') === '1';\n\nexport const AuthProvider: FC<AuthProviderProps> = ({\n // keycloak config\n realm,\n clientId,\n baseUrl,\n // auth config\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n ssr,\n // props\n children,\n cookies,\n disabled,\n loadingComponent,\n onEvent,\n onTokens,\n ...keycloakInitOptions\n}: AuthProviderProps) => {\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const authConfig = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...(typeof debug !== 'undefined' ? { debug } : {}),\n ...(typeof ensureFreshness !== 'undefined' ? { ensureFreshness } : {}),\n ...(typeof loginRoute !== 'undefined' ? { loginRoute } : {}),\n ...(typeof messageHandlerKeys !== 'undefined' ? { messageHandlerKeys } : {}),\n persist:\n !tokensFromState && !tokensFromQuery && cookies && ssr\n ? false\n : typeof persist !== 'undefined'\n ? persist\n : defaultAuthConfig.persist,\n ssr:\n !tokensFromState && !tokensFromQuery && cookies\n ? typeof ssr !== 'undefined'\n ? ssr\n : defaultAuthConfig.ssr\n : false,\n }),\n [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr],\n );\n\n if (disabled) {\n return <AuthConfigContext.Provider value={authConfig}>{children}</AuthConfigContext.Provider>;\n }\n\n return (\n <AuthConfigContext.Provider value={authConfig}>\n <KeycloakProvider\n cookies={cookies}\n keycloakConfig={{\n realm: realm || 'main',\n clientId: clientId || 'app',\n url: baseUrl,\n }}\n keycloakInitOptions={keycloakInitOptions}\n loadingComponent={loadingComponent}\n onEvent={onEvent}\n onTokens={onTokens}\n >\n {children}\n </KeycloakProvider>\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from './keycloakProvider';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgGW;AAxEX,mBAA+B;AAK/B,wBAAqD;AACrD,8BAAiC;AACjC,mBAAuD;AAEvD,oBAAuB;AAsFvB,6BAAc,+BAvHd;AAgDA,MAAM,UAAU,qBAAO,IAAI,kBAAkB,MAAM;AAE5C,MAAM,eAAsC,CAAC,OAmB3B;AAnB2B,eAElD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAnEF,IAkDoD,IAkB/C,gCAlB+C,IAkB/C;AAAA;AAAA,IAhBH;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,sBAAkB,iCAAmB;AAC3C,QAAM,sBAAkB,iCAAmB;AAC3C,QAAM,iBAAa;AAAA,IACjB,MAAO,6FACF,sCACC,OAAO,UAAU,cAAc,EAAE,MAAM,IAAI,CAAC,IAC5C,OAAO,oBAAoB,cAAc,EAAE,gBAAgB,IAAI,CAAC,IAChE,OAAO,eAAe,cAAc,EAAE,WAAW,IAAI,CAAC,IACtD,OAAO,uBAAuB,cAAc,EAAE,mBAAmB,IAAI,CAAC,IALrE;AAAA,MAML,SACE,CAAC,mBAAmB,CAAC,mBAAmB,WAAW,MAC/C,QACA,OAAO,YAAY,cACnB,UACA,oCAAkB;AAAA,MACxB,KACE,CAAC,mBAAmB,CAAC,mBAAmB,UACpC,OAAO,QAAQ,cACb,MACA,oCAAkB,MACpB;AAAA,IACR;AAAA,IACA,CAAC,OAAO,iBAAiB,YAAY,oBAAoB,SAAS,GAAG;AAAA,EACvE;AAEA,MAAI,UAAU;AACZ,WAAO,4CAAC,oCAAkB,UAAlB,EAA2B,OAAO,YAAa,UAAS;AAAA,EAClE;AAEA,SACE,4CAAC,oCAAkB,UAAlB,EAA2B,OAAO,YACjC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,gBAAgB;AAAA,QACd,OAAO,SAAS;AAAA,QAChB,UAAU,YAAY;AAAA,QACtB,KAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACH,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/state/index.ts"],
|
|
4
|
-
"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:
|
|
4
|
+
"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: 26-05-2023 07:31:04\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 { createStateStore } from 'multiplatform.one/zustand';\n// @ts-ignore\nimport { config } from 'app/config';\n\nconst { useStore } = createStateStore(\n 'auth',\n {\n idToken: '',\n refreshToken: '',\n token: '',\n },\n undefined,\n { persist: config.get('KEYCLOAK_PERSIST') === '1' },\n);\n\nexport function useAuthState() {\n return useStore();\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBA,qBAAiC;AAEjC,oBAAuB;AAEvB,MAAM,EAAE,SAAS,QAAI;AAAA,EACnB;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,cAAc;AAAA,IACd,OAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,EAAE,SAAS,qBAAO,IAAI,kBAAkB,MAAM,IAAI;AACpD;AAEO,SAAS,eAAe;AAC7B,SAAO,SAAS;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|