roboto-js 1.7.1 → 1.7.4
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/.last-build +1 -0
- package/dist/cjs/cookie_storage_adaptor.cjs +429 -0
- package/dist/cjs/index.cjs +57 -5
- package/dist/cjs/rbt_api.cjs +548 -463
- package/dist/cookie_storage_adaptor.js +415 -0
- package/dist/esm/cookie_storage_adaptor.js +226 -0
- package/dist/esm/index.js +37 -5
- package/dist/esm/rbt_api.js +50 -22
- package/dist/index.js +66 -40
- package/dist/rbt_api.js +574 -496
- package/dist/rbt_file.js +10 -16
- package/dist/rbt_metrics_api.js +6 -12
- package/dist/rbt_object.js +30 -36
- package/dist/rbt_user.js +11 -17
- package/package.json +1 -1
- package/src/cookie_storage_adaptor.js +246 -0
- package/src/index.js +41 -5
- package/src/rbt_api.js +51 -20
package/dist/esm/index.js
CHANGED
|
@@ -2,20 +2,22 @@ import RbtApi from './rbt_api.js';
|
|
|
2
2
|
import RbtObject from './rbt_object.js';
|
|
3
3
|
import RbtFile from './rbt_file.js';
|
|
4
4
|
import RbtMetricsApi from './rbt_metrics_api.js';
|
|
5
|
-
|
|
5
|
+
import CookieStorageAdaptor from './cookie_storage_adaptor.js';
|
|
6
|
+
export { RbtApi, RbtObject, RbtFile, CookieStorageAdaptor
|
|
6
7
|
//User,
|
|
7
8
|
//Site
|
|
8
9
|
};
|
|
9
10
|
export default class Roboto {
|
|
10
11
|
getVersion() {
|
|
11
|
-
return '1.7.
|
|
12
|
+
return '1.7.3';
|
|
12
13
|
}
|
|
13
14
|
constructor({
|
|
14
15
|
host,
|
|
15
16
|
accessKey,
|
|
16
17
|
localStorageAdaptor,
|
|
17
18
|
disableWebSocket = false,
|
|
18
|
-
metricsHost
|
|
19
|
+
metricsHost,
|
|
20
|
+
useCookies = true
|
|
19
21
|
}, proxyReq = null) {
|
|
20
22
|
if (Roboto.instance && !proxyReq) {
|
|
21
23
|
// if on client, there can only be one instance
|
|
@@ -24,12 +26,29 @@ export default class Roboto {
|
|
|
24
26
|
}
|
|
25
27
|
const isBrowser = typeof window !== "undefined";
|
|
26
28
|
this.data = {};
|
|
29
|
+
|
|
30
|
+
// Auto-configure storage adaptor
|
|
31
|
+
let storageAdaptor = localStorageAdaptor;
|
|
32
|
+
if (!storageAdaptor && isBrowser && useCookies) {
|
|
33
|
+
// Use cookies by default in browser for better server-side compatibility
|
|
34
|
+
storageAdaptor = new CookieStorageAdaptor({
|
|
35
|
+
secure: window.location.protocol === 'https:',
|
|
36
|
+
sameSite: 'Lax',
|
|
37
|
+
maxAge: 24 * 60 * 60 // 24 hours
|
|
38
|
+
});
|
|
39
|
+
console.log('[Roboto] Using CookieStorageAdaptor for authentication tokens');
|
|
40
|
+
|
|
41
|
+
// Set accessKey for server-side authentication (handled automatically by adapter)
|
|
42
|
+
if (accessKey) {
|
|
43
|
+
storageAdaptor.setItem('accessKey', accessKey).catch(e => console.warn('[Roboto] Failed to set accessKey cookie:', e));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
27
46
|
this.config = {
|
|
28
47
|
accessKey: accessKey,
|
|
29
48
|
// Use passed accessKey
|
|
30
49
|
baseUrl: `https://${host}`,
|
|
31
50
|
// Use passed host
|
|
32
|
-
localStorageAdaptor:
|
|
51
|
+
localStorageAdaptor: storageAdaptor
|
|
33
52
|
};
|
|
34
53
|
|
|
35
54
|
// DEVELOPMENT
|
|
@@ -54,6 +73,12 @@ export default class Roboto {
|
|
|
54
73
|
this.api = new RbtApi(this.config);
|
|
55
74
|
if (isBrowser) {
|
|
56
75
|
this.api.initLocalDb();
|
|
76
|
+
|
|
77
|
+
// Add global debug method for cookie storage adapter
|
|
78
|
+
if (this.config.localStorageAdaptor && this.config.localStorageAdaptor.debugState) {
|
|
79
|
+
window.debugRobotoCookies = () => this.config.localStorageAdaptor.debugState();
|
|
80
|
+
console.log('[Roboto] Added global debug method: window.debugRobotoCookies()');
|
|
81
|
+
}
|
|
57
82
|
}
|
|
58
83
|
|
|
59
84
|
// METRICS API instance (separate host or same)
|
|
@@ -130,7 +155,14 @@ export default class Roboto {
|
|
|
130
155
|
return this.api.loginWithOauth(params);
|
|
131
156
|
}
|
|
132
157
|
async logout() {
|
|
133
|
-
|
|
158
|
+
const result = await this.api.logout();
|
|
159
|
+
|
|
160
|
+
// Clear accessKey and authtoken using standard localStorage interface
|
|
161
|
+
if (this.config.localStorageAdaptor) {
|
|
162
|
+
await this.config.localStorageAdaptor.removeItem('accessKey');
|
|
163
|
+
await this.config.localStorageAdaptor.removeItem('authtoken');
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
134
166
|
}
|
|
135
167
|
async refreshAuthToken() {
|
|
136
168
|
return this.api.refreshAuthToken(this.config.authtoken);
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -42,28 +42,9 @@ export default class RbtApi {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
//
|
|
46
|
-
if
|
|
47
|
-
|
|
48
|
-
const token = localStorage.getItem('authtoken');
|
|
49
|
-
if (token) {
|
|
50
|
-
this.authtoken = token;
|
|
51
|
-
this.axios.defaults.headers.common['authtoken'] = token;
|
|
52
|
-
}
|
|
53
|
-
} catch {}
|
|
54
|
-
try {
|
|
55
|
-
const cachedUser = localStorage.getItem('rbtUser');
|
|
56
|
-
if (cachedUser) {
|
|
57
|
-
const parsed = JSON.parse(cachedUser);
|
|
58
|
-
if (parsed && parsed.id) {
|
|
59
|
-
this.currentUser = new RbtUser({
|
|
60
|
-
id: parsed.id
|
|
61
|
-
}, this.axios);
|
|
62
|
-
this.currentUser.setData(parsed);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} catch {}
|
|
66
|
-
}
|
|
45
|
+
// Asynchronous browser hydration: set auth header and in-memory user
|
|
46
|
+
// Use storage adaptor if available, otherwise fallback to localStorage
|
|
47
|
+
this._initializeFromStorage().catch(e => console.warn('[RbtApi] Storage initialization failed:', e));
|
|
67
48
|
this.localDb = null;
|
|
68
49
|
this.iac_session = null;
|
|
69
50
|
this.appServiceHost = baseUrl;
|
|
@@ -75,6 +56,51 @@ export default class RbtApi {
|
|
|
75
56
|
this.initAuthToken(authtoken);
|
|
76
57
|
this.initApiKey(apikey);
|
|
77
58
|
}
|
|
59
|
+
|
|
60
|
+
// Initialize authtoken and user from storage (cookies or localStorage)
|
|
61
|
+
async _initializeFromStorage() {
|
|
62
|
+
if (!this.localStorageAdaptor) return;
|
|
63
|
+
try {
|
|
64
|
+
// Try to get authtoken from storage adaptor (prefixed: rbt_authtoken)
|
|
65
|
+
let token = await this.localStorageAdaptor.getItem('authtoken');
|
|
66
|
+
|
|
67
|
+
// If not found in prefixed storage, try raw cookie (like accessKey)
|
|
68
|
+
if (!token && typeof document !== 'undefined') {
|
|
69
|
+
// Try to get from raw cookie
|
|
70
|
+
const cookies = document.cookie.split(';');
|
|
71
|
+
for (let cookie of cookies) {
|
|
72
|
+
const [name, value] = cookie.trim().split('=');
|
|
73
|
+
if (name === 'authtoken') {
|
|
74
|
+
token = decodeURIComponent(value);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (token) {
|
|
80
|
+
this.authtoken = token;
|
|
81
|
+
this.axios.defaults.headers.common['authtoken'] = token;
|
|
82
|
+
console.log('[RbtApi] Loaded authtoken from storage adaptor');
|
|
83
|
+
}
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.warn('[RbtApi] Failed to load authtoken from storage adaptor:', e);
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
// Try to get user from storage adaptor
|
|
89
|
+
const cachedUser = await this.localStorageAdaptor.getItem('rbtUser');
|
|
90
|
+
if (cachedUser) {
|
|
91
|
+
const parsed = typeof cachedUser === 'string' ? JSON.parse(cachedUser) : cachedUser;
|
|
92
|
+
if (parsed && parsed.id) {
|
|
93
|
+
this.currentUser = new RbtUser({
|
|
94
|
+
id: parsed.id
|
|
95
|
+
}, this.axios);
|
|
96
|
+
this.currentUser.setData(parsed);
|
|
97
|
+
console.log('[RbtApi] Loaded user from storage adaptor');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.warn('[RbtApi] Failed to load user from storage adaptor:', e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
78
104
|
getWebSocketClient() {
|
|
79
105
|
// Reuse existing WebSocket if it's OPEN or CONNECTING (to prevent race condition)
|
|
80
106
|
if (this.websocketClient && (this.websocketClient.readyState === WebSocket.OPEN || this.websocketClient.readyState === WebSocket.CONNECTING)) {
|
|
@@ -242,6 +268,8 @@ export default class RbtApi {
|
|
|
242
268
|
if (this.iac_session?.user) {
|
|
243
269
|
await this.localStorageAdaptor.setItem('rbtUser', JSON.stringify(this.iac_session.user));
|
|
244
270
|
}
|
|
271
|
+
|
|
272
|
+
// authtoken is automatically stored for server-side access by the adapter
|
|
245
273
|
}
|
|
246
274
|
return response.data;
|
|
247
275
|
} catch (e) {
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "RbtApi", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _rbt_api["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "RbtFile", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _rbt_file["default"];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "RbtObject", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _rbt_object["default"];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
exports["default"] = void 0;
|
|
25
|
-
var _rbt_api = _interopRequireDefault(require("./rbt_api.js"));
|
|
26
|
-
var _rbt_object = _interopRequireDefault(require("./rbt_object.js"));
|
|
27
|
-
var _rbt_file = _interopRequireDefault(require("./rbt_file.js"));
|
|
28
|
-
var _rbt_metrics_api = _interopRequireDefault(require("./rbt_metrics_api.js"));
|
|
29
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
30
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
31
2
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
32
3
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
@@ -37,14 +8,26 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
|
|
|
37
8
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
38
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
39
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
40
|
-
|
|
11
|
+
import RbtApi from './rbt_api.js';
|
|
12
|
+
import RbtObject from './rbt_object.js';
|
|
13
|
+
import RbtFile from './rbt_file.js';
|
|
14
|
+
import RbtMetricsApi from './rbt_metrics_api.js';
|
|
15
|
+
import CookieStorageAdaptor from './cookie_storage_adaptor.js';
|
|
16
|
+
export { RbtApi, RbtObject, RbtFile, CookieStorageAdaptor
|
|
17
|
+
//User,
|
|
18
|
+
//Site
|
|
19
|
+
};
|
|
20
|
+
var Roboto = /*#__PURE__*/function () {
|
|
41
21
|
function Roboto(_ref) {
|
|
22
|
+
var _this = this;
|
|
42
23
|
var host = _ref.host,
|
|
43
24
|
accessKey = _ref.accessKey,
|
|
44
25
|
localStorageAdaptor = _ref.localStorageAdaptor,
|
|
45
26
|
_ref$disableWebSocket = _ref.disableWebSocket,
|
|
46
27
|
disableWebSocket = _ref$disableWebSocket === void 0 ? false : _ref$disableWebSocket,
|
|
47
|
-
metricsHost = _ref.metricsHost
|
|
28
|
+
metricsHost = _ref.metricsHost,
|
|
29
|
+
_ref$useCookies = _ref.useCookies,
|
|
30
|
+
useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies;
|
|
48
31
|
var proxyReq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
49
32
|
_classCallCheck(this, Roboto);
|
|
50
33
|
if (Roboto.instance && !proxyReq) {
|
|
@@ -54,12 +37,31 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
54
37
|
}
|
|
55
38
|
var isBrowser = typeof window !== "undefined";
|
|
56
39
|
this.data = {};
|
|
40
|
+
|
|
41
|
+
// Auto-configure storage adaptor
|
|
42
|
+
var storageAdaptor = localStorageAdaptor;
|
|
43
|
+
if (!storageAdaptor && isBrowser && useCookies) {
|
|
44
|
+
// Use cookies by default in browser for better server-side compatibility
|
|
45
|
+
storageAdaptor = new CookieStorageAdaptor({
|
|
46
|
+
secure: window.location.protocol === 'https:',
|
|
47
|
+
sameSite: 'Lax',
|
|
48
|
+
maxAge: 24 * 60 * 60 // 24 hours
|
|
49
|
+
});
|
|
50
|
+
console.log('[Roboto] Using CookieStorageAdaptor for authentication tokens');
|
|
51
|
+
|
|
52
|
+
// Set accessKey for server-side authentication (handled automatically by adapter)
|
|
53
|
+
if (accessKey) {
|
|
54
|
+
storageAdaptor.setItem('accessKey', accessKey)["catch"](function (e) {
|
|
55
|
+
return console.warn('[Roboto] Failed to set accessKey cookie:', e);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
57
59
|
this.config = {
|
|
58
60
|
accessKey: accessKey,
|
|
59
61
|
// Use passed accessKey
|
|
60
62
|
baseUrl: "https://".concat(host),
|
|
61
63
|
// Use passed host
|
|
62
|
-
localStorageAdaptor:
|
|
64
|
+
localStorageAdaptor: storageAdaptor
|
|
63
65
|
};
|
|
64
66
|
|
|
65
67
|
// DEVELOPMENT
|
|
@@ -81,16 +83,24 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
81
83
|
this.config.accesskey = accesskey; // Set the accesskey in the config
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
|
-
this.api = new
|
|
86
|
+
this.api = new RbtApi(this.config);
|
|
85
87
|
if (isBrowser) {
|
|
86
88
|
this.api.initLocalDb();
|
|
89
|
+
|
|
90
|
+
// Add global debug method for cookie storage adapter
|
|
91
|
+
if (this.config.localStorageAdaptor && this.config.localStorageAdaptor.debugState) {
|
|
92
|
+
window.debugRobotoCookies = function () {
|
|
93
|
+
return _this.config.localStorageAdaptor.debugState();
|
|
94
|
+
};
|
|
95
|
+
console.log('[Roboto] Added global debug method: window.debugRobotoCookies()');
|
|
96
|
+
}
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
// METRICS API instance (separate host or same)
|
|
90
100
|
if (metricsHost && metricsHost !== host) {
|
|
91
101
|
var metricsUrl = metricsHost.startsWith('http') ? metricsHost : "https://".concat(metricsHost);
|
|
92
102
|
// You can customize headers if needed
|
|
93
|
-
this.metrics = new
|
|
103
|
+
this.metrics = new RbtMetricsApi({
|
|
94
104
|
config: {
|
|
95
105
|
baseURL: this._stripHttpsForDomains(metricsUrl, ['localhost']),
|
|
96
106
|
headers: {
|
|
@@ -100,7 +110,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
100
110
|
});
|
|
101
111
|
} else {
|
|
102
112
|
// Use the same axios instance as main API
|
|
103
|
-
this.metrics = new
|
|
113
|
+
this.metrics = new RbtMetricsApi({
|
|
104
114
|
axiosInstance: this.api.axios
|
|
105
115
|
});
|
|
106
116
|
}
|
|
@@ -109,7 +119,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
109
119
|
return _createClass(Roboto, [{
|
|
110
120
|
key: "getVersion",
|
|
111
121
|
value: function getVersion() {
|
|
112
|
-
return '1.
|
|
122
|
+
return '1.7.3';
|
|
113
123
|
}
|
|
114
124
|
}, {
|
|
115
125
|
key: "setSiteEnv",
|
|
@@ -144,7 +154,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
144
154
|
value: function setMetricsHost(host) {
|
|
145
155
|
this.metricsHost = host;
|
|
146
156
|
var metricsUrl = host.startsWith('http') ? host : "https://".concat(host);
|
|
147
|
-
this.metrics = new
|
|
157
|
+
this.metrics = new RbtMetricsApi({
|
|
148
158
|
config: {
|
|
149
159
|
baseURL: this._stripHttpsForDomains(metricsUrl, ['localhost']),
|
|
150
160
|
headers: {
|
|
@@ -168,7 +178,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
168
178
|
}, {
|
|
169
179
|
key: "recordToInstance",
|
|
170
180
|
value: function recordToInstance(recordHash) {
|
|
171
|
-
return new
|
|
181
|
+
return new RbtObject(recordHash, this.api.axios);
|
|
172
182
|
}
|
|
173
183
|
}, {
|
|
174
184
|
key: "_stripHttpsForDomains",
|
|
@@ -217,10 +227,25 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
217
227
|
key: "logout",
|
|
218
228
|
value: function () {
|
|
219
229
|
var _logout = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
230
|
+
var result;
|
|
220
231
|
return _regenerator().w(function (_context3) {
|
|
221
232
|
while (1) switch (_context3.n) {
|
|
222
233
|
case 0:
|
|
223
|
-
|
|
234
|
+
_context3.n = 1;
|
|
235
|
+
return this.api.logout();
|
|
236
|
+
case 1:
|
|
237
|
+
result = _context3.v;
|
|
238
|
+
if (!this.config.localStorageAdaptor) {
|
|
239
|
+
_context3.n = 3;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
_context3.n = 2;
|
|
243
|
+
return this.config.localStorageAdaptor.removeItem('accessKey');
|
|
244
|
+
case 2:
|
|
245
|
+
_context3.n = 3;
|
|
246
|
+
return this.config.localStorageAdaptor.removeItem('authtoken');
|
|
247
|
+
case 3:
|
|
248
|
+
return _context3.a(2, result);
|
|
224
249
|
}
|
|
225
250
|
}, _callee3, this);
|
|
226
251
|
}));
|
|
@@ -544,4 +569,5 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
544
569
|
return post;
|
|
545
570
|
}()
|
|
546
571
|
}]);
|
|
547
|
-
}();
|
|
572
|
+
}();
|
|
573
|
+
export { Roboto as default };
|