<commit_before># KeePassHttp Client

is a Node.js module for interaction with [KeePassHTTP](https://github.com/pfn/keepasshttp).

## Notes

- Code is written in TypeScript.
- Supported request types: `test-associate`, `associate`, `get-logins`, `get-logins-count`, `set-login`. Respective methods return ES2015 Promises.

## Code Example

Examples are in TypeScript syntax. For the JavaScript just use `require`-like dependencies importing.

Associating with KeePassHTTP, caching received `id` and `key` values and then passwords requesting:
```typescript
    import * as nconf from "nconf";
    import {KeePassHttpClient} from "keepasshttp-client";
    
    nconf.file(".keepasshttp-creds");
    
    const client = new KeePassHttpClient();
    
    client
        .associate()
        .then(() => {
            // cache key/id for future use
            nconf.set("id", client.id);
            nconf.set("key", client.key);
            nconf.save(() => {
                // at this stage key and id are initialized, so we can initiate "get-logins" request
                client.getLogins({url: "https://domain.com"})
                    .then((response) => {
                        console.log(JSON.stringify(response, null, 4));
                    });
            });
        });
```

Requesting passwords using previously cached `id` and `key` values:
```typescript
    import * as nconf from "nconf";
    import {KeePassHttpClient} from "keepasshttp-client";
    
    nconf.file(".keepasshttp-creds");
    
    const client = new KeePassHttpClient({
        // url: "http://localhost:19555",
        keyId: {
            id: nconf.get("id"),
            key: nconf.get("key"),
        },
    });
    
    client
        .getLogins({url: "https://domain.com"})<commit_msg>adjust readme<commit_after># KeePassHttp Client

is a Node.js module for interaction with [KeePassHTTP](https://github.com/pfn/keepasshttp).

## Notes

- Code is written in TypeScript.
- Supported request types: `test-associate`, `associate`, `get-logins`, `get-logins-count`, `set-login`. Respective methods return ES2015 Promises.

## Code Example

Associating with KeePassHTTP, caching received `id` and `key` values and then passwords requesting:
```typescript
    import * as nconf from "nconf";
    import {KeePassHttpClient} from "keepasshttp-client";
    
    // we will be using "nconf" as a cache store, but you can use any store for this purpose
    nconf.file(".keepasshttp-creds");
    
    const client = new KeePassHttpClient();
    
    client
        .associate()
        .then(() => {
            // at this stage (after successful associating) key and id are setup as a members of the client instance
            // so now we are ready to initiate the "get-logins" request
            // but let's first cache initialized key/id for future use
            nconf.set("id", client.id);
            nconf.set("key", client.key);
            nconf.save(() => {
                client.getLogins({url: "https://domain.com"})
                    .then((response) => {
                        console.log(JSON.stringify(response, null, 4));
                    });
            });
        });
```

Requesting passwords using previously cached `id` and `key` values:
```typescript
    import * as nconf from "nconf";
    import {KeePassHttpClient} from "keepasshttp-client";
    
    nconf.file(".keepasshttp-creds");
    
    const client = new KeePassHttpClient({
        // url: "http://localhost:19555",
        keyId: {
            id: nconf.get("id"),
            key: nconf.get("key"),
        },
    });
    
    client
        .getLogins({url: "https://domain.com"})
{'fraction_non_alphanumeric': 0.12936681222707425, 'fraction_numerical': 0.0054585152838427945, 'mean_word_length': 2.286995515695067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3558723', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1043, 'n_words': 303}