
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
eup-ipp-encoder
Advanced tools
一个轻量级、专注的互联网打印协议(IPP)编码器和解码器库。
本库致力于提供纯净的IPP消息序列化和反序列化功能,专注于做好编码和解码的核心工作,不包含任何无关的辅助功能。
本项目基于 watson/ipp-encoder 改造优化而来
npm install eup-ipp-encoder
以下是一个简单的打印机服务器场景示例:
import * as ipp from 'eup-ipp-encoder'
// 解码来自IPP客户端的二进制请求
const decoded = ipp.decoder.decodeRequest(buf)
// ...在这里处理客户端请求...
// 准备响应数据
const response: ipp.IPPResponse = {
statusCode: 0x00, // 如果是编码请求,则使用 `operationId` 替代
requestId: decoded.requestId,
groups: [
{
tag: 0x01, // OPERATION_ATTRIBUTES_TAG
attributes: [
{ tag: 0x21, name: 'job-id', value: [147] },
{ tag: 0x36, name: 'job-name', value: [{ lang: 'en-us', value: 'Foobar' }] }
]
}
]
}
// 将响应编码为二进制缓冲区
ipp.encoder.encode(response) // 返回 <Buffer 01 01 00 00 ... >
ipp.decoder.decodeRequest(buffer[, start][, end])将IPP请求的二进制缓冲区解码为结构化的JavaScript对象。
参数说明:
buffer - 包含IPP请求数据的二进制缓冲区start - 可选参数,指定解码的起始偏移位置(默认值:0)end - 可选参数,指定解码的结束偏移位置(默认值:buffer.length)返回的请求对象结构:
{
version: {
major: 1, // IPP协议主版本号
minor: 1 // IPP协议次版本号
},
operationId: 0x02, // IPP操作标识符
requestId: 1, // 请求ID
groups: [ // 属性组数组
{
tag: 0x01, // OPERATION_ATTRIBUTES_TAG
attributes: [ // 属性列表
{ tag: 0x21, name: 'job-id', value: [147] },
{ tag: 0x36, name: 'job-name', value: [{ lang: 'en-us', value: 'Foobar' }] },
{ tag: 0x22, name: 'ipp-attribute-fidelity', value: [true] }
]
}
]
}
ipp.decoder.decodeResponse(buffer[, start][, end])与 decodeRequest() 方法用法完全相同,但专门用于解码IPP响应消息。
ipp.encoder.encode(obj[, buffer][, offset])将结构化的IPP请求或响应对象编码为二进制缓冲区。
参数说明:
obj - 要编码的IPP请求或响应对象buffer - 可选参数,用于存储编码后数据的目标缓冲区offset - 可选参数,指定在目标缓冲区中的写入起始位置(默认值:0)响应对象示例结构:
{
statusCode: 0x00, // 响应状态码(请求使用operationId)
requestId: 1, // 请求ID(与对应的请求保持一致)
groups: [ // 属性组数组
{
tag: 0x01, // OPERATION_ATTRIBUTES_TAG
attributes: [ // 属性列表
{ tag: 0x21, name: 'job-id', value: [147] },
{ tag: 0x22, name: 'ipp-attribute-fidelity', value: [true] },
{ tag: 0x36, name: 'job-name', value: [{ lang: 'en-us', value: 'Foobar' }] }
]
}
]
}
提示:可以在请求或响应对象中指定自定义IPP版本(格式与上述示例中的version字段相同),默认使用IPP 1.1版本。
ipp.encoder.encodingLength(obj)计算编码指定IPP请求或响应对象所需的字节数,用于预先分配合适大小的缓冲区。
本库支持以下IPP标签的编码和解码功能:
分隔符标签用于组织属性组:
OPERATION_ATTRIBUTES_TAG (0x01) - 操作属性组标签JOB_ATTRIBUTES_TAG (0x02) - 作业属性组标签END_OF_ATTRIBUTES_TAG (0x03) - 属性组结束标签值类型标签用于标识属性值的数据类型:
INTEGER (0x21) - 整数类型BOOLEAN (0x22) - 布尔类型ENUM (0x23) - 枚举类型DATE_TIME (0x31) - 日期时间类型TEXT_WITH_LANG (0x35) - 带语言信息的文本NAME_WITH_LANG (0x36) - 带语言信息的名称KEYWORD (0x44) - 关键字类型MIT
FAQs
Internet Printing Protocol (IPP) encoder and decoder
We found that eup-ipp-encoder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.