side-channel <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

Store information about any JS value in a side channel. Uses WeakMap if available.

Warning: in an environment that lacks WeakMap, this implementation will leak memory until you delete the key.

Getting started

npm install --save side-channel

Usage/Examples

const assert = require('assert');
const getSideChannel = require('side-channel');

const channel = getSideChannel();

const key = {};
assert.equal(channel.has(key), false);
assert.throws(() => channel.assert(key), TypeError);

channel.set(key, 42);

channel.assert(key); // does not throw
assert.equal(channel.has(key), true);
assert.equal(channel.get(key), 42);

channel.delete(key);
assert.equal(channel.has(key), false);
assert.throws(() => channel.assert(key), TypeError);

Tests

Clone the repo, npm install, and run npm test

side-channel - Installation

To install side-channel via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install side-channel --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install side-channel

Learn more about the config option.

PNPM

pnpm install side-channel --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install side-channel --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

side-channel - Download

Download Tarball (v1.1.1)

Integrity sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==
SHASUM ea02c62e05dc4bea67d4442f0fb71ee192f8e0ab
Tarball https://js.registry.sudovanilla.org/side-channel/-/side-channel-1.1.1.tgz