Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ function activeloginInit(configuration: IBankIdUiScriptConfiguration, initState:
var flowIsCancelledByUser = false;
var flowIsFinished = false;

function launchBankIdApp(url: string) {
// Use BankID recommended approach for launching the app
// See: https://developers.bankid.com/getting-started/autostart
const link = document.createElement("a");
link.href = url;
link.referrerPolicy = "origin";
link.click();
}

function enableCancelButton(requestVerificationToken: string, cancelUrl: string, orderRef: string = null) {
var onCancelButtonClick = (event: Event) => {
cancel(requestVerificationToken, cancelUrl, orderRef);
Expand All @@ -132,15 +141,15 @@ function activeloginInit(configuration: IBankIdUiScriptConfiguration, initState:

if (data.deviceMightRequireUserInteractionToLaunchBankIdApp) {
var startBankIdAppButtonOnClick = (event: Event) => {
window.location.href = data.redirectUri;
launchBankIdApp(data.redirectUri);
hide(startBankIdAppButtonElement);
event.target.removeEventListener("click", startBankIdAppButtonOnClick);
};
startBankIdAppButtonElement.addEventListener("click", startBankIdAppButtonOnClick);

show(startBankIdAppButtonElement);
} else {
window.location.href = data.redirectUri;
launchBankIdApp(data.redirectUri);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,16 @@ public async Task<BankIdLaunchInfo> GetLaunchInfoAsync(LaunchUrlRequest request)
private bool GetDeviceMightRequireUserInteractionToLaunchBankIdApp(BankIdSupportedDevice detectedDevice, BankIdLauncherCustomBrowserConfig? customBrowserConfig)
{
var userInteractionBehaviour = customBrowserConfig?.BrowserMightRequireUserInteractionToLaunch ?? BrowserMightRequireUserInteractionToLaunch.Default;

return userInteractionBehaviour switch
{
BrowserMightRequireUserInteractionToLaunch.Always => true,
BrowserMightRequireUserInteractionToLaunch.Never => false,

// On Android, some browsers will (for security reasons) not launching a
// third party app/scheme (BankID) if there is no user interaction.
//
// - Chrome, Edge, Samsung Internet Browser and Brave is confirmed to require User Interaction
// - Firefox and Opera is confirmed to work without User Interaction
_ => detectedDevice.DeviceOs == BankIdSupportedDeviceOs.Android
&& detectedDevice.DeviceBrowser != BankIdSupportedDeviceBrowser.Firefox
&& detectedDevice.DeviceBrowser != BankIdSupportedDeviceBrowser.Opera
// Modern recommendation from BankID -> on mobile show fallback button
// Ref: https://developers.bankid.com/resources/ui-guide-mobile
_ => (detectedDevice.DeviceOs == BankIdSupportedDeviceOs.Ios
|| detectedDevice.DeviceOs == BankIdSupportedDeviceOs.Android)
};
}

Expand Down Expand Up @@ -99,20 +95,10 @@ private string GetPrefixPart(BankIdSupportedDevice device)

private static bool CanUseAppLink(BankIdSupportedDevice device)
{
// Only Safari on IOS and Chrome or Edge on Android version >= 6 seems to support
// the https://app.bankid.com/ launch url
// Universal Links (https://app.bankid.com/) are the recommended approach for mobile devices
// per BankID documentation: https://developers.bankid.com/getting-started/autostart

return device is
{
DeviceOs: BankIdSupportedDeviceOs.Ios,
DeviceBrowser: BankIdSupportedDeviceBrowser.Safari
}
or
{
DeviceOs: BankIdSupportedDeviceOs.Android,
DeviceOsVersion.MajorVersion: >= 6,
DeviceBrowser: BankIdSupportedDeviceBrowser.Chrome or BankIdSupportedDeviceBrowser.Edge
};
return device.DeviceOs == BankIdSupportedDeviceOs.Ios || device.DeviceOs == BankIdSupportedDeviceOs.Android;
}

private string GetQueryStringPart(BankIdSupportedDevice device, LaunchUrlRequest request, BankIdLauncherCustomBrowserConfig? customBrowserConfig)
Expand Down