socialcli 0.3.0__py3-none-any.whl

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.

Potentially problematic release.


This version of socialcli might be problematic. Click here for more details.

Files changed (224) hide show
  1. socialcli-0.3.0.dist-info/METADATA +168 -0
  2. socialcli-0.3.0.dist-info/RECORD +224 -0
  3. socialcli-0.3.0.dist-info/WHEEL +4 -0
  4. socialcli-0.3.0.dist-info/entry_points.txt +3 -0
  5. socialcli-0.3.0.dist-info/licenses/LICENSE +21 -0
  6. socialctl/__init__.py +0 -0
  7. socialctl/__main__.py +6 -0
  8. socialctl/adapters/__init__.py +6 -0
  9. socialctl/adapters/base.py +68 -0
  10. socialctl/adapters/errores.py +56 -0
  11. socialctl/adapters/facebook.py +180 -0
  12. socialctl/adapters/instagram.py +442 -0
  13. socialctl/adapters/tiktok.py +535 -0
  14. socialctl/adapters/youtube.py +331 -0
  15. socialctl/agent_errors.py +176 -0
  16. socialctl/agent_guide.py +23 -0
  17. socialctl/approval_cli.py +27 -0
  18. socialctl/auth.py +139 -0
  19. socialctl/authflow.py +344 -0
  20. socialctl/brands.py +194 -0
  21. socialctl/capabilities.py +57 -0
  22. socialctl/capabilities.yml +5945 -0
  23. socialctl/cli.py +1766 -0
  24. socialctl/connection_service/__init__.py +0 -0
  25. socialctl/connection_service/__main__.py +33 -0
  26. socialctl/connection_service/app.py +496 -0
  27. socialctl/connection_service/assets/PLATFORM-LOGOS-LICENSE.txt +50 -0
  28. socialctl/connection_service/assets/connection.css +75 -0
  29. socialctl/connection_service/assets/facebook.webp +0 -0
  30. socialctl/connection_service/assets/instagram.svg +194 -0
  31. socialctl/connection_service/assets/socialcli-logo.png +0 -0
  32. socialctl/connection_service/assets/tiktok.png +0 -0
  33. socialctl/connection_service/assets/youtube.svg +1 -0
  34. socialctl/connection_service/landing.py +146 -0
  35. socialctl/connection_service/legacy.py +48 -0
  36. socialctl/connection_service/peer.py +13 -0
  37. socialctl/connection_service/providers.py +324 -0
  38. socialctl/connection_service/settings.py +76 -0
  39. socialctl/connection_service/store.py +124 -0
  40. socialctl/connections/__init__.py +0 -0
  41. socialctl/connections/account_cli.py +438 -0
  42. socialctl/connections/cli.py +379 -0
  43. socialctl/connections/client.py +126 -0
  44. socialctl/connections/credential_cli.py +224 -0
  45. socialctl/connections/credential_store.py +49 -0
  46. socialctl/connections/file_store.py +193 -0
  47. socialctl/connections/keychain.py +78 -0
  48. socialctl/connections/meta_user.py +81 -0
  49. socialctl/connections/rotation_cli.py +116 -0
  50. socialctl/connections/saas_client.py +91 -0
  51. socialctl/connections/temporary_media.py +62 -0
  52. socialctl/delivery_options.py +70 -0
  53. socialctl/engagement.py +200 -0
  54. socialctl/engagement_cli.py +50 -0
  55. socialctl/executor.py +135 -0
  56. socialctl/formatter.py +291 -0
  57. socialctl/hosted_media.py +152 -0
  58. socialctl/identity.py +200 -0
  59. socialctl/inbox.py +298 -0
  60. socialctl/inbox_cli.py +46 -0
  61. socialctl/inventory.py +155 -0
  62. socialctl/inventory_cli.py +171 -0
  63. socialctl/inventory_sources.py +101 -0
  64. socialctl/management/__init__.py +1 -0
  65. socialctl/management/batch_cli.py +115 -0
  66. socialctl/management/batches.py +325 -0
  67. socialctl/management/changes.py +485 -0
  68. socialctl/management/cli.py +227 -0
  69. socialctl/management/comments_cli.py +352 -0
  70. socialctl/management/community_batch_cli.py +63 -0
  71. socialctl/management/community_batches.py +294 -0
  72. socialctl/management/community_changes.py +370 -0
  73. socialctl/management/community_cli.py +142 -0
  74. socialctl/management/community_schema.py +119 -0
  75. socialctl/management/facebook_groups.py +1118 -0
  76. socialctl/management/groups_cli.py +274 -0
  77. socialctl/management/inbox_readers.py +87 -0
  78. socialctl/management/meta_changes.py +197 -0
  79. socialctl/management/meta_cli.py +342 -0
  80. socialctl/management/meta_client.py +631 -0
  81. socialctl/management/meta_comment_inbox.py +565 -0
  82. socialctl/management/meta_comments.py +587 -0
  83. socialctl/management/meta_errors.py +59 -0
  84. socialctl/management/meta_pagination.py +52 -0
  85. socialctl/management/meta_schema.py +128 -0
  86. socialctl/management/meta_webhooks.py +147 -0
  87. socialctl/management/metadata_parts.py +144 -0
  88. socialctl/management/owned_assets.py +85 -0
  89. socialctl/management/owned_changes.py +470 -0
  90. socialctl/management/owned_cli.py +128 -0
  91. socialctl/management/owned_reorder.py +62 -0
  92. socialctl/management/owned_schema.py +368 -0
  93. socialctl/management/reply_context.py +24 -0
  94. socialctl/management/reply_evidence.py +80 -0
  95. socialctl/management/resource_changes.py +407 -0
  96. socialctl/management/resource_cli.py +136 -0
  97. socialctl/management/snippet_readback.py +26 -0
  98. socialctl/management/stories.py +713 -0
  99. socialctl/management/stories_cli.py +172 -0
  100. socialctl/management/youtube.py +323 -0
  101. socialctl/management/youtube_community.py +326 -0
  102. socialctl/management/youtube_metadata.py +122 -0
  103. socialctl/management/youtube_owned.py +259 -0
  104. socialctl/management/youtube_resources.py +305 -0
  105. socialctl/media.py +269 -0
  106. socialctl/media_cli.py +183 -0
  107. socialctl/media_ingress.py +211 -0
  108. socialctl/media_preflight.py +114 -0
  109. socialctl/media_registry.py +301 -0
  110. socialctl/media_requirements.py +52 -0
  111. socialctl/metricas/__init__.py +6 -0
  112. socialctl/metricas/almacen.py +133 -0
  113. socialctl/metricas/analytics_changes.py +295 -0
  114. socialctl/metricas/analytics_cli.py +191 -0
  115. socialctl/metricas/analytics_client.py +304 -0
  116. socialctl/metricas/analytics_ingest.py +260 -0
  117. socialctl/metricas/analytics_schema.py +174 -0
  118. socialctl/metricas/base.py +147 -0
  119. socialctl/metricas/facebook.py +418 -0
  120. socialctl/metricas/insights.py +227 -0
  121. socialctl/metricas/instagram.py +133 -0
  122. socialctl/metricas/modelos.py +87 -0
  123. socialctl/metricas/piezas.py +134 -0
  124. socialctl/metricas/reach.py +94 -0
  125. socialctl/metricas/reporting_client.py +112 -0
  126. socialctl/metricas/resumen.py +251 -0
  127. socialctl/metricas/slugs.py +89 -0
  128. socialctl/metricas/tiktok.py +185 -0
  129. socialctl/metricas/youtube.py +403 -0
  130. socialctl/migration_cli.py +60 -0
  131. socialctl/migration_files.py +68 -0
  132. socialctl/models.py +150 -0
  133. socialctl/native_schedule/__init__.py +13 -0
  134. socialctl/native_schedule/api_delivery.py +15 -0
  135. socialctl/native_schedule/api_reconcile.py +40 -0
  136. socialctl/native_schedule/approval.py +160 -0
  137. socialctl/native_schedule/cadence.py +73 -0
  138. socialctl/native_schedule/cli.py +510 -0
  139. socialctl/native_schedule/dispatcher.py +120 -0
  140. socialctl/native_schedule/facebook.py +112 -0
  141. socialctl/native_schedule/facebook_reels.py +140 -0
  142. socialctl/native_schedule/first_comment.py +181 -0
  143. socialctl/native_schedule/handoff.py +193 -0
  144. socialctl/native_schedule/instagram_delivery.py +224 -0
  145. socialctl/native_schedule/instagram_runtime.py +66 -0
  146. socialctl/native_schedule/inventory.py +70 -0
  147. socialctl/native_schedule/migration.py +310 -0
  148. socialctl/native_schedule/models.py +103 -0
  149. socialctl/native_schedule/reconcile.py +83 -0
  150. socialctl/native_schedule/remote_data.py +177 -0
  151. socialctl/native_schedule/report.py +151 -0
  152. socialctl/native_schedule/store.py +560 -0
  153. socialctl/native_schedule/verification.py +32 -0
  154. socialctl/native_schedule/youtube.py +339 -0
  155. socialctl/operation_output.py +87 -0
  156. socialctl/plantillas/accounts.yml +33 -0
  157. socialctl/plantillas/brand.md +95 -0
  158. socialctl/plantillas/estrategia.md +64 -0
  159. socialctl/postfile.py +240 -0
  160. socialctl/preflight.py +73 -0
  161. socialctl/publication_policy.py +34 -0
  162. socialctl/publication_status.py +75 -0
  163. socialctl/publication_steps.py +398 -0
  164. socialctl/publish_output.py +96 -0
  165. socialctl/publisher.py +445 -0
  166. socialctl/queue_migration.py +302 -0
  167. socialctl/read_budget.py +224 -0
  168. socialctl/read_reports.py +91 -0
  169. socialctl/rutas.py +103 -0
  170. socialctl/saas/__init__.py +1 -0
  171. socialctl/saas/access.py +75 -0
  172. socialctl/saas/auth.py +213 -0
  173. socialctl/saas/backup.py +124 -0
  174. socialctl/saas/billing.py +327 -0
  175. socialctl/saas/billing_enrollment.py +1237 -0
  176. socialctl/saas/billing_enrollment_schema.py +519 -0
  177. socialctl/saas/billing_inventory.py +775 -0
  178. socialctl/saas/billing_reconcile.py +127 -0
  179. socialctl/saas/billing_routes.py +27 -0
  180. socialctl/saas/budget.py +66 -0
  181. socialctl/saas/connections.py +374 -0
  182. socialctl/saas/consent.py +52 -0
  183. socialctl/saas/lifecycle.py +341 -0
  184. socialctl/saas/mail.py +89 -0
  185. socialctl/saas/maintenance.py +68 -0
  186. socialctl/saas/meta_user.py +298 -0
  187. socialctl/saas/meta_webhooks.py +358 -0
  188. socialctl/saas/migration.py +107 -0
  189. socialctl/saas/models.py +8 -0
  190. socialctl/saas/operations.py +102 -0
  191. socialctl/saas/pages.py +126 -0
  192. socialctl/saas/pairing.py +158 -0
  193. socialctl/saas/permissions.py +57 -0
  194. socialctl/saas/reminders.py +128 -0
  195. socialctl/saas/renewal.py +74 -0
  196. socialctl/saas/restore_guard.py +229 -0
  197. socialctl/saas/revocation.py +97 -0
  198. socialctl/saas/rotation.py +114 -0
  199. socialctl/saas/routes.py +221 -0
  200. socialctl/saas/settings.py +34 -0
  201. socialctl/saas/store.py +106 -0
  202. socialctl/saas/temporary_media.py +245 -0
  203. socialctl/saas/webhooks.py +76 -0
  204. socialctl/schedule_remote.py +262 -0
  205. socialctl/schedule_sqlite.py +44 -0
  206. socialctl/scheduler.py +581 -0
  207. socialctl/scheduler_launchd.py +319 -0
  208. socialctl/scheduler_systemd.py +167 -0
  209. socialctl/source_links.py +119 -0
  210. socialctl/ui/__init__.py +1 -0
  211. socialctl/ui/assets/agent-manual.md +850 -0
  212. socialctl/ui/assets/agents.md +27 -0
  213. socialctl/ui/assets/components.css +20 -0
  214. socialctl/ui/assets/connection-layout.css +53 -0
  215. socialctl/ui/assets/otp.template.html +10 -0
  216. socialctl/ui/assets/tokens.css +1 -0
  217. socialctl/ui/assets/trial.template.html +11 -0
  218. socialctl/ui/assets/web-layout.css +38 -0
  219. socialctl/ui/email/otp.html +10 -0
  220. socialctl/ui/email/trial.html +11 -0
  221. socialctl/upload_consent.py +13 -0
  222. socialctl/workspace.py +8 -0
  223. socialctl/youtube_data.py +471 -0
  224. socialctl/youtube_data_service.py +225 -0
