roboto-js 1.8.4 → 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 CHANGED
@@ -1 +1 @@
1
- 2025-10-09T21:04:42.145Z
1
+ 2025-11-05T08:58:03.769Z
package/BUILD_NOTES.md ADDED
@@ -0,0 +1,30 @@
1
+ # Build Configuration
2
+
3
+ ## Console Log Removal
4
+
5
+ The build process automatically strips all `console.log`, `console.warn`, and other console statements from the production build, **except for `console.error`** which is preserved for critical error reporting.
6
+
7
+ ### How It Works
8
+
9
+ - Uses `babel-plugin-transform-remove-console` during the build process
10
+ - Configuration is in `babel.config.json`
11
+ - Applies to both CommonJS (`dist/cjs`) and ESM (`dist/esm`) builds
12
+
13
+ ### Development vs Production
14
+
15
+ - **Development**: Keep all console statements in the `src/` files for debugging
16
+ - **Production**: When you run `npm run build` or `npm publish`, console statements are automatically stripped
17
+
18
+ ### What Gets Removed
19
+
20
+ - `console.log()` - ❌ Removed
21
+ - `console.warn()` - ❌ Removed
22
+ - `console.info()` - ❌ Removed
23
+ - `console.debug()` - ❌ Removed
24
+ - `console.error()` - ✅ **Preserved** (for critical error reporting)
25
+
26
+ ### Scripts
27
+
28
+ - `npm run build` - Builds both CJS and ESM with console removal
29
+ - `npm publish` - Automatically runs `prepublishOnly` which builds with console removal
30
+
@@ -0,0 +1,13 @@
1
+ {
2
+ "presets": [
3
+ ["@babel/preset-env", {
4
+ "modules": "auto"
5
+ }]
6
+ ],
7
+ "plugins": [
8
+ ["transform-remove-console", {
9
+ "exclude": ["error"]
10
+ }]
11
+ ]
12
+ }
13
+
@@ -48,15 +48,6 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
48
48
  // Keys that should be stored without prefix for server-side access
49
49
  serverAccessKeys: (_options$serverAccess = options.serverAccessKeys) !== null && _options$serverAccess !== void 0 ? _options$serverAccess : ['authtoken', 'accessKey', 'apikey']
50
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
51
  }
61
52
 
