49 lines
1.2 KiB
JavaScript
Executable File
49 lines
1.2 KiB
JavaScript
Executable File
#!/usr/bin/env node -r ts-node/register/transpile-only
|
|
import fs from "fs"
|
|
import chalk from "chalk"
|
|
import prompts from "prompts"
|
|
import { OnePassword } from "./src/index"
|
|
|
|
const path = "./freddy"
|
|
|
|
async function main(args: string[]) {
|
|
const instance = new OnePassword({ path })
|
|
const profiles = await instance.getProfileNames()
|
|
|
|
// const { profile } = await prompts({
|
|
// type: "select",
|
|
// name: "profile",
|
|
// choices: profiles.map(t => ({ title: t, value: t })),
|
|
// message: "Which vault?",
|
|
// })
|
|
|
|
// console.log(chalk`You have chosen {green ${profile}}.`)
|
|
const profile = "default"
|
|
|
|
const vault = await instance.getProfile(profile)
|
|
// const { password } = await prompts({
|
|
// type: "invisible",
|
|
// name: "password",
|
|
// message: "Master Password?",
|
|
// })
|
|
const password = "freddy"
|
|
|
|
vault.unlock(password)
|
|
|
|
const find = vault.overviews.get("A note with some attachments")!
|
|
const item = vault.getItem(find.uuid!)
|
|
|
|
const d = vault.decryptAttachment(
|
|
item!.original,
|
|
fs.readFileSync(
|
|
"./freddy/default/F2DB5DA3FCA64372A751E0E85C67A538_AFBDA49A5F684179A78161E40CA2AAD3.attachment"
|
|
)
|
|
)
|
|
|
|
fs.writeFileSync("./test2.png", d.file)
|
|
|
|
// console.log(vault.overviews.values())
|
|
}
|
|
|
|
main(process.argv.slice(2))
|