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

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,8 +112,22 @@ 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
132
  export declare const verified: (event: string, sectionId: string) => {
119
133
  name: string;
@@ -131,13 +145,13 @@ export declare const verified: (event: string, sectionId: string) => {
131
145
  };
132
146
  validator: never[];
133
147
  };
134
- export declare const idPendingVerificationBanner: (event: string, sectionId: string) => {
148
+ export declare const idVerificationBanner: (event: string, sectionId: string, status: "pending" | "verified" | "failed") => {
135
149
  name: string;
136
150
  type: string;
137
151
  fieldId: string;
138
152
  hideInPreview: boolean;
139
153
  custom: boolean;
140
- bannerType: string;
154
+ bannerType: "pending" | "verified" | "failed";
141
155
  idFieldName: string;
142
156
  label: {
143
157
  id: string;
@@ -170,7 +184,7 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
170
184
  fieldId: string;
171
185
  hideInPreview: boolean;
172
186
  custom: boolean;
173
- bannerType: string;
187
+ bannerType: "pending" | "verified" | "failed";
174
188
  idFieldName: string;
175
189
  label: {
176
190
  id: string;
@@ -182,3 +196,4 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
182
196
  expression: string;
183
197
  }[];
184
198
  })[];
199
+ 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,8 +137,9 @@ 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
145
  const verified = (event, sectionId) => {
@@ -162,16 +163,19 @@ const verified = (event, sectionId) => {
162
163
  };
163
164
  };
164
165
  exports.verified = verified;
165
- const idPendingVerificationBanner = (event, sectionId) => {
166
+ function capitalize(str) {
167
+ return str.charAt(0).toUpperCase() + str.slice(1);
168
+ }
169
+ const idVerificationBanner = (event, sectionId, status) => {
166
170
  const fieldName = "verified";
167
171
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
168
172
  return {
169
- name: "idPending",
173
+ name: `id${capitalize(status)}.`,
170
174
  type: "ID_VERIFICATION_BANNER",
171
175
  fieldId,
172
176
  hideInPreview: true,
173
177
  custom: true,
174
- bannerType: "pending",
178
+ bannerType: status,
175
179
  idFieldName: "idReader",
176
180
  label: {
177
181
  id: "form.field.label.empty",
@@ -181,16 +185,18 @@ const idPendingVerificationBanner = (event, sectionId) => {
181
185
  conditionals: [
182
186
  {
183
187
  action: "hide",
184
- expression: '$form?.verified !== "pending"',
188
+ expression: `$form?.verified !== "${status}"`,
185
189
  },
186
190
  ],
187
191
  };
188
192
  };
189
- exports.idPendingVerificationBanner = idPendingVerificationBanner;
193
+ exports.idVerificationBanner = idVerificationBanner;
190
194
  const idVerificationFields = (event, sectionId) => {
191
195
  return [
192
196
  (0, exports.verified)(event, sectionId),
193
- (0, exports.idPendingVerificationBanner)(event, sectionId),
197
+ (0, exports.idVerificationBanner)(event, sectionId, "pending"),
198
+ (0, exports.idVerificationBanner)(event, sectionId, "verified"),
199
+ (0, exports.idVerificationBanner)(event, sectionId, "failed"),
194
200
  ];
195
201
  };
196
202
  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.14",
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,8 +166,22 @@ 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
187
  export const verified = (event: string, sectionId: string) => {
@@ -195,19 +205,24 @@ export const verified = (event: string, sectionId: string) => {
195
205
  };
196
206
  };
197
207
 
198
- export const idPendingVerificationBanner = (
208
+ function capitalize(str: string) {
209
+ return str.charAt(0).toUpperCase() + str.slice(1);
210
+ }
211
+
212
+ export const idVerificationBanner = (
199
213
  event: string,
200
214
  sectionId: string,
215
+ status: "pending" | "verified" | "failed",
201
216
  ) => {
202
217
  const fieldName = "verified";
203
218
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
204
219
  return {
205
- name: "idPending",
220
+ name: `id${capitalize(status)}.`,
206
221
  type: "ID_VERIFICATION_BANNER",
207
222
  fieldId,
208
223
  hideInPreview: true,
209
224
  custom: true,
210
- bannerType: "pending",
225
+ bannerType: status,
211
226
  idFieldName: "idReader",
212
227
  label: {
213
228
  id: "form.field.label.empty",
@@ -217,7 +232,7 @@ export const idPendingVerificationBanner = (
217
232
  conditionals: [
218
233
  {
219
234
  action: "hide",
220
- expression: '$form?.verified !== "pending"',
235
+ expression: `$form?.verified !== "${status}"`,
221
236
  },
222
237
  ],
223
238
  };
@@ -226,6 +241,8 @@ export const idPendingVerificationBanner = (
226
241
  export const idVerificationFields = (event: string, sectionId: string) => {
227
242
  return [
228
243
  verified(event, sectionId),
229
- idPendingVerificationBanner(event, sectionId),
244
+ idVerificationBanner(event, sectionId, "pending"),
245
+ idVerificationBanner(event, sectionId, "verified"),
246
+ idVerificationBanner(event, sectionId, "failed"),
230
247
  ];
231
248
  };