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.
- package/.last-build +1 -1
- package/BUILD_NOTES.md +40 -0
- package/babel.config.json +29 -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 +8 -15
- package/dist/cjs/rbt_user.cjs +1 -3
- package/dist/esm/cookie_storage_adaptor.js +349 -197
- package/dist/esm/index.js +565 -169
- package/dist/esm/rbt_api.js +1956 -1164
- package/dist/esm/rbt_file.js +213 -123
- package/dist/esm/rbt_metrics_api.js +158 -69
- package/dist/esm/rbt_object.js +1008 -706
- package/dist/esm/rbt_user.js +202 -137
- package/dist/index.js +31 -10
- package/dist/rbt_api.js +13 -0
- package/package.json +5 -4
- package/src/index.js +21 -11
- package/src/rbt_api.js +3 -0
- package/src/rbt_object.js +3 -1
package/.last-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2025-11-
|
|
1
|
+
2025-11-05T08:58:03.769Z
|
package/BUILD_NOTES.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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` with environment-specific settings
|
|
11
|
+
- Applies to both CommonJS (`dist/cjs`) and ESM (`dist/esm`) builds
|
|
12
|
+
- ESM build preserves ES module syntax (`modules: false`)
|
|
13
|
+
- CJS build uses CommonJS syntax (`modules: "commonjs"`)
|
|
14
|
+
|
|
15
|
+
### Development vs Production
|
|
16
|
+
|
|
17
|
+
- **Development**: Keep all console statements in the `src/` files for debugging
|
|
18
|
+
- **Production**: When you run `npm run build` or `npm publish`, console statements are automatically stripped
|
|
19
|
+
|
|
20
|
+
### What Gets Removed
|
|
21
|
+
|
|
22
|
+
- `console.log()` - ❌ Removed
|
|
23
|
+
- `console.warn()` - ❌ Removed
|
|
24
|
+
- `console.info()` - ❌ Removed
|
|
25
|
+
- `console.debug()` - ❌ Removed
|
|
26
|
+
- `console.error()` - ✅ **Preserved** (for critical error reporting)
|
|
27
|
+
|
|
28
|
+
### Build Environments
|
|
29
|
+
|
|
30
|
+
The build uses `BABEL_ENV` to configure different output formats:
|
|
31
|
+
- `BABEL_ENV=esm` - ES Modules build with preserved import/export syntax
|
|
32
|
+
- `BABEL_ENV=cjs` - CommonJS build with require/exports syntax
|
|
33
|
+
|
|
34
|
+
### Scripts
|
|
35
|
+
|
|
36
|
+
- `npm run build` - Builds both CJS and ESM with console removal
|
|
37
|
+
- `npm run build:cjs` - Build CommonJS only (`BABEL_ENV=cjs`)
|
|
38
|
+
- `npm run build:esm` - Build ES Modules only (`BABEL_ENV=esm`)
|
|
39
|
+
- `npm publish` - Automatically runs `prepublishOnly` which builds with console removal
|
|
40
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"cjs": {
|
|
4
|
+
"presets": [
|
|
5
|
+
["@babel/preset-env", {
|
|
6
|
+
"modules": "commonjs"
|
|
7
|
+
}]
|
|
8
|
+
],
|
|
9
|
+
"plugins": [
|
|
10
|
+
["transform-remove-console", {
|
|
11
|
+
"exclude": ["error"]
|
|
12
|
+
}]
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"esm": {
|
|
16
|
+
"presets": [
|
|
17
|
+
["@babel/preset-env", {
|
|
18
|
+
"modules": false
|
|
19
|
+
}]
|
|
20
|
+
],
|
|
21
|
+
"plugins": [
|
|
22
|
+
["transform-remove-console", {
|
|
23
|
+
"exclude": ["error"]
|
|
24
|
+
}]
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -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 =
|
|
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
|
|
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 =
|
|
77
|
+
_context.prev = 8;
|
|
92
78
|
_iterator.s();
|
|
93
|
-
case
|
|
79
|
+
case 10:
|
|
94
80
|
if ((_step = _iterator.n()).done) {
|
|
95
|
-
_context.next =
|
|
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 =
|
|
87
|
+
_context.next = 23;
|
|
102
88
|
break;
|
|
103
89
|
}
|
|
104
90
|
rawValue = cookie.substring(name.length, cookie.length);
|
|
105
|
-
|
|
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
|
|
113
|
-
_context.prev =
|
|
114
|
-
_context.t0 = _context["catch"](
|
|
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
|
|
118
|
-
_context.next =
|
|
98
|
+
case 23:
|
|
99
|
+
_context.next = 10;
|
|
119
100
|
break;
|
|
120
|
-
case
|
|
121
|
-
_context.next =
|
|
101
|
+
case 25:
|
|
102
|
+
_context.next = 30;
|
|
122
103
|
break;
|
|
123
|
-
case
|
|
124
|
-
_context.prev =
|
|
125
|
-
_context.t1 = _context["catch"](
|
|
104
|
+
case 27:
|
|
105
|
+
_context.prev = 27;
|
|
106
|
+
_context.t1 = _context["catch"](8);
|
|
126
107
|
_iterator.e(_context.t1);
|
|
127
|
-
case
|
|
128
|
-
_context.prev =
|
|
108
|
+
case 30:
|
|
109
|
+
_context.prev = 30;
|
|
129
110
|
_iterator.f();
|
|
130
|
-
return _context.finish(
|
|
131
|
-
case
|
|
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
|
|
114
|
+
case 34:
|
|
135
115
|
case "end":
|
|
136
116
|
return _context.stop();
|
|
137
117
|
}
|
|
138
|
-
}, _callee, this, [[
|
|
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 =
|
|
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
|
|
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 =
|
|
155
|
+
_context2.next = 12;
|
|
182
156
|
return this.getItem(key);
|
|
183
|
-
case
|
|
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
|
|
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 =
|
|
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
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
// Check if cookie exists before removal
|
|
226
|
-
_context3.next = 8;
|
|
194
|
+
_context3.next = 6;
|
|
227
195
|
return this.getItem(key);
|
|
228
|
-
case
|
|
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 =
|
|
205
|
+
_context3.next = 14;
|
|
243
206
|
return this.getItem(key);
|
|
244
|
-
case
|
|
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
|
|
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;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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
|
|
81
|
+
return void 0;
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
this.config = {
|
|
86
|
-
|
|
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
|
|
99
|
-
var
|
|
100
|
-
var
|
|
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 (
|
|
103
|
-
this.config.authtoken =
|
|
110
|
+
if (header_authtoken) {
|
|
111
|
+
this.config.authtoken = header_authtoken; // Set the authtoken in the config
|
|
104
112
|
}
|
|
105
|
-
if (
|
|
106
|
-
this.config.apikey =
|
|
113
|
+
if (header_apikey) {
|
|
114
|
+
this.config.apikey = header_apikey; // Set the authtoken in the config
|
|
107
115
|
}
|
|
108
|
-
if (
|
|
109
|
-
this.config.accesskey =
|
|
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
|
|