@opencrvs/mosip 1.7.0-alpha.13 → 1.7.0-alpha.15

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
@@ -112,10 +112,24 @@ export declare const idReader: (event: string, sectionId: string, conditionals:
112
112
  };
113
113
  readers: any[];
114
114
  };
115
- export declare const qr: () => {
115
+ type MessageDescriptor = {
116
+ id: string;
117
+ defaultMessage: string;
118
+ description?: string;
119
+ };
120
+ export declare const qr: ({ validation, }: {
121
+ validation: {
122
+ rule: Record<string, unknown>;
123
+ errorMessage: MessageDescriptor;
124
+ };
125
+ }) => {
116
126
  type: string;
127
+ validation: {
128
+ rule: Record<string, unknown>;
129
+ errorMessage: MessageDescriptor;
130
+ };
117
131
  };
118
- export declare const verified: (event: string, sectionId: string) => {
132
+ export declare const verified: (event: string, sectionId: string, mapping: any) => {
119
133
  name: string;
120
134
  fieldId: string;
121
135
  customQuestionMappingId: string;
@@ -130,14 +144,15 @@ export declare const verified: (event: string, sectionId: string) => {
130
144
  expression: string;
131
145
  };
132
146
  validator: never[];
147
+ mapping: any;
133
148
  };
134
- export declare const idPendingVerificationBanner: (event: string, sectionId: string) => {
149
+ export declare const idVerificationBanner: (event: string, sectionId: string, status: "pending" | "verified" | "failed") => {
135
150
  name: string;
136
151
  type: string;
137
152
  fieldId: string;
138
153
  hideInPreview: boolean;
139
154
  custom: boolean;
140
- bannerType: string;
155
+ bannerType: "pending" | "verified" | "failed";
141
156
  idFieldName: string;
142
157
  label: {
143
158
  id: string;
@@ -149,7 +164,7 @@ export declare const idPendingVerificationBanner: (event: string, sectionId: str
149
164
  expression: string;
150
165
  }[];
151
166
  };
152
- export declare const idVerificationFields: (event: string, sectionId: string) => ({
167
+ export declare const idVerificationFields: (event: string, sectionId: string, mapping: any) => ({
153
168
  name: string;
154
169
  fieldId: string;
155
170
  customQuestionMappingId: string;
@@ -164,13 +179,14 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
164
179
  expression: string;
165
180
  };
166
181
  validator: never[];
182
+ mapping: any;
167
183
  } | {
168
184
  name: string;
169
185
  type: string;
170
186
  fieldId: string;
171
187
  hideInPreview: boolean;
172
188
  custom: boolean;
173
- bannerType: string;
189
+ bannerType: "pending" | "verified" | "failed";
174
190
  idFieldName: string;
175
191
  label: {
176
192
  id: string;
@@ -182,3 +198,4 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
182
198
  expression: string;
183
199
  }[];
184
200
  })[];
201
+ export {};
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.idPendingVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
4
+ exports.idVerificationFields = 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
@@ -25,7 +25,7 @@ const esignet = (esignetAuthUrl, openIdProviderClientId, openIdProviderClaims =
25
25
  url.searchParams.append("acr_values", "mosip:idp:acr:static-code");
26
26
  url.searchParams.append("claims", openIdProviderClaims);
27
27
  url.searchParams.append("state", "fetch-on-mount");
28
- url.searchParams.append("redirect_uri", '${window.location.href}');
28
+ url.searchParams.append("redirect_uri", "${window.location.href}");
29
29
  return {
30
30
  name: fieldName,
31
31
  validator: [],
@@ -90,7 +90,7 @@ const esignetCallback = ({ fieldName, mosipAPIUserInfoUrl, openIdProviderClientI
90
90
  },
91
91
  body: {
92
92
  clientId: openIdProviderClientId,
93
- redirectUri: '${window.location.href}',
93
+ redirectUri: "${window.location.href}",
94
94
  },
95
95
  method: "POST",
96
96
  },
@@ -137,11 +137,12 @@ const idReader = (event, sectionId, conditionals, readers) => {
137
137
  };
138
138
  };
139
139
  exports.idReader = idReader;
140
- const qr = () => ({
140
+ const qr = ({ validation, }) => ({
141
141
  type: "QR",
142
+ validation,
142
143
  });
143
144
  exports.qr = qr;
144
- const verified = (event, sectionId) => {
145
+ const verified = (event, sectionId, mapping) => {
145
146
  const fieldName = "verified";
146
147
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
147
148
  return {
@@ -159,19 +160,23 @@ const verified = (event, sectionId) => {
159
160
  expression: 'Boolean($form?.idReader)? "pending":""',
160
161
  },
161
162
  validator: [],
163
+ mapping
162
164
  };
163
165
  };
164
166
  exports.verified = verified;
165
- const idPendingVerificationBanner = (event, sectionId) => {
167
+ function capitalize(str) {
168
+ return str.charAt(0).toUpperCase() + str.slice(1);
169
+ }
170
+ const idVerificationBanner = (event, sectionId, status) => {
166
171
  const fieldName = "verified";
167
172
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
168
173
  return {
169
- name: "idPending",
174
+ name: `id${capitalize(status)}.`,
170
175
  type: "ID_VERIFICATION_BANNER",
171
176
  fieldId,
172
177
  hideInPreview: true,
173
178
  custom: true,
174
- bannerType: "pending",
179
+ bannerType: status,
175
180
  idFieldName: "idReader",
176
181
  label: {
177
182
  id: "form.field.label.empty",
@@ -181,16 +186,18 @@ const idPendingVerificationBanner = (event, sectionId) => {
181
186
  conditionals: [
182
187
  {
183
188
  action: "hide",
184
- expression: '$form?.verified !== "pending"',
189
+ expression: `$form?.verified !== "${status}"`,
185
190
  },
186
191
  ],
187
192
  };
188
193
  };
189
- exports.idPendingVerificationBanner = idPendingVerificationBanner;
190
- const idVerificationFields = (event, sectionId) => {
194
+ exports.idVerificationBanner = idVerificationBanner;
195
+ const idVerificationFields = (event, sectionId, mapping) => {
191
196
  return [
192
- (0, exports.verified)(event, sectionId),
193
- (0, exports.idPendingVerificationBanner)(event, sectionId),
197
+ (0, exports.verified)(event, sectionId, mapping),
198
+ (0, exports.idVerificationBanner)(event, sectionId, "pending"),
199
+ (0, exports.idVerificationBanner)(event, sectionId, "verified"),
200
+ (0, exports.idVerificationBanner)(event, sectionId, "failed"),
194
201
  ];
195
202
  };
196
203
  exports.idVerificationFields = idVerificationFields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/mosip",
3
- "version": "1.7.0-alpha.13",
3
+ "version": "1.7.0-alpha.15",
4
4
  "license": "MPL-2.0",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
package/src/forms.ts CHANGED
@@ -34,10 +34,7 @@ export const esignet = (
34
34
  url.searchParams.append("acr_values", "mosip:idp:acr:static-code");
35
35
  url.searchParams.append("claims", openIdProviderClaims);
36
36
  url.searchParams.append("state", "fetch-on-mount");
37
- url.searchParams.append(
38
- "redirect_uri",
39
- '${window.location.href}',
40
- );
37
+ url.searchParams.append("redirect_uri", "${window.location.href}");
41
38
 
42
39
  return {
43
40
  name: fieldName,
@@ -115,8 +112,7 @@ export const esignetCallback = ({
115
112
  },
116
113
  body: {
117
114
  clientId: openIdProviderClientId,
118
- redirectUri:
119
- '${window.location.href}',
115
+ redirectUri: "${window.location.href}",
120
116
  },
121
117
 
122
118
  method: "POST",
@@ -170,11 +166,25 @@ export const idReader = (
170
166
  };
171
167
  };
172
168
 
173
- export const qr = () => ({
169
+ type MessageDescriptor = {
170
+ id: string;
171
+ defaultMessage: string;
172
+ description?: string;
173
+ };
174
+
175
+ export const qr = ({
176
+ validation,
177
+ }: {
178
+ validation: {
179
+ rule: Record<string, unknown>;
180
+ errorMessage: MessageDescriptor;
181
+ };
182
+ }) => ({
174
183
  type: "QR",
184
+ validation,
175
185
  });
176
186
 
177
- export const verified = (event: string, sectionId: string) => {
187
+ export const verified = (event: string, sectionId: string, mapping: any) => {
178
188
  const fieldName = "verified";
179
189
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
180
190
  return {
@@ -192,22 +202,28 @@ export const verified = (event: string, sectionId: string) => {
192
202
  expression: 'Boolean($form?.idReader)? "pending":""',
193
203
  },
194
204
  validator: [],
205
+ mapping
195
206
  };
196
207
  };
197
208
 
198
- export const idPendingVerificationBanner = (
209
+ function capitalize(str: string) {
210
+ return str.charAt(0).toUpperCase() + str.slice(1);
211
+ }
212
+
213
+ export const idVerificationBanner = (
199
214
  event: string,
200
215
  sectionId: string,
216
+ status: "pending" | "verified" | "failed",
201
217
  ) => {
202
218
  const fieldName = "verified";
203
219
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
204
220
  return {
205
- name: "idPending",
221
+ name: `id${capitalize(status)}.`,
206
222
  type: "ID_VERIFICATION_BANNER",
207
223
  fieldId,
208
224
  hideInPreview: true,
209
225
  custom: true,
210
- bannerType: "pending",
226
+ bannerType: status,
211
227
  idFieldName: "idReader",
212
228
  label: {
213
229
  id: "form.field.label.empty",
@@ -217,15 +233,17 @@ export const idPendingVerificationBanner = (
217
233
  conditionals: [
218
234
  {
219
235
  action: "hide",
220
- expression: '$form?.verified !== "pending"',
236
+ expression: `$form?.verified !== "${status}"`,
221
237
  },
222
238
  ],
223
239
  };
224
240
  };
225
241
 
226
- export const idVerificationFields = (event: string, sectionId: string) => {
242
+ export const idVerificationFields = (event: string, sectionId: string, mapping: any) => {
227
243
  return [
228
- verified(event, sectionId),
229
- idPendingVerificationBanner(event, sectionId),
244
+ verified(event, sectionId, mapping),
245
+ idVerificationBanner(event, sectionId, "pending"),
246
+ idVerificationBanner(event, sectionId, "verified"),
247
+ idVerificationBanner(event, sectionId, "failed"),
230
248
  ];
231
249
  };