sipware-body
Advanced tools
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" |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
38737
112
3
4
1
+ Addedsipware@*
+ Addedsipware-ua@*
+ Added@korzio/djv-draft-04@2.0.1(transitive)
+ Addedaccepts@2.0.0(transitive)
+ Addedaddressparser@1.0.1(transitive)
+ Addedbuildmail@4.0.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddjv@2.1.4(transitive)
+ Addedemail-addresses@5.0.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedextend@3.0.2(transitive)
+ Addediconv-lite@0.4.15(transitive)
+ Addedlibbase64@0.1.0(transitive)
+ Addedlibmime@3.0.0(transitive)
+ Addedlibqp@1.1.0(transitive)
+ Addedmailcomposer@4.0.2(transitive)
+ Addedmailparser@0.6.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedmime-db@1.53.0(transitive)
+ Addedmime-types@3.0.0(transitive)
+ Addedmimelib@0.3.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addednegotiator@1.0.0(transitive)
+ Addednodemailer-fetch@1.6.0(transitive)
+ Addednodemailer-shared@1.1.0(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedsipware@1.0.2(transitive)
+ Addedsipware-ua@1.0.8(transitive)
+ Addeduue@3.1.2(transitive)
- Removed@selderee/plugin-htmlparser2@0.11.0(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removeddom-serializer@2.0.0(transitive)
- Removeddomelementtype@2.3.0(transitive)
- Removeddomhandler@5.0.3(transitive)
- Removeddomutils@3.2.2(transitive)
- Removedentities@4.5.0(transitive)
- Removedhe@1.2.0(transitive)
- Removedhtml-to-text@9.0.5(transitive)
- Removedhtmlparser2@8.0.2(transitive)
- Removedleac@0.6.0(transitive)
- Removedlinkify-it@5.0.0(transitive)
- Removedmailparser@3.7.2(transitive)
- Removedmailsplit@5.4.2(transitive)
- Removednodemailer@6.9.16(transitive)
- Removedparseley@0.12.1(transitive)
- Removedpeberminta@0.9.0(transitive)
- Removedpunycode.js@2.3.1(transitive)
- Removedselderee@0.11.0(transitive)
- Removedtlds@1.255.0(transitive)
- Removeduc.micro@2.1.0(transitive)
Updatedmailparser@0.6.x