PerimeterX

public class PerimeterX

PerimeterX main class. You should interact with it in order to setup and start the SDK.

Functions

Link copied to clipboard
final Unit addInitializationFinishedCallback(String appId, Function0<Unit> callback)

Use this function to get notified when the PerimeterX SDK is ready for the given AppID. If it's already ready, the callback will be called immediately. You should call this function only after you have already called the start(appId:delegate:completion:) function for the given AppID.

Link copied to clipboard
final String blockedErrorBody()

Returns a JSON string that represent a "blocked request" error. When the interceptor is enabled, the body of the URL response will be the same as the string that returns here. When the interceptor is disabled, you may replace the original URL response with the string that returns here.

Link copied to clipboard
final Boolean canHandleResponse(    String appId,     String response,     Integer code)

This function checks if the SDK can handle the URL request's response and presents the block screen. Returns true if the PerimeterX's payload in the response can be handled by the SDK. This function does not present the block screen. This function should be used only when the requestsInterceptedAutomaticallyEnabled is set to false in the policy. You must call the start(appId:delegate:completion:) function and wait until it's done before calling this function

Link copied to clipboard
final String challengeCancelledErrorBody()

Returns a JSON string that represent a "blocked request and challenge cancelled" error. When the interceptor is enabled, the body of the URL response will be the same as the string that returns here. When the interceptor is disabled, you may replace the original URL response with the string that returns here.

Link copied to clipboard
final String challengeSolvedErrorBody()

Returns a JSON string that represent a "blocked request and challenge solved" error. When the interceptor is enabled, the body of the URL response will be the same as the string that returns here.

Link copied to clipboard
final Boolean handleResponse(    String appId,     String response,     Integer code)

This function handles the URL request's response and presents the block screen, if necessary. Returns true if the PerimeterX's payload in the response was handled by the SDK. This function should be used only when the requestsInterceptedAutomaticallyEnabled is set to false in the policy. You must call the start(appId:delegate:completion:) function and wait until it's done before calling this function

Link copied to clipboard
final HashMap<String, String> headersForURLRequest(String appId)

Returns HTTP headers that should be added to the URL request. This function should be used only when the requestsInterceptedAutomaticallyEnabled is set to false in the policy.

Link copied to clipboard
final Boolean isChallengeCancelledError(String response)

Returns true if the error is "blocked request and challenge cancelled" error. This kind error should returned when the requestsInterceptedAutomaticallyEnabled is set to true and delayResponseUntilChallengeSolvedOrCancelled is set to true.

Link copied to clipboard
final Boolean isChallengeSolvedError(String response)

Returns true if the error is "blocked request and challenge solved" error. This kind error should returned when the requestsInterceptedAutomaticallyEnabled is set to true and delayResponseUntilChallengeSolvedOrCancelled is set to true.

Link copied to clipboard
final Boolean isRequestBlockedError(String response)

Returns true if the error is "blocked request" error. This kind error should returned when the requestsInterceptedAutomaticallyEnabled is set to true and delayResponseUntilChallengeSolvedOrCancelled is set to false.

final String registerCallbackForChallengeCancelledEvent(String appId, Function0<Unit> callback)

Register a callback that will be called after the user cancelled the challenge. Returns the registration ID. Use it to unregister with unregisterCallbackForChallengeCancelledEvent function. This function returns nil on failure. You must call the start function before calling this function.

Link copied to clipboard
final String registerCallbackForChallengeSolvedEvent(String appId, Function0<Unit> callback)

Register a callback that will be called after the user solved the challenge. Returns the registration ID. Use it to unregister with unregisterCallbackForChallengeSolvedEvent function. This function returns nil on failure. You must call the start function before calling this function.

Link copied to clipboard
final String registerCallbackForRequestBlockedEvent(String appId, Function0<Unit> callback)

Register a callback that will be called after a request was blocked. Returns the registration ID. Use it to unregister with unregisterCallbackForRequestBlockedEvent function. This function returns nil on failure. You must call the start function before calling this function.

Link copied to clipboard
final Unit registerOutgoingUrlRequest(String url, String appId)

Provide outgoing URL request to the Account Defender feature. You must call the setUserId function before calling this function. If you are using the automatic interceptor you should not need to use this function (it will be called automatically by the interceptor).

Link copied to clipboard
final String sdkVersion()

Returns the current SDK version.

Link copied to clipboard
final Unit setCustomParameters(HashMap<String, String> parameters, String appId)

Set custom parameters for given AppID.

Link copied to clipboard
final Unit setPolicy(PXPolicy policy, String appId)

Set policy for given AppID.

Link copied to clipboard
final Unit setupWebView(WebView webView, WebViewClient webViewClient)

Setup the web view to be synced with SDK. Do not set a web view client to the web view after calling this function. If you wish to set a web view client, call this function again with the new web view client. This function enables JavaScript in the web view's settings. Do not change this setting.

Link copied to clipboard
final Unit setUserId(String userId, String appId)

Calling this method with non-null userId will start the Account Defender feature. You must call the start function and wait until it's done before calling this function.

Link copied to clipboard
final Unit start(    Application application,     String appId,     PerimeterXDelegate delegate,     Boolean enableDoctorCheck,     Function1<Boolean, Unit> completion)

Start the bot protection. Protection will be started only after the completion is called with true result.

final Unit unregisterCallbackForChallengeCancelledEvent(String appId, String registrationId)

Unregister the callback for challenge cancelled that is associated with the given registration ID. Registration ID is provided from the registerCallbackForRequestCancelledEvent function.

final Unit unregisterCallbackForChallengeSolvedEvent(String appId, String registrationId)

Unregister the callback for challenge solved that is associated with the given registration ID. Registration ID is provided from the registerCallbackForRequestSolvedEvent function.

Link copied to clipboard
final Unit unregisterCallbackForRequestBlockedEvent(String appId, String registrationId)

Unregister the callback for request blocked that is associated with the given registration ID. Registration ID is provided from the registerCallbackForRequestBlockedEvent function.

Link copied to clipboard
final String vid(String appId)

Get the VID for given AppID.

Properties

Link copied to clipboard
public final static PerimeterX INSTANCE