roboto-js 1.8.5 → 1.8.6
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/BUILD_NOTES.md +30 -0
- package/babel.config.json +13 -0
- package/dist/cjs/cookie_storage_adaptor.cjs +38 -84
- package/dist/cjs/index.cjs +21 -14
- package/dist/cjs/rbt_api.cjs +28 -97
- package/dist/cjs/rbt_object.cjs +5 -14
- package/dist/cjs/rbt_user.cjs +1 -3
- package/dist/esm/cookie_storage_adaptor.js +354 -197
- package/dist/esm/index.js +604 -182
- package/dist/esm/rbt_api.js +1970 -1172
- package/dist/esm/rbt_file.js +222 -126
- package/dist/esm/rbt_metrics_api.js +166 -71
- package/dist/esm/rbt_object.js +1014 -708
- package/dist/esm/rbt_user.js +209 -138
- package/dist/index.js +31 -10
- package/dist/rbt_api.js +13 -0
- package/package.json +4 -3
- package/src/index.js +21 -11
- package/src/rbt_api.js +3 -0
|
@@ -1,226 +1,383 @@
|
|
|
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); }
|
|
1
22
|
/**
|
|
2
23
|
* Cookie-based storage adaptor for roboto-js
|
|
3
24
|
* Provides a localStorage-compatible interface using cookies
|
|
4
25
|
* This enables server-side access to authentication tokens
|
|
5
26
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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({
|
|
10
33
|
// Security settings
|
|
11
|
-
secure: options.secure
|
|
12
|
-
sameSite: options.sameSite
|
|
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',
|
|
13
36
|
httpOnly: false,
|
|
14
37
|
// Must be false so client-side JS can access
|
|
15
38
|
|
|
16
39
|
// Cookie settings
|
|
17
|
-
path: options.path
|
|
18
|
-
maxAge: options.maxAge
|
|
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,
|
|
19
42
|
// 24 hours default
|
|
20
|
-
domain: options.domain
|
|
43
|
+
domain: (_options$domain = options.domain) !== null && _options$domain !== void 0 ? _options$domain : undefined,
|
|
21
44
|
// Let browser determine domain
|
|
22
45
|
|
|
23
46
|
// Prefix for roboto cookies to avoid conflicts
|
|
24
|
-
prefix: options.prefix
|
|
47
|
+
prefix: (_options$prefix = options.prefix) !== null && _options$prefix !== void 0 ? _options$prefix : 'rbt_',
|
|
25
48
|
// Keys that should be stored without prefix for server-side access
|
|
26
|
-
serverAccessKeys: options.serverAccessKeys
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
console.log('[CookieStorageAdaptor] Initialized with options:', {
|
|
30
|
-
secure: this.options.secure,
|
|
31
|
-
sameSite: this.options.sameSite,
|
|
32
|
-
path: this.options.path,
|
|
33
|
-
maxAge: this.options.maxAge,
|
|
34
|
-
domain: this.options.domain,
|
|
35
|
-
prefix: this.options.prefix,
|
|
36
|
-
serverAccessKeys: this.options.serverAccessKeys
|
|
37
|
-
});
|
|
49
|
+
serverAccessKeys: (_options$serverAccess = options.serverAccessKeys) !== null && _options$serverAccess !== void 0 ? _options$serverAccess : ['authtoken', 'accessKey', 'apikey']
|
|
50
|
+
}, options);
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
/**
|
|
41
54
|
* Get item from cookies (localStorage-compatible interface)
|
|
42
55
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
_createClass(CookieStorageAdaptor, [{
|
|
57
|
+
key: "getItem",
|
|
58
|
+
value: (function () {
|
|
59
|
+
var _getItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
|
|
60
|
+
var usePrefix, cookieName, name, decodedCookie, cookies, _iterator, _step, cookie, rawValue, parsedValue;
|
|
61
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
+
while (1) switch (_context.prev = _context.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (!(typeof document === 'undefined')) {
|
|
65
|
+
_context.next = 2;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return _context.abrupt("return", null);
|
|
69
|
+
case 2:
|
|
70
|
+
// Check if this key should be stored without prefix for server access
|
|
71
|
+
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
72
|
+
cookieName = usePrefix ? this.options.prefix + key : key;
|
|
73
|
+
name = cookieName + '=';
|
|
74
|
+
decodedCookie = decodeURIComponent(document.cookie);
|
|
75
|
+
cookies = decodedCookie.split(';');
|
|
76
|
+
_iterator = _createForOfIteratorHelper(cookies);
|
|
77
|
+
_context.prev = 8;
|
|
78
|
+
_iterator.s();
|
|
79
|
+
case 10:
|
|
80
|
+
if ((_step = _iterator.n()).done) {
|
|
81
|
+
_context.next = 25;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
cookie = _step.value;
|
|
85
|
+
cookie = cookie.trim();
|
|
86
|
+
if (!(cookie.indexOf(name) === 0)) {
|
|
87
|
+
_context.next = 23;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
rawValue = cookie.substring(name.length, cookie.length);
|
|
91
|
+
_context.prev = 15;
|
|
92
|
+
parsedValue = JSON.parse(rawValue);
|
|
93
|
+
return _context.abrupt("return", parsedValue);
|
|
94
|
+
case 20:
|
|
95
|
+
_context.prev = 20;
|
|
96
|
+
_context.t0 = _context["catch"](15);
|
|
97
|
+
return _context.abrupt("return", rawValue);
|
|
98
|
+
case 23:
|
|
99
|
+
_context.next = 10;
|
|
100
|
+
break;
|
|
101
|
+
case 25:
|
|
102
|
+
_context.next = 30;
|
|
103
|
+
break;
|
|
104
|
+
case 27:
|
|
105
|
+
_context.prev = 27;
|
|
106
|
+
_context.t1 = _context["catch"](8);
|
|
107
|
+
_iterator.e(_context.t1);
|
|
108
|
+
case 30:
|
|
109
|
+
_context.prev = 30;
|
|
110
|
+
_iterator.f();
|
|
111
|
+
return _context.finish(30);
|
|
112
|
+
case 33:
|
|
113
|
+
return _context.abrupt("return", null);
|
|
114
|
+
case 34:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context.stop();
|
|
117
|
+
}
|
|
118
|
+
}, _callee, this, [[8, 27, 30, 33], [15, 20]]);
|
|
119
|
+
}));
|
|
120
|
+
function getItem(_x) {
|
|
121
|
+
return _getItem.apply(this, arguments);
|
|
72
122
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
document.cookie = cookieString;
|
|
104
|
-
|
|
105
|
-
// Verify the cookie was set by immediately reading it back
|
|
106
|
-
const verification = await this.getItem(key);
|
|
107
|
-
if (verification !== null) {
|
|
108
|
-
console.log(`[CookieStorageAdaptor] ✅ Successfully set and verified cookie: ${cookieName}`);
|
|
109
|
-
} else {
|
|
110
|
-
console.error(`[CookieStorageAdaptor] ❌ Failed to set cookie: ${cookieName}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Remove item from cookies (localStorage-compatible interface)
|
|
116
|
-
*/
|
|
117
|
-
async removeItem(key) {
|
|
118
|
-
if (typeof document === 'undefined') {
|
|
119
|
-
console.log(`[CookieStorageAdaptor] removeItem(${key}): document undefined, skipping`);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Check if this key should be stored without prefix for server access
|
|
124
|
-
const usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
125
|
-
const cookieName = usePrefix ? this.options.prefix + key : key;
|
|
126
|
-
console.log(`[CookieStorageAdaptor] removeItem(${key}): removing cookie "${cookieName}" ${usePrefix ? '(prefixed)' : '(server-accessible)'}`);
|
|
123
|
+
return getItem;
|
|
124
|
+
}()
|
|
125
|
+
/**
|
|
126
|
+
* Set item in cookies (localStorage-compatible interface)
|
|
127
|
+
*/
|
|
128
|
+
)
|
|
129
|
+
}, {
|
|
130
|
+
key: "setItem",
|
|
131
|
+
value: (function () {
|
|
132
|
+
var _setItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
133
|
+
var usePrefix, cookieName, cookieValue, secureFlag, domainFlag, httpOnlyFlag, cookieString, verification;
|
|
134
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
135
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
136
|
+
case 0:
|
|
137
|
+
if (!(typeof document === 'undefined')) {
|
|
138
|
+
_context2.next = 2;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
return _context2.abrupt("return");
|
|
142
|
+
case 2:
|
|
143
|
+
// Check if this key should be stored without prefix for server access
|
|
144
|
+
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
145
|
+
cookieName = usePrefix ? this.options.prefix + key : key; // Stringify objects/arrays like localStorage does
|
|
146
|
+
cookieValue = _typeof(value) === 'object' ? JSON.stringify(value) : String(value);
|
|
147
|
+
// Build cookie string with security options
|
|
148
|
+
secureFlag = this.options.secure ? '; Secure' : '';
|
|
149
|
+
domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
|
|
150
|
+
httpOnlyFlag = this.options.httpOnly ? '; HttpOnly' : '';
|
|
151
|
+
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);
|
|
152
|
+
document.cookie = cookieString;
|
|
127
153
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
// Verify the cookie was set by immediately reading it back
|
|
155
|
+
_context2.next = 12;
|
|
156
|
+
return this.getItem(key);
|
|
157
|
+
case 12:
|
|
158
|
+
verification = _context2.sent;
|
|
159
|
+
if (verification !== null) {} else {
|
|
160
|
+
console.error("[CookieStorageAdaptor] \u274C Failed to set cookie: ".concat(cookieName));
|
|
161
|
+
}
|
|
162
|
+
case 14:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context2.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee2, this);
|
|
167
|
+
}));
|
|
168
|
+
function setItem(_x2, _x3) {
|
|
169
|
+
return _setItem.apply(this, arguments);
|
|
170
|
+
}
|
|
171
|
+
return setItem;
|
|
172
|
+
}()
|
|
173
|
+
/**
|
|
174
|
+
* Remove item from cookies (localStorage-compatible interface)
|
|
175
|
+
*/
|
|
176
|
+
)
|
|
177
|
+
}, {
|
|
178
|
+
key: "removeItem",
|
|
179
|
+
value: (function () {
|
|
180
|
+
var _removeItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key) {
|
|
181
|
+
var usePrefix, cookieName, existingValue, secureFlag, domainFlag, removalString, verification;
|
|
182
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
183
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
184
|
+
case 0:
|
|
185
|
+
if (!(typeof document === 'undefined')) {
|
|
186
|
+
_context3.next = 2;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
return _context3.abrupt("return");
|
|
190
|
+
case 2:
|
|
191
|
+
// Check if this key should be stored without prefix for server access
|
|
192
|
+
usePrefix = !this.options.serverAccessKeys.includes(key);
|
|
193
|
+
cookieName = usePrefix ? this.options.prefix + key : key;
|
|
194
|
+
_context3.next = 6;
|
|
195
|
+
return this.getItem(key);
|
|
196
|
+
case 6:
|
|
197
|
+
existingValue = _context3.sent;
|
|
198
|
+
if (existingValue !== null) {} else {}
|
|
199
|
+
secureFlag = this.options.secure ? '; Secure' : '';
|
|
200
|
+
domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
|
|
201
|
+
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);
|
|
202
|
+
document.cookie = removalString;
|
|
161
203
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
204
|
+
// Verify the cookie was removed
|
|
205
|
+
_context3.next = 14;
|
|
206
|
+
return this.getItem(key);
|
|
207
|
+
case 14:
|
|
208
|
+
verification = _context3.sent;
|
|
209
|
+
if (verification === null) {} else {
|
|
210
|
+
console.error("[CookieStorageAdaptor] \u274C Failed to remove cookie: ".concat(cookieName, ", still has value:"), verification);
|
|
211
|
+
}
|
|
212
|
+
case 16:
|
|
213
|
+
case "end":
|
|
214
|
+
return _context3.stop();
|
|
215
|
+
}
|
|
216
|
+
}, _callee3, this);
|
|
217
|
+
}));
|
|
218
|
+
function removeItem(_x4) {
|
|
219
|
+
return _removeItem.apply(this, arguments);
|
|
166
220
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
221
|
+
return removeItem;
|
|
222
|
+
}()
|
|
223
|
+
/**
|
|
224
|
+
* Clear all roboto cookies
|
|
225
|
+
*/
|
|
226
|
+
)
|
|
227
|
+
}, {
|
|
228
|
+
key: "clear",
|
|
229
|
+
value: (function () {
|
|
230
|
+
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
231
|
+
var cookies, prefix, _iterator2, _step2, cookie, cookieName, key;
|
|
232
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
233
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
234
|
+
case 0:
|
|
235
|
+
if (!(typeof document === 'undefined')) {
|
|
236
|
+
_context4.next = 2;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
return _context4.abrupt("return");
|
|
240
|
+
case 2:
|
|
241
|
+
// Get all cookies and remove ones with our prefix or server access keys
|
|
242
|
+
cookies = document.cookie.split(';');
|
|
243
|
+
prefix = this.options.prefix;
|
|
244
|
+
_iterator2 = _createForOfIteratorHelper(cookies);
|
|
245
|
+
_context4.prev = 5;
|
|
246
|
+
_iterator2.s();
|
|
247
|
+
case 7:
|
|
248
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
249
|
+
_context4.next = 21;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
cookie = _step2.value;
|
|
253
|
+
cookieName = cookie.split('=')[0].trim(); // Remove prefixed cookies
|
|
254
|
+
if (!cookieName.startsWith(prefix)) {
|
|
255
|
+
_context4.next = 16;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
key = cookieName.substring(prefix.length);
|
|
259
|
+
_context4.next = 14;
|
|
260
|
+
return this.removeItem(key);
|
|
261
|
+
case 14:
|
|
262
|
+
_context4.next = 19;
|
|
263
|
+
break;
|
|
264
|
+
case 16:
|
|
265
|
+
if (!this.options.serverAccessKeys.includes(cookieName)) {
|
|
266
|
+
_context4.next = 19;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
_context4.next = 19;
|
|
270
|
+
return this.removeItem(cookieName);
|
|
271
|
+
case 19:
|
|
272
|
+
_context4.next = 7;
|
|
273
|
+
break;
|
|
274
|
+
case 21:
|
|
275
|
+
_context4.next = 26;
|
|
276
|
+
break;
|
|
277
|
+
case 23:
|
|
278
|
+
_context4.prev = 23;
|
|
279
|
+
_context4.t0 = _context4["catch"](5);
|
|
280
|
+
_iterator2.e(_context4.t0);
|
|
281
|
+
case 26:
|
|
282
|
+
_context4.prev = 26;
|
|
283
|
+
_iterator2.f();
|
|
284
|
+
return _context4.finish(26);
|
|
285
|
+
case 29:
|
|
286
|
+
case "end":
|
|
287
|
+
return _context4.stop();
|
|
288
|
+
}
|
|
289
|
+
}, _callee4, this, [[5, 23, 26, 29]]);
|
|
290
|
+
}));
|
|
291
|
+
function clear() {
|
|
292
|
+
return _clear.apply(this, arguments);
|
|
170
293
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
294
|
+
return clear;
|
|
295
|
+
}()
|
|
296
|
+
/**
|
|
297
|
+
* Get all keys (for debugging/compatibility)
|
|
298
|
+
*/
|
|
299
|
+
)
|
|
300
|
+
}, {
|
|
301
|
+
key: "keys",
|
|
302
|
+
value: (function () {
|
|
303
|
+
var _keys = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
304
|
+
var cookies, prefix, keys, _iterator3, _step3, cookie, cookieName;
|
|
305
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
306
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
307
|
+
case 0:
|
|
308
|
+
if (!(typeof document === 'undefined')) {
|
|
309
|
+
_context5.next = 2;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
return _context5.abrupt("return", []);
|
|
313
|
+
case 2:
|
|
314
|
+
cookies = document.cookie.split(';');
|
|
315
|
+
prefix = this.options.prefix;
|
|
316
|
+
keys = [];
|
|
317
|
+
_iterator3 = _createForOfIteratorHelper(cookies);
|
|
318
|
+
try {
|
|
319
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
320
|
+
cookie = _step3.value;
|
|
321
|
+
cookieName = cookie.split('=')[0].trim(); // Add prefixed cookies
|
|
322
|
+
if (cookieName.startsWith(prefix)) {
|
|
323
|
+
keys.push(cookieName.substring(prefix.length));
|
|
324
|
+
}
|
|
325
|
+
// Add server access keys (non-prefixed)
|
|
326
|
+
else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
327
|
+
keys.push(cookieName);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
} catch (err) {
|
|
331
|
+
_iterator3.e(err);
|
|
332
|
+
} finally {
|
|
333
|
+
_iterator3.f();
|
|
334
|
+
}
|
|
335
|
+
return _context5.abrupt("return", keys);
|
|
336
|
+
case 8:
|
|
337
|
+
case "end":
|
|
338
|
+
return _context5.stop();
|
|
339
|
+
}
|
|
340
|
+
}, _callee5, this);
|
|
341
|
+
}));
|
|
342
|
+
function keys() {
|
|
343
|
+
return _keys.apply(this, arguments);
|
|
188
344
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
345
|
+
return keys;
|
|
346
|
+
}()
|
|
347
|
+
/**
|
|
348
|
+
* Debug method to log all current cookies and adapter state
|
|
349
|
+
*/
|
|
350
|
+
)
|
|
351
|
+
}, {
|
|
352
|
+
key: "debugState",
|
|
353
|
+
value: function debugState() {
|
|
354
|
+
if (typeof document === 'undefined') {
|
|
355
|
+
return;
|
|
192
356
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
robotoKeys.push(cookieName);
|
|
216
|
-
} else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
217
|
-
serverKeys.push(cookieName);
|
|
218
|
-
} else if (cookieName) {
|
|
219
|
-
otherKeys.push(cookieName);
|
|
357
|
+
var cookies = document.cookie.split(';');
|
|
358
|
+
var robotoKeys = [];
|
|
359
|
+
var serverKeys = [];
|
|
360
|
+
var otherKeys = [];
|
|
361
|
+
var _iterator4 = _createForOfIteratorHelper(cookies),
|
|
362
|
+
_step4;
|
|
363
|
+
try {
|
|
364
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
365
|
+
var cookie = _step4.value;
|
|
366
|
+
var cookieName = cookie.split('=')[0].trim();
|
|
367
|
+
if (cookieName.startsWith(this.options.prefix)) {
|
|
368
|
+
robotoKeys.push(cookieName);
|
|
369
|
+
} else if (this.options.serverAccessKeys.includes(cookieName)) {
|
|
370
|
+
serverKeys.push(cookieName);
|
|
371
|
+
} else if (cookieName) {
|
|
372
|
+
otherKeys.push(cookieName);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} catch (err) {
|
|
376
|
+
_iterator4.e(err);
|
|
377
|
+
} finally {
|
|
378
|
+
_iterator4.f();
|
|
220
379
|
}
|
|
221
380
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
}
|
|
381
|
+
}]);
|
|
382
|
+
return CookieStorageAdaptor;
|
|
383
|
+
}();
|