added decoder

This commit is contained in:
Boki 2026-03-29 22:22:12 -04:00
parent 104bebb783
commit 748cce0eeb
4 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import { inflate } from 'pako';
/**
* Decodes TE obfuscated data: base64 decode -> XOR with key -> inflate -> JSON parse
*/
export function decodeTEData<T = unknown>(b64Data: string, key: string): T | null {
try {
const raw = Array.from(atob(b64Data), (c) => c.charCodeAt(0));
const keyBytes = Array.from(new TextEncoder().encode(key));
const keyLen = keyBytes.length;
const xored = new Uint8Array(raw.map((byte, i) => byte ^ (keyBytes[i % keyLen] ?? 0)));
return JSON.parse(inflate(xored, { to: 'string' }));
} catch {
return null;
}
}

View file

@ -1,2 +1,3 @@
export * from './config';
export * from './decode';
export * from './types';