perimeterx-js-core 0.5.1 → 0.6.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 +20 -15
- package/lib/action/Action.d.ts +6 -0
- package/lib/action/Action.js +7 -0
- package/lib/action/ActionData.d.ts +11 -0
- package/lib/action/ActionData.js +1 -0
- package/lib/action/ActionPriorityOrder.d.ts +2 -0
- package/lib/action/ActionPriorityOrder.js +7 -0
- package/lib/action/Decision.d.ts +6 -0
- package/lib/action/Decision.js +1 -0
- package/lib/action/index.d.ts +4 -0
- package/lib/action/index.js +4 -0
- package/lib/activities/ActivityType.js +2 -5
- package/lib/activities/HttpActivityClient.d.ts +7 -7
- package/lib/activities/HttpActivityClient.js +46 -95
- package/lib/activities/HttpBatchedActivityClient.d.ts +2 -2
- package/lib/activities/HttpBatchedActivityClient.js +46 -115
- package/lib/activities/IActivityClient.d.ts +3 -3
- package/lib/activities/IActivityClient.js +1 -2
- package/lib/activities/constants.js +1 -4
- package/lib/activities/index.d.ts +7 -6
- package/lib/activities/index.js +7 -9
- package/lib/activities/model/Activity.js +1 -2
- package/lib/activities/model/ActivityDetails.d.ts +9 -7
- package/lib/activities/model/ActivityDetails.js +1 -2
- package/lib/activities/model/index.d.ts +2 -0
- package/lib/activities/model/index.js +2 -0
- package/lib/activities/utils.d.ts +11 -8
- package/lib/activities/utils.js +65 -43
- package/lib/additional_activity_handler/AdditionalActivityHandler.d.ts +2 -2
- package/lib/additional_activity_handler/AdditionalActivityHandler.js +1 -2
- package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +2 -2
- package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.js +11 -53
- package/lib/additional_activity_handler/index.d.ts +2 -2
- package/lib/additional_activity_handler/index.js +2 -5
- package/lib/{block_handler → blocker}/BlockAction.d.ts +0 -1
- package/lib/blocker/BlockAction.js +6 -0
- package/lib/blocker/BlockActionToProductMap.d.ts +3 -0
- package/lib/blocker/BlockActionToProductMap.js +7 -0
- package/lib/blocker/BlockActionToWordMap.d.ts +2 -0
- package/lib/blocker/BlockActionToWordMap.js +6 -0
- package/lib/blocker/IBlocker.d.ts +5 -0
- package/lib/blocker/IBlocker.js +1 -0
- package/lib/blocker/IConditionalBlocker.d.ts +9 -0
- package/lib/blocker/IConditionalBlocker.js +1 -0
- package/lib/blocker/index.d.ts +5 -0
- package/lib/blocker/index.js +5 -0
- package/lib/config/ConfigurationParams.d.ts +20 -12
- package/lib/config/ConfigurationParams.js +1 -2
- package/lib/config/DefaultConfigurations.d.ts +1 -1
- package/lib/config/DefaultConfigurations.js +15 -13
- package/lib/config/IConfiguration.d.ts +103 -10
- package/lib/config/IConfiguration.js +1 -2
- package/lib/config/StaticConfigurationBase.d.ts +29 -6
- package/lib/config/StaticConfigurationBase.js +244 -394
- package/lib/config/index.js +2 -7
- package/lib/context/DefaultContext.d.ts +46 -0
- package/lib/context/DefaultContext.js +82 -0
- package/lib/context/index.d.ts +2 -4
- package/lib/context/index.js +2 -20
- package/lib/context/interfaces/IContext.d.ts +111 -0
- package/lib/context/interfaces/IContext.js +1 -0
- package/lib/context/interfaces/MobileData.d.ts +23 -0
- package/lib/context/interfaces/MobileData.js +1 -0
- package/lib/context/interfaces/ReadonlyContext.d.ts +3 -0
- package/lib/context/interfaces/ReadonlyContext.js +1 -0
- package/lib/context/interfaces/RequestData.d.ts +41 -0
- package/lib/context/interfaces/RequestData.js +1 -0
- package/lib/context/interfaces/RiskApiData.d.ts +27 -0
- package/lib/context/interfaces/RiskApiData.js +1 -0
- package/lib/context/interfaces/ServerData.d.ts +18 -0
- package/lib/context/interfaces/ServerData.js +1 -0
- package/lib/context/interfaces/TlsData.d.ts +30 -0
- package/lib/context/interfaces/TlsData.js +1 -0
- package/lib/context/interfaces/TokenData.d.ts +16 -0
- package/lib/context/interfaces/TokenData.js +1 -0
- package/lib/context/interfaces/index.d.ts +8 -0
- package/lib/context/interfaces/index.js +8 -0
- package/lib/cors/CustomBlockResponseHeadersHandler.d.ts +2 -2
- package/lib/cors/CustomBlockResponseHeadersHandler.js +1 -2
- package/lib/cors/CustomPreflightHandler.d.ts +2 -2
- package/lib/cors/CustomPreflightHandler.js +1 -2
- package/lib/cors/DefaultCors.d.ts +9 -9
- package/lib/cors/DefaultCors.js +39 -87
- package/lib/cors/ICors.d.ts +7 -7
- package/lib/cors/ICors.js +1 -2
- package/lib/cors/constants.js +2 -5
- package/lib/cors/index.js +2 -20
- package/lib/custom_parameters/CustomParameters.js +1 -2
- package/lib/custom_parameters/CustomParametersFunction.d.ts +1 -2
- package/lib/custom_parameters/CustomParametersFunction.js +1 -2
- package/lib/custom_parameters/CustomParametersUtils.d.ts +2 -2
- package/lib/custom_parameters/CustomParametersUtils.js +18 -60
- package/lib/custom_parameters/index.js +1 -5
- package/lib/enforcer/EnforcerBase.d.ts +43 -85
- package/lib/enforcer/EnforcerBase.js +120 -411
- package/lib/enforcer/IEnforcer.js +1 -2
- package/lib/enforcer/index.d.ts +2 -1
- package/lib/enforcer/index.js +2 -5
- package/lib/enforcer/options/EnforcerBaseOptions.d.ts +25 -0
- package/lib/enforcer/options/EnforcerBaseOptions.js +1 -0
- package/lib/enforcer/options/EnforcerOptionsType.d.ts +4 -0
- package/lib/enforcer/options/EnforcerOptionsType.js +1 -0
- package/lib/enforcer/options/EnforcerV2Options.d.ts +5 -0
- package/lib/enforcer/options/EnforcerV2Options.js +1 -0
- package/lib/enforcer/options/EnforcerV3Options.d.ts +7 -0
- package/lib/enforcer/options/EnforcerV3Options.js +1 -0
- package/lib/enforcer/options/index.d.ts +4 -0
- package/lib/enforcer/options/index.js +4 -0
- package/lib/filter/FilterReason.d.ts +2 -1
- package/lib/filter/FilterReason.js +3 -5
- package/lib/filter/IFilter.d.ts +4 -4
- package/lib/filter/IFilter.js +1 -2
- package/lib/filter/index.d.ts +2 -3
- package/lib/filter/index.js +2 -7
- package/lib/first_party/FirstPartyData.d.ts +5 -0
- package/lib/first_party/FirstPartyData.js +1 -0
- package/lib/first_party/IFirstParty.d.ts +5 -5
- package/lib/first_party/IFirstParty.js +1 -2
- package/lib/first_party/index.d.ts +2 -4
- package/lib/first_party/index.js +2 -21
- package/lib/graphql/DefaultGraphQLParser.d.ts +6 -5
- package/lib/graphql/DefaultGraphQLParser.js +77 -133
- package/lib/graphql/IGraphQLParser.d.ts +5 -4
- package/lib/graphql/IGraphQLParser.js +1 -2
- package/lib/graphql/index.d.ts +3 -5
- package/lib/graphql/index.js +3 -7
- package/lib/graphql/model/GraphQLData.js +1 -2
- package/lib/graphql/model/GraphQLOperation.js +1 -2
- package/lib/graphql/model/GraphQLOperationType.js +2 -5
- package/lib/graphql/model/index.d.ts +3 -0
- package/lib/graphql/model/index.js +3 -0
- package/lib/http/impl/FormDataImpl.d.ts +12 -0
- package/lib/http/impl/FormDataImpl.js +36 -0
- package/lib/http/impl/MinimalResponseImpl.d.ts +3 -3
- package/lib/http/impl/MinimalResponseImpl.js +3 -8
- package/lib/http/impl/OutgoingRequestImpl.d.ts +3 -3
- package/lib/http/impl/OutgoingRequestImpl.js +5 -10
- package/lib/http/impl/index.d.ts +1 -0
- package/lib/http/impl/index.js +4 -19
- package/lib/http/impl/phin/PhinHttpClient.js +30 -70
- package/lib/http/impl/phin/PhinIncomingResponse.d.ts +4 -5
- package/lib/http/impl/phin/PhinIncomingResponse.js +22 -70
- package/lib/http/impl/phin/index.js +2 -18
- package/lib/http/index.js +3 -19
- package/lib/http/interfaces/IBody.d.ts +10 -12
- package/lib/http/interfaces/IBody.js +1 -2
- package/lib/http/interfaces/IFormData.d.ts +9 -0
- package/lib/http/interfaces/IFormData.js +1 -0
- package/lib/http/interfaces/IHeaders.js +1 -2
- package/lib/http/interfaces/IHttpClient.js +1 -2
- package/lib/http/interfaces/IIncomingRequest.d.ts +10 -6
- package/lib/http/interfaces/IIncomingRequest.js +1 -2
- package/lib/http/interfaces/IIncomingResponse.d.ts +2 -2
- package/lib/http/interfaces/IIncomingResponse.js +1 -2
- package/lib/http/interfaces/IMinimalResponse.d.ts +2 -2
- package/lib/http/interfaces/IMinimalResponse.js +1 -2
- package/lib/http/interfaces/IOutgoingRequest.d.ts +2 -2
- package/lib/http/interfaces/IOutgoingRequest.js +1 -2
- package/lib/http/interfaces/IOutgoingResponse.d.ts +5 -1
- package/lib/http/interfaces/IOutgoingResponse.js +1 -2
- package/lib/http/interfaces/IURL.d.ts +6 -0
- package/lib/http/interfaces/IURL.js +1 -0
- package/lib/http/interfaces/ReadonlyHeaders.d.ts +6 -0
- package/lib/http/interfaces/ReadonlyHeaders.js +14 -0
- package/lib/http/interfaces/index.d.ts +3 -1
- package/lib/http/interfaces/index.js +11 -25
- package/lib/http/utils/ContentType.js +2 -5
- package/lib/http/utils/HttpMethod.js +2 -5
- package/lib/http/utils/MinimalResponseUtils.d.ts +6 -6
- package/lib/http/utils/MinimalResponseUtils.js +31 -48
- package/lib/http/utils/MultipartFormDataUtils.d.ts +6 -0
- package/lib/http/utils/MultipartFormDataUtils.js +45 -0
- package/lib/http/utils/constants.js +9 -12
- package/lib/http/utils/index.d.ts +3 -1
- package/lib/http/utils/index.js +5 -21
- package/lib/index.d.ts +4 -1
- package/lib/index.js +22 -35
- package/lib/logger/DefaultLogger.js +7 -28
- package/lib/logger/ILogger.js +1 -2
- package/lib/logger/LoggerBase.d.ts +2 -0
- package/lib/logger/LoggerBase.js +24 -22
- package/lib/logger/LoggerSeverity.js +2 -5
- package/lib/logger/index.js +3 -9
- package/lib/phase/IPhase.d.ts +5 -0
- package/lib/phase/IPhase.js +1 -0
- package/lib/phase/PhaseResult.d.ts +5 -0
- package/lib/phase/PhaseResult.js +1 -0
- package/lib/phase/flow/EnforceFlow.d.ts +6 -0
- package/lib/phase/flow/EnforceFlow.js +15 -0
- package/lib/phase/flow/FilterFlow.d.ts +6 -0
- package/lib/phase/flow/FilterFlow.js +12 -0
- package/lib/phase/flow/PostEnforceFlow.d.ts +6 -0
- package/lib/phase/flow/PostEnforceFlow.js +10 -0
- package/lib/phase/flow/index.d.ts +3 -0
- package/lib/phase/flow/index.js +3 -0
- package/lib/phase/impl/AdditionalActivityHandlerPhase.d.ts +9 -0
- package/lib/phase/impl/AdditionalActivityHandlerPhase.js +22 -0
- package/lib/phase/impl/CompositePhase.d.ts +8 -0
- package/lib/phase/impl/CompositePhase.js +26 -0
- package/lib/phase/impl/CreateBlockResponsePhase.d.ts +17 -0
- package/lib/phase/impl/CreateBlockResponsePhase.js +60 -0
- package/lib/phase/impl/DecideActionPhase.d.ts +19 -0
- package/lib/phase/impl/DecideActionPhase.js +56 -0
- package/lib/phase/impl/EnrichContextFromRequestPhase.d.ts +18 -0
- package/lib/phase/impl/EnrichContextFromRequestPhase.js +59 -0
- package/lib/phase/impl/EnrichContextFromResponsePhase.d.ts +10 -0
- package/lib/phase/impl/EnrichContextFromResponsePhase.js +29 -0
- package/lib/phase/impl/FilterPhase.d.ts +9 -0
- package/lib/phase/impl/FilterPhase.js +19 -0
- package/lib/phase/impl/FirstPartyPhase.d.ts +12 -0
- package/lib/phase/impl/FirstPartyPhase.js +42 -0
- package/lib/phase/impl/ModifyIncomingRequestPhase.d.ts +9 -0
- package/lib/phase/impl/ModifyIncomingRequestPhase.js +20 -0
- package/lib/phase/impl/ModifyOutgoingResponsePhase.d.ts +9 -0
- package/lib/phase/impl/ModifyOutgoingResponsePhase.js +25 -0
- package/lib/phase/impl/ParseTokenPhase.d.ts +10 -0
- package/lib/phase/impl/ParseTokenPhase.js +37 -0
- package/lib/phase/impl/PreflightPhase.d.ts +12 -0
- package/lib/phase/impl/PreflightPhase.js +28 -0
- package/lib/phase/impl/RiskApiPhase.d.ts +17 -0
- package/lib/phase/impl/RiskApiPhase.js +76 -0
- package/lib/phase/impl/SendAsyncActivitiesOnRequestPhase.d.ts +10 -0
- package/lib/phase/impl/SendAsyncActivitiesOnRequestPhase.js +28 -0
- package/lib/phase/impl/SendAsyncActivitiesOnResponsePhase.d.ts +9 -0
- package/lib/phase/impl/SendAsyncActivitiesOnResponsePhase.js +20 -0
- package/lib/phase/impl/TelemetryPhase.d.ts +10 -0
- package/lib/phase/impl/TelemetryPhase.js +29 -0
- package/lib/phase/impl/index.d.ts +16 -0
- package/lib/phase/impl/index.js +16 -0
- package/lib/phase/index.d.ts +4 -0
- package/lib/phase/index.js +4 -0
- package/lib/products/account_defender/AccountDefender.d.ts +23 -0
- package/lib/products/account_defender/AccountDefender.js +98 -0
- package/lib/products/account_defender/AccountDefenderData.d.ts +6 -0
- package/lib/products/account_defender/AccountDefenderData.js +1 -0
- package/lib/products/account_defender/IAccountDefender.d.ts +4 -0
- package/lib/products/account_defender/IAccountDefender.js +1 -0
- package/lib/products/account_defender/JwtData.d.ts +4 -0
- package/lib/products/account_defender/JwtData.js +1 -0
- package/lib/products/account_defender/constants.d.ts +1 -0
- package/lib/products/account_defender/constants.js +1 -0
- package/lib/products/account_defender/index.d.ts +5 -0
- package/lib/products/account_defender/index.js +5 -0
- package/lib/products/bot_defender/BotDefender.d.ts +47 -0
- package/lib/products/bot_defender/BotDefender.js +135 -0
- package/lib/products/bot_defender/BotDefenderActionData.d.ts +7 -0
- package/lib/products/bot_defender/BotDefenderActionData.js +6 -0
- package/lib/products/bot_defender/BotDefenderData.d.ts +13 -0
- package/lib/products/bot_defender/BotDefenderData.js +1 -0
- package/lib/products/bot_defender/BotDefenderUtils.d.ts +5 -0
- package/lib/products/bot_defender/BotDefenderUtils.js +19 -0
- package/lib/products/bot_defender/IBotDefender.d.ts +7 -0
- package/lib/products/bot_defender/IBotDefender.js +1 -0
- package/lib/products/bot_defender/block/DefaultBotDefenderBlocker.d.ts +14 -0
- package/lib/products/bot_defender/block/DefaultBotDefenderBlocker.js +39 -0
- package/lib/products/bot_defender/block/captcha/CaptchaBlocker.d.ts +13 -0
- package/lib/products/bot_defender/block/captcha/CaptchaBlocker.js +20 -0
- package/lib/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +9 -0
- package/lib/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +20 -0
- package/lib/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +10 -0
- package/lib/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +38 -0
- package/lib/products/bot_defender/block/captcha/MobileCaptchaBlocker.d.ts +12 -0
- package/lib/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +34 -0
- package/lib/products/bot_defender/block/captcha/index.d.ts +4 -0
- package/lib/products/bot_defender/block/captcha/index.js +4 -0
- package/lib/products/bot_defender/block/index.d.ts +5 -0
- package/lib/products/bot_defender/block/index.js +5 -0
- package/lib/{block_handler → products/bot_defender/block}/model/BlockData.d.ts +1 -1
- package/lib/products/bot_defender/block/model/BlockData.js +1 -0
- package/lib/products/bot_defender/block/model/JsonBlockPayload.js +1 -0
- package/lib/products/bot_defender/block/model/MobileBlockPayload.js +1 -0
- package/lib/products/bot_defender/block/model/index.d.ts +3 -0
- package/lib/products/bot_defender/block/model/index.js +3 -0
- package/lib/products/bot_defender/block/templates/captcha_template.js +50 -0
- package/lib/products/bot_defender/block/templates/index.d.ts +2 -0
- package/lib/products/bot_defender/block/templates/index.js +2 -0
- package/lib/products/bot_defender/block/templates/rate_limit_template.js +10 -0
- package/lib/products/bot_defender/block/utils.d.ts +5 -0
- package/lib/products/bot_defender/block/utils.js +43 -0
- package/lib/products/bot_defender/filter/DefaultBotDefenderFilter.d.ts +16 -0
- package/lib/products/bot_defender/filter/DefaultBotDefenderFilter.js +51 -0
- package/lib/products/bot_defender/filter/index.d.ts +1 -0
- package/lib/products/bot_defender/filter/index.js +1 -0
- package/lib/products/bot_defender/first_party/DefaultBotDefenderFirstParty.d.ts +20 -0
- package/lib/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +129 -0
- package/lib/products/bot_defender/first_party/FirstPartySuffix.d.ts +5 -0
- package/lib/products/bot_defender/first_party/FirstPartySuffix.js +6 -0
- package/lib/{first_party → products/bot_defender/first_party}/constants.d.ts +5 -2
- package/lib/products/bot_defender/first_party/constants.js +36 -0
- package/lib/products/bot_defender/first_party/index.d.ts +4 -0
- package/lib/products/bot_defender/first_party/index.js +4 -0
- package/lib/products/bot_defender/first_party/utils.d.ts +11 -0
- package/lib/products/bot_defender/first_party/utils.js +46 -0
- package/lib/products/bot_defender/index.d.ts +9 -0
- package/lib/products/bot_defender/index.js +9 -0
- package/lib/{block_handler/BlockReason.d.ts → products/bot_defender/reasons/BotDefenderBlockReason.d.ts} +1 -1
- package/lib/products/bot_defender/reasons/BotDefenderBlockReason.js +5 -0
- package/lib/{utils/PassReason.d.ts → products/bot_defender/reasons/BotDefenderPassReason.d.ts} +1 -1
- package/lib/products/bot_defender/reasons/BotDefenderPassReason.js +7 -0
- package/lib/products/bot_defender/reasons/BotDefenderReasonType.d.ts +5 -0
- package/lib/products/bot_defender/reasons/BotDefenderReasonType.js +1 -0
- package/lib/{risk_api/S2SCallReason.d.ts → products/bot_defender/reasons/BotDefenderS2SCallReason.d.ts} +1 -1
- package/lib/products/bot_defender/reasons/BotDefenderS2SCallReason.js +13 -0
- package/lib/products/bot_defender/reasons/index.d.ts +4 -0
- package/lib/products/bot_defender/reasons/index.js +4 -0
- package/lib/products/credential_intelligence/CredentialIntelligence.d.ts +22 -0
- package/lib/products/credential_intelligence/CredentialIntelligence.js +96 -0
- package/lib/products/credential_intelligence/ICredentialIntelligence.d.ts +4 -0
- package/lib/products/credential_intelligence/ICredentialIntelligence.js +1 -0
- package/lib/products/credential_intelligence/constants.d.ts +4 -0
- package/lib/products/credential_intelligence/constants.js +4 -0
- package/lib/products/credential_intelligence/endpoint/CredentialEndpoint.d.ts +21 -0
- package/lib/products/credential_intelligence/endpoint/CredentialEndpoint.js +37 -0
- package/lib/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.d.ts +74 -0
- package/lib/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.js +1 -0
- package/lib/products/credential_intelligence/endpoint/CredentialEndpointManager.d.ts +12 -0
- package/lib/products/credential_intelligence/endpoint/CredentialEndpointManager.js +32 -0
- package/lib/products/credential_intelligence/endpoint/ICredentialEndpoint.d.ts +9 -0
- package/lib/products/credential_intelligence/endpoint/ICredentialEndpoint.js +1 -0
- package/lib/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.d.ts +15 -0
- package/lib/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js +64 -0
- package/lib/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.js +21 -0
- package/lib/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.d.ts +9 -0
- package/lib/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js +24 -0
- package/lib/products/credential_intelligence/endpoint/extractor/HeaderCredentialExtractor.d.ts +10 -0
- package/lib/products/credential_intelligence/endpoint/extractor/HeaderCredentialExtractor.js +22 -0
- package/lib/products/credential_intelligence/endpoint/extractor/ICredentialExtractor.d.ts +6 -0
- package/lib/products/credential_intelligence/endpoint/extractor/ICredentialExtractor.js +1 -0
- package/lib/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.d.ts +10 -0
- package/lib/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +23 -0
- package/lib/products/credential_intelligence/endpoint/extractor/SentThrough.d.ts +6 -0
- package/lib/products/credential_intelligence/endpoint/extractor/SentThrough.js +7 -0
- package/lib/products/credential_intelligence/endpoint/extractor/index.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/extractor/index.js +5 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/CredentialIntelligenceHashProtocolFactory.d.ts +6 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/CredentialIntelligenceHashProtocolFactory.js +17 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/CredentialIntelligenceVersion.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/CredentialIntelligenceVersion.js +6 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/ICredentialIntelligenceHashProtocol.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/ICredentialIntelligenceHashProtocol.js +1 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/MultistepHashProtocol.d.ts +8 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/MultistepHashProtocol.js +30 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepAndMultistepHashProtocol.d.ts +8 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepAndMultistepHashProtocol.js +25 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepHashProtocol.d.ts +10 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepHashProtocol.js +49 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SsoStep.d.ts +4 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SsoStep.js +5 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/index.d.ts +7 -0
- package/lib/products/credential_intelligence/endpoint/hash_protocol/index.js +7 -0
- package/lib/products/credential_intelligence/endpoint/index.d.ts +8 -0
- package/lib/products/credential_intelligence/endpoint/index.js +8 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.d.ts +7 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +20 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulCallback.d.ts +1 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulCallback.js +1 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulParser.d.ts +8 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulParser.js +26 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/HeaderLoginSuccessfulParser.d.ts +8 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/HeaderLoginSuccessfulParser.js +23 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/ILoginSuccessfulParser.d.ts +4 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/ILoginSuccessfulParser.js +1 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.d.ts +6 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +26 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulReportingMethod.d.ts +6 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulReportingMethod.js +7 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/StatusLoginSuccessfulParser.d.ts +7 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/StatusLoginSuccessfulParser.js +19 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/index.d.ts +8 -0
- package/lib/products/credential_intelligence/endpoint/login_successful/index.js +8 -0
- package/lib/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +14 -0
- package/lib/products/credential_intelligence/endpoint/matcher/ExactPathEndpointMatcher.d.ts +10 -0
- package/lib/products/credential_intelligence/endpoint/matcher/ExactPathEndpointMatcher.js +9 -0
- package/lib/products/credential_intelligence/endpoint/matcher/ICredentialIntelligenceEndpointMatcher.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/matcher/ICredentialIntelligenceEndpointMatcher.js +1 -0
- package/lib/products/credential_intelligence/endpoint/matcher/PathType.d.ts +4 -0
- package/lib/products/credential_intelligence/endpoint/matcher/PathType.js +5 -0
- package/lib/products/credential_intelligence/endpoint/matcher/RegexPathEndpointMatcher.d.ts +10 -0
- package/lib/products/credential_intelligence/endpoint/matcher/RegexPathEndpointMatcher.js +9 -0
- package/lib/products/credential_intelligence/endpoint/matcher/index.d.ts +5 -0
- package/lib/products/credential_intelligence/endpoint/matcher/index.js +5 -0
- package/lib/products/credential_intelligence/index.d.ts +5 -0
- package/lib/products/credential_intelligence/index.js +5 -0
- package/lib/products/credential_intelligence/model/CredentialData.d.ts +8 -0
- package/lib/products/credential_intelligence/model/CredentialData.js +1 -0
- package/lib/products/credential_intelligence/model/CredentialIntelligenceData.d.ts +7 -0
- package/lib/products/credential_intelligence/model/CredentialIntelligenceData.js +1 -0
- package/lib/products/credential_intelligence/model/Credentials.d.ts +4 -0
- package/lib/products/credential_intelligence/model/Credentials.js +1 -0
- package/lib/products/credential_intelligence/model/CustomExtractionCallback.d.ts +2 -0
- package/lib/products/credential_intelligence/model/CustomExtractionCallback.js +1 -0
- package/lib/products/credential_intelligence/model/index.d.ts +4 -0
- package/lib/products/credential_intelligence/model/index.js +4 -0
- package/lib/products/index.d.ts +5 -0
- package/lib/products/index.js +5 -0
- package/lib/products/interfaces/IProduct.d.ts +10 -0
- package/lib/products/interfaces/IProduct.js +1 -0
- package/lib/products/interfaces/ProductData.d.ts +5 -0
- package/lib/products/interfaces/ProductData.js +1 -0
- package/lib/products/interfaces/ProductDataType.d.ts +5 -0
- package/lib/products/interfaces/ProductDataType.js +1 -0
- package/lib/products/interfaces/ProductType.d.ts +5 -0
- package/lib/products/interfaces/ProductType.js +1 -0
- package/lib/products/interfaces/Products.d.ts +5 -0
- package/lib/products/interfaces/Products.js +1 -0
- package/lib/products/interfaces/index.d.ts +5 -0
- package/lib/products/interfaces/index.js +5 -0
- package/lib/products/utils/ProductName.d.ts +7 -0
- package/lib/products/utils/ProductName.js +8 -0
- package/lib/products/utils/ProductPriorityOrder.d.ts +2 -0
- package/lib/products/utils/ProductPriorityOrder.js +8 -0
- package/lib/products/utils/index.d.ts +3 -0
- package/lib/products/utils/index.js +3 -0
- package/lib/products/utils/utils.d.ts +5 -0
- package/lib/products/utils/utils.js +12 -0
- package/lib/pxde/DefaultDataEnrichment.d.ts +7 -6
- package/lib/pxde/DefaultDataEnrichment.js +57 -116
- package/lib/pxde/IDataEnrichment.d.ts +5 -4
- package/lib/pxde/IDataEnrichment.js +1 -2
- package/lib/pxde/constants.js +4 -7
- package/lib/pxde/index.d.ts +3 -3
- package/lib/pxde/index.js +4 -20
- package/lib/pxde/model/PXDE.js +1 -2
- package/lib/pxde/model/PxdeData.d.ts +5 -0
- package/lib/pxde/model/PxdeData.js +1 -0
- package/lib/pxde/model/index.d.ts +2 -0
- package/lib/pxde/model/index.js +2 -0
- package/lib/pxhd/PXHDUtils.d.ts +3 -4
- package/lib/pxhd/PXHDUtils.js +15 -26
- package/lib/pxhd/index.js +2 -20
- package/lib/pxhd/model/PXHD.js +1 -2
- package/lib/pxhd/model/PXHDSource.js +2 -5
- package/lib/pxhd/model/index.js +2 -18
- package/lib/risk_api/client/IRiskApiClient.d.ts +4 -0
- package/lib/risk_api/client/IRiskApiClient.js +1 -0
- package/lib/risk_api/client/PostRiskApiClientBase.d.ts +44 -0
- package/lib/risk_api/client/PostRiskApiClientBase.js +235 -0
- package/lib/risk_api/client/PostRiskApiClientV2.d.ts +8 -0
- package/lib/risk_api/client/PostRiskApiClientV2.js +10 -0
- package/lib/risk_api/client/PostRiskApiClientV3.d.ts +8 -0
- package/lib/risk_api/client/PostRiskApiClientV3.js +10 -0
- package/lib/risk_api/client/index.d.ts +4 -0
- package/lib/risk_api/client/index.js +4 -0
- package/lib/risk_api/constants.js +1 -4
- package/lib/risk_api/index.d.ts +3 -12
- package/lib/risk_api/index.js +4 -34
- package/lib/risk_api/model/RiskActivity.d.ts +6 -2
- package/lib/risk_api/model/RiskActivity.js +1 -2
- package/lib/risk_api/model/RiskApiCallResult.d.ts +6 -0
- package/lib/risk_api/model/RiskApiCallResult.js +7 -0
- package/lib/risk_api/model/RiskStatus.js +2 -5
- package/lib/risk_api/{S2SErrorReason.js → model/S2SErrorReason.js} +2 -5
- package/lib/risk_api/model/index.d.ts +4 -0
- package/lib/risk_api/model/index.js +4 -0
- package/lib/risk_api/risk_response/IRiskResponse.d.ts +15 -0
- package/lib/risk_api/risk_response/IRiskResponse.js +1 -0
- package/lib/risk_api/risk_response/RiskResponseBase.d.ts +22 -0
- package/lib/risk_api/risk_response/RiskResponseBase.js +54 -0
- package/lib/risk_api/risk_response/RiskResponsePayloadType.d.ts +4 -0
- package/lib/risk_api/risk_response/RiskResponsePayloadType.js +1 -0
- package/lib/risk_api/risk_response/index.d.ts +4 -0
- package/lib/risk_api/risk_response/index.js +4 -0
- package/lib/risk_api/risk_response/v2/DefaultRiskResponseV2.d.ts +8 -0
- package/lib/risk_api/risk_response/v2/DefaultRiskResponseV2.js +18 -0
- package/lib/risk_api/{model/RiskResponseV2.d.ts → risk_response/v2/RiskResponseV2Payload.d.ts} +4 -4
- package/lib/risk_api/risk_response/v2/RiskResponseV2Payload.js +1 -0
- package/lib/risk_api/risk_response/v2/index.d.ts +2 -0
- package/lib/risk_api/risk_response/v2/index.js +2 -0
- package/lib/risk_api/risk_response/v3/DefaultRiskResponseV3.d.ts +8 -0
- package/lib/risk_api/risk_response/v3/DefaultRiskResponseV3.js +14 -0
- package/lib/risk_api/{model/RiskResponseV3.d.ts → risk_response/v3/RiskResponseV3Payload.d.ts} +4 -4
- package/lib/risk_api/risk_response/v3/RiskResponseV3Payload.js +1 -0
- package/lib/risk_api/risk_response/v3/index.d.ts +2 -0
- package/lib/risk_api/risk_response/v3/index.js +2 -0
- package/lib/risk_token/MobileError.js +2 -5
- package/lib/risk_token/TokenOrigin.js +2 -5
- package/lib/risk_token/{TokenVerificationResult.d.ts → TokenParseResult.d.ts} +2 -2
- package/lib/risk_token/TokenParseResult.js +7 -0
- package/lib/risk_token/TokenVersion.js +2 -5
- package/lib/risk_token/constants.js +9 -12
- package/lib/risk_token/index.d.ts +2 -3
- package/lib/risk_token/index.js +8 -32
- package/lib/risk_token/parser/DefaultTokenV2Parser.d.ts +13 -0
- package/lib/risk_token/parser/DefaultTokenV2Parser.js +14 -0
- package/lib/risk_token/parser/DefaultTokenV3Parser.d.ts +13 -0
- package/lib/risk_token/parser/DefaultTokenV3Parser.js +14 -0
- package/lib/risk_token/parser/ITokenParser.d.ts +4 -0
- package/lib/risk_token/parser/ITokenParser.js +1 -0
- package/lib/risk_token/parser/TokenParserBase.d.ts +19 -0
- package/lib/risk_token/parser/TokenParserBase.js +94 -0
- package/lib/risk_token/parser/TokenParserOptions.d.ts +4 -0
- package/lib/risk_token/parser/TokenParserOptions.js +1 -0
- package/lib/risk_token/parser/index.d.ts +5 -0
- package/lib/risk_token/parser/index.js +5 -0
- package/lib/risk_token/token/{IBotDefenderToken.d.ts → IToken.d.ts} +10 -9
- package/lib/risk_token/token/IToken.js +1 -0
- package/lib/risk_token/token/TokenBase.d.ts +32 -0
- package/lib/risk_token/token/TokenBase.js +50 -0
- package/lib/risk_token/token/TokenPayloadType.d.ts +4 -0
- package/lib/risk_token/token/TokenPayloadType.js +1 -0
- package/lib/risk_token/token/index.d.ts +6 -6
- package/lib/risk_token/token/index.js +4 -11
- package/lib/risk_token/token/v2/DefaultTokenV2.d.ts +27 -0
- package/lib/risk_token/token/v2/DefaultTokenV2.js +112 -0
- package/lib/risk_token/token/v2/{BotDefenderTokenV2Payload.d.ts → TokenV2Payload.d.ts} +1 -1
- package/lib/risk_token/token/v2/TokenV2Payload.js +1 -0
- package/lib/risk_token/token/v3/DefaultTokenV3.d.ts +30 -0
- package/lib/risk_token/token/v3/DefaultTokenV3.js +137 -0
- package/lib/risk_token/token/v3/TokenSignField.js +2 -5
- package/lib/risk_token/token/v3/TokenV3Payload.d.ts +9 -0
- package/lib/risk_token/token/v3/TokenV3Payload.js +1 -0
- package/lib/risk_token/utils.js +7 -11
- package/lib/telemetry/DefaultTelemetry.d.ts +8 -8
- package/lib/telemetry/DefaultTelemetry.js +86 -152
- package/lib/telemetry/ITelemetry.d.ts +4 -4
- package/lib/telemetry/ITelemetry.js +1 -2
- package/lib/telemetry/constants.js +7 -10
- package/lib/telemetry/index.js +2 -20
- package/lib/telemetry/model/TelemetryActivity.d.ts +1 -1
- package/lib/telemetry/model/TelemetryActivity.js +1 -2
- package/lib/utils/Algorithm.js +2 -5
- package/lib/utils/ModuleMode.js +2 -5
- package/lib/utils/VidSource.js +2 -5
- package/lib/utils/base64/AtobBase64Utils.js +6 -13
- package/lib/utils/base64/BufferBase64Utils.js +9 -16
- package/lib/utils/base64/IBase64Utils.js +1 -2
- package/lib/utils/base64/JSBase64Base64Utils.js +8 -15
- package/lib/utils/base64/index.js +4 -20
- package/lib/utils/cipher/CryptoCipherUtils.d.ts +1 -3
- package/lib/utils/cipher/CryptoCipherUtils.js +16 -53
- package/lib/utils/cipher/ICipherUtils.d.ts +2 -1
- package/lib/utils/cipher/ICipherUtils.js +1 -2
- package/lib/utils/cipher/SubtleCryptoCipherUtils.js +31 -78
- package/lib/utils/cipher/index.js +2 -18
- package/lib/utils/constants.d.ts +2 -1
- package/lib/utils/constants.js +11 -13
- package/lib/utils/cookie_parser/ICookieParser.js +1 -2
- package/lib/utils/cookie_parser/{DefaultCookieParser.d.ts → StringSplitCookieParser.d.ts} +2 -1
- package/lib/utils/cookie_parser/StringSplitCookieParser.js +28 -0
- package/lib/utils/cookie_parser/index.d.ts +2 -2
- package/lib/utils/cookie_parser/index.js +2 -5
- package/lib/utils/error/EnforcerError.js +6 -28
- package/lib/utils/error/EnforcerErrorName.js +2 -5
- package/lib/utils/error/EnforcerTimeoutError.js +7 -29
- package/lib/utils/error/index.js +3 -9
- package/lib/utils/hash/CryptoHashUtils.d.ts +11 -0
- package/lib/utils/hash/CryptoHashUtils.js +20 -0
- package/lib/utils/hash/IHashUtils.d.ts +2 -1
- package/lib/utils/hash/IHashUtils.js +1 -2
- package/lib/utils/hash/SubtleCryptoHashUtils.d.ts +8 -0
- package/lib/utils/hash/SubtleCryptoHashUtils.js +31 -0
- package/lib/utils/hash/index.d.ts +2 -2
- package/lib/utils/hash/index.js +3 -19
- package/lib/utils/{hash → hmac}/CryptoHmacUtils.d.ts +2 -2
- package/lib/utils/hmac/CryptoHmacUtils.js +19 -0
- package/lib/utils/{hash → hmac}/CryptoJSHmacUtils.d.ts +2 -2
- package/lib/utils/hmac/CryptoJSHmacUtils.js +12 -0
- package/lib/utils/hmac/IHmacUtils.d.ts +4 -0
- package/lib/utils/hmac/IHmacUtils.js +1 -0
- package/lib/utils/hmac/index.d.ts +3 -0
- package/lib/utils/hmac/index.js +3 -0
- package/lib/utils/index.d.ts +5 -6
- package/lib/utils/index.js +13 -34
- package/lib/utils/ip_range_checker/DefaultIpRangeChecker.js +5 -12
- package/lib/utils/ip_range_checker/IIpRangeChecker.js +1 -2
- package/lib/utils/ip_range_checker/index.js +1 -5
- package/lib/utils/request_id_generator/IRequestIdGenerator.d.ts +3 -0
- package/lib/utils/request_id_generator/IRequestIdGenerator.js +1 -0
- package/lib/utils/request_id_generator/UuidRequestIdGenerator.d.ts +4 -0
- package/lib/utils/request_id_generator/UuidRequestIdGenerator.js +6 -0
- package/lib/utils/request_id_generator/index.d.ts +2 -0
- package/lib/utils/request_id_generator/index.js +1 -0
- package/lib/utils/utils.d.ts +5 -2
- package/lib/utils/utils.js +52 -97
- package/package.json +5 -2
- package/lib/block_handler/BlockAction.js +0 -21
- package/lib/block_handler/BlockReason.js +0 -8
- package/lib/block_handler/DefaultBlockResponseGenerator.d.ts +0 -14
- package/lib/block_handler/DefaultBlockResponseGenerator.js +0 -55
- package/lib/block_handler/IBlockResponseGenerator.d.ts +0 -14
- package/lib/block_handler/IBlockResponseGenerator.js +0 -2
- package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.d.ts +0 -14
- package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.js +0 -30
- package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.d.ts +0 -10
- package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.js +0 -29
- package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.d.ts +0 -10
- package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.js +0 -47
- package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.d.ts +0 -12
- package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.js +0 -41
- package/lib/block_handler/index.d.ts +0 -13
- package/lib/block_handler/index.js +0 -21
- package/lib/block_handler/model/BlockData.js +0 -2
- package/lib/block_handler/model/JsonBlockPayload.js +0 -2
- package/lib/block_handler/model/MobileBlockPayload.js +0 -2
- package/lib/block_handler/templates/captcha_template.js +0 -4
- package/lib/block_handler/templates/rate_limit_template.js +0 -4
- package/lib/block_handler/utils.d.ts +0 -5
- package/lib/block_handler/utils.js +0 -48
- package/lib/context/ContextBase.d.ts +0 -57
- package/lib/context/ContextBase.js +0 -147
- package/lib/context/DefaultTokenV2Context.d.ts +0 -13
- package/lib/context/DefaultTokenV2Context.js +0 -35
- package/lib/context/DefaultTokenV3Context.d.ts +0 -13
- package/lib/context/DefaultTokenV3Context.js +0 -35
- package/lib/context/IContext.d.ts +0 -264
- package/lib/context/IContext.js +0 -2
- package/lib/filter/DefaultFilter.d.ts +0 -16
- package/lib/filter/DefaultFilter.js +0 -59
- package/lib/first_party/DefaultFirstParty.d.ts +0 -22
- package/lib/first_party/DefaultFirstParty.js +0 -227
- package/lib/first_party/constants.js +0 -37
- package/lib/first_party/utils.d.ts +0 -9
- package/lib/first_party/utils.js +0 -29
- package/lib/http/interfaces/ReadOnlyHeaders.d.ts +0 -4
- package/lib/http/interfaces/ReadOnlyHeaders.js +0 -19
- package/lib/risk_api/PostRiskApiClient.d.ts +0 -43
- package/lib/risk_api/PostRiskApiClient.js +0 -265
- package/lib/risk_api/S2SCallReason.js +0 -16
- package/lib/risk_api/S2SErrorHandler.d.ts +0 -9
- package/lib/risk_api/S2SErrorHandler.js +0 -121
- package/lib/risk_api/model/RiskResponseV2.js +0 -2
- package/lib/risk_api/model/RiskResponseV3.js +0 -2
- package/lib/risk_api/risk_response_handler/IRiskResponseHandler.d.ts +0 -5
- package/lib/risk_api/risk_response_handler/IRiskResponseHandler.js +0 -2
- package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.d.ts +0 -16
- package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.js +0 -73
- package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.d.ts +0 -10
- package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.js +0 -55
- package/lib/risk_api/risk_response_handler/RiskResponseV3Handler.d.ts +0 -10
- package/lib/risk_api/risk_response_handler/RiskResponseV3Handler.js +0 -57
- package/lib/risk_token/MobileErrorHandler.d.ts +0 -9
- package/lib/risk_token/MobileErrorHandler.js +0 -100
- package/lib/risk_token/RiskTokenScoreRetriever.d.ts +0 -14
- package/lib/risk_token/RiskTokenScoreRetriever.js +0 -148
- package/lib/risk_token/TokenVerificationResult.js +0 -10
- package/lib/risk_token/token/BotDefenderTokenBase.d.ts +0 -29
- package/lib/risk_token/token/BotDefenderTokenBase.js +0 -95
- package/lib/risk_token/token/IBotDefenderToken.js +0 -2
- package/lib/risk_token/token/v2/BotDefenderTokenV2Payload.js +0 -2
- package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.d.ts +0 -26
- package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.js +0 -206
- package/lib/risk_token/token/v3/BotDefenderTokenV3Payload.d.ts +0 -9
- package/lib/risk_token/token/v3/BotDefenderTokenV3Payload.js +0 -2
- package/lib/risk_token/token/v3/DefaultBotDefenderTokenV3.d.ts +0 -29
- package/lib/risk_token/token/v3/DefaultBotDefenderTokenV3.js +0 -231
- package/lib/utils/IScoreRetriever.d.ts +0 -14
- package/lib/utils/IScoreRetriever.js +0 -2
- package/lib/utils/PassReason.js +0 -10
- package/lib/utils/cookie_parser/DefaultCookieParser.js +0 -13
- package/lib/utils/hash/CryptoHmacUtils.js +0 -25
- package/lib/utils/hash/CryptoJSHmacUtils.js +0 -19
- package/lib/utils/uuid_generator/DefaultUuidGenerator.d.ts +0 -4
- package/lib/utils/uuid_generator/DefaultUuidGenerator.js +0 -13
- package/lib/utils/uuid_generator/IUuidGenerator.d.ts +0 -3
- package/lib/utils/uuid_generator/IUuidGenerator.js +0 -2
- package/lib/utils/uuid_generator/index.d.ts +0 -2
- package/lib/utils/uuid_generator/index.js +0 -5
- /package/lib/{block_handler → products/bot_defender/block}/model/JsonBlockPayload.d.ts +0 -0
- /package/lib/{block_handler → products/bot_defender/block}/model/MobileBlockPayload.d.ts +0 -0
- /package/lib/{block_handler → products/bot_defender/block}/templates/captcha_template.d.ts +0 -0
- /package/lib/{block_handler → products/bot_defender/block}/templates/rate_limit_template.d.ts +0 -0
- /package/lib/risk_api/{S2SErrorReason.d.ts → model/S2SErrorReason.d.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../../config';
|
|
2
|
+
import { ReadonlyContext } from '../../../../context';
|
|
3
|
+
import { IBlocker } from '../../../../blocker';
|
|
4
|
+
import { IMinimalResponse } from '../../../../http';
|
|
5
|
+
export declare class HtmlCaptchaBlocker<Req, Res> implements IBlocker<Req, Res> {
|
|
6
|
+
private readonly config;
|
|
7
|
+
constructor(config: IConfiguration<Req, Res>);
|
|
8
|
+
createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContentType, CONTENT_TYPE_HEADER_NAME, MinimalResponseImpl } from '../../../../http';
|
|
2
|
+
import { createBlockData, renderHtml } from '../utils';
|
|
3
|
+
import { CAPTCHA_TEMPLATE } from '../templates';
|
|
4
|
+
export class HtmlCaptchaBlocker {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
createBlockResponse(context) {
|
|
9
|
+
const status = 403;
|
|
10
|
+
const headers = {
|
|
11
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.TEXT_HTML],
|
|
12
|
+
};
|
|
13
|
+
const body = renderHtml(CAPTCHA_TEMPLATE, createBlockData(this.config, context));
|
|
14
|
+
return new MinimalResponseImpl({
|
|
15
|
+
body: body,
|
|
16
|
+
status: status,
|
|
17
|
+
headers: headers,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../../config';
|
|
2
|
+
import { ReadonlyContext } from '../../../../context';
|
|
3
|
+
import { IConditionalBlocker } from '../../../../blocker';
|
|
4
|
+
import { IMinimalResponse } from '../../../../http';
|
|
5
|
+
export declare class JsonCaptchaBlocker<Req, Res> implements IConditionalBlocker<Req, Res> {
|
|
6
|
+
private readonly config;
|
|
7
|
+
constructor(config: IConfiguration<Req, Res>);
|
|
8
|
+
shouldBlock(context: ReadonlyContext<Req, Res>): boolean;
|
|
9
|
+
createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BlockAction } from '../../../../blocker';
|
|
2
|
+
import { ContentType, CONTENT_TYPE_HEADER_NAME, ACCEPT_HEADER_NAME, MinimalResponseImpl, } from '../../../../http';
|
|
3
|
+
import { createBlockData } from '../utils';
|
|
4
|
+
export class JsonCaptchaBlocker {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
shouldBlock(context) {
|
|
9
|
+
if (!this.config.advancedBlockingResponseEnabled) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const acceptHeaderValue = context.requestData.request.headers.get(ACCEPT_HEADER_NAME) ||
|
|
13
|
+
context.requestData.request.headers.get(CONTENT_TYPE_HEADER_NAME) ||
|
|
14
|
+
'';
|
|
15
|
+
const acceptHeaderContainsJson = acceptHeaderValue === null || acceptHeaderValue === void 0 ? void 0 : acceptHeaderValue.split(',').some((value) => value.toLowerCase() === ContentType.APPLICATION_JSON);
|
|
16
|
+
return !context.isMobile && context.blockAction !== BlockAction.RATE_LIMIT && acceptHeaderContainsJson;
|
|
17
|
+
}
|
|
18
|
+
createBlockResponse(context) {
|
|
19
|
+
const status = 403;
|
|
20
|
+
const headers = {
|
|
21
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JSON],
|
|
22
|
+
};
|
|
23
|
+
const blockData = createBlockData(this.config, context);
|
|
24
|
+
const jsonBlockPayload = {
|
|
25
|
+
appId: blockData.appId,
|
|
26
|
+
jsClientSrc: blockData.jsClientSrc,
|
|
27
|
+
customLogo: blockData.customLogo,
|
|
28
|
+
firstPartyEnabled: blockData.firstPartyEnabled,
|
|
29
|
+
vid: blockData.vid,
|
|
30
|
+
uuid: blockData.uuid,
|
|
31
|
+
hostUrl: blockData.hostUrl,
|
|
32
|
+
blockScript: blockData.blockScript,
|
|
33
|
+
altBlockScript: blockData.altBlockScript,
|
|
34
|
+
};
|
|
35
|
+
const body = JSON.stringify(jsonBlockPayload);
|
|
36
|
+
return new MinimalResponseImpl({ status, headers, body });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../../config';
|
|
2
|
+
import { ReadonlyContext } from '../../../../context';
|
|
3
|
+
import { IBase64Utils } from '../../../../utils';
|
|
4
|
+
import { IConditionalBlocker } from '../../../../blocker';
|
|
5
|
+
import { IMinimalResponse } from '../../../../http';
|
|
6
|
+
export declare class MobileCaptchaBlocker<Req, Res> implements IConditionalBlocker<Req, Res> {
|
|
7
|
+
private readonly config;
|
|
8
|
+
private readonly base64Utils;
|
|
9
|
+
constructor(config: IConfiguration<Req, Res>, base64Utils: IBase64Utils);
|
|
10
|
+
shouldBlock(context: ReadonlyContext<Req, Res>): boolean;
|
|
11
|
+
createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BLOCK_ACTION_TO_WORD_MAP } from '../../../../blocker';
|
|
2
|
+
import { ContentType, CONTENT_TYPE_HEADER_NAME, MinimalResponseImpl } from '../../../../http';
|
|
3
|
+
import { createBlockData, renderHtml } from '../utils';
|
|
4
|
+
import { CAPTCHA_TEMPLATE } from '../templates';
|
|
5
|
+
export class MobileCaptchaBlocker {
|
|
6
|
+
constructor(config, base64Utils) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
this.base64Utils = base64Utils;
|
|
9
|
+
}
|
|
10
|
+
shouldBlock(context) {
|
|
11
|
+
return context.isMobile;
|
|
12
|
+
}
|
|
13
|
+
createBlockResponse(context) {
|
|
14
|
+
const status = 403;
|
|
15
|
+
const headers = {
|
|
16
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JSON],
|
|
17
|
+
};
|
|
18
|
+
const blockData = createBlockData(this.config, context);
|
|
19
|
+
const captchaPage = renderHtml(CAPTCHA_TEMPLATE, blockData);
|
|
20
|
+
const mobileBlockPayload = {
|
|
21
|
+
action: BLOCK_ACTION_TO_WORD_MAP.get(blockData.blockAction),
|
|
22
|
+
uuid: blockData.uuid,
|
|
23
|
+
vid: blockData.vid,
|
|
24
|
+
appId: blockData.appId,
|
|
25
|
+
page: this.base64Utils.base64Encode(captchaPage),
|
|
26
|
+
collectorHost: this.config.backendCollectorUrl,
|
|
27
|
+
};
|
|
28
|
+
return new MinimalResponseImpl({
|
|
29
|
+
body: JSON.stringify(mobileBlockPayload),
|
|
30
|
+
status: status,
|
|
31
|
+
headers: headers,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const CAPTCHA_TEMPLATE = `<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="description" content="px-captcha">
|
|
7
|
+
<title>Access to this page has been denied</title>
|
|
8
|
+
{{cssRef}}
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<script>
|
|
12
|
+
/* PerimeterX assignments */
|
|
13
|
+
window._pxVid = '{{vid}}';
|
|
14
|
+
window._pxUuid = '{{uuid}}';
|
|
15
|
+
window._pxAppId = '{{appId}}';
|
|
16
|
+
window._pxMobile = {{isMobile}};
|
|
17
|
+
window._pxHostUrl = '{{hostUrl}}';
|
|
18
|
+
window._pxCustomLogo = '{{customLogo}}';
|
|
19
|
+
window._pxJsClientSrc = '{{jsClientSrc}}';
|
|
20
|
+
window._pxFirstPartyEnabled = {{firstPartyEnabled}};
|
|
21
|
+
var pxCaptchaSrc = '{{blockScript}}';
|
|
22
|
+
|
|
23
|
+
var script = document.createElement('script');
|
|
24
|
+
script.src = pxCaptchaSrc;
|
|
25
|
+
script.onerror = function () {
|
|
26
|
+
script = document.createElement('script');
|
|
27
|
+
script.src = '{{altBlockScript}}';
|
|
28
|
+
script.onerror = window._pxOnError;
|
|
29
|
+
document.head.appendChild(script);
|
|
30
|
+
};
|
|
31
|
+
window._pxOnError = function () {
|
|
32
|
+
var style = document.createElement('style');
|
|
33
|
+
style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';
|
|
34
|
+
document.head.appendChild(style);
|
|
35
|
+
var div = document.createElement('div');
|
|
36
|
+
div.className = 'px-captcha-error-container';
|
|
37
|
+
div.innerHTML = '<div class="px-captcha-error-header">Before we continue...</div><div class="px-captcha-error-message">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class="px-captcha-error-button">Press & Hold</div><div class="px-captcha-error-wrapper"><div class="px-captcha-error"><img class="px-captcha-error" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class="px-captcha-error-refid">Reference ID ' + window._pxUuid + '</div>';
|
|
38
|
+
document.body.appendChild(div);
|
|
39
|
+
if (window._pxMobile) {
|
|
40
|
+
setTimeout(function() {
|
|
41
|
+
location.href = '/px/captcha_close?status=-1';
|
|
42
|
+
}, 5000);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
document.head.appendChild(script);
|
|
46
|
+
</script>
|
|
47
|
+
{{jsRef}}
|
|
48
|
+
</body>
|
|
49
|
+
</html>
|
|
50
|
+
`;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../config';
|
|
2
|
+
import { ReadonlyContext } from '../../../context';
|
|
3
|
+
import { BlockData } from './model';
|
|
4
|
+
export declare const renderHtml: (htmlTemplate: string, blockData?: BlockData) => string;
|
|
5
|
+
export declare const createBlockData: <Req, Res>(config: IConfiguration<Req, Res>, context: ReadonlyContext<Req, Res>) => BlockData;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PXVID_COOKIE_NAME } from '../../../utils';
|
|
2
|
+
import { FirstPartySuffix, getMostCustomizedFirstPartyPath } from '../first_party';
|
|
3
|
+
export const renderHtml = (htmlTemplate, blockData) => {
|
|
4
|
+
if (!blockData) {
|
|
5
|
+
return htmlTemplate;
|
|
6
|
+
}
|
|
7
|
+
Object.entries(blockData).forEach(([key, value]) => {
|
|
8
|
+
const replace = `{{${key}}}`;
|
|
9
|
+
const regEx = new RegExp(replace, 'g');
|
|
10
|
+
htmlTemplate = htmlTemplate.replace(regEx, `${value}`);
|
|
11
|
+
});
|
|
12
|
+
return htmlTemplate;
|
|
13
|
+
};
|
|
14
|
+
export const createBlockData = (config, context) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const captchaParams = `/captcha.js?a=${context.blockAction}&u=${context.uuid}&v=${context.vid || ''}&m=${context.isMobile ? '1' : '0'}`;
|
|
17
|
+
let jsClientSrc = `${config.backendClientUrl}/${config.appId}/main.min.js`;
|
|
18
|
+
let blockScript = `${config.backendCaptchaUrl}/${config.appId}${captchaParams}`;
|
|
19
|
+
let hostUrl = config.backendCollectorUrl;
|
|
20
|
+
if (config.firstPartyEnabled && !context.isMobile) {
|
|
21
|
+
jsClientSrc = getMostCustomizedFirstPartyPath(config, FirstPartySuffix.SENSOR);
|
|
22
|
+
blockScript = `${getMostCustomizedFirstPartyPath(config, FirstPartySuffix.CAPTCHA)}${captchaParams}`;
|
|
23
|
+
hostUrl = getMostCustomizedFirstPartyPath(config, FirstPartySuffix.XHR);
|
|
24
|
+
}
|
|
25
|
+
const cssRef = config.cssRef ? `<link rel="stylesheet" type="text/css" href="${config.cssRef}" />` : '';
|
|
26
|
+
const jsRef = config.jsRef ? `<script src="${config.jsRef}"></script>` : '';
|
|
27
|
+
const altBlockScript = `${config.altBackendCaptchaUrl}/${config.appId}${captchaParams}`;
|
|
28
|
+
return {
|
|
29
|
+
appId: config.appId,
|
|
30
|
+
vid: context.vid || ((_b = (_a = context.requestData) === null || _a === void 0 ? void 0 : _a.cookies) === null || _b === void 0 ? void 0 : _b[PXVID_COOKIE_NAME]) || '',
|
|
31
|
+
uuid: context.uuid || '',
|
|
32
|
+
isMobile: context.isMobile,
|
|
33
|
+
customLogo: config.customLogo || '',
|
|
34
|
+
blockAction: context.blockAction,
|
|
35
|
+
hostUrl,
|
|
36
|
+
cssRef,
|
|
37
|
+
jsRef,
|
|
38
|
+
jsClientSrc,
|
|
39
|
+
firstPartyEnabled: config.firstPartyEnabled,
|
|
40
|
+
blockScript,
|
|
41
|
+
altBlockScript,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../config';
|
|
2
|
+
import { ReadonlyContext } from '../../../context';
|
|
3
|
+
import { IFilter } from '../../../filter';
|
|
4
|
+
import { IIpRangeChecker } from '../../../utils';
|
|
5
|
+
export declare class DefaultBotDefenderFilter<Req, Res> implements IFilter<Req, Res> {
|
|
6
|
+
private readonly config;
|
|
7
|
+
private readonly ipRangeChecker;
|
|
8
|
+
constructor(config: IConfiguration<Req, Res>, ipRangeChecker: IIpRangeChecker);
|
|
9
|
+
shouldFilter(context: ReadonlyContext<Req, Res>): boolean;
|
|
10
|
+
private getFilterReason;
|
|
11
|
+
private shouldFilterByExtension;
|
|
12
|
+
private shouldFilterByHttpMethod;
|
|
13
|
+
private shouldFilterByIp;
|
|
14
|
+
private shouldFilterByRoute;
|
|
15
|
+
private shouldFilterByUserAgent;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HttpMethod } from '../../../http';
|
|
2
|
+
import { FilterReason } from '../../../filter';
|
|
3
|
+
import { getExtension, isRouteInPatterns } from '../../../utils';
|
|
4
|
+
export class DefaultBotDefenderFilter {
|
|
5
|
+
constructor(config, ipRangeChecker) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
this.ipRangeChecker = ipRangeChecker;
|
|
8
|
+
}
|
|
9
|
+
shouldFilter(context) {
|
|
10
|
+
const { requestData } = context;
|
|
11
|
+
const filterReason = this.getFilterReason(requestData);
|
|
12
|
+
return filterReason !== FilterReason.NONE;
|
|
13
|
+
}
|
|
14
|
+
getFilterReason(request) {
|
|
15
|
+
if (this.shouldFilterByExtension(request)) {
|
|
16
|
+
return FilterReason.EXTENSION;
|
|
17
|
+
}
|
|
18
|
+
if (this.shouldFilterByRoute(request.url.pathname)) {
|
|
19
|
+
return FilterReason.ROUTE;
|
|
20
|
+
}
|
|
21
|
+
if (this.shouldFilterByHttpMethod(request.method)) {
|
|
22
|
+
return FilterReason.HTTP_METHOD;
|
|
23
|
+
}
|
|
24
|
+
if (this.shouldFilterByUserAgent(request.userAgent)) {
|
|
25
|
+
return FilterReason.USER_AGENT;
|
|
26
|
+
}
|
|
27
|
+
if (this.shouldFilterByIp(request.ip)) {
|
|
28
|
+
return FilterReason.IP;
|
|
29
|
+
}
|
|
30
|
+
return FilterReason.NONE;
|
|
31
|
+
}
|
|
32
|
+
shouldFilterByExtension(requestData) {
|
|
33
|
+
if (requestData.method !== HttpMethod.GET && requestData.method !== HttpMethod.HEAD) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const ext = getExtension(requestData.url.href);
|
|
37
|
+
return !!ext && this.config.filteredExtensions.includes(ext);
|
|
38
|
+
}
|
|
39
|
+
shouldFilterByHttpMethod(method) {
|
|
40
|
+
return this.config.filteredHttpMethods.some((filteredMethod) => filteredMethod.toUpperCase() === method);
|
|
41
|
+
}
|
|
42
|
+
shouldFilterByIp(ip) {
|
|
43
|
+
return this.config.filteredIps.some((range) => this.ipRangeChecker.isIpInRange(ip, range));
|
|
44
|
+
}
|
|
45
|
+
shouldFilterByRoute(route) {
|
|
46
|
+
return isRouteInPatterns(route, this.config.filteredRoutes);
|
|
47
|
+
}
|
|
48
|
+
shouldFilterByUserAgent(userAgent) {
|
|
49
|
+
return this.config.filteredUserAgents.includes(userAgent);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DefaultBotDefenderFilter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DefaultBotDefenderFilter';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../config';
|
|
2
|
+
import { ReadonlyContext } from '../../../context';
|
|
3
|
+
import { FirstPartyData, IFirstParty } from '../../../first_party';
|
|
4
|
+
export declare class DefaultBotDefenderFirstParty<Req, Res> implements IFirstParty<Req, Res> {
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(config: IConfiguration<Req, Res>);
|
|
7
|
+
handleFirstPartyRequest(context: ReadonlyContext<Req, Res>): Promise<FirstPartyData | null>;
|
|
8
|
+
private proxySensorScriptRequest;
|
|
9
|
+
private proxyXhrRequest;
|
|
10
|
+
private static getDefaultXhrResponse;
|
|
11
|
+
private proxyCaptchaScriptRequest;
|
|
12
|
+
private getOutgoingRequest;
|
|
13
|
+
private prepareFirstPartyHeaders;
|
|
14
|
+
private setHostHeader;
|
|
15
|
+
private setXffHeader;
|
|
16
|
+
private addFirstPartyHeaders;
|
|
17
|
+
private getThirdPartySensorScriptUrl;
|
|
18
|
+
private getThirdPartyCaptchaScriptUrl;
|
|
19
|
+
private getThirdPartyXhrUrl;
|
|
20
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { removeSensitiveHeaders } from '../../../utils';
|
|
11
|
+
import { COOKIE_HEADER_NAME, HOST_HEADER_NAME, X_FORWARDED_FOR_HEADER_NAME, OutgoingRequestImpl, MinimalResponseImpl, toMutableHeaders, } from '../../../http';
|
|
12
|
+
import { getFirstPartyCaptchaScriptPathPrefixes, getFirstPartySensorScriptPaths, getFirstPartyXhrPathPrefixes, } from './utils';
|
|
13
|
+
import { DEFAULT_CLIENT_RESPONSE_OPTIONS, DEFAULT_GIF_RESPONSE, DEFAULT_XHR_RESPONSE, FIRST_PARTY_HEADER_NAME, FIRST_PARTY_HEADER_VALUE, X_PX_ENFORCER_TRUE_IP_HEADER_NAME, } from './constants';
|
|
14
|
+
export class DefaultBotDefenderFirstParty {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
handleFirstPartyRequest(context) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { pathname } = context.requestData.url;
|
|
21
|
+
if (getFirstPartySensorScriptPaths(this.config).includes(pathname)) {
|
|
22
|
+
return yield this.proxySensorScriptRequest(context);
|
|
23
|
+
}
|
|
24
|
+
const xhrPrefix = getFirstPartyXhrPathPrefixes(this.config).find((prefix) => pathname.startsWith(prefix));
|
|
25
|
+
if (xhrPrefix) {
|
|
26
|
+
return yield this.proxyXhrRequest(context, xhrPrefix);
|
|
27
|
+
}
|
|
28
|
+
const captchaPrefix = getFirstPartyCaptchaScriptPathPrefixes(this.config).find((prefix) => pathname.startsWith(prefix));
|
|
29
|
+
if (captchaPrefix) {
|
|
30
|
+
return yield this.proxyCaptchaScriptRequest(context, captchaPrefix);
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
proxySensorScriptRequest(context) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const defaultResponse = new MinimalResponseImpl(DEFAULT_CLIENT_RESPONSE_OPTIONS);
|
|
38
|
+
if (!this.config.firstPartyEnabled) {
|
|
39
|
+
return { defaultResponse };
|
|
40
|
+
}
|
|
41
|
+
const url = this.getThirdPartySensorScriptUrl();
|
|
42
|
+
const request = yield this.getOutgoingRequest(url, context);
|
|
43
|
+
return { request, defaultResponse };
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
proxyXhrRequest(context, prefix) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const defaultResponse = DefaultBotDefenderFirstParty.getDefaultXhrResponse(context.requestData.url.pathname);
|
|
49
|
+
if (!this.config.firstPartyEnabled) {
|
|
50
|
+
return { defaultResponse };
|
|
51
|
+
}
|
|
52
|
+
const url = this.getThirdPartyXhrUrl(context, prefix);
|
|
53
|
+
const request = yield this.getOutgoingRequest(url, context);
|
|
54
|
+
return { request, defaultResponse };
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static getDefaultXhrResponse(path) {
|
|
58
|
+
const { content, options } = path.endsWith('.gif') ? DEFAULT_GIF_RESPONSE : DEFAULT_XHR_RESPONSE;
|
|
59
|
+
return new MinimalResponseImpl({
|
|
60
|
+
body: content,
|
|
61
|
+
status: options.status,
|
|
62
|
+
headers: options.headers,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
proxyCaptchaScriptRequest(context, prefix) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const defaultResponse = new MinimalResponseImpl(DEFAULT_CLIENT_RESPONSE_OPTIONS);
|
|
68
|
+
if (!this.config.firstPartyEnabled) {
|
|
69
|
+
return { defaultResponse };
|
|
70
|
+
}
|
|
71
|
+
const url = this.getThirdPartyCaptchaScriptUrl(context, prefix);
|
|
72
|
+
const request = yield this.getOutgoingRequest(url, context);
|
|
73
|
+
return { request, defaultResponse };
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
getOutgoingRequest(url, { requestData, vid }) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
return new OutgoingRequestImpl({
|
|
79
|
+
url: url,
|
|
80
|
+
method: requestData.method,
|
|
81
|
+
headers: this.prepareFirstPartyHeaders(url, requestData, vid),
|
|
82
|
+
body: requestData.request.body,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
prepareFirstPartyHeaders(url, requestData, vid) {
|
|
87
|
+
let headers = toMutableHeaders(requestData.headers);
|
|
88
|
+
try {
|
|
89
|
+
headers = removeSensitiveHeaders(headers, this.config.sensitiveHeaders);
|
|
90
|
+
this.setHostHeader(headers, url);
|
|
91
|
+
this.setXffHeader(headers, requestData.ip);
|
|
92
|
+
this.addFirstPartyHeaders(headers, requestData.ip);
|
|
93
|
+
if (vid) {
|
|
94
|
+
const newCookies = (headers[COOKIE_HEADER_NAME] || []).concat([`pxvid=${vid}`]);
|
|
95
|
+
headers[COOKIE_HEADER_NAME] = [newCookies.join('; ')];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
this.config.logger.error(`Caught error preparing first party headers: ${e}`);
|
|
100
|
+
}
|
|
101
|
+
return headers;
|
|
102
|
+
}
|
|
103
|
+
setHostHeader(headers, url) {
|
|
104
|
+
headers[HOST_HEADER_NAME] = [new URL(url).host];
|
|
105
|
+
}
|
|
106
|
+
setXffHeader(headers, ip) {
|
|
107
|
+
const xffValue = headers[X_FORWARDED_FOR_HEADER_NAME] || [];
|
|
108
|
+
headers[X_FORWARDED_FOR_HEADER_NAME] = xffValue.concat([ip]);
|
|
109
|
+
}
|
|
110
|
+
addFirstPartyHeaders(headers, ip) {
|
|
111
|
+
headers[FIRST_PARTY_HEADER_NAME] = [FIRST_PARTY_HEADER_VALUE];
|
|
112
|
+
headers[X_PX_ENFORCER_TRUE_IP_HEADER_NAME] = [ip];
|
|
113
|
+
}
|
|
114
|
+
getThirdPartySensorScriptUrl() {
|
|
115
|
+
return `${this.config.backendClientUrl}/${this.config.appId}/main.min.js`;
|
|
116
|
+
}
|
|
117
|
+
getThirdPartyCaptchaScriptUrl(context, prefix) {
|
|
118
|
+
const originalUrl = context.requestData.url;
|
|
119
|
+
const { appId, backendCaptchaUrl } = this.config;
|
|
120
|
+
const regExString = `${originalUrl.origin}${prefix}`;
|
|
121
|
+
const regEx = new RegExp(regExString, 'ig');
|
|
122
|
+
return `${backendCaptchaUrl}/${appId}${originalUrl.href.replace(regEx, '')}`;
|
|
123
|
+
}
|
|
124
|
+
getThirdPartyXhrUrl(context, prefix) {
|
|
125
|
+
const originalUrl = context.requestData.url;
|
|
126
|
+
const { backendCollectorUrl } = this.config;
|
|
127
|
+
return `${backendCollectorUrl}${originalUrl.pathname.replace(prefix, '')}${originalUrl.search}`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { ContentType } from '
|
|
2
|
-
import { MinimalResponseOptions } from '
|
|
1
|
+
import { ContentType } from '../../../http';
|
|
2
|
+
import { MinimalResponseOptions } from '../../../http';
|
|
3
3
|
export declare const EMPTY_GIF: number[];
|
|
4
4
|
export declare const X_PX_ENFORCER_TRUE_IP_HEADER_NAME = "x-px-enforcer-true-ip";
|
|
5
5
|
export declare const FIRST_PARTY_HEADER_NAME = "x-px-first-party";
|
|
6
6
|
export declare const FIRST_PARTY_HEADER_VALUE = "1";
|
|
7
|
+
export declare const FIRST_PARTY_SENSOR_SUFFIX = "/init.js";
|
|
8
|
+
export declare const FIRST_PARTY_CAPTCHA_SUFFIX = "/captcha";
|
|
9
|
+
export declare const FIRST_PARTY_XHR_SUFFIX = "/xhr";
|
|
7
10
|
export declare const DEFAULT_CLIENT_RESPONSE_OPTIONS: MinimalResponseOptions;
|
|
8
11
|
export declare const DEFAULT_XHR_RESPONSE: {
|
|
9
12
|
content: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ContentType, CONTENT_TYPE_HEADER_NAME } from '../../../http';
|
|
2
|
+
export const EMPTY_GIF = [
|
|
3
|
+
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
|
|
4
|
+
0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b,
|
|
5
|
+
];
|
|
6
|
+
export const X_PX_ENFORCER_TRUE_IP_HEADER_NAME = 'x-px-enforcer-true-ip';
|
|
7
|
+
export const FIRST_PARTY_HEADER_NAME = 'x-px-first-party';
|
|
8
|
+
export const FIRST_PARTY_HEADER_VALUE = '1';
|
|
9
|
+
export const FIRST_PARTY_SENSOR_SUFFIX = '/init.js';
|
|
10
|
+
export const FIRST_PARTY_CAPTCHA_SUFFIX = '/captcha';
|
|
11
|
+
export const FIRST_PARTY_XHR_SUFFIX = '/xhr';
|
|
12
|
+
export const DEFAULT_CLIENT_RESPONSE_OPTIONS = {
|
|
13
|
+
body: '',
|
|
14
|
+
status: 200,
|
|
15
|
+
headers: {
|
|
16
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JAVASCRIPT],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const DEFAULT_XHR_RESPONSE = {
|
|
20
|
+
content: '{}',
|
|
21
|
+
options: {
|
|
22
|
+
status: 200,
|
|
23
|
+
headers: {
|
|
24
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JAVASCRIPT],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const DEFAULT_GIF_RESPONSE = {
|
|
29
|
+
content: 'GIF89a\x01\x00\x01\x00\x80\x00\x00ÿÿÿ\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;',
|
|
30
|
+
options: {
|
|
31
|
+
status: 200,
|
|
32
|
+
headers: {
|
|
33
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.IMAGE_GIF],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IConfiguration } from '../../../config';
|
|
2
|
+
import { FirstPartySuffix } from './FirstPartySuffix';
|
|
3
|
+
export declare const getAllFirstPartyPaths: <Req, Res>(config: IConfiguration<Req, Res, import("../../../config").ConfigurationParams<Req, Res>>, suffix: FirstPartySuffix) => string[];
|
|
4
|
+
export declare const getCustomEndpointFromFirstPartySuffix: <Req, Res>(config: IConfiguration<Req, Res, import("../../../config").ConfigurationParams<Req, Res>>, suffix: FirstPartySuffix) => string;
|
|
5
|
+
export declare const getMostCustomizedFirstPartyPath: <Req, Res>(config: IConfiguration<Req, Res, import("../../../config").ConfigurationParams<Req, Res>>, suffix: FirstPartySuffix) => string;
|
|
6
|
+
export declare const getFirstPartySensorScriptPaths: <Req, Res>(config: IConfiguration<Req, Res, import("../../../config").ConfigurationParams<Req, Res>>) => string[];
|
|
7
|
+
export declare const getFirstPartyCaptchaScriptPathPrefixes: <Req, Res>(config: IConfiguration<Req, Res, import("../../../config").ConfigurationParams<Req, Res>>) => string[];
|
|
8
|
+
export declare const getFirstPartyXhrPathPrefixes: <Req, Res>(config: IConfiguration<Req, Res, import("../../../config").ConfigurationParams<Req, Res>>) => string[];
|
|
9
|
+
export declare const getDefaultFirstPartyPrefix: (appId: string) => string;
|
|
10
|
+
export declare const getFirstPartyPath: (prefix: string, suffix: string) => string;
|
|
11
|
+
export declare const addInitialSlashIfNeeded: (path: string) => string;
|