roboto-js 1.8.5 → 1.8.7

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