Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stuntman/client

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stuntman/client - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

6

package.json
{
"name": "@stuntman/client",
"version": "0.1.6",
"version": "0.1.7",
"description": "Stuntman - HTTP proxy / mock API client",

@@ -58,5 +58,5 @@ "main": "dist/index.js",

"build": "tsc",
"lint": "prettier --check . && eslint . --ext ts",
"lint:fix": "prettier --write ./{src,test} && eslint ./{src,test} --ext ts --fix"
"lint": "prettier --check \"./{src,test}/**/*\" && eslint \"./{src,test}/**/*\"",
"lint:fix": "prettier --write \"./{src,test}/**/*\" && eslint \"./{src,test}/**/*\" --fix"
}
}
import serializeJavascript from 'serialize-javascript';
import { ClientError } from './clientError';
import { DEFAULT_API_PORT } from '@stuntman/shared';
import { stuntmanConfig } from '@stuntman/shared';
import type * as Stuntman from '@stuntman/shared';
type ClientOptions = {
protocol?: 'http' | 'https';
host?: string;
port?: number;
timeout?: number;
apiKey?: string;
};
const SERIALIZE_JAVASCRIPT_OPTIONS: serializeJavascript.SerializeJSOptions = {

@@ -100,3 +92,3 @@ unsafe: true,

private options: ClientOptions;
private options: Stuntman.ClientConfig;

@@ -107,9 +99,7 @@ private get baseUrl() {

constructor(options?: ClientOptions) {
constructor(options?: Partial<Stuntman.ClientConfig>) {
this.options = {
...stuntmanConfig.client,
...options,
timeout: options?.timeout || 60000,
host: options?.host || 'localhost',
protocol: options?.protocol || 'http',
port: options?.port || options?.protocol ? (options.protocol === 'https' ? 443 : 80) : DEFAULT_API_PORT,
port: options?.port || options?.protocol ? (options.protocol === 'https' ? 443 : 80) : stuntmanConfig.client.port,
};

@@ -116,0 +106,0 @@ }

@@ -20,4 +20,6 @@ import { AppError } from '@stuntman/shared';

super(args);
this.originalStack = args.stack;
if (args.stack) {
this.originalStack = args.stack;
}
}
}

@@ -62,6 +62,6 @@ import { v4 as uuidv4 } from 'uuid';

const [rawKey, ...rest] = path.split('.');
const key = rawKey.replace(arrayIndexerRegex, '');
const shouldBeArray = arrayIndexerRegex.test(rawKey);
const key = (rawKey ?? '').replace(arrayIndexerRegex, '');
const shouldBeArray = rawKey ? arrayIndexerRegex.test(rawKey) : false;
const arrayIndex =
(arrayIndexerRegex.exec(rawKey)?.groups?.arrayIndex || '').length > 0
rawKey && (arrayIndexerRegex.exec(rawKey)?.groups?.arrayIndex || '').length > 0
? Number(arrayIndexerRegex.exec(rawKey)?.groups?.arrayIndex)

@@ -86,7 +86,7 @@ : Number.NaN;

: actualValue !== undefined;
return { result, description: `${currentPath}` };
return { result, description: `${currentPath} === undefined` };
}
if (!shouldBeArray) {
const result = value instanceof RegExp ? value.test(actualValue) : value === actualValue;
return { result, description: `${currentPath}` };
return { result, description: `${currentPath} === "${actualValue}"` };
}

@@ -297,14 +297,13 @@ }

}
if (!matchBuilderVariables.bodyGql.variables) {
return { result: true, description: `no variables to match` };
}
for (const jsonMatcher of Array.isArray(matchBuilderVariables.bodyGql.variables)
? matchBuilderVariables.bodyGql.variables
: [matchBuilderVariables.bodyGql.variables]) {
const matchObjectResult = matchObject(req.gqlBody.variables, jsonMatcher.key, jsonMatcher.value);
if (!matchObjectResult.result) {
return {
result: false,
description: `GQL variable ${jsonMatcher.key} != "${jsonMatcher.value}". Detail: ${matchObjectResult.description}`,
};
if (matchBuilderVariables.bodyGql.variables) {
for (const jsonMatcher of Array.isArray(matchBuilderVariables.bodyGql.variables)
? matchBuilderVariables.bodyGql.variables
: [matchBuilderVariables.bodyGql.variables]) {
const matchObjectResult = matchObject(req.gqlBody.variables, jsonMatcher.key, jsonMatcher.value);
if (!matchObjectResult.result) {
return {
result: false,
description: `GQL variable ${jsonMatcher.key} != "${jsonMatcher.value}". Detail: ${matchObjectResult.description}`,
};
}
}

@@ -538,3 +537,7 @@ }

}
this._matchBuilderVariables.bodyJson.push({ key: keyOrMatcher, value: withValue });
if (withValue === undefined) {
this._matchBuilderVariables.bodyJson.push({ key: keyOrMatcher });
} else {
this._matchBuilderVariables.bodyJson.push({ key: keyOrMatcher, value: withValue });
}
return this;

@@ -553,2 +556,5 @@ }

withBodyGql(gqlMatcher: GQLRequestMatcher): RuleBuilderInitialized {
if (this._matchBuilderVariables.bodyGql) {
throw new Error('gqlMatcher already set');
}
this._matchBuilderVariables.bodyGql = gqlMatcher;

@@ -555,0 +561,0 @@ return this;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc