Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@storacha/one-webcrypto
Advanced tools
Import the webcrypto API as a single module in both nodejs and browsers.
The WebCrypto API is available in most browsers, under a global variable:
// in web pages
const webcrypto = window.crypto
// in web workers, etc.
const webcrypto = self.crypto
// or generally under
const webcrypto = globalThis.crypto
It is also available in NodeJS since version 15.
However, it is accessed differently:
// in node with commonjs
const webcrypto = require("crypto").webcrypto
// in node with ES Modules
import crypto from "crypto"
const webcrypto = crypto.webcrypto
These different ways of getting access to valuable cryptographic primitives (see webcrypto.subtle
) accross platforms (node & browsers) are hard to get right.
With this package, you can just import the WebCrypto API like so:
import { webcrypto } from "one-webcrypto"
webcrypto.getRandomValues( //...
await webcrypto.subtle.generateKey( //...
Or with CommonJS:
const { webcrypto } = require("one-webcrypto")
This package uses a fairly new package.json standard field, the exports
field.
Read more about it:
We're also making use of webpack's pseudo-standard of the "browser" flag for imports.
So if your environment doesn't support that, it may or may not work.
We know that this setup works (should work) with
We know that this setup can have issues with
If you have any experience (whether it supports the claims above or not), please create an issue. The idea is to help each other out in these crazy bundler times and document what works and what doesn't. :)
FAQs
Import the webcrypto API as a single module in both nodejs and browsers.
The npm package @storacha/one-webcrypto receives a total of 1,786 weekly downloads. As such, @storacha/one-webcrypto popularity was classified as popular.
We found that @storacha/one-webcrypto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
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.