1.3.0 • Published 1 year ago

lcs-usbtoken v1.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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:
        ```json
        {
          "tokenUsb": null, 
          "msgCode": "SERIAL_USB_NOT_MATCH", 
          "msg": "Serial usb token không trùng với đã chọn",
          "status": 0
        }

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);
1.2.0

1 year ago

1.2.8

1 year ago

1.1.9

1 year ago

1.2.7

1 year ago

1.1.8

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.9

1 year ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago