@multiplatform.one/keycloak 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/esm/Authenticated.js +8 -19
  2. package/esm/Authenticated.js.map +1 -1
  3. package/esm/authConfig.js +2 -2
  4. package/esm/authConfig.js.map +1 -1
  5. package/esm/expo/ExpoKeycloakContext.js +28 -0
  6. package/esm/expo/ExpoKeycloakContext.js.map +1 -0
  7. package/esm/expo/ExpoKeycloakProvider.js +113 -0
  8. package/esm/expo/ExpoKeycloakProvider.js.map +1 -0
  9. package/esm/expo/KeycloakContext.js +28 -0
  10. package/esm/expo/KeycloakContext.js.map +1 -0
  11. package/esm/expo/KeycloakProvider.js +142 -0
  12. package/esm/expo/KeycloakProvider.js.map +1 -0
  13. package/esm/expo/const.js +42 -0
  14. package/esm/expo/const.js.map +1 -0
  15. package/esm/expo/helpers.js +56 -0
  16. package/esm/expo/helpers.js.map +1 -0
  17. package/esm/expo/index.js +28 -0
  18. package/esm/expo/index.js.map +1 -0
  19. package/esm/expo/useExpoKeycloak.js +44 -0
  20. package/esm/expo/useExpoKeycloak.js.map +1 -0
  21. package/esm/expo/useTokenStorage.js +153 -0
  22. package/esm/expo/useTokenStorage.js.map +1 -0
  23. package/esm/hooks/useCurrentRouteName.js +2 -3
  24. package/esm/hooks/useCurrentRouteName.js.map +1 -1
  25. package/esm/hooks/useKeycloak/index.js +1 -1
  26. package/esm/hooks/useKeycloak/index.js.map +1 -1
  27. package/esm/hooks/useKeycloak/useKeycloak.js +17 -24
  28. package/esm/hooks/useKeycloak/useKeycloak.js.map +1 -1
  29. package/esm/hooks/useKeycloak/useKeycloak.native.js +39 -24
  30. package/esm/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
  31. package/esm/hooks/useLogin.js +12 -30
  32. package/esm/hooks/useLogin.js.map +1 -1
  33. package/esm/provider/afterAuth.js +21 -39
  34. package/esm/provider/afterAuth.js.map +1 -1
  35. package/esm/provider/index.js +11 -28
  36. package/esm/provider/index.js.map +1 -1
  37. package/esm/provider/keycloakProvider.js +55 -100
  38. package/esm/provider/keycloakProvider.js.map +1 -1
  39. package/esm/provider/keycloakProvider.native.js +12 -11
  40. package/esm/provider/keycloakProvider.native.js.map +1 -1
  41. package/esm/state/index.js +2 -2
  42. package/esm/state/index.js.map +1 -1
  43. package/lib/Authenticated.js +38 -26
  44. package/lib/Authenticated.js.map +1 -1
  45. package/lib/authConfig.js +2 -4
  46. package/lib/authConfig.js.map +1 -1
  47. package/lib/expo/ExpoKeycloakContext.d.ts +32 -0
  48. package/lib/expo/ExpoKeycloakContext.js +47 -0
  49. package/lib/expo/ExpoKeycloakContext.js.map +1 -0
  50. package/lib/expo/ExpoKeycloakProvider.d.ts +37 -0
  51. package/lib/expo/ExpoKeycloakProvider.js +130 -0
  52. package/lib/expo/ExpoKeycloakProvider.js.map +1 -0
  53. package/lib/expo/KeycloakContext.d.ts +32 -0
  54. package/lib/expo/KeycloakContext.js +49 -0
  55. package/lib/expo/KeycloakContext.js.map +1 -0
  56. package/lib/expo/KeycloakProvider.d.ts +37 -0
  57. package/lib/expo/KeycloakProvider.js +138 -0
  58. package/lib/expo/KeycloakProvider.js.map +1 -0
  59. package/lib/expo/const.d.ts +33 -0
  60. package/lib/expo/const.js +66 -0
  61. package/lib/expo/const.js.map +1 -0
  62. package/lib/expo/helpers.d.ts +41 -0
  63. package/lib/expo/helpers.js +77 -0
  64. package/lib/expo/helpers.js.map +1 -0
  65. package/lib/expo/index.d.ts +26 -0
  66. package/lib/expo/index.js +50 -0
  67. package/lib/expo/index.js.map +1 -0
  68. package/lib/expo/useExpoKeycloak.d.ts +31 -0
  69. package/lib/expo/useExpoKeycloak.js +62 -0
  70. package/lib/expo/useExpoKeycloak.js.map +1 -0
  71. package/lib/expo/useTokenStorage.d.ts +36 -0
  72. package/lib/expo/useTokenStorage.js +166 -0
  73. package/lib/expo/useTokenStorage.js.map +1 -0
  74. package/lib/hooks/index.js +3 -9
  75. package/lib/hooks/index.js.map +1 -1
  76. package/lib/hooks/useAuthConfig.js +0 -2
  77. package/lib/hooks/useAuthConfig.js.map +1 -1
  78. package/lib/hooks/useCurrentRouteName.js +6 -8
  79. package/lib/hooks/useCurrentRouteName.js.map +1 -1
  80. package/lib/hooks/useKeycloak/index.d.ts +6 -4
  81. package/lib/hooks/useKeycloak/index.js +1 -7
  82. package/lib/hooks/useKeycloak/index.js.map +1 -1
  83. package/lib/hooks/useKeycloak/useKeycloak.js +45 -30
  84. package/lib/hooks/useKeycloak/useKeycloak.js.map +1 -1
  85. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +12 -4
  86. package/lib/hooks/useKeycloak/useKeycloak.native.js +40 -28
  87. package/lib/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
  88. package/lib/hooks/useLogin.js +16 -25
  89. package/lib/hooks/useLogin.js.map +1 -1
  90. package/lib/index.js +4 -10
  91. package/lib/index.js.map +1 -1
  92. package/lib/provider/afterAuth.js +52 -52
  93. package/lib/provider/afterAuth.js.map +1 -1
  94. package/lib/provider/index.js +44 -43
  95. package/lib/provider/index.js.map +1 -1
  96. package/lib/provider/keycloakProvider.js +93 -114
  97. package/lib/provider/keycloakProvider.js.map +1 -1
  98. package/lib/provider/keycloakProvider.native.js +39 -15
  99. package/lib/provider/keycloakProvider.native.js.map +1 -1
  100. package/lib/state/index.js +3 -5
  101. package/lib/state/index.js.map +1 -1
  102. package/lib/tsconfig.build.tsbuildinfo +1 -1
  103. package/lib/types.js +2 -4
  104. package/lib/types.js.map +1 -1
  105. package/package.json +3 -2
  106. package/src/expo/ExpoKeycloakContext.ts +41 -0
  107. package/src/expo/ExpoKeycloakProvider.tsx +139 -0
  108. package/src/expo/NOTES +1 -0
  109. package/src/expo/const.ts +42 -0
  110. package/src/expo/helpers.ts +74 -0
  111. package/src/{@types/expoKeycloakAuth.d.ts → expo/index.ts} +6 -7
  112. package/src/expo/useExpoKeycloak.ts +44 -0
  113. package/src/expo/useTokenStorage.ts +168 -0
  114. package/src/hooks/useKeycloak/index.ts +10 -4
  115. package/src/hooks/useKeycloak/useKeycloak.native.ts +48 -11
  116. package/src/provider/keycloakProvider.native.tsx +8 -4
