Skip to content

Commit 3e09e18

Browse files
committed
6839a77 chore: update documentation
0b20c70 chore: fix death flow failing if no NID
2 parents 2f884c2 + 8451155 commit 3e09e18

21 files changed

+496
-80
lines changed

.github/workflows/docker-publish-esignet-mock.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
29+
with:
30+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
31+
# > Note that GITHUB_SHA for this event is the last merge commit of the pull request merge branch.
32+
# > If you want to get the commit ID for the last commit to the head branch of the pull request, use _github.event.pull_request.head.sha_ instead.
33+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
2934

3035
- name: Log in to the Container registry
3136
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
@@ -44,14 +49,20 @@ jobs:
4449
env:
4550
DOCKER_METADATA_SHORT_SHA_LENGTH: 7
4651

52+
# The package includes symlinks to elsewhere in the monorepo, this resolves the symlinks to actual files
53+
- name: Resolve symlinks
54+
run: |
55+
mkdir -p images/esignet-mock
56+
rsync -a --copy-links packages/esignet-mock/ images/esignet-mock/
57+
4758
- name: Copy yarn.lock to docker build context
48-
run: cp yarn.lock packages/esignet-mock/yarn.lock
59+
run: cp yarn.lock images/esignet-mock/yarn.lock
4960

5061
- name: Build and push Docker image
5162
id: push
5263
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
5364
with:
54-
context: packages/esignet-mock
65+
context: images/esignet-mock
5566
push: true
5667
tags: ${{ steps.meta.outputs.tags }}
5768
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/docker-publish-mosip-mock.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
29+
with:
30+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
31+
# > Note that GITHUB_SHA for this event is the last merge commit of the pull request merge branch.
32+
# > If you want to get the commit ID for the last commit to the head branch of the pull request, use _github.event.pull_request.head.sha_ instead.
33+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
2934

3035
- name: Log in to the Container registry
3136
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
@@ -44,14 +49,20 @@ jobs:
4449
env:
4550
DOCKER_METADATA_SHORT_SHA_LENGTH: 7
4651

52+
# The package includes symlinks to elsewhere in the monorepo, this resolves the symlinks to actual files
53+
- name: Resolve symlinks
54+
run: |
55+
mkdir -p images/mosip-mock
56+
rsync -a --copy-links packages/mosip-mock/ images/mosip-mock/
57+
4758
- name: Copy yarn.lock to docker build context
48-
run: cp yarn.lock packages/mosip-mock/yarn.lock
59+
run: cp yarn.lock images/mosip-mock/yarn.lock
4960

5061
- name: Build and push Docker image
5162
id: push
5263
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
5364
with:
54-
context: packages/mosip-mock
65+
context: images/mosip-mock
5566
push: true
5667
tags: ${{ steps.meta.outputs.tags }}
5768
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/docker-publish.yml

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
29+
with:
30+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
31+
# > Note that GITHUB_SHA for this event is the last merge commit of the pull request merge branch.
32+
# > If you want to get the commit ID for the last commit to the head branch of the pull request, use _github.event.pull_request.head.sha_ instead.
33+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
2934

3035
- name: Log in to the Container registry
3136
uses: docker/login-action@v3

docs/compatibility.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Compatibility
22

3-
This version supports the yet to be released OpenCRVS v1.7.
3+
This version supports the yet to be released OpenCRVS v1.8.
44

55
## Features
66

docs/mock-identities.json

+14
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,19 @@
5454
"birthDate": "2004-04-09",
5555
"gender": "male",
5656
"nid": "1234567897"
57+
},
58+
{
59+
"firstName": "Saida",
60+
"familyName": "Sharma",
61+
"birthDate": "1997-12-24",
62+
"gender": "female",
63+
"nid": "1234567898"
64+
},
65+
{
66+
"firstName": "Sahara",
67+
"familyName": "Moyo",
68+
"birthDate": "1994-10-02",
69+
"gender": "female",
70+
"nid": "1234567899"
5771
}
5872
]

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip",
3-
"version": "1.7.0-alpha.21",
3+
"version": "1.7.0-alpha.26",
44
"license": "MPL-2.0",
55
"private": true,
66
"packageManager": "yarn@1.22.13",

