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: introduce `supportsDigestAuth` field at the interceptor service level (#4498)

James George223dd2578875
diff --git a/packages/hoppscotch-common/src/platform/index.ts b/packages/hoppscotch-common/src/platform/index.ts
index 9acff14f4..2550a5a59 100644
--- a/packages/hoppscotch-common/src/platform/index.ts
+++ b/packages/hoppscotch-common/src/platform/index.ts
@@ -54,11 +54,6 @@ export type PlatformDef = {
* Whether to show the A/B testing workspace switcher click login flow or not
*/
workspaceSwitcherLogin?: Ref<boolean>
-
- /**
- * Whether to show the warning about supported interceptors while using the Digest Authorization type
- */
- showInterceptorWarningForDigestAuth?: boolean
}
limits?: LimitsPlatformDef
infra?: InfraPlatformDef
diff --git a/packages/hoppscotch-common/src/platform/interceptors.ts b/packages/hoppscotch-common/src/platform/interceptors.ts
index 9197cf722..6c2cd8324 100644
--- a/packages/hoppscotch-common/src/platform/interceptors.ts
+++ b/packages/hoppscotch-common/src/platform/interceptors.ts
@@ -14,5 +14,4 @@ export type PlatformInterceptorDef =
export type InterceptorsPlatformDef = {
default: string
interceptors: PlatformInterceptorDef[]
- showInterceptorWarningForDigestAuth?: boolean
}
diff --git a/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts b/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts
index ddb25045b..a27bce5e0 100644
--- a/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts
+++ b/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts
@@ -302,6 +302,8 @@ export class AgentInterceptorService extends Service implements Interceptor {
public proxyInfo = ref<RequestDef["proxy"]>(undefined)
+ public supportsDigestAuth = true
+
override onServiceInit() {
// Register the Root UI Extension
this.uiExtensionService.addRootUIExtension(AgentRootUIExtension)
diff --git a/packages/hoppscotch-common/src/services/inspection/inspectors/authorization.inspector.ts b/packages/hoppscotch-common/src/services/inspection/inspectors/authorization.inspector.ts
index e26f251e2..73373c099 100644
--- a/packages/hoppscotch-common/src/services/inspection/inspectors/authorization.inspector.ts
+++ b/packages/hoppscotch-common/src/services/inspection/inspectors/authorization.inspector.ts
@@ -6,8 +6,6 @@ import { Service } from "dioc"
import { computed, markRaw, Ref } from "vue"
import { getI18n } from "~/modules/i18n"
-import { platform } from "~/platform"
-import { AgentInterceptorService } from "~/platform/std/interceptors/agent"
import { InterceptorService } from "~/services/interceptor.service"
import { RESTTabService } from "~/services/tab/rest"
import IconAlertTriangle from "~icons/lucide/alert-triangle"
@@ -31,7 +29,6 @@ export class AuthorizationInspectorService
private readonly inspection = this.bind(InspectionService)
private readonly interceptorService = this.bind(InterceptorService)
- private readonly agentService = this.bind(AgentInterceptorService)
private readonly restTabService = this.bind(RESTTabService)
override onServiceInit() {
@@ -74,15 +71,12 @@ export class AuthorizationInspectorService
const results: InspectorResult[] = []
- // `Agent` interceptor is recommended while using Digest Auth
- const isUnsupportedInterceptor =
- platform.platformFeatureFlags.showInterceptorWarningForDigestAuth &&
- this.interceptorService.currentInterceptorID.value !==
- this.agentService.interceptorID
-
const resolvedAuthType = this.resolveAuthType(auth)
- if (resolvedAuthType === "digest" && isUnsupportedInterceptor) {
+ if (
+ resolvedAuthType === "digest" &&
+ !this.interceptorService.currentInterceptor.value?.supportsDigestAuth
+ ) {
results.push({
id: "url",
icon: markRaw(IconAlertTriangle),
diff --git a/packages/hoppscotch-common/src/services/interceptor.service.ts b/packages/hoppscotch-common/src/services/interceptor.service.ts
index 7b65b6179..25a5889fd 100644
--- a/packages/hoppscotch-common/src/services/interceptor.service.ts
+++ b/packages/hoppscotch-common/src/services/interceptor.service.ts
@@ -141,6 +141,12 @@ export type Interceptor<Err extends InterceptorError = InterceptorError> = {
* @param request The request to run the interceptor on.
*/
runRequest: (request: AxiosRequestConfig) => RequestRunResult<Err>
+
+ /**
+ * Defines whether the interceptor has support for Digest Auth.
+ * If this field is undefined, it is assumed as not supporting the Digest Auth type.
+ */
+ supportsDigestAuth?: boolean
}
/**
diff --git a/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts b/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts
index 17421e8ed..c6f08cf8d 100644
--- a/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts
+++ b/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts
@@ -277,6 +277,8 @@ export class NativeInterceptorService extends Service implements Interceptor {
public validateCerts = ref(true)
public proxyInfo = ref<RequestDef["proxy"]>(undefined)
+ public supportsDigestAuth = true
+
override onServiceInit() {
// Load SSL Validation
const persistedValidateSSL: unknown = JSON.parse(
diff --git a/packages/hoppscotch-selfhost-web/src/main.ts b/packages/hoppscotch-selfhost-web/src/main.ts
index 4482d4163..3d5839d4e 100644
--- a/packages/hoppscotch-selfhost-web/src/main.ts
+++ b/packages/hoppscotch-selfhost-web/src/main.ts
@@ -42,7 +42,6 @@ createHoppApp("#app", {
platformFeatureFlags: {
exportAsGIST: false,
hasTelemetry: false,
- showInterceptorWarningForDigestAuth: true,
},
limits: {
collectionImportSizeLimit: 50,