From db6bf5b39802718873413978c8df919a715b1394 Mon Sep 17 00:00:00 2001 From: parthlambdatest Date: Thu, 19 Sep 2024 18:00:58 +0530 Subject: [PATCH 1/3] add new config option requestHeaders --- src/lib/ctx.ts | 10 ++++++++-- src/lib/processSnapshot.ts | 10 ++++++++-- src/lib/schemaValidation.ts | 9 +++++++++ src/types.ts | 5 +++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/lib/ctx.ts b/src/lib/ctx.ts index 7857435..9a8d1da 100644 --- a/src/lib/ctx.ts +++ b/src/lib/ctx.ts @@ -1,4 +1,4 @@ -import { Context, Env, WebConfig, MobileConfig, basicAuth } from '../types.js' +import { Context, Env, WebConfig, MobileConfig, basicAuth, authToken } from '../types.js' import constants from './constants.js' import { version } from '../../package.json' import { validateConfig } from './schemaValidation.js' @@ -12,6 +12,7 @@ export default (options: Record): Context => { let webConfig: WebConfig; let mobileConfig: MobileConfig; let basicAuthObj: basicAuth + let requestHeaderObj: authToken let config = constants.DEFAULT_CONFIG; let port: number; let resolutionOff: boolean; @@ -60,6 +61,10 @@ export default (options: Record): Context => { if (config.basicAuthorization) { basicAuthObj = config.basicAuthorization } + if (config.requestHeaders){ + requestHeaderObj = config.requestHeaders + } + return { env: env, @@ -75,7 +80,8 @@ export default (options: Record): Context => { scrollTime: config.scrollTime || constants.DEFAULT_SCROLL_TIME, allowedHostnames: config.allowedHostnames || [], basicAuthorization: basicAuthObj, - smartIgnore: config.smartIgnore ?? false + smartIgnore: config.smartIgnore ?? false, + requestHeaders: requestHeaderObj }, uploadFilePath: '', webStaticConfig: [], diff --git a/src/lib/processSnapshot.ts b/src/lib/processSnapshot.ts index b7ba433..1921ac1 100644 --- a/src/lib/processSnapshot.ts +++ b/src/lib/processSnapshot.ts @@ -146,9 +146,15 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise; basicAuthorization: basicAuth | undefined; smartIgnore: boolean; + requestHeaders: authToken | undefined }; uploadFilePath: string; webStaticConfig: WebStaticConfig; @@ -148,3 +149,7 @@ export interface basicAuth { username: string; password: string; } + +export interface authToken { + auth: string; +} From 8b76cfca456bb501d5436b033376d9064fc7a31f Mon Sep 17 00:00:00 2001 From: parthlambdatest Date: Thu, 19 Sep 2024 18:08:06 +0530 Subject: [PATCH 2/3] code clean up --- src/lib/ctx.ts | 4 ++-- src/lib/processSnapshot.ts | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lib/ctx.ts b/src/lib/ctx.ts index 9a8d1da..eb19647 100644 --- a/src/lib/ctx.ts +++ b/src/lib/ctx.ts @@ -11,8 +11,8 @@ export default (options: Record): Context => { let env: Env = getEnv(); let webConfig: WebConfig; let mobileConfig: MobileConfig; - let basicAuthObj: basicAuth - let requestHeaderObj: authToken + let basicAuthObj: basicAuth; + let requestHeaderObj: authToken; let config = constants.DEFAULT_CONFIG; let port: number; let resolutionOff: boolean; diff --git a/src/lib/processSnapshot.ts b/src/lib/processSnapshot.ts index 1921ac1..09745a2 100644 --- a/src/lib/processSnapshot.ts +++ b/src/lib/processSnapshot.ts @@ -146,18 +146,19 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise Date: Tue, 24 Sep 2024 17:49:02 +0530 Subject: [PATCH 3/3] add validatio check for username password and auth --- src/lib/processSnapshot.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/processSnapshot.ts b/src/lib/processSnapshot.ts index 09745a2..b87c64b 100644 --- a/src/lib/processSnapshot.ts +++ b/src/lib/processSnapshot.ts @@ -151,10 +151,14 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise