Skip to content

oslo-project/cbor

Repository files navigation

@oslojs/cbor

Documentation: https://cbor.oslojs.dev

A CBOR library for JavaScript based on RFC 8949.

  • Runtime agnostic
  • No third-party dependencies
  • Fully typed
import { decodeCBORToNativeValueNoLeftoverBytes } from "@oslojs/cbor";

const MAX_DEPTH = 10;
const encoded = new Uint8Array([
	0xa1, 0x67, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x65, 0x68, 0x65, 0x6c, 0x6c, 0x6f
]);
const result = decodeCBORToNativeValueNoLeftoverBytes(encoded, MAX_DEPTH) as Result;
const message: string = result.message;

interface Result {
	message: string;
}

This package currently only supports decoding

Installation

npm i @oslojs/cbor

About

CBOR library for JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published