@gwydion-id/icao-9303-models 0.1.0

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.
Files changed (62) hide show
  1. package/LICENSES/CC0-1.0.txt +121 -0
  2. package/LICENSES/LGPL-3.0-or-later.txt +304 -0
  3. package/README.md +79 -0
  4. package/package.json +17 -0
  5. package/package.json.license +3 -0
  6. package/src/digitalseal.js +234 -0
  7. package/src/digitalsealv3.js +359 -0
  8. package/src/digitalsealv4.js +369 -0
  9. package/src/index.js +41 -0
  10. package/src/mrvadocument.js +465 -0
  11. package/src/mrvadocumentwithvds3.js +559 -0
  12. package/src/mrvadocumentwithvds4.js +559 -0
  13. package/src/mrvbdocument.js +466 -0
  14. package/src/mrvbdocumentwithvds3.js +560 -0
  15. package/src/mrvbdocumentwithvds4.js +560 -0
  16. package/src/td1document.js +408 -0
  17. package/src/td1documentwithvds3.js +479 -0
  18. package/src/td1documentwithvds4.js +479 -0
  19. package/src/td2document.js +379 -0
  20. package/src/td2documentwithvds3.js +466 -0
  21. package/src/td2documentwithvds4.js +466 -0
  22. package/src/td3document.js +391 -0
  23. package/src/td3documentwithvds3.js +466 -0
  24. package/src/td3documentwithvds4.js +466 -0
  25. package/src/traveldocument.js +306 -0
  26. package/src/utilities/bytes-to-date.js +23 -0
  27. package/src/utilities/c40-decode.js +225 -0
  28. package/src/utilities/c40-encode.js +254 -0
  29. package/src/utilities/c40-shift1.js +10 -0
  30. package/src/utilities/date-to-bytes.js +38 -0
  31. package/src/utilities/der-length-to-length.js +33 -0
  32. package/src/utilities/expand-year.js +26 -0
  33. package/src/utilities/gender-marker-to-mrz.js +14 -0
  34. package/src/utilities/generate-mrz-check-digit.js +139 -0
  35. package/src/utilities/icao-date.js +234 -0
  36. package/src/utilities/length-to-der-length.js +41 -0
  37. package/src/utilities/nationality-codes.js +303 -0
  38. package/src/utilities/normalize-mrz-string.js +19 -0
  39. package/src/utilities/optional-data-mrz.js +29 -0
  40. package/src/utilities/pad-mrz-string.js +16 -0
  41. package/src/utilities/set-signature-zone.js +34 -0
  42. package/src/utilities/stringify-validation-array.js +27 -0
  43. package/src/utilities/validate-hex-string.js +41 -0
  44. package/src/utilities/validate-identifier-code.js +38 -0
  45. package/src/utilities/validate-mrz-string.js +44 -0
  46. package/src/utilities/vds-magic.js +9 -0
  47. package/src/utilities/vds-signature-marker.js +9 -0
  48. package/src/utilities/vds-version-3.js +9 -0
  49. package/src/utilities/vds-version-4.js +9 -0
  50. package/src/visadocument.js +114 -0
  51. package/tests/models/digitalsealv4.test.js +67 -0
  52. package/tests/models/mrvadocument.test.js +61 -0
  53. package/tests/models/mrvbdocument.test.js +61 -0
  54. package/tests/models/td1document.test.js +50 -0
  55. package/tests/models/td2document.test.js +49 -0
  56. package/tests/models/td3document.test.js +88 -0
  57. package/tests/utilities/c40-encodation-scheme.test.js +34 -0
  58. package/tests/utilities/der-tlv-length-conversion.test.js +99 -0
  59. package/tests/utilities/document-utilities.test.js +199 -0
  60. package/tests/utilities/icao-constants.test.js +35 -0
  61. package/tests/utilities/icao-date.test.js +141 -0
  62. package/tests/utilities/vds-date-conversions.test.js +28 -0
