Files
hermes-mcp/product/app/styles.css
Garfield 61dab40585 feat(saas): SquareMCP v2 — multi-tenant MCP platform complete
Steps 0–10 of the v2 plan, 194 tests passing.

Core infrastructure
- Shared Redis client (src/redis.ts); all four Redis consumers migrated
- Vitest test harness with vitest.config.ts and npm test/test:watch scripts

Billing & invoicing (Steps 1–2)
- Monthly invoice generation with idempotency (MySQL uq_customer_period unique key)
- Cron job with Redis distributed lock (Lua compare-delete, 1-hr TTL)
- Invoice emailer via nodemailer (FETCHERPAY SMTP)
- Billing middleware: checkLimit gate in handleToolCall; platform attribution fix

Email multi-tenancy (Step 3)
- EmailCtx = Account | EmailCredentials; imap.ts + smtp.ts accept both
- resolveEmailCtx helper in tools.ts; all email tools use customer credentials

Analytics + platform health (Steps 4–5)
- Chart.js bar charts for platform breakdown and daily activity
- Token expiry check in getCredential with dynamic import refresh
- platform-health.ts: per-platform health probe with 10-min Redis cache
- GET /api/health/platforms; "Token expired" amber badge in dashboard

Tool schema filtering (Step 6)
- stripAccountParam deep-clones tool schemas; multi-tenant sessions never
  see the internal account enum

OAuth hardening (Step 7)
- Atomic auth code consumption: UPDATE SET used=TRUE, check affectedRows
- customer_id threaded through oauth_auth_codes → oauth_tokens
- getTokenCustomer(); requireAuth resolves req.customer from Bearer token
- Consent page requires authenticated session; redirect_uri validated
  against registered URIs; http://localhost:* loopback wildcard

DCR browser flow (Step 8)
- ensureOAuthAppRegistered() upserts pre-registered SquareMCP OAuth app
  on startup with redirect URIs for mcp-callback, localhost:*, claude-desktop,
  opencode
- GET /oauth/connect-mcp → server-side redirect (client_id off frontend)
- GET /oauth/mcp-callback → exchanges code, renders config snippet page
  with copy buttons for Claude Desktop and Codex CLI

Webhooks (Step 9)
- webhook_url + webhook_secret columns on customers
- deliverWebhook(): HMAC-SHA256 signing, 3× exponential retry (1s/4s/16s),
  Redis DLQ with 7-day TTL on total failure
- isValidWebhookUrl(): SSRF protection (blocks RFC-1918, localhost, .local)
- POST /api/webhooks/config (secret returned once), GET, DELETE
- GET /api/admin/webhooks/dlq/:customerId
- WhatsApp POST route uses express.raw() for raw body preservation
- Dashboard Webhooks tab with secret-once display and copy button

Developer docs (Step 10)
- docs/ static HTML site (GitHub Pages, no build pipeline)
- index.html: landing page with client + platform overview
- getting-started.html: tabbed MCP config for Claude Desktop, Codex CLI, opencode
- platforms.html: LinkedIn, TikTok, WhatsApp, Instagram, Twitter, Telegram guides
- agent-tutorial.html: complete Node.js agent (Anthropic SDK + MCP SDK),
  LinkedIn posting loop, extensions for multi-platform + inbound webhook reaction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 23:43:56 -04:00