@@ -1,19 +1,3 @@
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
1
  /**
18
2
  * File: /auth/provider/index.tsx
19
3
  * Project: app
@@ -41,20 +25,19 @@ import "core-js/modules/es.object.define-property.js";
41
25
  import React, { useMemo } from "react";
42
26
  import { AuthConfigContext, defaultAuthConfig } from "../authConfig";
43
27
  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), []);
28
+ export const AuthProvider = props => {
29
+ const {
30
+ authConfig,
31
+ debug
32
+ } = props;
33
+ const authConfigValue = useMemo(() => ({
34
+ ...defaultAuthConfig,
35
+ ...authConfig,
36
+ debug: !!debug
37
+ }), []);
55
38
  return /*#__PURE__*/React.createElement(AuthConfigContext.Provider, {
56
39
  value: authConfigValue
57
40
  }, /*#__PURE__*/React.createElement(KeycloakProvider, props));
58
- }.bind(this);
41
+ };
59
42
  export * from "./keycloakProvider";
60
43
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","names":["React","useMemo","AuthConfigContext","defaultAuthConfig","KeycloakProvider","AuthProvider","props","authConfig","debug","authConfigValue"],"sources":["../../src/provider/index.tsx"],"sourcesContent":["/**\n * File: /auth/provider/index.tsx\n * Project: app\n * File Created: 08-11-2022 06:33:07\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:00:13\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC, useMemo } from \"react\";\nimport {\n AuthConfig,\n AuthConfigContext,\n defaultAuthConfig,\n} from \"../authConfig\";\nimport { KeycloakProvider, KeycloakProviderProps } from \"./keycloakProvider\";\n\nexport interface AuthProviderProps extends KeycloakProviderProps {\n authConfig?: Partial<AuthConfig>;\n}\n\nexport const AuthProvider: FC<AuthProviderProps> = (\n props: AuthProviderProps\n) => {\n const { authConfig, debug } = props;\n const authConfigValue = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...authConfig,\n debug: !!debug,\n }),\n []\n );\n\n return (\n <AuthConfigContext.Provider value={authConfigValue}>\n <KeycloakProvider {...props} />\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from \"./keycloakProvider\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAQC,OAAO,QAAQ,OAAO;AAC1C,SAEEC,iBAAiB,EACjBC,iBAAiB;AAEnB,SAASC,gBAAgB;AAMzB,OAAO,MAAMC,YAAmC,GAC9CC,KAAwB,IACrB;EACH,MAAM;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGF,KAAK;EACnC,MAAMG,eAAe,GAAGR,OAAO,CAC7B,OAAO;IACL,GAAGE,iBAAiB;IACpB,GAAGI,UAAU;IACbC,KAAK,EAAE,CAAC,CAACA;EACX,CAAC,CAAC,EACF,EAAE,CACH;EAED,oBACE,oBAAC,iBAAiB,CAAC,QAAQ;IAAC,KAAK,EAAEC;EAAgB,gBACjD,oBAAC,gBAAgB,EAAKH,KAAK,CAAI,CACJ;AAEjC,CAAC;AAED"}
@@ -1,22 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _newArrowCheck from "@babel/runtime/helpers/newArrowCheck";
4
- var _this = this;
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- import "core-js/modules/es.function.bind.js";
8
- import "core-js/modules/es.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
1
  /**
21
2
  * File: /auth/provider/keycloakProvider.tsx
22
3
  * Project: app
@@ -50,134 +31,108 @@ import React, { useMemo, useEffect, useState } from "react";
50
31
  import { useAuthConfig } from "../hooks/useAuthConfig";
51
32
  import { useAuthState } from "../state";
52
33
  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);
34
+ const logger = console;
35
+ export const KeycloakProvider = _ref => {
36
+ var _query$token, _query$refreshToken;
37
+ let {
38
+ children,
39
+ cookies,
40
+ debug,
41
+ keycloakConfig,
42
+ keycloakInitOptions,
43
+ loadingComponent
44
+ } = _ref;
45
+ const [auth] = useAuthState();
46
+ const LoadingComponent = loadingComponent || (() => /*#__PURE__*/React.createElement(React.Fragment, null, debug ? "authenticating" : null));
47
+ const {
48
+ query
49
+ } = MultiPlatform.isNext() ? useRouter() : {
50
+ query: {}
51
+ };
52
+ const authConfig = useAuthConfig();
53
+ const [token, setToken] = useState("token" in query && (((_query$token = query.token) === null || _query$token === void 0 ? void 0 : _query$token.toString()) || true) || auth.token || false);
54
+ const [refreshToken, setRefreshToken] = useState("refreshToken" in query && (((_query$refreshToken = query.refreshToken) === null || _query$refreshToken === void 0 ? void 0 : _query$refreshToken.toString()) || true) || auth.refreshToken || false);
55
+ useEffect(() => {
56
+ var _window2, _window2$ReactNativeW, _window3, _window3$parent;
92
57
  if (token !== true && refreshToken !== true) return;
93
58
  if (debug) logger.debug("post message", {
94
59
  type: "LOADED"
95
60
  });
96
- (authConfig.messageHandlerKeys || []).forEach(function (key) {
61
+ (authConfig.messageHandlerKeys || []).forEach(key => {
97
62
  var _window, _window$webkit, _window$webkit$messag, _window$webkit$messag2;
98
- _newArrowCheck(this, _this3);
99
63
  (_window = window) === null || _window === void 0 ? void 0 : (_window$webkit = _window.webkit) === null || _window$webkit === void 0 ? void 0 : (_window$webkit$messag = _window$webkit.messageHandlers) === null || _window$webkit$messag === void 0 ? void 0 : (_window$webkit$messag2 = _window$webkit$messag[key]) === null || _window$webkit$messag2 === void 0 ? void 0 : _window$webkit$messag2.postMessage(JSON.stringify({
100
64
  type: "LOADED"
101
65
  }));
102
- }.bind(this));
66
+ });
103
67
  (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$ReactNativeW = _window2.ReactNativeWebView) === null || _window2$ReactNativeW === void 0 ? void 0 : _window2$ReactNativeW.postMessage(JSON.stringify({
104
68
  type: "LOADED"
105
69
  }));
106
70
  (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$parent = _window3.parent) === null || _window3$parent === void 0 ? void 0 : _window3$parent.postMessage(JSON.stringify({
107
71
  type: "LOADED"
108
72
  }));
109
- }.bind(this), []);
110
- useEffect(function () {
111
- var _this4 = this;
112
- _newArrowCheck(this, _this2);
73
+ }, []);
74
+ useEffect(() => {
113
75
  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;
76
+ const messageCallback = e => {
77
+ let data = e === null || e === void 0 ? void 0 : e.data;
117
78
  if (typeof data === "string") {
118
79
  try {
119
80
  data = JSON.parse(data);
120
81
  } catch (err) {}
121
82
  }
122
83
  if (debug) logger.debug("received message", data);
123
- var message = data;
84
+ const message = data;
124
85
  if (!message.type) return;
125
86
  if (message.type.toUpperCase() === "TOKEN" && message.payload) {
126
87
  if (debug) logger.debug("setting token", message.payload);
127
88
  setToken(message.payload);
128
89
  }
129
- }.bind(this);
90
+ };
130
91
  if (debug) logger.debug("listening for message", {
131
92
  type: "TOKEN",
132
93
  payload: "<some_token>"
133
94
  });
134
95
  window.addEventListener("message", messageCallback);
135
- return function () {
136
- _newArrowCheck(this, _this4);
96
+ return () => {
137
97
  window.removeEventListener("message", messageCallback);
138
- }.bind(this);
139
- }.bind(this), []);
140
- useEffect(function () {
141
- var _this5 = this;
142
- _newArrowCheck(this, _this2);
98
+ };
99
+ }, []);
100
+ useEffect(() => {
143
101
  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;
102
+ const messageCallback = e => {
103
+ let data = e === null || e === void 0 ? void 0 : e.data;
147
104
  if (typeof data === "string") {
148
105
  try {
149
106
  data = JSON.parse(data);
150
107
  } catch (err) {}
151
108
  }
152
109
  if (debug) logger.debug("received message", data);
153
- var message = data;
110
+ const message = data;
154
111
  if (!message.type) return;
155
112
  if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
156
113
  if (debug) logger.debug("setting refresh token", message.payload);
157
114
  setRefreshToken(message.payload);
158
115
  }
159
- }.bind(this);
116
+ };
160
117
  if (debug) logger.debug("listening for message", {
161
118
  type: "REFRESH_TOKEN",
162
119
  payload: "<some_refresh_token>"
163
120
  });