@@ -0,0 +1,465 @@
1
+ // SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
2
+ // SPDX-License-Identifier: LGPL-3.0-or-later
3
+
4
+ import { TravelDocument } from "./traveldocument.js";
5
+ import { VisaDocument } from "./visadocument.js";
6
+ import { generateMRZCheckDigit } from "./utilities/generate-mrz-check-digit.js";
7
+ import { normalizeMRZString } from "./utilities/normalize-mrz-string.js";
8
+ import { optionalDataMRZ } from "./utilities/optional-data-mrz.js";
9
+ import { padMRZString } from "./utilities/pad-mrz-string.js";
10
+ import { genderMarkerToMRZ } from "./utilities/gender-marker-to-mrz.js";
11
+ import { IcaoDate } from "./utilities/icao-date.js";
12
+
13
+ /**
14
+ * Stores properties and methods for machine-readable visas (MRV-A) with
15
+ * machine-readable zones. These visas are used when additional information
16
+ * is placed on the visa sticker and clear zones along the visa sticker is
17
+ * unnecessary for the passport page.
18
+ *
19
+ * `MRVADocument` may be used on its own or may be used to compose different
20
+ * kinds of MRTDs.
21
+ */
22
+ export class MRVADocument {
23
+ /**
24
+ * Create a `MRVADocument`.
25
+ * @param { Object } [opt] - An options object.
26
+ * @param { string } [opt.typeCode] - A 1-2 character string consisting of the
27
+ * characters A-Z, 0-9, ' ', or <. 'A', 'I', 'P', or 'V' are recommended
28
+ * for the first character.
29
+ * @param { string } [opt.authorityCode] - A 3-character string consisting of
30
+ * the characters A-Z, 0-9, ' ', or <. A code from ISO-3166-1,
31
+ * ICAO 9303-3, or these user-assigned ranges are recommended: AAA-AAZ,
32
+ * QMA-QZZ, XAA-XZZ, or ZZA-ZZZ.
33
+ * @param { string } [opt.number] - A string no longer than 9 characters
34
+ * consisting of the characters A-Z, 0-9, ' ', or <.
35
+ * @param { string } [opt.primaryIdentifier] - The visa holder's primary
36
+ * identifier.
37
+ * @param { string | null } [opt.primaryIdentifierNative] - The visa
38
+ * holder's primary identifier in their native language.
39
+ * @param { string | null } [opt.secondaryIdentifer] - The visa holder's
40
+ * secondary identifier.
41
+ * @param { string | null } [opt.secondaryIdentifierNative] - The visa
42
+ * holder's secondary identifier in their native language.
43
+ * @param { string } [opt.nationalityCode] - A 3-character string consisting
44
+ * of the characters A-Z, 0-9, ' ', or <. A code from ISO-3166-1,
45
+ * ICAO 9303-3, or these user-assigned ranges are recommended: AAA-AAZ,
46
+ * QMA-QZZ, XAA-XZZ, or ZZA-ZZZ.
47
+ * @param { string | Date | IcaoDate } [opt.birthDate] - A calendar date string in
48
+ * YYYY-MM-DD format, a `Date` object, or an `IcaoDate` object.
49
+ * @param { 'F' | 'M' | 'X' } [opt.genderMarker] - The character 'F', 'M', or 'X'.
50
+ * @param { string | Date | IcaoDate } [opt.validThru] - A calendar date string in
51
+ * YYYY-MM-DD format, a `Date` object, or an `IcaoDate` object..
52
+ * @param { string } [opt.optionalData] - Up to 16 characters. Valid
53
+ * characters are from the ranges A-Z, 0-9, ' ', or <.
54
+ * @param { string } [opt.mrzLine1] - A MRZ line string of a 44-character
55
+ * length.
56
+ * @param { string } [opt.mrzLine2] - A MRZ line string of a 44-character
57
+ * length.
58
+ * @param { string } [opt.machineReadableZone] - A MRZ string of an
59
+ * 88-character length.
60
+ * @param { string | HTMLImageElement | SVGImageElement | HTMLVideoElement |
61
+ * HTMLCanvasElement | ImageBitmap | OffscreenCanvas |
62
+ * VideoFrame } [opt.photo] - A path/URL to an image, or an image object,
63
+ * representing a photo of the visa holder or an image from the issuing
64
+ * authority.
65
+ * @param { string | HTMLImageElement | SVGImageElement | HTMLVideoElement |
66
+ * HTMLCanvasElement | ImageBitmap | OffscreenCanvas |
67
+ * VideoFrame } [opt.signatureImage] - A path/URL to an image, or an image
68
+ * object, representing the signature or usual mark of the visa issuer.
69
+ * @param { string } [opt.placeOfIssue] - Location where the visa was issued.
70
+ * @param { string | Date | IcaoDate } [opt.validFrom] - A calendar date string in
71
+ * YYYY-MM-DD format, a `Date` object, or an `IcaoDate` object.
72
+ * @param { string | number } [opt.numberOfEntries] - 0 or any string denotes
73
+ * an unlimited number of entries.
74
+ * @param { string } [opt.visaType] - A type/name/description for this visa.
75
+ * @param { string } [opt.additionalInfo] - Additional textual information.
76
+ * @param { string } [opt.passportNumber] - A string no longer than 9
77
+ * characters consisting of the characters A-Z, 0-9, ' ', or <.
78
+ * @param { boolean } [opt.usePassportInMRZ] - Use `this.passportNumber`
79
+ * instead of `this.number` in the Machine-Readable Zone (MRZ).
80
+ */
81
+ constructor(opt) {
82
+ this.#document = new TravelDocument();
83
+ this.#visa = new VisaDocument();
84
+
85
+ this.typeCode = opt?.typeCode ?? "V";
86
+ this.authorityCode = opt?.authorityCode ?? "UTO";
87
+ this.number = opt?.number ?? "M12388954";
88
+ this.primaryIdentifier = opt?.primaryIdentifier ?? "Eriksson";
89
+ this.primaryIdentifierNative = opt?.primaryIdentifierNative ?? null;
90
+ this.secondaryIdentifier = opt?.secondaryIdentifier ?? null;
91
+ this.secondaryIdentifierNative = opt?.secondaryIdentifierNative ?? null;
92
+ this.nationalityCode = opt?.nationalityCode ?? "XXX";
93
+ this.birthDate = opt?.birthDate ?? "1974-08-12";
94
+ this.genderMarker = opt?.genderMarker ?? "F";
95
+ this.validThru = opt?.validThru ?? "1996-12-10";
96
+ this.optionalData = opt?.optionalData ?? "6ZE184226B";
97
+ this.placeOfIssue = opt?.placeOfIssue ?? "Zenith";
98
+ this.validFrom = opt?.validFrom ?? "1991-12-10";
99
+ this.numberOfEntries = opt?.numberOfEntries ?? "Multiple";
100
+ this.visaType = opt?.visaType ?? "Business Multiple";
101
+ this.additionalInfo = opt?.additionalInfo ?? "";
102
+ this.passportNumber = opt?.passportNumber ?? "L8988901C";
103
+ this.usePassportInMRZ = opt?.usePassportInMRZ ?? true;
104
+
105
+ if (opt?.photo) { this.photo = opt.photo; }
106
+ if (opt?.signatureImage) { this.signatureImage = opt.signatureImage; }
107
+ if (opt?.mrzLine1) { this.mrzLine1 = opt.mrzLine1; }
108
+ if (opt?.mrzLine2) { this.mrzLine2 = opt.mrzLine2; }
109
+ if (opt?.machineReadableZone) {
110
+ this.machineReadableZone = opt.machineReadableZone;
111
+ }
112
+ }
113
+
114
+ // The objects `MRVADocument` uses to compose itself.
115
+ #document;
116
+ #visa;
117
+
118
+ /**
119
+ * A code identifying the visa type.
120
+ * @type { string }
121
+ */
122
+ get typeCode() { return this.#document.typeCode; }
123
+ /**
124
+ * @param { string } value - A 1-2 character string consisting of the
125
+ * characters A-Z, 0-9, ' ', or <. 'A', 'I', 'P', or 'V' are recommended
126
+ * for the first character.
127
+ */
128
+ set typeCode(value) { this.#document.typeCode = value; }
129
+
130
+ /**
131
+ * A code identifying the authority who issued this visa.
132
+ * @type { string }
133
+ */
134
+ get authorityCode() { return this.#document.authorityCode; }
135
+ /**
136
+ * @param { string } value - A 3-character string consisting of the characters
137
+ * A-Z, 0-9, ' ', or <. A code from ISO-3166-1, ICAO 9303-3, or these
138
+ * user-assigned ranges are recommended: AAA-AAZ, QMA-QZZ, XAA-XZZ, or
139
+ * ZZA-ZZZ.
140
+ */
141
+ set authorityCode(value) { this.#document.authorityCode = value; }
142
+
143
+ /**
144
+ * An identity document number unique for this visa.
145
+ * @type { string }
146
+ */
147
+ get number() { return this.#document.number; }
148
+ /**
149
+ * @param { string } value - A string no longer than 9 characters consisting
150
+ * of the characters A-Z, 0-9, ' ', or <.
151
+ */
152
+ set number(value) { this.#document.number = value; }
153
+
154
+ /**
155
+ * The visa holder's primary identifier
156
+ * @type { string }
157
+ */
158
+ get primaryIdentifier() { return this.#document.primaryIdentifier; }
159
+ /**
160
+ * @param { string }
161
+ */
162
+ set primaryIdentifier(value) { this.#document.primaryIdentifier = value; }
163
+
164
+ /**
165
+ * The visa holder's primary identifier in their native language
166
+ * @type { string | null }
167
+ */
168
+ get primaryIdentifierNative() { return this.#document.primaryIdentifierNative; }
169
+ /**
170
+ * @param { string | null }
171
+ */
172
+ set primaryIdentifierNative(value) { this.#document.primaryIdentifierNative = value; }
173
+
174
+ /**
175
+ * The visa holder's secondary identifier
176
+ * @type { string | null }
177
+ */
178
+ get secondaryIdentifier() { return this.#document.secondaryIdentifier; }
179
+ /**
180
+ * @param { string | null }
181
+ */
182
+ set secondaryIdentifier(value) { this.#document.secondaryIdentifier = value; }
183
+
184
+ /**
185
+ * The visa holder's secondary identifier in their native language
186
+ * @type { string | null }
187
+ */
188
+ get secondaryIdentifierNative() { return this.#document.secondaryIdentifierNative; }
189
+ /**
190
+ * @param { string | null }
191
+ */
192
+ set secondaryIdentifierNative(value) { this.#document.secondaryIdentifierNative = value; }
193
+
194
+ /**
195
+ * A code identifying the visa holder's nationality (or lack thereof).
196
+ * @type { string }
197
+ */
198
+ get nationalityCode() { return this.#document.nationalityCode; }
199
+ /**
200
+ * @param { string } value - A 3-character string consisting of the characters
201
+ * A-Z, 0-9, ' ', or <. A code from ISO-3166-1, ICAO 9303-3, or these
202
+ * user-assigned ranges are recommended: AAA-AAZ, QMA-QZZ, XAA-XZZ, or
203
+ * ZZA-ZZZ.
204
+ */
205
+ set nationalityCode(value) { this.#document.nationalityCode = value; }
206
+
207
+ /**
208
+ * The visa holder's date of birth.
209
+ * @type { IcaoDate }
210
+ */
211
+ get birthDate() { return this.#document.birthDate; }
212
+ /**
213
+ * @param { string | Date | IcaoDate } value - A calendar date string in YYYY-MM-DD
214
+ * format, a `Date` object, or an `IcaoDate` object.
215
+ */
216
+ set birthDate(value) { this.#document.birthDate = value; }
217
+
218
+ /**
219
+ * A marker representing the visa holder's gender.
220
+ * @type { 'F' | 'M' | 'X' }
221
+ */
222
+ get genderMarker() { return this.#document.genderMarker; }
223
+ /**
224
+ * @param { 'F' | 'M' | 'X' } value - The character 'F', 'M', or 'X'.
225
+ */
226
+ set genderMarker(value) { this.#document.genderMarker = value; }
227
+
228
+ /**
229
+ * The last date on which this visa is valid.
230
+ * @type { IcaoDate }
231
+ */
232
+ get validThru() { return this.#document.expirationDate; }
233
+ /**
234
+ * @param { string | Date | IcaoDate } value - A calendar date string in YYYY-MM-DD
235
+ * format, a `Date` object, or an `IcaoDate` object.
236
+ */
237
+ set validThru(value) { this.#document.expirationDate = value; }
238
+
239
+ /**
240
+ * Optional data to include in the Machine-Readable Zone (MRZ).
241
+ * @type { string }
242
+ */
243
+ get optionalData() { return this.#document.optionalData; }
244
+ /**
245
+ * @param { string } value - Up to 16 characters. Valid characters are from
246
+ * the ranges A-Z, 0-9, ' ', or <.
247
+ */
248
+ set optionalData(value) { this.#document.optionalData = value; }
249
+
250
+ /**
251
+ * A path/URL to an image, or an image object, representing a photo of the
252
+ * visa holder or an image from the issuing authority.
253
+ * @type { string | HTMLImageElement | SVGImageElement | HTMLVideoElement |
254
+ * HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame }
255
+ */
256
+ get photo() { return this.#document.photo; }
257
+ /**
258
+ * @param { string | HTMLImageElement | SVGImageElement | HTMLVideoElement |
259
+ * HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame } value
260
+ */
261
+ set photo(value) { this.#document.photo = value; }
262
+
263
+ /**
264
+ * A path/URL to an image, or an image object, representing the signature or
265
+ * usual mark of the visa issuer.
266
+ * @type { string | HTMLImageElement | SVGImageElement | HTMLVideoElement |
267
+ * HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame }
268
+ */
269
+ get signatureImage() { return this.#document.signatureImage; }
270
+ /**
271
+ * @param { string | HTMLImageElement | SVGImageElement | HTMLVideoElement |
272
+ * HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame } value
273
+ */
274
+ set signatureImage(value) { this.#document.signatureImage = value; }
275
+
276
+ /**
277
+ * Location where the visa was issued.
278
+ * @type { string }
279
+ */
280
+ get placeOfIssue() { return this.#visa.placeOfIssue; }
281
+ /**
282
+ * @param { string } value
283
+ */
284
+ set placeOfIssue(value) { this.#visa.placeOfIssue = value; }
285
+
286
+ /**
287
+ * Starting date on which the visa is valid.
288
+ * @type { IcaoDate }
289
+ */
290
+ get validFrom() { return this.#visa.validFrom; }
291
+ /**
292
+ * @param { string | Date | IcaoDate } value - A calendar date string in YYYY-MM-DD
293
+ * format, a `Date` object, or an `IcaoDate` object.
294
+ */
295
+ set validFrom(value) { this.#visa.validFrom = value; }
296
+
297
+ /**
298
+ * Maximum number of entries this visa allows.
299
+ * @type { string }
300
+ */
301
+ get numberOfEntries() { return this.#visa.numberOfEntries; }
302
+ /**
303
+ * @param { string | number } value - 0 or any string denotes an unlimited
304
+ * number of entries.
305
+ */
306
+ set numberOfEntries(value) { this.#visa.numberOfEntries = value; }
307
+
308
+ /**
309
+ * The textual type/name/description for this visa.
310
+ * @type { string }
311
+ */
312
+ get visaType() { return this.#visa.visaType; }
313
+ /**
314
+ * @param { string } value
315
+ */
316
+ set visaType(value) { this.#visa.visaType = value; }
317
+
318
+ /**
319
+ * Additional textual information to include with this visa.
320
+ * @type { string }
321
+ */
322
+ get additionalInfo() { return this.#visa.additionalInfo; }
323
+ /**
324
+ * @param { string } value
325
+ */
326
+ set additionalInfo(value) { this.#visa.additionalInfo = value; }
327
+
328
+ /**
329
+ * The identity document number for which this visa is issued.
330
+ * @type { string }
331
+ */
332
+ get passportNumber() { return this.#visa.passportNumber; }
333
+ /**
334
+ * @param { string } value - A string no longer than 9 characters consisting
335
+ * of the characters A-Z, 0-9, ' ', or <.
336
+ */
337
+ set passportNumber(value) { this.#visa.passportNumber = value; }
338
+
339
+ /**
340
+ * Use `this.passportNumber` instead of `this.number` in the Machine-Readable
341
+ * Zone (MRZ).
342
+ * @type { boolean }
343
+ */
344
+ get usePassportInMRZ() { return this.#visa.usePassportInMRZ; }
345
+ /**
346
+ * @param { boolean } value
347
+ */
348
+ set usePassportInMRZ(value) { this.#visa.usePassportInMRZ = value; }
349
+
350
+ /**
351
+ * The first line of the Machine-Readable Zone (MRZ).
352
+ * @type { string }
353
+ */
354
+ get mrzLine1() {
355
+ return padMRZString(this.typeCode.replace(/\s/gi, "<"), 2) +
356
+ padMRZString(this.authorityCode.replace(/\s/gi, "<"), 3) +
357
+ padMRZString(
358
+ normalizeMRZString(this.primaryIdentifier) +
359
+ "<<" +
360
+ normalizeMRZString(this.secondaryIdentifier)
361
+ , 39);
362
+ }
363
+ /**
364
+ * @param { string } value - A MRZ line string of a 44-character length.
365
+ */
366
+ set mrzLine1(value) {
367
+ if (value.length !== 44) {
368
+ throw new RangeError(
369
+ `Length '${value.length}' does not match the length of a MRV-A ` +
370
+ `Machine-Readable Zone (MRZ) line.`
371
+ );
372
+ }
373
+ this.typeCode = value.slice(0, 2).replace(/</gi, "");
374
+ this.authorityCode = value.slice(2, 5).replace(/</gi, "");
375
+ const [primary, ...secondary] = value.slice(5).split("<<");
376
+ this.primaryIdentifier = primary.replace(/</gi, " ").trimEnd();
377
+ this.secondaryIdentifier = secondary.join("").replace(/</gi, " ").trimEnd();
378
+ }
379
+
380
+ /**
381
+ * The second line of the Machine-Readable Zone (MRZ).
382
+ * @type { string }
383
+ */
384
+ get mrzLine2() {
385
+ const MRZ_NUMBER = this.usePassportInMRZ ? padMRZString(
386
+ this.passportNumber.replace(/\s/gi, "<"), 9
387
+ ) : padMRZString(this.number.replace(/\s/gi, "<"), 9);
388
+ return MRZ_NUMBER +
389
+ generateMRZCheckDigit(MRZ_NUMBER) +
390
+ padMRZString(this.nationalityCode.replace(/\s/gi, "<"), 3) +
391
+ this.birthDate.toMRZString() +
392
+ generateMRZCheckDigit(this.birthDate.toMRZString()) +
393
+ genderMarkerToMRZ(this.genderMarker) +
394
+ this.validThru.toMRZString() +
395
+ generateMRZCheckDigit(this.validThru.toMRZString()) +
396
+ optionalDataMRZ(this.optionalData, 16);
397
+ }
398
+ /**
399
+ * @param { string } value - A MRZ line string of a 44-character length.
400
+ */
401
+ set mrzLine2(value) {
402
+ if (value.length !== 44) {
403
+ throw new RangeError(
404
+ `Length '${value.length}' does not match the length of a MRV-A ` +
405
+ `Machine-Readable Zone (MRZ) line.`
406
+ );
407
+ }
408
+ if (value[9] !== generateMRZCheckDigit(
409
+ value.slice(0, 9)
410
+ )) {
411
+ throw new EvalError(
412
+ `Check digit '${value[9]}' does not match for the check digit on the ` +
413
+ `document number.`
414
+ );
415
+ }
416
+ if (value[19] !== generateMRZCheckDigit(
417
+ value.slice(13, 19)
418
+ )) {
419
+ throw new EvalError(
420
+ `Check digit '${value[19]}' does not match for the check digit on the` +
421
+ ` date of birth.`
422
+ );
423
+ }
424
+ if (value[27] !== generateMRZCheckDigit(
425
+ value.slice(21, 27)
426
+ )) {
427
+ throw new EvalError(
428
+ `Check digit '${value[27]}' does not match for the check digit on the` +
429
+ ` valid thru date.`
430
+ );
431
+ }
432
+ if (this.usePassportInMRZ) {
433
+ this.passportNumber = value.slice(0, 9).replace(/</gi, "");
434
+ } else {
435
+ this.number = value.slice(0, 9).replace(/</gi, "");
436
+ }
437
+ this.nationalityCode = value.slice(10, 13).replace(/</gi, "");
438
+ this.birthDate = new IcaoDate(value.slice(13, 19), new Date().getFullYear());
439
+ this.genderMarker = value[20] === "<" ? "X" : value[20];
440
+ this.validThru = new IcaoDate(value.slice(21, 27));
441
+ this.optionalData = value.slice(28).replace(/</gi, " ").trimEnd();
442
+ }
443
+
444
+ /**
445
+ * The full Machine-Readable Zone (MRZ).
446
+ * @type { string }
447
+ */
448
+ get machineReadableZone() {
449
+ return this.mrzLine1 + this.mrzLine2;
450
+ }
451
+ /**
452
+ * @param { string } value - A MRZ string of a 88-character length.
453
+ */
454
+ set machineReadableZone(value) {
455
+ if (value.length !== 88) {
456
+ throw new RangeError(
457
+ `Length '${value.length} does not match the length of a MRV-A ` +
458
+ `Machine-Readable Zone (MRZ).`
459
+ );
460
+ }
461
+ this.mrzLine1 = value.slice(0, 44);
462
+ this.mrzLine2 = value.slice(44);
463
+ }
464
+ }
465
+