@multiplatform.one/keycloak 0.1.10 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Authenticated.mjs +25 -0
- package/dist/esm/Authenticated.mjs.map +7 -0
- package/dist/esm/authConfig.mjs +10 -0
- package/dist/esm/authConfig.mjs.map +7 -0
- package/dist/esm/hooks/index.mjs +4 -0
- package/dist/esm/hooks/index.mjs.map +7 -0
- package/dist/esm/hooks/useAuthConfig.mjs +9 -0
- package/dist/esm/hooks/useAuthConfig.mjs.map +7 -0
- package/dist/esm/hooks/useCurrentRouteName/index.mjs +17 -0
- package/dist/esm/hooks/useCurrentRouteName/index.mjs.map +7 -0
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs +12 -0
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/index.mjs +2 -0
- package/dist/esm/hooks/useKeycloak/index.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs +81 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs +108 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs.map +7 -0
- package/dist/esm/hooks/useLogin.mjs +35 -0
- package/dist/esm/hooks/useLogin.mjs.map +7 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/provider/afterAuth.mjs +29 -0
- package/dist/esm/provider/afterAuth.mjs.map +7 -0
- package/dist/esm/provider/index.mjs +73 -0
- package/dist/esm/provider/index.mjs.map +7 -0
- package/dist/esm/provider/keycloakProvider.mjs +273 -0
- package/dist/esm/provider/keycloakProvider.mjs.map +7 -0
- package/dist/esm/provider/keycloakProvider.native.mjs +69 -0
- package/dist/esm/provider/keycloakProvider.native.mjs.map +7 -0
- package/dist/esm/state/index.mjs +14 -0
- package/dist/esm/state/index.mjs.map +7 -0
- package/dist/esm/types.mjs +5 -0
- package/dist/esm/types.mjs.map +7 -0
- package/dist/jsx/Authenticated.mjs +20 -0
- package/dist/jsx/Authenticated.mjs.map +7 -0
- package/dist/jsx/authConfig.mjs +10 -0
- package/dist/jsx/authConfig.mjs.map +7 -0
- package/dist/jsx/hooks/index.mjs +4 -0
- package/dist/jsx/hooks/index.mjs.map +7 -0
- package/dist/jsx/hooks/useAuthConfig.mjs +9 -0
- package/dist/jsx/hooks/useAuthConfig.mjs.map +7 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs +17 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs.map +7 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs +12 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/index.mjs +2 -0
- package/dist/jsx/hooks/useKeycloak/index.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs +25 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs +58 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs.map +7 -0
- package/dist/jsx/hooks/useLogin.mjs +33 -0
- package/dist/jsx/hooks/useLogin.mjs.map +7 -0
- package/dist/jsx/index.mjs +5 -0
- package/dist/jsx/index.mjs.map +7 -0
- package/dist/jsx/provider/afterAuth.mjs +28 -0
- package/dist/jsx/provider/afterAuth.mjs.map +7 -0
- package/dist/jsx/provider/index.mjs +20 -0
- package/dist/jsx/provider/index.mjs.map +7 -0
- package/dist/jsx/provider/keycloakProvider.mjs +158 -0
- package/dist/jsx/provider/keycloakProvider.mjs.map +7 -0
- package/dist/jsx/provider/keycloakProvider.native.mjs +14 -0
- package/dist/jsx/provider/keycloakProvider.native.mjs.map +7 -0
- package/dist/jsx/state/index.mjs +17 -0
- package/dist/jsx/state/index.mjs.map +7 -0
- package/dist/jsx/types.mjs +5 -0
- package/dist/jsx/types.mjs.map +7 -0
- package/{lib → dist/lib}/Authenticated.d.ts +1 -1
- package/dist/lib/Authenticated.js +60 -0
- package/dist/lib/Authenticated.js.map +7 -0
- package/dist/lib/authConfig.js +35 -0
- package/dist/lib/authConfig.js.map +7 -0
- package/{lib → dist/lib}/hooks/index.d.ts +3 -3
- package/dist/lib/hooks/index.js +27 -0
- package/dist/lib/hooks/index.js.map +7 -0
- package/dist/lib/hooks/useAuthConfig.js +33 -0
- package/dist/lib/hooks/useAuthConfig.js.map +7 -0
- package/{lib/hooks/useCurrentRouteName.d.ts → dist/lib/hooks/useCurrentRouteName/index.d.ts} +5 -5
- package/dist/lib/hooks/useCurrentRouteName/index.js +41 -0
- package/dist/lib/hooks/useCurrentRouteName/index.js.map +7 -0
- package/{esm/types.js → dist/lib/hooks/useCurrentRouteName/index.native.d.ts} +5 -7
- package/dist/lib/hooks/useCurrentRouteName/index.native.js +36 -0
- package/dist/lib/hooks/useCurrentRouteName/index.native.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/index.d.ts +11 -4
- package/dist/lib/hooks/useKeycloak/index.js +23 -0
- package/dist/lib/hooks/useKeycloak/index.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/useKeycloak.d.ts +2 -2
- package/dist/lib/hooks/useKeycloak/useKeycloak.js +63 -0
- package/dist/lib/hooks/useKeycloak/useKeycloak.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/useKeycloak.native.d.ts +4 -4
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js +93 -0
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js.map +7 -0
- package/{lib → dist/lib}/hooks/useLogin.d.ts +1 -1
- package/dist/lib/hooks/useLogin.js +57 -0
- package/dist/lib/hooks/useLogin.js.map +7 -0
- package/{lib → dist/lib}/index.d.ts +4 -4
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.js.map +7 -0
- package/{lib → dist/lib}/provider/afterAuth.d.ts +1 -1
- package/dist/lib/provider/afterAuth.js +53 -0
- package/dist/lib/provider/afterAuth.js.map +7 -0
- package/{lib → dist/lib}/provider/index.d.ts +4 -4
- package/dist/lib/provider/index.js +62 -0
- package/dist/lib/provider/index.js.map +7 -0
- package/{lib → dist/lib}/provider/keycloakProvider.d.ts +2 -2
- package/dist/lib/provider/keycloakProvider.js +212 -0
- package/dist/lib/provider/keycloakProvider.js.map +7 -0
- package/{lib → dist/lib}/provider/keycloakProvider.native.d.ts +2 -2
- package/dist/lib/provider/keycloakProvider.native.js +55 -0
- package/dist/lib/provider/keycloakProvider.native.js.map +7 -0
- package/{esm/state/index.js → dist/lib/state/index.d.ts} +8 -13
- package/dist/lib/state/index.js +41 -0
- package/dist/lib/state/index.js.map +7 -0
- package/dist/lib/tsconfig.build.tsbuildinfo +1 -0
- package/dist/lib/types.js +25 -0
- package/dist/lib/types.js.map +7 -0
- package/package.json +44 -63
- package/src/@types/coreJsPure.d.ts +2 -2
- package/src/@types/expoKeycloakAuth.d.ts +1 -1
- package/src/Authenticated.tsx +5 -8
- package/src/authConfig.ts +1 -1
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useAuthConfig.ts +2 -2
- package/{esm/hooks/useCurrentRouteName.js → src/hooks/useCurrentRouteName/index.native.ts} +8 -13
- package/src/hooks/{useCurrentRouteName.ts → useCurrentRouteName/index.ts} +8 -8
- package/src/hooks/useKeycloak/index.ts +12 -8
- package/src/hooks/useKeycloak/useKeycloak.native.ts +18 -32
- package/src/hooks/useKeycloak/useKeycloak.ts +7 -7
- package/src/hooks/useLogin.ts +7 -7
- package/src/index.ts +4 -4
- package/src/provider/afterAuth.tsx +10 -11
- package/src/provider/index.tsx +9 -12
- package/src/provider/keycloakProvider.native.tsx +8 -10
- package/src/provider/keycloakProvider.tsx +44 -61
- package/src/state/index.ts +13 -10
- package/esm/Authenticated.js +0 -42
- package/esm/Authenticated.js.map +0 -1
- package/esm/authConfig.js +0 -30
- package/esm/authConfig.js.map +0 -1
- package/esm/hooks/index.js +0 -28
- package/esm/hooks/index.js.map +0 -1
- package/esm/hooks/useAuthConfig.js +0 -30
- package/esm/hooks/useAuthConfig.js.map +0 -1
- package/esm/hooks/useCurrentRouteName.js.map +0 -1
- package/esm/hooks/useKeycloak/index.js +0 -27
- package/esm/hooks/useKeycloak/index.js.map +0 -1
- package/esm/hooks/useKeycloak/useKeycloak.js +0 -55
- package/esm/hooks/useKeycloak/useKeycloak.js.map +0 -1
- package/esm/hooks/useKeycloak/useKeycloak.native.js +0 -91
- package/esm/hooks/useKeycloak/useKeycloak.native.js.map +0 -1
- package/esm/hooks/useLogin.js +0 -50
- package/esm/hooks/useLogin.js.map +0 -1
- package/esm/index.js +0 -29
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
- package/esm/provider/afterAuth.js +0 -58
- package/esm/provider/afterAuth.js.map +0 -1
- package/esm/provider/index.js +0 -43
- package/esm/provider/index.js.map +0 -1
- package/esm/provider/keycloakProvider.js +0 -175
- package/esm/provider/keycloakProvider.js.map +0 -1
- package/esm/provider/keycloakProvider.native.js +0 -41
- package/esm/provider/keycloakProvider.native.js.map +0 -1
- package/esm/state/index.js.map +0 -1
- package/esm/types.js.map +0 -1
- package/lib/Authenticated.js +0 -64
- package/lib/Authenticated.js.map +0 -1
- package/lib/authConfig.js +0 -51
- package/lib/authConfig.js.map +0 -1
- package/lib/hooks/index.js +0 -50
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useAuthConfig.js +0 -48
- package/lib/hooks/useAuthConfig.js.map +0 -1
- package/lib/hooks/useCurrentRouteName.js +0 -54
- package/lib/hooks/useCurrentRouteName.js.map +0 -1
- package/lib/hooks/useKeycloak/index.js +0 -30
- package/lib/hooks/useKeycloak/index.js.map +0 -1
- package/lib/hooks/useKeycloak/useKeycloak.js +0 -71
- package/lib/hooks/useKeycloak/useKeycloak.js.map +0 -1
- package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -112
- package/lib/hooks/useKeycloak/useKeycloak.native.js.map +0 -1
- package/lib/hooks/useLogin.js +0 -65
- package/lib/hooks/useLogin.js.map +0 -1
- package/lib/index.js +0 -60
- package/lib/index.js.map +0 -1
- package/lib/package.json +0 -1
- package/lib/provider/afterAuth.js +0 -78
- package/lib/provider/afterAuth.js.map +0 -1
- package/lib/provider/index.js +0 -77
- package/lib/provider/index.js.map +0 -1
- package/lib/provider/keycloakProvider.js +0 -193
- package/lib/provider/keycloakProvider.js.map +0 -1
- package/lib/provider/keycloakProvider.native.js +0 -61
- package/lib/provider/keycloakProvider.native.js.map +0 -1
- package/lib/state/index.d.ts +0 -34
- package/lib/state/index.js +0 -55
- package/lib/state/index.js.map +0 -1
- package/lib/tsconfig.build.tsbuildinfo +0 -1
- package/lib/types.js +0 -46
- package/lib/types.js.map +0 -1
- /package/{lib → dist/lib}/authConfig.d.ts +0 -0
- /package/{lib → dist/lib}/hooks/useAuthConfig.d.ts +0 -0
- /package/{lib → dist/lib}/types.d.ts +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
function _typeof(obj) {
|
|
2
|
+
"@babel/helpers - typeof";
|
|
3
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
4
|
+
return typeof obj2;
|
|
5
|
+
} : function(obj2) {
|
|
6
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
7
|
+
}, _typeof(obj);
|
|
8
|
+
}
|
|
9
|
+
function ownKeys(object, enumerableOnly) {
|
|
10
|
+
var keys = Object.keys(object);
|
|
11
|
+
if (Object.getOwnPropertySymbols) {
|
|
12
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
13
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
14
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
15
|
+
})), keys.push.apply(keys, symbols);
|
|
16
|
+
}
|
|
17
|
+
return keys;
|
|
18
|
+
}
|
|
19
|
+
function _objectSpread(target) {
|
|
20
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
21
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
22
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
23
|
+
_defineProperty(target, key, source[key]);
|
|
24
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
25
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
function _defineProperty(obj, key, value) {
|
|
31
|
+
key = _toPropertyKey(key);
|
|
32
|
+
if (key in obj) {
|
|
33
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
34
|
+
} else {
|
|
35
|
+
obj[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
function _toPropertyKey(arg) {
|
|
40
|
+
var key = _toPrimitive(arg, "string");
|
|
41
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
42
|
+
}
|
|
43
|
+
function _toPrimitive(input, hint) {
|
|
44
|
+
if (_typeof(input) !== "object" || input === null)
|
|
45
|
+
return input;
|
|
46
|
+
var prim = input[Symbol.toPrimitive];
|
|
47
|
+
if (prim !== void 0) {
|
|
48
|
+
var res = prim.call(input, hint || "default");
|
|
49
|
+
if (_typeof(res) !== "object")
|
|
50
|
+
return res;
|
|
51
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
52
|
+
}
|
|
53
|
+
return (hint === "string" ? String : Number)(input);
|
|
54
|
+
}
|
|
55
|
+
function _slicedToArray(arr, i) {
|
|
56
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
57
|
+
}
|
|
58
|
+
function _nonIterableRest() {
|
|
59
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
60
|
+
}
|
|
61
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
62
|
+
if (!o)
|
|
63
|
+
return;
|
|
64
|
+
if (typeof o === "string")
|
|
65
|
+
return _arrayLikeToArray(o, minLen);
|
|
66
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
67
|
+
if (n === "Object" && o.constructor)
|
|
68
|
+
n = o.constructor.name;
|
|
69
|
+
if (n === "Map" || n === "Set")
|
|
70
|
+
return Array.from(o);
|
|
71
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
72
|
+
return _arrayLikeToArray(o, minLen);
|
|
73
|
+
}
|
|
74
|
+
function _arrayLikeToArray(arr, len) {
|
|
75
|
+
if (len == null || len > arr.length)
|
|
76
|
+
len = arr.length;
|
|
77
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
78
|
+
arr2[i] = arr[i];
|
|
79
|
+
return arr2;
|
|
80
|
+
}
|
|
81
|
+
function _iterableToArrayLimit(arr, i) {
|
|
82
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
83
|
+
if (null != _i) {
|
|
84
|
+
var _s, _e, _x, _r, _arr = [], _n = true, _d = false;
|
|
85
|
+
try {
|
|
86
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
87
|
+
if (Object(_i) !== _i)
|
|
88
|
+
return;
|
|
89
|
+
_n = false;
|
|
90
|
+
} else
|
|
91
|
+
for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = true)
|
|
92
|
+
;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
_d = true, _e = err;
|
|
95
|
+
} finally {
|
|
96
|
+
try {
|
|
97
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r))
|
|
98
|
+
return;
|
|
99
|
+
} finally {
|
|
100
|
+
if (_d)
|
|
101
|
+
throw _e;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return _arr;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function _arrayWithHoles(arr) {
|
|
108
|
+
if (Array.isArray(arr))
|
|
109
|
+
return arr;
|
|
110
|
+
}
|
|
111
|
+
import Keycloak from "keycloak-js";
|
|
112
|
+
import React, { useMemo, useEffect, useState } from "react";
|
|
113
|
+
import { AfterAuth } from "./afterAuth.mjs";
|
|
114
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
115
|
+
import { ReactKeycloakProvider } from "@react-keycloak/web";
|
|
116
|
+
import { SSRKeycloakProvider, SSRCookies } from "@react-keycloak/ssr";
|
|
117
|
+
import { useAuthConfig } from "../hooks/useAuthConfig.mjs";
|
|
118
|
+
import { useAuthState } from "../state/index.mjs";
|
|
119
|
+
import { useRouter } from "next/router";
|
|
120
|
+
var logger = console;
|
|
121
|
+
var KeycloakProvider = function KeycloakProvider2(_ref) {
|
|
122
|
+
var _query$token, _query$refreshToken;
|
|
123
|
+
var children = _ref.children, cookies = _ref.cookies, debug = _ref.debug, keycloakConfig = _ref.keycloakConfig, keycloakInitOptions = _ref.keycloakInitOptions, loadingComponent = _ref.loadingComponent;
|
|
124
|
+
var authState = useAuthState();
|
|
125
|
+
var LoadingComponent = loadingComponent || function() {
|
|
126
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, debug ? "authenticating" : null);
|
|
127
|
+
};
|
|
128
|
+
var _ref2 = MultiPlatform.isNext ? useRouter() : {
|
|
129
|
+
query: {}
|
|
130
|
+
}, query = _ref2.query;
|
|
131
|
+
var authConfig = useAuthConfig();
|
|
132
|
+
var _useState = useState("token" in query && (((_query$token = query.token) === null || _query$token === void 0 ? void 0 : _query$token.toString()) || true) || authState.token || false), _useState2 = _slicedToArray(_useState, 2), token = _useState2[0], setToken = _useState2[1];
|
|
133
|
+
var _useState3 = useState("refreshToken" in query && (((_query$refreshToken = query.refreshToken) === null || _query$refreshToken === void 0 ? void 0 : _query$refreshToken.toString()) || true) || authState.refreshToken || false), _useState4 = _slicedToArray(_useState3, 2), refreshToken = _useState4[0], setRefreshToken = _useState4[1];
|
|
134
|
+
useEffect(function() {
|
|
135
|
+
var _window2, _window2$ReactNativeW, _window3, _window3$parent;
|
|
136
|
+
if (token !== true && refreshToken !== true)
|
|
137
|
+
return;
|
|
138
|
+
if (debug)
|
|
139
|
+
logger.debug("post message", {
|
|
140
|
+
type: "LOADED"
|
|
141
|
+
});
|
|
142
|
+
(authConfig.messageHandlerKeys || []).forEach(function(key) {
|
|
143
|
+
var _window, _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
144
|
+
(_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({
|
|
145
|
+
type: "LOADED"
|
|
146
|
+
}));
|
|
147
|
+
});
|
|
148
|
+
(_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$ReactNativeW = _window2.ReactNativeWebView) === null || _window2$ReactNativeW === void 0 ? void 0 : _window2$ReactNativeW.postMessage(JSON.stringify({
|
|
149
|
+
type: "LOADED"
|
|
150
|
+
}));
|
|
151
|
+
(_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$parent = _window3.parent) === null || _window3$parent === void 0 ? void 0 : _window3$parent.postMessage(JSON.stringify({
|
|
152
|
+
type: "LOADED"
|
|
153
|
+
}));
|
|
154
|
+
}, []);
|
|
155
|
+
useEffect(function() {
|
|
156
|
+
if (token !== true)
|
|
157
|
+
return;
|
|
158
|
+
var messageCallback = function messageCallback2(e) {
|
|
159
|
+
var data = e === null || e === void 0 ? void 0 : e.data;
|
|
160
|
+
if (typeof data === "string") {
|
|
161
|
+
try {
|
|
162
|
+
data = JSON.parse(data);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (debug)
|
|
167
|
+
logger.debug("received message", data);
|
|
168
|
+
var message = data;
|
|
169
|
+
if (!message.type)
|
|
170
|
+
return;
|
|
171
|
+
if (message.type.toUpperCase() === "TOKEN" && message.payload) {
|
|
172
|
+
if (debug)
|
|
173
|
+
logger.debug("setting token", message.payload);
|
|
174
|
+
setToken(message.payload);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
if (debug)
|
|
178
|
+
logger.debug("listening for message", {
|
|
179
|
+
type: "TOKEN",
|
|
180
|
+
payload: "<some_token>"
|
|
181
|
+
});
|
|
182
|
+
window.addEventListener("message", messageCallback);
|
|
183
|
+
return function() {
|
|
184
|
+
window.removeEventListener("message", messageCallback);
|
|
185
|
+
};
|
|
186
|
+
}, []);
|
|
187
|
+
useEffect(function() {
|
|
188
|
+
if (refreshToken !== true)
|
|
189
|
+
return;
|
|
190
|
+
var messageCallback = function messageCallback2(e) {
|
|
191
|
+
var data = e === null || e === void 0 ? void 0 : e.data;
|
|
192
|
+
if (typeof data === "string") {
|
|
193
|
+
try {
|
|
194
|
+
data = JSON.parse(data);
|
|
195
|
+
} catch (err) {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (debug)
|
|
199
|
+
logger.debug("received message", data);
|
|
200
|
+
var message = data;
|
|
201
|
+
if (!message.type)
|
|
202
|
+
return;
|
|
203
|
+
if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
|
|
204
|
+
if (debug)
|
|
205
|
+
logger.debug("setting refresh token", message.payload);
|
|
206
|
+
setRefreshToken(message.payload);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
if (debug)
|
|
210
|
+
logger.debug("listening for message", {
|
|
211
|
+
type: "REFRESH_TOKEN",
|
|
212
|
+
payload: "<some_refresh_token>"
|
|
213
|
+
});
|
|
214
|
+
window.addEventListener("message", messageCallback);
|
|
215
|
+
return function() {
|
|
216
|
+
window.removeEventListener("message", messageCallback);
|
|
217
|
+
};
|
|
218
|
+
}, []);
|
|
219
|
+
var keycloak = useMemo(function() {
|
|
220
|
+
return typeof window !== "undefined" && new Keycloak({
|
|
221
|
+
url: keycloakConfig.baseUrl,
|
|
222
|
+
realm: keycloakConfig.realm,
|
|
223
|
+
clientId: keycloakConfig.clientId
|
|
224
|
+
});
|
|
225
|
+
}, []);
|
|
226
|
+
var initOptions = useMemo(function() {
|
|
227
|
+
var initOptions2 = _objectSpread(_objectSpread({}, defaultKeycloakInitOptions), keycloakInitOptions);
|
|
228
|
+
if (token && typeof token === "string") {
|
|
229
|
+
initOptions2.token = token;
|
|
230
|
+
if (refreshToken && typeof refreshToken === "string")
|
|
231
|
+
initOptions2.refreshToken = refreshToken;
|
|
232
|
+
initOptions2.checkLoginIframe = false;
|
|
233
|
+
initOptions2.onLoad = void 0;
|
|
234
|
+
}
|
|
235
|
+
return initOptions2;
|
|
236
|
+
}, [keycloakInitOptions, token, refreshToken]);
|
|
237
|
+
if (token === true || refreshToken === true)
|
|
238
|
+
return /* @__PURE__ */ React.createElement(LoadingComponent, null);
|
|
239
|
+
if (cookies && authConfig.ssr) {
|
|
240
|
+
return (
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
/* @__PURE__ */ React.createElement(SSRKeycloakProvider, {
|
|
243
|
+
initOptions,
|
|
244
|
+
keycloakConfig: {
|
|
245
|
+
url: keycloakConfig.baseUrl,
|
|
246
|
+
realm: keycloakConfig.realm,
|
|
247
|
+
clientId: keycloakConfig.clientId
|
|
248
|
+
},
|
|
249
|
+
persistor: SSRCookies(cookies),
|
|
250
|
+
LoadingComponent: /* @__PURE__ */ React.createElement(LoadingComponent, null)
|
|
251
|
+
}, /* @__PURE__ */ React.createElement(AfterAuth, null, children))
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
if (!keycloak)
|
|
255
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
256
|
+
return /* @__PURE__ */ React.createElement(ReactKeycloakProvider, {
|
|
257
|
+
initOptions,
|
|
258
|
+
authClient: keycloak,
|
|
259
|
+
LoadingComponent: /* @__PURE__ */ React.createElement(LoadingComponent, null)
|
|
260
|
+
}, /* @__PURE__ */ React.createElement(AfterAuth, null, children));
|
|
261
|
+
};
|
|
262
|
+
var defaultKeycloakInitOptions = {
|
|
263
|
+
checkLoginIframe: true,
|
|
264
|
+
checkLoginIframeInterval: 5,
|
|
265
|
+
enableLogging: false,
|
|
266
|
+
onLoad: "check-sso",
|
|
267
|
+
pkceMethod: "S256"
|
|
268
|
+
};
|
|
269
|
+
export {
|
|
270
|
+
KeycloakProvider,
|
|
271
|
+
defaultKeycloakInitOptions
|
|
272
|
+
};
|
|
273
|
+
//# sourceMappingURL=keycloakProvider.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/provider/keycloakProvider.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); }\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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i[\"return\"] && (_r = _i[\"return\"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n/**\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 from 'keycloak-js';\nimport React, { useMemo, useEffect, useState } from 'react';\nimport { AfterAuth } from \"./afterAuth.mjs\";\nimport { MultiPlatform } from 'multiplatform.one';\nimport { ReactKeycloakProvider } from '@react-keycloak/web';\nimport { SSRKeycloakProvider, SSRCookies } from '@react-keycloak/ssr';\nimport { useAuthConfig } from \"../hooks/useAuthConfig.mjs\";\nimport { useAuthState } from \"../state/index.mjs\";\nimport { useRouter } from 'next/router';\nvar logger = console;\nexport var KeycloakProvider = function KeycloakProvider(_ref) {\n var _query$token, _query$refreshToken;\n var children = _ref.children,\n cookies = _ref.cookies,\n debug = _ref.debug,\n keycloakConfig = _ref.keycloakConfig,\n keycloakInitOptions = _ref.keycloakInitOptions,\n loadingComponent = _ref.loadingComponent;\n var authState = useAuthState();\n var LoadingComponent = loadingComponent || function () {\n return /*#__PURE__*/React.createElement(React.Fragment, null, debug ? 'authenticating' : null);\n };\n var _ref2 = MultiPlatform.isNext ? useRouter() : {\n query: {}\n },\n query = _ref2.query;\n var authConfig = useAuthConfig();\n var _useState = useState('token' in query && (((_query$token = query.token) === null || _query$token === void 0 ? void 0 : _query$token.toString()) || true) || authState.token || false),\n _useState2 = _slicedToArray(_useState, 2),\n token = _useState2[0],\n setToken = _useState2[1];\n var _useState3 = useState('refreshToken' in query && (((_query$refreshToken = query.refreshToken) === null || _query$refreshToken === void 0 ? void 0 : _query$refreshToken.toString()) || true) || authState.refreshToken || false),\n _useState4 = _slicedToArray(_useState3, 2),\n refreshToken = _useState4[0],\n setRefreshToken = _useState4[1];\n useEffect(function () {\n var _window2, _window2$ReactNativeW, _window3, _window3$parent;\n if (token !== true && refreshToken !== true) return;\n if (debug) logger.debug('post message', {\n type: 'LOADED'\n });\n (authConfig.messageHandlerKeys || []).forEach(function (key) {\n var _window, _window$webkit, _window$webkit$messag, _window$webkit$messag2;\n (_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({\n type: 'LOADED'\n }));\n });\n (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$ReactNativeW = _window2.ReactNativeWebView) === null || _window2$ReactNativeW === void 0 ? void 0 : _window2$ReactNativeW.postMessage(JSON.stringify({\n type: 'LOADED'\n }));\n (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$parent = _window3.parent) === null || _window3$parent === void 0 ? void 0 : _window3$parent.postMessage(JSON.stringify({\n type: 'LOADED'\n }));\n }, []);\n useEffect(function () {\n if (token !== true) return;\n var messageCallback = function messageCallback(e) {\n var data = e === null || e === void 0 ? void 0 : 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 var message = 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) logger.debug('listening for message', {\n type: 'TOKEN',\n payload: '<some_token>'\n });\n window.addEventListener('message', messageCallback);\n return function () {\n window.removeEventListener('message', messageCallback);\n };\n }, []);\n useEffect(function () {\n if (refreshToken !== true) return;\n var messageCallback = function messageCallback(e) {\n var data = e === null || e === void 0 ? void 0 : 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 var message = 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) logger.debug('listening for message', {\n type: 'REFRESH_TOKEN',\n payload: '<some_refresh_token>'\n });\n window.addEventListener('message', messageCallback);\n return function () {\n window.removeEventListener('message', messageCallback);\n };\n }, []);\n var keycloak = useMemo(function () {\n return typeof window !== 'undefined' && new Keycloak({\n url: keycloakConfig.baseUrl,\n realm: keycloakConfig.realm,\n clientId: keycloakConfig.clientId\n });\n }, []);\n var initOptions = useMemo(function () {\n var initOptions = _objectSpread(_objectSpread({}, defaultKeycloakInitOptions), keycloakInitOptions);\n if (token && typeof token === 'string') {\n initOptions.token = token;\n if (refreshToken && typeof refreshToken === 'string') initOptions.refreshToken = refreshToken;\n initOptions.checkLoginIframe = false;\n initOptions.onLoad = undefined;\n }\n return initOptions;\n }, [keycloakInitOptions, token, refreshToken]);\n if (token === true || refreshToken === true) return /*#__PURE__*/React.createElement(LoadingComponent, null);\n if (cookies && authConfig.ssr) {\n return (\n /*#__PURE__*/\n // @ts-ignore\n React.createElement(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: /*#__PURE__*/React.createElement(LoadingComponent, null)\n }, /*#__PURE__*/React.createElement(AfterAuth, null, children))\n );\n }\n if (!keycloak) return /*#__PURE__*/React.createElement(React.Fragment, null, children);\n return /*#__PURE__*/React.createElement(ReactKeycloakProvider, {\n initOptions: initOptions,\n authClient: keycloak,\n LoadingComponent: /*#__PURE__*/React.createElement(LoadingComponent, null)\n }, /*#__PURE__*/React.createElement(AfterAuth, null, children));\n};\nexport var defaultKeycloakInitOptions = {\n checkLoginIframe: true,\n checkLoginIframeInterval: 5,\n enableLogging: false,\n onLoad: 'check-sso',\n pkceMethod: 'S256'\n};"],
|
|
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,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,C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ACO,IAAI,6BAA6B;AAAA,EACtC,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,YAAY;AACd;",
|
|
6
|
+
"names": ["obj", "KeycloakProvider", "messageCallback", "initOptions"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function _typeof(obj) {
|
|
2
|
+
"@babel/helpers - typeof";
|
|
3
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
4
|
+
return typeof obj2;
|
|
5
|
+
} : function(obj2) {
|
|
6
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
7
|
+
}, _typeof(obj);
|
|
8
|
+
}
|
|
9
|
+
function ownKeys(object, enumerableOnly) {
|
|
10
|
+
var keys = Object.keys(object);
|
|
11
|
+
if (Object.getOwnPropertySymbols) {
|
|
12
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
13
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
14
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
15
|
+
})), keys.push.apply(keys, symbols);
|
|
16
|
+
}
|
|
17
|
+
return keys;
|
|
18
|
+
}
|
|
19
|
+
function _objectSpread(target) {
|
|
20
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
21
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
22
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
23
|
+
_defineProperty(target, key, source[key]);
|
|
24
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
25
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
function _defineProperty(obj, key, value) {
|
|
31
|
+
key = _toPropertyKey(key);
|
|
32
|
+
if (key in obj) {
|
|
33
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
34
|
+
} else {
|
|
35
|
+
obj[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
function _toPropertyKey(arg) {
|
|
40
|
+
var key = _toPrimitive(arg, "string");
|
|
41
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
42
|
+
}
|
|
43
|
+
function _toPrimitive(input, hint) {
|
|
44
|
+
if (_typeof(input) !== "object" || input === null)
|
|
45
|
+
return input;
|
|
46
|
+
var prim = input[Symbol.toPrimitive];
|
|
47
|
+
if (prim !== void 0) {
|
|
48
|
+
var res = prim.call(input, hint || "default");
|
|
49
|
+
if (_typeof(res) !== "object")
|
|
50
|
+
return res;
|
|
51
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
52
|
+
}
|
|
53
|
+
return (hint === "string" ? String : Number)(input);
|
|
54
|
+
}
|
|
55
|
+
import React from "react";
|
|
56
|
+
import { AfterAuth } from "./afterAuth.mjs";
|
|
57
|
+
import { KeycloakProvider as ExpoKeycloakProvider } from "expo-keycloak-auth";
|
|
58
|
+
var KeycloakProvider = function KeycloakProvider2(_ref) {
|
|
59
|
+
var children = _ref.children, keycloakConfig = _ref.keycloakConfig;
|
|
60
|
+
var clonedKeycloakConfig = _objectSpread(_objectSpread({}, keycloakConfig), {}, {
|
|
61
|
+
url: keycloakConfig.baseUrl
|
|
62
|
+
});
|
|
63
|
+
delete keycloakConfig.baseUrl;
|
|
64
|
+
return /* @__PURE__ */ React.createElement(ExpoKeycloakProvider, clonedKeycloakConfig, /* @__PURE__ */ React.createElement(AfterAuth, null, children));
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
KeycloakProvider
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=keycloakProvider.native.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/provider/keycloakProvider.native.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); }\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); }\n/**\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 from 'react';\nimport { AfterAuth } from \"./afterAuth.mjs\";\nimport { KeycloakProvider as ExpoKeycloakProvider } from 'expo-keycloak-auth';\nexport var KeycloakProvider = function KeycloakProvider(_ref) {\n var children = _ref.children,\n keycloakConfig = _ref.keycloakConfig;\n var clonedKeycloakConfig = _objectSpread(_objectSpread({}, keycloakConfig), {}, {\n url: keycloakConfig.baseUrl\n });\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return /*#__PURE__*/React.createElement(ExpoKeycloakProvider, clonedKeycloakConfig, /*#__PURE__*/React.createElement(AfterAuth, null, children));\n};"],
|
|
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,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,QAA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UAAM,IAAI,UAAU,8CAA8C;AAAA,EAAG;AAAE,UAAQ,SAAS,WAAW,SAAS,QAAQ,KAAK;AAAG;AAyB5X,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB,4BAA4B;AAClD,IAAI,mBAAmB,SAASC,kBAAiB,MAAM;AAC5D,MAAI,WAAW,KAAK,UAClB,iBAAiB,KAAK;AACxB,MAAI,uBAAuB,cAAc,cAAc,CAAC,GAAG,cAAc,GAAG,CAAC,GAAG;AAAA,IAC9E,KAAK,eAAe;AAAA,EACtB,CAAC;AAED,SAAO,eAAe;AACtB,SAAoB,sBAAM,cAAc,sBAAsB,sBAAmC,sBAAM,cAAc,WAAW,MAAM,QAAQ,CAAC;AACjJ;",
|
|
6
|
+
"names": ["obj", "KeycloakProvider"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createStateStore } from "multiplatform.one/zustand";
|
|
2
|
+
var _createStateStore = createStateStore("auth", {
|
|
3
|
+
token: "",
|
|
4
|
+
refreshToken: ""
|
|
5
|
+
}, void 0, {
|
|
6
|
+
persist: true
|
|
7
|
+
}), useStore = _createStateStore.useStore;
|
|
8
|
+
function useAuthState() {
|
|
9
|
+
return useStore();
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
useAuthState
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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: 24-02-2023 06:26:51\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createStateStore } from 'multiplatform.one/zustand';\nvar _createStateStore = createStateStore('auth', {\n token: '',\n refreshToken: ''\n }, undefined, {\n persist: true\n }),\n useStore = _createStateStore.useStore;\nexport function useAuthState() {\n return useStore();\n}"],
|
|
5
|
+
"mappings": "AAwBA,SAAS,wBAAwB;AACjC,IAAI,oBAAoB,iBAAiB,QAAQ;AAAA,EAC7C,OAAO;AAAA,EACP,cAAc;AAChB,GAAG,QAAW;AAAA,EACZ,SAAS;AACX,CAAC,GACD,WAAW,kBAAkB;AACxB,SAAS,eAAe;AAC7B,SAAO,SAAS;AAClB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * File: /src/types.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 25-11-2022 10:27:53\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:28:25\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport default null;"],
|
|
5
|
+
"mappings": "AAwBA,IAAO,gBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLogin, useKeycloak } from "./hooks";
|
|
2
|
+
const Authenticated = (props) => {
|
|
3
|
+
const { authenticated } = useKeycloak();
|
|
4
|
+
const login = useLogin(props.loginRoute);
|
|
5
|
+
if (!props.disabled && !authenticated) {
|
|
6
|
+
if (authenticated === false)
|
|
7
|
+
login();
|
|
8
|
+
const LoggedOutComponent = props.loggedOutComponent || (() => null);
|
|
9
|
+
return <LoggedOutComponent />;
|
|
10
|
+
}
|
|
11
|
+
return <>{props.children}</>;
|
|
12
|
+
};
|
|
13
|
+
function withAuthenticated(Component) {
|
|
14
|
+
return (props) => <Authenticated><Component {...props} /></Authenticated>;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
Authenticated,
|
|
18
|
+
withAuthenticated
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=Authenticated.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 from 'react';\nimport type { 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> = (props: AuthenticatedProps) => {\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>(Component: ComponentType<P>) {\n return (props: P) => (\n <Authenticated>\n <Component {...props} />\n </Authenticated>\n );\n}\n"],
|
|
5
|
+
"mappings": "AA0BA,SAAS,UAAU,mBAAmB;AAS/B,MAAM,gBAAwC,CAAC,UAA8B;AAClF,QAAM,EAAE,cAAc,IAAI,YAAY;AACtC,QAAM,QAAQ,SAAS,MAAM,UAAU;AACvC,MAAI,CAAC,MAAM,YAAY,CAAC,eAAe;AACrC,QAAI,kBAAkB;AAAO,YAAM;AACnC,UAAM,qBAAqB,MAAM,uBAAuB,MAAM;AAC9D,WAAO,CAAC,mBAAmB;AAAA,EAC7B;AACA,SAAO,GAAG,MAAM,SAAS;AAC3B;AAEO,SAAS,kBAAoC,WAA6B;AAC/E,SAAO,CAAC,UACN,CAAC,cACC,CAAC,cAAc,OAAO,EACxB,EAFC;AAIL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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: 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"],
|
|
5
|
+
"mappings": "AAwBA,SAAS,qBAAqB;AAEvB,MAAM,oBAAgC;AAAA,EAC3C,KAAK;AACP;AAEO,MAAM,oBAAoB,cAA0B,iBAAiB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * File: /src/hooks/index.ts\n * Project: app\n * File Created: 08-11-2022 06:34:56\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 09:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './useCurrentRouteName';\nexport * from './useKeycloak';\nexport * from './useLogin';\n"],
|
|
5
|
+
"mappings": "AAwBA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useAuthConfig.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * File: /src/hooks/useAuthConfig.ts\n * Project: app\n * File Created: 08-11-2022 09:20:41\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 09:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useContext } from 'react';\nimport { AuthConfigContext } from '../authConfig';\n\nexport function useAuthConfig() {\n return useContext(AuthConfigContext);\n}\n"],
|
|
5
|
+
"mappings": "AAwBA,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAE3B,SAAS,gBAAgB;AAC9B,SAAO,WAAW,iBAAiB;AACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
+
import { useRoute } from "@react-navigation/native";
|
|
3
|
+
import { useRouter } from "next/router";
|
|
4
|
+
function useCurrentRouteName() {
|
|
5
|
+
if (MultiPlatform.isStorybook)
|
|
6
|
+
return null;
|
|
7
|
+
if (MultiPlatform.isNext) {
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
return router.route;
|
|
10
|
+
}
|
|
11
|
+
const route = useRoute();
|
|
12
|
+
return route.name;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
useCurrentRouteName
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/hooks/useCurrentRouteName/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * File: /src/hooks/useCurrentRouteName/index.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 24-02-2023 06:30:32\n * Author: Clay Risser\n * -----\n * Last Modified: 24-02-2023 06:30:54\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useRoute } from '@react-navigation/native';\nimport { useRouter } from 'next/router';\n\nexport function useCurrentRouteName() {\n if (MultiPlatform.isStorybook) return null;\n if (MultiPlatform.isNext) {\n const router = useRouter();\n return router.route;\n }\n const route = useRoute();\n return route.name;\n}\n"],
|
|
5
|
+
"mappings": "AAwBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAEnB,SAAS,sBAAsB;AACpC,MAAI,cAAc;AAAa,WAAO;AACtC,MAAI,cAAc,QAAQ;AACxB,UAAM,SAAS,UAAU;AACzB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,QAAQ,SAAS;AACvB,SAAO,MAAM;AACf;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
+
import { useRoute } from "@react-navigation/native";
|
|
3
|
+
function useCurrentRouteName() {
|
|
4
|
+
if (MultiPlatform.isStorybook)
|
|
5
|
+
return null;
|
|
6
|
+
const route = useRoute();
|
|
7
|
+
return route.name;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
useCurrentRouteName
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.native.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/hooks/useCurrentRouteName/index.native.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * File: /src/hooks/useCurrentRouteName/index.native.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 24-02-2023 06:30:36\n * Author: Clay Risser\n * -----\n * Last Modified: 24-02-2023 06:31:25\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useRoute } from '@react-navigation/native';\n\nexport function useCurrentRouteName() {\n if (MultiPlatform.isStorybook) return null;\n const route = useRoute();\n return route.name;\n}\n"],
|
|
5
|
+
"mappings": "AAwBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAElB,SAAS,sBAAsB;AACpC,MAAI,cAAc;AAAa,WAAO;AACtC,QAAM,QAAQ,SAAS;AACvB,SAAO,MAAM;AACf;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/hooks/useKeycloak/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 17-04-2023 19:14:28\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 type { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from 'keycloak-js';\nexport * from './useKeycloak';\n\nexport interface IKeycloak {\n authenticated?: boolean;\n realmAccess?: KeycloakRoles;\n refreshToken?: string;\n refreshTokenParsed?: KeycloakTokenParsed;\n resourceAccess?: KeycloakResourceAccess;\n subject?: string;\n token?: string;\n tokenParsed?: ITokenParsed;\n login: () => Promise<unknown> | unknown;\n logout: () => Promise<unknown> | unknown;\n}\n\nexport interface ITokenParsed extends KeycloakTokenParsed {\n 'allowed-origins'?: string[];\n email_verified?: boolean;\n preferred_username?: string;\n scope?: string;\n sid?: string;\n}\n"],
|
|
5
|
+
"mappings": "AAyBA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
+
import { useAuthConfig } from "../useAuthConfig";
|
|
3
|
+
import { useKeycloak as useReactKeycloak } from "@react-keycloak/web";
|
|
4
|
+
import { useKeycloak as useSsrKeycloak } from "@react-keycloak/ssr";
|
|
5
|
+
function useKeycloak() {
|
|
6
|
+
const authConfig = useAuthConfig();
|
|
7
|
+
if (MultiPlatform.isStorybook)
|
|
8
|
+
return { authenticated: true };
|
|
9
|
+
if (MultiPlatform.isNext && authConfig.ssr) {
|
|
10
|
+
const { keycloak: ssrKeycloak, initialized: initialized2 } = useSsrKeycloak();
|
|
11
|
+
const keycloak2 = { ...ssrKeycloak };
|
|
12
|
+
if (!initialized2)
|
|
13
|
+
keycloak2.authenticated = void 0;
|
|
14
|
+
return keycloak2;
|
|
15
|
+
}
|
|
16
|
+
const { keycloak: reactKeycloak, initialized } = useReactKeycloak();
|
|
17
|
+
const keycloak = { ...reactKeycloak };
|
|
18
|
+
if (!initialized)
|
|
19
|
+
keycloak.authenticated = void 0;
|
|
20
|
+
return keycloak;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
useKeycloak
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useKeycloak.mjs.map
|