From ab4ca518cb82d12d3c17db15cded78c4d52b08d5 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Mon, 1 Sep 2025 12:22:59 +0200 Subject: [PATCH] Fix u2f is not defined Signed-off-by: Liviu-Mihail Concioiu --- js/src/u2f.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/src/u2f.js b/js/src/u2f.js index 17af42f767..464858422a 100644 --- a/js/src/u2f.js +++ b/js/src/u2f.js @@ -8,6 +8,11 @@ AJAX.registerOnload('u2f.js', function () { setTimeout(function () { // A magic JS function that talks to the USB device. This function will keep polling for the USB device until it finds one. var request = JSON.parse($inputReg.attr('data-request')); + + if (!(window.u2f && typeof window.u2f.register === 'function')) { + return; + } + u2f.register(request.appId, [request], JSON.parse($inputReg.attr('data-signatures')), function (data) { // Handle returning error data if (data.errorCode && data.errorCode !== 0) { @@ -45,6 +50,11 @@ AJAX.registerOnload('u2f.js', function () { // Magic JavaScript talking to your HID // appid, challenge, authenticateRequests var request = JSON.parse($inputAuth.attr('data-request')); + + if (!(window.u2f && typeof window.u2f.sign === 'function')) { + return; + } + u2f.sign(request[0].appId, request[0].challenge, request, function (data) { // Handle returning error data if (data.errorCode && data.errorCode !== 0) {