mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-06-04 13:28:13 +02:00
668ce16dc7
Gate messages now propagate via the Infonet hashchain as encrypted blobs — every node syncs them through normal chain sync while only Gate members with MLS keys can decrypt. Added mesh reputation system, peer push workers, voluntary Wormhole opt-in for node participation, fork recovery, killwormhole scripts, obfuscated terminology, and hardened the self-updater to protect encryption keys and chain state during updates. New features: Shodan search, train tracking, Sentinel Hub imagery, 8 new intelligence layers, CCTV expansion to 11,000+ cameras across 6 countries, Mesh Terminal CLI, prediction markets, desktop-shell scaffold, and comprehensive mesh test suite (215 frontend + backend tests passing). Community contributors: @wa1id, @AlborzNazari, @adust09, @Xpirix, @imqdcr, @csysp, @suranyami, @chr0n1x, @johan-martensson, @singularfailure, @smithbh, @OrfeoTerkuci, @deuza, @tm-const, @Elhard1, @ttulttul
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
const DB_NAME = 'sb_mesh_keystore';
|
|
const DB_VERSION = 1;
|
|
const STORE_KEYS = 'keys';
|
|
|
|
function openDb(): Promise<IDBDatabase> {
|
|
return new Promise((resolve, reject) => {
|
|
const req = indexedDB.open(DB_NAME, DB_VERSION);
|
|
req.onupgradeneeded = () => {
|
|
const db = req.result;
|
|
if (!db.objectStoreNames.contains(STORE_KEYS)) {
|
|
db.createObjectStore(STORE_KEYS);
|
|
}
|
|
};
|
|
req.onsuccess = () => resolve(req.result);
|
|
req.onerror = () => reject(req.error);
|
|
});
|
|
}
|
|
|
|
async function withStore<T>(
|
|
mode: IDBTransactionMode,
|
|
handler: (store: IDBObjectStore) => IDBRequest,
|
|
): Promise<T> {
|
|
const db = await openDb();
|
|
return new Promise((resolve, reject) => {
|
|
const tx = db.transaction(STORE_KEYS, mode);
|
|
const store = tx.objectStore(STORE_KEYS);
|
|
const req = handler(store);
|
|
req.onsuccess = () => resolve(req.result as T);
|
|
req.onerror = () => reject(req.error);
|
|
tx.oncomplete = () => db.close();
|
|
tx.onerror = () => {
|
|
db.close();
|
|
reject(tx.error);
|
|
};
|
|
});
|
|
}
|
|
|
|
export async function setKey(id: string, key: CryptoKey): Promise<void> {
|
|
await withStore<void>('readwrite', (store) => store.put(key, id));
|
|
}
|
|
|
|
export async function getKey(id: string): Promise<CryptoKey | null> {
|
|
try {
|
|
const result = await withStore<CryptoKey | undefined>('readonly', (store) => store.get(id));
|
|
return result || null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export async function deleteKey(id: string): Promise<void> {
|
|
try {
|
|
await withStore<void>('readwrite', (store) => store.delete(id));
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
}
|