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

Use expo-secure-store instead of Typeorm to store pings and answers data #41

Merged
merged 38 commits into from
Sep 2, 2020

Conversation

hesyifei
Copy link
Member

@hesyifei hesyifei commented Sep 1, 2020

We use expo-secure-store to store the pings and answers data as it provides simple supports for encryption whereas setting up encryption for Typeorm is very complicated.

We stores each ping data (Ping) and each answer data (Answer) as a individual keychain item. This is because keychain has a size limit (see https://docs.expo.io/versions/latest/sdk/securestore/), so it makes sense to store each element separately. We then store a list of ping IDs in a AsyncStorage item, and a list of answer IDs in a AsyncStorage item for each ping. An example looks like this:

In AsyncStorage:

  • PingsList: [wellbeingStream1, interactionStream1, wellbeingStream2]
  • AnswersList
    • wellbeingStream1: [anxiety, stress, sadness]
    • interactionStream1: [peerInteraction, familyInteraction]
    • wellbeingStream2: [anxiety, stress, sadness]

In SecureStore: (all encrypted)

  • wellbeingStream1: { id: wellbeingStream1, notificationTime: ..., ... }
  • interactionStream1: { id: interactionStream1, notificationTime: ..., ... }
  • Other pings data...
  • wellbeingStream1.anxiety: { pingId: wellbeingStream1, questionId: anxiety, data: ... }
  • wellbeingStream1.stress: { pingId: wellbeingStream1, questionId: stress, data: ... }
  • wellbeingStream1.sadness: { pingId: wellbeingStream1, questionId: sadness, data: ... }
  • interactionStream1.peerInteraction: { pingId: interactionStream1, questionId: peerInteraction, data: ... }
  • Other answers data...

Changes:

  • Use SecureStore to store pings and answers data.
    • Change Typeorm's PingEntity and AnswerEntity to zod's PingSchema and AnswerSchema.
  • Remove Typeorm (which was added in Store data in database (TypeORM) #12).
  • Migrate to @react-native-community/async-storage and @react-native-community/slider because of their better jest test support.
  • Make sure all tests still work, and add more tests. (Part of Create unit tests & automated tests #11)
    • For example, in SurveyScreen.test/ tests, we now actually test the stored answers data.

Resolves #37.

@hesyifei hesyifei added the enhancement New feature or request label Sep 1, 2020
@hesyifei hesyifei self-assigned this Sep 1, 2020
@hesyifei hesyifei marked this pull request as ready for review September 2, 2020 06:18
@hesyifei hesyifei merged commit 639c38c into master Sep 2, 2020
@hesyifei hesyifei deleted the use-community-async-storage-and-slider branch September 2, 2020 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encrypt local database
1 participant