
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Perfect for CLI application user preferences
Out of the box 📦⤵️ easy application encrypted preferences 👍
npm$ npm install --save dotpref
yarn$ yarn add dotpref
Out of the box simple key/value store.
import Pref from 'dotpref';
Pref.set('foo', 'bar');
console.log(Pref.get('foo'));
//=> 'bar'
Pref.set('foo', { bar: 'baz' });
console.log(Pref.get('foo'));
//=> '{ bar: "baz" } '
PrefThe default export of the dotpref module is a singleton instance with a default configuration.
import Pref from 'dotpref';
createPrefCreates a custom instance of dotpref with custom configuration. This method can be used if you need multiple configurations.
import { createPref } from 'dotpref';
.getType: (key: string) => string
Get the value assigned to key in the state.
.setType: (key: string, value: string) => void
Set the value of key in the state. The value must serializable by the instance's serializer. For example, using the default serializer (JSON), setting a value of type undefined, function, or symbol will result in a TypeError.
.resetType: (key: string) => void
Reset the value assigned to key to the default state.
.writeType: () => void
Explicitly write to disk.
.readType: () => void
Explicitly read from disk to state.
.filePathType: readonly string
Readonly absolute path to the preference file stored on disk. This property will exist even if the preference file does not.
getDefaultCryptodefaultsType: state
An object specifying the default values of the preference state. If preferences are found, they will override the defaults in the state. If no preferences are found, defaults will be used – state will not be written to disk upon creation. Default: {}.
nameType: string
The name of your project. This value will be used to build the filePath of the preference file stored on disk. Default: the name property of your package.json.
filenameType: string
The filename of the preference file stored on disk. Default: config.pref
dirPathType: string
Absolute path determining where the preferences should be stored on disk. Default: <system config>/<name> where <system config> is the User's default system config path and <name> is the name property configuration property;
serializerType: state => string
A function that specifies how the state should be serialized when written to disk. Default: JSON.stringify.
deserializerType: string => state
The reverse of serializer. A function that specifies how the state should be deserialized when read from disk. Default: JSON.parse.
encoderType: string => string
A function that specifies how the state should be encrypted. Default: getDefaultCrypto.encrypt.
decoderType: string => string
A function that specifies how the state should be decrypted. Default: getDefaultCrypto.decrypt.
setterType: (state, key, value) => void
A function that takes the existing state, the key, and the value and returns a new state to be saved to disk. The state will be saved to disk if the equality function returns false. Default: (state, key, value) => { ...state, [key]: value }.
getterType: (state, key) => value
Reverse of setter. A function that takes the existing state and the key and returns the value. Default: (state, key) => state[key].
equalityType: boolean | (state, newState) => boolean
Determines the equality of the old state and the new state. This method is used to determine if the state has changed since the last write. If set to true the state will write to disk on every set. When set to false the state will never write to disk on set and therefore must explicitly be written via write.
For each OS below <home> is calculated using NodeJS' os.homedir().
<home>/Library/Preferences/<name><home>/AppData/Roaming/<name>/Config<home>/.config/<name> or $XDG_CONFIG_HOME/<name>FAQs
Perfect for CLI application user preferences.
The npm package dotpref receives a total of 23 weekly downloads. As such, dotpref popularity was classified as not popular.
We found that dotpref demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.