@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.
- package/LICENSES/CC0-1.0.txt +121 -0
- package/LICENSES/LGPL-3.0-or-later.txt +304 -0
- package/README.md +79 -0
- package/package.json +17 -0
- package/package.json.license +3 -0
- package/src/digitalseal.js +234 -0
- package/src/digitalsealv3.js +359 -0
- package/src/digitalsealv4.js +369 -0
- package/src/index.js +41 -0
- package/src/mrvadocument.js +465 -0
- package/src/mrvadocumentwithvds3.js +559 -0
- package/src/mrvadocumentwithvds4.js +559 -0
- package/src/mrvbdocument.js +466 -0
- package/src/mrvbdocumentwithvds3.js +560 -0
- package/src/mrvbdocumentwithvds4.js +560 -0
- package/src/td1document.js +408 -0
- package/src/td1documentwithvds3.js +479 -0
- package/src/td1documentwithvds4.js +479 -0
- package/src/td2document.js +379 -0
- package/src/td2documentwithvds3.js +466 -0
- package/src/td2documentwithvds4.js +466 -0
- package/src/td3document.js +391 -0
- package/src/td3documentwithvds3.js +466 -0
- package/src/td3documentwithvds4.js +466 -0
- package/src/traveldocument.js +306 -0
- package/src/utilities/bytes-to-date.js +23 -0
- package/src/utilities/c40-decode.js +225 -0
- package/src/utilities/c40-encode.js +254 -0
- package/src/utilities/c40-shift1.js +10 -0
- package/src/utilities/date-to-bytes.js +38 -0
- package/src/utilities/der-length-to-length.js +33 -0
- package/src/utilities/expand-year.js +26 -0
- package/src/utilities/gender-marker-to-mrz.js +14 -0
- package/src/utilities/generate-mrz-check-digit.js +139 -0
- package/src/utilities/icao-date.js +234 -0
- package/src/utilities/length-to-der-length.js +41 -0
- package/src/utilities/nationality-codes.js +303 -0
- package/src/utilities/normalize-mrz-string.js +19 -0
- package/src/utilities/optional-data-mrz.js +29 -0
- package/src/utilities/pad-mrz-string.js +16 -0
- package/src/utilities/set-signature-zone.js +34 -0
- package/src/utilities/stringify-validation-array.js +27 -0
- package/src/utilities/validate-hex-string.js +41 -0
- package/src/utilities/validate-identifier-code.js +38 -0
- package/src/utilities/validate-mrz-string.js +44 -0
- package/src/utilities/vds-magic.js +9 -0
- package/src/utilities/vds-signature-marker.js +9 -0
- package/src/utilities/vds-version-3.js +9 -0
- package/src/utilities/vds-version-4.js +9 -0
- package/src/visadocument.js +114 -0
- package/tests/models/digitalsealv4.test.js +67 -0
- package/tests/models/mrvadocument.test.js +61 -0
- package/tests/models/mrvbdocument.test.js +61 -0
- package/tests/models/td1document.test.js +50 -0
- package/tests/models/td2document.test.js +49 -0
- package/tests/models/td3document.test.js +88 -0
- package/tests/utilities/c40-encodation-scheme.test.js +34 -0
- package/tests/utilities/der-tlv-length-conversion.test.js +99 -0
- package/tests/utilities/document-utilities.test.js +199 -0
- package/tests/utilities/icao-constants.test.js +35 -0
- package/tests/utilities/icao-date.test.js +141 -0
- package/tests/utilities/vds-date-conversions.test.js +28 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Given a string[] from a validation function, stringify the errors into a
|
|
6
|
+
* human-readable result with punctuation and capitalization.
|
|
7
|
+
* @param { string[] } errors
|
|
8
|
+
*/
|
|
9
|
+
export function stringifyValidationArray(errors) {
|
|
10
|
+
if (errors.length === 0) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
let output = "";
|
|
14
|
+
errors.forEach((error, i) => {
|
|
15
|
+
if (i === 0) {
|
|
16
|
+
output += error[0].toUpperCase();
|
|
17
|
+
output += error.slice(1);
|
|
18
|
+
output += (i + 1) === errors.length ? "." : "; ";
|
|
19
|
+
} else {
|
|
20
|
+
output += (i + 1) === errors.length ? "and " : "";
|
|
21
|
+
output += error;
|
|
22
|
+
output += (i + 1) === errors.length ? "." : "; ";
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return output;
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { stringifyValidationArray } from "./stringify-validation-array.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check to see if a string is a hexadecimal string.
|
|
8
|
+
* @param { string } string - The string to validate
|
|
9
|
+
* @param { Object } [opt] - An options object.
|
|
10
|
+
* @param { number } [opt.minimum] - The minimum length of the string.
|
|
11
|
+
* @param { number } [opt.maximum] - The maximum length of the string.
|
|
12
|
+
* @returns { string } An empty string if it meets validation or a string
|
|
13
|
+
* which describes why the string isn't valid.
|
|
14
|
+
*/
|
|
15
|
+
export function validateHexString(string, opt) {
|
|
16
|
+
const errors = [];
|
|
17
|
+
const minimum = opt?.minimum ?? null;
|
|
18
|
+
const maximum = opt?.maximum ?? null;
|
|
19
|
+
const invalidCharacters = /[^0-9A-F]/i;
|
|
20
|
+
|
|
21
|
+
if (minimum !== null) {
|
|
22
|
+
if (string.length < minimum) {
|
|
23
|
+
errors.push(
|
|
24
|
+
`length must be at least ${minimum} character${minimum === 1 ? "":"s"}`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (maximum !== null) {
|
|
29
|
+
if (string.length > maximum) {
|
|
30
|
+
errors.push(
|
|
31
|
+
`length must be less than ${maximum} character${maximum === 1 ? "":"s"}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (invalidCharacters.test(string)) {
|
|
36
|
+
errors.push("must only use the characters 0-9 or A-F");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return stringifyValidationArray(errors);
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { stringifyValidationArray } from "./stringify-validation-array.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Given a string, check to see if it meets the requirements of an identifier
|
|
8
|
+
* code of a visible digital seal (VDS).
|
|
9
|
+
* @param { string } string
|
|
10
|
+
* @returns { string } An empty string if it meets validation, or a string
|
|
11
|
+
* which describes why the string isn't valid.
|
|
12
|
+
*/
|
|
13
|
+
export function validateIdentifierCode(string) {
|
|
14
|
+
const errors = [];
|
|
15
|
+
const countryCodeInvalid = /[^A-Z]/i;
|
|
16
|
+
const signerCodeInvalid = /[^A-Z0-9]/i;
|
|
17
|
+
const countryCode = string.slice(0, 2);
|
|
18
|
+
const signerCode = string.slice(2);
|
|
19
|
+
|
|
20
|
+
if (string.length !== 4) {
|
|
21
|
+
errors.push(
|
|
22
|
+
"full identifier code must be 4 characters long"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (countryCodeInvalid.test(countryCode)) {
|
|
26
|
+
errors.push(
|
|
27
|
+
"country code (characters 1-2) must use only characters A-Z"
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (signerCodeInvalid.test(signerCode)) {
|
|
31
|
+
errors.push(
|
|
32
|
+
"signer code (characters 3-4) must use only characters A-Z or 0-9"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return stringifyValidationArray(errors);
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { stringifyValidationArray } from "./stringify-validation-array.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Given a string, check to see if it meets the requirements to be used in a
|
|
8
|
+
* document's machine-readable zone (MRZ).
|
|
9
|
+
* @param { string } string - The string to validate.
|
|
10
|
+
* @param { Object } [opt] - An options object.
|
|
11
|
+
* @param { number } [opt.minimum] - The minimum length of the string.
|
|
12
|
+
* @param { number } [opt.maximum] - The maximum length of the string.
|
|
13
|
+
* @returns { string } An empty string if it meets validation, or a string
|
|
14
|
+
* which describes why the string isn't valid, which may be: it doesn't meet
|
|
15
|
+
* the set minimum or maximum ranges, or it uses a character that's invalid
|
|
16
|
+
* in the MRZ.
|
|
17
|
+
*/
|
|
18
|
+
export function validateMRZString(string, opt) {
|
|
19
|
+
const errors = [];
|
|
20
|
+
const minimum = opt?.minimum ?? null;
|
|
21
|
+
const maximum = opt?.maximum ?? null;
|
|
22
|
+
const invalidCharacters = /[^A-Z0-9<\s]/i;
|
|
23
|
+
|
|
24
|
+
if (minimum !== null) {
|
|
25
|
+
if (string.length < minimum) {
|
|
26
|
+
errors.push(
|
|
27
|
+
`length must be at least ${minimum} character${minimum === 1 ? "":"s"}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (maximum !== null) {
|
|
32
|
+
if (string.length > maximum) {
|
|
33
|
+
errors.push(
|
|
34
|
+
`length must be less than ${maximum} character${maximum === 1 ? "":"s"}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (invalidCharacters.test(string)) {
|
|
39
|
+
errors.push("must only use the characters A-Z, 0-9, ' ', or '<'");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return stringifyValidationArray(errors);
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { validateMRZString } from "./utilities/validate-mrz-string.js";
|
|
5
|
+
import { IcaoDate } from "./utilities/icao-date.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Stores properties specific to machine-readable visa documents.
|
|
9
|
+
*
|
|
10
|
+
* `VisaDocument` is intended to be used to compose different kinds of
|
|
11
|
+
* machine-readable visa documents. It is not intended to be instantiated
|
|
12
|
+
* directly.
|
|
13
|
+
*/
|
|
14
|
+
export class VisaDocument {
|
|
15
|
+
/**
|
|
16
|
+
* Create a `VisaDocument`.
|
|
17
|
+
* @param { Object } [opt] - An options object.
|
|
18
|
+
* @param { string } [opt.placeOfIssue] - Location where the visa was issued.
|
|
19
|
+
* @param { string | Date | IcaoDate } [opt.validFrom] - A calendar date string in
|
|
20
|
+
* YYYY-MM-DD format, a `Date` object, or an `IcaoDate` object.
|
|
21
|
+
* @param { string | number } [opt.numberOfEntries] - 0 or any string denotes
|
|
22
|
+
* an unlimited number of entries.
|
|
23
|
+
* @param { string } [opt.visaType] - A type/name/description for this visa.
|
|
24
|
+
* @param { string } [opt.additionalInfo] - Additional textual information.
|
|
25
|
+
* @param { string } [opt.passportNumber] - A string no longer than 9
|
|
26
|
+
* characters consisting of the characters A-Z, 0-9, ' ', or <.
|
|
27
|
+
* @param { boolean } [opt.usePassportInMRZ] - Use `this.passportNumber`
|
|
28
|
+
* instead of `this.number` in the Machine-Readable Zone (MRZ).
|
|
29
|
+
*/
|
|
30
|
+
constructor(opt) {
|
|
31
|
+
this.placeOfIssue = opt?.placeOfIssue ?? "Utopia";
|
|
32
|
+
this.validFrom = opt?.validFrom ?? "2007-04-15";
|
|
33
|
+
this.numberOfEntries = opt?.numberOfEntries ?? "Multiple";
|
|
34
|
+
this.visaType = opt?.visaType ?? "Entry Permit";
|
|
35
|
+
this.additionalInfo = opt?.additionalInfo ?? "";
|
|
36
|
+
this.passportNumber = opt?.passportNumber ?? "D23145890";
|
|
37
|
+
this.usePassportInMRZ = opt?.usePassportInMRZ ?? false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Location where the visa was issued.
|
|
42
|
+
* @type { string }
|
|
43
|
+
*/
|
|
44
|
+
placeOfIssue
|
|
45
|
+
|
|
46
|
+
#validFrom;
|
|
47
|
+
/**
|
|
48
|
+
* Starting date on which the visa is valid.
|
|
49
|
+
* @type { IcaoDate }
|
|
50
|
+
*/
|
|
51
|
+
get validFrom() { return this.#validFrom; }
|
|
52
|
+
/**
|
|
53
|
+
* @param { string | Date | IcaoDate } value - A calendar date string in YYYY-MM-DD
|
|
54
|
+
* format, a `Date` object, or an `IcaoDate` object.
|
|
55
|
+
*/
|
|
56
|
+
set validFrom(value) {
|
|
57
|
+
this.#validFrom = new IcaoDate(value);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#numberOfEntries;
|
|
61
|
+
/**
|
|
62
|
+
* Maximum number of entries this visa allows.
|
|
63
|
+
* @type { string }
|
|
64
|
+
*/
|
|
65
|
+
get numberOfEntries() { return this.#numberOfEntries; }
|
|
66
|
+
/**
|
|
67
|
+
* @param { string | number } value - 0 or any string denotes an unlimited
|
|
68
|
+
* number of entries.
|
|
69
|
+
*/
|
|
70
|
+
set numberOfEntries(value) { this.#numberOfEntries = String(value); }
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The textual type/name/description for this visa.
|
|
74
|
+
* @type { string }
|
|
75
|
+
*/
|
|
76
|
+
visaType
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Additional textual information to include with this visa.
|
|
80
|
+
* @type { string }
|
|
81
|
+
*/
|
|
82
|
+
additionalInfo
|
|
83
|
+
|
|
84
|
+
#passportNumber;
|
|
85
|
+
/**
|
|
86
|
+
* The identity document number for which this visa is issued.
|
|
87
|
+
* @type { string }
|
|
88
|
+
*/
|
|
89
|
+
get passportNumber() { return this.#passportNumber; }
|
|
90
|
+
/**
|
|
91
|
+
* @param { string } value - A string no longer than 9 characters consisting
|
|
92
|
+
* of the characters A-Z, 0-9, ' ', or <.
|
|
93
|
+
*/
|
|
94
|
+
set passportNumber(value) {
|
|
95
|
+
const isInvalid = validateMRZString(value, {
|
|
96
|
+
minimum: 1,
|
|
97
|
+
maximum: 9
|
|
98
|
+
});
|
|
99
|
+
if (isInvalid) {
|
|
100
|
+
throw new RangeError(
|
|
101
|
+
`Value set on 'passportNumber' has errors: ${isInvalid}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
this.#passportNumber = value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Use `this.passportNumber` instead of `this.number` in the Machine-Readable
|
|
109
|
+
* Zone (MRZ).
|
|
110
|
+
* @type { boolean }
|
|
111
|
+
*/
|
|
112
|
+
usePassportInMRZ;
|
|
113
|
+
}
|
|
114
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { DigitalSealV4 } from '../../src/digitalsealv4.js';
|
|
7
|
+
import { c40Decode } from '../../src/utilities/c40-decode.js';
|
|
8
|
+
import { c40Encode } from '../../src/utilities/c40-encode.js';
|
|
9
|
+
import { optionalDataMRZ } from '../../src/utilities/optional-data-mrz.js';
|
|
10
|
+
|
|
11
|
+
const signedSeal = [ 0xdc, 0x03, 0xd9, 0xc5, 0xd9, 0xca, 0xc8, 0xa7, 0x3a, 0x99, 0x5d, 0x91, 0x34, 0x5d, 0xdf, 0x54,
|
|
12
|
+
0x5d, 0x01, 0x02, 0x2c, 0xdd, 0x52, 0x13, 0x4a, 0x74, 0xda, 0x13, 0x47, 0xc6, 0xfe, 0xd9, 0x5c,
|
|
13
|
+
0xb8, 0x9f, 0x9f, 0xce, 0x13, 0x3c, 0x13, 0x3c, 0x13, 0x3c, 0x13, 0x3c, 0x20, 0x38, 0x33, 0x73,
|
|
14
|
+
0x4a, 0xaf, 0x47, 0xf0, 0xc3, 0x2f, 0x1a, 0x1e, 0x20, 0xeb, 0x26, 0x4d, 0x39, 0x3a, 0xfe, 0x34,
|
|
15
|
+
0x04, 0x03, 0x5a, 0x00, 0x00, 0x05, 0x06, 0x59, 0xe9, 0x32, 0xf9, 0x26, 0xc7, 0x03, 0x01, 0x02,
|
|
16
|
+
0xff, 0x40, 0x21, 0xc6, 0x78, 0x5b, 0x02, 0x7e, 0xc4, 0xa5, 0xbf, 0xa6, 0xdd, 0xe5, 0x37, 0xe8,
|
|
17
|
+
0xad, 0xfa, 0x91, 0xbe, 0xb1, 0x19, 0x7b, 0xed, 0x97, 0xad, 0xf2, 0xff, 0x89, 0xe0, 0xa3, 0x44,
|
|
18
|
+
0x51, 0x2b, 0x7b, 0x01, 0x36, 0xc4, 0x40, 0x50, 0xf1, 0x17, 0xe5, 0x07, 0xbc, 0x2a, 0x78, 0x2f,
|
|
19
|
+
0xfe, 0x15, 0xf6, 0x8d, 0xdd, 0x68, 0x18, 0xaf, 0x5a, 0x7b, 0xaf, 0x21, 0xca, 0x7c, 0xfc, 0x7e,
|
|
20
|
+
0xb3, 0xbe ]
|
|
21
|
+
|
|
22
|
+
describe('Visible Digital Seal version 4', () => {
|
|
23
|
+
|
|
24
|
+
describe('Import exemplary raw data from documentation [REF ICAO 9303 Part 7 Appendix E]', () => {
|
|
25
|
+
it('should equal the values from exemplary VDS in Appendix E-2.', () => {
|
|
26
|
+
const document = new DigitalSealV4({ signedSeal: signedSeal });
|
|
27
|
+
assert.deepStrictEqual(document.authorityCode, 'UTO');
|
|
28
|
+
assert.deepStrictEqual(document.identifierCode, 'UTTS');
|
|
29
|
+
assert.deepStrictEqual(document.certReference,'5B');
|
|
30
|
+
assert.deepStrictEqual(document.issueDate.toISOString(), '2020-06-13');
|
|
31
|
+
assert.deepStrictEqual(document.signatureDate.toISOString(), '2020-06-15');
|
|
32
|
+
// REF ICAO 9303 Part 7 SS 9.1, Page 39
|
|
33
|
+
assert.deepStrictEqual(document.featureDefinition, 93);
|
|
34
|
+
assert.deepStrictEqual(document.typeCategory, 1);
|
|
35
|
+
// REF ICAO 9303 Part 7 SS 9.1.3, Page 40-42
|
|
36
|
+
assert.deepStrictEqual(optionalDataMRZ(c40Decode(document.features.get(2), 64)), 'VCD<<DENT<<ARTHUR<PHILIP<<<<<<<<<<<<1234567XY7GBR5203116M2105253');
|
|
37
|
+
assert.deepStrictEqual(document.features.get(3), [ 2 ]);
|
|
38
|
+
assert.deepStrictEqual(document.features.get(4), [ 0x5a, 0x00, 0x00 ]);
|
|
39
|
+
assert.deepStrictEqual(c40Decode(document.features.get(5)), 'ABC424242');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('Use properties to reconstruct the exemplary raw data from documentation [REF ICAO 9303 Part 7 Appendix E]', () => {
|
|
44
|
+
it('should equal the exemplary raw data from documentation in Appendix E-2.', () => {
|
|
45
|
+
const document = new DigitalSealV4({
|
|
46
|
+
authorityCode: 'UTO',
|
|
47
|
+
identifierCode: 'UTTS',
|
|
48
|
+
certReference: '5B',
|
|
49
|
+
issueDate: '2020-06-13',
|
|
50
|
+
signatureDate: '2020-06-15',
|
|
51
|
+
featureDefinition: 93,
|
|
52
|
+
typeCategory: 1
|
|
53
|
+
});
|
|
54
|
+
document.features.set(2, c40Encode('VCD<<DENT<<ARTHUR<PHILIP<<<<<<<<<<<<1234567XY7GBR5203116M2105253'));
|
|
55
|
+
document.features.set(4, [ 0x5a, 0x00, 0x00 ]);
|
|
56
|
+
document.features.set(5, c40Encode('ABC424242'));
|
|
57
|
+
document.features.set(3, [ 2 ]);
|
|
58
|
+
document.signatureData = [ 0x21, 0xc6, 0x78, 0x5b, 0x02, 0x7e, 0xc4, 0xa5, 0xbf, 0xa6, 0xdd, 0xe5, 0x37, 0xe8, 0xad, 0xfa,
|
|
59
|
+
0x91, 0xbe, 0xb1, 0x19, 0x7b, 0xed, 0x97, 0xad, 0xf2, 0xff, 0x89, 0xe0, 0xa3, 0x44, 0x51, 0x2b,
|
|
60
|
+
0x7b, 0x01, 0x36, 0xc4, 0x40, 0x50, 0xf1, 0x17, 0xe5, 0x07, 0xbc, 0x2a, 0x78, 0x2f, 0xfe, 0x15,
|
|
61
|
+
0xf6, 0x8d, 0xdd, 0x68, 0x18, 0xaf, 0x5a, 0x7b, 0xaf, 0x21, 0xca, 0x7c, 0xfc, 0x7e, 0xb3, 0xbe ];
|
|
62
|
+
assert.deepStrictEqual(document.signedSeal, signedSeal);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
});
|
|
67
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { MRVADocument } from '../../src/mrvadocument.js';
|
|
7
|
+
|
|
8
|
+
describe('TD3-sized Machine Readable Visa', () => {
|
|
9
|
+
|
|
10
|
+
describe('Use properties to reconstruct exemplary MRZ from documentation [REF ICAO 9303 Part 7 Appendix A]', () => {
|
|
11
|
+
it('should equal the exemplary MRVA in Appendix A-1 and A-2.', () => {
|
|
12
|
+
const document = new MRVADocument({
|
|
13
|
+
typeCode: 'V',
|
|
14
|
+
authorityCode: 'UTO',
|
|
15
|
+
passportNumber: 'L8988901C',
|
|
16
|
+
birthDate: '1974-08-12',
|
|
17
|
+
genderMarker: 'F',
|
|
18
|
+
validThru: '1996-12-10',
|
|
19
|
+
nationalityCode: 'XXX',
|
|
20
|
+
primaryIdentifier: 'Eriksson',
|
|
21
|
+
secondaryIdentifier: 'Anna-Maria',
|
|
22
|
+
optionalData: '6ZE184226B',
|
|
23
|
+
usePassportInMRZ: true
|
|
24
|
+
});
|
|
25
|
+
assert.deepStrictEqual(document.mrzLine1, 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<');
|
|
26
|
+
assert.deepStrictEqual(document.mrzLine2, 'L8988901C4XXX7408122F96121096ZE184226B<<<<<<');
|
|
27
|
+
assert.deepStrictEqual(document.machineReadableZone, 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<L8988901C4XXX7408122F96121096ZE184226B<<<<<<');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('Import exemplary MRZ data from documentation [REF ICO 9303 Part 6 Appendix A]', () => {
|
|
32
|
+
it('document properties should equal the values from exemplary MRVA in Appendix A-1 and A-2.', () => {
|
|
33
|
+
const document = new MRVADocument({
|
|
34
|
+
machineReadableZone: 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<L8988901C4XXX7408122F96121096ZE184226B<<<<<<',
|
|
35
|
+
usePassportInMRZ: true
|
|
36
|
+
});
|
|
37
|
+
assert.deepStrictEqual(document.typeCode, 'V');
|
|
38
|
+
assert.deepStrictEqual(document.authorityCode, 'UTO');
|
|
39
|
+
assert.deepStrictEqual(document.passportNumber, 'L8988901C');
|
|
40
|
+
assert.deepStrictEqual(document.birthDate.toISOString(), '1974-08-12');
|
|
41
|
+
assert.deepStrictEqual(document.genderMarker, 'F');
|
|
42
|
+
assert.deepStrictEqual(document.validThru.toISOString(), '1996-12-10');
|
|
43
|
+
assert.deepStrictEqual(document.nationalityCode, 'XXX');
|
|
44
|
+
assert.deepStrictEqual(document.primaryIdentifier, 'ERIKSSON');
|
|
45
|
+
assert.deepStrictEqual(document.secondaryIdentifier, 'ANNA MARIA');
|
|
46
|
+
assert.deepStrictEqual(document.optionalData, '6ZE184226B');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('Import MRZ data from previous test with visa number in MRZ', () => {
|
|
51
|
+
it('should have "L8988901C" as the document number instead of the passport number.', () => {
|
|
52
|
+
const document = new MRVADocument({
|
|
53
|
+
machineReadableZone: 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<L8988901C4XXX7408122F96121096ZE184226B<<<<<<',
|
|
54
|
+
usePassportInMRZ: false
|
|
55
|
+
});
|
|
56
|
+
assert.deepStrictEqual(document.number, 'L8988901C');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { MRVBDocument } from '../../src/mrvbdocument.js';
|
|
7
|
+
|
|
8
|
+
describe('TD2-sized Machine Readable Visa', () => {
|
|
9
|
+
|
|
10
|
+
describe('Use properties to reconstruct exemplary MRZ from documentation [REF ICAO 9303 Part 7 Appendix A]', () => {
|
|
11
|
+
it('should equal the exemplary MRVB in Appendix A-3.', () => {
|
|
12
|
+
const document = new MRVBDocument({
|
|
13
|
+
typeCode: 'V',
|
|
14
|
+
authorityCode: 'UTO',
|
|
15
|
+
passportNumber: 'L8988901C',
|
|
16
|
+
birthDate: '1974-08-12',
|
|
17
|
+
genderMarker: 'F',
|
|
18
|
+
validThru: '1996-12-10',
|
|
19
|
+
nationalityCode: 'XXX',
|
|
20
|
+
primaryIdentifier: 'Eriksson',
|
|
21
|
+
secondaryIdentifier: 'Anna-Maria',
|
|
22
|
+
optionalData: '',
|
|
23
|
+
usePassportInMRZ: true
|
|
24
|
+
});
|
|
25
|
+
assert.deepStrictEqual(document.mrzLine1, 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<');
|
|
26
|
+
assert.deepStrictEqual(document.mrzLine2, 'L8988901C4XXX7408122F9612109<<<<<<<<');
|
|
27
|
+
assert.deepStrictEqual(document.machineReadableZone, 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<L8988901C4XXX7408122F9612109<<<<<<<<');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('Import exemplary MRZ data from documentation [REF ICO 9303 Part 6 Appendix A]', () => {
|
|
32
|
+
it('document properties should equal the values from the exemplary MRVB in Appendix A-3.', () => {
|
|
33
|
+
const document = new MRVBDocument({
|
|
34
|
+
machineReadableZone: 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<L8988901C4XXX7408122F9612109<<<<<<<<',
|
|
35
|
+
usePassportInMRZ: true
|
|
36
|
+
});
|
|
37
|
+
assert.deepStrictEqual(document.typeCode, 'V');
|
|
38
|
+
assert.deepStrictEqual(document.authorityCode, 'UTO');
|
|
39
|
+
assert.deepStrictEqual(document.passportNumber, 'L8988901C');
|
|
40
|
+
assert.deepStrictEqual(document.birthDate.toISOString(), '1974-08-12');
|
|
41
|
+
assert.deepStrictEqual(document.genderMarker, 'F');
|
|
42
|
+
assert.deepStrictEqual(document.validThru.toISOString(), '1996-12-10');
|
|
43
|
+
assert.deepStrictEqual(document.nationalityCode, 'XXX');
|
|
44
|
+
assert.deepStrictEqual(document.primaryIdentifier, 'ERIKSSON');
|
|
45
|
+
assert.deepStrictEqual(document.secondaryIdentifier, 'ANNA MARIA');
|
|
46
|
+
assert.deepStrictEqual(document.optionalData, '');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('Import MRZ data from previous test with visa number in MRZ', () => {
|
|
51
|
+
it('should have "L8988901C" as the document number instead of the passport number.', () => {
|
|
52
|
+
const document = new MRVBDocument({
|
|
53
|
+
machineReadableZone: 'V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<L8988901C4XXX7408122F9612109<<<<<<<<',
|
|
54
|
+
usePassportInMRZ: false
|
|
55
|
+
});
|
|
56
|
+
assert.deepStrictEqual(document.number, 'L8988901C');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { TD1Document } from '../../src/td1document.js';
|
|
7
|
+
|
|
8
|
+
describe('TD1-sized Machine Readable Travel Document', () => {
|
|
9
|
+
|
|
10
|
+
describe('Use properties to reconstruct exemplary MRZ from documentation [REF ICAO 9303 Part 5 Appendix A]', () => {
|
|
11
|
+
it('should equal the exemplary TD1 MRTD MRZ in Appendix A-1 and A-2.', () => {
|
|
12
|
+
const document = new TD1Document({
|
|
13
|
+
typeCode: 'I',
|
|
14
|
+
authorityCode: 'UTO',
|
|
15
|
+
number: 'D23145890',
|
|
16
|
+
birthDate: '1974-08-12',
|
|
17
|
+
genderMarker: 'F',
|
|
18
|
+
expirationDate: '2012-04-15',
|
|
19
|
+
nationalityCode: 'UTO',
|
|
20
|
+
primaryIdentifier: 'Eriksson',
|
|
21
|
+
secondaryIdentifier: 'Anna-Maria',
|
|
22
|
+
optionalData: ''
|
|
23
|
+
});
|
|
24
|
+
assert.deepStrictEqual(document.mrzLine1, 'I<UTOD231458907<<<<<<<<<<<<<<<');
|
|
25
|
+
assert.deepStrictEqual(document.mrzLine2, '7408122F1204159UTO<<<<<<<<<<<6');
|
|
26
|
+
assert.deepStrictEqual(document.mrzLine3, 'ERIKSSON<<ANNA<MARIA<<<<<<<<<<');
|
|
27
|
+
assert.deepStrictEqual(document.machineReadableZone, 'I<UTOD231458907<<<<<<<<<<<<<<<7408122F1204159UTO<<<<<<<<<<<6ERIKSSON<<ANNA<MARIA<<<<<<<<<<');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('Import exemplary MRZ data from documentation [REF ICO 9303 Part 5 Appendix A]', () => {
|
|
32
|
+
it('document properties should equal the values from exemplary TD1 MRTD in Appendix A-1 and A-2', () => {
|
|
33
|
+
const document = new TD1Document({
|
|
34
|
+
machineReadableZone: 'I<UTOD231458907<<<<<<<<<<<<<<<7408122F1204159UTO<<<<<<<<<<<6ERIKSSON<<ANNA<MARIA<<<<<<<<<<'
|
|
35
|
+
});
|
|
36
|
+
assert.deepStrictEqual(document.typeCode, 'I');
|
|
37
|
+
assert.deepStrictEqual(document.authorityCode, 'UTO');
|
|
38
|
+
assert.deepStrictEqual(document.number, 'D23145890');
|
|
39
|
+
assert.deepStrictEqual(document.birthDate.toISOString(), '1974-08-12');
|
|
40
|
+
assert.deepStrictEqual(document.genderMarker, 'F');
|
|
41
|
+
assert.deepStrictEqual(document.expirationDate.toISOString(), '2012-04-15');
|
|
42
|
+
assert.deepStrictEqual(document.nationalityCode, 'UTO');
|
|
43
|
+
assert.deepStrictEqual(document.primaryIdentifier, 'ERIKSSON');
|
|
44
|
+
assert.deepStrictEqual(document.secondaryIdentifier, 'ANNA MARIA');
|
|
45
|
+
assert.deepStrictEqual(document.optionalData, '');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
});
|
|
50
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Don Geronimo <https://sentamal.in>
|
|
2
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { TD2Document } from '../../src/td2document.js';
|
|
7
|
+
|
|
8
|
+
describe('TD2-sized Machine Readable Travel Document', () => {
|
|
9
|
+
|
|
10
|
+
describe('Use properties to reconstruct exemplary MRZ from documentation [REF ICAO 9303 Part 6 Appendix A]', () => {
|
|
11
|
+
it('should equal the exemplary TD2 MRTD MRZ in Appendix A-1 and A-2.', () => {
|
|
12
|
+
const document = new TD2Document({
|
|
13
|
+
typeCode: 'I',
|
|
14
|
+
authorityCode: 'UTO',
|
|
15
|
+
number: 'D23145890',
|
|
16
|
+
birthDate: '1974-08-12',
|
|
17
|
+
genderMarker: 'F',
|
|
18
|
+
expirationDate: '2012-04-15',
|
|
19
|
+
nationalityCode: 'UTO',
|
|
20
|
+
primaryIdentifier: 'Eriksson',
|
|
21
|
+
secondaryIdentifier: 'Anna-Maria',
|
|
22
|
+
optionalData: ''
|
|
23
|
+
});
|
|
24
|
+
assert.deepStrictEqual(document.mrzLine1, 'I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<');
|
|
25
|
+
assert.deepStrictEqual(document.mrzLine2, 'D231458907UTO7408122F1204159<<<<<<<6');
|
|
26
|
+
assert.deepStrictEqual(document.machineReadableZone, 'I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<D231458907UTO7408122F1204159<<<<<<<6');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('Import exemplary MRZ data from documentation [REF ICO 9303 Part 6 Appendix A]', () => {
|
|
31
|
+
it('document properties should equal the values from the exemplary TD2 MRTD in Appendix A-1 and A-2', () => {
|
|
32
|
+
const document = new TD2Document({
|
|
33
|
+
machineReadableZone: 'I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<D231458907UTO7408122F1204159<<<<<<<6'
|
|
34
|
+
});
|
|
35
|
+
assert.deepStrictEqual(document.typeCode, 'I');
|
|
36
|
+
assert.deepStrictEqual(document.authorityCode, 'UTO');
|
|
37
|
+
assert.deepStrictEqual(document.number, 'D23145890');
|
|
38
|
+
assert.deepStrictEqual(document.birthDate.toISOString(), '1974-08-12');
|
|
39
|
+
assert.deepStrictEqual(document.genderMarker, 'F');
|
|
40
|
+
assert.deepStrictEqual(document.expirationDate.toISOString(), '2012-04-15');
|
|
41
|
+
assert.deepStrictEqual(document.nationalityCode, 'UTO');
|
|
42
|
+
assert.deepStrictEqual(document.primaryIdentifier, 'ERIKSSON');
|
|
43
|
+
assert.deepStrictEqual(document.secondaryIdentifier, 'ANNA MARIA');
|
|
44
|
+
assert.deepStrictEqual(document.optionalData, '');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
});
|
|
49
|
+
|