roboto-js 1.0.17 → 1.0.18

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.
@@ -445,20 +445,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
445
445
  key: "configure",
446
446
  value: function configure(_ref) {
447
447
  var apiKey = _ref.apiKey,
448
- baseUrl = _ref.baseUrl;
448
+ baseUrl = _ref.baseUrl,
449
+ authtoken = _ref.authtoken,
450
+ accesskey = _ref.accesskey;
449
451
  if (!RbtApi.instance) {
450
452
  var isClient = typeof window !== 'undefined';
451
- var authtoken = isClient ? localStorage.getItem('authtoken') : null;
453
+ var authTokenToUse = isClient && !authtoken ? localStorage.getItem('authtoken') : authtoken;
452
454
  console.log('RbtApi authtoken ' + authtoken);
453
455
  var axiosInstance = _axios["default"].create({
454
456
  baseURL: baseUrl,
455
457
  headers: {
456
- accesskey: apiKey,
457
- authtoken: authtoken
458
+ 'accesskey': accesskey || apiKey,
459
+ 'authtoken': authTokenToUse
458
460
  }
459
461
  });
460
462
  RbtApi.instance = new RbtApi(axiosInstance);
461
- RbtApi.instance.authtoken = authtoken;
463
+ RbtApi.instance.authtoken = authTokenToUse;
462
464
  }
463
465
  return RbtApi.instance;
464
466
  }
@@ -445,20 +445,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
445
445
  key: "configure",
446
446
  value: function configure(_ref) {
447
447
  var apiKey = _ref.apiKey,
448
- baseUrl = _ref.baseUrl;
448
+ baseUrl = _ref.baseUrl,
449
+ authtoken = _ref.authtoken,
450
+ accesskey = _ref.accesskey;
449
451
  if (!RbtApi.instance) {
450
452
  var isClient = typeof window !== 'undefined';
451
- var authtoken = isClient ? localStorage.getItem('authtoken') : null;
453
+ var authTokenToUse = isClient && !authtoken ? localStorage.getItem('authtoken') : authtoken;
452
454
  console.log('RbtApi authtoken ' + authtoken);
453
455
  var axiosInstance = _axios["default"].create({
454
456
  baseURL: baseUrl,
455
457
  headers: {
456
- accesskey: apiKey,
457
- authtoken: authtoken
458
+ 'accesskey': accesskey || apiKey,
459
+ 'authtoken': authTokenToUse
458
460
  }
459
461
  });
460
462
  RbtApi.instance = new RbtApi(axiosInstance);
461
- RbtApi.instance.authtoken = authtoken;
463
+ RbtApi.instance.authtoken = authTokenToUse;
462
464
  }
463
465
  return RbtApi.instance;
464
466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -14,23 +14,23 @@ export default class RbtApi {
14
14
  this.authtoken = null;
15
15
  }
16
16
 
17
- static configure({ apiKey, baseUrl }) {
17
+ static configure({ apiKey, baseUrl, authtoken, accesskey }) {
18
18
  if (!RbtApi.instance) {
19
19
  const isClient = typeof window !== 'undefined';
20
20
 
21
- const authtoken = (isClient)? localStorage.getItem('authtoken'): null;
21
+ const authTokenToUse = isClient && !authtoken ? localStorage.getItem('authtoken') : authtoken;
22
22
 
23
23
  console.log('RbtApi authtoken '+authtoken);
24
24
  const axiosInstance = axios.create({
25
25
  baseURL: baseUrl,
26
26
  headers: {
27
- accesskey: apiKey,
28
- authtoken: authtoken
27
+ 'accesskey': accesskey || apiKey,
28
+ 'authtoken': authTokenToUse
29
29
  }
30
30
  });
31
31
 
32
32
  RbtApi.instance = new RbtApi(axiosInstance);
33
- RbtApi.instance.authtoken = authtoken;
33
+ RbtApi.instance.authtoken = authTokenToUse;
34
34
  }
35
35
  return RbtApi.instance;
36
36
  }