web-agent-bridge 2.9.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +51 -0
- package/README.ar.md +79 -0
- package/README.md +104 -4
- package/package.json +2 -1
- package/public/.well-known/ai-plugin.json +28 -0
- package/public/agent-workspace.html +3 -1
- package/public/ai.html +5 -3
- package/public/api.html +412 -0
- package/public/browser.html +4 -2
- package/public/cookies.html +4 -2
- package/public/dashboard.html +5 -3
- package/public/demo.html +1770 -1
- package/public/docs.html +6 -4
- package/public/growth.html +463 -0
- package/public/index.html +982 -738
- package/public/llms-full.txt +52 -1
- package/public/llms.txt +39 -0
- package/public/login.html +6 -4
- package/public/premium-dashboard.html +7 -5
- package/public/premium.html +6 -4
- package/public/privacy.html +4 -2
- package/public/register.html +6 -4
- package/public/score.html +263 -0
- package/public/terms.html +4 -2
- package/sdk/index.js +7 -1
- package/sdk/package.json +12 -1
- package/server/index.js +427 -375
- package/server/middleware/rateLimits.js +3 -3
- package/server/migrations/006_growth_suite.sql +138 -0
- package/server/routes/agent-workspace.js +162 -0
- package/server/routes/demo-showcase.js +332 -0
- package/server/routes/discovery.js +18 -7
- package/server/routes/gateway.js +157 -0
- package/server/routes/growth.js +962 -0
- package/server/routes/runtime.js +204 -0
- package/server/routes/universal.js +9 -1
- package/server/routes/wab-api.js +16 -6
- package/server/runtime/container-worker.js +111 -0
- package/server/runtime/container.js +448 -0
- package/server/runtime/distributed-worker.js +362 -0
- package/server/runtime/index.js +21 -1
- package/server/runtime/queue.js +599 -0
- package/server/runtime/replay.js +431 -29
- package/server/runtime/scheduler.js +194 -55
- package/server/services/api-key-engine.js +261 -0
- package/server/services/lfd.js +22 -3
- package/server/services/modules/affiliate-intelligence.js +93 -0
- package/server/services/modules/agent-firewall.js +90 -0
- package/server/services/modules/bounty.js +89 -0
- package/server/services/modules/collective-bargaining.js +92 -0
- package/server/services/modules/dark-pattern.js +66 -0
- package/server/services/modules/gov-intelligence.js +45 -0
- package/server/services/modules/neural.js +55 -0
- package/server/services/modules/notary.js +49 -0
- package/server/services/modules/price-time-machine.js +86 -0
- package/server/services/modules/protocol.js +104 -0
- package/server/services/premium.js +1 -1
- package/server/services/price-intelligence.js +2 -1
- package/server/services/vision.js +2 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Affiliate Intelligence (10-affiliate-intelligence) — PUBLIC API, PRIVATE DB
|
|
3
|
+
* Detects affiliate link manipulation and cookie stuffing.
|
|
4
|
+
* API is open, detection database is closed.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
const url = require('url');
|
|
14
|
+
|
|
15
|
+
const scanStore = new Map();
|
|
16
|
+
|
|
17
|
+
let affiliateDb;
|
|
18
|
+
try { affiliateDb = require('./affiliate-db'); } catch { affiliateDb = null; }
|
|
19
|
+
|
|
20
|
+
const KNOWN_AFFILIATE_PARAMS = ['ref', 'aff', 'affiliate', 'partner', 'utm_source', 'tag', 'associate', 'clickid', 'subid', 'irclickid', 'gclid', 'fbclid'];
|
|
21
|
+
const COOKIE_STUFFING_INDICATORS = ['iframe[style*="display:none"]', 'iframe[width="0"]', 'img[src*="click"]', 'img[width="1"][height="1"]'];
|
|
22
|
+
|
|
23
|
+
function createRouter(express) {
|
|
24
|
+
const router = express.Router();
|
|
25
|
+
|
|
26
|
+
router.post('/scan-url', (req, res) => {
|
|
27
|
+
const { target_url } = req.body;
|
|
28
|
+
if (!target_url) return res.status(400).json({ error: 'target_url required' });
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const parsed = new URL(target_url);
|
|
32
|
+
const affiliateParams = [];
|
|
33
|
+
for (const [key, value] of parsed.searchParams) {
|
|
34
|
+
if (KNOWN_AFFILIATE_PARAMS.includes(key.toLowerCase())) {
|
|
35
|
+
affiliateParams.push({ param: key, value, type: 'affiliate_tracking' });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const hasRedirect = /\/(click|go|redirect|track|aff|out)\//i.test(parsed.pathname);
|
|
40
|
+
let manipulation = null;
|
|
41
|
+
if (affiliateDb) {
|
|
42
|
+
manipulation = affiliateDb.checkManipulation(target_url, affiliateParams);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const scanId = 'ASCAN-' + crypto.randomBytes(6).toString('hex').toUpperCase();
|
|
46
|
+
const result = {
|
|
47
|
+
scan_id: scanId, url: target_url, hostname: parsed.hostname,
|
|
48
|
+
affiliate_params: affiliateParams, has_affiliate: affiliateParams.length > 0,
|
|
49
|
+
has_redirect_chain: hasRedirect, manipulation_detected: manipulation,
|
|
50
|
+
risk_level: affiliateParams.length > 2 ? 'HIGH' : affiliateParams.length > 0 ? 'MEDIUM' : 'LOW',
|
|
51
|
+
scanned_at: new Date().toISOString(),
|
|
52
|
+
};
|
|
53
|
+
scanStore.set(scanId, result);
|
|
54
|
+
res.json(result);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
res.status(400).json({ error: 'Invalid URL: ' + e.message });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
router.post('/scan-html', (req, res) => {
|
|
61
|
+
const { html, page_url } = req.body;
|
|
62
|
+
if (!html) return res.status(400).json({ error: 'html content required' });
|
|
63
|
+
|
|
64
|
+
const findings = [];
|
|
65
|
+
for (const indicator of COOKIE_STUFFING_INDICATORS) {
|
|
66
|
+
const tag = indicator.split('[')[0];
|
|
67
|
+
const attrMatch = indicator.match(/\[([^\]]+)\]/g) || [];
|
|
68
|
+
if (new RegExp(`<${tag}[^>]*${attrMatch.map(a => a.slice(1, -1).replace('*', '.*')).join('[^>]*')}`, 'gi').test(html)) {
|
|
69
|
+
findings.push({ type: 'COOKIE_STUFFING', indicator, severity: 'HIGH' });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const hiddenIframes = (html.match(/<iframe[^>]*(?:display\s*:\s*none|width\s*=\s*["']?0|height\s*=\s*["']?0)[^>]*>/gi) || []).length;
|
|
74
|
+
const trackingPixels = (html.match(/<img[^>]*(?:width\s*=\s*["']?1["']?\s+height\s*=\s*["']?1|height\s*=\s*["']?1["']?\s+width\s*=\s*["']?1)[^>]*>/gi) || []).length;
|
|
75
|
+
|
|
76
|
+
res.json({
|
|
77
|
+
page_url: page_url || 'unknown', cookie_stuffing_indicators: findings,
|
|
78
|
+
hidden_iframes: hiddenIframes, tracking_pixels: trackingPixels,
|
|
79
|
+
risk_level: findings.length > 0 || hiddenIframes > 2 ? 'HIGH' : trackingPixels > 5 ? 'MEDIUM' : 'LOW',
|
|
80
|
+
scanned_at: new Date().toISOString(),
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
router.get('/stats', (req, res) => {
|
|
85
|
+
let high = 0, manipulations = 0;
|
|
86
|
+
for (const s of scanStore.values()) { if (s.risk_level === 'HIGH') high++; if (s.manipulation_detected) manipulations++; }
|
|
87
|
+
res.json({ total_scans: scanStore.size, high_risk: high, manipulations_detected: manipulations });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return router;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Agent Firewall (01-agent-firewall) — PUBLIC API, PRIVATE DETECTION LOGIC
|
|
3
|
+
* Scans URLs and content for prompt injections, phishing, and dark patterns.
|
|
4
|
+
* API is open, deep detection rules are closed.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
|
|
14
|
+
const BASIC_THREATS = [
|
|
15
|
+
/ignore\s+(all\s+)?previous\s+instructions/gi,
|
|
16
|
+
/you\s+are\s+now\s+in\s+developer\s+mode/gi,
|
|
17
|
+
/disregard\s+(your\s+)?(prior\s+|previous\s+)?instructions/gi,
|
|
18
|
+
/<\s*script[^>]*>.*?<\/\s*script\s*>/gis,
|
|
19
|
+
/transfer\s+\$?\d+.*?to\s+(?:wallet|account|address)/gi,
|
|
20
|
+
/data:text\/html.*base64/gi,
|
|
21
|
+
/javascript:void/gi,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const MALICIOUS_DOMAINS = new Set([
|
|
25
|
+
'paypa1.com', 'amaz0n.com', 'g00gle.com', 'faceb00k.com',
|
|
26
|
+
'secure-paypal-login.com', 'amazon-security-alert.com',
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
let deepDetection;
|
|
30
|
+
try { deepDetection = require('./firewall-engine'); } catch { deepDetection = null; }
|
|
31
|
+
|
|
32
|
+
const scanLog = [];
|
|
33
|
+
|
|
34
|
+
function createRouter(express) {
|
|
35
|
+
const router = express.Router();
|
|
36
|
+
|
|
37
|
+
router.post('/scan', (req, res) => {
|
|
38
|
+
const { url: targetUrl, content, agent_id } = req.body;
|
|
39
|
+
const startTime = Date.now();
|
|
40
|
+
|
|
41
|
+
const urlThreats = [];
|
|
42
|
+
const contentThreats = [];
|
|
43
|
+
let riskScore = 0;
|
|
44
|
+
|
|
45
|
+
if (targetUrl) {
|
|
46
|
+
try {
|
|
47
|
+
const parsed = new URL(targetUrl);
|
|
48
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
49
|
+
if (MALICIOUS_DOMAINS.has(hostname)) { urlThreats.push({ type: 'MALICIOUS_DOMAIN', severity: 'CRITICAL', detail: hostname }); riskScore += 40; }
|
|
50
|
+
if (/[^\x00-\x7F]/.test(hostname)) { urlThreats.push({ type: 'HOMOGRAPH_ATTACK', severity: 'HIGH', detail: hostname }); riskScore += 25; }
|
|
51
|
+
if (/(?:password|token|apikey|secret)=/i.test(targetUrl)) { urlThreats.push({ type: 'DATA_EXFILTRATION', severity: 'HIGH', detail: 'Sensitive params in URL' }); riskScore += 25; }
|
|
52
|
+
} catch { urlThreats.push({ type: 'INVALID_URL', severity: 'LOW' }); }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (content && typeof content === 'string') {
|
|
56
|
+
for (const pattern of BASIC_THREATS) {
|
|
57
|
+
const matches = content.match(pattern);
|
|
58
|
+
if (matches) { contentThreats.push({ type: 'PROMPT_INJECTION', matches: matches.slice(0, 3), count: matches.length }); riskScore += 30; }
|
|
59
|
+
}
|
|
60
|
+
if (deepDetection) {
|
|
61
|
+
const deep = deepDetection.analyze(content, targetUrl);
|
|
62
|
+
contentThreats.push(...(deep.threats || []));
|
|
63
|
+
riskScore += deep.score || 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
riskScore = Math.min(100, riskScore);
|
|
68
|
+
const verdict = riskScore === 0 ? 'CLEAN' : riskScore > 50 ? 'BLOCKED' : 'WARNING';
|
|
69
|
+
const scanId = crypto.randomBytes(8).toString('hex');
|
|
70
|
+
|
|
71
|
+
scanLog.push({ scan_id: scanId, url: targetUrl, verdict, risk_score: riskScore, timestamp: new Date().toISOString() });
|
|
72
|
+
if (scanLog.length > 5000) scanLog.splice(0, scanLog.length - 5000);
|
|
73
|
+
|
|
74
|
+
res.json({
|
|
75
|
+
scan_id: scanId, verdict, risk_score: riskScore,
|
|
76
|
+
url_threats: urlThreats, content_threats: contentThreats,
|
|
77
|
+
processing_time_ms: Date.now() - startTime, scanned_at: new Date().toISOString(),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
router.get('/stats', (req, res) => {
|
|
82
|
+
let blocked = 0, warnings = 0;
|
|
83
|
+
for (const s of scanLog) { if (s.verdict === 'BLOCKED') blocked++; if (s.verdict === 'WARNING') warnings++; }
|
|
84
|
+
res.json({ total_scans: scanLog.length, blocked, warnings, clean: scanLog.length - blocked - warnings });
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return router;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Bounty Network (09-bounty-network) — PUBLIC API, PRIVATE VERIFICATION RULES
|
|
3
|
+
* Bug bounty and threat reporting network.
|
|
4
|
+
* Report interface is open, verification rules are closed.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
|
|
14
|
+
const reportStore = new Map();
|
|
15
|
+
const rewardStore = new Map();
|
|
16
|
+
|
|
17
|
+
const CATEGORIES = ['dark_pattern', 'price_manipulation', 'fake_reviews', 'hidden_fees', 'data_harvesting', 'accessibility_violation', 'misleading_ads', 'forced_subscription'];
|
|
18
|
+
const SEVERITY_REWARDS = { LOW: 10, MEDIUM: 50, HIGH: 200, CRITICAL: 500 };
|
|
19
|
+
|
|
20
|
+
let verifyReport;
|
|
21
|
+
try { verifyReport = require('./bounty-verification'); } catch { verifyReport = null; }
|
|
22
|
+
|
|
23
|
+
function createRouter(express) {
|
|
24
|
+
const router = express.Router();
|
|
25
|
+
|
|
26
|
+
router.post('/report', (req, res) => {
|
|
27
|
+
const { platform, url: targetUrl, category, description, evidence_html, reporter_token } = req.body;
|
|
28
|
+
if (!platform || !targetUrl || !category || !description) {
|
|
29
|
+
return res.status(400).json({ error: 'platform, url, category, and description required' });
|
|
30
|
+
}
|
|
31
|
+
if (!CATEGORIES.includes(category)) {
|
|
32
|
+
return res.status(400).json({ error: `Invalid category. Valid: ${CATEGORIES.join(', ')}` });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const reportId = 'RPT-' + crypto.randomBytes(8).toString('hex').toUpperCase();
|
|
36
|
+
const reporterHash = crypto.createHmac('sha256', process.env.WAB_SECRET || 'wab-bounty-salt')
|
|
37
|
+
.update(reporter_token || crypto.randomBytes(16).toString('hex')).digest('hex').substring(0, 16);
|
|
38
|
+
|
|
39
|
+
const report = {
|
|
40
|
+
report_id: reportId, platform, url: targetUrl, category, description,
|
|
41
|
+
reporter_hash: reporterHash, severity: null, reward_usd: 0,
|
|
42
|
+
status: 'SUBMITTED', submitted_at: new Date().toISOString(),
|
|
43
|
+
verified: false, verification_notes: null,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (verifyReport) {
|
|
47
|
+
const verification = verifyReport(report, evidence_html);
|
|
48
|
+
report.severity = verification.severity;
|
|
49
|
+
report.verified = verification.verified;
|
|
50
|
+
report.reward_usd = verification.verified ? (SEVERITY_REWARDS[verification.severity] || 0) : 0;
|
|
51
|
+
report.status = verification.verified ? 'VERIFIED' : 'PENDING_REVIEW';
|
|
52
|
+
} else {
|
|
53
|
+
report.status = 'PENDING_REVIEW';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
reportStore.set(reportId, report);
|
|
57
|
+
res.status(201).json(report);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
router.get('/report/:id', (req, res) => {
|
|
61
|
+
const report = reportStore.get(req.params.id);
|
|
62
|
+
if (!report) return res.status(404).json({ error: 'Report not found' });
|
|
63
|
+
res.json(report);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
router.get('/categories', (req, res) => {
|
|
67
|
+
res.json({ categories: CATEGORIES, severity_rewards_usd: SEVERITY_REWARDS });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
router.get('/leaderboard', (req, res) => {
|
|
71
|
+
const reporters = {};
|
|
72
|
+
for (const r of reportStore.values()) {
|
|
73
|
+
if (r.verified) { reporters[r.reporter_hash] = (reporters[r.reporter_hash] || 0) + r.reward_usd; }
|
|
74
|
+
}
|
|
75
|
+
const leaderboard = Object.entries(reporters).map(([hash, total]) => ({ reporter_hash: hash, total_rewards_usd: total }))
|
|
76
|
+
.sort((a, b) => b.total_rewards_usd - a.total_rewards_usd).slice(0, 20);
|
|
77
|
+
res.json({ leaderboard });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
router.get('/stats', (req, res) => {
|
|
81
|
+
let verified = 0, totalReward = 0;
|
|
82
|
+
for (const r of reportStore.values()) { if (r.verified) { verified++; totalReward += r.reward_usd; } }
|
|
83
|
+
res.json({ total_reports: reportStore.size, verified_reports: verified, total_rewards_usd: totalReward, categories: CATEGORIES.length });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return router;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Collective Bargaining (04-collective-bargaining) — PUBLIC JOIN API, PRIVATE MATCHING ENGINE
|
|
3
|
+
* Groups buyers to negotiate bulk discounts.
|
|
4
|
+
* Join interface is open, matching engine is closed.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
|
|
14
|
+
const demandPools = new Map();
|
|
15
|
+
const NEGOTIATION_THRESHOLDS = {
|
|
16
|
+
electronics: { minBuyers: 10, targetDiscount: 0.15 },
|
|
17
|
+
travel: { minBuyers: 5, targetDiscount: 0.20 },
|
|
18
|
+
fashion: { minBuyers: 20, targetDiscount: 0.25 },
|
|
19
|
+
software: { minBuyers: 50, targetDiscount: 0.30 },
|
|
20
|
+
default: { minBuyers: 15, targetDiscount: 0.15 },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let matchingEngine;
|
|
24
|
+
try { matchingEngine = require('./bargaining-engine'); } catch { matchingEngine = null; }
|
|
25
|
+
|
|
26
|
+
function createRouter(express) {
|
|
27
|
+
const router = express.Router();
|
|
28
|
+
|
|
29
|
+
router.post('/join', (req, res) => {
|
|
30
|
+
const { platform, product_id, product_name, category, current_price, currency, max_price } = req.body;
|
|
31
|
+
if (!platform || !product_id || !current_price) {
|
|
32
|
+
return res.status(400).json({ error: 'platform, product_id, and current_price required' });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const poolKey = `${platform}:${product_id}`;
|
|
36
|
+
if (!demandPools.has(poolKey)) {
|
|
37
|
+
const cat = category || 'default';
|
|
38
|
+
const threshold = NEGOTIATION_THRESHOLDS[cat] || NEGOTIATION_THRESHOLDS.default;
|
|
39
|
+
demandPools.set(poolKey, {
|
|
40
|
+
id: 'POOL-' + crypto.randomBytes(8).toString('hex').toUpperCase(),
|
|
41
|
+
platform, product_id, product_name: product_name || product_id,
|
|
42
|
+
category: cat, current_price: parseFloat(current_price), currency: currency || 'USD',
|
|
43
|
+
target_price: parseFloat((current_price * (1 - threshold.targetDiscount)).toFixed(2)),
|
|
44
|
+
target_discount_pct: Math.round(threshold.targetDiscount * 100),
|
|
45
|
+
min_buyers: threshold.minBuyers, members: 0, status: 'OPEN',
|
|
46
|
+
created_at: new Date().toISOString(),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const pool = demandPools.get(poolKey);
|
|
51
|
+
if (pool.status !== 'OPEN') return res.status(400).json({ error: 'Pool is not open' });
|
|
52
|
+
pool.members++;
|
|
53
|
+
|
|
54
|
+
if (matchingEngine && pool.members >= pool.min_buyers) {
|
|
55
|
+
const deal = matchingEngine.negotiate(pool);
|
|
56
|
+
pool.status = deal ? 'DEAL_REACHED' : 'NEGOTIATING';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
res.json({
|
|
60
|
+
success: true, pool_id: pool.id, member_count: pool.members, status: pool.status,
|
|
61
|
+
progress_pct: Math.min(100, Math.round(pool.members / pool.min_buyers * 100)),
|
|
62
|
+
members_needed: Math.max(0, pool.min_buyers - pool.members),
|
|
63
|
+
target_price: pool.target_price, target_discount_pct: pool.target_discount_pct,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
router.get('/pools', (req, res) => {
|
|
68
|
+
const pools = Array.from(demandPools.values()).map(p => ({
|
|
69
|
+
pool_id: p.id, platform: p.platform, product_name: p.product_name,
|
|
70
|
+
current_price: p.current_price, target_price: p.target_price,
|
|
71
|
+
members: p.members, min_buyers: p.min_buyers, status: p.status,
|
|
72
|
+
progress_pct: Math.min(100, Math.round(p.members / p.min_buyers * 100)),
|
|
73
|
+
}));
|
|
74
|
+
res.json({ total: pools.length, pools: pools.filter(p => p.status === 'OPEN').slice(0, 50) });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
router.get('/pool/:id', (req, res) => {
|
|
78
|
+
const pool = Array.from(demandPools.values()).find(p => p.id === req.params.id);
|
|
79
|
+
if (!pool) return res.status(404).json({ error: 'Pool not found' });
|
|
80
|
+
res.json(pool);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
router.get('/stats', (req, res) => {
|
|
84
|
+
let totalMembers = 0, activePoolsCount = 0;
|
|
85
|
+
for (const p of demandPools.values()) { totalMembers += p.members; if (p.status === 'OPEN') activePoolsCount++; }
|
|
86
|
+
res.json({ total_pools: demandPools.size, active_pools: activePoolsCount, total_participants: totalMembers });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return router;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Dark Pattern Detector (03-dark-pattern) — FULLY CLOSED
|
|
3
|
+
* DSA compliance engine detects all 17 OECD dark patterns.
|
|
4
|
+
* All detection rules are proprietary.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
let darkPatternEngine;
|
|
13
|
+
try { darkPatternEngine = require('./dark-pattern-engine'); } catch { darkPatternEngine = null; }
|
|
14
|
+
|
|
15
|
+
function createRouter(express) {
|
|
16
|
+
const router = express.Router();
|
|
17
|
+
|
|
18
|
+
router.post('/audit', async (req, res) => {
|
|
19
|
+
const { url: targetUrl } = req.body;
|
|
20
|
+
if (!targetUrl) return res.status(400).json({ error: 'url required' });
|
|
21
|
+
if (!darkPatternEngine) return res.status(503).json({ error: 'Dark pattern engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
22
|
+
try {
|
|
23
|
+
const report = await darkPatternEngine.generateReport(targetUrl);
|
|
24
|
+
res.json(report);
|
|
25
|
+
} catch (e) { res.status(500).json({ error: e.message }); }
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
router.post('/scan', (req, res) => {
|
|
29
|
+
const { html, page_url } = req.body;
|
|
30
|
+
if (!html) return res.status(400).json({ error: 'html content required' });
|
|
31
|
+
if (!darkPatternEngine) return res.status(503).json({ error: 'Dark pattern engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
32
|
+
const result = darkPatternEngine.scanContent(html, page_url);
|
|
33
|
+
res.json(result);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
router.get('/patterns', (req, res) => {
|
|
37
|
+
res.json({ total: 17, categories: [
|
|
38
|
+
{ id: 'DP001', name: 'False Urgency', severity: 'HIGH', dsa_article: 'Article 25(1)(a)' },
|
|
39
|
+
{ id: 'DP002', name: 'Scarcity Manipulation', severity: 'HIGH', dsa_article: 'Article 25(1)(a)' },
|
|
40
|
+
{ id: 'DP003', name: 'Hidden Costs', severity: 'CRITICAL', dsa_article: 'Article 25(1)(b)' },
|
|
41
|
+
{ id: 'DP004', name: 'Trick Question', severity: 'HIGH', dsa_article: 'Article 25(1)(c)' },
|
|
42
|
+
{ id: 'DP005', name: 'Roach Motel', severity: 'CRITICAL', dsa_article: 'Article 25(1)(d)' },
|
|
43
|
+
{ id: 'DP006', name: 'Confirmshaming', severity: 'MEDIUM', dsa_article: 'Article 25(1)(a)' },
|
|
44
|
+
{ id: 'DP007', name: 'Forced Continuity', severity: 'CRITICAL', dsa_article: 'Article 25(1)(b)' },
|
|
45
|
+
{ id: 'DP008', name: 'Misdirection', severity: 'MEDIUM', dsa_article: 'Article 25(1)(a)' },
|
|
46
|
+
{ id: 'DP009', name: 'Disguised Ads', severity: 'HIGH', dsa_article: 'Article 26' },
|
|
47
|
+
{ id: 'DP010', name: 'Nagging', severity: 'LOW', dsa_article: 'Article 25(1)(a)' },
|
|
48
|
+
{ id: 'DP011', name: 'Basket Sneaking', severity: 'CRITICAL', dsa_article: 'Article 25(1)(b)' },
|
|
49
|
+
{ id: 'DP012', name: 'Bait and Switch', severity: 'CRITICAL', dsa_article: 'Article 25(1)(b)' },
|
|
50
|
+
{ id: 'DP013', name: 'Privacy Zuckering', severity: 'HIGH', dsa_article: 'Article 25(1)(c)' },
|
|
51
|
+
{ id: 'DP014', name: 'Fake Social Proof', severity: 'HIGH', dsa_article: 'Article 25(1)(a)' },
|
|
52
|
+
{ id: 'DP015', name: 'Interface Interference', severity: 'MEDIUM', dsa_article: 'Article 25(1)(a)' },
|
|
53
|
+
{ id: 'DP016', name: 'Drip Pricing', severity: 'HIGH', dsa_article: 'Article 25(1)(b)' },
|
|
54
|
+
{ id: 'DP017', name: 'Disguised Subscription', severity: 'CRITICAL', dsa_article: 'Article 25(1)(b)' },
|
|
55
|
+
]});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
router.get('/stats', (req, res) => {
|
|
59
|
+
if (!darkPatternEngine) return res.json({ status: 'engine_not_loaded', patterns_tracked: 17 });
|
|
60
|
+
res.json(darkPatternEngine.getStats());
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return router;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Gov Intelligence (05-gov-intelligence) — FULLY CLOSED
|
|
3
|
+
* Regulatory compliance and government intelligence database.
|
|
4
|
+
* All data and logic is proprietary.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
let govEngine;
|
|
13
|
+
try { govEngine = require('./gov-engine'); } catch { govEngine = null; }
|
|
14
|
+
|
|
15
|
+
function createRouter(express) {
|
|
16
|
+
const router = express.Router();
|
|
17
|
+
|
|
18
|
+
router.get('/check/:domain', (req, res) => {
|
|
19
|
+
if (!govEngine) return res.status(503).json({ error: 'Gov intelligence engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
20
|
+
const result = govEngine.checkDomain(req.params.domain);
|
|
21
|
+
res.json(result);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
router.get('/regulations', (req, res) => {
|
|
25
|
+
const { country, sector } = req.query;
|
|
26
|
+
if (!govEngine) return res.status(503).json({ error: 'Gov intelligence engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
27
|
+
res.json(govEngine.getRegulations(country, sector));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
router.post('/compliance-report', (req, res) => {
|
|
31
|
+
const { domain, country } = req.body;
|
|
32
|
+
if (!domain) return res.status(400).json({ error: 'domain required' });
|
|
33
|
+
if (!govEngine) return res.status(503).json({ error: 'Gov intelligence engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
34
|
+
res.json(govEngine.generateComplianceReport(domain, country));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
router.get('/stats', (req, res) => {
|
|
38
|
+
if (!govEngine) return res.json({ status: 'offline' });
|
|
39
|
+
res.json(govEngine.getStats());
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return router;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Neural Engine (07-neural) — FULLY CLOSED
|
|
3
|
+
* Local AI inference engine. All logic is proprietary.
|
|
4
|
+
* Only the API interface is exposed here.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
let neuralEngine;
|
|
13
|
+
try { neuralEngine = require('./neural-engine'); } catch { neuralEngine = null; }
|
|
14
|
+
|
|
15
|
+
function createRouter(express) {
|
|
16
|
+
const router = express.Router();
|
|
17
|
+
|
|
18
|
+
router.post('/analyze-url', (req, res) => {
|
|
19
|
+
const { url: targetUrl } = req.body;
|
|
20
|
+
if (!targetUrl) return res.status(400).json({ error: 'url required' });
|
|
21
|
+
if (!neuralEngine) return res.status(503).json({ error: 'Neural engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
22
|
+
const result = neuralEngine.analyzeUrl(targetUrl);
|
|
23
|
+
res.json(result);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
router.post('/classify', (req, res) => {
|
|
27
|
+
const { content, categories } = req.body;
|
|
28
|
+
if (!content) return res.status(400).json({ error: 'content required' });
|
|
29
|
+
if (!neuralEngine) return res.status(503).json({ error: 'Neural engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
30
|
+
const result = neuralEngine.classify(content, categories);
|
|
31
|
+
res.json(result);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
router.post('/embeddings', (req, res) => {
|
|
35
|
+
const { text } = req.body;
|
|
36
|
+
if (!text) return res.status(400).json({ error: 'text required' });
|
|
37
|
+
if (!neuralEngine) return res.status(503).json({ error: 'Neural engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
38
|
+
const result = neuralEngine.embed(text);
|
|
39
|
+
res.json(result);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
router.get('/models', (req, res) => {
|
|
43
|
+
if (!neuralEngine) return res.json({ models: [], message: 'Neural engine not loaded' });
|
|
44
|
+
res.json(neuralEngine.listModels());
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
router.get('/stats', (req, res) => {
|
|
48
|
+
if (!neuralEngine) return res.json({ status: 'offline' });
|
|
49
|
+
res.json(neuralEngine.getStats());
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return router;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Notary (02-notary) — FULLY CLOSED
|
|
3
|
+
* Cryptographic certificate system for price discrimination evidence.
|
|
4
|
+
* Signing algorithm is proprietary.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
let notaryEngine;
|
|
13
|
+
try { notaryEngine = require('./notary-engine'); } catch { notaryEngine = null; }
|
|
14
|
+
|
|
15
|
+
function createRouter(express) {
|
|
16
|
+
const router = express.Router();
|
|
17
|
+
|
|
18
|
+
router.post('/price', (req, res) => {
|
|
19
|
+
const { platform, productId, priceShown } = req.body;
|
|
20
|
+
if (!platform || !productId || priceShown === undefined) {
|
|
21
|
+
return res.status(400).json({ error: 'platform, productId, and priceShown required' });
|
|
22
|
+
}
|
|
23
|
+
if (!notaryEngine) return res.status(503).json({ error: 'Notary engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
24
|
+
const cert = notaryEngine.issuePriceCertificate(req.body);
|
|
25
|
+
res.status(201).json(cert);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
router.post('/transaction', (req, res) => {
|
|
29
|
+
if (!notaryEngine) return res.status(503).json({ error: 'Notary engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
30
|
+
const cert = notaryEngine.issueTransactionCertificate(req.body);
|
|
31
|
+
res.status(201).json(cert);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
router.get('/verify/:certId', (req, res) => {
|
|
35
|
+
if (!notaryEngine) return res.status(503).json({ error: 'Notary engine not available', code: 'MODULE_UNAVAILABLE' });
|
|
36
|
+
const result = notaryEngine.verifyCertificate(req.params.certId);
|
|
37
|
+
if (!result) return res.status(404).json({ error: 'Certificate not found' });
|
|
38
|
+
res.json(result);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
router.get('/stats', (req, res) => {
|
|
42
|
+
if (!notaryEngine) return res.json({ status: 'offline' });
|
|
43
|
+
res.json(notaryEngine.getStats());
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return router;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = { createRouter };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAB Price Time Machine (06-price-time-machine) — PUBLIC API, PRIVATE ENGINE
|
|
3
|
+
* Historical price tracking and fake discount detection.
|
|
4
|
+
* API is open, database and detection algorithm are closed.
|
|
5
|
+
*
|
|
6
|
+
* Powered by WAB — Web Agent Bridge
|
|
7
|
+
* https://www.webagentbridge.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
|
|
14
|
+
const priceStore = new Map();
|
|
15
|
+
const alertStore = new Map();
|
|
16
|
+
|
|
17
|
+
let priceEngine;
|
|
18
|
+
try { priceEngine = require('./price-engine'); } catch { priceEngine = null; }
|
|
19
|
+
|
|
20
|
+
function createRouter(express) {
|
|
21
|
+
const router = express.Router();
|
|
22
|
+
|
|
23
|
+
router.post('/track', (req, res) => {
|
|
24
|
+
const { platform, product_id, product_name, price, currency, url: productUrl } = req.body;
|
|
25
|
+
if (!platform || !product_id || price === undefined) {
|
|
26
|
+
return res.status(400).json({ error: 'platform, product_id, and price are required' });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const key = `${platform}:${product_id}`;
|
|
30
|
+
if (!priceStore.has(key)) priceStore.set(key, { entries: [], metadata: { platform, product_id, product_name, currency: currency || 'USD', url: productUrl } });
|
|
31
|
+
const record = priceStore.get(key);
|
|
32
|
+
record.entries.push({ price: parseFloat(price), timestamp: Date.now(), date: new Date().toISOString() });
|
|
33
|
+
if (record.entries.length > 5000) record.entries.splice(0, record.entries.length - 5000);
|
|
34
|
+
|
|
35
|
+
const prices = record.entries.map(e => e.price);
|
|
36
|
+
const avg = prices.reduce((a, b) => a + b, 0) / prices.length;
|
|
37
|
+
const min = Math.min(...prices);
|
|
38
|
+
const max = Math.max(...prices);
|
|
39
|
+
|
|
40
|
+
let fakeDiscount = null;
|
|
41
|
+
if (priceEngine) {
|
|
42
|
+
fakeDiscount = priceEngine.detectFakeDiscount(record.entries);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
res.json({
|
|
46
|
+
tracked: true, product_id, platform, current_price: price, data_points: record.entries.length,
|
|
47
|
+
statistics: { average: parseFloat(avg.toFixed(2)), min, max, range_pct: parseFloat(((max - min) / avg * 100).toFixed(1)) },
|
|
48
|
+
fake_discount: fakeDiscount,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
router.get('/history/:platform/:productId', (req, res) => {
|
|
53
|
+
const key = `${req.params.platform}:${req.params.productId}`;
|
|
54
|
+
const record = priceStore.get(key);
|
|
55
|
+
if (!record) return res.status(404).json({ error: 'No price history for this product' });
|
|
56
|
+
const days = parseInt(req.query.days) || 30;
|
|
57
|
+
const cutoff = Date.now() - days * 86400000;
|
|
58
|
+
const filtered = record.entries.filter(e => e.timestamp >= cutoff);
|
|
59
|
+
res.json({ ...record.metadata, period_days: days, data_points: filtered.length, history: filtered });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
router.get('/compare', (req, res) => {
|
|
63
|
+
const { product_name } = req.query;
|
|
64
|
+
if (!product_name) return res.status(400).json({ error: 'product_name query param required' });
|
|
65
|
+
const results = [];
|
|
66
|
+
const search = product_name.toLowerCase();
|
|
67
|
+
for (const [key, record] of priceStore) {
|
|
68
|
+
if (record.metadata.product_name && record.metadata.product_name.toLowerCase().includes(search)) {
|
|
69
|
+
const prices = record.entries.map(e => e.price);
|
|
70
|
+
results.push({ platform: record.metadata.platform, product_id: record.metadata.product_id, product_name: record.metadata.product_name,
|
|
71
|
+
current_price: prices[prices.length - 1], lowest_price: Math.min(...prices), highest_price: Math.max(...prices), data_points: prices.length });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
res.json({ query: product_name, results: results.sort((a, b) => a.current_price - b.current_price) });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
router.get('/stats', (req, res) => {
|
|
78
|
+
let totalPoints = 0;
|
|
79
|
+
for (const r of priceStore.values()) totalPoints += r.entries.length;
|
|
80
|
+
res.json({ products_tracked: priceStore.size, total_data_points: totalPoints, alerts_active: alertStore.size });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return router;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { createRouter };
|