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