164
121
  window.addEventListener("message", messageCallback);
165
- return function () {
166
- _newArrowCheck(this, _this5);
122
+ return () => {
167
123
  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);
124
+ };
125
+ }, []);
126
+ const keycloak = useMemo(() => typeof window !== "undefined" && new Keycloak({
127
+ url: keycloakConfig.baseUrl,
128
+ realm: keycloakConfig.realm,
129
+ clientId: keycloakConfig.clientId
130
+ }), []);
131
+ const initOptions = useMemo(() => {
132
+ const initOptions = {
133
+ ...defaultKeycloakInitOptions,
134
+ ...keycloakInitOptions
135
+ };
181
136
  if (token && typeof token === "string") {
182
137
  initOptions.token = token;
183
138
  if (refreshToken && typeof refreshToken === "string") initOptions.refreshToken = refreshToken;
@@ -185,7 +140,7 @@ export var KeycloakProvider = function KeycloakProvider(_ref) {
185
140
  initOptions.onLoad = undefined;
186
141
  }
187
142
  return initOptions;
188
- }.bind(this), [keycloakInitOptions, token, refreshToken]);
143
+ }, [keycloakInitOptions, token, refreshToken]);
189
144
  if (token === true || refreshToken === true) return /*#__PURE__*/React.createElement(LoadingComponent, null);
