You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

mockttp

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.14.0 to 0.14.1

dist/client/introspection-query.d.ts

2

dist/client/mockttp-client.d.ts

@@ -33,2 +33,3 @@ /**

private mockServerStream;
private mockServerSchema;
constructor(mockServerOptions?: MockttpOptions);

@@ -41,2 +42,3 @@ private requestFromStandalone;

stop(): Promise<void>;
private typeHasField;
enableDebug(): void;

@@ -43,0 +45,0 @@ reset: () => Promise<boolean>;

28

dist/client/mockttp-client.js

@@ -30,2 +30,3 @@ "use strict";

const request_utils_1 = require("../server/request-utils");
const introspection_query_1 = require("./introspection-query");
class ConnectionError extends typed_error_1.TypedError {

@@ -70,3 +71,3 @@ }

reset
}`)).data;
}`));
});

@@ -80,3 +81,3 @@ this.addRule = (rule) => __awaiter(this, void 0, void 0, function* () {

newRule: mock_rule_1.serializeRuleData(rule, { clientStream: this.mockServerStream })
})).data.addRule.id;
})).addRule.id;
return new mocked_endpoint_client_1.MockedEndpointClient(ruleId, this.getEndpointData(ruleId));

@@ -100,3 +101,3 @@ });

});
const mockedEndpoint = result.data.mockedEndpoint;
const mockedEndpoint = result.mockedEndpoint;
if (!mockedEndpoint)

@@ -173,3 +174,3 @@ return null;

try {
return yield this.requestFromMockServer('/', {
return (yield this.requestFromMockServer('/', {
method: 'POST',

@@ -180,3 +181,3 @@ headers: new Headers({

body: JSON.stringify({ query, variables })
});
})).data;
}

@@ -212,2 +213,4 @@ catch (e) {

this.mockServerConfig = mockServerConfig;
// Load the schema on server start, so we can check for feature support
this.mockServerSchema = (yield this.queryMockServer(introspection_query_1.introspectionQuery)).__schema;
});

@@ -226,2 +229,8 @@ }

}
typeHasField(typeName, fieldName) {
const type = _.find(this.mockServerSchema.types, { name: typeName });
if (!type)
return false;
return !!_.find(type.fields, { name: fieldName });
}
enableDebug() {

@@ -251,2 +260,4 @@ throw new Error("Client-side debug info not implemented.");

}[event];
// Note the typeHasField checks - these are a quick hack for backward compatibility,
// introspecting the server schema to avoid requesting fields that don't exist on old servers.
const query = {

@@ -266,3 +277,3 @@ request: {

body,
timingEvents
${this.typeHasField('Request', 'timingEvents') ? 'timingEvents' : ''}
}

@@ -280,3 +291,3 @@ }`

body,
timingEvents
${this.typeHasField('Response', 'timingEvents') ? 'timingEvents' : ''}
}

@@ -314,2 +325,5 @@ }`

}
else {
data.timingEvents = {}; // For backward compat
}
if (data.body) {

@@ -316,0 +330,0 @@ data.body = request_utils_1.buildBodyReader(Buffer.from(data.body, 'base64'), data.headers);

@@ -63,3 +63,3 @@ /**

body: CompletedBody;
timingEvents: TimingEvents;
timingEvents: TimingEvents | {};
}

@@ -86,3 +86,3 @@ export interface TimingEvents {

body: CompletedBody;
timingEvents: TimingEvents;
timingEvents: TimingEvents | {};
}

@@ -89,0 +89,0 @@ /**

{
"name": "mockttp",
"version": "0.14.0",
"version": "0.14.1",
"description": "Mock HTTP server for testing HTTP clients and stubbing webservices",

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

@@ -31,2 +31,3 @@ /**

import { RequireProps } from '../util/type-utils';
import { introspectionQuery } from './introspection-query';

@@ -75,2 +76,3 @@ export class ConnectionError extends TypedError { }

private mockServerStream: Duplex | undefined;
private mockServerSchema: any;

@@ -158,3 +160,3 @@ constructor(mockServerOptions: MockttpOptions = {}) {

try {
return await this.requestFromMockServer<T>('/', {
return (await this.requestFromMockServer<{ data: T }>('/', {
method: 'POST',

@@ -165,3 +167,3 @@ headers: new Headers({

body: JSON.stringify({ query, variables })
});
})).data;
} catch (e) {

@@ -196,2 +198,5 @@ try {

this.mockServerConfig = mockServerConfig;
// Load the schema on server start, so we can check for feature support
this.mockServerSchema = (await this.queryMockServer<any>(introspectionQuery)).__schema;
}

@@ -210,2 +215,8 @@

private typeHasField(typeName: string, fieldName: string): boolean {
const type: any = _.find(this.mockServerSchema.types, { name: typeName });
if (!type) return false;
return !!_.find(type.fields, { name: fieldName });
}
enableDebug(): void {

@@ -216,7 +227,7 @@ throw new Error("Client-side debug info not implemented.");

reset = async (): Promise<boolean> => {
return (await this.queryMockServer<{ data: boolean }>(
return (await this.queryMockServer<boolean>(
`mutation Reset {
reset
}`
)).data;
));
}

@@ -237,5 +248,3 @@

public addRule = async (rule: MockRuleData): Promise<MockedEndpoint> => {
let ruleId = (await this.queryMockServer<{
data: { addRule: { id: string } }
}>(
let ruleId = (await this.queryMockServer<{ addRule: { id: string } }>(
`mutation AddRule($newRule: MockRule!) {

@@ -248,3 +257,3 @@ addRule(input: $newRule) {

}
)).data.addRule.id;
)).addRule.id;

@@ -267,2 +276,5 @@ return new MockedEndpointClient(ruleId, this.getEndpointData(ruleId));

// Note the typeHasField checks - these are a quick hack for backward compatibility,
// introspecting the server schema to avoid requesting fields that don't exist on old servers.
const query = {

@@ -282,3 +294,3 @@ request: {

body,
timingEvents
${this.typeHasField('Request', 'timingEvents') ? 'timingEvents' : ''}
}

@@ -296,3 +308,3 @@ }`

body,
timingEvents
${this.typeHasField('Response', 'timingEvents') ? 'timingEvents' : ''}
}

@@ -330,2 +342,4 @@ }`

data.timingEvents = JSON.parse(data.timingEvents);
} else {
data.timingEvents = {}; // For backward compat
}

@@ -351,3 +365,3 @@ if (data.body) {

let result = await this.queryMockServer<{
data: { mockedEndpoint: MockedEndpointData | null }
mockedEndpoint: MockedEndpointData | null
}>(

@@ -371,3 +385,3 @@ `query GetEndpointData($id: ID!) {

const mockedEndpoint = result.data.mockedEndpoint;
const mockedEndpoint = result.mockedEndpoint;

@@ -374,0 +388,0 @@ if (!mockedEndpoint) return null;

@@ -77,3 +77,3 @@ /**

body: CompletedBody;
timingEvents: TimingEvents;
timingEvents: TimingEvents | {};
}

@@ -107,3 +107,3 @@

body: CompletedBody;
timingEvents: TimingEvents;
timingEvents: TimingEvents | {};
}

@@ -110,0 +110,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc