46 lines
1.3 KiB
JavaScript
Executable File
46 lines
1.3 KiB
JavaScript
Executable File
#!/usr/bin/env -S 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-2013-12-04.opvault"
|
|
|
|
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 [attachment] = item.attachments
|
|
// console.log({ details: item.itemDetails, overview: item.overview })
|
|
// console.log(attachment.metadata)
|
|
|
|
const op = vault.getItem(vault.overviews.get("1Password")!.uuid)!
|
|
console.log(op.itemDetails.sections[0])
|
|
|
|
// console.log(vault.overviews.values())
|
|
}
|
|
|
|
main(process.argv.slice(2))
|