versacall-core-library-react 2.0.65 → 2.0.67
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/components/CoreAlert/CoreAlert.js +43 -107
- package/dist/components/CoreAlert/index.js +2 -4
- package/dist/components/CoreAppBar/CoreAppBar.js +275 -418
- package/dist/components/CoreAppBar/CoreAppBarDrawer.js +88 -171
- package/dist/components/CoreAppBar/index.js +2 -4
- package/dist/components/CoreAppSelector/AppLink.js +36 -60
- package/dist/components/CoreAppSelector/CoreAppSelector.js +109 -200
- package/dist/components/CoreAppSelector/index.js +2 -4
- package/dist/components/CoreDialogueToolBar/CoreDialogueToolBar.js +43 -69
- package/dist/components/CoreDialogueToolBar/index.js +2 -4
- package/dist/components/CoreDrawer/CoreDrawer.js +168 -286
- package/dist/components/CoreDrawer/index.js +2 -4
- package/dist/components/CoreDropDownTextfield/CoreDropDownTextfield.js +57 -121
- package/dist/components/CoreDropDownTextfield/index.js +2 -4
- package/dist/components/CoreElapsedTime/CoreElapsedTime.js +38 -97
- package/dist/components/CoreElapsedTime/index.js +2 -4
- package/dist/components/CoreFrame/CoreFrame.js +17 -28
- package/dist/components/CoreFrame/index.js +2 -4
- package/dist/components/CoreImportDialog/CoreImportDialog.js +87 -189
- package/dist/components/CoreImportDialog/index.js +2 -4
- package/dist/components/CoreImportResultsDialog/CoreImportResultsDialog.js +19 -45
- package/dist/components/CoreImportResultsDialog/index.js +2 -4
- package/dist/components/CoreImporting/CoreImporting.js +23 -39
- package/dist/components/CoreImporting/index.js +2 -4
- package/dist/components/CorePlugin/CorePlugin.js +83 -160
- package/dist/components/CorePlugin/OldCorePlugin.js +73 -149
- package/dist/components/CorePlugin/index.js +2 -4
- package/dist/components/CoreSaveChangesDialog/CoreSaveChangesDialog.js +10 -32
- package/dist/components/CoreSaveChangesDialog/index.js +2 -4
- package/dist/components/CoreShiftTagFilter/CoreShiftTagFilter.js +288 -408
- package/dist/components/CoreShiftTagFilter/OldCoreShiftTagFilter.js +161 -257
- package/dist/components/CoreShiftTagFilter/index.js +2 -4
- package/dist/components/CoreSideBar/CoreSideBar.js +578 -737
- package/dist/components/CoreSideBar/CoreSideBarDrawer.js +122 -212
- package/dist/components/CoreSideBar/index.js +2 -4
- package/dist/components/CoreSnackBar/CoreSnackBar.js +76 -143
- package/dist/components/CoreSnackBar/index.js +2 -4
- package/dist/components/CoreTable/CoreTable.js +219 -337
- package/dist/components/CoreTable/CoreTableChips.js +11 -19
- package/dist/components/CoreTable/CoreTableHead.js +125 -205
- package/dist/components/CoreTable/CoreTableToolbar.js +34 -56
- package/dist/components/CoreTable/index.js +2 -4
- package/dist/components/CoreTagFilter/CoreTagFilter.js +212 -319
- package/dist/components/CoreTagFilter/OldCoreTagFilter.js +270 -402
- package/dist/components/CoreTagFilter/OldTagChip.js +10 -20
- package/dist/components/CoreTagFilter/OldTagFilterSelector.js +77 -148
- package/dist/components/CoreTagFilter/OldTagOption.js +21 -47
- package/dist/components/CoreTagFilter/TagFilterBuilder.js +114 -274
- package/dist/components/CoreTagFilter/index.js +2 -4
- package/dist/components/CoreTextField/CoreTextField.js +69 -132
- package/dist/components/CoreTextField/index.js +2 -4
- package/dist/components/CoreTheme/CoreTheme.js +13 -27
- package/dist/components/CoreTheme/index.js +2 -4
- package/dist/components/CoreTile/CoreTile.js +21 -34
- package/dist/components/CoreTile/CoreTileToolbar.js +21 -36
- package/dist/components/CoreTile/index.js +2 -4
- package/dist/components/CoreTimerInput/CoreTimerInput.js +36 -60
- package/dist/components/CoreTimerInput/CoreTimerInputOld.js +29 -47
- package/dist/components/CoreTimerInput/index.js +2 -4
- package/dist/components/CoreToolbar/CoreToolbar.js +65 -95
- package/dist/components/CoreToolbar/index.js +2 -4
- package/dist/components/CoreTracker/CoreTracker.js +32 -91
- package/dist/components/CoreTracker/index.js +2 -4
- package/dist/components/CoreTranslate/CoreTranslate.js +17 -48
- package/dist/components/CoreTranslate/index.js +2 -4
- package/dist/components/CoreTranslateWrapper/CoreTranslateWrapper.js +7 -15
- package/dist/components/CoreTranslateWrapper/index.js +2 -4
- package/dist/components/CoreWidget/CoreWidget.js +81 -149
- package/dist/components/CoreWidget/index.js +2 -4
- package/dist/components/CoreWrapper/CoreWrapper.js +8 -16
- package/dist/components/CoreWrapper/index.js +2 -4
- package/dist/components/index.js +29 -58
- package/dist/constants/index.js +3 -6
- package/dist/constants/testOrganization.js +2 -3
- package/dist/constants/testToken.js +2 -3
- package/dist/context/Authentication/AuthenticationContext.js +3 -8
- package/dist/context/Authentication/AuthenticationProvider.js +156 -257
- package/dist/context/Authentication/index.js +4 -8
- package/dist/context/Authentication/withAuthentication.js +5 -14
- package/dist/context/Channels/ChannelsConsumer.js +14 -70
- package/dist/context/Channels/ChannelsContext.js +3 -8
- package/dist/context/Channels/ChannelsProvider.js +132 -278
- package/dist/context/Channels/DataChannel.js +39 -103
- package/dist/context/Channels/EntityChannel.js +40 -104
- package/dist/context/Channels/EveryoneChannel.js +32 -92
- package/dist/context/Channels/OrganizationChannel.js +40 -104
- package/dist/context/Channels/UserChannel.js +37 -99
- package/dist/context/Channels/index.js +10 -20
- package/dist/context/Channels/withChannels.js +5 -14
- package/dist/context/Core/CoreContext.js +3 -8
- package/dist/context/Core/CoreProvider.js +68 -132
- package/dist/context/Core/index.js +4 -8
- package/dist/context/Core/withCore.js +5 -14
- package/dist/context/Organization/OrganizationContext.js +3 -8
- package/dist/context/Organization/OrganizationProvider.js +48 -120
- package/dist/context/Organization/index.js +4 -8
- package/dist/context/Organization/withOrganization.js +5 -14
- package/dist/context/Plugin/PluginContext.js +3 -8
- package/dist/context/Plugin/PluginProvider.js +55 -112
- package/dist/context/Plugin/index.js +4 -8
- package/dist/context/Plugin/withPlugin.js +5 -14
- package/dist/context/index.js +5 -15
- package/dist/css/index.js +3 -6
- package/dist/functions/TagEvaluator.js +107 -156
- package/dist/functions/compareObjects.js +0 -7
- package/dist/functions/formatElapsedTime.js +5 -6
- package/dist/functions/formatNameFileSafe.js +3 -4
- package/dist/functions/getIconUrl.js +0 -3
- package/dist/functions/getParameterByName.js +9 -12
- package/dist/functions/getProperty.js +4 -8
- package/dist/functions/getUrl.js +0 -3
- package/dist/functions/index.js +9 -18
- package/dist/icons/CopyIcon.js +11 -22
- package/dist/icons/DeleteIcon.js +11 -22
- package/dist/icons/DuplicateIcon.js +11 -22
- package/dist/icons/EditIcon.js +11 -22
- package/dist/icons/FabAddIcon.js +19 -35
- package/dist/icons/PasteIcon.js +11 -22
- package/dist/icons/index.js +7 -14
- package/dist/index.js +6 -18
- package/package.json +89 -79
|
@@ -1,318 +1,220 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
9
|
var _axios = _interopRequireDefault(require("axios"));
|
|
15
|
-
|
|
16
10
|
var _AuthenticationContext = _interopRequireDefault(require("./AuthenticationContext"));
|
|
17
|
-
|
|
18
11
|
var _functions = require("../../functions");
|
|
19
|
-
|
|
20
12
|
var _constants = require("../../constants");
|
|
21
|
-
|
|
22
13
|
var _Core = require("../Core");
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
-
|
|
32
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
33
|
-
|
|
34
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
35
|
-
|
|
36
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
37
|
-
|
|
38
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
-
|
|
40
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
41
|
-
|
|
42
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
43
|
-
|
|
44
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
-
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
|
-
|
|
48
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
-
|
|
50
|
-
var namespace = 'AuthenticationProvider';
|
|
51
|
-
var authenticationTokenLocalStorage = 'authenticationTokenLocalStorage';
|
|
52
|
-
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
const namespace = 'AuthenticationProvider';
|
|
18
|
+
const authenticationTokenLocalStorage = 'authenticationTokenLocalStorage';
|
|
53
19
|
function getToken() {
|
|
54
|
-
|
|
20
|
+
const token = localStorage.getItem(authenticationTokenLocalStorage);
|
|
55
21
|
return token ? JSON.parse(token) : null;
|
|
56
22
|
}
|
|
57
|
-
|
|
58
23
|
function setToken(token) {
|
|
59
24
|
localStorage.setItem(authenticationTokenLocalStorage, JSON.stringify(token));
|
|
60
25
|
}
|
|
61
|
-
|
|
62
26
|
function deleteToken() {
|
|
63
27
|
localStorage.removeItem(authenticationTokenLocalStorage);
|
|
64
28
|
}
|
|
65
|
-
|
|
66
29
|
function compareTokens(tr1, tr2) {
|
|
67
30
|
if (tr1 === null || tr2 === null) {
|
|
68
31
|
return tr1 === tr2;
|
|
69
32
|
}
|
|
70
|
-
|
|
71
33
|
return tr1.id === tr2.id;
|
|
72
34
|
}
|
|
73
|
-
|
|
74
|
-
function _checkRight(right, value) {
|
|
35
|
+
function checkRight(right, value) {
|
|
75
36
|
if (right !== undefined) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return x === value;
|
|
79
|
-
});
|
|
80
|
-
|
|
37
|
+
const valuesArray = right.split('-');
|
|
38
|
+
const found = valuesArray.find(x => x === value);
|
|
81
39
|
if (found !== undefined) {
|
|
82
40
|
return true;
|
|
83
41
|
}
|
|
84
42
|
}
|
|
85
|
-
|
|
86
43
|
return false;
|
|
87
44
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var _super = _createSuper(AuthenticationProvider);
|
|
93
|
-
|
|
94
|
-
function AuthenticationProvider(props) {
|
|
95
|
-
var _this;
|
|
96
|
-
|
|
97
|
-
_classCallCheck(this, AuthenticationProvider);
|
|
98
|
-
|
|
99
|
-
_this = _super.call(this, props);
|
|
100
|
-
_this.state = {
|
|
45
|
+
class AuthenticationProvider extends _react.Component {
|
|
46
|
+
constructor(props) {
|
|
47
|
+
super(props);
|
|
48
|
+
this.state = {
|
|
101
49
|
authenticated: false,
|
|
102
|
-
token: null
|
|
50
|
+
token: null,
|
|
51
|
+
apiKey: null
|
|
103
52
|
};
|
|
104
|
-
|
|
105
53
|
if (props.test) {
|
|
106
|
-
|
|
107
|
-
|
|
54
|
+
this.state.authenticated = true;
|
|
55
|
+
this.state.token = _constants.testToken;
|
|
108
56
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
57
|
+
const token = getToken();
|
|
58
|
+
const apiKey = (0, _functions.getParameterByName)('apiKey');
|
|
111
59
|
if (token !== null) {
|
|
112
|
-
|
|
113
|
-
|
|
60
|
+
this.state.authenticated = true;
|
|
61
|
+
this.state.token = token;
|
|
114
62
|
} else if (process.env.NODE_ENV === 'development') {
|
|
115
|
-
|
|
116
|
-
|
|
63
|
+
let param = (0, _functions.getParameterByName)('authentication');
|
|
117
64
|
if (param !== null && param !== undefined && param.length > 0) {
|
|
118
65
|
param = JSON.parse(param.replace(/%22/g, '"').replace(/%20/g, ' '));
|
|
119
|
-
|
|
120
|
-
|
|
66
|
+
this.state.authenticated = param.authenticated;
|
|
67
|
+
this.state.token = param.token;
|
|
121
68
|
}
|
|
69
|
+
} else if (apiKey && apiKey.length > 0) {
|
|
70
|
+
this.state.apiKey = apiKey;
|
|
71
|
+
// TODO - Make call to get token from Api Key...
|
|
122
72
|
} else {
|
|
123
|
-
|
|
73
|
+
this.redirectToLogin();
|
|
124
74
|
}
|
|
125
75
|
}
|
|
126
|
-
|
|
127
|
-
return _this;
|
|
128
76
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
77
|
+
componentDidMount() {
|
|
78
|
+
this.onReceiveMessageBinded = this.onReceiveMessage.bind(this);
|
|
79
|
+
this.onLocalStorageChangeBinded = this.onLocalStorageChange.bind(this);
|
|
80
|
+
window.addEventListener('message', this.onReceiveMessageBinded);
|
|
81
|
+
window.addEventListener('storage', this.onLocalStorageChangeBinded);
|
|
82
|
+
}
|
|
83
|
+
componentWillUnmount() {
|
|
84
|
+
window.removeEventListener('message', this.onReceiveMessageBinded);
|
|
85
|
+
window.removeEventListener('storage', this.onLocalStorageChangeBinded);
|
|
86
|
+
}
|
|
87
|
+
onReceiveMessage(event) {
|
|
88
|
+
if (event.data && event.data.shellAuthentication) {
|
|
89
|
+
this.setState({
|
|
90
|
+
authenticated: event.data.shellAuthentication.authenticated,
|
|
91
|
+
token: event.data.shellAuthentication.token
|
|
92
|
+
});
|
|
143
93
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
94
|
+
}
|
|
95
|
+
onLocalStorageChange(event) {
|
|
96
|
+
if (event.key === authenticationTokenLocalStorage) {
|
|
97
|
+
const value = event.newValue;
|
|
98
|
+
// console.log('authentication changed', value);
|
|
99
|
+
if (value) {
|
|
148
100
|
this.setState({
|
|
149
|
-
authenticated:
|
|
150
|
-
token:
|
|
101
|
+
authenticated: true,
|
|
102
|
+
token: JSON.parse(value)
|
|
151
103
|
});
|
|
104
|
+
} else {
|
|
105
|
+
// this.setState({ authenticated: false, token: null });
|
|
106
|
+
this.logout();
|
|
152
107
|
}
|
|
153
108
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.setState({
|
|
162
|
-
authenticated: true,
|
|
163
|
-
token: JSON.parse(value)
|
|
164
|
-
});
|
|
165
|
-
} else {
|
|
166
|
-
// this.setState({ authenticated: false, token: null });
|
|
167
|
-
this.logout();
|
|
168
|
-
}
|
|
109
|
+
}
|
|
110
|
+
getRight(objectId, key) {
|
|
111
|
+
if (this.state.token !== null && this.state.token.permissions !== undefined) {
|
|
112
|
+
const permission = this.state.token.permissions.find(x => x.objectIds.indexOf(objectId) > -1);
|
|
113
|
+
if (permission !== undefined) {
|
|
114
|
+
const right = permission.rights[key];
|
|
115
|
+
return right;
|
|
169
116
|
}
|
|
170
117
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
didChange(prevContext) {
|
|
121
|
+
// NOTE: Might also need to check apiKey...
|
|
122
|
+
return !compareTokens(this.state.token, prevContext.token);
|
|
123
|
+
}
|
|
124
|
+
logout() {
|
|
125
|
+
this.setState({
|
|
126
|
+
authenticated: false,
|
|
127
|
+
token: null
|
|
128
|
+
});
|
|
129
|
+
deleteToken();
|
|
130
|
+
this.redirectToLogin();
|
|
131
|
+
}
|
|
132
|
+
http(configuration) {
|
|
133
|
+
const methodName = 'http()';
|
|
134
|
+
if (!this.state.authenticated) {
|
|
135
|
+
return Promise.reject(new Error({
|
|
136
|
+
response: {
|
|
137
|
+
status: 401
|
|
182
138
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return undefined;
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
key: "didChange",
|
|
189
|
-
value: function didChange(prevContext) {
|
|
190
|
-
return !compareTokens(this.state.token, prevContext.token);
|
|
139
|
+
}));
|
|
191
140
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.setState({
|
|
196
|
-
authenticated: false,
|
|
197
|
-
token: null
|
|
198
|
-
});
|
|
199
|
-
deleteToken();
|
|
200
|
-
this.redirectToLogin();
|
|
201
|
-
}
|
|
202
|
-
}, {
|
|
203
|
-
key: "http",
|
|
204
|
-
value: function http(configuration) {
|
|
205
|
-
var _this2 = this;
|
|
206
|
-
|
|
207
|
-
var methodName = 'http()';
|
|
208
|
-
|
|
209
|
-
if (!this.state.authenticated) {
|
|
210
|
-
return Promise.reject(new Error({
|
|
211
|
-
response: {
|
|
212
|
-
status: 401
|
|
213
|
-
}
|
|
214
|
-
}));
|
|
141
|
+
let configurationCombined = Object.assign(configuration, {
|
|
142
|
+
headers: {
|
|
143
|
+
Authorization: "Bearer ".concat(this.state.token.token)
|
|
215
144
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
145
|
+
});
|
|
146
|
+
// NOTE: If we have an ApiKey, might want to include a "X-API-Key" header...
|
|
147
|
+
if (this.state.apiKey) {
|
|
148
|
+
configurationCombined.headers['X-API-Key'] = this.state.apiKey;
|
|
149
|
+
}
|
|
150
|
+
return new Promise((resolve, reject) => {
|
|
151
|
+
(0, _axios.default)(configurationCombined).then(results => {
|
|
152
|
+
resolve(results);
|
|
153
|
+
}).catch(error => {
|
|
154
|
+
if (error.response !== undefined && error.response.status === 401) {
|
|
155
|
+
this.props.core.log('debug', namespace, methodName, 'Attempting to Renew Token');
|
|
156
|
+
_axios.default.post("".concat(this.props.core.urlServer, "/api/authentication/renew"), JSON.stringify(this.state.token.token), {
|
|
157
|
+
headers: {
|
|
158
|
+
'Content-Type': 'application/json'
|
|
159
|
+
}
|
|
160
|
+
}).then(results => {
|
|
161
|
+
setToken(results.data);
|
|
162
|
+
this.setState({
|
|
163
|
+
authenticated: true,
|
|
164
|
+
token: results.data
|
|
165
|
+
});
|
|
166
|
+
configurationCombined = Object.assign(configuration, {
|
|
230
167
|
headers: {
|
|
231
|
-
|
|
168
|
+
Authorization: "Bearer ".concat(results.data.token)
|
|
232
169
|
}
|
|
233
|
-
}).then(function (results) {
|
|
234
|
-
setToken(results.data);
|
|
235
|
-
|
|
236
|
-
_this2.setState({
|
|
237
|
-
authenticated: true,
|
|
238
|
-
token: results.data
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
configurationCombined = Object.assign(configuration, {
|
|
242
|
-
headers: {
|
|
243
|
-
Authorization: "Bearer ".concat(results.data.token)
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
(0, _axios.default)(configurationCombined).then(function (resultsSecond) {
|
|
247
|
-
resolve(resultsSecond);
|
|
248
|
-
}).catch(function (errorSecond) {
|
|
249
|
-
_this2.props.core.log('warning', namespace, 'Second error', errorSecond);
|
|
250
|
-
|
|
251
|
-
reject(errorSecond);
|
|
252
|
-
});
|
|
253
|
-
}).catch(function (errorRenew) {
|
|
254
|
-
_this2.props.core.log('warning', namespace, 'Renew Error', errorRenew);
|
|
255
|
-
|
|
256
|
-
_this2.logout();
|
|
257
170
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}, {
|
|
271
|
-
key: "redirectToLogin",
|
|
272
|
-
value: function redirectToLogin() {
|
|
273
|
-
window.location = "".concat(this.props.core.baseUrl, "/login?redirect=").concat(window.location);
|
|
274
|
-
}
|
|
275
|
-
}, {
|
|
276
|
-
key: "render",
|
|
277
|
-
value: function render() {
|
|
278
|
-
var _this3 = this;
|
|
279
|
-
|
|
280
|
-
var _this$state = this.state,
|
|
281
|
-
authenticated = _this$state.authenticated,
|
|
282
|
-
token = _this$state.token;
|
|
283
|
-
return /*#__PURE__*/_react.default.createElement(_AuthenticationContext.default.Provider, {
|
|
284
|
-
value: {
|
|
285
|
-
authenticated: authenticated,
|
|
286
|
-
token: token,
|
|
287
|
-
logout: function logout() {
|
|
288
|
-
return _this3.logout();
|
|
289
|
-
},
|
|
290
|
-
http: function http(config) {
|
|
291
|
-
return _this3.http(config);
|
|
292
|
-
},
|
|
293
|
-
httpRequest: function httpRequest(config) {
|
|
294
|
-
return _this3.http(config);
|
|
295
|
-
},
|
|
296
|
-
didChange: function didChange(prevContext) {
|
|
297
|
-
return _this3.didChange(prevContext);
|
|
298
|
-
},
|
|
299
|
-
checkRight: function checkRight(right, value) {
|
|
300
|
-
return _checkRight(right, value);
|
|
301
|
-
},
|
|
302
|
-
getRight: function getRight(objectId, key) {
|
|
303
|
-
return _this3.getRight(objectId, key);
|
|
304
|
-
},
|
|
305
|
-
checkPermission: function checkPermission(objectId, key, value) {
|
|
306
|
-
return _this3.checkPermission(objectId, key, value);
|
|
307
|
-
}
|
|
171
|
+
(0, _axios.default)(configurationCombined).then(resultsSecond => {
|
|
172
|
+
resolve(resultsSecond);
|
|
173
|
+
}).catch(errorSecond => {
|
|
174
|
+
this.props.core.log('warning', namespace, 'Second error', errorSecond);
|
|
175
|
+
reject(errorSecond);
|
|
176
|
+
});
|
|
177
|
+
}).catch(errorRenew => {
|
|
178
|
+
this.props.core.log('warning', namespace, 'Renew Error', errorRenew);
|
|
179
|
+
this.logout();
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
reject(error);
|
|
308
183
|
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
checkPermission(objectId, key, value) {
|
|
188
|
+
const right = this.getRight(objectId, key);
|
|
189
|
+
return checkRight(right, value);
|
|
190
|
+
}
|
|
191
|
+
redirectToLogin() {
|
|
192
|
+
// Need to encode the redirect URL since we are passing it as a parameter
|
|
193
|
+
const redirect = encodeURIComponent(window.location);
|
|
194
|
+
window.location = "".concat(this.props.core.baseUrl, "/login?redirect=").concat(redirect);
|
|
195
|
+
}
|
|
196
|
+
render() {
|
|
197
|
+
const {
|
|
198
|
+
authenticated,
|
|
199
|
+
token,
|
|
200
|
+
apiKey
|
|
201
|
+
} = this.state;
|
|
202
|
+
return /*#__PURE__*/_react.default.createElement(_AuthenticationContext.default.Provider, {
|
|
203
|
+
value: {
|
|
204
|
+
authenticated: authenticated,
|
|
205
|
+
token: token,
|
|
206
|
+
apiKey: apiKey,
|
|
207
|
+
logout: () => this.logout(),
|
|
208
|
+
http: config => this.http(config),
|
|
209
|
+
httpRequest: config => this.http(config),
|
|
210
|
+
didChange: prevContext => this.didChange(prevContext),
|
|
211
|
+
checkRight: (right, value) => checkRight(right, value),
|
|
212
|
+
getRight: (objectId, key) => this.getRight(objectId, key),
|
|
213
|
+
checkPermission: (objectId, key, value) => this.checkPermission(objectId, key, value)
|
|
214
|
+
}
|
|
215
|
+
}, authenticated && this.props.children);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
316
218
|
AuthenticationProvider.propTypes = {
|
|
317
219
|
test: _propTypes.default.bool,
|
|
318
220
|
core: _propTypes.default.shape().isRequired,
|
|
@@ -321,7 +223,4 @@ AuthenticationProvider.propTypes = {
|
|
|
321
223
|
AuthenticationProvider.defaultProps = {
|
|
322
224
|
test: false
|
|
323
225
|
};
|
|
324
|
-
|
|
325
|
-
var _default = (0, _Core.withCore)(AuthenticationProvider);
|
|
326
|
-
|
|
327
|
-
exports.default = _default;
|
|
226
|
+
var _default = exports.default = (0, _Core.withCore)(AuthenticationProvider);
|
|
@@ -5,27 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "AuthenticationContext", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _AuthenticationContext.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "AuthenticationProvider", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _AuthenticationProvider.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "withAuthentication", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _withAuthentication.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
25
24
|
var _AuthenticationProvider = _interopRequireDefault(require("./AuthenticationProvider"));
|
|
26
|
-
|
|
27
25
|
var _AuthenticationContext = _interopRequireDefault(require("./AuthenticationContext"));
|
|
28
|
-
|
|
29
26
|
var _withAuthentication = _interopRequireDefault(require("./withAuthentication"));
|
|
30
|
-
|
|
31
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -4,21 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = withAuthentication;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _AuthenticationContext = _interopRequireDefault(require("./AuthenticationContext"));
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16
11
|
function withAuthentication(Component) {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
authentication: authentication
|
|
21
|
-
}));
|
|
22
|
-
});
|
|
23
|
-
};
|
|
12
|
+
return props => /*#__PURE__*/_react.default.createElement(_AuthenticationContext.default.Consumer, null, authentication => /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
|
|
13
|
+
authentication: authentication
|
|
14
|
+
})));
|
|
24
15
|
}
|
|
@@ -1,83 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
9
|
var _OrganizationChannel = _interopRequireDefault(require("./OrganizationChannel"));
|
|
15
|
-
|
|
16
10
|
var _EveryoneChannel = _interopRequireDefault(require("./EveryoneChannel"));
|
|
17
|
-
|
|
18
11
|
var _EntityChannel = _interopRequireDefault(require("./EntityChannel"));
|
|
19
|
-
|
|
20
12
|
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
21
|
-
|
|
22
13
|
var _UserChannel = _interopRequireDefault(require("./UserChannel"));
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
-
|
|
32
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
33
|
-
|
|
34
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
35
|
-
|
|
36
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
37
|
-
|
|
38
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
-
|
|
40
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
41
|
-
|
|
42
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
43
|
-
|
|
44
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
-
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
|
-
|
|
48
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
-
|
|
50
|
-
var ChannelsConsumer = /*#__PURE__*/function (_Component) {
|
|
51
|
-
_inherits(ChannelsConsumer, _Component);
|
|
52
|
-
|
|
53
|
-
var _super = _createSuper(ChannelsConsumer);
|
|
54
|
-
|
|
55
|
-
function ChannelsConsumer() {
|
|
56
|
-
_classCallCheck(this, ChannelsConsumer);
|
|
57
|
-
|
|
58
|
-
return _super.apply(this, arguments);
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
class ChannelsConsumer extends _react.Component {
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
this.props.channels.registerHandlers(this.props.id, this.props.handler, this.props.connectionChanged, this.props.subscribing);
|
|
59
20
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
key: "componentWillUnmount",
|
|
68
|
-
value: function componentWillUnmount() {
|
|
69
|
-
this.props.channels.unregisterHandlers(this.props.id);
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "render",
|
|
73
|
-
value: function render() {
|
|
74
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.props.addDefaultChannels && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EveryoneChannel.default, null), /*#__PURE__*/_react.default.createElement(_UserChannel.default, null), /*#__PURE__*/_react.default.createElement(_OrganizationChannel.default, null), /*#__PURE__*/_react.default.createElement(_EntityChannel.default, null)), this.props.children);
|
|
75
|
-
}
|
|
76
|
-
}]);
|
|
77
|
-
|
|
78
|
-
return ChannelsConsumer;
|
|
79
|
-
}(_react.Component);
|
|
80
|
-
|
|
21
|
+
componentWillUnmount() {
|
|
22
|
+
this.props.channels.unregisterHandlers(this.props.id);
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.props.addDefaultChannels && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EveryoneChannel.default, null), /*#__PURE__*/_react.default.createElement(_UserChannel.default, null), /*#__PURE__*/_react.default.createElement(_OrganizationChannel.default, null), /*#__PURE__*/_react.default.createElement(_EntityChannel.default, null)), this.props.children);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
81
28
|
ChannelsConsumer.propTypes = {
|
|
82
29
|
children: _propTypes.default.node,
|
|
83
30
|
id: _propTypes.default.string.isRequired,
|
|
@@ -93,7 +40,4 @@ ChannelsConsumer.defaultProps = {
|
|
|
93
40
|
addDefaultChannels: true,
|
|
94
41
|
children: null
|
|
95
42
|
};
|
|
96
|
-
|
|
97
|
-
var _default = (0, _withChannels.default)(ChannelsConsumer);
|
|
98
|
-
|
|
99
|
-
exports.default = _default;
|
|
43
|
+
var _default = exports.default = (0, _withChannels.default)(ChannelsConsumer);
|