@yrneh_jang/asn1
v2.0.2
Published
Contains parsers and serializers for ASN.1 (currently BER only). Fork of @ldapjs/asn1 with Cloudflare Workers support (lazy fs loading).
Readme
@yrneh_jang/asn1
Fork of @ldapjs/asn1 with Cloudflare Workers support.
Changes from upstream
fsmodule is lazy-loaded inside the function body instead of at module load time, so the package works in Cloudflare Workers wherefsis not available.
Installation
npm install @yrneh_jang/asn1Usage
Decoding
const { BerReader, BerTypes } = require('@yrneh_jang/asn1')
const reader = new BerReader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]))
reader.readSequence()
console.log('Sequence len: ' + reader.length)
if (reader.peek() === BerTypes.Boolean)
console.log(reader.readBoolean())Encoding
const { BerWriter } = require('@yrneh_jang/asn1')
const writer = new BerWriter()
writer.startSequence()
writer.writeBoolean(true)
writer.endSequence()
console.log(writer.buffer)Cloudflare Workers
No additional configuration needed. Works out of the box with nodejs_compat compatibility flag.
# wrangler.toml
compatibility_flags = ["nodejs_compat"]License
MIT
