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

Move AWS secrets from .env to lookit-api and add S3 error handling #85

Merged
merged 8 commits into from
Oct 29, 2024

Conversation

becky-gilbert
Copy link
Contributor

@becky-gilbert becky-gilbert commented Oct 25, 2024

This PR moves the AWS S3 secrets for jsPsych video uploading out of an environment variable in the data package. They'll now be available to the data package via the lookit-api (including in local development).

The AWS secrets have also been changed to temporary credentials, so this adds checks and error handling for an 'expired token' error that can occur in response to any request sent to AWS S3.

List of changes

  • Moves the AWS variables from a data package .env file to the lookit-api. This means that the variables are obtained from the document at runtime, and we are no longer using the dotenv package or process.env in data.
  • Adds a new MissingCredentials error for when the AWS credentials are not found on the page.
  • Adds a new ExpiredCredentials error for when the AWS credentials have expired.
  • Adds tests for the new errors and error handling.

Important

This change to lookit-jspsych must be made in conjunction with the corresponding change in lookit-api, which adds the AWS secret temporary credentials into the jsPsych study template.

To do

In the future we should change this to an API call. This will allow us to refresh the credentials if they expire during a session (assuming the user is logged in), instead of requiring the user to start a new session.

…s from document, throw errors for expired credentials
…ase one of the uploadPart promises throws an error, and catch an ExpiredCredentials error from uploadPart in the completeUpload catch block
Copy link

changeset-bot bot commented Oct 25, 2024

🦋 Changeset detected

Latest commit: 7fc4b24

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@lookit/data Minor
@lookit/templates Major
@lookit/lookit-initjspsych Patch
@lookit/record Major
@lookit/surveys Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@becky-gilbert becky-gilbert self-assigned this Oct 25, 2024
Copy link
Collaborator

@okaycj okaycj left a comment

Choose a reason for hiding this comment

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

This looks great! Now that the environment variables have changed, you might want to update (or remove) the environment.d.ts file.

@okaycj
Copy link
Collaborator

okaycj commented Oct 29, 2024

I want to get these updates into API, so I resolved the conflicts with "main" and removed "data"'s environment.d.ts file. My apologies if this was a mistake.

@okaycj okaycj merged commit 9605ac4 into main Oct 29, 2024
2 checks passed
@okaycj okaycj deleted the remove-data-env-vars branch October 29, 2024 14:00
@becky-gilbert
Copy link
Contributor Author

I want to get these updates into API, so I resolved the conflicts with "main" and removed "data"'s environment.d.ts file. My apologies if this was a mistake.

@okaycj these were very straightforward changes and I agree we need to get this merged ASAP, so thanks for getting it done!

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