From 6f7da10b8de87c134d316c1c67ab086c85e55f31 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 24 Jul 2025 10:00:34 -0600 Subject: [PATCH 1/3] reversed imports --- templates/api-index.js | 23 +---------------------- templates/axios.js | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/templates/api-index.js b/templates/api-index.js index f0c5440..f67287d 100644 --- a/templates/api-index.js +++ b/templates/api-index.js @@ -1,4 +1,4 @@ -const { axios } = require('../axios'); +const { axios, scrub } = require('../axios'); const set = require('lodash/set'); const https = require('https'); const fs = require('fs'); @@ -49,27 +49,6 @@ const handleError = (err) => { }; } -const scrub = (data) => { - if (!data || typeof data !== 'object' ) return data; - const secrets = ["x_api_key", "x-api-key", "access_token", "access-token", "authorization", "api_key", "api-key", "apikey", "accesstoken", "token", "password", "key"]; - if (Array.isArray(data)) { - return data.map(item => scrub(item)) - } - else { - const temp = {}; - for (const key of Object.keys(data)) { - if (typeof data[key] === 'object') { - temp[key] = scrub(data[key]); - } else if (secrets.includes(key.toLowerCase())) { - temp[key] = "********"; - } else { - temp[key] = data[key]; - } - } - return temp - } -} - const executeApiFunction = (id, clientID, polyCustom, requestArgs) => { const requestServerStartTime = Date.now(); diff --git a/templates/axios.js b/templates/axios.js index eece1f7..f999d62 100644 --- a/templates/axios.js +++ b/templates/axios.js @@ -5,7 +5,6 @@ const https = require('https'); const dotenv = require('dotenv'); const polyCustom = require('./poly-custom'); const { API_KEY, API_BASE_URL } = require('./constants'); -const { scrub } = require('../api/index.js') dotenv.config(); @@ -43,6 +42,29 @@ axios.interceptors.request.use( } ); + +const scrub = (data) => { + if (!data || typeof data !== 'object' ) return data; + const secrets = ["x_api_key", "x-api-key", "access_token", "access-token", "authorization", "api_key", "api-key", "apikey", "accesstoken", "token", "password", "key"]; + if (Array.isArray(data)) { + return data.map(item => scrub(item)) + } + else { + const temp = {}; + for (const key of Object.keys(data)) { + if (typeof data[key] === 'object') { + temp[key] = scrub(data[key]); + } else if (secrets.includes(key.toLowerCase())) { + temp[key] = "********"; + } else { + temp[key] = data[key]; + } + } + return temp + } +} + + const scrubKeys = (err) => { if (!err.request || typeof err.request.headers !== 'object') throw err const temp = scrub(err.request.headers) From c6e98f9a94ee93514c49c6ce27467e271bbd90a5 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 24 Jul 2025 10:01:08 -0600 Subject: [PATCH 2/3] bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2442abe..396d5f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.10", + "version": "0.24.11", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { From 41cdb1e4fc6ad2a717026f087d2513077781e7d9 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 24 Jul 2025 10:07:28 -0600 Subject: [PATCH 3/3] added scrub to exports --- templates/axios.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/axios.js b/templates/axios.js index f999d62..55587b7 100644 --- a/templates/axios.js +++ b/templates/axios.js @@ -81,5 +81,6 @@ const scrubKeys = (err) => { module.exports = { axios, - scrubKeys + scrubKeys, + scrub };