8000 GitHub - hazae41/kdbx: Rust-like KeePass (KDBX 4) file format for TypeScript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hazae41/kdbx

Repository files navigation

KDBX

Rust-like KeePass (KDBX 4) file format for TypeScript

npm i @hazae41/kdbx

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies
  • Rust-like patterns
  • Easy read/modify/write
  • Uses WebCrypto and WebAssembly

Usage

import { Readable, Writable } from "@hazae41/binary"
import { CompositeKey, Database, PasswordKey } from "@hazae41/kdbx"
import { readFileSync, writeFileSync } from "node:fs"

const password = await CompositeKey.digestOrThrow(await PasswordKey.digestOrThrow(new TextEncoder().encode("test")))

const encrypted = Readable.readFromBytesOrThrow(Database.Encrypted, readFileSync("./local/input.kdbx")).cloneOrThrow()
const decrypted = await encrypted.decryptOrThrow(password)

const file = decrypted.inner.content.value
const root = file.getRootOrThrow()
const meta = file.getMetaOrThrow()

const group0 = root.getDirectGroupByIndexOrThrow(0)
const subgroup0 = group0.getDirectGroupByIndexOrThrow(0)
const entry0 = subgroup0.getDirectEntryByIndexOrThrow(0)

entry0.cloneToHistoryOrThrow()

entry0.getDirectStringByKeyOrThrow("Title").getValueOrThrow().set("Example")

entry0.getTimesOrThrow().getLastModificationTimeOrThrow().setOrThrow(new Date())
entry0.getTimesOrThrow().getLastAccessTimeOrThrow().setOrThrow(new Date())
entry0.getTimesOrThrow().getUsageCountOrThrow().incrementOrThrow()

const decrypted2 = await decrypted.rotateOrThrow(password)
const encrypted2 = await decrypted2.encryptOrThrow()

writeFileSync("./local/output.kdbx", Writable.writeToBytesOrThrow(encrypted2))

About

Rust-like KeePass (KDBX 4) file format for TypeScript

Resources

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published
0