@@ -32,6 +32,14 @@ const server = createServer((request, response) => {
3232 return
3333 }
3434
35+ if ( request . method === 'OPTIONS' && request . url === '/nested-detail' ) {
36+ response . statusCode = 405
37+ response . setHeader ( 'allow' , 'POST' )
38+ response . setHeader ( 'content-type' , 'application/json' )
39+ response . end ( JSON . stringify ( { detail : 'Method Not Allowed' } ) )
40+ return
41+ }
42+
3543 if ( request . method === 'OPTIONS' ) {
3644 response . statusCode = 204
3745 response . setHeader ( 'access-control-allow-origin' , '*' )
@@ -970,6 +978,30 @@ data: ${JSON.stringify({
970978 return
971979 }
972980
981+ if ( request . url === '/nested-detail' ) {
982+ response . statusCode = 402
983+ response . setHeader ( 'content-type' , 'application/json' )
984+ response . end ( JSON . stringify ( {
985+ detail : {
986+ x402Version : 1 ,
987+ error : 'Payment Required' ,
988+ accepts : [ {
989+ scheme : 'exact' ,
990+ network : 'base-mainnet' ,
991+ maxAmountRequired : '500000' ,
992+ resource : `${ serverUrl } /nested-detail` ,
993+ description : 'Nested framework detail challenge' ,
994+ mimeType : 'application/json' ,
995+ payTo : '0xc174A7C8088BF271399CD3E9f88c20D37CAb967D' ,
996+ maxTimeoutSeconds : 300 ,
997+ asset : '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ,
998+ extra : { name : 'USD Coin' , version : '2' } ,
999+ } ] ,
1000+ } ,
1001+ } ) )
1002+ return
1003+ }
1004+
9731005 if ( request . url === '/mpp/descriptor-only' ) {
9741006 response . statusCode = 402
9751007 response . setHeader ( 'content-type' , 'application/json' )
@@ -1510,6 +1542,25 @@ try {
15101542 assert . match ( strictCache . stdout , / C l o u d f l a r e x 4 0 2 W o r k e r S t a r t e r / )
15111543 assert . match ( strictCache . stdout , / x 4 0 2 A t t a c k M a p 2 0 2 6 / )
15121544
1545+ const nestedDetail = await execFileAsync ( 'node' , [
1546+ 'bin/x402-surface-check.mjs' ,
1547+ '--endpoint' ,
1548+ '--method' ,
1549+ 'POST' ,
1550+ `${ serverUrl } /nested-detail` ,
1551+ '--origin' ,
1552+ 'https://example.com' ,
1553+ '--strict-cache' ,
1554+ ] , { cwd : new URL ( '..' , import . meta. url ) } )
1555+
1556+ assert . match ( nestedDetail . stdout , / d i r e c t e n d p o i n t / )
1557+ assert . match ( nestedDetail . stdout , / b a s e - m a i n n e t / )
1558+ assert . match ( nestedDetail . stdout , / \$ 0 \. 5 0 / )
1559+ assert . match ( nestedDetail . stdout , / 4 0 2 c h a l l e n g e r e s p o n s e d o e s n o t a l l o w t h e r e q u e s t i n g o r i g i n / )
1560+ assert . match ( nestedDetail . stdout , / C O R S p r e f l i g h t d o e s n o t a l l o w t h e r e q u e s t i n g o r i g i n / )
1561+ assert . match ( nestedDetail . stdout , / C O R S p r e f l i g h t d o e s n o t a l l o w a k n o w n x 4 0 2 r e t r y h e a d e r / )
1562+ assert . match ( nestedDetail . stdout , / p a y m e n t c h a l l e n g e r e s p o n s e d i d n o t e x p o s e C a c h e - C o n t r o l / )
1563+
15131564 const schemes = await execFileAsync ( 'node' , [
15141565 'bin/x402-surface-check.mjs' ,
15151566 '--endpoint' ,
0 commit comments