roboto-js 1.8.9 → 1.8.11
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 +2 -1
- package/dist/esm/index.js +23 -2
- package/dist/esm/rbt_api.js +2 -1
- 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 +2 -1
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
|
@@ -60,7 +60,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
60
60
|
baseURL: baseUrl,
|
|
61
61
|
headers: {
|
|
62
62
|
'accesskey': accesskey
|
|
63
|
-
}
|
|
63
|
+
},
|
|
64
|
+
withCredentials: true // Enable sending cookies in cross-origin requests
|
|
64
65
|
});
|
|
65
66
|
this.axios.__rbtApiInstance = this;
|
|
66
67
|
if (localStorageAdaptor) {
|
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
|
@@ -53,7 +53,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
53
53
|
baseURL: baseUrl,
|
|
54
54
|
headers: {
|
|
55
55
|
'accesskey': accesskey
|
|
56
|
-
}
|
|
56
|
+
},
|
|
57
|
+
withCredentials: true // Enable sending cookies in cross-origin requests
|
|
57
58
|
});
|
|
58
59
|
this.axios.__rbtApiInstance = this;
|
|
59
60
|
if (localStorageAdaptor) {
|
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
|
|