Constructor
new Cos7816(cpuCosReader)
构造Cos7816操作对象
Name | Type | Description |
---|---|---|
cpuCosReader | CpuCosTypeA | | CPU-COS读卡器操作对象 |
- Source
Members
(static, readonly) KeyAlg :number
COS密钥算法
- number
Name | Type | Description |
---|---|---|
NONE | number | 无效未设置 |
PIN | number | 密码大小必须2~8字节之间 |
DES | number | 密钥大小必须8或16字节 |
- Source
(static, readonly) LogIdMode :number
记录文件ID模式选项
- number
Name | Type | Description |
---|---|---|
first | number | 匹配记录标识第一条 |
last | number | 匹配记录标识最后一条 |
down | number | 匹配记录标识下一条 |
up | number | 匹配记录标识上一条 |
number | number | 匹配记录编号 |
- Source
Methods
(async) addLog(sfid, data, safe) → {Promise}
追加写入一条新的记录
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
data | string | 写入的十六进制字符串数据 注意不能超过创建时定长记录大小 | |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval
- Type:
- Promise
(async) addTlv(sfid, tlvData, safe) → {Promise}
追加写入一条新的变长TLV记录
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
tlvData | TlvData | 写入的变长记录TLV格式数据 参考TlvData方法生成 | |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval
- Type:
- Promise
(async) auth(id, key) → {Promise}
外部认证授权
Name | Type | Description |
---|---|---|
id | number | 外部认证密钥标识ID 通常为0x00 |
key | KeyData | 密钥数据对象 参考KeyData方法生成 |
- Source
err/msg + retval
- Type:
- Promise
(async) calc(id, type, data) → {Promise}
内部认证运算
Name | Type | Description |
---|---|---|
id | number | 内部认证密钥标识ID |
type | number | 运算类型 通常为0x00=加密 0x01=解密 0x02=校验 |
data | string | 运算的十六进制字符串数据 |
- Source
err/msg + retval/data
- Type:
- Promise
getCpuId() → {number}
获取当前COS读卡器CPU协议ID
- Source
- Type:
- number
(async) rand(is32) → {Promise}
获取随机数
Name | Type | Default | Description |
---|---|---|---|
is32 | boolean | false | 默认false=8字节随机数 true=4字节随机数 |
- Source
err/msg + retval/data(十六进制字符串)
- Type:
- Promise
(async) readBin(sfid, pos, size, safe) → {Promise}
读普通文件数据
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
pos | number | 起始位置偏移量 如果sfid=0偏移最大0x7FFF否则最大0xFF | |
size | number | 0 | 指定读取的大小 默认0最大程度读取全部 |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval/data
- Type:
- Promise
(async) readLog(sfid, id, mode, size, safe) → {Promise}
读记录文件数据
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
id | number | 读取的记录编号或标识 如果为0x00则代表当前记录 | |
mode | LogIdMode | 记录ID模式 参考LogIdMode | |
size | number | 0 | 指定读取的大小 默认0最大程度读取全部 |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval/data
- Type:
- Promise
(async) readTlv(sfid, id, mode, size, safe) → {Promise}
读变长记录文件数据
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
id | number | 读取的记录编号或标识 如果为0x00则代表当前记录 | |
mode | LogIdMode | 记录ID模式 参考LogIdMode | |
size | number | 0 | 指定读取的大小 默认0最大程度读取全部 |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval/data(TlvData对象)
- Type:
- Promise
(async) selectAID(aid) → {Promise}
选择专用标识
Name | Type | Description |
---|---|---|
aid | string | 专用应用标识十六进制字符串 |
- Source
err/msg + retval/[fci={df/private/sfi/ver/tmp}(注意FCI每个字段都非必定存在)]
- Type:
- Promise
(async) selectFID(fid) → {Promise}
选择文件id
Name | Type | Description |
---|---|---|
fid | number | 文件标识符ID |
- Source
err/msg + retval/[fci={df/private/sfi/ver/tmp}(注意FCI每个字段都非必定存在)]
- Type:
- Promise
(async) selectName(name) → {Promise}
选择字符串文件名
Name | Type | Description |
---|---|---|
name | string | 字符串文件名称 |
- Source
err/msg + retval/[fci={df/private/sfi/ver/tmp}(注意FCI每个字段都非必定存在)]
- Type:
- Promise
setCpuCosReader(cpuCosReader)
重新设置CPU-COS读卡器操作对象
Name | Type | Description |
---|---|---|
cpuCosReader | CpuCosTypeA | | CPU-COS读卡器操作对象 |
- Source
(async) verify(id, pin) → {Promise}
验证用户口令PIN
Name | Type | Description |
---|---|---|
id | number | 口令密钥标识ID 通常为0x00 |
pin | string | 用户字符口令 |
- Source
err/msg + retval
- Type:
- Promise
(async) writeBin(sfid, pos, data, safe) → {Promise}
写普通文件数据
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
pos | number | 起始位置偏移量 如果sfid=0偏移最大0x7FFF否则最大0xFF | |
data | string | 写入的十六进制字符串数据 | |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval
- Type:
- Promise
(async) writeLog(sfid, id, mode, data, safe) → {Promise}
写记录文件数据
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
id | number | 写入位置的记录编号或标识 如果为0x00则代表当前记录 | |
mode | LogIdMode | 记录ID模式 参考LogIdMode | |
data | string | 写入的十六进制字符串数据 注意不能超过创建时定长记录大小 | |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval
- Type:
- Promise
(async) writeTlv(sfid, id, mode, tlvData, safe) → {Promise}
写变长TLV记录文件 注意已添加的TLV记录不能改变长度
Name | Type | Default | Description |
---|---|---|---|
sfid | number | 文件短标识符(0x01~0x1F) 0x00=当前打开的文件 | |
id | number | 写入位置的记录编号或标识 如果为0x00则代表当前记录 | |
mode | LogIdMode | 记录ID模式 参考LogIdMode | |
tlvData | TlvData | 写入的变长记录TLV格式数据 参考TlvData方法生成 | |
safe | RfSafe | null | 线路安全选项 参考RfSafe方法生成 默认忽略 |
- Source
err/msg + retval
- Type:
- Promise
(static) KeyData(param, alg, provider)
生成KeyData密钥数据对象参数
Name | Type | Description |
---|---|---|
param | string | 十六进制字符串密钥数据或自定义提供者字符串附加参数 |
alg | KeyAlg | 默认DES |
provider | string | 密钥算法运算提供程序回调 暂不支持自定义回调 默认空字符使用内置标准运算 |
- Source
(static) RfSafe(key, enc, mac)
生成RfSafe线路安全对象参数
Name | Type | Description |
---|---|---|
key | KeyData | 线路安全密钥 参考KeyData方法生成 |
enc | boolean | 安全选项-线路加密 |
mac | boolean | 安全选项-线路保护 |
- Source
(static) TlvData(tag, data)
生成TlvData变长记录数据对象
Name | Type | Description |
---|---|---|
tag | number | 记录标签 0x00~0xFF范围 |
data | string | 十六进制字符串数据 字节大小不可超过0xFA |
- Source
(static) dumpTlvData(tlvData)
获取TlvData变长记录数据对象原始十六进制数据
Name | Type | Description |
---|---|---|
tlvData | TlvData | 变长记录数据对象 |
- Source
(static) parseTlvData(data)
解析原始Tlv数据生成TlvData变长记录数据对象
Name | Type | Description |
---|---|---|
data | string | 十六进制字符串数据 |
- Source