@opencrvs/mosip 1.7.0-alpha.21 → 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 +32 -6
- package/build/forms.js +52 -11
- package/package.json +1 -1
- package/src/forms.ts +77 -11
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
|
-
export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => any[];
|
|
186
|
-
export declare const idVerificationFields: (event: string, sectionId: string, mapping: any) => ({
|
|
211
|
+
export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father" | "spouse" | "deceased", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => 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
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @TODO: Yet to be implemented! Placeholders for NPM publish.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.idVerificationFields = exports.idReaderFields = exports.getInitialValueFromIDReader = exports.idVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
|
|
5
2
|
/**
|
|
6
3
|
* E-Signet popup button and hidden field form definitions
|
|
7
4
|
* @example
|
|
@@ -12,6 +9,9 @@ exports.idVerificationFields = exports.idReaderFields = exports.getInitialValueF
|
|
|
12
9
|
* ]
|
|
13
10
|
* ```
|
|
14
11
|
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
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)
|
|
@@ -147,7 +147,7 @@ const qr = ({ validation }) => ({
|
|
|
147
147
|
validation,
|
|
148
148
|
});
|
|
149
149
|
exports.qr = qr;
|
|
150
|
-
const verified = (event, sectionId, mapping) => {
|
|
150
|
+
const verified = (event, sectionId, mapping, esignetConfig) => {
|
|
151
151
|
const fieldName = "verified";
|
|
152
152
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
153
153
|
return {
|
|
@@ -160,10 +160,15 @@ const verified = (event, sectionId, mapping) => {
|
|
|
160
160
|
id: "form.field.label.empty",
|
|
161
161
|
defaultMessage: "",
|
|
162
162
|
},
|
|
163
|
-
initialValue:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
+
},
|
|
167
172
|
validator: [],
|
|
168
173
|
mapping,
|
|
169
174
|
};
|
|
@@ -197,6 +202,30 @@ const idVerificationBanner = (event, sectionId, status) => {
|
|
|
197
202
|
};
|
|
198
203
|
};
|
|
199
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
|
+
}
|
|
200
229
|
const getInitialValueFromIDReader = (fieldNameInReader) => ({
|
|
201
230
|
dependsOn: ["idReader", "esignetCallback"],
|
|
202
231
|
expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
|
|
@@ -207,7 +236,7 @@ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomF
|
|
|
207
236
|
const fields = [
|
|
208
237
|
(0, exports.idReader)(event, section, conditionals.concat({
|
|
209
238
|
action: "hide",
|
|
210
|
-
expression: "$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'",
|
|
239
|
+
expression: "$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed' || !!$form?.esignetCallback?.loading",
|
|
211
240
|
}), readers),
|
|
212
241
|
];
|
|
213
242
|
if (esignetConfig) {
|
|
@@ -217,6 +246,18 @@ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomF
|
|
|
217
246
|
mosipAPIUserInfoUrl: esignetConfig.callback.mosipAPIUserInfoUrl,
|
|
218
247
|
openIdProviderClientId: esignetConfig.openIdProviderClientId,
|
|
219
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
|
+
];
|
|
220
261
|
}
|
|
221
262
|
return [
|
|
222
263
|
...fields,
|
|
@@ -224,9 +265,9 @@ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomF
|
|
|
224
265
|
];
|
|
225
266
|
};
|
|
226
267
|
exports.idReaderFields = idReaderFields;
|
|
227
|
-
const idVerificationFields = (event, sectionId, mapping) => {
|
|
268
|
+
const idVerificationFields = (event, sectionId, mapping, esignetConfig) => {
|
|
228
269
|
return [
|
|
229
|
-
(0, exports.verified)(event, sectionId, mapping),
|
|
270
|
+
(0, exports.verified)(event, sectionId, mapping, esignetConfig),
|
|
230
271
|
(0, exports.idVerificationBanner)(event, sectionId, "verified"),
|
|
231
272
|
(0, exports.idVerificationBanner)(event, sectionId, "failed"),
|
|
232
273
|
(0, exports.idVerificationBanner)(event, sectionId, "authenticated"),
|
package/package.json
CHANGED
package/src/forms.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @TODO: Yet to be implemented! Placeholders for NPM publish.
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* E-Signet popup button and hidden field form definitions
|
|
5
3
|
* @example
|
|
@@ -200,9 +198,15 @@ interface ESignetConfig {
|
|
|
200
198
|
fieldName: string;
|
|
201
199
|
mosipAPIUserInfoUrl: string;
|
|
202
200
|
};
|
|
201
|
+
loaderFieldName?: string;
|
|
203
202
|
}
|
|
204
203
|
|
|
205
|
-
export const verified = (
|
|
204
|
+
export const verified = (
|
|
205
|
+
event: string,
|
|
206
|
+
sectionId: string,
|
|
207
|
+
mapping: any,
|
|
208
|
+
esignetConfig?: ESignetConfig,
|
|
209
|
+
) => {
|
|
206
210
|
const fieldName = "verified";
|
|
207
211
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
208
212
|
return {
|
|
@@ -215,10 +219,15 @@ export const verified = (event: string, sectionId: string, mapping: any) => {
|
|
|
215
219
|
id: "form.field.label.empty",
|
|
216
220
|
defaultMessage: "",
|
|
217
221
|
},
|
|
218
|
-
initialValue:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
+
},
|
|
222
231
|
validator: [],
|
|
223
232
|
mapping,
|
|
224
233
|
};
|
|
@@ -228,10 +237,12 @@ function capitalize(str: string) {
|
|
|
228
237
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
229
238
|
}
|
|
230
239
|
|
|
240
|
+
type VerificationStatus = "verified" | "failed" | "authenticated";
|
|
241
|
+
|
|
231
242
|
export const idVerificationBanner = (
|
|
232
243
|
event: string,
|
|
233
244
|
sectionId: string,
|
|
234
|
-
status:
|
|
245
|
+
status: VerificationStatus,
|
|
235
246
|
) => {
|
|
236
247
|
const fieldName = "verified";
|
|
237
248
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
@@ -257,6 +268,41 @@ export const idVerificationBanner = (
|
|
|
257
268
|
};
|
|
258
269
|
};
|
|
259
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
|
+
|
|
260
306
|
export const getInitialValueFromIDReader = (fieldNameInReader: string) => ({
|
|
261
307
|
dependsOn: ["idReader", "esignetCallback"],
|
|
262
308
|
expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
|
|
@@ -264,7 +310,7 @@ export const getInitialValueFromIDReader = (fieldNameInReader: string) => ({
|
|
|
264
310
|
|
|
265
311
|
export const idReaderFields = (
|
|
266
312
|
event: "birth" | "death",
|
|
267
|
-
section: "informant" | "mother" | "father",
|
|
313
|
+
section: "informant" | "mother" | "father" | "spouse" | "deceased",
|
|
268
314
|
qrConfig: QRConfig,
|
|
269
315
|
esignetConfig: ESignetConfig | undefined,
|
|
270
316
|
verifiedCustomFieldMapping: any,
|
|
@@ -278,7 +324,7 @@ export const idReaderFields = (
|
|
|
278
324
|
conditionals.concat({
|
|
279
325
|
action: "hide",
|
|
280
326
|
expression:
|
|
281
|
-
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'",
|
|
327
|
+
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed' || !!$form?.esignetCallback?.loading",
|
|
282
328
|
}),
|
|
283
329
|
readers,
|
|
284
330
|
),
|
|
@@ -300,6 +346,25 @@ export const idReaderFields = (
|
|
|
300
346
|
openIdProviderClientId: esignetConfig.openIdProviderClientId,
|
|
301
347
|
}),
|
|
302
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
|
+
];
|
|
303
368
|
}
|
|
304
369
|
return [
|
|
305
370
|
...fields,
|
|
@@ -310,9 +375,10 @@ export const idVerificationFields = (
|
|
|
310
375
|
event: string,
|
|
311
376
|
sectionId: string,
|
|
312
377
|
mapping: any,
|
|
378
|
+
esignetConfig?: ESignetConfig,
|
|
313
379
|
) => {
|
|
314
380
|
return [
|
|
315
|
-
verified(event, sectionId, mapping),
|
|
381
|
+
verified(event, sectionId, mapping, esignetConfig),
|
|
316
382
|
idVerificationBanner(event, sectionId, "verified"),
|
|
317
383
|
idVerificationBanner(event, sectionId, "failed"),
|
|
318
384
|
idVerificationBanner(event, sectionId, "authenticated"),
|