Using nested variable in base64 encode function
- Dominant language
- TypeScript
- Stars
- 40k
- Forks
- 2.4k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 61
Description
**Describe the bug**
I have some request in our application which need a double authentication, due to thrid party software which is in use. Therefore I tried to use the base64 encode function of insomnia, but the function can only work with one parameter. So I introduced another variable which stores the concat of the username + : + password. This variable is added to the base64 function. The return value is stored in another variable, which is then used in the customHeader in the request.
In the environment view the value is correct base64 encoded. But if I use the variable with the base64 encoded value in the request view, the generated value is not correct. If you decode the value with another online tool you will see that the decoded value will show {{ application.user.username }} + {{ application.user.password }} .
If the concatValue and the base64 variable are moved to the first level in the JSON it works. Only if it is nested it is not working.
**To Reproduce**
Steps to reproduce the behavior:
Here is an example how the environment looks like:
Base environment:
```
{
"application": {
"utils": {
"concatValue": "{{ application.credentials.user.username }} : {{ application.credentials.user.password }}",
"base64EncodedValue": "base64({{ application.utils.concatValue }})"
}
}
}
```
Subenvironment:
```
{
"application": {
"credentials": {
"user": {
"username": "test",
"password": "test"
}
}
}
}
```
Add the application.utils.base64EncodedValue to the request header value.
**Expected behavior**
The nested value should be base64 encoded and not the variable names.
**Screenshots**
No screenshot as the preview value is not captured. Sorry
**Desktop (please complete the following information):**
- OS: Windows 10
- Installation Method: Download
- App Version Insomnia Core 2020.4.1
Contributor guide
Research direction
Reproduce the nested environment example in Insomnia and trace how template variables are resolved before the base64 function runs. Done means application.utils.base64EncodedValue resolves nested credentials and the request header contains the encoding of the actual test credentials rather than the variable names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100