UNPKG

emvco-qr-sdk

Version:

A robust TypeScript SDK for decoding, validating, and processing EMVCo-compliant QR codes used in digital payment systems.

26 lines (25 loc) 1.21 kB
import { TlvEntity } from '../entities/tlv.entity'; /** * Service responsible for parsing a raw TLV-encoded string into structured `TlvEntity` objects. * * Supports recursive parsing of nested TLVs (e.g., value fields that themselves contain TLV structures), * commonly used in QR codes that follow the EMVCo standard. */ export declare class TlvParserService { /** * Parses a TLV-encoded string into a list of `TlvEntity` instances. * * The TLV (Tag-Length-Value) format assumes that: * - Each tag is 2 characters long. * - Each length is 2 characters, representing the length of the value in characters. * - The value follows the length field, and may itself be recursively parsed as a TLV string. * * @param tlvString - The raw TLV-encoded string. * @param recursive - Whether to recursively parse value fields that are TLV-encoded. Defaults to `true`. * * @returns An array of parsed `TlvEntity` objects representing the structure of the input string. * * @throws {Error} If the input string is invalid (e.g., incomplete, malformed length, or overflows). */ static parse(tlvString: string, recursive?: boolean): TlvEntity[]; }