emvco-qr-sdk
Version:
A robust TypeScript SDK for decoding, validating, and processing EMVCo-compliant QR codes used in digital payment systems.
32 lines (31 loc) • 1.52 kB
TypeScript
import { TlvEntity } from '../../domain/entities/tlv.entity';
import { SubtagNameResolver, TagNameResolver } from '../types/tag-resolver.type';
/**
* Provides a static mapping function to transform TLV entities into
* human-readable key-value objects using tag names and mapping strategies.
*
* This mapper supports region-specific logic (e.g., Colombia, Global),
* and resolves tag/subtag names into meaningful labels.
*/
export declare class NamedFieldsMapper {
/**
* Maps an array of TLV entities into a flat object with named keys.
* For each TLV entity, it determines if a mapping strategy exists
* for the region and applies it, otherwise it attempts generic subtag mapping
* or uses the raw value.
*
* @param tlvs - List of TLV entities to be mapped.
* @param resolveTagName - Function that resolves tag IDs to human-readable keys.
* @param resolveSubtagName - (Optional) Function that resolves subtag IDs to keys (used if subtags are present).
* @returns An object with resolved keys and values for each TLV.
*/
static map(tlvs: TlvEntity[], resolveTagName: TagNameResolver, resolveSubtagName?: SubtagNameResolver): Record<string, any>;
/**
* Determines the current region (CO, GLOBAL, or DEFAULT) based on
* the resolver function provided. This affects how tags are mapped.
*
* @param resolveTagName - Resolver used to identify tag names.
* @returns The matching region code.
*/
private static resolveRegion;
}