@wardenjs/csr
v0.2.0
Published
Browser-side security as composable decorators: decorate() plus the KeyValueStore and Fetcher contracts. Zero dependencies.
Maintainers
Readme
@wardenjs/csr
Part of warden's browser track: security controls for code that runs in the browser. Here CSR means client side, not client-side rendering. Nothing here is a trust boundary; the server track enforces.
The contract browser plugins build on. No controls, no configuration, no dependencies.
npm i @wardenjs/csrimport { decorate, type Decorator, type KeyValueStore } from '@wardenjs/csr';
const logged: Decorator<KeyValueStore> = (inner) => ({
...inner,
set: async (key, value) => {
console.debug('write', key);
return inner.set(key, value);
},
});
const store = decorate(base, logged, otherDecorator); // logged(otherDecorator(base))| | |
| --- | --- |
| Decorator<T>, decorate(base, ...decorators) | First listed is outermost. See docs/csr.md. |
| KeyValueStore | Async string store; what storage decorators wrap. |
| Fetcher | The fetch signature; what fetch decorators wrap. |
| emit, SecurityEvent | The event shape plugins report through onEvent. |
| SecurityRegistry, Permission | Augment once with your permission names; -access reads them. |
