perimeterx-js-core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -9
- package/lib/activities/HttpActivityClient.d.ts +1 -1
- package/lib/activities/HttpActivityClient.js +7 -4
- package/lib/activities/HttpBatchedActivityClient.d.ts +1 -1
- package/lib/activities/model/ActivityDetails.d.ts +4 -2
- package/lib/activities/utils.js +2 -1
- package/lib/block_handler/DefaultBlockResponseGenerator.d.ts +2 -2
- package/lib/block_handler/DefaultBlockResponseGenerator.js +7 -2
- package/lib/block_handler/IBlockResponseGenerator.d.ts +2 -2
- package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.d.ts +2 -2
- package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.d.ts +2 -2
- package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.js +6 -1
- package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.d.ts +2 -2
- package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.js +8 -4
- package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.d.ts +2 -2
- package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.js +6 -1
- package/lib/config/ConfigurationParams.d.ts +4 -0
- package/lib/config/DefaultConfigurations.js +9 -5
- package/lib/config/IConfiguration.d.ts +18 -0
- package/lib/config/StaticConfigurationBase.d.ts +4 -0
- package/lib/config/StaticConfigurationBase.js +28 -0
- package/lib/context/ContextBase.d.ts +9 -7
- package/lib/context/ContextBase.js +22 -89
- package/lib/context/DefaultTokenV2Context.d.ts +2 -2
- package/lib/context/DefaultTokenV2Context.js +1 -1
- package/lib/context/DefaultTokenV3Context.d.ts +2 -2
- package/lib/context/DefaultTokenV3Context.js +1 -1
- package/lib/context/IContext.d.ts +9 -6
- package/lib/custom_parameters/CustomParametersFunction.d.ts +2 -2
- package/lib/custom_parameters/CustomParametersUtils.d.ts +3 -0
- package/lib/custom_parameters/CustomParametersUtils.js +59 -0
- package/lib/enforcer/EnforcerBase.d.ts +20 -27
- package/lib/enforcer/EnforcerBase.js +54 -19
- package/lib/filter/DefaultFilter.js +1 -1
- package/lib/first_party/DefaultFirstParty.d.ts +3 -2
- package/lib/first_party/DefaultFirstParty.js +45 -35
- package/lib/first_party/IFirstParty.d.ts +2 -2
- package/lib/first_party/constants.d.ts +2 -9
- package/lib/first_party/constants.js +7 -9
- package/lib/graphql/DefaultGraphQLParser.d.ts +19 -0
- package/lib/graphql/DefaultGraphQLParser.js +179 -0
- package/lib/graphql/IGraphQLParser.d.ts +5 -0
- package/lib/graphql/index.d.ts +5 -0
- package/lib/graphql/index.js +7 -0
- package/lib/graphql/model/GraphQLData.d.ts +7 -0
- package/lib/graphql/model/GraphQLOperation.d.ts +5 -0
- package/lib/graphql/model/GraphQLOperationType.d.ts +5 -0
- package/lib/graphql/model/GraphQLOperationType.js +9 -0
- package/lib/http/impl/MinimalResponseImpl.d.ts +13 -0
- package/lib/http/impl/MinimalResponseImpl.js +12 -0
- package/lib/http/impl/OutgoingRequestImpl.d.ts +14 -0
- package/lib/http/impl/OutgoingRequestImpl.js +14 -0
- package/lib/http/impl/index.d.ts +2 -0
- package/lib/http/impl/index.js +18 -0
- package/lib/http/index.d.ts +2 -9
- package/lib/http/index.js +2 -11
- package/lib/http/interfaces/IBody.d.ts +26 -0
- package/lib/http/interfaces/IHttpClient.d.ts +8 -0
- package/lib/http/interfaces/IIncomingRequest.d.ts +23 -0
- package/lib/http/interfaces/IIncomingRequest.js +2 -0
- package/lib/http/interfaces/IIncomingResponse.d.ts +9 -0
- package/lib/http/interfaces/IIncomingResponse.js +2 -0
- package/lib/http/interfaces/IMinimalResponse.d.ts +6 -0
- package/lib/http/interfaces/IMinimalResponse.js +2 -0
- package/lib/http/interfaces/IOutgoingRequest.d.ts +11 -0
- package/lib/http/interfaces/IOutgoingRequest.js +2 -0
- package/lib/http/interfaces/IOutgoingResponse.d.ts +17 -0
- package/lib/http/interfaces/IOutgoingResponse.js +2 -0
- package/lib/http/interfaces/ReadOnlyHeaders.d.ts +3 -0
- package/lib/http/interfaces/ReadOnlyHeaders.js +25 -0
- package/lib/http/interfaces/index.d.ts +7 -0
- package/lib/http/interfaces/index.js +23 -0
- package/lib/http/utils/MinimalResponseUtils.d.ts +4 -0
- package/lib/http/utils/MinimalResponseUtils.js +39 -0
- package/lib/http/utils/index.d.ts +1 -3
- package/lib/http/utils/index.js +2 -5
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/pxde/IDataEnrichment.d.ts +1 -1
- package/lib/pxhd/PXHDUtils.d.ts +5 -2
- package/lib/pxhd/PXHDUtils.js +17 -2
- package/lib/risk_api/PostRiskApiClient.d.ts +3 -2
- package/lib/risk_api/PostRiskApiClient.js +20 -14
- package/lib/risk_api/S2SErrorHandler.d.ts +2 -2
- package/lib/risk_api/S2SErrorHandler.js +1 -1
- package/lib/risk_api/model/RiskActivity.d.ts +2 -0
- package/lib/risk_api/model/RiskResponseV2.d.ts +2 -0
- package/lib/risk_api/risk_response_handler/IRiskResponseHandler.d.ts +2 -2
- package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.d.ts +2 -2
- package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.js +1 -0
- package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.js +12 -4
- package/lib/telemetry/DefaultTelemetry.d.ts +2 -1
- package/lib/telemetry/DefaultTelemetry.js +16 -7
- package/lib/utils/IScoreRetriever.d.ts +1 -1
- package/lib/utils/base64/{DefaultBase64Utils.d.ts → AtobBase64Utils.d.ts} +2 -2
- package/lib/utils/base64/AtobBase64Utils.js +15 -0
- package/lib/utils/base64/BufferBase64Utils.d.ts +6 -0
- package/lib/utils/base64/BufferBase64Utils.js +18 -0
- package/lib/utils/base64/JSBase64Base64Utils.d.ts +5 -0
- package/lib/utils/base64/JSBase64Base64Utils.js +16 -0
- package/lib/utils/base64/index.d.ts +4 -2
- package/lib/utils/base64/index.js +18 -3
- package/lib/utils/cipher/CryptoCipherUtils.d.ts +12 -0
- package/lib/{http/body_reader/StringBodyReader.js → utils/cipher/CryptoCipherUtils.js} +20 -25
- package/lib/utils/cipher/SubtleCryptoCipherUtils.d.ts +9 -0
- package/lib/utils/cipher/SubtleCryptoCipherUtils.js +94 -0
- package/lib/utils/cipher/index.d.ts +2 -0
- package/lib/utils/cipher/index.js +16 -0
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +1 -1
- package/lib/utils/hash/CryptoHmacUtils.d.ts +11 -0
- package/lib/utils/hash/CryptoHmacUtils.js +25 -0
- package/lib/utils/hash/{DefaultHashUtils.d.ts → CryptoJSHmacUtils.d.ts} +1 -1
- package/lib/utils/hash/CryptoJSHmacUtils.js +19 -0
- package/lib/utils/hash/index.d.ts +3 -2
- package/lib/utils/hash/index.js +17 -3
- package/lib/utils/utils.d.ts +1 -2
- package/lib/utils/utils.js +15 -4
- package/package.json +1 -2
- package/lib/http/IHttpClient.d.ts +0 -14
- package/lib/http/body_reader/IBodyReader.d.ts +0 -5
- package/lib/http/body_reader/StringBodyReader.d.ts +0 -8
- package/lib/http/request/DefaultHttpRequest.d.ts +0 -5
- package/lib/http/request/DefaultHttpRequest.js +0 -42
- package/lib/http/request/HttpRequestBase.d.ts +0 -24
- package/lib/http/request/HttpRequestBase.js +0 -77
- package/lib/http/request/IHttpRequest.d.ts +0 -31
- package/lib/http/response/DefaultHttpResponse.d.ts +0 -5
- package/lib/http/response/DefaultHttpResponse.js +0 -32
- package/lib/http/response/HttpResponseBase.d.ts +0 -17
- package/lib/http/response/HttpResponseBase.js +0 -75
- package/lib/http/response/IHttpResponse.d.ts +0 -26
- package/lib/http/utils/HttpBody.d.ts +0 -4
- package/lib/http/utils/HttpHeaders.d.ts +0 -51
- package/lib/http/utils/HttpHeaders.js +0 -106
- package/lib/utils/base64/DefaultBase64Utils.js +0 -16
- package/lib/utils/hash/DefaultHashUtils.js +0 -19
- /package/lib/{http/IHttpClient.js → graphql/IGraphQLParser.js} +0 -0
- /package/lib/{http/body_reader/IBodyReader.js → graphql/model/GraphQLData.js} +0 -0
- /package/lib/{http/request/IHttpRequest.js → graphql/model/GraphQLOperation.js} +0 -0
- /package/lib/http/{response/IHttpResponse.js → interfaces/IBody.js} +0 -0
- /package/lib/http/{utils/HttpBody.js → interfaces/IHttpClient.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultFilter = void 0;
|
|
4
|
-
var http_1 = require("../http");
|
|
5
4
|
var utils_1 = require("../utils");
|
|
6
5
|
var FilterReason_1 = require("./FilterReason");
|
|
6
|
+
var http_1 = require("../http");
|
|
7
7
|
var DefaultFilter = /** @class */ (function () {
|
|
8
8
|
function DefaultFilter(config, ipRangeChecker) {
|
|
9
9
|
if (ipRangeChecker === void 0) { ipRangeChecker = new utils_1.DefaultIpRangeChecker(); }
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { IConfiguration } from '../config';
|
|
2
2
|
import { IContext } from '../context/IContext';
|
|
3
|
-
import { IHttpClient, IHttpResponse } from '../http';
|
|
4
3
|
import { IFirstParty } from './IFirstParty';
|
|
4
|
+
import { IHttpClient } from '../http';
|
|
5
|
+
import { IMinimalResponse } from '../http';
|
|
5
6
|
export declare class DefaultFirstParty implements IFirstParty {
|
|
6
7
|
private readonly config;
|
|
7
8
|
private readonly httpClient;
|
|
8
9
|
constructor(config: IConfiguration, httpClient: IHttpClient);
|
|
9
|
-
handleFirstPartyRequest(context: IContext): Promise<
|
|
10
|
+
handleFirstPartyRequest(context: IContext): Promise<IMinimalResponse>;
|
|
10
11
|
private proxySensorScriptRequest;
|
|
11
12
|
private proxyXhrRequest;
|
|
12
13
|
private static getDefaultXhrResponse;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,6 +52,9 @@ var utils_1 = require("../utils");
|
|
|
41
52
|
var http_1 = require("../http");
|
|
42
53
|
var utils_2 = require("./utils");
|
|
43
54
|
var constants_1 = require("./constants");
|
|
55
|
+
var http_2 = require("../http");
|
|
56
|
+
var http_3 = require("../http");
|
|
57
|
+
var minimalResponseUtils = require("../http/utils/MinimalResponseUtils");
|
|
44
58
|
var DefaultFirstParty = /** @class */ (function () {
|
|
45
59
|
function DefaultFirstParty(config, httpClient) {
|
|
46
60
|
this.config = config;
|
|
@@ -80,15 +94,13 @@ var DefaultFirstParty = /** @class */ (function () {
|
|
|
80
94
|
switch (_a.label) {
|
|
81
95
|
case 0:
|
|
82
96
|
if (!this.config.firstPartyEnabled) {
|
|
83
|
-
return [2 /*return*/, new
|
|
97
|
+
return [2 /*return*/, new http_3.MinimalResponseImpl(constants_1.DEFAULT_CLIENT_RESPONSE_OPTIONS)];
|
|
84
98
|
}
|
|
85
99
|
url = this.getThirdPartySensorScriptUrl();
|
|
86
100
|
return [4 /*yield*/, this.forwardRequest(url, context)];
|
|
87
101
|
case 1:
|
|
88
102
|
response = _a.sent();
|
|
89
|
-
return [2 /*return*/, response
|
|
90
|
-
? response
|
|
91
|
-
: new http_1.DefaultHttpResponse(constants_1.DEFAULT_CLIENT_RESPONSE.content, constants_1.DEFAULT_CLIENT_RESPONSE.options)];
|
|
103
|
+
return [2 /*return*/, response ? response : new http_3.MinimalResponseImpl(constants_1.DEFAULT_CLIENT_RESPONSE_OPTIONS)];
|
|
92
104
|
}
|
|
93
105
|
});
|
|
94
106
|
});
|
|
@@ -115,7 +127,11 @@ var DefaultFirstParty = /** @class */ (function () {
|
|
|
115
127
|
};
|
|
116
128
|
DefaultFirstParty.getDefaultXhrResponse = function (path) {
|
|
117
129
|
var _a = path.endsWith('.gif') ? constants_1.DEFAULT_GIF_RESPONSE : constants_1.DEFAULT_XHR_RESPONSE, content = _a.content, options = _a.options;
|
|
118
|
-
return new
|
|
130
|
+
return new http_3.MinimalResponseImpl({
|
|
131
|
+
body: content,
|
|
132
|
+
status: options.status,
|
|
133
|
+
headers: options.headers,
|
|
134
|
+
});
|
|
119
135
|
};
|
|
120
136
|
DefaultFirstParty.prototype.proxyCaptchaScriptRequest = function (context, prefix) {
|
|
121
137
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -124,15 +140,13 @@ var DefaultFirstParty = /** @class */ (function () {
|
|
|
124
140
|
switch (_a.label) {
|
|
125
141
|
case 0:
|
|
126
142
|
if (!this.config.firstPartyEnabled) {
|
|
127
|
-
return [2 /*return*/, new
|
|
143
|
+
return [2 /*return*/, new http_3.MinimalResponseImpl(constants_1.DEFAULT_CLIENT_RESPONSE_OPTIONS)];
|
|
128
144
|
}
|
|
129
145
|
url = this.getThirdPartyCaptchaScriptUrl(context, prefix);
|
|
130
146
|
return [4 /*yield*/, this.forwardRequest(url, context)];
|
|
131
147
|
case 1:
|
|
132
148
|
response = _a.sent();
|
|
133
|
-
return [2 /*return*/, response
|
|
134
|
-
? response
|
|
135
|
-
: new http_1.DefaultHttpResponse(constants_1.DEFAULT_CLIENT_RESPONSE.content, constants_1.DEFAULT_CLIENT_RESPONSE.options)];
|
|
149
|
+
return [2 /*return*/, response ? response : new http_3.MinimalResponseImpl(constants_1.DEFAULT_CLIENT_RESPONSE_OPTIONS)];
|
|
136
150
|
}
|
|
137
151
|
});
|
|
138
152
|
});
|
|
@@ -140,20 +154,24 @@ var DefaultFirstParty = /** @class */ (function () {
|
|
|
140
154
|
DefaultFirstParty.prototype.forwardRequest = function (url, _a) {
|
|
141
155
|
var requestData = _a.requestData, vid = _a.vid;
|
|
142
156
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
-
var
|
|
144
|
-
return __generator(this, function (
|
|
145
|
-
switch (
|
|
157
|
+
var request, _b, _c, e_1;
|
|
158
|
+
return __generator(this, function (_d) {
|
|
159
|
+
switch (_d.label) {
|
|
146
160
|
case 0:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
_d.trys.push([0, 2, , 3]);
|
|
162
|
+
request = new http_2.OutgoingRequestImpl({
|
|
163
|
+
url: url,
|
|
164
|
+
method: requestData.request.method,
|
|
165
|
+
headers: this.prepareFirstPartyHeaders(url, requestData, vid),
|
|
166
|
+
body: requestData.request.body,
|
|
167
|
+
});
|
|
151
168
|
this.config.logger.debug('forwarding to ' + url);
|
|
152
|
-
|
|
153
|
-
|
|
169
|
+
_c = (_b = minimalResponseUtils).from;
|
|
170
|
+
return [4 /*yield*/, this.httpClient.send(request)];
|
|
171
|
+
case 1: return [2 /*return*/, _c.apply(_b, [_d.sent()])];
|
|
154
172
|
case 2:
|
|
155
|
-
e_1 =
|
|
156
|
-
this.config.logger.debug("failed sending first party request to ".concat(url));
|
|
173
|
+
e_1 = _d.sent();
|
|
174
|
+
this.config.logger.debug("failed sending first party request to ".concat(url, ": ").concat(e_1));
|
|
157
175
|
return [2 /*return*/, null];
|
|
158
176
|
case 3: return [2 /*return*/];
|
|
159
177
|
}
|
|
@@ -161,14 +179,14 @@ var DefaultFirstParty = /** @class */ (function () {
|
|
|
161
179
|
});
|
|
162
180
|
};
|
|
163
181
|
DefaultFirstParty.prototype.prepareFirstPartyHeaders = function (url, requestData, vid) {
|
|
164
|
-
var headers = requestData.headers
|
|
182
|
+
var headers = __assign({}, requestData.headers);
|
|
165
183
|
try {
|
|
166
184
|
headers = (0, utils_1.removeSensitiveHeaders)(headers, this.config.sensitiveHeaders);
|
|
167
185
|
this.setHostHeader(headers, url);
|
|
168
186
|
this.setXffHeader(headers, requestData.ip);
|
|
169
187
|
this.addFirstPartyHeaders(headers, requestData.ip);
|
|
170
188
|
if (vid) {
|
|
171
|
-
headers.
|
|
189
|
+
headers[http_1.COOKIE_HEADER_NAME] = (headers[http_1.COOKIE_HEADER_NAME] || []).concat(["pxvid=".concat(vid)]);
|
|
172
190
|
}
|
|
173
191
|
}
|
|
174
192
|
catch (e) {
|
|
@@ -177,23 +195,15 @@ var DefaultFirstParty = /** @class */ (function () {
|
|
|
177
195
|
return headers;
|
|
178
196
|
};
|
|
179
197
|
DefaultFirstParty.prototype.setHostHeader = function (headers, url) {
|
|
180
|
-
|
|
181
|
-
headers.set(http_1.HOST_HEADER_NAME, host);
|
|
198
|
+
headers[http_1.HOST_HEADER_NAME] = [new URL(url).host];
|
|
182
199
|
};
|
|
183
200
|
DefaultFirstParty.prototype.setXffHeader = function (headers, ip) {
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
if (xffValue) {
|
|
187
|
-
xffValue += ", ".concat(ip);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
xffValue = ip;
|
|
191
|
-
}
|
|
192
|
-
headers.set(http_1.X_FORWARDED_FOR_HEADER_NAME, xffValue);
|
|
201
|
+
var xffValue = headers[http_1.X_FORWARDED_FOR_HEADER_NAME] || [];
|
|
202
|
+
headers[http_1.X_FORWARDED_FOR_HEADER_NAME] = xffValue.concat([ip]);
|
|
193
203
|
};
|
|
194
204
|
DefaultFirstParty.prototype.addFirstPartyHeaders = function (headers, ip) {
|
|
195
|
-
headers
|
|
196
|
-
headers
|
|
205
|
+
headers[constants_1.FIRST_PARTY_HEADER_NAME] = [constants_1.FIRST_PARTY_HEADER_VALUE];
|
|
206
|
+
headers[constants_1.X_PX_ENFORCER_TRUE_IP_HEADER_NAME] = [ip];
|
|
197
207
|
};
|
|
198
208
|
DefaultFirstParty.prototype.getThirdPartySensorScriptUrl = function () {
|
|
199
209
|
return "".concat(this.config.backendClientUrl, "/").concat(this.config.appId, "/main.min.js");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IContext } from '../context';
|
|
2
|
-
import {
|
|
2
|
+
import { IMinimalResponse } from '../http';
|
|
3
3
|
export interface IFirstParty {
|
|
4
4
|
/**
|
|
5
5
|
* @param context - The request context
|
|
6
6
|
* @returns Promise<IHttpResponse<UnreadBodyType>> - If the request is not a first party request, it will return null.
|
|
7
7
|
*/
|
|
8
|
-
handleFirstPartyRequest(context: IContext): Promise<
|
|
8
|
+
handleFirstPartyRequest(context: IContext): Promise<IMinimalResponse>;
|
|
9
9
|
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { ContentType } from '../http';
|
|
2
|
+
import { MinimalResponseOptions } from '../http';
|
|
2
3
|
export declare const EMPTY_GIF: number[];
|
|
3
4
|
export declare const X_PX_ENFORCER_TRUE_IP_HEADER_NAME = "x-px-enforcer-true-ip";
|
|
4
5
|
export declare const FIRST_PARTY_HEADER_NAME = "x-px-first-party";
|
|
5
6
|
export declare const FIRST_PARTY_HEADER_VALUE = "1";
|
|
6
|
-
export declare const
|
|
7
|
-
content: string;
|
|
8
|
-
options: {
|
|
9
|
-
status: number;
|
|
10
|
-
headers: {
|
|
11
|
-
"content-type": ContentType[];
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
7
|
+
export declare const DEFAULT_CLIENT_RESPONSE_OPTIONS: MinimalResponseOptions;
|
|
15
8
|
export declare const DEFAULT_XHR_RESPONSE: {
|
|
16
9
|
content: string;
|
|
17
10
|
options: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b, _c;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DEFAULT_GIF_RESPONSE = exports.DEFAULT_XHR_RESPONSE = exports.
|
|
4
|
+
exports.DEFAULT_GIF_RESPONSE = exports.DEFAULT_XHR_RESPONSE = exports.DEFAULT_CLIENT_RESPONSE_OPTIONS = exports.FIRST_PARTY_HEADER_VALUE = exports.FIRST_PARTY_HEADER_NAME = exports.X_PX_ENFORCER_TRUE_IP_HEADER_NAME = exports.EMPTY_GIF = void 0;
|
|
5
5
|
var http_1 = require("../http");
|
|
6
6
|
exports.EMPTY_GIF = [
|
|
7
7
|
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
|
|
@@ -10,14 +10,12 @@ exports.EMPTY_GIF = [
|
|
|
10
10
|
exports.X_PX_ENFORCER_TRUE_IP_HEADER_NAME = 'x-px-enforcer-true-ip';
|
|
11
11
|
exports.FIRST_PARTY_HEADER_NAME = 'x-px-first-party';
|
|
12
12
|
exports.FIRST_PARTY_HEADER_VALUE = '1';
|
|
13
|
-
exports.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_a),
|
|
20
|
-
},
|
|
13
|
+
exports.DEFAULT_CLIENT_RESPONSE_OPTIONS = {
|
|
14
|
+
body: '',
|
|
15
|
+
status: 200,
|
|
16
|
+
headers: (_a = {},
|
|
17
|
+
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JAVASCRIPT],
|
|
18
|
+
_a),
|
|
21
19
|
};
|
|
22
20
|
exports.DEFAULT_XHR_RESPONSE = {
|
|
23
21
|
content: '{}',
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IContext } from '../context/IContext';
|
|
2
|
+
import { IConfiguration } from '../config';
|
|
3
|
+
import { IGraphQLParser } from './IGraphQLParser';
|
|
4
|
+
export declare class DefaultGraphQLParser implements IGraphQLParser {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly graphqlRoutes;
|
|
7
|
+
private readonly sensitiveOperationTypes;
|
|
8
|
+
private readonly sensitiveOperationNames;
|
|
9
|
+
constructor(config: IConfiguration);
|
|
10
|
+
isGraphQLRequest({ requestData }: IContext): boolean;
|
|
11
|
+
parseGraphQLRequest(context: IContext): Promise<boolean>;
|
|
12
|
+
private getGraphQLOperationsFromBody;
|
|
13
|
+
private parseGraphQLOperations;
|
|
14
|
+
private parseGraphQlOperation;
|
|
15
|
+
private getOperationNameToTypeMap;
|
|
16
|
+
private getGraphQLData;
|
|
17
|
+
private isSensitiveOperation;
|
|
18
|
+
private extractGraphQLVariableNames;
|
|
19
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DefaultGraphQLParser = void 0;
|
|
40
|
+
var GraphQLOperationType_1 = require("./model/GraphQLOperationType");
|
|
41
|
+
var utils_1 = require("../utils");
|
|
42
|
+
var http_1 = require("../http");
|
|
43
|
+
var DefaultGraphQLParser = /** @class */ (function () {
|
|
44
|
+
function DefaultGraphQLParser(config) {
|
|
45
|
+
this.logger = config.logger;
|
|
46
|
+
this.graphqlRoutes = config.graphqlRoutes;
|
|
47
|
+
this.sensitiveOperationNames = config.sensitiveGraphqlOperationNames;
|
|
48
|
+
this.sensitiveOperationTypes = config.sensitiveGraphqlOperationTypes;
|
|
49
|
+
}
|
|
50
|
+
DefaultGraphQLParser.prototype.isGraphQLRequest = function (_a) {
|
|
51
|
+
var requestData = _a.requestData;
|
|
52
|
+
return (requestData.method === http_1.HttpMethod.POST && (0, utils_1.isRouteInPatterns)(requestData.url.pathname, this.graphqlRoutes));
|
|
53
|
+
};
|
|
54
|
+
DefaultGraphQLParser.prototype.parseGraphQLRequest = function (context) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var graphQLOperations, data, e_1;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
_a.trys.push([0, 2, , 3]);
|
|
61
|
+
return [4 /*yield*/, this.getGraphQLOperationsFromBody(context.requestData)];
|
|
62
|
+
case 1:
|
|
63
|
+
graphQLOperations = _a.sent();
|
|
64
|
+
if (!graphQLOperations) {
|
|
65
|
+
this.logger.debug('unable to get graphql operations from request body');
|
|
66
|
+
return [2 /*return*/, false];
|
|
67
|
+
}
|
|
68
|
+
data = this.parseGraphQLOperations(graphQLOperations);
|
|
69
|
+
if (!data || data.length === 0) {
|
|
70
|
+
this.logger.debug('unable to parse graphql operations');
|
|
71
|
+
return [2 /*return*/, false];
|
|
72
|
+
}
|
|
73
|
+
this.logger.debug("".concat(data.length, " graphql operation").concat(data.length === 1 ? '' : 's', " parsed successfully"));
|
|
74
|
+
context.graphqlData = data;
|
|
75
|
+
context.isSensitiveRequest = context.isSensitiveRequest || data.some(function (operation) { return operation.sensitive; });
|
|
76
|
+
return [2 /*return*/, true];
|
|
77
|
+
case 2:
|
|
78
|
+
e_1 = _a.sent();
|
|
79
|
+
this.logger.debug("error parsing graphql request: ".concat(e_1));
|
|
80
|
+
return [2 /*return*/, false];
|
|
81
|
+
case 3: return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
DefaultGraphQLParser.prototype.getGraphQLOperationsFromBody = function (_a) {
|
|
87
|
+
var request = _a.request;
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var body;
|
|
90
|
+
var _this = this;
|
|
91
|
+
return __generator(this, function (_b) {
|
|
92
|
+
switch (_b.label) {
|
|
93
|
+
case 0: return [4 /*yield*/, request.json().catch(function (e) {
|
|
94
|
+
_this.logger.debug("unable to parse string body: ".concat(e));
|
|
95
|
+
return null;
|
|
96
|
+
})];
|
|
97
|
+
case 1:
|
|
98
|
+
body = _b.sent();
|
|
99
|
+
if (!body) {
|
|
100
|
+
return [2 /*return*/, null];
|
|
101
|
+
}
|
|
102
|
+
return [2 /*return*/, Array.isArray(body) ? body : [body]];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
DefaultGraphQLParser.prototype.parseGraphQLOperations = function (operations) {
|
|
108
|
+
var _this = this;
|
|
109
|
+
return operations.map(function (operation) { return _this.parseGraphQlOperation(operation); }).filter(function (x) { return x; });
|
|
110
|
+
};
|
|
111
|
+
DefaultGraphQLParser.prototype.parseGraphQlOperation = function (operation) {
|
|
112
|
+
if (!operation.query || typeof operation.query !== 'string') {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
var operationNameToTypeMap = this.getOperationNameToTypeMap(operation.query);
|
|
116
|
+
if (!operationNameToTypeMap) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return this.getGraphQLData(operationNameToTypeMap, operation);
|
|
120
|
+
};
|
|
121
|
+
DefaultGraphQLParser.prototype.getOperationNameToTypeMap = function (query) {
|
|
122
|
+
var operationTypesString = Object.values(GraphQLOperationType_1.GraphQLOperationType).join('|');
|
|
123
|
+
var pattern = new RegExp("\\s*(".concat(operationTypesString, ")\\s+(\\w+)"), 'gm');
|
|
124
|
+
var match;
|
|
125
|
+
var map = {};
|
|
126
|
+
while ((match = pattern.exec(query)) !== null) {
|
|
127
|
+
var operationType = match[1];
|
|
128
|
+
var operationName = match[2];
|
|
129
|
+
if (map[operationName]) {
|
|
130
|
+
// query contains two operations with the same name which is illegal
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
map[operationName] = operationType;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return map;
|
|
138
|
+
};
|
|
139
|
+
DefaultGraphQLParser.prototype.getGraphQLData = function (operationNameToTypeMap, operation) {
|
|
140
|
+
var name = operation.operationName ||
|
|
141
|
+
(Object.keys(operationNameToTypeMap).length === 1 ? Object.keys(operationNameToTypeMap)[0] : undefined);
|
|
142
|
+
var type = operationNameToTypeMap[name];
|
|
143
|
+
if (!type && /^\s*{/.test(operation.query)) {
|
|
144
|
+
type = GraphQLOperationType_1.GraphQLOperationType.QUERY;
|
|
145
|
+
}
|
|
146
|
+
if (!type) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
var data = { name: name, type: type };
|
|
150
|
+
if (this.isSensitiveOperation(name, type)) {
|
|
151
|
+
data.sensitive = true;
|
|
152
|
+
}
|
|
153
|
+
if (operation.variables && typeof operation.variables === 'object') {
|
|
154
|
+
data.variables = this.extractGraphQLVariableNames(operation.variables);
|
|
155
|
+
}
|
|
156
|
+
return data;
|
|
157
|
+
};
|
|
158
|
+
DefaultGraphQLParser.prototype.isSensitiveOperation = function (operationName, operationType) {
|
|
159
|
+
return (this.sensitiveOperationTypes.some(function (type) { return type === operationType; }) ||
|
|
160
|
+
this.sensitiveOperationNames.some(function (name) { return name === operationName; }));
|
|
161
|
+
};
|
|
162
|
+
DefaultGraphQLParser.prototype.extractGraphQLVariableNames = function (variables) {
|
|
163
|
+
var processVariables = function (variablesObj, prefix) {
|
|
164
|
+
return Object.entries(variablesObj).reduce(function (total, _a) {
|
|
165
|
+
var key = _a[0], value = _a[1];
|
|
166
|
+
if (!value || typeof value !== 'object' || Object.keys(value).length === 0) {
|
|
167
|
+
total.push(prefix + key);
|
|
168
|
+
return total;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return total.concat(processVariables(value, "".concat(prefix).concat(key, ".")));
|
|
172
|
+
}
|
|
173
|
+
}, []);
|
|
174
|
+
};
|
|
175
|
+
return processVariables(variables, '');
|
|
176
|
+
};
|
|
177
|
+
return DefaultGraphQLParser;
|
|
178
|
+
}());
|
|
179
|
+
exports.DefaultGraphQLParser = DefaultGraphQLParser;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { GraphQLOperationType } from './model/GraphQLOperationType';
|
|
2
|
+
export { GraphQLOperation } from './model/GraphQLOperation';
|
|
3
|
+
export { GraphQLData } from './model/GraphQLData';
|
|
4
|
+
export { IGraphQLParser } from './IGraphQLParser';
|
|
5
|
+
export { DefaultGraphQLParser } from './DefaultGraphQLParser';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultGraphQLParser = exports.GraphQLOperationType = void 0;
|
|
4
|
+
var GraphQLOperationType_1 = require("./model/GraphQLOperationType");
|
|
5
|
+
Object.defineProperty(exports, "GraphQLOperationType", { enumerable: true, get: function () { return GraphQLOperationType_1.GraphQLOperationType; } });
|
|
6
|
+
var DefaultGraphQLParser_1 = require("./DefaultGraphQLParser");
|
|
7
|
+
Object.defineProperty(exports, "DefaultGraphQLParser", { enumerable: true, get: function () { return DefaultGraphQLParser_1.DefaultGraphQLParser; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphQLOperationType = void 0;
|
|
4
|
+
var GraphQLOperationType;
|
|
5
|
+
(function (GraphQLOperationType) {
|
|
6
|
+
GraphQLOperationType["QUERY"] = "query";
|
|
7
|
+
GraphQLOperationType["MUTATION"] = "mutation";
|
|
8
|
+
GraphQLOperationType["SUBSCRIPTION"] = "subscription";
|
|
9
|
+
})(GraphQLOperationType = exports.GraphQLOperationType || (exports.GraphQLOperationType = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IMinimalResponse } from '../interfaces';
|
|
2
|
+
import { ReadOnlyHeaders } from '../interfaces';
|
|
3
|
+
export declare type MinimalResponseOptions = {
|
|
4
|
+
status?: number;
|
|
5
|
+
headers?: ReadOnlyHeaders;
|
|
6
|
+
body: any;
|
|
7
|
+
};
|
|
8
|
+
export declare class MinimalResponseImpl implements IMinimalResponse {
|
|
9
|
+
readonly body: any;
|
|
10
|
+
readonly headers: ReadOnlyHeaders;
|
|
11
|
+
readonly status: number;
|
|
12
|
+
constructor(options: MinimalResponseOptions);
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MinimalResponseImpl = void 0;
|
|
4
|
+
var MinimalResponseImpl = /** @class */ (function () {
|
|
5
|
+
function MinimalResponseImpl(options) {
|
|
6
|
+
this.body = options.body;
|
|
7
|
+
this.headers = options.headers || {};
|
|
8
|
+
this.status = options.status || 200;
|
|
9
|
+
}
|
|
10
|
+
return MinimalResponseImpl;
|
|
11
|
+
}());
|
|
12
|
+
exports.MinimalResponseImpl = MinimalResponseImpl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReadOnlyHeaders, HttpMethod, IOutgoingRequest } from '..';
|
|
2
|
+
export declare type OutGoingRequestImplOptions = {
|
|
3
|
+
url: string;
|
|
4
|
+
method?: HttpMethod | string;
|
|
5
|
+
headers?: ReadOnlyHeaders;
|
|
6
|
+
body?: any;
|
|
7
|
+
};
|
|
8
|
+
export declare class OutgoingRequestImpl implements IOutgoingRequest {
|
|
9
|
+
readonly body: any;
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly method: HttpMethod;
|
|
12
|
+
readonly headers: ReadOnlyHeaders;
|
|
13
|
+
constructor(options: OutGoingRequestImplOptions);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutgoingRequestImpl = void 0;
|
|
4
|
+
var __1 = require("..");
|
|
5
|
+
var OutgoingRequestImpl = /** @class */ (function () {
|
|
6
|
+
function OutgoingRequestImpl(options) {
|
|
7
|
+
this.url = options.url;
|
|
8
|
+
this.method = options.method || __1.HttpMethod.GET;
|
|
9
|
+
this.headers = options.headers || {};
|
|
10
|
+
this.body = options.body;
|
|
11
|
+
}
|
|
12
|
+
return OutgoingRequestImpl;
|
|
13
|
+
}());
|
|
14
|
+
exports.OutgoingRequestImpl = OutgoingRequestImpl;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MinimalResponseImpl"), exports);
|
|
18
|
+
__exportStar(require("./OutgoingRequestImpl"), exports);
|
package/lib/http/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export { IHttpClient, HttpSendOptions } from './IHttpClient';
|
|
2
|
-
export { IHttpRequest } from './request/IHttpRequest';
|
|
3
|
-
export { HttpRequestBase, HttpRequestOptions, HttpRequestBaseOptions } from './request/HttpRequestBase';
|
|
4
|
-
export { DefaultHttpRequest } from './request/DefaultHttpRequest';
|
|
5
|
-
export { IHttpResponse } from './response/IHttpResponse';
|
|
6
|
-
export { HttpResponseBase, HttpResponseOptions } from './response/HttpResponseBase';
|
|
7
|
-
export { DefaultHttpResponse } from './response/DefaultHttpResponse';
|
|
8
|
-
export { IBodyReader } from './body_reader/IBodyReader';
|
|
9
|
-
export { StringBodyReader } from './body_reader/StringBodyReader';
|
|
10
1
|
export * from './utils';
|
|
2
|
+
export * from './interfaces';
|
|
3
|
+
export * from './impl';
|
package/lib/http/index.js
CHANGED
|
@@ -14,15 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.StringBodyReader = exports.DefaultHttpResponse = exports.HttpResponseBase = exports.DefaultHttpRequest = exports.HttpRequestBase = void 0;
|
|
18
|
-
var HttpRequestBase_1 = require("./request/HttpRequestBase");
|
|
19
|
-
Object.defineProperty(exports, "HttpRequestBase", { enumerable: true, get: function () { return HttpRequestBase_1.HttpRequestBase; } });
|
|
20
|
-
var DefaultHttpRequest_1 = require("./request/DefaultHttpRequest");
|
|
21
|
-
Object.defineProperty(exports, "DefaultHttpRequest", { enumerable: true, get: function () { return DefaultHttpRequest_1.DefaultHttpRequest; } });
|
|
22
|
-
var HttpResponseBase_1 = require("./response/HttpResponseBase");
|
|
23
|
-
Object.defineProperty(exports, "HttpResponseBase", { enumerable: true, get: function () { return HttpResponseBase_1.HttpResponseBase; } });
|
|
24
|
-
var DefaultHttpResponse_1 = require("./response/DefaultHttpResponse");
|
|
25
|
-
Object.defineProperty(exports, "DefaultHttpResponse", { enumerable: true, get: function () { return DefaultHttpResponse_1.DefaultHttpResponse; } });
|
|
26
|
-
var StringBodyReader_1 = require("./body_reader/StringBodyReader");
|
|
27
|
-
Object.defineProperty(exports, "StringBodyReader", { enumerable: true, get: function () { return StringBodyReader_1.StringBodyReader; } });
|
|
28
17
|
__exportStar(require("./utils"), exports);
|
|
18
|
+
__exportStar(require("./interfaces"), exports);
|
|
19
|
+
__exportStar(require("./impl"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface IBody {
|
|
2
|
+
/**
|
|
3
|
+
* the unread body.
|
|
4
|
+
*/
|
|
5
|
+
readonly body: any;
|
|
6
|
+
/**
|
|
7
|
+
* Converts the body to json
|
|
8
|
+
*/
|
|
9
|
+
json(): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Converts the body to formData
|
|
12
|
+
*/
|
|
13
|
+
formData(): Promise<FormData>;
|
|
14
|
+
/**
|
|
15
|
+
* Converts the body to text
|
|
16
|
+
*/
|
|
17
|
+
text(): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Converts the body to blob
|
|
20
|
+
*/
|
|
21
|
+
blob(): Promise<Blob>;
|
|
22
|
+
/**
|
|
23
|
+
* Converts the body to arrayBuffer
|
|
24
|
+
*/
|
|
25
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
26
|
+
}
|