UNPKG

emvco-qr-sdk

Version:

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

21 lines (20 loc) 798 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidTLVFormat = isValidTLVFormat; const tag_1 = require("../../../domain/value-objects/tag"); /** * Checks if a string appears to be in a valid TLV format (superficial validation). * * This does NOT guarantee the entire structure is valid — it only checks the initial pattern. * * @param tlv - The raw string to validate. * @returns True if the string starts with a valid TLV structure, false otherwise. */ function isValidTLVFormat(tlv) { if (!tlv || tlv.length < 4) return false; const tag = tlv.substring(0, 2); const lengthStr = tlv.substring(2, 4); const length = parseInt(lengthStr, 10); return tag_1.Tag.isValid(tag) && !isNaN(length) && 4 + length <= tlv.length; }