mrz-parser

0.0.1 • Public • Published

Alt text Alt text Alt text Alt text

requests example

curl -X POST --data '{"mrz": ["ARCHEDB07156586166492802<<<<<<", "9108183F2104083RKS<<<<<<<<<<<0", "PUKA<<VJOLLCA<<<<<<<<<<<<<<<<<"]}' http://localhost:8080/parse -H "Content-Type: application/json"
curl -X POST --data '{"mrz":"ARCHEDB07156586166492802<<<<<<\n9108183F2104083RKS<<<<<<<<<<<0\nPUKA<<VJOLLCA<<<<<<<<<<<<<<<<<"}' http://localhost:8080/parse -H "Content-Type: application/json"
curl -X POST --data '{"mrz":"IAAZEAA012345650123456<<<<<<<<\n8012311M4012313AZE<<<<<<<<<<<3\nDOE<<IVAN<<<<<<<<<<<<<<<<<<<<<", "ocr": [{"category":"First name","content":"John","contentType":"string"},{"category":"Last name","content":"Doe","contentType":"string"}]
}' http://localhost:8080/normalize -H "Content-Type: application/json"

parse(mrz)

Parses the provided MRZ. The argument can be an array of lines or a single string including line breaks. This function throws an error if the input is in an unsupported format. It will never throw an error when there are invalid fields in the MRZ. Instead, the result.valid value will be false and details about the invalid fields can be found in result.details.

result.format

String identifying the format of the parsed MRZ. Supported formats are:

  • TD1 (identity card with three MRZ lines)
  • TD2 (identity card with two MRZ lines)
  • TD3 (passport)
  • SWISS_DRIVING_LICENSE
  • FRENCH_NATIONAL_ID
  • FRENCH_DRIVING_LICENSE
  • ESTONIAN_DRIVING_LICENSE
  • IRELAND_DRIVING_LICENSE

result.valid

true if all fields are valid. false otherwise.

result.fields

Object mapping field names to their respective value. The value is set to null if it is invalid. The value may be different than the raw value. For example result.fields.sex will be "male" when the raw value was "M".

result.details

Array of objects describing all parsed fields. Its structure is:

  • label {string} - Full english term for the field.
  • field {string} - Name of the field in result.fields.
  • value {string} - Value of the field or null.
  • valid {boolean}
  • ranges {Array} - Array of ranges that are necessary to compute this field. Ranges are objects with line, start, end and raw.
  • line {number} - Index of the line where the field is located.
  • start {number} - Index of the start of the field in line.
  • end {number} - Index of the end of the field in line.

formats

Static mapping of supported formats.

states

Static mapping of state code to state name.

Specifications

TD1, TD2 and TD3

https://www.icao.int/publications/pages/publication.aspx?docnum=9303

Swiss driving license

http://www.astra2.admin.ch/media/pdfpub/2003-10-15_2262_f.pdf

French national id

https://fr.wikipedia.org/wiki/Carte_nationale_d%27identit%C3%A9_en_France#Codage_Bande_MRZ_(lecture_optique)

Readme

Keywords

Package Sidebar

Install

npm i mrz-parser

Weekly Downloads

0

Version

0.0.1

License

none

Unpacked Size

196 kB

Total Files

150

Last publish

Collaborators

  • getid