New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sipware-body

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sipware-body - npm Package Compare versions

Comparing version 0.2.60 to 0.2.62

52

index.js
const MailParser = require('mailparser').MailParser;
const {Content} = require('sipware-ua');
const {Protocol} = require('sipware');
const proto = new Protocol();
const cr = 13, lf = 10;

@@ -87,29 +90,44 @@

module.exports = async(ctx) => {
if(ctx.raw) {
var msg = await parseMessage(ctx.raw);
async function rawParser(ctx) {
var msg = await parseMessage(ctx.raw);
ctx.text = msg.text;
ctx.html = msg.html;
if(msg.headers['content-type']) {
var [type] = msg.headers['content-type'].split(';')
if(msg.headers['content-type']) {
var [type] = msg.headers['content-type'].split(';')
if(type == 'application/json') {
if(msg.attachments && msg.attachments[0].content) {
if(type == 'application/json') {
if(msg.attachments && msg.attachments[0]) {
if(msg.attachments[0].content) {
try {
ctx.json = JSON.parse(msg.attachments[0].content.toString());
msg.json = JSON.parse(msg.attachments[0].content.toString());
} catch(ex) {
// console.log('Body parser err', ex);
console.log('Raw parser err', ex);
}
}
} else {
ctx.attachments = msg.attachments;
msg.json = msg.json || {};
msg.attachments = undefined;
}
}
}
ctx.content = new Content(msg);
}
async function bodyParser(ctx) {
var body = ctx.body instanceof Buffer ? ctx.body.toString() : ctx.body;
ctx.raw = proto.createHeaders(ctx.headers) + '\n' + ctx.body;
await rawParser(ctx);
}
module.exports = async(ctx) => {
if(ctx.content) {
return;
}
if(ctx.raw) {
await rawParser(ctx);
} else if(ctx.body) {
await bodyParser(ctx);
} else {
if('object' == typeof ctx.content) {
ctx.json = ctx.content;
}
console.log('No parser for body?');
}
}

@@ -5,3 +5,5 @@ {

"dependencies": {
"mailparser": "*"
"sipware": "*",
"sipware-ua": "*",
"mailparser": "0.6.x"
},

@@ -19,3 +21,3 @@ "engines": {

"optionalDependencies": {},
"version": "0.2.60",
"version": "0.2.62",
"directories": {

@@ -22,0 +24,0 @@ "lib": "lib"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc