roboto-js 1.3.4 → 1.3.5

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.
@@ -165,19 +165,23 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
165
165
  this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
166
166
  // update axios instance headers with authtoken
167
167
  this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
168
- if (typeof localStorage != 'undefined') {
169
- localStorage.setItem('authtoken', response.data.authToken);
168
+ if (!this.localStorageAdaptor) {
169
+ _context3.next = 13;
170
+ break;
170
171
  }
172
+ _context3.next = 13;
173
+ return this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
174
+ case 13:
171
175
  return _context3.abrupt("return", response.data);
172
- case 14:
173
- _context3.prev = 14;
176
+ case 16:
177
+ _context3.prev = 16;
174
178
  _context3.t0 = _context3["catch"](0);
175
179
  this._handleError(_context3.t0);
176
- case 17:
180
+ case 19:
177
181
  case "end":
178
182
  return _context3.stop();
179
183
  }
180
- }, _callee3, this, [[0, 14]]);
184
+ }, _callee3, this, [[0, 16]]);
181
185
  }));
182
186
  function login(_x2) {
183
187
  return _login.apply(this, arguments);
@@ -211,21 +215,23 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
211
215
  }
212
216
 
213
217
  // Clear localStorage if it's being used
214
- if (typeof localStorage !== 'undefined') {
215
- localStorage.removeItem('authtoken');
218
+ if (!this.localStorageAdaptor) {
219
+ _context4.next = 12;
220
+ break;
216
221
  }
217
-
218
- // Return some kind of success response or the response from the server
222
+ _context4.next = 12;
223
+ return this.localStorageAdaptor.removeItem('authtoken');
224
+ case 12:
219
225
  return _context4.abrupt("return", response.data);
220
- case 13:
221
- _context4.prev = 13;
226
+ case 15:
227
+ _context4.prev = 15;
222
228
  _context4.t0 = _context4["catch"](0);
223
229
  this._handleError(_context4.t0);
224
- case 16:
230
+ case 18:
225
231
  case "end":
226
232
  return _context4.stop();
227
233
  }
228
- }, _callee4, this, [[0, 13]]);
234
+ }, _callee4, this, [[0, 15]]);
229
235
  }));
230
236
  function logout() {
231
237
  return _logout.apply(this, arguments);
@@ -83,8 +83,8 @@ export default class RbtApi {
83
83
  this.currentUser = this.iac_session ? new RbtUser(this.iac_session.user, this.axios) : null;
84
84
  // update axios instance headers with authtoken
85
85
  this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
86
- if (typeof localStorage != 'undefined') {
87
- localStorage.setItem('authtoken', response.data.authToken);
86
+ if (this.localStorageAdaptor) {
87
+ await this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
88
88
  }
89
89
  return response.data;
90
90
  } catch (e) {
@@ -108,8 +108,8 @@ export default class RbtApi {
108
108
  }
109
109
 
110
110
  // Clear localStorage if it's being used
111
- if (typeof localStorage !== 'undefined') {
112
- localStorage.removeItem('authtoken');
111
+ if (this.localStorageAdaptor) {
112
+ await this.localStorageAdaptor.removeItem('authtoken');
113
113
  }
114
114
 
115
115
  // Return some kind of success response or the response from the server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -97,8 +97,8 @@ export default class RbtApi {
97
97
  // update axios instance headers with authtoken
98
98
  this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
99
99
 
100
- if(typeof localStorage != 'undefined'){
101
- localStorage.setItem('authtoken', response.data.authToken);
100
+ if(this.localStorageAdaptor){
101
+ await this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
102
102
  }
103
103
 
104
104
  return response.data;
@@ -126,8 +126,8 @@ export default class RbtApi {
126
126
  }
127
127
 
128
128
  // Clear localStorage if it's being used
129
- if (typeof localStorage !== 'undefined') {
130
- localStorage.removeItem('authtoken');
129
+ if (this.localStorageAdaptor) {
130
+ await this.localStorageAdaptor.removeItem('authtoken');
131
131
  }
132
132
 
133
133
  // Return some kind of success response or the response from the server