Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
hypercore-xsalsa20-onwrite-hook
Advanced tools
A write hook to decrypt data using a XSalsa20 cipher into a hypercore storage when replicating from peers
A write hook to decrypt data using a XSalsa20 cipher into a hypercore storage when replicating from peers.
$ npm install hypercore-xsalsa20-onwrite-hook
const hook = require('hypercore-xsalsa20-onwrite-hook')
const feed = hypercore(storage, key, {
onwrite: hook({
nonce: storageNonce,
key: sharedStorageKey
})
})
const { keyPair } = require('hypercore-crypto')
const replicate = require('hypercore-replicate')
const hypercore = require('hypercore')
const xsalsa20 = require('xsalsa20-encoding')
const crypto = require('crypto')
const hook = require('hypercore-xsalsa20-onwrite-hook')
const ram = require('random-access-memory')
const key = crypto.randomBytes(32)
const nonce = crypto.randomBytes(32)
const onwrite = hook({ nonce, key })
const { publicKey, secretKey } = keyPair()
const valueEncoding = xsalsa20(nonce, key)
const feed = hypercore(ram, publicKey, { secretKey, valueEncoding })
feed.ready(() => {
const copy = hypercore(ram, publicKey, { onwrite })
const other = hypercore(ram, publicKey, { valueEncoding })
feed.append('hello')
replicate(feed, copy.replicate({ live: true }), other.replicate({ live: true }), {
userData: Buffer.from([0xfa, 0xce]),
live: true
})
copy.update(() => {
copy.head((err, buf) => {
console.log('%s', buf) // 'hello'
})
})
other.update(() => {
other.head((err, buf) => {
console.log('%s', buf) // 'hello'
})
})
})
hook = require('hypercore-xsalsa20-onwrite-hook')(opts)
where opts
can be:
{
nonce: [Buffer], // An optional 24 byte nonce. If not given, the hypercore's public key is used
key: Buffer, // A required shared 32 byte shared secret key
}
MIT
FAQs
A write hook to decrypt data using a XSalsa20 cipher into a hypercore storage when replicating from peers
The npm package hypercore-xsalsa20-onwrite-hook receives a total of 1 weekly downloads. As such, hypercore-xsalsa20-onwrite-hook popularity was classified as not popular.
We found that hypercore-xsalsa20-onwrite-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.