petrus-react-native 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 (163) hide show
  1. package/PetrusReactNative.podspec +20 -0
  2. package/android/build.gradle +64 -0
  3. package/android/src/main/AndroidManifest.xml +4 -0
  4. package/android/src/main/java/com/petrusreactnative/PDF417ScanSession.kt +86 -0
  5. package/android/src/main/java/com/petrusreactnative/PassportScanSession.kt +137 -0
  6. package/android/src/main/java/com/petrusreactnative/PetrusCameraView.kt +146 -0
  7. package/android/src/main/java/com/petrusreactnative/PetrusCameraViewManager.kt +93 -0
  8. package/android/src/main/java/com/petrusreactnative/PetrusOverlayView.kt +87 -0
  9. package/android/src/main/java/com/petrusreactnative/PetrusReactNativeModule.kt +253 -0
  10. package/android/src/main/java/com/petrusreactnative/PetrusReactNativePackage.kt +38 -0
  11. package/android/src/main/java/com/petrusreactnative/VehicleRegistrationScanSession.kt +119 -0
  12. package/android/src/main/java/com/petrusreactnative/events/CapturedEvent.kt +30 -0
  13. package/android/src/main/java/com/petrusreactnative/events/DocumentDetectedEvent.kt +49 -0
  14. package/android/src/main/java/com/petrusreactnative/events/FrameMetadataEvent.kt +24 -0
  15. package/android/src/main/java/com/petrusreactnative/mrz/PassportResultMapping.kt +54 -0
  16. package/android/src/main/java/com/petrusreactnative/ocr/OCRResultMapping.kt +52 -0
  17. package/android/src/main/java/com/petrusreactnative/pdf417/SouthAfricanDriversLicenseResultMapping.kt +80 -0
  18. package/android/src/main/java/com/petrusreactnative/sa/SouthAfricanIDResultMapping.kt +50 -0
  19. package/android/src/main/java/com/petrusreactnative/vehicle/VehicleRegistrationResultMapping.kt +72 -0
  20. package/ios/PetrusReactNative.h +5 -0
  21. package/ios/PetrusReactNative.mm +21 -0
  22. package/lib/module/NativePetrusReactNative.js +5 -0
  23. package/lib/module/NativePetrusReactNative.js.map +1 -0
  24. package/lib/module/PetrusCameraView.js +6 -0
  25. package/lib/module/PetrusCameraView.js.map +1 -0
  26. package/lib/module/PetrusCameraView.native.js +24 -0
  27. package/lib/module/PetrusCameraView.native.js.map +1 -0
  28. package/lib/module/PetrusCameraViewNativeComponent.ts +47 -0
  29. package/lib/module/cameraPermissions.js +9 -0
  30. package/lib/module/cameraPermissions.js.map +1 -0
  31. package/lib/module/cameraPermissions.native.js +10 -0
  32. package/lib/module/cameraPermissions.native.js.map +1 -0
  33. package/lib/module/getPipelineVersion.js +6 -0
  34. package/lib/module/getPipelineVersion.js.map +1 -0
  35. package/lib/module/getPipelineVersion.native.js +7 -0
  36. package/lib/module/getPipelineVersion.native.js.map +1 -0
  37. package/lib/module/index.js +45 -0
  38. package/lib/module/index.js.map +1 -0
  39. package/lib/module/package.json +1 -0
  40. package/lib/module/parseMRZ.js +6 -0
  41. package/lib/module/parseMRZ.js.map +1 -0
  42. package/lib/module/parseMRZ.native.js +12 -0
  43. package/lib/module/parseMRZ.native.js.map +1 -0
  44. package/lib/module/parseSouthAfricanDriversLicense.js +6 -0
  45. package/lib/module/parseSouthAfricanDriversLicense.js.map +1 -0
  46. package/lib/module/parseSouthAfricanDriversLicense.native.js +12 -0
  47. package/lib/module/parseSouthAfricanDriversLicense.native.js.map +1 -0
  48. package/lib/module/parseSouthAfricanID.js +6 -0
  49. package/lib/module/parseSouthAfricanID.js.map +1 -0
  50. package/lib/module/parseSouthAfricanID.native.js +8 -0
  51. package/lib/module/parseSouthAfricanID.native.js.map +1 -0
  52. package/lib/module/parseVehicleRegistration.js +6 -0
  53. package/lib/module/parseVehicleRegistration.js.map +1 -0
  54. package/lib/module/parseVehicleRegistration.native.js +8 -0
  55. package/lib/module/parseVehicleRegistration.native.js.map +1 -0
  56. package/lib/module/recognizeText.js +6 -0
  57. package/lib/module/recognizeText.js.map +1 -0
  58. package/lib/module/recognizeText.native.js +8 -0
  59. package/lib/module/recognizeText.native.js.map +1 -0
  60. package/lib/module/scanPDF417.js +6 -0
  61. package/lib/module/scanPDF417.js.map +1 -0
  62. package/lib/module/scanPDF417.native.js +8 -0
  63. package/lib/module/scanPDF417.native.js.map +1 -0
  64. package/lib/module/scanPassport.js +6 -0
  65. package/lib/module/scanPassport.js.map +1 -0
  66. package/lib/module/scanPassport.native.js +13 -0
  67. package/lib/module/scanPassport.native.js.map +1 -0
  68. package/lib/module/scanSouthAfricanDriversLicense.js +6 -0
  69. package/lib/module/scanSouthAfricanDriversLicense.js.map +1 -0
  70. package/lib/module/scanSouthAfricanDriversLicense.native.js +12 -0
  71. package/lib/module/scanSouthAfricanDriversLicense.native.js.map +1 -0
  72. package/lib/module/scanVehicleRegistration.js +6 -0
  73. package/lib/module/scanVehicleRegistration.js.map +1 -0
  74. package/lib/module/scanVehicleRegistration.native.js +13 -0
  75. package/lib/module/scanVehicleRegistration.native.js.map +1 -0
  76. package/lib/module/types.js +2 -0
  77. package/lib/module/types.js.map +1 -0
  78. package/lib/typescript/package.json +1 -0
  79. package/lib/typescript/src/NativePetrusReactNative.d.ts +271 -0
  80. package/lib/typescript/src/NativePetrusReactNative.d.ts.map +1 -0
  81. package/lib/typescript/src/PetrusCameraView.d.ts +10 -0
  82. package/lib/typescript/src/PetrusCameraView.d.ts.map +1 -0
  83. package/lib/typescript/src/PetrusCameraView.native.d.ts +4 -0
  84. package/lib/typescript/src/PetrusCameraView.native.d.ts.map +1 -0
  85. package/lib/typescript/src/PetrusCameraViewNativeComponent.d.ts +38 -0
  86. package/lib/typescript/src/PetrusCameraViewNativeComponent.d.ts.map +1 -0
  87. package/lib/typescript/src/cameraPermissions.d.ts +4 -0
  88. package/lib/typescript/src/cameraPermissions.d.ts.map +1 -0
  89. package/lib/typescript/src/cameraPermissions.native.d.ts +4 -0
  90. package/lib/typescript/src/cameraPermissions.native.d.ts.map +1 -0
  91. package/lib/typescript/src/getPipelineVersion.d.ts +2 -0
  92. package/lib/typescript/src/getPipelineVersion.d.ts.map +1 -0
  93. package/lib/typescript/src/getPipelineVersion.native.d.ts +2 -0
  94. package/lib/typescript/src/getPipelineVersion.native.d.ts.map +1 -0
  95. package/lib/typescript/src/index.d.ts +45 -0
  96. package/lib/typescript/src/index.d.ts.map +1 -0
  97. package/lib/typescript/src/parseMRZ.d.ts +3 -0
  98. package/lib/typescript/src/parseMRZ.d.ts.map +1 -0
  99. package/lib/typescript/src/parseMRZ.native.d.ts +8 -0
  100. package/lib/typescript/src/parseMRZ.native.d.ts.map +1 -0
  101. package/lib/typescript/src/parseSouthAfricanDriversLicense.d.ts +3 -0
  102. package/lib/typescript/src/parseSouthAfricanDriversLicense.d.ts.map +1 -0
  103. package/lib/typescript/src/parseSouthAfricanDriversLicense.native.d.ts +8 -0
  104. package/lib/typescript/src/parseSouthAfricanDriversLicense.native.d.ts.map +1 -0
  105. package/lib/typescript/src/parseSouthAfricanID.d.ts +3 -0
  106. package/lib/typescript/src/parseSouthAfricanID.d.ts.map +1 -0
  107. package/lib/typescript/src/parseSouthAfricanID.native.d.ts +4 -0
  108. package/lib/typescript/src/parseSouthAfricanID.native.d.ts.map +1 -0
  109. package/lib/typescript/src/parseVehicleRegistration.d.ts +3 -0
  110. package/lib/typescript/src/parseVehicleRegistration.d.ts.map +1 -0
  111. package/lib/typescript/src/parseVehicleRegistration.native.d.ts +4 -0
  112. package/lib/typescript/src/parseVehicleRegistration.native.d.ts.map +1 -0
  113. package/lib/typescript/src/recognizeText.d.ts +3 -0
  114. package/lib/typescript/src/recognizeText.d.ts.map +1 -0
  115. package/lib/typescript/src/recognizeText.native.d.ts +4 -0
  116. package/lib/typescript/src/recognizeText.native.d.ts.map +1 -0
  117. package/lib/typescript/src/scanPDF417.d.ts +3 -0
  118. package/lib/typescript/src/scanPDF417.d.ts.map +1 -0
  119. package/lib/typescript/src/scanPDF417.native.d.ts +4 -0
  120. package/lib/typescript/src/scanPDF417.native.d.ts.map +1 -0
  121. package/lib/typescript/src/scanPassport.d.ts +3 -0
  122. package/lib/typescript/src/scanPassport.d.ts.map +1 -0
  123. package/lib/typescript/src/scanPassport.native.d.ts +9 -0
  124. package/lib/typescript/src/scanPassport.native.d.ts.map +1 -0
  125. package/lib/typescript/src/scanSouthAfricanDriversLicense.d.ts +3 -0
  126. package/lib/typescript/src/scanSouthAfricanDriversLicense.d.ts.map +1 -0
  127. package/lib/typescript/src/scanSouthAfricanDriversLicense.native.d.ts +8 -0
  128. package/lib/typescript/src/scanSouthAfricanDriversLicense.native.d.ts.map +1 -0
  129. package/lib/typescript/src/scanVehicleRegistration.d.ts +3 -0
  130. package/lib/typescript/src/scanVehicleRegistration.d.ts.map +1 -0
  131. package/lib/typescript/src/scanVehicleRegistration.native.d.ts +9 -0
  132. package/lib/typescript/src/scanVehicleRegistration.native.d.ts.map +1 -0
  133. package/lib/typescript/src/types.d.ts +237 -0
  134. package/lib/typescript/src/types.d.ts.map +1 -0
  135. package/package.json +124 -0
  136. package/src/NativePetrusReactNative.ts +303 -0
  137. package/src/PetrusCameraView.native.tsx +44 -0
  138. package/src/PetrusCameraView.tsx +19 -0
  139. package/src/PetrusCameraViewNativeComponent.ts +47 -0
  140. package/src/cameraPermissions.native.tsx +10 -0
  141. package/src/cameraPermissions.tsx +13 -0
  142. package/src/getPipelineVersion.native.tsx +5 -0
  143. package/src/getPipelineVersion.tsx +5 -0
  144. package/src/index.tsx +83 -0
  145. package/src/parseMRZ.native.tsx +11 -0
  146. package/src/parseMRZ.tsx +7 -0
  147. package/src/parseSouthAfricanDriversLicense.native.tsx +13 -0
  148. package/src/parseSouthAfricanDriversLicense.tsx +9 -0
  149. package/src/parseSouthAfricanID.native.tsx +7 -0
  150. package/src/parseSouthAfricanID.tsx +7 -0
  151. package/src/parseVehicleRegistration.native.tsx +9 -0
  152. package/src/parseVehicleRegistration.tsx +9 -0
  153. package/src/recognizeText.native.tsx +7 -0
  154. package/src/recognizeText.tsx +7 -0
  155. package/src/scanPDF417.native.tsx +7 -0
  156. package/src/scanPDF417.tsx +7 -0
  157. package/src/scanPassport.native.tsx +12 -0
  158. package/src/scanPassport.tsx +7 -0
  159. package/src/scanSouthAfricanDriversLicense.native.tsx +11 -0
  160. package/src/scanSouthAfricanDriversLicense.tsx +7 -0
  161. package/src/scanVehicleRegistration.native.tsx +12 -0
  162. package/src/scanVehicleRegistration.tsx +7 -0
  163. package/src/types.ts +272 -0