packages/country-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip",
3-
"version": "1.7.0-alpha.21",
3+
"version": "1.7.0-alpha.26",
44
"license": "MPL-2.0",
55
"main": "./build/index.js",
66
"exports": {

packages/country-config/src/forms.ts

+102-22
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export const esignet = (
5454
expression: "!!$form.redirectCallbackFetch",
5555
},
5656
],
57+
mapping: {
58+
mutation: {
59+
operation: "ignoreFieldTransformer",
60+
},
61+
},
5762
options: {
5863
url: url.toString(),
5964
callback: {
@@ -103,6 +108,11 @@ export const esignetCallback = ({
103108
},
104109
validator: [],
105110
hideInPreview: true,
111+
mapping: {
112+
mutation: {
113+
operation: "ignoreFieldTransformer",
114+
},
115+
},
106116
options: {
107117
url: mosipAPIUserInfoUrl,
108118
headers: {
@@ -124,12 +134,6 @@ export const esignetHidden = () => {
124134
};
125135
};
126136

127-
/**
128-
*
129-
* @description QR reader type definition (this field may not be supported in the latest release of OpenCRVS yet)
130-
*
131-
*/
132-
133137
export const idReader = (
134138
event: string,
135139
sectionId: string,
@@ -198,9 +202,15 @@ interface ESignetConfig {
198202
fieldName: string;
199203
mosipAPIUserInfoUrl: string;
200204
};
205+
loaderFieldName?: string;
201206
}
202207

203-
export const verified = (event: string, sectionId: string, mapping: any) => {
208+
export const verified = (
209+
event: string,
210+
sectionId: string,
211+
mapping: any,
212+
esignetConfig?: ESignetConfig,
213+
) => {
204214
const fieldName = "verified";
205215
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
206216
return {
@@ -213,10 +223,15 @@ export const verified = (event: string, sectionId: string, mapping: any) => {
213223
id: "form.field.label.empty",
214224
defaultMessage: "",
215225
},
216-
initialValue: {
217-
dependsOn: ["idReader"],
218-
expression: 'Boolean($form?.idReader)? "pending":""',
219-
},
226+
initialValue: esignetConfig
227+
? {
228+
dependsOn: ["idReader", esignetConfig.callback.fieldName],
229+
expression: `Boolean($form?.idReader)? "pending": Boolean($form?.${esignetConfig.callback.fieldName}?.data)? "authenticated": ""`,
230+
}
231+
: {
232+
dependsOn: ["idReader"],
233+
expression: 'Boolean($form?.idReader)? "pending":""',
234+
},
220235
validator: [],
221236
mapping,
222237
};
@@ -226,10 +241,13 @@ function capitalize(str: string) {
226241
return str.charAt(0).toUpperCase() + str.slice(1);
227242
}
228243

244+
type VerificationStatus = "verified" | "failed" | "authenticated";
245+
229246
export const idVerificationBanner = (
230247
event: string,
231248
sectionId: string,
232-
status: "verified" | "failed" | "authenticated",
249+
status: VerificationStatus,
250+
conditionals: any[] = [],
233251
) => {
234252
const fieldName = "verified";
235253
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
@@ -240,29 +258,64 @@ export const idVerificationBanner = (
240258
hideInPreview: true,
241259
custom: true,
242260
bannerType: status,
243-
idFieldName: "idReader",
261+
idFieldName: status === "authenticated" ? "esignetCallback" : "idReader",
244262
label: {
245263
id: "form.field.label.empty",
246264
defaultMessage: "",
247265
},
248266
validator: [],
249-
conditionals: [
267+
conditionals: conditionals.concat([
250268
{
251269
action: "hide",
252270
expression: `$form?.verified !== "${status}"`,
253271
},
254-
],
272+
]),
255273
};
256274
};
257275

276+
export function esignetLoaderField({
277+
event,
278+
section,
279+
fieldName,
280+
esignetCallbackFieldName,
281+
}: {
282+
event: "birth" | "death";
283+
section: "informant" | "mother" | "father" | "spouse" | "deceased";
284+
fieldName: string;
285+
esignetCallbackFieldName: string;
286+
}) {
287+
const fieldId = `${event}.${section}.${section}-view-group.${fieldName}`;
288+
return {
289+
name: fieldName,
290+
type: "LOADER",
291+
fieldId,
292+
hideInPreview: true,
293+
custom: true,
294+
label: {
295+
id: "form.field.label.idReader",
296+
defaultMessage: "ID verification",
297+
},
298+
loadingText: {
299+
id: "form.field.label.authenticating.nid",
300+
defaultMessage: "Fetching the person's data from E-Signet",
301+
},
302+
conditionals: [
303+
{
304+
action: "hide",
305+
expression: `!$form?.${esignetCallbackFieldName}?.loading`,
306+
},
307+
],
308+
};
309+
}
310+
258311
export const getInitialValueFromIDReader = (fieldNameInReader: string) => ({
259312
dependsOn: ["idReader", "esignetCallback"],
260313
expression: `$form?.idReader?.${fieldNameInReader} || $form?.esignetCallback?.data?.${fieldNameInReader} || ""`,
261314
});
262315

263316
export const idReaderFields = (
264317
event: "birth" | "death",
265-
section: "informant" | "mother" | "father",
318+
section: "informant" | "mother" | "father" | "spouse" | "deceased",
266319
qrConfig: QRConfig,
267320
esignetConfig: ESignetConfig | undefined,
268321
verifiedCustomFieldMapping: any,
@@ -276,7 +329,7 @@ export const idReaderFields = (
276329
conditionals.concat({
277330
action: "hide",
278331
expression:
279-
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed'",
332+
"$form?.verified === 'verified' || $form?.verified === 'authenticated' || $form?.verified === 'failed' || !!$form?.esignetCallback?.loading",
280333
}),
281334
readers,
282335
),
@@ -298,21 +351,48 @@ export const idReaderFields = (
298351
openIdProviderClientId: esignetConfig.openIdProviderClientId,
299352
}),
300353
);
354+
if (esignetConfig.loaderFieldName) {
355+
fields.push(
356+
esignetLoaderField({
357+
event,
358+
section,
359+
fieldName: esignetConfig.loaderFieldName,
360+
esignetCallbackFieldName: esignetConfig.callback.fieldName,
361+
}),
362+
);
363+
}
364+
return [
365+
...fields,
366+
...idVerificationFields(
367+
event,
368+
section,
369+
verifiedCustomFieldMapping,
370+
conditionals,
371+
esignetConfig,
372+
),
373+
];
301374
}
302375
return [
303376
...fields,
304-
...idVerificationFields(event, section, verifiedCustomFieldMapping),
377+
...idVerificationFields(
378+
event,
379+
section,
380+
verifiedCustomFieldMapping,
381+
conditionals,
382+
),
305383
];
306384
};
307385
export const idVerificationFields = (
308386
event: string,
309387
sectionId: string,
310388
mapping: any,
389+
conditionals: any[] = [],
390+
esignetConfig?: ESignetConfig,
311391
) => {
312392
return [
313-
verified(event, sectionId, mapping),
314-
idVerificationBanner(event, sectionId, "verified"),
315-
idVerificationBanner(event, sectionId, "failed"),
316-
idVerificationBanner(event, sectionId, "authenticated"),
393+
verified(event, sectionId, mapping, esignetConfig),
394+
idVerificationBanner(event, sectionId, "verified", conditionals),
395+
idVerificationBanner(event, sectionId, "failed", conditionals),
396+
idVerificationBanner(event, sectionId, "authenticated", conditionals),
317397
];
318398
};

packages/esignet-mock/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@opencrvs/esignet-mock",
33
"license": "MPL-2.0",
4-
"version": "1.7.0-alpha.21",
4+
"version": "1.7.0-alpha.26",
55
"main": "index.js",
66
"scripts": {
77
"dev": "NODE_ENV=development tsx watch src/index.ts",
@@ -11,7 +11,6 @@
1111
"@fastify/formbody": "^8.0.1",
1212
"@fastify/static": "^8.0.3",
1313
"@types/node": "^22.4.1",
14-
"casual": "^1.6.2",
1514
"envalid": "^8.0.0",
1615
"fastify": "^5.0.0",
1716
"jose": "^5.9.6",

packages/esignet-mock/src/constants.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { join } from "node:path";
44
export const env = cleanEnv(process.env, {
55
PORT: port({ default: 20260 }),
66
HOST: str({ default: "0.0.0.0", devDefault: "localhost" }),
7-
CLIENT_URL: url({ devDefault: "http://localhost:3000" }),
87
OIDP_CLIENT_PRIVATE_KEY_PATH: str({
98
devDefault: join(__dirname, "../../../certs/esignet-jwk.txt"),
109
}),

0 commit comments

Comments
 (0)