🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@cryptella/eml-rfc822

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cryptella/eml-rfc822

EML/RFC822 parser and serializer.

0.0.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

@cryptella/eml-rfc822

What

This package offers a streaming, high-performance parser and serializer for the RFC822 (EML) format. Built on top Web Streams, this package works in modern browsers, Bun and Node.js.

Compatibility

  • Bun 1+
  • Node.js 16+
  • Modern browsers

Usage

import { parse } from '@cryptella/eml-rfc822';

const stream = new ReadableStream(); // get stream somehow...

// `headers` is always an array IHeader[] ({ name: string; value: string; params?: Record<string, string> }[])
// `body` is a ReadableStream<UInt8Array>

const { headers, body } = await parse(stream, {
  decoders: [
    multipartDecoder(async (headers, body) => {
      // consume nested parts here...
    }),
  ],
});

Or use a simple parseMultipart() function that returns ArrayBuffers instead of streams and includes base64 decoder:

import { parseMultipart } from '@cryptella/eml-rfc822';

const message: Multipart = await parseMultipart(stream);
interface Multipart = {
  boundary: string;
  body: Uint8Array;
  headers: IHeader[];
  parts: Multipart[];
  rawHeaders: Uint8Array;
}

Sponsor

This project is sponsored by bausw.com - no-code business apps for the construction industry.

License

MIT

Keywords

eml

FAQs

Package last updated on 15 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts