chore(common): fixes lint errors and clean up code (#5237)

Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
Anwarul Islam 2025-07-11 13:26:03 +06:00 committed by GitHub
parent fe5c07faed
commit eecaa745af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 41 deletions

View file

@ -576,7 +576,7 @@ watch([props.modelValue, aggregateEnvs], async () => {
}
})
computedHeaders.value = (
await getComputedHeaders(props.modelValue, resolvedEnvs, true)
await getComputedHeaders(props.modelValue, resolvedEnvs)
).map((header, index) => ({
id: `header-${index}`,
...header,

View file

@ -180,7 +180,7 @@ async function fetchUrlData() {
const res = await urlFetchLogic(inputChooseGistToImportFrom.value)
if (E.isLeft(res)) {
// @ts-ignore
// @ts-expect-error Assuming error is of type Error
if (isCorsError(res.left?.error)) {
showCorsError.value = true
} else {

View file

@ -46,12 +46,7 @@ export async function generateAuthHeaders(
case "digest":
return generateDigestAuthHeaders(auth, request, envVars, showKeyIfSecret)
case "aws-signature":
return generateAwsSignatureAuthHeaders(
auth,
request,
envVars,
showKeyIfSecret
)
return generateAwsSignatureAuthHeaders(auth, request, envVars)
case "hawk":
return generateHawkAuthHeaders(auth, request, envVars, showKeyIfSecret)
case "jwt":
@ -78,14 +73,9 @@ export async function generateAuthParams(
case "oauth-2":
return generateOAuth2AuthParams(auth, request, envVars, showKeyIfSecret)
case "aws-signature":
return generateAwsSignatureAuthParams(
auth,
request,
envVars,
showKeyIfSecret
)
return generateAwsSignatureAuthParams(auth, request, envVars)
case "jwt":
return generateJwtAuthParams(auth, request, envVars, showKeyIfSecret)
return generateJwtAuthParams(auth, request, envVars)
default:
return []
}

View file

@ -1,10 +1,10 @@
import {
parseTemplateString,
HoppRESTAuth,
HoppRESTRequest,
Environment,
HoppRESTAuth,
HoppRESTHeader,
HoppRESTParam,
HoppRESTRequest,
parseTemplateString,
} from "@hoppscotch/data"
import { AwsV4Signer } from "aws4fetch"
import { getFinalBodyFromRequest } from "~/helpers/utils/EffectiveURL"
@ -12,8 +12,7 @@ import { getFinalBodyFromRequest } from "~/helpers/utils/EffectiveURL"
export async function generateAwsSignatureAuthHeaders(
auth: HoppRESTAuth & { authType: "aws-signature" },
request: HoppRESTRequest,
envVars: Environment["variables"],
showKeyIfSecret = false
envVars: Environment["variables"]
): Promise<HoppRESTHeader[]> {
if (auth.addTo !== "HEADERS") return []
@ -54,8 +53,7 @@ export async function generateAwsSignatureAuthHeaders(
export async function generateAwsSignatureAuthParams(
auth: HoppRESTAuth & { authType: "aws-signature" },
request: HoppRESTRequest,
envVars: Environment["variables"],
showKeyIfSecret = false
envVars: Environment["variables"]
): Promise<HoppRESTParam[]> {
if (auth.addTo !== "QUERY_PARAMS") return []

View file

@ -1,11 +1,11 @@
import {
parseTemplateString,
Environment,
generateJWTToken,
HoppRESTAuth,
HoppRESTRequest,
Environment,
HoppRESTHeader,
HoppRESTParam,
HoppRESTRequest,
parseTemplateString,
} from "@hoppscotch/data"
export async function generateJwtAuthHeaders(
@ -48,8 +48,7 @@ export async function generateJwtAuthHeaders(
export async function generateJwtAuthParams(
auth: HoppRESTAuth & { authType: "jwt" },
request: HoppRESTRequest,
envVars: Environment["variables"],
showKeyIfSecret = false
envVars: Environment["variables"]
): Promise<HoppRESTParam[]> {
if (auth.addTo !== "QUERY_PARAMS") return []

View file

@ -23,12 +23,12 @@ import qs from "qs"
import { combineLatest, Observable } from "rxjs"
import { map } from "rxjs/operators"
import { generateAuthHeaders, generateAuthParams } from "../auth/auth-types"
import { stripComments } from "../editor/linting/jsonc"
import { arrayFlatMap, arraySort } from "../functional/array"
import { toFormData } from "../functional/formData"
import { tupleWithSameKeysToRecord } from "../functional/record"
import { isJSONContentType } from "./contenttypes"
import { stripComments } from "../editor/linting/jsonc"
import { generateAuthHeaders, generateAuthParams } from "../auth/auth-types"
export interface EffectiveHoppRESTRequest extends HoppRESTRequest {
/**
@ -61,7 +61,6 @@ export const getComputedAuthHeaders = async (
headers: HoppRESTHeaders
},
auth?: HoppRESTRequest["auth"],
parse = true,
showKeyIfSecret = false
) => {
const request = auth ? { auth: auth ?? { authActive: false } } : req
@ -160,18 +159,11 @@ export const getComputedHeaders = async (
headers: HoppRESTHeaders
},
envVars: Environment["variables"],
parse = true,
showKeyIfSecret = false
): Promise<ComputedHeader[]> => {
return [
...(
await getComputedAuthHeaders(
envVars,
req,
undefined,
parse,
showKeyIfSecret
)
await getComputedAuthHeaders(envVars, req, undefined, showKeyIfSecret)
).map((header) => ({
source: "auth" as const,
header,
@ -368,9 +360,9 @@ export async function getEffectiveRESTRequest(
showKeyIfSecret = false
): Promise<EffectiveHoppRESTRequest> {
const effectiveFinalHeaders = pipe(
(await getComputedHeaders(request, environment.variables)).map(
(h) => h.header
),
(
await getComputedHeaders(request, environment.variables, showKeyIfSecret)
).map((h) => h.header),
A.concat(request.headers),
A.filter((x) => x.active && x.key !== ""),
A.map((x) => ({