190
145
  if (cookies && authConfig.ssr) {
191
146
  return (
@@ -209,8 +164,8 @@ export var KeycloakProvider = function KeycloakProvider(_ref) {
209
164
  authClient: keycloak,
210
165
  LoadingComponent: /*#__PURE__*/React.createElement(LoadingComponent, null)
211
166
  }, /*#__PURE__*/React.createElement(AfterAuth, null, children));
212
- }.bind(this);
213
- export var defaultKeycloakInitOptions = {
167
+ };
168
+ export const defaultKeycloakInitOptions = {
214
169
  checkLoginIframe: true,
215
170
  checkLoginIframeInterval: 5,
216
171
  enableLogging: false,
@@ -1 +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,IAA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1B;EACA,IAAI,CAACsC,QAAQ,EAAE,oBAAO,0CAAGtC,QAAQ,CAAI;EACrC,oBACE,oBAAC,qBAAqB;IACpB,WAAW,EAAE2C,WAAY;IACzB,UAAU,EAAEL,QAAS;IACrB,gBAAgB,eAAE,oBAAC,gBAAgB;EAAI,gBAEvC,oBAAC,SAAS,QAAEtC,QAAQ,CAAa,CACX;AAE5B,CAAC;AASD,OAAO,IAAM4C,0BAA+C,GAAG;EAC7DC,gBAAgB,EAAE,IAAI;EACtBI,wBAAwB,EAAE,CAAC;EAC3BC,aAAa,EAAE,KAAK;EACpBJ,MAAM,EAAE,WAAW;EACnBK,UAAU,EAAE;AACd,CAAC"}
1
+ {"version":3,"file":"keycloakProvider.js","names":["Keycloak","MultiPlatform","ReactKeycloakProvider","SSRKeycloakProvider","SSRCookies","useRouter","React","useMemo","useEffect","useState","useAuthConfig","useAuthState","AfterAuth","logger","console","KeycloakProvider","children","cookies","debug","keycloakConfig","keycloakInitOptions","loadingComponent","auth","LoadingComponent","query","isNext","authConfig","token","setToken","toString","refreshToken","setRefreshToken","type","messageHandlerKeys","forEach","key","window","webkit","messageHandlers","postMessage","JSON","stringify","ReactNativeWebView","parent","messageCallback","e","data","parse","err","message","toUpperCase","payload","addEventListener","removeEventListener","keycloak","url","baseUrl","realm","clientId","initOptions","defaultKeycloakInitOptions","checkLoginIframe","onLoad","undefined","ssr","checkLoginIframeInterval","enableLogging","pkceMethod"],"sources":["../../src/provider/keycloakProvider.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:43\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:07:46\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Keycloak, { KeycloakInitOptions } from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { ReactKeycloakProvider } from \"@react-keycloak/web\";\nimport { SSRKeycloakProvider, SSRCookies } from \"@react-keycloak/ssr\";\nimport { useRouter } from \"next/router\";\nimport React, {\n FC,\n ReactNode,\n useMemo,\n useEffect,\n useState,\n ComponentType,\n} from \"react\";\nimport { useAuthConfig } from \"../hooks/useAuthConfig\";\nimport { useAuthState } from \"../state\";\nimport { AfterAuth } from \"./afterAuth\";\n\nexport interface KeycloakProviderProps {\n children: ReactNode;\n cookies?: unknown;\n debug?: boolean;\n disabled?: boolean;\n keycloakConfig: KeycloakConfig;\n keycloakInitOptions?: KeycloakInitOptions;\n loadingComponent?: ComponentType;\n}\n\nconst logger = console;\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n cookies,\n debug,\n keycloakConfig,\n keycloakInitOptions,\n loadingComponent,\n}: KeycloakProviderProps) => {\n const [auth] = useAuthState();\n const LoadingComponent =\n loadingComponent || (() => <>{debug ? \"authenticating\" : null}</>);\n const { query } = MultiPlatform.isNext() ? useRouter() : { query: {} };\n const authConfig = useAuthConfig();\n const [token, setToken] = useState<string | boolean>(\n (\"token\" in query && (query.token?.toString() || true)) ||\n auth.token ||\n false\n );\n const [refreshToken, setRefreshToken] = useState<string | boolean>(\n (\"refreshToken\" in query && (query.refreshToken?.toString() || true)) ||\n auth.refreshToken ||\n false\n );\n\n useEffect(() => {\n if (token !== true && refreshToken !== true) return;\n if (debug) logger.debug(\"post message\", { type: \"LOADED\" });\n (authConfig.messageHandlerKeys || []).forEach((key: string) => {\n window?.webkit?.messageHandlers?.[key]?.postMessage(\n JSON.stringify({ type: \"LOADED\" })\n );\n });\n window?.ReactNativeWebView?.postMessage(JSON.stringify({ type: \"LOADED\" }));\n window?.parent?.postMessage(JSON.stringify({ type: \"LOADED\" }));\n }, []);\n\n useEffect(() => {\n if (token !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data;\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug(\"received message\", data);\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === \"TOKEN\" && message.payload) {\n if (debug) logger.debug(\"setting token\", message.payload);\n setToken(message.payload);\n }\n };\n if (debug)\n logger.debug(\"listening for message\", {\n type: \"TOKEN\",\n payload: \"<some_token>\",\n });\n window.addEventListener(\"message\", messageCallback);\n return () => {\n window.removeEventListener(\"message\", messageCallback);\n };\n }, []);\n\n useEffect(() => {\n if (refreshToken !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data;\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug(\"received message\", data);\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === \"REFRESH_TOKEN\" && message.payload) {\n if (debug) logger.debug(\"setting refresh token\", message.payload);\n setRefreshToken(message.payload);\n }\n };\n if (debug)\n logger.debug(\"listening for message\", {\n type: \"REFRESH_TOKEN\",\n payload: \"<some_refresh_token>\",\n });\n window.addEventListener(\"message\", messageCallback);\n return () => {\n window.removeEventListener(\"message\", messageCallback);\n };\n }, []);\n\n const keycloak = useMemo(\n () =>\n typeof window !== \"undefined\" &&\n new Keycloak({\n url: keycloakConfig.baseUrl,\n realm: keycloakConfig.realm,\n clientId: keycloakConfig.clientId,\n }),\n []\n );\n\n const initOptions = useMemo(() => {\n const initOptions = {\n ...defaultKeycloakInitOptions,\n ...keycloakInitOptions,\n };\n if (token && typeof token === \"string\") {\n initOptions.token = token;\n if (refreshToken && typeof refreshToken === \"string\")\n initOptions.refreshToken = refreshToken;\n initOptions.checkLoginIframe = false;\n initOptions.onLoad = undefined;\n }\n return initOptions;\n }, [keycloakInitOptions, token, refreshToken]);\n\n if (token === true || refreshToken === true) return <LoadingComponent />;\n if (cookies && authConfig.ssr) {\n return (\n // @ts-ignore\n <SSRKeycloakProvider\n initOptions={initOptions}\n keycloakConfig={{\n url: keycloakConfig.baseUrl,\n realm: keycloakConfig.realm,\n clientId: keycloakConfig.clientId,\n }}\n persistor={SSRCookies(cookies)}\n LoadingComponent={<LoadingComponent />}\n >\n <AfterAuth>{children}</AfterAuth>\n </SSRKeycloakProvider>\n );\n }\n if (!keycloak) return <>{children}</>;\n return (\n <ReactKeycloakProvider\n initOptions={initOptions}\n authClient={keycloak}\n LoadingComponent={<LoadingComponent />}\n >\n <AfterAuth>{children}</AfterAuth>\n </ReactKeycloakProvider>\n );\n};\n\nexport interface KeycloakConfig {\n clientId: string;\n realm: string;\n scheme?: string;\n baseUrl: string;\n}\n\nexport const defaultKeycloakInitOptions: KeycloakInitOptions = {\n checkLoginIframe: true,\n checkLoginIframeInterval: 5,\n enableLogging: false,\n onLoad: \"check-sso\",\n pkceMethod: \"S256\",\n};\n\nexport interface MessageSchema {\n type: string;\n payload?: string;\n}\n"],"mappings":"AAAA;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,MAAMC,MAAM,GAAGC,OAAO;AAEtB,OAAO,MAAMC,gBAA2C,GAAG,QAO9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AC,SAAS,QAAED,QAAQ,CAAa;IACb;EAE1B;EACA,IAAI,CAACsC,QAAQ,EAAE,oBAAO,0CAAGtC,QAAQ,CAAI;EACrC,oBACE,oBAAC,qBAAqB;IACpB,WAAW,EAAE2C,WAAY;IACzB,UAAU,EAAEL,QAAS;IACrB,gBAAgB,eAAE,oBAAC,gBAAgB;EAAI,gBAEvC,oBAAC,SAAS,QAAEtC,QAAQ,CAAa,CACX;AAE5B,CAAC;AASD,OAAO,MAAM4C,0BAA+C,GAAG;EAC7DC,gBAAgB,EAAE,IAAI;EACtBI,wBAAwB,EAAE,CAAC;EAC3BC,aAAa,EAAE,KAAK;EACpBJ,MAAM,EAAE,WAAW;EACnBK,UAAU,EAAE;AACd,CAAC"}
@@ -1,6 +1,3 @@
1
- import _newArrowCheck from "@babel/runtime/helpers/newArrowCheck";
2
- var _this = this;
3
- import "core-js/modules/es.function.bind.js";
4
1
  /**
5
2
  * File: /auth/provider/keycloakProvider.native.tsx
6
3
  * Project: app
@@ -25,16 +22,20 @@ import "core-js/modules/es.function.bind.js";
25
22
  * limitations under the License.
26
23
  */
27
24
 
28
- import { KeycloakProvider as ExpoKeycloakProvider } from "expo-keycloak-auth";
29
25
  import React from "react";
30
26
  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;
27
+ import { ExpoKeycloakProvider } from "../expo";
28
+ export const KeycloakProvider = _ref => {
29
+ let {
30
+ children,
31
+ keycloakConfig
32
+ } = _ref;
33
+ const clonedKeycloakConfig = {
34
+ ...keycloakConfig,
35
+ url: keycloakConfig.baseUrl
36
+ };
36
37
  // @ts-ignore
37
38
  delete keycloakConfig.baseUrl;
38
- return /*#__PURE__*/React.createElement(ExpoKeycloakProvider, keycloakConfig, /*#__PURE__*/React.createElement(AfterAuth, null, children));
39
- }.bind(this);
39
+ return /*#__PURE__*/React.createElement(ExpoKeycloakProvider, clonedKeycloakConfig, /*#__PURE__*/React.createElement(AfterAuth, null, children));
40
+ };
40
41
  //# sourceMappingURL=keycloakProvider.native.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"keycloakProvider.native.js","names":["React","AfterAuth","ExpoKeycloakProvider","KeycloakProvider","children","keycloakConfig","clonedKeycloakConfig","url","baseUrl"],"sources":["../../src/provider/keycloakProvider.native.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.native.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:37\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 17:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC } from \"react\";\nimport type { KeycloakProviderProps } from \"./keycloakProvider\";\nimport { AfterAuth } from \"./afterAuth\";\nimport { ExpoKeycloakProvider } from \"../expo\";\nimport { KeycloakConfig } from \"keycloak-js\";\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n keycloakConfig,\n}: KeycloakProviderProps) => {\n const clonedKeycloakConfig = {\n ...(keycloakConfig as Omit<KeycloakConfig, \"baseUrl\">),\n url: keycloakConfig.baseUrl,\n };\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return (\n <ExpoKeycloakProvider {...clonedKeycloakConfig}>\n <AfterAuth>{children}</AfterAuth>\n </ExpoKeycloakProvider>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAc,OAAO;AAEjC,SAASC,SAAS;AAClB,SAASC,oBAAoB;AAG7B,OAAO,MAAMC,gBAA2C,GAAG,QAG9B;EAAA,IAH+B;IAC1DC,QAAQ;IACRC;EACqB,CAAC;EACtB,MAAMC,oBAAoB,GAAG;IAC3B,GAAID,cAAkD;IACtDE,GAAG,EAAEF,cAAc,CAACG;EACtB,CAAC;EACD;EACA,OAAOH,cAAc,CAACG,OAAO;EAC7B,oBACE,oBAAC,oBAAoB,EAAKF,oBAAoB,eAC5C,oBAAC,SAAS,QAAEF,QAAQ,CAAa,CACZ;AAE3B,CAAC"}
