Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: QR code scanner #1

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f56735b
chore: qr code related changes
tahmidrahman-dsi Nov 13, 2024
ec66906
fix: handle optional values
tahmidrahman-dsi Nov 13, 2024
19f93e0
chore: add qr scanner form field
tahmidrahman-dsi Nov 14, 2024
be3e321
chore: some more changes
tahmidrahman-dsi Nov 14, 2024
036b0f0
feat: qr code variants
tahmidrahman-dsi Nov 19, 2024
3fd40ef
fix: add form configuration changes
tahmidrahman-dsi Nov 19, 2024
64bf134
fix: add missing import
tahmidrahman-dsi Dec 11, 2024
385bcfe
chore(WIP): set an example of how id reader field can be incorporated
tahmidrahman-dsi Dec 18, 2024
43a1e5f
chore: add translations
tahmidrahman-dsi Dec 24, 2024
6b79627
fix: conditionals
tahmidrahman-dsi Dec 24, 2024
b8048be
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig-…
tahmidrahman-dsi Jan 6, 2025
be7b103
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig …
tahmidrahman-dsi Jan 6, 2025
3ffe6b3
fix: update yarn-lock
tahmidrahman-dsi Jan 6, 2025
13477e4
Merge pull request #3 from opencrvs/qr-reader-with-latest-develop
tahmidrahman-dsi Jan 6, 2025
d3a6bd6
chore(wip): changes
tahmidrahman-dsi Jan 6, 2025
89ed652
fix: update form config defining pending logic
tahmidrahman-dsi Jan 7, 2025
6829114
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig-…
tahmidrahman-dsi Jan 7, 2025
e5d3432
refactor: rename REDIRECT to LINK_BUTTON
tahmidrahman-dsi Jan 7, 2025
a67dde2
chore: implement e-signet links
tahmidrahman-dsi Jan 8, 2025
d15f9ac
fix: remove unused custom field
tahmidrahman-dsi Jan 9, 2025
f8996f4
fix: improve naming
tahmidrahman-dsi Jan 9, 2025
cb8d286
chore: add hidden form field type
tahmidrahman-dsi Jan 10, 2025
0fb71a3
Adjust field definitions and add env var for server package
euanmillar Jan 10, 2025
b4322f4
Merge branch 'feat/ocrvs-7978/qr-reader' of github.com:opencrvs/openc…
euanmillar Jan 10, 2025
f6de859
bump package number
euanmillar Jan 10, 2025
974535c
fix: typo
tahmidrahman-dsi Jan 13, 2025
7cb991d
Ensure redirectUri is populated
euanmillar Jan 13, 2025
a44b3c9
chore: update mosip images tags
tahmidrahman-dsi Jan 14, 2025
7ba86ff
refactor: rename variable esignet auth url
tahmidrahman-dsi Jan 14, 2025
c5469a9
fix: env vars
tahmidrahman-dsi Jan 14, 2025
352a962
chore: upgrade @opencrvs/mosip
tahmidrahman-dsi Jan 15, 2025
a36bebc
chore: upgrade mosip dep version
tahmidrahman-dsi Jan 16, 2025
36f61aa
chore: update form field condition
tahmidrahman-dsi Jan 16, 2025
f1dc222
chore: update mosip dependency
tahmidrahman-dsi Jan 16, 2025
f381fe4
Merge branch 'develop' into feat/ocrvs-7978/qr-reader
tahmidrahman-dsi Jan 16, 2025
e810071
Merge branch 'develop' into feat/ocrvs-7978/qr-reader
tahmidrahman-dsi Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions infrastructure/docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ 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}
- LOCALE=en

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naftis I would like this LOCALE env var available to the server package used in this PR: opencrvs/mosip#31. How should we set up docker-compose config for this?

networks:
- overlay_net
logging:
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/docker-compose.development-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/docker-compose.qa-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/docker-compose.staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -122,4 +122,4 @@
"minimist": "^1.2.2",
"acorn": "^6.4.1"
}
}
}
2 changes: 2 additions & 0 deletions src/api/certificates/source/birth-certificate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' })
})
36 changes: 36 additions & 0 deletions src/form/birth/custom-fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { getCustomFieldMapping } from '@countryconfig/utils/mapping/field-mapping-utils'
import { formMessageDescriptors } from '../common/messages'
import { Conditional, SerializedFormField } from '../types/types'
import { genderOptions } from '../common/select-options'

/**
*
* @param event
* @param sectionId
* @returns hidden field to store QR scanned data
*/

