Socket
Socket
Sign inDemoInstall

mockttp

Package Overview
Dependencies
148
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.12.3-updategraphql to 0.12.3

typedoc/classes/mockruledata.cookiematcherdata.html

15

dist/rules/matchers.d.ts

@@ -81,3 +81,15 @@ /**

}
export declare type MatcherData = (WildcardMatcherData | MethodMatcherData | SimplePathMatcherData | RegexPathMatcherData | HeaderMatcherData | QueryMatcherData | FormDataMatcherData | RawBodyMatcherData);
export declare class CookieMatcherData extends Serializable {
cookie: {
[key: string]: string;
};
readonly type: 'cookie';
constructor(cookie: {
[key: string]: string;
});
buildMatcher(): ((request: OngoingRequest) => Promise<boolean | undefined>) & {
explain: () => string;
};
}
export declare type MatcherData = (WildcardMatcherData | MethodMatcherData | SimplePathMatcherData | RegexPathMatcherData | HeaderMatcherData | QueryMatcherData | FormDataMatcherData | RawBodyMatcherData | CookieMatcherData);
export declare const MatcherDataLookup: {

@@ -92,3 +104,4 @@ 'wildcard': typeof WildcardMatcherData;

'raw-body': typeof RawBodyMatcherData;
'cookie': typeof CookieMatcherData;
};
export declare function buildMatchers(matcherPartData: MatcherData[]): RequestMatcher;

@@ -221,2 +221,31 @@ "use strict";

exports.RawBodyMatcherData = RawBodyMatcherData;
var CookieMatcherData = /** @class */ (function (_super) {
__extends(CookieMatcherData, _super);
function CookieMatcherData(cookie) {
var _this = _super.call(this) || this;
_this.cookie = cookie;
_this.type = 'cookie';
return _this;
}
CookieMatcherData.prototype.buildMatcher = function () {
var _this = this;
return _.assign(function (request) { return __awaiter(_this, void 0, void 0, function () {
var cookies;
var _this = this;
return __generator(this, function (_a) {
if (!request.headers || !request.headers.cookie) {
return [2 /*return*/];
}
cookies = request.headers.cookie.split(';').map(function (cookie) {
var _a;
var _b = cookie.split('='), key = _b[0], value = _b[1];
return _a = {}, _a[key.trim()] = (value || '').trim(), _a;
});
return [2 /*return*/, cookies.some(function (element) { return _.isEqual(element, _this.cookie); })];
});
}); }, { explain: function () { return "with cookies including " + JSON.stringify(_this.cookie); } });
};
return CookieMatcherData;
}(serialization_1.Serializable));
exports.CookieMatcherData = CookieMatcherData;
exports.MatcherDataLookup = {

@@ -230,3 +259,4 @@ 'wildcard': WildcardMatcherData,

'form-data': FormDataMatcherData,
'raw-body': RawBodyMatcherData
'raw-body': RawBodyMatcherData,
'cookie': CookieMatcherData
};

@@ -233,0 +263,0 @@ function buildMatchers(matcherPartData) {

@@ -61,2 +61,8 @@ /**

/**
* Match only requests that include the given cookies
*/
withCookie(cookie: {
[key: string]: string;
}): this;
/**
* Run this rule forever, for all matching requests

@@ -63,0 +69,0 @@ */

@@ -116,2 +116,9 @@ "use strict";

/**
* Match only requests that include the given cookies
*/
MockRuleBuilder.prototype.withCookie = function (cookie) {
this.matchers.push(new matchers_1.CookieMatcherData(cookie));
return this;
};
/**
* Run this rule forever, for all matching requests

@@ -118,0 +125,0 @@ */

4

package.json
{
"name": "mockttp",
"version": "0.12.3-updategraphql",
"version": "0.12.3",
"description": "Mock HTTP server for testing HTTP clients and stubbing webservices",

@@ -100,3 +100,3 @@ "main": "dist/main.js",

"typedoc-plugin-external-module-name": "^1.1.1",
"typescript": "^3.1.6",
"typescript": "3.1.6",
"url-search-params": "^0.10.0",

@@ -103,0 +103,0 @@ "webpack": "^3.7.1",

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

export class CookieMatcherData extends Serializable {
readonly type: 'cookie' = 'cookie';
constructor(
public cookie: { [key: string]: string },
) {
super();
}
buildMatcher() {
return _.assign(
async (request: OngoingRequest) => {
if(!request.headers || !request.headers.cookie) {
return;
}
const cookies = request.headers.cookie.split(';').map(cookie => {
const [key, value] = cookie.split('=');
return { [key.trim()]: (value || '').trim()}
});
return cookies.some(element => _.isEqual(element, this.cookie))
},
{ explain: () => `with cookies including ${JSON.stringify(this.cookie)}` }
);
}
}
export type MatcherData = (

@@ -169,3 +198,4 @@ WildcardMatcherData |

FormDataMatcherData |
RawBodyMatcherData
RawBodyMatcherData |
CookieMatcherData
);

@@ -181,4 +211,5 @@

'form-data': FormDataMatcherData,
'raw-body': RawBodyMatcherData
}
'raw-body': RawBodyMatcherData,
'cookie': CookieMatcherData
};

@@ -202,2 +233,2 @@ export function buildMatchers(matcherPartData: MatcherData[]): RequestMatcher {

} });
}
}

@@ -35,3 +35,4 @@ /**

RawBodyMatcherData,
WildcardMatcherData
WildcardMatcherData,
CookieMatcherData
} from "./matchers";

@@ -138,2 +139,10 @@

/**
* Match only requests that include the given cookies
*/
withCookie(cookie: { [key: string]: string }) {
this.matchers.push(new CookieMatcherData(cookie));
return this;
}
/**
* Run this rule forever, for all matching requests

@@ -140,0 +149,0 @@ */

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 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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc