@sealsystems/ipp
Advanced tools
Comparing version 2.0.9 to 2.0.11
@@ -15,3 +15,4 @@ 'use strict'; | ||
tags: require('./lib/tags'), | ||
statusCodes: require('./lib/statusCodes') | ||
statusCodes: require('./lib/statusCodes'), | ||
StreamParser: require('./lib/StreamParser') | ||
}; | ||
@@ -18,0 +19,0 @@ module.exports.operations = module.exports.enums['operations-supported']; |
@@ -194,2 +194,45 @@ 'use strict'; | ||
]), | ||
'cups-operations-supported': xref([ | ||
// https://www.cups.org/doc/spec-ipp.html | ||
'CUPS-Get-Default', | ||
'CUPS-Get-Printers', | ||
'CUPS-Add-Modify-Printer', | ||
'CUPS-Delete-Printer', | ||
'CUPS-Get-Classes', | ||
'CUPS-Add-Modify-Class', | ||
'CUPS-Delete-Class', | ||
'CUPS-Accept-Jobs', | ||
'CUPS-Reject-Jobs', | ||
'CUPS-Set-Default', | ||
'CUPS-Get-Devices', | ||
'CUPS-Get-PPDs', | ||
'CUPS-Move-Job', | ||
'CUPS-Authenticate-Job', | ||
'CUPS-Get-PPD', | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
'CUPS-Get-Document', | ||
'CUPS-Create-Local-Printer' | ||
], 0x4001), | ||
'job-collation-type': xref([ | ||
@@ -196,0 +239,0 @@ // IPP2.1 http://tools.ietf.org/html/rfc3381#section-6.3 |
@@ -6,7 +6,7 @@ 'use strict'; | ||
// converts the arrays to objects and tacks on a 'lookup' property. | ||
const xref = (arr) => { | ||
const xref = (arr, offset = 0) => { | ||
const obj = {}; | ||
arr.forEach((item, index) => { | ||
obj[item] = index; | ||
obj[item] = index + offset; | ||
}); | ||
@@ -13,0 +13,0 @@ obj.lookup = arr; |
'use strict'; | ||
const enums = require('./enums'), | ||
statusCodes = require('./statusCodes'), | ||
tags = require('./tags'); | ||
const enums = require('./enums'); | ||
const statusCodes = require('./statusCodes'); | ||
const tags = require('./tags'); | ||
const operations = enums['operations-supported'], | ||
RS = '\u001e'; | ||
const operations = enums['operations-supported']; | ||
const cupsOperations = enums['cups-operations-supported']; | ||
const RS = '\u001e'; | ||
@@ -16,2 +17,6 @@ const parser = (buf) => { | ||
const read1 = () => { | ||
if (position + 1 > buf.length) { | ||
throw new Error('NotEnoughData'); | ||
} | ||
return buf[position++]; | ||
@@ -21,2 +26,5 @@ }; | ||
const read2 = () => { | ||
if (position + 2 > buf.length) { | ||
throw new Error('NotEnoughData'); | ||
} | ||
const val = buf.readInt16BE(position, true); | ||
@@ -30,2 +38,5 @@ | ||
const read4 = () => { | ||
if (position + 4 > buf.length) { | ||
throw new Error('NotEnoughData'); | ||
} | ||
const val = buf.readInt32BE(position, true); | ||
@@ -42,2 +53,5 @@ | ||
} | ||
if (position + length > buf.length) { | ||
throw new Error('NotEnoughData'); | ||
} | ||
const start = position; | ||
@@ -188,2 +202,5 @@ | ||
if (position >= buf.length) { | ||
throw new Error('NotEnoughData'); | ||
} | ||
while (buf[position] >= 0x0f) { | ||
@@ -204,2 +221,5 @@ // delimiters are between 0x00 to 0x0F | ||
} | ||
if (group !== 0x03) { | ||
throw new Error('NotEnoughData'); | ||
} | ||
}; | ||
@@ -264,3 +284,3 @@ | ||
if (bytes2and3 >= 0x02 || bytes2and3 <= 0x3d) { | ||
obj.operation = operations.lookup[bytes2and3]; | ||
obj.operation = operations.lookup[bytes2and3] || cupsOperations.lookup[bytes2and3]; | ||
} | ||
@@ -281,2 +301,4 @@ | ||
module.exports = parser; | ||
module.exports.handleUnknownTag = (tag, name, length, read) => { | ||
@@ -288,2 +310,1 @@ const value = length ? read(length) : undefined; | ||
module.exports = parser; |
@@ -7,2 +7,3 @@ 'use strict'; | ||
const operations = require('./enums')['operations-supported']; | ||
const cupsOperations = require('./enums')['cups-operations-supported']; | ||
const statusCodes = require('./statusCodes'); | ||
@@ -338,3 +339,3 @@ const tags = require('./tags'); | ||
write2(versions[msg.version || '2.0']); | ||
write2(msg.operation ? operations[msg.operation] : statusCodes[msg.statusCode]); | ||
write2(msg.operation ? operations[msg.operation] || cupsOperations[msg.operation] : statusCodes[msg.statusCode]); | ||
@@ -341,0 +342,0 @@ // request-id |
{ | ||
"name": "@sealsystems/ipp", | ||
"version": "2.0.9", | ||
"version": "2.0.11", | ||
"description": "Internet Printing Protocol (IPP) for nodejs", | ||
"keywords": ["ipp", "print", "printing"], | ||
"keywords": [ | ||
"ipp", | ||
"print", | ||
"printing" | ||
], | ||
"scripts": { | ||
@@ -7,0 +11,0 @@ "bot": "bot", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
148195
17
4038
3