Upload index.html
Browse files- static/index.html +15 -9
static/index.html
CHANGED
|
@@ -1325,20 +1325,23 @@ const el = (tag, attrs={}, ...children) => {
|
|
| 1325 |
|
| 1326 |
// βββ Encryption helpers (Web Crypto API) ββββββββββββββββββββββββββ
|
| 1327 |
const Crypto = {
|
|
|
|
| 1328 |
async getKey() {
|
| 1329 |
-
const raw = 'agentscope-key-
|
| 1330 |
const enc = new TextEncoder().encode(raw);
|
| 1331 |
const hash = await crypto.subtle.digest('SHA-256', enc);
|
| 1332 |
return crypto.subtle.importKey('raw', hash, {name:'AES-GCM'}, false, ['encrypt','decrypt']);
|
| 1333 |
},
|
| 1334 |
async encrypt(text) {
|
| 1335 |
-
|
| 1336 |
-
|
| 1337 |
-
|
| 1338 |
-
|
| 1339 |
-
|
| 1340 |
-
|
| 1341 |
-
|
|
|
|
|
|
|
| 1342 |
},
|
| 1343 |
async decrypt(b64) {
|
| 1344 |
try {
|
|
@@ -1347,7 +1350,10 @@ const Crypto = {
|
|
| 1347 |
const iv = buf.slice(0,12), ct = buf.slice(12);
|
| 1348 |
const dec = await crypto.subtle.decrypt({name:'AES-GCM',iv}, key, ct);
|
| 1349 |
return new TextDecoder().decode(dec);
|
| 1350 |
-
} catch {
|
|
|
|
|
|
|
|
|
|
| 1351 |
}
|
| 1352 |
};
|
| 1353 |
|
|
|
|
| 1325 |
|
| 1326 |
// βββ Encryption helpers (Web Crypto API) ββββββββββββββββββββββββββ
|
| 1327 |
const Crypto = {
|
| 1328 |
+
// Koristimo fiksni kljuΔ β userAgent mijenja pri update-u i gubi kljuΔeve
|
| 1329 |
async getKey() {
|
| 1330 |
+
const raw = 'agentscope-static-key-v2';
|
| 1331 |
const enc = new TextEncoder().encode(raw);
|
| 1332 |
const hash = await crypto.subtle.digest('SHA-256', enc);
|
| 1333 |
return crypto.subtle.importKey('raw', hash, {name:'AES-GCM'}, false, ['encrypt','decrypt']);
|
| 1334 |
},
|
| 1335 |
async encrypt(text) {
|
| 1336 |
+
try {
|
| 1337 |
+
const key = await this.getKey();
|
| 1338 |
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
| 1339 |
+
const enc = new TextEncoder().encode(text);
|
| 1340 |
+
const ct = await crypto.subtle.encrypt({name:'AES-GCM',iv}, key, enc);
|
| 1341 |
+
const buf = new Uint8Array(iv.length + ct.byteLength);
|
| 1342 |
+
buf.set(iv); buf.set(new Uint8Array(ct), iv.length);
|
| 1343 |
+
return btoa(String.fromCharCode(...buf));
|
| 1344 |
+
} catch { return btoa(text); }
|
| 1345 |
},
|
| 1346 |
async decrypt(b64) {
|
| 1347 |
try {
|
|
|
|
| 1350 |
const iv = buf.slice(0,12), ct = buf.slice(12);
|
| 1351 |
const dec = await crypto.subtle.decrypt({name:'AES-GCM',iv}, key, ct);
|
| 1352 |
return new TextDecoder().decode(dec);
|
| 1353 |
+
} catch {
|
| 1354 |
+
// Fallback: pokuΕ‘aj starih userAgent-enkriptovanih kljuΔeva ili plain base64
|
| 1355 |
+
try { return atob(b64); } catch { return ''; }
|
| 1356 |
+
}
|
| 1357 |
}
|
| 1358 |
};
|
| 1359 |
|