polyapi 0.24.10 → 0.24.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/templates/api-index.js +1 -22
- package/build/templates/axios.js +25 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { axios } = require('../axios');
|
|
1
|
+
const { axios, scrub } = require('../axios');
|
|
2
2
|
const set = require('lodash/set');
|
|
3
3
|
const https = require('https');
|
|
4
4
|
const fs = require('fs');
|
|
@@ -49,27 +49,6 @@ const handleError = (err) => {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const scrub = (data) => {
|
|
53
|
-
if (!data || typeof data !== 'object' ) return data;
|
|
54
|
-
const secrets = ["x_api_key", "x-api-key", "access_token", "access-token", "authorization", "api_key", "api-key", "apikey", "accesstoken", "token", "password", "key"];
|
|
55
|
-
if (Array.isArray(data)) {
|
|
56
|
-
return data.map(item => scrub(item))
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const temp = {};
|
|
60
|
-
for (const key of Object.keys(data)) {
|
|
61
|
-
if (typeof data[key] === 'object') {
|
|
62
|
-
temp[key] = scrub(data[key]);
|
|
63
|
-
} else if (secrets.includes(key.toLowerCase())) {
|
|
64
|
-
temp[key] = "********";
|
|
65
|
-
} else {
|
|
66
|
-
temp[key] = data[key];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return temp
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
52
|
|
|
74
53
|
const executeApiFunction = (id, clientID, polyCustom, requestArgs) => {
|
|
75
54
|
const requestServerStartTime = Date.now();
|
package/build/templates/axios.js
CHANGED
|
@@ -5,7 +5,6 @@ const https = require('https');
|
|
|
5
5
|
const dotenv = require('dotenv');
|
|
6
6
|
const polyCustom = require('./poly-custom');
|
|
7
7
|
const { API_KEY, API_BASE_URL } = require('./constants');
|
|
8
|
-
import { scrub } from './api-index.js'
|
|
9
8
|
|
|
10
9
|
dotenv.config();
|
|
11
10
|
|
|
@@ -43,6 +42,29 @@ axios.interceptors.request.use(
|
|
|
43
42
|
}
|
|
44
43
|
);
|
|
45
44
|
|
|
45
|
+
|
|
46
|
+
const scrub = (data) => {
|
|
47
|
+
if (!data || typeof data !== 'object' ) return data;
|
|
48
|
+
const secrets = ["x_api_key", "x-api-key", "access_token", "access-token", "authorization", "api_key", "api-key", "apikey", "accesstoken", "token", "password", "key"];
|
|
49
|
+
if (Array.isArray(data)) {
|
|
50
|
+
return data.map(item => scrub(item))
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const temp = {};
|
|
54
|
+
for (const key of Object.keys(data)) {
|
|
55
|
+
if (typeof data[key] === 'object') {
|
|
56
|
+
temp[key] = scrub(data[key]);
|
|
57
|
+
} else if (secrets.includes(key.toLowerCase())) {
|
|
58
|
+
temp[key] = "********";
|
|
59
|
+
} else {
|
|
60
|
+
temp[key] = data[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return temp
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
46
68
|
const scrubKeys = (err) => {
|
|
47
69
|
if (!err.request || typeof err.request.headers !== 'object') throw err
|
|
48
70
|
const temp = scrub(err.request.headers)
|
|
@@ -59,5 +81,6 @@ const scrubKeys = (err) => {
|
|
|
59
81
|
|
|
60
82
|
module.exports = {
|
|
61
83
|
axios,
|
|
62
|
-
scrubKeys
|
|
84
|
+
scrubKeys,
|
|
85
|
+
scrub
|
|
63
86
|
};
|