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

Adding a new CLI for consistent management of compression and encryption #2

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

lgriffin
Copy link

Please check if the PR fulfills these requirements

  • The commit message is sensible and easily understood
  • Tests for the changes have been added (for bug fixes / features where relevant)
  • Docs have been added / updated (for bug fixes / features where relevant)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

This is a feature addition to try and partly address Issue tutors-sdk#689 wherein we need to have a consistent usage of encryption tooling and standards.

What commits does this PR relate to?

Thank you for your contribution

We hope you stay around and connect with our growing community!

Copy link

netlify bot commented Jun 12, 2024

Deploy Preview for redirect-tutors-reader canceled.

Name Link
🔨 Latest commit b106f90
🔍 Latest deploy log https://app.netlify.com/sites/redirect-tutors-reader/deploys/6669baac16018e0008648618

interface EncryptedCompressedData {
isCompressed: boolean;
isEncrypted: boolean;
data: string;
Copy link
Author

Choose a reason for hiding this comment

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

Structurally what I am aiming for here is two booleans to allow me know the order of operations as the encryption happens before the compression so the inverse has to occur in that order to successfully return the file

return JSON.stringify({
isCompressed,
isEncrypted,
data: jsonData
Copy link
Author

Choose a reason for hiding this comment

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

This is the structure we are left with meaning we can quickly get a true/false read on the JSON that is created and the "payload" of jsonData is then free to interact with and parse later.

@lgriffin
Copy link
Author

I added two single line comments to show one of the approaches that we can then reuse when this is applied elsewhere, it creates a simple boolean control included with the modified JSON payload. That should give us a simple if statement as a control, if the booleans are there, we decrypt and / or decompress, if they are not we have a plain text JSON.

@edeleastar edeleastar merged commit cfa9684 into tutors-sdk:development Jun 25, 2024
4 checks passed
@edeleastar
Copy link

Hi @lgriffin

I have tried just focussing on the simple compress/decompress functions initially. I can successfully integrate into the generator, and have verified that they work successfully, achieving approx 5x compression.

However, when the compressed file is fetched in the reader, we get "incorrect header check" consistently. In debug, we can see the correct number of raw bytes coming down, pako cannot inflate correctly.

Perhaps it is related to the compression/encoding? Particularly compatibility with http/text?

In addition, the controller strategy looks interesting. It could, however, be shortcutted perhpas by the upgraded generator generating a "tutors.bin" instead of "tutors.json". The reader then can attempt to fetch the "bin" version. If present, assume it is encrypted and compressed. If not present, then we fall back to fetching the json?

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.

2 participants