From c3518cf678c2ff950c8f9747b8095719da2c9be0 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:28:13 +0530 Subject: [PATCH] chore: add `showInterceptorWarningForDigestAuth` field under `platformFeatureFlags` Introduce a new platform-level feature flag indicating whether to display a warning via the inspector regarding supported interceptor alongside Digest Auth. --- packages/hoppscotch-common/src/platform/index.ts | 5 +++++ packages/hoppscotch-common/src/platform/interceptors.ts | 1 + .../inspection/inspectors/authorization.inspector.ts | 4 +--- packages/hoppscotch-selfhost-web/src/main.ts | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/hoppscotch-common/src/platform/index.ts b/packages/hoppscotch-common/src/platform/index.ts index 2550a5a59..9acff14f4 100644 --- a/packages/hoppscotch-common/src/platform/index.ts +++ b/packages/hoppscotch-common/src/platform/index.ts @@ -54,6 +54,11 @@ export type PlatformDef = { * Whether to show the A/B testing workspace switcher click login flow or not */ workspaceSwitcherLogin?: Ref + + /** + * 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 6c2cd8324..9197cf722 100644 --- a/packages/hoppscotch-common/src/platform/interceptors.ts +++ b/packages/hoppscotch-common/src/platform/interceptors.ts @@ -14,4 +14,5 @@ export type PlatformInterceptorDef = export type InterceptorsPlatformDef = { default: string interceptors: PlatformInterceptorDef[] + showInterceptorWarningForDigestAuth?: boolean } 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 4a9818abb..e26f251e2 100644 --- a/packages/hoppscotch-common/src/services/inspection/inspectors/authorization.inspector.ts +++ b/packages/hoppscotch-common/src/services/inspection/inspectors/authorization.inspector.ts @@ -75,10 +75,8 @@ export class AuthorizationInspectorService const results: InspectorResult[] = [] // `Agent` interceptor is recommended while using Digest Auth - // TODO: Better check to detect the platform - // Interceptor check only applies to the browser platform const isUnsupportedInterceptor = - platform.interceptors.default === "browser" && + platform.platformFeatureFlags.showInterceptorWarningForDigestAuth && this.interceptorService.currentInterceptorID.value !== this.agentService.interceptorID diff --git a/packages/hoppscotch-selfhost-web/src/main.ts b/packages/hoppscotch-selfhost-web/src/main.ts index 3d5839d4e..4482d4163 100644 --- a/packages/hoppscotch-selfhost-web/src/main.ts +++ b/packages/hoppscotch-selfhost-web/src/main.ts @@ -42,6 +42,7 @@ createHoppApp("#app", { platformFeatureFlags: { exportAsGIST: false, hasTelemetry: false, + showInterceptorWarningForDigestAuth: true, }, limits: { collectionImportSizeLimit: 50,