Refine shared DPoP verifier Effect patterns#3030
Draft
cursor[bot] wants to merge 3 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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.
What Changed
dpopCommon, while preserving the existing nullable compatibility wrapper.Schema.fromJsonStringdecoders instead ofJSON.parseplus manual record traversal.Schema.TaggedErrorClassrejection types to DPoP verification results while keeping the existingreasonstring for current call sites.@effect/vitestassertand assert typed rejection tags.Why
This makes the verifier more idiomatic Effect and easier to test/extend: parsing is schema-driven, optional values use
Optioninternally, and rejection cases are granular structured values rather than only strings.UI Changes
None.
Checklist
Validation:
pnpm test src/dpop.test.tsfrompackages/sharedpassed (5 tests)pnpm exec vp checkpassedpnpm exec vp run typecheckpassedNote
Add typed error classes and structured failure results to
verifyDpopProofdpop.tsto return a typedDpopVerificationError(with a discriminating_tag) alongside the existingreasonstring on all failure paths, covering missing proof, malformed JWT, header/payload validation, thumbprint/method/URL/access-token-hash mismatches, time window violations, and signature failures.DpopJwtHeaderandDpopJwtPayloadSchema definitions and Option-returning decode helpers to replace ad-hoc parsing; replaces the throwingpublicKeyBytesFromJwkwithpublicKeyBytesFromJwkOptionso malformed JWK coordinates produce a structured error instead of throwing.normalizeDpopHtuOptionintodpopCommon.tsand re-exports it fromdpop.ts;normalizeDpopHtunow delegates to it.dpop.test.tsto assert specific error_tagvalues using newassertAccepted/assertRejectedhelpers.verifyDpopProofnow receive anerrorfield on the failure result; the success path is unchanged.Macroscope summarized b948600.