perimeterx-js-core 0.3.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/utils.js +1 -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/DefaultConfigurations.js +4 -4
- package/lib/context/ContextBase.d.ts +6 -5
- package/lib/context/ContextBase.js +11 -14
- 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 +6 -4
- package/lib/custom_parameters/CustomParametersFunction.d.ts +2 -2
- package/lib/enforcer/EnforcerBase.d.ts +14 -26
- package/lib/enforcer/EnforcerBase.js +13 -12
- package/lib/filter/DefaultFilter.js +1 -1
- package/lib/first_party/DefaultFirstParty.d.ts +3 -2
- package/lib/first_party/DefaultFirstParty.js +44 -34
- 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.js +7 -11
- 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/IIncomingResponse.d.ts +9 -0
- package/lib/http/interfaces/IMinimalResponse.d.ts +6 -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/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 +14 -11
- package/lib/risk_api/S2SErrorHandler.d.ts +2 -2
- package/lib/risk_api/S2SErrorHandler.js +1 -1
- 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_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 +14 -3
- package/package.json +1 -1
- 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 -53
- package/lib/http/utils/HttpHeaders.js +0 -123
- package/lib/utils/base64/DefaultBase64Utils.js +0 -16
- package/lib/utils/hash/DefaultHashUtils.js +0 -19
- /package/lib/http/{IHttpClient.js → interfaces/IBody.js} +0 -0
- /package/lib/http/{body_reader/IBodyReader.js → interfaces/IHttpClient.js} +0 -0
- /package/lib/http/{request/IHttpRequest.js → interfaces/IIncomingRequest.js} +0 -0
- /package/lib/http/{response/IHttpResponse.js → interfaces/IIncomingResponse.js} +0 -0
- /package/lib/http/{utils/HttpBody.js → interfaces/IMinimalResponse.js} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IEnforcer } from './IEnforcer';
|
|
2
2
|
import { IConfiguration } from '../config';
|
|
3
|
-
import { IHttpClient, IHttpRequest, IHttpResponse } from '../http';
|
|
4
3
|
import { IBase64Utils, ICipherUtils, IHashUtils, IIpRangeChecker, IScoreRetriever } from '../utils';
|
|
5
4
|
import { IContext } from '../context';
|
|
6
5
|
import { IFilter } from '../filter';
|
|
@@ -11,6 +10,9 @@ import { IBlockResponseGenerator } from '../block_handler';
|
|
|
11
10
|
import { TokenVersion } from '../risk_token';
|
|
12
11
|
import { IActivityClient } from '../activities';
|
|
13
12
|
import { IGraphQLParser } from '../graphql';
|
|
13
|
+
import { IHttpClient } from '../http';
|
|
14
|
+
import { IOutgoingResponse } from '../http';
|
|
15
|
+
import { IMinimalResponse } from '../http';
|
|
14
16
|
export declare type EnforcerBaseOptions = {
|
|
15
17
|
tokenVersion?: TokenVersion;
|
|
16
18
|
dataEnrichment?: IDataEnrichment;
|
|
@@ -35,7 +37,7 @@ export declare type EnforcerBaseOptions = {
|
|
|
35
37
|
riskApiScoreRetriever: IScoreRetriever;
|
|
36
38
|
activityClient: IActivityClient;
|
|
37
39
|
});
|
|
38
|
-
export declare abstract class EnforcerBase<EnforceArgs extends any[], Req, Res> implements IEnforcer<EnforceArgs, [Req, Res, ...EnforceArgs], Promise<
|
|
40
|
+
export declare abstract class EnforcerBase<EnforceArgs extends any[], Req, Res> implements IEnforcer<EnforceArgs, [Req, Res, ...EnforceArgs], Promise<null | Res>, Promise<void>> {
|
|
39
41
|
protected config: IConfiguration;
|
|
40
42
|
protected filter: IFilter;
|
|
41
43
|
protected dataEnrichment: IDataEnrichment;
|
|
@@ -69,38 +71,24 @@ export declare abstract class EnforcerBase<EnforceArgs extends any[], Req, Res>
|
|
|
69
71
|
* @protected
|
|
70
72
|
*/
|
|
71
73
|
protected abstract retrieveContext(req: Req, res: Res, ...args: EnforceArgs): IContext | null;
|
|
72
|
-
/**
|
|
73
|
-
* Converts the IHttpRequest object into the Req object.
|
|
74
|
-
* @param httpRequest - The IHttpRequest object.
|
|
75
|
-
* @returns Promise<Req> - A Promise resolving to Req.
|
|
76
|
-
* @protected
|
|
77
|
-
*/
|
|
78
|
-
protected abstract convertToReq(httpRequest: IHttpRequest): Promise<Req>;
|
|
79
74
|
/**
|
|
80
75
|
* Converts the IHttpResponse object into the Res object.
|
|
81
76
|
* @param httpResponse - The IHttpResponse object.
|
|
82
77
|
* @returns Promise<Res> - A Promise resolving to Res.
|
|
83
78
|
* @protected
|
|
84
79
|
*/
|
|
85
|
-
protected abstract convertToRes(httpResponse:
|
|
86
|
-
/**
|
|
87
|
-
* Converts the Req object into the IHttpRequest interface.
|
|
88
|
-
* @param req - The Req object.
|
|
89
|
-
* @returns Promise<IHttpRequest> - A Promise resolving to IHttpRequest.
|
|
90
|
-
* @protected
|
|
91
|
-
*/
|
|
92
|
-
protected abstract convertToHttpRequest(req: Req): Promise<IHttpRequest>;
|
|
80
|
+
protected abstract convertToRes(httpResponse: IMinimalResponse): Promise<Res>;
|
|
93
81
|
/**
|
|
94
82
|
* Converts the Res object into the IHttpResponse interface.
|
|
95
83
|
* @param res - The Res object.
|
|
96
84
|
* @returns Promise<IHttpResponse> - A Promise resolving to IHttpResponse.
|
|
97
85
|
* @protected
|
|
98
86
|
*/
|
|
99
|
-
protected abstract convertToHttpResponse(res: Res): Promise<
|
|
87
|
+
protected abstract convertToHttpResponse(res: Res): Promise<IOutgoingResponse>;
|
|
100
88
|
/**
|
|
101
89
|
* The EnforcerBase constructor.
|
|
102
90
|
* @param config - The enforcer configuration.
|
|
103
|
-
* @param options - An
|
|
91
|
+
* @param options - An MinimalResponseOptions object that allows for overriding any functional building blocks in the enforcer.
|
|
104
92
|
* @protected
|
|
105
93
|
*/
|
|
106
94
|
protected constructor(config: IConfiguration, options: EnforcerBaseOptions);
|
|
@@ -109,16 +97,16 @@ export declare abstract class EnforcerBase<EnforceArgs extends any[], Req, Res>
|
|
|
109
97
|
* @param args - The EnforceArgs required to enforce the incoming request.
|
|
110
98
|
* @returns Promise<Req|Res> - A Promise resolving to a either Req or Res depending on the action that should be taken.
|
|
111
99
|
*/
|
|
112
|
-
enforce(...args: EnforceArgs): Promise<
|
|
100
|
+
enforce(...args: EnforceArgs): Promise<Res | null>;
|
|
113
101
|
/**
|
|
114
102
|
* Performs all enforcer functionality on the incoming request context.
|
|
115
103
|
* @param args - The EnforceArgs required to enforce the incoming request.
|
|
116
104
|
* @returns Promise<Req|Res> - A Promise resolving to a either Req or Res depending on the action that should be taken.
|
|
117
105
|
* @protected
|
|
118
106
|
*/
|
|
119
|
-
protected doEnforce(...args: EnforceArgs): Promise<
|
|
107
|
+
protected doEnforce(...args: EnforceArgs): Promise<Res | null>;
|
|
120
108
|
protected createContext(...args: EnforceArgs): Promise<IContext>;
|
|
121
|
-
protected handleFirstParty(context: IContext): Promise<
|
|
109
|
+
protected handleFirstParty(context: IContext): Promise<IMinimalResponse>;
|
|
122
110
|
protected handleFilter(context: IContext): boolean;
|
|
123
111
|
protected handleCompleteContextInitialization(context: IContext): Promise<void>;
|
|
124
112
|
protected handleGraphQL(context: IContext): Promise<void>;
|
|
@@ -128,7 +116,7 @@ export declare abstract class EnforcerBase<EnforceArgs extends any[], Req, Res>
|
|
|
128
116
|
protected handleCookieRetrieverIfNeeded(context: IContext): Promise<void>;
|
|
129
117
|
protected handleRiskApiIfNeeded(context: IContext): Promise<void>;
|
|
130
118
|
protected handleAdditionalActivityHandler(context: IContext): Promise<void>;
|
|
131
|
-
protected handleBlockResponse(context: IContext): Promise<null |
|
|
119
|
+
protected handleBlockResponse(context: IContext): Promise<null | IMinimalResponse>;
|
|
132
120
|
protected handleSendActivities(context: IContext): Promise<void>;
|
|
133
121
|
/**
|
|
134
122
|
* Performs all required functionality after an origin response has been received.
|
|
@@ -138,7 +126,7 @@ export declare abstract class EnforcerBase<EnforceArgs extends any[], Req, Res>
|
|
|
138
126
|
* @returns Promise<Res> - A modified response
|
|
139
127
|
* @protected
|
|
140
128
|
*/
|
|
141
|
-
postEnforce(req: Req, res: Res, ...args: EnforceArgs): Promise<
|
|
142
|
-
protected setResponseData(context: IContext, response:
|
|
143
|
-
protected handlePxhd(context: IContext, response:
|
|
129
|
+
postEnforce(req: Req, res: Res, ...args: EnforceArgs): Promise<void>;
|
|
130
|
+
protected setResponseData(context: IContext, response: IOutgoingResponse): Promise<void>;
|
|
131
|
+
protected handlePxhd(context: IContext, response: IOutgoingResponse): Promise<void>;
|
|
144
132
|
}
|
|
@@ -63,13 +63,13 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
63
63
|
/**
|
|
64
64
|
* The EnforcerBase constructor.
|
|
65
65
|
* @param config - The enforcer configuration.
|
|
66
|
-
* @param options - An
|
|
66
|
+
* @param options - An MinimalResponseOptions object that allows for overriding any functional building blocks in the enforcer.
|
|
67
67
|
* @protected
|
|
68
68
|
*/
|
|
69
69
|
function EnforcerBase(config, options) {
|
|
70
70
|
this.config = config;
|
|
71
|
-
var base64Utils = options.base64Utils || new utils_1.
|
|
72
|
-
var hashUtils = options.hashUtils || new utils_1.
|
|
71
|
+
var base64Utils = options.base64Utils || new utils_1.JSBase64Base64Utils();
|
|
72
|
+
var hashUtils = options.hashUtils || new utils_1.CryptoJSHmacUtils();
|
|
73
73
|
this.filter = options.filter || new filter_1.DefaultFilter(this.config, options === null || options === void 0 ? void 0 : options.ipRangeChecker);
|
|
74
74
|
this.cookieScoreRetriever = options.cookieScoreRetriever || new risk_token_1.RiskTokenScoreRetriever(this.config);
|
|
75
75
|
this.blockGenerator = options.blockGenerator || new block_handler_1.DefaultBlockResponseGenerator(this.config, base64Utils);
|
|
@@ -109,7 +109,7 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
109
109
|
_a.trys.push([0, 2, , 3]);
|
|
110
110
|
if (!this.config.moduleEnabled) {
|
|
111
111
|
this.config.logger.debug('module is disabled, will not enforce');
|
|
112
|
-
return [2 /*return*/,
|
|
112
|
+
return [2 /*return*/, null];
|
|
113
113
|
}
|
|
114
114
|
this.config.logger.debug('module is enabled, continuing with enforcement');
|
|
115
115
|
return [4 /*yield*/, this.doEnforce.apply(this, args)];
|
|
@@ -117,7 +117,7 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
117
117
|
case 2:
|
|
118
118
|
e_1 = _a.sent();
|
|
119
119
|
this.config.logger.error("caught error in enforce - ".concat(e_1));
|
|
120
|
-
return [2 /*return*/,
|
|
120
|
+
return [2 /*return*/, null];
|
|
121
121
|
case 3: return [2 /*return*/];
|
|
122
122
|
}
|
|
123
123
|
});
|
|
@@ -150,7 +150,7 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
150
150
|
}
|
|
151
151
|
if (this.handleFilter(context)) {
|
|
152
152
|
this.config.logger.debug("filtering due to ".concat(context.filterReason));
|
|
153
|
-
return [2 /*return*/,
|
|
153
|
+
return [2 /*return*/, null];
|
|
154
154
|
}
|
|
155
155
|
return [4 /*yield*/, this.handleCompleteContextInitialization(context)];
|
|
156
156
|
case 3:
|
|
@@ -185,7 +185,7 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
185
185
|
return [2 /*return*/, this.convertToRes(httpResponse)];
|
|
186
186
|
}
|
|
187
187
|
this.config.logger.debug("passing request due to ".concat(context.passReason || 'monitor mode'));
|
|
188
|
-
return [2 /*return*/,
|
|
188
|
+
return [2 /*return*/, null];
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
});
|
|
@@ -381,15 +381,14 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
381
381
|
_a.sent();
|
|
382
382
|
return [4 /*yield*/, this.handlePxhd(context_1, response)];
|
|
383
383
|
case 5:
|
|
384
|
-
|
|
384
|
+
_a.sent();
|
|
385
385
|
_a.label = 6;
|
|
386
386
|
case 6: return [3 /*break*/, 8];
|
|
387
387
|
case 7:
|
|
388
388
|
e_2 = _a.sent();
|
|
389
389
|
this.config.logger.error("error in post enforce - ".concat(e_2));
|
|
390
390
|
return [3 /*break*/, 8];
|
|
391
|
-
case 8: return [
|
|
392
|
-
case 9: return [2 /*return*/, _a.sent()];
|
|
391
|
+
case 8: return [2 /*return*/];
|
|
393
392
|
}
|
|
394
393
|
});
|
|
395
394
|
});
|
|
@@ -397,7 +396,9 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
397
396
|
EnforcerBase.prototype.setResponseData = function (context, response) {
|
|
398
397
|
return __awaiter(this, void 0, void 0, function () {
|
|
399
398
|
return __generator(this, function (_a) {
|
|
400
|
-
|
|
399
|
+
if (response.status) {
|
|
400
|
+
context.responseData.status = response.status;
|
|
401
|
+
}
|
|
401
402
|
return [2 /*return*/];
|
|
402
403
|
});
|
|
403
404
|
});
|
|
@@ -405,7 +406,7 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
405
406
|
EnforcerBase.prototype.handlePxhd = function (context, response) {
|
|
406
407
|
return __awaiter(this, void 0, void 0, function () {
|
|
407
408
|
return __generator(this, function (_a) {
|
|
408
|
-
return [2 /*return*/, pxhd_1.PXHDUtils.
|
|
409
|
+
return [2 /*return*/, pxhd_1.PXHDUtils.addPxhdToOutgoingResponse(context, response)];
|
|
409
410
|
});
|
|
410
411
|
});
|
|
411
412
|
};
|
|
@@ -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,19 +154,23 @@ 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 =
|
|
173
|
+
e_1 = _d.sent();
|
|
156
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*/];
|
|
@@ -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: '{}',
|
|
@@ -37,9 +37,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.DefaultGraphQLParser = void 0;
|
|
40
|
-
var http_1 = require("../http");
|
|
41
40
|
var GraphQLOperationType_1 = require("./model/GraphQLOperationType");
|
|
42
41
|
var utils_1 = require("../utils");
|
|
42
|
+
var http_1 = require("../http");
|
|
43
43
|
var DefaultGraphQLParser = /** @class */ (function () {
|
|
44
44
|
function DefaultGraphQLParser(config) {
|
|
45
45
|
this.logger = config.logger;
|
|
@@ -87,20 +87,16 @@ var DefaultGraphQLParser = /** @class */ (function () {
|
|
|
87
87
|
var request = _a.request;
|
|
88
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
89
|
var body;
|
|
90
|
+
var _this = this;
|
|
90
91
|
return __generator(this, function (_b) {
|
|
91
92
|
switch (_b.label) {
|
|
92
|
-
case 0: return [4 /*yield*/, request.
|
|
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
|
+
})];
|
|
93
97
|
case 1:
|
|
94
98
|
body = _b.sent();
|
|
95
|
-
if (
|
|
96
|
-
try {
|
|
97
|
-
body = JSON.parse(body);
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
this.logger.debug("unable to parse string body: ".concat(e));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!body || typeof body !== 'object') {
|
|
99
|
+
if (!body) {
|
|
104
100
|
return [2 /*return*/, null];
|
|
105
101
|
}
|
|
106
102
|
return [2 /*return*/, Array.isArray(body) ? body : [body]];
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IOutgoingRequest } from './IOutgoingRequest';
|
|
2
|
+
import { IIncomingResponse } from './IIncomingResponse';
|
|
3
|
+
export declare type HttpSendOptions = {
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
};
|
|
6
|
+
export interface IHttpClient {
|
|
7
|
+
send(request: IOutgoingRequest, options?: HttpSendOptions): Promise<IIncomingResponse>;
|
|
8
|
+
}
|