@@ -27,9 +27,9 @@ import persist from "react-native-recoil-persist";
27
27
  export function useAuthState() {
28
28
  return useRecoilState(authState);
29
29
  }
30
- export var authState = atom({
30
+ export const authState = atom({
31
31
  key: "auth",
32
- "default": {},
32
+ default: {},
33
33
  effects: [persist.persistAtom]
34
34
  });
35
35
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","names":["atom","useRecoilState","persist","useAuthState","authState","key","default","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,MAAMA,SAAS,GAAGJ,IAAI,CAA4C;EACvEK,GAAG,EAAE,MAAM;EACXC,OAAO,EAAE,CAAC,CAAC;EACXC,OAAO,EAAE,CAACL,OAAO,CAACM,WAAW;AAC/B,CAAC,CAAC"}
@@ -1,18 +1,16 @@
1
- require("core-js/modules/esnext.global-this.js");
2
- require("core-js/modules/es.object.define-property.js");
3
1
  (function (global, factory) {
4
2
  if (typeof define === "function" && define.amd) {
5
- define(["exports", "core-js/modules/es.function.bind.js", "@babel/runtime/helpers/newArrowCheck", "react", "./hooks"], factory);
3
+ define(["exports", "react", "./hooks"], factory);
6
4
  } 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"));
5
+ factory(exports, require("react"), require("./hooks"));
8
6
  } else {
9
7
  var mod = {
10
8
  exports: {}
11
9
  };
12
- factory(mod.exports, global.esFunctionBind, global.newArrowCheck, global.react, global.hooks);
10
+ factory(mod.exports, global.react, global.hooks);
13
11
  global.Authenticated = mod.exports;
14
12
  }
15
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _esFunctionBind, _newArrowCheck2, _react, _hooks) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _hooks) {
16
14
  "use strict";
17
15
 
18
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -21,32 +19,46 @@ require("core-js/modules/es.object.define-property.js");
21
19
  });
