@opencrvs/mosip 1.9.2-mock.1 → 2.0.0-rc.1
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/api.d.ts +47 -29
- package/build/api.js +41 -5
- package/build/index.d.ts +1 -3
- package/build/index.js +1 -3
- package/package.json +6 -6
- package/src/api.ts +54 -32
- package/src/index.ts +1 -3
- package/build/events.d.ts +0 -30
- package/build/events.js +0 -80
- package/build/forms.d.ts +0 -253
- package/build/forms.js +0 -298
- package/build/transform.d.ts +0 -77
- package/build/transform.js +0 -19
- package/src/events.ts +0 -105
- package/src/forms.ts +0 -455
- package/src/transform.ts +0 -100
package/src/events.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type * as Hapi from "@hapi/hapi";
|
|
2
|
-
import fetch from "node-fetch";
|
|
3
|
-
import { MOSIPPayload } from "./transform";
|
|
4
|
-
import { VerificationStatus } from "./api";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* NOTE!
|
|
8
|
-
*
|
|
9
|
-
* This file is used in OpenCRVS pre-1.9 country-configs and registrations. You are looking for `api.ts` which caters for OpenCRVS 1.9+.
|
|
10
|
-
* This file can be removed in future versions.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
* Replaces event registration handler in country config
|
|
16
|
-
*/
|
|
17
|
-
export const mosipRegistrationHandler = ({
|
|
18
|
-
url,
|
|
19
|
-
headers,
|
|
20
|
-
payload,
|
|
21
|
-
}: {
|
|
22
|
-
url: string;
|
|
23
|
-
headers: Record<string, string>;
|
|
24
|
-
payload: MOSIPPayload;
|
|
25
|
-
}) =>
|
|
26
|
-
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
27
|
-
const MOSIP_API_REGISTRATION_EVENT_URL = new URL(
|
|
28
|
-
"./events/registration",
|
|
29
|
-
url,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const response = await fetch(MOSIP_API_REGISTRATION_EVENT_URL, {
|
|
33
|
-
method: "POST",
|
|
34
|
-
body: JSON.stringify(payload),
|
|
35
|
-
headers: {
|
|
36
|
-
...headers,
|
|
37
|
-
"content-type": "application/json",
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
return h
|
|
43
|
-
.response({
|
|
44
|
-
error: "OpenCRVS-MOSIP event registration route did not return a 200",
|
|
45
|
-
response: await response.text(),
|
|
46
|
-
})
|
|
47
|
-
.code(500);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return h.response({ success: true }).code(200);
|
|
51
|
-
}) satisfies Hapi.ServerRoute["handler"];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated
|
|
55
|
-
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
56
|
-
*/
|
|
57
|
-
export const mosipRegistrationForReviewHandler = ({ url }: { url: string }) =>
|
|
58
|
-
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
59
|
-
// Corresponds to `packages/mosip-api` /events/review -route
|
|
60
|
-
let response;
|
|
61
|
-
try {
|
|
62
|
-
response = await verify({ url, request });
|
|
63
|
-
} catch (error) {
|
|
64
|
-
return h
|
|
65
|
-
.response({
|
|
66
|
-
error: "OpenCRVS-MOSIP event review route did not return a 200",
|
|
67
|
-
response: error instanceof Error ? error.message : "Unknown error",
|
|
68
|
-
})
|
|
69
|
-
.code(500);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return h.response(response).code(200);
|
|
73
|
-
}) satisfies Hapi.ServerRoute["handler"];
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
77
|
-
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
78
|
-
*/
|
|
79
|
-
export const mosipRegistrationForApprovalHandler =
|
|
80
|
-
mosipRegistrationForReviewHandler;
|
|
81
|
-
|
|
82
|
-
export const verify = async ({
|
|
83
|
-
url,
|
|
84
|
-
request,
|
|
85
|
-
}: {
|
|
86
|
-
url: string;
|
|
87
|
-
request: Hapi.Request;
|
|
88
|
-
}): Promise<Partial<VerificationStatus>> => {
|
|
89
|
-
const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
|
|
90
|
-
|
|
91
|
-
const response = await fetch(MOSIP_API_REVIEW_EVENT_URL, {
|
|
92
|
-
method: "POST",
|
|
93
|
-
body: JSON.stringify(request.payload),
|
|
94
|
-
headers: {
|
|
95
|
-
...request.headers,
|
|
96
|
-
"content-type": "application/json",
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
if (!response.ok) {
|
|
101
|
-
throw new Error(await response.text());
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return (await response.json()) satisfies Partial<VerificationStatus>;
|
|
105
|
-
};
|
package/src/forms.ts
DELETED
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* E-Signet popup button and hidden field form definitions
|
|
3
|
-
* @example
|
|
4
|
-
* ```
|
|
5
|
-
* [
|
|
6
|
-
* // ...other fields
|
|
7
|
-
* ...esignet({ url: "https://opencrvs-mosip-gateway.farajaland.opencrvs.org" })
|
|
8
|
-
* ]
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export const esignet = (
|
|
18
|
-
esignetAuthUrl: string,
|
|
19
|
-
openIdProviderClientId: string,
|
|
20
|
-
openIdProviderClaims: string = "name,family_name,given_name,middle_name,birthdate,address",
|
|
21
|
-
fieldName: string,
|
|
22
|
-
callbackFieldName: string,
|
|
23
|
-
) => {
|
|
24
|
-
const url = new URL(esignetAuthUrl);
|
|
25
|
-
|
|
26
|
-
url.searchParams.append(
|
|
27
|
-
"client_id",
|
|
28
|
-
openIdProviderClientId || "mock-client_id",
|
|
29
|
-
);
|
|
30
|
-
url.searchParams.append("response_type", "code");
|
|
31
|
-
url.searchParams.append("scope", "openid profile");
|
|
32
|
-
url.searchParams.append("acr_values", "mosip:idp:acr:static-code");
|
|
33
|
-
url.searchParams.append("claims", openIdProviderClaims);
|
|
34
|
-
url.searchParams.append("state", "fetch-on-mount");
|
|
35
|
-
url.searchParams.append("redirect_uri", "${window.location.href}");
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
name: fieldName,
|
|
39
|
-
validator: [],
|
|
40
|
-
icon: {
|
|
41
|
-
desktop: "Globe",
|
|
42
|
-
mobile: "Fingerprint",
|
|
43
|
-
},
|
|
44
|
-
type: "LINK_BUTTON",
|
|
45
|
-
custom: true,
|
|
46
|
-
label: {
|
|
47
|
-
id: "views.idReader.label.eSignet",
|
|
48
|
-
defaultMessage: "E-signet",
|
|
49
|
-
},
|
|
50
|
-
hideInPreview: true,
|
|
51
|
-
conditionals: [
|
|
52
|
-
{
|
|
53
|
-
action: "disable",
|
|
54
|
-
expression: "!!$form.redirectCallbackFetch",
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
mapping: {
|
|
58
|
-
mutation: {
|
|
59
|
-
operation: "ignoreFieldTransformer",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
options: {
|
|
63
|
-
url: url.toString(),
|
|
64
|
-
callback: {
|
|
65
|
-
params: {
|
|
66
|
-
state: "fetch-on-mount",
|
|
67
|
-
},
|
|
68
|
-
trigger: callbackFieldName,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const popupButton = ({
|
|
75
|
-
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
|
|
76
|
-
url,
|
|
77
|
-
}: {
|
|
78
|
-
url: string;
|
|
79
|
-
}) => {
|
|
80
|
-
return {
|
|
81
|
-
name: "INFORMANT_AUTHENTICATION_POPUP_BUTTON",
|
|
82
|
-
type: "POPUP_BUTTON",
|
|
83
|
-
url,
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
* @description esignet callback button form definition. Calls https://mosip-api.{{hostname}}/esignet/get-oidp-user-info
|
|
90
|
-
*
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
export const esignetCallback = ({
|
|
94
|
-
fieldName,
|
|
95
|
-
mosipAPIUserInfoUrl,
|
|
96
|
-
openIdProviderClientId,
|
|
97
|
-
}: {
|
|
98
|
-
fieldName: string;
|
|
99
|
-
mosipAPIUserInfoUrl: string;
|
|
100
|
-
openIdProviderClientId: string;
|
|
101
|
-
}) => ({
|
|
102
|
-
name: fieldName,
|
|
103
|
-
type: "HTTP",
|
|
104
|
-
custom: true,
|
|
105
|
-
label: {
|
|
106
|
-
id: "form.field.label.empty",
|
|
107
|
-
defaultMessage: "",
|
|
108
|
-
},
|
|
109
|
-
validator: [],
|
|
110
|
-
hideInPreview: true,
|
|
111
|
-
mapping: {
|
|
112
|
-
mutation: {
|
|
113
|
-
operation: "ignoreFieldTransformer",
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
options: {
|
|
117
|
-
url: mosipAPIUserInfoUrl,
|
|
118
|
-
headers: {
|
|
119
|
-
"Content-type": "application/json",
|
|
120
|
-
},
|
|
121
|
-
body: {
|
|
122
|
-
clientId: openIdProviderClientId,
|
|
123
|
-
redirectUri: "${window.location.href}",
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
method: "POST",
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
export const esignetHidden = () => {
|
|
131
|
-
return {
|
|
132
|
-
name: "INFORMANT_PSUT_TOKEN",
|
|
133
|
-
type: "HIDDEN",
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export const idReader = (
|
|
138
|
-
event: string,
|
|
139
|
-
sectionId: string,
|
|
140
|
-
conditionals: any[],
|
|
141
|
-
readers: any[],
|
|
142
|
-
/** E-Signet callback field name */
|
|
143
|
-
esignetCallbackFieldName?: string,
|
|
144
|
-
) => {
|
|
145
|
-
const fieldName: string = "idReader";
|
|
146
|
-
const fieldId: string = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
147
|
-
const initialValue = esignetCallbackFieldName
|
|
148
|
-
? {
|
|
149
|
-
dependsOn: [esignetCallbackFieldName],
|
|
150
|
-
expression: "''",
|
|
151
|
-
}
|
|
152
|
-
: "";
|
|
153
|
-
return {
|
|
154
|
-
name: fieldName,
|
|
155
|
-
customQuestionMappingId: fieldId,
|
|
156
|
-
custom: true,
|
|
157
|
-
required: false,
|
|
158
|
-
type: "ID_READER",
|
|
159
|
-
label: {
|
|
160
|
-
id: "form.field.label.idReader",
|
|
161
|
-
defaultMessage: "ID verification",
|
|
162
|
-
},
|
|
163
|
-
hideInPreview: true,
|
|
164
|
-
initialValue,
|
|
165
|
-
validator: [],
|
|
166
|
-
conditionals,
|
|
167
|
-
dividerLabel: {
|
|
168
|
-
id: "views.idReader.label.or",
|
|
169
|
-
defaultMessage: "Or",
|
|
170
|
-
},
|
|
171
|
-
manualInputInstructionLabel: {
|
|
172
|
-
id: "views.idReader.label.manualInput",
|
|
173
|
-
defaultMessage: "Complete fields below",
|
|
174
|
-
},
|
|
175
|
-
mapping: {
|
|
176
|
-
mutation: {
|
|
177
|
-
operation: "ignoreFieldTransformer",
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
readers,
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
type MessageDescriptor = {
|
|
185
|
-
id: string;
|
|
186
|
-
defaultMessage: string;
|
|
187
|
-
description?: string;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
interface QRValidation {
|
|
191
|
-
rule: Record<string, unknown>;
|
|
192
|
-
errorMessage: MessageDescriptor;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
interface QRConfig {
|
|
196
|
-
validation: QRValidation;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export const qr = ({ validation }: QRConfig) => ({
|
|
200
|
-
type: "QR",
|
|
201
|
-
validation,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
interface ESignetConfig {
|
|
205
|
-
esignetAuthUrl: string;
|
|
206
|
-
openIdProviderClientId: string;
|
|
207
|
-
openIdProviderClaims: string | undefined;
|
|
208
|
-
fieldName: string;
|
|
209
|
-
callback: {
|
|
210
|
-
fieldName: string;
|
|
211
|
-
mosipAPIUserInfoUrl: string;
|
|
212
|
-
};
|
|
213
|
-
loaderFieldName?: string;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export const verified = (
|
|
217
|
-
event: string,
|
|
218
|
-
sectionId: string,
|
|
219
|
-
mapping: any,
|
|
220
|
-
esignetConfig?: ESignetConfig,
|
|
221
|
-
) => {
|
|
222
|
-
const fieldName = "verified";
|
|
223
|
-
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
224
|
-
return {
|
|
225
|
-
name: "verified",
|
|
226
|
-
fieldId,
|
|
227
|
-
customQuestionMappingId: fieldId,
|
|
228
|
-
type: "HIDDEN",
|
|
229
|
-
custom: true,
|
|
230
|
-
label: {
|
|
231
|
-
id: "form.field.label.empty",
|
|
232
|
-
defaultMessage: "",
|
|
233
|
-
},
|
|
234
|
-
initialValue: esignetConfig
|
|
235
|
-
? {
|
|
236
|
-
dependsOn: ["idReader", esignetConfig.callback.fieldName],
|
|
237
|
-
expression: `Boolean($form?.idReader)? "pending"
|
|
238
|
-
: Boolean($form?.${esignetConfig.callback.fieldName}?.data)? "authenticated"
|
|
239
|
-
: Boolean($form?.${esignetConfig.callback.fieldName}?.error)? "failedFetchIdDetails"
|
|
240
|
-
: ""`,
|
|
241
|
-
}
|
|
242
|
-
: {
|
|
243
|
-
dependsOn: ["idReader"],
|
|
244
|
-
expression: 'Boolean($form?.idReader)? "pending":""',
|
|
245
|
-
},
|
|
246
|
-
validator: [],
|
|
247
|
-
mapping,
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
function capitalize(str: string) {
|
|
252
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
type VerificationStatus =
|
|
256
|
-
| "verified"
|
|
257
|
-
| "failed"
|
|
258
|
-
| "authenticated"
|
|
259
|
-
| "failedFetchIdDetails";
|
|
260
|
-
|
|
261
|
-
export const idVerificationBanner = (
|
|
262
|
-
event: string,
|
|
263
|
-
sectionId: string,
|
|
264
|
-
status: VerificationStatus,
|
|
265
|
-
conditionals: any[] = [],
|
|
266
|
-
) => {
|
|
267
|
-
const fieldName = "verified";
|
|
268
|
-
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
269
|
-
return {
|
|
270
|
-
name: `id${capitalize(status)}.`,
|
|
271
|
-
type: "ID_VERIFICATION_BANNER",
|
|
272
|
-
fieldId,
|
|
273
|
-
hideInPreview: true,
|
|
274
|
-
custom: true,
|
|
275
|
-
bannerType: status,
|
|
276
|
-
idFieldName:
|
|
277
|
-
status === "authenticated" || "failedFetchIdDetails"
|
|
278
|
-
? "esignetCallback"
|
|
279
|
-
: "idReader",
|
|
280
|
-
label: {
|
|
281
|
-
id: "form.field.label.empty",
|
|
282
|
-
defaultMessage: "",
|
|
283
|
-
},
|
|
284
|
-
validator: [],
|
|
285
|
-
conditionals: conditionals.concat([
|
|
286
|
-
{
|
|
287
|
-
action: "hide",
|
|
288
|
-
expression: `$form?.verified !== "${status}"`,
|
|
289
|
-
},
|
|
290
|
-
]),
|
|
291
|
-
};
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
export function esignetLoaderField({
|
|
295
|
-
event,
|
|
296
|
-
section,
|
|
297
|
-
fieldName,
|
|
298
|
-
esignetCallbackFieldName,
|
|
299
|
-
}: {
|
|
300
|
-
event: "birth" | "death";
|
|
301
|
-
section: "informant" | "mother" | "father" | "spouse" | "deceased";
|
|
302
|
-
fieldName: string;
|
|
303
|
-
esignetCallbackFieldName: string;
|
|
304
|
-
}) {
|
|
305
|
-
const fieldId = `${event}.${section}.${section}-view-group.${fieldName}`;
|
|
306
|
-
return {
|
|
307
|
-
name: fieldName,
|
|
308
|
-
type: "LOADER",
|
|
309
|
-
fieldId,
|
|
310
|
-
hideInPreview: true,
|
|
311
|
-
custom: true,
|
|
312
|
-
label: {
|
|
313
|
-
id: "form.field.label.idReader",
|
|
314
|
-
defaultMessage: "ID verification",
|
|
315
|
-
},
|
|
316
|
-
loadingText: {
|
|
317
|
-
id: "form.field.label.authenticating.nid",
|
|
318
|
-
defaultMessage: "Fetching the person's data from E-Signet",
|
|
319
|
-
},
|
|
320
|
-
conditionals: [
|
|
321
|
-
{
|
|
322
|
-
action: "hide",
|
|
323
|
-
expression: `!$form?.${esignetCallbackFieldName}?.loading`,
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
export const getInitialValueFromIDReader = (fieldNameInReader: string) => ({
|
|
330
|
-
dependsOn: ["idReader", "esignetCallback"],
|
|
331
|
-
expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
// Define a type def so that a country implementor cannot
|
|
335
|
-
// provide both QR and E-Signet config undefined at the same time
|
|
336
|
-
type IDReaderParams = {
|
|
337
|
-
(
|
|
338
|
-
event: "birth" | "death",
|
|
339
|
-
section: "informant" | "mother" | "father" | "spouse" | "deceased",
|
|
340
|
-
qrConfig: QRConfig,
|
|
341
|
-
esignetConfig: ESignetConfig,
|
|
342
|
-
verifiedCustomFieldMapping: any,
|
|
343
|
-
conditionals?: any[],
|
|
344
|
-
): any[];
|
|
345
|
-
(
|
|
346
|
-
event: "birth" | "death",
|
|
347
|
-
section: "informant" | "mother" | "father" | "spouse" | "deceased",
|
|
348
|
-
qrConfig: QRConfig,
|
|
349
|
-
esignetConfig: undefined,
|
|
350
|
-
verifiedCustomFieldMapping: any,
|
|
351
|
-
conditionals?: any[],
|
|
352
|
-
): any[];
|
|
353
|
-
(
|
|
354
|
-
event: "birth" | "death",
|
|
355
|
-
section: "informant" | "mother" | "father" | "spouse" | "deceased",
|
|
356
|
-
qrConfig: undefined,
|
|
357
|
-
esignetConfig: ESignetConfig,
|
|
358
|
-
verifiedCustomFieldMapping: any,
|
|
359
|
-
conditionals?: any[],
|
|
360
|
-
): any[];
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
export const idReaderFields: IDReaderParams = (
|
|
364
|
-
event: "birth" | "death",
|
|
365
|
-
section: "informant" | "mother" | "father" | "spouse" | "deceased",
|
|
366
|
-
qrConfig: QRConfig | undefined,
|
|
367
|
-
esignetConfig: ESignetConfig | undefined,
|
|
368
|
-
verifiedCustomFieldMapping: any,
|
|
369
|
-
conditionals: any[] = [],
|
|
370
|
-
) => {
|
|
371
|
-
const readers: any[] = [];
|
|
372
|
-
if (qrConfig) {
|
|
373
|
-
readers.push(qr(qrConfig));
|
|
374
|
-
}
|
|
375
|
-
const fields: any[] = [
|
|
376
|
-
idReader(
|
|
377
|
-
event,
|
|
378
|
-
section,
|
|
379
|
-
conditionals.concat({
|
|
380
|
-
action: "hide",
|
|
381
|
-
expression:
|
|
382
|
-
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed' || $form?.verified === 'failedFetchIdDetails' || !!$form?.esignetCallback?.loading",
|
|
383
|
-
}),
|
|
384
|
-
readers,
|
|
385
|
-
esignetConfig?.callback.fieldName,
|
|
386
|
-
),
|
|
387
|
-
];
|
|
388
|
-
if (esignetConfig) {
|
|
389
|
-
readers.push(
|
|
390
|
-
esignet(
|
|
391
|
-
esignetConfig.esignetAuthUrl,
|
|
392
|
-
esignetConfig.openIdProviderClientId,
|
|
393
|
-
esignetConfig.openIdProviderClaims,
|
|
394
|
-
esignetConfig.fieldName,
|
|
395
|
-
esignetConfig.callback.fieldName,
|
|
396
|
-
),
|
|
397
|
-
);
|
|
398
|
-
fields.push(
|
|
399
|
-
esignetCallback({
|
|
400
|
-
fieldName: esignetConfig.callback.fieldName,
|
|
401
|
-
mosipAPIUserInfoUrl: esignetConfig.callback.mosipAPIUserInfoUrl,
|
|
402
|
-
openIdProviderClientId: esignetConfig.openIdProviderClientId,
|
|
403
|
-
}),
|
|
404
|
-
);
|
|
405
|
-
if (esignetConfig.loaderFieldName) {
|
|
406
|
-
fields.push(
|
|
407
|
-
esignetLoaderField({
|
|
408
|
-
event,
|
|
409
|
-
section,
|
|
410
|
-
fieldName: esignetConfig.loaderFieldName,
|
|
411
|
-
esignetCallbackFieldName: esignetConfig.callback.fieldName,
|
|
412
|
-
}),
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
return [
|
|
416
|
-
...fields,
|
|
417
|
-
...idVerificationFields(
|
|
418
|
-
event,
|
|
419
|
-
section,
|
|
420
|
-
verifiedCustomFieldMapping,
|
|
421
|
-
conditionals,
|
|
422
|
-
esignetConfig,
|
|
423
|
-
),
|
|
424
|
-
];
|
|
425
|
-
}
|
|
426
|
-
return [
|
|
427
|
-
...fields,
|
|
428
|
-
...idVerificationFields(
|
|
429
|
-
event,
|
|
430
|
-
section,
|
|
431
|
-
verifiedCustomFieldMapping,
|
|
432
|
-
conditionals,
|
|
433
|
-
),
|
|
434
|
-
];
|
|
435
|
-
};
|
|
436
|
-
export const idVerificationFields = (
|
|
437
|
-
event: string,
|
|
438
|
-
sectionId: string,
|
|
439
|
-
mapping: any,
|
|
440
|
-
conditionals: any[] = [],
|
|
441
|
-
esignetConfig?: ESignetConfig,
|
|
442
|
-
) => {
|
|
443
|
-
return [
|
|
444
|
-
verified(event, sectionId, mapping, esignetConfig),
|
|
445
|
-
idVerificationBanner(event, sectionId, "verified", conditionals),
|
|
446
|
-
idVerificationBanner(event, sectionId, "failed", conditionals),
|
|
447
|
-
idVerificationBanner(event, sectionId, "authenticated", conditionals),
|
|
448
|
-
idVerificationBanner(
|
|
449
|
-
event,
|
|
450
|
-
sectionId,
|
|
451
|
-
"failedFetchIdDetails",
|
|
452
|
-
conditionals,
|
|
453
|
-
),
|
|
454
|
-
];
|
|
455
|
-
};
|
package/src/transform.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
type IdentityInfo = { value: string; language: string };
|
|
2
|
-
|
|
3
|
-
export interface MOSIPPayload {
|
|
4
|
-
compositionId: string;
|
|
5
|
-
trackingId: string;
|
|
6
|
-
notification: {
|
|
7
|
-
recipientFullName: string;
|
|
8
|
-
recipientEmail: string;
|
|
9
|
-
recipientPhone: string;
|
|
10
|
-
};
|
|
11
|
-
requestFields: {
|
|
12
|
-
fullName: string;
|
|
13
|
-
dateOfBirth: string;
|
|
14
|
-
gender: string;
|
|
15
|
-
guardianOrParentName: string;
|
|
16
|
-
nationalIdNumber: string;
|
|
17
|
-
passportNumber: string;
|
|
18
|
-
drivingLicenseNumber: string;
|
|
19
|
-
deceasedStatus: boolean;
|
|
20
|
-
residenceStatus: string;
|
|
21
|
-
vid: string;
|
|
22
|
-
email: string;
|
|
23
|
-
phone: string;
|
|
24
|
-
guardianOrParentBirthCertificateNumber: string;
|
|
25
|
-
deathCertificateNumber: string;
|
|
26
|
-
birthCertificateNumber: string;
|
|
27
|
-
addressLine1: string;
|
|
28
|
-
addressLine2: string;
|
|
29
|
-
addressLine3: string;
|
|
30
|
-
district: string;
|
|
31
|
-
village: string;
|
|
32
|
-
birthRegistrationCertificate: string;
|
|
33
|
-
passportId: string;
|
|
34
|
-
nationalId: string;
|
|
35
|
-
drivingLicenseId: string;
|
|
36
|
-
addressProof: string;
|
|
37
|
-
selectedHandles: string;
|
|
38
|
-
UIN: string;
|
|
39
|
-
deathDeclared: string;
|
|
40
|
-
dateOfDeath: string;
|
|
41
|
-
};
|
|
42
|
-
metaInfo: {
|
|
43
|
-
metaData: string;
|
|
44
|
-
registrationId: string;
|
|
45
|
-
operationsData: string;
|
|
46
|
-
capturedRegisteredDevices: string;
|
|
47
|
-
creationDate: string;
|
|
48
|
-
};
|
|
49
|
-
audit: {
|
|
50
|
-
uuid: string;
|
|
51
|
-
createdAt: string;
|
|
52
|
-
eventId: string;
|
|
53
|
-
eventName: string;
|
|
54
|
-
eventType: string;
|
|
55
|
-
hostName: string;
|
|
56
|
-
hostIp: string;
|
|
57
|
-
applicationId: string;
|
|
58
|
-
applicationName: string;
|
|
59
|
-
sessionUserId: string;
|
|
60
|
-
sessionUserName: string;
|
|
61
|
-
id: string;
|
|
62
|
-
idType: string;
|
|
63
|
-
createdBy: string;
|
|
64
|
-
moduleName: string;
|
|
65
|
-
moduleId: string;
|
|
66
|
-
description: string;
|
|
67
|
-
actionTimeStamp: string;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
type Resolver<T> = (bundle: fhir3.Bundle) => T;
|
|
72
|
-
|
|
73
|
-
type ResolverMap<T> = {
|
|
74
|
-
[K in keyof T]?: T[K] extends IdentityInfo[] | string | boolean | number
|
|
75
|
-
? Resolver<T[K]>
|
|
76
|
-
: ResolverMap<T[K]>;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export function fhirBundleToMOSIPPayload(
|
|
80
|
-
bundle: fhir3.Bundle,
|
|
81
|
-
resolverMap: ResolverMap<MOSIPPayload>,
|
|
82
|
-
): MOSIPPayload {
|
|
83
|
-
const assignResolvers = <T extends object>(resolvers: ResolverMap<T>): T => {
|
|
84
|
-
const result = {} as T;
|
|
85
|
-
|
|
86
|
-
for (const key in resolvers) {
|
|
87
|
-
const resolver = resolvers[key];
|
|
88
|
-
|
|
89
|
-
if (typeof resolver === "function") {
|
|
90
|
-
result[key] = resolver(bundle);
|
|
91
|
-
} else if (resolver && typeof resolver === "object") {
|
|
92
|
-
result[key] = assignResolvers(resolver) as T[Extract<keyof T, string>];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return result;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
return assignResolvers(resolverMap);
|
|
100
|
-
}
|