read-once objects for sensitive data.
- Its main purpose is to facilitate detection of unintentional use.
- It represents a sensitive value or concept.
- It’s often a domain primitive.
- Its value can be read once, and once only.
- It prevents serialization of sensitive data.
- It prevents subclassing and extension.
Quote from Secure by Design.
ReadOnce
: It allow to read at onceNoSerializedValue
: It disallow to serialize value that is marked as secret.
Install with npm:
npm install read-once
import { SensitiveValue } from "read-once"
const value = new SensitiveValue("secret");
// Read once
assert.strictEqual(value.value, "secret");
// When read twice, throw an ReferenceError
assert.throws(() => {
value.value;
}, ReferenceError);
See Releases page.
Install devDependencies and Run npm test
:
npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © azu