
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-catbox
Advanced tools
node-catboxA library for interacting with Catbox.moe written in TypeScript with no dependencies. |
This library aims to be a sort of successor to https://www.npmjs.com/package/catbox.moe.
npm i node-catbox
yarn add node-catbox
bun add node-catbox
import { Catbox } from 'node-catbox';
const catbox = new Catbox();
try {
const response = await catbox.uploadFile({
path: '/path/to/my/file.ext'
});
// or to upload from direct file URL
const response = await catbox.uploadURL({
url: 'https://i.imgur.com/8rR6IZn.png'
});
console.log(response); // -> https://files.catbox.moe/XXXXX.ext
} catch (err) {
console.error(err); // -> error message from server
}
// ---
// NEW in v3.4.0
const stream = createReadStream('/path/to/my/file.ext');
await catbox.uploadFileStream({
stream,
filename: 'file.ext'
});
Some operations require your account's user hash which can be set on instantiation with
const catbox = new Catbox('098f6bcd4621d373cade4e832');
... or later with
const catbox = new Catbox();
catbox.setUserHash('098f6bcd4621d373cade4e832');
import { Catbox } from 'node-catbox';
// user hash required
const catbox = new Catbox('098f6bcd4621d373cade4e832');
await catbox.deleteFiles({
files: ['XXXXX.ext']
});
import { Catbox } from 'node-catbox';
// user hash only required if you plan to edit or delete the album later
const catbox = new Catbox('098f6bcd4621d373cade4e832');
const albumURL = await catbox.createAlbum({
title: 'album title',
description: 'album description',
files: ['XXXXX.ext'] // optional
});
import { Catbox } from 'node-catbox';
// user hash required
const catbox = new Catbox('098f6bcd4621d373cade4e832');
await catbox.editAlbum({
id: 'YYYYY',
title: 'new title',
description: 'new description',
files: ['WWWWW.ext', 'VVVVV.ext'] // optional
});
Warning This is a potentially destructive method where values are applied to the album directly. Consider using the method below if you are only adding/removing files from an album.
import { Catbox } from 'node-catbox';
// user hash required
const catbox = new Catbox('098f6bcd4621d373cade4e832');
await catbox.addFilesToAlbum({
id: 'YYYYY',
files: ['ZZZZZ.ext']
});
await catbox.removeFilesFromAlbum({
id: 'YYYYY',
files: ['ZZZZZ.ext']
});
import { Catbox } from 'node-catbox';
// user hash required
const catbox = new Catbox('098f6bcd4621d373cade4e832');
await catbox.removeAlbum({
id: 'YYYYY'
});
import { Litterbox } from 'node-catbox';
const litterbox = new Litterbox();
await litterbox.uploadFile({
path: '/path/to/my/file.ext',
duration: '12h' // or omit to default to 1h
});
// ---
import { FileLifetime } from 'node-catbox';
// Using an enum for duration
await litterbox.uploadFile({
path: '/path/to/my/file.ext',
duration: FileLifetime.TwelveHours
});
// ---
// NEW in v3.4.0
const stream = createReadStream('/path/to/my/file.ext');
await litterbox.uploadFileStream({
stream,
filename: 'file.ext'
});
// ---
// NEW in v4.1.0
import { FileNameLength } from 'node-catbox';
// Using an enum for duration
await litterbox.uploadFile({
path: '/path/to/my/file.ext',
fileNameLength: FileNameLength.Sixteen
});
As of 4.0.0, both Catbox and Litterbox emit a request and response event as well as events specific to each class:
import { Catbox, Litterbox } from 'node-catbox';
const catbox = new Catbox();
const litterbox = new Litterbox();
// `request` is a sanitized read-only snapshot (no raw body)
catbox.on('request', request => console.log(request.method, request.hasBody));
// `response` is a read-only snapshot
catbox.on('response', response => console.log(`${response.status} - ${response.statusText}`));
litterbox.on('uploadingFile', (filepath, duration) => console.log('Uploading file', filepath, 'with a duration of', duration));
Before you test the library you need to provide your Catbox account's user hash. Create a .env file in the project root and set the USER_HASH value to your account's user hash.
By default, network-dependent integration tests are skipped to avoid flaky failures and rate limits.
yarn testRUN_INTEGRATION_TESTS=1This project does not include any source code generated by artificial intelligence tools. All application logic, implementation, and architectural decisions are authored and maintained by human contributors, flaws and all.
AI tools may be used in a limited, non-code capacity to assist with:
No AI-generated content is used for:
Any use of AI is strictly limited to improving clarity and readability of written documentation, and all changes are reviewed before being committed.
FAQs
A library for interacting with Catbox.moe written in TypeScript.
The npm package node-catbox receives a total of 7,302 weekly downloads. As such, node-catbox popularity was classified as popular.
We found that node-catbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.