} placement="bottom-end">
props.theme.input.border};
diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/StyledWrapper.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/StyledWrapper.js
index e4d6a7d6c..856f35b9b 100644
--- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/StyledWrapper.js
+++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/StyledWrapper.js
@@ -5,6 +5,7 @@ const Wrapper = styled.div`
font-size: 0.8125rem;
}
.single-line-editor-wrapper {
+ max-width: 400px;
padding: 0.15rem 0.4rem;
border-radius: 3px;
border: solid 1px ${(props) => props.theme.input.border};
diff --git a/packages/bruno-lang/v1/src/utils.js b/packages/bruno-lang/v1/src/utils.js
index ef9307c8b..74b22c952 100644
--- a/packages/bruno-lang/v1/src/utils.js
+++ b/packages/bruno-lang/v1/src/utils.js
@@ -9,7 +9,7 @@ const safeParseJson = (json) => {
const indentString = (str) => {
if (!str || !str.length) {
- return str;
+ return str || '';
}
return str
@@ -20,7 +20,7 @@ const indentString = (str) => {
const outdentString = (str) => {
if (!str || !str.length) {
- return str;
+ return str || '';
}
return str
diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js
index 17b551449..bd0eec919 100644
--- a/packages/bruno-lang/v2/src/jsonToBru.js
+++ b/packages/bruno-lang/v2/src/jsonToBru.js
@@ -89,12 +89,12 @@ const jsonToBru = (json) => {
if (auth && auth.awsv4) {
bru += `auth:awsv4 {
-${indentString(`accessKeyId: ${auth.awsv4.accessKeyId}`)}
-${indentString(`secretAccessKey: ${auth.awsv4.secretAccessKey}`)}
-${indentString(`sessionToken: ${auth.awsv4.sessionToken}`)}
-${indentString(`service: ${auth.awsv4.service}`)}
-${indentString(`region: ${auth.awsv4.region}`)}
-${indentString(`profileName: ${auth.awsv4.profileName}`)}
+${indentString(`accessKeyId: ${auth?.awsv4?.accessKeyId || ''}`)}
+${indentString(`secretAccessKey: ${auth?.awsv4?.secretAccessKey || ''}`)}
+${indentString(`sessionToken: ${auth?.awsv4?.sessionToken || ''}`)}
+${indentString(`service: ${auth?.awsv4?.service || ''}`)}
+${indentString(`region: ${auth?.awsv4?.region || ''}`)}
+${indentString(`profileName: ${auth?.awsv4?.profileName || ''}`)}
}
`;
@@ -102,8 +102,8 @@ ${indentString(`profileName: ${auth.awsv4.profileName}`)}
if (auth && auth.basic) {
bru += `auth:basic {
-${indentString(`username: ${auth.basic.username}`)}
-${indentString(`password: ${auth.basic.password}`)}
+${indentString(`username: ${auth?.basic?.username || ''}`)}
+${indentString(`password: ${auth?.basic?.password || ''}`)}
}
`;
@@ -111,7 +111,7 @@ ${indentString(`password: ${auth.basic.password}`)}
if (auth && auth.bearer) {
bru += `auth:bearer {
-${indentString(`token: ${auth.bearer.token}`)}
+${indentString(`token: ${auth?.bearer?.token || ''}`)}
}
`;
@@ -119,8 +119,8 @@ ${indentString(`token: ${auth.bearer.token}`)}
if (auth && auth.digest) {
bru += `auth:digest {
-${indentString(`username: ${auth.digest.username}`)}
-${indentString(`password: ${auth.digest.password}`)}
+${indentString(`username: ${auth?.digest?.username || ''}`)}
+${indentString(`password: ${auth?.digest?.password || ''}`)}
}
`;
@@ -131,8 +131,8 @@ ${indentString(`password: ${auth.digest.password}`)}
case 'password':
bru += `auth:oauth2 {
${indentString(`grant_type: password`)}
-${indentString(`username: ${auth.oauth2.username}`)}
-${indentString(`password: ${auth.oauth2.password}`)}
+${indentString(`username: ${auth?.oauth2?.username || ''}`)}
+${indentString(`password: ${auth?.oauth2?.password || ''}`)}
}
`;
@@ -140,12 +140,12 @@ ${indentString(`password: ${auth.oauth2.password}`)}
case 'authorization_code':
bru += `auth:oauth2 {
${indentString(`grant_type: authorization_code`)}
-${indentString(`callback_url: ${auth.oauth2.callbackUrl}`)}
-${indentString(`authorization_url: ${auth.oauth2.authorizationUrl}`)}
-${indentString(`access_token_url: ${auth.oauth2.accessTokenUrl}`)}
-${indentString(`client_id: ${auth.oauth2.clientId}`)}
-${indentString(`client_secret: ${auth.oauth2.clientSecret}`)}
-${indentString(`scope: ${auth.oauth2.scope}`)}
+${indentString(`callback_url: ${auth?.oauth2?.callbackUrl || ''}`)}
+${indentString(`authorization_url: ${auth?.oauth2?.authorizationUrl || ''}`)}
+${indentString(`access_token_url: ${auth?.oauth2?.accessTokenUrl || ''}`)}
+${indentString(`client_id: ${auth?.oauth2?.clientId || ''}`)}
+${indentString(`client_secret: ${auth?.oauth2?.clientSecret || ''}`)}
+${indentString(`scope: ${auth?.oauth2?.scope || ''}`)}
}
`;
@@ -153,8 +153,8 @@ ${indentString(`scope: ${auth.oauth2.scope}`)}
case 'client_credentials':
bru += `auth:oauth2 {
${indentString(`grant_type: client_credentials`)}
-${indentString(`client_id: ${auth.oauth2.clientId}`)}
-${indentString(`client_secret: ${auth.oauth2.clientSecret}`)}
+${indentString(`client_id: ${auth?.oauth2?.clientId || ''}`)}
+${indentString(`client_secret: ${auth?.oauth2?.clientSecret || ''}`)}
}
`;
@@ -368,3 +368,5 @@ ${indentString(docs)}
};
module.exports = jsonToBru;
+
+// alternative to writing the below code to avoif undefined
diff --git a/packages/bruno-schema/src/collections/index.js b/packages/bruno-schema/src/collections/index.js
index 36ddf2811..b3c5e8dc5 100644
--- a/packages/bruno-schema/src/collections/index.js
+++ b/packages/bruno-schema/src/collections/index.js
@@ -168,7 +168,9 @@ const oauth2Schema = Yup.object({
.strict();
const authSchema = Yup.object({
- mode: Yup.string().oneOf(['inherit', 'none', 'awsv4', 'basic', 'bearer', 'digest', 'oauth2']).required('mode is required'),
+ mode: Yup.string()
+ .oneOf(['inherit', 'none', 'awsv4', 'basic', 'bearer', 'digest', 'oauth2'])
+ .required('mode is required'),
awsv4: authAwsV4Schema.nullable(),
basic: authBasicSchema.nullable(),
bearer: authBearerSchema.nullable(),