
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
web3.storage
Advanced tools
The JavaScript API client for https://web3.storage
Install the package using npm
npm install web3.storage
The code below shows how you create a new web3.storage api client, and use it to put your files to web3, and get them back again.
Sign in to https://web3.storage, create an API token, and use it in place of API_TOKEN when creating your instance of the client.
import { Web3Storage } from 'web3.storage'
// Construct with token and endpoint
const client = new Web3Storage({ token: API_TOKEN })
const fileInput = document.querySelector('input[type="file"]')
// Pack files into a CAR and send to web3.storage
const rootCid = await client.put(fileInput.files) // Promise<CIDString>
// Get info on the Filecoin deals that the CID is stored in
const info = await client.status(rootCid) // Promise<Status | undefined>
// Fetch and verify files from web3.storage
const res = await client.get(rootCid) // Promise<Web3Response | null>
const files = await res.files() // Promise<Web3File[]>
for (const file of files) {
console.log(`${file.cid} ${file.name} ${file.size}`)
}
Management of mutable name records with IPNS has now moved to the w3name client.
Run npm test to test the ESM code, CJS, and in the browser via playwright-test. 100% test coverage is required by the hundreds module.
To test in individual environments, you'll need two terminal windows open. In the first, start up the mock API by running npm run mock:api. In the second, you can then run npm run test:web, npm run test:esm or npm run test:cjs.
Tests are written in mocha and use a mock API server to assert functionality. When adding a new method to the client, add a test/<method>.spec.js test suite to go with it.
The mock api is built with smoke file-based mock server. You add a files to the test/mocks/api directory, and the file name determines which API enpoint you are mocking. You can provide a .json for a static response, or a .js file to add some logic to the mock.
post_car.js handles POST /car requests.get_car#@cid.js handes GET /car/:cid requests. The cid part of the path is provided to the mock as params.cid.Add more mocks as required.
FAQs
API client for web3.storage
The npm package web3.storage receives a total of 1,209 weekly downloads. As such, web3.storage popularity was classified as popular.
We found that web3.storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.