
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
@levischuck/tiny-cbor
Advanced tools
This minimal generic library decodes and encodes most useful CBOR structures into simple JavaScript structures:
string
s or number
s with CBORType
values as a Map
CBORType
valuesnumber
snumber
sNaN
, Infinity
, -Infinity
string
sUint8Array
null
and undefined
CBORTag(tag, value)
This implementation does not support:
[-9007199254740991, 9007199254740991]
, see
Number.MAX_SAFE_INTEGERMap
sThis implementation has the following constraints:
Maps that have duplicate keys will throw an error during decoding. Decoding data that is incomplete will throw an error during decoding.
CBOR byte decoding example, this outputs a CBORType which is up to you to ensure matches the right underlying type (e.g. a string) at runtime.
// NPM
// import { decodeCBOR } from "@levischuck/tiny-cbor";
// or JSR
// import { decodeCBOR } from "jsr:@levischuck/tiny-cbor";
import { decodeCBOR } from "./index.ts";
// Get your bytes somehow, directly or with decodeBase64 / decodeHex (available through @levischuck/tiny-encodings)
// encoded ["hello", "world", 1]
const HELLO_WORLD_BYTES = new Uint8Array([
0x83, // Array (3)
0x65, // text (5),
0x68, // h
0x65, // e
0x6C, // l
0x6C, // l
0x6F, // o
0x65, // text(5),
0x77, // w
0x6F, // o
0x72, // r
0x6C, // l
0x64, // d
0x01, // 1
]);
const decoded = decodeCBOR(HELLO_WORLD_BYTES);
if (
Array.isArray(decoded) && decoded.length == 3 && decoded[0] == "hello" &&
decoded[1] == "world" && decoded[2] == 1
) {
console.log("Success!");
}
If you're looking to make this more ergonomic in JS / TS, check out tiny-cbor-schema!
This library is available on NPM and JSR.
This library is no longer automatically published to Deno's Third Party Modules. Newer versions may appear on deno.land/x, but do not work.
0.3.1 (2025-05-21)
FAQs
Tiny CBOR library
The npm package @levischuck/tiny-cbor receives a total of 469,164 weekly downloads. As such, @levischuck/tiny-cbor popularity was classified as popular.
We found that @levischuck/tiny-cbor 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.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.