roboto-js 1.8.7 → 1.8.9

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-11-05T08:58:03.769Z
1
+ 2025-11-12T07:28:57.602Z
@@ -102,19 +102,23 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
102
102
  this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
103
103
 
104
104
  // Check if a request object is provided
105
- if (proxyReq && proxyReq.headers) {
106
- var header_authtoken = proxyReq.headers.authtoken;
107
- var header_accesskey = proxyReq.headers.accesskey;
108
- var header_apikey = proxyReq.headers.apikey;
105
+ if (proxyReq) {
106
+ var _proxyReq$headers, _proxyReq$headers2, _proxyReq$headers3;
107
+ // First priority: properties set by middleware (supports cookie-based auth)
108
+ // Second priority: custom headers (backward compatibility)
109
+ var req_authtoken = proxyReq.authToken || ((_proxyReq$headers = proxyReq.headers) === null || _proxyReq$headers === void 0 ? void 0 : _proxyReq$headers.authtoken);
110
+ var req_accesskey = proxyReq.accessKey || ((_proxyReq$headers2 = proxyReq.headers) === null || _proxyReq$headers2 === void 0 ? void 0 : _proxyReq$headers2.accesskey);
111
+ var req_apikey = proxyReq.apiKey || ((_proxyReq$headers3 = proxyReq.headers) === null || _proxyReq$headers3 === void 0 ? void 0 : _proxyReq$headers3.apikey);
112
+
109
113
  // Optionally add more headers as needed
110
- if (header_authtoken) {
111
- this.config.authtoken = header_authtoken; // Set the authtoken in the config
114
+ if (req_authtoken) {
115
+ this.config.authtoken = req_authtoken; // Set the authtoken in the config
112
116
  }
113
- if (header_apikey) {
114
- this.config.apikey = header_apikey; // Set the authtoken in the config
117
+ if (req_apikey) {
118
+ this.config.apikey = req_apikey; // Set the apikey in the config
115
119
  }
116
- if (header_accesskey) {
117
- this.config.accesskey = header_accesskey; // Set the accesskey in the config
120
+ if (req_accesskey) {
121
+ this.config.accesskey = req_accesskey; // Set the accesskey in the config
118
122
  }
119
123
  }
120
124
  this.api = new _rbt_api["default"](this.config);
@@ -1939,11 +1939,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1939
1939
  * Performs a GET request to the specified endpoint.
1940
1940
  *
1941
1941
  * This method uses the Axios instance to make an authenticated GET request.
1942
- * The `authtoken` stored in the class instance is included in the request headers
1943
- * for authorization. It handles any errors and returns the response data.
1942
+ * The `authtoken` and `accesskey` from axios defaults are automatically included.
1943
+ * Additional custom headers can be passed and will be merged with the defaults.
1944
1944
  *
1945
1945
  * @param {string} endpoint - The endpoint URL to which the GET request is made.
1946
1946
  * @param {Object} [params={}] - Optional parameters to be sent with the request.
1947
+ * @param {Object} [customHeaders=null] - Optional custom headers to merge with defaults.
1947
1948
  * @returns {Promise<Object>} - The response data from the API.
1948
1949
  */
1949
1950
  )
@@ -1952,41 +1953,50 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1952
1953
  value: (function () {
1953
1954
  var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(endpoint) {
1954
1955
  var params,
1955
- headers,
1956
+ customHeaders,
1957
+ config,
1956
1958
  response,
1957
1959
  _args29 = arguments;
1958
1960
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1959
1961
  while (1) switch (_context29.prev = _context29.next) {
1960
1962
  case 0:
1961
1963
  params = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
1962
- _context29.prev = 1;
1963
- // Add the authToken to the headers
1964
- headers = {
1965
- authtoken: this.authtoken
1966
- }; // Make the GET request using Axios
1967
- _context29.next = 5;
1968
- return this.axios.get(endpoint, {
1969
- params: params,
1970
- headers: headers
1971
- });
1972
- case 5:
1964
+ customHeaders = _args29.length > 2 && _args29[2] !== undefined ? _args29[2] : null;
1965
+ _context29.prev = 2;
1966
+ // Build request config
1967
+ config = {
1968
+ params: params
1969
+ }; // Only pass headers if custom headers are provided
1970
+ // If no custom headers, let axios use its defaults automatically
1971
+ // This ensures proper merging of all default headers (accesskey, authtoken, apikey)
1972
+ if (customHeaders && Object.keys(customHeaders).length > 0) {
1973
+ // When custom headers are provided, we need to manually merge with defaults
1974
+ // Axios will handle merging when we pass them this way
1975
+ config.headers = customHeaders;
1976
+ }
1977
+ // Otherwise, don't set config.headers at all - let axios use its defaults
1978
+
1979
+ // Make the GET request using Axios
1980
+ _context29.next = 7;
1981
+ return this.axios.get(endpoint, config);
1982
+ case 7:
1973
1983
  response = _context29.sent;
1974
1984
  if (!(response.data.ok === false)) {
1975
- _context29.next = 8;
1985
+ _context29.next = 10;
1976
1986
  break;
1977
1987
  }
1978
1988
  return _context29.abrupt("return", this._handleError(response));
1979
- case 8:
1989
+ case 10:
1980
1990
  return _context29.abrupt("return", response.data);
1981
- case 11:
1982
- _context29.prev = 11;
1983
- _context29.t0 = _context29["catch"](1);
1991
+ case 13:
1992
+ _context29.prev = 13;
1993
+ _context29.t0 = _context29["catch"](2);
1984
1994
  return _context29.abrupt("return", this._handleError(_context29.t0));
1985
- case 14:
1995
+ case 16:
1986
1996
  case "end":
1987
1997
  return _context29.stop();
1988
1998
  }
1989
- }, _callee29, this, [[1, 11]]);
1999
+ }, _callee29, this, [[2, 13]]);
1990
2000
  }));
