
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Lib for parsing mime streams.
This is supposed to be a "low level" mime parsing module. No magic is performed on the data (eg. no joining HTML parts etc.). All body data is emitted out as Typed Arrays, so no need to perform any base64 or quoted printable decoding by yourself. Text parts are decoded to UTF-8 if needed.
npm install --save mimeparser
This module depends on mimefuncs and wo-addressparser . The dependency will be fetched automatically. Please use your require config accordingly.
var MimeParser = require('mimeparser');
<script src="mimeparser"></script>
// exposes MimeParser the constructor to the global object
Feed data with write(chunk)
. Where chunk
is supposed to be an Uint8Array or a 'binary' string.
parser.write('Subject: test\n\nHello world!');
When all data is feeded to the parser, call end()
parser.end();
You can receive the output by creating appropriate event handler functions.
To receive node headers, define onheader
function
parser.onheader = function(node){
console.log(node.header.join('\n')); // List all headers
console.log(node.headers['content-type']); // List value for Content-Type
};
Body is emitted in chunks of Typed Arrays, define onbody
to catch these chunks
parser.onbody = function(node, chunk){
console.log('Received %s bytes for %s', chunk.byteLength, node.path.join("."));
};
When the parsing is finished, onend
is called
parser.onend = function(){
console.log('Parsing is finished');
};
This seems like asynchronous but actually it is not. So always define onheader
, onbody
and onend
before writing the first chunk of data to the parser.
message/rfc822 is automatically parsed if the mime part does not have a Content-Disposition: attachment
header, otherwise it will be emitted as a regular attachment (as one long Uint8Array value).
git clone git@github.com:whiteout-io/mimeparser.git
cd mimeparser
npm install && npm test
Copyright (c) 2013 Andris Reinman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
FAQs
Parse a mime tree, no magic included.
We found that mimeparser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.