perimeterx-js-core 0.16.1 → 0.18.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 +27 -7
- package/lib/cjs/activities/utils.js +3 -3
- package/lib/cjs/blocker/utils.js +2 -1
- package/lib/cjs/config/defaults/constants.js +0 -0
- package/lib/cjs/context/ContextJson.js +2 -0
- package/lib/cjs/context/DefaultContext.js +41 -20
- package/lib/cjs/context/SerializedContext.js +66 -0
- package/lib/cjs/context/index.js +2 -0
- package/lib/cjs/enforcer/EnforcerBase.js +2 -101
- package/lib/cjs/enforcer/index.js +3 -3
- package/lib/cjs/enforcer/utils.js +96 -0
- package/lib/cjs/impl/url/UrlImpl.js +3 -0
- package/lib/cjs/products/bot_defender/first_party/IDefaultBotDefenderFirstPartyConfiguration.js +0 -0
- package/lib/cjs/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js +4 -6
- package/lib/cjs/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js +1 -11
- package/lib/cjs/products/hype_sale_challenge/HypeSaleChallenge.js +1 -1
- package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +14 -0
- package/lib/cjs/risk_api/risk_response/index.js +1 -0
- package/lib/cjs/risk_api/risk_response/serialize/RiskResponseJson.js +2 -0
- package/lib/cjs/risk_api/risk_response/serialize/SerializedRiskResponse.js +22 -0
- package/lib/cjs/risk_api/risk_response/serialize/index.js +18 -0
- package/lib/cjs/risk_token/parser/TokenParserBase.js +1 -1
- package/lib/cjs/risk_token/token/TokenBase.js +31 -7
- package/lib/cjs/risk_token/token/index.js +19 -9
- package/lib/cjs/risk_token/token/serialize/SerializedToken.js +30 -0
- package/lib/cjs/risk_token/token/serialize/TokenJson.js +2 -0
- package/lib/cjs/risk_token/token/serialize/index.js +18 -0
- package/lib/cjs/risk_token/token/v2/index.js +18 -0
- package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +3 -2
- package/lib/cjs/risk_token/token/v3/index.js +19 -0
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/cjs/utils/cookie_parser/StringSplitCookieParser.js +20 -4
- package/lib/esm/activities/HttpActivityClient.js +27 -7
- package/lib/esm/activities/utils.js +3 -3
- package/lib/esm/blocker/utils.js +2 -1
- package/lib/esm/config/defaults/constants.js +0 -0
- package/lib/esm/context/ContextJson.js +1 -0
- package/lib/esm/context/DefaultContext.js +36 -13
- package/lib/esm/context/SerializedContext.js +87 -0
- package/lib/esm/context/index.js +2 -0
- package/lib/esm/enforcer/EnforcerBase.js +2 -89
- package/lib/esm/enforcer/index.js +3 -1
- package/lib/esm/enforcer/utils.js +79 -0
- package/lib/esm/impl/url/UrlImpl.js +3 -0
- package/lib/esm/products/bot_defender/first_party/IDefaultBotDefenderFirstPartyConfiguration.js +0 -0
- package/lib/esm/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js +6 -8
- package/lib/esm/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js +1 -6
- package/lib/esm/products/hype_sale_challenge/HypeSaleChallenge.js +1 -1
- package/lib/esm/risk_api/risk_response/RiskResponseBase.js +14 -0
- package/lib/esm/risk_api/risk_response/index.js +1 -0
- package/lib/esm/risk_api/risk_response/serialize/RiskResponseJson.js +1 -0
- package/lib/esm/risk_api/risk_response/serialize/SerializedRiskResponse.js +27 -0
- package/lib/esm/risk_api/risk_response/serialize/index.js +2 -0
- package/lib/esm/risk_token/parser/TokenParserBase.js +1 -1
- package/lib/esm/risk_token/token/TokenBase.js +19 -4
- package/lib/esm/risk_token/token/index.js +5 -4
- package/lib/esm/risk_token/token/serialize/SerializedToken.js +36 -0
- package/lib/esm/risk_token/token/serialize/TokenJson.js +1 -0
- package/lib/esm/risk_token/token/serialize/index.js +2 -0
- package/lib/esm/risk_token/token/v2/index.js +2 -0
- package/lib/esm/risk_token/token/v3/DefaultTokenV3.js +2 -2
- package/lib/esm/risk_token/token/v3/index.js +3 -0
- package/lib/esm/utils/constants.js +1 -1
- package/lib/esm/utils/cookie_parser/StringSplitCookieParser.js +16 -3
- package/lib/types/activities/HttpActivityClient.d.ts +6 -0
- package/lib/types/activities/utils.d.ts +91 -60
- package/lib/types/blocker/utils.d.ts +9 -6
- package/lib/types/config/defaults/constants.d.ts +0 -0
- package/lib/types/context/ContextJson.d.ts +41 -0
- package/lib/types/context/DefaultContext.d.ts +5 -3
- package/lib/types/context/SerializedContext.d.ts +46 -0
- package/lib/types/context/index.d.ts +2 -0
- package/lib/types/enforcer/EnforcerBase.d.ts +2 -13
- package/lib/types/enforcer/index.d.ts +3 -2
- package/lib/types/enforcer/utils.d.ts +7 -0
- package/lib/types/impl/url/UrlImpl.d.ts +1 -0
- package/lib/types/monitored_request/MonitoredRequestUtils.d.ts +27 -18
- package/lib/types/phase/flow/EndEnforcerFlow.d.ts +1 -1
- package/lib/types/phase/flow/EnforceFlow.d.ts +3 -1
- package/lib/types/phase/flow/PostEnforceFlow.d.ts +1 -1
- package/lib/types/products/bot_defender/first_party/IDefaultBotDefenderFirstPartyConfiguration.d.ts +0 -0
- package/lib/types/products/bot_defender/first_party/utils.d.ts +7 -6
- package/lib/types/pxhd/PXHDUtils.d.ts +18 -12
- package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +2 -0
- package/lib/types/risk_api/risk_response/index.d.ts +1 -0
- package/lib/types/risk_api/risk_response/serialize/RiskResponseJson.d.ts +15 -0
- package/lib/types/risk_api/risk_response/serialize/SerializedRiskResponse.d.ts +19 -0
- package/lib/types/risk_api/risk_response/serialize/index.d.ts +2 -0
- package/lib/types/risk_token/token/IToken.d.ts +3 -3
- package/lib/types/risk_token/token/TokenBase.d.ts +6 -4
- package/lib/types/risk_token/token/index.d.ts +5 -7
- package/lib/types/risk_token/token/serialize/SerializedToken.d.ts +23 -0
- package/lib/types/risk_token/token/serialize/TokenJson.d.ts +13 -0
- package/lib/types/risk_token/token/serialize/index.d.ts +2 -0
- package/lib/types/risk_token/token/v2/index.d.ts +2 -0
- package/lib/types/risk_token/token/v3/DefaultTokenV3.d.ts +1 -1
- package/lib/types/risk_token/token/v3/index.d.ts +3 -0
- package/lib/types/sensitive_request/SensitiveRequestUtils.d.ts +18 -12
- package/lib/types/utils/constants.d.ts +1 -1
- package/lib/types/utils/cookie_parser/ICookieParser.d.ts +1 -1
- package/lib/types/utils/cookie_parser/StringSplitCookieParser.d.ts +5 -2
- package/lib/types/utils/url/IUrl.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DefaultTokenV2Parser, DefaultTokenV3Parser, TokenVersion } from '../risk_token';
|
|
2
|
+
import { DefaultRemoteConfigUpdater, HttpRemoteConfigServiceClient } from '../config';
|
|
3
|
+
import { DefaultCors } from '../cors';
|
|
4
|
+
import { DefaultTelemetry } from '../telemetry';
|
|
5
|
+
import { DefaultDataEnrichment } from '../pxde';
|
|
6
|
+
import { DefaultGraphQLParser } from '../graphql';
|
|
7
|
+
import { PostRiskApiClientV2, PostRiskApiClientV3 } from '../risk_api';
|
|
8
|
+
import { HttpActivityClient, HttpBatchedActivityClient } from '../activities';
|
|
9
|
+
import { HttpLogServiceClient } from '../logger';
|
|
10
|
+
import { AccountDefender, BotDefender, CredentialIntelligence, HypeSaleChallenge, ProductName, } from '../products';
|
|
11
|
+
export const createEnforcerInitializationBlock = (config, options) => {
|
|
12
|
+
const { tokenVersion, httpClient, base64Utils, hmacUtils, hashUtils, urlUtils, ipRangeChecker } = options;
|
|
13
|
+
const cipherUtils = tokenVersion === TokenVersion.V2 ? null : options.cipherUtils;
|
|
14
|
+
const cors = options.cors || new DefaultCors(config);
|
|
15
|
+
const telemetry = options.telemetry || new DefaultTelemetry(config, httpClient, base64Utils, hmacUtils);
|
|
16
|
+
const dataEnrichment = options.dataEnrichment || new DefaultDataEnrichment(config, base64Utils, hmacUtils);
|
|
17
|
+
const graphQLParser = options.graphQLParser || new DefaultGraphQLParser(config);
|
|
18
|
+
const tokenParser = options.tokenParser ||
|
|
19
|
+
(tokenVersion === TokenVersion.V2
|
|
20
|
+
? new DefaultTokenV2Parser(config, { base64Utils, hmacUtils })
|
|
21
|
+
: new DefaultTokenV3Parser(config, { cipherUtils, hmacUtils }));
|
|
22
|
+
const riskApiClient = options.riskApiClient ||
|
|
23
|
+
(tokenVersion === TokenVersion.V2
|
|
24
|
+
? new PostRiskApiClientV2(config, httpClient)
|
|
25
|
+
: new PostRiskApiClientV3(config, httpClient));
|
|
26
|
+
const activityClient = options.activityClient ||
|
|
27
|
+
(config.maxActivityBatchSize > 1
|
|
28
|
+
? new HttpBatchedActivityClient(config, httpClient)
|
|
29
|
+
: new HttpActivityClient(config, httpClient));
|
|
30
|
+
const logServiceClient = options.logServiceClient || (config.loggerAuthToken ? new HttpLogServiceClient(config, httpClient) : null);
|
|
31
|
+
const remoteConfigStorageClient = options.remoteConfigStorageClient;
|
|
32
|
+
const remoteConfigServiceClient = options.remoteConfigServiceClient ||
|
|
33
|
+
(config.remoteConfigAuthToken ? new HttpRemoteConfigServiceClient(config, httpClient) : null);
|
|
34
|
+
const remoteConfigUpdater = options.remoteConfigUpdater ||
|
|
35
|
+
(remoteConfigStorageClient && remoteConfigServiceClient
|
|
36
|
+
? new DefaultRemoteConfigUpdater(config, {
|
|
37
|
+
serviceClient: remoteConfigServiceClient,
|
|
38
|
+
storageClient: remoteConfigStorageClient,
|
|
39
|
+
base64Utils,
|
|
40
|
+
hmacUtils,
|
|
41
|
+
})
|
|
42
|
+
: null);
|
|
43
|
+
const allOptions = {
|
|
44
|
+
httpClient,
|
|
45
|
+
base64Utils,
|
|
46
|
+
hmacUtils,
|
|
47
|
+
hashUtils,
|
|
48
|
+
urlUtils,
|
|
49
|
+
ipRangeChecker,
|
|
50
|
+
cors,
|
|
51
|
+
telemetry,
|
|
52
|
+
dataEnrichment,
|
|
53
|
+
graphQLParser,
|
|
54
|
+
tokenParser,
|
|
55
|
+
riskApiClient,
|
|
56
|
+
activityClient,
|
|
57
|
+
logServiceClient,
|
|
58
|
+
remoteConfigStorageClient,
|
|
59
|
+
remoteConfigServiceClient,
|
|
60
|
+
remoteConfigUpdater,
|
|
61
|
+
};
|
|
62
|
+
const products = createEnforcerProducts(config, options.products, base64Utils, hashUtils, urlUtils, ipRangeChecker);
|
|
63
|
+
return { products, ...allOptions };
|
|
64
|
+
};
|
|
65
|
+
export const createEnforcerProducts = (config, products, base64Utils, hashUtils, urlUtils, ipRangeChecker) => {
|
|
66
|
+
const botDefender = products?.bd || new BotDefender(config, { base64Utils, ipRangeChecker, urlUtils });
|
|
67
|
+
const accountDefender = products?.ad || new AccountDefender(config, { base64Utils });
|
|
68
|
+
const credentialIntelligence = config.ciEnabled
|
|
69
|
+
? products?.ci || new CredentialIntelligence(config, { hashUtils, urlUtils })
|
|
70
|
+
: null;
|
|
71
|
+
const hypeSaleChallenge = products?.hsc || new HypeSaleChallenge(config, { base64Utils });
|
|
72
|
+
return {
|
|
73
|
+
[ProductName.BOT_DEFENDER]: botDefender,
|
|
74
|
+
[ProductName.ACCOUNT_DEFENDER]: accountDefender,
|
|
75
|
+
[ProductName.CODE_DEFENDER]: products?.cd,
|
|
76
|
+
[ProductName.CREDENTIAL_INTELLIGENCE]: credentialIntelligence,
|
|
77
|
+
[ProductName.HYPE_SALE_CHALLENGE]: hypeSaleChallenge,
|
|
78
|
+
};
|
|
79
|
+
};
|
package/lib/esm/products/bot_defender/first_party/IDefaultBotDefenderFirstPartyConfiguration.js
ADDED
|
File without changes
|
package/lib/esm/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONTENT_TYPE_HEADER_NAME, ContentType } from '../../../../http';
|
|
2
|
-
import { getPropertyFromObject } from '../../../../utils';
|
|
2
|
+
import { EnforcerError, getPropertyFromObject } from '../../../../utils';
|
|
3
3
|
export class BodyCredentialExtractor {
|
|
4
4
|
userField;
|
|
5
5
|
passField;
|
|
@@ -8,14 +8,12 @@ export class BodyCredentialExtractor {
|
|
|
8
8
|
this.passField = passField;
|
|
9
9
|
}
|
|
10
10
|
async extractCredentials(request) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return typeof credentials?.user === 'string' || typeof credentials?.pass === 'string' ? credentials : null;
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
return null;
|
|
11
|
+
const contentType = request.headers.get(CONTENT_TYPE_HEADER_NAME);
|
|
12
|
+
if (!contentType) {
|
|
13
|
+
throw new EnforcerError('cannot extract credentials from body without content-type!');
|
|
18
14
|
}
|
|
15
|
+
const credentials = await this.extractFromBody(contentType, request);
|
|
16
|
+
return typeof credentials?.user === 'string' || typeof credentials?.pass === 'string' ? credentials : null;
|
|
19
17
|
}
|
|
20
18
|
async extractFromBody(contentType, request) {
|
|
21
19
|
if (contentType.includes('json')) {
|
package/lib/esm/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js
CHANGED
|
@@ -4,11 +4,6 @@ export class CustomCredentialExtractor {
|
|
|
4
4
|
this.callback = callback;
|
|
5
5
|
}
|
|
6
6
|
async extractCredentials(request) {
|
|
7
|
-
|
|
8
|
-
return await this.callback(request.getUnderlyingRequest());
|
|
9
|
-
}
|
|
10
|
-
catch (e) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
7
|
+
return this.callback(request.getUnderlyingRequest());
|
|
13
8
|
}
|
|
14
9
|
}
|
|
@@ -66,7 +66,7 @@ export class HypeSaleChallenge {
|
|
|
66
66
|
return customParameters?.[IS_HYPESALE_PARAM_NAME];
|
|
67
67
|
}
|
|
68
68
|
isTokenHscApproved({ tokenParseResult, token }) {
|
|
69
|
-
return tokenParseResult === TokenParseResult.SUCCESSFUL && token?.
|
|
69
|
+
return tokenParseResult === TokenParseResult.SUCCESSFUL && token?.isValidated && token.cpa;
|
|
70
70
|
}
|
|
71
71
|
isRiskResponseHscApproved({ riskApiCallResult, riskResponse }) {
|
|
72
72
|
return (riskApiCallResult === RiskApiCallResult.SUCCESSFUL &&
|
|
@@ -41,4 +41,18 @@ export class RiskResponseBase {
|
|
|
41
41
|
get drc() {
|
|
42
42
|
return this.riskResponse?.drc;
|
|
43
43
|
}
|
|
44
|
+
toJSON() {
|
|
45
|
+
return {
|
|
46
|
+
status: this.status,
|
|
47
|
+
action: this.action,
|
|
48
|
+
message: this.message,
|
|
49
|
+
dataEnrichment: this.dataEnrichment,
|
|
50
|
+
pxhd: this.pxhd,
|
|
51
|
+
pxhdDomain: this.pxhdDomain,
|
|
52
|
+
score: this.score,
|
|
53
|
+
drc: this.drc,
|
|
54
|
+
additionalRiskInfo: this.additionalRiskInfo,
|
|
55
|
+
uuid: this.uuid,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
44
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class SerializedRiskResponse {
|
|
2
|
+
action;
|
|
3
|
+
additionalRiskInfo;
|
|
4
|
+
dataEnrichment;
|
|
5
|
+
drc;
|
|
6
|
+
message;
|
|
7
|
+
pxhd;
|
|
8
|
+
pxhdDomain;
|
|
9
|
+
score;
|
|
10
|
+
status;
|
|
11
|
+
uuid;
|
|
12
|
+
constructor(riskResponseJson) {
|
|
13
|
+
this.action = riskResponseJson.action;
|
|
14
|
+
this.additionalRiskInfo = riskResponseJson.additionalRiskInfo;
|
|
15
|
+
this.dataEnrichment = riskResponseJson.dataEnrichment;
|
|
16
|
+
this.drc = riskResponseJson.drc;
|
|
17
|
+
this.message = riskResponseJson.message;
|
|
18
|
+
this.pxhd = riskResponseJson.pxhd;
|
|
19
|
+
this.pxhdDomain = riskResponseJson.pxhdDomain;
|
|
20
|
+
this.score = riskResponseJson.score;
|
|
21
|
+
this.status = riskResponseJson.status;
|
|
22
|
+
this.uuid = riskResponseJson.uuid;
|
|
23
|
+
}
|
|
24
|
+
validate() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -78,7 +78,7 @@ export class TokenParserBase {
|
|
|
78
78
|
}
|
|
79
79
|
mobileData.originalTokenParseResult = await mobileData.originalToken.verify(context);
|
|
80
80
|
if (mobileData.originalTokenParseResult === TokenParseResult.SUCCESSFUL) {
|
|
81
|
-
mobileData.decodedOriginalToken = mobileData.originalToken.
|
|
81
|
+
mobileData.decodedOriginalToken = mobileData.originalToken.payloadString;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -6,12 +6,13 @@ export class TokenBase {
|
|
|
6
6
|
cookieSecret;
|
|
7
7
|
cookieMaxLength;
|
|
8
8
|
isValidated;
|
|
9
|
-
constructor(config, cookieString) {
|
|
9
|
+
constructor(config, cookieString, isValidated = false, payload) {
|
|
10
10
|
this.config = config;
|
|
11
11
|
this.cookieSecret = config.cookieSecret;
|
|
12
12
|
this.cookieMaxLength = config.riskCookieMaxLength;
|
|
13
13
|
this.cookieString = cookieString;
|
|
14
|
-
this.isValidated =
|
|
14
|
+
this.isValidated = isValidated;
|
|
15
|
+
this.payload = payload;
|
|
15
16
|
}
|
|
16
17
|
async verify(context) {
|
|
17
18
|
if (!this.cookieString) {
|
|
@@ -36,10 +37,24 @@ export class TokenBase {
|
|
|
36
37
|
isValid() {
|
|
37
38
|
return this.isValidated;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
get tokenString() {
|
|
40
41
|
return this.cookieString;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
get payloadString() {
|
|
43
44
|
return this.payload ? JSON.stringify(this.payload) : '';
|
|
44
45
|
}
|
|
46
|
+
toJSON() {
|
|
47
|
+
return {
|
|
48
|
+
action: this.action,
|
|
49
|
+
cpa: this.cpa,
|
|
50
|
+
hmac: this.hmac,
|
|
51
|
+
isValidated: this.isValidated,
|
|
52
|
+
payloadString: this.payloadString,
|
|
53
|
+
score: this.score,
|
|
54
|
+
timestamp: this.timestamp,
|
|
55
|
+
tokenString: this.tokenString,
|
|
56
|
+
uuid: this.uuid,
|
|
57
|
+
vid: this.vid,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
45
60
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export * from './IToken';
|
|
2
|
+
export * from './TokenBase';
|
|
3
|
+
export * from './v2';
|
|
4
|
+
export * from './v3';
|
|
5
|
+
export * from './serialize';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TokenParseResult } from '../../TokenParseResult';
|
|
2
|
+
export class SerializedToken {
|
|
3
|
+
action;
|
|
4
|
+
cpa;
|
|
5
|
+
hmac;
|
|
6
|
+
isValidated;
|
|
7
|
+
payloadString;
|
|
8
|
+
score;
|
|
9
|
+
timestamp;
|
|
10
|
+
tokenString;
|
|
11
|
+
uuid;
|
|
12
|
+
vid;
|
|
13
|
+
blockingScore;
|
|
14
|
+
constructor(config, serializedToken) {
|
|
15
|
+
this.blockingScore = config.blockingScore;
|
|
16
|
+
this.action = serializedToken.action;
|
|
17
|
+
this.cpa = serializedToken.cpa;
|
|
18
|
+
this.hmac = serializedToken.hmac;
|
|
19
|
+
this.isValidated = serializedToken.isValidated;
|
|
20
|
+
this.payloadString = serializedToken.payloadString;
|
|
21
|
+
this.score = serializedToken.score;
|
|
22
|
+
this.timestamp = serializedToken.timestamp;
|
|
23
|
+
this.tokenString = serializedToken.tokenString;
|
|
24
|
+
this.uuid = serializedToken.uuid;
|
|
25
|
+
this.vid = serializedToken.vid;
|
|
26
|
+
}
|
|
27
|
+
isExpired() {
|
|
28
|
+
return Date.now() >= this.timestamp;
|
|
29
|
+
}
|
|
30
|
+
isHighScore() {
|
|
31
|
+
return this.score >= this.blockingScore;
|
|
32
|
+
}
|
|
33
|
+
verify(context) {
|
|
34
|
+
return TokenParseResult.NONE;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,8 +9,8 @@ export class DefaultTokenV3 extends TokenBase {
|
|
|
9
9
|
cipherUtils;
|
|
10
10
|
hmacUtils;
|
|
11
11
|
hash;
|
|
12
|
-
constructor(config, cookieString, cipherUtils, hmacUtils) {
|
|
13
|
-
super(config, cookieString);
|
|
12
|
+
constructor(config, cookieString, cipherUtils, hmacUtils, isValidated = false, payload) {
|
|
13
|
+
super(config, cookieString, isValidated, payload);
|
|
14
14
|
this.maxIterations = config.riskCookieMaxIterations;
|
|
15
15
|
this.minIterations = config.riskCookieMinIterations;
|
|
16
16
|
this.blockingScore = config.blockingScore;
|
|
@@ -10,4 +10,4 @@ export const PUSH_DATA_HMAC_HEADER_NAME = 'x-px-pushdata';
|
|
|
10
10
|
export const PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
|
|
11
11
|
export const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
12
12
|
export const URL_REGEX = /^(https?\:)\/\/(([^@\s:]+):?([^@\s]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
13
|
-
export const CORE_MODULE_VERSION = 'JS Core 0.
|
|
13
|
+
export const CORE_MODULE_VERSION = 'JS Core 0.18.0';
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
export class StringSplitCookieParser {
|
|
2
|
-
|
|
2
|
+
cookieDelimiter;
|
|
3
|
+
constructor(cookieDelimiter = ';') {
|
|
4
|
+
this.cookieDelimiter = cookieDelimiter;
|
|
5
|
+
}
|
|
6
|
+
parseCookies(...cookieHeaderValues) {
|
|
7
|
+
const cookies = {};
|
|
8
|
+
if (!cookieHeaderValues) {
|
|
9
|
+
return cookies;
|
|
10
|
+
}
|
|
11
|
+
cookieHeaderValues.forEach((value) => {
|
|
12
|
+
Object.assign(cookies, this.parseCookieHeaderValue(value));
|
|
13
|
+
});
|
|
14
|
+
return cookies;
|
|
15
|
+
}
|
|
16
|
+
parseCookieHeaderValue(cookieHeaderValue) {
|
|
3
17
|
if (!cookieHeaderValue || typeof cookieHeaderValue !== 'string') {
|
|
4
18
|
return {};
|
|
5
19
|
}
|
|
6
|
-
const
|
|
7
|
-
const cookieEntries = cookieHeaderValue.split(COOKIE_DELIMITER).map(this.getCookieParts).filter(Boolean);
|
|
20
|
+
const cookieEntries = cookieHeaderValue.split(this.cookieDelimiter).map(this.getCookieParts).filter(Boolean);
|
|
8
21
|
const cookies = {};
|
|
9
22
|
cookieEntries.forEach(([cookieName, cookieValue]) => {
|
|
10
23
|
cookies[cookieName] = cookieValue;
|
|
@@ -10,6 +10,12 @@ export declare class HttpActivityClient<Req, Res> implements IActivityClient<Req
|
|
|
10
10
|
constructor(config: IConfiguration<Req, Res>, httpClient: IHttpClient);
|
|
11
11
|
sendActivities(context: ReadonlyContext<Req, Res>): Promise<boolean>;
|
|
12
12
|
protected createActivities(context: ReadonlyContext<Req, Res>): AsyncActivity[];
|
|
13
|
+
protected shouldCreateBlockActivity(context: ReadonlyContext<Req, Res>): boolean;
|
|
14
|
+
protected shouldCreatePageRequestedActivity(context: ReadonlyContext<Req, Res>): boolean;
|
|
15
|
+
protected shouldCreateAdditionalS2SActivity(context: ReadonlyContext<Req, Res>): boolean;
|
|
16
|
+
protected createBlockActivity(context: ReadonlyContext<Req, Res>): AsyncActivity;
|
|
17
|
+
protected createPageRequestedActivity(context: ReadonlyContext<Req, Res>): AsyncActivity;
|
|
18
|
+
protected createAdditionalS2SActivity(context: ReadonlyContext<Req, Res>): AsyncActivity;
|
|
13
19
|
/**
|
|
14
20
|
* Allows for expansions or alterations to the async activity if needed.
|
|
15
21
|
* @param activity
|