-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathingest-texts-db.js
More file actions
28 lines (21 loc) · 893 Bytes
/
ingest-texts-db.js
File metadata and controls
28 lines (21 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const os = require('os')
const path = require('path')
const keytar = require('/Applications/Texts.app/Contents/Resources/app/node_modules/keytar')
const bs = require('/Applications/Texts.app/Contents/Resources/app/node_modules/better-sqlite3') // https://github.com/signalapp/better-sqlite3
let db
async function getUnlockedDb() {
if (db) return db
const key = await keytar.getPassword('com.kishanbagaria.jack', 'etilqs_key')
const keyBuffer = Buffer.from(key, 'base64')
const keyHex = keyBuffer.toString('hex')
db = bs(path.join(os.homedir(), 'Library/Application Support/jack/.index.db'))
const pragmaKeySql = `PRAGMA key = "x'${keyHex}'";`
db.exec(pragmaKeySql)
return db
}
async function findMessagesCount() {
const db = await getUnlockedDb()
const count = db.prepare('select count(*) from messages').pluck().get()
console.log({ count })
}
findMessagesCount()