@opencrvs/mosip 1.9.1 → 1.9.2-alpha.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 CHANGED
@@ -34,6 +34,6 @@ export interface VerificationStatus {
34
34
  spouse: boolean;
35
35
  }
36
36
  export declare const createMosipInteropClient: (url: string, authorizationHeader: string) => {
37
- register: (payload: MosipInteropPayload) => Promise<any>;
38
- verifyNid: (payload: VerifyNidPayload) => Promise<"verified" | "failed">;
37
+ register: (payload: MosipInteropPayload, timeoutMs?: number) => Promise<any>;
38
+ verifyNid: (payload: VerifyNidPayload, timeoutMs?: number) => Promise<"verified" | "failed">;
39
39
  };
package/build/api.js CHANGED
@@ -17,7 +17,7 @@ async function fetchWithTimeout(input, init = {}, timeoutMs = 15000) {
17
17
  }
18
18
  const createMosipInteropClient = (url, authorizationHeader) => {
19
19
  return {
20
- register: async (payload) => {
20
+ register: async (payload, timeoutMs = 15000) => {
21
21
  const MOSIP_API_REGISTRATION_EVENT_URL = new URL("./events/registration", url).href;
22
22
  const response = await fetchWithTimeout(MOSIP_API_REGISTRATION_EVENT_URL, {
23
23
  method: "POST",
@@ -26,13 +26,13 @@ const createMosipInteropClient = (url, authorizationHeader) => {
26
26
  Authorization: authorizationHeader,
27
27
  "content-type": "application/json",
28
28
  },
29
- });
29
+ }, timeoutMs);
30
30
  if (!response.ok) {
31
31
  throw new Error(`Failed to register event: ${await response.text()}`);
32
32
  }
33
33
  return response.json();
34
34
  },
35
- verifyNid: async (payload) => {
35
+ verifyNid: async (payload, timeoutMs = 15000) => {
36
36
  const MOSIP_API_VERIFY_URL = new URL("./verify", url).href;
37
37
  const response = await fetchWithTimeout(MOSIP_API_VERIFY_URL, {
38
38
  method: "POST",
@@ -41,7 +41,7 @@ const createMosipInteropClient = (url, authorizationHeader) => {
41
41
  Authorization: authorizationHeader,
42
42
  "content-type": "application/json",
43
43
  },
44
- });
44
+ }, timeoutMs);
45
45
  if (!response.ok) {
46
46
  throw new Error(`Failed to verify: ${await response.text()}`);
47
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/mosip",
3
- "version": "1.9.1",
3
+ "version": "1.9.2-alpha.1",
4
4
  "license": "MPL-2.0",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
package/src/api.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { EventDocument, FieldValue } from "@opencrvs/toolkit/events";
1
+ import type { FieldValue } from "@opencrvs/toolkit/events";
2
2
 
3
3
  export interface BirthRequestFields extends Record<string, unknown> {
4
4
  birthCertificateNumber: string;
@@ -63,7 +63,7 @@ export const createMosipInteropClient = (
63
63
  authorizationHeader: string,
64
64
  ) => {
65
65
  return {
66
- register: async (payload: MosipInteropPayload) => {
66
+ register: async (payload: MosipInteropPayload, timeoutMs = 15000) => {
67
67
  const MOSIP_API_REGISTRATION_EVENT_URL = new URL(
68
68
  "./events/registration",
69
69
  url,
@@ -79,6 +79,7 @@ export const createMosipInteropClient = (
79
79
  "content-type": "application/json",
80
80
  },
81
81
  },
82
+ timeoutMs,
82
83
  );
83
84
 
84
85
  if (!response.ok) {
@@ -87,17 +88,21 @@ export const createMosipInteropClient = (
87
88
 
88
89
  return response.json();
89
90
  },
90
- verifyNid: async (payload: VerifyNidPayload) => {
91
+ verifyNid: async (payload: VerifyNidPayload, timeoutMs = 15000) => {
91
92
  const MOSIP_API_VERIFY_URL = new URL("./verify", url).href;
92
93
 
93
- const response = await fetchWithTimeout(MOSIP_API_VERIFY_URL, {
94
- method: "POST",
95
- body: JSON.stringify(payload),
96
- headers: {
97
- Authorization: authorizationHeader,
98
- "content-type": "application/json",
94
+ const response = await fetchWithTimeout(
95
+ MOSIP_API_VERIFY_URL,
96
+ {
97
+ method: "POST",
98
+ body: JSON.stringify(payload),
99
+ headers: {
100
+ Authorization: authorizationHeader,
101
+ "content-type": "application/json",
102
+ },
99
103
  },
100
- });
104
+ timeoutMs,
105
+ );
101
106
 
102
107
  if (!response.ok) {
103
108
  throw new Error(`Failed to verify: ${await response.text()}`);