@@ -0,0 +1,75 @@
1
+ /* Generated by scripts/build_ui_assets.py. Edit socialctl/ui/assets/. */
2
+ :root{color-scheme:light;--ink:#10213d;--muted:#627087;--blue:#1464ec;--line:#e5eaf2;--surface:#fff;--background:#f5f7fb;--danger:#a12b32;--radius:11px;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased}
3
+ /* Shared customer controls and accessibility. */
4
+ :focus-visible{outline:3px solid #8cbbff;outline-offset:4px}
5
+ .skip-link{position:absolute;left:16px;top:-100px;z-index:2;background:var(--surface);padding:12px;color:var(--blue)}
6
+ .skip-link:focus{top:12px}
7
+ label{display:block;text-align:left;font-size:14px;font-weight:600;margin:18px 0 7px}
8
+ input:not([type=hidden]):not([type=radio]):not([type=checkbox]),select{width:100%;min-height:48px;padding:12px;border:1px solid var(--line);border-radius:var(--radius);font:inherit;background:var(--surface);color:var(--ink)}
9
+ input[aria-invalid=true]:not([type=hidden]):not([type=radio]):not([type=checkbox]){border-color:var(--danger)}
10
+ .field-error{color:var(--danger);font-size:13px;text-align:left;line-height:1.5}
11
+ .form-stack{display:grid;grid-template-columns:minmax(0,1fr);gap:14px;text-align:left;margin-top:24px}
12
+ .status-notice{border:1px solid var(--line);border-radius:var(--radius);padding:16px;margin:20px 0;line-height:1.6;text-align:left;overflow-wrap:anywhere}
13
+ .status-notice[role=alert]{border-color:var(--danger)}
14
+ .account-list{list-style:none;padding:0;display:grid;gap:12px;text-align:left}
15
+ .account-list li{border:1px solid var(--line);padding:16px;border-radius:var(--radius);overflow-wrap:anywhere}
16
+ button:disabled{opacity:.65;cursor:wait}
17
+ @media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
18
+
19
+ .permission-options{min-width:0;border:1px solid var(--line);border-radius:var(--radius);padding:16px;margin:0;text-align:left}
20
+ .permission-options legend{max-width:100%;padding:0 6px;font-size:14px;font-weight:600}
21
+ .permission-options label{display:flex;align-items:center;gap:10px;min-height:44px;margin:0}
22
+ .permission-options input{width:18px;height:18px;margin:0;accent-color:var(--blue);flex-shrink:0}
23
+ *{box-sizing:border-box}
24
+ body{margin:0;min-height:100svh;color:var(--ink);background:var(--background);background-image:radial-gradient(ellipse at 50% 0%,#e9effb 0,transparent 60%);display:flex;flex-direction:column}
25
+ a{color:inherit;text-decoration:none}
26
+ svg{width:20px;height:20px;flex-shrink:0}
27
+ .site-header{width:min(1120px,100%);margin:0 auto;padding:30px 40px;display:flex;align-items:center;justify-content:space-between;gap:20px}
28
+ .wordmark{display:inline-flex;align-items:center;gap:11px;font-size:23px;font-weight:700;letter-spacing:-.7px}
29
+ .wordmark img{display:block;border-radius:12px}
30
+ .header-label{font-size:10px;font-weight:650;letter-spacing:1.8px;color:var(--muted)}
31
+ main{width:100%;padding:30px 24px 35px;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}
32
+ .connection-card{overflow-wrap:anywhere;position:relative;overflow:hidden;width:min(100%,540px);background:var(--surface);border:1px solid #dfe6f1;border-radius:24px;padding:38px 44px 28px;text-align:center;box-shadow:0 24px 64px -32px #19335c38,0 3px 12px #19335c04}
33
+ .connection-card:before{content:"";position:absolute;top:0;left:calc(50% - 38px);width:76px;height:3px;background:var(--blue);border-radius:0 0 3px 3px}
34
+ .connection-symbols{display:flex;align-items:center;justify-content:center;margin:0 0 25px}
35
+ .connection-symbols img{display:block;border-radius:17px}
36
+ .connection-line{width:48px;height:1px;margin:0 14px;background:#d6dfed;position:relative}
37
+ .connection-line:before,.connection-line:after{content:"";position:absolute;width:5px;height:5px;border-radius:50%;background:#b9c8df;top:-2px}
38
+ .connection-line:before{left:0}.connection-line:after{right:0}
39
+ .provider-mark{width:64px;height:64px;display:grid;place-items:center;border:1px solid var(--line);border-radius:18px;background:#fff}
40
+ .connection-symbols .provider-logo{width:36px;height:36px;border-radius:0}
41
+ .provider-app-icon{background:transparent;border:0;border-radius:0}
42
+ .connection-symbols .provider-app-icon .provider-logo{width:100%;height:100%;object-fit:contain;border-radius:0}
43
+ .eyebrow{margin:0 0 12px;font-size:10px;font-weight:700;letter-spacing:1.7px;color:var(--blue)}
44
+ h1{font-size:clamp(30px,4vw,38px);line-height:1.13;font-weight:650;letter-spacing:-1.35px;margin:0;text-wrap:balance}
45
+ .description{margin:16px auto 0;max-width:360px;font-size:14px;line-height:1.65;color:var(--muted);text-wrap:pretty}
46
+ .steps{list-style:none;padding:0;margin:26px 0 24px;display:flex;align-items:center;justify-content:center;gap:18px}
47
+ .steps li{display:flex;align-items:center;gap:6px;color:#6b788b;font-size:10px;white-space:nowrap;font-weight:500}
48
+ .steps li span{display:grid;place-items:center;width:19px;height:19px;border-radius:50%;border:1px solid #dfe5ee;font-size:9px}
49
+ .steps .current{color:var(--blue);font-weight:650}.steps .current span{background:#edf3ff;border-color:#d2e2ff}
50
+ form{margin:0}
51
+ .primary-button,.secondary-button{width:100%;min-height:52px;border:1px solid transparent;border-radius:11px;display:flex;align-items:center;justify-content:center;gap:14px;font:inherit;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s,box-shadow .15s,transform .15s}
52
+ .primary-button{color:#fff;background:var(--blue);box-shadow:0 4px 10px #1464ec24}
53
+ .primary-button svg{width:18px;height:18px}.primary-button:hover{background:#0d51cc;box-shadow:0 5px 15px #1464ec30}.primary-button:active{transform:translateY(1px)}
54
+ .secondary-button{color:var(--ink);background:#f4f7fc;border-color:#dfe6f1;margin-top:24px}.secondary-button:hover{background:#eaf0fa}
55
+ :focus-visible{outline:3px solid #8cbbff;outline-offset:4px}
56
+ .button-note{font-size:11px;line-height:1.5;color:#768297;margin:11px 0 0}
57
+ .connection-details{margin:26px 0 22px;padding-top:22px;border-top:1px solid var(--line);display:grid;gap:17px;text-align:left}
58
+ .detail{display:flex;gap:12px;align-items:flex-start}.detail>svg{margin-top:2px;color:#6b80a0;width:18px;height:18px}
59
+ h2{font-size:12px;font-weight:650;line-height:1.5;margin:0 0 3px}
60
+ .detail p,.return-panel p{font-size:11px;line-height:1.65;color:var(--muted);margin:0}
61
+ .quiet-notice{padding:11px 14px;background:#f3f6fc;border:1px solid #e9eef7;border-radius:9px;font-size:11px;line-height:1.6;color:#536580;margin:0;text-wrap:pretty}
62
+ .expiry-note{font-size:10px;line-height:1.6;color:#7b8699;margin:13px 0 0}
63
+ .trust-note{display:flex;align-items:center;justify-content:center;gap:6px;margin:21px 0 0;font-size:10px;color:#6f7d93;letter-spacing:.1px;text-align:center;line-height:1.6}
64
+ .trust-note svg{width:12px;height:12px}
65
+ .site-footer{width:min(1120px,100%);margin:0 auto;padding:22px 40px 27px;display:flex;align-items:center;justify-content:space-between;gap:20px;color:#7b8697;font-size:11px;line-height:1.6}
66
+ .site-footer nav{display:flex;gap:22px}.site-footer a:hover,.text-link:hover{color:var(--blue)}
67
+ .result-symbol{width:72px;height:72px;border-radius:22px;display:grid;place-items:center;margin:4px auto 27px;border:1px solid}
68
+ .result-symbol svg{width:31px;height:31px}.success{color:#208265;background:#eef9f4;border-color:#d7eee3}.neutral{color:#60728e;background:#f1f4fa;border-color:#e2e8f2}.warning{color:#9c6c26;background:#fff9ed;border-color:#f3e7cc}
69
+ .return-panel{display:flex;align-items:flex-start;gap:12px;padding:18px 19px;text-align:left;margin:27px 0 21px;border:1px solid var(--line);border-radius:12px;background:#fafbfd}
70
+ .return-panel>svg{margin-top:2px;color:var(--blue)}
71
+ .text-link{display:inline-flex;align-items:center;gap:8px;color:#556986;font-size:11px;margin-top:22px;font-weight:600;min-height:30px}
72
+ @media(min-width:1400px){main{padding-top:45px;padding-bottom:50px}}
73
+ @media(max-width:600px){.site-header{padding:23px 24px}.wordmark{font-size:21px}.wordmark img{width:36px;height:36px}.header-label{font-size:8px;letter-spacing:1.2px}main{padding:16px 16px 25px;justify-content:flex-start}.connection-card{padding:30px 25px 24px;border-radius:20px}h1{font-size:34px;letter-spacing:-1.1px}.description{font-size:13px;max-width:320px}.steps{gap:14px}.connection-details{margin-top:24px}.site-footer{padding:18px 24px 22px;flex-direction:column;gap:10px}.trust-note{font-size:9px}.provider-mark,.connection-symbols img{width:58px;height:58px}.connection-line{width:34px;margin:0 12px}}
74
+ @media(max-width:360px){.header-label{display:none}.connection-card{padding-left:20px;padding-right:20px}h1{font-size:30px}.steps{gap:9px}.steps li{font-size:9px}}
75
+ @media(prefers-reduced-motion:reduce){*{transition:none!important}}
@@ -0,0 +1,194 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:xlink="http://www.w3.org/1999/xlink"
9
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ width="264.58334mm"
12
+ height="264.58334mm"
13
+ viewBox="0 0 264.58334 264.58334"
14
+ version="1.1"
15
+ id="svg8"
16
+ inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
17
+ sodipodi:docname="Instagram_(2022).svg">
18
+ <defs
19
+ id="defs2">
20
+ <linearGradient
21
+ inkscape:collect="always"
22
+ id="linearGradient2531">
23
+ <stop
24
+ style="stop-color:#ff005f;stop-opacity:1"
25
+ offset="0"
26
+ id="stop2527" />
27
+ <stop
28
+ style="stop-color:#fc01d8;stop-opacity:1"
29
+ offset="1"
30
+ id="stop2529" />
31
+ </linearGradient>
32
+ <linearGradient
33
+ id="linearGradient2513">
34
+ <stop
35
+ offset="0"
36
+ stop-color="#3771c8"
37
+ id="stop2505"
38
+ style="stop-color:#780cff;stop-opacity:1" />
39
+ <stop
40
+ stop-color="#3771c8"
41
+ offset="1"
42
+ id="stop2507"
43
+ style="stop-color:#820bff;stop-opacity:0" />
44
+ </linearGradient>
45
+ <linearGradient
46
+ inkscape:collect="always"
47
+ id="linearGradient2485">
48
+ <stop
49
+ style="stop-color:#ffcc00;stop-opacity:1"
50
+ offset="0"
51
+ id="stop2481" />
52
+ <stop
53
+ style="stop-color:#ffcc00;stop-opacity:0"
54
+ offset="1"
55
+ id="stop2483" />
56
+ </linearGradient>
57
+ <linearGradient
58
+ id="a">
59
+ <stop
60
+ offset="0"
61
+ stop-color="#fd5"
62
+ id="stop14"
63
+ style="stop-color:#ffcc00;stop-opacity:1" />
64
+ <stop
65
+ offset="0.12416067"
66
+ stop-color="#fd5"
67
+ id="stop16"
68
+ style="stop-color:#ffcc00;stop-opacity:1" />
69
+ <stop
70
+ offset="0.56719624"
71
+ stop-color="#fd5"
72
+ id="stop2487"
73
+ style="stop-color:#fe4a05;stop-opacity:1" />
74
+ <stop
75
+ offset="0.69420281"
76
+ stop-color="#ff543e"
77
+ id="stop18"
78
+ style="stop-color:#ff0f3f;stop-opacity:1" />
79
+ <stop
80
+ offset="1"
81
+ stop-color="#ff543e"
82
+ id="stop2515"
83
+ style="stop-color:#fe0657;stop-opacity:0" />
84
+ </linearGradient>
85
+ <radialGradient
86
+ id="c"
87
+ cx="158.429"
88
+ cy="578.08801"
89
+ r="52.351524"
90
+ xlink:href="#a"
91
+ gradientUnits="userSpaceOnUse"
92
+ gradientTransform="matrix(0,-4.0341789,4.2801844,0,-2332.2273,942.2356)"
93
+ fx="158.429"
94
+ fy="578.08801" />
95
+ <radialGradient
96
+ inkscape:collect="always"
97
+ xlink:href="#linearGradient2485"
98
+ id="radialGradient2479"
99
+ gradientUnits="userSpaceOnUse"
100
+ gradientTransform="matrix(0.67441347,-1.1620263,1.5128335,0.87801401,-814.3657,-47.835421)"
101
+ cx="172.61488"
102
+ cy="600.69244"
103
+ fx="172.61488"
104
+ fy="600.69244"
105
+ r="65" />
106
+ <radialGradient
107
+ inkscape:collect="always"
108
+ xlink:href="#linearGradient2513"
109
+ id="radialGradient2503"
110
+ cx="144.01199"
111
+ cy="51.3367"
112
+ fx="144.01199"
113
+ fy="51.3367"
114
+ r="67.080994"
115
+ gradientTransform="matrix(-2.3989082,0.67548907,-0.23007853,-0.81731518,464.99573,-26.403484)"
116
+ gradientUnits="userSpaceOnUse" />
117
+ <radialGradient
118
+ inkscape:collect="always"
119
+ xlink:href="#linearGradient2531"
120
+ id="radialGradient2525"
121
+ gradientUnits="userSpaceOnUse"
122
+ gradientTransform="matrix(-3.1079707,0.87652434,-0.63149336,-2.2391423,1345.6503,1374.1983)"
123
+ cx="199.78836"
124
+ cy="628.43787"
125
+ fx="199.78836"
126
+ fy="628.43787"
127
+ r="52.351524" />
128
+ </defs>
129
+ <sodipodi:namedview
130
+ id="base"
131
+ pagecolor="#ffffff"
132
+ bordercolor="#666666"
133
+ borderopacity="1.0"
134
+ inkscape:pageopacity="0.0"
135
+ inkscape:pageshadow="2"
136
+ inkscape:zoom="0.51499999"
137
+ inkscape:cx="500"
138
+ inkscape:cy="500.00001"
139
+ inkscape:document-units="mm"
140
+ inkscape:current-layer="layer1"
141
+ inkscape:document-rotation="0"
142
+ showgrid="false"
143
+ inkscape:window-width="1366"
144
+ inkscape:window-height="705"
145
+ inkscape:window-x="-8"
146
+ inkscape:window-y="-8"
147
+ inkscape:window-maximized="1" />
148
+ <metadata
149
+ id="metadata5">
150
+ <rdf:RDF>
151
+ <cc:Work
152
+ rdf:about="">
153
+ <dc:format>image/svg+xml</dc:format>
154
+ <dc:type
155
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
156
+ <dc:title></dc:title>
157
+ </cc:Work>
158
+ </rdf:RDF>
159
+ </metadata>
160
+ <g
161
+ inkscape:label="Layer 1"
162
+ inkscape:groupmode="layer"
163
+ id="layer1"
164
+ transform="translate(-71.815468,-18.142853)">
165
+ <g
166
+ id="g986">
167
+ <path
168
+ d="m 204.15032,18.142853 c -55.23055,0 -71.38338,0.05699 -74.52318,0.317526 -11.33425,0.942403 -18.38712,2.727476 -26.07081,6.554082 -5.921479,2.941193 -10.591515,6.350535 -15.200504,11.129723 -8.393854,8.715706 -13.481038,19.438344 -15.322599,32.184197 -0.895345,6.187704 -1.155808,7.449668 -1.208715,39.055809 -0.02035,10.53538 0,24.40072 0,42.99843 0,55.20082 0.06105,71.34177 0.32558,74.47633 0.915693,11.03203 2.645335,17.97284 6.308108,25.56499 6.999966,14.53296 20.369086,25.44286 36.11901,29.51371 5.45346,1.40445 11.47669,2.17791 19.20921,2.54429 3.27614,0.14248 36.66842,0.24425 70.08105,0.24425 33.41263,0 66.82526,-0.0407 70.02001,-0.20354 8.95344,-0.42134 14.15255,-1.11949 19.90106,-2.60535 15.85167,-4.09121 28.97661,-14.83828 36.11901,-29.57478 3.59156,-7.40896 5.41277,-14.61438 6.23689,-25.07038 0.17907,-2.27967 0.25436,-38.62632 0.25436,-74.92412 0,-36.30391 -0.0814,-72.583393 -0.26047,-74.863071 -0.83429,-10.624939 -2.6555,-17.769292 -6.36304,-25.320733 -3.04214,-6.181596 -6.42003,-10.797949 -11.32407,-15.518109 -8.752,-8.361541 -19.45543,-13.450112 -32.21002,-15.290139 -6.17991,-0.893554 -7.41101,-1.158159 -39.03295,-1.213115 z"
169
+ id="path2517"
170
+ style="fill:url(#radialGradient2525);fill-opacity:1;stroke-width:0.264619"
171
+ inkscape:connector-curvature="0" />
172
+ <path
173
+ d="m 204.15032,18.142853 c -55.23055,0 -71.38338,0.05699 -74.52318,0.317526 -11.33425,0.942403 -18.38712,2.727476 -26.07081,6.554082 -5.921479,2.941193 -10.591515,6.350535 -15.200504,11.129723 -8.393854,8.715706 -13.481038,19.438344 -15.322599,32.184197 -0.895345,6.187704 -1.155808,7.449668 -1.208715,39.055809 -0.02035,10.53538 0,24.40072 0,42.99843 0,55.20082 0.06105,71.34177 0.32558,74.47633 0.915693,11.03203 2.645335,17.97284 6.308108,25.56499 6.999966,14.53296 20.369086,25.44286 36.11901,29.51371 5.45346,1.40445 11.47669,2.17791 19.20921,2.54429 3.27614,0.14248 36.66842,0.24425 70.08105,0.24425 33.41263,0 66.82526,-0.0407 70.02001,-0.20354 8.95344,-0.42134 14.15255,-1.11949 19.90106,-2.60535 15.85167,-4.09121 28.97661,-14.83828 36.11901,-29.57478 3.59156,-7.40896 5.41277,-14.61438 6.23689,-25.07038 0.17907,-2.27967 0.25436,-38.62632 0.25436,-74.92412 0,-36.30391 -0.0814,-72.583393 -0.26047,-74.863071 -0.83429,-10.624939 -2.6555,-17.769292 -6.36304,-25.320733 -3.04214,-6.181596 -6.42003,-10.797949 -11.32407,-15.518109 -8.752,-8.361541 -19.45543,-13.450112 -32.21002,-15.290139 -6.17991,-0.893554 -7.41101,-1.158159 -39.03295,-1.213115 z"
174
+ id="path24"
175
+ style="fill:url(#c);stroke-width:0.264619"
176
+ inkscape:connector-curvature="0" />
177
+ <path
178
+ d="m 204.15032,18.142853 c -55.23055,0 -71.38338,0.05699 -74.52318,0.317526 -11.33425,0.942403 -18.38712,2.727476 -26.07081,6.554082 -5.921479,2.941193 -10.591515,6.350535 -15.200504,11.129723 -8.393854,8.715706 -13.481038,19.438344 -15.322599,32.184197 -0.895345,6.187704 -1.155808,7.449668 -1.208715,39.055809 -0.02035,10.53538 0,24.40072 0,42.99843 0,55.20082 0.06105,71.34177 0.32558,74.47633 0.915693,11.03203 2.645335,17.97284 6.308108,25.56499 6.999966,14.53296 20.369086,25.44286 36.11901,29.51371 5.45346,1.40445 11.47669,2.17791 19.20921,2.54429 3.27614,0.14248 36.66842,0.24425 70.08105,0.24425 33.41263,0 66.82526,-0.0407 70.02001,-0.20354 8.95344,-0.42134 14.15255,-1.11949 19.90106,-2.60535 15.85167,-4.09121 28.97661,-14.83828 36.11901,-29.57478 3.59156,-7.40896 5.41277,-14.61438 6.23689,-25.07038 0.17907,-2.27967 0.25436,-38.62632 0.25436,-74.92412 0,-36.30391 -0.0814,-72.583393 -0.26047,-74.863071 -0.83429,-10.624939 -2.6555,-17.769292 -6.36304,-25.320733 -3.04214,-6.181596 -6.42003,-10.797949 -11.32407,-15.518109 -8.752,-8.361541 -19.45543,-13.450112 -32.21002,-15.290139 -6.17991,-0.893554 -7.41101,-1.158159 -39.03295,-1.213115 z"
179
+ id="path2471"
180
+ style="fill:url(#radialGradient2479);fill-opacity:1;stroke-width:0.264619"
181
+ inkscape:connector-curvature="0" />
182
+ <path
183
+ d="m 204.15032,18.142853 c -55.23055,0 -71.38338,0.05699 -74.52318,0.317526 -11.33425,0.942403 -18.38712,2.727476 -26.07081,6.554082 -5.921479,2.941193 -10.591515,6.350535 -15.200504,11.129723 -8.393854,8.715706 -13.481038,19.438344 -15.322599,32.184197 -0.895345,6.187704 -1.155808,7.449668 -1.208715,39.055809 -0.02035,10.53538 0,24.40072 0,42.99843 0,55.20082 0.06105,71.34177 0.32558,74.47633 0.915693,11.03203 2.645335,17.97284 6.308108,25.56499 6.999966,14.53296 20.369086,25.44286 36.11901,29.51371 5.45346,1.40445 11.47669,2.17791 19.20921,2.54429 3.27614,0.14248 36.66842,0.24425 70.08105,0.24425 33.41263,0 66.82526,-0.0407 70.02001,-0.20354 8.95344,-0.42134 14.15255,-1.11949 19.90106,-2.60535 15.85167,-4.09121 28.97661,-14.83828 36.11901,-29.57478 3.59156,-7.40896 5.41277,-14.61438 6.23689,-25.07038 0.17907,-2.27967 0.25436,-38.62632 0.25436,-74.92412 0,-36.30391 -0.0814,-72.583393 -0.26047,-74.863071 -0.83429,-10.624939 -2.6555,-17.769292 -6.36304,-25.320733 -3.04214,-6.181596 -6.42003,-10.797949 -11.32407,-15.518109 -8.752,-8.361541 -19.45543,-13.450112 -32.21002,-15.290139 -6.17991,-0.893554 -7.41101,-1.158159 -39.03295,-1.213115 z"
184
+ id="path2501"
185
+ style="fill:url(#radialGradient2503);fill-opacity:1;stroke-width:0.264619"
186
+ inkscape:connector-curvature="0" />
187
+ <path
188
+ d="m 204.16071,52.115853 c -26.71676,0 -30.06967,0.116733 -40.56291,0.593903 -10.47273,0.479218 -17.62124,2.135999 -23.87619,4.566903 -6.47015,2.510768 -11.9586,5.869386 -17.42655,11.335331 -5.47206,5.463898 -8.83317,10.948278 -11.35401,17.411568 -2.43885,6.252353 -4.09891,13.397611 -4.57029,23.858462 -0.46933,10.48547 -0.59229,13.83792 -0.59229,40.53486 0,26.6969 0.11887,30.03709 0.59434,40.5225 0.48162,10.46498 2.13964,17.60819 4.57029,23.8585 2.51469,6.46533 5.8758,11.9497 11.34581,17.41361 5.4659,5.46797 10.95436,8.83482 17.4204,11.34555 6.25905,2.43091 13.40961,4.08769 23.8803,4.56694 10.49323,0.47714 13.84409,0.59388 40.55878,0.59388 26.7188,0 30.06147,-0.11674 40.55469,-0.59388 10.47276,-0.47925 17.62944,-2.13603 23.88849,-4.56694 6.4681,-2.51073 11.94837,-5.87758 17.41428,-11.34555 5.47205,-5.46391 8.83317,-10.94828 11.354,-17.41157 2.41836,-6.25235 4.07842,-13.3976 4.57029,-23.85848 0.47137,-10.48543 0.59433,-13.82766 0.59433,-40.52456 0,-26.69694 -0.12296,-30.04734 -0.59433,-40.53282 -0.49187,-10.464941 -2.15193,-17.608149 -4.57029,-23.858455 -2.52083,-6.465337 -5.88195,-11.949717 -11.354,-17.413615 -5.47208,-5.467992 -10.94414,-8.826611 -17.42042,-11.335331 -6.27135,-2.430904 -13.42395,-4.087685 -23.89667,-4.566903 -10.49325,-0.47717 -13.83387,-0.593903 -40.55881,-0.593903 z m -8.82498,17.714662 c 2.6192,-0.0041 5.54174,0 8.82498,0 26.26586,0 29.37898,0.09421 39.75129,0.565232 9.59148,0.438259 14.79708,2.039745 18.26476,3.385241 4.59082,1.781706 7.86379,3.911558 11.30483,7.352095 3.44309,3.440534 5.57452,6.717238 7.36165,11.304618 1.34651,3.461013 2.95122,8.662769 3.38775,18.247119 0.47138,10.36255 0.57388,13.47545 0.57388,39.7095 0,26.23408 -0.1025,29.34698 -0.57388,39.70953 -0.43858,9.58432 -2.04124,14.7861 -3.38775,18.24712 -1.78301,4.58739 -3.91856,7.85385 -7.36165,11.29232 -3.44308,3.44054 -6.71197,5.57039 -11.30483,7.3521 -3.46358,1.35166 -8.67328,2.94904 -18.26476,3.38728 -10.37026,0.47103 -13.48543,0.57342 -39.75129,0.57342 -26.26793,0 -29.38106,-0.10239 -39.75132,-0.57342 -9.59147,-0.44233 -14.79709,-2.04384 -18.26683,-3.38933 -4.59079,-1.7817 -7.86992,-3.91155 -11.31301,-7.35209 -3.44309,-3.44053 -5.57453,-6.70906 -7.36166,-11.29846 -1.34649,-3.46102 -2.95122,-8.6628 -3.38776,-18.24716 -0.47137,-10.36255 -0.56565,-13.47539 -0.56565,-39.72588 0,-26.25044 0.0943,-29.34695 0.56565,-39.7095 0.43859,-9.58435 2.04127,-14.786113 3.38776,-18.251221 1.78303,-4.587381 3.91857,-7.864081 7.36166,-11.304618 3.44309,-3.440533 6.72222,-5.570389 11.31301,-7.356192 3.46769,-1.351636 8.67536,-2.949031 18.26683,-3.389336 9.07501,-0.409585 12.59187,-0.532463 30.92634,-0.552941 z m 61.33621,16.322063 c -6.5173,0 -11.80488,5.277535 -11.80488,11.792022 0,6.51245 5.28758,11.79612 11.80488,11.79612 6.51727,0 11.80488,-5.28367 11.80488,-11.79612 0,-6.51244 -5.28761,-11.796117 -11.80488,-11.796117 z m -52.51123,13.782618 c -27.8993,0 -50.51918,22.603094 -50.51918,50.481684 0,27.87855 22.61988,50.47139 50.51918,50.47139 27.89928,0 50.51094,-22.59284 50.51094,-50.47139 0,-27.87859 -22.61371,-50.481684 -50.51303,-50.481684 z m 0,17.714654 c 18.109,0 32.79132,14.66941 32.79132,32.76703 0,18.09554 -14.68232,32.76699 -32.79132,32.76699 -18.11108,0 -32.79136,-14.67145 -32.79136,-32.76699 0,-18.09762 14.68028,-32.76703 32.79136,-32.76703 z"
189
+ id="path28"
190
+ inkscape:connector-curvature="0"
191
+ style="fill:#ffffff;stroke-width:0.266378" />
192
+ </g>
193
+ </g>
194
+ </svg>
@@ -0,0 +1 @@
1
+ <svg fill="#FF0000" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>YouTube</title><path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
@@ -0,0 +1,146 @@
1
+ """Read-only login landing and browser-bound, authenticated form tokens."""
2
+ from __future__ import annotations
3
+
4
+ import hashlib
5
+ import hmac
6
+ import json
7
+ from html import escape
8
+
9
+ from cryptography.fernet import Fernet, MultiFernet
10
+
11
+
12
+ ASSETS = '/connect/assets'
13
+
14
+ PROVIDER_LOGOS = {'youtube': 'youtube.svg', 'facebook': 'facebook.webp',
15
+ 'instagram': 'instagram.svg', 'tiktok': 'tiktok.png'}
16
+
17
+ PROVIDERS = {
18
+ 'youtube': ('YouTube', 'Google', 'Choose your channel and review access with Google.'),
19
+ 'facebook': ('Facebook', 'Facebook', 'Choose the Page you want to connect with SocialCli.'),
20
+ 'instagram': ('Instagram', 'Facebook', 'Connect your professional account through Facebook Login.'),
21
+ 'tiktok': ('TikTok', 'TikTok', 'Sign in to TikTok and choose the access you want to share.'),
22
+ }
23
+
24
+
25
+ def _icon(name: str) -> str:
26
+ paths = {
27
+ 'arrow': '<path d="M5 12h14m-6-6 6 6-6 6"/>',
28
+ 'lock': '<rect x="5" y="10" width="14" height="11" rx="3"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/>',
29
+ 'terminal': '<rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3m6 0h4"/>',
30
+ 'check': '<path d="m5 12 4 4L19 6"/>',
31
+ 'refresh': '<path d="M20 7v5h-5M4 17v-5h5"/><path d="M6 7a7 7 0 0 1 12-1l2 6M4 12l2 6a7 7 0 0 0 12-1"/>',
32
+ 'close': '<path d="m6 6 12 12M6 18 18 6"/>',
33
+ }
34
+ return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' + paths[name] + '</svg>'
35
+
36
+
37
+ def _page(title: str, content: str, *, platform=None) -> str:
38
+ provider = PROVIDERS.get(platform)
39
+ logo = PROVIDER_LOGOS[platform] if provider else 'socialcli-logo.png'
40
+ mime = {'svg': 'image/svg+xml', 'png': 'image/png', 'webp': 'image/webp'}[logo.rsplit('.', 1)[1]]
41
+ label = provider[0].upper() + ' CONNECTION' if provider else 'ACCOUNT CONNECTION'
42
+ return f'''<!doctype html>
43
+ <html lang="en"><head><meta charset="utf-8">
44
+ <meta name="viewport" content="width=device-width,initial-scale=1">
45
+ <meta name="robots" content="noindex,nofollow">
46
+ <meta name="color-scheme" content="light">
47
+ <title>{escape(title)} · SocialCli</title>
48
+ <link rel="icon" type="{mime}" href="{ASSETS}/{logo}">
49
+ <link rel="stylesheet" href="{ASSETS}/connection.css">
50
+ </head><body>
51
+ <header class="site-header"><a class="wordmark" href="/" aria-label="SocialCli home">
52
+ <img src="{ASSETS}/socialcli-logo.png" alt="SocialCli" width="42" height="42"><span>SocialCli</span></a>
53
+ <span class="header-label">{label}</span></header>
54
+ <main id="main-content"><section class="connection-card" aria-labelledby="page-title">{content}</section>
55
+ <p class="trust-note">{_icon('lock')} Your account. Your permissions. Your choice.</p></main>
56
+ <footer class="site-footer"><span>Social tools. Human control.</span>
57
+ <nav aria-label="Legal and support"><a href="/privacy.html">Privacy</a><a href="/terms.html">Terms</a><a href="/connections.html">Help</a></nav>
58
+ </footer></body></html>'''
59
+
60
+
61
+ def connection_symbols(platform):
62
+ return f'''<div class="connection-symbols" aria-hidden="true"><img src="{ASSETS}/socialcli-logo.png" alt="" width="64" height="64">
63
+ <span class="connection-line"></span><span class="provider-mark provider-{platform}{" provider-app-icon" if platform != "youtube" else ""}"><img class="provider-logo" src="{ASSETS}/{PROVIDER_LOGOS[platform]}" alt="" width="32" height="32"></span></div>'''
64
+
65
+
66
+ def landing_page(authorization_id: str, form_token: str, *, platform='youtube', browser_selection=False) -> str:
67
+ from socialctl.saas import consent
68
+ from socialctl.saas.pages import assistant_choice_html
69
+ privacy = f'<input type="hidden" name="privacy_version" value="{escape(consent.PRIVACY_VERSION,quote=True)}"><label for="privacy-accept"><input id="privacy-accept" type="checkbox" name="privacy_accept" value="1" required> I am the account owner and have read and agree to the <a href="https://socialcli.app/privacy.html" target="_blank" rel="noopener">Privacy Policy</a>.</label>'
70
+ assistant = '' if browser_selection else assistant_choice_html()
71
+ action = escape('/connect/' + authorization_id, quote=True)
72
+ token = escape(form_token, quote=True)
73
+ name, login, description = PROVIDERS[platform]
74
+ confirmation = ('After signing in, choose and confirm your account in this browser.'
75
+ if browser_selection else 'Return there to choose and confirm your account.')
76
+ content = f'''
77
+ {connection_symbols(platform)}
78
+ <p class="eyebrow">LET'S GET CONNECTED</p>
79
+ <h1 id="page-title">Connect to {name}</h1>
80
+ <p class="description">{description}</p>
81
+ <ol class="steps" aria-label="Connection steps"><li class="current"><span>1</span>Sign in</li><li><span>2</span>Review access</li><li><span>3</span>Confirm</li></ol>
82
+ <form method="post" action="{action}">
83
+ <input type="hidden" name="form_token" value="{token}">
84
+ {privacy}{assistant}
85
+ <button class="primary-button" type="submit"><span>Continue with {login}</span>{_icon('arrow')}</button></form>
86
+ <p class="button-note">You'll continue to {login} to sign in.</p>
87
+ <div class="connection-details"><div class="detail">{_icon('lock')}<div><h2>You're in control</h2><p>Review the requested access before you approve.</p></div></div>
88
+ <div class="detail">{_icon('terminal')}<div><h2>Keep SocialCli open</h2><p>{confirmation}</p></div></div></div>
89
+ <p class="quiet-notice">Connecting does not publish content.</p>
90
+ <p class="expiry-note">This link expires 10 minutes after it was created.</p>'''
91
+ return _page('Connect to ' + name, content, platform=platform)
92
+
93
+
94
+ def result_page(message: str, *, success=False, cancelled=False, platform=None) -> str:
95
+ title = 'Authorization received' if success else 'Authorization cancelled' if cancelled else "We couldn't connect"
96
+ if platform in PROVIDERS:
97
+ title += ' · ' + PROVIDERS[platform][0]
98
+ description = ('One more step: return to SocialCli to choose and confirm your account.' if success else
99
+ 'Nothing was connected. You can start again whenever you are ready.' if cancelled else
100
+ 'Return to SocialCli and request a new connection link to try again.')
101
+ icon = 'check' if success else 'close' if cancelled else 'refresh'
102
+ state = 'success' if success else 'neutral' if cancelled else 'warning'
103
+ content = f'''{connection_symbols(platform) if platform in PROVIDERS else ''}<div class="result-symbol {state}">{_icon(icon)}</div>
104
+ <p class="eyebrow">{'READY FOR THE NEXT STEP' if success else 'ACCOUNT CONNECTION'}</p>
105
+ <h1 id="page-title">{escape(title)}</h1><p class="description">{description}</p>
106
+ <div class="return-panel">{_icon('terminal')}<div><h2>Return to SocialCli</h2><p>{'Choose and confirm your account to finish.' if success else 'Your assistant or terminal can help you start again.'}</p></div></div>
107
+ <p class="quiet-notice">{escape(message)}</p>
108
+ <a class="text-link" href="/connections.html">Connection help <span aria-hidden="true">↗</span></a>'''
109
+ return _page(title, content, platform=platform)
110
+
111
+
112
+ def error_page(status_code: int) -> str:
113
+ title = ('This link is no longer available' if status_code == 404 else
114
+ 'This connection has already started' if status_code == 409 else
115
+ "We couldn't verify this connection" if status_code == 403 else
116
+ "Let's try that again")
117
+ description = ('For your security, connection links expire and can only be used once.'
118
+ if status_code in {404,409} else 'This connection could not be completed. Your account has not been connected by this request.')
119
+ content = f'''<div class="result-symbol warning">{_icon('refresh')}</div>
120
+ <p class="eyebrow">ACCOUNT CONNECTION</p><h1 id="page-title">{escape(title)}</h1>
121
+ <p class="description">{description}</p>
122
+ <div class="return-panel">{_icon('terminal')}<div><h2>Return to SocialCli</h2><p>Ask your assistant or use your terminal to get a new connection link.</p></div></div>
123
+ <a class="secondary-button" href="/connections.html">Connection help {_icon('arrow')}</a>
124
+ <p class="expiry-note">No need to share your password or credentials.</p>'''
125
+ return _page(title, content)
126
+
127
+
128
+ class LandingTokens:
129
+ def __init__(self, keys: list[bytes]):
130
+ self.cipher = MultiFernet([Fernet(key) for key in keys])
131
+
132
+ def issue(self, authorization_id: str, cookie: str, expires: float) -> str:
133
+ payload = {'purpose': 'socialcli-connect-form-v1', 'id': authorization_id,
134
+ 'browser': hashlib.sha256(cookie.encode()).hexdigest(), 'expires': expires}
135
+ return self.cipher.encrypt(json.dumps(payload).encode()).decode()
136
+
137
+ def valid(self, token: str, authorization_id: str, cookie: str, now: float) -> bool:
138
+ try:
139
+ if not 16 <= len(cookie) <= 512 or not 1 <= len(token) <= 4096:
140
+ return False
141
+ data = json.loads(self.cipher.decrypt(token.encode()))
142
+ return (data['purpose'] == 'socialcli-connect-form-v1' and data['id'] == authorization_id
143
+ and data['expires'] > now
144
+ and hmac.compare_digest(data['browser'], hashlib.sha256(cookie.encode()).hexdigest()))
145
+ except Exception:
146
+ return False
@@ -0,0 +1,48 @@
1
+ """Durable, enumerated legacy allowance after the commercial cutover."""
2
+ from fastapi import HTTPException
3
+
4
+
5
+ class LegacyPolicy:
6
+ def __init__(self,vault,clock,*,close=False):
7
+ self.vault,self.clock=vault,clock
8
+ with vault.transaction() as db:
9
+ db.execute('CREATE TABLE IF NOT EXISTS legacy_cutoff (singleton INTEGER PRIMARY KEY CHECK(singleton=1),closed_at REAL NOT NULL,drain_until REAL NOT NULL)')
10
+ db.execute('CREATE TABLE IF NOT EXISTS legacy_allowance (kind TEXT NOT NULL,id TEXT NOT NULL,expires REAL NOT NULL,activated INTEGER NOT NULL DEFAULT 0,PRIMARY KEY(kind,id))')
11
+ existing=db.execute('SELECT closed_at FROM legacy_cutoff WHERE singleton=1').fetchone()
12
+ if close and existing is None:
13
+ now=clock();deadline=now+600
14
+ db.execute('INSERT INTO legacy_cutoff VALUES(1,?,?)',(now,deadline))
15
+ rows=db.execute("SELECT kind,id FROM records WHERE kind IN ('authorization','connection') AND expires>?",(now,)).fetchall()
16
+ for row in rows:
17
+ record=vault.get(db,row['kind'],row['id'])
18
+ if record['payload'].get('saas'):continue
19
+ activated=row['kind']=='connection' and record['payload'].get('activated',False)
20
+ expires=record['expires'] if activated else min(record['expires'],deadline)
21
+ db.execute('INSERT INTO legacy_allowance VALUES(?,?,?,?)',(row['kind'],row['id'],expires,int(activated)))
22
+
23
+ def closed(self,db):
24
+ return db.execute('SELECT * FROM legacy_cutoff WHERE singleton=1').fetchone()
25
+
26
+ def allow_creation(self,db):
27
+ if self.closed(db):
28
+ raise HTTPException(410,'upgrade_required: Install the current SocialCli and sign in to connect an account.')
29
+
30
+ def require(self,db,kind,record_id,record):
31
+ if record and record['payload'].get('saas'):return
32
+ if not self.closed(db):return
33
+ allowance=db.execute('SELECT * FROM legacy_allowance WHERE kind=? AND id=?',(kind,record_id)).fetchone()
34
+ if not allowance or allowance['expires']<=self.clock():
35
+ raise HTTPException(410,'upgrade_required: This legacy connection is unavailable. Sign in to the current SocialCli.')
36
+
37
+ def provisional(self,db,authorization_id,connection_id,expires):
38
+ closed=self.closed(db)
39
+ if closed:
40
+ authorization=self.vault.get(db,'authorization',authorization_id)
41
+ self.require(db,'authorization',authorization_id,authorization)
42
+ expires=min(expires,closed['drain_until'])
43
+ db.execute('INSERT INTO legacy_allowance VALUES(?,?,?,0)',('connection',connection_id,expires))
44
+ return expires
45
+
46
+ def activated(self,db,connection_id,expires):
47
+ if self.closed(db):
48
+ db.execute("UPDATE legacy_allowance SET activated=1,expires=? WHERE kind='connection' AND id=?",(expires,connection_id))
@@ -0,0 +1,13 @@
1
+ """Trust the edge's overwritten X-Real-IP only from explicitly configured peers."""
2
+ from ipaddress import ip_address, ip_network
3
+
4
+
5
+ def client_ip(request, settings):
6
+ peer = request.client.host if request.client else 'unknown'
7
+ try:
8
+ address = ip_address(peer)
9
+ if any(address in ip_network(cidr) for cidr in settings.trusted_proxy_cidrs):
10
+ return str(ip_address(request.headers.get('x-real-ip', '')))
11
+ except ValueError:
12
+ pass
13
+ return peer