Skip to content

Conversation

@maremp
Copy link

@maremp maremp commented Oct 8, 2025

This PR fixes:
On iOS, JavaScript polling of BankID’s /collect endpoint may pause while the user is in the BankID app and won’t always resume on return. Handling the polling on the server makes the authentication flow more robust, particularly if the returnUrl doesn’t return the user to the correct browser/app

High level overview of this PR:

Refactored QR code refresh to use setInterval for periodic updates, replacing recursive timeouts. Introduced startQrCodeRefresh and stopQrCodeRefresh for better control and cleanup.

Rewrote status polling with an asynchronous loop, adding a statusPollingActive flag to prevent duplicate loops. Improved flow control for cancellation and completion states.

Refactored postJson to use iterative retries, enhancing error handling for non-JSON responses and unknown errors.

Improved type safety by using string | null for nullable parameters and variables. Enhanced event listener handling with optional chaining for safer execution.

Cleaned up redundant variables, consolidated logic, and added comments for better readability and maintainability. Updated UI visibility functions to handle null display values gracefully.

These things have been implemented (when relevant):

  • [X ] Code written
  • Test added
  • Documentation updated / written

Refactored QR code refresh to use `setInterval` for periodic updates, replacing recursive timeouts. Introduced `startQrCodeRefresh` and `stopQrCodeRefresh` for better control and cleanup.

Rewrote status polling with an asynchronous loop, adding a `statusPollingActive` flag to prevent duplicate loops. Improved flow control for cancellation and completion states.

Refactored `postJson` to use iterative retries, enhancing error handling for non-JSON responses and unknown errors.

Improved type safety by using `string | null` for nullable parameters and variables. Enhanced event listener handling with optional chaining for safer execution.

Cleaned up redundant variables, consolidated logic, and added comments for better readability and maintainability. Updated UI visibility functions to handle `null` display values gracefully.
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.

1 participant