@atcute/repo

中文文档
1.1.1发布于 2026/10/100BSDES Module近 30 天下载 30.9万

AT Protocol repository decoder for AT Protocol.

原始使用文档
文档目录6 节
  1. usage
  2. streaming usage
  3. streaming usage (for runtimes without await using yet)
  4. sync usage
  5. verifying records
  6. transform streams

@atcute/repo

read AT Protocol repository exports.

npm install @atcute/repo

AT Protocol stores user data in repositories - Merkle tree structures containing records organized by collection. this package reads repository CAR exports (from com.atproto.sync.getRepo or account exports) and iterates over the records.

usage

streaming usage

[!NOTE]
PDS implementations, including the reference PDS, may not emit blocks in the efficient order specified by Sync v1.1. the streaming reader compensates by buffering internally, so memory usage may be higher than expected.

streaming may still be useful when responsiveness matters, such as web apps that want to display records as they arrive rather than waiting for the entire CAR to load.

this library intends to enforce efficient block ordering once Sync v1.1 is finalized.

import { fromStream } from '@atcute/repo';

const stream = new ReadableStream({/* ... */});

await using repo = fromStream(stream);

for await (const entry of repo) {
    entry;
    // ^? RepoEntry { collection: 'app.bsky.feed.post', rkey: '3lprcc55bb222', ... }
}

repo.missingBlocks;
//   ^? []

streaming usage (for runtimes without await using yet)

const repo = fromStream(stream);

try {
    for await (const entry of repo) {
        entry;
        // ^? RepoEntry
    }
} finally {
    await repo.dispose();
}

sync usage

const buffer = Uint8Array.from([/* ... */]);

const repo = fromUint8Array(buffer);

for (const entry of repo) {
    entry;
    // ^? RepoEntry { collection: 'app.bsky.feed.post', rkey: '3lprcc55bb222', ... }
}

repo.missingBlocks;
//   ^? []

verifying records

verify a record's inclusion in a repository with optional signature verification:

import { verifyRecord } from '@atcute/repo';

const { cid, record } = await verifyRecord({
    collection: 'app.bsky.feed.post',
    rkey: '3lprcc55bb222',
    carBytes: carBytes,
    // optional: verify commit signature
    publicKey: key,
    // optional: verify DID matches
    did: 'did:plc:...',
});

transform streams

for piping repository data through a transform:

import { repoEntryTransform } from '@atcute/repo';

const { readable, writable } = repoEntryTransform();

// pipe CAR data in, get RepoEntry objects out
response.body.pipeTo(writable);

for await (const entry of readable) {
    console.log(entry.collection, entry.rkey);
}

版本与发布记录

@atcute/repo 共发布 11 个版本,首次发布于 2025/10/20;过去 12 个月发布了 10 个版本。

版本发布日期距今
1.1.1latest2026/10/1028 天前
1.1.02026/09/241 个月前
1.0.22026/06/294 个月前
1.0.12026/06/154 个月前
1.0.02026/05/095 个月前
0.1.52026/05/086 个月前

关于 @atcute/repo 的常见问题

@atcute/repo 是什么?

AT Protocol repository decoder for AT Protocol.

如何安装 @atcute/repo?

在项目目录运行 npm install @atcute/repo,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@atcute/cid(^2.5.0)、@atcute/cbor(^2.0.0)、@atcute/lexicons(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atcute/repo 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/atcute__repo 是否存在。

@atcute/repo 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@atcute/repo 可以商用吗?

@atcute/repo 使用 0BSD 许可。几乎没有限制:可自由使用、修改和分发,连保留版权声明也不要求。以上为概括,不构成法律意见,请以许可原文为准。

@atcute/repo 的下载量有多少?

根据 npm 官方下载统计,@atcute/repo 在 2026/10/07 – 2026/11/05 这 30 天内被下载 308,704 次,日均约 10,290 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atcute/repo 还在维护吗?

最新版本 1.1.1 发布于 2026/10/10(28 天前);至今共发布 11 个版本,其中过去 12 个月发布了 10 个;首次发布于 2025/10/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。