perimeterx-js-core 0.15.2 → 0.16.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/lib/cjs/activities/HttpActivityClient.js +4 -4
- package/lib/cjs/activities/HttpBatchedActivityClient.js +7 -7
- package/lib/cjs/additional_activity_handler/AdditionalActivityHandlerUtils.js +2 -2
- package/lib/cjs/config/ConfigurationBase.js +4 -1
- package/lib/cjs/config/remote_config/DefaultRemoteConfigUpdater.js +25 -30
- package/lib/cjs/config/remote_config/RemoteConfigUtils.js +14 -0
- package/lib/cjs/config/remote_config/index.js +1 -0
- package/lib/cjs/context/DefaultContext.js +18 -7
- package/lib/cjs/custom_parameters/CustomParametersUtils.js +1 -1
- package/lib/cjs/enforcer/EnforcerBase.js +40 -31
- package/lib/cjs/graphql/DefaultGraphQLParser.js +20 -22
- package/lib/cjs/impl/url/DefaultUrlUtils.js +7 -1
- package/lib/cjs/logger/DefaultLogger.js +2 -2
- package/lib/cjs/logger/HttpLogServiceClient.js +32 -27
- package/lib/cjs/logger/LoggerBase.js +5 -1
- package/lib/cjs/monitored_request/MonitoredRequestUtils.js +8 -8
- package/lib/cjs/phase/impl/CreateBlockResponsePhase.js +2 -2
- package/lib/cjs/phase/impl/DecideActionPhase.js +3 -4
- package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +3 -2
- package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +1 -1
- package/lib/cjs/phase/impl/FirstPartyPhase.js +4 -4
- package/lib/cjs/phase/impl/RiskApiPhase.js +1 -1
- package/lib/cjs/phase/impl/SendLogsPhase.js +2 -2
- package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +0 -1
- package/lib/cjs/products/account_defender/AccountDefender.js +9 -8
- package/lib/cjs/products/bot_defender/filter/DefaultBotDefenderFilter.js +10 -10
- package/lib/cjs/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +17 -17
- package/lib/cjs/products/credential_intelligence/endpoint/CredentialEndpoint.js +8 -9
- package/lib/cjs/products/credential_intelligence/endpoint/CredentialEndpointManager.js +13 -15
- package/lib/cjs/pxde/DefaultDataEnrichment.js +11 -11
- package/lib/cjs/risk_api/client/PostRiskApiClientBase.js +5 -5
- package/lib/cjs/risk_token/parser/TokenParserBase.js +12 -13
- package/lib/cjs/risk_token/token/v2/DefaultTokenV2.js +5 -5
- package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +11 -11
- package/lib/cjs/sensitive_request/SensitiveRequestUtils.js +4 -4
- package/lib/cjs/telemetry/DefaultTelemetry.js +7 -7
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/cjs/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +7 -7
- package/lib/esm/activities/HttpActivityClient.js +4 -4
- package/lib/esm/activities/HttpBatchedActivityClient.js +7 -7
- package/lib/esm/additional_activity_handler/AdditionalActivityHandlerUtils.js +2 -2
- package/lib/esm/config/ConfigurationBase.js +4 -1
- package/lib/esm/config/remote_config/DefaultRemoteConfigUpdater.js +21 -23
- package/lib/esm/config/remote_config/RemoteConfigUtils.js +9 -0
- package/lib/esm/config/remote_config/index.js +1 -0
- package/lib/esm/context/DefaultContext.js +18 -8
- package/lib/esm/custom_parameters/CustomParametersUtils.js +1 -1
- package/lib/esm/enforcer/EnforcerBase.js +18 -7
- package/lib/esm/graphql/DefaultGraphQLParser.js +9 -10
- package/lib/esm/impl/url/DefaultUrlUtils.js +7 -1
- package/lib/esm/logger/DefaultLogger.js +2 -2
- package/lib/esm/logger/HttpLogServiceClient.js +25 -27
- package/lib/esm/logger/LoggerBase.js +6 -1
- package/lib/esm/monitored_request/MonitoredRequestUtils.js +8 -8
- package/lib/esm/phase/impl/CreateBlockResponsePhase.js +2 -2
- package/lib/esm/phase/impl/DecideActionPhase.js +2 -6
- package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +4 -2
- package/lib/esm/phase/impl/EnrichContextFromResponsePhase.js +1 -1
- package/lib/esm/phase/impl/FirstPartyPhase.js +4 -4
- package/lib/esm/phase/impl/RiskApiPhase.js +1 -1
- package/lib/esm/phase/impl/SendLogsPhase.js +2 -2
- package/lib/esm/phase/impl/UpdateRemoteConfigPhase.js +0 -1
- package/lib/esm/products/account_defender/AccountDefender.js +9 -8
- package/lib/esm/products/bot_defender/filter/DefaultBotDefenderFilter.js +8 -8
- package/lib/esm/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +16 -15
- package/lib/esm/products/credential_intelligence/endpoint/CredentialEndpoint.js +8 -10
- package/lib/esm/products/credential_intelligence/endpoint/CredentialEndpointManager.js +5 -5
- package/lib/esm/pxde/DefaultDataEnrichment.js +11 -11
- package/lib/esm/risk_api/client/PostRiskApiClientBase.js +5 -5
- package/lib/esm/risk_token/parser/TokenParserBase.js +12 -11
- package/lib/esm/risk_token/token/v2/DefaultTokenV2.js +5 -5
- package/lib/esm/risk_token/token/v3/DefaultTokenV3.js +11 -11
- package/lib/esm/sensitive_request/SensitiveRequestUtils.js +4 -4
- package/lib/esm/telemetry/DefaultTelemetry.js +7 -7
- package/lib/esm/utils/constants.js +1 -1
- package/lib/esm/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +7 -7
- package/lib/types/activities/HttpActivityClient.d.ts +4 -3
- package/lib/types/activities/HttpBatchedActivityClient.d.ts +8 -7
- package/lib/types/activities/utils.d.ts +270 -0
- package/lib/types/blocker/utils.d.ts +27 -0
- package/lib/types/config/ConfigurationBase.d.ts +6 -5
- package/lib/types/config/remote_config/DefaultRemoteConfigUpdater.d.ts +5 -5
- package/lib/types/config/remote_config/RemoteConfigUtils.d.ts +4 -0
- package/lib/types/config/remote_config/index.d.ts +1 -0
- package/lib/types/context/DefaultContext.d.ts +7 -2
- package/lib/types/context/interfaces/IContext.d.ts +11 -2
- package/lib/types/enforcer/EnforcerBase.d.ts +2 -1
- package/lib/types/graphql/DefaultGraphQLParser.d.ts +1 -2
- package/lib/types/logger/DefaultLogger.d.ts +1 -1
- package/lib/types/logger/HttpLogServiceClient.d.ts +5 -10
- package/lib/types/logger/ILogServiceClient.d.ts +1 -2
- package/lib/types/logger/LoggerBase.d.ts +2 -1
- package/lib/types/logger/model/LogMetadata.d.ts +1 -0
- package/lib/types/monitored_request/MonitoredRequestUtils.d.ts +1353 -2
- package/lib/types/phase/impl/DecideActionPhase.d.ts +0 -3
- package/lib/types/phase/impl/EnrichContextFromRequestPhase.d.ts +1 -0
- package/lib/types/phase/impl/FirstPartyPhase.d.ts +1 -1
- package/lib/types/products/account_defender/AccountDefender.d.ts +4 -5
- package/lib/types/products/bot_defender/filter/DefaultBotDefenderFilter.d.ts +2 -3
- package/lib/types/products/bot_defender/first_party/DefaultBotDefenderFirstParty.d.ts +3 -4
- package/lib/types/products/credential_intelligence/endpoint/CredentialEndpoint.d.ts +3 -5
- package/lib/types/products/credential_intelligence/endpoint/CredentialEndpointManager.d.ts +2 -2
- package/lib/types/products/credential_intelligence/endpoint/ICredentialEndpoint.d.ts +3 -4
- package/lib/types/pxhd/PXHDUtils.d.ts +54 -0
- package/lib/types/risk_api/client/PostRiskApiClientBase.d.ts +1 -1
- package/lib/types/risk_token/parser/TokenParserBase.d.ts +4 -5
- package/lib/types/risk_token/token/v3/DefaultTokenV3.d.ts +1 -1
- package/lib/types/sensitive_request/SensitiveRequestUtils.d.ts +705 -17
- package/lib/types/telemetry/DefaultTelemetry.d.ts +1 -1
- package/lib/types/utils/constants.d.ts +1 -1
- package/lib/types/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.d.ts +3 -2
- package/lib/types/utils/timestamp_hmac_header_validator/ITimestampHmacHeaderValidator.d.ts +2 -1
- package/package.json +1 -1
|
@@ -45,30 +45,28 @@ var CredentialEndpointManager = /** @class */ (function () {
|
|
|
45
45
|
var requestData = _a.requestData;
|
|
46
46
|
return this.endpoints.findIndex(function (endpoint) { return endpoint.matches(requestData); });
|
|
47
47
|
};
|
|
48
|
-
CredentialEndpointManager.prototype.getCredentialsData = function (endpointIndex,
|
|
49
|
-
var
|
|
50
|
-
var requestData = _a.requestData;
|
|
48
|
+
CredentialEndpointManager.prototype.getCredentialsData = function (endpointIndex, context) {
|
|
49
|
+
var _a;
|
|
51
50
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
return __generator(this, function (
|
|
53
|
-
switch (
|
|
54
|
-
case 0: return [4 /*yield*/, ((
|
|
55
|
-
case 1: return [2 /*return*/,
|
|
51
|
+
return __generator(this, function (_b) {
|
|
52
|
+
switch (_b.label) {
|
|
53
|
+
case 0: return [4 /*yield*/, ((_a = this.endpoints[endpointIndex]) === null || _a === void 0 ? void 0 : _a.getCredentialData(context))];
|
|
54
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
});
|
|
59
58
|
};
|
|
60
|
-
CredentialEndpointManager.prototype.isLoginSuccessful = function (endpointIndex,
|
|
61
|
-
var
|
|
62
|
-
var response = _a.response;
|
|
59
|
+
CredentialEndpointManager.prototype.isLoginSuccessful = function (endpointIndex, context) {
|
|
60
|
+
var _a;
|
|
63
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
return __generator(this, function (
|
|
65
|
-
switch (
|
|
62
|
+
return __generator(this, function (_b) {
|
|
63
|
+
switch (_b.label) {
|
|
66
64
|
case 0:
|
|
67
|
-
if (!response) {
|
|
65
|
+
if (!context.response) {
|
|
68
66
|
return [2 /*return*/, undefined];
|
|
69
67
|
}
|
|
70
|
-
return [4 /*yield*/, ((
|
|
71
|
-
case 1: return [2 /*return*/,
|
|
68
|
+
return [4 /*yield*/, ((_a = this.endpoints[endpointIndex]) === null || _a === void 0 ? void 0 : _a.isLoginSuccessful(context))];
|
|
69
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
72
70
|
}
|
|
73
71
|
});
|
|
74
72
|
});
|
|
@@ -54,19 +54,19 @@ var DefaultDataEnrichment = /** @class */ (function () {
|
|
|
54
54
|
_a.trys.push([0, 3, , 4]);
|
|
55
55
|
pxdeCookie = context.requestData.cookies[utils_1.PXDE_COOKIE_NAME];
|
|
56
56
|
if (!pxdeCookie) return [3 /*break*/, 2];
|
|
57
|
-
return [4 /*yield*/, this.parsePxde(pxdeCookie)];
|
|
57
|
+
return [4 /*yield*/, this.parsePxde(pxdeCookie, context)];
|
|
58
58
|
case 1: return [2 /*return*/, _a.sent()];
|
|
59
59
|
case 2: return [3 /*break*/, 4];
|
|
60
60
|
case 3:
|
|
61
61
|
e_1 = _a.sent();
|
|
62
|
-
|
|
62
|
+
context.logger.debug("unable to parse pxde cookie - ".concat(e_1));
|
|
63
63
|
return [3 /*break*/, 4];
|
|
64
64
|
case 4: return [2 /*return*/, null];
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
-
DefaultDataEnrichment.prototype.parsePxde = function (pxdeCookie) {
|
|
69
|
+
DefaultDataEnrichment.prototype.parsePxde = function (pxdeCookie, context) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
71
|
var pxdeParts, hmac, encodedPayload;
|
|
72
72
|
var _a;
|
|
@@ -75,27 +75,27 @@ var DefaultDataEnrichment = /** @class */ (function () {
|
|
|
75
75
|
case 0:
|
|
76
76
|
pxdeParts = pxdeCookie.split(constants_1.PXDE_COOKIE_DELIMITER);
|
|
77
77
|
if (pxdeParts.length !== constants_1.PXDE_COOKIE_PARTS_COUNT) {
|
|
78
|
-
|
|
78
|
+
context.logger.debug("malformed pxde cookie: ".concat(pxdeCookie));
|
|
79
79
|
return [2 /*return*/, null];
|
|
80
80
|
}
|
|
81
81
|
hmac = pxdeParts[constants_1.PXDE_HMAC_INDEX];
|
|
82
82
|
encodedPayload = pxdeParts[constants_1.PXDE_PAYLOAD_INDEX];
|
|
83
83
|
if (!hmac || !encodedPayload) {
|
|
84
|
-
|
|
84
|
+
context.logger.debug("malformed pxde cookie: hmac: ".concat(hmac, ", payload: ").concat(encodedPayload));
|
|
85
85
|
return [2 /*return*/, null];
|
|
86
86
|
}
|
|
87
87
|
_a = {};
|
|
88
|
-
return [4 /*yield*/, this.parsePxdePayload(encodedPayload)];
|
|
88
|
+
return [4 /*yield*/, this.parsePxdePayload(encodedPayload, context)];
|
|
89
89
|
case 1:
|
|
90
90
|
_a.pxde = _b.sent();
|
|
91
|
-
return [4 /*yield*/, this.verifyPxdeHmac(hmac, encodedPayload)];
|
|
91
|
+
return [4 /*yield*/, this.verifyPxdeHmac(hmac, encodedPayload, context)];
|
|
92
92
|
case 2: return [2 /*return*/, (_a.pxdeVerified = _b.sent(),
|
|
93
93
|
_a)];
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
};
|
|
98
|
-
DefaultDataEnrichment.prototype.verifyPxdeHmac = function (givenHmac, encodedPayload) {
|
|
98
|
+
DefaultDataEnrichment.prototype.verifyPxdeHmac = function (givenHmac, encodedPayload, context) {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
100
|
var _a, e_2;
|
|
101
101
|
return __generator(this, function (_b) {
|
|
@@ -108,14 +108,14 @@ var DefaultDataEnrichment = /** @class */ (function () {
|
|
|
108
108
|
(_b.sent()))];
|
|
109
109
|
case 2:
|
|
110
110
|
e_2 = _b.sent();
|
|
111
|
-
|
|
111
|
+
context.logger.debug("failed verifying pxde hmac: ".concat(e_2));
|
|
112
112
|
return [2 /*return*/, false];
|
|
113
113
|
case 3: return [2 /*return*/];
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
|
-
DefaultDataEnrichment.prototype.parsePxdePayload = function (encodedPayload) {
|
|
118
|
+
DefaultDataEnrichment.prototype.parsePxdePayload = function (encodedPayload, context) {
|
|
119
119
|
return __awaiter(this, void 0, void 0, function () {
|
|
120
120
|
var decodedPayload;
|
|
121
121
|
return __generator(this, function (_a) {
|
|
@@ -124,7 +124,7 @@ var DefaultDataEnrichment = /** @class */ (function () {
|
|
|
124
124
|
return [2 /*return*/, JSON.parse(decodedPayload)];
|
|
125
125
|
}
|
|
126
126
|
catch (e) {
|
|
127
|
-
|
|
127
|
+
context.logger.debug("failed parsing pxde payload: ".concat(e));
|
|
128
128
|
return [2 /*return*/, null];
|
|
129
129
|
}
|
|
130
130
|
return [2 /*return*/];
|
|
@@ -74,7 +74,7 @@ var PostRiskApiClientBase = /** @class */ (function () {
|
|
|
74
74
|
case 1:
|
|
75
75
|
_a.trys.push([1, 8, , 10]);
|
|
76
76
|
riskActivity = this.createRiskActivity(context);
|
|
77
|
-
return [4 /*yield*/, this.sendRiskActivity(riskActivity, riskApiData)];
|
|
77
|
+
return [4 /*yield*/, this.sendRiskActivity(riskActivity, riskApiData, context)];
|
|
78
78
|
case 2:
|
|
79
79
|
response = _a.sent();
|
|
80
80
|
if (!((response === null || response === void 0 ? void 0 : response.status) !== 200)) return [3 /*break*/, 4];
|
|
@@ -89,14 +89,14 @@ var PostRiskApiClientBase = /** @class */ (function () {
|
|
|
89
89
|
return [4 /*yield*/, this.handleS2SError(riskApiData, response)];
|
|
90
90
|
case 6: return [2 /*return*/, _a.sent()];
|
|
91
91
|
case 7:
|
|
92
|
-
|
|
92
|
+
context.logger.debug("received risk response, score: ".concat(riskResponse.score, ", rtt: ").concat(riskApiData.riskRtt));
|
|
93
93
|
return [2 /*return*/, riskApiData];
|
|
94
94
|
case 8:
|
|
95
95
|
err_1 = _a.sent();
|
|
96
96
|
if (err_1.name === utils_1.EnforcerErrorName.ENFORCER_TIMEOUT_ERROR) {
|
|
97
97
|
return [2 /*return*/, this.handleS2STimeout(riskApiData)];
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
context.logger.error("caught error in risk api: ".concat(err_1, " - ").concat(JSON.stringify(context.requestData.url)));
|
|
100
100
|
return [4 /*yield*/, this.handleS2SError(riskApiData, response, err_1)];
|
|
101
101
|
case 9: return [2 /*return*/, _a.sent()];
|
|
102
102
|
case 10: return [2 /*return*/];
|
|
@@ -138,7 +138,7 @@ var PostRiskApiClientBase = /** @class */ (function () {
|
|
|
138
138
|
var headersWithoutSensitive = (0, utils_1.removeSensitiveHeaders)(headers, this.config.sensitiveHeaders);
|
|
139
139
|
return (0, activities_1.toHeaderEntryArray)(headersWithoutSensitive);
|
|
140
140
|
};
|
|
141
|
-
PostRiskApiClientBase.prototype.sendRiskActivity = function (riskActivity, riskApiData) {
|
|
141
|
+
PostRiskApiClientBase.prototype.sendRiskActivity = function (riskActivity, riskApiData, context) {
|
|
142
142
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
143
|
var url, headers, body, method, riskRequest, startTime, response, endTime;
|
|
144
144
|
return __generator(this, function (_a) {
|
|
@@ -149,7 +149,7 @@ var PostRiskApiClientBase = /** @class */ (function () {
|
|
|
149
149
|
body = JSON.stringify(riskActivity);
|
|
150
150
|
method = http_1.HttpMethod.POST;
|
|
151
151
|
riskRequest = new http_1.OutgoingRequestImpl({ url: url, method: method, headers: headers, body: body });
|
|
152
|
-
|
|
152
|
+
context.logger.debug("sending risk api to ".concat(url));
|
|
153
153
|
startTime = Date.now();
|
|
154
154
|
return [4 /*yield*/, this.httpClient.send(riskRequest, { timeoutMs: this.config.s2sTimeout })];
|
|
155
155
|
case 1:
|
|
@@ -57,7 +57,7 @@ var TokenParserBase = /** @class */ (function () {
|
|
|
57
57
|
case 1:
|
|
58
58
|
_b.trys.push([1, 5, , 6]);
|
|
59
59
|
if (!!tokenData.token) return [3 /*break*/, 3];
|
|
60
|
-
|
|
60
|
+
context.logger.debug('no token found');
|
|
61
61
|
return [4 /*yield*/, this.handleMobileErrorIfNeeded(context, tokenData)];
|
|
62
62
|
case 2:
|
|
63
63
|
_b.sent();
|
|
@@ -70,7 +70,7 @@ var TokenParserBase = /** @class */ (function () {
|
|
|
70
70
|
return [3 /*break*/, 6];
|
|
71
71
|
case 5:
|
|
72
72
|
e_1 = _b.sent();
|
|
73
|
-
|
|
73
|
+
context.logger.debug("could not parse token - ".concat(e_1));
|
|
74
74
|
tokenData.tokenParseResult = tokenData.token ? TokenParseResult_1.TokenParseResult.DECRYPTION_FAILED : TokenParseResult_1.TokenParseResult.NONE;
|
|
75
75
|
return [3 /*break*/, 6];
|
|
76
76
|
case 6: return [2 /*return*/, tokenData];
|
|
@@ -78,23 +78,22 @@ var TokenParserBase = /** @class */ (function () {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
-
TokenParserBase.prototype.initializeToken = function (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return this.createMobileTokenData(requestData);
|
|
81
|
+
TokenParserBase.prototype.initializeToken = function (context) {
|
|
82
|
+
if (context.isMobile) {
|
|
83
|
+
return this.createMobileTokenData(context);
|
|
85
84
|
}
|
|
86
85
|
else {
|
|
87
|
-
return this.createWebTokenData(requestData.cookies);
|
|
86
|
+
return this.createWebTokenData(context.requestData.cookies);
|
|
88
87
|
}
|
|
89
88
|
};
|
|
90
|
-
TokenParserBase.prototype.createMobileTokenData = function (
|
|
91
|
-
var request =
|
|
89
|
+
TokenParserBase.prototype.createMobileTokenData = function (context) {
|
|
90
|
+
var request = context.requestData.request;
|
|
92
91
|
var mobileToken = request.headers.get(utils_1.X_PX_AUTHORIZATION_HEADER_NAME);
|
|
93
92
|
var tokenData = {
|
|
94
93
|
tokenParseResult: TokenParseResult_1.TokenParseResult.NONE,
|
|
95
|
-
token: this.getMobileToken(mobileToken),
|
|
94
|
+
token: this.getMobileToken(mobileToken, context),
|
|
96
95
|
mobileData: {
|
|
97
|
-
originalToken: this.getMobileToken(request.headers.get(utils_1.X_PX_ORIGINAL_TOKEN_HEADER_NAME)),
|
|
96
|
+
originalToken: this.getMobileToken(request.headers.get(utils_1.X_PX_ORIGINAL_TOKEN_HEADER_NAME), context),
|
|
98
97
|
bypassReason: request.headers.get(utils_1.X_PX_BYPASS_REASON_HEADER_NAME) || '',
|
|
99
98
|
},
|
|
100
99
|
};
|
|
@@ -103,7 +102,7 @@ var TokenParserBase = /** @class */ (function () {
|
|
|
103
102
|
}
|
|
104
103
|
return tokenData;
|
|
105
104
|
};
|
|
106
|
-
TokenParserBase.prototype.getMobileToken = function (mobileToken) {
|
|
105
|
+
TokenParserBase.prototype.getMobileToken = function (mobileToken, context) {
|
|
107
106
|
var _a;
|
|
108
107
|
try {
|
|
109
108
|
if (!mobileToken || (mobileToken === null || mobileToken === void 0 ? void 0 : mobileToken.indexOf(constants_1.COOKIE_SPLIT_DELIMITER)) === -1) {
|
|
@@ -117,7 +116,7 @@ var TokenParserBase = /** @class */ (function () {
|
|
|
117
116
|
return this.createToken(this.config, (_a = {}, _a[cookieName] = cookieString.join(constants_1.COOKIE_SPLIT_DELIMITER), _a), this.options);
|
|
118
117
|
}
|
|
119
118
|
catch (e) {
|
|
120
|
-
|
|
119
|
+
context.logger.debug("error extracting mobile token - ".concat(e, ", token: ").concat(mobileToken));
|
|
121
120
|
return null;
|
|
122
121
|
}
|
|
123
122
|
};
|
|
@@ -68,13 +68,13 @@ var DefaultTokenV2 = /** @class */ (function (_super) {
|
|
|
68
68
|
try {
|
|
69
69
|
var payload = this.decode(this.cookieString);
|
|
70
70
|
if ((payload === null || payload === void 0 ? void 0 : payload.t) == null || (payload === null || payload === void 0 ? void 0 : payload.h) == null || (payload === null || payload === void 0 ? void 0 : payload.u) == null || (payload === null || payload === void 0 ? void 0 : payload.v) == null) {
|
|
71
|
-
|
|
71
|
+
context.logger.debug("missing cookie v2 fields: ".concat(JSON.stringify(payload)));
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
return payload;
|
|
75
75
|
}
|
|
76
76
|
catch (e) {
|
|
77
|
-
|
|
77
|
+
context.logger.debug("cookie v2 decryption failed: ".concat(e));
|
|
78
78
|
}
|
|
79
79
|
return null;
|
|
80
80
|
};
|
|
@@ -88,7 +88,7 @@ var DefaultTokenV2 = /** @class */ (function (_super) {
|
|
|
88
88
|
!(0, utils_1.isValidUuid)(this.payload.v) ||
|
|
89
89
|
!(0, utils_1.isValidUuid)(this.payload.u) ||
|
|
90
90
|
!this.payload.h) {
|
|
91
|
-
|
|
91
|
+
context.logger.debug("invalid cookie v2 structure: ".concat(JSON.stringify(this.payload)));
|
|
92
92
|
return [2 /*return*/, false];
|
|
93
93
|
}
|
|
94
94
|
_a.label = 1;
|
|
@@ -109,11 +109,11 @@ var DefaultTokenV2 = /** @class */ (function (_super) {
|
|
|
109
109
|
this.isHighRisk = true;
|
|
110
110
|
return [2 /*return*/, true];
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
context.logger.debug("unknown cookie v2 hmac (".concat(this.payload.h, "), does not match pass (").concat(passHmac, ") or block (").concat(blockHmac, ")"));
|
|
113
113
|
return [3 /*break*/, 5];
|
|
114
114
|
case 4:
|
|
115
115
|
e_1 = _a.sent();
|
|
116
|
-
|
|
116
|
+
context.logger.debug("cookie v2 validation caught error: ".concat(e_1));
|
|
117
117
|
return [3 /*break*/, 5];
|
|
118
118
|
case 5: return [2 /*return*/, false];
|
|
119
119
|
}
|
|
@@ -77,7 +77,7 @@ var DefaultTokenV3 = /** @class */ (function (_super) {
|
|
|
77
77
|
_a.trys.push([0, 2, , 3]);
|
|
78
78
|
data = this.cookieString.split(constants_1.COOKIE_SPLIT_DELIMITER);
|
|
79
79
|
if (data.length !== constants_1.COOKIE_V3_PARTS_COUNT) {
|
|
80
|
-
|
|
80
|
+
context.logger.debug("invalid cookie v3 structure: ".concat(data));
|
|
81
81
|
return [2 /*return*/, null];
|
|
82
82
|
}
|
|
83
83
|
this.hash = data[constants_1.COOKIE_V3_HMAC_INDEX];
|
|
@@ -87,29 +87,29 @@ var DefaultTokenV3 = /** @class */ (function (_super) {
|
|
|
87
87
|
: Number(data[constants_1.COOKIE_V3_ITERATIONS_INDEX]);
|
|
88
88
|
encryptedCookie = data[constants_1.COOKIE_V3_PAYLOAD_INDEX];
|
|
89
89
|
if (!iterations || iterations > this.maxIterations || iterations < this.minIterations) {
|
|
90
|
-
|
|
90
|
+
context.logger.debug("invalid cookie v3 iterations: ".concat(iterations, " is not between ").concat(this.minIterations, " and ").concat(this.maxIterations));
|
|
91
91
|
return [2 /*return*/, null];
|
|
92
92
|
}
|
|
93
93
|
if (!salt || typeof salt !== 'string' || salt.length > constants_1.COOKIE_V3_MAXIMUM_SALT_LENGTH) {
|
|
94
|
-
|
|
94
|
+
context.logger.debug("invalid cookie v3 salt: ".concat(salt));
|
|
95
95
|
return [2 /*return*/, null];
|
|
96
96
|
}
|
|
97
97
|
if (!encryptedCookie || typeof encryptedCookie !== 'string') {
|
|
98
|
-
|
|
98
|
+
context.logger.debug("invalid cookie v3 encrypted payload: ".concat(encryptedCookie));
|
|
99
99
|
return [2 /*return*/, null];
|
|
100
100
|
}
|
|
101
|
-
return [4 /*yield*/, this.decryptPayload(encryptedCookie, salt, iterations)];
|
|
101
|
+
return [4 /*yield*/, this.decryptPayload(encryptedCookie, salt, iterations, context)];
|
|
102
102
|
case 1: return [2 /*return*/, _a.sent()];
|
|
103
103
|
case 2:
|
|
104
104
|
e_1 = _a.sent();
|
|
105
|
-
|
|
105
|
+
context.logger.debug("cookie v3 decryption failed: ".concat(e_1));
|
|
106
106
|
return [3 /*break*/, 3];
|
|
107
107
|
case 3: return [2 /*return*/, null];
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
};
|
|
112
|
-
DefaultTokenV3.prototype.decryptPayload = function (encryptedCookie, salt, iterations) {
|
|
112
|
+
DefaultTokenV3.prototype.decryptPayload = function (encryptedCookie, salt, iterations, context) {
|
|
113
113
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
114
|
var decryptedCookie, payload, e_2;
|
|
115
115
|
return __generator(this, function (_a) {
|
|
@@ -120,7 +120,7 @@ var DefaultTokenV3 = /** @class */ (function (_super) {
|
|
|
120
120
|
case 1:
|
|
121
121
|
decryptedCookie = _a.sent();
|
|
122
122
|
if (!decryptedCookie) {
|
|
123
|
-
|
|
123
|
+
context.logger.debug("cookie v3 decryption returned falsy value: ".concat(decryptedCookie));
|
|
124
124
|
return [2 /*return*/, null];
|
|
125
125
|
}
|
|
126
126
|
payload = JSON.parse(decryptedCookie);
|
|
@@ -129,13 +129,13 @@ var DefaultTokenV3 = /** @class */ (function (_super) {
|
|
|
129
129
|
(payload === null || payload === void 0 ? void 0 : payload.t) == null ||
|
|
130
130
|
(payload === null || payload === void 0 ? void 0 : payload.u) == null ||
|
|
131
131
|
(payload === null || payload === void 0 ? void 0 : payload.v) == null) {
|
|
132
|
-
|
|
132
|
+
context.logger.debug("invalid cookie v3 structure: ".concat(JSON.stringify(payload)));
|
|
133
133
|
return [2 /*return*/, null];
|
|
134
134
|
}
|
|
135
135
|
return [2 /*return*/, payload];
|
|
136
136
|
case 2:
|
|
137
137
|
e_2 = _a.sent();
|
|
138
|
-
|
|
138
|
+
context.logger.debug("error decrypting cookie v3: ".concat(e_2));
|
|
139
139
|
return [2 /*return*/, null];
|
|
140
140
|
case 3: return [2 /*return*/];
|
|
141
141
|
}
|
|
@@ -158,7 +158,7 @@ var DefaultTokenV3 = /** @class */ (function (_super) {
|
|
|
158
158
|
return [2 /*return*/, hash === this.hmac];
|
|
159
159
|
case 2:
|
|
160
160
|
e_3 = _a.sent();
|
|
161
|
-
|
|
161
|
+
context.logger.debug("error validating cookie v3: ".concat(e_3));
|
|
162
162
|
return [2 /*return*/, false];
|
|
163
163
|
case 3: return [2 /*return*/];
|
|
164
164
|
}
|
|
@@ -49,7 +49,7 @@ var SensitiveRequestUtils;
|
|
|
49
49
|
_a = SensitiveRequestUtils.isSensitiveRoute(context.requestData.url, config.sensitiveRoutes) ||
|
|
50
50
|
SensitiveRequestUtils.isSensitiveGraphqlOperation(context.graphqlData);
|
|
51
51
|
if (_a) return [3 /*break*/, 2];
|
|
52
|
-
return [4 /*yield*/, SensitiveRequestUtils.invokeCustomIsSensitiveRequest(config, context
|
|
52
|
+
return [4 /*yield*/, SensitiveRequestUtils.invokeCustomIsSensitiveRequest(config, context)];
|
|
53
53
|
case 1:
|
|
54
54
|
_a = (_b.sent());
|
|
55
55
|
_b.label = 2;
|
|
@@ -63,7 +63,7 @@ var SensitiveRequestUtils;
|
|
|
63
63
|
SensitiveRequestUtils.isSensitiveGraphqlOperation = function (graphQLData) {
|
|
64
64
|
return !!(graphQLData === null || graphQLData === void 0 ? void 0 : graphQLData.some(function (operation) { return operation.sensitive; }));
|
|
65
65
|
};
|
|
66
|
-
SensitiveRequestUtils.invokeCustomIsSensitiveRequest = function (config,
|
|
66
|
+
SensitiveRequestUtils.invokeCustomIsSensitiveRequest = function (config, context) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
67
|
var err_1;
|
|
68
68
|
return __generator(this, function (_a) {
|
|
69
69
|
switch (_a.label) {
|
|
@@ -72,11 +72,11 @@ var SensitiveRequestUtils;
|
|
|
72
72
|
_a.label = 1;
|
|
73
73
|
case 1:
|
|
74
74
|
_a.trys.push([1, 3, , 4]);
|
|
75
|
-
return [4 /*yield*/, config.customIsSensitiveRequest(request.getUnderlyingRequest())];
|
|
75
|
+
return [4 /*yield*/, config.customIsSensitiveRequest(context.requestData.request.getUnderlyingRequest())];
|
|
76
76
|
case 2: return [2 /*return*/, _a.sent()];
|
|
77
77
|
case 3:
|
|
78
78
|
err_1 = _a.sent();
|
|
79
|
-
|
|
79
|
+
context.logger.debug("caught custom sensitive request error - ".concat(err_1));
|
|
80
80
|
return [3 /*break*/, 4];
|
|
81
81
|
case 4: return [2 /*return*/, false];
|
|
82
82
|
}
|
|
@@ -57,14 +57,14 @@ var DefaultTelemetry = /** @class */ (function () {
|
|
|
57
57
|
telemetryHeader = this.getTelemetryHeader(context);
|
|
58
58
|
_a = !!telemetryHeader;
|
|
59
59
|
if (!_a) return [3 /*break*/, 2];
|
|
60
|
-
return [4 /*yield*/, this.isTelemetryHeaderValid(telemetryHeader)];
|
|
60
|
+
return [4 /*yield*/, this.isTelemetryHeaderValid(telemetryHeader, context)];
|
|
61
61
|
case 1:
|
|
62
62
|
_a = (_b.sent());
|
|
63
63
|
_b.label = 2;
|
|
64
64
|
case 2: return [2 /*return*/, _a];
|
|
65
65
|
case 3:
|
|
66
66
|
e_1 = _b.sent();
|
|
67
|
-
|
|
67
|
+
context.logger.debug("error validating telemetry - ".concat(e_1));
|
|
68
68
|
return [2 /*return*/, false];
|
|
69
69
|
case 4: return [2 /*return*/];
|
|
70
70
|
}
|
|
@@ -84,7 +84,7 @@ var DefaultTelemetry = /** @class */ (function () {
|
|
|
84
84
|
return [3 /*break*/, 3];
|
|
85
85
|
case 2:
|
|
86
86
|
e_2 = _a.sent();
|
|
87
|
-
|
|
87
|
+
context.logger.debug("error sending telemetry - ".concat(e_2));
|
|
88
88
|
return [3 /*break*/, 3];
|
|
89
89
|
case 3: return [2 /*return*/];
|
|
90
90
|
}
|
|
@@ -94,11 +94,11 @@ var DefaultTelemetry = /** @class */ (function () {
|
|
|
94
94
|
DefaultTelemetry.prototype.getTelemetryHeader = function (context) {
|
|
95
95
|
return context.requestData.request.headers.get(constants_1.TELEMETRY_HEADER_NAME) || '';
|
|
96
96
|
};
|
|
97
|
-
DefaultTelemetry.prototype.isTelemetryHeaderValid = function (headerValue) {
|
|
97
|
+
DefaultTelemetry.prototype.isTelemetryHeaderValid = function (headerValue, context) {
|
|
98
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
99
|
return __generator(this, function (_a) {
|
|
100
|
-
|
|
101
|
-
return [2 /*return*/, this.timestampHmacHeaderValidator.isValid(headerValue)];
|
|
100
|
+
context.logger.debug('received command to send enforcer telemetry');
|
|
101
|
+
return [2 /*return*/, this.timestampHmacHeaderValidator.isValid(headerValue, context.logger)];
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
};
|
|
@@ -109,7 +109,7 @@ var DefaultTelemetry = /** @class */ (function () {
|
|
|
109
109
|
switch (_a.label) {
|
|
110
110
|
case 0:
|
|
111
111
|
telemetryRequest = this.createTelemetryRequest(context);
|
|
112
|
-
|
|
112
|
+
context.logger.debug("sending telemetry to ".concat(telemetryRequest.url));
|
|
113
113
|
return [4 /*yield*/, this.httpClient.send(telemetryRequest)];
|
|
114
114
|
case 1:
|
|
115
115
|
_a.sent();
|
|
@@ -13,4 +13,4 @@ exports.PUSH_DATA_HMAC_HEADER_NAME = 'x-px-pushdata';
|
|
|
13
13
|
exports.PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
|
|
14
14
|
exports.EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
15
15
|
exports.URL_REGEX = /^(https?\:)\/\/(([^@\s:]+):?([^@\s]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
16
|
-
exports.CORE_MODULE_VERSION = 'JS Core 0.
|
|
16
|
+
exports.CORE_MODULE_VERSION = 'JS Core 0.16.0';
|
package/lib/cjs/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js
CHANGED
|
@@ -47,7 +47,7 @@ var DefaultTimestampHmacHeaderValidator = /** @class */ (function () {
|
|
|
47
47
|
this.base64Utils = base64Utils;
|
|
48
48
|
this.hmacUtils = hmacUtils;
|
|
49
49
|
}
|
|
50
|
-
DefaultTimestampHmacHeaderValidator.prototype.isValid = function (headerValue) {
|
|
50
|
+
DefaultTimestampHmacHeaderValidator.prototype.isValid = function (headerValue, logger) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
52
|
var decodedValue, splitValue, timestamp, givenHmac, curUnixTime, timestampNumber;
|
|
53
53
|
return __generator(this, function (_a) {
|
|
@@ -56,20 +56,20 @@ var DefaultTimestampHmacHeaderValidator = /** @class */ (function () {
|
|
|
56
56
|
decodedValue = this.base64Utils.base64Decode(headerValue);
|
|
57
57
|
splitValue = decodedValue.split(TIMESTAMP_HMAC_HEADER_DELIMITER);
|
|
58
58
|
if (splitValue.length !== TIMESTAMP_HMAC_HEADER_PARTS_COUNT) {
|
|
59
|
-
|
|
59
|
+
logger.debug("malformed timestamp:hmac header: ".concat(decodedValue));
|
|
60
60
|
return [2 /*return*/, false];
|
|
61
61
|
}
|
|
62
62
|
timestamp = splitValue[0], givenHmac = splitValue[1];
|
|
63
|
-
return [4 /*yield*/, this.isHmacValid(givenHmac, timestamp)];
|
|
63
|
+
return [4 /*yield*/, this.isHmacValid(givenHmac, timestamp, logger)];
|
|
64
64
|
case 1:
|
|
65
65
|
if (!(_a.sent())) {
|
|
66
|
-
|
|
66
|
+
logger.debug("hmac validation failed. original hmac: ".concat(givenHmac, ", timestamp: ").concat(timestamp, "."));
|
|
67
67
|
return [2 /*return*/, false];
|
|
68
68
|
}
|
|
69
69
|
curUnixTime = +new Date();
|
|
70
70
|
timestampNumber = parseInt ? parseInt(timestamp) : Number(timestamp);
|
|
71
71
|
if (isNaN(timestampNumber) || timestampNumber < curUnixTime) {
|
|
72
|
-
|
|
72
|
+
logger.debug("hmac header timestamp expired: ".concat(timestamp, " < ").concat(curUnixTime));
|
|
73
73
|
return [2 /*return*/, false];
|
|
74
74
|
}
|
|
75
75
|
return [2 /*return*/, true];
|
|
@@ -77,7 +77,7 @@ var DefaultTimestampHmacHeaderValidator = /** @class */ (function () {
|
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
|
-
DefaultTimestampHmacHeaderValidator.prototype.isHmacValid = function (givenHmac, timestamp) {
|
|
80
|
+
DefaultTimestampHmacHeaderValidator.prototype.isHmacValid = function (givenHmac, timestamp, logger) {
|
|
81
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
82
82
|
var _a, err_1;
|
|
83
83
|
return __generator(this, function (_b) {
|
|
@@ -89,7 +89,7 @@ var DefaultTimestampHmacHeaderValidator = /** @class */ (function () {
|
|
|
89
89
|
case 1: return [2 /*return*/, _a === (_b.sent())];
|
|
90
90
|
case 2:
|
|
91
91
|
err_1 = _b.sent();
|
|
92
|
-
|
|
92
|
+
logger.debug("caught error calculating timestamp:header hmac: ".concat(err_1));
|
|
93
93
|
return [2 /*return*/, false];
|
|
94
94
|
case 3: return [2 /*return*/];
|
|
95
95
|
}
|
|
@@ -14,10 +14,10 @@ export class HttpActivityClient {
|
|
|
14
14
|
async sendActivities(context) {
|
|
15
15
|
try {
|
|
16
16
|
const activities = this.createActivities(context);
|
|
17
|
-
return await this.postActivities(activities);
|
|
17
|
+
return await this.postActivities(activities, context.logger);
|
|
18
18
|
}
|
|
19
19
|
catch (e) {
|
|
20
|
-
|
|
20
|
+
context.logger.error(`unable to send activities - ${e}`);
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -43,7 +43,7 @@ export class HttpActivityClient {
|
|
|
43
43
|
finalizeActivity(activity) {
|
|
44
44
|
return activity;
|
|
45
45
|
}
|
|
46
|
-
async postActivities(activities) {
|
|
46
|
+
async postActivities(activities, logger) {
|
|
47
47
|
const url = `${this.config.backendCollectorUrl}${ACTIVITIES_ENDPOINT}`;
|
|
48
48
|
const method = HttpMethod.POST;
|
|
49
49
|
const headers = {
|
|
@@ -51,7 +51,7 @@ export class HttpActivityClient {
|
|
|
51
51
|
[AUTHORIZATION_HEADER_NAME]: [getAuthorizationHeader(this.config.authToken)],
|
|
52
52
|
};
|
|
53
53
|
const body = activities.length === 1 ? JSON.stringify(activities[0]) : JSON.stringify(activities);
|
|
54
|
-
|
|
54
|
+
logger.debug(`sending ${activities.map(({ type }) => `${type} activity`).join(', ')} to ${url}`);
|
|
55
55
|
const req = new OutgoingRequestImpl({ url, method, headers, body });
|
|
56
56
|
const res = await this.httpClient.send(req);
|
|
57
57
|
return res?.status === 200;
|
|
@@ -19,9 +19,9 @@ export class HttpBatchedActivityClient extends HttpActivityClient {
|
|
|
19
19
|
this.shouldKill = true;
|
|
20
20
|
this.stopTimer();
|
|
21
21
|
}
|
|
22
|
-
async postActivities(activities) {
|
|
22
|
+
async postActivities(activities, logger) {
|
|
23
23
|
this.addToBuffer(activities);
|
|
24
|
-
return this.shouldFlush() ? this.triggerFlush() : true;
|
|
24
|
+
return this.shouldFlush() ? this.triggerFlush(logger) : true;
|
|
25
25
|
}
|
|
26
26
|
addToBuffer(activities) {
|
|
27
27
|
this.buffer = activities.concat(this.buffer);
|
|
@@ -32,18 +32,18 @@ export class HttpBatchedActivityClient extends HttpActivityClient {
|
|
|
32
32
|
shouldFlush() {
|
|
33
33
|
return this.buffer.length >= this.batchSize;
|
|
34
34
|
}
|
|
35
|
-
async triggerFlush() {
|
|
35
|
+
async triggerFlush(logger) {
|
|
36
36
|
this.stopTimer();
|
|
37
|
-
const sentSuccessfully = this.buffer.length > 0 && (await this.flush());
|
|
37
|
+
const sentSuccessfully = this.buffer.length > 0 && (await this.flush(logger));
|
|
38
38
|
if (!this.shouldKill) {
|
|
39
39
|
this.startTimer();
|
|
40
40
|
}
|
|
41
41
|
return sentSuccessfully;
|
|
42
42
|
}
|
|
43
|
-
async flush() {
|
|
43
|
+
async flush(logger) {
|
|
44
44
|
const bufferCopy = this.buffer.concat();
|
|
45
45
|
this.clear();
|
|
46
|
-
const sentSuccessfully = await super.postActivities(bufferCopy);
|
|
46
|
+
const sentSuccessfully = await super.postActivities(bufferCopy, logger);
|
|
47
47
|
if (!sentSuccessfully) {
|
|
48
48
|
this.buffer = this.buffer.concat(bufferCopy);
|
|
49
49
|
}
|
|
@@ -53,7 +53,7 @@ export class HttpBatchedActivityClient extends HttpActivityClient {
|
|
|
53
53
|
this.buffer = [];
|
|
54
54
|
}
|
|
55
55
|
startTimer() {
|
|
56
|
-
this.timeoutId = setTimeout(() => this.triggerFlush(), this.timeoutMs);
|
|
56
|
+
this.timeoutId = setTimeout(() => this.triggerFlush(this.config.logger), this.timeoutMs);
|
|
57
57
|
}
|
|
58
58
|
stopTimer() {
|
|
59
59
|
clearTimeout(this.timeoutId);
|
|
@@ -3,11 +3,11 @@ export var AdditionalActivityHandlerUtils;
|
|
|
3
3
|
AdditionalActivityHandlerUtils.invokeAdditionalActivityHandler = async (config, context) => {
|
|
4
4
|
if (config.additionalActivityHandler && typeof config.additionalActivityHandler === 'function') {
|
|
5
5
|
try {
|
|
6
|
-
|
|
6
|
+
context.logger.debug('calling additional activity handler');
|
|
7
7
|
await config.additionalActivityHandler(config.toParams(), context, context.requestData.request.getUnderlyingRequest());
|
|
8
8
|
}
|
|
9
9
|
catch (e) {
|
|
10
|
-
|
|
10
|
+
context.logger.error(`caught additional activity handler error - ${e}`);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
};
|
|
@@ -9,7 +9,7 @@ export class ConfigurationBase {
|
|
|
9
9
|
...DEFAULT_CONFIGURATION_PARAMS,
|
|
10
10
|
...defaultParams,
|
|
11
11
|
});
|
|
12
|
-
this.internalLogger =
|
|
12
|
+
this.internalLogger = this.createInternalLogger(this.configParams.px_logger_severity);
|
|
13
13
|
}
|
|
14
14
|
initialize(params, defaultParams) {
|
|
15
15
|
this.throwIfMissingRequiredField(params);
|
|
@@ -61,6 +61,9 @@ export class ConfigurationBase {
|
|
|
61
61
|
return defaultParams[key];
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
createInternalLogger(loggerSeverity) {
|
|
65
|
+
return new DefaultLogger(loggerSeverity, false);
|
|
66
|
+
}
|
|
64
67
|
toParams() {
|
|
65
68
|
return Object.assign({}, this.configParams);
|
|
66
69
|
}
|