- JWT auth with bcrypt password hashing, cookie sessions, forgot/reset password - Per-user encrypted credential storage (Redis + AES-256-GCM) for all 9 platforms - Usage tracking with monthly limits per plan (free/starter/growth/enterprise) - Invoice generation and retrieval (admin + user views) - Admin panel with customer listing (role-based access) - Web app UI at app.squaremcp.com — login, dashboard, connections, usage, invoices - Unified auth middleware: API key, OAuth Bearer, and JWT cookie support - Facebook Graph API fixes: published_posts endpoint, photo/video post support - TikTok sandbox compliance: SELF_ONLY privacy for unaudited apps - URL verification files for TikTok app review
415 lines
12 KiB
HTML
415 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>SquareMCP - TikTok Integration Demo</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
background: #f7f7f8;
|
|
color: #1a1a1a;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.header {
|
|
background: #fff;
|
|
border-bottom: 1px solid #e5e5e5;
|
|
padding: 14px 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
|
|
}
|
|
.header img { width: 32px; height: 32px; border-radius: 6px; }
|
|
.header h1 { font-size: 16px; font-weight: 600; color: #1a1a1a; }
|
|
.header .badge {
|
|
margin-left: auto;
|
|
background: #e3f2fd;
|
|
color: #1976d2;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
padding: 4px 10px;
|
|
border-radius: 12px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
.chat {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 24px;
|
|
max-width: 800px;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
}
|
|
.message {
|
|
display: flex;
|
|
gap: 16px;
|
|
margin-bottom: 24px;
|
|
opacity: 0;
|
|
transform: translateY(12px);
|
|
transition: all 0.5s ease;
|
|
}
|
|
.message.visible { opacity: 1; transform: translateY(0); }
|
|
.avatar {
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: #fff;
|
|
}
|
|
.user .avatar { background: #10a37f; }
|
|
.assistant .avatar { background: #1a1a1a; }
|
|
.bubble {
|
|
background: #fff;
|
|
border: 1px solid #e5e5e5;
|
|
border-radius: 12px;
|
|
padding: 16px 20px;
|
|
max-width: 640px;
|
|
line-height: 1.6;
|
|
font-size: 15px;
|
|
}
|
|
.user .bubble { background: #f0f9f6; border-color: #c8e6d5; }
|
|
.bubble strong { color: #1a1a1a; }
|
|
.bubble code {
|
|
background: #f4f4f5;
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
font-family: 'SF Mono', Monaco, monospace;
|
|
font-size: 13px;
|
|
}
|
|
.bubble pre {
|
|
background: #1a1a1a;
|
|
color: #e5e5e5;
|
|
padding: 14px;
|
|
border-radius: 8px;
|
|
overflow-x: auto;
|
|
font-size: 13px;
|
|
margin-top: 10px;
|
|
}
|
|
.bubble .btn {
|
|
display: inline-block;
|
|
background: #1a1a1a;
|
|
color: #fff;
|
|
padding: 10px 20px;
|
|
border-radius: 8px;
|
|
text-decoration: none;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
margin-top: 10px;
|
|
cursor: pointer;
|
|
border: none;
|
|
}
|
|
.bubble .btn:hover { background: #333; }
|
|
.bubble .btn.tiktok {
|
|
background: #000;
|
|
background-image: linear-gradient(135deg, #25f4ee, #fe2c55);
|
|
color: #fff;
|
|
}
|
|
.bubble .success { color: #059669; font-weight: 600; }
|
|
.bubble .error { color: #dc2626; font-weight: 600; }
|
|
.spinner {
|
|
display: inline-block;
|
|
width: 16px;
|
|
height: 16px;
|
|
border: 2px solid #e5e5e5;
|
|
border-top-color: #1a1a1a;
|
|
border-radius: 50%;
|
|
animation: spin 0.8s linear infinite;
|
|
margin-right: 8px;
|
|
vertical-align: middle;
|
|
}
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
.typing {
|
|
display: flex;
|
|
gap: 4px;
|
|
padding: 8px 0;
|
|
}
|
|
.typing span {
|
|
width: 8px;
|
|
height: 8px;
|
|
background: #999;
|
|
border-radius: 50%;
|
|
animation: bounce 1.2s infinite;
|
|
}
|
|
.typing span:nth-child(2) { animation-delay: 0.2s; }
|
|
.typing span:nth-child(3) { animation-delay: 0.4s; }
|
|
@keyframes bounce {
|
|
0%, 80%, 100% { transform: translateY(0); }
|
|
40% { transform: translateY(-6px); }
|
|
}
|
|
.profile-card {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
margin-top: 12px;
|
|
padding: 14px;
|
|
background: #fafafa;
|
|
border-radius: 10px;
|
|
}
|
|
.profile-card img {
|
|
width: 56px;
|
|
height: 56px;
|
|
border-radius: 50%;
|
|
object-fit: cover;
|
|
}
|
|
.profile-card .info h3 { font-size: 16px; margin-bottom: 4px; }
|
|
.profile-card .info p { font-size: 13px; color: #666; }
|
|
.stats {
|
|
display: flex;
|
|
gap: 24px;
|
|
margin-top: 12px;
|
|
}
|
|
.stat { text-align: center; }
|
|
.stat .num { font-size: 20px; font-weight: 700; color: #1a1a1a; }
|
|
.stat .lbl { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
|
|
.publish-form {
|
|
margin-top: 12px;
|
|
}
|
|
.publish-form input {
|
|
width: 100%;
|
|
padding: 10px 14px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
margin-bottom: 10px;
|
|
}
|
|
.video-preview {
|
|
margin-top: 12px;
|
|
border-radius: 10px;
|
|
overflow: hidden;
|
|
max-width: 320px;
|
|
}
|
|
.video-preview video { width: 100%; display: block; }
|
|
.status-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
background: #ecfdf5;
|
|
color: #059669;
|
|
padding: 6px 14px;
|
|
border-radius: 20px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
margin-top: 10px;
|
|
}
|
|
.status-badge::before {
|
|
content: '';
|
|
width: 8px;
|
|
height: 8px;
|
|
background: #059669;
|
|
border-radius: 50%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="header">
|
|
<div style="width:32px;height:32px;background:linear-gradient(135deg,#25f4ee,#fe2c55);border-radius:8px;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:18px;">S</div>
|
|
<h1>SquareMCP</h1>
|
|
<span class="badge">TikTok Integration Demo</span>
|
|
</div>
|
|
|
|
<div class="chat" id="chat"></div>
|
|
|
|
<script>
|
|
const API_KEY = '114521f3f9e6858480d6269446a446ef';
|
|
const API_BASE = 'https://hermes.squaremcp.com';
|
|
|
|
function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
|
|
|
|
function addMessage(role, html) {
|
|
const chat = document.getElementById('chat');
|
|
const div = document.createElement('div');
|
|
div.className = `message ${role}`;
|
|
const avatar = role === 'user' ? 'U' : 'S';
|
|
const bg = role === 'user' ? '#10a37f' : '#1a1a1a';
|
|
div.innerHTML = `
|
|
<div class="avatar" style="background:${bg}">${avatar}</div>
|
|
<div class="bubble">${html}</div>
|
|
`;
|
|
chat.appendChild(div);
|
|
chat.scrollTop = chat.scrollHeight;
|
|
requestAnimationFrame(() => div.classList.add('visible'));
|
|
}
|
|
|
|
function addTyping() {
|
|
const chat = document.getElementById('chat');
|
|
const div = document.createElement('div');
|
|
div.className = 'message assistant';
|
|
div.id = 'typing-indicator';
|
|
div.innerHTML = `
|
|
<div class="avatar" style="background:#1a1a1a">S</div>
|
|
<div class="bubble">
|
|
<div class="typing"><span></span><span></span><span></span></div>
|
|
</div>
|
|
`;
|
|
chat.appendChild(div);
|
|
chat.scrollTop = chat.scrollHeight;
|
|
requestAnimationFrame(() => div.classList.add('visible'));
|
|
}
|
|
|
|
function removeTyping() {
|
|
const t = document.getElementById('typing-indicator');
|
|
if (t) t.remove();
|
|
}
|
|
|
|
async function apiGet(path) {
|
|
const res = await fetch(`${API_BASE}${path}`, { headers: { 'x-api-key': API_KEY } });
|
|
return res.json();
|
|
}
|
|
|
|
async function apiPost(path, body) {
|
|
const res = await fetch(`${API_BASE}${path}`, {
|
|
method: 'POST',
|
|
headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(body)
|
|
});
|
|
return res.json();
|
|
}
|
|
|
|
async function runDemo() {
|
|
await sleep(1500);
|
|
|
|
// Step 1: Connect
|
|
addMessage('user', 'Connect my TikTok account to SquareMCP');
|
|
await sleep(800);
|
|
addTyping();
|
|
await sleep(1500);
|
|
removeTyping();
|
|
addMessage('assistant', `
|
|
I'll help you connect your TikTok account. Click the button below to authorize SquareMCP.
|
|
<br><br>
|
|
<button class="btn tiktok" onclick="this.textContent='Connecting...'">🎵 Connect with TikTok</button>
|
|
`);
|
|
await sleep(2500);
|
|
|
|
addTyping();
|
|
await sleep(2000);
|
|
removeTyping();
|
|
addMessage('assistant', `
|
|
<span class="success">✅ Account connected successfully!</span><br>
|
|
Welcome, <strong>Garfield Heron</strong>. Your TikTok account is now linked to SquareMCP.
|
|
`);
|
|
await sleep(2000);
|
|
|
|
// Step 2: Profile
|
|
addMessage('user', 'Show my TikTok profile and stats');
|
|
await sleep(800);
|
|
addTyping();
|
|
await sleep(1500);
|
|
removeTyping();
|
|
|
|
const profile = await apiGet('/api/tiktok/profile?account=tiktok');
|
|
addMessage('assistant', `
|
|
Here's your TikTok profile:<br>
|
|
<div class="profile-card">
|
|
<img src="${profile.avatar_url || ''}" onerror="this.style.display='none'" alt="avatar">
|
|
<div class="info">
|
|
<h3>${profile.display_name || 'Garfield Heron'}</h3>
|
|
<p>@${profile.username || 'garfieldheron'} ${profile.is_verified ? '✓' : ''}</p>
|
|
</div>
|
|
</div>
|
|
<div class="stats">
|
|
<div class="stat"><div class="num">${profile.follower_count ?? 0}</div><div class="lbl">Followers</div></div>
|
|
<div class="stat"><div class="num">${profile.following_count ?? 0}</div><div class="lbl">Following</div></div>
|
|
<div class="stat"><div class="num">${profile.likes_count ?? 0}</div><div class="lbl">Likes</div></div>
|
|
<div class="stat"><div class="num">${profile.video_count ?? 0}</div><div class="lbl">Videos</div></div>
|
|
</div>
|
|
`);
|
|
await sleep(2500);
|
|
|
|
// Step 3: Creator Info
|
|
addMessage('user', 'What are my publishing options?');
|
|
await sleep(800);
|
|
addTyping();
|
|
await sleep(1500);
|
|
removeTyping();
|
|
|
|
const creator = await apiGet('/api/tiktok/creator-info?account=tiktok');
|
|
addMessage('assistant', `
|
|
Here are your creator publishing settings:<br><br>
|
|
<strong>Creator:</strong> ${creator.creator_nickname || 'Garfield Heron'} (@${creator.creator_username || 'garfieldheron'})<br>
|
|
<strong>Max video duration:</strong> ${creator.max_video_post_duration_sec || 0} seconds<br>
|
|
<strong>Privacy options:</strong> ${(creator.privacy_level_options || []).join(', ')}<br>
|
|
<strong>Duet:</strong> ${creator.duet_disabled ? 'Disabled' : 'Enabled'}<br>
|
|
<strong>Stitch:</strong> ${creator.stitch_disabled ? 'Disabled' : 'Enabled'}<br>
|
|
<strong>Comments:</strong> ${creator.comment_disabled ? 'Disabled' : 'Enabled'}
|
|
`);
|
|
await sleep(2500);
|
|
|
|
// Step 4: Publish
|
|
addMessage('user', 'Publish this video to my TikTok: https://squaremcp.com/squaremcp-tiktok-launch.mp4');
|
|
await sleep(800);
|
|
addTyping();
|
|
await sleep(1500);
|
|
removeTyping();
|
|
|
|
addMessage('assistant', `
|
|
I'll publish that video for you.<br><br>
|
|
<div class="video-preview">
|
|
<video src="https://squaremcp.com/squaremcp-tiktok-launch.mp4" muted loop autoplay playsinline></video>
|
|
</div>
|
|
<br>
|
|
<em>Publishing with privacy: ${creator.privacy_level_options?.[0] || 'SELF_ONLY'} (sandbox restriction)</em>
|
|
`);
|
|
await sleep(2500);
|
|
|
|
addTyping();
|
|
await sleep(2000);
|
|
removeTyping();
|
|
|
|
const publish = await apiPost('/api/tiktok/video', {
|
|
video_url: 'https://squaremcp.com/squaremcp-tiktok-launch.mp4',
|
|
title: 'SquareMCP TikTok Launch 🚀',
|
|
account: 'tiktok'
|
|
});
|
|
addMessage('assistant', `
|
|
<span class="success">✅ Video published!</span><br>
|
|
<strong>Publish ID:</strong> <code>${publish.publish_id}</code><br>
|
|
<strong>Status:</strong> ${publish.status}
|
|
`);
|
|
await sleep(2000);
|
|
|
|
// Step 5: Status check
|
|
addMessage('user', 'Has the video finished processing?');
|
|
await sleep(800);
|
|
addTyping();
|
|
await sleep(2000);
|
|
removeTyping();
|
|
|
|
const status = await apiPost('/api/tiktok/video/status', {
|
|
publish_id: publish.publish_id,
|
|
account: 'tiktok'
|
|
});
|
|
addMessage('assistant', `
|
|
<div class="status-badge">${status.status}</div><br><br>
|
|
Your video has been successfully published to TikTok! You can view it in your TikTok app under your profile.
|
|
`);
|
|
await sleep(2000);
|
|
|
|
// End
|
|
addMessage('user', 'Thanks!');
|
|
await sleep(600);
|
|
addTyping();
|
|
await sleep(1000);
|
|
removeTyping();
|
|
addMessage('assistant', `
|
|
You're welcome! 🎉<br><br>
|
|
With SquareMCP, you can manage all your social media — TikTok, LinkedIn, Instagram, Facebook, Twitter/X, and more — directly from chat.
|
|
`);
|
|
}
|
|
|
|
runDemo();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|