mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-28 23:24:05 +00:00
* feat: add certs and proxy config to bru.sendRequest API Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle URL string argument in bru.sendRequest When bru.sendRequest is called with a plain URL string instead of a config object, the function now normalizes it to { url: string } before processing. This fixes the case where spreading a string created an invalid config object. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add variable interpolation to bru.sendRequest certs and proxy config Interpolate environment variables in clientCertificates and proxy configuration for bru.sendRequest API, enabling use of variables like {{CERT_PATH}} or {{PROXY_HOST}} in certificate paths and proxy settings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: use interpolateObject for certs and proxy config interpolation - Add interpolateObject to electron's interpolate-string.js using buildCombinedVars pattern (matches CLI implementation) - Simplify cert-utils.js by using interpolateObject instead of manual field-by-field interpolation - Add interpolation for clientCertificates and proxy config in CLI's run-single-request.js for bru.sendRequest Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: add all variable types to sendRequest interpolation options - Add globalEnvVars, collectionVariables, folderVariables, requestVariables to sendRequestInterpolationOptions for complete variable support - Use cached system proxy instead of redundant getSystemProxy() call - Remove duplicate getOptions() call Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: skip CA cert loading when TLS verification is disabled Only load CA certificates when shouldVerifyTls is true, since they are not used for validation when TLS verification is disabled. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
const { forOwn, cloneDeep } = require('lodash');
|
|
const { interpolate, interpolateObject: interpolateObjectCommon } = require('@usebruno/common');
|
|
|
|
const buildCombinedVars = ({
|
|
globalEnvironmentVariables,
|
|
collectionVariables,
|
|
envVars,
|
|
folderVariables,
|
|
requestVariables,
|
|
runtimeVariables,
|
|
processEnvVars,
|
|
promptVariables
|
|
}) => {
|
|
processEnvVars = processEnvVars || {};
|
|
runtimeVariables = runtimeVariables || {};
|
|
globalEnvironmentVariables = globalEnvironmentVariables || {};
|
|
collectionVariables = collectionVariables || {};
|
|
folderVariables = folderVariables || {};
|
|
requestVariables = requestVariables || {};
|
|
promptVariables = promptVariables || {};
|
|
|
|
// we clone envVars because we don't want to modify the original object
|
|
envVars = envVars ? cloneDeep(envVars) : {};
|
|
|
|
// envVars can inturn have values as {{process.env.VAR_NAME}}
|
|
// so we need to interpolate envVars first with processEnvVars
|
|
forOwn(envVars, (value, key) => {
|
|
envVars[key] = interpolate(value, {
|
|
process: {
|
|
env: {
|
|
...processEnvVars
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
return {
|
|
...globalEnvironmentVariables,
|
|
...collectionVariables,
|
|
...envVars,
|
|
...folderVariables,
|
|
...requestVariables,
|
|
...runtimeVariables,
|
|
...promptVariables,
|
|
process: {
|
|
env: {
|
|
...processEnvVars
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
const interpolateString = (str, interpolationOptions) => {
|
|
if (!str || !str.length || typeof str !== 'string') {
|
|
return str;
|
|
}
|
|
|
|
const combinedVars = buildCombinedVars(interpolationOptions);
|
|
return interpolate(str, combinedVars);
|
|
};
|
|
|
|
/**
|
|
* Recursively interpolates all string values in an object
|
|
*/
|
|
const interpolateObject = (obj, interpolationOptions) => {
|
|
const combinedVars = buildCombinedVars(interpolationOptions);
|
|
return interpolateObjectCommon(obj, combinedVars);
|
|
};
|
|
|
|
module.exports = {
|
|
interpolateString,
|
|
interpolateObject
|
|
};
|