@opencrvs/mosip 1.7.0-alpha.12 → 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
@@ -55,8 +55,6 @@ export declare const popupButton: ({ url, }: {
55
55
  */
56
56
  export declare const esignetCallback: ({ fieldName, mosipAPIUserInfoUrl, openIdProviderClientId, }: {
57
57
  fieldName: string;
58
- event: string;
59
- sectionId: string;
60
58
  mosipAPIUserInfoUrl: string;
61
59
  openIdProviderClientId: string;
62
60
  }) => {
@@ -114,8 +112,22 @@ export declare const idReader: (event: string, sectionId: string, conditionals:
114
112
  };
115
113
  readers: any[];
116
114
  };
117
- 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
+ }) => {
118
126
  type: string;
127
+ validation: {
128
+ rule: Record<string, unknown>;
129
+ errorMessage: MessageDescriptor;
130
+ };
119
131
  };
120
132
  export declare const verified: (event: string, sectionId: string) => {
121
133
  name: string;
@@ -133,13 +145,13 @@ export declare const verified: (event: string, sectionId: string) => {
133
145
  };
134
146
  validator: never[];
135
147
  };
136
- export declare const idPendingVerificationBanner: (event: string, sectionId: string) => {
148
+ export declare const idVerificationBanner: (event: string, sectionId: string, status: "pending" | "verified" | "failed") => {
137
149
  name: string;
138
150
  type: string;
139
151
  fieldId: string;
140
152
  hideInPreview: boolean;
141
153
  custom: boolean;
142
- bannerType: string;
154
+ bannerType: "pending" | "verified" | "failed";
143
155
  idFieldName: string;
144
156
  label: {
145
157
  id: string;
@@ -172,7 +184,7 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
172
184
  fieldId: string;
173
185
  hideInPreview: boolean;
174
186
  custom: boolean;
175
- bannerType: string;
187
+ bannerType: "pending" | "verified" | "failed";
176
188
  idFieldName: string;
177
189
  label: {
178
190
  id: string;
@@ -184,3 +196,4 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
184
196
  expression: string;
185
197
  }[];
186
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.12",
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,
@@ -96,8 +93,6 @@ export const esignetCallback = ({
96
93
  openIdProviderClientId,
97
94
  }: {
98
95
  fieldName: string;
99
- event: string;
100
- sectionId: string;
101
96
  mosipAPIUserInfoUrl: string;
102
97
  openIdProviderClientId: string;
103
98
  }) => ({
@@ -117,8 +112,7 @@ export const esignetCallback = ({
117
112
  },
118
113
  body: {
119
114
  clientId: openIdProviderClientId,
120
- redirectUri:
121
- '${window.location.href}',
115
+ redirectUri: "${window.location.href}",
122
116
  },
123
117
 
124
118
  method: "POST",
@@ -172,8 +166,22 @@ export const idReader = (
172
166
  };
173
167
  };
174
168
 
175
- 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
+ }) => ({
176
183
  type: "QR",
184
+ validation,
177
185
  });
178
186
 
179
187
  export const verified = (event: string, sectionId: string) => {
@@ -197,19 +205,24 @@ export const verified = (event: string, sectionId: string) => {
197
205
  };
198
206
  };
199
207
 
200
- export const idPendingVerificationBanner = (
208
+ function capitalize(str: string) {
209
+ return str.charAt(0).toUpperCase() + str.slice(1);
210
+ }
211
+
212
+ export const idVerificationBanner = (
201
213
  event: string,
202
214
  sectionId: string,
215
+ status: "pending" | "verified" | "failed",
203
216
  ) => {
204
217
  const fieldName = "verified";
205
218
  const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
206
219
  return {
207
- name: "idPending",
220
+ name: `id${capitalize(status)}.`,
208
221
  type: "ID_VERIFICATION_BANNER",
209
222
  fieldId,
210
223
  hideInPreview: true,
211
224
  custom: true,
212
- bannerType: "pending",
225
+ bannerType: status,
213
226
  idFieldName: "idReader",
214
227
  label: {
215
228
  id: "form.field.label.empty",
@@ -219,7 +232,7 @@ export const idPendingVerificationBanner = (
219
232
  conditionals: [
220
233
  {
221
234
  action: "hide",
222
- expression: '$form?.verified !== "pending"',
235
+ expression: `$form?.verified !== "${status}"`,
223
236
  },
224
237
  ],
225
238
  };
@@ -228,6 +241,8 @@ export const idPendingVerificationBanner = (
228
241
  export const idVerificationFields = (event: string, sectionId: string) => {
229
242
  return [
230
243
  verified(event, sectionId),
231
- idPendingVerificationBanner(event, sectionId),
244
+ idVerificationBanner(event, sectionId, "pending"),
245
+ idVerificationBanner(event, sectionId, "verified"),
246
+ idVerificationBanner(event, sectionId, "failed"),
232
247
  ];
233
248
  };