roboto-js 1.8.8 → 1.8.10
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/dist/cjs/index.cjs +23 -2
- package/dist/cjs/rbt_api.cjs +31 -21
- package/dist/esm/index.js +23 -2
- package/dist/esm/rbt_api.js +31 -21
- package/dist/index.js +14 -10
- package/dist/rbt_api.js +21 -11
- package/package.json +1 -1
- package/src/index.js +23 -3
- package/src/rbt_api.js +17 -8
package/.last-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2025-11-
|
|
1
|
+
2025-11-14T12:07:32.032Z
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -55,7 +55,9 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
55
55
|
disableWebSocket = _ref$disableWebSocket === void 0 ? false : _ref$disableWebSocket,
|
|
56
56
|
metricsHost = _ref.metricsHost,
|
|
57
57
|
_ref$useCookies = _ref.useCookies,
|
|
58
|
-
useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies
|
|
58
|
+
useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies,
|
|
59
|
+
_ref$cookieDomain = _ref.cookieDomain,
|
|
60
|
+
cookieDomain = _ref$cookieDomain === void 0 ? 'auto' : _ref$cookieDomain;
|
|
59
61
|
var proxyReq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
60
62
|
_classCallCheck(this, Roboto);
|
|
61
63
|
if (Roboto.instance && !proxyReq) {
|
|
@@ -69,11 +71,30 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
69
71
|
// Auto-configure storage adaptor
|
|
70
72
|
var storageAdaptor = localStorageAdaptor;
|
|
71
73
|
if (!storageAdaptor && isBrowser && useCookies) {
|
|
74
|
+
// Determine cookie domain for cross-subdomain support
|
|
75
|
+
var domain = undefined;
|
|
76
|
+
if (cookieDomain === 'auto') {
|
|
77
|
+
// Auto-detect: extract root domain for cross-subdomain cookies
|
|
78
|
+
// e.g., "beta.ringable.ai" → ".ringable.ai"
|
|
79
|
+
var hostname = window.location.hostname;
|
|
80
|
+
var parts = hostname.split('.');
|
|
81
|
+
// Only set domain for multi-part domains (not localhost or IPs)
|
|
82
|
+
if (parts.length > 2 && !hostname.match(/^\d+\.\d+\.\d+\.\d+$/)) {
|
|
83
|
+
// Get last two parts (domain.tld) and prepend with dot
|
|
84
|
+
domain = '.' + parts.slice(-2).join('.');
|
|
85
|
+
}
|
|
86
|
+
} else if (cookieDomain && cookieDomain !== 'none') {
|
|
87
|
+
// Use explicitly provided domain
|
|
88
|
+
domain = cookieDomain;
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
// Use cookies by default in browser for better server-side compatibility
|
|
73
92
|
storageAdaptor = new _cookie_storage_adaptor["default"]({
|
|
74
93
|
secure: window.location.protocol === 'https:',
|
|
75
94
|
sameSite: 'Lax',
|
|
76
|
-
maxAge: 24 * 60 * 60
|
|
95
|
+
maxAge: 24 * 60 * 60,
|
|
96
|
+
// 24 hours
|
|
97
|
+
domain: domain
|
|
77
98
|
});
|
|
78
99
|
// Set accessKey for server-side authentication (handled automatically by adapter)
|
|
79
100
|
if (accessKey) {
|
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -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`
|
|
1943
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
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 =
|
|
1985
|
+
_context29.next = 10;
|
|
1976
1986
|
break;
|
|
1977
1987
|
}
|
|
1978
1988
|
return _context29.abrupt("return", this._handleError(response));
|
|
1979
|
-
case
|
|
1989
|
+
case 10:
|
|
1980
1990
|
return _context29.abrupt("return", response.data);
|
|
1981
|
-
case
|
|
1982
|
-
_context29.prev =
|
|
1983
|
-
_context29.t0 = _context29["catch"](
|
|
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
|
|
1995
|
+
case 16:
|
|
1986
1996
|
case "end":
|
|
1987
1997
|
return _context29.stop();
|
|
1988
1998
|
}
|
|
1989
|
-
}, _callee29, this, [[
|
|
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
|
@@ -28,7 +28,9 @@ var Roboto = /*#__PURE__*/function () {
|
|
|
28
28
|
disableWebSocket = _ref$disableWebSocket === void 0 ? false : _ref$disableWebSocket,
|
|
29
29
|
metricsHost = _ref.metricsHost,
|
|
30
30
|
_ref$useCookies = _ref.useCookies,
|
|
31
|
-
useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies
|
|
31
|
+
useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies,
|
|
32
|
+
_ref$cookieDomain = _ref.cookieDomain,
|
|
33
|
+
cookieDomain = _ref$cookieDomain === void 0 ? 'auto' : _ref$cookieDomain;
|
|
32
34
|
var proxyReq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
33
35
|
_classCallCheck(this, Roboto);
|
|
34
36
|
if (Roboto.instance && !proxyReq) {
|
|
@@ -42,11 +44,30 @@ var Roboto = /*#__PURE__*/function () {
|
|
|
42
44
|
// Auto-configure storage adaptor
|
|
43
45
|
var storageAdaptor = localStorageAdaptor;
|
|
44
46
|
if (!storageAdaptor && isBrowser && useCookies) {
|
|
47
|
+
// Determine cookie domain for cross-subdomain support
|
|
48
|
+
var domain = undefined;
|
|
49
|
+
if (cookieDomain === 'auto') {
|
|
50
|
+
// Auto-detect: extract root domain for cross-subdomain cookies
|
|
51
|
+
// e.g., "beta.ringable.ai" → ".ringable.ai"
|
|
52
|
+
var hostname = window.location.hostname;
|
|
53
|
+
var parts = hostname.split('.');
|
|
54
|
+
// Only set domain for multi-part domains (not localhost or IPs)
|
|
55
|
+
if (parts.length > 2 && !hostname.match(/^\d+\.\d+\.\d+\.\d+$/)) {
|
|
56
|
+
// Get last two parts (domain.tld) and prepend with dot
|
|
57
|
+
domain = '.' + parts.slice(-2).join('.');
|
|
58
|
+
}
|
|
59
|
+
} else if (cookieDomain && cookieDomain !== 'none') {
|
|
60
|
+
// Use explicitly provided domain
|
|
61
|
+
domain = cookieDomain;
|
|
62
|
+
}
|
|
63
|
+
|
|
45
64
|
// Use cookies by default in browser for better server-side compatibility
|
|
46
65
|
storageAdaptor = new CookieStorageAdaptor({
|
|
47
66
|
secure: window.location.protocol === 'https:',
|
|
48
67
|
sameSite: 'Lax',
|
|
49
|
-
maxAge: 24 * 60 * 60
|
|
68
|
+
maxAge: 24 * 60 * 60,
|
|
69
|
+
// 24 hours
|
|
70
|
+
domain: domain
|
|
50
71
|
});
|
|
51
72
|
// Set accessKey for server-side authentication (handled automatically by adapter)
|
|
52
73
|
if (accessKey) {
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -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`
|
|
1936
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
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 =
|
|
1978
|
+
_context29.next = 10;
|
|
1969
1979
|
break;
|
|
1970
1980
|
}
|
|
1971
1981
|
return _context29.abrupt("return", this._handleError(response));
|
|
1972
|
-
case
|
|
1982
|
+
case 10:
|
|
1973
1983
|
return _context29.abrupt("return", response.data);
|
|
1974
|
-
case
|
|
1975
|
-
_context29.prev =
|
|
1976
|
-
_context29.t0 = _context29["catch"](
|
|
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
|
|
1988
|
+
case 16:
|
|
1979
1989
|
case "end":
|
|
1980
1990
|
return _context29.stop();
|
|
1981
1991
|
}
|
|
1982
|
-
}, _callee29, this, [[
|
|
1992
|
+
}, _callee29, this, [[2, 13]]);
|
|
1983
1993
|
}));
|
|
1984
1994
|
function get(_x18) {
|
|
1985
1995
|
return _get.apply(this, arguments);
|
package/dist/index.js
CHANGED
|
@@ -89,19 +89,23 @@ var Roboto = /*#__PURE__*/function () {
|
|
|
89
89
|
this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
|
|
90
90
|
|
|
91
91
|
// Check if a request object is provided
|
|
92
|
-
if (proxyReq
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
if (proxyReq) {
|
|
93
|
+
var _proxyReq$headers, _proxyReq$headers2, _proxyReq$headers3;
|
|
94
|
+
// First priority: properties set by middleware (supports cookie-based auth)
|
|
95
|
+
// Second priority: custom headers (backward compatibility)
|
|
96
|
+
var req_authtoken = proxyReq.authToken || ((_proxyReq$headers = proxyReq.headers) === null || _proxyReq$headers === void 0 ? void 0 : _proxyReq$headers.authtoken);
|
|
97
|
+
var req_accesskey = proxyReq.accessKey || ((_proxyReq$headers2 = proxyReq.headers) === null || _proxyReq$headers2 === void 0 ? void 0 : _proxyReq$headers2.accesskey);
|
|
98
|
+
var req_apikey = proxyReq.apiKey || ((_proxyReq$headers3 = proxyReq.headers) === null || _proxyReq$headers3 === void 0 ? void 0 : _proxyReq$headers3.apikey);
|
|
99
|
+
|
|
96
100
|
// Optionally add more headers as needed
|
|
97
|
-
if (
|
|
98
|
-
this.config.authtoken =
|
|
101
|
+
if (req_authtoken) {
|
|
102
|
+
this.config.authtoken = req_authtoken; // Set the authtoken in the config
|
|
99
103
|
}
|
|
100
|
-
if (
|
|
101
|
-
this.config.apikey =
|
|
104
|
+
if (req_apikey) {
|
|
105
|
+
this.config.apikey = req_apikey; // Set the apikey in the config
|
|
102
106
|
}
|
|
103
|
-
if (
|
|
104
|
-
this.config.accesskey =
|
|
107
|
+
if (req_accesskey) {
|
|
108
|
+
this.config.accesskey = req_accesskey; // Set the accesskey in the config
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
this.api = new RbtApi(this.config);
|
package/dist/rbt_api.js
CHANGED
|
@@ -1957,11 +1957,12 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1957
1957
|
* Performs a GET request to the specified endpoint.
|
|
1958
1958
|
*
|
|
1959
1959
|
* This method uses the Axios instance to make an authenticated GET request.
|
|
1960
|
-
* The `authtoken`
|
|
1961
|
-
*
|
|
1960
|
+
* The `authtoken` and `accesskey` from axios defaults are automatically included.
|
|
1961
|
+
* Additional custom headers can be passed and will be merged with the defaults.
|
|
1962
1962
|
*
|
|
1963
1963
|
* @param {string} endpoint - The endpoint URL to which the GET request is made.
|
|
1964
1964
|
* @param {Object} [params={}] - Optional parameters to be sent with the request.
|
|
1965
|
+
* @param {Object} [customHeaders=null] - Optional custom headers to merge with defaults.
|
|
1965
1966
|
* @returns {Promise<Object>} - The response data from the API.
|
|
1966
1967
|
*/
|
|
1967
1968
|
)
|
|
@@ -1970,7 +1971,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1970
1971
|
value: (function () {
|
|
1971
1972
|
var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(endpoint) {
|
|
1972
1973
|
var params,
|
|
1973
|
-
|
|
1974
|
+
customHeaders,
|
|
1975
|
+
config,
|
|
1974
1976
|
response,
|
|
1975
1977
|
_args27 = arguments,
|
|
1976
1978
|
_t20;
|
|
@@ -1978,16 +1980,24 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1978
1980
|
while (1) switch (_context27.p = _context27.n) {
|
|
1979
1981
|
case 0:
|
|
1980
1982
|
params = _args27.length > 1 && _args27[1] !== undefined ? _args27[1] : {};
|
|
1983
|
+
customHeaders = _args27.length > 2 && _args27[2] !== undefined ? _args27[2] : null;
|
|
1981
1984
|
_context27.p = 1;
|
|
1982
|
-
//
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}; //
|
|
1985
|
+
// Build request config
|
|
1986
|
+
config = {
|
|
1987
|
+
params: params
|
|
1988
|
+
}; // Only pass headers if custom headers are provided
|
|
1989
|
+
// If no custom headers, let axios use its defaults automatically
|
|
1990
|
+
// This ensures proper merging of all default headers (accesskey, authtoken, apikey)
|
|
1991
|
+
if (customHeaders && Object.keys(customHeaders).length > 0) {
|
|
1992
|
+
// When custom headers are provided, we need to manually merge with defaults
|
|
1993
|
+
// Axios will handle merging when we pass them this way
|
|
1994
|
+
config.headers = customHeaders;
|
|
1995
|
+
}
|
|
1996
|
+
// Otherwise, don't set config.headers at all - let axios use its defaults
|
|
1997
|
+
|
|
1998
|
+
// Make the GET request using Axios
|
|
1986
1999
|
_context27.n = 2;
|
|
1987
|
-
return this.axios.get(endpoint,
|
|
1988
|
-
params: params,
|
|
1989
|
-
headers: headers
|
|
1990
|
-
});
|
|
2000
|
+
return this.axios.get(endpoint, config);
|
|
1991
2001
|
case 2:
|
|
1992
2002
|
response = _context27.v;
|
|
1993
2003
|
if (!(response.data.ok === false)) {
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -20,9 +20,9 @@ export default class Roboto{
|
|
|
20
20
|
return '1.7.3';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
constructor({ host, accessKey, apiKey, authToken, localStorageAdaptor, disableWebSocket = false, metricsHost, useCookies = true }, proxyReq = null) {
|
|
23
|
+
constructor({ host, accessKey, apiKey, authToken, localStorageAdaptor, disableWebSocket = false, metricsHost, useCookies = true, cookieDomain = 'auto' }, proxyReq = null) {
|
|
24
24
|
|
|
25
|
-
console.log('[Roboto] constructor', { host, accessKey, apiKey, authToken, localStorageAdaptor, disableWebSocket, metricsHost, useCookies, proxyReq });
|
|
25
|
+
console.log('[Roboto] constructor', { host, accessKey, apiKey, authToken, localStorageAdaptor, disableWebSocket, metricsHost, useCookies, cookieDomain, proxyReq });
|
|
26
26
|
|
|
27
27
|
if (Roboto.instance && !proxyReq) {
|
|
28
28
|
// if on client, there can only be one instance
|
|
@@ -36,11 +36,31 @@ export default class Roboto{
|
|
|
36
36
|
// Auto-configure storage adaptor
|
|
37
37
|
let storageAdaptor = localStorageAdaptor;
|
|
38
38
|
if (!storageAdaptor && isBrowser && useCookies) {
|
|
39
|
+
// Determine cookie domain for cross-subdomain support
|
|
40
|
+
let domain = undefined;
|
|
41
|
+
if (cookieDomain === 'auto') {
|
|
42
|
+
// Auto-detect: extract root domain for cross-subdomain cookies
|
|
43
|
+
// e.g., "beta.ringable.ai" → ".ringable.ai"
|
|
44
|
+
const hostname = window.location.hostname;
|
|
45
|
+
const parts = hostname.split('.');
|
|
46
|
+
// Only set domain for multi-part domains (not localhost or IPs)
|
|
47
|
+
if (parts.length > 2 && !hostname.match(/^\d+\.\d+\.\d+\.\d+$/)) {
|
|
48
|
+
// Get last two parts (domain.tld) and prepend with dot
|
|
49
|
+
domain = '.' + parts.slice(-2).join('.');
|
|
50
|
+
console.log(`[Roboto] Auto-detected cookie domain: ${domain} from hostname: ${hostname}`);
|
|
51
|
+
}
|
|
52
|
+
} else if (cookieDomain && cookieDomain !== 'none') {
|
|
53
|
+
// Use explicitly provided domain
|
|
54
|
+
domain = cookieDomain;
|
|
55
|
+
console.log(`[Roboto] Using explicit cookie domain: ${domain}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
39
58
|
// Use cookies by default in browser for better server-side compatibility
|
|
40
59
|
storageAdaptor = new CookieStorageAdaptor({
|
|
41
60
|
secure: window.location.protocol === 'https:',
|
|
42
61
|
sameSite: 'Lax',
|
|
43
|
-
maxAge: 24 * 60 * 60 // 24 hours
|
|
62
|
+
maxAge: 24 * 60 * 60, // 24 hours
|
|
63
|
+
domain: domain
|
|
44
64
|
});
|
|
45
65
|
console.log('[Roboto] Using CookieStorageAdaptor for authentication tokens');
|
|
46
66
|
|
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`
|
|
1243
|
-
*
|
|
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
|
-
//
|
|
1254
|
-
const
|
|
1255
|
-
|
|
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,
|
|
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) {
|