@opencrvs/mosip 1.7.0-alpha.9 → 1.8.0-beta.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/events.d.ts +30 -1
- package/build/events.js +54 -7
- package/build/forms.d.ts +84 -24
- package/build/forms.js +175 -83
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/transform.d.ts +69 -0
- package/build/transform.js +19 -0
- package/package.json +3 -2
- package/src/events.ts +83 -6
- package/src/forms.ts +277 -99
- package/src/index.ts +1 -0
- package/src/transform.ts +92 -0
- package/tsconfig.json +1 -1
package/build/events.d.ts
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
import type * as Hapi from "@hapi/hapi";
|
|
2
|
-
|
|
2
|
+
import { MOSIPPayload } from "./transform";
|
|
3
|
+
interface VerificationStatus {
|
|
4
|
+
father: boolean;
|
|
5
|
+
mother: boolean;
|
|
6
|
+
informant: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Replaces event registration handler in country config
|
|
10
|
+
*/
|
|
11
|
+
export declare const mosipRegistrationHandler: ({ url, headers, payload, }: {
|
|
3
12
|
url: string;
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
payload: MOSIPPayload;
|
|
4
15
|
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
16
|
+
/**
|
|
17
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
18
|
+
*/
|
|
19
|
+
export declare const mosipRegistrationForReviewHandler: ({ url }: {
|
|
20
|
+
url: string;
|
|
21
|
+
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
22
|
+
/**
|
|
23
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
24
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
25
|
+
*/
|
|
26
|
+
export declare const mosipRegistrationForApprovalHandler: ({ url }: {
|
|
27
|
+
url: string;
|
|
28
|
+
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
29
|
+
export declare const verify: ({ url, request, }: {
|
|
30
|
+
url: string;
|
|
31
|
+
request: Hapi.Request;
|
|
32
|
+
}) => Promise<Partial<VerificationStatus>>;
|
|
33
|
+
export {};
|
package/build/events.js
CHANGED
|
@@ -3,19 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mosipRegistrationHandler = void 0;
|
|
6
|
+
exports.verify = exports.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler = exports.mosipRegistrationHandler = void 0;
|
|
7
7
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Replaces event registration handler in country config
|
|
10
|
+
*/
|
|
11
|
+
const mosipRegistrationHandler = ({ url, headers, payload, }) => (async (request, h) => {
|
|
12
|
+
const MOSIP_API_REGISTRATION_EVENT_URL = new URL("./events/registration", url);
|
|
13
|
+
const response = await (0, node_fetch_1.default)(MOSIP_API_REGISTRATION_EVENT_URL, {
|
|
11
14
|
method: "POST",
|
|
12
|
-
body: JSON.stringify(
|
|
13
|
-
headers:
|
|
15
|
+
body: JSON.stringify(payload),
|
|
16
|
+
headers: {
|
|
17
|
+
...headers,
|
|
18
|
+
"content-type": "application/json",
|
|
19
|
+
},
|
|
14
20
|
});
|
|
15
21
|
if (!response.ok) {
|
|
16
22
|
return h
|
|
17
23
|
.response({
|
|
18
|
-
error: "OpenCRVS-MOSIP
|
|
24
|
+
error: "OpenCRVS-MOSIP event registration route did not return a 200",
|
|
19
25
|
response: await response.text(),
|
|
20
26
|
})
|
|
21
27
|
.code(500);
|
|
@@ -23,3 +29,44 @@ const mosipRegistrationHandler = ({ url }) => (async (request, h) => {
|
|
|
23
29
|
return h.response({ success: true }).code(200);
|
|
24
30
|
});
|
|
25
31
|
exports.mosipRegistrationHandler = mosipRegistrationHandler;
|
|
32
|
+
/**
|
|
33
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
34
|
+
*/
|
|
35
|
+
const mosipRegistrationForReviewHandler = ({ url }) => (async (request, h) => {
|
|
36
|
+
// Corresponds to `packages/mosip-api` /events/review -route
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
response = await (0, exports.verify)({ url, request });
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return h
|
|
43
|
+
.response({
|
|
44
|
+
error: "OpenCRVS-MOSIP event review route did not return a 200",
|
|
45
|
+
response: error instanceof Error ? error.message : "Unknown error",
|
|
46
|
+
})
|
|
47
|
+
.code(500);
|
|
48
|
+
}
|
|
49
|
+
return h.response(response).code(200);
|
|
50
|
+
});
|
|
51
|
+
exports.mosipRegistrationForReviewHandler = mosipRegistrationForReviewHandler;
|
|
52
|
+
/**
|
|
53
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
54
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
55
|
+
*/
|
|
56
|
+
exports.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler;
|
|
57
|
+
const verify = async ({ url, request, }) => {
|
|
58
|
+
const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
|
|
59
|
+
const response = await (0, node_fetch_1.default)(MOSIP_API_REVIEW_EVENT_URL, {
|
|
60
|
+
method: "POST",
|
|
61
|
+
body: JSON.stringify(request.payload),
|
|
62
|
+
headers: {
|
|
63
|
+
...request.headers,
|
|
64
|
+
"content-type": "application/json",
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
throw new Error(await response.text());
|
|
69
|
+
}
|
|
70
|
+
return (await response.json());
|
|
71
|
+
};
|
|
72
|
+
exports.verify = verify;
|
package/build/forms.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
export declare const esignet: (
|
|
16
|
+
export declare const esignet: (esignetAuthUrl: string, openIdProviderClientId: string, openIdProviderClaims: string | undefined, fieldName: string, callbackFieldName: string) => {
|
|
17
17
|
name: string;
|
|
18
18
|
validator: never[];
|
|
19
19
|
icon: {
|
|
@@ -31,6 +31,11 @@ export declare const esignet: (event: string, sectionId: string, esignetAuthUrl:
|
|
|
31
31
|
action: string;
|
|
32
32
|
expression: string;
|
|
33
33
|
}[];
|
|
34
|
+
mapping: {
|
|
35
|
+
mutation: {
|
|
36
|
+
operation: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
34
39
|
options: {
|
|
35
40
|
url: string;
|
|
36
41
|
callback: {
|
|
@@ -41,7 +46,7 @@ export declare const esignet: (event: string, sectionId: string, esignetAuthUrl:
|
|
|
41
46
|
};
|
|
42
47
|
};
|
|
43
48
|
};
|
|
44
|
-
export declare const popupButton: ({ url }: {
|
|
49
|
+
export declare const popupButton: ({ url, }: {
|
|
45
50
|
url: string;
|
|
46
51
|
}) => {
|
|
47
52
|
name: string;
|
|
@@ -50,14 +55,12 @@ export declare const popupButton: ({ url }: {
|
|
|
50
55
|
};
|
|
51
56
|
/**
|
|
52
57
|
*
|
|
53
|
-
* @description esignet callback button form definition. Calls mosip-api/esignet
|
|
58
|
+
* @description esignet callback button form definition. Calls https://mosip-api.{{hostname}}/esignet/get-oidp-user-info
|
|
54
59
|
*
|
|
55
60
|
*/
|
|
56
|
-
export declare const esignetCallback: ({ fieldName,
|
|
61
|
+
export declare const esignetCallback: ({ fieldName, mosipAPIUserInfoUrl, openIdProviderClientId, }: {
|
|
57
62
|
fieldName: string;
|
|
58
|
-
|
|
59
|
-
sectionId: string;
|
|
60
|
-
getOIDPUserInfoUrl: string;
|
|
63
|
+
mosipAPIUserInfoUrl: string;
|
|
61
64
|
openIdProviderClientId: string;
|
|
62
65
|
}) => {
|
|
63
66
|
name: string;
|
|
@@ -68,10 +71,16 @@ export declare const esignetCallback: ({ fieldName, event, sectionId, getOIDPUse
|
|
|
68
71
|
defaultMessage: string;
|
|
69
72
|
};
|
|
70
73
|
validator: never[];
|
|
74
|
+
hideInPreview: boolean;
|
|
75
|
+
mapping: {
|
|
76
|
+
mutation: {
|
|
77
|
+
operation: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
71
80
|
options: {
|
|
72
|
-
|
|
81
|
+
url: string;
|
|
73
82
|
headers: {
|
|
74
|
-
|
|
83
|
+
"Content-type": string;
|
|
75
84
|
};
|
|
76
85
|
body: {
|
|
77
86
|
clientId: string;
|
|
@@ -84,11 +93,6 @@ export declare const esignetHidden: () => {
|
|
|
84
93
|
name: string;
|
|
85
94
|
type: string;
|
|
86
95
|
};
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
* @description QR reader type definition (this field may not be supported in the latest release of OpenCRVS yet)
|
|
90
|
-
*
|
|
91
|
-
*/
|
|
92
96
|
export declare const idReader: (event: string, sectionId: string, conditionals: any[], readers: any[]) => {
|
|
93
97
|
name: string;
|
|
94
98
|
customQuestionMappingId: string;
|
|
@@ -111,12 +115,41 @@ export declare const idReader: (event: string, sectionId: string, conditionals:
|
|
|
111
115
|
id: string;
|
|
112
116
|
defaultMessage: string;
|
|
113
117
|
};
|
|
118
|
+
mapping: {
|
|
119
|
+
mutation: {
|
|
120
|
+
operation: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
114
123
|
readers: any[];
|
|
115
124
|
};
|
|
116
|
-
|
|
125
|
+
type MessageDescriptor = {
|
|
126
|
+
id: string;
|
|
127
|
+
defaultMessage: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
};
|
|
130
|
+
interface QRValidation {
|
|
131
|
+
rule: Record<string, unknown>;
|
|
132
|
+
errorMessage: MessageDescriptor;
|
|
133
|
+
}
|
|
134
|
+
interface QRConfig {
|
|
135
|
+
validation: QRValidation;
|
|
136
|
+
}
|
|
137
|
+
export declare const qr: ({ validation }: QRConfig) => {
|
|
117
138
|
type: string;
|
|
139
|
+
validation: QRValidation;
|
|
118
140
|
};
|
|
119
|
-
|
|
141
|
+
interface ESignetConfig {
|
|
142
|
+
esignetAuthUrl: string;
|
|
143
|
+
openIdProviderClientId: string;
|
|
144
|
+
openIdProviderClaims: string | undefined;
|
|
145
|
+
fieldName: string;
|
|
146
|
+
callback: {
|
|
147
|
+
fieldName: string;
|
|
148
|
+
mosipAPIUserInfoUrl: string;
|
|
149
|
+
};
|
|
150
|
+
loaderFieldName?: string;
|
|
151
|
+
}
|
|
152
|
+
export declare const verified: (event: string, sectionId: string, mapping: any, esignetConfig?: ESignetConfig) => {
|
|
120
153
|
name: string;
|
|
121
154
|
fieldId: string;
|
|
122
155
|
customQuestionMappingId: string;
|
|
@@ -131,26 +164,54 @@ export declare const verified: (event: string, sectionId: string) => {
|
|
|
131
164
|
expression: string;
|
|
132
165
|
};
|
|
133
166
|
validator: never[];
|
|
167
|
+
mapping: any;
|
|
134
168
|
};
|
|
135
|
-
|
|
169
|
+
type VerificationStatus = "verified" | "failed" | "authenticated" | "failedFetchIdDetails";
|
|
170
|
+
export declare const idVerificationBanner: (event: string, sectionId: string, status: VerificationStatus, conditionals?: any[]) => {
|
|
136
171
|
name: string;
|
|
137
172
|
type: string;
|
|
138
173
|
fieldId: string;
|
|
139
174
|
hideInPreview: boolean;
|
|
140
175
|
custom: boolean;
|
|
141
|
-
bannerType:
|
|
176
|
+
bannerType: VerificationStatus;
|
|
142
177
|
idFieldName: string;
|
|
143
178
|
label: {
|
|
144
179
|
id: string;
|
|
145
180
|
defaultMessage: string;
|
|
146
181
|
};
|
|
147
182
|
validator: never[];
|
|
183
|
+
conditionals: any[];
|
|
184
|
+
};
|
|
185
|
+
export declare function esignetLoaderField({ event, section, fieldName, esignetCallbackFieldName, }: {
|
|
186
|
+
event: "birth" | "death";
|
|
187
|
+
section: "informant" | "mother" | "father" | "spouse" | "deceased";
|
|
188
|
+
fieldName: string;
|
|
189
|
+
esignetCallbackFieldName: string;
|
|
190
|
+
}): {
|
|
191
|
+
name: string;
|
|
192
|
+
type: string;
|
|
193
|
+
fieldId: string;
|
|
194
|
+
hideInPreview: boolean;
|
|
195
|
+
custom: boolean;
|
|
196
|
+
label: {
|
|
197
|
+
id: string;
|
|
198
|
+
defaultMessage: string;
|
|
199
|
+
};
|
|
200
|
+
loadingText: {
|
|
201
|
+
id: string;
|
|
202
|
+
defaultMessage: string;
|
|
203
|
+
};
|
|
148
204
|
conditionals: {
|
|
149
205
|
action: string;
|
|
150
206
|
expression: string;
|
|
151
207
|
}[];
|
|
152
208
|
};
|
|
153
|
-
export declare const
|
|
209
|
+
export declare const getInitialValueFromIDReader: (fieldNameInReader: string) => {
|
|
210
|
+
dependsOn: string[];
|
|
211
|
+
expression: string;
|
|
212
|
+
};
|
|
213
|
+
export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father" | "spouse" | "deceased", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => any[];
|
|
214
|
+
export declare const idVerificationFields: (event: string, sectionId: string, mapping: any, conditionals?: any[], esignetConfig?: ESignetConfig) => ({
|
|
154
215
|
name: string;
|
|
155
216
|
fieldId: string;
|
|
156
217
|
customQuestionMappingId: string;
|
|
@@ -165,21 +226,20 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
|
|
|
165
226
|
expression: string;
|
|
166
227
|
};
|
|
167
228
|
validator: never[];
|
|
229
|
+
mapping: any;
|
|
168
230
|
} | {
|
|
169
231
|
name: string;
|
|
170
232
|
type: string;
|
|
171
233
|
fieldId: string;
|
|
172
234
|
hideInPreview: boolean;
|
|
173
235
|
custom: boolean;
|
|
174
|
-
bannerType:
|
|
236
|
+
bannerType: VerificationStatus;
|
|
175
237
|
idFieldName: string;
|
|
176
238
|
label: {
|
|
177
239
|
id: string;
|
|
178
240
|
defaultMessage: string;
|
|
179
241
|
};
|
|
180
242
|
validator: never[];
|
|
181
|
-
conditionals:
|
|
182
|
-
action: string;
|
|
183
|
-
expression: string;
|
|
184
|
-
}[];
|
|
243
|
+
conditionals: any[];
|
|
185
244
|
})[];
|
|
245
|
+
export {};
|