feat: fetch and consume device prekey bundle#211
Open
Andreschuks101 wants to merge 1 commit into
Open
Conversation
|
@Andreschuks101 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fetch + consume prekey bundle — GET /users/:userId/devices/:deviceId/key-bundle
closes #160
Serves a recipient device's public prekey bundle and consumes one one-time prekey
per fetch, so a sender can start an X3DH/Signal-style encrypted session.
Changes
devices(identity public key, registrationId, signedprekey + signature,
revokedAt) andone_time_pre_keys(consumedflag,unique
(device_id, key_id),(device_id, consumed)index). Migration0007_device_key_bundles. Only public key material is stored.fetchAndConsumeKeyBundle: looks up the device, returns 404 if it isunknown or revoked, and otherwise returns
{ identityPublicKey, registrationId, signedPreKey, oneTimePreKey | null }.GET /users/:userId/devices/:deviceId/key-bundle, authenticated.Atomic, race-free consumption
The one-time prekey is claimed in a single statement:
FOR UPDATE SKIP LOCKEDensures concurrent senders skip a row another transactionis already claiming, so the same one-time prekey can never be issued twice. When
the pool is exhausted the bundle is still returned with
oneTimePreKey: null.Acceptance criteria
oneTimePreKey: nullgracefully when the pool is exhausted.Testing
null on exhaustion, 404 for unknown and revoked devices, and a "no private
material" shape assertion.