/** To bypass config validation */
export function getGenderCustom(
event: string,
sectionId: string,
conditionals: Conditional[],
initialValue: { dependsOn: string[]; expression: string } | string = ''
) {
const fieldName: string = 'gender'
const fieldId: string = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`
return {
name: fieldName,
type: 'SELECT_WITH_OPTIONS',
customQuestionMappingId: fieldId,
custom: true,
label: formMessageDescriptors.sex,
required: false,
initialValue,
conditionals,
validator: [],
placeholder: formMessageDescriptors.formSelectPlaceholder,
mapping: getCustomFieldMapping(fieldId),
options: genderOptions
} satisfies SerializedFormField
}
75 changes: 70 additions & 5 deletions src/form/birth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -79,6 +79,20 @@
import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils'
import { getReasonForLateRegistration } from '../custom-fields'
import { getIDNumberFields, getIDType } 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 =======================
Expand Down Expand Up @@ -219,20 +233,66 @@
fields: [
informantType, // Required field.
otherInformantType(Event.Birth), // Required field.
idReader(
'birth',
'informant',
informantFirstNameConditionals
.concat(hideIfInformantMotherOrFather)
.concat({
action: 'hide',
expression: '!!$form?.verified'
}),
[
qr(),
esignet(
'birth',
'informant',
E_SIGNET_AUTH_URL,
OPENID_PROVIDER_CLIENT_ID,
OPENID_PROVIDER_CLAIMS,
'esignet',

Check failure on line 253 in src/form/birth/index.ts

View workflow job for this annotation

GitHub Actions / test

Expected 5 arguments, but got 7.
'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(
hideIfInformantMotherOrFather
),
certificateHandlebars.informantFirstName
), // Required field.
certificateHandlebars.informantFirstName,
{
dependsOn: ['idReader', 'esignetCallback'],
expression:
'$form?.idReader?.firstName || "$form?.esignetCallback?.data?.firstName"'
}
), // Required field. In Farajaland, we have built the option to integrate with MOSIP. So we have different conditionals for each name to check MOSIP responses. You could always refactor firstNamesEng for a basic setup
getFamilyNameField(
'informantNameInEnglish',
informantFamilyNameConditionals.concat(
hideIfInformantMotherOrFather
),
certificateHandlebars.informantFamilyName
certificateHandlebars.informantFamilyName,
{
dependsOn: ['idReader', 'esignetCallback'],
expression:
'$form?.idReader?.familyName || "$form?.esignetCallback?.data?.familyName"'
}
), // Required field.
getGenderCustom('birth', 'informant', [], {
dependsOn: ['idReader', 'esignetCallback'],
expression:
'$form?.idReader?.gender || "$form?.esignetCallback?.data?.gender"'
}),
getBirthDate(
'informantBirthDate',
informantBirthDateConditionals.concat(
Expand All @@ -248,7 +308,12 @@
parameters: []
}
],
certificateHandlebars.informantBirthDate
certificateHandlebars.informantBirthDate,
{
dependsOn: ['idReader', 'esignetCallback'],
expression:
'$form?.idReader?.birthDate || "$form?.esignetCallback?.data?.birthDate"'
}
), // Required field.
exactDateOfBirthUnknown(hideIfInformantMotherOrFather),
getAgeOfIndividualInYears(
Expand Down
15 changes: 9 additions & 6 deletions src/form/common/common-required-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export const getBirthDate = (
fieldName: string,
conditionals: Conditional[],
validator: any[],
certificateHandlebar: string
certificateHandlebar: string,
initialValue: string | { dependsOn: string[]; expression: string } = ''
): SerializedFormField => ({
name: fieldName, // A field with this name MUST exist
type: 'DATE',
label: formMessageDescriptors.dateOfBirth,
required: true,
conditionals,
initialValue: '',
initialValue,
validator,
mapping: getFieldMapping('birthDate', certificateHandlebar)
})
Expand All @@ -48,7 +49,8 @@ export const getGender = (certificateHandlebar: string) =>
export const getFamilyNameField = (
previewGroup: string,
conditionals: Conditional[],
certificateHandlebar: string
certificateHandlebar: string,
initialValue: string | { dependsOn: string[]; expression: string } = ''
) =>
({
name: 'familyNameEng', // A field with this name MUST exist
Expand All @@ -58,7 +60,7 @@ export const getFamilyNameField = (
label: formMessageDescriptors.familyName,
maxLength: 32,
required: true,
initialValue: '',
initialValue,
validator: [
{
operation: 'englishOnlyNameFormat'
Expand All @@ -70,7 +72,8 @@ export const getFamilyNameField = (
export const getFirstNameField = (
previewGroup: string,
conditionals: Conditional[],
certificateHandlebar: string
certificateHandlebar: string,
initialValue: string | { dependsOn: string[]; expression: string } = ''
) =>
({
name: 'firstNamesEng', // A field with this name MUST exist
Expand All @@ -84,7 +87,7 @@ export const getFirstNameField = (
conditionals,
maxLength: 32,
required: true,
initialValue: '',
initialValue,
validator: [
{
operation: 'englishOnlyNameFormat'
Expand Down
63 changes: 63 additions & 0 deletions src/form/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
export const NUMBER = 'NUMBER'
export const BIG_NUMBER = 'BIG_NUMBER'
export const RADIO_GROUP = 'RADIO_GROUP'
export const HIDDEN = 'HIDDEN'

Check failure on line 118 in src/form/types/types.ts

View workflow job for this annotation

GitHub Actions / test

Cannot redeclare block-scoped variable 'HIDDEN'.
export const INFORMATIVE_RADIO_GROUP = 'INFORMATIVE_RADIO_GROUP'
export const CHECKBOX_GROUP = 'CHECKBOX_GROUP'
export const CHECKBOX = 'CHECKBOX'
Expand Down Expand Up @@ -142,6 +143,11 @@
export const DIVIDER = 'DIVIDER'
export const HEADING3 = 'HEADING3'
export const SIGNATURE = 'SIGNATURE'
export const HIDDEN = 'HIDDEN'

Check failure on line 146 in src/form/types/types.ts

View workflow job for this annotation

GitHub Actions / test

Cannot redeclare block-scoped variable 'HIDDEN'.
export const LINK_BUTTON = 'LINK_BUTTON'
export const ID_READER = 'ID_READER'
export const HTTP = 'HTTP'
euanmillar marked this conversation as resolved.
Show resolved Hide resolved
export const ID_VERIFICATION_BANNER = 'ID_VERIFICATION_BANNER'

export enum RadioSize {
LARGE = 'large',
Expand Down Expand Up @@ -491,6 +497,54 @@
)[]
}

export interface IHiddenFormField extends IFormFieldBase {

Check failure on line 500 in src/form/types/types.ts

View workflow job for this annotation

GitHub Actions / test

Individual declarations in merged declaration 'IHiddenFormField' must be all exported or all local.
type: typeof HIDDEN
}

export interface IHttpFormField extends IFormFieldBase {
euanmillar marked this conversation as resolved.
Show resolved Hide resolved
type: typeof HTTP
options: {
url: string
method?: string
headers: Record<string, string>
body?: Record<string, any>
params?: Record<string, any>
}
}

export interface ILinkButtonFormField extends IFormFieldBase {
type: typeof LINK_BUTTON
icon?: {
desktop: string
mobile: string
}
options: {
url: string
callback: {
trigger: string
params: Record<string, string>
}
}
}

export interface QRReaderType {
type: 'QR'
}

type ReaderType = QRReaderType | ILinkButtonFormField
export interface IIDReaderFormField extends IFormFieldBase {
type: typeof ID_READER
dividerLabel: MessageDescriptor
manualInputInstructionLabel: MessageDescriptor
readers: [ReaderType, ...ReaderType[]]
}

export type BannerType = 'pending' | 'verified' | 'failed'
export interface IIDVerificationBannerFormField extends IFormFieldBase {
type: typeof ID_VERIFICATION_BANNER
bannerType: BannerType
idFieldName: string
}
export type IFormField =
| ITextFormField
| ITelFormField
Expand Down Expand Up @@ -524,6 +578,11 @@
| IDividerField
| IHeading3Field
| ISignatureFormField
| IHiddenFormField
| IIDReaderFormField
| ILinkButtonFormField
| IHttpFormField
| IIDVerificationBannerFormField

export interface SelectComponentOption {
value: string
Expand Down Expand Up @@ -739,6 +798,10 @@
mapping?: IFormFieldMapping
}

interface IHiddenFormField extends IFormFieldBase {

Check failure on line 801 in src/form/types/types.ts

View workflow job for this annotation

GitHub Actions / test

Individual declarations in merged declaration 'IHiddenFormField' must be all exported or all local.
type: typeof HIDDEN
}

export type IFormSectionQueryMapFunction = (
transFormedData: IFormData,
queryData: any,
Expand Down
Loading
Loading