Skip to content

Commit

Permalink
docs(readme): update
Browse files Browse the repository at this point in the history
  • Loading branch information
Aetherinox committed Dec 23, 2024
1 parent 5d049f4 commit 3f79789
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 2 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2021 Antelle
Copyright (C) 2021-2025 Antelle

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,55 @@

KdbxWeb is a high-performance javascript library for reading/writing KeePass v2 databases (kdbx) in node.js or browser.

<br />

---

<br />

- [KdbxWeb ](#kdbxweb--)
- [Features](#features)
- [Browser support](#browser-support)
- [Compatibility](#compatibility)
- [Kdbx4](#kdbx4)
- [Usage](#usage)
- [Loading](#loading)
- [Saving](#saving)
- [File info](#file-info)
- [Changing credentials](#changing-credentials)
- [Creation](#creation)
- [Maintenance](#maintenance)
- [Merge](#merge)
- [Groups](#groups)
- [Group creation](#group-creation)
- [Group deletion](#group-deletion)
- [Group move](#group-move)
- [Recycle Bin](#recycle-bin)
- [Recursive traverse](#recursive-traverse)
- [Entries](#entries)
- [Entry creation](#entry-creation)
- [Entry modification](#entry-modification)
- [Entry deletion](#entry-deletion)
- [Entry move](#entry-move)
- [ProtectedValue](#protectedvalue)
- [Errors](#errors)
- [Consts](#consts)
- [Random](#random)
- [ByteUtils](#byteutils)
- [Building](#building)
- [3rd party libs](#3rd-party-libs)
- [Tools](#tools)
- [See it in action](#see-it-in-action)
- [Extras](#extras)
- [License](#license)


<br />

---

<br />

## Features

- runs in browser or node.js
Expand All @@ -14,15 +63,33 @@ KdbxWeb is a high-performance javascript library for reading/writing KeePass v2
- high code coverage
- strict TypeScript

<br />

---

<br />

## Browser support

- modern browsers: Chrome, Firefox, Safari, Opera, Edge
- node.js

<br />

---

<br />

## Compatibility

Supported formats are Kdbx3 and Kdbx4, current KeePass file format. Old kdb files (for KeePass v1) are out of scope of this library.

<br />

---

<br />

## Kdbx4

Kdbx4 has introduced Argon2, a new hashing function. Due to complex calculations, you have to implement it manually and export to kdbxweb, if you want to support such files. Here's how:
Expand All @@ -40,6 +107,12 @@ You can find an implementation example in [tests](https://github.com/keeweb/kdbx

It's not compiled into the library because there's no universal way to provide a fast implementation, so it's up to you, to choose the best one.

<br />

---

<br />

## Usage

##### Loading
Expand All @@ -63,6 +136,8 @@ You can also pretty-print XML:
const prettyPrintedXml = await db.saveXml(true);
```

<br />

##### File info
```ts
db.header
Expand All @@ -88,6 +163,8 @@ let group = newDb.createGroup(newDb.getDefaultGroup(), 'subgroup');
let entry = newDb.createEntry(group);
```

<br />

##### Maintenance

```ts
Expand All @@ -107,6 +184,8 @@ db.setVersion(3);
db.setKdf(kdbxweb.Consts.KdfId.Aes);
```

<br />

##### Merge

Entries, groups and meta are consistent against merging in any direction with any state.
Expand All @@ -133,30 +212,40 @@ if (pushedOk) {
}
```

<br />

##### Groups
```ts
let defaultGroup = db.getDefaultGroup();
let anotherGroup = db.getGroup(uuid);
let deepGroup = defaultGroup.groups[1].groups[2];
```

<br />

##### Group creation
```ts
let group = db.createGroup(db.getDefaultGroup(), 'New group');
let anotherGroup = db.createGroup(group, 'Subgroup');
```

<br />

##### Group deletion
```ts
db.remove(group);
```

<br />

##### Group move
```ts
db.move(group, toGroup);
db.move(group, toGroup, atIndex);
```

<br />

##### Recycle Bin
```ts
let recycleBin = db.getGroup(db.meta.recycleBinUuid);
Expand All @@ -165,25 +254,33 @@ if (!recycleBin) {
}
```

<br />

##### Recursive traverse
```ts
for (const entry of group.allEntries()) { /* ... */ }
for (const group of group.allGroups()) { /* ... */ }
for (const entryOrGroup of group.allGroupsAndEntries()) { /* ... */ }
```

<br />

##### Entries
```ts
let entry = db.getDefaultGroup().entries[0];
entry.fields.AccountNumber = '1234 5678';
entry.fields.Pin = kdbxweb.ProtectedValue.fromString('4321');
```

<br />

##### Entry creation
```ts
let entry = db.createEntry(group);
```

<br />

##### Entry modification
```ts
// push current state to history stack
Expand All @@ -197,11 +294,15 @@ entry.removeHistory(index, count);
```
Important: don't modify history states directly, this will break merge.

<br />

##### Entry deletion
```ts
db.remove(entry);
```

<br />

##### Entry move
```ts
db.move(entry, toGroup);
Expand All @@ -212,6 +313,8 @@ If you're moving an entry from another file, this is called _import_:
db.importEntry(entry, toGroup, sourceFile);
```

<br />

##### ProtectedValue
Used for passwords and custom fields, stored the value in memory XOR'ed
```ts
Expand All @@ -234,6 +337,8 @@ try {
}
```

<br />

##### Consts
[Consts definition](https://github.com/keeweb/kdbxweb/blob/master/lib/defs/consts.ts)
```ts
Expand All @@ -242,11 +347,15 @@ kdbxweb.Consts.Defaults // default db settings
kdbxweb.Consts.Icons // icons map
```

<br />

##### Random
```ts
let randomArray = kdbxweb.Crypto.random(/* desired length */ 100);
```

<br />

##### ByteUtils
```ts
kdbxweb.ByteUtils.bytesToString(bytes);
Expand All @@ -257,6 +366,12 @@ kdbxweb.ByteUtils.bytesToHex(bytes);
kdbxweb.ByteUtils.hexToBytes(str);
```

<br />

---

<br />

## Building

Use npm to build this project:
Expand All @@ -269,12 +384,24 @@ To run tests:
npm test
```

<br />

---

<br />

## 3rd party libs

kdbxweb includes these 3rd party libraries:
- [fflate](https://github.com/101arrowz/fflate)
- [xmldom](https://github.com/xmldom/xmldom)

<br />

---

<br />

## Tools

The library provides a number of scripts to work with KDBX files:
Expand All @@ -284,31 +411,55 @@ Dump the binary header:
npm run script:dump-header my-db.kdbx
```

<br />

Print detailed size information about internal objects:
```sh
npm run script:kdbx-size-profiler my-db.kdbx password
```

<br />

Dump the internal XML:
```sh
npm run script:kdbx-to-xml my-db.kdbx password
```

<br />

Generate big files for load testing:
```sh
npm run script:make-big-files
```

<br />

---

<br />

## See it in action

This library is used in [KeeWeb](https://app.keeweb.info)

<br />

---

<br />

## Extras

We also provide a template for [HexFiend](https://github.com/ridiculousfish/HexFiend)
to explore the contents of KDBX files, you can find it
[here](format).

<br />

---

<br />

## License

MIT

0 comments on commit 3f79789

Please sign in to comment.