22
20
  _exports.Authenticated = void 0;
23
21
  _exports.withAuthenticated = withAuthenticated;
24
- _newArrowCheck2 = _interopRequireDefault(_newArrowCheck2);
25
22
  _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);
23
+ /**
24
+ * File: /auth/Authenticated.tsx
25
+ * Project: app
26
+ * File Created: 08-11-2022 05:58:23
27
+ * Author: Clay Risser
28
+ * -----
29
+ * Last Modified: 22-11-2022 06:26:38
30
+ * Modified By: Clay Risser
31
+ * -----
32
+ * Risser Labs LLC (c) Copyright 2021 - 2022
33
+ *
34
+ * Licensed under the Apache License, Version 2.0 (the "License");
35
+ * you may not use this file except in compliance with the License.
36
+ * You may obtain a copy of the License at
37
+ *
38
+ * http://www.apache.org/licenses/LICENSE-2.0
39
+ *
40
+ * Unless required by applicable law or agreed to in writing, software
41
+ * distributed under the License is distributed on an "AS IS" BASIS,
42
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43
+ * See the License for the specific language governing permissions and
44
+ * limitations under the License.
45
+ */
46
+
47
+ const Authenticated = props => {
48
+ const {
49
+ authenticated
50
+ } = (0, _hooks.useKeycloak)();
51
+ const login = (0, _hooks.useLogin)(props.loginRoute);
33
52
  if (!props.disabled && !authenticated) {
34
53
  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);
54
+ const LoggedOutComponent = props.loggedOutComponent || (() => null);
55
+ return /*#__PURE__*/_react.default.createElement(LoggedOutComponent, null);
40
56
  }
