Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{"version":3,"file":"register.min.js","sources":["../src/register.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * For collecting WebAuthn authenticator details on factor setup\n *\n * @module     factor_webauthn/register\n * @copyright  Catalyst IT\n * @author     Alex Morris <alex.morris@catalyst.net.nz>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['factor_webauthn/utils', 'core/log'], function(utils, Log) {\n    /**\n     * Register the security key.\n     *\n     * @param {*} createArgs\n     */\n    async function registerSecurityKey(createArgs) {\n        try {\n            if (!navigator.credentials || !navigator.credentials.create) {\n                throw new Error('Browser not supported.');\n            }\n\n            if (createArgs.success === false) {\n                throw new Error(createArgs.msg || 'unknown error occurred');\n            }\n\n            utils.recursiveBase64StrToArrayBuffer(createArgs);\n            const cred = await navigator.credentials.create(createArgs);\n            const authenticatorResponse = {\n                transports: cred.response.getTransports ? cred.response.getTransports() : null,\n                clientDataJSON: cred.response.clientDataJSON ?\n                    utils.arrayBufferToBase64(cred.response.clientDataJSON) : null,\n                attestationObject: cred.response.attestationObject ?\n                    utils.arrayBufferToBase64(cred.response.attestationObject) : null,\n            };\n            document.getElementById('id_response_input').value = JSON.stringify(authenticatorResponse);\n            // Enable the submit button so that we can proceed.\n            document.getElementById('id_submitbutton').disabled = false;\n        } catch (e) {\n            Log.debug('The request timed out or you have canceled the request. Please try again later.');\n        }\n    }\n\n    return {\n        init: function(createArgs) {\n            // Disable the submit button until we have registered a security key.\n            document.getElementById('id_submitbutton').disabled = true;\n            createArgs = JSON.parse(createArgs);\n            // Register event listeners.\n            document.getElementById('factor_webauthn-register').addEventListener('click', function() {\n                registerSecurityKey(createArgs);\n            });\n            document.getElementById('factor_webauthn-register').addEventListener('keypress', function() {\n                registerSecurityKey(createArgs);\n            });\n        }\n    };\n});\n"],"names":["define","utils","Log","registerSecurityKey","createArgs","navigator","credentials","create","Error","success","msg","recursiveBase64StrToArrayBuffer","cred","authenticatorResponse","transports","response","getTransports","clientDataJSON","arrayBufferToBase64","attestationObject","document","getElementById","value","JSON","stringify","disabled","e","debug","init","parse","addEventListener"],"mappings":";;;;;;;;AAwBAA,kCAAO,CAAC,wBAAyB,aAAa,SAASC,MAAOC,oBAM3CC,oBAAoBC,oBAEtBC,UAAUC,cAAgBD,UAAUC,YAAYC,aAC3C,IAAIC,MAAM,8BAGO,IAAvBJ,WAAWK,cACL,IAAID,MAAMJ,WAAWM,KAAO,0BAGtCT,MAAMU,gCAAgCP,kBAChCQ,WAAaP,UAAUC,YAAYC,OAAOH,YAC1CS,sBAAwB,CAC1BC,WAAYF,KAAKG,SAASC,cAAgBJ,KAAKG,SAASC,gBAAkB,KAC1EC,eAAgBL,KAAKG,SAASE,eAC1BhB,MAAMiB,oBAAoBN,KAAKG,SAASE,gBAAkB,KAC9DE,kBAAmBP,KAAKG,SAASI,kBAC7BlB,MAAMiB,oBAAoBN,KAAKG,SAASI,mBAAqB,MAErEC,SAASC,eAAe,qBAAqBC,MAAQC,KAAKC,UAAUX,uBAEpEO,SAASC,eAAe,mBAAmBI,UAAW,EACxD,MAAOC,GACLxB,IAAIyB,MAAM,0FAIX,CACHC,KAAM,SAASxB,YAEXgB,SAASC,eAAe,mBAAmBI,UAAW,EACtDrB,WAAamB,KAAKM,MAAMzB,YAExBgB,SAASC,eAAe,4BAA4BS,iBAAiB,SAAS,WAC1E3B,oBAAoBC,eAExBgB,SAASC,eAAe,4BAA4BS,iBAAiB,YAAY,WAC7E3B,oBAAoBC"}