lcs-usbtoken
v1.3.0
Published
Get usb token and sign over websocket
Downloads
58
Readme
LCS GET USB TOKEN AND SIGN OVER WEBSOCKET
Installation
$ npm i lcs-usbtoken
Usage
Require the module with:
const client = require('lcs-usbtoken');
Connect to websocket connectWs
:
- Example:
client.connectWs(url, callback);
Check websocket still connected by healthcheck
:
Destination:
/healthcheck
Input:
NONE
Output:
True/False
Example:
client.healthcheck(url, callback);
Check USB Token PIN by checkLogin
Destination:
/checkLogin
Input:
{ "tokenSerial":"ABCxxxxxxxxxxxxx", "tokenPin":"123123123", "listUid":[], "certSerial":"", "version":"1.0.0" }
Output:
- Success:
{ "tokenUsb": null, "msgCode": "SUCCESS", "msg": "Thành công", "status": 1 }
- Failure:
- Incorrect PIN:
{ "tokenUsb": null, "msgCode": "CKR_PIN_INCORRECT", "msg": "Sai mã số PIN!", "status": 0 }
- USB Serial Token not match:
{ "tokenUsb": null, "msgCode": "SERIAL_USB_NOT_MATCH", "msg": "Serial usb token không trùng với đã chọn", "status": 0 }
- Success:
Get USB Token by getUsbToken
:
Get USB Token by exactly tokenSerial:
Destination:
/getUsbToken
Input:
{ "GetUsbToken":{ "tokenSerial":"ABCxxxxxxxxxxxxx", "version":"1.0.0" } }
Output:
Success:
{ "listTokenUsb": [ { "libName": "C:\\WINDOWS\\system32\\LCS-CAv2.0.dll", "slot": 1, "tokenName": "LCS-CA Token v2.0", "tokenSerial": "LCS2004A00000000", "pinCountLow": false, "pinFinalTry": false, "pinLocked": false } ], "msgCode": "SUCCESS", "msg": "Thành công", "status": 1 }
Failure:
{ "listTokenUsb": null, "msgCode": "SERIAL_USB_NOT_MATCH", "msg": "Serial usb token không trùng với đã chọn", "status": 0 }
Get USB Token list:
Destination:
/getUsbToken
Input:
{ "GetUsbToken":{ "tokenSerial":"", "version":"1.0.0" } }
Output:
{ "listTokenUsb": [ { "libName": "C:\\WINDOWS\\system32\\LCS-CAv2.0.dll", "slot": 1, "tokenName": "LCS-CA Token v2.0", "tokenSerial": "LCS2004A00000068", "pinCountLow": false, "pinFinalTry": false, "pinLocked": false }, { "libName": "C:\\WINDOWS\\system32\\LCS-CAv3.0.dll", "slot": 2, "tokenName": "LCS-CA Token v2.0", "tokenSerial": "LCS2004A00000069", "pinCountLow": false, "pinFinalTry": false, "pinLocked": false } ], "msgCode": "SUCCESS", "msg": "Thành công", "status": 1 }
Example:
client.getUsbToken(url, params, callback);
Get USB Token by signDoc
:
Destination:
/signDoc
Input: documentBase64 is contain base64 of pdf file.
{ "tokenInfoDto": { "tokenSerial": "LCS2004A00000000", "tokenPin": "12312312", "version": "1.0.0" }, "dataList": [{"originalFileName": "example.pdf", "documentBase64": "pdfBase64", "mimeType": "application/pdf"}], "cmd": { "signerName": "", "signerLocation": "Ho Chi Minh", "signatureReason": "I agree the agreement", "signingHints": { "showSignatureImage": true, "location": "LAST_PAGE", "x": 0.0, "y": 0.0, "width": 233, "height": 64, "marginX": 121, "marginY": 25, "fieldName": "VPB_FC", "signaturePosition": "BOTTOM_RIGHT" }, "signerType": "O" } }
Output:
Success:
{ "code": "SUCCESS", "msg": "Thành công", "status": 1, "resultData": [{ "code": "sucessed", "msg": "sucessed", "resultData": "", "mimeType": "application/pd" }] }
Failure:
Incorrect PIN:
{ "code": "CKR_PIN_INCORRECT", "msg": "Sai mã số PIN!", "resultData": null, "status": 0 }
USB Token Not match:
{ "code": "SERIAL_USB_NOT_MATCH", "msg": "Serial usb token không trùng với đã chọn", "resultData": null, "status": 0 }
Sign Failed:
{ "code": "", "msg": "Không tim thấy cert hợp lệ", "resultData": null, "status": 0 }
Test mode
Insert "TEST" to enable this mode after callback function. For example:
client.connectWs(url, callback, true);
client.getUsbToken(url, params, callback, true);