Merge pull request #19840 from liviuconcioiu/18066

Fix #18066 - Fix u2f is not defined

Fixes #18066
This commit is contained in:
Maurício Meneghini Fauth 2025-09-06 20:13:53 -03:00 committed by GitHub
commit e0f00c6508
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {