Skip to content

Prevent overwriting encryption keys#603

Merged
jhaven-stytch merged 4 commits intomainfrom
jordan/encryption-key-improvements
Feb 25, 2026
Merged

Prevent overwriting encryption keys#603
jhaven-stytch merged 4 commits intomainfrom
jordan/encryption-key-improvements

Conversation

@jhaven-stytch
Copy link
Contributor

Changes:

  1. Change the encryption key property into a getter with a cached backing field, and lazy load it (Bug: Encryption Key is not present on relaunch #601). This helps reduce the chance that the key is fetched before protected data is available
  2. If the key doesn't exist, ensure we don't try to read it if protected data is not available; instead print an error log and let the caller throw it's own error about the key not being available. This protects us from potentially overwriting the key if it was simply accessed before it was ready
  3. Add a listener to the startup client to proactively fetch the encryption key when protected data becomes available to maintain first-access performance.

Checklist:

  • I have verified that this change works in the relevant demo app, or N/A
  • I have added or updated any tests relevant to this change, or N/A
  • I have updated any relevant README files for this change, or N/A

Sailor-Saturn and others added 4 commits February 23, 2026 10:31
Delay encryption key initialization until first use, preventing key creation before fresh-install keychain reset during SDK configure.

Co-authored-by: Łukasz Śliwiński <lukasz.sliwinski@withintent.com>
…rwrite a key just because the keychain was not yet available
@jhaven-stytch jhaven-stytch requested a review from a team as a code owner February 23, 2026 16:17
@jhaven-stytch
Copy link
Contributor Author

cc: @Sailor-Saturn, not sure if you got pinged on this, so just making sure it's on your radar!

@jhaven-stytch jhaven-stytch merged commit 3f2a950 into main Feb 25, 2026
11 of 13 checks passed
@jhaven-stytch jhaven-stytch deleted the jordan/encryption-key-improvements branch February 25, 2026 20:39
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.

3 participants