@pagopa/io-react-native-cie 1.2.0 → 1.2.2

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.
@@ -100,7 +100,7 @@ export const setCurrentAlertMessage = value => {
100
100
  * Initiates the internal authentication process using the provided challenge and timeout.
101
101
  *
102
102
  * @param challenge - The challenge string to be used for authentication.
103
- * @param resultEncoding - The encoding of the result byte arrays, either 'base64' or 'hex' (default: 'base64')
103
+ * @param resultEncoding - The encoding of the result byte arrays, either 'base64', 'base64url' or 'hex' (default: 'base64')
104
104
  * @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
105
105
  * @returns A promise that resolves when the authentication process has ended.
106
106
  */
@@ -108,6 +108,103 @@ const startInternalAuthentication = async (challenge, resultEncoding = 'base64',
108
108
  return IoReactNativeCie.startInternalAuthentication(challenge, resultEncoding, timeout);
109
109
  };
110
110
 
111
+ /**
112
+ * Initiates a PACE (Password Authenticated Connection Establishment) reading
113
+ * session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
114
+ * Access Number) to read the MRTD information.
115
+ *
116
+ * The operation is asynchronous; Since the Promise resolves
117
+ * with `void`, any resulting data or errors are expected to be surfaced through
118
+ * native events.
119
+ *
120
+ * @param can The 6‑digit Card Access Number printed on the CIE, used to
121
+ * bootstrap the PACE secure messaging protocol. Must be a numeric
122
+ * string; validation (if any) occurs in the native layer.
123
+ * @param resultEncoding The encoding format expected for any binary payloads
124
+ * produced during the reading process. Defaults to
125
+ * `'base64'`. Use `'hex'` if downstream consumers require
126
+ * hexadecimal representation.
127
+ * @param timeout Maximum time (in milliseconds) allowed for the PACE reading
128
+ * session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
129
+ * A larger value may be required on older devices or in
130
+ * environments with slower NFC interactions.
131
+ *
132
+ * @returns Promise that resolves when the reading process has started.
133
+ *
134
+ * @throws May reject with:
135
+ * - Invalid input (e.g., malformed CAN).
136
+ * - NFC subsystem unavailable or disabled.
137
+ * - Operation timeout exceeded.
138
+ * - Native module internal errors.
139
+ *
140
+ * @example
141
+ * await startPaceReading("123456"); // Uses base64 encoding and default timeout.
142
+ *
143
+ * @example
144
+ * await startPaceReading("654321", "hex", 15000);
145
+ *
146
+ * @remarks
147
+ * Ensure NFC is enabled and the user has positioned the CIE correctly before
148
+ * calling this function to minimize timeouts and improve reliability.
149
+ *
150
+ * Once the MRTD reading with PACE flow has been initiated, a Promise resolves,
151
+ * while when the reading process produces data, the `'onSuccess'` event has been called.
152
+ * The `'onError'` event is called if an error occurs during the reading process.
153
+ * The `'onEvent'` event is called to provide progress updates.
154
+ */
155
+ const startMRTDReading = async (can, resultEncoding = 'base64', timeout = DEFAULT_TIMEOUT) => {
156
+ return IoReactNativeCie.startMRTDReading(can, resultEncoding, timeout);
157
+ };
158
+
159
+ /**
160
+ * Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
161
+ * that performs both Internal Authentication and MRTD reading using PACE.
162
+ *
163
+ * The operation is asynchronous; Since the Promise resolves
164
+ * with `void`, any resulting data or errors are expected to be surfaced through
165
+ * native events.
166
+ *
167
+ * @param can The 6‑digit Card Access Number printed on the CIE, used to
168
+ * bootstrap the PACE secure messaging protocol. Must be a numeric
169
+ * string; validation (if any) occurs in the native layer.
170
+ * @param challenge The challenge string to be used for Internal Authentication.
171
+ * @param resultEncoding The encoding format expected for any binary payloads
172
+ * produced during the reading process. Defaults to
173
+ * `'base64'`. Use `'hex'` if downstream consumers require
174
+ * hexadecimal representation.
175
+ * @param timeout Maximum time (in milliseconds) allowed for the combined reading
176
+ * session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
177
+ * A larger value may be required on older devices or in
178
+ * environments with slower NFC interactions.
179
+ *
180
+ * @returns Promise that resolves when the reading process has started.
181
+ *
182
+ * @throws May reject with:
183
+ * - Invalid input (e.g., malformed CAN or challenge).
184
+ * - NFC subsystem unavailable or disabled.
185
+ * - Operation timeout exceeded.
186
+ * - Native module internal errors.
187
+ *
188
+ * @example
189
+ * await startInternalAuthAndMRTDReading("123456", "challengeString");
190
+ *
191
+ * @example
192
+ * await startInternalAuthAndMRTDReading("654321", "challengeString", "hex", 15000);
193
+ *
194
+ * @remarks
195
+ * Ensure NFC is enabled and the user has positioned the CIE correctly before
196
+ * calling this function to minimize timeouts and improve reliability.
197
+ *
198
+ * Once the Internal Authentication and MRTD reading with PACE flow has been initiated,
199
+ * a Promise resolves, while when the reading process produces data,
200
+ * the `'onSuccess'` event has been called.
201
+ * The `'onError'` event is called if an error occurs during the reading process.
202
+ * The `'onEvent'` event is called to provide progress updates.
203
+ */
204
+ const startInternalAuthAndMRTDReading = async (can, challenge, resultEncoding = 'base64', timeout = DEFAULT_TIMEOUT) => {
205
+ return IoReactNativeCie.startInternalAuthAndMRTDReading(can, challenge, resultEncoding, timeout);
206
+ };
207
+
111
208
  /**
112
209
  * Starts the process of reading attributes from the CIE card.
113
210
  *
@@ -159,5 +256,5 @@ const startReading = async (pin, authenticationUrl, timeout = DEFAULT_TIMEOUT) =
159
256
  const stopReading = async () => {
160
257
  return IoReactNativeCie.stopReading();
161
258
  };
162
- export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startReading, stopReading };
259
+ export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, stopReading };
163
260
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","IoReactNativeCie","getDefaultIdpUrl","DEFAULT_TIMEOUT","eventEmitter","addListener","event","listener","subscription","remove","removeListener","removeAllListeners","setCustomIdpUrl","url","setAlertMessage","key","value","setCurrentAlertMessage","startInternalAuthentication","challenge","resultEncoding","timeout","startReadingAttributes","startReading","pin","authenticationUrl","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,gBAAgB,Q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ACA;AACA,OAAO,MAAMC,sBAAsB,GAAID,KAAa,IAAK;EACvDf,gBAAgB,CAACgB,sBAAsB,CAACD,KAAK,CAAC;AAChD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,2BAA2B,GAAG,MAAAA,CAClCC,SAAiB,EACjBC,cAAgC,GAAG,QAAQ,EAC3CC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACiB,2BAA2B,CACjDC,SAAS,EACTC,cAAc,EACdC,OACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAG,MAAAA,CAC7BD,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACqB,sBAAsB,CAACD,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAAY,GAAG,MAAAA,CACnBC,GAAW,EACXC,iBAAyB,EACzBJ,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACsB,YAAY,CAACC,GAAG,EAAEC,iBAAiB,EAAEJ,OAAO,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,WAAW,GAAG,MAAAA,CAAA,KAA2B;EAC7C,OAAOzB,gBAAgB,CAACyB,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SACErB,WAAW,EACXK,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfU,sBAAsB,EACtBJ,2BAA2B,EAC3BK,YAAY,EACZG,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["NativeEventEmitter","IoReactNativeCie","getDefaultIdpUrl","DEFAULT_TIMEOUT","eventEmitter","addListener","event","listener","subscription","remove","removeListener","removeAllListeners","setCustomIdpUrl","url","setAlertMessage","key","value","setCurrentAlertMessage","startInternalAuthentication","challenge","resultEncoding","timeout","startMRTDReading","can","startInternalAuthAndMRTDReading","startReadingAttributes","startReading","pin","authenticationUrl","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,cAAW;AAO5C,SAASC,gBAAgB,QAAQ,YAAS;AAE1C,MAAMC,eAAe,GAAG,KAAK;AAE7B,MAAMC,YAAY,GAAG,IAAIJ,kBAAkB,CAACC,gBAAgB,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,WAAW,GAAGA,CAClBC,KAAQ,EACRC,QAA6B,KAC1B;EACH,MAAMC,YAAY,GAAGJ,YAAY,CAACC,WAAW,CAACC,KAAK,EAAEC,QAAQ,CAAC;EAC9D,OAAOC,YAAY,CAACC,MAAM;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAIJ,KAAe,IAAK;EAC1CF,YAAY,CAACO,kBAAkB,CAACL,KAAK,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,kBAAkB,GAAGA,CAAA,KAAM;EAC/BP,YAAY,CAACO,kBAAkB,CAAC,SAAS,CAAC;EAC1CP,YAAY,CAACO,kBAAkB,CAAC,SAAS,CAAC;EAC1CP,YAAY,CAACO,kBAAkB,CAAC,qBAAqB,CAAC;EACtDP,YAAY,CAACO,kBAAkB,CAAC,WAAW,CAAC;AAC9C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAIC,GAAuB,IAAK;EACnDZ,gBAAgB,CAACW,eAAe,CAACC,GAAG,IAAIX,gBAAgB,CAAC,CAAC,CAAC;AAC7D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,eAAe,GAAGA,CAACC,GAAoB,EAAEC,KAAa,KAAK;EACtEf,gBAAgB,CAACa,eAAe,CAACC,GAAG,EAAEC,KAAK,CAAC;AAC9C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAID,KAAa,IAAK;EACvDf,gBAAgB,CAACgB,sBAAsB,CAACD,KAAK,CAAC;AAChD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,2BAA2B,GAAG,MAAAA,CAClCC,SAAiB,EACjBC,cAA8B,GAAG,QAAQ,EACzCC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACiB,2BAA2B,CACjDC,SAAS,EACTC,cAAc,EACdC,OACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,MAAAA,CACvBC,GAAW,EACXH,cAA8B,GAAG,QAAQ,EACzCC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACqB,gBAAgB,CAACC,GAAG,EAAEH,cAAc,EAAEC,OAAO,CAAC;AACxE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,+BAA+B,GAAG,MAAAA,CACtCD,GAAW,EACXJ,SAAiB,EACjBC,cAA8B,GAAG,QAAQ,EACzCC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACuB,+BAA+B,CACrDD,GAAG,EACHJ,SAAS,EACTC,cAAc,EACdC,OACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,sBAAsB,GAAG,MAAAA,CAC7BJ,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACwB,sBAAsB,CAACJ,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,YAAY,GAAG,MAAAA,CACnBC,GAAW,EACXC,iBAAyB,EACzBP,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACyB,YAAY,CAACC,GAAG,EAAEC,iBAAiB,EAAEP,OAAO,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMQ,WAAW,GAAG,MAAAA,CAAA,KAA2B;EAC7C,OAAO5B,gBAAgB,CAAC4B,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SACExB,WAAW,EACXK,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfa,sBAAsB,EACtBP,2BAA2B,EAC3BI,gBAAgB,EAChBE,+BAA+B,EAC/BE,YAAY,EACZG,WAAW","ignoreList":[]}
@@ -34,8 +34,8 @@ z.object({
34
34
  attemptsLeft: z.number()
35
35
  })]);
36
36
  /**
37
- * Represent the CIE attributes containing the CIE type
38
- * All string value are Hex encoded
37
+ * Represent the CIE response coming from NIS Internal Auth
38
+ * All string value are Hex or Base64 encoded
39
39
  */
40
40
  export const InternalAuthResponseObject = z.object({
41
41
  nis: z.string(),
@@ -43,6 +43,33 @@ export const InternalAuthResponseObject = z.object({
43
43
  sod: z.string(),
44
44
  signedChallenge: z.string()
45
45
  });
46
+ /**
47
+ * Represent the CIE response coming from MRTD with PACE reading
48
+ * All string value are Hex or Base64 encoded
49
+ */
50
+ export const MrtdResponseObject = z.object({
51
+ dg1: z.string(),
52
+ dg11: z.string(),
53
+ sod: z.string()
54
+ });
55
+ /**
56
+ * Represent the CIE response coming from NIS Internal Auth
57
+ * and MRTD with PACE reading during the same NFC session.
58
+ * All string value are Hex or Base64 encoded
59
+ */
60
+ export const InternalAuthAndMrtdResponse = z.object({
61
+ nis_data: z.object({
62
+ nis: z.string(),
63
+ publicKey: z.string(),
64
+ sod: z.string(),
65
+ signedChallenge: z.string()
66
+ }),
67
+ mrtd_data: z.object({
68
+ dg1: z.string(),
69
+ dg11: z.string(),
70
+ sod: z.string()
71
+ })
72
+ });
46
73
  /**
47
74
  * Represent the CIE attributes containing the CIE type
48
75
  */
@@ -51,6 +78,10 @@ export const CieAttributes = z.object({
51
78
  base64: z.string()
52
79
  });
53
80
 
81
+ /**
82
+ * Possible encodings for the CIE reading results
83
+ */
84
+
54
85
  /**
55
86
  * Event handler that can be used to handle the CIE events during the reading process
56
87
  */
@@ -1 +1 @@
1
- {"version":3,"names":["z","AlertMessageKey","enum","NfcEvent","object","name","string","progress","coerce","number","NfcErrorName","NfcError","union","exclude","message","optional","extract","attemptsLeft","InternalAuthResponseObject","nis","publicKey","sod","signedChallenge","CieAttributes","type","base64"],"sourceRoot":"../../../src","sources":["manager/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,IAAI,CAAC,CACpC,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,CACf,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAA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iB,aAAa,GAAGvB,CAAC,CAACI,MAAM,CAAC;EACpCoB,IAAI,EAAExB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBmB,MAAM,EAAEzB,CAAC,CAACM,MAAM,CAAC;AACnB,CAAC,CAAC;;AAIF;AACA;AACA;;AASA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["z","AlertMessageKey","enum","NfcEvent","object","name","string","progress","coerce","number","NfcErrorName","NfcError","union","exclude","message","optional","extract","attemptsLeft","InternalAuthResponseObject","nis","publicKey","sod","signedChallenge","MrtdResponseObject","dg1","dg11","InternalAuthAndMrtdResponse","nis_data","mrtd_data","CieAttributes","type","base64"],"sourceRoot":"../../../src","sources":["manager/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,IAAI,CAAC,CACpC,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,CACf,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC/BC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBC,QAAQ,EAAEP,CAAC,CAACQ,MAAM,CAACC,MAAM,CAAC;AAC5B,CAAC,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGV,CAAC,CAACE,IAAI,CAAC,CACjC,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,CAChB,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMS,QAAQ,GAAGX,CAAC,CAACY,KAAK,CAAC,CAC9BZ,CAAC,CAACI,M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,MAAM,CAAC,CAAC;IACfgB,eAAe,EAAEtB,CAAC,CAACM,MAAM,CAAC;EAC5B,CAAC,CAAC;EACFsB,SAAS,EAAE5B,CAAC,CAACI,MAAM,CAAC;IAClBoB,GAAG,EAAExB,CAAC,CAACM,MAAM,CAAC,CAAC;IACfmB,IAAI,EAAEzB,CAAC,CAACM,MAAM,CAAC,CAAC;IAChBe,GAAG,EAAErB,CAAC,CAACM,MAAM,CAAC;EAChB,CAAC;AACH,CAAC,CAAC;AAMF;AACA;AACA;AACA,OAAO,MAAMuB,aAAa,GAAG7B,CAAC,CAACI,MAAM,CAAC;EACpC0B,IAAI,EAAE9B,CAAC,CAACM,MAAM,CAAC,CAAC;EAChByB,MAAM,EAAE/B,CAAC,CAACM,MAAM,CAAC;AACnB,CAAC,CAAC;;AAIF;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import * as CieUtils from './utils';
2
2
  import * as CieManager from './manager';
3
3
  export { CieUtils, CieManager };
4
- export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, } from './manager/types';
4
+ export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, InternalAuthResponse, MrtdResponse, InternalAuthAndMrtdResponse, ResultEncoding, } from './manager/types';
5
5
  export type { CieErrorSchema, CieError, CieErrorCodes } from './errors';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEhC,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEhC,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,2BAA2B,EAC3B,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
@@ -1,4 +1,4 @@
1
- import { AlertMessageKey, type CieEvent, type CieEventHandlers } from './types';
1
+ import { AlertMessageKey, type CieEvent, type CieEventHandlers, type ResultEncoding } from './types';
2
2
  /**
3
3
  * Adds a listener for a specific CIE event.
4
4
  *
@@ -71,11 +71,102 @@ export declare const setCurrentAlertMessage: (value: string) => void;
71
71
  * Initiates the internal authentication process using the provided challenge and timeout.
72
72
  *
73
73
  * @param challenge - The challenge string to be used for authentication.
74
- * @param resultEncoding - The encoding of the result byte arrays, either 'base64' or 'hex' (default: 'base64')
74
+ * @param resultEncoding - The encoding of the result byte arrays, either 'base64', 'base64url' or 'hex' (default: 'base64')
75
75
  * @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
76
76
  * @returns A promise that resolves when the authentication process has ended.
77
77
  */
78
- declare const startInternalAuthentication: (challenge: string, resultEncoding?: "base64" | "hex", timeout?: number) => Promise<void>;
78
+ declare const startInternalAuthentication: (challenge: string, resultEncoding?: ResultEncoding, timeout?: number) => Promise<void>;
79
+ /**
80
+ * Initiates a PACE (Password Authenticated Connection Establishment) reading
81
+ * session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
82
+ * Access Number) to read the MRTD information.
83
+ *
84
+ * The operation is asynchronous; Since the Promise resolves
85
+ * with `void`, any resulting data or errors are expected to be surfaced through
86
+ * native events.
87
+ *
88
+ * @param can The 6‑digit Card Access Number printed on the CIE, used to
89
+ * bootstrap the PACE secure messaging protocol. Must be a numeric
90
+ * string; validation (if any) occurs in the native layer.
91
+ * @param resultEncoding The encoding format expected for any binary payloads
92
+ * produced during the reading process. Defaults to
93
+ * `'base64'`. Use `'hex'` if downstream consumers require
94
+ * hexadecimal representation.
95
+ * @param timeout Maximum time (in milliseconds) allowed for the PACE reading
96
+ * session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
97
+ * A larger value may be required on older devices or in
98
+ * environments with slower NFC interactions.
99
+ *
100
+ * @returns Promise that resolves when the reading process has started.
101
+ *
102
+ * @throws May reject with:
103
+ * - Invalid input (e.g., malformed CAN).
104
+ * - NFC subsystem unavailable or disabled.
105
+ * - Operation timeout exceeded.
106
+ * - Native module internal errors.
107
+ *
108
+ * @example
109
+ * await startPaceReading("123456"); // Uses base64 encoding and default timeout.
110
+ *
111
+ * @example
112
+ * await startPaceReading("654321", "hex", 15000);
113
+ *
114
+ * @remarks
115
+ * Ensure NFC is enabled and the user has positioned the CIE correctly before
116
+ * calling this function to minimize timeouts and improve reliability.
117
+ *
118
+ * Once the MRTD reading with PACE flow has been initiated, a Promise resolves,
119
+ * while when the reading process produces data, the `'onSuccess'` event has been called.
120
+ * The `'onError'` event is called if an error occurs during the reading process.
121
+ * The `'onEvent'` event is called to provide progress updates.
122
+ */
123
+ declare const startMRTDReading: (can: string, resultEncoding?: ResultEncoding, timeout?: number) => Promise<void>;
124
+ /**
125
+ * Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
126
+ * that performs both Internal Authentication and MRTD reading using PACE.
127
+ *
128
+ * The operation is asynchronous; Since the Promise resolves
129
+ * with `void`, any resulting data or errors are expected to be surfaced through
130
+ * native events.
131
+ *
132
+ * @param can The 6‑digit Card Access Number printed on the CIE, used to
133
+ * bootstrap the PACE secure messaging protocol. Must be a numeric
134
+ * string; validation (if any) occurs in the native layer.
135
+ * @param challenge The challenge string to be used for Internal Authentication.
136
+ * @param resultEncoding The encoding format expected for any binary payloads
137
+ * produced during the reading process. Defaults to
138
+ * `'base64'`. Use `'hex'` if downstream consumers require
139
+ * hexadecimal representation.
140
+ * @param timeout Maximum time (in milliseconds) allowed for the combined reading
141
+ * session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
142
+ * A larger value may be required on older devices or in
143
+ * environments with slower NFC interactions.
144
+ *
145
+ * @returns Promise that resolves when the reading process has started.
146
+ *
147
+ * @throws May reject with:
148
+ * - Invalid input (e.g., malformed CAN or challenge).
149
+ * - NFC subsystem unavailable or disabled.
150
+ * - Operation timeout exceeded.
151
+ * - Native module internal errors.
152
+ *
153
+ * @example
154
+ * await startInternalAuthAndMRTDReading("123456", "challengeString");
155
+ *
156
+ * @example
157
+ * await startInternalAuthAndMRTDReading("654321", "challengeString", "hex", 15000);
158
+ *
159
+ * @remarks
160
+ * Ensure NFC is enabled and the user has positioned the CIE correctly before
161
+ * calling this function to minimize timeouts and improve reliability.
162
+ *
163
+ * Once the Internal Authentication and MRTD reading with PACE flow has been initiated,
164
+ * a Promise resolves, while when the reading process produces data,
165
+ * the `'onSuccess'` event has been called.
166
+ * The `'onError'` event is called if an error occurs during the reading process.
167
+ * The `'onEvent'` event is called to provide progress updates.
168
+ */
169
+ declare const startInternalAuthAndMRTDReading: (can: string, challenge: string, resultEncoding?: ResultEncoding, timeout?: number) => Promise<void>;
79
170
  /**
80
171
  * Starts the process of reading attributes from the CIE card.
81
172
  *
@@ -119,5 +210,5 @@ declare const startReading: (pin: string, authenticationUrl: string, timeout?: n
119
210
  * ```
120
211
  */
121
212
  declare const stopReading: () => Promise<void>;
122
- export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startReading, stopReading, };
213
+ export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, stopReading, };
123
214
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manager/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAOhF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,WAAW,GAAI,CAAC,SAAS,QAAQ,EACrC,OAAO,CAAC,EACR,UAAU,gBAAgB,CAAC,CAAC,CAAC,eAI9B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,cAAc,GAAI,OAAO,QAAQ,SAEtC,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,YAKvB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,eAAe,GAAI,KAAK,MAAM,GAAG,SAAS,SAE/C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,eAAe,EAAE,OAAO,MAAM,SAElE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,SAEnD,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,2BAA2B,GAC/B,WAAW,MAAM,EACjB,iBAAgB,QAAQ,GAAG,KAAgB,EAC3C,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAMd,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,sBAAsB,GAC1B,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,YAAY,GAChB,KAAK,MAAM,EACX,mBAAmB,MAAM,EACzB,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,QAAA,MAAM,+BAA+B,GACnC,KAAK,MAAM,EACX,WAAW,MAAM,EACjB,iBAAgB,cAAyB,EACzC,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,sBAAsB,GAC1B,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,YAAY,GAChB,KAAK,MAAM,EACX,mBAAmB,MAAM,EACzB,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,QAAa,OAAO,CAAC,IAAI,CAEzC,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,+BAA+B,EAC/B,YAAY,EACZ,WAAW,GACZ,CAAC"}
@@ -53,8 +53,8 @@ export declare const NfcError: z.ZodUnion<[z.ZodObject<{
53
53
  }>]>;
54
54
  export type NfcError = z.infer<typeof NfcError>;
55
55
  /**
56
- * Represent the CIE attributes containing the CIE type
57
- * All string value are Hex encoded
56
+ * Represent the CIE response coming from NIS Internal Auth
57
+ * All string value are Hex or Base64 encoded
58
58
  */
59
59
  export declare const InternalAuthResponseObject: z.ZodObject<{
60
60
  nis: z.ZodString;
@@ -73,6 +73,85 @@ export declare const InternalAuthResponseObject: z.ZodObject<{
73
73
  signedChallenge: string;
74
74
  }>;
75
75
  export type InternalAuthResponse = z.infer<typeof InternalAuthResponseObject>;
76
+ /**
77
+ * Represent the CIE response coming from MRTD with PACE reading
78
+ * All string value are Hex or Base64 encoded
79
+ */
80
+ export declare const MrtdResponseObject: z.ZodObject<{
81
+ dg1: z.ZodString;
82
+ dg11: z.ZodString;
83
+ sod: z.ZodString;
84
+ }, "strip", z.ZodTypeAny, {
85
+ sod: string;
86
+ dg1: string;
87
+ dg11: string;
88
+ }, {
89
+ sod: string;
90
+ dg1: string;
91
+ dg11: string;
92
+ }>;
93
+ export type MrtdResponse = z.infer<typeof MrtdResponseObject>;
94
+ /**
95
+ * Represent the CIE response coming from NIS Internal Auth
96
+ * and MRTD with PACE reading during the same NFC session.
97
+ * All string value are Hex or Base64 encoded
98
+ */
99
+ export declare const InternalAuthAndMrtdResponse: z.ZodObject<{
100
+ nis_data: z.ZodObject<{
101
+ nis: z.ZodString;
102
+ publicKey: z.ZodString;
103
+ sod: z.ZodString;
104
+ signedChallenge: z.ZodString;
105
+ }, "strip", z.ZodTypeAny, {
106
+ nis: string;
107
+ publicKey: string;
108
+ sod: string;
109
+ signedChallenge: string;
110
+ }, {
111
+ nis: string;
112
+ publicKey: string;
113
+ sod: string;
114
+ signedChallenge: string;
115
+ }>;
116
+ mrtd_data: z.ZodObject<{
117
+ dg1: z.ZodString;
118
+ dg11: z.ZodString;
119
+ sod: z.ZodString;
120
+ }, "strip", z.ZodTypeAny, {
121
+ sod: string;
122
+ dg1: string;
123
+ dg11: string;
124
+ }, {
125
+ sod: string;
126
+ dg1: string;
127
+ dg11: string;
128
+ }>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ nis_data: {
131
+ nis: string;
132
+ publicKey: string;
133
+ sod: string;
134
+ signedChallenge: string;
135
+ };
136
+ mrtd_data: {
137
+ sod: string;
138
+ dg1: string;
139
+ dg11: string;
140
+ };
141
+ }, {
142
+ nis_data: {
143
+ nis: string;
144
+ publicKey: string;
145
+ sod: string;
146
+ signedChallenge: string;
147
+ };
148
+ mrtd_data: {
149
+ sod: string;
150
+ dg1: string;
151
+ dg11: string;
152
+ };
153
+ }>;
154
+ export type InternalAuthAndMrtdResponse = z.infer<typeof InternalAuthAndMrtdResponse>;
76
155
  /**
77
156
  * Represent the CIE attributes containing the CIE type
78
157
  */
@@ -87,13 +166,19 @@ export declare const CieAttributes: z.ZodObject<{
87
166
  base64: string;
88
167
  }>;
89
168
  export type CieAttributes = z.infer<typeof CieAttributes>;
169
+ /**
170
+ * Possible encodings for the CIE reading results
171
+ */
172
+ export type ResultEncoding = 'hex' | 'base64' | 'base64url';
90
173
  /**
91
174
  * Event handler that can be used to handle the CIE events during the reading process
92
175
  */
93
176
  export type CieEventHandlers = {
94
177
  onEvent: (event: NfcEvent) => void;
95
178
  onError: (error: NfcError) => void;
96
- onInternalAuthenticationSuccess: (attributes: InternalAuthResponse) => void;
179
+ onInternalAuthenticationSuccess: (internalAuthResponse: InternalAuthResponse) => void;
180
+ onMRTDWithPaceSuccess: (mrtdResponse: MrtdResponse) => void;
181
+ onInternalAuthAndMRTDWithPaceSuccess: (internalAuthAndMrtdResponse: InternalAuthAndMrtdResponse) => void;
97
182
  onAttributesSuccess: (attributes: CieAttributes) => void;
98
183
  onSuccess: (uri: string) => void;
99
184
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,eAAe,+LAW1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;EAGnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,YAAY,uNAYvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;IAWnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK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IAC5D,oCAAoC,EAAE,CACpC,2BAA2B,EAAE,2BAA2B,KACrD,IAAI,CAAC;IACV,mBAAmB,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,IAAI,CAAC;IACzD,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-react-native-cie",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Native support for CIE",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
package/src/index.ts CHANGED
@@ -9,6 +9,10 @@ export type {
9
9
  CieAttributes,
10
10
  CieEventHandlers,
11
11
  CieEvent,
12
+ InternalAuthResponse,
13
+ MrtdResponse,
14
+ InternalAuthAndMrtdResponse,
15
+ ResultEncoding,
12
16
  } from './manager/types';
13
17
 
14
18
  export type { CieErrorSchema, CieError, CieErrorCodes } from './errors';
@@ -1,6 +1,11 @@
1
1
  import { NativeEventEmitter } from 'react-native';
2
2
  import { IoReactNativeCie } from '../native';
3
- import { AlertMessageKey, type CieEvent, type CieEventHandlers } from './types';
3
+ import {
4
+ AlertMessageKey,
5
+ type CieEvent,
6
+ type CieEventHandlers,
7
+ type ResultEncoding,
8
+ } from './types';
4
9
  import { getDefaultIdpUrl } from './utils';
5
10
 
6
11
  const DEFAULT_TIMEOUT = 10000;
@@ -104,13 +109,13 @@ export const setCurrentAlertMessage = (value: string) => {
104
109
  * Initiates the internal authentication process using the provided challenge and timeout.
105
110
  *
106
111
  * @param challenge - The challenge string to be used for authentication.
107
- * @param resultEncoding - The encoding of the result byte arrays, either 'base64' or 'hex' (default: 'base64')
112
+ * @param resultEncoding - The encoding of the result byte arrays, either 'base64', 'base64url' or 'hex' (default: 'base64')
108
113
  * @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
109
114
  * @returns A promise that resolves when the authentication process has ended.
110
115
  */
111
116
  const startInternalAuthentication = async (
112
117
  challenge: string,
113
- resultEncoding: 'base64' | 'hex' = 'base64',
118
+ resultEncoding: ResultEncoding = 'base64',
114
119
  timeout: number = DEFAULT_TIMEOUT
115
120
  ): Promise<void> => {
116
121
  return IoReactNativeCie.startInternalAuthentication(
@@ -120,6 +125,117 @@ const startInternalAuthentication = async (
120
125
  );
121
126
  };
122
127
 
128
+ /**
129
+ * Initiates a PACE (Password Authenticated Connection Establishment) reading
130
+ * session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
131
+ * Access Number) to read the MRTD information.
132
+ *
133
+ * The operation is asynchronous; Since the Promise resolves
134
+ * with `void`, any resulting data or errors are expected to be surfaced through
135
+ * native events.
136
+ *
137
+ * @param can The 6‑digit Card Access Number printed on the CIE, used to
138
+ * bootstrap the PACE secure messaging protocol. Must be a numeric
139
+ * string; validation (if any) occurs in the native layer.
140
+ * @param resultEncoding The encoding format expected for any binary payloads
141
+ * produced during the reading process. Defaults to
142
+ * `'base64'`. Use `'hex'` if downstream consumers require
143
+ * hexadecimal representation.
144
+ * @param timeout Maximum time (in milliseconds) allowed for the PACE reading
145
+ * session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
146
+ * A larger value may be required on older devices or in
147
+ * environments with slower NFC interactions.
148
+ *
149
+ * @returns Promise that resolves when the reading process has started.
150
+ *
151
+ * @throws May reject with:
152
+ * - Invalid input (e.g., malformed CAN).
153
+ * - NFC subsystem unavailable or disabled.
154
+ * - Operation timeout exceeded.
155
+ * - Native module internal errors.
156
+ *
157
+ * @example
158
+ * await startPaceReading("123456"); // Uses base64 encoding and default timeout.
159
+ *
160
+ * @example
161
+ * await startPaceReading("654321", "hex", 15000);
162
+ *
163
+ * @remarks
164
+ * Ensure NFC is enabled and the user has positioned the CIE correctly before
165
+ * calling this function to minimize timeouts and improve reliability.
166
+ *
167
+ * Once the MRTD reading with PACE flow has been initiated, a Promise resolves,
168
+ * while when the reading process produces data, the `'onSuccess'` event has been called.
169
+ * The `'onError'` event is called if an error occurs during the reading process.
170
+ * The `'onEvent'` event is called to provide progress updates.
171
+ */
172
+ const startMRTDReading = async (
173
+ can: string,
174
+ resultEncoding: ResultEncoding = 'base64',
175
+ timeout: number = DEFAULT_TIMEOUT
176
+ ): Promise<void> => {
177
+ return IoReactNativeCie.startMRTDReading(can, resultEncoding, timeout);
178
+ };
179
+
180
+ /**
181
+ * Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
182
+ * that performs both Internal Authentication and MRTD reading using PACE.
183
+ *
184
+ * The operation is asynchronous; Since the Promise resolves
185
+ * with `void`, any resulting data or errors are expected to be surfaced through
186
+ * native events.
187
+ *
188
+ * @param can The 6‑digit Card Access Number printed on the CIE, used to
189
+ * bootstrap the PACE secure messaging protocol. Must be a numeric
190
+ * string; validation (if any) occurs in the native layer.
191
+ * @param challenge The challenge string to be used for Internal Authentication.
192
+ * @param resultEncoding The encoding format expected for any binary payloads
193
+ * produced during the reading process. Defaults to
194
+ * `'base64'`. Use `'hex'` if downstream consumers require
195
+ * hexadecimal representation.
196
+ * @param timeout Maximum time (in milliseconds) allowed for the combined reading
197
+ * session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
198
+ * A larger value may be required on older devices or in
199
+ * environments with slower NFC interactions.
200
+ *
201
+ * @returns Promise that resolves when the reading process has started.
202
+ *
203
+ * @throws May reject with:
204
+ * - Invalid input (e.g., malformed CAN or challenge).
205
+ * - NFC subsystem unavailable or disabled.
206
+ * - Operation timeout exceeded.
207
+ * - Native module internal errors.
208
+ *
209
+ * @example
210
+ * await startInternalAuthAndMRTDReading("123456", "challengeString");
211
+ *
212
+ * @example
213
+ * await startInternalAuthAndMRTDReading("654321", "challengeString", "hex", 15000);
214
+ *
215
+ * @remarks
216
+ * Ensure NFC is enabled and the user has positioned the CIE correctly before
217
+ * calling this function to minimize timeouts and improve reliability.
218
+ *
219
+ * Once the Internal Authentication and MRTD reading with PACE flow has been initiated,
220
+ * a Promise resolves, while when the reading process produces data,
221
+ * the `'onSuccess'` event has been called.
222
+ * The `'onError'` event is called if an error occurs during the reading process.
223
+ * The `'onEvent'` event is called to provide progress updates.
224
+ */
225
+ const startInternalAuthAndMRTDReading = async (
226
+ can: string,
227
+ challenge: string,
228
+ resultEncoding: ResultEncoding = 'base64',
229
+ timeout: number = DEFAULT_TIMEOUT
230
+ ): Promise<void> => {
231
+ return IoReactNativeCie.startInternalAuthAndMRTDReading(
232
+ can,
233
+ challenge,
234
+ resultEncoding,
235
+ timeout
236
+ );
237
+ };
238
+
123
239
  /**
124
240
  * Starts the process of reading attributes from the CIE card.
125
241
  *
@@ -185,6 +301,8 @@ export {
185
301
  setCustomIdpUrl,
186
302
  startReadingAttributes,
187
303
  startInternalAuthentication,
304
+ startMRTDReading,
305
+ startInternalAuthAndMRTDReading,
188
306
  startReading,
189
307
  stopReading,
190
308
  };