@opencrvs/mosip 2.0.0-rc.1 → 2.0.0-rc.11
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 +40 -1
- package/build/api.js +46 -2
- package/package.json +3 -3
- package/src/api.ts +57 -1
package/build/api.d.ts
CHANGED
|
@@ -8,6 +8,15 @@ export declare const DeathRequestFieldsSchema: z.ZodObject<{
|
|
|
8
8
|
deathCertificateNumber: z.ZodString;
|
|
9
9
|
birthCertificateNumber: z.ZodOptional<z.ZodUndefined>;
|
|
10
10
|
}, z.core.$loose>;
|
|
11
|
+
export declare const CorrectionRequestFieldsSchema: z.ZodObject<{
|
|
12
|
+
VID: z.ZodString;
|
|
13
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
14
|
+
dateOfBirth: z.ZodOptional<z.ZodString>;
|
|
15
|
+
gender: z.ZodOptional<z.ZodString>;
|
|
16
|
+
introducerInfoToken: z.ZodOptional<z.ZodString>;
|
|
17
|
+
birthCertificateNumber: z.ZodOptional<z.ZodUndefined>;
|
|
18
|
+
deathCertificateNumber: z.ZodOptional<z.ZodUndefined>;
|
|
19
|
+
}, z.core.$loose>;
|
|
11
20
|
export declare const MosipNotificationSchema: z.ZodObject<{
|
|
12
21
|
recipientFullName: z.ZodString;
|
|
13
22
|
recipientEmail: z.ZodString;
|
|
@@ -26,7 +35,34 @@ export declare const MosipInteropPayloadSchema: z.ZodObject<{
|
|
|
26
35
|
}, z.core.$loose>, z.ZodObject<{
|
|
27
36
|
deathCertificateNumber: z.ZodString;
|
|
28
37
|
birthCertificateNumber: z.ZodOptional<z.ZodUndefined>;
|
|
38
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
39
|
+
VID: z.ZodString;
|
|
40
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
41
|
+
dateOfBirth: z.ZodOptional<z.ZodString>;
|
|
42
|
+
gender: z.ZodOptional<z.ZodString>;
|
|
43
|
+
introducerInfoToken: z.ZodOptional<z.ZodString>;
|
|
44
|
+
birthCertificateNumber: z.ZodOptional<z.ZodUndefined>;
|
|
45
|
+
deathCertificateNumber: z.ZodOptional<z.ZodUndefined>;
|
|
29
46
|
}, z.core.$loose>]>;
|
|
47
|
+
schemaJson: z.ZodOptional<z.ZodString>;
|
|
48
|
+
metaInfo: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
49
|
+
audit: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export declare const MosipCorrectionPayloadSchema: z.ZodObject<{
|
|
52
|
+
trackingId: z.ZodString;
|
|
53
|
+
notification: z.ZodObject<{
|
|
54
|
+
recipientFullName: z.ZodString;
|
|
55
|
+
recipientEmail: z.ZodString;
|
|
56
|
+
recipientPhone: z.ZodString;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
requestFields: z.ZodObject<{
|
|
59
|
+
VID: z.ZodString;
|
|
60
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
61
|
+
dateOfBirth: z.ZodOptional<z.ZodString>;
|
|
62
|
+
gender: z.ZodOptional<z.ZodString>;
|
|
63
|
+
introducerInfoToken: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
schemaJson: z.ZodOptional<z.ZodString>;
|
|
30
66
|
metaInfo: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
67
|
audit: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
32
68
|
}, z.core.$strip>;
|
|
@@ -41,7 +77,9 @@ export declare const VerifyNidResponseSchema: z.ZodUnion<readonly [z.ZodLiteral<
|
|
|
41
77
|
export declare const RegistrationEventResponseSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
42
78
|
export type BirthRequestFields = z.infer<typeof BirthRequestFieldsSchema>;
|
|
43
79
|
export type DeathRequestFields = z.infer<typeof DeathRequestFieldsSchema>;
|
|
80
|
+
export type CorrectionRequestFields = z.infer<typeof CorrectionRequestFieldsSchema>;
|
|
44
81
|
export type MosipInteropPayload = z.infer<typeof MosipInteropPayloadSchema>;
|
|
82
|
+
export type MosipCorrectionPayload = z.infer<typeof MosipCorrectionPayloadSchema>;
|
|
45
83
|
export type VerifyNidPayload = z.infer<typeof VerifyNidPayloadSchema>;
|
|
46
84
|
export type VerifyNidResponse = z.infer<typeof VerifyNidResponseSchema>;
|
|
47
85
|
export interface VerificationStatus {
|
|
@@ -53,5 +91,6 @@ export interface VerificationStatus {
|
|
|
53
91
|
}
|
|
54
92
|
export declare const createMosipInteropClient: (url: string, authorizationHeader: string) => {
|
|
55
93
|
register: (payload: MosipInteropPayload) => Promise<Record<string, unknown>>;
|
|
56
|
-
|
|
94
|
+
updateBiographics: (payload: MosipCorrectionPayload) => Promise<Record<string, unknown>>;
|
|
95
|
+
verifyNid: (payload: VerifyNidPayload) => Promise<"verified" | "failed">;
|
|
57
96
|
};
|
package/build/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMosipInteropClient = exports.RegistrationEventResponseSchema = exports.VerifyNidResponseSchema = exports.VerifyNidPayloadSchema = exports.MosipInteropPayloadSchema = exports.MosipNotificationSchema = exports.DeathRequestFieldsSchema = exports.BirthRequestFieldsSchema = void 0;
|
|
3
|
+
exports.createMosipInteropClient = exports.RegistrationEventResponseSchema = exports.VerifyNidResponseSchema = exports.VerifyNidPayloadSchema = exports.MosipCorrectionPayloadSchema = exports.MosipInteropPayloadSchema = exports.MosipNotificationSchema = exports.CorrectionRequestFieldsSchema = exports.DeathRequestFieldsSchema = exports.BirthRequestFieldsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.BirthRequestFieldsSchema = zod_1.z.looseObject({
|
|
6
6
|
birthCertificateNumber: zod_1.z.string(),
|
|
@@ -10,6 +10,15 @@ exports.DeathRequestFieldsSchema = zod_1.z.looseObject({
|
|
|
10
10
|
deathCertificateNumber: zod_1.z.string(),
|
|
11
11
|
birthCertificateNumber: zod_1.z.undefined().optional(),
|
|
12
12
|
});
|
|
13
|
+
exports.CorrectionRequestFieldsSchema = zod_1.z.looseObject({
|
|
14
|
+
VID: zod_1.z.string(),
|
|
15
|
+
fullName: zod_1.z.string().optional(),
|
|
16
|
+
dateOfBirth: zod_1.z.string().optional(),
|
|
17
|
+
gender: zod_1.z.string().optional(),
|
|
18
|
+
introducerInfoToken: zod_1.z.string().optional(),
|
|
19
|
+
birthCertificateNumber: zod_1.z.undefined().optional(),
|
|
20
|
+
deathCertificateNumber: zod_1.z.undefined().optional(),
|
|
21
|
+
});
|
|
13
22
|
exports.MosipNotificationSchema = zod_1.z.object({
|
|
14
23
|
recipientFullName: zod_1.z.string(),
|
|
15
24
|
recipientEmail: zod_1.z.string(),
|
|
@@ -18,7 +27,26 @@ exports.MosipNotificationSchema = zod_1.z.object({
|
|
|
18
27
|
exports.MosipInteropPayloadSchema = zod_1.z.object({
|
|
19
28
|
trackingId: zod_1.z.string(),
|
|
20
29
|
notification: exports.MosipNotificationSchema,
|
|
21
|
-
requestFields: zod_1.z.union([
|
|
30
|
+
requestFields: zod_1.z.union([
|
|
31
|
+
exports.BirthRequestFieldsSchema,
|
|
32
|
+
exports.DeathRequestFieldsSchema,
|
|
33
|
+
exports.CorrectionRequestFieldsSchema,
|
|
34
|
+
]),
|
|
35
|
+
schemaJson: zod_1.z.string().optional(),
|
|
36
|
+
metaInfo: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
37
|
+
audit: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
38
|
+
});
|
|
39
|
+
exports.MosipCorrectionPayloadSchema = zod_1.z.object({
|
|
40
|
+
trackingId: zod_1.z.string(),
|
|
41
|
+
notification: exports.MosipNotificationSchema,
|
|
42
|
+
requestFields: zod_1.z.object({
|
|
43
|
+
VID: zod_1.z.string(),
|
|
44
|
+
fullName: zod_1.z.string().optional(),
|
|
45
|
+
dateOfBirth: zod_1.z.string().optional(),
|
|
46
|
+
gender: zod_1.z.string().optional(),
|
|
47
|
+
introducerInfoToken: zod_1.z.string().optional(),
|
|
48
|
+
}),
|
|
49
|
+
schemaJson: zod_1.z.string().optional(),
|
|
22
50
|
metaInfo: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
23
51
|
audit: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
24
52
|
});
|
|
@@ -67,6 +95,22 @@ const createMosipInteropClient = (url, authorizationHeader) => {
|
|
|
67
95
|
}
|
|
68
96
|
return exports.RegistrationEventResponseSchema.parse(await response.json());
|
|
69
97
|
},
|
|
98
|
+
updateBiographics: async (payload) => {
|
|
99
|
+
const parsedPayload = exports.MosipCorrectionPayloadSchema.parse(payload);
|
|
100
|
+
const MOSIP_API_CORRECTION_EVENT_URL = new URL("./events/update-biographics", url).href;
|
|
101
|
+
const response = await fetchWithTimeout(MOSIP_API_CORRECTION_EVENT_URL, {
|
|
102
|
+
method: "POST",
|
|
103
|
+
body: JSON.stringify(parsedPayload),
|
|
104
|
+
headers: {
|
|
105
|
+
Authorization: authorizationHeader,
|
|
106
|
+
"content-type": "application/json",
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`Failed to update biographics: ${await response.text()}`);
|
|
111
|
+
}
|
|
112
|
+
return exports.RegistrationEventResponseSchema.parse(await response.json());
|
|
113
|
+
},
|
|
70
114
|
verifyNid: async (payload) => {
|
|
71
115
|
const parsedPayload = exports.VerifyNidPayloadSchema.parse(payload);
|
|
72
116
|
const MOSIP_API_VERIFY_URL = new URL("./verify", url).href;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencrvs/mosip",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.11",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"zod": "^4.1.12"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@opencrvs/toolkit": "1.9.
|
|
18
|
+
"@opencrvs/toolkit": "1.9.12-rc.1b9bbf4",
|
|
19
19
|
"@types/hapi__hapi": "^20.0.0",
|
|
20
20
|
"@types/node-fetch": "^2.6.11",
|
|
21
21
|
"node-fetch": "2.6.7",
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"node-fetch": "2.6.7"
|
|
26
26
|
}
|
|
27
|
-
}
|
|
27
|
+
}
|
package/src/api.ts
CHANGED
|
@@ -11,6 +11,16 @@ export const DeathRequestFieldsSchema = z.looseObject({
|
|
|
11
11
|
birthCertificateNumber: z.undefined().optional(),
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
export const CorrectionRequestFieldsSchema = z.looseObject({
|
|
15
|
+
VID: z.string(),
|
|
16
|
+
fullName: z.string().optional(),
|
|
17
|
+
dateOfBirth: z.string().optional(),
|
|
18
|
+
gender: z.string().optional(),
|
|
19
|
+
introducerInfoToken: z.string().optional(),
|
|
20
|
+
birthCertificateNumber: z.undefined().optional(),
|
|
21
|
+
deathCertificateNumber: z.undefined().optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
14
24
|
export const MosipNotificationSchema = z.object({
|
|
15
25
|
recipientFullName: z.string(),
|
|
16
26
|
recipientEmail: z.string(),
|
|
@@ -20,7 +30,27 @@ export const MosipNotificationSchema = z.object({
|
|
|
20
30
|
export const MosipInteropPayloadSchema = z.object({
|
|
21
31
|
trackingId: z.string(),
|
|
22
32
|
notification: MosipNotificationSchema,
|
|
23
|
-
requestFields: z.union([
|
|
33
|
+
requestFields: z.union([
|
|
34
|
+
BirthRequestFieldsSchema,
|
|
35
|
+
DeathRequestFieldsSchema,
|
|
36
|
+
CorrectionRequestFieldsSchema,
|
|
37
|
+
]),
|
|
38
|
+
schemaJson: z.string().optional(),
|
|
39
|
+
metaInfo: z.record(z.string(), z.unknown()),
|
|
40
|
+
audit: z.record(z.string(), z.unknown()),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const MosipCorrectionPayloadSchema = z.object({
|
|
44
|
+
trackingId: z.string(),
|
|
45
|
+
notification: MosipNotificationSchema,
|
|
46
|
+
requestFields: z.object({
|
|
47
|
+
VID: z.string(),
|
|
48
|
+
fullName: z.string().optional(),
|
|
49
|
+
dateOfBirth: z.string().optional(),
|
|
50
|
+
gender: z.string().optional(),
|
|
51
|
+
introducerInfoToken: z.string().optional(),
|
|
52
|
+
}),
|
|
53
|
+
schemaJson: z.string().optional(),
|
|
24
54
|
metaInfo: z.record(z.string(), z.unknown()),
|
|
25
55
|
audit: z.record(z.string(), z.unknown()),
|
|
26
56
|
});
|
|
@@ -47,7 +77,9 @@ export const RegistrationEventResponseSchema = z.record(
|
|
|
47
77
|
|
|
48
78
|
export type BirthRequestFields = z.infer<typeof BirthRequestFieldsSchema>;
|
|
49
79
|
export type DeathRequestFields = z.infer<typeof DeathRequestFieldsSchema>;
|
|
80
|
+
export type CorrectionRequestFields = z.infer<typeof CorrectionRequestFieldsSchema>;
|
|
50
81
|
export type MosipInteropPayload = z.infer<typeof MosipInteropPayloadSchema>;
|
|
82
|
+
export type MosipCorrectionPayload = z.infer<typeof MosipCorrectionPayloadSchema>;
|
|
51
83
|
export type VerifyNidPayload = z.infer<typeof VerifyNidPayloadSchema>;
|
|
52
84
|
export type VerifyNidResponse = z.infer<typeof VerifyNidResponseSchema>;
|
|
53
85
|
|
|
@@ -108,6 +140,30 @@ export const createMosipInteropClient = (
|
|
|
108
140
|
|
|
109
141
|
return RegistrationEventResponseSchema.parse(await response.json());
|
|
110
142
|
},
|
|
143
|
+
updateBiographics: async (payload: MosipCorrectionPayload) => {
|
|
144
|
+
const parsedPayload = MosipCorrectionPayloadSchema.parse(payload);
|
|
145
|
+
const MOSIP_API_CORRECTION_EVENT_URL = new URL(
|
|
146
|
+
"./events/update-biographics",
|
|
147
|
+
url,
|
|
148
|
+
).href;
|
|
149
|
+
|
|
150
|
+
const response = await fetchWithTimeout(MOSIP_API_CORRECTION_EVENT_URL, {
|
|
151
|
+
method: "POST",
|
|
152
|
+
body: JSON.stringify(parsedPayload),
|
|
153
|
+
headers: {
|
|
154
|
+
Authorization: authorizationHeader,
|
|
155
|
+
"content-type": "application/json",
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
`Failed to update biographics: ${await response.text()}`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return RegistrationEventResponseSchema.parse(await response.json());
|
|
166
|
+
},
|
|
111
167
|
verifyNid: async (payload: VerifyNidPayload) => {
|
|
112
168
|
const parsedPayload = VerifyNidPayloadSchema.parse(payload);
|
|
113
169
|
const MOSIP_API_VERIFY_URL = new URL("./verify", url).href;
|