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/.last-build
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2025-10-01T06:27:28.595Z
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
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); }
|
|
8
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
|
+
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); }
|
|
22
|
+
/**
|
|
23
|
+
* Cookie-based storage adaptor for roboto-js
|
|
24
|
+
* Provides a localStorage-compatible interface using cookies
|
|
25
|
+
* This enables server-side access to authentication tokens
|
|
26
|
+
*/
|
|
27
|
+
var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
|
|
28
|
+
function CookieStorageAdaptor() {
|
|
29
|
+
var _options$secure, _options$sameSite, _options$path, _options$maxAge, _options$domain, _options$prefix, _options$serverAccess;
|
|
30
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
31
|
+
_classCallCheck(this, CookieStorageAdaptor);
|
|
32
|
+
this.options = _objectSpread({
|
|
33
|
+
// Security settings
|
|
34
|
+
secure: (_options$secure = options.secure) !== null && _options$secure !== void 0 ? _options$secure : typeof window !== 'undefined' && window.location.protocol === 'https:',
|
|
35
|
+
sameSite: (_options$sameSite = options.sameSite) !== null && _options$sameSite !== void 0 ? _options$sameSite : 'Lax',
|
|
36
|
+
httpOnly: false,
|
|
37
|
+
// Must be false so client-side JS can access
|
|
38
|
+
|
|
39
|
+
// Cookie settings
|
|
40
|
+
path: (_options$path = options.path) !== null && _options$path !== void 0 ? _options$path : '/',
|
|
41
|
+
maxAge: (_options$maxAge = options.maxAge) !== null && _options$maxAge !== void 0 ? _options$maxAge : 24 * 60 * 60,
|
|
42
|
+
// 24 hours default
|
|
43
|
+
domain: (_options$domain = options.domain) !== null && _options$domain !== void 0 ? _options$domain : undefined,
|
|
44
|
+
// Let browser determine domain
|
|
45
|
+
|
|
46
|
+
// Prefix for roboto cookies to avoid conflicts
|
|
47
|
+
prefix: (_options$prefix = options.prefix) !== null && _options$prefix !== void 0 ? _options$prefix : 'rbt_',
|
|
48
|
+
// Keys that should be stored without prefix for server-side access
|
|
49
|
+
serverAccessKeys: (_options$serverAccess = options.serverAccessKeys) !== null && _options$serverAccess !== void 0 ? _options$serverAccess : ['authtoken', 'accessKey', 'apikey']
|
|
50
|
+
}, options);
|
|
51
|
+
console.log('[CookieStorageAdaptor] Initialized with options:', {
|
|
52
|
+
secure: this.options.secure,
|
|
53
|
+
sameSite: this.options.sameSite,
|
|
54
|
+
path: this.options.path,
|
|
55
|
+
maxAge: this.options.maxAge,
|
|
56
|
+
domain: this.options.domain,
|
|
57
|
+
prefix: this.options.prefix,
|
|
58
|
+
serverAccessKeys: this.options.serverAccessKeys
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get item from cookies (localStorage-compatible interface)
|
|
64
|
+
*/
|
|
65
|
+
_createClass(CookieStorageAdaptor, [{
|
|
66
|
+
key: "getItem",
|
|
67
|
+
value: (function () {
|
|
68
|
+
var _getItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
|
|
69
|
+
var usePrefix, cookieName, name, decodedCookie, cookies, _iterator, _step, cookie, rawValue, parsedValue;
|
|
70
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
71
|
+
while (1) switch (_context.prev = _context.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(typeof document === 'undefined')) {
|
|
74
|
+
_context.next = 3;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): document undefined, returning null"));
|
|
78
|
+
return _context.abrupt("return", null);
|
|
79
|
+
case 3:
|
|
80
|
+
// Check if this key should be stored without prefix for server access
|
|
81
|
+
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
82
|
+
cookieName = usePrefix ? this.options.prefix + key : key;
|
|
83
|
+
name = cookieName + '=';
|
|
84
|
+
decodedCookie = decodeURIComponent(document.cookie);
|
|
85
|
+
cookies = decodedCookie.split(';');
|
|
86
|
+
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): looking for cookie \"").concat(cookieName, "\" ").concat(usePrefix ? '(prefixed)' : '(server-accessible)'));
|
|
87
|
+
console.log("[CookieStorageAdaptor] Available cookies:", cookies.map(function (c) {
|
|
88
|
+
return c.trim().split('=')[0];
|
|
89
|
+
}).join(', '));
|
|
90
|
+
_iterator = _createForOfIteratorHelper(cookies);
|
|
91
|
+
_context.prev = 11;
|
|
92
|
+
_iterator.s();
|
|
93
|
+
case 13:
|
|
94
|
+
if ((_step = _iterator.n()).done) {
|
|
95
|
+
_context.next = 31;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
cookie = _step.value;
|
|
99
|
+
cookie = cookie.trim();
|
|
100
|
+
if (!(cookie.indexOf(name) === 0)) {
|
|
101
|
+
_context.next = 29;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
rawValue = cookie.substring(name.length, cookie.length);
|
|
105
|
+
console.log("[CookieStorageAdaptor] Found cookie \"".concat(cookieName, "\" with raw value:"), rawValue);
|
|
106
|
+
|
|
107
|
+
// Handle JSON values (like rbtUser)
|
|
108
|
+
_context.prev = 19;
|
|
109
|
+
parsedValue = JSON.parse(rawValue);
|
|
110
|
+
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): returning parsed JSON:"), parsedValue);
|
|
111
|
+
return _context.abrupt("return", parsedValue);
|
|
112
|
+
case 25:
|
|
113
|
+
_context.prev = 25;
|
|
114
|
+
_context.t0 = _context["catch"](19);
|
|
115
|
+
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): returning string value:"), rawValue);
|
|
116
|
+
return _context.abrupt("return", rawValue);
|
|
117
|
+
case 29:
|
|
118
|
+
_context.next = 13;
|
|
119
|
+
break;
|
|
120
|
+
case 31:
|
|
121
|
+
_context.next = 36;
|
|
122
|
+
break;
|
|
123
|
+
case 33:
|
|
124
|
+
_context.prev = 33;
|
|
125
|
+
_context.t1 = _context["catch"](11);
|
|
126
|
+
_iterator.e(_context.t1);
|
|
127
|
+
case 36:
|
|
128
|
+
_context.prev = 36;
|
|
129
|
+
_iterator.f();
|
|
130
|
+
return _context.finish(36);
|
|
131
|
+
case 39:
|
|
132
|
+
console.log("[CookieStorageAdaptor] getItem(".concat(key, "): cookie \"").concat(cookieName, "\" not found, returning null"));
|
|
133
|
+
return _context.abrupt("return", null);
|
|
134
|
+
case 41:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context.stop();
|
|
137
|
+
}
|
|
138
|
+
}, _callee, this, [[11, 33, 36, 39], [19, 25]]);
|
|
139
|
+
}));
|
|
140
|
+
function getItem(_x) {
|
|
141
|
+
return _getItem.apply(this, arguments);
|
|
142
|
+
}
|
|
143
|
+
return getItem;
|
|
144
|
+
}()
|
|
145
|
+
/**
|
|
146
|
+
* Set item in cookies (localStorage-compatible interface)
|
|
147
|
+
*/
|
|
148
|
+
)
|
|
149
|
+
}, {
|
|
150
|
+
key: "setItem",
|
|
151
|
+
value: (function () {
|
|
152
|
+
var _setItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
153
|
+
var usePrefix, cookieName, cookieValue, secureFlag, domainFlag, httpOnlyFlag, cookieString, verification;
|
|
154
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
155
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
if (!(typeof document === 'undefined')) {
|
|
158
|
+
_context2.next = 3;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
console.log("[CookieStorageAdaptor] setItem(".concat(key, "): document undefined, skipping"));
|
|
162
|
+
return _context2.abrupt("return");
|
|
163
|
+
case 3:
|
|
164
|
+
// Check if this key should be stored without prefix for server access
|
|
165
|
+
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
166
|
+
cookieName = usePrefix ? this.options.prefix + key : key; // Stringify objects/arrays like localStorage does
|
|
167
|
+
cookieValue = _typeof(value) === 'object' ? JSON.stringify(value) : String(value);
|
|
168
|
+
console.log("[CookieStorageAdaptor] setItem(".concat(key, "): storing as \"").concat(cookieName, "\" ").concat(usePrefix ? '(prefixed)' : '(server-accessible)'));
|
|
169
|
+
console.log("[CookieStorageAdaptor] Original value:", value);
|
|
170
|
+
console.log("[CookieStorageAdaptor] Cookie value:", cookieValue);
|
|
171
|
+
|
|
172
|
+
// Build cookie string with security options
|
|
173
|
+
secureFlag = this.options.secure ? '; Secure' : '';
|
|
174
|
+
domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
|
|
175
|
+
httpOnlyFlag = this.options.httpOnly ? '; HttpOnly' : '';
|
|
176
|
+
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);
|
|
177
|
+
console.log("[CookieStorageAdaptor] Full cookie string:", cookieString);
|
|
178
|
+
document.cookie = cookieString;
|
|
179
|
+
|
|
180
|
+
// Verify the cookie was set by immediately reading it back
|
|
181
|
+
_context2.next = 17;
|
|
182
|
+
return this.getItem(key);
|
|
183
|
+
case 17:
|
|
184
|
+
verification = _context2.sent;
|
|
185
|
+
if (verification !== null) {
|
|
186
|
+
console.log("[CookieStorageAdaptor] \u2705 Successfully set and verified cookie: ".concat(cookieName));
|
|
187
|
+
} else {
|
|
188
|
+
console.error("[CookieStorageAdaptor] \u274C Failed to set cookie: ".concat(cookieName));
|
|
189
|
+
}
|
|
190
|
+
case 19:
|
|
191
|
+
case "end":
|
|
192
|
+
return _context2.stop();
|
|
193
|
+
}
|
|
194
|
+
}, _callee2, this);
|
|
195
|
+
}));
|
|
196
|
+
function setItem(_x2, _x3) {
|
|
197
|
+
return _setItem.apply(this, arguments);
|
|
198
|
+
}
|
|
199
|
+
return setItem;
|
|
200
|
+
}()
|
|
201
|
+
/**
|
|
202
|
+
* Remove item from cookies (localStorage-compatible interface)
|
|
203
|
+
*/
|
|
204
|
+
)
|
|
205
|
+
}, {
|
|
206
|
+
key: "removeItem",
|
|
207
|
+
value: (function () {
|
|
208
|
+
var _removeItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key) {
|
|
209
|
+
var usePrefix, cookieName, existingValue, secureFlag, domainFlag, removalString, verification;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
211
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
if (!(typeof document === 'undefined')) {
|
|
214
|
+
_context3.next = 3;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
console.log("[CookieStorageAdaptor] removeItem(".concat(key, "): document undefined, skipping"));
|
|
218
|
+
return _context3.abrupt("return");
|
|
219
|
+
case 3:
|
|
220
|
+
// Check if this key should be stored without prefix for server access
|
|
221
|
+
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
222
|
+
cookieName = usePrefix ? this.options.prefix + key : key;
|
|
223
|
+
console.log("[CookieStorageAdaptor] removeItem(".concat(key, "): removing cookie \"").concat(cookieName, "\" ").concat(usePrefix ? '(prefixed)' : '(server-accessible)'));
|
|
224
|
+
|
|
225
|
+
// Check if cookie exists before removal
|
|
226
|
+
_context3.next = 8;
|
|
227
|
+
return this.getItem(key);
|
|
228
|
+
case 8:
|
|
229
|
+
existingValue = _context3.sent;
|
|
230
|
+
if (existingValue !== null) {
|
|
231
|
+
console.log("[CookieStorageAdaptor] Cookie \"".concat(cookieName, "\" exists, removing..."));
|
|
232
|
+
} else {
|
|
233
|
+
console.log("[CookieStorageAdaptor] Cookie \"".concat(cookieName, "\" doesn't exist, removal not needed"));
|
|
234
|
+
}
|
|
235
|
+
secureFlag = this.options.secure ? '; Secure' : '';
|
|
236
|
+
domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
|
|
237
|
+
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);
|
|
238
|
+
console.log("[CookieStorageAdaptor] Removal cookie string:", removalString);
|
|
239
|
+
document.cookie = removalString;
|
|
240
|
+
|
|
241
|
+
// Verify the cookie was removed
|
|
242
|
+
_context3.next = 17;
|
|
243
|
+
return this.getItem(key);
|
|
244
|
+
case 17:
|
|
245
|
+
verification = _context3.sent;
|
|
246
|
+
if (verification === null) {
|
|
247
|
+
console.log("[CookieStorageAdaptor] \u2705 Successfully removed cookie: ".concat(cookieName));
|
|
248
|
+
} else {
|
|
249
|
+
console.error("[CookieStorageAdaptor] \u274C Failed to remove cookie: ".concat(cookieName, ", still has value:"), verification);
|
|
250
|
+
}
|
|
251
|
+
case 19:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context3.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee3, this);
|
|
256
|
+
}));
|
|
257
|
+
function removeItem(_x4) {
|
|
258
|
+
return _removeItem.apply(this, arguments);
|
|
259
|
+
}
|
|
260
|
+
return removeItem;
|
|
261
|
+
}()
|
|
262
|
+
/**
|
|
263
|
+
* Clear all roboto cookies
|
|
264
|
+
*/
|
|
265
|
+
)
|
|
266
|
+
}, {
|
|
267
|
+
key: "clear",
|
|
268
|
+
value: (function () {
|
|
269
|
+
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
270
|
+
var cookies, prefix, _iterator2, _step2, cookie, cookieName, key;
|
|
271
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
272
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
273
|
+
case 0:
|
|
274
|
+
if (!(typeof document === 'undefined')) {
|
|
275
|
+
_context4.next = 2;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
return _context4.abrupt("return");
|
|
279
|
+
case 2:
|
|
280
|
+
// Get all cookies and remove ones with our prefix or server access keys
|
|
281
|
+
cookies = document.cookie.split(';');
|
|
282
|
+
prefix = this.options.prefix;
|
|
283
|
+
_iterator2 = _createForOfIteratorHelper(cookies);
|
|
284
|
+
_context4.prev = 5;
|
|
285
|
+
_iterator2.s();
|
|
286
|
+
case 7:
|
|
287
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
288
|
+
_context4.next = 21;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
cookie = _step2.value;
|
|
292
|
+
cookieName = cookie.split('=')[0].trim(); // Remove prefixed cookies
|
|
293
|
+
if (!cookieName.startsWith(prefix)) {
|
|
294
|
+
_context4.next = 16;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
key = cookieName.substring(prefix.length);
|
|
298
|
+
_context4.next = 14;
|
|
299
|
+
return this.removeItem(key);
|
|
300
|
+
case 14:
|
|
301
|
+
_context4.next = 19;
|
|
302
|
+
break;
|
|
303
|
+
case 16:
|
|
304
|
+
if (!this.options.serverAccessKeys.includes(cookieName)) {
|
|
305
|
+
_context4.next = 19;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
_context4.next = 19;
|
|
309
|
+
return this.removeItem(cookieName);
|
|
310
|
+
case 19:
|
|
311
|
+
_context4.next = 7;
|
|
312
|
+
break;
|
|
313
|
+
case 21:
|
|
314
|
+
_context4.next = 26;
|
|
315
|
+
break;
|
|
316
|
+
case 23:
|
|
317
|
+
_context4.prev = 23;
|
|
318
|
+
_context4.t0 = _context4["catch"](5);
|
|
319
|
+
_iterator2.e(_context4.t0);
|
|
320
|
+
case 26:
|
|
321
|
+
_context4.prev = 26;
|
|
322
|
+
_iterator2.f();
|
|
323
|
+
return _context4.finish(26);
|
|
324
|
+
case 29:
|
|
325
|
+
case "end":
|
|
326
|
+
return _context4.stop();
|
|
327
|
+
}
|
|
328
|
+
}, _callee4, this, [[5, 23, 26, 29]]);
|
|
329
|
+
}));
|
|
330
|
+
function clear() {
|
|
331
|
+
return _clear.apply(this, arguments);
|
|
332
|
+
}
|
|
333
|
+
return clear;
|
|
334
|
+
}()
|
|
335
|
+
/**
|
|
336
|
+
* Get all keys (for debugging/compatibility)
|
|
337
|
+
*/
|
|
338
|
+
)
|
|
339
|
+
}, {
|
|
340
|
+
key: "keys",
|
|
341
|
+
value: (function () {
|
|
342
|
+
var _keys = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
343
|
+
var cookies, prefix, keys, _iterator3, _step3, cookie, cookieName;
|
|
344
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
345
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
if (!(typeof document === 'undefined')) {
|
|
348
|
+
_context5.next = 2;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
return _context5.abrupt("return", []);
|
|
352
|
+
case 2:
|
|
353
|
+
cookies = document.cookie.split(';');
|
|
354
|
+
prefix = this.options.prefix;
|
|
355
|
+
keys = [];
|
|
356
|
+
_iterator3 = _createForOfIteratorHelper(cookies);
|
|
357
|
+
try {
|
|
358
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
359
|
+
cookie = _step3.value;
|
|
360
|
+
cookieName = cookie.split('=')[0].trim(); // Add prefixed cookies
|
|
361
|
+
if (cookieName.startsWith(prefix)) {
|
|
362
|
+
keys.push(cookieName.substring(prefix.length));
|
|
363
|
+
}
|
|
364
|
+
// Add server access keys (non-prefixed)
|
|
365
|
+
else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
366
|
+
keys.push(cookieName);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
} catch (err) {
|
|
370
|
+
_iterator3.e(err);
|
|
371
|
+
} finally {
|
|
372
|
+
_iterator3.f();
|
|
373
|
+
}
|
|
374
|
+
return _context5.abrupt("return", keys);
|
|
375
|
+
case 8:
|
|
376
|
+
case "end":
|
|
377
|
+
return _context5.stop();
|
|
378
|
+
}
|
|
379
|
+
}, _callee5, this);
|
|
380
|
+
}));
|
|
381
|
+
function keys() {
|
|
382
|
+
return _keys.apply(this, arguments);
|
|
383
|
+
}
|
|
384
|
+
return keys;
|
|
385
|
+
}()
|
|
386
|
+
/**
|
|
387
|
+
* Debug method to log all current cookies and adapter state
|
|
388
|
+
*/
|
|
389
|
+
)
|
|
390
|
+
}, {
|
|
391
|
+
key: "debugState",
|
|
392
|
+
value: function debugState() {
|
|
393
|
+
if (typeof document === 'undefined') {
|
|
394
|
+
console.log('[CookieStorageAdaptor] DEBUG: document undefined (server-side)');
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
console.log('[CookieStorageAdaptor] DEBUG STATE:');
|
|
398
|
+
console.log('- Options:', this.options);
|
|
399
|
+
console.log('- All cookies:', document.cookie);
|
|
400
|
+
var cookies = document.cookie.split(';');
|
|
401
|
+
var robotoKeys = [];
|
|
402
|
+
var serverKeys = [];
|
|
403
|
+
var otherKeys = [];
|
|
404
|
+
var _iterator4 = _createForOfIteratorHelper(cookies),
|
|
405
|
+
_step4;
|
|
406
|
+
try {
|
|
407
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
408
|
+
var cookie = _step4.value;
|
|
409
|
+
var cookieName = cookie.split('=')[0].trim();
|
|
410
|
+
if (cookieName.startsWith(this.options.prefix)) {
|
|
411
|
+
robotoKeys.push(cookieName);
|
|
412
|
+
} else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
413
|
+
serverKeys.push(cookieName);
|
|
414
|
+
} else if (cookieName) {
|
|
415
|
+
otherKeys.push(cookieName);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
} catch (err) {
|
|
419
|
+
_iterator4.e(err);
|
|
420
|
+
} finally {
|
|
421
|
+
_iterator4.f();
|
|
422
|
+
}
|
|
423
|
+
console.log('- Roboto prefixed cookies:', robotoKeys);
|
|
424
|
+
console.log('- Server access cookies:', serverKeys);
|
|
425
|
+
console.log('- Other cookies:', otherKeys);
|
|
426
|
+
}
|
|
427
|
+
}]);
|
|
428
|
+
return CookieStorageAdaptor;
|
|
429
|
+
}();
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "CookieStorageAdaptor", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _cookie_storage_adaptor["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "RbtApi", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -26,6 +32,7 @@ var _rbt_api = _interopRequireDefault(require("./rbt_api.cjs"));
|
|
|
26
32
|
var _rbt_object = _interopRequireDefault(require("./rbt_object.cjs"));
|
|
27
33
|
var _rbt_file = _interopRequireDefault(require("./rbt_file.cjs"));
|
|
28
34
|
var _rbt_metrics_api = _interopRequireDefault(require("./rbt_metrics_api.cjs"));
|
|
35
|
+
var _cookie_storage_adaptor = _interopRequireDefault(require("./cookie_storage_adaptor.cjs"));
|
|
29
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
30
37
|
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
38
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
@@ -38,12 +45,15 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
38
45
|
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); }
|
|
39
46
|
var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
40
47
|
function Roboto(_ref) {
|
|
48
|
+
var _this = this;
|
|
41
49
|
var host = _ref.host,
|
|
42
50
|
accessKey = _ref.accessKey,
|
|
43
51
|
localStorageAdaptor = _ref.localStorageAdaptor,
|
|
44
52
|
_ref$disableWebSocket = _ref.disableWebSocket,
|
|
45
53
|
disableWebSocket = _ref$disableWebSocket === void 0 ? false : _ref$disableWebSocket,
|
|
46
|
-
metricsHost = _ref.metricsHost
|
|
54
|
+
metricsHost = _ref.metricsHost,
|
|
55
|
+
_ref$useCookies = _ref.useCookies,
|
|
56
|
+
useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies;
|
|
47
57
|
var proxyReq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
48
58
|
_classCallCheck(this, Roboto);
|
|
49
59
|
if (Roboto.instance && !proxyReq) {
|
|
@@ -53,12 +63,31 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
53
63
|
}
|
|
54
64
|
var isBrowser = typeof window !== "undefined";
|
|
55
65
|
this.data = {};
|
|
66
|
+
|
|
67
|
+
// Auto-configure storage adaptor
|
|
68
|
+
var storageAdaptor = localStorageAdaptor;
|
|
69
|
+
if (!storageAdaptor && isBrowser && useCookies) {
|
|
70
|
+
// Use cookies by default in browser for better server-side compatibility
|
|
71
|
+
storageAdaptor = new _cookie_storage_adaptor["default"]({
|
|
72
|
+
secure: window.location.protocol === 'https:',
|
|
73
|
+
sameSite: 'Lax',
|
|
74
|
+
maxAge: 24 * 60 * 60 // 24 hours
|
|
75
|
+
});
|
|
76
|
+
console.log('[Roboto] Using CookieStorageAdaptor for authentication tokens');
|
|
77
|
+
|
|
78
|
+
// Set accessKey for server-side authentication (handled automatically by adapter)
|
|
79
|
+
if (accessKey) {
|
|
80
|
+
storageAdaptor.setItem('accessKey', accessKey)["catch"](function (e) {
|
|
81
|
+
return console.warn('[Roboto] Failed to set accessKey cookie:', e);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
56
85
|
this.config = {
|
|
57
86
|
accessKey: accessKey,
|
|
58
87
|
// Use passed accessKey
|
|
59
88
|
baseUrl: "https://".concat(host),
|
|
60
89
|
// Use passed host
|
|
61
|
-
localStorageAdaptor:
|
|
90
|
+
localStorageAdaptor: storageAdaptor
|
|
62
91
|
};
|
|
63
92
|
|
|
64
93
|
// DEVELOPMENT
|
|
@@ -83,6 +112,14 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
83
112
|
this.api = new _rbt_api["default"](this.config);
|
|
84
113
|
if (isBrowser) {
|
|
85
114
|
this.api.initLocalDb();
|
|
115
|
+
|
|
116
|
+
// Add global debug method for cookie storage adapter
|
|
117
|
+
if (this.config.localStorageAdaptor && this.config.localStorageAdaptor.debugState) {
|
|
118
|
+
window.debugRobotoCookies = function () {
|
|
119
|
+
return _this.config.localStorageAdaptor.debugState();
|
|
120
|
+
};
|
|
121
|
+
console.log('[Roboto] Added global debug method: window.debugRobotoCookies()');
|
|
122
|
+
}
|
|
86
123
|
}
|
|
87
124
|
|
|
88
125
|
// METRICS API instance (separate host or same)
|
|
@@ -108,7 +145,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
108
145
|
_createClass(Roboto, [{
|
|
109
146
|
key: "getVersion",
|
|
110
147
|
value: function getVersion() {
|
|
111
|
-
return '1.7.
|
|
148
|
+
return '1.7.3';
|
|
112
149
|
}
|
|
113
150
|
}, {
|
|
114
151
|
key: "setSiteEnv",
|
|
@@ -222,11 +259,26 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
222
259
|
key: "logout",
|
|
223
260
|
value: function () {
|
|
224
261
|
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
262
|
+
var result;
|
|
225
263
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
226
264
|
while (1) switch (_context3.prev = _context3.next) {
|
|
227
265
|
case 0:
|
|
228
|
-
|
|
229
|
-
|
|
266
|
+
_context3.next = 2;
|
|
267
|
+
return this.api.logout();
|
|
268
|
+
case 2:
|
|
269
|
+
result = _context3.sent;
|
|
270
|
+
if (!this.config.localStorageAdaptor) {
|
|
271
|
+
_context3.next = 8;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
_context3.next = 6;
|
|
275
|
+
return this.config.localStorageAdaptor.removeItem('accessKey');
|
|
276
|
+
case 6:
|
|
277
|
+
_context3.next = 8;
|
|
278
|
+
return this.config.localStorageAdaptor.removeItem('authtoken');
|
|
279
|
+
case 8:
|
|
280
|
+
return _context3.abrupt("return", result);
|
|
281
|
+
case 9:
|
|
230
282
|
case "end":
|
|
231
283
|
return _context3.stop();
|
|
232
284
|
}
|