@@ -147,8 +147,8 @@ export const idReader = (
147
147
required : false ,
148
148
type : "ID_READER" ,
149
149
label : {
150
- id : "form.field.label.empty " ,
151
- defaultMessage : "" ,
150
+ id : "form.field.label.idReader " ,
151
+ defaultMessage : "ID verification " ,
152
152
} ,
153
153
hideInPreview : true ,
154
154
initialValue : "" ,
@@ -162,6 +162,11 @@ export const idReader = (
162
162
id : "views.idReader.label.manualInput" ,
163
163
defaultMessage : "Complete fields below" ,
164
164
} ,
165
+ mapping : {
166
+ mutation : {
167
+ operation : "ignoreFieldTransformer" ,
168
+ } ,
169
+ } ,
165
170
readers,
166
171
} ;
167
172
} ;
@@ -172,18 +177,31 @@ type MessageDescriptor = {
172
177
description ?: string ;
173
178
} ;
174
179
175
- export const qr = ( {
176
- validation,
177
- } : {
178
- validation : {
179
- rule : Record < string , unknown > ;
180
- errorMessage : MessageDescriptor ;
181
- } ;
182
- } ) => ( {
180
+ interface QRValidation {
181
+ rule : Record < string , unknown > ;
182
+ errorMessage : MessageDescriptor ;
183
+ }
184
+
185
+ interface QRConfig {
186
+ validation : QRValidation ;
187
+ }
188
+
189
+ export const qr = ( { validation } : QRConfig ) => ( {
183
190
type : "QR" ,
184
191
validation,
185
192
} ) ;
186
193
194
+ interface ESignetConfig {
195
+ esignetAuthUrl : string ;
196
+ openIdProviderClientId : string ;
197
+ openIdProviderClaims : string | undefined ;
198
+ fieldName : string ;
199
+ callback : {
200
+ fieldName : string ;
201
+ mosipAPIUserInfoUrl : string ;
202
+ } ;
203
+ }
204
+
187
205
export const verified = ( event : string , sectionId : string , mapping : any ) => {
188
206
const fieldName = "verified" ;
189
207
const fieldId = `${ event } .${ sectionId } .${ sectionId } -view-group.${ fieldName } ` ;
@@ -202,7 +220,7 @@ export const verified = (event: string, sectionId: string, mapping: any) => {
202
220
expression : 'Boolean($form?.idReader)? "pending":""' ,
203
221
} ,
204
222
validator : [ ] ,
205
- mapping
223
+ mapping,
206
224
} ;
207
225
} ;
208
226
@@ -213,7 +231,7 @@ function capitalize(str: string) {
213
231
export const idVerificationBanner = (
214
232
event : string ,
215
233
sectionId : string ,
216
- status : "pending " | "verified " | "failed " ,
234
+ status : "verified " | "failed " | "authenticated " ,
217
235
) => {
218
236
const fieldName = "verified" ;
219
237
const fieldId = `${ event } .${ sectionId } .${ sectionId } -view-group.${ fieldName } ` ;
@@ -239,11 +257,64 @@ export const idVerificationBanner = (
239
257
} ;
240
258
} ;
241
259
242
- export const idVerificationFields = ( event : string , sectionId : string , mapping : any ) => {
260
+ export const getInitialValueFromIDReader = ( fieldNameInReader : string ) => ( {
261
+ dependsOn : [ "idReader" , "esignetCallback" ] ,
262
+ expression : `$form?.idReader?.${ fieldNameInReader } || $form?.esignetCallback?.data?.${ fieldNameInReader } || ""` ,
263
+ } ) ;
264
+
265
+ export const idReaderFields = (
266
+ event : "birth" | "death" ,
267
+ section : "informant" | "mother" | "father" ,
268
+ qrConfig : QRConfig ,
269
+ esignetConfig : ESignetConfig | undefined ,
270
+ verifiedCustomFieldMapping : any ,
271
+ conditionals : any [ ] = [ ] ,
272
+ ) => {
273
+ const readers : any [ ] = [ qr ( qrConfig ) ] ;
274
+ const fields : any [ ] = [
275
+ idReader (
276
+ event ,
277
+ section ,
278
+ conditionals . concat ( {
279
+ action : "hide" ,
280
+ expression :
281
+ "$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'" ,
282
+ } ) ,
283
+ readers ,
284
+ ) ,
285
+ ] ;
286
+ if ( esignetConfig ) {
287
+ readers . push (
288
+ esignet (
289
+ esignetConfig . esignetAuthUrl ,
290
+ esignetConfig . openIdProviderClientId ,
291
+ esignetConfig . openIdProviderClaims ,
292
+ esignetConfig . fieldName ,
293
+ esignetConfig . callback . fieldName ,
294
+ ) ,
295
+ ) ;
296
+ fields . push (
297
+ esignetCallback ( {
298
+ fieldName : esignetConfig . callback . fieldName ,
299
+ mosipAPIUserInfoUrl : esignetConfig . callback . mosipAPIUserInfoUrl ,
300
+ openIdProviderClientId : esignetConfig . openIdProviderClientId ,
301
+ } ) ,
302
+ ) ;
303
+ }
304
+ return [
305
+ ...fields ,
306
+ ...idVerificationFields ( event , section , verifiedCustomFieldMapping ) ,
307
+ ] ;
308
+ } ;
309
+ export const idVerificationFields = (
310
+ event : string ,
311
+ sectionId : string ,
312
+ mapping : any ,
313
+ ) => {
243
314
return [
244
315
verified ( event , sectionId , mapping ) ,
245
- idVerificationBanner ( event , sectionId , "pending" ) ,
246
316
idVerificationBanner ( event , sectionId , "verified" ) ,
247
317
idVerificationBanner ( event , sectionId , "failed" ) ,
318
+ idVerificationBanner ( event , sectionId , "authenticated" ) ,
248
319
] ;
249
320
} ;
0 commit comments