const https = require('https'); function httpGet(url) { return new Promise((res,rej)=>{ const u = new URL(url); https.request({ hostname:u.hostname, path:u.pathname+u.search, headers:{'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/120.0','Accept':'application/json,*/*'} }, r=>{ let d=''; r.on('data',c=>d+=c); r.on('end',()=>res({status:r.statusCode,data:d})); }).on('error',rej).end(); }); } // Now in format "2026-03-05T20:15:48" (ISO without ms/Z) function nowIso() { return new Date().toISOString().replace(/\.\d+Z$/,''); } function buildVtexGraphqlUrl(host, operationName, hash, sender, account) { const now = nowIso(); const innerVars = { where: `active=true AND ((active_from < ${now}) AND (active_to > ${now}))`, account }; const ext = { persistedQuery: {version:1, sha256Hash:hash, sender, provider:'vtex.store-graphql@2.x'}, variables: Buffer.from(JSON.stringify(innerVars)).toString('base64') }; const params = new URLSearchParams({ workspace:'master', maxAge:'short', appsEtag:'remove', domain:'store', locale:'es-AR', operationName, variables:'{}', extensions: JSON.stringify(ext) }); return `https://${host}/_v/public/graphql/v1?${params}`; } (async()=>{ // Test Carrefour console.log('=== CARREFOUR ==='); const curl = buildVtexGraphqlUrl( 'www.carrefour.com.ar', 'GetPromotions', 'cdedb2142b133164ce61b85e94287592451ebee4a2fbede815e09336d40d29ae', 'valtech.carrefourar-bank-promotions@0.x', 'carrefourar' ); const cr = await httpGet(curl); console.log('status:', cr.status, 'size:', cr.data.length); try { const d = JSON.parse(cr.data); const docs = d?.data?.documents; console.log('documents:', Array.isArray(docs) ? 'array len='+docs.length : JSON.stringify(docs).slice(0,100)); if (Array.isArray(docs) && docs.length) { console.log('first doc keys:', Object.keys(docs[0]||{}).join(', ')); console.log('first doc:', JSON.stringify(docs[0]).slice(0,500)); } if (d?.errors) console.log('errors:', JSON.stringify(d.errors).slice(0,300)); } catch(e) { console.log('parse err:', cr.data.slice(0,300)); } // Test Changomas console.log('\n=== CHANGOMAS ==='); const murl = buildVtexGraphqlUrl( 'www.masonline.com.ar', 'GetPromos', '1a071ebc5dc407a3f65e687b0f4c0a3b8d12a0c45d8d11370075c3b2a505251c', 'valtech.gdn-banks-promotions@0.x', 'masonlineprod' ); const mr = await httpGet(murl); console.log('status:', mr.status, 'size:', mr.data.length); try { const d = JSON.parse(mr.data); const docs = d?.data?.documents; console.log('documents:', Array.isArray(docs) ? 'array len='+docs.length : JSON.stringify(docs).slice(0,100)); if (Array.isArray(docs) && docs.length) { console.log('first doc keys:', Object.keys(docs[0]||{}).join(', ')); console.log('first doc:', JSON.stringify(docs[0]).slice(0,500)); } if (d?.errors) console.log('errors:', JSON.stringify(d.errors).slice(0,300)); } catch(e) { console.log('parse err:', mr.data.slice(0,300)); } // Try Disco account names console.log('\n=== DISCO account name guesses ==='); for (const an of ['jumboargentina','cencosudretail','discotiendasretail','discofresh','cencosud-disco']) { const r = await httpGet(`https://www.disco.com.ar/api/dataentities/JN/documents/bankDiscount?_fields=value,id&an=${an}&_size=3`); console.log(`an=${an}: ${r.status} size=${r.data.length} preview=${r.data.slice(0,80)}`); } })().catch(e=>console.error(e));