Admin view
This surface is designed for hub owners and members. Admins can audit connections from Admin pages.
Continue in the app
' : '';
const flashHtml = startConnectFlash + (savedFlash === '1' ? 'Open PS Launcher, sign in with TikTok, then come back here and press Connect TikTok.
TikTok channel saved
' : savedFlash === 'removed' ? 'This hub can now use that TikTok slug for bridge health checks and bundle testing.
TikTok channel removed
' : savedFlash === 'missing_channel' ? 'This hub no longer has a saved TikTok channel.
Action needed
' : savedFlash === 'error' ? 'Enter a TikTok channel slug before saving.
Save failed
' : linkedFlash === '1' ? 'TikTok channel could not be saved right now.
TikTok account connected
' : linkedFlash === 'removed' ? 'This Pickle Systems account now has a connected TikTok profile. If this hub did not already have a TikTok channel saved, that channel was also applied automatically.
TikTok account disconnected
' : linkedFlash === 'missing_channel' ? 'The connected TikTok profile was removed from this Pickle Systems account.
Action needed
' : linkedFlash === 'account_missing' ? 'Finish the TikTok app sign-in first, then come back here.
Account setup needed
' : linkedFlash === 'identity_already_linked' ? 'This TikTok connection needs an existing Pickle Systems account first.
Already connected elsewhere
' : linkedFlash === 'error' ? 'That TikTok profile is already connected to another Pickle Systems account.
Connection failed
' : alignedFlash === '1' ? 'TikTok could not be connected to this Pickle Systems account right now.
Hub TikTok channel updated
' : alignedFlash === 'missing_connected' ? 'This hub now uses the connected TikTok profile as its saved TikTok channel.
Action needed
' : alignedFlash === 'error' ? 'Connect a TikTok profile to this account before using it for the hub.
Update failed
' : bundleFlash === 'missing_channel' ? 'The connected TikTok profile could not be applied to this hub right now.
Connect TikTok first
' : bundleFlash === 'error' ? 'Download the app, sign in with TikTok, then come back here and connect your account.
Download failed
' : bundleFlash === 'plain' ? 'PS Launcher.exe could not be prepared right now.
Fallback download used
' : '');
const effectiveSlug = normalizeChannelNameForPlatform('tiktok', savedSlug || linkedTikTokLogin || '');
const usingConnectedOnly = !savedSlug && !!linkedTikTokLogin;
const directHealthUrl = effectiveSlug ? `${publicBaseUrl}/api/tiktok/bridge/health?tenantId=${encodeURIComponent(tid)}&channelSlug=${encodeURIComponent(effectiveSlug)}` : `${publicBaseUrl}/api/tiktok/bridge/health?tenantId=${encodeURIComponent(tid)}&channelSlug=yourtiktokslug`;
const connectionsHealthHref = effectiveSlug ? `/connections/tiktok/health?channelSlug=${encodeURIComponent(effectiveSlug)}` : '/connections/tiktok/health';
let mappedTenantId = '';
try {
mappedTenantId = effectiveSlug ? String(await ctx?.db?.getTenantIdForChannel?.('tiktok', effectiveSlug) || '').trim() : '';
} catch {}
const mappingStatus = !effectiveSlug ? 'missing_channel' : (!mappedTenantId || mappedTenantId === tid ? (mappedTenantId ? 'matched' : 'unmapped') : 'mismatch');
const tenant = tid ? await ctx?.storage?.tenants?.getTenantById?.(tid) : null;
const fastLaneFeature = tid ? await ctx?.services?.entitlements?.getFeatureAccess?.(tid, 'tiktok_fast_lane') : null;
const premiumish = ['vip','premium','pro'];
const hasFastLane = premiumish.includes(String(tenant?.plan || '').toLowerCase()) && Number(fastLaneFeature?.enabled ?? 1) !== 0;
const responseLaneName = hasFastLane ? 'premium fast' : 'standard buffered';
const responseLaneTone = hasFastLane ? 'info' : 'muted';
const responseLaneHelp = hasFastLane ? 'This tenant is on the faster immediate TikTok lane.' : 'This tenant is on the standard TikTok lane. Relay commands are slightly buffered.';
const configuredBridgeSecret = String(cfg?.tiktokBridgeSecret || '').trim();
const secretConfigured = !!configuredBridgeSecret;
const oauthConfigured = !!(String(cfg?.tiktokClientKey || '').trim() && String(cfg?.tiktokClientSecret || '').trim());
const oauthReturnTarget = '/connections/tiktok?linked=1';
const oauthHref = oauthConfigured
? `/auth/tiktok-tenant?next=${encodeURIComponent(oauthReturnTarget)}`
: '';
const bundleSecretState = secretConfigured ? 'Scoped desktop token included' : 'Needs server secret first';
const readyToTest = !!effectiveSlug && mappingStatus !== 'mismatch' && secretConfigured;
const readinessTone = readyToTest ? 'info' : (effectiveSlug || secretConfigured ? 'warning' : 'muted');
const readinessText = !secretConfigured ? 'Setup needed' : !effectiveSlug ? 'Connect TikTok to continue' : mappingStatus === 'mismatch' ? 'Fix connection first' : usingConnectedOnly ? 'Ready from connected TikTok' : 'Ready';
const accountLinkState = linkedTikTokLogin ? (savedSlug && linkedTikTokLogin === savedSlug ? 'matched' : 'connected') : 'not_connected';
const accountLinkTone = accountLinkState === 'matched' ? 'info' : accountLinkState === 'connected' ? 'warning' : 'muted';
const accountLinkText = accountLinkState === 'matched' ? 'Connected to this account' : accountLinkState === 'connected' ? 'Connected, but different from saved channel' : 'Not connected';
const alignmentState = !savedSlug && !linkedTikTokLogin ? 'missing_both' : (!savedSlug && linkedTikTokLogin ? 'connected_only' : (savedSlug && !linkedTikTokLogin ? 'saved_only' : (savedSlug === linkedTikTokLogin ? 'aligned' : 'mismatch')));
const alignmentTone = alignmentState === 'aligned' ? 'info' : alignmentState === 'mismatch' ? 'warning' : alignmentState === 'connected_only' ? 'warning' : 'muted';
const alignmentText = alignmentState === 'aligned'
? 'Saved channel and connected TikTok match'
: alignmentState === 'connected_only'
? 'Connected TikTok is ready to be used as this hub channel'
: alignmentState === 'saved_only'
? 'Saved hub channel is not connected to this account yet'
: alignmentState === 'mismatch'
? 'Saved channel and connected TikTok are different'
: 'No saved or connected TikTok yet';
const channelSourceText = savedSlug ? 'Saved hub TikTok channel' : linkedTikTokLogin ? 'Connected TikTok profile (not saved to hub yet)' : 'No TikTok selected yet';
const channelSourceTone = savedSlug ? 'info' : linkedTikTokLogin ? 'warning' : 'muted';
const connectionsDashboardHref = '/t';
const bundleHref = `/connections/tiktok/download?tenantId=${encodeURIComponent(tid)}${effectiveSlug ? `&channelSlug=${encodeURIComponent(effectiveSlug)}` : ''}&publicBaseUrl=${encodeURIComponent(publicBaseUrl || 'https://www.picklesystems.net')}`;
const handoffTarget = effectiveSlug || savedSlug || linkedTikTokLogin || 'yourtiktokslug';
const handoffText = readyToTest
? `1. Download PS Launcher.exe. 2. Run the app. 3. Use Sign in with TikTok, or open Manual setup and fill the * fields if support gave you manual details. 4. Test !enter from @${handoffTarget}.`
: !effectiveSlug
? 'Save or connect a TikTok profile first, then download PS Launcher.exe for this hub.'
: 'This TikTok setup points at another account right now. Fix the mapping before handing this setup to a tester.';
return `
${flashHtml}
The prefilled launcher could not be generated, so Pickle Systems sent the standard PS Launcher.exe instead. Manual setup is still available in the desktop app.
TikTok
Download the Pickle Systems app, then sign in with TikTok.
Connect TikTok
Use the real TikTok sign-in flow here. After that, your account is connected.
Connected TikTok profile
The TikTok profile currently attached to your Pickle Systems account.
Account link status
Once the app signs in, connect that TikTok profile to this account.
${linkedTikTokLogin ? `` : (oauthConfigured ? `Sign in with TikTok` : '')}
Download PS Launcher
${!linkedTikTokLogin ? `After TikTok sign-in, this page will show your connected account automatically.${oauthConfigured ? '' : ' TikTok sign-in must be configured in Admin Platform Setup first.'}
` : ''}
Advanced
Use this when you want to run TikTok without OAuth or when support asks you to override the TikTok channel manually.
Status
Saved TikTok channel
The TikTok channel currently saved for this hub.
Connected TikTok profile
The TikTok profile connected to this Pickle Systems account.
TikTok source for setup
Connections now uses the saved hub channel first. If there is no saved hub channel yet, it can fall back to the connected TikTok profile for health checks and bundle handoff.
Alignment status
Best result: your saved hub channel and connected TikTok profile match so setup stays seamless across your hub, app bundle and giveaway path.
Mapping status
This confirms whether the TikTok setup currently being used resolves cleanly back to this hub.
Expected response lane
${esc(responseLaneHelp)}
Bridge secret
This checks whether the server side TikTok bridge secret is configured for this environment. When it is configured, Connections can mint the scoped desktop sign-in token used by the local app bundle and bootstrap sign-in flow.
Ready
Your TikTok setup is ready once the account, channel and mapping all line up.
Health check URL
Use this Connections-side check to confirm the bridge secret, mapping and lane are ready without manually adding secret headers.
PS Launcher
Download the Pickle Systems launcher for this account and hub. It is prefilled when possible, and the launcher still supports manual setup if you are not using TikTok sign-in yet.
Channel Dashboard
Open your Channel Dashboard after connecting TikTok.
App setup
Everything you need for the desktop app is here. Manual setup stays available in the launcher even if TikTok sign-in is not being used yet.
Tenant
The current signed-in hub that this TikTok setup belongs to.
TikTok channel
The TikTok channel currently driving setup for this hub.
Next steps
Use these exact steps on Windows.
${esc(handoffText)}
Bundle sign-in state
Shows whether the downloaded bundle can create its first desktop session with a scoped desktop sign-in token.
Bundle name
The download now uses the active TikTok setup source in the file name so it is easier to hand off without renaming it manually.
Local app page
After the app starts, open this page locally.
Health check
Use this to confirm the server side is ready for this TikTok setup.