1991
2001
  function get(_x18) {
1992
2002
  return _get.apply(this, arguments);
package/dist/esm/index.js CHANGED
@@ -75,19 +75,23 @@ var Roboto = /*#__PURE__*/function () {
75
75
  this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
76
76
 
77
77
  // Check if a request object is provided
78
- if (proxyReq && proxyReq.headers) {
79
- var header_authtoken = proxyReq.headers.authtoken;
80
- var header_accesskey = proxyReq.headers.accesskey;
81
- var header_apikey = proxyReq.headers.apikey;
78
+ if (proxyReq) {
79
+ var _proxyReq$headers, _proxyReq$headers2, _proxyReq$headers3;
80
+ // First priority: properties set by middleware (supports cookie-based auth)
81
+ // Second priority: custom headers (backward compatibility)
82
+ var req_authtoken = proxyReq.authToken || ((_proxyReq$headers = proxyReq.headers) === null || _proxyReq$headers === void 0 ? void 0 : _proxyReq$headers.authtoken);
83
+ var req_accesskey = proxyReq.accessKey || ((_proxyReq$headers2 = proxyReq.headers) === null || _proxyReq$headers2 === void 0 ? void 0 : _proxyReq$headers2.accesskey);
84
+ var req_apikey = proxyReq.apiKey || ((_proxyReq$headers3 = proxyReq.headers) === null || _proxyReq$headers3 === void 0 ? void 0 : _proxyReq$headers3.apikey);
85
+
82
86
  // Optionally add more headers as needed
83
- if (header_authtoken) {
84
- this.config.authtoken = header_authtoken; // Set the authtoken in the config
87
+ if (req_authtoken) {
88
+ this.config.authtoken = req_authtoken; // Set the authtoken in the config
85
89
  }
86
- if (header_apikey) {
87
- this.config.apikey = header_apikey; // Set the authtoken in the config
90
+ if (req_apikey) {
91
+ this.config.apikey = req_apikey; // Set the apikey in the config
88
92
  }
89
- if (header_accesskey) {
90
- this.config.accesskey = header_accesskey; // Set the accesskey in the config
93
+ if (req_accesskey) {
94
+ this.config.accesskey = req_accesskey; // Set the accesskey in the config
91
95
  }
92
96
  }
93
97
  this.api = new RbtApi(this.config);
@@ -1932,11 +1932,12 @@ var RbtApi = /*#__PURE__*/function () {
1932
1932
  * Performs a GET request to the specified endpoint.
1933
1933
  *
1934
1934
  * This method uses the Axios instance to make an authenticated GET request.
1935
- * The `authtoken` stored in the class instance is included in the request headers
1936
- * for authorization. It handles any errors and returns the response data.
1935
+ * The `authtoken` and `accesskey` from axios defaults are automatically included.
1936
+ * Additional custom headers can be passed and will be merged with the defaults.
1937
1937
  *
1938
1938
  * @param {string} endpoint - The endpoint URL to which the GET request is made.
1939
1939
  * @param {Object} [params={}] - Optional parameters to be sent with the request.
1940
+ * @param {Object} [customHeaders=null] - Optional custom headers to merge with defaults.
1940
1941
  * @returns {Promise<Object>} - The response data from the API.
1941
1942
  */
1942
1943
  )
@@ -1945,41 +1946,50 @@ var RbtApi = /*#__PURE__*/function () {
1945
1946
  value: (function () {
1946
1947
  var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(endpoint) {
1947
1948
  var params,
1948
- headers,
1949
+ customHeaders,
1950
+ config,
1949
1951
  response,
1950
1952
  _args29 = arguments;
1951
1953
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1952
1954
  while (1) switch (_context29.prev = _context29.next) {
1953
1955
  case 0:
1954
1956
  params = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
1955
- _context29.prev = 1;
1956
- // Add the authToken to the headers
1957
- headers = {
1958
- authtoken: this.authtoken
1959
- }; // Make the GET request using Axios
1960
- _context29.next = 5;
1961
- return this.axios.get(endpoint, {
1962
- params: params,
1963
- headers: headers
1964
- });
1965
- case 5:
1957
+ customHeaders = _args29.length > 2 && _args29[2] !== undefined ? _args29[2] : null;
1958
+ _context29.prev = 2;
1959
+ // Build request config
1960
+ config = {
1961
+ params: params
1962
+ }; // Only pass headers if custom headers are provided
1963
+ // If no custom headers, let axios use its defaults automatically
1964
+ // This ensures proper merging of all default headers (accesskey, authtoken, apikey)
1965
+ if (customHeaders && Object.keys(customHeaders).length > 0) {
1966
+ // When custom headers are provided, we need to manually merge with defaults
1967
+ // Axios will handle merging when we pass them this way
1968
+ config.headers = customHeaders;
1969
+ }
1970
+ // Otherwise, don't set config.headers at all - let axios use its defaults
1971
+
1972
+ // Make the GET request using Axios
1973
+ _context29.next = 7;
1974
+ return this.axios.get(endpoint, config);
1975
+ case 7:
1966
1976
  response = _context29.sent;
1967
1977
  if (!(response.data.ok === false)) {
1968
- _context29.next = 8;
1978
+ _context29.next = 10;
1969
1979
  break;
1970
1980
  }
1971
1981
  return _context29.abrupt("return", this._handleError(response));
1972
- case 8:
1982
+ case 10:
1973
1983
  return _context29.abrupt("return", response.data);
1974
- case 11:
1975
- _context29.prev = 11;
1976
- _context29.t0 = _context29["catch"](1);
1984
+ case 13:
1985
+ _context29.prev = 13;
1986
+ _context29.t0 = _context29["catch"](2);
1977
1987
  return _context29.abrupt("return", this._handleError(_context29.t0));
1978
- case 14:
1988
+ case 16:
1979
1989
  case "end":
1980
1990
  return _context29.stop();
1981
1991
  }
1982
- }, _callee29, this, [[1, 11]]);
1992
+ }, _callee29, this, [[2, 13]]);
1983
1993
  }));
1984
1994
  function get(_x18) {
1985
1995
  return _get.apply(this, arguments);
@@ -66,7 +66,9 @@ var RbtObject = /*#__PURE__*/function () {
66
66
  return _createClass(RbtObject, [{
67
67
  key: "get",
68
68
  value: function get(path) {
69
- return _.get(this._data, path);
69
+ var value = _.get(this._data, path);
70
+ // Return a deep clone to prevent reference issues when modifying returned objects
71
+ return _.cloneDeep(value);
70
72
  }
71
73
  }, {
72
74
  key: "getData",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -70,19 +70,22 @@ export default class Roboto{
70
70
  this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
71
71
 
72
72
  // Check if a request object is provided
73
- if (proxyReq && proxyReq.headers) {
74
- const header_authtoken = proxyReq.headers.authtoken;
75
- const header_accesskey = proxyReq.headers.accesskey;
76
- const header_apikey = proxyReq.headers.apikey;
73
+ if (proxyReq) {
74
+ // First priority: properties set by middleware (supports cookie-based auth)
75
+ // Second priority: custom headers (backward compatibility)
76
+ const req_authtoken = proxyReq.authToken || proxyReq.headers?.authtoken;
77
+ const req_accesskey = proxyReq.accessKey || proxyReq.headers?.accesskey;
78
+ const req_apikey = proxyReq.apiKey || proxyReq.headers?.apikey;
79
+
77
80
  // Optionally add more headers as needed
78
- if (header_authtoken) {
79
- this.config.authtoken = header_authtoken; // Set the authtoken in the config
81
+ if (req_authtoken) {
82
+ this.config.authtoken = req_authtoken; // Set the authtoken in the config
80
83
  }
81
- if (header_apikey) {
82
- this.config.apikey = header_apikey; // Set the authtoken in the config
84
+ if (req_apikey) {
85
+ this.config.apikey = req_apikey; // Set the apikey in the config
83
86
  }
84
- if (header_accesskey) {
85
- this.config.accesskey = header_accesskey; // Set the accesskey in the config
87
+ if (req_accesskey) {
88
+ this.config.accesskey = req_accesskey; // Set the accesskey in the config
86
89
  }
87
90
 
88
91
  }
package/src/rbt_api.js CHANGED
@@ -1239,24 +1239,33 @@ export default class RbtApi {
1239
1239
  * Performs a GET request to the specified endpoint.
1240
1240
  *
1241
1241
  * This method uses the Axios instance to make an authenticated GET request.
1242
- * The `authtoken` stored in the class instance is included in the request headers
1243
- * for authorization. It handles any errors and returns the response data.
1242
+ * The `authtoken` and `accesskey` from axios defaults are automatically included.
1243
+ * Additional custom headers can be passed and will be merged with the defaults.
1244
1244
  *
1245
1245
  * @param {string} endpoint - The endpoint URL to which the GET request is made.
1246
1246
  * @param {Object} [params={}] - Optional parameters to be sent with the request.
1247
+ * @param {Object} [customHeaders=null] - Optional custom headers to merge with defaults.
1247
1248
  * @returns {Promise<Object>} - The response data from the API.
1248
1249
  */
1249
- async get(endpoint, params = {}) {
1250
+ async get(endpoint, params = {}, customHeaders = null) {
1250
1251
 
1251
1252
  try {
1252
1253
 
1253
- // Add the authToken to the headers
1254
- const headers = {
1255
- authtoken: this.authtoken
1256
- };
1254
+ // Build request config
1255
+ const config = { params };
1256
+
1257
+ // Only pass headers if custom headers are provided
1258
+ // If no custom headers, let axios use its defaults automatically
1259
+ // This ensures proper merging of all default headers (accesskey, authtoken, apikey)
1260
+ if (customHeaders && Object.keys(customHeaders).length > 0) {
1261
+ // When custom headers are provided, we need to manually merge with defaults
1262
+ // Axios will handle merging when we pass them this way
1263
+ config.headers = customHeaders;
1264
+ }
1265
+ // Otherwise, don't set config.headers at all - let axios use its defaults
1257
1266
 
1258
1267
  // Make the GET request using Axios
1259
- const response = await this.axios.get(endpoint, { params, headers });
1268
+ const response = await this.axios.get(endpoint, config);
1260
1269
 
1261
1270
  // Check if the response is not okay
1262
1271
  if (response.data.ok === false) {