UNPKG

emvco-qr-sdk

Version:

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

47 lines (46 loc) 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TagNameResolverUtil = void 0; const colombia_subtags_map_1 = require("../../config/qr-mapping/colombia-subtags.map"); const colombia_tags_map_1 = require("../../config/qr-mapping/colombia-tags.map"); const standard_tags_map_1 = require("../../config/qr-mapping/standard-tags.map"); /** * Utility class for resolving tag and subtag names based on region. * * This resolver provides name translations for TLV tag identifiers, * supporting both the EMVCo standard set and Colombian QR extensions. */ class TagNameResolverUtil { /** * Resolves a tag to its EMVCo standard field name. * * @param tag - A 2-character TLV tag. * @returns A human-readable name for the tag, or the raw tag if not found. */ static getStandardName(tag) { var _a; return (_a = standard_tags_map_1.STANDARD_TAG_NAMES[tag]) !== null && _a !== void 0 ? _a : tag; } /** * Resolves a tag to its Colombian-specific field name. * * @param tag - A 2-character TLV tag. * @returns A mapped field name for the Colombian format, or the raw tag if not found. */ static getColombianName(tag) { var _a; return (_a = colombia_tags_map_1.COLOMBIA_TAG_NAMES[tag]) !== null && _a !== void 0 ? _a : tag; } /** * Resolves a subtag within a parent tag according to the Colombian QR spec. * * @param tag - The parent tag (e.g., "26", "49"). * @param subtag - The subfield tag (e.g., "00", "01"). * @returns The subfield name, or the raw subtag if not mapped. */ static getColombianSubtagName(tag, subtag) { var _a, _b; return (_b = (_a = colombia_subtags_map_1.COLOMBIA_SUBTAG_NAMES[tag]) === null || _a === void 0 ? void 0 : _a[subtag]) !== null && _b !== void 0 ? _b : subtag; } } exports.TagNameResolverUtil = TagNameResolverUtil;