@trustchex/react-native-sdk 1.163.7 → 1.163.10
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/TrustchexSDK.podspec +0 -1
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +9 -0
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +173 -157
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +15 -3
- package/lib/module/Shared/EIDReader/constants/eidConstants.js +65 -0
- package/lib/module/Shared/EIDReader/data/country.js +21 -44
- package/lib/module/Shared/EIDReader/data/countryInterface.js +1 -0
- package/lib/module/Shared/EIDReader/data/countryRegistry.js +65 -0
- package/lib/module/Shared/EIDReader/data/isoCountry.js +5 -1
- package/lib/module/Shared/EIDReader/data/unicodeCountry.js +5 -1
- package/lib/module/Shared/EIDReader/defaultFileSystem.js +4 -4
- package/lib/module/Shared/EIDReader/eidService.js +52 -51
- package/lib/module/Shared/EIDReader/lds/cvcaFile.js +2 -2
- package/lib/module/Shared/EIDReader/tlv/tlvCore.js +161 -0
- package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +13 -11
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -2
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +2 -0
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/EIDReader/constants/eidConstants.d.ts +58 -0
- package/lib/typescript/src/Shared/EIDReader/constants/eidConstants.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/data/country.d.ts +4 -5
- package/lib/typescript/src/Shared/EIDReader/data/country.d.ts.map +1 -1
- package/lib/typescript/src/Shared/EIDReader/data/countryInterface.d.ts +21 -0
- package/lib/typescript/src/Shared/EIDReader/data/countryInterface.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/data/countryRegistry.d.ts +14 -0
- package/lib/typescript/src/Shared/EIDReader/data/countryRegistry.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/data/isoCountry.d.ts.map +1 -1
- package/lib/typescript/src/Shared/EIDReader/data/unicodeCountry.d.ts.map +1 -1
- package/lib/typescript/src/Shared/EIDReader/eidService.d.ts.map +1 -1
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvCore.d.ts +22 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvCore.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts +2 -2
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts.map +1 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -2
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +1 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Shared/Components/QrCodeScannerCamera.tsx +15 -2
- package/src/Shared/EIDReader/constants/eidConstants.ts +67 -0
- package/src/Shared/EIDReader/data/country.ts +16 -47
- package/src/Shared/EIDReader/data/countryInterface.ts +21 -0
- package/src/Shared/EIDReader/data/countryRegistry.ts +73 -0
- package/src/Shared/EIDReader/data/isoCountry.ts +4 -0
- package/src/Shared/EIDReader/data/unicodeCountry.ts +4 -0
- package/src/Shared/EIDReader/defaultFileSystem.ts +4 -4
- package/src/Shared/EIDReader/eidService.ts +58 -53
- package/src/Shared/EIDReader/lds/cvcaFile.ts +2 -2
- package/src/Shared/EIDReader/tlv/tlvCore.ts +170 -0
- package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +13 -12
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -4
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +2 -0
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.js +0 -66
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts +0 -13
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts.map +0 -1
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.tsx +0 -85
|
@@ -12,166 +12,171 @@ import { BACProtocol } from './protocol/bacProtocol';
|
|
|
12
12
|
import { CommandAPDU } from './smartcards/commandAPDU';
|
|
13
13
|
import type { APDUListener } from './smartcards/apduListener';
|
|
14
14
|
import { APDUEvent } from './smartcards/apduEvent';
|
|
15
|
+
import { EID_CONSTANTS } from './constants/eidConstants';
|
|
15
16
|
|
|
16
17
|
export class EIDService extends AbstractMRTDCardService {
|
|
17
18
|
/** Shared secret type for non-PACE key. */
|
|
18
|
-
public static NO_PACE_KEY_REFERENCE: number =
|
|
19
|
+
public static NO_PACE_KEY_REFERENCE: number =
|
|
20
|
+
EID_CONSTANTS.NO_PACE_KEY_REFERENCE;
|
|
19
21
|
|
|
20
22
|
/** Shared secret type for PACE according to BSI TR-03110 v2.03 B.11.1. */
|
|
21
|
-
public static MRZ_PACE_KEY_REFERENCE: number =
|
|
23
|
+
public static MRZ_PACE_KEY_REFERENCE: number =
|
|
24
|
+
EID_CONSTANTS.MRZ_PACE_KEY_REFERENCE;
|
|
22
25
|
|
|
23
26
|
/** Shared secret type for PACE according to BSI TR-03110 v2.03 B.11.1. */
|
|
24
|
-
public static CAN_PACE_KEY_REFERENCE: number =
|
|
27
|
+
public static CAN_PACE_KEY_REFERENCE: number =
|
|
28
|
+
EID_CONSTANTS.CAN_PACE_KEY_REFERENCE;
|
|
25
29
|
|
|
26
30
|
/** Shared secret type for PACE according to BSI TR-03110 v2.03 B.11.1. */
|
|
27
|
-
public static PIN_PACE_KEY_REFERENCE: number =
|
|
31
|
+
public static PIN_PACE_KEY_REFERENCE: number =
|
|
32
|
+
EID_CONSTANTS.PIN_PACE_KEY_REFERENCE;
|
|
28
33
|
|
|
29
34
|
/** Shared secret type for PACE according to BSI TR-03110 v2.03 B.11.1. */
|
|
30
|
-
public static PUK_PACE_KEY_REFERENCE: number =
|
|
35
|
+
public static PUK_PACE_KEY_REFERENCE: number =
|
|
36
|
+
EID_CONSTANTS.PUK_PACE_KEY_REFERENCE;
|
|
31
37
|
|
|
32
38
|
/** Card Access. */
|
|
33
|
-
public static EF_CARD_ACCESS: number =
|
|
39
|
+
public static EF_CARD_ACCESS: number = EID_CONSTANTS.EF_CARD_ACCESS;
|
|
34
40
|
|
|
35
41
|
/** Card Security. */
|
|
36
|
-
public static EF_CARD_SECURITY: number =
|
|
42
|
+
public static EF_CARD_SECURITY: number = EID_CONSTANTS.EF_CARD_SECURITY;
|
|
37
43
|
|
|
38
44
|
/** File identifier for data group 1. Data group 1 contains the MRZ. */
|
|
39
|
-
public static EF_DG1: number =
|
|
45
|
+
public static EF_DG1: number = EID_CONSTANTS.EF_DG1;
|
|
40
46
|
|
|
41
47
|
/** File identifier for data group 2. Data group 2 contains face image data. */
|
|
42
|
-
public static EF_DG2: number =
|
|
48
|
+
public static EF_DG2: number = EID_CONSTANTS.EF_DG2;
|
|
43
49
|
|
|
44
50
|
/** File identifier for data group 3. Data group 3 contains finger print data. */
|
|
45
|
-
public static EF_DG3: number =
|
|
51
|
+
public static EF_DG3: number = EID_CONSTANTS.EF_DG3;
|
|
46
52
|
|
|
47
53
|
/** File identifier for data group 4. Data group 4 contains iris data. */
|
|
48
|
-
public static EF_DG4: number =
|
|
54
|
+
public static EF_DG4: number = EID_CONSTANTS.EF_DG4;
|
|
49
55
|
|
|
50
56
|
/** File identifier for data group 5. Data group 5 contains displayed portrait. */
|
|
51
|
-
public static EF_DG5: number =
|
|
57
|
+
public static EF_DG5: number = EID_CONSTANTS.EF_DG5;
|
|
52
58
|
|
|
53
59
|
/** File identifier for data group 6. Data group 6 is RFU. */
|
|
54
|
-
public static EF_DG6: number =
|
|
60
|
+
public static EF_DG6: number = EID_CONSTANTS.EF_DG6;
|
|
55
61
|
|
|
56
62
|
/** File identifier for data group 7. Data group 7 contains displayed signature. */
|
|
57
|
-
public static EF_DG7: number =
|
|
63
|
+
public static EF_DG7: number = EID_CONSTANTS.EF_DG7;
|
|
58
64
|
|
|
59
65
|
/** File identifier for data group 8. Data group 8 contains data features. */
|
|
60
|
-
public static EF_DG8: number =
|
|
66
|
+
public static EF_DG8: number = EID_CONSTANTS.EF_DG8;
|
|
61
67
|
|
|
62
68
|
/** File identifier for data group 9. Data group 9 contains structure features. */
|
|
63
|
-
public static EF_DG9: number =
|
|
69
|
+
public static EF_DG9: number = EID_CONSTANTS.EF_DG9;
|
|
64
70
|
|
|
65
71
|
/** File identifier for data group 10. Data group 10 contains substance features. */
|
|
66
|
-
public static EF_DG10: number =
|
|
72
|
+
public static EF_DG10: number = EID_CONSTANTS.EF_DG10;
|
|
67
73
|
|
|
68
74
|
/** File identifier for data group 11. Data group 11 contains additional personal details. */
|
|
69
|
-
public static EF_DG11: number =
|
|
75
|
+
public static EF_DG11: number = EID_CONSTANTS.EF_DG11;
|
|
70
76
|
|
|
71
77
|
/** File identifier for data group 12. Data group 12 contains additional document details. */
|
|
72
|
-
public static EF_DG12: number =
|
|
78
|
+
public static EF_DG12: number = EID_CONSTANTS.EF_DG12;
|
|
73
79
|
|
|
74
80
|
/** File identifier for data group 13. Data group 13 contains optional details. */
|
|
75
|
-
public static EF_DG13: number =
|
|
81
|
+
public static EF_DG13: number = EID_CONSTANTS.EF_DG13;
|
|
76
82
|
|
|
77
83
|
/** File identifier for data group 14. Data group 14 contains security infos. */
|
|
78
|
-
public static EF_DG14: number =
|
|
84
|
+
public static EF_DG14: number = EID_CONSTANTS.EF_DG14;
|
|
79
85
|
|
|
80
86
|
/** File identifier for data group 15. Data group 15 contains the public key used for Active Authentication. */
|
|
81
|
-
public static EF_DG15: number =
|
|
87
|
+
public static EF_DG15: number = EID_CONSTANTS.EF_DG15;
|
|
82
88
|
|
|
83
89
|
/** File identifier for data group 16. Data group 16 contains person(s) to notify. */
|
|
84
|
-
public static EF_DG16: number =
|
|
90
|
+
public static EF_DG16: number = EID_CONSTANTS.EF_DG16;
|
|
85
91
|
|
|
86
92
|
/** The security document. */
|
|
87
|
-
public static EF_SOD: number =
|
|
93
|
+
public static EF_SOD: number = EID_CONSTANTS.EF_SOD;
|
|
88
94
|
|
|
89
95
|
/** The data group presence list. */
|
|
90
|
-
public static EF_COM: number =
|
|
96
|
+
public static EF_COM: number = EID_CONSTANTS.EF_COM;
|
|
91
97
|
|
|
92
98
|
/**
|
|
93
99
|
* Contains EAC CVA references. Note: this can be overridden by a file
|
|
94
100
|
* identifier in the DG14 file (in a TerminalAuthenticationInfo). Check DG14
|
|
95
101
|
* first. Also, this file does not have a header tag, like the others.
|
|
96
102
|
*/
|
|
97
|
-
public static EF_CVCA: number =
|
|
103
|
+
public static EF_CVCA: number = EID_CONSTANTS.EF_CVCA;
|
|
98
104
|
|
|
99
105
|
/** Short file identifier for card access file. */
|
|
100
|
-
public static SFI_CARD_ACCESS: number =
|
|
106
|
+
public static SFI_CARD_ACCESS: number = EID_CONSTANTS.SFI_CARD_ACCESS;
|
|
101
107
|
|
|
102
108
|
/** Short file identifier for card security file. */
|
|
103
|
-
public static SFI_CARD_SECURITY: number =
|
|
109
|
+
public static SFI_CARD_SECURITY: number = EID_CONSTANTS.SFI_CARD_SECURITY;
|
|
104
110
|
|
|
105
111
|
/** Short file identifier for file. */
|
|
106
|
-
public static SFI_DG1: number =
|
|
112
|
+
public static SFI_DG1: number = EID_CONSTANTS.SFI_DG1;
|
|
107
113
|
|
|
108
114
|
/** Short file identifier for file. */
|
|
109
|
-
public static SFI_DG2: number =
|
|
115
|
+
public static SFI_DG2: number = EID_CONSTANTS.SFI_DG2;
|
|
110
116
|
|
|
111
117
|
/** Short file identifier for file. */
|
|
112
|
-
public static SFI_DG3: number =
|
|
118
|
+
public static SFI_DG3: number = EID_CONSTANTS.SFI_DG3;
|
|
113
119
|
|
|
114
120
|
/** Short file identifier for file. */
|
|
115
|
-
public static SFI_DG4: number =
|
|
121
|
+
public static SFI_DG4: number = EID_CONSTANTS.SFI_DG4;
|
|
116
122
|
|
|
117
123
|
/** Short file identifier for file. */
|
|
118
|
-
public static SFI_DG5: number =
|
|
124
|
+
public static SFI_DG5: number = EID_CONSTANTS.SFI_DG5;
|
|
119
125
|
|
|
120
126
|
/** Short file identifier for file. */
|
|
121
|
-
public static SFI_DG6: number =
|
|
127
|
+
public static SFI_DG6: number = EID_CONSTANTS.SFI_DG6;
|
|
122
128
|
|
|
123
129
|
/** Short file identifier for file. */
|
|
124
|
-
public static SFI_DG7: number =
|
|
130
|
+
public static SFI_DG7: number = EID_CONSTANTS.SFI_DG7;
|
|
125
131
|
|
|
126
132
|
/** Short file identifier for file. */
|
|
127
|
-
public static SFI_DG8: number =
|
|
133
|
+
public static SFI_DG8: number = EID_CONSTANTS.SFI_DG8;
|
|
128
134
|
|
|
129
135
|
/** Short file identifier for file. */
|
|
130
|
-
public static SFI_DG9: number =
|
|
136
|
+
public static SFI_DG9: number = EID_CONSTANTS.SFI_DG9;
|
|
131
137
|
|
|
132
138
|
/** Short file identifier for file. */
|
|
133
|
-
public static SFI_DG10: number =
|
|
139
|
+
public static SFI_DG10: number = EID_CONSTANTS.SFI_DG10;
|
|
134
140
|
|
|
135
141
|
/** Short file identifier for file. */
|
|
136
|
-
public static SFI_DG11: number =
|
|
142
|
+
public static SFI_DG11: number = EID_CONSTANTS.SFI_DG11;
|
|
137
143
|
|
|
138
144
|
/** Short file identifier for file. */
|
|
139
|
-
public static SFI_DG12: number =
|
|
145
|
+
public static SFI_DG12: number = EID_CONSTANTS.SFI_DG12;
|
|
140
146
|
|
|
141
147
|
/** Short file identifier for file. */
|
|
142
|
-
public static SFI_DG13: number =
|
|
148
|
+
public static SFI_DG13: number = EID_CONSTANTS.SFI_DG13;
|
|
143
149
|
|
|
144
150
|
/** Short file identifier for file. */
|
|
145
|
-
public static SFI_DG14: number =
|
|
151
|
+
public static SFI_DG14: number = EID_CONSTANTS.SFI_DG14;
|
|
146
152
|
|
|
147
153
|
/** Short file identifier for file. */
|
|
148
|
-
public static SFI_DG15: number =
|
|
154
|
+
public static SFI_DG15: number = EID_CONSTANTS.SFI_DG15;
|
|
149
155
|
|
|
150
156
|
/** Short file identifier for file. */
|
|
151
|
-
public static SFI_DG16: number =
|
|
157
|
+
public static SFI_DG16: number = EID_CONSTANTS.SFI_DG16;
|
|
152
158
|
|
|
153
159
|
/** Short file identifier for file. */
|
|
154
|
-
public static SFI_COM: number =
|
|
160
|
+
public static SFI_COM: number = EID_CONSTANTS.SFI_COM;
|
|
155
161
|
|
|
156
162
|
/** Short file identifier for file. */
|
|
157
|
-
public static SFI_SOD: number =
|
|
163
|
+
public static SFI_SOD: number = EID_CONSTANTS.SFI_SOD;
|
|
158
164
|
|
|
159
165
|
/** Short file identifier for file. */
|
|
160
|
-
public static SFI_CVCA: number =
|
|
166
|
+
public static SFI_CVCA: number = EID_CONSTANTS.SFI_CVCA;
|
|
161
167
|
|
|
162
168
|
/** The default maximal blocksize used for unencrypted APDUs. */
|
|
163
|
-
public static DEFAULT_MAX_BLOCKSIZE: number =
|
|
169
|
+
public static DEFAULT_MAX_BLOCKSIZE: number =
|
|
170
|
+
EID_CONSTANTS.DEFAULT_MAX_BLOCKSIZE;
|
|
164
171
|
|
|
165
172
|
/** The normal maximal transceive length of APDUs. */
|
|
166
|
-
public static NORMAL_MAX_TRANSCEIVE_LENGTH: number =
|
|
173
|
+
public static NORMAL_MAX_TRANSCEIVE_LENGTH: number = EID_CONSTANTS.NORMAL_MAX_TRANSCEIVE_LENGTH;
|
|
167
174
|
|
|
168
175
|
/** The extended maximal transceive length of APDUs. */
|
|
169
|
-
public static EXTENDED_MAX_TRANSCEIVE_LENGTH: number =
|
|
176
|
+
public static EXTENDED_MAX_TRANSCEIVE_LENGTH: number = EID_CONSTANTS.EXTENDED_MAX_TRANSCEIVE_LENGTH;
|
|
170
177
|
|
|
171
178
|
/** The applet we select when we start a session. */
|
|
172
|
-
public static APPLET_AID: Uint8Array =
|
|
173
|
-
0xa0, 0x00, 0x00, 0x02, 0x47, 0x10, 0x01,
|
|
174
|
-
]);
|
|
179
|
+
public static APPLET_AID: Uint8Array = EID_CONSTANTS.APPLET_AID;
|
|
175
180
|
|
|
176
181
|
private maxBlockSize: number;
|
|
177
182
|
private isOpen: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EID_CONSTANTS } from '../constants/eidConstants';
|
|
2
2
|
import { CVCPrincipal } from '../cert/cvcPrincipal';
|
|
3
3
|
import { InputStream } from '../java/inputStream';
|
|
4
4
|
import { OutputStream } from '../java/outputStream';
|
|
@@ -31,7 +31,7 @@ export class CVCAFile {
|
|
|
31
31
|
this.caReference = caReference;
|
|
32
32
|
this.altCAReference = altCAReference || null;
|
|
33
33
|
} else {
|
|
34
|
-
this.fid =
|
|
34
|
+
this.fid = EID_CONSTANTS.EF_CVCA;
|
|
35
35
|
this.readObject(fidOrInputStream);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ASN1Constants } from './asn1Constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core TLV utility functions that don't depend on TLVInputStream/TLVOutputStream
|
|
5
|
+
* to avoid circular dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export class TLVCore extends ASN1Constants {
|
|
8
|
+
// Tag class constants
|
|
9
|
+
public static readonly UNIVERSAL_CLASS = 0;
|
|
10
|
+
public static readonly APPLICATION_CLASS = 1;
|
|
11
|
+
public static readonly CONTEXT_SPECIFIC_CLASS = 2;
|
|
12
|
+
public static readonly PRIVATE_CLASS = 3;
|
|
13
|
+
|
|
14
|
+
public static isPrimitive(tag: number): boolean {
|
|
15
|
+
let i = 3;
|
|
16
|
+
for (; i >= 0; i--) {
|
|
17
|
+
const mask = 0xff << (8 * i);
|
|
18
|
+
if ((tag & mask) !== 0x00) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const msByte = ((tag & (0xff << (8 * i))) >> (8 * i)) & 0xff;
|
|
23
|
+
return (msByte & 0x20) === 0x00;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static getTagLength(tag: number): number {
|
|
27
|
+
if (tag < 0x1f) {
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
if (tag < 0x80) {
|
|
31
|
+
return 2;
|
|
32
|
+
}
|
|
33
|
+
if (tag < 0x8000) {
|
|
34
|
+
return 3;
|
|
35
|
+
}
|
|
36
|
+
if (tag < 0x800000) {
|
|
37
|
+
return 4;
|
|
38
|
+
}
|
|
39
|
+
return 5;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static isValidTag(tag: number): boolean {
|
|
43
|
+
return tag >= 0x00 && tag <= 0xffffffff;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public static getLengthLength(length: number): number {
|
|
47
|
+
if (length < 0x80) {
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
if (length < 0x100) {
|
|
51
|
+
return 2;
|
|
52
|
+
}
|
|
53
|
+
if (length < 0x10000) {
|
|
54
|
+
return 3;
|
|
55
|
+
}
|
|
56
|
+
if (length < 0x1000000) {
|
|
57
|
+
return 4;
|
|
58
|
+
}
|
|
59
|
+
return 5;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public static getTagAsBytes(tag: number): number[] {
|
|
63
|
+
const out: number[] = [];
|
|
64
|
+
const byteCount = Math.floor(Math.log(tag) / Math.log(256)) + 1;
|
|
65
|
+
for (let i = 0; i < byteCount; i++) {
|
|
66
|
+
const pos = 8 * (byteCount - i - 1);
|
|
67
|
+
out.push((tag & (0xff << pos)) >> pos);
|
|
68
|
+
}
|
|
69
|
+
const tagBytes = out;
|
|
70
|
+
switch (TLVCore.getTagClass(tag)) {
|
|
71
|
+
case TLVCore.APPLICATION_CLASS:
|
|
72
|
+
tagBytes[0] |= 0x40;
|
|
73
|
+
break;
|
|
74
|
+
case TLVCore.CONTEXT_SPECIFIC_CLASS:
|
|
75
|
+
tagBytes[0] |= 0x80;
|
|
76
|
+
break;
|
|
77
|
+
case TLVCore.PRIVATE_CLASS:
|
|
78
|
+
tagBytes[0] |= 0xc0;
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
/* NOTE: Unsupported tag class. Now what? */
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
if (!TLVCore.isPrimitive(tag)) {
|
|
85
|
+
tagBytes[0] |= 0x20;
|
|
86
|
+
}
|
|
87
|
+
return tagBytes;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public static getLengthAsBytes(length: number): number[] {
|
|
91
|
+
const out: number[] = [];
|
|
92
|
+
if (length < 0x80) {
|
|
93
|
+
/* short form */
|
|
94
|
+
out.push(length);
|
|
95
|
+
} else {
|
|
96
|
+
const byteCount = TLVCore.log(length, 256);
|
|
97
|
+
out.push(0x80 | byteCount);
|
|
98
|
+
for (let i = 0; i < byteCount; i++) {
|
|
99
|
+
const pos = 8 * (byteCount - i - 1);
|
|
100
|
+
out.push((length & (0xff << pos)) >> pos);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public static getTagClass(tag: number): number {
|
|
107
|
+
let i = 3;
|
|
108
|
+
for (; i >= 0; i--) {
|
|
109
|
+
const mask = 0xff << (8 * i);
|
|
110
|
+
if ((tag & mask) !== 0x00) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const msByte = ((tag & (0xff << (8 * i))) >> (8 * i)) & 0xff;
|
|
115
|
+
switch (msByte & 0xc0) {
|
|
116
|
+
case 0x00:
|
|
117
|
+
return TLVCore.UNIVERSAL_CLASS;
|
|
118
|
+
case 0x40:
|
|
119
|
+
return TLVCore.APPLICATION_CLASS;
|
|
120
|
+
case 0x80:
|
|
121
|
+
return TLVCore.CONTEXT_SPECIFIC_CLASS;
|
|
122
|
+
case 0xc0:
|
|
123
|
+
default:
|
|
124
|
+
return TLVCore.PRIVATE_CLASS;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private static log(n: number, base: number): number {
|
|
129
|
+
let result = 0;
|
|
130
|
+
while (n > 0) {
|
|
131
|
+
n = n / base;
|
|
132
|
+
result++;
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public static writeTagLength(tag: number, length: number): Uint8Array {
|
|
138
|
+
const tagLength = TLVCore.getTagLength(tag);
|
|
139
|
+
const lengthLength = TLVCore.getLengthLength(length);
|
|
140
|
+
const result = new Uint8Array(tagLength + lengthLength);
|
|
141
|
+
let offset = 0;
|
|
142
|
+
|
|
143
|
+
// Write tag
|
|
144
|
+
if (tagLength === 1) {
|
|
145
|
+
result[offset++] = tag & 0xff;
|
|
146
|
+
} else if (tagLength === 2) {
|
|
147
|
+
result[offset++] = 0x1f;
|
|
148
|
+
result[offset++] = tag & 0xff;
|
|
149
|
+
} else {
|
|
150
|
+
result[offset++] = 0x1f;
|
|
151
|
+
for (let i = tagLength - 2; i >= 0; i--) {
|
|
152
|
+
result[offset++] = (tag >> (i * 8)) & 0xff;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Write length
|
|
157
|
+
if (lengthLength === 1) {
|
|
158
|
+
result[offset++] = length & 0xff;
|
|
159
|
+
} else {
|
|
160
|
+
result[offset++] = 0x80 | (lengthLength - 1);
|
|
161
|
+
for (let i = lengthLength - 2; i >= 0; i--) {
|
|
162
|
+
result[offset++] = (length >> (i * 8)) & 0xff;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export default TLVCore;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ByteArrayInputStream } from '../java/byteArrayInputStream';
|
|
2
2
|
import { DataInputStream } from '../java/dataInputStream';
|
|
3
3
|
import { InputStream } from '../java/inputStream';
|
|
4
|
-
import
|
|
4
|
+
import TLVCore from './tlvCore';
|
|
5
5
|
import { TLVInputState } from './tlvInputState';
|
|
6
6
|
|
|
7
7
|
export class TLVInputStream extends InputStream {
|
|
@@ -132,11 +132,11 @@ export class TLVInputStream extends InputStream {
|
|
|
132
132
|
if (this.state.getIsAtStartOfTag()) {
|
|
133
133
|
} else if (this.state.getIsAtStartOfLength()) {
|
|
134
134
|
await this.readLength();
|
|
135
|
-
if (
|
|
135
|
+
if (TLVCore.isPrimitive(this.state.getTag())) {
|
|
136
136
|
await this.skipValue();
|
|
137
137
|
}
|
|
138
138
|
} else {
|
|
139
|
-
if (
|
|
139
|
+
if (TLVCore.isPrimitive(this.state.getTag())) {
|
|
140
140
|
await this.skipValue();
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -144,7 +144,7 @@ export class TLVInputStream extends InputStream {
|
|
|
144
144
|
if (tag === searchTag) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
if (
|
|
147
|
+
if (TLVCore.isPrimitive(tag)) {
|
|
148
148
|
const length = await this.readLength();
|
|
149
149
|
const skippedBytes = await this.skipValue();
|
|
150
150
|
if (skippedBytes >= length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TLVCore from './tlvCore';
|
|
2
2
|
|
|
3
3
|
export class TLVOutputState {
|
|
4
4
|
private state: TLVStruct[];
|
|
@@ -68,7 +68,7 @@ export class TLVOutputState {
|
|
|
68
68
|
const obj = new TLVStruct(tag);
|
|
69
69
|
if (this.state.length !== 0) {
|
|
70
70
|
const parent = this.state[this.state.length - 1];
|
|
71
|
-
const tagBytes =
|
|
71
|
+
const tagBytes = TLVCore.getTagAsBytes(tag);
|
|
72
72
|
parent.write(tagBytes, 0, tagBytes.length);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -99,7 +99,7 @@ export class TLVOutputState {
|
|
|
99
99
|
const obj = this.state.pop();
|
|
100
100
|
if (this.state.length !== 0) {
|
|
101
101
|
const parent = this.state[this.state.length - 1];
|
|
102
|
-
const lengthBytes =
|
|
102
|
+
const lengthBytes = TLVCore.getLengthAsBytes(length);
|
|
103
103
|
parent.write(lengthBytes, 0, lengthBytes.length);
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -125,7 +125,7 @@ export class TLVOutputState {
|
|
|
125
125
|
currentObject.getValueBytesProcessed() === currentObject.getLength()
|
|
126
126
|
) {
|
|
127
127
|
this.state.pop();
|
|
128
|
-
const lengthBytes =
|
|
128
|
+
const lengthBytes = TLVCore.getLengthAsBytes(byteCount);
|
|
129
129
|
const value = currentObject.getValue();
|
|
130
130
|
this.updateValueBytesProcessed(lengthBytes, 0, lengthBytes.length);
|
|
131
131
|
this.updateValueBytesProcessed(value, 0, value.length);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataOutputStream } from '../java/dataOutputStream';
|
|
2
2
|
import { OutputStream } from '../java/outputStream';
|
|
3
|
-
import
|
|
3
|
+
import TLVCore from './tlvCore';
|
|
4
4
|
import { TLVOutputState } from './tlvOutputState';
|
|
5
5
|
|
|
6
6
|
export class TLVOutputStream extends OutputStream {
|
|
@@ -16,21 +16,22 @@ export class TLVOutputStream extends OutputStream {
|
|
|
16
16
|
this.state = new TLVOutputState();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
writeTag(tag: number): void {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.outputStream.writeBytes(Uint8Array.from(tagAsBytes));
|
|
19
|
+
public async writeTag(tag: number): Promise<void> {
|
|
20
|
+
if (!this.state.getIsAtStartOfTag()) {
|
|
21
|
+
throw new Error('Cannot write tag, still need length');
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
const tagAsBytes = TLVCore.getTagAsBytes(tag);
|
|
24
|
+
await this.outputStream.writeBytes(Uint8Array.from(tagAsBytes));
|
|
25
25
|
this.state.setTagProcessed(tag);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
writeLength(length: number): void {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (this.state.canBeWritten()) {
|
|
32
|
-
this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
28
|
+
public async writeLength(length: number): Promise<void> {
|
|
29
|
+
if (!this.state.getIsAtStartOfLength()) {
|
|
30
|
+
throw new Error('Cannot write length');
|
|
33
31
|
}
|
|
32
|
+
const lengthAsBytes = TLVCore.getLengthAsBytes(length);
|
|
33
|
+
await this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
34
|
+
this.state.setLengthProcessed(length);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
writeValue(value: Uint8Array): void {
|
|
@@ -91,7 +92,7 @@ export class TLVOutputStream extends OutputStream {
|
|
|
91
92
|
const length = bufferedValueBytes.length;
|
|
92
93
|
this.state.updatePreviousLength(length);
|
|
93
94
|
if (this.state.canBeWritten()) {
|
|
94
|
-
const lengthAsBytes =
|
|
95
|
+
const lengthAsBytes = TLVCore.getLengthAsBytes(length);
|
|
95
96
|
this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
96
97
|
this.outputStream.writeBytes(Uint8Array.from(bufferedValueBytes));
|
|
97
98
|
}
|
|
@@ -31,10 +31,6 @@ export type {
|
|
|
31
31
|
} from './hooks/useBarcodeScanner';
|
|
32
32
|
export type { UseCameraPermissionResult } from './hooks/useCameraPermissions';
|
|
33
33
|
|
|
34
|
-
// Components
|
|
35
|
-
export { BarcodeCamera } from './components/BarcodeCamera';
|
|
36
|
-
export type { BarcodeCameraProps } from './components/BarcodeCamera';
|
|
37
|
-
|
|
38
34
|
// Utilities
|
|
39
35
|
export {
|
|
40
36
|
convertFrameToScreen,
|
|
@@ -20,6 +20,8 @@ export function createBarcodeScannerPlugin(): BarcodeScannerPlugin {
|
|
|
20
20
|
try {
|
|
21
21
|
// @ts-ignore
|
|
22
22
|
const result = plugin.call(frame, options) as Barcode[];
|
|
23
|
+
|
|
24
|
+
// iOS now handles coordinate conversion, so return results directly
|
|
23
25
|
return result || [];
|
|
24
26
|
} catch (error) {
|
|
25
27
|
console.warn('scanCodes: Plugin call failed:', error);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useCallback, useState } from 'react';
|
|
4
|
-
import { StyleSheet, View } from 'react-native';
|
|
5
|
-
import { Camera, useCameraDevices } from 'react-native-vision-camera';
|
|
6
|
-
import { useBarcodeScanner, useCameraPermissions } from "../index.js";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
export const BarcodeCamera = ({
|
|
9
|
-
style,
|
|
10
|
-
isActive = true,
|
|
11
|
-
device = 'back',
|
|
12
|
-
enableZoomGesture = true,
|
|
13
|
-
onBarcodeScanned,
|
|
14
|
-
onError,
|
|
15
|
-
onInitialized,
|
|
16
|
-
...barcodeScannerOptions
|
|
17
|
-
}) => {
|
|
18
|
-
const devices = useCameraDevices();
|
|
19
|
-
const cameraDevice = devices.find(d => device === 'back' ? d.position === 'back' : d.position === 'front');
|
|
20
|
-
const {
|
|
21
|
-
hasPermission,
|
|
22
|
-
requestPermission
|
|
23
|
-
} = useCameraPermissions();
|
|
24
|
-
const [isCameraInitialized, setIsCameraInitialized] = useState(false);
|
|
25
|
-
const {
|
|
26
|
-
scanBarcodes
|
|
27
|
-
} = useBarcodeScanner({
|
|
28
|
-
...barcodeScannerOptions,
|
|
29
|
-
onBarcodeScanned,
|
|
30
|
-
onError
|
|
31
|
-
});
|
|
32
|
-
const handleCameraInitialized = useCallback(() => {
|
|
33
|
-
setIsCameraInitialized(true);
|
|
34
|
-
onInitialized?.();
|
|
35
|
-
}, [onInitialized]);
|
|
36
|
-
|
|
37
|
-
// Request permission if not granted
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
if (!hasPermission) {
|
|
40
|
-
requestPermission();
|
|
41
|
-
}
|
|
42
|
-
}, [hasPermission, requestPermission]);
|
|
43
|
-
if (!hasPermission || !cameraDevice) {
|
|
44
|
-
return /*#__PURE__*/_jsx(View, {
|
|
45
|
-
style: [styles.container, style]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return /*#__PURE__*/_jsx(Camera, {
|
|
49
|
-
style: [styles.camera, style],
|
|
50
|
-
device: cameraDevice,
|
|
51
|
-
isActive: isActive && isCameraInitialized,
|
|
52
|
-
enableZoomGesture: enableZoomGesture,
|
|
53
|
-
onInitialized: handleCameraInitialized,
|
|
54
|
-
onError: onError
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const styles = StyleSheet.create({
|
|
58
|
-
container: {
|
|
59
|
-
flex: 1,
|
|
60
|
-
backgroundColor: 'black'
|
|
61
|
-
},
|
|
62
|
-
camera: {
|
|
63
|
-
flex: 1
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
export default BarcodeCamera;
|
package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type UseBarcodeScannerOptions } from '../index';
|
|
3
|
-
export interface BarcodeCameraProps extends UseBarcodeScannerOptions {
|
|
4
|
-
style?: any;
|
|
5
|
-
isActive?: boolean;
|
|
6
|
-
device?: 'back' | 'front';
|
|
7
|
-
enableZoomGesture?: boolean;
|
|
8
|
-
onInitialized?: () => void;
|
|
9
|
-
onError?: (error: Error) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const BarcodeCamera: React.FC<BarcodeCameraProps>;
|
|
12
|
-
export default BarcodeCamera;
|
|
13
|
-
//# sourceMappingURL=BarcodeCamera.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BarcodeCamera.d.ts","sourceRoot":"","sources":["../../../../../../../src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAOrD,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,kBAAmB,SAAQ,wBAAwB;IAClE,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiDtD,CAAC;AAYF,eAAe,aAAa,CAAC"}
|