@@ -0,0 +1,4 @@
1
+ import type { PDF417ScanResult } from './types';
2
+ /** `imagePath` may be a bare filesystem path or a URI (file://, content://, ...). */
3
+ export declare function scanPDF417(imagePath: string): Promise<PDF417ScanResult>;
4
+ //# sourceMappingURL=scanPDF417.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanPDF417.native.d.ts","sourceRoot":"","sources":["../../../src/scanPDF417.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEvE"}
@@ -0,0 +1,3 @@
1
+ import type { PassportResult } from './types';
2
+ export declare function scanPassport(): Promise<PassportResult>;
3
+ //# sourceMappingURL=scanPassport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanPassport.d.ts","sourceRoot":"","sources":["../../../src/scanPassport.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,YAAY,IAAI,OAAO,CAAC,cAAc,CAAC,CAItD"}
@@ -0,0 +1,9 @@
1
+ import type { PassportResult } from './types';
2
+ /**
3
+ * Opens a headless (no preview UI) camera session; per frame, detects the
4
+ * document boundary, crops just the MRZ band, runs OCR on only that crop, and
5
+ * parses it -- stops once a frame yields a non-empty passport number. Rejects
6
+ * on timeout (~20s) or if no Activity is available.
7
+ */
8
+ export declare function scanPassport(): Promise<PassportResult>;
9
+ //# sourceMappingURL=scanPassport.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanPassport.native.d.ts","sourceRoot":"","sources":["../../../src/scanPassport.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC,cAAc,CAAC,CAEtD"}
@@ -0,0 +1,3 @@
1
+ import type { SouthAfricanDriversLicenseResult } from './types';
2
+ export declare function scanSouthAfricanDriversLicense(): Promise<SouthAfricanDriversLicenseResult>;
3
+ //# sourceMappingURL=scanSouthAfricanDriversLicense.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanSouthAfricanDriversLicense.d.ts","sourceRoot":"","sources":["../../../src/scanSouthAfricanDriversLicense.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAEhE,wBAAgB,8BAA8B,IAAI,OAAO,CAAC,gCAAgC,CAAC,CAI1F"}
@@ -0,0 +1,8 @@
1
+ import type { SouthAfricanDriversLicenseResult } from './types';
2
+ /**
3
+ * Opens a headless (no preview UI) camera session, scans for a PDF417 barcode, and
4
+ * parses it as an SA driver's licence in one call. Rejects on timeout (~20s) or if
5
+ * no Activity is available.
6
+ */
7
+ export declare function scanSouthAfricanDriversLicense(): Promise<SouthAfricanDriversLicenseResult>;
8
+ //# sourceMappingURL=scanSouthAfricanDriversLicense.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanSouthAfricanDriversLicense.native.d.ts","sourceRoot":"","sources":["../../../src/scanSouthAfricanDriversLicense.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,OAAO,CAAC,gCAAgC,CAAC,CAE1F"}
@@ -0,0 +1,3 @@
1
+ import type { VehicleRegistrationResult } from './types';
2
+ export declare function scanVehicleRegistration(): Promise<VehicleRegistrationResult>;
3
+ //# sourceMappingURL=scanVehicleRegistration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanVehicleRegistration.d.ts","sourceRoot":"","sources":["../../../src/scanVehicleRegistration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD,wBAAgB,uBAAuB,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAI5E"}
@@ -0,0 +1,9 @@
1
+ import type { VehicleRegistrationResult } from './types';
2
+ /**
3
+ * Opens a headless (no preview UI) camera session, runs OCR on frames, and parses
4
+ * each result as a vehicle registration document -- stops once a frame yields a
5
+ * registration number or VIN. Rejects on timeout (~20s) or if no Activity is
6
+ * available.
7
+ */
8
+ export declare function scanVehicleRegistration(): Promise<VehicleRegistrationResult>;
9
+ //# sourceMappingURL=scanVehicleRegistration.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanVehicleRegistration.native.d.ts","sourceRoot":"","sources":["../../../src/scanVehicleRegistration.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAE5E"}
@@ -0,0 +1,237 @@
1
+ export type PetrusCameraPermissionStatus = 'granted' | 'denied' | 'blocked';
2
+ export interface PetrusFrameMetadata {
3
+ width: number;
4
+ height: number;
5
+ rotation: number;
6
+ /** Epoch milliseconds. */
7
+ timestamp: number;
8
+ }
9
+ export interface PetrusPoint2D {
10
+ x: number;
11
+ y: number;
12
+ }
13
+ /**
14
+ * Corners are normalized (0..1) relative to frameWidth x frameHeight -- the analysis
15
+ * frame's own (unrotated) buffer space, before rotationDegrees is applied.
16
+ */
17
+ export interface PetrusDocumentCorners {
18
+ topLeft: PetrusPoint2D;
19
+ topRight: PetrusPoint2D;
20
+ bottomRight: PetrusPoint2D;
21
+ bottomLeft: PetrusPoint2D;
22
+ frameWidth: number;
23
+ frameHeight: number;
24
+ rotationDegrees: number;
25
+ }
26
+ export interface PetrusDocumentDetectedEvent {
27
+ detected: boolean;
28
+ isStable: boolean;
29
+ stableDurationMs: number;
30
+ confidence: number;
31
+ /** Meaningless (zeroed) when `detected` is false -- check `detected` first. */
32
+ corners: PetrusDocumentCorners;
33
+ }
34
+ export interface PetrusCapturedEvent {
35
+ corners: PetrusDocumentCorners;
36
+ confidence: number;
37
+ /** Epoch milliseconds. */
38
+ timestamp: number;
39
+ }
40
+ export interface OCRBoundingBox {
41
+ left: number;
42
+ top: number;
43
+ right: number;
44
+ bottom: number;
45
+ }
46
+ /** One recognized word (ML Kit's finest granularity). */
47
+ export interface OCRWord {
48
+ text: string;
49
+ boundingBox: OCRBoundingBox;
50
+ /** [0, 1]; may read 0 on older Play Services versions -- see README. */
51
+ confidence: number;
52
+ }
53
+ export interface OCRLine {
54
+ text: string;
55
+ boundingBox: OCRBoundingBox;
56
+ /** [0, 1]; may read 0 on older Play Services versions -- see README. */
57
+ confidence: number;
58
+ words: OCRWord[];
59
+ }
60
+ /** ML Kit reports no confidence at block level -- only OCRLine/OCRWord carry one. */
61
+ export interface OCRBlock {
62
+ text: string;
63
+ boundingBox: OCRBoundingBox;
64
+ lines: OCRLine[];
65
+ }
66
+ /**
67
+ * Raw OCR output: text, geometry, confidence. Deliberately has no notion of document
68
+ * type or fields -- SA ID/driver's licence/MRZ/PDF417 parsing all consume this from
69
+ * outside; none of that logic lives in petrus-react-native or petrus-core.
70
+ */
71
+ export interface OCRResult {
72
+ fullText: string;
73
+ /** Average confidence across all recognized words; 0 if none. */
74
+ confidence: number;
75
+ blocks: OCRBlock[];
76
+ }
77
+ export type SouthAfricanGender = 'male' | 'female';
78
+ /** 0 = SA citizen, 1 = permanent resident, 2 = refugee; anything else is 'unknown'. */
79
+ export type SouthAfricanCitizenship = 'citizen' | 'permanent_resident' | 'refugee' | 'unknown';
80
+ export interface SouthAfricanDateOfBirth {
81
+ year: number;
82
+ month: number;
83
+ day: number;
84
+ }
85
+ export interface SouthAfricanIDValidation {
86
+ isValid: boolean;
87
+ hasValidChecksum: boolean;
88
+ hasValidDateOfBirth: boolean;
89
+ hasValidCitizenshipDigit: boolean;
90
+ }
91
+ /**
92
+ * `idNumber` is the best 13-digit candidate found in the text (digit-lookalike-
93
+ * corrected), even if it failed validation -- `isValid`/`validation` say whether it
94
+ * actually checks out. `dateOfBirth`/`gender`/`citizenship` are derived straight
95
+ * from `idNumber`'s digits regardless of checksum validity. All fields are `null`
96
+ * when no 13-digit candidate was found in the text at all.
97
+ */
98
+ export interface SouthAfricanIDResult {
99
+ idNumber: string | null;
100
+ isValid: boolean;
101
+ dateOfBirth: SouthAfricanDateOfBirth | null;
102
+ gender: SouthAfricanGender | null;
103
+ citizenship: SouthAfricanCitizenship | null;
104
+ validation: SouthAfricanIDValidation | null;
105
+ }
106
+ /**
107
+ * Raw output of scanning a PDF417 barcode -- no SA-specific interpretation. SA
108
+ * driver's licence barcodes carry binary (RSA-"encrypted") data, so `rawText` is
109
+ * rarely human-readable for them; pass `rawDataBase64` to
110
+ * parseSouthAfricanDriversLicense instead.
111
+ */
112
+ export interface PDF417ScanResult {
113
+ /** Base64-encoded raw decoded barcode bytes. */
114
+ rawDataBase64: string;
115
+ rawText: string;
116
+ }
117
+ /** Which reverse-engineered generation of the SA driver's licence barcode format was detected. */
118
+ export type SouthAfricanDriversLicenseVersion = 'v1' | 'v2';
119
+ export interface CalendarDate {
120
+ year: number;
121
+ month: number;
122
+ day: number;
123
+ }
124
+ /**
125
+ * Structured SA driver's licence fields decoded from a PDF417 barcode. See the
126
+ * README's confidence note on this reverse-engineered format before relying on
127
+ * these fields in production -- `parseWarnings` flags anything that looked
128
+ * malformed or implausible while parsing *this* barcode specifically.
129
+ */
130
+ export interface SouthAfricanDriversLicenseResult {
131
+ version: SouthAfricanDriversLicenseVersion;
132
+ surname: string;
133
+ initials: string;
134
+ idNumber: string | null;
135
+ /** Reuses the same SA ID validation used by parseSouthAfricanID. */
136
+ idNumberValidation: SouthAfricanIDValidation | null;
137
+ licenseNumber: string;
138
+ vehicleCodes: string[];
139
+ vehicleRestrictions: string[];
140
+ prdpCode: string | null;
141
+ idCountryOfIssue: string;
142
+ licenseCountryOfIssue: string;
143
+ gender: SouthAfricanGender | null;
144
+ dateOfBirth: CalendarDate | null;
145
+ licenseIssueNumber: number | null;
146
+ licenseValidFrom: CalendarDate | null;
147
+ licenseValidTo: CalendarDate | null;
148
+ prdpExpiry: CalendarDate | null;
149
+ driverRestrictionCodes: number[];
150
+ parseWarnings: string[];
151
+ }
152
+ /** Which NATIS/eNaTIS vehicle document type was detected -- see the README's confidence note. */
153
+ export type VehicleDocumentType = 'registration_certificate' | 'license_disc' | 'notification_of_change' | 'roadworthy_certificate' | 'unknown';
154
+ /**
155
+ * ISO 3779 structural checks (universal) plus an optional North American
156
+ * (SAE J853/NHTSA) position-9 check digit signal -- NOT universal, since South
157
+ * Africa isn't a North-American-format vehicle market. `null` when the VIN wasn't
158
+ * structurally valid to begin with (no check digit to evaluate).
159
+ */
160
+ export interface VINValidation {
161
+ hasValidLength: boolean;
162
+ hasValidCharacterSet: boolean;
163
+ isStructurallyValid: boolean;
164
+ northAmericanCheckDigitValid: boolean | null;
165
+ }
166
+ export interface VehicleRegistrationValidation {
167
+ isValid: boolean;
168
+ hasStructurallyValidVin: boolean;
169
+ hasPlausibleRegistrationNumber: boolean;
170
+ hasPlausibleYearModel: boolean;
171
+ }
172
+ /**
173
+ * Structured fields parsed from a NATIS/eNaTIS vehicle registration document. See
174
+ * the README's confidence note on label wording before relying on these fields in
175
+ * production -- `parseWarnings` flags anything that looked malformed or
176
+ * implausible while parsing *this* document specifically. `ownerIdNumber`/
177
+ * `ownerIdValidation` are a bonus cross-check using the same SA ID validation as
178
+ * parseSouthAfricanID, when an ID number happens to appear near the owner's name.
179
+ */
180
+ export interface VehicleRegistrationResult {
181
+ documentType: VehicleDocumentType;
182
+ registrationNumber: string | null;
183
+ vin: string | null;
184
+ vinValidation: VINValidation | null;
185
+ engineNumber: string | null;
186
+ make: string | null;
187
+ model: string | null;
188
+ yearModel: number | null;
189
+ ownerName: string | null;
190
+ ownerIdNumber: string | null;
191
+ ownerIdValidation: SouthAfricanIDValidation | null;
192
+ validation: VehicleRegistrationValidation;
193
+ parseWarnings: string[];
194
+ }
195
+ /** MRZ sex marker. `'unspecified'` covers ICAO 9303's `<` (unspecified) value, not just an OCR failure. */
196
+ export type MRZSex = 'male' | 'female' | 'unspecified';
197
+ /**
198
+ * A date decoded from an MRZ's 2-digit-year `YYMMDD` field, with the century
199
+ * resolved by `parseMRZ`/`scanPassport` -- ICAO 9303 doesn't itself specify a
200
+ * resolution rule; see the README's confidence note.
201
+ */
202
+ export interface MRZDate {
203
+ year: number;
204
+ month: number;
205
+ day: number;
206
+ twoDigitYear: number;
207
+ }
208
+ export interface MRZValidation {
209
+ isValid: boolean;
210
+ passportNumberCheckValid: boolean;
211
+ dateOfBirthCheckValid: boolean;
212
+ expiryDateCheckValid: boolean;
213
+ personalNumberCheckValid: boolean;
214
+ compositeCheckValid: boolean;
215
+ }
216
+ /**
217
+ * Structured fields parsed from an ICAO 9303 TD3 (passport) MRZ. `parseWarnings`
218
+ * flags anything that looked malformed or implausible while parsing *this*
219
+ * MRZ -- including "no MRZ found at all", in which case every `string` field is
220
+ * `""` and the date/personalNumber fields are `null` (this function never
221
+ * throws/returns null -- see the README's confidence note).
222
+ */
223
+ export interface PassportResult {
224
+ documentCode: string;
225
+ issuingCountry: string;
226
+ surname: string;
227
+ givenNames: string;
228
+ passportNumber: string;
229
+ nationality: string;
230
+ dateOfBirth: MRZDate | null;
231
+ sex: MRZSex;
232
+ dateOfExpiry: MRZDate | null;
233
+ personalNumber: string | null;
234
+ validation: MRZValidation;
235
+ parseWarnings: string[];
236
+ }
237
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAA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O,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,wBAAwB,EAAE,OAAO,CAAC;IAClC,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,aAAa,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB"}
package/package.json ADDED
@@ -0,0 +1,124 @@
1
+ {
2
+ "name": "petrus-react-native",
3
+ "version": "0.1.0",
4
+ "description": "Identity document capture, correction, OCR and field extraction for React Native",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "petrus-react-native-source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "clean": "del-cli android/build ios/build lib",
36
+ "prepare": "bob build",
37
+ "typecheck": "tsc",
38
+ "test": "jest"
39
+ },
40
+ "keywords": [
41
+ "react-native",
42
+ "ios",
43
+ "android"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/petrus/petrus.git",
48
+ "directory": "packages/petrus-react-native"
49
+ },
50
+ "author": "Munzhedzi Munyadziwa Petrus <phoquedmoll@gmail.com> (https://github.com/petrus)",
51
+ "license": "MIT",
52
+ "bugs": {
53
+ "url": "https://github.com/petrus/petrus-react-native/issues"
54
+ },
55
+ "homepage": "https://github.com/petrus/petrus-react-native#readme",
56
+ "publishConfig": {
57
+ "registry": "https://registry.npmjs.org/"
58
+ },
59
+ "devDependencies": {
60
+ "@jest/globals": "^29.7.0",
61
+ "@react-native/babel-preset": "0.85.0",
62
+ "@react-native/jest-preset": "0.85.0",
63
+ "@types/react": "^19.2.0",
64
+ "del-cli": "^7.0.0",
65
+ "jest": "^29.7.0",
66
+ "react": "19.2.3",
67
+ "react-native": "0.85.0",
68
+ "react-native-builder-bob": "^0.41.0",
69
+ "typescript": "^6.0.3"
70
+ },
71
+ "peerDependencies": {
72
+ "react": "*",
73
+ "react-native": "*"
74
+ },
75
+ "packageManager": "yarn@4.11.0",
76
+ "react-native-builder-bob": {
77
+ "source": "src",
78
+ "output": "lib",
79
+ "targets": [
80
+ [
81
+ "module",
82
+ {
83
+ "esm": true
84
+ }
85
+ ],
86
+ [
87
+ "typescript",
88
+ {
89
+ "project": "tsconfig.build.json"
90
+ }
91
+ ]
92
+ ]
93
+ },
94
+ "codegenConfig": {
95
+ "name": "PetrusReactNativeSpec",
96
+ "type": "all",
97
+ "jsSrcsDir": "src",
98
+ "android": {
99
+ "javaPackageName": "com.petrusreactnative"
100
+ }
101
+ },
102
+ "jest": {
103
+ "preset": "@react-native/jest-preset",
104
+ "testEnvironmentOptions": {
105
+ "customExportConditions": [
106
+ "require",
107
+ "react-native",
108
+ "<%- project.sourceCondition -%>"
109
+ ]
110
+ },
111
+ "modulePathIgnorePatterns": [
112
+ "<rootDir>/example/node_modules",
113
+ "<rootDir>/lib/"
114
+ ]
115
+ },
116
+ "create-react-native-library": {
117
+ "type": "turbo-module",
118
+ "languages": "kotlin-objc",
119
+ "tools": [
120
+ "jest"
121
+ ],
122
+ "version": "0.63.0"
123
+ }
124
+ }