41
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, props.children);
42
- }.bind(void 0);
57
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
58
+ };
43
59
  _exports.Authenticated = Authenticated;
44
60
  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);
61
+ return props => /*#__PURE__*/_react.default.createElement(Authenticated, null, /*#__PURE__*/_react.default.createElement(Component, props));
50
62
  }
51
63
  });
52
64
  //# sourceMappingURL=Authenticated.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"Authenticated.js","names":["Authenticated","props","authenticated","useKeycloak","login","useLogin","loginRoute","disabled","LoggedOutComponent","loggedOutComponent","children","withAuthenticated","Component"],"sources":["../src/Authenticated.tsx"],"sourcesContent":["/**\n * File: /auth/Authenticated.tsx\n * Project: app\n * File Created: 08-11-2022 05:58:23\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 06:26:38\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentType, FC, ReactNode } from \"react\";\nimport { useLogin, useKeycloak } from \"./hooks\";\n\nexport interface AuthenticatedProps {\n children: ReactNode;\n disabled?: boolean;\n loggedOutComponent?: ComponentType;\n loginRoute?: string;\n}\n\nexport const Authenticated: FC<AuthenticatedProps> = (\n props: AuthenticatedProps\n) => {\n const { authenticated } = useKeycloak();\n const login = useLogin(props.loginRoute);\n if (!props.disabled && !authenticated) {\n if (authenticated === false) login();\n const LoggedOutComponent = props.loggedOutComponent || (() => null);\n return <LoggedOutComponent />;\n }\n return <>{props.children}</>;\n};\n\nexport function withAuthenticated<P extends object>(\n Component: ComponentType<P>\n) {\n return (props: P) => (\n <Authenticated>\n <Component {...props} />\n </Authenticated>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAYO,MAAMA,aAAqC,GAChDC,KAAyB,IACtB;IACH,MAAM;MAAEC;IAAc,CAAC,GAAG,IAAAC,kBAAW,GAAE;IACvC,MAAMC,KAAK,GAAG,IAAAC,eAAQ,EAACJ,KAAK,CAACK,UAAU,CAAC;IACxC,IAAI,CAACL,KAAK,CAACM,QAAQ,IAAI,CAACL,aAAa,EAAE;MACrC,IAAIA,aAAa,KAAK,KAAK,EAAEE,KAAK,EAAE;MACpC,MAAMI,kBAAkB,GAAGP,KAAK,CAACQ,kBAAkB,KAAK,MAAM,IAAI,CAAC;MACnE,oBAAO,6BAAC,kBAAkB,OAAG;IAC/B;IACA,oBAAO,4DAAGR,KAAK,CAACS,QAAQ,CAAI;EAC9B,CAAC;EAAC;EAEK,SAASC,iBAAiB,CAC/BC,SAA2B,EAC3B;IACA,OAAQX,KAAQ,iBACd,6BAAC,aAAa,qBACZ,6BAAC,SAAS,EAAKA,KAAK,CAAI,CAE3B;EACH;AAAC"}
