HSBot Defender
Functions
This function checks if the SDK can handle the URL request's response and presents the challenge screen. Returns true if the Human's payload in the response can be handled by the SDK. This function does not present the challenge screen. You must call the start(appId:delegate:completion:) function and wait until it's done before calling this function
Returns the challenge's Reference ID. This value will appear in the challenge screen. The value is unique per app run. Meaning, for each challenge in the app, the value will be the same for all challenges. Note that the value in the challenge screen will be different from the returned value when the Doctor App is enabled, due to internal implementation.
Returns a JSON string that represents the given error type. When the automatic interceptor is enabled, the body of the URL response will be the same as the string that returns here. When the automatic interceptor is disabled, you may replace the original URL response with the string that returns here.
Returns a JSON string that represents the given error type and (optionally) the accompanying reason for HSBotDefenderErrorType.CHALLENGE_SOLVED_WITH_ERROR.
Returns the HSBotDefenderChallengeFailureReason encoded in the given synthetic error body, or null if no reason is present / parseable. Only HSBotDefenderErrorType.CHALLENGE_SOLVED_WITH_ERROR bodies carry a reason; for other error types this always returns null.
Returns the relevant `HSBotDefenderErrorType` of the given error. When the policy type is set to `HSPolicyUrlRequestInterceptionType/INTERCEPT`, you can use this function to know if the request was blocked. When the policy type is set to `HSPolicyUrlRequestInterceptionType/INTERCEPT_WITH_DELAY`, you can use this function with the response to know if the request was solved or cancelled. If the error is not related, this function will return `HSBotDefenderErrorType/unknown`.
Handles the URL request's response and presents the challenge screen, if necessary. This suspend function is a coroutine-based alternative to handleBlockResponse. It suspends and returns the result once the challenge is solved or canceled.
Callback-based API. The callback receives only HSBotDefenderChallengeResult.SOLVED or HSBotDefenderChallengeResult.CANCELLED; HSBotDefenderChallengeResult.SOLVED_WITH_ERROR is folded down to HSBotDefenderChallengeResult.SOLVED for backward compatibility. Use handleBlockResponseWithReason to observe the full result and reason.
Callback-based API that surfaces the full result including HSBotDefenderChallengeResult.SOLVED_WITH_ERROR together with the accompanying HSBotDefenderChallengeFailureReason when applicable.
Returns HTTP headers that should be added to the URL request. This function should be used only when the `HSPolicy/urlRequestInterceptionType` is set to `PXPolicyUrlRequestInterceptionType/NONE`.
Set custom parameters for the given AppID.