import * as Cryptr from 'cryptr'; import { paths } from './paths'; import { publicKey } from './keys'; import { readFileSync } from 'fs'; import {Config} from '@radic/util' // crypted DB const cryptr = new Cryptr(publicKey) const db: LowDB = require('lowdb')(paths.userDatabase, { format : { deserialize : ( str ) => { const decrypted = cryptr.decrypt(str) const obj = JSON.parse(decrypted) return obj }, serialize : ( obj ) => { const str = JSON.stringify(obj) const encrypted = cryptr.encrypt(str) return encrypted } } }); db.defaults({ auths : [] }).value(); function rawDB() { let str = readFileSync(paths.userDatabase); const decrypted = cryptr.decrypt(str) const obj = JSON.parse(decrypted) return obj } export class DB { static get(name){ } static has(name){ } static raw(){ } static asConfig(){ new Config(); } } export { db, rawDB };