web-agent-bridge 3.2.0 → 3.4.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 +84 -72
- package/README.ar.md +1304 -1152
- package/README.md +298 -1635
- package/bin/agent-runner.js +474 -474
- package/bin/cli.js +237 -138
- package/bin/wab-init.js +223 -0
- package/bin/wab.js +80 -80
- package/examples/azure-dns-wab.js +83 -0
- package/examples/bidi-agent.js +119 -119
- package/examples/cloudflare-wab-dns.js +121 -0
- package/examples/cpanel-wab-dns.js +114 -0
- package/examples/cross-site-agent.js +91 -91
- package/examples/dns-discovery-agent.js +166 -0
- package/examples/gcp-dns-wab.js +76 -0
- package/examples/governance-agent.js +169 -0
- package/examples/mcp-agent.js +94 -94
- package/examples/next-app-router/README.md +44 -44
- package/examples/plesk-wab-dns.js +103 -0
- package/examples/puppeteer-agent.js +108 -108
- package/examples/route53-wab-dns.js +144 -0
- package/examples/saas-dashboard/README.md +55 -55
- package/examples/safe-mode-agent.js +96 -0
- package/examples/shopify-hydrogen/README.md +74 -74
- package/examples/vision-agent.js +171 -171
- package/examples/wab-sign.js +74 -0
- package/examples/wab-verify.js +60 -0
- package/examples/wordpress-elementor/README.md +77 -77
- package/package.json +19 -6
- package/public/.well-known/agent-tools.json +180 -180
- package/public/.well-known/ai-assets.json +59 -59
- package/public/.well-known/security.txt +8 -0
- package/public/.well-known/wab.json +28 -0
- package/public/activate.html +368 -0
- package/public/adoption-metrics.html +188 -0
- package/public/agent-workspace.html +349 -349
- package/public/ai.html +198 -198
- package/public/api.html +413 -412
- package/public/azure-dns-integration.html +289 -0
- package/public/browser.html +486 -486
- package/public/cloudflare-integration.html +380 -0
- package/public/commander-dashboard.html +243 -243
- package/public/cookies.html +210 -210
- package/public/cpanel-integration.html +398 -0
- package/public/css/agent-workspace.css +1713 -1713
- package/public/css/premium.css +317 -317
- package/public/css/styles.css +1263 -1235
- package/public/dashboard.html +707 -706
- package/public/dns.html +436 -0
- package/public/docs.html +588 -587
- package/public/feed.xml +89 -89
- package/public/gcp-dns-integration.html +318 -0
- package/public/growth.html +465 -463
- package/public/index.html +1266 -982
- package/public/integrations.html +556 -0
- package/public/js/activate.js +145 -0
- package/public/js/agent-workspace.js +1740 -1740
- package/public/js/auth-nav.js +65 -31
- package/public/js/auth-redirect.js +12 -12
- package/public/js/cookie-consent.js +56 -56
- package/public/js/dns.js +438 -0
- package/public/js/wab-demo-page.js +721 -721
- package/public/js/ws-client.js +74 -74
- package/public/llms-full.txt +360 -360
- package/public/llms.txt +125 -125
- package/public/login.html +85 -85
- package/public/mesh-dashboard.html +328 -328
- package/public/openapi.json +669 -580
- package/public/phone-shield.html +281 -0
- package/public/plesk-integration.html +375 -0
- package/public/premium-dashboard.html +2489 -2489
- package/public/premium.html +793 -793
- package/public/privacy.html +297 -297
- package/public/provider-onboarding.html +172 -0
- package/public/provider-sandbox.html +134 -0
- package/public/providers.html +359 -0
- package/public/register.html +105 -105
- package/public/registrar-integrations.html +141 -0
- package/public/robots.txt +99 -87
- package/public/route53-integration.html +531 -0
- package/public/script/wab-consent.d.ts +36 -36
- package/public/script/wab-consent.js +104 -104
- package/public/script/wab-schema.js +131 -131
- package/public/script/wab.d.ts +108 -108
- package/public/script/wab.min.js +580 -580
- package/public/security.txt +8 -0
- package/public/shieldqr.html +231 -0
- package/public/sitemap.xml +6 -0
- package/public/terms.html +256 -256
- package/public/wab-trust.html +200 -0
- package/public/wab-vs-protocols.html +210 -0
- package/public/whitepaper.html +449 -0
- package/script/ai-agent-bridge.js +1754 -1754
- package/sdk/README.md +99 -99
- package/sdk/agent-mesh.js +449 -449
- package/sdk/auto-discovery.js +288 -0
- package/sdk/commander.js +262 -262
- package/sdk/governance.js +262 -0
- package/sdk/index.d.ts +464 -464
- package/sdk/index.js +25 -1
- package/sdk/multi-agent.js +318 -318
- package/sdk/package.json +2 -2
- package/sdk/safe-mode.js +221 -0
- package/sdk/safety-shield.js +219 -0
- package/sdk/schema-discovery.js +83 -83
- package/server/adapters/index.js +520 -520
- package/server/config/plans.js +367 -367
- package/server/config/secrets.js +102 -102
- package/server/control-plane/index.js +301 -301
- package/server/data-plane/index.js +354 -354
- package/server/index.js +670 -427
- package/server/llm/index.js +404 -404
- package/server/middleware/adminAuth.js +35 -35
- package/server/middleware/auth.js +50 -50
- package/server/middleware/featureGate.js +88 -88
- package/server/middleware/rateLimits.js +100 -100
- package/server/middleware/sensitiveAction.js +157 -0
- package/server/migrations/001_add_analytics_indexes.sql +7 -7
- package/server/migrations/002_premium_features.sql +418 -418
- package/server/migrations/003_ads_integer_cents.sql +33 -33
- package/server/migrations/004_agent_os.sql +158 -158
- package/server/migrations/005_marketplace_metering.sql +126 -126
- package/server/migrations/007_governance.sql +106 -0
- package/server/migrations/008_plans.sql +144 -0
- package/server/migrations/009_shieldqr.sql +30 -0
- package/server/migrations/010_extended_trust.sql +33 -0
- package/server/models/adapters/index.js +33 -33
- package/server/models/adapters/mysql.js +183 -183
- package/server/models/adapters/postgresql.js +172 -172
- package/server/models/adapters/sqlite.js +7 -7
- package/server/models/db.js +740 -681
- package/server/observability/failure-analysis.js +337 -337
- package/server/observability/index.js +394 -394
- package/server/protocol/capabilities.js +223 -223
- package/server/protocol/index.js +243 -243
- package/server/protocol/schema.js +584 -584
- package/server/registry/certification.js +271 -271
- package/server/registry/index.js +326 -326
- package/server/routes/admin-plans.js +76 -0
- package/server/routes/admin-premium.js +673 -671
- package/server/routes/admin-shieldqr.js +90 -0
- package/server/routes/admin-trust-monitor.js +83 -0
- package/server/routes/admin.js +549 -261
- package/server/routes/ads.js +130 -130
- package/server/routes/agent-workspace.js +540 -540
- package/server/routes/api.js +150 -150
- package/server/routes/auth.js +71 -71
- package/server/routes/billing.js +57 -45
- package/server/routes/commander.js +316 -316
- package/server/routes/demo-showcase.js +332 -332
- package/server/routes/demo-store.js +154 -0
- package/server/routes/discovery.js +2348 -417
- package/server/routes/gateway.js +173 -157
- package/server/routes/governance.js +208 -0
- package/server/routes/license.js +251 -240
- package/server/routes/mesh.js +469 -469
- package/server/routes/noscript.js +543 -543
- package/server/routes/plans.js +33 -0
- package/server/routes/premium-v2.js +686 -686
- package/server/routes/premium.js +724 -724
- package/server/routes/providers.js +650 -0
- package/server/routes/runtime.js +2148 -2147
- package/server/routes/shieldqr.js +88 -0
- package/server/routes/sovereign.js +465 -385
- package/server/routes/universal.js +200 -185
- package/server/routes/wab-api.js +850 -501
- package/server/runtime/container-worker.js +111 -111
- package/server/runtime/container.js +448 -448
- package/server/runtime/distributed-worker.js +362 -362
- package/server/runtime/event-bus.js +210 -210
- package/server/runtime/index.js +253 -253
- package/server/runtime/queue.js +599 -599
- package/server/runtime/replay.js +666 -666
- package/server/runtime/sandbox.js +266 -266
- package/server/runtime/scheduler.js +534 -534
- package/server/runtime/session-engine.js +293 -293
- package/server/runtime/state-manager.js +188 -188
- package/server/security/cross-site-redactor.js +196 -0
- package/server/security/dry-run.js +180 -0
- package/server/security/human-gate-rate-limit.js +147 -0
- package/server/security/human-gate-transports.js +178 -0
- package/server/security/human-gate.js +281 -0
- package/server/security/index.js +368 -368
- package/server/security/intent-engine.js +245 -0
- package/server/security/reward-guard.js +171 -0
- package/server/security/rollback-store.js +239 -0
- package/server/security/token-scope.js +404 -0
- package/server/security/url-policy.js +139 -0
- package/server/services/agent-chat.js +506 -506
- package/server/services/agent-learning.js +601 -575
- package/server/services/agent-memory.js +625 -625
- package/server/services/agent-mesh.js +555 -539
- package/server/services/agent-symphony.js +717 -717
- package/server/services/agent-tasks.js +1807 -1807
- package/server/services/api-key-engine.js +292 -261
- package/server/services/cluster.js +894 -894
- package/server/services/commander.js +738 -738
- package/server/services/edge-compute.js +440 -440
- package/server/services/email.js +233 -204
- package/server/services/governance.js +466 -0
- package/server/services/hosted-runtime.js +205 -205
- package/server/services/lfd.js +635 -635
- package/server/services/local-ai.js +389 -389
- package/server/services/marketplace.js +270 -270
- package/server/services/metering.js +182 -182
- package/server/services/modules/affiliate-intelligence.js +93 -93
- package/server/services/modules/agent-firewall.js +90 -90
- package/server/services/modules/bounty.js +89 -89
- package/server/services/modules/collective-bargaining.js +92 -92
- package/server/services/modules/dark-pattern.js +66 -66
- package/server/services/modules/gov-intelligence.js +45 -45
- package/server/services/modules/neural.js +55 -55
- package/server/services/modules/notary.js +49 -49
- package/server/services/modules/price-time-machine.js +86 -86
- package/server/services/modules/protocol.js +104 -104
- package/server/services/negotiation.js +439 -439
- package/server/services/plans.js +214 -0
- package/server/services/plugins.js +771 -771
- package/server/services/premium.js +1 -1
- package/server/services/price-intelligence.js +566 -566
- package/server/services/price-shield.js +1137 -1137
- package/server/services/provider-clients.js +740 -0
- package/server/services/reputation.js +465 -465
- package/server/services/search-engine.js +357 -357
- package/server/services/security.js +513 -513
- package/server/services/self-healing.js +843 -843
- package/server/services/shieldqr.js +322 -0
- package/server/services/sovereign-shield.js +542 -0
- package/server/services/ssl-inspector.js +42 -0
- package/server/services/ssl-monitor.js +167 -0
- package/server/services/stripe.js +205 -192
- package/server/services/swarm.js +788 -788
- package/server/services/universal-scraper.js +662 -661
- package/server/services/verification.js +481 -481
- package/server/services/vision.js +1163 -1163
- package/server/services/wab-crypto.js +178 -0
- package/server/utils/cache.js +125 -125
- package/server/utils/migrate.js +81 -81
- package/server/utils/safe-fetch.js +228 -0
- package/server/utils/secureFields.js +50 -50
- package/server/ws.js +161 -161
- package/templates/artisan-marketplace.yaml +104 -104
- package/templates/book-price-scout.yaml +98 -98
- package/templates/electronics-price-tracker.yaml +108 -108
- package/templates/flight-deal-hunter.yaml +113 -113
- package/templates/freelancer-direct.yaml +116 -116
- package/templates/grocery-price-compare.yaml +93 -93
- package/templates/hotel-direct-booking.yaml +113 -113
- package/templates/local-services.yaml +98 -98
- package/templates/olive-oil-tunisia.yaml +88 -88
- package/templates/organic-farm-fresh.yaml +101 -101
- package/templates/restaurant-direct.yaml +97 -97
- package/public/score.html +0 -263
- package/server/migrations/006_growth_suite.sql +0 -138
- package/server/routes/growth.js +0 -962
- package/server/services/fairness-engine.js +0 -409
- package/server/services/fairness.js +0 -420
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>WAB DNS — Cloudflare One-Click Integration</title>
|
|
7
|
+
<link rel="stylesheet" href="/css/main.css">
|
|
8
|
+
<style>
|
|
9
|
+
body { font-family: system-ui, sans-serif; background: #0f172a; color: #e2e8f0; margin: 0; padding: 0; }
|
|
10
|
+
.page { max-width: 860px; margin: 0 auto; padding: 40px 20px 80px; }
|
|
11
|
+
h1 { font-size: 1.7rem; margin-bottom: 6px; }
|
|
12
|
+
.sub { color: #94a3b8; margin-bottom: 32px; font-size: .97rem; }
|
|
13
|
+
.card { background: #1e293b; border-radius: 10px; padding: 24px; margin-bottom: 24px; }
|
|
14
|
+
h2 { font-size: 1.1rem; margin: 0 0 14px; }
|
|
15
|
+
label { display: block; font-size: .85rem; color: #94a3b8; margin-bottom: 4px; margin-top: 14px; }
|
|
16
|
+
label:first-child { margin-top: 0; }
|
|
17
|
+
input[type=text], input[type=password] {
|
|
18
|
+
width: 100%; box-sizing: border-box; background: #0f172a; border: 1px solid #334155;
|
|
19
|
+
color: #e2e8f0; border-radius: 6px; padding: 9px 12px; font-size: .93rem;
|
|
20
|
+
}
|
|
21
|
+
input:focus { outline: 2px solid #6366f1; border-color: transparent; }
|
|
22
|
+
.row { display: flex; gap: 12px; }
|
|
23
|
+
.row > * { flex: 1; }
|
|
24
|
+
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
|
|
25
|
+
.btn { padding: 9px 20px; border-radius: 7px; border: none; cursor: pointer; font-size: .92rem; font-weight: 600; transition: opacity .15s; }
|
|
26
|
+
.btn:hover { opacity: .85; }
|
|
27
|
+
.btn:disabled { opacity: .45; cursor: not-allowed; }
|
|
28
|
+
.btn-enable { background: #22c55e; color: #000; }
|
|
29
|
+
.btn-disable { background: #ef4444; color: #fff; }
|
|
30
|
+
.btn-verify { background: #6366f1; color: #fff; }
|
|
31
|
+
.btn-secondary { background: #334155; color: #e2e8f0; }
|
|
32
|
+
#statusBar { margin-top: 18px; min-height: 36px; padding: 10px 14px; border-radius: 7px; background: #0f172a; font-size: .88rem; color: #94a3b8; display: none; }
|
|
33
|
+
#statusBar.ok { display: block; color: #4ade80; border: 1px solid #166534; }
|
|
34
|
+
#statusBar.err { display: block; color: #f87171; border: 1px solid #7f1d1d; }
|
|
35
|
+
#statusBar.info { display: block; color: #93c5fd; border: 1px solid #1e3a5f; }
|
|
36
|
+
pre { background: #0f172a; border-radius: 7px; padding: 14px 16px; font-size: .82rem; color: #94a3b8; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 14px 0 0; }
|
|
37
|
+
.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: .74rem; font-weight: 700; background: #1d4ed8; color: #bfdbfe; margin-left: 8px; vertical-align: middle; }
|
|
38
|
+
.badge.green { background: #14532d; color: #86efac; }
|
|
39
|
+
.badge.red { background: #7f1d1d; color: #fca5a5; }
|
|
40
|
+
.step { counter-increment: step; display: flex; gap: 14px; margin-bottom: 18px; }
|
|
41
|
+
.step-num { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: #334155; color: #e2e8f0; font-size: .82rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
|
|
42
|
+
.step-body { flex: 1; padding-top: 3px; }
|
|
43
|
+
a { color: #818cf8; }
|
|
44
|
+
code { background: #0f172a; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
|
|
45
|
+
.tab-bar { display: flex; gap: 4px; margin-bottom: 14px; }
|
|
46
|
+
.tab { padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: .84rem; background: #0f172a; color: #94a3b8; border: 1px solid #334155; }
|
|
47
|
+
.tab.active { background: #6366f1; color: #fff; border-color: transparent; }
|
|
48
|
+
.tab-panel { display: none; }
|
|
49
|
+
.tab-panel.active { display: block; }
|
|
50
|
+
</style>
|
|
51
|
+
</head>
|
|
52
|
+
<body>
|
|
53
|
+
<div class="page">
|
|
54
|
+
<h1>Cloudflare × WAB DNS Discovery</h1>
|
|
55
|
+
<p class="sub">
|
|
56
|
+
One-click enable or disable the WAB DNS Discovery TXT record for any domain managed in Cloudflare.
|
|
57
|
+
Uses the <a href="https://developers.cloudflare.com/api/" target="_blank" rel="noopener">Cloudflare API</a> directly from your browser — your token never leaves your device.
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
<!-- ── STEP 1: credentials ── -->
|
|
61
|
+
<div class="card">
|
|
62
|
+
<h2>1. Cloudflare Credentials</h2>
|
|
63
|
+
<label>API Token <span style="color:#94a3b8;font-weight:400">(needs <code>Zone:DNS:Edit</code> permission)</span></label>
|
|
64
|
+
<input type="password" id="cfToken" placeholder="eyJhbGci…" autocomplete="off">
|
|
65
|
+
<p style="margin:8px 0 0;font-size:.82rem;color:#64748b">
|
|
66
|
+
Create a scoped token at
|
|
67
|
+
<a href="https://dash.cloudflare.com/profile/api-tokens" target="_blank" rel="noopener">dash.cloudflare.com → API Tokens</a>.
|
|
68
|
+
Select template <strong>Edit zone DNS</strong> and restrict to the zone you need.
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<!-- ── STEP 2: domain ── -->
|
|
73
|
+
<div class="card">
|
|
74
|
+
<h2>2. Domain</h2>
|
|
75
|
+
<div class="row">
|
|
76
|
+
<div>
|
|
77
|
+
<label>Root domain (Cloudflare zone)</label>
|
|
78
|
+
<input type="text" id="cfDomain" placeholder="example.com">
|
|
79
|
+
</div>
|
|
80
|
+
<div>
|
|
81
|
+
<label>Endpoint URL <span style="color:#94a3b8;font-weight:400">(leave blank for auto)</span></label>
|
|
82
|
+
<input type="text" id="cfEndpoint" placeholder="https://example.com/.well-known/wab.json">
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<!-- ── STEP 3: actions ── -->
|
|
88
|
+
<div class="card">
|
|
89
|
+
<h2>3. Actions</h2>
|
|
90
|
+
<div class="actions">
|
|
91
|
+
<button class="btn btn-enable" id="btnEnable" onclick="cfAction('enable')">✓ Enable WAB Discovery</button>
|
|
92
|
+
<button class="btn btn-disable" id="btnDisable" onclick="cfAction('disable')">✗ Disable WAB Discovery</button>
|
|
93
|
+
<button class="btn btn-verify" id="btnVerify" onclick="cfVerify()">⟳ Verify Status</button>
|
|
94
|
+
<button class="btn btn-secondary" onclick="window.open('/provider-sandbox','_blank')">Open Sandbox</button>
|
|
95
|
+
</div>
|
|
96
|
+
<div id="statusBar"></div>
|
|
97
|
+
<pre id="jsonOut" style="display:none"></pre>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<!-- ── HOW IT WORKS ── -->
|
|
101
|
+
<div class="card">
|
|
102
|
+
<h2>How it works</h2>
|
|
103
|
+
<div style="counter-reset:step">
|
|
104
|
+
<div class="step">
|
|
105
|
+
<div class="step-num">1</div>
|
|
106
|
+
<div class="step-body">Fetch the WAB <strong>record template</strong> for your domain (<code>GET /api/discovery/provider/record-template</code>) to get the exact TXT value.</div>
|
|
107
|
+
</div>
|
|
108
|
+
<div class="step">
|
|
109
|
+
<div class="step-num">2</div>
|
|
110
|
+
<div class="step-body">Resolve the Cloudflare <strong>Zone ID</strong> from the domain name (<code>GET /zones?name=…</code>).</div>
|
|
111
|
+
</div>
|
|
112
|
+
<div class="step">
|
|
113
|
+
<div class="step-num">3</div>
|
|
114
|
+
<div class="step-body"><strong>Enable:</strong> look up existing <code>_wab</code> TXT record → create it if absent, or update it if the value changed.<br>
|
|
115
|
+
<strong>Disable:</strong> look up the record → delete it if found.</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="step">
|
|
118
|
+
<div class="step-num">4</div>
|
|
119
|
+
<div class="step-body">Call <code>GET /api/discovery/provider/status?domain=…</code> to confirm WAB sees the record live (DNS propagation may take up to 60 s).</div>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<!-- ── CODE SNIPPETS ── -->
|
|
125
|
+
<div class="card">
|
|
126
|
+
<h2>Code Snippets</h2>
|
|
127
|
+
<div class="tab-bar">
|
|
128
|
+
<div class="tab active" onclick="switchTab('nodejs')">Node.js</div>
|
|
129
|
+
<div class="tab" onclick="switchTab('curl')">cURL</div>
|
|
130
|
+
<div class="tab" onclick="switchTab('python')">Python</div>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<div id="tab-nodejs" class="tab-panel active">
|
|
134
|
+
<pre>// npm install node-fetch
|
|
135
|
+
const fetch = require('node-fetch');
|
|
136
|
+
|
|
137
|
+
const CF_TOKEN = process.env.CF_API_TOKEN;
|
|
138
|
+
const DOMAIN = 'example.com';
|
|
139
|
+
const WAB_ENDPOINT = `https://${DOMAIN}/.well-known/wab.json`;
|
|
140
|
+
const TXT_VALUE = `v=wab1; endpoint=${WAB_ENDPOINT}`;
|
|
141
|
+
|
|
142
|
+
async function cfHeaders() {
|
|
143
|
+
return { Authorization: `Bearer ${CF_TOKEN}`, 'Content-Type': 'application/json' };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function getZoneId(domain) {
|
|
147
|
+
const r = await fetch(`https://api.cloudflare.com/client/v4/zones?name=${domain}`, { headers: await cfHeaders() });
|
|
148
|
+
const j = await r.json();
|
|
149
|
+
if (!j.success || !j.result[0]) throw new Error('Zone not found');
|
|
150
|
+
return j.result[0].id;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function enableWAB() {
|
|
154
|
+
const zoneId = await getZoneId(DOMAIN);
|
|
155
|
+
const base = `https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records`;
|
|
156
|
+
// check existing
|
|
157
|
+
const list = await (await fetch(`${base}?type=TXT&name=_wab.${DOMAIN}`, { headers: await cfHeaders() })).json();
|
|
158
|
+
if (list.result && list.result[0]) {
|
|
159
|
+
// update
|
|
160
|
+
const id = list.result[0].id;
|
|
161
|
+
await fetch(`${base}/${id}`, { method: 'PUT', headers: await cfHeaders(),
|
|
162
|
+
body: JSON.stringify({ type: 'TXT', name: `_wab.${DOMAIN}`, content: TXT_VALUE, ttl: 3600 }) });
|
|
163
|
+
console.log('Updated _wab TXT record');
|
|
164
|
+
} else {
|
|
165
|
+
await fetch(base, { method: 'POST', headers: await cfHeaders(),
|
|
166
|
+
body: JSON.stringify({ type: 'TXT', name: `_wab.${DOMAIN}`, content: TXT_VALUE, ttl: 3600 }) });
|
|
167
|
+
console.log('Created _wab TXT record');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function disableWAB() {
|
|
172
|
+
const zoneId = await getZoneId(DOMAIN);
|
|
173
|
+
const base = `https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records`;
|
|
174
|
+
const list = await (await fetch(`${base}?type=TXT&name=_wab.${DOMAIN}`, { headers: await cfHeaders() })).json();
|
|
175
|
+
if (list.result && list.result[0]) {
|
|
176
|
+
await fetch(`${base}/${list.result[0].id}`, { method: 'DELETE', headers: await cfHeaders() });
|
|
177
|
+
console.log('Deleted _wab TXT record');
|
|
178
|
+
} else {
|
|
179
|
+
console.log('No _wab record found (already disabled)');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
enableWAB().catch(console.error);
|
|
184
|
+
</pre>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div id="tab-curl" class="tab-panel">
|
|
188
|
+
<pre># 1. Get Zone ID
|
|
189
|
+
ZONE=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=example.com" \
|
|
190
|
+
-H "Authorization: Bearer $CF_API_TOKEN" | jq -r '.result[0].id')
|
|
191
|
+
|
|
192
|
+
# 2. Create TXT record
|
|
193
|
+
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records" \
|
|
194
|
+
-H "Authorization: Bearer $CF_API_TOKEN" \
|
|
195
|
+
-H "Content-Type: application/json" \
|
|
196
|
+
--data '{
|
|
197
|
+
"type": "TXT",
|
|
198
|
+
"name": "_wab.example.com",
|
|
199
|
+
"content": "v=wab1; endpoint=https://example.com/.well-known/wab.json",
|
|
200
|
+
"ttl": 3600
|
|
201
|
+
}'
|
|
202
|
+
|
|
203
|
+
# Delete (disable)
|
|
204
|
+
REC=$(curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records?type=TXT&name=_wab.example.com" \
|
|
205
|
+
-H "Authorization: Bearer $CF_API_TOKEN" | jq -r '.result[0].id')
|
|
206
|
+
curl -s -X DELETE "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records/$REC" \
|
|
207
|
+
-H "Authorization: Bearer $CF_API_TOKEN"
|
|
208
|
+
</pre>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div id="tab-python" class="tab-panel">
|
|
212
|
+
<pre>import os, requests
|
|
213
|
+
|
|
214
|
+
CF_TOKEN = os.environ['CF_API_TOKEN']
|
|
215
|
+
DOMAIN = 'example.com'
|
|
216
|
+
HEADERS = {'Authorization': f'Bearer {CF_TOKEN}', 'Content-Type': 'application/json'}
|
|
217
|
+
TXT_VAL = f'v=wab1; endpoint=https://{DOMAIN}/.well-known/wab.json'
|
|
218
|
+
|
|
219
|
+
def zone_id():
|
|
220
|
+
r = requests.get(f'https://api.cloudflare.com/client/v4/zones?name={DOMAIN}', headers=HEADERS)
|
|
221
|
+
return r.json()['result'][0]['id']
|
|
222
|
+
|
|
223
|
+
def enable_wab():
|
|
224
|
+
zid = zone_id()
|
|
225
|
+
base = f'https://api.cloudflare.com/client/v4/zones/{zid}/dns_records'
|
|
226
|
+
lst = requests.get(f'{base}?type=TXT&name=_wab.{DOMAIN}', headers=HEADERS).json()
|
|
227
|
+
payload = {'type': 'TXT', 'name': f'_wab.{DOMAIN}', 'content': TXT_VAL, 'ttl': 3600}
|
|
228
|
+
if lst['result']:
|
|
229
|
+
requests.put(f'{base}/{lst["result"][0]["id"]}', json=payload, headers=HEADERS)
|
|
230
|
+
print('Updated')
|
|
231
|
+
else:
|
|
232
|
+
requests.post(base, json=payload, headers=HEADERS)
|
|
233
|
+
print('Created')
|
|
234
|
+
|
|
235
|
+
def disable_wab():
|
|
236
|
+
zid = zone_id()
|
|
237
|
+
base = f'https://api.cloudflare.com/client/v4/zones/{zid}/dns_records'
|
|
238
|
+
lst = requests.get(f'{base}?type=TXT&name=_wab.{DOMAIN}', headers=HEADERS).json()
|
|
239
|
+
if lst['result']:
|
|
240
|
+
requests.delete(f'{base}/{lst["result"][0]["id"]}', headers=HEADERS)
|
|
241
|
+
print('Deleted')
|
|
242
|
+
else:
|
|
243
|
+
print('Already disabled')
|
|
244
|
+
|
|
245
|
+
enable_wab()
|
|
246
|
+
</pre>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<p style="text-align:center;margin-top:30px;font-size:.85rem;color:#475569">
|
|
251
|
+
<a href="/provider-onboarding">← Back to Provider Onboarding</a> ·
|
|
252
|
+
<a href="/provider-sandbox">Provider Sandbox</a> ·
|
|
253
|
+
<a href="/dns">DNS Discovery</a>
|
|
254
|
+
</p>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<script>
|
|
258
|
+
function switchTab(name) {
|
|
259
|
+
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
|
260
|
+
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
|
|
261
|
+
document.querySelector(`#tab-${name}`).classList.add('active');
|
|
262
|
+
event.target.classList.add('active');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function setStatus(msg, type) {
|
|
266
|
+
const bar = document.getElementById('statusBar');
|
|
267
|
+
bar.textContent = msg;
|
|
268
|
+
bar.className = type;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function showJson(obj) {
|
|
272
|
+
const pre = document.getElementById('jsonOut');
|
|
273
|
+
pre.textContent = JSON.stringify(obj, null, 2);
|
|
274
|
+
pre.style.display = 'block';
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function getInputs() {
|
|
278
|
+
const token = document.getElementById('cfToken').value.trim();
|
|
279
|
+
const domain = document.getElementById('cfDomain').value.trim().toLowerCase().replace(/^https?:\/\//, '').replace(/\/$/, '');
|
|
280
|
+
const ep = document.getElementById('cfEndpoint').value.trim() || `https://${domain}/.well-known/wab.json`;
|
|
281
|
+
return { token, domain, ep };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async function cfHeaders(token) {
|
|
285
|
+
return { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function getZoneId(token, domain) {
|
|
289
|
+
const r = await fetch(`https://api.cloudflare.com/client/v4/zones?name=${encodeURIComponent(domain)}`, {
|
|
290
|
+
headers: await cfHeaders(token)
|
|
291
|
+
});
|
|
292
|
+
const j = await r.json();
|
|
293
|
+
if (!j.success || !j.result || !j.result[0]) throw new Error(`Zone not found for "${domain}". Make sure the domain is in your Cloudflare account.`);
|
|
294
|
+
return j.result[0].id;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function cfAction(action) {
|
|
298
|
+
const { token, domain, ep } = getInputs();
|
|
299
|
+
if (!token) return setStatus('Please enter your Cloudflare API Token.', 'err');
|
|
300
|
+
if (!domain) return setStatus('Please enter a domain name.', 'err');
|
|
301
|
+
|
|
302
|
+
document.getElementById(`btn${action === 'enable' ? 'Enable' : 'Disable'}`).disabled = true;
|
|
303
|
+
setStatus('Fetching WAB record template…', 'info');
|
|
304
|
+
|
|
305
|
+
try {
|
|
306
|
+
// 1. get record value from WAB
|
|
307
|
+
const tplRes = await fetch(`/api/discovery/provider/record-template?domain=${encodeURIComponent(domain)}&endpoint=${encodeURIComponent(ep)}`);
|
|
308
|
+
const tpl = await tplRes.json();
|
|
309
|
+
const txtVal = tpl.record && tpl.record.value;
|
|
310
|
+
if (!txtVal) throw new Error('Could not fetch WAB record template.');
|
|
311
|
+
|
|
312
|
+
setStatus('Resolving Cloudflare Zone ID…', 'info');
|
|
313
|
+
const zoneId = await getZoneId(token, domain);
|
|
314
|
+
|
|
315
|
+
const baseUrl = `https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records`;
|
|
316
|
+
const cfHdr = await cfHeaders(token);
|
|
317
|
+
const listUrl = `${baseUrl}?type=TXT&name=_wab.${domain}`;
|
|
318
|
+
|
|
319
|
+
setStatus('Looking up existing _wab TXT record…', 'info');
|
|
320
|
+
const listRes = await fetch(listUrl, { headers: cfHdr });
|
|
321
|
+
const listJ = await listRes.json();
|
|
322
|
+
const existing = listJ.result && listJ.result[0];
|
|
323
|
+
|
|
324
|
+
let resultJson;
|
|
325
|
+
if (action === 'enable') {
|
|
326
|
+
const body = JSON.stringify({ type: 'TXT', name: `_wab.${domain}`, content: txtVal, ttl: 3600 });
|
|
327
|
+
if (existing) {
|
|
328
|
+
setStatus(`Updating existing record (id=${existing.id})…`, 'info');
|
|
329
|
+
const r = await fetch(`${baseUrl}/${existing.id}`, { method: 'PUT', headers: cfHdr, body });
|
|
330
|
+
resultJson = await r.json();
|
|
331
|
+
if (!resultJson.success) throw new Error(JSON.stringify(resultJson.errors));
|
|
332
|
+
setStatus(`✓ _wab TXT record updated for ${domain}. DNS propagation may take up to 60 s.`, 'ok');
|
|
333
|
+
} else {
|
|
334
|
+
setStatus('Creating new _wab TXT record…', 'info');
|
|
335
|
+
const r = await fetch(baseUrl, { method: 'POST', headers: cfHdr, body });
|
|
336
|
+
resultJson = await r.json();
|
|
337
|
+
if (!resultJson.success) throw new Error(JSON.stringify(resultJson.errors));
|
|
338
|
+
setStatus(`✓ _wab TXT record created for ${domain}. WAB Discovery is now ENABLED.`, 'ok');
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
// disable
|
|
342
|
+
if (!existing) {
|
|
343
|
+
setStatus(`No _wab TXT record found for ${domain} — already disabled.`, 'ok');
|
|
344
|
+
showJson({ note: 'no record found', domain });
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
setStatus(`Deleting record (id=${existing.id})…`, 'info');
|
|
348
|
+
const r = await fetch(`${baseUrl}/${existing.id}`, { method: 'DELETE', headers: cfHdr });
|
|
349
|
+
resultJson = await r.json();
|
|
350
|
+
if (!resultJson.success) throw new Error(JSON.stringify(resultJson.errors));
|
|
351
|
+
setStatus(`✓ _wab TXT record deleted for ${domain}. WAB Discovery is now DISABLED.`, 'ok');
|
|
352
|
+
}
|
|
353
|
+
showJson(resultJson);
|
|
354
|
+
} catch (err) {
|
|
355
|
+
setStatus(`Error: ${err.message}`, 'err');
|
|
356
|
+
} finally {
|
|
357
|
+
document.getElementById('btnEnable').disabled = false;
|
|
358
|
+
document.getElementById('btnDisable').disabled = false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async function cfVerify() {
|
|
363
|
+
const { domain } = getInputs();
|
|
364
|
+
if (!domain) return setStatus('Please enter a domain name.', 'err');
|
|
365
|
+
setStatus('Checking WAB status via DNS…', 'info');
|
|
366
|
+
try {
|
|
367
|
+
const r = await fetch(`/api/discovery/provider/status?domain=${encodeURIComponent(domain)}`);
|
|
368
|
+
const j = await r.json();
|
|
369
|
+
const st = j.status;
|
|
370
|
+
if (st === 'enabled') setStatus(`✓ ${domain} — WAB Discovery is ENABLED (record verified).`, 'ok');
|
|
371
|
+
else if (st === 'partial') setStatus(`⚠ ${domain} — DNS found but endpoint has issues (status: partial).`, 'info');
|
|
372
|
+
else setStatus(`✗ ${domain} — WAB Discovery is DISABLED (no valid TXT record found).`, 'err');
|
|
373
|
+
showJson(j);
|
|
374
|
+
} catch (err) {
|
|
375
|
+
setStatus(`Verify error: ${err.message}`, 'err');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
</script>
|
|
379
|
+
</body>
|
|
380
|
+
</html>
|