versacall-core-library-react 2.0.65 → 2.0.66
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.
|
@@ -99,7 +99,8 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
99
99
|
_this = _super.call(this, props);
|
|
100
100
|
_this.state = {
|
|
101
101
|
authenticated: false,
|
|
102
|
-
token: null
|
|
102
|
+
token: null,
|
|
103
|
+
apiKey: null
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
if (props.test) {
|
|
@@ -107,6 +108,7 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
107
108
|
_this.state.token = _constants.testToken;
|
|
108
109
|
} else {
|
|
109
110
|
var token = getToken();
|
|
111
|
+
var apiKey = (0, _functions.getParameterByName)('apiKey');
|
|
110
112
|
|
|
111
113
|
if (token !== null) {
|
|
112
114
|
_this.state.authenticated = true;
|
|
@@ -119,6 +121,8 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
119
121
|
_this.state.authenticated = param.authenticated;
|
|
120
122
|
_this.state.token = param.token;
|
|
121
123
|
}
|
|
124
|
+
} else if (apiKey && apiKey.length > 0) {
|
|
125
|
+
_this.state.apiKey = apiKey; // TODO - Make call to get token from Api Key...
|
|
122
126
|
} else {
|
|
123
127
|
_this.redirectToLogin();
|
|
124
128
|
}
|
|
@@ -187,6 +191,7 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
187
191
|
}, {
|
|
188
192
|
key: "didChange",
|
|
189
193
|
value: function didChange(prevContext) {
|
|
194
|
+
// NOTE: Might also need to check apiKey...
|
|
190
195
|
return !compareTokens(this.state.token, prevContext.token);
|
|
191
196
|
}
|
|
192
197
|
}, {
|
|
@@ -218,7 +223,12 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
218
223
|
headers: {
|
|
219
224
|
Authorization: "Bearer ".concat(this.state.token.token)
|
|
220
225
|
}
|
|
221
|
-
});
|
|
226
|
+
}); // NOTE: If we have an ApiKey, might want to include a "X-API-Key" header...
|
|
227
|
+
|
|
228
|
+
if (this.state.apiKey) {
|
|
229
|
+
configurationCombined.headers['X-API-Key'] = this.state.apiKey;
|
|
230
|
+
}
|
|
231
|
+
|
|
222
232
|
return new Promise(function (resolve, reject) {
|
|
223
233
|
(0, _axios.default)(configurationCombined).then(function (results) {
|
|
224
234
|
resolve(results);
|
|
@@ -270,7 +280,9 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
270
280
|
}, {
|
|
271
281
|
key: "redirectToLogin",
|
|
272
282
|
value: function redirectToLogin() {
|
|
273
|
-
|
|
283
|
+
// Need to encode the redirect URL since we are passing it as a parameter
|
|
284
|
+
var redirect = encodeURIComponent(window.location);
|
|
285
|
+
window.location = "".concat(this.props.core.baseUrl, "/login?redirect=").concat(redirect);
|
|
274
286
|
}
|
|
275
287
|
}, {
|
|
276
288
|
key: "render",
|
|
@@ -279,11 +291,13 @@ var AuthenticationProvider = /*#__PURE__*/function (_Component) {
|
|
|
279
291
|
|
|
280
292
|
var _this$state = this.state,
|
|
281
293
|
authenticated = _this$state.authenticated,
|
|
282
|
-
token = _this$state.token
|
|
294
|
+
token = _this$state.token,
|
|
295
|
+
apiKey = _this$state.apiKey;
|
|
283
296
|
return /*#__PURE__*/_react.default.createElement(_AuthenticationContext.default.Provider, {
|
|
284
297
|
value: {
|
|
285
298
|
authenticated: authenticated,
|
|
286
299
|
token: token,
|
|
300
|
+
apiKey: apiKey,
|
|
287
301
|
logout: function logout() {
|
|
288
302
|
return _this3.logout();
|
|
289
303
|
},
|
package/package.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"versacall": {
|
|
3
3
|
"title": "Versacall Core Library React",
|
|
4
4
|
"applicationType": "react-library",
|
|
5
|
-
"build":
|
|
5
|
+
"build": 66
|
|
6
6
|
},
|
|
7
7
|
"name": "versacall-core-library-react",
|
|
8
|
-
"version": "2.0.
|
|
8
|
+
"version": "2.0.66",
|
|
9
9
|
"description": "Versacall Core Library",
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"module": "dist/index.js",
|