@arrowsphere/api-client 3.180.0-rc.fdi.10 → 3.180.0-rc.fdi.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/build/axiosSingleton.d.ts +42 -4
- package/build/axiosSingleton.js +46 -5
- package/package.json +1 -1
|
@@ -5,18 +5,56 @@ export declare type AxiosSingletonConfiguration = {
|
|
|
5
5
|
export declare class AxiosSingleton {
|
|
6
6
|
private static _axiosInstance;
|
|
7
7
|
private static _isLogging;
|
|
8
|
+
/**
|
|
9
|
+
* Get the singleton instance of Axios.
|
|
10
|
+
* @param configuration - Configuration object for AxiosSingleton.
|
|
11
|
+
*
|
|
12
|
+
* @returns The Axios instance.
|
|
13
|
+
*/
|
|
8
14
|
static getInstance(configuration?: AxiosSingletonConfiguration): AxiosInstance;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the request interceptor.
|
|
17
|
+
*/
|
|
9
18
|
private static _initializedRequestInterceptor;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the response interceptor.
|
|
21
|
+
*/
|
|
10
22
|
private static _initializedResponseInterceptor;
|
|
11
23
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
24
|
+
* Handle the request before it is sent.
|
|
25
|
+
*
|
|
26
|
+
* @param request - The Axios request configuration.
|
|
27
|
+
* @param isLogging - Whether logging is enabled.
|
|
28
|
+
*
|
|
29
|
+
* @returns The modified request configuration.
|
|
14
30
|
*/
|
|
15
31
|
private static _handleRequest;
|
|
16
32
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
33
|
+
* Handle the response after it is received.
|
|
34
|
+
*
|
|
35
|
+
* @param response - The Axios response.
|
|
36
|
+
* @param isLogging - Whether logging is enabled.
|
|
37
|
+
*
|
|
38
|
+
* @returns The modified response.
|
|
19
39
|
*/
|
|
20
40
|
private static _handleResponse;
|
|
41
|
+
/**
|
|
42
|
+
* Clean the response log by removing sensitive information.
|
|
43
|
+
*
|
|
44
|
+
* @param response - The Axios response.
|
|
45
|
+
*
|
|
46
|
+
* @returns The sanitized response.
|
|
47
|
+
*/
|
|
48
|
+
private static cleanResponseLog;
|
|
49
|
+
/**
|
|
50
|
+
* Sanitize an object by obfuscating sensitive fields.
|
|
51
|
+
* This function is recursive and supports circular references using WeakMap.
|
|
52
|
+
*
|
|
53
|
+
* @param obj - The object to sanitize.
|
|
54
|
+
* @param fieldsToObfuscate - List of keys whose values should be replaced with '***'. Defaults to ["authorization", "x-api-key", "password", "token"].
|
|
55
|
+
* @param seen - Internal map to track processed objects and prevent infinite loops. Defaults to new WeakMap().
|
|
56
|
+
*
|
|
57
|
+
* @returns A new sanitized object with sensitive data obfuscated or removed.
|
|
58
|
+
*/
|
|
21
59
|
private static sanitizeObject;
|
|
22
60
|
}
|
package/build/axiosSingleton.js
CHANGED
|
@@ -14,6 +14,12 @@ var DefaultObfuscateFields;
|
|
|
14
14
|
DefaultObfuscateFields["OLD_PASSWORD"] = "oldPassword";
|
|
15
15
|
})(DefaultObfuscateFields || (DefaultObfuscateFields = {}));
|
|
16
16
|
class AxiosSingleton {
|
|
17
|
+
/**
|
|
18
|
+
* Get the singleton instance of Axios.
|
|
19
|
+
* @param configuration - Configuration object for AxiosSingleton.
|
|
20
|
+
*
|
|
21
|
+
* @returns The Axios instance.
|
|
22
|
+
*/
|
|
17
23
|
static getInstance(configuration = {}) {
|
|
18
24
|
this._isLogging = !!configuration.isLogging;
|
|
19
25
|
if (!AxiosSingleton._axiosInstance) {
|
|
@@ -24,15 +30,25 @@ class AxiosSingleton {
|
|
|
24
30
|
}
|
|
25
31
|
return AxiosSingleton._axiosInstance;
|
|
26
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the request interceptor.
|
|
35
|
+
*/
|
|
27
36
|
static _initializedRequestInterceptor() {
|
|
28
37
|
this._axiosInstance.interceptors.request.use((req) => this._handleRequest(req, this._isLogging));
|
|
29
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Initialize the response interceptor.
|
|
41
|
+
*/
|
|
30
42
|
static _initializedResponseInterceptor() {
|
|
31
43
|
this._axiosInstance.interceptors.response.use((req) => this._handleResponse(req, this._isLogging));
|
|
32
44
|
}
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
46
|
+
* Handle the request before it is sent.
|
|
47
|
+
*
|
|
48
|
+
* @param request - The Axios request configuration.
|
|
49
|
+
* @param isLogging - Whether logging is enabled.
|
|
50
|
+
*
|
|
51
|
+
* @returns The modified request configuration.
|
|
36
52
|
*/
|
|
37
53
|
static _handleRequest(request, isLogging = false) {
|
|
38
54
|
if (isLogging) {
|
|
@@ -41,15 +57,40 @@ class AxiosSingleton {
|
|
|
41
57
|
return request;
|
|
42
58
|
}
|
|
43
59
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
60
|
+
* Handle the response after it is received.
|
|
61
|
+
*
|
|
62
|
+
* @param response - The Axios response.
|
|
63
|
+
* @param isLogging - Whether logging is enabled.
|
|
64
|
+
*
|
|
65
|
+
* @returns The modified response.
|
|
46
66
|
*/
|
|
47
67
|
static _handleResponse(response, isLogging = false) {
|
|
48
68
|
if (isLogging) {
|
|
49
|
-
console.info('AXIOS - Response : ', AxiosSingleton.
|
|
69
|
+
console.info('AXIOS - Response : ', AxiosSingleton.cleanResponseLog(response));
|
|
50
70
|
}
|
|
51
71
|
return response;
|
|
52
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Clean the response log by removing sensitive information.
|
|
75
|
+
*
|
|
76
|
+
* @param response - The Axios response.
|
|
77
|
+
*
|
|
78
|
+
* @returns The sanitized response.
|
|
79
|
+
*/
|
|
80
|
+
static cleanResponseLog(response) {
|
|
81
|
+
delete response.request;
|
|
82
|
+
return AxiosSingleton.sanitizeObject(response);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Sanitize an object by obfuscating sensitive fields.
|
|
86
|
+
* This function is recursive and supports circular references using WeakMap.
|
|
87
|
+
*
|
|
88
|
+
* @param obj - The object to sanitize.
|
|
89
|
+
* @param fieldsToObfuscate - List of keys whose values should be replaced with '***'. Defaults to ["authorization", "x-api-key", "password", "token"].
|
|
90
|
+
* @param seen - Internal map to track processed objects and prevent infinite loops. Defaults to new WeakMap().
|
|
91
|
+
*
|
|
92
|
+
* @returns A new sanitized object with sensitive data obfuscated or removed.
|
|
93
|
+
*/
|
|
53
94
|
static sanitizeObject(obj, fieldsToObfuscate = [
|
|
54
95
|
DefaultObfuscateFields.API_KEY,
|
|
55
96
|
DefaultObfuscateFields.PASSWORD,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/ArrowSphere/nodejs-api-client.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "3.180.0-rc.fdi.
|
|
7
|
+
"version": "3.180.0-rc.fdi.11",
|
|
8
8
|
"description": "Node.js client for ArrowSphere's public API",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"types": "build/index.d.ts",
|