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,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DefaultHttpResponse = void 0;
|
|
19
|
-
var HttpResponseBase_1 = require("./HttpResponseBase");
|
|
20
|
-
var StringBodyReader_1 = require("../body_reader/StringBodyReader");
|
|
21
|
-
var DefaultHttpResponse = /** @class */ (function (_super) {
|
|
22
|
-
__extends(DefaultHttpResponse, _super);
|
|
23
|
-
function DefaultHttpResponse(body, options) {
|
|
24
|
-
if (body === void 0) { body = ''; }
|
|
25
|
-
return _super.call(this, new StringBodyReader_1.StringBodyReader(body), options) || this;
|
|
26
|
-
}
|
|
27
|
-
DefaultHttpResponse.prototype.getUnderlyingResponse = function () {
|
|
28
|
-
return this;
|
|
29
|
-
};
|
|
30
|
-
return DefaultHttpResponse;
|
|
31
|
-
}(HttpResponseBase_1.HttpResponseBase));
|
|
32
|
-
exports.DefaultHttpResponse = DefaultHttpResponse;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HttpHeaders, HttpHeadersInit, HttpBody } from '../utils';
|
|
2
|
-
import { IBodyReader } from '../body_reader/IBodyReader';
|
|
3
|
-
import { IHttpResponse } from './IHttpResponse';
|
|
4
|
-
export declare type HttpResponseOptions = {
|
|
5
|
-
status?: number;
|
|
6
|
-
headers?: HttpHeaders | HttpHeadersInit;
|
|
7
|
-
};
|
|
8
|
-
export declare abstract class HttpResponseBase<UnreadBodyType, Res> implements IHttpResponse<UnreadBodyType, Res> {
|
|
9
|
-
headers: HttpHeaders;
|
|
10
|
-
status: number;
|
|
11
|
-
protected httpBody: HttpBody;
|
|
12
|
-
protected readonly bodyReader: IBodyReader<UnreadBodyType>;
|
|
13
|
-
abstract getUnderlyingResponse(): Res;
|
|
14
|
-
protected constructor(bodyReader: IBodyReader<UnreadBodyType>, options?: HttpResponseOptions);
|
|
15
|
-
get body(): UnreadBodyType | string;
|
|
16
|
-
readBody(): Promise<HttpBody>;
|
|
17
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
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.HttpResponseBase = void 0;
|
|
40
|
-
var utils_1 = require("../utils");
|
|
41
|
-
var HttpResponseBase = /** @class */ (function () {
|
|
42
|
-
function HttpResponseBase(bodyReader, options) {
|
|
43
|
-
this.bodyReader = bodyReader;
|
|
44
|
-
this.status = (options === null || options === void 0 ? void 0 : options.status) || 200;
|
|
45
|
-
this.headers = (options === null || options === void 0 ? void 0 : options.headers) instanceof utils_1.HttpHeaders ? options === null || options === void 0 ? void 0 : options.headers : new utils_1.HttpHeaders(options === null || options === void 0 ? void 0 : options.headers);
|
|
46
|
-
}
|
|
47
|
-
Object.defineProperty(HttpResponseBase.prototype, "body", {
|
|
48
|
-
get: function () {
|
|
49
|
-
return this.bodyReader.body;
|
|
50
|
-
},
|
|
51
|
-
enumerable: false,
|
|
52
|
-
configurable: true
|
|
53
|
-
});
|
|
54
|
-
HttpResponseBase.prototype.readBody = function () {
|
|
55
|
-
var _a;
|
|
56
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var _b;
|
|
58
|
-
return __generator(this, function (_c) {
|
|
59
|
-
switch (_c.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
if (typeof this.httpBody !== 'undefined') {
|
|
62
|
-
return [2 /*return*/, this.httpBody];
|
|
63
|
-
}
|
|
64
|
-
_b = this;
|
|
65
|
-
return [4 /*yield*/, this.bodyReader.readBody((_a = this.headers.get(utils_1.CONTENT_TYPE_HEADER_NAME)) === null || _a === void 0 ? void 0 : _a[0])];
|
|
66
|
-
case 1:
|
|
67
|
-
_b.httpBody = _c.sent();
|
|
68
|
-
return [2 /*return*/, this.httpBody];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
return HttpResponseBase;
|
|
74
|
-
}());
|
|
75
|
-
exports.HttpResponseBase = HttpResponseBase;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { HttpHeaders, HttpBody } from '../utils';
|
|
2
|
-
export interface IHttpResponse<UnreadBodyType = unknown, Res = unknown> {
|
|
3
|
-
/**
|
|
4
|
-
* The numerical status code of the response
|
|
5
|
-
* e.g., 200, 404, etc.
|
|
6
|
-
*/
|
|
7
|
-
status: number;
|
|
8
|
-
/**
|
|
9
|
-
* An object representing the HTTP headers. For more information, see the documentation for the HttpHeaders class.
|
|
10
|
-
*/
|
|
11
|
-
headers: HttpHeaders;
|
|
12
|
-
/**
|
|
13
|
-
* A representation of the response body. If the response does not have a body, it should be undefined.
|
|
14
|
-
* This is called when the response body needs to be accessed or used to reconstruct a new response, but not read.
|
|
15
|
-
*/
|
|
16
|
-
readonly body: UnreadBodyType | string;
|
|
17
|
-
/**
|
|
18
|
-
* A string or object representation of the response body if it needs to be used in the enforcer. If read, the call to
|
|
19
|
-
* HttpResponse.body should return the saved string value so as not to consume the same ReadableStream twice.
|
|
20
|
-
*/
|
|
21
|
-
readBody(): Promise<HttpBody>;
|
|
22
|
-
/**
|
|
23
|
-
* The underlying, platform-specific implementation of the response object.
|
|
24
|
-
*/
|
|
25
|
-
getUnderlyingResponse(): Res;
|
|
26
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export declare type HttpHeadersInit = Record<string, string[]>;
|
|
2
|
-
export declare class HttpHeaders {
|
|
3
|
-
private readonly headers;
|
|
4
|
-
static from(headers: Headers): HttpHeaders;
|
|
5
|
-
/**
|
|
6
|
-
* Constructs a new instance of the HttpHeaders class.
|
|
7
|
-
* @param init - Optional header names and values with which to initialize the HttpHeaders instance.
|
|
8
|
-
*/
|
|
9
|
-
constructor(init?: HttpHeadersInit);
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves the values associated with the provided header name. If no header exists, it returns undefined.
|
|
12
|
-
* @param name - The case-insensitive header name.
|
|
13
|
-
* @returns values - An array of strings representing the header values associated with the provided header name.
|
|
14
|
-
*/
|
|
15
|
-
get(name: string): readonly string[] | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Sets a header with the provided name and value(s). If no header by that name exists, one will be added.
|
|
18
|
-
* If the header name already exists, the provided values will override all pre-existing values.
|
|
19
|
-
* @param name - The case-insensitive header name.
|
|
20
|
-
* @param values - The header values to be associated with the provided header name.
|
|
21
|
-
*/
|
|
22
|
-
set(name: string, ...values: readonly string[]): void;
|
|
23
|
-
/**
|
|
24
|
-
* Adds the value(s) to the header with the given name. If no header by that name exists, one will be added.
|
|
25
|
-
* If the header name already exists, the provided values will be added to the end of the list of existing values.
|
|
26
|
-
* @param name - The case-insensitive header name.
|
|
27
|
-
* @param values - The header values to be associated with the provided header name.
|
|
28
|
-
*/
|
|
29
|
-
append(name: string, ...values: readonly string[]): void;
|
|
30
|
-
/**
|
|
31
|
-
* Deletes a header and all its associated values. If no header by that name exists, no action is taken.
|
|
32
|
-
* @param name - The case-insensitive header name.
|
|
33
|
-
*/
|
|
34
|
-
delete(name: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Returns a deep copy of the current HttpHeaders instance.
|
|
37
|
-
* @returns HttpHeaders - A new instance of the HttpHeaders class with the same header names and values as the original.
|
|
38
|
-
*/
|
|
39
|
-
copy(): HttpHeaders;
|
|
40
|
-
/**
|
|
41
|
-
* Returns an object representation of the HttpHeaders instance.
|
|
42
|
-
* @returns object - An object representing the current state of the HttpHeaders instance. The keys are the header
|
|
43
|
-
* names (all lowercase), and the values are arrays of all the associated header values.
|
|
44
|
-
*/
|
|
45
|
-
toObject(joinDelimiter?: string): Record<string, string | string[]>;
|
|
46
|
-
/**
|
|
47
|
-
* Iterates through all headers and applies a callback function to each one.
|
|
48
|
-
* @param callbackFn - The callback function to be applied on every header.
|
|
49
|
-
*/
|
|
50
|
-
forEach(callbackFn: (values: readonly string[], name: string) => void): void;
|
|
51
|
-
private toKey;
|
|
52
|
-
entries(delimiter?: string): [string, string][];
|
|
53
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HttpHeaders = void 0;
|
|
13
|
-
var HttpHeaders = /** @class */ (function () {
|
|
14
|
-
/**
|
|
15
|
-
* Constructs a new instance of the HttpHeaders class.
|
|
16
|
-
* @param init - Optional header names and values with which to initialize the HttpHeaders instance.
|
|
17
|
-
*/
|
|
18
|
-
function HttpHeaders(init) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
this.headers = init ? new Map(Object.keys(init).map(function (name) { return [_this.toKey(name), init[name]]; })) : new Map();
|
|
21
|
-
}
|
|
22
|
-
HttpHeaders.from = function (headers) {
|
|
23
|
-
var ret = new HttpHeaders();
|
|
24
|
-
headers.forEach(function (value, key) {
|
|
25
|
-
ret.append(key, value);
|
|
26
|
-
});
|
|
27
|
-
return ret;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Retrieves the values associated with the provided header name. If no header exists, it returns undefined.
|
|
31
|
-
* @param name - The case-insensitive header name.
|
|
32
|
-
* @returns values - An array of strings representing the header values associated with the provided header name.
|
|
33
|
-
*/
|
|
34
|
-
HttpHeaders.prototype.get = function (name) {
|
|
35
|
-
return this.headers.get(this.toKey(name));
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Sets a header with the provided name and value(s). If no header by that name exists, one will be added.
|
|
39
|
-
* If the header name already exists, the provided values will override all pre-existing values.
|
|
40
|
-
* @param name - The case-insensitive header name.
|
|
41
|
-
* @param values - The header values to be associated with the provided header name.
|
|
42
|
-
*/
|
|
43
|
-
HttpHeaders.prototype.set = function (name) {
|
|
44
|
-
var values = [];
|
|
45
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
46
|
-
values[_i - 1] = arguments[_i];
|
|
47
|
-
}
|
|
48
|
-
if ((values === null || values === void 0 ? void 0 : values.length) > 0) {
|
|
49
|
-
this.headers.set(this.toKey(name), values);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Adds the value(s) to the header with the given name. If no header by that name exists, one will be added.
|
|
54
|
-
* If the header name already exists, the provided values will be added to the end of the list of existing values.
|
|
55
|
-
* @param name - The case-insensitive header name.
|
|
56
|
-
* @param values - The header values to be associated with the provided header name.
|
|
57
|
-
*/
|
|
58
|
-
HttpHeaders.prototype.append = function (name) {
|
|
59
|
-
var values = [];
|
|
60
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
61
|
-
values[_i - 1] = arguments[_i];
|
|
62
|
-
}
|
|
63
|
-
var existingValues = this.get(name);
|
|
64
|
-
if (existingValues) {
|
|
65
|
-
this.set.apply(this, __spreadArray([name], existingValues.concat(values), false));
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.set.apply(this, __spreadArray([name], values, false));
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Deletes a header and all its associated values. If no header by that name exists, no action is taken.
|
|
73
|
-
* @param name - The case-insensitive header name.
|
|
74
|
-
*/
|
|
75
|
-
HttpHeaders.prototype.delete = function (name) {
|
|
76
|
-
this.headers.delete(this.toKey(name));
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Returns a deep copy of the current HttpHeaders instance.
|
|
80
|
-
* @returns HttpHeaders - A new instance of the HttpHeaders class with the same header names and values as the original.
|
|
81
|
-
*/
|
|
82
|
-
HttpHeaders.prototype.copy = function () {
|
|
83
|
-
var copy = new HttpHeaders();
|
|
84
|
-
this.forEach(function (values, name) {
|
|
85
|
-
copy.set.apply(copy, __spreadArray([name], values, false));
|
|
86
|
-
});
|
|
87
|
-
return copy;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Returns an object representation of the HttpHeaders instance.
|
|
91
|
-
* @returns object - An object representing the current state of the HttpHeaders instance. The keys are the header
|
|
92
|
-
* names (all lowercase), and the values are arrays of all the associated header values.
|
|
93
|
-
*/
|
|
94
|
-
HttpHeaders.prototype.toObject = function (joinDelimiter) {
|
|
95
|
-
var obj = {};
|
|
96
|
-
this.forEach(function (values, name) {
|
|
97
|
-
obj[name] = joinDelimiter ? values.join(joinDelimiter) : __spreadArray([], values, true);
|
|
98
|
-
});
|
|
99
|
-
return obj;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Iterates through all headers and applies a callback function to each one.
|
|
103
|
-
* @param callbackFn - The callback function to be applied on every header.
|
|
104
|
-
*/
|
|
105
|
-
HttpHeaders.prototype.forEach = function (callbackFn) {
|
|
106
|
-
this.headers.forEach(function (values, name) { return callbackFn(values, name); });
|
|
107
|
-
};
|
|
108
|
-
HttpHeaders.prototype.toKey = function (name) {
|
|
109
|
-
return name.toLowerCase();
|
|
110
|
-
};
|
|
111
|
-
HttpHeaders.prototype.entries = function (delimiter) {
|
|
112
|
-
if (delimiter === void 0) { delimiter = ','; }
|
|
113
|
-
var ret = [];
|
|
114
|
-
this.headers.forEach(function (values, headerName) {
|
|
115
|
-
if (values === null || values === void 0 ? void 0 : values.length) {
|
|
116
|
-
ret.push([headerName, values.join(delimiter)]);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return ret;
|
|
120
|
-
};
|
|
121
|
-
return HttpHeaders;
|
|
122
|
-
}());
|
|
123
|
-
exports.HttpHeaders = HttpHeaders;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultBase64Utils = void 0;
|
|
4
|
-
var js_base64_1 = require("js-base64");
|
|
5
|
-
var DefaultBase64Utils = /** @class */ (function () {
|
|
6
|
-
function DefaultBase64Utils() {
|
|
7
|
-
}
|
|
8
|
-
DefaultBase64Utils.prototype.base64Encode = function (stringToEncode) {
|
|
9
|
-
return (0, js_base64_1.encode)(stringToEncode);
|
|
10
|
-
};
|
|
11
|
-
DefaultBase64Utils.prototype.base64Decode = function (stringToDecode) {
|
|
12
|
-
return (0, js_base64_1.decode)(stringToDecode);
|
|
13
|
-
};
|
|
14
|
-
return DefaultBase64Utils;
|
|
15
|
-
}());
|
|
16
|
-
exports.DefaultBase64Utils = DefaultBase64Utils;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultHashUtils = void 0;
|
|
4
|
-
var crypto_js_1 = require("crypto-js");
|
|
5
|
-
var Algorithm_1 = require("../Algorithm");
|
|
6
|
-
var DefaultHashUtils = /** @class */ (function () {
|
|
7
|
-
function DefaultHashUtils() {
|
|
8
|
-
}
|
|
9
|
-
DefaultHashUtils.prototype.createHmac = function (algo, payload, secret) {
|
|
10
|
-
switch (algo) {
|
|
11
|
-
case Algorithm_1.Algorithm.SHA256:
|
|
12
|
-
default:
|
|
13
|
-
var payloadHmac = (0, crypto_js_1.HmacSHA256)(payload, secret);
|
|
14
|
-
return crypto_js_1.enc.Hex.stringify(payloadHmac);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return DefaultHashUtils;
|
|
18
|
-
}());
|
|
19
|
-
exports.DefaultHashUtils = DefaultHashUtils;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|