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(client): add EncryptionService to validate encrypt submission responses #2436

Merged
merged 7 commits into from
Jul 28, 2021

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Jul 26, 2021

Problem

Storage mode submissions saved to the database cannot be updated due to end-to-end encryption. This means that submissions saved in the wrong format can be difficult or impossible to salvage.

This PR introduces EncryptionService which contains a validation function, enforcing the shape of the submission response. Using this service with the present AngularJS code in production and subsequently reusing it with React can assure us that it the encryption is being performed correctly in the new frontend.

To implement the above service, various field response zod schema constants are created in the new rooted /shared folder and used for the validation.

Closes #2209

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible
    • Pure client side validation

Features:

  • feat: add shared field response types with zod validation
  • feat: add EncryptionService for validating and encrypting responses
  • ref(Form.class): use EncryptionService to get encrypted content string

Improvements:

  • chore: set eslint rule for typesafe to be warn in /public folder

Tests

  • unit tests have been added for the new exported EncryptionService function.

Manual tests

  • Submit a storage mode form with all field types, should submit properly. The submission should also be decrypted properly.
  • Submit an email mode form with all field types. Enable email copy. Should submit properly. Should receive submission with all the correct fields.
  • Submit an email MyInfo form with all MyInfo fields. Same as above.

Sorry, something went wrong.

@karrui karrui requested review from mantariksh and tshuli July 26, 2021 07:59
@karrui karrui force-pushed the feat/encryption-service branch from 2d04ad2 to 7782c9b Compare July 27, 2021 02:56
Copy link
Contributor

@mantariksh mantariksh left a comment

Choose a reason for hiding this comment

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

just one question on the type guard

src/public/services/EncryptionService.ts Outdated Show resolved Hide resolved
@karrui karrui requested a review from mantariksh July 28, 2021 05:50
@karrui karrui merged commit b187544 into develop Jul 28, 2021
@karrui karrui deleted the feat/encryption-service branch July 28, 2021 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce (runtime?) type-checking in frontend submissions pipeline
2 participants