# @atcute/cid

> lightweight DASL CID codec library for AT Protocol

Latest version **2.4.2** (published 2026-06-29) · 0BSD license · 0 weekly downloads

## Install

```sh
npm install @atcute/cid
pnpm add @atcute/cid
yarn add @atcute/cid
bun add @atcute/cid
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.4.2 |
| Published | 2026-06-29 |
| First published | 2024-08-18 |
| Weekly downloads | 0 |
| License | 0BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 517 |
| Maintainers | externdefs |
| Keywords | atproto, cid, dasl |

## Links

- npm: https://www.npmjs.com/package/@atcute/cid
- Repository: https://tangled.org/did:plc:pljn5qch4tgadongtc7i6qij
- npm.io page: https://npm.io/package/@atcute/cid

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.4.2 (latest) — 2026-06-29
- 2.4.1 — 2026-02-12
- 2.4.0 — 2026-01-15
- 2.3.0 — 2025-12-27
- 2.2.6 — 2025-10-20
- 2.2.5 — 2025-10-14
- 2.2.4 — 2025-10-09
- 2.2.3 — 2025-05-17
- 2.2.2 — 2025-05-04
- 2.2.1 — 2025-04-10
- 2.2.0 — 2025-03-20
- 2.1.0 — 2025-01-04
- 2.0.1 — 2024-12-29
- 2.0.0 — 2024-12-26
- 1.0.3 — 2024-12-25
- … 3 more at https://npm.io/package/@atcute/cid/versions

## README

# @atcute/cid

content identifier (CID) codec for AT Protocol.

```sh
npm install @atcute/cid
```

this library implements DASL's [CID][dasl-cid] format used by AT Protocol to address resources by
their contents.

[dasl-cid]: https://dasl.ing/cid.html

## usage

```ts
import * as CID from '@atcute/cid';
import { toCidLink, fromCidLink, isCidLink } from '@atcute/cid';

// create a CID by hashing data (0x71 for DAG-CBOR, 0x55 for raw)
const cid = await CID.create(0x71, cborBytes);
// -> { version: 1, codec: 113, digest: { codec: 18, contents: Uint8Array(32) }, bytes: Uint8Array(36) }

// parse from base32 string
const parsed = CID.fromString('bafyreihffx5a2e7k5uwrmmgofbvzujc5cmw5h4espouwuxt3liqoflx3ee');

// parse from binary (with 0x00 prefix) or raw CID bytes
const fromBin = CID.fromBinary(binaryBytes);
const fromRaw = CID.decode(cidBytes);

// serialize to base32 string or binary format
CID.toString(cid); // -> "bafyreihffx5a2e7k5uwrmmgofbvzujc5cmw5h4espouwuxt3liqoflx3ee"
CID.toBinary(cid); // -> Uint8Array(37) with 0x00 prefix

// compare two CIDs
CID.equals(cidA, cidB); // -> true if identical

// convert to CidLink for JSON serialization (atproto data model)
const link = toCidLink(cid); // -> { $link: "bafyrei..." }
const back = fromCidLink(link);

// type guard for CidLink
if (isCidLink(value)) {
	console.log(value.$link);
}
```

---
_Source: https://npm.io/package/@atcute/cid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
