Server IP : 104.21.38.3 / Your IP : 172.71.124.88 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/lapma.in/phpMyAdmin/js/src/ |
Upload File : |
/** * @param {ArrayBuffer} buffer * * @return {string} */ const arrayBufferToBase64 = buffer => { const bytes = new Uint8Array(buffer); let string = ''; for (const byte of bytes) { string += String.fromCharCode(byte); } return window.btoa(string); }; /** * @param {string} string * * @return {Uint8Array} */ const base64ToUint8Array = string => { return Uint8Array.from(window.atob(string), char => char.charCodeAt(0)); }; /** * @param {JQuery<HTMLElement>} $input * * @return {void} */ const handleCreation = $input => { const $form = $input.parents('form'); $form.find('input[type=submit]').hide(); const creationOptionsJson = $input.attr('data-creation-options'); const creationOptions = JSON.parse(creationOptionsJson); const publicKey = creationOptions; publicKey.challenge = base64ToUint8Array(creationOptions.challenge); publicKey.user.id = base64ToUint8Array(creationOptions.user.id); if (creationOptions.excludeCredentials) { const excludedCredentials = []; for (let value of creationOptions.excludeCredentials) { let excludedCredential = value; excludedCredential.id = base64ToUint8Array(value.id); excludedCredentials.push(excludedCredential); } publicKey.excludeCredentials = excludedCredentials; } // eslint-disable-next-line compat/compat navigator.credentials.create({ publicKey: publicKey }) .then((credential) => { const credentialJson = JSON.stringify({ id: credential.id, rawId: arrayBufferToBase64(credential.rawId), type: credential.type, response: { clientDataJSON: arrayBufferToBase64(credential.response.clientDataJSON), attestationObject: arrayBufferToBase64(credential.response.attestationObject), } }); $input.val(credentialJson); $form.trigger('submit'); }) .catch((error) => Functions.ajaxShowMessage(error, false, 'error')); }; /** * @param {JQuery<HTMLElement>} $input * * @return {void} */ const handleRequest = $input => { const $form = $input.parents('form'); $form.find('input[type=submit]').hide(); const requestOptionsJson = $input.attr('data-request-options'); const requestOptions = JSON.parse(requestOptionsJson); const publicKey = requestOptions; publicKey.challenge = base64ToUint8Array(requestOptions.challenge); if (requestOptions.allowCredentials) { const allowedCredentials = []; for (let value of requestOptions.allowCredentials) { let allowedCredential = value; allowedCredential.id = base64ToUint8Array(value.id); allowedCredentials.push(allowedCredential); } publicKey.allowCredentials = allowedCredentials; } // eslint-disable-next-line compat/compat navigator.credentials.get({ publicKey: publicKey }) .then((credential) => { const credentialJson = JSON.stringify({ id: credential.id, rawId: arrayBufferToBase64(credential.rawId), type: credential.type, response: { authenticatorData: arrayBufferToBase64(credential.response.authenticatorData), clientDataJSON: arrayBufferToBase64(credential.response.clientDataJSON), signature: arrayBufferToBase64(credential.response.signature), userHandle: arrayBufferToBase64(credential.response.userHandle), } }); $input.val(credentialJson); $form.trigger('submit'); }) .catch((error) => Functions.ajaxShowMessage(error, false, 'error')); }; AJAX.registerOnload('webauthn.js', function () { if ( ! navigator.credentials || ! navigator.credentials.create || ! navigator.credentials.get || ! window.PublicKeyCredential ) { Functions.ajaxShowMessage(Messages.webAuthnNotSupported, false, 'error'); return; } const $creationInput = $('#webauthn_creation_response'); if ($creationInput.length > 0) { handleCreation($creationInput); } const $requestInput = $('#webauthn_request_response'); if ($requestInput.length > 0) { handleRequest($requestInput); } });