Skip to content

Skip pre auth ACS form so onAuthorizationCompleted fires only on the final callback#45

Open
jim-daf wants to merge 2 commits into
LivotovLabs:masterfrom
jim-daf:fix/skip-pre-auth-form-issue-18
Open

Skip pre auth ACS form so onAuthorizationCompleted fires only on the final callback#45
jim-daf wants to merge 2 commits into
LivotovLabs:masterfrom
jim-daf:fix/skip-pre-auth-form-issue-18

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented Apr 22, 2026

Skip pre auth ACS form for 3D Secure with Continue button

Resolves #18

Some banks (the one in the linked issue is one of them) render an extra page
before the real ACS callback. That page is a normal HTML form with an MD
input, a PaReq input and a TermUrl input but no PaRes. The library used to
rely only on the strict ordering of MD then PaRes to know whether to fire the
callback, which is fragile and could fire too early on devices where the
regex matchers behaved differently across runs.

What changed

  1. D3SRegexUtils gets a small findPaReq helper so we can ask the same
    question the bank page asks itself: is this the pre auth form or the
    real callback.
  2. D3SView.match3DSV1Parameters now bails out as soon as it sees a PaReq
    input. That guarantees the listener is only invoked on the final form
    that carries MD and PaRes.

Why this works

The pre auth form always carries PaReq. The final ACS callback never does.
Detecting PaReq is therefore a reliable way to ignore the interstitial page
without affecting any other 3DS flow.

Testing

Existing D3SRegexUtilsTest cases continue to pass. The new helper is small
and mirrors the existing findMd and findPaRes style so it can be covered
by a one liner test if the maintainers want to extend the suite.

jim-daf added 2 commits April 22, 2026 20:33
Used by D3SView to skip the interstitial form some banks render before
the real ACS callback.
@jim-daf jim-daf marked this pull request as ready for review April 22, 2026 18:38
Copilot AI review requested due to automatic review settings April 22, 2026 18:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the 3DS v1 HTML parsing flow to avoid firing onAuthorizationCompleted on an interstitial “pre-auth” ACS form by explicitly detecting PaReq and skipping those pages.

Changes:

  • Add D3SRegexUtils.findPaReq(...) and a corresponding PaReq <input> regex pattern.
  • Update D3SView.match3DSV1Parameters(...) to return early when PaReq is present, ensuring callbacks occur only on the final MD + PaRes form.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
3DSView/src/main/java/eu/livotov/labs/android/d3s/D3SView.java Skips interstitial pre-auth 3DS v1 pages by bailing out when PaReq is detected.
3DSView/src/main/java/eu/livotov/labs/android/d3s/D3SRegexUtils.java Adds PaReq extraction support via a new regex pattern and helper method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 70 to +74
* @param html String representation of the html page to search within.
* @return PaRes or null if not found
*/
/**
* Returns the PaReq value if present, otherwise null. Use this to detect a
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Javadoc block ending with @return PaRes... (lines just above) is now separated from the findPaRes method by the newly inserted findPaReq, so it no longer documents the method it describes. Move the PaRes Javadoc to directly precede findPaRes, and keep only the PaReq Javadoc directly above findPaReq.

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +81
@Nullable
static String findPaReq(@NonNull String html) {
if (html.trim().isEmpty()) return null;

Matcher matcher = paReqFinder.matcher(html);
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findPaReq introduces new parsing behavior that affects when 3DS v1 callbacks fire, but it currently has no unit tests. Since D3SRegexUtilsTest already covers findMd/findPaRes thoroughly, please add analogous tests for findPaReq (empty/blank/no match/match/case-insensitive/multiline as appropriate).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

completeAuthorization called without required html form for 3D Secure with Continue button

2 participants