-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
@x402/core exports two separate ResourceInfo interfaces from different entry points:
Wire format type (@x402/core/types)
typescript/packages/core/src/types/payments.ts L3-L7
Server configuration type (@x402/core/server)
typescript/packages/core/src/server/x402ResourceServer.ts L31-L35
Both are named ResourceInfo, both have url, description, and mimeType. The server version has description and mimeType as required. The wire format version currently also has them as required, but once #1154 is addressed the wire format will have them as optional per the v2 spec, creating a divergence between two identically-named interfaces.
Why this is confusing
- Importing
ResourceInfofrom the wrong entry point gives a type with different optionality - TypeScript won't flag structural compatibility issues between them since the required version is assignable to the optional version, but not vice versa
- The server version's JSDoc says "Resource information for PaymentRequired response" -- suggesting it represents the same concept as the wire format type
Possible fixes
- Have the server import and re-export from
types/payments.ts-- eliminates the duplication. Server code that constructs these values would need to handle the optional fields. - Rename the server version (e.g.,
RouteResourceInfoorResourceConfig) -- makes the distinction explicit. - Keep both but document the difference -- least disruptive but doesn't fix the naming collision.
Related
- [TypeScript] TS type fields required where v2 spec marks them optional #1154 -- TS type optionality fix that creates the divergence
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels