Skip to content

feat(apm)(POCP-1409): pick web redirects first, deep links as fallback - #298

Draft
lukasz-k-bieszczad-cko wants to merge 1 commit into
feat/apm-sessions-manual-finalizationfrom
feat/apm-sessions-web-redirect
Draft

lukasz-k-bieszczad-cko wants to merge 1 commit into
feat/apm-sessions-manual-finalizationfrom
feat/apm-sessions-web-redirect

Conversation

@lukasz-k-bieszczad-cko

@lukasz-k-bieszczad-cko lukasz-k-bieszczad-cko commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

The api is changing the redirect step of APM sessions. It keeps redirect, the link it picks as best, and may add alternative_redirects. Any of these links can be a web link (type: "web") or a deep link (type: "deep_link"). Until now, src/apm opened redirect.url whatever it was.

Agreed on the APM sync (2026-12-03): processout.js prefers the web link and uses a deep link only when there is no web link. HTTPS Universal Links, such as Revolut's, count as web unless the api types them as deep links.

Stacked on the manual finalization PR.

Solution

  • selectRedirect (src/apm/API.ts) picks the link to open from redirect followed by alternative_redirects:
    1. the first web link: type: "web" or no type, with an http(s) URL;
    2. otherwise the first type: "deep_link";
    3. otherwise nothing. Unknown types are never picked.
  • Blocked schemes: a deep link URL reaches window.open, so it must have a scheme and must not be javascript:, data:, vbscript:, file:, filesystem:, blob: or about:. Only the leading characters browsers strip (C0 controls and space) are trimmed before the check, so tab, newline and NBSP tricks are rejected.
  • The chosen link replaces redirect on the step, so views/Redirect.ts is unchanged. A NEXT_STEP_REQUIRED with only alternative_redirects is also a redirect step.
  • No usable link: the widget opens nothing, logs the offered types to telemetry (not the URLs, which carry tokens), stops polling, and fails with processout-js.apm.redirect-not-supported. That emits failure and shows the error view.
  • Malformed alternative_redirects (not an array) counts as absent, and null entries are skipped.
  • Types: Redirect gains type, confirmation_required and deep_link, and the step type gains alternative_redirects. confirmation_required isn't read: it is for mobile consent to deep links.
  • Docs: a "Redirects" section in the migration guide.

Demo

Not tested against the api yet, because the api doesn't send alternative_redirects or typed redirects yet. Covered by unit tests: the selection order, the deep-link fallback, the blocked schemes, the redirect step on the first answer, after a form submit and on a polling answer, the failure path through Page, and the logged message.

Checklist

  • I bumped the version of the project using yarn bump-version
  • I have checked the code for any potential issues
  • I tested my changes in the browser

Notes

  • Deep links don't complete yet. When a deep link opens a provider app, the redirect tab never posts back, so the flow still ends with customer.canceled (tab_closed). Redirect-step polling (stop on a new action_id) fixes this in a follow-up PR stacked on this one.
  • Behaviour change: a redirect step whose links are all unknown types or unsafe URLs now fails with processout-js.apm.redirect-not-supported. Before, the widget opened the URL.
  • Existing module/apm answers (an untyped redirect with an https URL) behave as before.

Jira Issue

POCP-1409

🤖 Generated with Claude Code

@lukasz-k-bieszczad-cko
lukasz-k-bieszczad-cko force-pushed the feat/apm-sessions-web-redirect branch from 0c4df39 to 8cf4ee8 Compare December 3, 2026 14:02
@lukasz-k-bieszczad-cko lukasz-k-bieszczad-cko changed the title feat(apm): open only web redirects from the redirect step feat(apm): pick web redirects first, deep links as fallback Dec 3, 2026
@lukasz-k-bieszczad-cko lukasz-k-bieszczad-cko changed the title feat(apm): pick web redirects first, deep links as fallback feat(apm)(POCP-1409): pick web redirects first, deep links as fallback Dec 3, 2026
@lukasz-k-bieszczad-cko
lukasz-k-bieszczad-cko force-pushed the feat/apm-sessions-web-redirect branch from 8cf4ee8 to 9d25928 Compare December 3, 2026 14:51
The api sends `redirect` (the link it picks as best) and may add
`alternative_redirects`. Either can be a web link or a deep link.

`selectRedirect` picks the link to open from `redirect` followed by
`alternative_redirects`: the first web link (`type: "web"` or no type,
with an http(s) URL), else the first `deep_link`. HTTPS Universal Links
count as web unless the api types them as deep links. The chosen link is
normalised into `redirect`, so the Redirect view is unchanged, and a
step with only `alternative_redirects` is a redirect step too.

A deep link URL reaches window.open, so it must have a scheme and must
not be javascript:, data:, vbscript:, file:, filesystem:, blob: or
about:. Only the leading characters browsers strip are trimmed first.

With no usable link the widget opens nothing, logs the offered types
(not the URLs, which carry tokens), stops polling and fails with
`processout-js.apm.redirect-not-supported`: `failure` plus the error
view. A malformed `alternative_redirects` counts as absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukasz-k-bieszczad-cko
lukasz-k-bieszczad-cko force-pushed the feat/apm-sessions-web-redirect branch from 9d25928 to 28759a3 Compare December 3, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant