idmission-web-sdk 2.3.177-feature-barcode-client-scan-a7b73a2 → 2.3.177-feature-barcode-client-scan-e5cc362

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ export type ParsedAAMVAField = {
10
10
  export type ParsedAAMVAData = {
11
11
  fields: ParsedAAMVAField[];
12
12
  rawData: string;
13
- version?: string;
13
+ aamvaVersion?: number;
14
14
  jurisdictionId?: string;
15
15
  };
16
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AAMVAParser.d.ts","sourceRoot":"","sources":["../../../src/lib/barcode/AAMVAParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+FH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,gBAAgB,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AA4DD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAgDlE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAGpB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAM3D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAW9D;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,C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AAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,iBAAiB,CAAA;CAC1B,CAAA;AAcD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CA0E9E"}
@@ -9951,6 +9951,8 @@ var AAMVA_FIELD_LABELS = {
9951
9951
  DCS: 'Last Name',
9952
9952
  DAC: 'First Name',
9953
9953
  DAD: 'Middle Name',
9954
+ DAA: 'Full Name',
9955
+ // Older AAMVA versions (1-3) use this instead of separate name fields
9954
9956
  DBB: 'Date of Birth',
9955
9957
  DBC: 'Sex',
9956
9958
  DAY: 'Eye Color',
@@ -10034,22 +10036,36 @@ var HAIR_COLOR_CODES = {
10034
10036
  UNK: 'Unknown'
10035
10037
  };
10036
10038
  /**
10037
- * Formats a date string from AAMVA format (MMDDYYYY) to readable format
10039
+ * Formats a date string from AAMVA format to readable format (MM/DD/YYYY).
10040
+ * AAMVA versions 1-3 use YYYYMMDD (CCYYMMDD) format.
10041
+ * AAMVA versions 4+ use MMDDYYYY (MMDDCCYY) format.
10038
10042
  */
10039
- function formatDate(value) {
10043
+ function formatDate(value, aamvaVersion) {
10040
10044
  if (value.length !== 8) return value;
10041
- var month = value.substring(0, 2);
10042
- var day = value.substring(2, 4);
10043
- var year = value.substring(4, 8);
10045
+ // AAMVA versions 1-3 (pre-2000) use YYYYMMDD format
10046
+ // AAMVA versions 4+ (2000 onwards) use MMDDYYYY format
10047
+ var usesYYYYMMDD = aamvaVersion !== undefined && aamvaVersion <= 3;
10048
+ var month, day, year;
10049
+ if (usesYYYYMMDD) {
10050
+ // YYYYMMDD format (older versions)
10051
+ year = value.substring(0, 4);
10052
+ month = value.substring(4, 6);
10053
+ day = value.substring(6, 8);
10054
+ } else {
10055
+ // MMDDYYYY format (newer versions, default)
10056
+ month = value.substring(0, 2);
10057
+ day = value.substring(2, 4);
10058
+ year = value.substring(4, 8);
10059
+ }
10044
10060
  return "".concat(month, "/").concat(day, "/").concat(year);
10045
10061
  }
10046
10062
  /**
10047
10063
  * Formats a value based on its field code
10048
10064
  */
10049
- function formatValue$1(code, value) {
10065
+ function formatValue$1(code, value, aamvaVersion) {
10050
10066
  // Date fields
10051
10067
  if (['DBB', 'DBD', 'DBA', 'DDB', 'DDC', 'DDH', 'DDI', 'DDJ'].includes(code)) {
10052
- return formatDate(value);
10068
+ return formatDate(value, aamvaVersion);
10053
10069
  }
10054
10070
  // Sex field
10055
10071
  if (code === 'DBC') {
@@ -10081,6 +10097,77 @@ function formatValue$1(code, value) {
10081
10097
  }
10082
10098
  return value.trim();
10083
10099
  }
10100
+ /**
10101
+ * Extracts the AAMVA version from the barcode header.
10102
+ * Header format: ANSI <IIN(6 digits)><AAMVA Version(2 digits)><Jurisdiction Version(2 digits)>...
10103
+ * Returns undefined if version cannot be determined.
10104
+ */
10105
+ function extractAAMVAVersion(rawData) {
10106
+ // Match ANSI followed by at least 8 digits (6 for IIN + 2 for version)
10107
+ var headerMatch = rawData.match(/ANSI\s*(\d{6})(\d{2})/);
10108
+ if (headerMatch) {
10109
+ var version = parseInt(headerMatch[2], 10);
10110
+ // Valid AAMVA versions are 1-99 (realistically 1-10 as of 2024)
10111
+ if (version >= 1 && version <= 99) {
10112
+ return version;
10113
+ }
10114
+ }
10115
+ return undefined;
10116
+ }
10117
+ /**
10118
+ * Parses the DAA field (full name) used in older AAMVA versions.
10119
+ * Format is typically "LAST,FIRST,MIDDLE" or "LAST,FIRST MIDDLE".
10120
+ * Returns an array of ParsedAAMVAField for LastName, FirstName, and MiddleName.
10121
+ */
10122
+ function parseDAAField(value) {
10123
+ var fields = [];
10124
+ // DAA format is typically "LASTNAME,FIRSTNAME,MIDDLENAME" or "LASTNAME,FIRSTNAME MIDDLENAME"
10125
+ // Some jurisdictions use spaces instead of commas
10126
+ var parts = value.split(',').map(function (p) {
10127
+ return p.trim();
10128
+ });
10129
+ if (parts.length >= 1 && parts[0]) {
10130
+ fields.push({
10131
+ code: 'DCS',
10132
+ label: 'Last Name',
10133
+ value: parts[0]
10134
+ });
10135
+ }
10136
+ if (parts.length >= 2 && parts[1]) {
10137
+ // The second part might contain "FIRSTNAME MIDDLENAME"
10138
+ var nameParts = parts[1].split(/\s+/);
10139
+ if (nameParts[0]) {
10140
+ fields.push({
10141
+ code: 'DAC',
10142
+ label: 'First Name',
10143
+ value: nameParts[0]
10144
+ });
10145
+ }
10146
+ // If there's more after the first name, treat it as middle name
10147
+ if (nameParts.length > 1) {
10148
+ fields.push({
10149
+ code: 'DAD',
10150
+ label: 'Middle Name',
10151
+ value: nameParts.slice(1).join(' ')
10152
+ });
10153
+ }
10154
+ }
10155
+ // If there's a third comma-separated part, it's the middle name
10156
+ if (parts.length >= 3 && parts[2]) {
10157
+ // Check if we already added a middle name from the second part
10158
+ var existingMiddle = fields.find(function (f) {
10159
+ return f.code === 'DAD';
10160
+ });
10161
+ if (!existingMiddle) {
10162
+ fields.push({
10163
+ code: 'DAD',
10164
+ label: 'Middle Name',
10165
+ value: parts[2]
10166
+ });
10167
+ }
10168
+ }
10169
+ return fields;
10170
+ }
10084
10171
  /**
10085
10172
  * Parses AAMVA PDF417 barcode data into structured fields
10086
10173
  */
@@ -10089,6 +10176,13 @@ function parseAAMVABarcode(rawData) {
10089
10176
  fields: [],
10090
10177
  rawData: rawData
10091
10178
  };
10179
+ // Extract AAMVA version first - needed for date format detection
10180
+ result.aamvaVersion = extractAAMVAVersion(rawData);
10181
+ // Extract jurisdiction ID from header
10182
+ var headerMatch = rawData.match(/ANSI\s*(\d{6})/);
10183
+ if (headerMatch) {
10184
+ result.jurisdictionId = headerMatch[1];
10185
+ }
10092
10186
  // Clean up the data - remove control characters but keep newlines for parsing
10093
10187
  // AAMVA uses various separators: \n, \r, record separator (0x1E), etc.
10094
10188
  // eslint-disable-next-line no-control-regex
@@ -10101,6 +10195,13 @@ function parseAAMVABarcode(rawData) {
10101
10195
  });
10102
10196
  // Extract fields using regex - AAMVA fields are 3-letter codes followed by data
10103
10197
  var fieldRegex = /^([A-Z]{3})(.*)$/;
10198
+ // Track if we've seen separate name fields (DCS, DAC, DAD)
10199
+ var hasSeenNameFields = {
10200
+ DCS: false,
10201
+ DAC: false,
10202
+ DAD: false
10203
+ };
10204
+ var daaValue = null;
10104
10205
  for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
10105
10206
  var line = lines_1[_i];
10106
10207
  var match = line.match(fieldRegex);
@@ -10110,8 +10211,17 @@ function parseAAMVABarcode(rawData) {
10110
10211
  var value = rawValue.trim();
10111
10212
  // Skip empty values and header/version info
10112
10213
  if (!value || code === 'ANS') continue;
10214
+ // Track name fields
10215
+ if (code === 'DCS' || code === 'DAC' || code === 'DAD') {
10216
+ hasSeenNameFields[code] = true;
10217
+ }
10218
+ // Store DAA value for later processing (in case no separate name fields exist)
10219
+ if (code === 'DAA') {
10220
+ daaValue = value;
10221
+ continue; // Don't add DAA directly, we'll process it below
10222
+ }
10113
10223
  var label = AAMVA_FIELD_LABELS[code] || code;
10114
- var formattedValue = formatValue$1(code, value);
10224
+ var formattedValue = formatValue$1(code, value, result.aamvaVersion);
10115
10225
  result.fields.push({
10116
10226
  code: code,
10117
10227
  label: label,
@@ -10119,10 +10229,22 @@ function parseAAMVABarcode(rawData) {
10119
10229
  });
10120
10230
  }
10121
10231
  }
10122
- // Try to extract version and jurisdiction from header
10123
- var headerMatch = rawData.match(/ANSI\s*(\d+)/);
10124
- if (headerMatch) {
10125
- result.jurisdictionId = headerMatch[1].substring(0, 6);
10232
+ // If we have a DAA field and are missing any separate name fields, parse DAA
10233
+ if (daaValue && (!hasSeenNameFields.DCS || !hasSeenNameFields.DAC)) {
10234
+ var daaFields = parseDAAField(daaValue);
10235
+ var _loop_1 = function _loop_1(field) {
10236
+ // Only add if we don't already have this field
10237
+ var existingField = result.fields.find(function (f) {
10238
+ return f.code === field.code;
10239
+ });
10240
+ if (!existingField) {
10241
+ result.fields.push(field);
10242
+ }
10243
+ };
10244
+ for (var _a = 0, daaFields_1 = daaFields; _a < daaFields_1.length; _a++) {
10245
+ var field = daaFields_1[_a];
10246
+ _loop_1(field);
10247
+ }
10126
10248
  }
10127
10249
  return result;
10128
10250
  }