@opencrvs/mosip 1.7.0-alpha.20 → 1.7.0-alpha.22

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 CHANGED
@@ -1,4 +1,9 @@
1
1
  import type * as Hapi from "@hapi/hapi";
2
+ interface VerificationStatus {
3
+ father: boolean;
4
+ mother: boolean;
5
+ informant: boolean;
6
+ }
2
7
  /**
3
8
  * Replaces event registration handler in country config
4
9
  */
@@ -18,3 +23,8 @@ export declare const mosipRegistrationForReviewHandler: ({ url }: {
18
23
  export declare const mosipRegistrationForApprovalHandler: ({ url }: {
19
24
  url: string;
20
25
  }) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
26
+ export declare const verify: ({ url, request, }: {
27
+ url: string;
28
+ request: Hapi.Request;
29
+ }) => Promise<Partial<VerificationStatus>>;
30
+ export {};
package/build/events.js CHANGED
@@ -3,7 +3,7 @@ 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.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler = 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
8
  /**
9
9
  * Replaces event registration handler in country config
@@ -34,25 +34,19 @@ exports.mosipRegistrationHandler = mosipRegistrationHandler;
34
34
  */
35
35
  const mosipRegistrationForReviewHandler = ({ url }) => (async (request, h) => {
36
36
  // Corresponds to `packages/mosip-api` /events/review -route
37
- const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
38
- console.info(request.headers);
39
- const response = await (0, node_fetch_1.default)(MOSIP_API_REVIEW_EVENT_URL, {
40
- method: "POST",
41
- body: JSON.stringify(request.payload),
42
- headers: {
43
- ...request.headers,
44
- "content-type": "application/json",
45
- },
46
- });
47
- if (!response.ok) {
37
+ let response;
38
+ try {
39
+ response = await (0, exports.verify)({ url, request });
40
+ }
41
+ catch (error) {
48
42
  return h
49
43
  .response({
50
44
  error: "OpenCRVS-MOSIP event review route did not return a 200",
51
- response: await response.text(),
45
+ response: error instanceof Error ? error.message : "Unknown error",
52
46
  })
53
47
  .code(500);
54
48
  }
55
- return h.response({ success: true }).code(200);
49
+ return h.response(response).code(200);
56
50
  });
57
51
  exports.mosipRegistrationForReviewHandler = mosipRegistrationForReviewHandler;
58
52
  /**
@@ -60,3 +54,19 @@ exports.mosipRegistrationForReviewHandler = mosipRegistrationForReviewHandler;
60
54
  * Currently the same as `/events/{event}/actions/sent-notification-for-review`
61
55
  */
62
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
@@ -182,7 +182,7 @@ export declare const getInitialValueFromIDReader: (fieldNameInReader: string) =>
182
182
  dependsOn: string[];
183
183
  expression: string;
184
184
  };
185
- export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => any[];
185
+ export declare const idReaderFields: (event: "birth" | "death", section: "informant" | "mother" | "father" | "spouse" | "deceased", qrConfig: QRConfig, esignetConfig: ESignetConfig | undefined, verifiedCustomFieldMapping: any, conditionals?: any[]) => any[];
186
186
  export declare const idVerificationFields: (event: string, sectionId: string, mapping: any) => ({
187
187
  name: string;
188
188
  fieldId: string;
package/build/forms.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- // @TODO: Yet to be implemented! Placeholders for NPM publish.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.idVerificationFields = exports.idReaderFields = exports.getInitialValueFromIDReader = exports.idVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
5
2
  /**
6
3
  * E-Signet popup button and hidden field form definitions
7
4
  * @example
@@ -12,6 +9,8 @@ exports.idVerificationFields = exports.idReaderFields = exports.getInitialValueF
12
9
  * ]
13
10
  * ```
14
11
  */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.idVerificationFields = exports.idReaderFields = exports.getInitialValueFromIDReader = exports.idVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
15
14
  /**
16
15
  *
17
16
  * @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/mosip",
3
- "version": "1.7.0-alpha.20",
3
+ "version": "1.7.0-alpha.22",
4
4
  "license": "MPL-2.0",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
@@ -16,9 +16,10 @@
16
16
  "devDependencies": {
17
17
  "@types/hapi__hapi": "^20.0.0",
18
18
  "@types/node-fetch": "^2.6.11",
19
+ "node-fetch": "2.6.7",
19
20
  "typescript": "^5.6.3"
20
21
  },
21
22
  "peerDependencies": {
22
- "node-fetch": "^3.3.2"
23
+ "node-fetch": "2.6.7"
23
24
  }
24
25
  }
package/src/events.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import type * as Hapi from "@hapi/hapi";
2
2
  import fetch from "node-fetch";
3
3
 
4
+ interface VerificationStatus {
5
+ father: boolean;
6
+ mother: boolean;
7
+ informant: boolean;
8
+ }
9
+
4
10
  /**
5
11
  * Replaces event registration handler in country config
6
12
  */
@@ -38,33 +44,49 @@ export const mosipRegistrationHandler = ({ url }: { url: string }) =>
38
44
  export const mosipRegistrationForReviewHandler = ({ url }: { url: string }) =>
39
45
  (async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
40
46
  // Corresponds to `packages/mosip-api` /events/review -route
41
- const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
42
-
43
- console.info(request.headers);
44
-
45
- const response = await fetch(MOSIP_API_REVIEW_EVENT_URL, {
46
- method: "POST",
47
- body: JSON.stringify(request.payload),
48
- headers: {
49
- ...request.headers,
50
- "content-type": "application/json",
51
- },
52
- });
53
-
54
- if (!response.ok) {
47
+ let response;
48
+ try {
49
+ response = await verify({ url, request });
50
+ } catch (error) {
55
51
  return h
56
52
  .response({
57
53
  error: "OpenCRVS-MOSIP event review route did not return a 200",
58
- response: await response.text(),
54
+ response: error instanceof Error ? error.message : "Unknown error",
59
55
  })
60
56
  .code(500);
61
57
  }
62
58
 
63
- return h.response({ success: true }).code(200);
59
+ return h.response(response).code(200);
64
60
  }) satisfies Hapi.ServerRoute["handler"];
65
61
 
66
62
  /**
67
63
  * Replaces `/events/{event}/actions/sent-for-approval` handler in country config
68
64
  * Currently the same as `/events/{event}/actions/sent-notification-for-review`
69
65
  */
70
- export const mosipRegistrationForApprovalHandler = mosipRegistrationForReviewHandler
66
+ export const mosipRegistrationForApprovalHandler =
67
+ mosipRegistrationForReviewHandler;
68
+
69
+ export const verify = async ({
70
+ url,
71
+ request,
72
+ }: {
73
+ url: string;
74
+ request: Hapi.Request;
75
+ }): Promise<Partial<VerificationStatus>> => {
76
+ const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
77
+
78
+ const response = await fetch(MOSIP_API_REVIEW_EVENT_URL, {
79
+ method: "POST",
80
+ body: JSON.stringify(request.payload),
81
+ headers: {
82
+ ...request.headers,
83
+ "content-type": "application/json",
84
+ },
85
+ });
86
+
87
+ if (!response.ok) {
88
+ throw new Error(await response.text());
89
+ }
90
+
91
+ return (await response.json()) satisfies Partial<VerificationStatus>;
92
+ };
package/src/forms.ts CHANGED
@@ -1,5 +1,3 @@
1
- // @TODO: Yet to be implemented! Placeholders for NPM publish.
2
-
3
1
  /**
4
2
  * E-Signet popup button and hidden field form definitions
5
3
  * @example
@@ -264,7 +262,7 @@ export const getInitialValueFromIDReader = (fieldNameInReader: string) => ({
264
262
 
265
263
  export const idReaderFields = (
266
264
  event: "birth" | "death",
267
- section: "informant" | "mother" | "father",
265
+ section: "informant" | "mother" | "father" | "spouse" | "deceased",
268
266
  qrConfig: QRConfig,
269
267
  esignetConfig: ESignetConfig | undefined,
270
268
  verifiedCustomFieldMapping: any,