Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@oslojs/asn1

oslo-project1.5mMIT1.0.0TypeScript support: included

Encode and decode ASN.1 DER

auth, asn1, der

readme

@oslojs/asn1

Documentation: https://asn1.oslojs.dev

A JavaScript library for encoding and decoding ASN.1 with Distinguished Encoding Rules (DER) by Oslo.

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

const parsed = parseASN1NoLeftoverBytes(encoded);
const oid = parsed.sequence().at(0).objectIdentifier();
if (!oid.is("1.2.840.10045.4.3.2")) {
    throw new Error("Invalid OID");
}

This library only supports DER and not CER or BER.

Installation

npm i @oslojs/asn1

changelog

@oslojs/asn1

1.0.0

  • No changes.

0.2.3

  • Update dependencies.

0.2.2

  • Add missing error messages.

0.2.1

  • Add stricter parameter checks in ASN1BitString

0.2.0

  • [Breaking] Replace decodeASN1() with parseASN1()
  • Add ASN1Value and ASN1Encodable

0.1.3

  • Update dependencies.

0.1.2

  • Replace const enum with enum

0.1.1

  • Fix issue where ASN1Sequence and ASN1Set were tagged as primitive