roboto-js 1.8.3 → 1.8.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 -1
- package/dist/cjs/rbt_api.cjs +33 -5
- package/dist/esm/rbt_api.js +33 -5
- package/package.json +1 -1
- package/src/rbt_api.js +33 -5
- package/dist/cookie_storage_adaptor.js +0 -415
- package/dist/index.js +0 -573
- package/dist/rbt_api.js +0 -2074
- package/dist/rbt_file.js +0 -223
- package/dist/rbt_metrics_api.js +0 -200
- package/dist/rbt_object.js +0 -1110
- package/dist/rbt_user.js +0 -235
package/.last-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2025-10-
|
|
1
|
+
2025-10-09T21:04:42.145Z
|
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -1777,8 +1777,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1777
1777
|
this.pollTaskProgress(jobId, callbacks);
|
|
1778
1778
|
}
|
|
1779
1779
|
if (status === 'ERROR' && onError) {
|
|
1780
|
-
//
|
|
1781
|
-
onError(response);
|
|
1780
|
+
// Normalize error response to have consistent message/label at top level
|
|
1781
|
+
onError(this._normalizeErrorResponse(response));
|
|
1782
1782
|
}
|
|
1783
1783
|
if (status === 'STOPPED' && onStopped) {
|
|
1784
1784
|
// Provide the current progress to the callback function
|
|
@@ -1790,7 +1790,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1790
1790
|
}
|
|
1791
1791
|
if (status === 'DONE' && onDone) {
|
|
1792
1792
|
// Provide the current progress to the callback function
|
|
1793
|
-
//console.log('Finish (request) ',response);
|
|
1793
|
+
//console.log('Finish (request) ',response); s
|
|
1794
1794
|
onDone(response);
|
|
1795
1795
|
}
|
|
1796
1796
|
return _context25.abrupt("return", {
|
|
@@ -1875,6 +1875,34 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
return stopJob;
|
|
1877
1877
|
}()
|
|
1878
|
+
/**
|
|
1879
|
+
* Normalize error response to have consistent message/label at top level
|
|
1880
|
+
* Extracts from messages array if present (from chain execution)
|
|
1881
|
+
*/
|
|
1882
|
+
}, {
|
|
1883
|
+
key: "_normalizeErrorResponse",
|
|
1884
|
+
value: function _normalizeErrorResponse(response) {
|
|
1885
|
+
// If response already has message/label at top level and no messages array, return as-is
|
|
1886
|
+
if ((response.message || response.label) && !response.messages) {
|
|
1887
|
+
return response;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
// Extract the most recent error from messages array
|
|
1891
|
+
if (response.messages && response.messages.length > 0) {
|
|
1892
|
+
var lastMessage = response.messages[response.messages.length - 1];
|
|
1893
|
+
return _objectSpread(_objectSpread({}, response), {}, {
|
|
1894
|
+
message: lastMessage.message || response.message || 'Unknown error',
|
|
1895
|
+
label: lastMessage.label || response.label || 'Error'
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
// Fallback: ensure we have at least message/label fields
|
|
1900
|
+
return _objectSpread(_objectSpread({}, response), {}, {
|
|
1901
|
+
message: response.message || 'Unknown error',
|
|
1902
|
+
label: response.label || 'Error'
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1878
1906
|
/**
|
|
1879
1907
|
* Polls the progress of a long-running task.
|
|
1880
1908
|
*
|
|
@@ -1915,8 +1943,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1915
1943
|
onDone(response);
|
|
1916
1944
|
}
|
|
1917
1945
|
if (response.status === 'ERROR' && onError) {
|
|
1918
|
-
//
|
|
1919
|
-
onError(response);
|
|
1946
|
+
// Normalize error response to have consistent message/label at top level
|
|
1947
|
+
onError(_this9._normalizeErrorResponse(response));
|
|
1920
1948
|
}
|
|
1921
1949
|
if (response.status === 'STOPPED' && onStopped) {
|
|
1922
1950
|
// Provide the current progress to the callback function
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -1025,8 +1025,8 @@ export default class RbtApi {
|
|
|
1025
1025
|
this.pollTaskProgress(jobId, callbacks);
|
|
1026
1026
|
}
|
|
1027
1027
|
if (status === 'ERROR' && onError) {
|
|
1028
|
-
//
|
|
1029
|
-
onError(response);
|
|
1028
|
+
// Normalize error response to have consistent message/label at top level
|
|
1029
|
+
onError(this._normalizeErrorResponse(response));
|
|
1030
1030
|
}
|
|
1031
1031
|
if (status === 'STOPPED' && onStopped) {
|
|
1032
1032
|
// Provide the current progress to the callback function
|
|
@@ -1038,7 +1038,7 @@ export default class RbtApi {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
if (status === 'DONE' && onDone) {
|
|
1040
1040
|
// Provide the current progress to the callback function
|
|
1041
|
-
//console.log('Finish (request) ',response);
|
|
1041
|
+
//console.log('Finish (request) ',response); s
|
|
1042
1042
|
onDone(response);
|
|
1043
1043
|
}
|
|
1044
1044
|
return {
|
|
@@ -1085,6 +1085,34 @@ export default class RbtApi {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
1087
1087
|
|
|
1088
|
+
/**
|
|
1089
|
+
* Normalize error response to have consistent message/label at top level
|
|
1090
|
+
* Extracts from messages array if present (from chain execution)
|
|
1091
|
+
*/
|
|
1092
|
+
_normalizeErrorResponse(response) {
|
|
1093
|
+
// If response already has message/label at top level and no messages array, return as-is
|
|
1094
|
+
if ((response.message || response.label) && !response.messages) {
|
|
1095
|
+
return response;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// Extract the most recent error from messages array
|
|
1099
|
+
if (response.messages && response.messages.length > 0) {
|
|
1100
|
+
const lastMessage = response.messages[response.messages.length - 1];
|
|
1101
|
+
return {
|
|
1102
|
+
...response,
|
|
1103
|
+
message: lastMessage.message || response.message || 'Unknown error',
|
|
1104
|
+
label: lastMessage.label || response.label || 'Error'
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// Fallback: ensure we have at least message/label fields
|
|
1109
|
+
return {
|
|
1110
|
+
...response,
|
|
1111
|
+
message: response.message || 'Unknown error',
|
|
1112
|
+
label: response.label || 'Error'
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1088
1116
|
/**
|
|
1089
1117
|
* Polls the progress of a long-running task.
|
|
1090
1118
|
*
|
|
@@ -1117,8 +1145,8 @@ export default class RbtApi {
|
|
|
1117
1145
|
onDone(response);
|
|
1118
1146
|
}
|
|
1119
1147
|
if (response.status === 'ERROR' && onError) {
|
|
1120
|
-
//
|
|
1121
|
-
onError(response);
|
|
1148
|
+
// Normalize error response to have consistent message/label at top level
|
|
1149
|
+
onError(this._normalizeErrorResponse(response));
|
|
1122
1150
|
}
|
|
1123
1151
|
if (response.status === 'STOPPED' && onStopped) {
|
|
1124
1152
|
// Provide the current progress to the callback function
|
package/package.json
CHANGED
package/src/rbt_api.js
CHANGED
|
@@ -1078,8 +1078,8 @@ export default class RbtApi {
|
|
|
1078
1078
|
this.pollTaskProgress(jobId, callbacks);
|
|
1079
1079
|
}
|
|
1080
1080
|
if (status === 'ERROR' && onError){
|
|
1081
|
-
//
|
|
1082
|
-
onError(response);
|
|
1081
|
+
// Normalize error response to have consistent message/label at top level
|
|
1082
|
+
onError(this._normalizeErrorResponse(response));
|
|
1083
1083
|
}
|
|
1084
1084
|
if (status === 'STOPPED' && onStopped){
|
|
1085
1085
|
// Provide the current progress to the callback function
|
|
@@ -1091,7 +1091,7 @@ export default class RbtApi {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
if (status === 'DONE' && onDone){
|
|
1093
1093
|
// Provide the current progress to the callback function
|
|
1094
|
-
//console.log('Finish (request) ',response);
|
|
1094
|
+
//console.log('Finish (request) ',response); s
|
|
1095
1095
|
onDone(response);
|
|
1096
1096
|
}
|
|
1097
1097
|
|
|
@@ -1142,6 +1142,34 @@ export default class RbtApi {
|
|
|
1142
1142
|
}
|
|
1143
1143
|
|
|
1144
1144
|
|
|
1145
|
+
/**
|
|
1146
|
+
* Normalize error response to have consistent message/label at top level
|
|
1147
|
+
* Extracts from messages array if present (from chain execution)
|
|
1148
|
+
*/
|
|
1149
|
+
_normalizeErrorResponse(response) {
|
|
1150
|
+
// If response already has message/label at top level and no messages array, return as-is
|
|
1151
|
+
if ((response.message || response.label) && !response.messages) {
|
|
1152
|
+
return response;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// Extract the most recent error from messages array
|
|
1156
|
+
if (response.messages && response.messages.length > 0) {
|
|
1157
|
+
const lastMessage = response.messages[response.messages.length - 1];
|
|
1158
|
+
return {
|
|
1159
|
+
...response,
|
|
1160
|
+
message: lastMessage.message || response.message || 'Unknown error',
|
|
1161
|
+
label: lastMessage.label || response.label || 'Error'
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
// Fallback: ensure we have at least message/label fields
|
|
1166
|
+
return {
|
|
1167
|
+
...response,
|
|
1168
|
+
message: response.message || 'Unknown error',
|
|
1169
|
+
label: response.label || 'Error'
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1145
1173
|
/**
|
|
1146
1174
|
* Polls the progress of a long-running task.
|
|
1147
1175
|
*
|
|
@@ -1165,8 +1193,8 @@ export default class RbtApi {
|
|
|
1165
1193
|
onDone(response);
|
|
1166
1194
|
}
|
|
1167
1195
|
if (response.status === 'ERROR' && onError){
|
|
1168
|
-
//
|
|
1169
|
-
onError(response);
|
|
1196
|
+
// Normalize error response to have consistent message/label at top level
|
|
1197
|
+
onError(this._normalizeErrorResponse(response));
|
|
1170
1198
|
}
|
|
1171
1199
|
if (response.status === 'STOPPED' && onStopped){
|
|
1172
1200
|
// Provide the current progress to the callback function
|
|
@@ -1,415 +0,0 @@
|
|
|
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); }
|
|
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 }; })(); }
|
|
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); }
|
|
4
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
5
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
8
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
14
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
-
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); }
|
|
17
|
-
/**
|
|
18
|
-
* Cookie-based storage adaptor for roboto-js
|
|
19
|
-
* Provides a localStorage-compatible interface using cookies
|
|
20
|
-
* This enables server-side access to authentication tokens
|
|
21
|
-
*/
|
|
22
|
-
var CookieStorageAdaptor = /*#__PURE__*/function () {
|
|
23
|
-
function CookieStorageAdaptor() {
|
|
24
|
-
var _options$secure, _options$sameSite, _options$path, _options$maxAge, _options$domain, _options$prefix, _options$serverAccess;
|
|
25
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
|
-
_classCallCheck(this, CookieStorageAdaptor);
|
|
27
|
-
this.options = _objectSpread({
|
|
28
|
-
// Security settings
|
|
29
|
-
secure: (_options$secure = options.secure) !== null && _options$secure !== void 0 ? _options$secure : typeof window !== 'undefined' && window.location.protocol === 'https:',
|
|
30
|
-
sameSite: (_options$sameSite = options.sameSite) !== null && _options$sameSite !== void 0 ? _options$sameSite : 'Lax',
|
|
31
|
-
httpOnly: false,
|
|
32
|
-
// Must be false so client-side JS can access
|
|
33
|
-
|
|
34
|
-
// Cookie settings
|
|
35
|
-
path: (_options$path = options.path) !== null && _options$path !== void 0 ? _options$path : '/',
|
|
36
|
-
maxAge: (_options$maxAge = options.maxAge) !== null && _options$maxAge !== void 0 ? _options$maxAge : 24 * 60 * 60,
|
|
37
|
-
// 24 hours default
|
|
38
|
-
domain: (_options$domain = options.domain) !== null && _options$domain !== void 0 ? _options$domain : undefined,
|
|
39
|
-
// Let browser determine domain
|
|
40
|
-
|
|
41
|
-
// Prefix for roboto cookies to avoid conflicts
|
|
42
|
-
prefix: (_options$prefix = options.prefix) !== null && _options$prefix !== void 0 ? _options$prefix : 'rbt_',
|
|
43
|
-
// Keys that should be stored without prefix for server-side access
|
|
44
|
-
serverAccessKeys: (_options$serverAccess = options.serverAccessKeys) !== null && _options$serverAccess !== void 0 ? _options$serverAccess : ['authtoken', 'accessKey', 'apikey']
|
|
45
|
-
}, options);
|
|
46
|
-
console.log('[CookieStorageAdaptor] Initialized with options:', {
|
|
47
|
-
secure: this.options.secure,
|
|
48
|
-
sameSite: this.options.sameSite,
|
|
49
|
-
path: this.options.path,
|
|
50
|
-
maxAge: this.options.maxAge,
|
|
51
|
-
domain: this.options.domain,
|
|
52
|
-
prefix: this.options.prefix,
|
|
53
|
-
serverAccessKeys: this.options.serverAccessKeys
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get item from cookies (localStorage-compatible interface)
|
|
59
|
-
*/
|
|
60
|
-
return _createClass(CookieStorageAdaptor, [{
|
|
61
|
-
key: "getItem",
|
|
62
|
-
value: (function () {
|
|
63
|
-
var _getItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(key) {
|
|
64
|
-
var usePrefix, cookieName, name, decodedCookie, cookies, _iterator, _step, cookie, rawValue, parsedValue, _t, _t2;
|
|
65
|
-
return _regenerator().w(function (_context) {
|
|
66
|
-
while (1) switch (_context.p = _context.n) {
|
|
67
|
-
case 0:
|
|
68
|
-
if (!(typeof document === 'undefined')) {
|
|
69
|
-
_context.n = 1;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): document undefined, returning null"));
|
|
73
|
-
return _context.a(2, null);
|
|
74
|
-
case 1:
|
|
75
|
-
// Check if this key should be stored without prefix for server access
|
|
76
|
-
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
77
|
-
cookieName = usePrefix ? this.options.prefix + key : key;
|
|
78
|
-
name = cookieName + '=';
|
|
79
|
-
decodedCookie = decodeURIComponent(document.cookie);
|
|
80
|
-
cookies = decodedCookie.split(';');
|
|
81
|
-
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): looking for cookie \"").concat(cookieName, "\" ").concat(usePrefix ? '(prefixed)' : '(server-accessible)'));
|
|
82
|
-
console.log("[CookieStorageAdaptor] Available cookies:", cookies.map(function (c) {
|
|
83
|
-
return c.trim().split('=')[0];
|
|
84
|
-
}).join(', '));
|
|
85
|
-
_iterator = _createForOfIteratorHelper(cookies);
|
|
86
|
-
_context.p = 2;
|
|
87
|
-
_iterator.s();
|
|
88
|
-
case 3:
|
|
89
|
-
if ((_step = _iterator.n()).done) {
|
|
90
|
-
_context.n = 7;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
cookie = _step.value;
|
|
94
|
-
cookie = cookie.trim();
|
|
95
|
-
if (!(cookie.indexOf(name) === 0)) {
|
|
96
|
-
_context.n = 6;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
rawValue = cookie.substring(name.length, cookie.length);
|
|
100
|
-
console.log("[CookieStorageAdaptor] Found cookie \"".concat(cookieName, "\" with raw value:"), rawValue);
|
|
101
|
-
|
|
102
|
-
// Handle JSON values (like rbtUser)
|
|
103
|
-
_context.p = 4;
|
|
104
|
-
parsedValue = JSON.parse(rawValue);
|
|
105
|
-
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): returning parsed JSON:"), parsedValue);
|
|
106
|
-
return _context.a(2, parsedValue);
|
|
107
|
-
case 5:
|
|
108
|
-
_context.p = 5;
|
|
109
|
-
_t = _context.v;
|
|
110
|
-
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): returning string value:"), rawValue);
|
|
111
|
-
return _context.a(2, rawValue);
|
|
112
|
-
case 6:
|
|
113
|
-
_context.n = 3;
|
|
114
|
-
break;
|
|
115
|
-
case 7:
|
|
116
|
-
_context.n = 9;
|
|
117
|
-
break;
|
|
118
|
-
case 8:
|
|
119
|
-
_context.p = 8;
|
|
120
|
-
_t2 = _context.v;
|
|
121
|
-
_iterator.e(_t2);
|
|
122
|
-
case 9:
|
|
123
|
-
_context.p = 9;
|
|
124
|
-
_iterator.f();
|
|
125
|
-
return _context.f(9);
|
|
126
|
-
case 10:
|
|
127
|
-
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): cookie \"").concat(cookieName, "\" not found, returning null"));
|
|
128
|
-
return _context.a(2, null);
|
|
129
|
-
}
|
|
130
|
-
}, _callee, this, [[4, 5], [2, 8, 9, 10]]);
|
|
131
|
-
}));
|
|
132
|
-
function getItem(_x) {
|
|
133
|
-
return _getItem.apply(this, arguments);
|
|
134
|
-
}
|
|
135
|
-
return getItem;
|
|
136
|
-
}()
|
|
137
|
-
/**
|
|
138
|
-
* Set item in cookies (localStorage-compatible interface)
|
|
139
|
-
*/
|
|
140
|
-
)
|
|
141
|
-
}, {
|
|
142
|
-
key: "setItem",
|
|
143
|
-
value: (function () {
|
|
144
|
-
var _setItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(key, value) {
|
|
145
|
-
var usePrefix, cookieName, cookieValue, secureFlag, domainFlag, httpOnlyFlag, cookieString, verification;
|
|
146
|
-
return _regenerator().w(function (_context2) {
|
|
147
|
-
while (1) switch (_context2.n) {
|
|
148
|
-
case 0:
|
|
149
|
-
if (!(typeof document === 'undefined')) {
|
|
150
|
-
_context2.n = 1;
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
console.log("[CookieStorageAdaptor] setItem(".concat(key, "): document undefined, skipping"));
|
|
154
|
-
return _context2.a(2);
|
|
155
|
-
case 1:
|
|
156
|
-
// Check if this key should be stored without prefix for server access
|
|
157
|
-
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
158
|
-
cookieName = usePrefix ? this.options.prefix + key : key; // Stringify objects/arrays like localStorage does
|
|
159
|
-
cookieValue = _typeof(value) === 'object' ? JSON.stringify(value) : String(value);
|
|
160
|
-
console.log("[CookieStorageAdaptor] setItem(".concat(key, "): storing as \"").concat(cookieName, "\" ").concat(usePrefix ? '(prefixed)' : '(server-accessible)'));
|
|
161
|
-
console.log("[CookieStorageAdaptor] Original value:", value);
|
|
162
|
-
console.log("[CookieStorageAdaptor] Cookie value:", cookieValue);
|
|
163
|
-
|
|
164
|
-
// Build cookie string with security options
|
|
165
|
-
secureFlag = this.options.secure ? '; Secure' : '';
|
|
166
|
-
domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
|
|
167
|
-
httpOnlyFlag = this.options.httpOnly ? '; HttpOnly' : '';
|
|
168
|
-
cookieString = "".concat(cookieName, "=").concat(encodeURIComponent(cookieValue), "; path=").concat(this.options.path, "; max-age=").concat(this.options.maxAge, "; SameSite=").concat(this.options.sameSite).concat(secureFlag).concat(domainFlag).concat(httpOnlyFlag);
|
|
169
|
-
console.log("[CookieStorageAdaptor] Full cookie string:", cookieString);
|
|
170
|
-
document.cookie = cookieString;
|
|
171
|
-
|
|
172
|
-
// Verify the cookie was set by immediately reading it back
|
|
173
|
-
_context2.n = 2;
|
|
174
|
-
return this.getItem(key);
|
|
175
|
-
case 2:
|
|
176
|
-
verification = _context2.v;
|
|
177
|
-
if (verification !== null) {
|
|
178
|
-
console.log("[CookieStorageAdaptor] \u2705 Successfully set and verified cookie: ".concat(cookieName));
|
|
179
|
-
} else {
|
|
180
|
-
console.error("[CookieStorageAdaptor] \u274C Failed to set cookie: ".concat(cookieName));
|
|
181
|
-
}
|
|
182
|
-
case 3:
|
|
183
|
-
return _context2.a(2);
|
|
184
|
-
}
|
|
185
|
-
}, _callee2, this);
|
|
186
|
-
}));
|
|
187
|
-
function setItem(_x2, _x3) {
|
|
188
|
-
return _setItem.apply(this, arguments);
|
|
189
|
-
}
|
|
190
|
-
return setItem;
|
|
191
|
-
}()
|
|
192
|
-
/**
|
|
193
|
-
* Remove item from cookies (localStorage-compatible interface)
|
|
194
|
-
*/
|
|
195
|
-
)
|
|
196
|
-
}, {
|
|
197
|
-
key: "removeItem",
|
|
198
|
-
value: (function () {
|
|
199
|
-
var _removeItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(key) {
|
|
200
|
-
var usePrefix, cookieName, existingValue, secureFlag, domainFlag, removalString, verification;
|
|
201
|
-
return _regenerator().w(function (_context3) {
|
|
202
|
-
while (1) switch (_context3.n) {
|
|
203
|
-
case 0:
|
|
204
|
-
if (!(typeof document === 'undefined')) {
|
|
205
|
-
_context3.n = 1;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
console.log("[CookieStorageAdaptor] removeItem(".concat(key, "): document undefined, skipping"));
|
|
209
|
-
return _context3.a(2);
|
|
210
|
-
case 1:
|
|
211
|
-
// Check if this key should be stored without prefix for server access
|
|
212
|
-
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
213
|
-
cookieName = usePrefix ? this.options.prefix + key : key;
|
|
214
|
-
console.log("[CookieStorageAdaptor] removeItem(".concat(key, "): removing cookie \"").concat(cookieName, "\" ").concat(usePrefix ? '(prefixed)' : '(server-accessible)'));
|
|
215
|
-
|
|
216
|
-
// Check if cookie exists before removal
|
|
217
|
-
_context3.n = 2;
|
|
218
|
-
return this.getItem(key);
|
|
219
|
-
case 2:
|
|
220
|
-
existingValue = _context3.v;
|
|
221
|
-
if (existingValue !== null) {
|
|
222
|
-
console.log("[CookieStorageAdaptor] Cookie \"".concat(cookieName, "\" exists, removing..."));
|
|
223
|
-
} else {
|
|
224
|
-
console.log("[CookieStorageAdaptor] Cookie \"".concat(cookieName, "\" doesn't exist, removal not needed"));
|
|
225
|
-
}
|
|
226
|
-
secureFlag = this.options.secure ? '; Secure' : '';
|
|
227
|
-
domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
|
|
228
|
-
removalString = "".concat(cookieName, "=; path=").concat(this.options.path, "; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=").concat(this.options.sameSite).concat(secureFlag).concat(domainFlag);
|
|
229
|
-
console.log("[CookieStorageAdaptor] Removal cookie string:", removalString);
|
|
230
|
-
document.cookie = removalString;
|
|
231
|
-
|
|
232
|
-
// Verify the cookie was removed
|
|
233
|
-
_context3.n = 3;
|
|
234
|
-
return this.getItem(key);
|
|
235
|
-
case 3:
|
|
236
|
-
verification = _context3.v;
|
|
237
|
-
if (verification === null) {
|
|
238
|
-
console.log("[CookieStorageAdaptor] \u2705 Successfully removed cookie: ".concat(cookieName));
|
|
239
|
-
} else {
|
|
240
|
-
console.error("[CookieStorageAdaptor] \u274C Failed to remove cookie: ".concat(cookieName, ", still has value:"), verification);
|
|
241
|
-
}
|
|
242
|
-
case 4:
|
|
243
|
-
return _context3.a(2);
|
|
244
|
-
}
|
|
245
|
-
}, _callee3, this);
|
|
246
|
-
}));
|
|
247
|
-
function removeItem(_x4) {
|
|
248
|
-
return _removeItem.apply(this, arguments);
|
|
249
|
-
}
|
|
250
|
-
return removeItem;
|
|
251
|
-
}()
|
|
252
|
-
/**
|
|
253
|
-
* Clear all roboto cookies
|
|
254
|
-
*/
|
|
255
|
-
)
|
|
256
|
-
}, {
|
|
257
|
-
key: "clear",
|
|
258
|
-
value: (function () {
|
|
259
|
-
var _clear = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
260
|
-
var cookies, prefix, _iterator2, _step2, cookie, cookieName, key, _t3;
|
|
261
|
-
return _regenerator().w(function (_context4) {
|
|
262
|
-
while (1) switch (_context4.p = _context4.n) {
|
|
263
|
-
case 0:
|
|
264
|
-
if (!(typeof document === 'undefined')) {
|
|
265
|
-
_context4.n = 1;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
return _context4.a(2);
|
|
269
|
-
case 1:
|
|
270
|
-
// Get all cookies and remove ones with our prefix or server access keys
|
|
271
|
-
cookies = document.cookie.split(';');
|
|
272
|
-
prefix = this.options.prefix;
|
|
273
|
-
_iterator2 = _createForOfIteratorHelper(cookies);
|
|
274
|
-
_context4.p = 2;
|
|
275
|
-
_iterator2.s();
|
|
276
|
-
case 3:
|
|
277
|
-
if ((_step2 = _iterator2.n()).done) {
|
|
278
|
-
_context4.n = 7;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
cookie = _step2.value;
|
|
282
|
-
cookieName = cookie.split('=')[0].trim(); // Remove prefixed cookies
|
|
283
|
-
if (!cookieName.startsWith(prefix)) {
|
|
284
|
-
_context4.n = 5;
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
key = cookieName.substring(prefix.length);
|
|
288
|
-
_context4.n = 4;
|
|
289
|
-
return this.removeItem(key);
|
|
290
|
-
case 4:
|
|
291
|
-
_context4.n = 6;
|
|
292
|
-
break;
|
|
293
|
-
case 5:
|
|
294
|
-
if (!this.options.serverAccessKeys.includes(cookieName)) {
|
|
295
|
-
_context4.n = 6;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
_context4.n = 6;
|
|
299
|
-
return this.removeItem(cookieName);
|
|
300
|
-
case 6:
|
|
301
|
-
_context4.n = 3;
|
|
302
|
-
break;
|
|
303
|
-
case 7:
|
|
304
|
-
_context4.n = 9;
|
|
305
|
-
break;
|
|
306
|
-
case 8:
|
|
307
|
-
_context4.p = 8;
|
|
308
|
-
_t3 = _context4.v;
|
|
309
|
-
_iterator2.e(_t3);
|
|
310
|
-
case 9:
|
|
311
|
-
_context4.p = 9;
|
|
312
|
-
_iterator2.f();
|
|
313
|
-
return _context4.f(9);
|
|
314
|
-
case 10:
|
|
315
|
-
return _context4.a(2);
|
|
316
|
-
}
|
|
317
|
-
}, _callee4, this, [[2, 8, 9, 10]]);
|
|
318
|
-
}));
|
|
319
|
-
function clear() {
|
|
320
|
-
return _clear.apply(this, arguments);
|
|
321
|
-
}
|
|
322
|
-
return clear;
|
|
323
|
-
}()
|
|
324
|
-
/**
|
|
325
|
-
* Get all keys (for debugging/compatibility)
|
|
326
|
-
*/
|
|
327
|
-
)
|
|
328
|
-
}, {
|
|
329
|
-
key: "keys",
|
|
330
|
-
value: (function () {
|
|
331
|
-
var _keys = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
332
|
-
var cookies, prefix, keys, _iterator3, _step3, cookie, cookieName;
|
|
333
|
-
return _regenerator().w(function (_context5) {
|
|
334
|
-
while (1) switch (_context5.n) {
|
|
335
|
-
case 0:
|
|
336
|
-
if (!(typeof document === 'undefined')) {
|
|
337
|
-
_context5.n = 1;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
return _context5.a(2, []);
|
|
341
|
-
case 1:
|
|
342
|
-
cookies = document.cookie.split(';');
|
|
343
|
-
prefix = this.options.prefix;
|
|
344
|
-
keys = [];
|
|
345
|
-
_iterator3 = _createForOfIteratorHelper(cookies);
|
|
346
|
-
try {
|
|
347
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
348
|
-
cookie = _step3.value;
|
|
349
|
-
cookieName = cookie.split('=')[0].trim(); // Add prefixed cookies
|
|
350
|
-
if (cookieName.startsWith(prefix)) {
|
|
351
|
-
keys.push(cookieName.substring(prefix.length));
|
|
352
|
-
}
|
|
353
|
-
// Add server access keys (non-prefixed)
|
|
354
|
-
else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
355
|
-
keys.push(cookieName);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
} catch (err) {
|
|
359
|
-
_iterator3.e(err);
|
|
360
|
-
} finally {
|
|
361
|
-
_iterator3.f();
|
|
362
|
-
}
|
|
363
|
-
return _context5.a(2, keys);
|
|
364
|
-
}
|
|
365
|
-
}, _callee5, this);
|
|
366
|
-
}));
|
|
367
|
-
function keys() {
|
|
368
|
-
return _keys.apply(this, arguments);
|
|
369
|
-
}
|
|
370
|
-
return keys;
|
|
371
|
-
}()
|
|
372
|
-
/**
|
|
373
|
-
* Debug method to log all current cookies and adapter state
|
|
374
|
-
*/
|
|
375
|
-
)
|
|
376
|
-
}, {
|
|
377
|
-
key: "debugState",
|
|
378
|
-
value: function debugState() {
|
|
379
|
-
if (typeof document === 'undefined') {
|
|
380
|
-
console.log('[CookieStorageAdaptor] DEBUG: document undefined (server-side)');
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
console.log('[CookieStorageAdaptor] DEBUG STATE:');
|
|
384
|
-
console.log('- Options:', this.options);
|
|
385
|
-
console.log('- All cookies:', document.cookie);
|
|
386
|
-
var cookies = document.cookie.split(';');
|
|
387
|
-
var robotoKeys = [];
|
|
388
|
-
var serverKeys = [];
|
|
389
|
-
var otherKeys = [];
|
|
390
|
-
var _iterator4 = _createForOfIteratorHelper(cookies),
|
|
391
|
-
_step4;
|
|
392
|
-
try {
|
|
393
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
394
|
-
var cookie = _step4.value;
|
|
395
|
-
var cookieName = cookie.split('=')[0].trim();
|
|
396
|
-
if (cookieName.startsWith(this.options.prefix)) {
|
|
397
|
-
robotoKeys.push(cookieName);
|
|
398
|
-
} else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
399
|
-
serverKeys.push(cookieName);
|
|
400
|
-
} else if (cookieName) {
|
|
401
|
-
otherKeys.push(cookieName);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
} catch (err) {
|
|
405
|
-
_iterator4.e(err);
|
|
406
|
-
} finally {
|
|
407
|
-
_iterator4.f();
|
|
408
|
-
}
|
|
409
|
-
console.log('- Roboto prefixed cookies:', robotoKeys);
|
|
410
|
-
console.log('- Server access cookies:', serverKeys);
|
|
411
|
-
console.log('- Other cookies:', otherKeys);
|
|
412
|
-
}
|
|
413
|
-
}]);
|
|
414
|
-
}();
|
|
415
|
-
export { CookieStorageAdaptor as default };
|