Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"login.min.js","sources":["../src/login.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 login\n *\n * @module     factor_webauthn/login\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'], function(utils) {\n    return {\n        init: function(getArgs) {\n            const idSubmitButton = document.getElementById('id_submitbutton');\n            if (idSubmitButton) {\n                idSubmitButton.addEventListener('click', async function(e) {\n                    e.preventDefault();\n                    if (!navigator.credentials || !navigator.credentials.create) {\n                        throw new Error('Browser not supported.');\n                    }\n\n                    getArgs = JSON.parse(getArgs);\n\n                    if (getArgs.success === false) {\n                        throw new Error(getArgs.msg || 'unknown error occured');\n                    }\n\n                    utils.recursiveBase64StrToArrayBuffer(getArgs);\n\n                    const cred = await navigator.credentials.get(getArgs);\n\n                    const authenticatorAttestationResponse = {\n                        id: cred.rawId ? utils.arrayBufferToBase64(cred.rawId) : null,\n                        clientDataJSON:\n                            cred.response.clientDataJSON ? utils.arrayBufferToBase64(cred.response.clientDataJSON) : null,\n                        authenticatorData:\n                            cred.response.authenticatorData ? utils.arrayBufferToBase64(cred.response.authenticatorData) : null,\n                        signature: cred.response.signature ? utils.arrayBufferToBase64(cred.response.signature) : null,\n                        userHandle: cred.response.userHandle ? utils.arrayBufferToBase64(cred.response.userHandle) : null\n                    };\n\n                    const responseInput = document.getElementById('id_response_input');\n                    responseInput.value = JSON.stringify(authenticatorAttestationResponse);\n                    responseInput.form.submit();\n                });\n            }\n        }\n    };\n});\n"],"names":["define","utils","init","getArgs","idSubmitButton","document","getElementById","addEventListener","async","e","preventDefault","navigator","credentials","create","Error","JSON","parse","success","msg","recursiveBase64StrToArrayBuffer","cred","get","authenticatorAttestationResponse","id","rawId","arrayBufferToBase64","clientDataJSON","response","authenticatorData","signature","userHandle","responseInput","value","stringify","form","submit"],"mappings":";;;;;;;;AAwBAA,+BAAO,CAAC,0BAA0B,SAASC,aAChC,CACHC,KAAM,SAASC,eACLC,eAAiBC,SAASC,eAAe,mBAC3CF,gBACAA,eAAeG,iBAAiB,SAASC,eAAeC,MACpDA,EAAEC,kBACGC,UAAUC,cAAgBD,UAAUC,YAAYC,aAC3C,IAAIC,MAAM,8BAKI,KAFxBX,QAAUY,KAAKC,MAAMb,UAETc,cACF,IAAIH,MAAMX,QAAQe,KAAO,yBAGnCjB,MAAMkB,gCAAgChB,eAEhCiB,WAAaT,UAAUC,YAAYS,IAAIlB,SAEvCmB,iCAAmC,CACrCC,GAAIH,KAAKI,MAAQvB,MAAMwB,oBAAoBL,KAAKI,OAAS,KACzDE,eACIN,KAAKO,SAASD,eAAiBzB,MAAMwB,oBAAoBL,KAAKO,SAASD,gBAAkB,KAC7FE,kBACIR,KAAKO,SAASC,kBAAoB3B,MAAMwB,oBAAoBL,KAAKO,SAASC,mBAAqB,KACnGC,UAAWT,KAAKO,SAASE,UAAY5B,MAAMwB,oBAAoBL,KAAKO,SAASE,WAAa,KAC1FC,WAAYV,KAAKO,SAASG,WAAa7B,MAAMwB,oBAAoBL,KAAKO,SAASG,YAAc,MAG3FC,cAAgB1B,SAASC,eAAe,qBAC9CyB,cAAcC,MAAQjB,KAAKkB,UAAUX,kCACrCS,cAAcG,KAAKC"}