package/lib/authConfig.js CHANGED
@@ -1,5 +1,3 @@
1
- require("core-js/modules/esnext.global-this.js");
2
- require("core-js/modules/es.object.define-property.js");
3
1
  (function (global, factory) {
4
2
  if (typeof define === "function" && define.amd) {
5
3
  define(["exports", "react"], factory);
@@ -43,11 +41,11 @@ require("core-js/modules/es.object.define-property.js");
43
41
  * limitations under the License.
44
42
  */
45
43
 
46
- var defaultAuthConfig = {
44
+ const defaultAuthConfig = {
47
45
  ssr: true
48
46
  };
49
47
  _exports.defaultAuthConfig = defaultAuthConfig;
50
- var AuthConfigContext = /*#__PURE__*/(0, _react.createContext)(defaultAuthConfig);
48
+ const AuthConfigContext = /*#__PURE__*/(0, _react.createContext)(defaultAuthConfig);
51
49
  _exports.AuthConfigContext = AuthConfigContext;
52
50
  });
53
51
  //# sourceMappingURL=authConfig.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"authConfig.js","names":["defaultAuthConfig","ssr","AuthConfigContext","createContext"],"sources":["../src/authConfig.ts"],"sourcesContent":["/**\n * File: /src/authConfig.ts\n * Project: app\n * File Created: 08-11-2022 09:21:15\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:29:29\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContext } from \"react\";\n\nexport const defaultAuthConfig: AuthConfig = {\n ssr: true,\n};\n\nexport const AuthConfigContext = createContext<AuthConfig>(defaultAuthConfig);\n\nexport interface AuthConfig {\n debug?: boolean;\n loginRoute?: string;\n messageHandlerKeys?: string[];\n ssr?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAIO,MAAMA,iBAA6B,GAAG;IAC3CC,GAAG,EAAE;EACP,CAAC;EAAC;EAEK,MAAMC,iBAAiB,gBAAG,IAAAC,oBAAa,EAAaH,iBAAiB,CAAC;EAAC;AAAA"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * File: /src/expo/ExpoKeycloakContext.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 26-11-2022 06:58:16
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 26-11-2022 08:38: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
+ /// <reference types="react" />
25
+ import { AuthRequestPromptOptions, AuthSessionResult, TokenResponse } from "expo-auth-session";
26
+ export declare const ExpoKeycloakContext: import("react").Context<{
27
+ ready: boolean;
28
+ isLoggedIn?: boolean | undefined;
29
+ login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>;
30
+ logout: () => undefined;
31
+ token: TokenResponse | null;
32
+ }>;