@opencrvs/mosip 1.7.0-alpha.22 → 1.7.0-alpha.23
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/build/forms.d.ts +31 -5
- package/build/forms.js +50 -8
- package/package.json +1 -1
- package/src/forms.ts +76 -8
package/build/forms.d.ts
CHANGED
|
@@ -142,8 +142,9 @@ interface ESignetConfig {
|
|
|
142
142
|
fieldName: string;
|
|
143
143
|
mosipAPIUserInfoUrl: string;
|
|
144
144
|
};
|
|
145
|
+
loaderFieldName?: string;
|
|
145
146
|
}
|
|
146
|
-
export declare const verified: (event: string, sectionId: string, mapping: any) => {
|
|
147
|
+
export declare const verified: (event: string, sectionId: string, mapping: any, esignetConfig?: ESignetConfig) => {
|
|
147
148
|
name: string;
|
|
148
149
|
fieldId: string;
|
|
149
150
|
customQuestionMappingId: string;
|
|
@@ -160,13 +161,14 @@ export declare const verified: (event: string, sectionId: string, mapping: any)
|
|
|
160
161
|
validator: never[];
|
|
161
162
|
mapping: any;
|
|
162
163
|
};
|
|
163
|
-
|
|
164
|
+
type VerificationStatus = "verified" | "failed" | "authenticated";
|
|
165
|
+
export declare const idVerificationBanner: (event: string, sectionId: string, status: VerificationStatus) => {
|
|
164
166
|
name: string;
|
|
165
167
|
type: string;
|
|
166
168
|
fieldId: string;
|
|
167
169
|
hideInPreview: boolean;
|
|
168
170
|
custom: boolean;
|
|
169
|
-
bannerType:
|
|
171
|
+
bannerType: VerificationStatus;
|
|
170
172
|
idFieldName: string;
|
|
171
173
|
label: {
|
|
172
174
|
id: string;
|
|
@@ -178,12 +180,36 @@ export declare const idVerificationBanner: (event: string, sectionId: string, st
|
|
|
178
180
|
expression: string;
|
|
179
181
|
}[];
|
|
180
182
|
};
|
|
183
|
+
export declare function esignetLoaderField({ event, section, fieldName, esignetCallbackFieldName, }: {
|
|
184
|
+
event: "birth" | "death";
|
|
185
|
+
section: "informant" | "mother" | "father" | "spouse" | "deceased";
|
|
186
|
+
fieldName: string;
|
|
187
|
+
esignetCallbackFieldName: string;
|
|
188
|
+
}): {
|
|
189
|
+
name: string;
|
|
190
|
+
type: string;
|
|
191
|
+
fieldId: string;
|
|
192
|
+
hideInPreview: boolean;
|
|
193
|
+
custom: boolean;
|
|
194
|
+
label: {
|
|
195
|
+
id: string;
|
|
196
|
+
defaultMessage: string;
|
|
197
|
+
};
|
|
198
|
+
loadingText: {
|
|
199
|
+
id: string;
|
|
200
|
+
defaultMessage: string;
|
|
201
|
+
};
|
|
202
|
+
conditionals: {
|
|
203
|
+
action: string;
|
|
204
|
+
expression: string;
|
|
205
|
+
}[];
|
|
206
|
+
};
|
|
181
207
|
export declare const getInitialValueFromIDReader: (fieldNameInReader: string) => {
|
|
182
208
|
dependsOn: string[];
|
|
183
209
|
expression: string;
|
|
184
210
|
};
|
|
185
211
|
export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father" | "spouse" | "deceased", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => any[];
|
|
186
|
-
export declare const idVerificationFields: (event: string, sectionId: string, mapping: any) => ({
|
|
212
|
+
export declare const idVerificationFields: (event: string, sectionId: string, mapping: any, esignetConfig?: ESignetConfig) => ({
|
|
187
213
|
name: string;
|
|
188
214
|
fieldId: string;
|
|
189
215
|
customQuestionMappingId: string;
|
|
@@ -205,7 +231,7 @@ export declare const idVerificationFields: (event: string, sectionId: string, ma
|
|
|
205
231
|
fieldId: string;
|
|
206
232
|
hideInPreview: boolean;
|
|
207
233
|
custom: boolean;
|
|
208
|
-
bannerType:
|
|
234
|
+
bannerType: VerificationStatus;
|
|
209
235
|
idFieldName: string;
|
|
210
236
|
label: {
|
|
211
237
|
id: string;
|
package/build/forms.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.idVerificationFields = exports.idReaderFields = exports.getInitialValueFromIDReader = exports.idVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
|
|
14
|
+
exports.esignetLoaderField = esignetLoaderField;
|
|
14
15
|
/**
|
|
15
16
|
*
|
|
16
17
|
* @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
|
|
@@ -146,7 +147,7 @@ const qr = ({ validation }) => ({
|
|
|
146
147
|
validation,
|
|
147
148
|
});
|
|
148
149
|
exports.qr = qr;
|
|
149
|
-
const verified = (event, sectionId, mapping) => {
|
|
150
|
+
const verified = (event, sectionId, mapping, esignetConfig) => {
|
|
150
151
|
const fieldName = "verified";
|
|
151
152
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
152
153
|
return {
|
|
@@ -159,10 +160,15 @@ const verified = (event, sectionId, mapping) => {
|
|
|
159
160
|
id: "form.field.label.empty",
|
|
160
161
|
defaultMessage: "",
|
|
161
162
|
},
|
|
162
|
-
initialValue:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
initialValue: esignetConfig
|
|
164
|
+
? {
|
|
165
|
+
dependsOn: ["idReader", esignetConfig.callback.fieldName],
|
|
166
|
+
expression: `Boolean($form?.idReader)? "pending": Boolean($form?.${esignetConfig.callback.fieldName}?.data)? "authenticated": ""`,
|
|
167
|
+
}
|
|
168
|
+
: {
|
|
169
|
+
dependsOn: ["idReader"],
|
|
170
|
+
expression: 'Boolean($form?.idReader)? "pending":""',
|
|
171
|
+
},
|
|
166
172
|
validator: [],
|
|
167
173
|
mapping,
|
|
168
174
|
};
|
|
@@ -196,6 +202,30 @@ const idVerificationBanner = (event, sectionId, status) => {
|
|
|
196
202
|
};
|
|
197
203
|
};
|
|
198
204
|
exports.idVerificationBanner = idVerificationBanner;
|
|
205
|
+
function esignetLoaderField({ event, section, fieldName, esignetCallbackFieldName, }) {
|
|
206
|
+
const fieldId = `${event}.${section}.${section}-view-group.${fieldName}`;
|
|
207
|
+
return {
|
|
208
|
+
name: fieldName,
|
|
209
|
+
type: "LOADER",
|
|
210
|
+
fieldId,
|
|
211
|
+
hideInPreview: true,
|
|
212
|
+
custom: true,
|
|
213
|
+
label: {
|
|
214
|
+
id: "form.field.label.idReader",
|
|
215
|
+
defaultMessage: "ID verification",
|
|
216
|
+
},
|
|
217
|
+
loadingText: {
|
|
218
|
+
id: "form.field.label.authenticating.nid",
|
|
219
|
+
defaultMessage: "Fetching the person's data from E-Signet",
|
|
220
|
+
},
|
|
221
|
+
conditionals: [
|
|
222
|
+
{
|
|
223
|
+
action: "hide",
|
|
224
|
+
expression: `!$form?.${esignetCallbackFieldName}?.loading`,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
199
229
|
const getInitialValueFromIDReader = (fieldNameInReader) => ({
|
|
200
230
|
dependsOn: ["idReader", "esignetCallback"],
|
|
201
231
|
expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
|
|
@@ -206,7 +236,7 @@ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomF
|
|
|
206
236
|
const fields = [
|
|
207
237
|
(0, exports.idReader)(event, section, conditionals.concat({
|
|
208
238
|
action: "hide",
|
|
209
|
-
expression: "$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'",
|
|
239
|
+
expression: "$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed' || !!$form?.esignetCallback?.loading",
|
|
210
240
|
}), readers),
|
|
211
241
|
];
|
|
212
242
|
if (esignetConfig) {
|
|
@@ -216,6 +246,18 @@ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomF
|
|
|
216
246
|
mosipAPIUserInfoUrl: esignetConfig.callback.mosipAPIUserInfoUrl,
|
|
217
247
|
openIdProviderClientId: esignetConfig.openIdProviderClientId,
|
|
218
248
|
}));
|
|
249
|
+
if (esignetConfig.loaderFieldName) {
|
|
250
|
+
fields.push(esignetLoaderField({
|
|
251
|
+
event,
|
|
252
|
+
section,
|
|
253
|
+
fieldName: esignetConfig.loaderFieldName,
|
|
254
|
+
esignetCallbackFieldName: esignetConfig.callback.fieldName,
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
return [
|
|
258
|
+
...fields,
|
|
259
|
+
...(0, exports.idVerificationFields)(event, section, verifiedCustomFieldMapping, esignetConfig),
|
|
260
|
+
];
|
|
219
261
|
}
|
|
220
262
|
return [
|
|
221
263
|
...fields,
|
|
@@ -223,9 +265,9 @@ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomF
|
|
|
223
265
|
];
|
|
224
266
|
};
|
|
225
267
|
exports.idReaderFields = idReaderFields;
|
|
226
|
-
const idVerificationFields = (event, sectionId, mapping) => {
|
|
268
|
+
const idVerificationFields = (event, sectionId, mapping, esignetConfig) => {
|
|
227
269
|
return [
|
|
228
|
-
(0, exports.verified)(event, sectionId, mapping),
|
|
270
|
+
(0, exports.verified)(event, sectionId, mapping, esignetConfig),
|
|
229
271
|
(0, exports.idVerificationBanner)(event, sectionId, "verified"),
|
|
230
272
|
(0, exports.idVerificationBanner)(event, sectionId, "failed"),
|
|
231
273
|
(0, exports.idVerificationBanner)(event, sectionId, "authenticated"),
|
package/package.json
CHANGED
package/src/forms.ts
CHANGED
|
@@ -198,9 +198,15 @@ interface ESignetConfig {
|
|
|
198
198
|
fieldName: string;
|
|
199
199
|
mosipAPIUserInfoUrl: string;
|
|
200
200
|
};
|
|
201
|
+
loaderFieldName?: string;
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
export const verified = (
|
|
204
|
+
export const verified = (
|
|
205
|
+
event: string,
|
|
206
|
+
sectionId: string,
|
|
207
|
+
mapping: any,
|
|
208
|
+
esignetConfig?: ESignetConfig,
|
|
209
|
+
) => {
|
|
204
210
|
const fieldName = "verified";
|
|
205
211
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
206
212
|
return {
|
|
@@ -213,10 +219,15 @@ export const verified = (event: string, sectionId: string, mapping: any) => {
|
|
|
213
219
|
id: "form.field.label.empty",
|
|
214
220
|
defaultMessage: "",
|
|
215
221
|
},
|
|
216
|
-
initialValue:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
initialValue: esignetConfig
|
|
223
|
+
? {
|
|
224
|
+
dependsOn: ["idReader", esignetConfig.callback.fieldName],
|
|
225
|
+
expression: `Boolean($form?.idReader)? "pending": Boolean($form?.${esignetConfig.callback.fieldName}?.data)? "authenticated": ""`,
|
|
226
|
+
}
|
|
227
|
+
: {
|
|
228
|
+
dependsOn: ["idReader"],
|
|
229
|
+
expression: 'Boolean($form?.idReader)? "pending":""',
|
|
230
|
+
},
|
|
220
231
|
validator: [],
|
|
221
232
|
mapping,
|
|
222
233
|
};
|
|
@@ -226,10 +237,12 @@ function capitalize(str: string) {
|
|
|
226
237
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
227
238
|
}
|
|
228
239
|
|
|
240
|
+
type VerificationStatus = "verified" | "failed" | "authenticated";
|
|
241
|
+
|
|
229
242
|
export const idVerificationBanner = (
|
|
230
243
|
event: string,
|
|
231
244
|
sectionId: string,
|
|
232
|
-
status:
|
|
245
|
+
status: VerificationStatus,
|
|
233
246
|
) => {
|
|
234
247
|
const fieldName = "verified";
|
|
235
248
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
@@ -255,6 +268,41 @@ export const idVerificationBanner = (
|
|
|
255
268
|
};
|
|
256
269
|
};
|
|
257
270
|
|
|
271
|
+
export function esignetLoaderField({
|
|
272
|
+
event,
|
|
273
|
+
section,
|
|
274
|
+
fieldName,
|
|
275
|
+
esignetCallbackFieldName,
|
|
276
|
+
}: {
|
|
277
|
+
event: "birth" | "death";
|
|
278
|
+
section: "informant" | "mother" | "father" | "spouse" | "deceased";
|
|
279
|
+
fieldName: string;
|
|
280
|
+
esignetCallbackFieldName: string;
|
|
281
|
+
}) {
|
|
282
|
+
const fieldId = `${event}.${section}.${section}-view-group.${fieldName}`;
|
|
283
|
+
return {
|
|
284
|
+
name: fieldName,
|
|
285
|
+
type: "LOADER",
|
|
286
|
+
fieldId,
|
|
287
|
+
hideInPreview: true,
|
|
288
|
+
custom: true,
|
|
289
|
+
label: {
|
|
290
|
+
id: "form.field.label.idReader",
|
|
291
|
+
defaultMessage: "ID verification",
|
|
292
|
+
},
|
|
293
|
+
loadingText: {
|
|
294
|
+
id: "form.field.label.authenticating.nid",
|
|
295
|
+
defaultMessage: "Fetching the person's data from E-Signet",
|
|
296
|
+
},
|
|
297
|
+
conditionals: [
|
|
298
|
+
{
|
|
299
|
+
action: "hide",
|
|
300
|
+
expression: `!$form?.${esignetCallbackFieldName}?.loading`,
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
258
306
|
export const getInitialValueFromIDReader = (fieldNameInReader: string) => ({
|
|
259
307
|
dependsOn: ["idReader", "esignetCallback"],
|
|
260
308
|
expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
|
|
@@ -276,7 +324,7 @@ export const idReaderFields = (
|
|
|
276
324
|
conditionals.concat({
|
|
277
325
|
action: "hide",
|
|
278
326
|
expression:
|
|
279
|
-
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'",
|
|
327
|
+
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed' || !!$form?.esignetCallback?.loading",
|
|
280
328
|
}),
|
|
281
329
|
readers,
|
|
282
330
|
),
|
|
@@ -298,6 +346,25 @@ export const idReaderFields = (
|
|
|
298
346
|
openIdProviderClientId: esignetConfig.openIdProviderClientId,
|
|
299
347
|
}),
|
|
300
348
|
);
|
|
349
|
+
if (esignetConfig.loaderFieldName) {
|
|
350
|
+
fields.push(
|
|
351
|
+
esignetLoaderField({
|
|
352
|
+
event,
|
|
353
|
+
section,
|
|
354
|
+
fieldName: esignetConfig.loaderFieldName,
|
|
355
|
+
esignetCallbackFieldName: esignetConfig.callback.fieldName,
|
|
356
|
+
}),
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
return [
|
|
360
|
+
...fields,
|
|
361
|
+
...idVerificationFields(
|
|
362
|
+
event,
|
|
363
|
+
section,
|
|
364
|
+
verifiedCustomFieldMapping,
|
|
365
|
+
esignetConfig,
|
|
366
|
+
),
|
|
367
|
+
];
|
|
301
368
|
}
|
|
302
369
|
return [
|
|
303
370
|
...fields,
|
|
@@ -308,9 +375,10 @@ export const idVerificationFields = (
|
|
|
308
375
|
event: string,
|
|
309
376
|
sectionId: string,
|
|
310
377
|
mapping: any,
|
|
378
|
+
esignetConfig?: ESignetConfig,
|
|
311
379
|
) => {
|
|
312
380
|
return [
|
|
313
|
-
verified(event, sectionId, mapping),
|
|
381
|
+
verified(event, sectionId, mapping, esignetConfig),
|
|
314
382
|
idVerificationBanner(event, sectionId, "verified"),
|
|
315
383
|
idVerificationBanner(event, sectionId, "failed"),
|
|
316
384
|
idVerificationBanner(event, sectionId, "authenticated"),
|