From a67dde281e2f67578950e1c923f6b936fc9615c7 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Wed, 8 Jan 2025 15:29:17 +0600 Subject: [PATCH] chore: implement e-signet links --- infrastructure/docker-compose.deploy.yml | 4 + .../docker-compose.development-deploy.yml | 4 + infrastructure/docker-compose.qa-deploy.yml | 4 + .../docker-compose.staging-deploy.yml | 4 + package.json | 2 +- src/constants.ts | 6 ++ src/environment.ts | 6 +- src/form/birth/index.ts | 89 ++++++++----------- yarn.lock | 10 +-- 9 files changed, 68 insertions(+), 61 deletions(-) diff --git a/infrastructure/docker-compose.deploy.yml b/infrastructure/docker-compose.deploy.yml index 21899170a..47dc1df46 100644 --- a/infrastructure/docker-compose.deploy.yml +++ b/infrastructure/docker-compose.deploy.yml @@ -581,6 +581,10 @@ services: - INFOBIP_API_KEY=${INFOBIP_API_KEY:-} - INFOBIP_SENDER_ID=${INFOBIP_SENDER_ID:-} - DOMAIN={{hostname}} + - E_SIGNET_AUTH_URL=${E_SIGNET_AUTH_URL} + - OPENID_PROVIDER_CLIENT_ID=${OPENID_PROVIDER_CLIENT_ID} + - OPENID_PROVIDER_CLAIMS=${OPENID_PROVIDER_CLAIMS} + - OIDP_USER_INFO_URL=${OIDP_USER_INFO_URL} networks: - overlay_net logging: diff --git a/infrastructure/docker-compose.development-deploy.yml b/infrastructure/docker-compose.development-deploy.yml index 10450eb28..0e1c2b4a0 100644 --- a/infrastructure/docker-compose.development-deploy.yml +++ b/infrastructure/docker-compose.development-deploy.yml @@ -28,6 +28,10 @@ services: - SMTP_USERNAME=${SMTP_USERNAME} - SMTP_PASSWORD=${SMTP_PASSWORD} - SMTP_SECURE=${SMTP_SECURE} + - E_SIGNET_AUTH_URL=${E_SIGNET_AUTH_URL} + - OPENID_PROVIDER_CLIENT_ID=${OPENID_PROVIDER_CLIENT_ID} + - OPENID_PROVIDER_CLAIMS=${OPENID_PROVIDER_CLAIMS} + - OIDP_USER_INFO_URL=${OIDP_USER_INFO_URL} deploy: replicas: 1 networks: diff --git a/infrastructure/docker-compose.qa-deploy.yml b/infrastructure/docker-compose.qa-deploy.yml index 68a315434..a053df26e 100644 --- a/infrastructure/docker-compose.qa-deploy.yml +++ b/infrastructure/docker-compose.qa-deploy.yml @@ -57,6 +57,10 @@ services: - SMTP_USERNAME=${SMTP_USERNAME} - SMTP_PASSWORD=${SMTP_PASSWORD} - SMTP_SECURE=${SMTP_SECURE} + - E_SIGNET_AUTH_URL=${E_SIGNET_AUTH_URL} + - OPENID_PROVIDER_CLIENT_ID=${OPENID_PROVIDER_CLIENT_ID} + - OPENID_PROVIDER_CLAIMS=${OPENID_PROVIDER_CLAIMS} + - OIDP_USER_INFO_URL=${OIDP_USER_INFO_URL} deploy: replicas: 1 networks: diff --git a/infrastructure/docker-compose.staging-deploy.yml b/infrastructure/docker-compose.staging-deploy.yml index dab5ee159..a121ef36f 100644 --- a/infrastructure/docker-compose.staging-deploy.yml +++ b/infrastructure/docker-compose.staging-deploy.yml @@ -107,6 +107,10 @@ services: - SMTP_USERNAME=${SMTP_USERNAME} - SMTP_PASSWORD=${SMTP_PASSWORD} - SMTP_SECURE=${SMTP_SECURE} + - E_SIGNET_AUTH_URL=${E_SIGNET_AUTH_URL} + - OPENID_PROVIDER_CLIENT_ID=${OPENID_PROVIDER_CLIENT_ID} + - OPENID_PROVIDER_CLAIMS=${OPENID_PROVIDER_CLAIMS} + - OIDP_USER_INFO_URL=${OIDP_USER_INFO_URL} deploy: replicas: 1 diff --git a/package.json b/package.json index c98aa4ac6..56252ffc1 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@hapi/boom": "^9.1.1", "@hapi/hapi": "^20.0.1", "@hapi/inert": "^6.0.3", - "@opencrvs/mosip": "^1.7.0-alpha.2", + "@opencrvs/mosip": "^1.7.0-alpha.4", "@opencrvs/toolkit": "0.0.6-events", "@types/chalk": "^2.2.0", "@types/csv2json": "^1.4.0", diff --git a/src/constants.ts b/src/constants.ts index fecca17fc..93bdf5c7f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -30,3 +30,9 @@ export const CHECK_INVALID_TOKEN = env.CHECK_INVALID_TOKEN export const PRODUCTION = env.isProd export const QA_ENV = env.QA_ENV + +// e-signet +export const E_SIGNET_AUTH_URL = env.E_SIGNET_AUTH_URL +export const OPENID_PROVIDER_CLIENT_ID = env.OPENID_PROVIDER_CLIENT_ID +export const OPENID_PROVIDER_CLAIMS = env.OPENID_PROVIDER_CLAIMS +export const OIDP_USER_INFO_URL = env.OIDP_USER_INFO_URL diff --git a/src/environment.ts b/src/environment.ts index 1a084ab61..a4a5f1bdd 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -30,5 +30,9 @@ export const env = cleanEnv(process.env, { CONFIRM_REGISTRATION_URL: url({ devDefault: 'http://localhost:5050/confirm/registration' }), - QA_ENV: bool({ default: false }) + QA_ENV: bool({ default: false }), + E_SIGNET_AUTH_URL: url({ devDefault: '' }), + OPENID_PROVIDER_CLIENT_ID: str({ devDefault: '' }), + OPENID_PROVIDER_CLAIMS: str({ devDefault: '' }), + OIDP_USER_INFO_URL: url({ devDefault: '' }) }) diff --git a/src/form/birth/index.ts b/src/form/birth/index.ts index aad010f07..c4bffece2 100644 --- a/src/form/birth/index.ts +++ b/src/form/birth/index.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { Event, ISerializedForm } from '../types/types' +import { Event, ISerializedForm, SerializedFormField } from '../types/types' import { formMessageDescriptors } from '../common/messages' import { informantType } from './required-fields' import { @@ -79,7 +79,20 @@ import { getSectionMapping } from '@countryconfig/utils/mapping/section/birth/ma import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' import { getReasonForLateRegistration } from '../custom-fields' import { getIDNumberFields, getIDType } from '../custom-fields' -import { getGenderCustom, getIDReaderField } from './custom-fields' +import { + esignet, + esignetCallback, + idReader, + idVerificationFields, + qr +} from '@opencrvs/mosip' +import { getGenderCustom } from './custom-fields' +import { + E_SIGNET_AUTH_URL, + OIDP_USER_INFO_URL, + OPENID_PROVIDER_CLAIMS, + OPENID_PROVIDER_CLIENT_ID +} from '@countryconfig/constants' // import { createCustomFieldExample } from '../custom-fields' // ======================= FORM CONFIGURATION ======================= @@ -220,7 +233,7 @@ export const birthForm: ISerializedForm = { fields: [ informantType, // Required field. otherInformantType(Event.Birth), // Required field. - getIDReaderField( + idReader( 'birth', 'informant', informantFirstNameConditionals @@ -228,57 +241,27 @@ export const birthForm: ISerializedForm = { .concat({ action: 'hide', expression: '!!$form?.verified' - }) - ), - { - name: 'someHTTPField', - type: 'HTTP', - custom: true, - label: { - id: 'messages.empty', - defaultMessage: ' ' - }, - validator: [], - options: { - url: 'someRoute', - headers: { - 'Content-type': 'application/json' - }, - method: 'GET' - } - }, - { - name: 'verified', - type: 'HIDDEN', - custom: true, - label: { - id: 'messages.empty', - defaultMessage: '' - }, - initialValue: { - dependsOn: ['idReader'], - expression: 'Boolean($form?.idReader)? "pending":""' - }, - validator: [] - }, - { - name: 'idPending', - type: 'ID_VERIFICATION_BANNER', - custom: true, - bannerType: 'pending', - idFieldName: 'idReader', - label: { - id: 'messages.empty', - defaultMessage: '' - }, - validator: [], - conditionals: [ - { - action: 'hide', - expression: '$form?.verified !== "pending"' - } + }), + [ + qr(), + esignet( + E_SIGNET_AUTH_URL, + OPENID_PROVIDER_CLIENT_ID, + OPENID_PROVIDER_CLAIMS, + 'esignet', + 'esignetCallback' + ) ] - }, + ) as SerializedFormField, + esignetCallback({ + fieldName: 'esignetCallback', + getOIDPUserInfoUrl: OIDP_USER_INFO_URL, + openIdProviderClientId: OPENID_PROVIDER_CLIENT_ID + }) as SerializedFormField, + ...(idVerificationFields( + 'birth', + 'informant' + ) as SerializedFormField[]), getFirstNameField( 'informantNameInEnglish', informantFirstNameConditionals.concat( diff --git a/yarn.lock b/yarn.lock index 3b59f55aa..4dd2bfa11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -790,12 +790,10 @@ dependencies: "@octokit/openapi-types" "^18.0.0" -"@opencrvs/mosip@^1.7.0-alpha.2": - version "1.7.0-alpha.2" - resolved "https://registry.yarnpkg.com/@opencrvs/mosip/-/mosip-1.7.0-alpha.2.tgz#b3de70d993607142d739c7ada0c021b0d0f32b46" - integrity sha512-UiZUxuUiNGP/9CuQh1yPtmXmZTRAFiY4jQI2qlihCXZ8A0JbdXut2g3Dw3dRNvA9SvUnix1uuQpmWU/tAePWJA== - dependencies: - "@hapi/hapi" "^20.0.1" +"@opencrvs/mosip@^1.7.0-alpha.4": + version "1.7.0-alpha.4" + resolved "https://registry.yarnpkg.com/@opencrvs/mosip/-/mosip-1.7.0-alpha.4.tgz#82bd22e6dfbebfced533343774825da9ec194289" + integrity sha512-INdAXQWpdZ4y04MDhZd5cYl4pTl1FvrQfyWn4P8nqukAh/JpW8UtZE98zoIJ7/wS331zO6Lj5w0th+baGgQu/A== "@opencrvs/toolkit@0.0.6-events": version "0.0.6-events"