// Builds n8n/W5-purchase-check.json — public footer purchase/expiry webhook. // Trigger: GET /webhook/dk-purchase-check?u= // Response (JSON, CORS: https://drive.digikedai.com): // { username, known, purchases: [{product, expires_at, display_state}] } // No HMAC (key would ship client-side = theatre). Access control = CORS + // Cloudflare WAF rate-limit/Origin rule (documented in delivery guide). // Run: node n8n/gen_w5.js const fs = require('fs'); const path = require('path'); const body = fs.readFileSync(path.join(__dirname, 'w5-body.js'), 'utf8'); const workflow = { name: 'W5 - Footer Purchase Check (Public)', nodes: [ { parameters: { httpMethod: 'GET', path: 'dk-purchase-check', responseMode: 'lastNode', options: { responseCode: 200, responseHeaders: { entries: [ { name: 'Access-Control-Allow-Origin', value: 'https://drive.digikedai.com' }, { name: 'Content-Type', value: 'application/json' } ] } } }, id: 'trigger-webhook', name: 'Footer Purchase Check (Webhook)', type: 'n8n-nodes-base.webhook', typeVersion: 2, position: [0, 0], webhookId: 'dk-purchase-check' }, { parameters: { jsCode: body }, id: 'lookup', name: 'Lookup Purchases', type: 'n8n-nodes-base.code', typeVersion: 2, position: [220, 0] } ], connections: { 'Footer Purchase Check (Webhook)': { main: [[{ node: 'Lookup Purchases', type: 'main', index: 0 }]] } }, settings: { executionOrder: 'v1' }, pinData: {} }; fs.writeFileSync(path.join(__dirname, 'W5-purchase-check.json'), JSON.stringify(workflow, null, 2) + '\n'); console.log('wrote W5-purchase-check.json (' + body.length + ' chars body)');