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

[TECH-676] Use properly LatestConfig to encrypt affidavit #217

Merged

Conversation

w0st
Copy link
Contributor

@w0st w0st commented Dec 14, 2022

No description provided.

@w0st w0st marked this pull request as ready for review December 14, 2022 11:17
@@ -272,7 +272,6 @@ export interface LatestConfig {
items: LatestConfigItems
receipt?: string
affidavit?: AffidavitConfig
castRequestItemAttachmentEncryptionKey?: string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This element is not available on the root object.

@w0st w0st requested review from av-mads, av-lukas, unnunhexium and MateuszMichalowski and removed request for av-mads December 14, 2022 11:18
@w0st w0st merged commit 857bff1 into main Dec 14, 2022
@w0st w0st deleted the TECH-676-use-properly-dbb-latest-config-to-encrypt-affidavit branch December 14, 2022 11:51
@@ -396,9 +396,9 @@ export class AVClient implements IAVClient {

let encryptedAffidavit;

if (affidavit && this.latestConfig && this.latestConfig.castRequestItemAttachmentEncryptionKey) {
if (affidavit && this?.latestConfig?.items?.electionConfig?.content?.castRequestItemAttachmentEncryptionKey) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given we're using TypeScript, can we make these null assertions at the Type level? (i.e., fail when parsing the API response)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@MateuszMichalowski MateuszMichalowski Dec 15, 2022

Choose a reason for hiding this comment

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

Are you referring to add union types with null possibility to these @av-lukas or you have something else in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how union types would be used here, but I'm referring to the fact that at this point in the lifecycle of the av_client, if the affidavit is present, then it also means that the client has been told to ask for one, via the configuration object. So, in that case, the castRequestItemAttachmentEncryptionKey should always be present, and the null checks shouldn't be necessary. The class that wraps it should enforce it to be present when parsing the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants