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

Configure Feed

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

README.md

@atcute/cbor#

deterministic CBOR codec for AT Protocol.

npm install @atcute/cbor

this library implements DASL's DRISL format used by AT Protocol for encoding records and repository data.

usage#

encoding#

import { encode } from '@atcute/cbor';

const record = {
	$type: 'app.bsky.feed.post',
	createdAt: '2024-08-18T03:18:24.000Z',
	langs: ['en'],
	text: 'hello world!',
};

const cbor = encode(record);
// -> Uint8Array(90)

decoding#

import { decode, decodeFirst } from '@atcute/cbor';

const record = decode(cborBytes);
// -> { $type: 'app.bsky.feed.post', ... }

// decode from a buffer containing multiple values
const [value, remainder] = decodeFirst(cborBytes);

notes#

  • undefined values are omitted from maps (making it easier to construct objects)
  • bytes and CID links use lazy wrappers (BytesWrapper, CidLinkWrapper) compatible with atproto's lex-json format
  • use toBytes/fromBytes and toCidLink/fromCidLink to convert between lex-json and raw types
  • integers must be within JavaScript's safe integer range (no bigint support)

based on microcbor.