{"library":"node-tlv","title":"TLV Parser for Node.js","description":"The `node-tlv` library provides a robust parser and builder for Tag-Length-Value (TLV) encoded data, commonly found in smart card protocols like EMV and ISO7816. It supports parsing both simple TLV and BER-TLV structures, allowing developers to extract and manipulate data elements such as DGI, EMV, ISO7816, and DOL tags. Currently at stable version 1.5.14, the package does not explicitly state a release cadence, but its versioning and continuous updates suggest ongoing maintenance. Its key differentiator lies in its focused support for financial and smart card industry standards, offering both parsing of raw hexadecimal strings into structured TLV objects and the ability to programmatically construct complex TLV hierarchies, useful for building responses like PPSE FCI or PSE records. It is designed for Node.js environments, providing a programmatic interface to navigate and construct TLV data structures.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install node-tlv"],"cli":null},"imports":["const TLV = require('node-tlv');","const TLV = require('node-tlv');\nconst parsedTlv = TLV.parse('770E82025800...');","const TLV = require('node-tlv');\nconst newTlv = new TLV('84', '325041592E5359532E4444463031');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const TLV = require('node-tlv');\nconst assert = require('assert');\n\n// A sample GPO (Get Processing Options) response in hex string format.\nconst resp = '770E8202580094080801010010010301';\n\n// Parse the raw hexadecimal string into a TLV object tree.\nconst tlv = TLV.parse(resp);\n\n// Assertions to verify the top-level TLV object's tag, length, and value.\nassert(tlv.getTag() === '77');\nassert(tlv.getLength() === 14); // Length in bytes for the value '8202580094080801010010010301'\nassert(tlv.getValue() === '8202580094080801010010010301');\n\n// Retrieve child TLV objects from the parsed structure.\nconst child = tlv.getChild();\nassert(child.length === 2);\nassert(child[0].getTag() === '82');\n\n// Find a specific TLV tag using either a number or string representation.\nconst aip = tlv.find(0x82); // Application Interchange Profile (AIP)\nassert(aip.getTag() === '82');\nassert(aip.getLength() === 2);\nassert(aip.getValue() === '5800');\n\nconst afl = tlv.find('94'); // Application File Locator (AFL)\nassert(afl.getTag() === '94');\nassert(afl.getLength() === 8);\nassert(afl.getValue() === '0801010010010301');","lang":"javascript","description":"This quickstart demonstrates how to parse a raw hexadecimal string containing TLV data into a structured object, navigate its child elements, and find specific tags by their hexadecimal value or string representation, crucial for EMV transaction processing.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}