emvco-qr-sdk
Version:
A robust TypeScript SDK for decoding, validating, and processing EMVCo-compliant QR codes used in digital payment systems.
34 lines (33 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.genericGuiStrategy = void 0;
const tag_name_resolver_util_1 = require("../../utils/resolvers/tag-name-resolver.util");
/**
* Mapping strategy for TLV tags that contain generic GUI-based subfields.
*
* This strategy is used for tags that follow the [GUI, value] pattern in their subtags,
* such as tags 50, 51, 81–85, 90, 91, and 99. It uses the Colombian subtag dictionary
* to resolve meaningful names for each subfield.
*
* Example output:
* ```ts
* {
* gui: "CO.COM.CRB.RED",
* vatCondition: "02",
* vatValueOrPercentage: "10.00"
* }
* ```
*
* @param tlv - The TLV entity to map.
* @returns An object where subtag keys are replaced with named fields and mapped values.
*/
const genericGuiStrategy = (tlv) => {
var _a;
const result = {};
for (const sub of (_a = tlv.subTags) !== null && _a !== void 0 ? _a : []) {
const key = tag_name_resolver_util_1.TagNameResolverUtil.getColombianSubtagName(tlv.tag, sub.tag);
result[key] = sub.value;
}
return result;
};
exports.genericGuiStrategy = genericGuiStrategy;