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

Fetch certificate configuration from country config #6165

Merged
merged 10 commits into from
Nov 8, 2023

Conversation

Zangetsu101
Copy link
Collaborator

@Zangetsu101 Zangetsu101 commented Nov 6, 2023

Core looks for certificate configurations(currently only fonts, more will be added in the future releases) in the /certificate-configuration endpoint in country-config, if the GET request succeeds then it uses the font definitions received from it. If the endpoint returns 404, then core falls back to using only NotoSans, as it did in v1.3.0 previously.

There is also a bug fix for caching the validations, conditionals & handlebars through the service worker.

@Zangetsu101 Zangetsu101 added 💥 Hot Fixes Hot fixes for (prod/qa/staging) deployment Docs Documentation needs to be updated labels Nov 6, 2023
@@ -64,7 +64,7 @@ export function createPDF(
return pdfMake.createPdf(
JSON.parse(definitionString),
undefined,
template.fonts[intl.locale] || template.fonts[intl.defaultLocale]
template.fonts
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Zangetsu101 by removing this, are we not removing the possibility to support say a cert in Bengali and a cert in English? The font file may not contain all characters.

Copy link
Collaborator Author

@Zangetsu101 Zangetsu101 Nov 7, 2023

Choose a reason for hiding this comment

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

Not necessarily as the certificateConfiguration we are getting from country config isn't restricted to be only a single font definition so we can just pass a Bengali font & a English one and use them both on the certificate or a single one if we want. So I decided to flatten the structure or am I missing something?

Copy link
Collaborator Author

@Zangetsu101 Zangetsu101 Nov 7, 2023

Choose a reason for hiding this comment

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

In the future if we perhaps render a different certificate depending on the selected language, this configuration would still support that as which font needs to be used is mentioned in the svg & where to fetch the font from would be defined in this configuration

}
}
}
fonts: {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above. I think we need to keep the "en"

normal: string
bold: string
italics: string
bolditalics: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jpye-finch what do you think of this. Essentially we are restricting the possibilities to 4 types of font. https://fonts.google.com/knowledge/glossary/family_or_type_family_or_font_family

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes not sure if required to be honest.

Just need to allow them to say what fonts they are using in the certificate. Is there any reason we need to restrict the numbers.

An example below. ie you might have two bolds

Font 1: Roboto Bold
Font 2: Noto Sans Bold
Font 3: Roboto Medium
Font 4: Roboto Light

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are not restricting a country from supplying multiple fonts but its just that our pdf renderer library only supports 4 variants of a single font: Regular, Bold, Italic & BoldItalic.

Copy link
Collaborator Author

@Zangetsu101 Zangetsu101 Nov 7, 2023

Choose a reason for hiding this comment

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

But as @jpye-finch mentioned if we want more weights, we can add multiple fonts like Roboto Light, Roboto Medium and each of them are allowed up to 4 variants.

Copy link
Collaborator

@jpye-finch jpye-finch Nov 7, 2023

Choose a reason for hiding this comment

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

@Zangetsu101 The above examples don't have variant fonts.

Roboto is the font family.

Then from Google Fonts, I can choose to download the individual font variants. Eg. Roboto Bold, Roboto Light

Copy link
Collaborator

Choose a reason for hiding this comment

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

The country should just need to upload the font variants they use imo

Copy link

codecov bot commented Nov 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@euanmillar euanmillar merged commit 56a9c54 into release-v1.3.1 Nov 8, 2023
18 checks passed
@euanmillar euanmillar deleted the certificate-fonts branch November 8, 2023 12:38
rikukissa added a commit that referenced this pull request Nov 13, 2023
* Bump release number

* Hotfix v1.2.1 (#5139)

* Bump hotfix version

* Informant address has nullable fields causing GraphQL error (#5138)

* 4750 Fix local - international - local phone number transformations (#5143)

* 4750 Fix local - international - local phone number transformations for all countries

* Restore country-data dependency to login app

* Force disk encryption (#5144)

* Add informant type handlebar and localise handlebars (#5140)

* Add informant type handlebar and localise all message descriptors in cert

* Fix test

* Fix certificate preview

* Combine approaches to localisation of certs

* Fixed PDFUtils test

* Bump hotfix release number

* Show correct button for certified declarations (#6041)

* ocrvs 5795 - search by email (#5872)

* email add for ui in search

* contactEmail add in gateway and search query

* search with email update

* rename contact relation for search

* rename elastic field in migration

* search result test fix

* form field condition add for email

* search migration func name update

* swap params of rename func of search

* ocrvs-6063 query validation for location endpoint (#6076)

* Validate location search query params

* Pass the type parameter to location query

* Restrict locationId param to a valid uuid

* Remove empty braces

* Ocrvs 5793 Cameroon improvements (#6054)

* Add separate validator dateNotPastLimit

* Minor tweak masking strategy in login two step to avoid text overflow

* Fixed select placeholder french lang (#5576)

* change how alive ES connection is detected

* one more check to see if elastic is connected

* improve ping endpoint in gateway to give out all statuses of all services

* remove old query validation from ping endpoint

* Add past date validation in child birth date

* use process env DOMAIN as sentry environment so it doesnt get populated with docker containers id

* add sourcemaps to build

* Fixed failed test for health check

* Remove unused import

---------

Co-authored-by: Sadman Anik <36187489+sadmananik@users.noreply.github.com>
Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>
Co-authored-by: Sadman Anik <sadman.anik@dsinnovators.com>

* Ocrvs 6021 - in progress declaration data fix  (#6050)

* unnecessary import fix

* original data set only for registered declaration

* Ocrvs 5794 - configurable signature for different users (#6024)

* validation add for signature of different roles

* add config constant in window

* conditional add for signature section

* fix validation for signature roles

* allow signature in history for more reg status

* mock data fix for config

* system roles array update for signtature

* signature row fix for create user (#6003)

* signature row fix for create user

* type fix for form data

* Make signatre not required

* create user test fix

---------

Co-authored-by: euanmillar <euanmillar77@gmail.com>

* Fix deps vulnerabilities (#5999)

* Upgrade problematic packages

* Update yarn lock file

* Remove minio type module

* Remove patch files

* Remove stub type modules @types/pino, @types/hapi-pino and upgraded those packages which have their own type definitions

* Minor type assertion amends

* Fix tests with type non null assertion

* Remove caret from vitest as we dont want to upgrade vitest for now

* Fix type error

* Apply new patch to the newer version of pdfmake that solves an old problem

* Requirements for Niue (#6016)

* No reason that titles should be mandatory

* Hide a field based on the user type

* Move background image into login INdexedDB

* Hide questions on review page from users

* OCRVS 6085: Configurable handlebar helpers (#6086)

* No reason that titles should be mandatory

* Hide a field based on the user type

* Move background image into login INdexedDB

* Hide questions on review page from users

* Make it possible to confgure handlebars

* remove output

* fix test

* Fix import handlebar helpers

* Ocrvs 5994 - list for certificator collector and correction requester (#6058)

* collector form section update

* collector form section array update

* message update for print cert

* filter informant type option for mother father bride groom

* print reducer remove

* delete unused objects

* refactor collector section form

* issue collector form refactor

* clean up collector section

* unnecessary variable remove

* unused exports remove

* correction form refactor with informant

* corrector message update

* filter options func fix

* new key generate for additional param in radio option

* collector form test fix for refactor collector section

* revert mock data and fix collector form test

* corrector form test fix for collector section refactor

* clean up collector section functions

* refactor id verifier for print and issue

* message description fix

* id verfier for corrector refactor

* message for age field fix

* id number fix for id verifier by gql transformer

---------

Co-authored-by: Euan Millar <euanmillar@users.noreply.github.com>
Co-authored-by: euanmillar <euanmillar77@gmail.com>

* Update yarn lock

* Add registration location to email as a variable (#6104)

* Add registration location to email

* Fix test

* Fix another test

* Fix uploadSVG handler and tests

* Add configurable support for death registration (#6116)

* Add support for passing intl and other context variables to custom handlebar helpers (#6115)

* add support for passing intl and other context variables to custom handlebar helpers

* mock custom handlebar helpers fetching in unit tests

* add a comment warning anyone who wants to expose more values through custom handlebar helpers

* Replace hard coded messages (#6122)

* Replace hard coded messages of UserList table

* Uppercase table header texts

* path for nginx default config when building client images (#6127)

* Configurable domains & whitelist (#6123)

* Pass whitelist as a string array from env vars

* different approach to whitelist

* Strip https

* revert tslint change

* Rename variable

* No need to strip https

* Id verifier and collector form fix (#6106)

* set collector type from declaration

* collector and corrector type set conditionally

* informant name fix for underscore

* deprecate legal guardian option if informant already

* fix record audit history for correction

* title messages fix for id verifiers

* comment add for label mapper for record audit history

* messages update for id verifier buttons

* collector and corrector type fix

* Remove hard-coded collector/corrector check

---------

Co-authored-by: Tameem Bin Haider <tameem.haider@dsinnovators.com>

* Skip decorative types when checking for unknowns (#6135)

Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>

* Fix crude birth rates & pass performance metrics as a Float to 2 decimal places to support small populations (#6109)

* No need for these users to update workqueues

* remove unnecessary change

* wip

* Tests for estimates array

* Update schema

* Deduplication doesnt work if another type of ID is submitted (#6144)

* Store whatever supported identifier is supplied to Elasticsearch

* comment out dejavu again

* revert changes to de-dupe command

* Fis de-dupe

* minor refactor

---------

Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>

* Introduce a new handlebar "printInAdvance" (#6146)

* feat(v1.3.1): allow configuring dashboard queries from country config (#6121)

* feat: allow configuring dashboard queries from country config

* chore: rename the queries to be descriptive of what they edit

* Handle empty deceased/child resource in search (#6152)

* Support one location level in verify certificate (#6151)

* Fix death reg notification and copy amend on review page (#6159)

* fix bug sending reg location to death email handler

* Copy amend

* Fix mother / father details getting mixed up when informant type is changed (#6149)

* OCRVS-6022:  Allow null values for user mobile and emailForNotification when creating users but still check for uniqueness (#6166)

* Allow null values for users mobile

* Migration for email and mobile uniqueness

* Fetch certificate configuration from country config (#6165)

* Load fonts from country-config

* Cache font & cert config in service worker

* Update cache routes for validators, handlebars etc

* Use NotoSans as fallback for backward compatibility

* Remove auth header from cert config request

* Add retry on load failed

* Provide mock for the fonts

* Mock loadCertificateConfiguration function

* Remove dev certificate handler

---------

Co-authored-by: euanmillar <euanmillar77@gmail.com>

* Initialize object before setting value (#6173)

---------

Co-authored-by: Tahmid Rahman <42269993+tahmidrahman-dsi@users.noreply.github.com>
Co-authored-by: Md. Ashikul Alam <32668488+Nil20@users.noreply.github.com>
Co-authored-by: Tameem Bin Haider <tameem.haider@dsinnovators.com>
Co-authored-by: Sadman Anik <36187489+sadmananik@users.noreply.github.com>
Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>
Co-authored-by: Sadman Anik <sadman.anik@dsinnovators.com>
Co-authored-by: Pyry Rouvila <pyry.rouvila@gmail.com>
@jpye-finch jpye-finch linked an issue Nov 22, 2023 that may be closed by this pull request
@jpye-finch jpye-finch linked an issue Nov 29, 2023 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Documentation needs to be updated 💥 Hot Fixes Hot fixes for (prod/qa/staging) deployment 🔧Waiting for fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants