a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
99
fork

Configure Feed

Select the types of activity you want to include in your feed.

README.md

@atcute/car#

content-addressable archive (CAR) codec for AT Protocol.

npm install @atcute/car

this library implements DASL's CAR format used by AT Protocol to store and transfer repository data.

usage#

streaming usage#

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

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

await using car = fromStream(stream);

const roots = await car.roots();

for await (const entry of car) {
	entry;
	// ^? CarEntry { cid: CidLink {}, bytes: Uint8Array {}, ... }
}

streaming usage (for runtimes without await using yet)#

const car = fromStream(stream);

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

sync usage#

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

// read generic CAR archives
const car = fromUint8Array(buffer);

const roots = car.roots;

for (const entry of car) {
	entry;
	// ^? CarEntry { cid: CidLink {}, bytes: Uint8Array {}, ... }
}

writing#

import { writeCarStream } from '@atcute/car';

const blocks = async function* () {
	yield { cid: commitCid.bytes, data: commitBytes };
	yield { cid: nodeCid.bytes, data: nodeBytes };
};

for await (const chunk of writeCarStream([rootCid], blocks())) {
	stream.write(chunk);
}