From cd00c21781a0ca6d354c3d60ec2026f9d293ebf9 Mon Sep 17 00:00:00 2001 From: lohit-bruno Date: Wed, 20 Aug 2025 16:30:08 +0530 Subject: [PATCH 1/4] dsl updates --- packages/bruno-lang/v2/src/bruToJson.js | 44 +++++++++---------- .../bruno-lang/v2/src/collectionBruToJson.js | 44 +++++++++---------- packages/bruno-lang/v2/src/jsonToBru.js | 16 +++---- .../bruno-lang/v2/src/jsonToCollectionBru.js | 16 +++---- .../v2/tests/oauth2-additional-params.spec.js | 32 +++++++------- 5 files changed, 76 insertions(+), 76 deletions(-) diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index d569d196a..766835061 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -29,17 +29,17 @@ const { safeParseJson, outdentString } = require('./utils'); * */ const grammar = ohm.grammar(`Bru { - BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | settings | docs | authOAuth2Configs)* - auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey + BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | settings | docs)* + auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey | authOauth2Configs bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body bodyforms = bodyformurlencoded | bodymultipart | bodyfile params = paramspath | paramsquery // Oauth2 additional parameters - authOAuth2Configs = oAuth2AuthorizationConfig | oAuth2TokenConfig | oAuth2RefreshConfig - oAuth2AuthorizationConfig = oAuth2AuthorizationHeaders | oAuth2AuthorizationQueryParams - oAuth2TokenConfig = oAuth2TokenHeaders | oAuth2TokenQueryParams | oAuth2TokenBodyValues - oAuth2RefreshConfig = oAuth2RefreshHeaders | oAuth2RefreshQueryParams | oAuth2RefreshBodyValues + authOauth2Configs = oauth2AuthReqConfig | oauth2AccessTokenReqConfig | oauth2RefreshTokenReqConfig + oauth2AuthReqConfig = oauth2AuthReqHeaders | oauth2AuthReqQueryParams + oauth2AccessTokenReqConfig = oauth2AccessTokenReqHeaders | oauth2AccessTokenReqQueryParams | oauth2AccessTokenReqBody + oauth2RefreshTokenReqConfig = oauth2RefreshTokenReqHeaders | oauth2RefreshTokenReqQueryParams | oauth2RefreshTokenReqBody nl = "\\r"? "\\n" st = " " | "\\t" @@ -111,14 +111,14 @@ const grammar = ohm.grammar(`Bru { authwsse = "auth:wsse" dictionary authapikey = "auth:apikey" dictionary - oAuth2AuthorizationHeaders = "auth:oauth2:authorization_headers" dictionary - oAuth2AuthorizationQueryParams = "auth:oauth2:authorization_queryparams" dictionary - oAuth2TokenHeaders = "auth:oauth2:token_headers" dictionary - oAuth2TokenQueryParams = "auth:oauth2:token_queryparams" dictionary - oAuth2TokenBodyValues = "auth:oauth2:token_bodyvalues" dictionary - oAuth2RefreshHeaders = "auth:oauth2:refresh_headers" dictionary - oAuth2RefreshQueryParams = "auth:oauth2:refresh_queryparams" dictionary - oAuth2RefreshBodyValues = "auth:oauth2:refresh_bodyvalues" dictionary + oauth2AuthReqHeaders = "auth:oauth2:additional_params:auth_req:headers" dictionary + oauth2AuthReqQueryParams = "auth:oauth2:additional_params:auth_req:queryparams" dictionary + oauth2AccessTokenReqHeaders = "auth:oauth2:additional_params:access_token_req:headers" dictionary + oauth2AccessTokenReqQueryParams = "auth:oauth2:additional_params:access_token_req:queryparams" dictionary + oauth2AccessTokenReqBody = "auth:oauth2:additional_params:access_token_req:body" dictionary + oauth2RefreshTokenReqHeaders = "auth:oauth2:additional_params:refresh_token_req:headers" dictionary + oauth2RefreshTokenReqQueryParams = "auth:oauth2:additional_params:refresh_token_req:queryparams" dictionary + oauth2RefreshTokenReqBody = "auth:oauth2:additional_params:refresh_token_req:body" dictionary body = "body" st* "{" nl* textblock tagend bodyjson = "body:json" st* "{" nl* textblock tagend @@ -655,42 +655,42 @@ const sem = grammar.createSemantics().addAttribute('ast', { } }; }, - oAuth2AuthorizationHeaders(_1, dictionary) { + oauth2AuthReqHeaders(_1, dictionary) { return { oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2AuthorizationQueryParams(_1, dictionary) { + oauth2AuthReqQueryParams(_1, dictionary) { return { oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2TokenHeaders(_1, dictionary) { + oauth2AccessTokenReqHeaders(_1, dictionary) { return { oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2TokenQueryParams(_1, dictionary) { + oauth2AccessTokenReqQueryParams(_1, dictionary) { return { oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2TokenBodyValues(_1, dictionary) { + oauth2AccessTokenReqBody(_1, dictionary) { return { oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2RefreshHeaders(_1, dictionary) { + oauth2RefreshTokenReqHeaders(_1, dictionary) { return { oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2RefreshQueryParams(_1, dictionary) { + oauth2RefreshTokenReqQueryParams(_1, dictionary) { return { oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2RefreshBodyValues(_1, dictionary) { + oauth2RefreshTokenReqBody(_1, dictionary) { return { oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; diff --git a/packages/bruno-lang/v2/src/collectionBruToJson.js b/packages/bruno-lang/v2/src/collectionBruToJson.js index 5a12e4302..0c698e6ce 100644 --- a/packages/bruno-lang/v2/src/collectionBruToJson.js +++ b/packages/bruno-lang/v2/src/collectionBruToJson.js @@ -3,14 +3,14 @@ const _ = require('lodash'); const { safeParseJson, outdentString } = require('./utils'); const grammar = ohm.grammar(`Bru { - BruFile = (meta | query | headers | auth | auths | vars | script | tests | docs | authOAuth2Configs)* - auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM |authOAuth2 | authwsse | authapikey + BruFile = (meta | query | headers | auth | auths | vars | script | tests | docs)* + auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM |authOAuth2 | authwsse | authapikey | authOauth2Configs // Oauth2 additional parameters - authOAuth2Configs = oAuth2AuthorizationConfig | oAuth2TokenConfig | oAuth2RefreshConfig - oAuth2AuthorizationConfig = oAuth2AuthorizationHeaders | oAuth2AuthorizationQueryParams - oAuth2TokenConfig = oAuth2TokenHeaders | oAuth2TokenQueryParams | oAuth2TokenBodyValues - oAuth2RefreshConfig = oAuth2RefreshHeaders | oAuth2RefreshQueryParams | oAuth2RefreshBodyValues + authOauth2Configs = oauth2AuthReqConfig | oauth2AccessTokenReqConfig | oauth2RefreshTokenReqConfig + oauth2AuthReqConfig = oauth2AuthReqHeaders | oauth2AuthReqQueryParams + oauth2AccessTokenReqConfig = oauth2AccessTokenReqHeaders | oauth2AccessTokenReqQueryParams | oauth2AccessTokenReqBody + oauth2RefreshTokenReqConfig = oauth2RefreshTokenReqHeaders | oauth2RefreshTokenReqQueryParams | oauth2RefreshTokenReqBody nl = "\\r"? "\\n" st = " " | "\\t" @@ -36,14 +36,14 @@ const grammar = ohm.grammar(`Bru { auth = "auth" dictionary - oAuth2AuthorizationHeaders = "auth:oauth2:authorization_headers" dictionary - oAuth2AuthorizationQueryParams = "auth:oauth2:authorization_queryparams" dictionary - oAuth2TokenHeaders = "auth:oauth2:token_headers" dictionary - oAuth2TokenQueryParams = "auth:oauth2:token_queryparams" dictionary - oAuth2TokenBodyValues = "auth:oauth2:token_bodyvalues" dictionary - oAuth2RefreshHeaders = "auth:oauth2:refresh_headers" dictionary - oAuth2RefreshQueryParams = "auth:oauth2:refresh_queryparams" dictionary - oAuth2RefreshBodyValues = "auth:oauth2:refresh_bodyvalues" dictionary + oauth2AuthReqHeaders = "auth:oauth2:additional_params:auth_req:headers" dictionary + oauth2AuthReqQueryParams = "auth:oauth2:additional_params:auth_req:queryparams" dictionary + oauth2AccessTokenReqHeaders = "auth:oauth2:additional_params:access_token_req:headers" dictionary + oauth2AccessTokenReqQueryParams = "auth:oauth2:additional_params:access_token_req:queryparams" dictionary + oauth2AccessTokenReqBody = "auth:oauth2:additional_params:access_token_req:body" dictionary + oauth2RefreshTokenReqHeaders = "auth:oauth2:additional_params:refresh_token_req:headers" dictionary + oauth2RefreshTokenReqQueryParams = "auth:oauth2:additional_params:refresh_token_req:queryparams" dictionary + oauth2RefreshTokenReqBody = "auth:oauth2:additional_params:refresh_token_req:body" dictionary headers = "headers" dictionary @@ -377,42 +377,42 @@ const sem = grammar.createSemantics().addAttribute('ast', { } }; }, - oAuth2AuthorizationHeaders(_1, dictionary) { + oauth2AuthReqHeaders(_1, dictionary) { return { oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2AuthorizationQueryParams(_1, dictionary) { + oauth2AuthReqQueryParams(_1, dictionary) { return { oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2TokenHeaders(_1, dictionary) { + oauth2AccessTokenReqHeaders(_1, dictionary) { return { oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2TokenQueryParams(_1, dictionary) { + oauth2AccessTokenReqQueryParams(_1, dictionary) { return { oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2TokenBodyValues(_1, dictionary) { + oauth2AccessTokenReqBody(_1, dictionary) { return { oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2RefreshHeaders(_1, dictionary) { + oauth2RefreshTokenReqHeaders(_1, dictionary) { return { oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2RefreshQueryParams(_1, dictionary) { + oauth2RefreshTokenReqQueryParams(_1, dictionary) { return { oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, - oAuth2RefreshBodyValues(_1, dictionary) { + oauth2RefreshTokenReqBody(_1, dictionary) { return { oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js index e226f51e5..ec601fce1 100644 --- a/packages/bruno-lang/v2/src/jsonToBru.js +++ b/packages/bruno-lang/v2/src/jsonToBru.js @@ -286,7 +286,7 @@ ${indentString(`auto_fetch_token: ${(auth?.oauth2?.autoFetchToken ?? true).toStr const { authorization: authorizationParams, token: tokenParams, refresh: refreshParams } = auth?.oauth2?.additionalParameters; const authorizationHeaders = authorizationParams?.filter(p => p?.sendIn == 'headers'); if (authorizationHeaders?.length) { - bru += `auth:oauth2:authorization_headers { + bru += `auth:oauth2:additional_params:auth_req:headers { ${indentString( authorizationHeaders .filter(item => item?.name?.length) @@ -299,7 +299,7 @@ ${indentString( } const authorizationQueryParams = authorizationParams?.filter(p => p?.sendIn == 'queryparams'); if (authorizationQueryParams?.length) { - bru += `auth:oauth2:authorization_queryparams { + bru += `auth:oauth2:additional_params:auth_req:queryparams { ${indentString( authorizationQueryParams .filter(item => item?.name?.length) @@ -312,7 +312,7 @@ ${indentString( } const tokenHeaders = tokenParams?.filter(p => p?.sendIn == 'headers'); if (tokenHeaders?.length) { - bru += `auth:oauth2:token_headers { + bru += `auth:oauth2:additional_params:access_token_req:headers { ${indentString( tokenHeaders .filter(item => item?.name?.length) @@ -325,7 +325,7 @@ ${indentString( } const tokenQueryParams = tokenParams?.filter(p => p?.sendIn == 'queryparams'); if (tokenQueryParams?.length) { - bru += `auth:oauth2:token_queryparams { + bru += `auth:oauth2:additional_params:access_token_req:queryparams { ${indentString( tokenQueryParams .filter(item => item?.name?.length) @@ -338,7 +338,7 @@ ${indentString( } const tokenBodyValues = tokenParams?.filter(p => p?.sendIn == 'body'); if (tokenBodyValues?.length) { - bru += `auth:oauth2:token_bodyvalues { + bru += `auth:oauth2:additional_params:access_token_req:body { ${indentString( tokenBodyValues .filter(item => item?.name?.length) @@ -351,7 +351,7 @@ ${indentString( } const refreshHeaders = refreshParams?.filter(p => p?.sendIn == 'headers'); if (refreshHeaders?.length) { - bru += `auth:oauth2:refresh_headers { + bru += `auth:oauth2:additional_params:refresh_token_req:headers { ${indentString( refreshHeaders .filter(item => item?.name?.length) @@ -364,7 +364,7 @@ ${indentString( } const refreshQueryParams = refreshParams?.filter(p => p?.sendIn == 'queryparams'); if (refreshQueryParams?.length) { - bru += `auth:oauth2:refresh_queryparams { + bru += `auth:oauth2:additional_params:refresh_token_req:queryparams { ${indentString( refreshQueryParams .filter(item => item?.name?.length) @@ -377,7 +377,7 @@ ${indentString( } const refreshBodyValues = refreshParams?.filter(p => p?.sendIn == 'body'); if (refreshBodyValues?.length) { - bru += `auth:oauth2:refresh_bodyvalues { + bru += `auth:oauth2:additional_params:refresh_token_req:body { ${indentString( refreshBodyValues .filter(item => item?.name?.length) diff --git a/packages/bruno-lang/v2/src/jsonToCollectionBru.js b/packages/bruno-lang/v2/src/jsonToCollectionBru.js index 1af07313b..d5aa1c1e0 100644 --- a/packages/bruno-lang/v2/src/jsonToCollectionBru.js +++ b/packages/bruno-lang/v2/src/jsonToCollectionBru.js @@ -239,7 +239,7 @@ ${indentString(`auto_refresh_token: ${(auth?.oauth2?.autoRefreshToken ?? false). const { authorization: authorizationParams, token: tokenParams, refresh: refreshParams } = auth?.oauth2?.additionalParameters; const authorizationHeaders = authorizationParams?.filter(p => p?.sendIn == 'headers'); if (authorizationHeaders?.length) { - bru += `auth:oauth2:authorization_headers { + bru += `auth:oauth2:additional_params:auth_req:headers { ${indentString( authorizationHeaders .filter(item => item?.name?.length) @@ -252,7 +252,7 @@ ${indentString( } const authorizationQueryParams = authorizationParams?.filter(p => p?.sendIn == 'queryparams'); if (authorizationQueryParams?.length) { - bru += `auth:oauth2:authorization_queryparams { + bru += `auth:oauth2:additional_params:auth_req:queryparams { ${indentString( authorizationQueryParams .filter(item => item?.name?.length) @@ -265,7 +265,7 @@ ${indentString( } const tokenHeaders = tokenParams?.filter(p => p?.sendIn == 'headers'); if (tokenHeaders?.length) { - bru += `auth:oauth2:token_headers { + bru += `auth:oauth2:additional_params:access_token_req:headers { ${indentString( tokenHeaders .filter(item => item?.name?.length) @@ -278,7 +278,7 @@ ${indentString( } const tokenQueryParams = tokenParams?.filter(p => p?.sendIn == 'queryparams'); if (tokenQueryParams?.length) { - bru += `auth:oauth2:token_queryparams { + bru += `auth:oauth2:additional_params:access_token_req:queryparams { ${indentString( tokenQueryParams .filter(item => item?.name?.length) @@ -291,7 +291,7 @@ ${indentString( } const tokenBodyValues = tokenParams?.filter(p => p?.sendIn == 'body'); if (tokenBodyValues?.length) { - bru += `auth:oauth2:token_bodyvalues { + bru += `auth:oauth2:additional_params:access_token_req:body { ${indentString( tokenBodyValues .filter(item => item?.name?.length) @@ -304,7 +304,7 @@ ${indentString( } const refreshHeaders = refreshParams?.filter(p => p?.sendIn == 'headers'); if (refreshHeaders?.length) { - bru += `auth:oauth2:refresh_headers { + bru += `auth:oauth2:additional_params:refresh_token_req:headers { ${indentString( refreshHeaders .filter(item => item?.name?.length) @@ -317,7 +317,7 @@ ${indentString( } const refreshQueryParams = refreshParams?.filter(p => p?.sendIn == 'queryparams'); if (refreshQueryParams?.length) { - bru += `auth:oauth2:refresh_queryparams { + bru += `auth:oauth2:additional_params:refresh_token_req:queryparams { ${indentString( refreshQueryParams .filter(item => item?.name?.length) @@ -330,7 +330,7 @@ ${indentString( } const refreshBodyValues = refreshParams?.filter(p => p?.sendIn == 'body'); if (refreshBodyValues?.length) { - bru += `auth:oauth2:refresh_bodyvalues { + bru += `auth:oauth2:additional_params:refresh_token_req:body { ${indentString( refreshBodyValues .filter(item => item?.name?.length) diff --git a/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js b/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js index 674582114..c412b64cf 100644 --- a/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js +++ b/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js @@ -21,42 +21,42 @@ auth:oauth2 { access_token_url: https://auth.usebruno.com/oauth/token } -auth:oauth2:authorization_headers { +auth:oauth2:additional_params:auth_req:headers { auth-header: auth-header-value ~disabled-auth-header: disabled-auth-header-value } -auth:oauth2:authorization_queryparams { +auth:oauth2:additional_params:auth_req:queryparams { auth-query-param: auth-query-param-value ~disabled-auth-query-param: disabled-auth-query-param-value } -auth:oauth2:token_headers { +auth:oauth2:additional_params:access_token_req:headers { token-header: token-header-value ~disabled-token-header: disabled-token-header-value } -auth:oauth2:token_queryparams { +auth:oauth2:additional_params:access_token_req:queryparams { token-query-param: token-query-param-value ~disabled-token-query-param: disabled-token-query-param-value } -auth:oauth2:token_bodyvalues { +auth:oauth2:additional_params:access_token_req:body { token-body: token-body-value ~disabled-token-body: disabled-token-body-value } -auth:oauth2:refresh_headers { +auth:oauth2:additional_params:refresh_token_req:headers { refresh-header: refresh-header-value ~disabled-refresh-header: disabled-refresh-header-value } -auth:oauth2:refresh_queryparams { +auth:oauth2:additional_params:refresh_token_req:queryparams { refresh-query-param: refresh-query-param-value ~disabled-refresh-query-param: disabled-refresh-query-param-value } -auth:oauth2:refresh_bodyvalues { +auth:oauth2:additional_params:refresh_token_req:body { refresh-body: refresh-body-value ~disabled-refresh-body: disabled-refresh-body-value } @@ -182,42 +182,42 @@ auth:oauth2 { access_token_url: https://auth.usebruno.com/oauth/token } -auth:oauth2:authorization_headers { +auth:oauth2:additional_params:auth_req:headers { auth-header: auth-header-value ~disabled-auth-header: disabled-auth-header-value } -auth:oauth2:authorization_queryparams { +auth:oauth2:additional_params:auth_req:queryparams { auth-query-param: auth-query-param-value ~disabled-auth-query-param: disabled-auth-query-param-value } -auth:oauth2:token_headers { +auth:oauth2:additional_params:access_token_req:headers { token-header: token-header-value ~disabled-token-header: disabled-token-header-value } -auth:oauth2:token_queryparams { +auth:oauth2:additional_params:access_token_req:queryparams { token-query-param: token-query-param-value ~disabled-token-query-param: disabled-token-query-param-value } -auth:oauth2:token_bodyvalues { +auth:oauth2:additional_params:access_token_req:body { token-body: token-body-value ~disabled-token-body: disabled-token-body-value } -auth:oauth2:refresh_headers { +auth:oauth2:additional_params:refresh_token_req:headers { refresh-header: refresh-header-value ~disabled-refresh-header: disabled-refresh-header-value } -auth:oauth2:refresh_queryparams { +auth:oauth2:additional_params:refresh_token_req:queryparams { refresh-query-param: refresh-query-param-value ~disabled-refresh-query-param: disabled-refresh-query-param-value } -auth:oauth2:refresh_bodyvalues { +auth:oauth2:additional_params:refresh_token_req:body { refresh-body: refresh-body-value ~disabled-refresh-body: disabled-refresh-body-value } From 8dde2701f42421fa7f965fd4832f28479cfd826f Mon Sep 17 00:00:00 2001 From: lohit-bruno Date: Wed, 20 Aug 2025 16:32:52 +0530 Subject: [PATCH 2/4] ui updates --- .../OAuth2/AdditionalParams/StyledWrapper.js | 21 ++++++++++++++++++ .../Auth/OAuth2/AdditionalParams/index.js | 22 +++++-------------- .../Auth/OAuth2/AuthorizationCode/index.js | 11 +++++----- .../Auth/OAuth2/ClientCredentials/index.js | 11 +++++----- .../RequestPane/Auth/OAuth2/Implicit/index.js | 11 +++++----- .../Auth/OAuth2/PasswordCredentials/index.js | 11 +++++----- 6 files changed, 50 insertions(+), 37 deletions(-) diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/StyledWrapper.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/StyledWrapper.js index cc8980abe..712367fd7 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/StyledWrapper.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/StyledWrapper.js @@ -19,6 +19,27 @@ const StyledWrapper = styled.div` } } } + + table { + width: 100%; + border-collapse: collapse; + font-weight: 600; + table-layout: fixed; + + thead, + td { + border: 1px solid ${(props) => props.theme.table.border}; + } + + thead { + color: ${(props) => props.theme.table.thead.color}; + font-size: 0.8125rem; + user-select: none; + } + td { + padding: 6px 10px; + } + } .additional-parameter-sends-in-selector { select { diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js index 0069c5203..4b56142e3 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js @@ -1,14 +1,14 @@ import { useDispatch } from "react-redux"; -import React, { forwardRef, useState } from 'react'; +import React, { useState } from 'react'; import get from 'lodash/get'; import { useTheme } from 'providers/Theme'; -import { IconPlus, IconCaretDown, IconTrash, IconAdjustmentsHorizontal } from '@tabler/icons'; +import { IconPlus, IconTrash, IconAdjustmentsHorizontal } from '@tabler/icons'; import { cloneDeep } from "lodash"; import SingleLineEditor from "components/SingleLineEditor/index"; import StyledWrapper from "./StyledWrapper"; import Table from "components/Table/index"; -const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => { +const AdditionalParams = ({ item = {}, request, updateAuth, collection, handleSave }) => { const dispatch = useDispatch(); const { storedTheme } = useTheme(); @@ -201,6 +201,7 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => { value })} collection={collection} + onSave={handleSave} /> @@ -214,6 +215,7 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => { value })} collection={collection} + onSave={handleSave} /> @@ -284,20 +286,6 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => { export default AdditionalParams; -const Icon = forwardRef((props, ref) => { - const { value } = props - return ( -
-
- {value} -
-
- -
-
- ); -}); - const sendInOptionsMap = { 'authorization_code': { 'authorization': ['headers', 'queryparams'], diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AuthorizationCode/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AuthorizationCode/index.js index 207b3510b..7c890513e 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AuthorizationCode/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AuthorizationCode/index.js @@ -336,11 +336,12 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu - diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js index 3ad22ae28..253adeac0 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js @@ -293,11 +293,12 @@ const OAuth2ClientCredentials = ({ save, item = {}, request, handleRun, updateAu - diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/Implicit/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/Implicit/index.js index 5b0b44ec4..9715aa3ce 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/Implicit/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/Implicit/index.js @@ -218,11 +218,12 @@ const OAuth2Implicit = ({ save, item = {}, request, handleRun, updateAuth, colle - diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js index 43bb35cbd..f048183e6 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js @@ -296,11 +296,12 @@ const OAuth2PasswordCredentials = ({ save, item = {}, request, handleRun, update - From ef12401d2e21c23f21996bc5712e5477bbf02f41 Mon Sep 17 00:00:00 2001 From: lohit-bruno Date: Wed, 20 Aug 2025 16:34:03 +0530 Subject: [PATCH 3/4] fetch/refresh token - collection/request variables usage fix --- .../providers/ReduxStore/slices/collections/actions.js | 2 +- packages/bruno-electron/src/ipc/collection.js | 10 ++++++---- packages/bruno-electron/src/utils/collection.js | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index 7e3a758d3..60d8cfe96 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -1324,7 +1324,7 @@ export const refreshOauth2Credentials = (payload) => async (dispatch, getState) request.globalEnvironmentVariables = globalEnvironmentVariables; return new Promise((resolve, reject) => { window.ipcRenderer - .invoke('renderer:refresh-oauth2-credentials', { request, collection }) + .invoke('renderer:refresh-oauth2-credentials', { itemUid, request, collection }) .then(({ credentials, url, collectionUid, debugInfo, credentialsId }) => { dispatch( collectionAddOauth2CredentialsByUrl({ diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index 0d51b2f92..30d0e6f84 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -985,9 +985,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection const processEnvVars = getProcessEnvVars(collectionUid); const partialItem = { uid: itemUid }; const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem); - if (requestTreePath && requestTreePath.length > 0) { - mergeVars(collection, requestCopy, requestTreePath); - } + mergeVars(collection, requestCopy, requestTreePath); interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars); const certsAndProxyConfig = await getCertsAndProxyConfig({ @@ -1108,7 +1106,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection } }); - ipcMain.handle('renderer:refresh-oauth2-credentials', async (event, { request, collection }) => { + ipcMain.handle('renderer:refresh-oauth2-credentials', async (event, { itemUid, request, collection }) => { try { if (request.oauth2) { let requestCopy = _.cloneDeep(request); @@ -1116,7 +1114,11 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection const environment = _.find(environments, (e) => e.uid === activeEnvironmentUid); const envVars = getEnvVars(environment); const processEnvVars = getProcessEnvVars(collectionUid); + const partialItem = { uid: itemUid }; + const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem); + mergeVars(collection, requestCopy, requestTreePath); interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars); + const certsAndProxyConfig = await getCertsAndProxyConfig({ collectionUid, request: requestCopy, diff --git a/packages/bruno-electron/src/utils/collection.js b/packages/bruno-electron/src/utils/collection.js index b502fe4a5..6eb0a7ccc 100644 --- a/packages/bruno-electron/src/utils/collection.js +++ b/packages/bruno-electron/src/utils/collection.js @@ -47,7 +47,7 @@ const mergeHeaders = (collection, request, requestTreePath) => { request.headers = Array.from(headers, ([name, value]) => ({ name, value, enabled: true })); }; -const mergeVars = (collection, request, requestTreePath) => { +const mergeVars = (collection, request, requestTreePath = []) => { let reqVars = new Map(); let collectionRequestVars = get(collection, 'root.request.vars.req', []); let collectionVariables = {}; From 311a2329680f014d4549cdb66bb11ad53c5b3879 Mon Sep 17 00:00:00 2001 From: lohit-bruno Date: Wed, 20 Aug 2025 16:57:07 +0530 Subject: [PATCH 4/4] updates --- .../Auth/OAuth2/AdditionalParams/index.js | 2 +- .../fixtures/oauth2-additional-params.js | 16 ++-- .../bru/utils/oauth2-additional-params.ts | 32 +++---- packages/bruno-lang/v2/src/bruToJson.js | 16 ++-- .../bruno-lang/v2/src/collectionBruToJson.js | 16 ++-- packages/bruno-lang/v2/src/utils.js | 80 +--------------- .../v2/tests/oauth2-additional-params.spec.js | 96 +++++++++---------- 7 files changed, 90 insertions(+), 168 deletions(-) diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js index 4b56142e3..1d2f81bee 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/AdditionalParams/index.js @@ -274,7 +274,7 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection, handleS
diff --git a/packages/bruno-filestore/src/formats/bru/tests/fixtures/oauth2-additional-params.js b/packages/bruno-filestore/src/formats/bru/tests/fixtures/oauth2-additional-params.js index 0fe31f485..c3498340c 100644 --- a/packages/bruno-filestore/src/formats/bru/tests/fixtures/oauth2-additional-params.js +++ b/packages/bruno-filestore/src/formats/bru/tests/fixtures/oauth2-additional-params.js @@ -13,7 +13,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "grantType": grantType, }, }, - "oauth2_additional_parameters_authorization_headers": [ + "oauth2_additional_parameters_auth_req_headers": [ { "name": "auth-header", "value": "auth-header-value", @@ -25,7 +25,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_authorization_queryparams": [ + "oauth2_additional_parameters_auth_req_queryparams": [ { "name": "auth-query-param", "value": "auth-query-param-value", @@ -37,7 +37,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_token_headers": [ + "oauth2_additional_parameters_access_token_req_headers": [ { "name": "token-header", "value": "token-header-value", @@ -49,7 +49,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_token_queryparams": [ + "oauth2_additional_parameters_access_token_req_queryparams": [ { "name": "token-query-param", "value": "token-query-param-value", @@ -61,7 +61,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_token_bodyvalues": [ + "oauth2_additional_parameters_access_token_req_bodyvalues": [ { "name": "token-body", "value": "token-body-value", @@ -73,7 +73,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_refresh_headers": [ + "oauth2_additional_parameters_refresh_token_req_headers": [ { "name": "refresh-header", "value": "refresh-header-value", @@ -85,7 +85,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_refresh_queryparams": [ + "oauth2_additional_parameters_refresh_token_req_queryparams": [ { "name": "refresh-query-param", "value": "refresh-query-param-value", @@ -97,7 +97,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({ "enabled": false } ], - "oauth2_additional_parameters_refresh_bodyvalues": [ + "oauth2_additional_parameters_refresh_token_req_bodyvalues": [ { "name": "refresh-body", "value": "refresh-body-value", diff --git a/packages/bruno-filestore/src/formats/bru/utils/oauth2-additional-params.ts b/packages/bruno-filestore/src/formats/bru/utils/oauth2-additional-params.ts index 6bf57cefa..54a613807 100644 --- a/packages/bruno-filestore/src/formats/bru/utils/oauth2-additional-params.ts +++ b/packages/bruno-filestore/src/formats/bru/utils/oauth2-additional-params.ts @@ -23,14 +23,14 @@ export interface T_BruJson { auth: { oauth2: T_Oauth2Auth; }; - oauth2_additional_parameters_authorization_headers?: any[]; - oauth2_additional_parameters_authorization_queryparams?: any[]; - oauth2_additional_parameters_token_headers?: any[]; - oauth2_additional_parameters_token_queryparams?: any[]; - oauth2_additional_parameters_token_bodyvalues?: any[]; - oauth2_additional_parameters_refresh_headers?: any[]; - oauth2_additional_parameters_refresh_queryparams?: any[]; - oauth2_additional_parameters_refresh_bodyvalues?: any[]; + oauth2_additional_parameters_auth_req_headers?: any[]; + oauth2_additional_parameters_auth_req_queryparams?: any[]; + oauth2_additional_parameters_access_token_req_headers?: any[]; + oauth2_additional_parameters_access_token_req_queryparams?: any[]; + oauth2_additional_parameters_access_token_req_bodyvalues?: any[]; + oauth2_additional_parameters_refresh_token_req_headers?: any[]; + oauth2_additional_parameters_refresh_token_req_queryparams?: any[]; + oauth2_additional_parameters_refresh_token_req_bodyvalues?: any[]; } interface T_Oauth2ParameterMapping { @@ -41,18 +41,18 @@ interface T_Oauth2ParameterMapping { const PARAMETER_MAPPINGS: T_Oauth2ParameterMapping[] = [ // Authorization parameters (only for authorization_code grant type) - { type: 'authorization', sendIn: 'headers', source: 'oauth2_additional_parameters_authorization_headers' }, - { type: 'authorization', sendIn: 'queryparams', source: 'oauth2_additional_parameters_authorization_queryparams' }, + { type: 'authorization', sendIn: 'headers', source: 'oauth2_additional_parameters_auth_req_headers' }, + { type: 'authorization', sendIn: 'queryparams', source: 'oauth2_additional_parameters_auth_req_queryparams' }, // Token parameters (for all grant types) - { type: 'token', sendIn: 'headers', source: 'oauth2_additional_parameters_token_headers' }, - { type: 'token', sendIn: 'queryparams', source: 'oauth2_additional_parameters_token_queryparams' }, - { type: 'token', sendIn: 'body', source: 'oauth2_additional_parameters_token_bodyvalues' }, + { type: 'token', sendIn: 'headers', source: 'oauth2_additional_parameters_access_token_req_headers' }, + { type: 'token', sendIn: 'queryparams', source: 'oauth2_additional_parameters_access_token_req_queryparams' }, + { type: 'token', sendIn: 'body', source: 'oauth2_additional_parameters_access_token_req_bodyvalues' }, // Refresh parameters (for grant types that support refresh) - { type: 'refresh', sendIn: 'headers', source: 'oauth2_additional_parameters_refresh_headers' }, - { type: 'refresh', sendIn: 'queryparams', source: 'oauth2_additional_parameters_refresh_queryparams' }, - { type: 'refresh', sendIn: 'body', source: 'oauth2_additional_parameters_refresh_bodyvalues' }, + { type: 'refresh', sendIn: 'headers', source: 'oauth2_additional_parameters_refresh_token_req_headers' }, + { type: 'refresh', sendIn: 'queryparams', source: 'oauth2_additional_parameters_refresh_token_req_queryparams' }, + { type: 'refresh', sendIn: 'body', source: 'oauth2_additional_parameters_refresh_token_req_bodyvalues' }, ]; /** diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 766835061..134fc9aa7 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -657,42 +657,42 @@ const sem = grammar.createSemantics().addAttribute('ast', { }, oauth2AuthReqHeaders(_1, dictionary) { return { - oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_auth_req_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AuthReqQueryParams(_1, dictionary) { return { - oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_auth_req_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AccessTokenReqHeaders(_1, dictionary) { return { - oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_access_token_req_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AccessTokenReqQueryParams(_1, dictionary) { return { - oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_access_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AccessTokenReqBody(_1, dictionary) { return { - oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_access_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2RefreshTokenReqHeaders(_1, dictionary) { return { - oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_refresh_token_req_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2RefreshTokenReqQueryParams(_1, dictionary) { return { - oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_refresh_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2RefreshTokenReqBody(_1, dictionary) { return { - oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_refresh_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; }, authwsse(_1, dictionary) { diff --git a/packages/bruno-lang/v2/src/collectionBruToJson.js b/packages/bruno-lang/v2/src/collectionBruToJson.js index 0c698e6ce..f3925ad62 100644 --- a/packages/bruno-lang/v2/src/collectionBruToJson.js +++ b/packages/bruno-lang/v2/src/collectionBruToJson.js @@ -379,42 +379,42 @@ const sem = grammar.createSemantics().addAttribute('ast', { }, oauth2AuthReqHeaders(_1, dictionary) { return { - oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_auth_req_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AuthReqQueryParams(_1, dictionary) { return { - oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_auth_req_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AccessTokenReqHeaders(_1, dictionary) { return { - oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_access_token_req_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AccessTokenReqQueryParams(_1, dictionary) { return { - oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_access_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2AccessTokenReqBody(_1, dictionary) { return { - oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_access_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2RefreshTokenReqHeaders(_1, dictionary) { return { - oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_refresh_token_req_headers: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2RefreshTokenReqQueryParams(_1, dictionary) { return { - oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_refresh_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast) }; }, oauth2RefreshTokenReqBody(_1, dictionary) { return { - oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) + oauth2_additional_parameters_refresh_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast) }; }, authwsse(_1, dictionary) { diff --git a/packages/bruno-lang/v2/src/utils.js b/packages/bruno-lang/v2/src/utils.js index aaef783c4..74b22c952 100644 --- a/packages/bruno-lang/v2/src/utils.js +++ b/packages/bruno-lang/v2/src/utils.js @@ -29,86 +29,8 @@ const outdentString = (str) => { .join('\n'); }; -const mergeOauth2AdditionalParameters = (ast) => { - let additionalParameters = {}; - const authorizationHeaders = ast?.oauth2_additional_parameters_authorization_headers; - const authorizationQueryParams = ast?.oauth2_additional_parameters_authorization_queryparams; - const tokenHeaders = ast?.oauth2_additional_parameters_token_headers; - const tokenQueryParams = ast?.oauth2_additional_parameters_token_queryparams; - const tokenBodyValues = ast?.oauth2_additional_parameters_token_bodyvalues; - const refreshHeaders = ast?.oauth2_additional_parameters_refresh_headers; - const refreshQueryParams = ast?.oauth2_additional_parameters_refresh_queryparams; - const refreshBodyValues = ast?.oauth2_additional_parameters_refresh_bodyvalues; - - if (ast?.auth?.oauth2?.grantType == 'authorization_code') { - if (authorizationHeaders?.length || authorizationQueryParams?.length) { - additionalParameters['authorization'] = [] - } - if (authorizationHeaders?.length) { - additionalParameters['authorization'] = [ - ...authorizationHeaders?.map(_ => ({ ..._, sendIn: 'headers' })) - ] - } - if (authorizationQueryParams?.length) { - additionalParameters['authorization'] = [ - ...additionalParameters['authorization'] || [], - ...authorizationQueryParams?.map(_ => ({ ..._, sendIn: 'queryparams' })) - ] - } - } - - if (tokenHeaders?.length || tokenQueryParams?.length || tokenBodyValues?.length) { - additionalParameters['token'] = [] - } - if (tokenHeaders?.length) { - additionalParameters['token'] = [ - ...tokenHeaders?.map(_ => ({ ..._, sendIn: 'headers' })) - ] - } - if (tokenQueryParams?.length) { - additionalParameters['token'] = [ - ...additionalParameters['token'] || [], - ...tokenQueryParams?.map(_ => ({ ..._, sendIn: 'queryparams' })) - ] - } - if (tokenBodyValues?.length) { - additionalParameters['token'] = [ - ...additionalParameters['token'] || [], - ...tokenBodyValues?.map(_ => ({ ..._, sendIn: 'body' })) - ] - } - - if (refreshHeaders?.length || refreshQueryParams?.length || refreshBodyValues?.length) { - additionalParameters['refresh'] = [] - } - if (refreshHeaders?.length) { - additionalParameters['refresh'] = [ - ...refreshHeaders?.map(_ => ({ ..._, sendIn: 'headers' })) - ] - } - if (refreshQueryParams?.length) { - additionalParameters['refresh'] = [ - ...additionalParameters['refresh'] || [], - ...refreshQueryParams?.map(_ => ({ ..._, sendIn: 'queryparams' })) - ] - } - if (refreshBodyValues?.length) { - additionalParameters['refresh'] = [ - ...additionalParameters['refresh'] || [], - ...refreshBodyValues?.map(_ => ({ ..._, sendIn: 'body' })) - ] - } - - if(ast?.auth?.oauth2 && Object.keys(additionalParameters)?.length) { - ast.auth.oauth2.additionalParameters = additionalParameters; - } - - return ast; -} - module.exports = { safeParseJson, indentString, - outdentString, - mergeOauth2AdditionalParameters + outdentString }; diff --git a/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js b/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js index c412b64cf..c38ea7ef0 100644 --- a/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js +++ b/packages/bruno-lang/v2/tests/oauth2-additional-params.spec.js @@ -65,27 +65,27 @@ auth:oauth2:additional_params:refresh_token_req:body { const result = bruToJson(input); // Verify all config types are present - expect(result).toHaveProperty('oauth2_additional_parameters_authorization_headers'); - expect(result).toHaveProperty('oauth2_additional_parameters_authorization_queryparams'); - expect(result).toHaveProperty('oauth2_additional_parameters_token_headers'); - expect(result).toHaveProperty('oauth2_additional_parameters_token_queryparams'); - expect(result).toHaveProperty('oauth2_additional_parameters_token_bodyvalues'); - expect(result).toHaveProperty('oauth2_additional_parameters_refresh_headers'); - expect(result).toHaveProperty('oauth2_additional_parameters_refresh_queryparams'); - expect(result).toHaveProperty('oauth2_additional_parameters_refresh_bodyvalues'); + expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_headers'); + expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_queryparams'); + expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_headers'); + expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_queryparams'); + expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_bodyvalues'); + expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_headers'); + expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_queryparams'); + expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_bodyvalues'); // Verify each has exactly one parameter - expect(result.oauth2_additional_parameters_authorization_headers).toHaveLength(2); - expect(result.oauth2_additional_parameters_authorization_queryparams).toHaveLength(2); - expect(result.oauth2_additional_parameters_token_headers).toHaveLength(2); - expect(result.oauth2_additional_parameters_token_queryparams).toHaveLength(2); - expect(result.oauth2_additional_parameters_token_bodyvalues).toHaveLength(2); - expect(result.oauth2_additional_parameters_refresh_headers).toHaveLength(2); - expect(result.oauth2_additional_parameters_refresh_queryparams).toHaveLength(2); - expect(result.oauth2_additional_parameters_refresh_bodyvalues).toHaveLength(2); + expect(result.oauth2_additional_parameters_auth_req_headers).toHaveLength(2); + expect(result.oauth2_additional_parameters_auth_req_queryparams).toHaveLength(2); + expect(result.oauth2_additional_parameters_access_token_req_headers).toHaveLength(2); + expect(result.oauth2_additional_parameters_access_token_req_queryparams).toHaveLength(2); + expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toHaveLength(2); + expect(result.oauth2_additional_parameters_refresh_token_req_headers).toHaveLength(2); + expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toHaveLength(2); + expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toHaveLength(2); // Verify parameter values - expect(result.oauth2_additional_parameters_authorization_headers).toEqual([{ + expect(result.oauth2_additional_parameters_auth_req_headers).toEqual([{ name: 'auth-header', value: 'auth-header-value', enabled: true @@ -95,7 +95,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_authorization_queryparams).toEqual([{ + expect(result.oauth2_additional_parameters_auth_req_queryparams).toEqual([{ name: 'auth-query-param', value: 'auth-query-param-value', enabled: true @@ -105,7 +105,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_token_headers).toEqual([{ + expect(result.oauth2_additional_parameters_access_token_req_headers).toEqual([{ name: 'token-header', value: 'token-header-value', enabled: true @@ -115,7 +115,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_token_queryparams).toEqual([{ + expect(result.oauth2_additional_parameters_access_token_req_queryparams).toEqual([{ name: 'token-query-param', value: 'token-query-param-value', enabled: true @@ -125,7 +125,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_token_bodyvalues).toEqual([{ + expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toEqual([{ name: 'token-body', value: 'token-body-value', enabled: true @@ -135,7 +135,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_refresh_headers).toEqual([{ + expect(result.oauth2_additional_parameters_refresh_token_req_headers).toEqual([{ name: 'refresh-header', value: 'refresh-header-value', enabled: true @@ -145,7 +145,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_refresh_queryparams).toEqual([{ + expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toEqual([{ name: 'refresh-query-param', value: 'refresh-query-param-value', enabled: true @@ -155,7 +155,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_refresh_bodyvalues).toEqual([{ + expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toEqual([{ name: 'refresh-body', value: 'refresh-body-value', enabled: true @@ -226,27 +226,27 @@ auth:oauth2:additional_params:refresh_token_req:body { const result = collectionBruToJson(input); // Verify all config types are present - expect(result).toHaveProperty('oauth2_additional_parameters_authorization_headers'); - expect(result).toHaveProperty('oauth2_additional_parameters_authorization_queryparams'); - expect(result).toHaveProperty('oauth2_additional_parameters_token_headers'); - expect(result).toHaveProperty('oauth2_additional_parameters_token_queryparams'); - expect(result).toHaveProperty('oauth2_additional_parameters_token_bodyvalues'); - expect(result).toHaveProperty('oauth2_additional_parameters_refresh_headers'); - expect(result).toHaveProperty('oauth2_additional_parameters_refresh_queryparams'); - expect(result).toHaveProperty('oauth2_additional_parameters_refresh_bodyvalues'); + expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_headers'); + expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_queryparams'); + expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_headers'); + expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_queryparams'); + expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_bodyvalues'); + expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_headers'); + expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_queryparams'); + expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_bodyvalues'); // Verify each has exactly one parameter - expect(result.oauth2_additional_parameters_authorization_headers).toHaveLength(2); - expect(result.oauth2_additional_parameters_authorization_queryparams).toHaveLength(2); - expect(result.oauth2_additional_parameters_token_headers).toHaveLength(2); - expect(result.oauth2_additional_parameters_token_queryparams).toHaveLength(2); - expect(result.oauth2_additional_parameters_token_bodyvalues).toHaveLength(2); - expect(result.oauth2_additional_parameters_refresh_headers).toHaveLength(2); - expect(result.oauth2_additional_parameters_refresh_queryparams).toHaveLength(2); - expect(result.oauth2_additional_parameters_refresh_bodyvalues).toHaveLength(2); + expect(result.oauth2_additional_parameters_auth_req_headers).toHaveLength(2); + expect(result.oauth2_additional_parameters_auth_req_queryparams).toHaveLength(2); + expect(result.oauth2_additional_parameters_access_token_req_headers).toHaveLength(2); + expect(result.oauth2_additional_parameters_access_token_req_queryparams).toHaveLength(2); + expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toHaveLength(2); + expect(result.oauth2_additional_parameters_refresh_token_req_headers).toHaveLength(2); + expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toHaveLength(2); + expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toHaveLength(2); // Verify parameter values - expect(result.oauth2_additional_parameters_authorization_headers).toEqual([{ + expect(result.oauth2_additional_parameters_auth_req_headers).toEqual([{ name: 'auth-header', value: 'auth-header-value', enabled: true @@ -256,7 +256,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_authorization_queryparams).toEqual([{ + expect(result.oauth2_additional_parameters_auth_req_queryparams).toEqual([{ name: 'auth-query-param', value: 'auth-query-param-value', enabled: true @@ -266,7 +266,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_token_headers).toEqual([{ + expect(result.oauth2_additional_parameters_access_token_req_headers).toEqual([{ name: 'token-header', value: 'token-header-value', enabled: true @@ -276,7 +276,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_token_queryparams).toEqual([{ + expect(result.oauth2_additional_parameters_access_token_req_queryparams).toEqual([{ name: 'token-query-param', value: 'token-query-param-value', enabled: true @@ -286,7 +286,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_token_bodyvalues).toEqual([{ + expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toEqual([{ name: 'token-body', value: 'token-body-value', enabled: true @@ -296,7 +296,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_refresh_headers).toEqual([{ + expect(result.oauth2_additional_parameters_refresh_token_req_headers).toEqual([{ name: 'refresh-header', value: 'refresh-header-value', enabled: true @@ -306,7 +306,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_refresh_queryparams).toEqual([{ + expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toEqual([{ name: 'refresh-query-param', value: 'refresh-query-param-value', enabled: true @@ -316,7 +316,7 @@ auth:oauth2:additional_params:refresh_token_req:body { enabled: false }]); - expect(result.oauth2_additional_parameters_refresh_bodyvalues).toEqual([{ + expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toEqual([{ name: 'refresh-body', value: 'refresh-body-value', enabled: true