Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 15, 2021
1 parent e7eb75c commit 57bd2a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,9 @@ The only use-case I can think of is having the config located in the app directo
Type: `string | Buffer | TypedArray | DataView`\
Default: `undefined`

This can be used to secure sensitive data **if** the encryption key is stored in a secure manner (not plain-text) in the Node.js app. For example, by using [`node-keytar`](https://github.com/atom/node-keytar) to store the encryption key securely, or asking the encryption key from the user (a password) and then storing it in a variable.
Note that this is **not intended for security purposes**, since the encryption key would be easily found inside a plain-text Node.js app.

In addition to security, this could be used for obscurity. If a user looks through the config directory and finds the config file, since it's just a JSON file, they may be tempted to modify it. By providing an encryption key, the file will be obfuscated, which should hopefully deter any users from doing so.

It also has the added bonus of ensuring the config file's integrity. If the file is changed in any way, the decryption will not work, in which case the store will just reset back to its default state.
Its main use is for obscurity. If a user looks through the config directory and finds the config file, since it's just a JSON file, they may be tempted to modify it. By providing an encryption key, the file will be obfuscated, which should hopefully deter any users from doing so.

When specified, the store will be encrypted using the [`aes-256-cbc`](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation) encryption algorithm.

Expand Down
8 changes: 4 additions & 4 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ class Conf<T extends Record<string, any> = Record<string, unknown>> implements I
}

/**
Set an item or multiple items at once.
Set an item or multiple items at once.
@param {key|object} - You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a key to access nested properties. Or a hashmap of items to set at once.
@param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.
*/
*/
set<Key extends keyof T>(key: Key, value?: T[Key]): void;
set(key: string, value: unknown): void;
set(object: Partial<T>): void;
Expand Down Expand Up @@ -290,7 +290,7 @@ class Conf<T extends Record<string, any> = Record<string, unknown>> implements I
}

/**
Watches the given `key`, calling `callback` on any changes.
Watches the given `key`, calling `callback` on any changes.
@param key - The key wo watch.
@param callback - A callback function that is called on any changes. When a `key` is first set `oldValue` will be `undefined`, and when a key is deleted `newValue` will be `undefined`.
Expand All @@ -312,7 +312,7 @@ class Conf<T extends Record<string, any> = Record<string, unknown>> implements I
}

/**
Watches the whole config object, calling `callback` on any changes.
Watches the whole config object, calling `callback` on any changes.
@param callback - A callback function that is called on any changes. When a `key` is first set `oldValue` will be `undefined`, and when a key is deleted `newValue` will be `undefined`.
@returns A function, that when called, will unsubscribe.
Expand Down

0 comments on commit 57bd2a2

Please sign in to comment.