754 lines
12 KiB
CSS

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0f0f10;
--surface: #1a1a1b;
--surface-hover: #222223;
--border: #2a2a2b;
--text: #e5e5e5;
--text-secondary: #888;
--accent: #10a37f;
--accent-hover: #0d8c6d;
--danger: #dc2626;
--radius: 12px;
--shadow: 0 4px 24px rgba(0,0,0,0.4);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
line-height: 1.5;
}
.hidden { display: none !important; }
/* Views */
.view {
min-height: 100vh;
}
/* Auth */
#login-view {
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
}
.auth-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 40px;
width: 100%;
max-width: 400px;
box-shadow: var(--shadow);
}
.logo {
text-align: center;
margin-bottom: 32px;
}
.logo-mark {
width: 56px;
height: 56px;
background: linear-gradient(135deg, #25f4ee, #fe2c55);
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-weight: 700;
font-size: 28px;
margin: 0 auto 16px;
}
.logo-mark.small {
width: 36px;
height: 36px;
font-size: 18px;
border-radius: 10px;
margin: 0;
}
.logo h1 {
font-size: 24px;
font-weight: 600;
margin-bottom: 4px;
}
.logo p {
color: var(--text-secondary);
font-size: 14px;
}
.tabs {
display: flex;
gap: 8px;
margin-bottom: 24px;
background: var(--bg);
padding: 4px;
border-radius: 10px;
}
.tab-btn {
flex: 1;
padding: 10px;
border: none;
background: transparent;
color: var(--text-secondary);
font-size: 14px;
font-weight: 500;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s;
}
.tab-btn.active {
background: var(--surface);
color: var(--text);
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.auth-form {
display: flex;
flex-direction: column;
gap: 14px;
}
.auth-form input {
padding: 12px 14px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-size: 15px;
outline: none;
transition: border-color 0.2s;
}
.auth-form input:focus {
border-color: var(--accent);
}
.auth-form input::placeholder {
color: #555;
}
.btn {
padding: 12px 20px;
border: none;
border-radius: 8px;
font-size: 15px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
}
.btn-primary {
background: var(--accent);
color: #fff;
}
.btn-primary:hover {
background: var(--accent-hover);
}
.btn-ghost {
background: transparent;
color: var(--text-secondary);
padding: 8px 14px;
font-size: 13px;
}
.btn-ghost:hover {
color: var(--text);
}
.btn-connect {
background: var(--bg);
color: var(--text);
border: 1px solid var(--border);
padding: 8px 16px;
font-size: 13px;
white-space: nowrap;
}
.btn-connect:hover {
background: var(--surface-hover);
border-color: var(--accent);
}
.error-msg {
color: var(--danger);
font-size: 13px;
text-align: center;
min-height: 18px;
}
/* Dashboard */
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 24px;
background: var(--surface);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 10;
}
.header-left {
display: flex;
align-items: center;
gap: 12px;
}
.app-title {
font-weight: 600;
font-size: 16px;
}
.header-right {
display: flex;
align-items: center;
gap: 16px;
}
.user-email {
color: var(--text-secondary);
font-size: 14px;
}
.dashboard {
max-width: 1200px;
margin: 0 auto;
padding: 32px 24px;
}
.welcome {
margin-bottom: 32px;
}
.welcome h2 {
font-size: 28px;
font-weight: 600;
margin-bottom: 8px;
}
.welcome p {
color: var(--text-secondary);
font-size: 16px;
}
.platform-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 16px;
}
.platform-card {
display: flex;
align-items: center;
gap: 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
transition: border-color 0.2s, transform 0.2s;
}
.platform-card:hover {
border-color: #3a3a3b;
transform: translateY(-2px);
}
.platform-icon {
width: 48px;
height: 48px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
flex-shrink: 0;
}
.platform-info {
flex: 1;
min-width: 0;
}
.platform-info h3 {
font-size: 16px;
font-weight: 600;
margin-bottom: 2px;
}
.platform-desc {
color: var(--text-secondary);
font-size: 13px;
margin-bottom: 6px;
}
.status-badge {
display: inline-block;
padding: 3px 10px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.3px;
}
.status-badge.connected {
background: rgba(16, 163, 127, 0.15);
color: var(--accent);
}
.status-badge.disconnected {
background: rgba(136, 136, 136, 0.1);
color: var(--text-secondary);
}
.status-badge.expired {
background: rgba(245, 158, 11, 0.15);
color: #f59e0b;
}
/* Modal */
.modal {
position: fixed;
inset: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
}
.modal-backdrop {
position: absolute;
inset: 0;
background: rgba(0,0,0,0.7);
backdrop-filter: blur(4px);
}
.modal-content {
position: relative;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 32px;
width: 100%;
max-width: 480px;
max-height: 80vh;
overflow-y: auto;
box-shadow: var(--shadow);
z-index: 1;
}
.modal-close {
position: absolute;
top: 16px;
right: 16px;
background: none;
border: none;
color: var(--text-secondary);
font-size: 24px;
cursor: pointer;
}
.modal-close:hover {
color: var(--text);
}
/* Connection form in modal */
.connect-form {
display: flex;
flex-direction: column;
gap: 14px;
}
.connect-form h3 {
margin-bottom: 8px;
}
.connect-form p {
color: var(--text-secondary);
font-size: 14px;
margin-bottom: 8px;
}
.connect-form label {
font-size: 13px;
font-weight: 500;
color: var(--text-secondary);
}
.connect-form input {
padding: 12px 14px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-size: 14px;
outline: none;
}
.connect-form input:focus {
border-color: var(--accent);
}
.connect-form .btn-primary {
margin-top: 8px;
}
.instructions {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px;
font-size: 13px;
color: var(--text-secondary);
line-height: 1.6;
}
.instructions code {
background: #2a2a2b;
padding: 2px 6px;
border-radius: 4px;
font-family: 'SF Mono', monospace;
font-size: 12px;
}
@media (max-width: 640px) {
.platform-grid {
grid-template-columns: 1fr;
}
.auth-card {
padding: 28px 20px;
}
}
/* Usage bar */
.usage-bar {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px 20px;
margin-bottom: 24px;
}
.usage-info {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.plan-badge {
background: var(--accent);
color: #fff;
padding: 4px 12px;
border-radius: 12px;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
}
.usage-text {
color: var(--text-secondary);
font-size: 13px;
}
.usage-bar-track {
height: 6px;
background: var(--bg);
border-radius: 3px;
overflow: hidden;
}
.usage-bar-fill {
height: 100%;
background: var(--accent);
border-radius: 3px;
transition: width 0.5s ease;
}
.usage-bar-fill.warning {
background: #f59e0b;
}
.usage-bar-fill.danger {
background: #dc2626;
}
/* Header nav */
.header-nav {
display: flex;
gap: 4px;
margin-right: 16px;
}
.nav-link {
background: transparent;
border: none;
color: var(--text-secondary);
font-size: 13px;
font-weight: 500;
padding: 6px 12px;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s;
}
.nav-link:hover {
color: var(--text);
}
.nav-link.active {
background: var(--bg);
color: var(--text);
}
/* Invoices */
.invoices-section, .admin-section {
margin-top: 24px;
}
.invoices-section h3, .admin-section h3 {
font-size: 18px;
margin-bottom: 16px;
}
.invoices-list {
display: flex;
flex-direction: column;
gap: 10px;
}
.invoice-item {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 16px 20px;
}
.invoice-item .inv-num {
font-weight: 600;
font-size: 14px;
}
.invoice-item .inv-period {
color: var(--text-secondary);
font-size: 12px;
}
.invoice-item .inv-amount {
font-weight: 700;
font-size: 16px;
}
.invoice-item .inv-status {
padding: 3px 10px;
border-radius: 10px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.inv-status.draft { background: rgba(136,136,136,0.1); color: #888; }
.inv-status.sent { background: rgba(245,158,11,0.15); color: #f59e0b; }
.inv-status.paid { background: rgba(16,163,127,0.15); color: var(--accent); }
.inv-status.overdue { background: rgba(220,38,38,0.15); color: #dc2626; }
/* Admin */
.admin-customers {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
}
.admin-table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
}
.admin-table th {
text-align: left;
padding: 12px 16px;
color: var(--text-secondary);
font-weight: 500;
border-bottom: 1px solid var(--border);
}
.admin-table td {
padding: 12px 16px;
border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td {
border-bottom: none;
}
.admin-table .btn-small {
padding: 4px 10px;
font-size: 11px;
}
/* Analytics */
.analytics-section {
margin-top: 24px;
}
.section-title {
font-size: 18px;
margin-bottom: 4px;
}
.section-subtitle {
color: var(--text-secondary);
font-size: 13px;
margin-bottom: 20px;
}
.charts-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
@media (max-width: 700px) {
.charts-grid { grid-template-columns: 1fr; }
}
.chart-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
}
.chart-card h4 {
font-size: 13px;
font-weight: 600;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 16px;
}
.chart-container {
position: relative;
height: 220px;
}
.analytics-empty {
padding: 40px 20px;
text-align: center;
color: var(--text-secondary);
font-size: 14px;
}
/* Webhooks */
.webhooks-section {
margin-top: 24px;
}
.webhook-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 24px;
max-width: 640px;
}
.webhook-status-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
.webhook-url-display {
flex: 1;
font-size: 14px;
color: var(--text-secondary);
word-break: break-all;
}
.webhook-form {
display: flex;
gap: 10px;
margin-bottom: 16px;
}
.webhook-form input {
flex: 1;
padding: 10px 14px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-size: 14px;
outline: none;
}
.webhook-form input:focus {
border-color: var(--accent);
}
.webhook-secret-box {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px;
margin-bottom: 16px;
}
.webhook-secret-label {
font-size: 12px;
color: #f59e0b;
margin-bottom: 8px;
}
.webhook-secret-value {
font-family: 'SF Mono', monospace;
font-size: 12px;
word-break: break-all;
margin-bottom: 8px;
color: var(--text);
}
.webhook-instructions {
font-size: 13px;
color: var(--text-secondary);
line-height: 1.6;
}
.webhook-instructions code {
background: #2a2a2b;
padding: 2px 6px;
border-radius: 4px;
font-family: 'SF Mono', monospace;
font-size: 12px;
}
/* Password reset */
.success-msg {
color: var(--accent);
font-size: 13px;
text-align: center;
min-height: 18px;
}