Initial
This commit is contained in:
commit
104740166a
13 files changed
+1121
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -0,0 +1,898 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>CrabChat - Secure E2EE P2P Mesh (Equestrian Node)</title>
|
||||
<link id="dynamic-favicon" rel="icon" href="/favicon.ico">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Comic Code Regular', "Comic Sans MS", "Comic Sans", cursive, sans-serif;
|
||||
background: transparent;
|
||||
color: #4a3b5c;
|
||||
padding: 20px;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
}
|
||||
#ascii-bg {
|
||||
position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
|
||||
z-index: -1; font-family: monospace; font-size: 11px; line-height: 1.05; opacity: 0.55;
|
||||
}
|
||||
.card {
|
||||
background: #ffffffdd; border: 2px solid #e2d4f0; border-radius: 16px;
|
||||
padding: 24px; width: 100%; max-width: 650px; box-shadow: 0 8px 24px rgba(210, 190, 230, 0.3);
|
||||
box-sizing: border-box; margin-bottom: 20px; backdrop-filter: blur(4px);
|
||||
}
|
||||
h1, h2 { color: #6a4c93; margin-top: 0; text-align: center; }
|
||||
input, button, select {
|
||||
background: #f7f1fb; color: #4a3b5c; border: 2px solid #d8c8e8;
|
||||
border-radius: 10px; padding: 12px; margin: 8px 0; width: 100%; box-sizing: border-box;
|
||||
font-family: inherit; font-size: 14px;
|
||||
}
|
||||
button {
|
||||
background: linear-gradient(135deg, #ffd1dc 0%, #e0c3fc 50%, #c1d3fe 100%);
|
||||
font-weight: bold; cursor: pointer; transition: opacity 0.2s;
|
||||
}
|
||||
button.danger {
|
||||
background: linear-gradient(135deg, #ffccd5 0%, #ffb3c1 100%);
|
||||
color: #721c24;
|
||||
border-color: #f5c6cb;
|
||||
}
|
||||
button:hover { opacity: 0.9; }
|
||||
button:disabled, select:disabled { background: #e8e8e8; color: #aaa; border-color: #ddd; cursor: not-allowed; }
|
||||
.hidden { display: none; }
|
||||
#chat-box { width: 100%; height: 300px; border: 2px solid #d8c8e8; border-radius: 10px; overflow-y: scroll; padding: 12px; margin-bottom: 12px; background: #ffffff; box-sizing: border-box; }
|
||||
.msg { margin-bottom: 8px; word-wrap: break-word; }
|
||||
.msg.system { color: #8c78a0; font-style: italic; }
|
||||
.msg.private { color: #d81b60; font-weight: bold; }
|
||||
#status { font-weight: bold; color: #7a6095; margin-bottom: 10px; }
|
||||
.flex-row { display: flex; gap: 10px; align-items: center; }
|
||||
.file-input-wrapper { position: relative; overflow: hidden; display: inline-block; width: 100%; margin: 0; }
|
||||
.file-input-wrapper input[type=file] { font-size: 100px; position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; }
|
||||
progress { width: 100%; height: 16px; margin: 5px 0; }
|
||||
.turn-config { background: #fdfbf7; border: 1px dashed #d8c8e8; padding: 12px; border-radius: 10px; margin: 10px 0; }
|
||||
</style>
|
||||
<script src="/libsodium.js"></script>
|
||||
<script src="/libsodium-wrappers.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="ascii-bg"> .. .....
|
||||
....------..
|
||||
..:--------.. .......
|
||||
..----------.. ....---..
|
||||
...---------=------::....:----:..
|
||||
..-----=+**************=-----:...
|
||||
.----+****************=-----...
|
||||
.--=****************=-----=**+:::--:....
|
||||
.-=#*********##**++=---====++**+-----:.
|
||||
..:==********#=.+@%-==++===++===++*=----...
|
||||
.:=::******%%+-::=++====+==++====+**=--...
|
||||
.:+..+*****--@===-:-%--====-=+====+*#=:..
|
||||
.-=.-****#=.#+===--=+===----======+*+..
|
||||
.:=:+****#@#+=====-**-----*+====++**:.
|
||||
.. .=****=--======-..%-----%+==++***+-..
|
||||
..=++***+-.----======..*-----#+==+***#%#+..
|
||||
.. .:-..---=====--------=-+==+**-@*. ............::::::....
|
||||
..=:..--===+-:-------*%+==*+#%**=. .....:-------------------------:.
|
||||
..............-:..--===+-..:-------+==+==.:... ...:----------------------------::.
|
||||
......:----------::=:...--==+--:.:-------+==+=:.... ....--------------------------:.....
|
||||
..:::----------------=-::.:--===---:.:------=--:.... ...:---------------------------...
|
||||
..:------------------=--:..:--=+=--------::.:+-..... ...------------------------------..
|
||||
...:-----------------:....----==-------:...=%*.......:::--------------------------------:..
|
||||
...--------------:+......---------------:+%%#.----------------------------:.......-----:..
|
||||
.:----===-------:-.. .:--------------*%%%%=--------------========------:.......-------:...
|
||||
..-:.:------------....-.=---------=#%%%%##%------------=-----------------------------------..
|
||||
.:--:....:--------:##*=:.-------=#%%%%%%#%+-----------=-------------------------------------:
|
||||
..:-----------------::*%%#-------=###%%%%##=--------------------------------------:............
|
||||
..:-------------------:.-#%%##+==+%%%%%%#%+------------------------...:::--------------::::::..
|
||||
...:----------------------..-#%#%%%%%%%%*+#%=-------------------------=-:....:----------------:...
|
||||
--------------------------:.-#%%%%%%%%+#@%%%--------------------------=++=-::---------------:...
|
||||
---------------------------...+%%%%%]%%%%#---------------------------------------------:....
|
||||
............------.....----:....-#%%%%%%%*=------------------------------::+=---------.......
|
||||
..:-... ....-----.. ....-=-------------------------------------.=*+=.......
|
||||
..---:....:-----:.......:--------------------------:-------------==+=-......
|
||||
.:-------------..........:---------------------------..:-------------==..........
|
||||
..-------------:... ...--------:...----------------....:-----------==-...........
|
||||
..:----==------:..-.... ..--------:...:---------------.....:----------=+=.....
|
||||
..------==+=++==-..+--:. .:--------.....-----------=*%=.. ..----------=+=......
|
||||
....------------........:... ..:--------.....-------+#%%#@%.. ...----------=+=......
|
||||
....---------===:............... .:----=+*#=. ..--+#**+%@@@#%+. ..:-:..=----=*=:.....
|
||||
:............:=::+=:--:=.=-.::=... ..*@*-+%@@@:.....-@@#%@*#@@@#%:.. ..-:..---:-#**+-.........
|
||||
.. ...::::....::-.:.::-.. ..*%:..*@@@*.. ..-%#%@@+%@@@@=.. ...::.=#=..-%*++=:... ...
|
||||
...... .......... ..**...*#=*%:. .-*#@%+#%@@@@+... ..*%@%+...+%+=*+=-...
|
||||
..*#:.-#+..+-. ..-*#**%%*%@@%=.. ..-%@@*:..+@%=:+**+=:..
|
||||
..*@#*%%=..==. .-*%@#%@##@@@#-. ...#@@%*-=%@@#:..-=++=-
|
||||
.:#@*-:++..==. .=#%@%*@@*%*=+*:....:.+@*::+%@@@%=......-*
|
||||
.-%+...=%##%-. .+@*@%*%@##*-:*+..:-==*@=..:#@+:=*:.......
|
||||
.:*#:..:*@@@%:. .-%@*%@#*%*#=..-%-....:+#=-.:#%-.:+-.......
|
||||
.+@#=.-*@@@@*.. ....-%@@@@@@=..+%*.. .-%--=+#%-.:*-. ....
|
||||
.-=++++++++=... .:***+++==::::... .-%#=-*#%#**#-. </pre>
|
||||
|
||||
<div id="auth-section" class="card">
|
||||
<h1 id="main-title" style="font-size: 28px;">🦀 CrabChat</h1>
|
||||
<h2 id="auth-title">Awaiting Princess Pi's Cryptographic Grimoire...</h2>
|
||||
|
||||
<input type="text" id="room-input" placeholder="Room ID (Leave blank to generate an invite-only room)">
|
||||
<input type="text" id="username" placeholder="Username (Optional)">
|
||||
<input type="password" id="passphrase" placeholder="Passphrase (Min 20 chars, Upper, Lower, Digit, Special)">
|
||||
|
||||
<div class="turn-config">
|
||||
<div style="font-size: 12px; font-weight: bold; margin-bottom: 5px; color: #6a4c93;">Optional TURN Server (Fixes ICE/Firewall Connection Failures):</div>
|
||||
<input type="text" id="turn-url" placeholder="turn:your-turn-server.com:3478" style="margin: 4px 0; font-size: 12px; padding: 8px;">
|
||||
<input type="text" id="turn-username" placeholder="TURN Username" style="margin: 4px 0; font-size: 12px; padding: 8px;">
|
||||
<input type="password" id="turn-credential" placeholder="TURN Password / Secret" style="margin: 4px 0; font-size: 12px; padding: 8px;">
|
||||
</div>
|
||||
|
||||
<button id="auth-btn">Unlock / Generate</button>
|
||||
|
||||
<div style="margin-top: 15px; border-top: 1px dashed #d8c8e8; padding-top: 15px; display: flex; gap: 10px; align-items: center;">
|
||||
<button id="export-key-btn" style="flex: 1; margin: 0; font-size: 13px; padding: 8px;">💾 Export Key</button>
|
||||
<div class="file-input-wrapper" style="flex: 1; margin: 0;">
|
||||
<button style="width: 100%; margin: 0; font-size: 13px; padding: 8px;">📁 Import Key</button>
|
||||
<input type="file" id="import-key-file" accept=".json,.key,.txt" style="margin: 0;" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 10px;">
|
||||
<button id="destroy-identity-auth-btn" class="danger" style="font-size: 13px; padding: 8px; margin: 0;">⚠️ Destroy Identity</button>
|
||||
</div>
|
||||
<p id="auth-status" style="text-align: center; color: #8c78a0; font-size: 13px; margin-top: 10px;"></p>
|
||||
</div>
|
||||
|
||||
<div id="chat-section" class="card hidden">
|
||||
<h1 id="main-title-chat" style="font-size: 28px;">🦀 CrabChat</h1>
|
||||
|
||||
<div class="header-controls" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-size: 14px; flex-wrap: wrap; gap: 10px;">
|
||||
<div><strong>Identity:</strong> <span id="my-identity"></span></div>
|
||||
<div style="display: flex; align-items: center; gap: 5px;">
|
||||
<strong>Room:</strong> <span id="current-room-display"></span>
|
||||
<button id="copy-room-btn" style="width:auto; padding: 4px 8px; margin: 0;">📋 Copy Link</button>
|
||||
</div>
|
||||
<div style="display: flex; gap: 5px;">
|
||||
<button id="chat-export-key-btn" style="width: auto; padding: 4px 8px; margin: 0; font-size: 12px;">💾 Export</button>
|
||||
<div class="file-input-wrapper" style="display: inline-block; width: auto; margin: 0;">
|
||||
<button style="width: auto; padding: 4px 8px; margin: 0; font-size: 12px;">📁 Import</button>
|
||||
<input type="file" id="chat-import-key-file" accept=".json,.key,.txt" style="margin: 0;" />
|
||||
</div>
|
||||
<button id="destroy-identity-chat-btn" class="danger" style="width: auto; padding: 4px 8px; margin: 0; font-size: 12px;">⚠️ Destroy</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="status">Status: Connecting to signaling server...</div>
|
||||
<div id="chat-box"></div>
|
||||
|
||||
<!-- File Transfer & Message Controls -->
|
||||
<div style="margin-bottom: 10px; display: flex; gap: 10px; align-items: center;">
|
||||
<div class="file-input-wrapper" style="flex: 1;">
|
||||
<button style="margin: 0; font-size: 13px; padding: 8px;">📎 Send File (Max 100MB)</button>
|
||||
<input type="file" id="file-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="file-progress-container" class="hidden">
|
||||
<span id="file-progress-label" style="font-size: 12px; color: #6a4c93;">Uploading file...</span>
|
||||
<progress id="file-progress" value="0" max="100"></progress>
|
||||
</div>
|
||||
|
||||
<div class="flex-row">
|
||||
<select id="recipient-select" style="width: 30%; margin:0;" disabled>
|
||||
<option value="all">Everyone</option>
|
||||
</select>
|
||||
<input type="text" id="message-input" placeholder="Type an encrypted message (max 2000 chars)..." maxlength="2000" disabled style="margin:0; width: 50%;" />
|
||||
<button id="send-btn" disabled style="width: 20%; margin:0;">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script>
|
||||
/* =========================================================================
|
||||
ARGON2ID & PFS SETUP CONFIGURATIONS
|
||||
========================================================================= */
|
||||
const ARGON2_OPSLIMIT = window.sodium?.crypto_pwhash_OPSLIMIT_MODERATE || 3;
|
||||
const ARGON2_MEMLIMIT = window.sodium?.crypto_pwhash_MEMLIMIT_MODERATE || 268435456; // 256MB
|
||||
const MAX_MESSAGE_LENGTH = 2000;
|
||||
const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
||||
const CHUNK_SIZE = 64 * 1024; // 64KB chunks for WebRTC DataChannel
|
||||
|
||||
let myKeyPair = null;
|
||||
let myPublicKeyHex = null;
|
||||
let myUsername = "Anonymous";
|
||||
let currentRoom = null;
|
||||
|
||||
// PFS Session Store: maps userId -> ephemeral precalculated shared secret session key
|
||||
const sessionKeys = {};
|
||||
const incomingFiles = {};
|
||||
|
||||
const socket = io({ autoConnect: false });
|
||||
const peerConnections = {};
|
||||
const dataChannels = {};
|
||||
const peerIdentities = {};
|
||||
|
||||
const rawStunServers = [
|
||||
"stun.nextcloud.com:443",
|
||||
"stun.services.mozilla.com:3478",
|
||||
"stun.stunprotocol.org:3478",
|
||||
"stun.freeswitch.org:3478"
|
||||
];
|
||||
|
||||
const pastelColors = ['#ffd1dc', '#ffb7b2', '#ffdac1', '#e2f0cb', '#b5ead7', '#c7ceea', '#e0c3fc', '#f3c6ff', '#d8b4fe', '#bae1ff', '#ffffba'];
|
||||
|
||||
function setFavicon(state) {
|
||||
const favicon = document.getElementById('dynamic-favicon');
|
||||
if (!favicon) return;
|
||||
if (state === 'good') favicon.href = '/favicon-good.ico';
|
||||
else if (state === 'bad') favicon.href = '/favicon-bad.ico';
|
||||
else favicon.href = '/favicon.ico';
|
||||
}
|
||||
|
||||
function triggerGoodFaviconPulse() {
|
||||
setFavicon('good');
|
||||
setTimeout(() => setFavicon('normal'), 4000);
|
||||
}
|
||||
|
||||
function animateAsciiBg() {
|
||||
const asciiEl = document.getElementById('ascii-bg');
|
||||
if (!asciiEl) return;
|
||||
asciiEl.style.color = pastelColors[Math.floor(Math.random() * pastelColors.length)];
|
||||
setTimeout(animateAsciiBg, Math.floor(Math.random() * (600 - 5 + 1)) + 5);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
animateAsciiBg();
|
||||
try {
|
||||
await sodium.ready;
|
||||
init();
|
||||
} catch (e) {
|
||||
setFavicon('bad');
|
||||
document.getElementById('auth-title').innerText = "Libsodium Failed to Load!";
|
||||
}
|
||||
});
|
||||
|
||||
function initHeaderAnimation(elementId) {
|
||||
const headerEl = document.getElementById(elementId);
|
||||
if (!headerEl) return;
|
||||
const text = headerEl.textContent;
|
||||
headerEl.innerHTML = '';
|
||||
const pastelAnimColors = ['#ffd1dc', '#ffb7b2', '#ffdac1', '#e2f0cb', '#b5ead7', '#c7ceea', '#e0c3fc', '#f3c6ff', '#d8b4fe'];
|
||||
|
||||
text.split('').forEach(char => {
|
||||
const span = document.createElement('span');
|
||||
span.textContent = char;
|
||||
headerEl.appendChild(span);
|
||||
function randomize() {
|
||||
span.style.color = pastelAnimColors[Math.floor(Math.random() * pastelAnimColors.length)];
|
||||
setTimeout(randomize, Math.floor(Math.random() * 595) + 5);
|
||||
}
|
||||
randomize();
|
||||
});
|
||||
}
|
||||
|
||||
async function validatePassphrase(passphrase) {
|
||||
if (passphrase.length < 20) return "Passphrase must be at least 20 characters long.";
|
||||
if (!/[a-z]/.test(passphrase)) return "Passphrase must contain at least one lowercase letter.";
|
||||
if (!/[A-Z]/.test(passphrase)) return "Passphrase must contain at least one uppercase letter.";
|
||||
if (!/[0-9]/.test(passphrase)) return "Passphrase must contain at least one digit.";
|
||||
if (!/[^A-Za-z0-9]/.test(passphrase)) return "Passphrase must contain at least one special character.";
|
||||
return null;
|
||||
}
|
||||
|
||||
function init() {
|
||||
initHeaderAnimation('main-title');
|
||||
initHeaderAnimation('main-title-chat');
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const roomParam = urlParams.get('room');
|
||||
if (roomParam) document.getElementById('room-input').value = roomParam;
|
||||
|
||||
// Load saved TURN config if any
|
||||
const savedTurn = localStorage.getItem('crabchat_turn');
|
||||
if (savedTurn) {
|
||||
try {
|
||||
const tConfig = JSON.parse(savedTurn);
|
||||
document.getElementById('turn-url').value = tConfig.url || '';
|
||||
document.getElementById('turn-username').value = tConfig.username || '';
|
||||
document.getElementById('turn-credential').value = tConfig.credential || '';
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
const authBtn = document.getElementById('auth-btn');
|
||||
const authTitle = document.getElementById('auth-title');
|
||||
const savedData = localStorage.getItem('crabchat_identity');
|
||||
|
||||
if (savedData) {
|
||||
authTitle.innerText = "Encrypted Identity Found in LocalStorage";
|
||||
authBtn.innerText = "Decrypt & Login";
|
||||
authBtn.onclick = () => unlockKey(JSON.parse(savedData));
|
||||
} else {
|
||||
authTitle.innerText = "Generate New Identity (Argon2id Protected)";
|
||||
authBtn.onclick = generateKey;
|
||||
}
|
||||
|
||||
document.getElementById('export-key-btn').onclick = exportKey;
|
||||
document.getElementById('import-key-file').onchange = handleKeyImport;
|
||||
document.getElementById('chat-export-key-btn').onclick = exportKey;
|
||||
document.getElementById('chat-import-key-file').onchange = handleKeyImport;
|
||||
document.getElementById('file-input').onchange = handleFileUpload;
|
||||
|
||||
// Destroy Identity hooks
|
||||
document.getElementById('destroy-identity-auth-btn').onclick = destroyIdentity;
|
||||
document.getElementById('destroy-identity-chat-btn').onclick = destroyIdentity;
|
||||
}
|
||||
|
||||
function saveTurnConfig() {
|
||||
const url = document.getElementById('turn-url').value.trim();
|
||||
const username = document.getElementById('turn-username').value.trim();
|
||||
const credential = document.getElementById('turn-credential').value.trim();
|
||||
if (url) {
|
||||
localStorage.setItem('crabchat_turn', JSON.stringify({ url, username, credential }));
|
||||
} else {
|
||||
localStorage.removeItem('crabchat_turn');
|
||||
}
|
||||
}
|
||||
|
||||
function destroyIdentity() {
|
||||
if (confirm("⚠️ Are you sure you want to destroy your cryptographic identity? This will permanently delete your keys from local storage, close all connections, and reset CrabChat.")) {
|
||||
localStorage.removeItem('crabchat_identity');
|
||||
localStorage.removeItem('crabchat_turn');
|
||||
myKeyPair = null;
|
||||
myPublicKeyHex = null;
|
||||
for (const pid in peerConnections) {
|
||||
try { peerConnections[pid].close(); } catch(e) {}
|
||||
}
|
||||
if (socket.connected) socket.disconnect();
|
||||
window.location.href = window.location.pathname;
|
||||
}
|
||||
}
|
||||
|
||||
/* ROBUST ARGON2ID KEY DERIVATION WITH WEBCRYPTO FALLBACK */
|
||||
async function deriveKeyFromPassphrase(passphrase, saltBytes) {
|
||||
if (window.sodium && typeof window.sodium.crypto_pwhash === 'function') {
|
||||
const enc = new TextEncoder();
|
||||
const passwdBytes = enc.encode(passphrase);
|
||||
return window.sodium.crypto_pwhash(
|
||||
32,
|
||||
passwdBytes,
|
||||
saltBytes,
|
||||
ARGON2_OPSLIMIT,
|
||||
ARGON2_MEMLIMIT,
|
||||
window.sodium.crypto_pwhash_ALG_ARGON2ID
|
||||
);
|
||||
} else {
|
||||
const enc = new TextEncoder();
|
||||
const baseKey = await window.crypto.subtle.importKey(
|
||||
"raw",
|
||||
enc.encode(passphrase),
|
||||
{ name: "PBKDF2" },
|
||||
false,
|
||||
["deriveBits"]
|
||||
);
|
||||
const derivedBits = await window.crypto.subtle.deriveBits(
|
||||
{
|
||||
name: "PBKDF2",
|
||||
salt: saltBytes,
|
||||
iterations: 100000,
|
||||
hash: "SHA-256"
|
||||
},
|
||||
baseKey,
|
||||
256
|
||||
);
|
||||
return new Uint8Array(derivedBits);
|
||||
}
|
||||
}
|
||||
|
||||
async function exportKey() {
|
||||
if (!myKeyPair) {
|
||||
const passphrase = document.getElementById('passphrase').value;
|
||||
if (!passphrase) return alert("No active identity loaded. Unlock or provide a valid passphrase to export.");
|
||||
const err = await validatePassphrase(passphrase);
|
||||
if (err) return alert(err);
|
||||
myKeyPair = window.sodium.crypto_sign_keypair();
|
||||
myPublicKeyHex = window.sodium.to_hex(myKeyPair.publicKey);
|
||||
}
|
||||
const data = {
|
||||
publicKey: window.sodium.to_hex(myKeyPair.publicKey),
|
||||
privateKey: window.sodium.to_hex(myKeyPair.privateKey),
|
||||
metadata: "Exported under Princess Pi & Prince Stolas protection (Argon2id + PFS)"
|
||||
};
|
||||
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'crabchat-identity.json';
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
triggerGoodFaviconPulse();
|
||||
}
|
||||
|
||||
async function handleKeyImport(event) {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (e) => {
|
||||
try {
|
||||
const parsed = JSON.parse(e.target.result);
|
||||
const privKeyBytes = window.sodium.from_hex(parsed.privateKey);
|
||||
|
||||
let pubKey;
|
||||
if (window.sodium && typeof window.sodium.crypto_sign_ed25519_sk_to_pk === 'function') {
|
||||
pubKey = window.sodium.crypto_sign_ed25519_sk_to_pk(privKeyBytes);
|
||||
} else if (privKeyBytes.length === 64) {
|
||||
pubKey = privKeyBytes.subarray(32, 64);
|
||||
} else if (privKeyBytes.length === 32) {
|
||||
const kp = window.sodium.crypto_sign_seed_keypair(privKeyBytes);
|
||||
pubKey = kp.publicKey;
|
||||
myKeyPair = kp;
|
||||
} else {
|
||||
throw new Error("Invalid private key length.");
|
||||
}
|
||||
|
||||
if (!myKeyPair) {
|
||||
myKeyPair = { privateKey: privKeyBytes, publicKey: pubKey };
|
||||
}
|
||||
myPublicKeyHex = window.sodium.to_hex(myKeyPair.publicKey);
|
||||
await promptAndEncryptAndStoreImportedKey();
|
||||
} catch (err) {
|
||||
setFavicon('bad');
|
||||
alert("Key import failed: " + err.message);
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
async function promptAndEncryptAndStoreImportedKey() {
|
||||
const passphrase = prompt("Enter encryption passphrase (Min 20 chars, Upper, Lower, Digit, Special):");
|
||||
if (!passphrase) return;
|
||||
const err = await validatePassphrase(passphrase);
|
||||
if (err) { alert(err); return; }
|
||||
|
||||
const salt = window.crypto.getRandomValues(new Uint8Array(16));
|
||||
const derivedKey = await deriveKeyFromPassphrase(passphrase, salt);
|
||||
const nonce = window.sodium.randombytes_buf(window.sodium.crypto_secretbox_NONCEBYTES);
|
||||
const encryptedPrivKey = window.sodium.crypto_secretbox_easy(myKeyPair.privateKey, nonce, derivedKey);
|
||||
|
||||
const identityData = {
|
||||
publicKey: myPublicKeyHex,
|
||||
encryptedPrivKey: window.sodium.to_hex(encryptedPrivKey),
|
||||
salt: Array.from(salt),
|
||||
nonce: window.sodium.to_hex(nonce)
|
||||
};
|
||||
localStorage.setItem('crabchat_identity', JSON.stringify(identityData));
|
||||
saveTurnConfig();
|
||||
alert("Imported identity successfully encrypted and stored!");
|
||||
}
|
||||
|
||||
async function generateKey() {
|
||||
const passphrase = document.getElementById('passphrase').value;
|
||||
const errorMsg = await validatePassphrase(passphrase);
|
||||
if (errorMsg) { alert(errorMsg); return; }
|
||||
|
||||
try {
|
||||
const keypair = window.sodium.crypto_sign_keypair();
|
||||
const salt = window.crypto.getRandomValues(new Uint8Array(16));
|
||||
const derivedKey = await deriveKeyFromPassphrase(passphrase, salt);
|
||||
const nonce = window.sodium.randombytes_buf(window.sodium.crypto_secretbox_NONCEBYTES);
|
||||
const encryptedPrivKey = window.sodium.crypto_secretbox_easy(keypair.privateKey, nonce, derivedKey);
|
||||
|
||||
const identityData = {
|
||||
publicKey: window.sodium.to_hex(keypair.publicKey),
|
||||
encryptedPrivKey: window.sodium.to_hex(encryptedPrivKey),
|
||||
salt: Array.from(salt),
|
||||
nonce: window.sodium.to_hex(nonce)
|
||||
};
|
||||
|
||||
localStorage.setItem('crabchat_identity', JSON.stringify(identityData));
|
||||
saveTurnConfig();
|
||||
myKeyPair = keypair;
|
||||
myPublicKeyHex = identityData.publicKey;
|
||||
myUsername = document.getElementById('username').value || "Princess Pi's Admirer";
|
||||
enterChat();
|
||||
} catch (err) {
|
||||
setFavicon('bad');
|
||||
alert("Key generation failed: " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function unlockKey(data) {
|
||||
const passphrase = document.getElementById('passphrase').value;
|
||||
if (!passphrase) return alert("Passphrase required to unlock your key.");
|
||||
try {
|
||||
const salt = new Uint8Array(data.salt);
|
||||
const derivedKey = await deriveKeyFromPassphrase(passphrase, salt);
|
||||
const nonce = window.sodium.from_hex(data.nonce);
|
||||
const encryptedPrivKey = window.sodium.from_hex(data.encryptedPrivKey);
|
||||
|
||||
myKeyPair = {
|
||||
publicKey: window.sodium.from_hex(data.publicKey),
|
||||
privateKey: window.sodium.crypto_secretbox_open_easy(encryptedPrivKey, nonce, derivedKey)
|
||||
};
|
||||
myPublicKeyHex = data.publicKey;
|
||||
myUsername = document.getElementById('username').value || "Princess Pi's Admirer";
|
||||
saveTurnConfig();
|
||||
enterChat();
|
||||
} catch (e) {
|
||||
setFavicon('bad');
|
||||
alert("Incorrect passphrase or corrupted grimoire key.");
|
||||
}
|
||||
}
|
||||
|
||||
/* PERFECT FORWARD SECRECY (PFS) ENCRYPTION / DECRYPTION */
|
||||
function encryptForPeer(plaintext, userId) {
|
||||
const sessionKey = sessionKeys[userId];
|
||||
if (!sessionKey) throw new Error("No active PFS session key established with peer.");
|
||||
const nonce = window.sodium.randombytes_buf(window.sodium.crypto_box_NONCEBYTES);
|
||||
const ciphertext = window.sodium.crypto_box_easy_afternm(plaintext, nonce, sessionKey);
|
||||
return { ciphertext: window.sodium.to_hex(ciphertext), nonce: window.sodium.to_hex(nonce) };
|
||||
}
|
||||
|
||||
function decryptFromPeer(encryptedPayload, userId) {
|
||||
const sessionKey = sessionKeys[userId];
|
||||
if (!sessionKey) throw new Error("No active PFS session key established with peer.");
|
||||
const plaintextBytes = window.sodium.crypto_box_open_easy_afternm(
|
||||
window.sodium.from_hex(encryptedPayload.ciphertext),
|
||||
window.sodium.from_hex(encryptedPayload.nonce),
|
||||
sessionKey
|
||||
);
|
||||
return window.sodium.to_string(plaintextBytes);
|
||||
}
|
||||
|
||||
function enterChat() {
|
||||
document.getElementById('auth-section').classList.add('hidden');
|
||||
document.getElementById('chat-section').classList.remove('hidden');
|
||||
document.getElementById('my-identity').innerText = `${myUsername} (@${myPublicKeyHex.substring(0, 8)})`;
|
||||
|
||||
currentRoom = document.getElementById('room-input').value.trim() || window.sodium.to_hex(window.sodium.randombytes_buf(8));
|
||||
window.history.pushState({}, '', '?room=' + currentRoom);
|
||||
document.getElementById('current-room-display').innerText = currentRoom;
|
||||
|
||||
document.getElementById('copy-room-btn').onclick = () => {
|
||||
navigator.clipboard.writeText(window.location.origin + window.location.pathname + '?room=' + currentRoom);
|
||||
alert('Secure invite link copied!');
|
||||
};
|
||||
socket.connect();
|
||||
}
|
||||
|
||||
const statusDiv = document.getElementById('status');
|
||||
const chatBox = document.getElementById('chat-box');
|
||||
const messageInput = document.getElementById('message-input');
|
||||
const sendBtn = document.getElementById('send-btn');
|
||||
const recipientSelect = document.getElementById('recipient-select');
|
||||
|
||||
function appendMessage(sender, text, isSystem = false, isPrivate = false) {
|
||||
const div = document.createElement('div');
|
||||
div.className = isSystem ? 'msg system' : (isPrivate ? 'msg private' : 'msg');
|
||||
div.textContent = isSystem ? text : `${sender}: ${text}`;
|
||||
chatBox.appendChild(div);
|
||||
chatBox.scrollTop = chatBox.scrollHeight;
|
||||
}
|
||||
|
||||
function appendFileMessage(sender, fileName, fileBlob, isPrivate = false) {
|
||||
const div = document.createElement('div');
|
||||
div.className = isPrivate ? 'msg private' : 'msg';
|
||||
const url = URL.createObjectURL(fileBlob);
|
||||
div.innerHTML = `${sender} sent a file: <a href="${url}" download="${fileName}">${fileName}</a>`;
|
||||
chatBox.appendChild(div);
|
||||
chatBox.scrollTop = chatBox.scrollHeight;
|
||||
}
|
||||
|
||||
function updateActivePeers() {
|
||||
const activeKeys = Object.keys(sessionKeys).length;
|
||||
if (activeKeys > 0) {
|
||||
statusDiv.textContent = `Status: PFS E2EE Tunnel Active with ${activeKeys} peer(s).`;
|
||||
messageInput.disabled = false;
|
||||
sendBtn.disabled = false;
|
||||
recipientSelect.disabled = false;
|
||||
} else {
|
||||
statusDiv.textContent = `Status: In Room '${currentRoom}'. Waiting for peers...`;
|
||||
messageInput.disabled = true;
|
||||
sendBtn.disabled = true;
|
||||
recipientSelect.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function addRecipientOption(userId, label) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = userId;
|
||||
opt.textContent = label;
|
||||
opt.id = `opt-${userId}`;
|
||||
recipientSelect.appendChild(opt);
|
||||
}
|
||||
|
||||
function removeRecipientOption(userId) {
|
||||
const opt = document.getElementById(`opt-${userId}`);
|
||||
if (opt) {
|
||||
opt.remove();
|
||||
if (recipientSelect.value === userId) recipientSelect.value = 'all';
|
||||
}
|
||||
}
|
||||
|
||||
function createPeerConnection(userId, isInitiator = false) {
|
||||
if (peerConnections[userId]) peerConnections[userId].close();
|
||||
|
||||
const currentStun = 'stun:' + rawStunServers[Math.floor(Math.random() * rawStunServers.length)];
|
||||
const iceServers = [{ urls: currentStun }];
|
||||
|
||||
// Include custom TURN server if configured
|
||||
const savedTurn = localStorage.getItem('crabchat_turn');
|
||||
if (savedTurn) {
|
||||
try {
|
||||
const t = JSON.parse(savedTurn);
|
||||
if (t.url) {
|
||||
const turnServer = { urls: t.url };
|
||||
if (t.username) turnServer.username = t.username;
|
||||
if (t.credential) turnServer.credential = t.credential;
|
||||
iceServers.push(turnServer);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
const pc = new RTCPeerConnection({ iceServers });
|
||||
peerConnections[userId] = pc;
|
||||
|
||||
pc.onicecandidate = (e) => { if (e.candidate) socket.emit('ice-candidate', { target: userId, candidate: e.candidate }); };
|
||||
return pc;
|
||||
}
|
||||
|
||||
function setupDataChannelEvents(dc, userId) {
|
||||
dataChannels[userId] = dc;
|
||||
|
||||
dc.onopen = () => {
|
||||
const ephKey = window.sodium.crypto_box_keypair();
|
||||
const sig = window.sodium.crypto_sign_detached(ephKey.publicKey, myKeyPair.privateKey);
|
||||
|
||||
dc.send(JSON.stringify({
|
||||
type: 'pfs-handshake',
|
||||
pubKey: myPublicKeyHex,
|
||||
username: myUsername,
|
||||
ephPubKey: window.sodium.to_hex(ephKey.publicKey),
|
||||
signature: window.sodium.to_hex(sig)
|
||||
}));
|
||||
dc.ephKey = ephKey;
|
||||
};
|
||||
|
||||
dc.onclose = () => {
|
||||
delete dataChannels[userId];
|
||||
delete sessionKeys[userId];
|
||||
delete peerIdentities[userId];
|
||||
removeRecipientOption(userId);
|
||||
updateActivePeers();
|
||||
};
|
||||
|
||||
dc.onmessage = (event) => {
|
||||
try {
|
||||
if (typeof event.data === 'string') {
|
||||
const data = JSON.parse(event.data);
|
||||
|
||||
if (data.type === 'pfs-handshake') {
|
||||
const valid = window.sodium.crypto_sign_verify_detached(
|
||||
window.sodium.from_hex(data.signature),
|
||||
window.sodium.from_hex(data.ephPubKey),
|
||||
window.sodium.from_hex(data.pubKey)
|
||||
);
|
||||
if (!valid) throw new Error("Invalid ephemeral key signature!");
|
||||
|
||||
peerIdentities[userId] = { pubKey: data.pubKey, username: data.username };
|
||||
|
||||
const peerEphPubBytes = window.sodium.from_hex(data.ephPubKey);
|
||||
const sharedSecret = window.sodium.crypto_box_beforenm(peerEphPubBytes, dc.ephKey.privateKey);
|
||||
sessionKeys[userId] = sharedSecret;
|
||||
|
||||
const shortId = data.pubKey.substring(0, 8);
|
||||
const label = `${data.username} (@${shortId})`;
|
||||
addRecipientOption(userId, label);
|
||||
appendMessage('', `[Network] ${label} verified with Perfect Forward Secrecy.`, true);
|
||||
triggerGoodFaviconPulse();
|
||||
updateActivePeers();
|
||||
|
||||
} else if (data.type === 'chat') {
|
||||
const identity = peerIdentities[userId];
|
||||
const decryptedMsg = decryptFromPeer(data.payload, userId);
|
||||
const shortId = identity.pubKey.substring(0, 8);
|
||||
const prefix = data.isPrivate ? '[DM] ' : '';
|
||||
appendMessage(`${identity.username} (@${shortId})`, prefix + decryptedMsg, false, data.isPrivate);
|
||||
triggerGoodFaviconPulse();
|
||||
|
||||
} else if (data.type === 'file-meta') {
|
||||
incomingFiles[data.fileId] = {
|
||||
name: data.fileName,
|
||||
size: data.fileSize,
|
||||
key: data.fileKey,
|
||||
nonce: data.fileNonce,
|
||||
chunks: [],
|
||||
receivedBytes: 0,
|
||||
sender: userId,
|
||||
isPrivate: data.isPrivate
|
||||
};
|
||||
} else if (data.type === 'file-chunk') {
|
||||
const fileMeta = incomingFiles[data.fileId];
|
||||
if (fileMeta) {
|
||||
fileMeta.chunks[data.chunkIndex] = window.sodium.from_hex(data.chunkData);
|
||||
fileMeta.receivedBytes += fileMeta.chunks[data.chunkIndex].length;
|
||||
if (fileMeta.receivedBytes >= fileMeta.size) {
|
||||
const fullEncrypted = new Uint8Array(fileMeta.size);
|
||||
let offset = 0;
|
||||
for (const chunk of fileMeta.chunks) {
|
||||
fullEncrypted.set(chunk, offset);
|
||||
offset += chunk.length;
|
||||
}
|
||||
try {
|
||||
const decryptedFileBytes = window.sodium.crypto_secretbox_open_easy(
|
||||
fullEncrypted,
|
||||
window.sodium.from_hex(fileMeta.nonce),
|
||||
window.sodium.from_hex(fileMeta.key)
|
||||
);
|
||||
const blob = new Blob([decryptedFileBytes]);
|
||||
const identity = peerIdentities[userId];
|
||||
const prefix = fileMeta.isPrivate ? '[DM File] ' : '[File] ';
|
||||
appendFileMessage(identity.username, prefix + fileMeta.name, blob, fileMeta.isPrivate);
|
||||
} catch (err) {
|
||||
appendMessage('', '[Security Alert] Failed to decrypt received file.', true);
|
||||
}
|
||||
delete incomingFiles[data.fileId];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
setFavicon('bad');
|
||||
appendMessage('', `[Security Alert] Protocol error or decryption failure`, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function initiateCall(userId) {
|
||||
const pc = createPeerConnection(userId, true);
|
||||
const dc = pc.createDataChannel("chat");
|
||||
setupDataChannelEvents(dc, userId);
|
||||
const offer = await pc.createOffer();
|
||||
await pc.setLocalDescription(offer);
|
||||
socket.emit('offer', { target: userId, offer });
|
||||
}
|
||||
|
||||
socket.on('connect', () => {
|
||||
socket.emit('join-room', currentRoom);
|
||||
updateActivePeers();
|
||||
});
|
||||
|
||||
socket.on('user-joined', (userId) => {
|
||||
triggerGoodFaviconPulse();
|
||||
initiateCall(userId);
|
||||
});
|
||||
|
||||
socket.on('offer', async ({ sender, offer }) => {
|
||||
const pc = createPeerConnection(sender, false);
|
||||
pc.ondatachannel = (event) => setupDataChannelEvents(event.channel, sender);
|
||||
await pc.setRemoteDescription(new RTCSessionDescription(offer));
|
||||
const answer = await pc.createAnswer();
|
||||
await pc.setLocalDescription(answer);
|
||||
socket.emit('answer', { target: sender, answer });
|
||||
});
|
||||
|
||||
socket.on('answer', async ({ sender, answer }) => {
|
||||
if (peerConnections[sender]) await peerConnections[sender].setRemoteDescription(new RTCSessionDescription(answer));
|
||||
});
|
||||
|
||||
socket.on('ice-candidate', async ({ sender, candidate }) => {
|
||||
if (peerConnections[sender]) await peerConnections[sender].addIceCandidate(new RTCIceCandidate(candidate));
|
||||
});
|
||||
|
||||
socket.on('user-disconnected', (userId) => {
|
||||
if (peerConnections[userId]) { peerConnections[userId].close(); delete peerConnections[userId]; }
|
||||
if (peerIdentities[userId]) {
|
||||
const ident = peerIdentities[userId];
|
||||
appendMessage('', `[Network] ${ident.username} disconnected.`, true);
|
||||
delete peerIdentities[userId];
|
||||
}
|
||||
delete dataChannels[userId];
|
||||
delete sessionKeys[userId];
|
||||
removeRecipientOption(userId);
|
||||
updateActivePeers();
|
||||
});
|
||||
|
||||
/* FILE TRANSFER HANDLING (UP TO 100MB) */
|
||||
async function handleFileUpload(event) {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
if (file.size > MAX_FILE_SIZE) {
|
||||
alert("File exceeds maximum size limit of 100MB.");
|
||||
event.target.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const targetUserId = recipientSelect.value;
|
||||
const isPrivate = targetUserId !== 'all';
|
||||
const fileId = window.sodium.to_hex(window.sodium.randombytes_buf(8));
|
||||
|
||||
const progressContainer = document.getElementById('file-progress-container');
|
||||
const progressBar = document.getElementById('file-progress');
|
||||
progressContainer.classList.remove('hidden');
|
||||
progressBar.value = 0;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (e) => {
|
||||
const fileBytes = new Uint8Array(e.target.result);
|
||||
const fileKey = window.sodium.randombytes_buf(window.sodium.crypto_secretbox_KEYBYTES);
|
||||
const fileNonce = window.sodium.randombytes_buf(window.sodium.crypto_secretbox_NONCEBYTES);
|
||||
|
||||
const encryptedFile = window.sodium.crypto_secretbox_easy(fileBytes, fileNonce, fileKey);
|
||||
|
||||
for (const userId in dataChannels) {
|
||||
if (isPrivate && userId !== targetUserId) continue;
|
||||
const dc = dataChannels[userId];
|
||||
if (dc.readyState === 'open') {
|
||||
dc.send(JSON.stringify({
|
||||
type: 'file-meta',
|
||||
fileId,
|
||||
fileName: file.name,
|
||||
fileSize: encryptedFile.length,
|
||||
fileKey: window.sodium.to_hex(fileKey),
|
||||
fileNonce: window.sodium.to_hex(fileNonce),
|
||||
isPrivate
|
||||
}));
|
||||
|
||||
let offset = 0;
|
||||
let chunkIndex = 0;
|
||||
while (offset < encryptedFile.length) {
|
||||
const chunk = encryptedFile.subarray(offset, offset + CHUNK_SIZE);
|
||||
dc.send(JSON.stringify({
|
||||
type: 'file-chunk',
|
||||
fileId,
|
||||
chunkIndex,
|
||||
chunkData: window.sodium.to_hex(chunk)
|
||||
}));
|
||||
offset += CHUNK_SIZE;
|
||||
chunkIndex++;
|
||||
progressBar.value = Math.round((offset / encryptedFile.length) * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
progressContainer.classList.add('hidden');
|
||||
appendFileMessage('You', (isPrivate ? '[DM File] ' : '[File] ') + file.name, new Blob([fileBytes]), isPrivate);
|
||||
event.target.value = '';
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
|
||||
/* MESSAGE SENDING WITH LENGTH GUARDRAILS */
|
||||
sendBtn.onclick = () => {
|
||||
const message = messageInput.value;
|
||||
if (!message) return;
|
||||
|
||||
if (message.length > MAX_MESSAGE_LENGTH) {
|
||||
alert(`Message exceeds maximum limit of ${MAX_MESSAGE_LENGTH} characters.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const targetUserId = recipientSelect.value;
|
||||
const isPrivate = targetUserId !== 'all';
|
||||
let sentToAnyone = false;
|
||||
|
||||
for (const userId in dataChannels) {
|
||||
if (isPrivate && userId !== targetUserId) continue;
|
||||
const dc = dataChannels[userId];
|
||||
const identity = peerIdentities[userId];
|
||||
|
||||
if (dc.readyState === 'open' && identity) {
|
||||
try {
|
||||
const encryptedPayload = encryptForPeer(message, userId);
|
||||
dc.send(JSON.stringify({ type: 'chat', isPrivate, payload: encryptedPayload }));
|
||||
sentToAnyone = true;
|
||||
} catch (err) {
|
||||
setFavicon('bad');
|
||||
console.error("Encryption failed for user", userId, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sentToAnyone) {
|
||||
appendMessage('You', isPrivate ? `[DM] ${message}` : message, false, isPrivate);
|
||||
messageInput.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
messageInput.onkeypress = (e) => { if (e.key === 'Enter') sendBtn.click(); };
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
!function(e){function r(e,r){"use strict";var t,a=r.ready.then(function(){function a(){if(t._sodium_init()<0)throw new Error("libsodium was not correctly initialized.");for(var r=["crypto_aead_aegis128l_decrypt","crypto_aead_aegis128l_decrypt_detached","crypto_aead_aegis128l_encrypt","crypto_aead_aegis128l_encrypt_detached","crypto_aead_aegis128l_keygen","crypto_aead_aegis256_decrypt","crypto_aead_aegis256_decrypt_detached","crypto_aead_aegis256_encrypt","crypto_aead_aegis256_encrypt_detached","crypto_aead_aegis256_keygen","crypto_aead_chacha20poly1305_decrypt","crypto_aead_chacha20poly1305_decrypt_detached","crypto_aead_chacha20poly1305_encrypt","crypto_aead_chacha20poly1305_encrypt_detached","crypto_aead_chacha20poly1305_ietf_decrypt","crypto_aead_chacha20poly1305_ietf_decrypt_detached","crypto_aead_chacha20poly1305_ietf_encrypt","crypto_aead_chacha20poly1305_ietf_encrypt_detached","crypto_aead_chacha20poly1305_ietf_keygen","crypto_aead_chacha20poly1305_keygen","crypto_aead_xchacha20poly1305_ietf_decrypt","crypto_aead_xchacha20poly1305_ietf_decrypt_detached","crypto_aead_xchacha20poly1305_ietf_encrypt","crypto_aead_xchacha20poly1305_ietf_encrypt_detached","crypto_aead_xchacha20poly1305_ietf_keygen","crypto_auth","crypto_auth_hmacsha256","crypto_auth_hmacsha256_final","crypto_auth_hmacsha256_init","crypto_auth_hmacsha256_keygen","crypto_auth_hmacsha256_update","crypto_auth_hmacsha256_verify","crypto_auth_hmacsha512","crypto_auth_hmacsha512256","crypto_auth_hmacsha512256_final","crypto_auth_hmacsha512256_init","crypto_auth_hmacsha512256_keygen","crypto_auth_hmacsha512256_update","crypto_auth_hmacsha512256_verify","crypto_auth_hmacsha512_final","crypto_auth_hmacsha512_init","crypto_auth_hmacsha512_keygen","crypto_auth_hmacsha512_update","crypto_auth_hmacsha512_verify","crypto_auth_keygen","crypto_auth_verify","crypto_box_beforenm","crypto_box_curve25519xchacha20poly1305_beforenm","crypto_box_curve25519xchacha20poly1305_detached","crypto_box_curve25519xchacha20poly1305_detached_afternm","crypto_box_curve25519xchacha20poly1305_easy","crypto_box_curve25519xchacha20poly1305_easy_afternm","crypto_box_curve25519xchacha20poly1305_keypair","crypto_box_curve25519xchacha20poly1305_open_detached","crypto_box_curve25519xchacha20poly1305_open_detached_afternm","crypto_box_curve25519xchacha20poly1305_open_easy","crypto_box_curve25519xchacha20poly1305_open_easy_afternm","crypto_box_curve25519xchacha20poly1305_seal","crypto_box_curve25519xchacha20poly1305_seal_open","crypto_box_curve25519xchacha20poly1305_seed_keypair","crypto_box_detached","crypto_box_easy","crypto_box_easy_afternm","crypto_box_keypair","crypto_box_open_detached","crypto_box_open_easy","crypto_box_open_easy_afternm","crypto_box_seal","crypto_box_seal_open","crypto_box_seed_keypair","crypto_core_ed25519_add","crypto_core_ed25519_from_hash","crypto_core_ed25519_from_uniform","crypto_core_ed25519_is_valid_point","crypto_core_ed25519_random","crypto_core_ed25519_scalar_add","crypto_core_ed25519_scalar_complement","crypto_core_ed25519_scalar_invert","crypto_core_ed25519_scalar_mul","crypto_core_ed25519_scalar_negate","crypto_core_ed25519_scalar_random","crypto_core_ed25519_scalar_reduce","crypto_core_ed25519_scalar_sub","crypto_core_ed25519_sub","crypto_core_hchacha20","crypto_core_hsalsa20","crypto_core_ristretto255_add","crypto_core_ristretto255_from_hash","crypto_core_ristretto255_is_valid_point","crypto_core_ristretto255_random","crypto_core_ristretto255_scalar_add","crypto_core_ristretto255_scalar_complement","crypto_core_ristretto255_scalar_invert","crypto_core_ristretto255_scalar_mul","crypto_core_ristretto255_scalar_negate","crypto_core_ristretto255_scalar_random","crypto_core_ristretto255_scalar_reduce","crypto_core_ristretto255_scalar_sub","crypto_core_ristretto255_sub","crypto_generichash","crypto_generichash_blake2b_salt_personal","crypto_generichash_final","crypto_generichash_init","crypto_generichash_keygen","crypto_generichash_update","crypto_hash","crypto_hash_sha256","crypto_hash_sha256_final","crypto_hash_sha256_init","crypto_hash_sha256_update","crypto_hash_sha3256","crypto_hash_sha3256_final","crypto_hash_sha3256_init","crypto_hash_sha3256_update","crypto_hash_sha3512","crypto_hash_sha3512_final","crypto_hash_sha3512_init","crypto_hash_sha3512_update","crypto_hash_sha512","crypto_hash_sha512_final","crypto_hash_sha512_init","crypto_hash_sha512_update","crypto_ipcrypt_decrypt","crypto_ipcrypt_encrypt","crypto_ipcrypt_keygen","crypto_ipcrypt_nd_decrypt","crypto_ipcrypt_nd_encrypt","crypto_ipcrypt_nd_keygen","crypto_ipcrypt_ndx_decrypt","crypto_ipcrypt_ndx_encrypt","crypto_ipcrypt_ndx_keygen","crypto_ipcrypt_pfx_decrypt","crypto_ipcrypt_pfx_encrypt","crypto_ipcrypt_pfx_keygen","crypto_kdf_derive_from_key","crypto_kdf_keygen","crypto_kem_dec","crypto_kem_enc","crypto_kem_keypair","crypto_kem_mlkem768_dec","crypto_kem_mlkem768_enc","crypto_kem_mlkem768_enc_deterministic","crypto_kem_mlkem768_keypair","crypto_kem_mlkem768_seed_keypair","crypto_keLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
!function(A){function I(A){"use strict";var I;void 0===(I=A)&&(I={});var g=I;"object"!=typeof g.sodium&&("object"==typeof global?g=global:"object"==typeof window&&(g=window));var C=I;return I.ready=new Promise((function(A,I){(i=C).onAbort=I,i.print=function(A){},i.printErr=function(A){},i.onRuntimeInitialized=function(){try{i._crypto_secretbox_keybytes(),A()}catch(A){I(A)}},i.useBackupModule=function(){return new Promise((function(A,I){(i={}).onAbort=I,i.onRuntimeInitialized=function(){Object.keys(C).forEach((function(A){"getRandomValue"!==A&&delete C[A]})),Object.keys(i).forEach((function(A){C[A]=i[A]})),A()};var g,B,Q,i=void 0!==i?i:{},E=Object.assign({},i),o="object"==typeof window,a="function"==typeof importScripts,n="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,r="";if(n){var f=require("fs"),t=require("path");r=a?t.dirname(r)+"/":__dirname+"/",g=(A,I)=>{var g=T(A);return g?I?g:g.toString():(A=x(A)?new URL(A):t.normalize(A),f.readFileSync(A,I?void 0:"utf8"))},Q=A=>{var I=g(A,!0);return I.buffer||(I=new Uint8Array(I)),I},B=(A,I,g)=>{var C=T(A);C&&I(C),A=x(A)?new URL(A):t.normalize(A),f.readFile(A,(function(A,C){A?g(A):I(C.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),"undefined"!=typeof module&&(module.exports=i),i.inspect=function(){return"[Emscripten Module object]"}}else(o||a)&&(a?r=self.location.href:"undefined"!=typeof document&&document.currentScript&&(r=document.currentScript.src),r=0!==r.indexOf("blob:")?r.substr(0,r.replace(/[?#].*/,"").lastIndexOf("/")+1):"",g=A=>{try{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.send(null),I.responseText}catch(I){var g=T(A);if(g)return function(A){for(var I=[],g=0;g<A.length;g++){var C=A[g];C>255&&(C&=255),I.push(String.fromCharCode(C))}return I.join("")}(g);throw I}},a&&(Q=A=>{try{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.responseType="arraybuffer",I.send(null),new Uint8Array(I.response)}catch(I){var g=T(A);if(g)return g;throw I}}),B=(A,I,g)=>{var C=new XMLHttpRequest;C.open("GET",A,!0),C.responseType="arraybuffer",C.onload=()=>{if(200==C.status||0==C.status&&C.response)I(C.response);else{var B=T(A);B?I(B.buffer):g()}},C.onerror=g,C.send(null)});i.print;var e,c=i.printErr||void 0;Object.assign(i,E),E=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(e=i.wasmBinary),i.noExitRuntime;var y,D={Memory:function(A){this.buffer=new ArrayBuffer(65536*A.initial)},Module:function(A){},Instance:function(A,I){this.exports=function(A){for(var I,g=new Uint8Array(123),C=25;C>=0;--C)g[48+C]=52+C,g[65+C]=C,g[97+C]=26+C;function B(A,I,C){for(var B,Q,i=0,E=I,o=C.length,a=I+(3*o>>2)-("="==C[o-2])-("="==C[o-1]);i<o;i+=4)B=g[C.charCodeAt(i+1)],Q=g[C.charCodeAt(i+2)],A[E++]=g[C.charCodeAt(i)]<<2|B>>4,E<a&&(A[E++]=B<<4|Q>>2),E<a&&(A[E++]=Q<<6|g[C.charCodeAt(i+3)])}function Q(){throw new Error("abort")}return g[43]=62,g[47]=63,function(A){var g=A.a,C=g.a,i=C.buffer;C.grow=function(A){A|=0;var g=0|rI(),B=g+A|0;if(g<B&&B<65536){var Q=new ArrayBuffer(r(B,65536));new Int8Array(Q).set(E),E=new Int8Array(Q),new Int16Array(Q),o=new Int32Array(Q),a=new Uint8Array(Q),new Uint16Array(Q),n=new Uint32Array(Q),new Float32Array(Q),new Float64Array(Q),i=Q,C.buffer=i,I=a}return g};var E=new Int8Array(i),o=(new Int16Array(i),new Int32Array(i)),a=new Uint8Array(i),n=(new Uint16Array(i),new Uint32Array(i)),r=(new Float32Array(i),new Float64Array(i),Math.imul),f=(Math.fround,Math.abs,Math.clz32),t=(Math.min,Math.max,Math.floor,Math.ceil,Math.trunc,Math.sqrt,g.b),e=g.c,c=g.d,y=g.e,D=101744,w=0;function h(A,I){var g,C,B,Q,i,o=0,n=0,r=0,f=0,t=0,e=0,c=0,y=0,D=0,h=0,s=0,p=0,u=0,k=0,F=0,l=0,S=0,H=0,M=0,G=0,U=0,J=0,N=0,Y=0,b=0,_=0,K=0,P=0,v=0,m=0,d=0,L=0,R=0,x=0,j=0,X=0,q=0,z=0,V=0,O=0,T=0,W=0,Z=0,$=0,AA=0,IA=0,gA=0,CA=0,BA=0,QA=0,iA=0,EA=0,oA=0,aA=0,rA=0,fA=0,tA=0,eA=0,cA=0,yA=0,DA=0,wA=0,hA=0,sA=0,pA=0,uA=0,kA=0,FA=0,lA=0,SA=0,HA=0,MA=0,GA=0,UA=0;eA=a[I+40|0]|a[I+41|0]<<8|a[I+42|0]<<16|a[I+43|0]<<24,yA=o=a[I+44|0]|a[I+45|0]<<8|a[I+46|0]<<16|a[I+47|0]<<24,gA=a[I+104|0]|a[I+105|0]<<8|a[I+106|0]<<16|a[I+107|0]<<24,DA=o=a[I+108|0]|a[I+109|0]<<8|a[I+110|0]<<16|a[I+111|0]<<24,o=a[I+68|0]|a[I+69|0]<<8|a[I+70|0]<<16|a[I+71|0]<<24,q=a[I+64|0]|a[I+65|0]<<8|a[I+66|0]<<16|a[I+67|0]<<24,BA=o,HA=o=a[I+36|0]|a[I+37|0]<<8|a[I+38|0]<<16|a[I+39|0]<<24,S=o,oA=a[I+120|0]|a[I+121|0]<<8|a[I+122|0]<<16|a[I+123|0]<<24,pA=o=a[I+124|0]|a[I+125|0]<<8|a[I+126|0]<<16|a[I+127|0]<<24,B=o=a[I+92|0]|a[I+93|0]<<8|a[I+94|0]<<16|a[I+95|0]<<24,g=a[I+88|0]|a[I+89|0]<<8|a[I+90|0]<<16|a[I+91|0]<<24,X=o,EA=a[I+80|0]|a[I+81|0]<<8|a[I+82|0]<<16|a[I+83|0]<<24,hA=o=a[I+84|0]|a[I+85|0]<<8|a[I+86|0]<<16|a[I+87|0]<<24,z=o,QA=a[A+16|0]|a[A+17|0]<<8|a[A+18|0]<<16|a[A+19|0]<<24,o=(rA=a[A+52|0]|a[A+53|0]<<8|a[A+54|0]<<16|a[A+55|0]<<24)+S|0,x=(aA=a[A+48|0]|a[A+49|0]<<8|a[A+50|0]<<16|a[A+51|0]<<24)+(fA=a[I+32|0]|a[I+33|0]<<8|a[I+34|0]<<16|a[I+35|0]<<24)|0,o=(a[A+20|0]|a[A+21|0]<<8|a[A+22|0]<<16|a[A+23|0]<<2Line truncated
|
||||
Reference in new issue
Block a user