62
53
  /**
@@ -71,71 +62,60 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
71
62
  while (1) switch (_context.prev = _context.next) {
72
63
  case 0:
73
64
  if (!(typeof document === 'undefined')) {
74
- _context.next = 3;
65
+ _context.next = 2;
75
66
  break;
76
67
  }
77
- console.log("[CookieStorageAdaptor] getItem(".concat(key, "): document undefined, returning null"));
78
68
  return _context.abrupt("return", null);
79
- case 3:
69
+ case 2:
80
70
  // Check if this key should be stored without prefix for server access
81
71
  usePrefix = !this.options.serverAccessKeys.includes(key);
82
72
  cookieName = usePrefix ? this.options.prefix + key : key;
83
73
  name = cookieName + '=';
84
74
  decodedCookie = decodeURIComponent(document.cookie);
85
75
  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
76
  _iterator = _createForOfIteratorHelper(cookies);
91
- _context.prev = 11;
77
+ _context.prev = 8;
92
78
  _iterator.s();
93
- case 13:
79
+ case 10:
94
80
  if ((_step = _iterator.n()).done) {
95
- _context.next = 31;
81
+ _context.next = 25;
96
82
  break;
97
83
  }
98
84
  cookie = _step.value;
99
85
  cookie = cookie.trim();
100
86
  if (!(cookie.indexOf(name) === 0)) {
101
- _context.next = 29;
87
+ _context.next = 23;
102
88
  break;
103
89
  }
104
90
  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;
91
+ _context.prev = 15;
109
92
  parsedValue = JSON.parse(rawValue);
110
- console.log("[CookieStorageAdaptor] getItem(".concat(key, "): returning parsed JSON:"), parsedValue);
111
93
  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);
94
+ case 20:
95
+ _context.prev = 20;
96
+ _context.t0 = _context["catch"](15);
116
97
  return _context.abrupt("return", rawValue);
117
- case 29:
118
- _context.next = 13;
98
+ case 23:
99
+ _context.next = 10;
119
100
  break;
120
- case 31:
121
- _context.next = 36;
101
+ case 25:
102
+ _context.next = 30;
122
103
  break;
123
- case 33:
124
- _context.prev = 33;
125
- _context.t1 = _context["catch"](11);
104
+ case 27:
105
+ _context.prev = 27;
106
+ _context.t1 = _context["catch"](8);
126
107
  _iterator.e(_context.t1);
127
- case 36:
128
- _context.prev = 36;
108
+ case 30:
109
+ _context.prev = 30;
129
110
  _iterator.f();
130
- return _context.finish(36);
131
- case 39:
132
- console.log("[CookieStorageAdaptor] getItem(".concat(key, "): cookie \"").concat(cookieName, "\" not found, returning null"));
111
+ return _context.finish(30);
112
+ case 33:
133
113
  return _context.abrupt("return", null);
134
- case 41:
114
+ case 34:
135
115
  case "end":
136
116
  return _context.stop();
137
117
  }
138
- }, _callee, this, [[11, 33, 36, 39], [19, 25]]);
118
+ }, _callee, this, [[8, 27, 30, 33], [15, 20]]);
139
119
  }));
140
120
  function getItem(_x) {
141
121
  return _getItem.apply(this, arguments);
@@ -155,39 +135,31 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
155
135
  while (1) switch (_context2.prev = _context2.next) {
156
136
  case 0:
157
137
  if (!(typeof document === 'undefined')) {
158
- _context2.next = 3;
138
+ _context2.next = 2;
159
139
  break;
160
140
  }
161
- console.log("[CookieStorageAdaptor] setItem(".concat(key, "): document undefined, skipping"));
162
141
  return _context2.abrupt("return");
163
- case 3:
142
+ case 2:
164
143
  // Check if this key should be stored without prefix for server access
165
144
  usePrefix = !this.options.serverAccessKeys.includes(key);
166
145
  cookieName = usePrefix ? this.options.prefix + key : key; // Stringify objects/arrays like localStorage does
167
146
  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
147
  // Build cookie string with security options
173
148
  secureFlag = this.options.secure ? '; Secure' : '';
174
149
  domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
175
150
  httpOnlyFlag = this.options.httpOnly ? '; HttpOnly' : '';
176
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);
177
- console.log("[CookieStorageAdaptor] Full cookie string:", cookieString);
178
152
  document.cookie = cookieString;
179
153
 
180
154
  // Verify the cookie was set by immediately reading it back
181
- _context2.next = 17;
155
+ _context2.next = 12;
182
156
  return this.getItem(key);
183
- case 17:
157
+ case 12:
184
158
  verification = _context2.sent;
185
- if (verification !== null) {
186
- console.log("[CookieStorageAdaptor] \u2705 Successfully set and verified cookie: ".concat(cookieName));
187
- } else {
159
+ if (verification !== null) {} else {
188
160
  console.error("[CookieStorageAdaptor] \u274C Failed to set cookie: ".concat(cookieName));
189
161
  }
190
- case 19:
162
+ case 14:
191
163
  case "end":
192
164
  return _context2.stop();
193
165
  }
@@ -211,44 +183,33 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
211
183
  while (1) switch (_context3.prev = _context3.next) {
212
184
  case 0:
213
185
  if (!(typeof document === 'undefined')) {
214
- _context3.next = 3;
186
+ _context3.next = 2;
215
187
  break;
216
188
  }
217
- console.log("[CookieStorageAdaptor] removeItem(".concat(key, "): document undefined, skipping"));
218
189
  return _context3.abrupt("return");
219
- case 3:
190
+ case 2:
220
191
  // Check if this key should be stored without prefix for server access
221
192
  usePrefix = !this.options.serverAccessKeys.includes(key);
222
193
  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;
194
+ _context3.next = 6;
227
195
  return this.getItem(key);
228
- case 8:
196
+ case 6:
229
197
  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
- }
198
+ if (existingValue !== null) {} else {}
235
199
  secureFlag = this.options.secure ? '; Secure' : '';
236
200
  domainFlag = this.options.domain ? "; Domain=".concat(this.options.domain) : '';
237
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);
238
- console.log("[CookieStorageAdaptor] Removal cookie string:", removalString);
239
202
  document.cookie = removalString;
240
203
 
241
204
  // Verify the cookie was removed
242
- _context3.next = 17;
205
+ _context3.next = 14;
243
206
  return this.getItem(key);
244
- case 17:
207
+ case 14:
245
208
  verification = _context3.sent;
246
- if (verification === null) {
247
- console.log("[CookieStorageAdaptor] \u2705 Successfully removed cookie: ".concat(cookieName));
248
- } else {
209
+ if (verification === null) {} else {
249
210
  console.error("[CookieStorageAdaptor] \u274C Failed to remove cookie: ".concat(cookieName, ", still has value:"), verification);
250
211
  }
251
- case 19:
212
+ case 16:
252
213
  case "end":
253
214
  return _context3.stop();
254
215
  }
@@ -391,12 +352,8 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
391
352
  key: "debugState",
392
353
  value: function debugState() {
393
354
  if (typeof document === 'undefined') {
394
- console.log('[CookieStorageAdaptor] DEBUG: document undefined (server-side)');
395
355
  return;
396
356
  }
397
- console.log('[CookieStorageAdaptor] DEBUG STATE:');
398
- console.log('- Options:', this.options);
399
- console.log('- All cookies:', document.cookie);
400
357
  var cookies = document.cookie.split(';');
401
358
  var robotoKeys = [];
402
359
  var serverKeys = [];
@@ -420,9 +377,6 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
420
377
  } finally {
421
378
  _iterator4.f();
422
379
  }
423
- console.log('- Roboto prefixed cookies:', robotoKeys);
424
- console.log('- Server access cookies:', serverKeys);
425
- console.log('- Other cookies:', otherKeys);
426
380
  }
427
381
  }]);
428
382
  return CookieStorageAdaptor;
@@ -48,6 +48,8 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
48
48
  var _this = this;
49
49
  var host = _ref.host,
50
50
  accessKey = _ref.accessKey,
51
+ apiKey = _ref.apiKey,
52
+ authToken = _ref.authToken,
51
53
  localStorageAdaptor = _ref.localStorageAdaptor,
52
54
  _ref$disableWebSocket = _ref.disableWebSocket,
53
55
  disableWebSocket = _ref$disableWebSocket === void 0 ? false : _ref$disableWebSocket,
@@ -73,40 +75,46 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
73
75
  sameSite: 'Lax',
74
76
  maxAge: 24 * 60 * 60 // 24 hours
75
77
  });
76
- console.log('[Roboto] Using CookieStorageAdaptor for authentication tokens');
77
-
78
78
  // Set accessKey for server-side authentication (handled automatically by adapter)
79
79
  if (accessKey) {
80
80
  storageAdaptor.setItem('accessKey', accessKey)["catch"](function (e) {
81
- return console.warn('[Roboto] Failed to set accessKey cookie:', e);
81
+ return void 0;
82
82
  });
83
83
  }
84
84
  }
85
85
  this.config = {
86
- accessKey: accessKey,
86
+ accesskey: accessKey,
87
87
  // Use passed accessKey
88
88
  baseUrl: "https://".concat(host),
89
89
  // Use passed host
90
90
  localStorageAdaptor: storageAdaptor
91
91
  };
92
92
 
93
+ // Add apikey and authtoken if provided directly
94
+ if (apiKey) {
95
+ this.config.apikey = apiKey;
96
+ }
97
+ if (authToken) {
98
+ this.config.authtoken = authToken;
99
+ }
100
+
93
101
  // DEVELOPMENT
94
102
  this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
95
103
 
96
104
  // Check if a request object is provided
97
105
  if (proxyReq && proxyReq.headers) {
98
- var authtoken = proxyReq.headers.authtoken;
99
- var accesskey = proxyReq.headers.accesskey;
100
- var apikey = proxyReq.headers.apikey;
106
+ var header_authtoken = proxyReq.headers.authtoken;
107
+ var header_accesskey = proxyReq.headers.accesskey;
108
+ var header_apikey = proxyReq.headers.apikey;
101
109
  // Optionally add more headers as needed
102
- if (authtoken) {
103
- this.config.authtoken = authtoken; // Set the authtoken in the config
110
+ if (header_authtoken) {
111
+ this.config.authtoken = header_authtoken; // Set the authtoken in the config
104
112
  }
105
- if (apikey) {
106
- this.config.apikey = apikey; // Set the authtoken in the config
113
+ if (header_apikey) {
114
+ this.config.apikey = header_apikey; // Set the authtoken in the config
107
115
  }
108
- if (accesskey) {
109
- this.config.accesskey = accesskey; // Set the accesskey in the config
116
+ if (header_accesskey) {
117
+ this.config.accesskey = header_accesskey; // Set the accesskey in the config
110
118
  }
111
119
  }
112
120
  this.api = new _rbt_api["default"](this.config);
@@ -118,7 +126,6 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
118
126
  window.debugRobotoCookies = function () {
119
127
  return _this.config.localStorageAdaptor.debugState();
120
128
  };
121
- console.log('[Roboto] Added global debug method: window.debugRobotoCookies()');
122
129
  }
123
130
  }
124
131