Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

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

Anwarul Islameecaa745af69
diff --git a/packages/hoppscotch-common/src/components/http/Headers.vue b/packages/hoppscotch-common/src/components/http/Headers.vue
index 20b74b4e9..11c35048b 100644
--- a/packages/hoppscotch-common/src/components/http/Headers.vue
+++ b/packages/hoppscotch-common/src/components/http/Headers.vue
@@ -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,
diff --git a/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/UrlImport.vue b/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/UrlImport.vue
index 591f8381d..d9aa75a6f 100644
--- a/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/UrlImport.vue
+++ b/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/UrlImport.vue
@@ -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 {
diff --git a/packages/hoppscotch-common/src/helpers/auth/auth-types.ts b/packages/hoppscotch-common/src/helpers/auth/auth-types.ts
index d73c57356..520e247dc 100644
--- a/packages/hoppscotch-common/src/helpers/auth/auth-types.ts
+++ b/packages/hoppscotch-common/src/helpers/auth/auth-types.ts
@@ -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 []
}
diff --git a/packages/hoppscotch-common/src/helpers/auth/types/aws-signature.ts b/packages/hoppscotch-common/src/helpers/auth/types/aws-signature.ts
index 8ebfefcbf..4b253c9ba 100644
--- a/packages/hoppscotch-common/src/helpers/auth/types/aws-signature.ts
+++ b/packages/hoppscotch-common/src/helpers/auth/types/aws-signature.ts
@@ -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 []
diff --git a/packages/hoppscotch-common/src/helpers/auth/types/jwt.ts b/packages/hoppscotch-common/src/helpers/auth/types/jwt.ts
index f9bcf0f3a..86d926303 100644
--- a/packages/hoppscotch-common/src/helpers/auth/types/jwt.ts
+++ b/packages/hoppscotch-common/src/helpers/auth/types/jwt.ts
@@ -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 []
diff --git a/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts b/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts
index a92f9f6e8..0d8a868dd 100644
--- a/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts
+++ b/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts
@@ -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) => ({