Enforce receipt timestamp ordering and future-time bounds (Fixes #1537)#1615
Open
ayomideadeniran wants to merge 1 commit into
Open
Enforce receipt timestamp ordering and future-time bounds (Fixes #1537)#1615ayomideadeniran wants to merge 1 commit into
ayomideadeniran wants to merge 1 commit into
Conversation
Collaborator
|
@ayomideadeniran tell your agent to run bun command with prettier to format the code Then check ✅ it again with bun after with bun prettier check ✅... That the case for all your issues. If you have CODEX try using it or just connect your GitHub with GPT and use chatGPT work with the GitHub mcp It should also solve it |
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.
Summary
This PR addresses issue #1537 by adding domain schema refinements to
src/server/api/domain.tsto enforce receipt timestamp chronological ordering and future-time bounds.Previously,
receiptSchemavalidated ISO 8601 syntax fordeliveredAtandreadAt, but did not enforce:readAtfollowsdeliveredAt(readAt >= deliveredAt).deliveredAtandreadAtare plausible (not set too far into the future).Changes Implemented
src/server/api/domain.ts:DEFAULT_RECEIPT_FUTURE_TOLERANCE_MS(5 minutes tolerance for clock skew).ReceiptSchemaOptionsallowing configurablemaxFutureSkewMsand reference clocknowinjection.createReceiptSchema(options)using Zod.superRefine(...):deliveredAtandreadAtdatetime validation to accept ISO 8601 strings with timezone offsets ({ offset: true }).deliveredAtmust not exceednow() + maxFutureSkewMs(throws"Delivery timestamp is too far in the future").readAt !== null:readAtmust not precededeliveredAt(throws"Read time cannot precede delivery time").readAtmust not exceednow() + maxFutureSkewMs(throws"Read timestamp is too far in the future").readAt: nullas valid without ordering/future checks.receiptSchema = createReceiptSchema().tests/unit/api/domain.test.ts:receiptSchemaandcreateReceiptSchema:readAt: null.readAtequal todeliveredAt(exact boundary).readAtafterdeliveredAt.Zvs offset+02:00).readAtprecedesdeliveredAt.deliveredAtorreadAtexceeds future clock tolerance.nowandmaxFutureSkewMs.Verification
11 passed):tests/unit/api/domain.test.tsFixes #1537