Repository navigation
server: carry the scheme's workOptional into the 402 requirements - #7
Merged
kilkelly merged 1 commit intoNov 6, 2026
Merged
Conversation
The Facilitator advertises `extra.workOptional: true` in its SupportedKind when it can generate work, and the spec's Appendix says a Resource Server whose Facilitator does so MUST set `extra.workOptional: true` in the PaymentRequirements it serves. `enhancePaymentRequirements` voided `supportedKind` and copied only the route's own `extra`, and @x402/core does not merge `supportedKind.extra` either, so the flag never reached the 402 unless the route config repeated it by hand; the client then generated work itself. Forward `supportedKind.extra.workOptional` into `extra` when it is `true` and the route has not set the key. Adds a server unit test that mocks a Facilitator advertising work generation and checks the built requirement carries `extra.workOptional: true` for a route with no `extra`. Filed at kilkelly's request in the x402nano#5 thread (review item 1). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.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.
On the
v1.0.0branch,ExactNanoScheme.enhancePaymentRequirementsinsrc/typescript/server/scheme.tsvoidssupportedKindand copies only the route's ownextra, and@x402/coredoes not mergesupportedKind.extraeither. So when the Facilitator advertisesextra.workOptional: truein its SupportedKind, the flag never reaches the 402 unless the route config repeats it by hand, and the client generates work itself. The spec's Appendix says a Resource Server whose Facilitator advertisesworkOptional: trueMUST setextra.workOptional: truein PaymentRequirements.This change forwards
supportedKind.extra.workOptionalintoextrawhen it istrueand the route has not set the key (oneifinenhancePaymentRequirements, plus the JSDoc line). The new test insrc/typescript/test/unit/server.test.tsmocks a Facilitator whosegetSupportedcarriesextra: { workOptional: true }, builds the requirements for a route with noextra, and checks the result hasextra.workOptional: true; it also checks a Facilitator without the flag leavesextraas{}. The test fails on the branch tip without the source change and passes with it; the unit suite is 61 of 61. Filed at kilkelly's request in #5, item 1.🤖 Generated with Claude Code