@opencrvs/mosip 1.7.0-alpha.16 → 1.7.0-alpha.18

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 CHANGED
@@ -110,6 +110,11 @@ export declare const idReader: (event: string, sectionId: string, conditionals:
110
110
  id: string;
111
111
  defaultMessage: string;
112
112
  };
113
+ mapping: {
114
+ mutation: {
115
+ operation: string;
116
+ };
117
+ };
113
118
  readers: any[];
114
119
  };
115
120
  type MessageDescriptor = {
@@ -117,18 +122,27 @@ type MessageDescriptor = {
117
122
  defaultMessage: string;
118
123
  description?: string;
119
124
  };
120
- export declare const qr: ({ validation, }: {
121
- validation: {
122
- rule: Record<string, unknown>;
123
- errorMessage: MessageDescriptor;
124
- };
125
- }) => {
125
+ interface QRValidation {
126
+ rule: Record<string, unknown>;
127
+ errorMessage: MessageDescriptor;
128
+ }
129
+ interface QRConfig {
130
+ validation: QRValidation;
131
+ }
132
+ export declare const qr: ({ validation }: QRConfig) => {
126
133
  type: string;
127
- validation: {
128
- rule: Record<string, unknown>;
129
- errorMessage: MessageDescriptor;
130
- };
134
+ validation: QRValidation;
131
135
  };
136
+ interface ESignetConfig {
137
+ esignetAuthUrl: string;
138
+ openIdProviderClientId: string;
139
+ openIdProviderClaims: string | undefined;
140
+ fieldName: string;
141
+ callback: {
142
+ fieldName: string;
143
+ mosipAPIUserInfoUrl: string;
144
+ };
145
+ }
132
146
  export declare const verified: (event: string, sectionId: string, mapping: any) => {
133
147
  name: string;
134
148
  fieldId: string;
@@ -146,13 +160,13 @@ export declare const verified: (event: string, sectionId: string, mapping: any)
146
160
  validator: never[];
147
161
  mapping: any;
148
162
  };
149
- export declare const idVerificationBanner: (event: string, sectionId: string, status: "pending" | "verified" | "failed") => {
163
+ export declare const idVerificationBanner: (event: string, sectionId: string, status: "verified" | "failed" | "authenticated") => {
150
164
  name: string;
151
165
  type: string;
152
166
  fieldId: string;
153
167
  hideInPreview: boolean;
154
168
  custom: boolean;
155
- bannerType: "pending" | "verified" | "failed";
169
+ bannerType: "verified" | "failed" | "authenticated";
156
170
  idFieldName: string;
157
171
  label: {
158
172
  id: string;
@@ -164,6 +178,11 @@ export declare const idVerificationBanner: (event: string, sectionId: string, st
164
178
  expression: string;
165
179
  }[];
166
180
  };
181
+ export declare const getInitialValueFromIDReader: (fieldNameInReader: string) => {
182
+ dependsOn: string[];
183
+ expression: string;
184
+ };
185
+ export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => any[];
167
186
  export declare const idVerificationFields: (event: string, sectionId: string, mapping: any) => ({
168
187
  name: string;
169
188
  fieldId: string;
@@ -186,7 +205,7 @@ export declare const idVerificationFields: (event: string, sectionId: string, ma
186
205
  fieldId: string;
187
206
  hideInPreview: boolean;
188
207
  custom: boolean;
189
- bannerType: "pending" | "verified" | "failed";
208
+ bannerType: "verified" | "failed" | "authenticated";
190
209
  idFieldName: string;
191
210
  label: {
192
211
  id: string;
package/build/forms.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // @TODO: Yet to be implemented! Placeholders for NPM publish.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.idVerificationFields = exports.idVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
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
5
  /**
6
6
  * E-Signet popup button and hidden field form definitions
7
7
  * @example
@@ -118,8 +118,8 @@ const idReader = (event, sectionId, conditionals, readers) => {
118
118
  required: false,
119
119
  type: "ID_READER",
120
120
  label: {
121
- id: "form.field.label.empty",
122
- defaultMessage: "",
121
+ id: "form.field.label.idReader",
122
+ defaultMessage: "ID verification",
123
123
  },
124
124
  hideInPreview: true,
125
125
  initialValue: "",
@@ -133,11 +133,16 @@ const idReader = (event, sectionId, conditionals, readers) => {
133
133
  id: "views.idReader.label.manualInput",
134
134
  defaultMessage: "Complete fields below",
135
135
  },
136
+ mapping: {
137
+ mutation: {
138
+ operation: "ignoreFieldTransformer",
139
+ },
140
+ },
136
141
  readers,
137
142
  };
138
143
  };
139
144
  exports.idReader = idReader;
140
- const qr = ({ validation, }) => ({
145
+ const qr = ({ validation }) => ({
141
146
  type: "QR",
142
147
  validation,
143
148
  });
@@ -160,7 +165,7 @@ const verified = (event, sectionId, mapping) => {
160
165
  expression: 'Boolean($form?.idReader)? "pending":""',
161
166
  },
162
167
  validator: [],
163
- mapping
168
+ mapping,
164
169
  };
165
170
  };
166
171
  exports.verified = verified;
@@ -192,12 +197,39 @@ const idVerificationBanner = (event, sectionId, status) => {
192
197
  };
193
198
  };
194
199
  exports.idVerificationBanner = idVerificationBanner;
200
+ const getInitialValueFromIDReader = (fieldNameInReader) => ({
201
+ dependsOn: ["idReader", "esignetCallback"],
202
+ expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
203
+ });
204
+ exports.getInitialValueFromIDReader = getInitialValueFromIDReader;
205
+ const idReaderFields = (event, section, qrConfig, esignetConfig, verifiedCustomFieldMapping, conditionals = []) => {
206
+ const readers = [(0, exports.qr)(qrConfig)];
207
+ const fields = [
208
+ (0, exports.idReader)(event, section, conditionals.concat({
209
+ action: "hide",
210
+ expression: "$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'",
211
+ }), readers),
212
+ ];
213
+ if (esignetConfig) {
214
+ readers.push((0, exports.esignet)(esignetConfig.esignetAuthUrl, esignetConfig.openIdProviderClientId, esignetConfig.openIdProviderClaims, esignetConfig.fieldName, esignetConfig.callback.fieldName));
215
+ fields.push((0, exports.esignetCallback)({
216
+ fieldName: esignetConfig.callback.fieldName,
217
+ mosipAPIUserInfoUrl: esignetConfig.callback.mosipAPIUserInfoUrl,
218
+ openIdProviderClientId: esignetConfig.openIdProviderClientId,
219
+ }));
220
+ }
221
+ return [
222
+ ...fields,
223
+ ...(0, exports.idVerificationFields)(event, section, verifiedCustomFieldMapping),
224
+ ];
225
+ };
226
+ exports.idReaderFields = idReaderFields;
195
227
  const idVerificationFields = (event, sectionId, mapping) => {
196
228
  return [
197
229
  (0, exports.verified)(event, sectionId, mapping),
198
- (0, exports.idVerificationBanner)(event, sectionId, "pending"),
199
230
  (0, exports.idVerificationBanner)(event, sectionId, "verified"),
200
231
  (0, exports.idVerificationBanner)(event, sectionId, "failed"),
232
+ (0, exports.idVerificationBanner)(event, sectionId, "authenticated"),
201
233
  ];
202
234
  };
203
235
  exports.idVerificationFields = idVerificationFields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/mosip",
3
- "version": "1.7.0-alpha.16",
3
+ "version": "1.7.0-alpha.18",
4
4
  "license": "MPL-2.0",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
package/src/forms.ts CHANGED
@@ -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
  };