@flamingo-stack/openframe-frontend-core 0.0.644 → 0.0.645

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.
Files changed (211) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-FOSIR4QF.js → chunk-3DWDJ54N.js} +5 -5
  3. package/dist/{chunk-CBXZSTAG.cjs → chunk-3J7YNAYI.cjs} +973 -793
  4. package/dist/chunk-3J7YNAYI.cjs.map +1 -0
  5. package/dist/{chunk-3DGRXC74.js → chunk-3PGYHT67.js} +5 -5
  6. package/dist/{chunk-YB6FI2G3.js → chunk-3SMLYVM2.js} +1 -1
  7. package/dist/{chunk-YB6FI2G3.js.map → chunk-3SMLYVM2.js.map} +1 -1
  8. package/dist/{chunk-DCCY54LU.cjs → chunk-46G4WFA7.cjs} +14 -14
  9. package/dist/{chunk-DCCY54LU.cjs.map → chunk-46G4WFA7.cjs.map} +1 -1
  10. package/dist/{chunk-OMSUWB6A.cjs → chunk-4A4DQSTI.cjs} +118 -118
  11. package/dist/{chunk-OMSUWB6A.cjs.map → chunk-4A4DQSTI.cjs.map} +1 -1
  12. package/dist/{chunk-4EEUB62O.js → chunk-4HVWGYHI.js} +2 -2
  13. package/dist/{chunk-UKV52KAP.cjs → chunk-56FDKQ7R.cjs} +44 -44
  14. package/dist/{chunk-UKV52KAP.cjs.map → chunk-56FDKQ7R.cjs.map} +1 -1
  15. package/dist/{chunk-G5U4JP45.js → chunk-5ONM3FHQ.js} +4 -4
  16. package/dist/{chunk-PFV4DAX5.js → chunk-6PMUA6JW.js} +10 -10
  17. package/dist/{chunk-GELNUDBT.cjs → chunk-77BLJHKI.cjs} +10 -10
  18. package/dist/{chunk-GELNUDBT.cjs.map → chunk-77BLJHKI.cjs.map} +1 -1
  19. package/dist/{chunk-KJWPAJRT.js → chunk-7EI3NES7.js} +3 -3
  20. package/dist/{chunk-3IXDZI3R.cjs → chunk-DOVVKQMZ.cjs} +3 -3
  21. package/dist/{chunk-3IXDZI3R.cjs.map → chunk-DOVVKQMZ.cjs.map} +1 -1
  22. package/dist/{chunk-KOQCA5X5.cjs → chunk-DWJREJRA.cjs} +5 -5
  23. package/dist/{chunk-KOQCA5X5.cjs.map → chunk-DWJREJRA.cjs.map} +1 -1
  24. package/dist/{chunk-S2KMNFFN.js → chunk-EI3SLIWL.js} +7 -7
  25. package/dist/{chunk-7R2DIGG4.cjs → chunk-EX5PJGVA.cjs} +76 -76
  26. package/dist/{chunk-7R2DIGG4.cjs.map → chunk-EX5PJGVA.cjs.map} +1 -1
  27. package/dist/{chunk-GBEUGDZG.cjs → chunk-F6U2H42L.cjs} +23 -23
  28. package/dist/{chunk-GBEUGDZG.cjs.map → chunk-F6U2H42L.cjs.map} +1 -1
  29. package/dist/{chunk-KEKN76JR.js → chunk-FRQ2DE5Z.js} +5 -5
  30. package/dist/{chunk-3UBT2OIX.cjs → chunk-GPZ6Q2NP.cjs} +74 -74
  31. package/dist/{chunk-3UBT2OIX.cjs.map → chunk-GPZ6Q2NP.cjs.map} +1 -1
  32. package/dist/{chunk-JOV64HW5.js → chunk-GRBZC5N3.js} +3 -3
  33. package/dist/{chunk-CHIHYC7Q.cjs → chunk-GSD62VAY.cjs} +21 -21
  34. package/dist/{chunk-CHIHYC7Q.cjs.map → chunk-GSD62VAY.cjs.map} +1 -1
  35. package/dist/{chunk-UEXIMEVU.js → chunk-GSNX2GDA.js} +10 -10
  36. package/dist/{chunk-LPMDCQLL.js → chunk-H3EJDISW.js} +2 -2
  37. package/dist/{chunk-RNMGKAS6.js → chunk-HDCIDJSP.js} +15 -15
  38. package/dist/{chunk-7Q5XXPCB.js → chunk-HHE7UNGR.js} +14 -14
  39. package/dist/{chunk-KOLVBEW5.js → chunk-IWISVG4P.js} +3 -3
  40. package/dist/{chunk-GNKM6R55.cjs → chunk-JH5P72AF.cjs} +25 -25
  41. package/dist/{chunk-GNKM6R55.cjs.map → chunk-JH5P72AF.cjs.map} +1 -1
  42. package/dist/{chunk-LCK7T2RM.cjs → chunk-JU6SBF3C.cjs} +13 -13
  43. package/dist/{chunk-LCK7T2RM.cjs.map → chunk-JU6SBF3C.cjs.map} +1 -1
  44. package/dist/{chunk-27RD5XTP.js → chunk-JZVSQT2V.js} +5 -5
  45. package/dist/{chunk-F2KBCLUG.js → chunk-KKSSA4CS.js} +2 -2
  46. package/dist/{chunk-MRIOYSXH.js → chunk-KYIOOOQY.js} +5 -5
  47. package/dist/{chunk-FKBM6U43.js → chunk-LZLT67PE.js} +2 -2
  48. package/dist/{chunk-LZYPSDFE.cjs → chunk-M2MTAES4.cjs} +90 -90
  49. package/dist/{chunk-LZYPSDFE.cjs.map → chunk-M2MTAES4.cjs.map} +1 -1
  50. package/dist/{chunk-B3Z3RJRW.js → chunk-M4AD2PHE.js} +5 -5
  51. package/dist/{chunk-BVQEU5JB.js → chunk-MT5A25AX.js} +2 -2
  52. package/dist/{chunk-TTVOBWAH.js → chunk-MTC6DWVH.js} +5 -5
  53. package/dist/{chunk-OVXYX47B.cjs → chunk-N4Q5GKBN.cjs} +19 -19
  54. package/dist/{chunk-OVXYX47B.cjs.map → chunk-N4Q5GKBN.cjs.map} +1 -1
  55. package/dist/{chunk-FAD5WURS.cjs → chunk-OGBM3JPR.cjs} +124 -124
  56. package/dist/{chunk-FAD5WURS.cjs.map → chunk-OGBM3JPR.cjs.map} +1 -1
  57. package/dist/chunk-OXB6LRBK.js +20 -0
  58. package/dist/chunk-OXB6LRBK.js.map +1 -0
  59. package/dist/{chunk-TGUA3C4U.cjs → chunk-Q7XUKTBB.cjs} +9 -9
  60. package/dist/{chunk-TGUA3C4U.cjs.map → chunk-Q7XUKTBB.cjs.map} +1 -1
  61. package/dist/{chunk-RFFF2EYD.cjs → chunk-QXML4X4W.cjs} +15 -15
  62. package/dist/{chunk-RFFF2EYD.cjs.map → chunk-QXML4X4W.cjs.map} +1 -1
  63. package/dist/{chunk-HOGOQA2X.js → chunk-R3CH2ASE.js} +3 -3
  64. package/dist/{chunk-SKABQX44.js → chunk-RUC2V3VH.js} +7 -7
  65. package/dist/{chunk-MCQAOIUK.cjs → chunk-SID5YPKF.cjs} +37 -37
  66. package/dist/{chunk-MCQAOIUK.cjs.map → chunk-SID5YPKF.cjs.map} +1 -1
  67. package/dist/{chunk-HPWLIYRL.js → chunk-T36DLNMO.js} +14 -14
  68. package/dist/{chunk-UPKZU6QU.cjs → chunk-U2YLMFJK.cjs} +1 -1
  69. package/dist/{chunk-UPKZU6QU.cjs.map → chunk-U2YLMFJK.cjs.map} +1 -1
  70. package/dist/{chunk-B5IFXCRF.cjs → chunk-UF7AUQ3M.cjs} +41 -41
  71. package/dist/{chunk-B5IFXCRF.cjs.map → chunk-UF7AUQ3M.cjs.map} +1 -1
  72. package/dist/{chunk-IXD6SHQ6.js → chunk-ULJNU46H.js} +6 -6
  73. package/dist/{chunk-CCWI3622.cjs → chunk-VTYP25OW.cjs} +4 -4
  74. package/dist/{chunk-CCWI3622.cjs.map → chunk-VTYP25OW.cjs.map} +1 -1
  75. package/dist/{chunk-C5Y5T6GC.cjs → chunk-WIYSHSNU.cjs} +20 -20
  76. package/dist/{chunk-C5Y5T6GC.cjs.map → chunk-WIYSHSNU.cjs.map} +1 -1
  77. package/dist/{chunk-T3C3JLGV.cjs → chunk-WKX7DYFM.cjs} +8 -8
  78. package/dist/{chunk-T3C3JLGV.cjs.map → chunk-WKX7DYFM.cjs.map} +1 -1
  79. package/dist/{chunk-4WVWRFGP.js → chunk-WSRGTWQL.js} +9 -9
  80. package/dist/chunk-X7CEWD6V.cjs +20 -0
  81. package/dist/chunk-X7CEWD6V.cjs.map +1 -0
  82. package/dist/{chunk-I57XLISO.js → chunk-X7LGHPH5.js} +195 -15
  83. package/dist/chunk-X7LGHPH5.js.map +1 -0
  84. package/dist/{chunk-5JUTGEZE.js → chunk-XBTZOO74.js} +2 -2
  85. package/dist/{chunk-RWURXICE.cjs → chunk-XGD6SCHN.cjs} +44 -44
  86. package/dist/{chunk-RWURXICE.cjs.map → chunk-XGD6SCHN.cjs.map} +1 -1
  87. package/dist/{chunk-RB6L5EGM.cjs → chunk-XILTWY3L.cjs} +1131 -1131
  88. package/dist/{chunk-RB6L5EGM.cjs.map → chunk-XILTWY3L.cjs.map} +1 -1
  89. package/dist/{chunk-EHAYNUOL.cjs → chunk-XOGD2AME.cjs} +3 -3
  90. package/dist/{chunk-EHAYNUOL.cjs.map → chunk-XOGD2AME.cjs.map} +1 -1
  91. package/dist/{chunk-IIXB5REN.cjs → chunk-YEXV52L5.cjs} +16 -16
  92. package/dist/{chunk-IIXB5REN.cjs.map → chunk-YEXV52L5.cjs.map} +1 -1
  93. package/dist/{chunk-65EVGKFV.cjs → chunk-YQZXCJQL.cjs} +14 -14
  94. package/dist/{chunk-65EVGKFV.cjs.map → chunk-YQZXCJQL.cjs.map} +1 -1
  95. package/dist/{chunk-N6HNK25A.cjs → chunk-YWUZL3RT.cjs} +11 -11
  96. package/dist/{chunk-N6HNK25A.cjs.map → chunk-YWUZL3RT.cjs.map} +1 -1
  97. package/dist/{chunk-VE52MSYC.js → chunk-Z7UIO5RQ.js} +8 -8
  98. package/dist/components/calendar.cjs +10 -10
  99. package/dist/components/calendar.js +2 -2
  100. package/dist/components/case-studies/index.cjs +30 -30
  101. package/dist/components/case-studies/index.js +14 -14
  102. package/dist/components/chat/embeddable-chat.d.ts +1 -1
  103. package/dist/components/chat/index.cjs +9 -9
  104. package/dist/components/chat/index.js +8 -8
  105. package/dist/components/chat/utils/source-row-cta.d.ts +1 -1
  106. package/dist/components/command.d.ts +7 -7
  107. package/dist/components/contact/index.cjs +15 -15
  108. package/dist/components/contact/index.js +14 -14
  109. package/dist/components/docs/index.cjs +18 -18
  110. package/dist/components/docs/index.js +17 -17
  111. package/dist/components/embeds/index.cjs +15 -15
  112. package/dist/components/embeds/index.js +14 -14
  113. package/dist/components/faq/index.cjs +16 -16
  114. package/dist/components/faq/index.js +15 -15
  115. package/dist/components/features/index.cjs +14 -14
  116. package/dist/components/features/index.js +13 -13
  117. package/dist/components/help-center-pages/index.cjs +37 -37
  118. package/dist/components/help-center-pages/index.js +28 -28
  119. package/dist/components/icons/index.cjs +3 -3
  120. package/dist/components/icons/index.js +2 -2
  121. package/dist/components/index.cjs +115 -115
  122. package/dist/components/index.cjs.map +1 -1
  123. package/dist/components/index.js +31 -31
  124. package/dist/components/index.js.map +1 -1
  125. package/dist/components/meeting-scheduler/index.cjs +119 -119
  126. package/dist/components/meeting-scheduler/index.js +15 -15
  127. package/dist/components/navigation/index.cjs +17 -17
  128. package/dist/components/navigation/index.js +16 -16
  129. package/dist/components/onboarding-guides/index.cjs +18 -18
  130. package/dist/components/onboarding-guides/index.js +17 -17
  131. package/dist/components/related-content/index.cjs +10 -10
  132. package/dist/components/related-content/index.js +9 -9
  133. package/dist/components/resizable.d.ts +1 -1
  134. package/dist/components/tickets/index.cjs +19 -19
  135. package/dist/components/tickets/index.js +18 -18
  136. package/dist/components/ui/file-manager/index.cjs +57 -57
  137. package/dist/components/ui/file-manager/index.js +4 -4
  138. package/dist/components/ui/index.cjs +14 -14
  139. package/dist/components/ui/index.js +13 -13
  140. package/dist/contexts/chat-runtime-context.d.ts +1 -1
  141. package/dist/contexts/index.cjs +2 -2
  142. package/dist/contexts/index.js +1 -1
  143. package/dist/hooks/index.cjs +7 -7
  144. package/dist/hooks/index.js +6 -6
  145. package/dist/index.cjs +36 -28
  146. package/dist/index.cjs.map +1 -1
  147. package/dist/index.js +30 -22
  148. package/dist/index.js.map +1 -1
  149. package/dist/platform-domains.cjs +43 -0
  150. package/dist/platform-domains.cjs.map +1 -1
  151. package/dist/platform-domains.d.ts +62 -4
  152. package/dist/platform-domains.d.ts.map +1 -1
  153. package/dist/platform-domains.js +39 -1
  154. package/dist/platform-domains.js.map +1 -1
  155. package/dist/types/index.cjs +0 -104
  156. package/dist/types/index.cjs.map +1 -1
  157. package/dist/types/index.js +0 -104
  158. package/dist/types/index.js.map +1 -1
  159. package/dist/utils/cn.d.ts +0 -21
  160. package/dist/utils/cn.d.ts.map +1 -1
  161. package/dist/utils/index.cjs +53 -25
  162. package/dist/utils/index.cjs.map +1 -1
  163. package/dist/utils/index.d.ts +1 -2
  164. package/dist/utils/index.d.ts.map +1 -1
  165. package/dist/utils/index.js +49 -25
  166. package/dist/utils/index.js.map +1 -1
  167. package/package.json +1 -1
  168. package/src/__tests__/platform-domains.test.ts +124 -0
  169. package/src/components/chat/embeddable-chat.tsx +2 -2
  170. package/src/components/chat/utils/__tests__/source-row-cta.test.ts +2 -2
  171. package/src/components/chat/utils/source-row-cta.ts +4 -4
  172. package/src/components/made-with-love.tsx +2 -2
  173. package/src/contexts/chat-runtime-context.tsx +1 -1
  174. package/src/platform-domains.ts +99 -4
  175. package/src/utils/.cn.md +3 -23
  176. package/src/utils/cn.ts +0 -47
  177. package/src/utils/index.ts +9 -2
  178. package/dist/chunk-23V5BSHD.cjs +0 -169
  179. package/dist/chunk-23V5BSHD.cjs.map +0 -1
  180. package/dist/chunk-CBXZSTAG.cjs.map +0 -1
  181. package/dist/chunk-I57XLISO.js.map +0 -1
  182. package/dist/chunk-O4MCCKKN.js +0 -169
  183. package/dist/chunk-O4MCCKKN.js.map +0 -1
  184. /package/dist/{chunk-FOSIR4QF.js.map → chunk-3DWDJ54N.js.map} +0 -0
  185. /package/dist/{chunk-3DGRXC74.js.map → chunk-3PGYHT67.js.map} +0 -0
  186. /package/dist/{chunk-4EEUB62O.js.map → chunk-4HVWGYHI.js.map} +0 -0
  187. /package/dist/{chunk-G5U4JP45.js.map → chunk-5ONM3FHQ.js.map} +0 -0
  188. /package/dist/{chunk-PFV4DAX5.js.map → chunk-6PMUA6JW.js.map} +0 -0
  189. /package/dist/{chunk-KJWPAJRT.js.map → chunk-7EI3NES7.js.map} +0 -0
  190. /package/dist/{chunk-S2KMNFFN.js.map → chunk-EI3SLIWL.js.map} +0 -0
  191. /package/dist/{chunk-KEKN76JR.js.map → chunk-FRQ2DE5Z.js.map} +0 -0
  192. /package/dist/{chunk-JOV64HW5.js.map → chunk-GRBZC5N3.js.map} +0 -0
  193. /package/dist/{chunk-UEXIMEVU.js.map → chunk-GSNX2GDA.js.map} +0 -0
  194. /package/dist/{chunk-LPMDCQLL.js.map → chunk-H3EJDISW.js.map} +0 -0
  195. /package/dist/{chunk-RNMGKAS6.js.map → chunk-HDCIDJSP.js.map} +0 -0
  196. /package/dist/{chunk-7Q5XXPCB.js.map → chunk-HHE7UNGR.js.map} +0 -0
  197. /package/dist/{chunk-KOLVBEW5.js.map → chunk-IWISVG4P.js.map} +0 -0
  198. /package/dist/{chunk-27RD5XTP.js.map → chunk-JZVSQT2V.js.map} +0 -0
  199. /package/dist/{chunk-F2KBCLUG.js.map → chunk-KKSSA4CS.js.map} +0 -0
  200. /package/dist/{chunk-MRIOYSXH.js.map → chunk-KYIOOOQY.js.map} +0 -0
  201. /package/dist/{chunk-FKBM6U43.js.map → chunk-LZLT67PE.js.map} +0 -0
  202. /package/dist/{chunk-B3Z3RJRW.js.map → chunk-M4AD2PHE.js.map} +0 -0
  203. /package/dist/{chunk-BVQEU5JB.js.map → chunk-MT5A25AX.js.map} +0 -0
  204. /package/dist/{chunk-TTVOBWAH.js.map → chunk-MTC6DWVH.js.map} +0 -0
  205. /package/dist/{chunk-HOGOQA2X.js.map → chunk-R3CH2ASE.js.map} +0 -0
  206. /package/dist/{chunk-SKABQX44.js.map → chunk-RUC2V3VH.js.map} +0 -0
  207. /package/dist/{chunk-HPWLIYRL.js.map → chunk-T36DLNMO.js.map} +0 -0
  208. /package/dist/{chunk-IXD6SHQ6.js.map → chunk-ULJNU46H.js.map} +0 -0
  209. /package/dist/{chunk-4WVWRFGP.js.map → chunk-WSRGTWQL.js.map} +0 -0
  210. /package/dist/{chunk-5JUTGEZE.js.map → chunk-XBTZOO74.js.map} +0 -0
  211. /package/dist/{chunk-VE52MSYC.js.map → chunk-Z7UIO5RQ.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/platform-domains.ts"],"names":[],"mappings":";;;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AA,EAAI,IAAI,EAAE,CAAA,EAAG;AACtD,MAAA,OAAO,OAAO,UAAA,CAAW,GAAG,CAAA,GAAI,MAAA,GAAS,IAAI,MAAM,CAAA,CAAA;AAAA,IACrD;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AASA,IAAM,SAAA,GAAY,CAAC,CAAA,KAAyB,gBAAA,CAAiB,UAAU,CAAA,CAAA,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAA;AACvF,IACE,UAAU,UAAU,CAAA,GAAI,UAAU,iBAAiB,CAAA,IACnD,UAAU,UAAU,CAAA,GAAI,UAAU,WAAW,CAAA,IAC7C,sBAAsB,aAAa,CAAA,KAAM,qBACzC,qBAAA,CAAsB,kBAAkB,MAAM,WAAA,EAC9C;AACA,EAAA,OAAA,CAAQ,KAAA;AAAA,IACN;AAAA,GAEF;AACF","file":"platform-domains.cjs","sourcesContent":["/**\n * Platform-Domain SSOT (single source of truth) + derivations.\n *\n * ONE registry maps each platform → its canonical production URL (`defaultUrl`,\n * the load-bearing source) with an optional per-deploy `NEXT_PUBLIC_*_URL`\n * OVERRIDE. Everything else — the reverse host→platform resolver, the cookie\n * base-domain set (the cross-subdomain SSO mechanism), www/apex expansion, the\n * URL→host parse, preview detection — derives from this one table.\n *\n * EDGE-SAFE + PURE: no React/clsx/tailwind, no `server-only`, no `node:`\n * builtins, no `'use client'`. So it is legal in the Edge middleware\n * (`proxy.ts`), in `'use client'` providers, AND in `server-only` modules\n * (e.g. cookie-domain-server.ts) simultaneously. The ONLY non-pure export is\n * `getAllPlatformBaseDomains`, which reads `typeof window`/`process.env` to\n * preserve byte-identical cookie behavior.\n */\n\nimport type { PlatformName } from './types/platform';\n\nexport type PlatformDomainKey = PlatformName | 'openframe-dashboard';\n\nexport interface PlatformDomainEntry {\n /** Platform key (matches `PlatformName`, plus the forward-only `openframe-dashboard`). */\n key: PlatformDomainKey;\n /** Canonical production URL — the LOAD-BEARING source of truth (today's hardcoded fallbacks). */\n defaultUrl: string;\n /** `NEXT_PUBLIC_*_URL` per-deploy OVERRIDE. The `defaultUrl` covers it when unset. */\n envVar: string;\n /** Legacy/secondary hosts that REVERSE-map to this key (no env var exists — NOT canonical). */\n aliasHostnames?: string[];\n /** Forward-only: no DB row, excluded from the reverse index + cookie set (e.g. the product-CTA dashboard). */\n pseudo?: boolean;\n}\n\nexport const PLATFORM_DOMAINS: readonly PlatformDomainEntry[] = [\n { key: 'marketing-hub', defaultUrl: 'https://marketing-hub.flamingo.so', envVar: 'NEXT_PUBLIC_MARKETING_HUB_URL' },\n { key: 'company-hub', defaultUrl: 'https://company-hub.flamingo.so', envVar: 'NEXT_PUBLIC_COMPANY_HUB_URL' },\n { key: 'product-hub', defaultUrl: 'https://product-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PRODUCT_HUB_URL' },\n { key: 'revenue-hub', defaultUrl: 'https://revenue-hub.flamingo.so', envVar: 'NEXT_PUBLIC_REVENUE_HUB_URL' },\n { key: 'people-hub', defaultUrl: 'https://people-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PEOPLE_HUB_URL' },\n { key: 'openmsp', defaultUrl: 'https://www.openmsp.ai', envVar: 'NEXT_PUBLIC_OPENMSP_URL' },\n // ORDERING INVARIANT (first-wins, load-bearing): `flamingo` MUST precede `flamingo-teaser` + `universal`.\n // All three resolve to www.flamingo.run; the reverse index is first-wins → flamingo claims the shared host,\n // teaser keeps only its unique flamingo.cx aliases, universal contributes no unique host.\n // ⚠️ DO NOT REORDER — enforced by the module-load self-check at the bottom of this file.\n { key: 'flamingo', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n { key: 'tmcg', defaultUrl: 'https://www.tmcg.miami', envVar: 'NEXT_PUBLIC_TMCG_URL' },\n { key: 'mlg', defaultUrl: 'https://www.mlg.soccer', envVar: 'NEXT_PUBLIC_MLG_URL' },\n {\n key: 'flamingo-teaser',\n defaultUrl: 'https://www.flamingo.run',\n envVar: 'NEXT_PUBLIC_FLAMINGO_URL',\n aliasHostnames: ['flamingo.cx', 'www.flamingo.cx'],\n },\n {\n key: 'openframe',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_URL',\n aliasHostnames: ['openframe.ai', 'www.openframe.ai', 'hub.openframe.ai'],\n },\n {\n key: 'openframe-dashboard',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL',\n pseudo: true,\n },\n { key: 'universal', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n];\n\n// ── Compile-time key guards (anchor the table on PlatformName, both directions) ──\n// (1) Removal/typo guard: every table key must be a valid PlatformDomainKey.\nconst _tableSatisfies = PLATFORM_DOMAINS satisfies readonly PlatformDomainEntry[];\nvoid _tableSatisfies;\n// (2) Addition guard: a NEW PlatformName member that lacks a table row fails the build.\ntype _MissingKey = Exclude<PlatformName, (typeof PLATFORM_DOMAINS)[number]['key']>;\nconst _exhaustive: [_MissingKey] extends [never] ? true : false = true;\nvoid _exhaustive;\n\n// ── Env overrides (the ONLY place env URLs enter — literal-key inlined + compile-time-guarded) ──\n// `process.env.NEXT_PUBLIC_X` is build-inlined ONLY with a LITERAL key, so the env-var name is the\n// irreducible two-copy (the registry `envVar` column + the literal access below). The `satisfies` makes\n// `tsc`/`next build` FAIL if this map is missing a registry env var OR carries a stale one (bidirectional).\ntype EnvVarKey = (typeof PLATFORM_DOMAINS)[number]['envVar'];\nconst ENV_OVERRIDES = {\n NEXT_PUBLIC_MARKETING_HUB_URL: process.env.NEXT_PUBLIC_MARKETING_HUB_URL,\n NEXT_PUBLIC_COMPANY_HUB_URL: process.env.NEXT_PUBLIC_COMPANY_HUB_URL,\n NEXT_PUBLIC_PRODUCT_HUB_URL: process.env.NEXT_PUBLIC_PRODUCT_HUB_URL,\n NEXT_PUBLIC_REVENUE_HUB_URL: process.env.NEXT_PUBLIC_REVENUE_HUB_URL,\n NEXT_PUBLIC_PEOPLE_HUB_URL: process.env.NEXT_PUBLIC_PEOPLE_HUB_URL,\n NEXT_PUBLIC_OPENMSP_URL: process.env.NEXT_PUBLIC_OPENMSP_URL,\n NEXT_PUBLIC_FLAMINGO_URL: process.env.NEXT_PUBLIC_FLAMINGO_URL,\n NEXT_PUBLIC_TMCG_URL: process.env.NEXT_PUBLIC_TMCG_URL,\n NEXT_PUBLIC_MLG_URL: process.env.NEXT_PUBLIC_MLG_URL,\n NEXT_PUBLIC_OPENFRAME_URL: process.env.NEXT_PUBLIC_OPENFRAME_URL,\n NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL: process.env.NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL,\n} satisfies Record<EnvVarKey, string | undefined>;\n\n/** The registry entry for a key (undefined for an unknown key). */\nexport function byKey(key: string): PlatformDomainEntry | undefined {\n return PLATFORM_DOMAINS.find(e => e.key === key);\n}\n\n/** Read a platform's `NEXT_PUBLIC_*_URL` override (or null). */\nfunction envOverrideFor(key: string): string | null {\n const envVar = byKey(key)?.envVar;\n if (!envVar) return null;\n return (ENV_OVERRIDES as Record<string, string | undefined>)[envVar] || null;\n}\n\n/**\n * Ensure a URL string carries a scheme. Per-deploy `NEXT_PUBLIC_*_URL` overrides are\n * stored SCHEME-LESS (bare host, e.g. `www.openmsp.ai` / `hub.openframe.ai`) — the\n * canonical convention in the Vercel shared-env store. This normalizes them to a full\n * `https://` URL so every downstream consumer (`hostOf`/`new URL`, hrefs, the cookie\n * base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry\n * `defaultUrl`s, any scheme'd override) pass through unchanged.\n *\n * EXPORTED as the single owner of the scheme-normalization rule (next.config.mjs keeps a\n * byte-identical local copy ONLY because Next evaluates its config outside the TS module\n * graph and cannot import this — see the comment there).\n *\n * Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it\n * doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).\n */\nexport function ensureScheme(url: string): string {\n const trimmed = url.trim();\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(trimmed)) return trimmed; // already has a scheme\n return `https://${trimmed.replace(/^\\/+/, '')}`; // bare host or protocol-relative `//host`\n}\n\n/**\n * Canonical production URL for a platform: env override wins, else the `defaultUrl`.\n * NEVER throws / undefined — the default guarantees a host (this is what keeps the\n * cookie base-domains, the reverse map, and CSP intact even with every override unset).\n * The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides\n * resolve to valid URLs. Unknown-key fallback preserves cn.ts's flamingo.run default.\n */\nexport function getPlatformProductionUrl(platform: string): string {\n const resolved =\n envOverrideFor(platform) ?? byKey(platform)?.defaultUrl ?? envOverrideFor('flamingo') ?? 'https://www.flamingo.run';\n return ensureScheme(resolved);\n}\n\n// ── Single-owner host primitives ──\n\n/** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */\nexport function hostOf(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n return new URL(value).hostname.toLowerCase();\n } catch {\n return null;\n }\n}\n\n/** Expand a host into its `www.`/apex pair. 3+-label and single-label hosts return `[host]`. */\nexport function expandWwwApex(host: string): string[] {\n if (host.startsWith('www.')) return [host, host.slice(4)];\n if (host.split('.').length === 2) return [host, `www.${host}`];\n return [host];\n}\n\n/** Registrable base domain (`parts.slice(-2).join('.')`), dotless; undefined for <2-label. */\nexport function toRegistrableBaseDomain(host: string): string | undefined {\n const parts = host.split('.');\n if (parts.length >= 2) return parts.slice(-2).join('.');\n return undefined;\n}\n\n/** An entry's alias hosts (single-owner reader). */\nexport function aliasHostsOf(key: string): string[] {\n return byKey(key)?.aliasHostnames ?? [];\n}\n\n/** All hosts an entry contributes to the reverse index (resolved host + optional aliases). */\nfunction hostsForEntry(entry: PlatformDomainEntry, opts: { includeAliases: boolean }): string[] {\n const resolved = hostOf(getPlatformProductionUrl(entry.key));\n const hosts = resolved ? expandWwwApex(resolved) : [];\n if (opts.includeAliases) hosts.push(...aliasHostsOf(entry.key));\n return hosts;\n}\n\n/**\n * Reverse resolver: hostname → platform key (first-wins over registry order, non-pseudo only).\n * Guarantees openframe.ai / www.openframe.ai / hub.openframe.ai → openframe in every env.\n * Replaces the hub `PLATFORM_DOMAIN_MAP`.\n */\nexport function getPlatformByHostname(hostname: string): PlatformDomainKey | null {\n const host = hostname.toLowerCase();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n if (hostsForEntry(entry, { includeAliases: true }).includes(host)) return entry.key;\n }\n return null;\n}\n\n// ── Preview detection (two distinct predicates — env-form vs host-form) ──\n\n/** Env-form preview predicate (Vercel `VERCEL_ENV`). */\nexport function isPreviewEnv(): boolean {\n return process.env.VERCEL_ENV === 'preview';\n}\n\n/** Host-form preview predicate (a `*.vercel.app` host). Dot-bounded suffix so a\n * malicious `foo.vercel.app.evil.com` is NOT treated as preview. */\nexport function isPreviewHost(hostname: string): boolean {\n return hostname.endsWith('.vercel.app');\n}\n\n/**\n * ALL unique cookie base domains (the cross-subdomain SSO mechanism).\n *\n * NON-PURE (the sole such export): reads `typeof window` + `process.env` to\n * preserve byte-identical cookie behavior. Keeps the original three branches:\n * 1. localhost / private IP → [] (host-only cookies)\n * 2. Vercel preview (env OR host) → ['.vercel.app','vercel.app']\n * 3. production → for each non-pseudo platform, registrable base of its resolved\n * host, emitted as both `.base` and bare `base`.\n *\n * Because `getPlatformProductionUrl` always yields a host (override OR default),\n * `.flamingo.so` / `.flamingo.run` / `.openmsp.ai` / `.tmcg.miami` / `.openframe.ai`\n * are ALWAYS present → cross-hub SSO is byte-identical to today.\n */\nexport function getAllPlatformBaseDomains(): string[] {\n if (typeof window === 'undefined') return [];\n\n const hostname = window.location.hostname;\n\n // Case 1: localhost / private IP — no domains\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('127.')) {\n return [];\n }\n\n // Case 2: Vercel preview — vercel.app domain\n const previewEnv =\n process.env.VERCEL_ENV === 'preview' || process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' || isPreviewHost(hostname);\n if (previewEnv) {\n return ['.vercel.app', 'vercel.app'];\n }\n\n // Case 3: production — registrable base of every non-pseudo platform's resolved host\n const baseDomains = new Set<string>();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n const host = hostOf(getPlatformProductionUrl(entry.key));\n if (!host) continue;\n const base = toRegistrableBaseDomain(host);\n if (base) {\n baseDomains.add(`.${base}`);\n baseDomains.add(base);\n }\n }\n return Array.from(baseDomains);\n}\n\n// ── Cookie-domain guard + match (single owner; shared by the client cookie-domain.ts +\n// server-only cookie-domain-server.ts resolvers, which previously hand-rolled both 3×) ──\n\n/**\n * Hosts that must NOT receive a `Domain=` cookie → the caller returns undefined (host-only):\n * localhost, loopback/private IPs, and any `*.vercel.app`. `vercel.app` is on the Public Suffix\n * List, so browsers SILENTLY drop `Set-Cookie: Domain=.vercel.app` — which broke the PKCE verifier\n * + session cookies on preview deploys. Host-only is sufficient there (the same preview host\n * round-trips the OAuth chain); production hosts (`.flamingo.so`/`.openmsp.ai`/…) fall through.\n */\nexport function isNonCookieableHost(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname.startsWith('127.') ||\n hostname.startsWith('192.168.') ||\n hostname.startsWith('10.') ||\n hostname.includes('.vercel.app')\n );\n}\n\n/**\n * Match a hostname against a set of registrable base domains → the dotted cookie `Domain`\n * (`.flamingo.so`), or undefined when none contains the host. Accepts bases with or without a\n * leading dot and always returns the dotted form. Single owner for the match loop both resolvers ran.\n */\nexport function matchCookieDomain(hostname: string, baseDomains: string[]): string | undefined {\n for (const domain of baseDomains) {\n const bare = domain.startsWith('.') ? domain.slice(1) : domain;\n if (hostname === bare || hostname.endsWith(`.${bare}`)) {\n return domain.startsWith('.') ? domain : `.${domain}`;\n }\n }\n return undefined;\n}\n\n// ── Module-load ordering self-check (NON-fatal — this module is imported by cn.ts → ~everything,\n// so a hard throw would be a total outage if the assertion were ever over-strict). Checks the REAL\n// invariant — table order — STRUCTURALLY (findIndex), NOT via getPlatformByHostname on a hardcoded\n// host: the latter false-positives when NEXT_PUBLIC_FLAMINGO_URL is overridden to a non-default host\n// (flamingo's resolved host changes, so `www.flamingo.run` no longer reverse-maps to it though the\n// ordering is fine). The alias checks below ARE env-immune (aliasHostnames are unique per key). The\n// authoritative guard is the reverse-map vitest. ⚠️ keep `flamingo` before `flamingo-teaser`/`universal`.\nconst _orderIdx = (k: PlatformDomainKey) => PLATFORM_DOMAINS.findIndex(e => e.key === k);\nif (\n _orderIdx('flamingo') > _orderIdx('flamingo-teaser') ||\n _orderIdx('flamingo') > _orderIdx('universal') ||\n getPlatformByHostname('flamingo.cx') !== 'flamingo-teaser' ||\n getPlatformByHostname('hub.openframe.ai') !== 'openframe'\n) {\n console.error(\n '[platform-domains] ⚠️ PLATFORM_DOMAINS ordering invariant violated — `flamingo` must precede ' +\n '`flamingo-teaser`/`universal`, and the openframe/teaser aliases must be intact. Do not reorder the table.',\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/platform-domains.ts"],"names":[],"mappings":";;;AAkCO,IAAM,gBAAA,GAAmD;AAAA,EAC9D,EAAE,GAAA,EAAK,eAAA,EAAiB,UAAA,EAAY,mCAAA,EAAqC,QAAQ,+BAAA,EAAgC;AAAA,EACjH,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,EAAmC,QAAQ,6BAAA,EAA8B;AAAA,EAC3G,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,EAAmC,QAAQ,6BAAA,EAA8B;AAAA,EAC3G,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,EAAmC,QAAQ,6BAAA,EAA8B;AAAA,EAC3G,EAAE,GAAA,EAAK,YAAA,EAAc,UAAA,EAAY,gCAAA,EAAkC,QAAQ,4BAAA,EAA6B;AAAA,EACxG,EAAE,GAAA,EAAK,SAAA,EAAW,UAAA,EAAY,wBAAA,EAA0B,QAAQ,yB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A,EAAA,OAAO,KAAA,CAAM,KAAK,WAAW,CAAA;AAC/B;AAYO,SAAS,oBAAoB,QAAA,EAA2B;AAC7D,EAAA,OACE,aAAa,WAAA,IACb,QAAA,KAAa,eACb,QAAA,CAAS,UAAA,CAAW,MAAM,CAAA,IAC1B,QAAA,CAAS,UAAA,CAAW,UAAU,KAC9B,QAAA,CAAS,UAAA,CAAW,KAAK,CAAA,IACzB,QAAA,CAAS,SAAS,aAAa,CAAA;AAEnC;AAOO,SAAS,iBAAA,CAAkB,UAAkB,WAAA,EAA2C;AAC7F,EAAA,KAAA,MAAW,UAAU,WAAA,EAAa;AAChC,IAAA,MAAM,IAAA,GAAO,OAAO,UAAA,CAAW,GAAG,IAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,GAAI,MAAA;AACxD,IAAA,IAAI,aAAa,IAAA,IAAQ,QAAA,CAAS,SAAS,CAAA,CAAA,EAAI,IAAI,EAAE,CAAA,EAAG;AACtD,MAAA,OAAO,OAAO,UAAA,CAAW,GAAG,CAAA,GAAI,MAAA,GAAS,IAAI,MAAM,CAAA,CAAA;AAAA,IACrD;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AASA,IAAM,SAAA,GAAY,CAAC,CAAA,KAAyB,gBAAA,CAAiB,UAAU,CAAA,CAAA,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAA;AACvF,IACE,UAAU,UAAU,CAAA,GAAI,UAAU,iBAAiB,CAAA,IACnD,UAAU,UAAU,CAAA,GAAI,UAAU,WAAW,CAAA,IAC7C,sBAAsB,aAAa,CAAA,KAAM,qBACzC,qBAAA,CAAsB,kBAAkB,MAAM,WAAA,EAC9C;AACA,EAAA,OAAA,CAAQ,KAAA;AAAA,IACN;AAAA,GAEF;AACF","file":"platform-domains.cjs","sourcesContent":["/**\n * Platform-Domain SSOT (single source of truth) + derivations.\n *\n * ONE registry maps each platform → its canonical production URL (`defaultUrl`,\n * the load-bearing source) with an optional per-deploy `NEXT_PUBLIC_*_URL`\n * OVERRIDE. Everything else — the reverse host→platform resolver, the cookie\n * base-domain set (the cross-subdomain SSO mechanism), www/apex expansion, the\n * URL→host parse, preview detection — derives from this one table.\n *\n * EDGE-SAFE + PURE: no React/clsx/tailwind, no `server-only`, no `node:`\n * builtins, no `'use client'`. So it is legal in the Edge middleware\n * (`proxy.ts`), in `'use client'` providers, AND in `server-only` modules\n * (e.g. cookie-domain-server.ts) simultaneously. The ONLY non-pure export is\n * `getAllPlatformBaseDomains`, which reads `typeof window`/`process.env` to\n * preserve byte-identical cookie behavior.\n */\n\nimport type { PlatformName } from './types/platform';\n\nexport type PlatformDomainKey = PlatformName | 'openframe-dashboard';\n\nexport interface PlatformDomainEntry {\n /** Platform key (matches `PlatformName`, plus the forward-only `openframe-dashboard`). */\n key: PlatformDomainKey;\n /** Canonical production URL — the LOAD-BEARING source of truth (today's hardcoded fallbacks). */\n defaultUrl: string;\n /** `NEXT_PUBLIC_*_URL` per-deploy OVERRIDE. The `defaultUrl` covers it when unset. */\n envVar: string;\n /** Legacy/secondary hosts that REVERSE-map to this key (no env var exists — NOT canonical). */\n aliasHostnames?: string[];\n /** Forward-only: no DB row, excluded from the reverse index + cookie set (e.g. the product-CTA dashboard). */\n pseudo?: boolean;\n}\n\nexport const PLATFORM_DOMAINS: readonly PlatformDomainEntry[] = [\n { key: 'marketing-hub', defaultUrl: 'https://marketing-hub.flamingo.so', envVar: 'NEXT_PUBLIC_MARKETING_HUB_URL' },\n { key: 'company-hub', defaultUrl: 'https://company-hub.flamingo.so', envVar: 'NEXT_PUBLIC_COMPANY_HUB_URL' },\n { key: 'product-hub', defaultUrl: 'https://product-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PRODUCT_HUB_URL' },\n { key: 'revenue-hub', defaultUrl: 'https://revenue-hub.flamingo.so', envVar: 'NEXT_PUBLIC_REVENUE_HUB_URL' },\n { key: 'people-hub', defaultUrl: 'https://people-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PEOPLE_HUB_URL' },\n { key: 'openmsp', defaultUrl: 'https://www.openmsp.ai', envVar: 'NEXT_PUBLIC_OPENMSP_URL' },\n // ORDERING INVARIANT (first-wins, load-bearing): `flamingo` MUST precede `flamingo-teaser` + `universal`.\n // All three resolve to www.flamingo.run; the reverse index is first-wins → flamingo claims the shared host,\n // teaser keeps only its unique flamingo.cx aliases, universal contributes no unique host.\n // ⚠️ DO NOT REORDER — enforced by the module-load self-check at the bottom of this file.\n { key: 'flamingo', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n { key: 'tmcg', defaultUrl: 'https://www.tmcg.miami', envVar: 'NEXT_PUBLIC_TMCG_URL' },\n { key: 'mlg', defaultUrl: 'https://www.mlg.soccer', envVar: 'NEXT_PUBLIC_MLG_URL' },\n {\n key: 'flamingo-teaser',\n defaultUrl: 'https://www.flamingo.run',\n envVar: 'NEXT_PUBLIC_FLAMINGO_URL',\n aliasHostnames: ['flamingo.cx', 'www.flamingo.cx'],\n },\n {\n key: 'openframe',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_URL',\n aliasHostnames: ['openframe.ai', 'www.openframe.ai', 'hub.openframe.ai'],\n },\n {\n key: 'openframe-dashboard',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL',\n pseudo: true,\n },\n { key: 'universal', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n];\n\n// ── Compile-time key guards (anchor the table on PlatformName, both directions) ──\n// (1) Removal/typo guard: every table key must be a valid PlatformDomainKey.\nconst _tableSatisfies = PLATFORM_DOMAINS satisfies readonly PlatformDomainEntry[];\nvoid _tableSatisfies;\n// (2) Addition guard: a NEW PlatformName member that lacks a table row fails the build.\ntype _MissingKey = Exclude<PlatformName, (typeof PLATFORM_DOMAINS)[number]['key']>;\nconst _exhaustive: [_MissingKey] extends [never] ? true : false = true;\nvoid _exhaustive;\n\n// ── Env overrides (the ONLY place env URLs enter — literal-key inlined + compile-time-guarded) ──\n// `process.env.NEXT_PUBLIC_X` is build-inlined ONLY with a LITERAL key, so the env-var name is the\n// irreducible two-copy (the registry `envVar` column + the literal access below). The `satisfies` makes\n// `tsc`/`next build` FAIL if this map is missing a registry env var OR carries a stale one (bidirectional).\ntype EnvVarKey = (typeof PLATFORM_DOMAINS)[number]['envVar'];\nconst ENV_OVERRIDES = {\n NEXT_PUBLIC_MARKETING_HUB_URL: process.env.NEXT_PUBLIC_MARKETING_HUB_URL,\n NEXT_PUBLIC_COMPANY_HUB_URL: process.env.NEXT_PUBLIC_COMPANY_HUB_URL,\n NEXT_PUBLIC_PRODUCT_HUB_URL: process.env.NEXT_PUBLIC_PRODUCT_HUB_URL,\n NEXT_PUBLIC_REVENUE_HUB_URL: process.env.NEXT_PUBLIC_REVENUE_HUB_URL,\n NEXT_PUBLIC_PEOPLE_HUB_URL: process.env.NEXT_PUBLIC_PEOPLE_HUB_URL,\n NEXT_PUBLIC_OPENMSP_URL: process.env.NEXT_PUBLIC_OPENMSP_URL,\n NEXT_PUBLIC_FLAMINGO_URL: process.env.NEXT_PUBLIC_FLAMINGO_URL,\n NEXT_PUBLIC_TMCG_URL: process.env.NEXT_PUBLIC_TMCG_URL,\n NEXT_PUBLIC_MLG_URL: process.env.NEXT_PUBLIC_MLG_URL,\n NEXT_PUBLIC_OPENFRAME_URL: process.env.NEXT_PUBLIC_OPENFRAME_URL,\n NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL: process.env.NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL,\n} satisfies Record<EnvVarKey, string | undefined>;\n\n/** The registry entry for a key (undefined for an unknown key). */\nexport function byKey(key: string): PlatformDomainEntry | undefined {\n return PLATFORM_DOMAINS.find(e => e.key === key);\n}\n\n/** Read a platform's `NEXT_PUBLIC_*_URL` override (or null). */\nfunction envOverrideFor(key: string): string | null {\n const envVar = byKey(key)?.envVar;\n if (!envVar) return null;\n return (ENV_OVERRIDES as Record<string, string | undefined>)[envVar] || null;\n}\n\n/**\n * Ensure a URL string carries a scheme. Per-deploy `NEXT_PUBLIC_*_URL` overrides are\n * stored SCHEME-LESS (bare host, e.g. `www.openmsp.ai` / `hub.openframe.ai`) — the\n * canonical convention in the Vercel shared-env store. This normalizes them to a full\n * `https://` URL so every downstream consumer (`hostOf`/`new URL`, hrefs, the cookie\n * base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry\n * `defaultUrl`s, any scheme'd override) pass through unchanged.\n *\n * EXPORTED as the single owner of the scheme-normalization rule. This subpath is pure ESM,\n * so a consumer's next.config.mjs imports it directly rather than keeping a copy.\n *\n * Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it\n * doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).\n */\nexport function ensureScheme(url: string): string {\n const trimmed = url.trim();\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(trimmed)) return trimmed; // already has a scheme\n return `https://${trimmed.replace(/^\\/+/, '')}`; // bare host or protocol-relative `//host`\n}\n\n/**\n * Canonical production URL for a platform: env override wins, else the `defaultUrl`.\n * NEVER throws / undefined — the default guarantees a host (this is what keeps the\n * cookie base-domains, the reverse map, and CSP intact even with every override unset).\n * The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides\n * resolve to valid URLs. Unknown-key fallback is flamingo's URL.\n */\nexport function getPlatformProductionUrl(platform: string): string {\n const resolved =\n envOverrideFor(platform) ?? byKey(platform)?.defaultUrl ?? envOverrideFor('flamingo') ?? 'https://www.flamingo.run';\n return ensureScheme(resolved);\n}\n\n/**\n * THE URL of a platform, for the environment the code is running in, no trailing slash.\n * The one platform-URL resolver: consumers build every link to a platform from this.\n *\n * - `environment: 'current'` (default): the local dev URL (`NEXT_PUBLIC_DEV_URL`, else\n * `http://localhost:3000`) outside a production build, the registry's production URL\n * in any production build (a preview included — a preview never links to itself as\n * canonical).\n * - `environment: 'production'`: the registry's production URL everywhere, for links that\n * leave the machine.\n *\n * `platform` is REQUIRED. The former `getBaseUrl()` accepted none and then returned\n * `VERCEL_PROJECT_PRODUCTION_URL` — whichever domain Vercel lists first for a project\n * (`flamingo.cx` on flamingo, a 308), and production on previews. A deployment's own\n * origin is not a platform URL; consumers resolve it themselves.\n */\nexport function getPlatformUrl(platform: string, options: { environment?: 'current' | 'production' } = {}): string {\n const url =\n options.environment !== 'production' && process.env.NODE_ENV !== 'production'\n ? process.env.NEXT_PUBLIC_DEV_URL || 'http://localhost:3000'\n : getPlatformProductionUrl(platform);\n return url.replace(/\\/+$/, '');\n}\n\n/**\n * Where THIS app is reachable, no trailing slash: what anything outside the app must\n * fetch from the code that is running (rendered images, provider callbacks, self-calls).\n * The one app-origin resolver; each app only supplies its own platform and config.\n *\n * In order:\n * 1. In the browser: the page's origin.\n * 2. `configuredUrl`: an app whose URL is configured at runtime (a self-hosted OpenFrame\n * install's `NEXT_PUBLIC_APP_URL`) — that install's address wins over any default.\n * 3. On a Vercel preview: the deployment's immutable `VERCEL_URL` (not the branch alias,\n * which moves to the next commit and would serve other code).\n * 4. In any production build: the platform's registry URL.\n * 5. In development: `NEXT_PUBLIC_DEV_URL`, else localhost on the running port.\n */\nexport function getDeploymentUrl(options: { platform: string; configuredUrl?: string | null }): string {\n if (typeof window !== 'undefined') return window.location.origin;\n const configured = options.configuredUrl?.trim();\n if (configured) return ensureScheme(configured).replace(/\\/+$/, '');\n if (process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_URL) {\n return ensureScheme(process.env.VERCEL_URL).replace(/\\/+$/, '');\n }\n if (process.env.VERCEL_ENV === 'production' || process.env.NODE_ENV === 'production') {\n return getPlatformUrl(options.platform, { environment: 'production' });\n }\n return (process.env.NEXT_PUBLIC_DEV_URL || `http://localhost:${process.env.PORT ?? 3000}`).replace(/\\/+$/, '');\n}\n\n/** A hostname on the local machine, matched WHOLE: `localhost.example.com` and\n * `127.evil.example` are public hosts. */\nconst LOCAL_HOSTNAME = /^(localhost|127(?:\\.\\d{1,3}){3}|0\\.0\\.0\\.0|\\[::1\\])$/i;\n\n/** Is this URL on the local machine, where no external system (a webhook sender, an\n * OAuth provider) can reach it? False for anything that is not a URL. */\nexport function isLocalUrl(url: string): boolean {\n try {\n return LOCAL_HOSTNAME.test(new URL(url).hostname);\n } catch {\n return false;\n }\n}\n\n/**\n * The origin a server request arrived on, from its `host` header only (what the edge set\n * for this request — a client-writable `x-forwarded-host` never chooses where a flow\n * returns). `http` for a local host unless the proxy says otherwise, else `https`.\n * With no Host header, the app's own origin (`getDeploymentUrl` for `platform`).\n */\nexport function getRequestOrigin(\n headers: { get(name: string): string | null },\n options: { platform: string; configuredUrl?: string | null },\n): string {\n const host = headers.get('host');\n if (!host) return getDeploymentUrl(options);\n const local = LOCAL_HOSTNAME.test(host.replace(/:\\d+$/, ''));\n const proto = headers.get('x-forwarded-proto')?.split(',')[0].trim() || (local ? 'http' : 'https');\n return `${proto}://${host}`;\n}\n\n/**\n * Where a redirect goes: a path resolves against `origin`; an explicit absolute\n * `http(s)://` URL is used as is. THROWS when a relative target resolves to another\n * origin (`//evil.example`, `/\\\\evil.example`), so a shared redirect helper built on it\n * can never be an open redirect.\n */\nexport function resolveRedirectTarget(origin: string, target: string): URL {\n const url = new URL(target, origin);\n if (!/^https?:\\/\\//i.test(target) && url.origin !== new URL(origin).origin) {\n throw new Error(`resolveRedirectTarget: \"${target}\" is not a same-origin path`);\n }\n return url;\n}\n\n// ── Single-owner host primitives ──\n\n/** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */\nexport function hostOf(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n return new URL(value).hostname.toLowerCase();\n } catch {\n return null;\n }\n}\n\n/** Expand a host into its `www.`/apex pair. 3+-label and single-label hosts return `[host]`. */\nexport function expandWwwApex(host: string): string[] {\n if (host.startsWith('www.')) return [host, host.slice(4)];\n if (host.split('.').length === 2) return [host, `www.${host}`];\n return [host];\n}\n\n/** Registrable base domain (`parts.slice(-2).join('.')`), dotless; undefined for <2-label. */\nexport function toRegistrableBaseDomain(host: string): string | undefined {\n const parts = host.split('.');\n if (parts.length >= 2) return parts.slice(-2).join('.');\n return undefined;\n}\n\n/** An entry's alias hosts (single-owner reader). */\nexport function aliasHostsOf(key: string): string[] {\n return byKey(key)?.aliasHostnames ?? [];\n}\n\n/** All hosts an entry contributes to the reverse index (resolved host + optional aliases). */\nfunction hostsForEntry(entry: PlatformDomainEntry, opts: { includeAliases: boolean }): string[] {\n const resolved = hostOf(getPlatformProductionUrl(entry.key));\n const hosts = resolved ? expandWwwApex(resolved) : [];\n if (opts.includeAliases) hosts.push(...aliasHostsOf(entry.key));\n return hosts;\n}\n\n/**\n * Reverse resolver: hostname → platform key (first-wins over registry order, non-pseudo only).\n * Guarantees openframe.ai / www.openframe.ai / hub.openframe.ai → openframe in every env.\n * Replaces the hub `PLATFORM_DOMAIN_MAP`.\n */\nexport function getPlatformByHostname(hostname: string): PlatformDomainKey | null {\n const host = hostname.toLowerCase();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n if (hostsForEntry(entry, { includeAliases: true }).includes(host)) return entry.key;\n }\n return null;\n}\n\n// ── Preview detection (two distinct predicates — env-form vs host-form) ──\n\n/** Env-form preview predicate (Vercel `VERCEL_ENV`). */\nexport function isPreviewEnv(): boolean {\n return process.env.VERCEL_ENV === 'preview';\n}\n\n/** Host-form preview predicate (a `*.vercel.app` host). Dot-bounded suffix so a\n * malicious `foo.vercel.app.evil.com` is NOT treated as preview. */\nexport function isPreviewHost(hostname: string): boolean {\n return hostname.endsWith('.vercel.app');\n}\n\n/**\n * ALL unique cookie base domains (the cross-subdomain SSO mechanism).\n *\n * NON-PURE (the sole such export): reads `typeof window` + `process.env` to\n * preserve byte-identical cookie behavior. Keeps the original three branches:\n * 1. localhost / private IP → [] (host-only cookies)\n * 2. Vercel preview (env OR host) → ['.vercel.app','vercel.app']\n * 3. production → for each non-pseudo platform, registrable base of its resolved\n * host, emitted as both `.base` and bare `base`.\n *\n * Because `getPlatformProductionUrl` always yields a host (override OR default),\n * `.flamingo.so` / `.flamingo.run` / `.openmsp.ai` / `.tmcg.miami` / `.openframe.ai`\n * are ALWAYS present → cross-hub SSO is byte-identical to today.\n */\nexport function getAllPlatformBaseDomains(): string[] {\n if (typeof window === 'undefined') return [];\n\n const hostname = window.location.hostname;\n\n // Case 1: localhost / private IP — no domains\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('127.')) {\n return [];\n }\n\n // Case 2: Vercel preview — vercel.app domain\n const previewEnv =\n process.env.VERCEL_ENV === 'preview' || process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' || isPreviewHost(hostname);\n if (previewEnv) {\n return ['.vercel.app', 'vercel.app'];\n }\n\n // Case 3: production — registrable base of every non-pseudo platform's resolved host\n const baseDomains = new Set<string>();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n const host = hostOf(getPlatformProductionUrl(entry.key));\n if (!host) continue;\n const base = toRegistrableBaseDomain(host);\n if (base) {\n baseDomains.add(`.${base}`);\n baseDomains.add(base);\n }\n }\n return Array.from(baseDomains);\n}\n\n// ── Cookie-domain guard + match (single owner; shared by the client cookie-domain.ts +\n// server-only cookie-domain-server.ts resolvers, which previously hand-rolled both 3×) ──\n\n/**\n * Hosts that must NOT receive a `Domain=` cookie → the caller returns undefined (host-only):\n * localhost, loopback/private IPs, and any `*.vercel.app`. `vercel.app` is on the Public Suffix\n * List, so browsers SILENTLY drop `Set-Cookie: Domain=.vercel.app` — which broke the PKCE verifier\n * + session cookies on preview deploys. Host-only is sufficient there (the same preview host\n * round-trips the OAuth chain); production hosts (`.flamingo.so`/`.openmsp.ai`/…) fall through.\n */\nexport function isNonCookieableHost(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname.startsWith('127.') ||\n hostname.startsWith('192.168.') ||\n hostname.startsWith('10.') ||\n hostname.includes('.vercel.app')\n );\n}\n\n/**\n * Match a hostname against a set of registrable base domains → the dotted cookie `Domain`\n * (`.flamingo.so`), or undefined when none contains the host. Accepts bases with or without a\n * leading dot and always returns the dotted form. Single owner for the match loop both resolvers ran.\n */\nexport function matchCookieDomain(hostname: string, baseDomains: string[]): string | undefined {\n for (const domain of baseDomains) {\n const bare = domain.startsWith('.') ? domain.slice(1) : domain;\n if (hostname === bare || hostname.endsWith(`.${bare}`)) {\n return domain.startsWith('.') ? domain : `.${domain}`;\n }\n }\n return undefined;\n}\n\n// ── Module-load ordering self-check (NON-fatal — this module is imported by cn.ts → ~everything,\n// so a hard throw would be a total outage if the assertion were ever over-strict). Checks the REAL\n// invariant — table order — STRUCTURALLY (findIndex), NOT via getPlatformByHostname on a hardcoded\n// host: the latter false-positives when NEXT_PUBLIC_FLAMINGO_URL is overridden to a non-default host\n// (flamingo's resolved host changes, so `www.flamingo.run` no longer reverse-maps to it though the\n// ordering is fine). The alias checks below ARE env-immune (aliasHostnames are unique per key). The\n// authoritative guard is the reverse-map vitest. ⚠️ keep `flamingo` before `flamingo-teaser`/`universal`.\nconst _orderIdx = (k: PlatformDomainKey) => PLATFORM_DOMAINS.findIndex(e => e.key === k);\nif (\n _orderIdx('flamingo') > _orderIdx('flamingo-teaser') ||\n _orderIdx('flamingo') > _orderIdx('universal') ||\n getPlatformByHostname('flamingo.cx') !== 'flamingo-teaser' ||\n getPlatformByHostname('hub.openframe.ai') !== 'openframe'\n) {\n console.error(\n '[platform-domains] ⚠️ PLATFORM_DOMAINS ordering invariant violated — `flamingo` must precede ' +\n '`flamingo-teaser`/`universal`, and the openframe/teaser aliases must be intact. Do not reorder the table.',\n );\n}\n"]}
@@ -39,9 +39,8 @@ export declare function byKey(key: string): PlatformDomainEntry | undefined;
39
39
  * base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry
40
40
  * `defaultUrl`s, any scheme'd override) pass through unchanged.
41
41
  *
42
- * EXPORTED as the single owner of the scheme-normalization rule (next.config.mjs keeps a
43
- * byte-identical local copy ONLY because Next evaluates its config outside the TS module
44
- * graph and cannot import this — see the comment there).
42
+ * EXPORTED as the single owner of the scheme-normalization rule. This subpath is pure ESM,
43
+ * so a consumer's next.config.mjs imports it directly rather than keeping a copy.
45
44
  *
46
45
  * Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it
47
46
  * doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).
@@ -52,9 +51,68 @@ export declare function ensureScheme(url: string): string;
52
51
  * NEVER throws / undefined — the default guarantees a host (this is what keeps the
53
52
  * cookie base-domains, the reverse map, and CSP intact even with every override unset).
54
53
  * The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides
55
- * resolve to valid URLs. Unknown-key fallback preserves cn.ts's flamingo.run default.
54
+ * resolve to valid URLs. Unknown-key fallback is flamingo's URL.
56
55
  */
57
56
  export declare function getPlatformProductionUrl(platform: string): string;
57
+ /**
58
+ * THE URL of a platform, for the environment the code is running in, no trailing slash.
59
+ * The one platform-URL resolver: consumers build every link to a platform from this.
60
+ *
61
+ * - `environment: 'current'` (default): the local dev URL (`NEXT_PUBLIC_DEV_URL`, else
62
+ * `http://localhost:3000`) outside a production build, the registry's production URL
63
+ * in any production build (a preview included — a preview never links to itself as
64
+ * canonical).
65
+ * - `environment: 'production'`: the registry's production URL everywhere, for links that
66
+ * leave the machine.
67
+ *
68
+ * `platform` is REQUIRED. The former `getBaseUrl()` accepted none and then returned
69
+ * `VERCEL_PROJECT_PRODUCTION_URL` — whichever domain Vercel lists first for a project
70
+ * (`flamingo.cx` on flamingo, a 308), and production on previews. A deployment's own
71
+ * origin is not a platform URL; consumers resolve it themselves.
72
+ */
73
+ export declare function getPlatformUrl(platform: string, options?: {
74
+ environment?: 'current' | 'production';
75
+ }): string;
76
+ /**
77
+ * Where THIS app is reachable, no trailing slash: what anything outside the app must
78
+ * fetch from the code that is running (rendered images, provider callbacks, self-calls).
79
+ * The one app-origin resolver; each app only supplies its own platform and config.
80
+ *
81
+ * In order:
82
+ * 1. In the browser: the page's origin.
83
+ * 2. `configuredUrl`: an app whose URL is configured at runtime (a self-hosted OpenFrame
84
+ * install's `NEXT_PUBLIC_APP_URL`) — that install's address wins over any default.
85
+ * 3. On a Vercel preview: the deployment's immutable `VERCEL_URL` (not the branch alias,
86
+ * which moves to the next commit and would serve other code).
87
+ * 4. In any production build: the platform's registry URL.
88
+ * 5. In development: `NEXT_PUBLIC_DEV_URL`, else localhost on the running port.
89
+ */
90
+ export declare function getDeploymentUrl(options: {
91
+ platform: string;
92
+ configuredUrl?: string | null;
93
+ }): string;
94
+ /** Is this URL on the local machine, where no external system (a webhook sender, an
95
+ * OAuth provider) can reach it? False for anything that is not a URL. */
96
+ export declare function isLocalUrl(url: string): boolean;
97
+ /**
98
+ * The origin a server request arrived on, from its `host` header only (what the edge set
99
+ * for this request — a client-writable `x-forwarded-host` never chooses where a flow
100
+ * returns). `http` for a local host unless the proxy says otherwise, else `https`.
101
+ * With no Host header, the app's own origin (`getDeploymentUrl` for `platform`).
102
+ */
103
+ export declare function getRequestOrigin(headers: {
104
+ get(name: string): string | null;
105
+ }, options: {
106
+ platform: string;
107
+ configuredUrl?: string | null;
108
+ }): string;
109
+ /**
110
+ * Where a redirect goes: a path resolves against `origin`; an explicit absolute
111
+ * `http(s)://` URL is used as is. THROWS when a relative target resolves to another
112
+ * origin (`//evil.example`, `/\\evil.example`), so a shared redirect helper built on it
113
+ * can never be an open redirect.
114
+ */
115
+ export declare function resolveRedirectTarget(origin: string, target: string): URL;
58
116
  /** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */
59
117
  export declare function hostOf(value: string | null | undefined): string | null;
60
118
  /** Expand a host into its `www.`/apex pair. 3+-label and single-label hosts return `[host]`. */
@@ -1 +1 @@
1
- {"version":3,"file":"platform-domains.d.ts","sourceRoot":"","sources":["../src/platform-domains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,E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;qEACqE;AACrE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CA8BpD;AAKD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAS7D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAQ7F"}
@@ -63,6 +63,44 @@ function getPlatformProductionUrl(platform) {
63
63
  const resolved = envOverrideFor(platform) ?? byKey(platform)?.defaultUrl ?? envOverrideFor("flamingo") ?? "https://www.flamingo.run";
64
64
  return ensureScheme(resolved);
65
65
  }
66
+ function getPlatformUrl(platform, options = {}) {
67
+ const url = options.environment !== "production" && process.env.NODE_ENV !== "production" ? process.env.NEXT_PUBLIC_DEV_URL || "http://localhost:3000" : getPlatformProductionUrl(platform);
68
+ return url.replace(/\/+$/, "");
69
+ }
70
+ function getDeploymentUrl(options) {
71
+ if (typeof window !== "undefined") return window.location.origin;
72
+ const configured = options.configuredUrl?.trim();
73
+ if (configured) return ensureScheme(configured).replace(/\/+$/, "");
74
+ if (process.env.VERCEL_ENV === "preview" && process.env.VERCEL_URL) {
75
+ return ensureScheme(process.env.VERCEL_URL).replace(/\/+$/, "");
76
+ }
77
+ if (process.env.VERCEL_ENV === "production" || process.env.NODE_ENV === "production") {
78
+ return getPlatformUrl(options.platform, { environment: "production" });
79
+ }
80
+ return (process.env.NEXT_PUBLIC_DEV_URL || `http://localhost:${process.env.PORT ?? 3e3}`).replace(/\/+$/, "");
81
+ }
82
+ var LOCAL_HOSTNAME = /^(localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1\])$/i;
83
+ function isLocalUrl(url) {
84
+ try {
85
+ return LOCAL_HOSTNAME.test(new URL(url).hostname);
86
+ } catch {
87
+ return false;
88
+ }
89
+ }
90
+ function getRequestOrigin(headers, options) {
91
+ const host = headers.get("host");
92
+ if (!host) return getDeploymentUrl(options);
93
+ const local = LOCAL_HOSTNAME.test(host.replace(/:\d+$/, ""));
94
+ const proto = headers.get("x-forwarded-proto")?.split(",")[0].trim() || (local ? "http" : "https");
95
+ return `${proto}://${host}`;
96
+ }
97
+ function resolveRedirectTarget(origin, target) {
98
+ const url = new URL(target, origin);
99
+ if (!/^https?:\/\//i.test(target) && url.origin !== new URL(origin).origin) {
100
+ throw new Error(`resolveRedirectTarget: "${target}" is not a same-origin path`);
101
+ }
102
+ return url;
103
+ }
66
104
  function hostOf(value) {
67
105
  if (!value) return null;
68
106
  try {
@@ -146,6 +184,6 @@ if (_orderIdx("flamingo") > _orderIdx("flamingo-teaser") || _orderIdx("flamingo"
146
184
  );
147
185
  }
148
186
 
149
- export { PLATFORM_DOMAINS, aliasHostsOf, byKey, ensureScheme, expandWwwApex, getAllPlatformBaseDomains, getPlatformByHostname, getPlatformProductionUrl, hostOf, isNonCookieableHost, isPreviewEnv, isPreviewHost, matchCookieDomain, toRegistrableBaseDomain };
187
+ export { PLATFORM_DOMAINS, aliasHostsOf, byKey, ensureScheme, expandWwwApex, getAllPlatformBaseDomains, getDeploymentUrl, getPlatformByHostname, getPlatformProductionUrl, getPlatformUrl, getRequestOrigin, hostOf, isLocalUrl, isNonCookieableHost, isPreviewEnv, isPreviewHost, matchCookieDomain, resolveRedirectTarget, toRegistrableBaseDomain };
150
188
  //# sourceMappingURL=platform-domains.js.map
151
189
  //# sourceMappingURL=platform-domains.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/platform-domains.ts"],"names":[],"mappings":";AAkCO,IAAM,gBAAA,GAAmD;AAAA,EAC9D,EAAE,GAAA,EAAK,eAAA,EAAiB,UAAA,EAAY,mCAAA,EAAqC,QAAQ,+BAAA,EAAgC;AAAA,EACjH,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,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AM,SAAA,GAAY,CAAC,CAAA,KAAyB,gBAAA,CAAiB,UAAU,CAAA,CAAA,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAA;AACvF,IACE,UAAU,UAAU,CAAA,GAAI,UAAU,iBAAiB,CAAA,IACnD,UAAU,UAAU,CAAA,GAAI,UAAU,WAAW,CAAA,IAC7C,sBAAsB,aAAa,CAAA,KAAM,qBACzC,qBAAA,CAAsB,kBAAkB,MAAM,WAAA,EAC9C;AACA,EAAA,OAAA,CAAQ,KAAA;AAAA,IACN;AAAA,GAEF;AACF","file":"platform-domains.js","sourcesContent":["/**\n * Platform-Domain SSOT (single source of truth) + derivations.\n *\n * ONE registry maps each platform → its canonical production URL (`defaultUrl`,\n * the load-bearing source) with an optional per-deploy `NEXT_PUBLIC_*_URL`\n * OVERRIDE. Everything else — the reverse host→platform resolver, the cookie\n * base-domain set (the cross-subdomain SSO mechanism), www/apex expansion, the\n * URL→host parse, preview detection — derives from this one table.\n *\n * EDGE-SAFE + PURE: no React/clsx/tailwind, no `server-only`, no `node:`\n * builtins, no `'use client'`. So it is legal in the Edge middleware\n * (`proxy.ts`), in `'use client'` providers, AND in `server-only` modules\n * (e.g. cookie-domain-server.ts) simultaneously. The ONLY non-pure export is\n * `getAllPlatformBaseDomains`, which reads `typeof window`/`process.env` to\n * preserve byte-identical cookie behavior.\n */\n\nimport type { PlatformName } from './types/platform';\n\nexport type PlatformDomainKey = PlatformName | 'openframe-dashboard';\n\nexport interface PlatformDomainEntry {\n /** Platform key (matches `PlatformName`, plus the forward-only `openframe-dashboard`). */\n key: PlatformDomainKey;\n /** Canonical production URL — the LOAD-BEARING source of truth (today's hardcoded fallbacks). */\n defaultUrl: string;\n /** `NEXT_PUBLIC_*_URL` per-deploy OVERRIDE. The `defaultUrl` covers it when unset. */\n envVar: string;\n /** Legacy/secondary hosts that REVERSE-map to this key (no env var exists — NOT canonical). */\n aliasHostnames?: string[];\n /** Forward-only: no DB row, excluded from the reverse index + cookie set (e.g. the product-CTA dashboard). */\n pseudo?: boolean;\n}\n\nexport const PLATFORM_DOMAINS: readonly PlatformDomainEntry[] = [\n { key: 'marketing-hub', defaultUrl: 'https://marketing-hub.flamingo.so', envVar: 'NEXT_PUBLIC_MARKETING_HUB_URL' },\n { key: 'company-hub', defaultUrl: 'https://company-hub.flamingo.so', envVar: 'NEXT_PUBLIC_COMPANY_HUB_URL' },\n { key: 'product-hub', defaultUrl: 'https://product-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PRODUCT_HUB_URL' },\n { key: 'revenue-hub', defaultUrl: 'https://revenue-hub.flamingo.so', envVar: 'NEXT_PUBLIC_REVENUE_HUB_URL' },\n { key: 'people-hub', defaultUrl: 'https://people-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PEOPLE_HUB_URL' },\n { key: 'openmsp', defaultUrl: 'https://www.openmsp.ai', envVar: 'NEXT_PUBLIC_OPENMSP_URL' },\n // ORDERING INVARIANT (first-wins, load-bearing): `flamingo` MUST precede `flamingo-teaser` + `universal`.\n // All three resolve to www.flamingo.run; the reverse index is first-wins → flamingo claims the shared host,\n // teaser keeps only its unique flamingo.cx aliases, universal contributes no unique host.\n // ⚠️ DO NOT REORDER — enforced by the module-load self-check at the bottom of this file.\n { key: 'flamingo', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n { key: 'tmcg', defaultUrl: 'https://www.tmcg.miami', envVar: 'NEXT_PUBLIC_TMCG_URL' },\n { key: 'mlg', defaultUrl: 'https://www.mlg.soccer', envVar: 'NEXT_PUBLIC_MLG_URL' },\n {\n key: 'flamingo-teaser',\n defaultUrl: 'https://www.flamingo.run',\n envVar: 'NEXT_PUBLIC_FLAMINGO_URL',\n aliasHostnames: ['flamingo.cx', 'www.flamingo.cx'],\n },\n {\n key: 'openframe',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_URL',\n aliasHostnames: ['openframe.ai', 'www.openframe.ai', 'hub.openframe.ai'],\n },\n {\n key: 'openframe-dashboard',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL',\n pseudo: true,\n },\n { key: 'universal', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n];\n\n// ── Compile-time key guards (anchor the table on PlatformName, both directions) ──\n// (1) Removal/typo guard: every table key must be a valid PlatformDomainKey.\nconst _tableSatisfies = PLATFORM_DOMAINS satisfies readonly PlatformDomainEntry[];\nvoid _tableSatisfies;\n// (2) Addition guard: a NEW PlatformName member that lacks a table row fails the build.\ntype _MissingKey = Exclude<PlatformName, (typeof PLATFORM_DOMAINS)[number]['key']>;\nconst _exhaustive: [_MissingKey] extends [never] ? true : false = true;\nvoid _exhaustive;\n\n// ── Env overrides (the ONLY place env URLs enter — literal-key inlined + compile-time-guarded) ──\n// `process.env.NEXT_PUBLIC_X` is build-inlined ONLY with a LITERAL key, so the env-var name is the\n// irreducible two-copy (the registry `envVar` column + the literal access below). The `satisfies` makes\n// `tsc`/`next build` FAIL if this map is missing a registry env var OR carries a stale one (bidirectional).\ntype EnvVarKey = (typeof PLATFORM_DOMAINS)[number]['envVar'];\nconst ENV_OVERRIDES = {\n NEXT_PUBLIC_MARKETING_HUB_URL: process.env.NEXT_PUBLIC_MARKETING_HUB_URL,\n NEXT_PUBLIC_COMPANY_HUB_URL: process.env.NEXT_PUBLIC_COMPANY_HUB_URL,\n NEXT_PUBLIC_PRODUCT_HUB_URL: process.env.NEXT_PUBLIC_PRODUCT_HUB_URL,\n NEXT_PUBLIC_REVENUE_HUB_URL: process.env.NEXT_PUBLIC_REVENUE_HUB_URL,\n NEXT_PUBLIC_PEOPLE_HUB_URL: process.env.NEXT_PUBLIC_PEOPLE_HUB_URL,\n NEXT_PUBLIC_OPENMSP_URL: process.env.NEXT_PUBLIC_OPENMSP_URL,\n NEXT_PUBLIC_FLAMINGO_URL: process.env.NEXT_PUBLIC_FLAMINGO_URL,\n NEXT_PUBLIC_TMCG_URL: process.env.NEXT_PUBLIC_TMCG_URL,\n NEXT_PUBLIC_MLG_URL: process.env.NEXT_PUBLIC_MLG_URL,\n NEXT_PUBLIC_OPENFRAME_URL: process.env.NEXT_PUBLIC_OPENFRAME_URL,\n NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL: process.env.NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL,\n} satisfies Record<EnvVarKey, string | undefined>;\n\n/** The registry entry for a key (undefined for an unknown key). */\nexport function byKey(key: string): PlatformDomainEntry | undefined {\n return PLATFORM_DOMAINS.find(e => e.key === key);\n}\n\n/** Read a platform's `NEXT_PUBLIC_*_URL` override (or null). */\nfunction envOverrideFor(key: string): string | null {\n const envVar = byKey(key)?.envVar;\n if (!envVar) return null;\n return (ENV_OVERRIDES as Record<string, string | undefined>)[envVar] || null;\n}\n\n/**\n * Ensure a URL string carries a scheme. Per-deploy `NEXT_PUBLIC_*_URL` overrides are\n * stored SCHEME-LESS (bare host, e.g. `www.openmsp.ai` / `hub.openframe.ai`) — the\n * canonical convention in the Vercel shared-env store. This normalizes them to a full\n * `https://` URL so every downstream consumer (`hostOf`/`new URL`, hrefs, the cookie\n * base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry\n * `defaultUrl`s, any scheme'd override) pass through unchanged.\n *\n * EXPORTED as the single owner of the scheme-normalization rule (next.config.mjs keeps a\n * byte-identical local copy ONLY because Next evaluates its config outside the TS module\n * graph and cannot import this — see the comment there).\n *\n * Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it\n * doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).\n */\nexport function ensureScheme(url: string): string {\n const trimmed = url.trim();\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(trimmed)) return trimmed; // already has a scheme\n return `https://${trimmed.replace(/^\\/+/, '')}`; // bare host or protocol-relative `//host`\n}\n\n/**\n * Canonical production URL for a platform: env override wins, else the `defaultUrl`.\n * NEVER throws / undefined — the default guarantees a host (this is what keeps the\n * cookie base-domains, the reverse map, and CSP intact even with every override unset).\n * The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides\n * resolve to valid URLs. Unknown-key fallback preserves cn.ts's flamingo.run default.\n */\nexport function getPlatformProductionUrl(platform: string): string {\n const resolved =\n envOverrideFor(platform) ?? byKey(platform)?.defaultUrl ?? envOverrideFor('flamingo') ?? 'https://www.flamingo.run';\n return ensureScheme(resolved);\n}\n\n// ── Single-owner host primitives ──\n\n/** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */\nexport function hostOf(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n return new URL(value).hostname.toLowerCase();\n } catch {\n return null;\n }\n}\n\n/** Expand a host into its `www.`/apex pair. 3+-label and single-label hosts return `[host]`. */\nexport function expandWwwApex(host: string): string[] {\n if (host.startsWith('www.')) return [host, host.slice(4)];\n if (host.split('.').length === 2) return [host, `www.${host}`];\n return [host];\n}\n\n/** Registrable base domain (`parts.slice(-2).join('.')`), dotless; undefined for <2-label. */\nexport function toRegistrableBaseDomain(host: string): string | undefined {\n const parts = host.split('.');\n if (parts.length >= 2) return parts.slice(-2).join('.');\n return undefined;\n}\n\n/** An entry's alias hosts (single-owner reader). */\nexport function aliasHostsOf(key: string): string[] {\n return byKey(key)?.aliasHostnames ?? [];\n}\n\n/** All hosts an entry contributes to the reverse index (resolved host + optional aliases). */\nfunction hostsForEntry(entry: PlatformDomainEntry, opts: { includeAliases: boolean }): string[] {\n const resolved = hostOf(getPlatformProductionUrl(entry.key));\n const hosts = resolved ? expandWwwApex(resolved) : [];\n if (opts.includeAliases) hosts.push(...aliasHostsOf(entry.key));\n return hosts;\n}\n\n/**\n * Reverse resolver: hostname → platform key (first-wins over registry order, non-pseudo only).\n * Guarantees openframe.ai / www.openframe.ai / hub.openframe.ai → openframe in every env.\n * Replaces the hub `PLATFORM_DOMAIN_MAP`.\n */\nexport function getPlatformByHostname(hostname: string): PlatformDomainKey | null {\n const host = hostname.toLowerCase();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n if (hostsForEntry(entry, { includeAliases: true }).includes(host)) return entry.key;\n }\n return null;\n}\n\n// ── Preview detection (two distinct predicates — env-form vs host-form) ──\n\n/** Env-form preview predicate (Vercel `VERCEL_ENV`). */\nexport function isPreviewEnv(): boolean {\n return process.env.VERCEL_ENV === 'preview';\n}\n\n/** Host-form preview predicate (a `*.vercel.app` host). Dot-bounded suffix so a\n * malicious `foo.vercel.app.evil.com` is NOT treated as preview. */\nexport function isPreviewHost(hostname: string): boolean {\n return hostname.endsWith('.vercel.app');\n}\n\n/**\n * ALL unique cookie base domains (the cross-subdomain SSO mechanism).\n *\n * NON-PURE (the sole such export): reads `typeof window` + `process.env` to\n * preserve byte-identical cookie behavior. Keeps the original three branches:\n * 1. localhost / private IP → [] (host-only cookies)\n * 2. Vercel preview (env OR host) → ['.vercel.app','vercel.app']\n * 3. production → for each non-pseudo platform, registrable base of its resolved\n * host, emitted as both `.base` and bare `base`.\n *\n * Because `getPlatformProductionUrl` always yields a host (override OR default),\n * `.flamingo.so` / `.flamingo.run` / `.openmsp.ai` / `.tmcg.miami` / `.openframe.ai`\n * are ALWAYS present → cross-hub SSO is byte-identical to today.\n */\nexport function getAllPlatformBaseDomains(): string[] {\n if (typeof window === 'undefined') return [];\n\n const hostname = window.location.hostname;\n\n // Case 1: localhost / private IP — no domains\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('127.')) {\n return [];\n }\n\n // Case 2: Vercel preview — vercel.app domain\n const previewEnv =\n process.env.VERCEL_ENV === 'preview' || process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' || isPreviewHost(hostname);\n if (previewEnv) {\n return ['.vercel.app', 'vercel.app'];\n }\n\n // Case 3: production — registrable base of every non-pseudo platform's resolved host\n const baseDomains = new Set<string>();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n const host = hostOf(getPlatformProductionUrl(entry.key));\n if (!host) continue;\n const base = toRegistrableBaseDomain(host);\n if (base) {\n baseDomains.add(`.${base}`);\n baseDomains.add(base);\n }\n }\n return Array.from(baseDomains);\n}\n\n// ── Cookie-domain guard + match (single owner; shared by the client cookie-domain.ts +\n// server-only cookie-domain-server.ts resolvers, which previously hand-rolled both 3×) ──\n\n/**\n * Hosts that must NOT receive a `Domain=` cookie → the caller returns undefined (host-only):\n * localhost, loopback/private IPs, and any `*.vercel.app`. `vercel.app` is on the Public Suffix\n * List, so browsers SILENTLY drop `Set-Cookie: Domain=.vercel.app` — which broke the PKCE verifier\n * + session cookies on preview deploys. Host-only is sufficient there (the same preview host\n * round-trips the OAuth chain); production hosts (`.flamingo.so`/`.openmsp.ai`/…) fall through.\n */\nexport function isNonCookieableHost(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname.startsWith('127.') ||\n hostname.startsWith('192.168.') ||\n hostname.startsWith('10.') ||\n hostname.includes('.vercel.app')\n );\n}\n\n/**\n * Match a hostname against a set of registrable base domains → the dotted cookie `Domain`\n * (`.flamingo.so`), or undefined when none contains the host. Accepts bases with or without a\n * leading dot and always returns the dotted form. Single owner for the match loop both resolvers ran.\n */\nexport function matchCookieDomain(hostname: string, baseDomains: string[]): string | undefined {\n for (const domain of baseDomains) {\n const bare = domain.startsWith('.') ? domain.slice(1) : domain;\n if (hostname === bare || hostname.endsWith(`.${bare}`)) {\n return domain.startsWith('.') ? domain : `.${domain}`;\n }\n }\n return undefined;\n}\n\n// ── Module-load ordering self-check (NON-fatal — this module is imported by cn.ts → ~everything,\n// so a hard throw would be a total outage if the assertion were ever over-strict). Checks the REAL\n// invariant — table order — STRUCTURALLY (findIndex), NOT via getPlatformByHostname on a hardcoded\n// host: the latter false-positives when NEXT_PUBLIC_FLAMINGO_URL is overridden to a non-default host\n// (flamingo's resolved host changes, so `www.flamingo.run` no longer reverse-maps to it though the\n// ordering is fine). The alias checks below ARE env-immune (aliasHostnames are unique per key). The\n// authoritative guard is the reverse-map vitest. ⚠️ keep `flamingo` before `flamingo-teaser`/`universal`.\nconst _orderIdx = (k: PlatformDomainKey) => PLATFORM_DOMAINS.findIndex(e => e.key === k);\nif (\n _orderIdx('flamingo') > _orderIdx('flamingo-teaser') ||\n _orderIdx('flamingo') > _orderIdx('universal') ||\n getPlatformByHostname('flamingo.cx') !== 'flamingo-teaser' ||\n getPlatformByHostname('hub.openframe.ai') !== 'openframe'\n) {\n console.error(\n '[platform-domains] ⚠️ PLATFORM_DOMAINS ordering invariant violated — `flamingo` must precede ' +\n '`flamingo-teaser`/`universal`, and the openframe/teaser aliases must be intact. Do not reorder the table.',\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/platform-domains.ts"],"names":[],"mappings":";AAkCO,IAAM,gBAAA,GAAmD;AAAA,EAC9D,EAAE,GAAA,EAAK,eAAA,EAAiB,UAAA,EAAY,mCAAA,EAAqC,QAAQ,+BAAA,EAAgC;AAAA,EACjH,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,EAAmC,QAAQ,6BAAA,EAA8B;AAAA,EAC3G,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,EAAmC,QAAQ,6BAAA,EAA8B;AAAA,EAC3G,EAAE,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,iCAAA,EAAmC,QAAQ,6BAAA,EAA8B;AAAA,EAC3G,EAAE,GAAA,EAAK,YAAA,EAAc,UAAA,EAAY,gCAAA,EAAkC,QAAQ,4BAAA,EAA6B;AAAA,EACxG,EAAE,GAAA,EAAK,SAAA,EAAW,UAAA,EAAY,wBAAA,EAA0B,QAAQ,yBAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1F,EAAE,GAAA,EAAK,UAAA,EAAY,UAAA,EAAY,0BAAA,EAA4B,QAAQ,0BAAA,EAA2B;AAAA,EAC9F,EAAE,GAAA,EAAK,MAAA,EAAQ,UAAA,EAAY,wB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CAAS,UAAA,CAAW,UAAU,KAC9B,QAAA,CAAS,UAAA,CAAW,KAAK,CAAA,IACzB,QAAA,CAAS,SAAS,aAAa,CAAA;AAEnC;AAOO,SAAS,iBAAA,CAAkB,UAAkB,WAAA,EAA2C;AAC7F,EAAA,KAAA,MAAW,UAAU,WAAA,EAAa;AAChC,IAAA,MAAM,IAAA,GAAO,OAAO,UAAA,CAAW,GAAG,IAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,GAAI,MAAA;AACxD,IAAA,IAAI,aAAa,IAAA,IAAQ,QAAA,CAAS,SAAS,CAAA,CAAA,EAAI,IAAI,EAAE,CAAA,EAAG;AACtD,MAAA,OAAO,OAAO,UAAA,CAAW,GAAG,CAAA,GAAI,MAAA,GAAS,IAAI,MAAM,CAAA,CAAA;AAAA,IACrD;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AASA,IAAM,SAAA,GAAY,CAAC,CAAA,KAAyB,gBAAA,CAAiB,UAAU,CAAA,CAAA,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAA;AACvF,IACE,UAAU,UAAU,CAAA,GAAI,UAAU,iBAAiB,CAAA,IACnD,UAAU,UAAU,CAAA,GAAI,UAAU,WAAW,CAAA,IAC7C,sBAAsB,aAAa,CAAA,KAAM,qBACzC,qBAAA,CAAsB,kBAAkB,MAAM,WAAA,EAC9C;AACA,EAAA,OAAA,CAAQ,KAAA;AAAA,IACN;AAAA,GAEF;AACF","file":"platform-domains.js","sourcesContent":["/**\n * Platform-Domain SSOT (single source of truth) + derivations.\n *\n * ONE registry maps each platform → its canonical production URL (`defaultUrl`,\n * the load-bearing source) with an optional per-deploy `NEXT_PUBLIC_*_URL`\n * OVERRIDE. Everything else — the reverse host→platform resolver, the cookie\n * base-domain set (the cross-subdomain SSO mechanism), www/apex expansion, the\n * URL→host parse, preview detection — derives from this one table.\n *\n * EDGE-SAFE + PURE: no React/clsx/tailwind, no `server-only`, no `node:`\n * builtins, no `'use client'`. So it is legal in the Edge middleware\n * (`proxy.ts`), in `'use client'` providers, AND in `server-only` modules\n * (e.g. cookie-domain-server.ts) simultaneously. The ONLY non-pure export is\n * `getAllPlatformBaseDomains`, which reads `typeof window`/`process.env` to\n * preserve byte-identical cookie behavior.\n */\n\nimport type { PlatformName } from './types/platform';\n\nexport type PlatformDomainKey = PlatformName | 'openframe-dashboard';\n\nexport interface PlatformDomainEntry {\n /** Platform key (matches `PlatformName`, plus the forward-only `openframe-dashboard`). */\n key: PlatformDomainKey;\n /** Canonical production URL — the LOAD-BEARING source of truth (today's hardcoded fallbacks). */\n defaultUrl: string;\n /** `NEXT_PUBLIC_*_URL` per-deploy OVERRIDE. The `defaultUrl` covers it when unset. */\n envVar: string;\n /** Legacy/secondary hosts that REVERSE-map to this key (no env var exists — NOT canonical). */\n aliasHostnames?: string[];\n /** Forward-only: no DB row, excluded from the reverse index + cookie set (e.g. the product-CTA dashboard). */\n pseudo?: boolean;\n}\n\nexport const PLATFORM_DOMAINS: readonly PlatformDomainEntry[] = [\n { key: 'marketing-hub', defaultUrl: 'https://marketing-hub.flamingo.so', envVar: 'NEXT_PUBLIC_MARKETING_HUB_URL' },\n { key: 'company-hub', defaultUrl: 'https://company-hub.flamingo.so', envVar: 'NEXT_PUBLIC_COMPANY_HUB_URL' },\n { key: 'product-hub', defaultUrl: 'https://product-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PRODUCT_HUB_URL' },\n { key: 'revenue-hub', defaultUrl: 'https://revenue-hub.flamingo.so', envVar: 'NEXT_PUBLIC_REVENUE_HUB_URL' },\n { key: 'people-hub', defaultUrl: 'https://people-hub.flamingo.so', envVar: 'NEXT_PUBLIC_PEOPLE_HUB_URL' },\n { key: 'openmsp', defaultUrl: 'https://www.openmsp.ai', envVar: 'NEXT_PUBLIC_OPENMSP_URL' },\n // ORDERING INVARIANT (first-wins, load-bearing): `flamingo` MUST precede `flamingo-teaser` + `universal`.\n // All three resolve to www.flamingo.run; the reverse index is first-wins → flamingo claims the shared host,\n // teaser keeps only its unique flamingo.cx aliases, universal contributes no unique host.\n // ⚠️ DO NOT REORDER — enforced by the module-load self-check at the bottom of this file.\n { key: 'flamingo', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n { key: 'tmcg', defaultUrl: 'https://www.tmcg.miami', envVar: 'NEXT_PUBLIC_TMCG_URL' },\n { key: 'mlg', defaultUrl: 'https://www.mlg.soccer', envVar: 'NEXT_PUBLIC_MLG_URL' },\n {\n key: 'flamingo-teaser',\n defaultUrl: 'https://www.flamingo.run',\n envVar: 'NEXT_PUBLIC_FLAMINGO_URL',\n aliasHostnames: ['flamingo.cx', 'www.flamingo.cx'],\n },\n {\n key: 'openframe',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_URL',\n aliasHostnames: ['openframe.ai', 'www.openframe.ai', 'hub.openframe.ai'],\n },\n {\n key: 'openframe-dashboard',\n defaultUrl: 'https://openframe.ai',\n envVar: 'NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL',\n pseudo: true,\n },\n { key: 'universal', defaultUrl: 'https://www.flamingo.run', envVar: 'NEXT_PUBLIC_FLAMINGO_URL' },\n];\n\n// ── Compile-time key guards (anchor the table on PlatformName, both directions) ──\n// (1) Removal/typo guard: every table key must be a valid PlatformDomainKey.\nconst _tableSatisfies = PLATFORM_DOMAINS satisfies readonly PlatformDomainEntry[];\nvoid _tableSatisfies;\n// (2) Addition guard: a NEW PlatformName member that lacks a table row fails the build.\ntype _MissingKey = Exclude<PlatformName, (typeof PLATFORM_DOMAINS)[number]['key']>;\nconst _exhaustive: [_MissingKey] extends [never] ? true : false = true;\nvoid _exhaustive;\n\n// ── Env overrides (the ONLY place env URLs enter — literal-key inlined + compile-time-guarded) ──\n// `process.env.NEXT_PUBLIC_X` is build-inlined ONLY with a LITERAL key, so the env-var name is the\n// irreducible two-copy (the registry `envVar` column + the literal access below). The `satisfies` makes\n// `tsc`/`next build` FAIL if this map is missing a registry env var OR carries a stale one (bidirectional).\ntype EnvVarKey = (typeof PLATFORM_DOMAINS)[number]['envVar'];\nconst ENV_OVERRIDES = {\n NEXT_PUBLIC_MARKETING_HUB_URL: process.env.NEXT_PUBLIC_MARKETING_HUB_URL,\n NEXT_PUBLIC_COMPANY_HUB_URL: process.env.NEXT_PUBLIC_COMPANY_HUB_URL,\n NEXT_PUBLIC_PRODUCT_HUB_URL: process.env.NEXT_PUBLIC_PRODUCT_HUB_URL,\n NEXT_PUBLIC_REVENUE_HUB_URL: process.env.NEXT_PUBLIC_REVENUE_HUB_URL,\n NEXT_PUBLIC_PEOPLE_HUB_URL: process.env.NEXT_PUBLIC_PEOPLE_HUB_URL,\n NEXT_PUBLIC_OPENMSP_URL: process.env.NEXT_PUBLIC_OPENMSP_URL,\n NEXT_PUBLIC_FLAMINGO_URL: process.env.NEXT_PUBLIC_FLAMINGO_URL,\n NEXT_PUBLIC_TMCG_URL: process.env.NEXT_PUBLIC_TMCG_URL,\n NEXT_PUBLIC_MLG_URL: process.env.NEXT_PUBLIC_MLG_URL,\n NEXT_PUBLIC_OPENFRAME_URL: process.env.NEXT_PUBLIC_OPENFRAME_URL,\n NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL: process.env.NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL,\n} satisfies Record<EnvVarKey, string | undefined>;\n\n/** The registry entry for a key (undefined for an unknown key). */\nexport function byKey(key: string): PlatformDomainEntry | undefined {\n return PLATFORM_DOMAINS.find(e => e.key === key);\n}\n\n/** Read a platform's `NEXT_PUBLIC_*_URL` override (or null). */\nfunction envOverrideFor(key: string): string | null {\n const envVar = byKey(key)?.envVar;\n if (!envVar) return null;\n return (ENV_OVERRIDES as Record<string, string | undefined>)[envVar] || null;\n}\n\n/**\n * Ensure a URL string carries a scheme. Per-deploy `NEXT_PUBLIC_*_URL` overrides are\n * stored SCHEME-LESS (bare host, e.g. `www.openmsp.ai` / `hub.openframe.ai`) — the\n * canonical convention in the Vercel shared-env store. This normalizes them to a full\n * `https://` URL so every downstream consumer (`hostOf`/`new URL`, hrefs, the cookie\n * base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry\n * `defaultUrl`s, any scheme'd override) pass through unchanged.\n *\n * EXPORTED as the single owner of the scheme-normalization rule. This subpath is pure ESM,\n * so a consumer's next.config.mjs imports it directly rather than keeping a copy.\n *\n * Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it\n * doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).\n */\nexport function ensureScheme(url: string): string {\n const trimmed = url.trim();\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(trimmed)) return trimmed; // already has a scheme\n return `https://${trimmed.replace(/^\\/+/, '')}`; // bare host or protocol-relative `//host`\n}\n\n/**\n * Canonical production URL for a platform: env override wins, else the `defaultUrl`.\n * NEVER throws / undefined — the default guarantees a host (this is what keeps the\n * cookie base-domains, the reverse map, and CSP intact even with every override unset).\n * The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides\n * resolve to valid URLs. Unknown-key fallback is flamingo's URL.\n */\nexport function getPlatformProductionUrl(platform: string): string {\n const resolved =\n envOverrideFor(platform) ?? byKey(platform)?.defaultUrl ?? envOverrideFor('flamingo') ?? 'https://www.flamingo.run';\n return ensureScheme(resolved);\n}\n\n/**\n * THE URL of a platform, for the environment the code is running in, no trailing slash.\n * The one platform-URL resolver: consumers build every link to a platform from this.\n *\n * - `environment: 'current'` (default): the local dev URL (`NEXT_PUBLIC_DEV_URL`, else\n * `http://localhost:3000`) outside a production build, the registry's production URL\n * in any production build (a preview included — a preview never links to itself as\n * canonical).\n * - `environment: 'production'`: the registry's production URL everywhere, for links that\n * leave the machine.\n *\n * `platform` is REQUIRED. The former `getBaseUrl()` accepted none and then returned\n * `VERCEL_PROJECT_PRODUCTION_URL` — whichever domain Vercel lists first for a project\n * (`flamingo.cx` on flamingo, a 308), and production on previews. A deployment's own\n * origin is not a platform URL; consumers resolve it themselves.\n */\nexport function getPlatformUrl(platform: string, options: { environment?: 'current' | 'production' } = {}): string {\n const url =\n options.environment !== 'production' && process.env.NODE_ENV !== 'production'\n ? process.env.NEXT_PUBLIC_DEV_URL || 'http://localhost:3000'\n : getPlatformProductionUrl(platform);\n return url.replace(/\\/+$/, '');\n}\n\n/**\n * Where THIS app is reachable, no trailing slash: what anything outside the app must\n * fetch from the code that is running (rendered images, provider callbacks, self-calls).\n * The one app-origin resolver; each app only supplies its own platform and config.\n *\n * In order:\n * 1. In the browser: the page's origin.\n * 2. `configuredUrl`: an app whose URL is configured at runtime (a self-hosted OpenFrame\n * install's `NEXT_PUBLIC_APP_URL`) — that install's address wins over any default.\n * 3. On a Vercel preview: the deployment's immutable `VERCEL_URL` (not the branch alias,\n * which moves to the next commit and would serve other code).\n * 4. In any production build: the platform's registry URL.\n * 5. In development: `NEXT_PUBLIC_DEV_URL`, else localhost on the running port.\n */\nexport function getDeploymentUrl(options: { platform: string; configuredUrl?: string | null }): string {\n if (typeof window !== 'undefined') return window.location.origin;\n const configured = options.configuredUrl?.trim();\n if (configured) return ensureScheme(configured).replace(/\\/+$/, '');\n if (process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_URL) {\n return ensureScheme(process.env.VERCEL_URL).replace(/\\/+$/, '');\n }\n if (process.env.VERCEL_ENV === 'production' || process.env.NODE_ENV === 'production') {\n return getPlatformUrl(options.platform, { environment: 'production' });\n }\n return (process.env.NEXT_PUBLIC_DEV_URL || `http://localhost:${process.env.PORT ?? 3000}`).replace(/\\/+$/, '');\n}\n\n/** A hostname on the local machine, matched WHOLE: `localhost.example.com` and\n * `127.evil.example` are public hosts. */\nconst LOCAL_HOSTNAME = /^(localhost|127(?:\\.\\d{1,3}){3}|0\\.0\\.0\\.0|\\[::1\\])$/i;\n\n/** Is this URL on the local machine, where no external system (a webhook sender, an\n * OAuth provider) can reach it? False for anything that is not a URL. */\nexport function isLocalUrl(url: string): boolean {\n try {\n return LOCAL_HOSTNAME.test(new URL(url).hostname);\n } catch {\n return false;\n }\n}\n\n/**\n * The origin a server request arrived on, from its `host` header only (what the edge set\n * for this request — a client-writable `x-forwarded-host` never chooses where a flow\n * returns). `http` for a local host unless the proxy says otherwise, else `https`.\n * With no Host header, the app's own origin (`getDeploymentUrl` for `platform`).\n */\nexport function getRequestOrigin(\n headers: { get(name: string): string | null },\n options: { platform: string; configuredUrl?: string | null },\n): string {\n const host = headers.get('host');\n if (!host) return getDeploymentUrl(options);\n const local = LOCAL_HOSTNAME.test(host.replace(/:\\d+$/, ''));\n const proto = headers.get('x-forwarded-proto')?.split(',')[0].trim() || (local ? 'http' : 'https');\n return `${proto}://${host}`;\n}\n\n/**\n * Where a redirect goes: a path resolves against `origin`; an explicit absolute\n * `http(s)://` URL is used as is. THROWS when a relative target resolves to another\n * origin (`//evil.example`, `/\\\\evil.example`), so a shared redirect helper built on it\n * can never be an open redirect.\n */\nexport function resolveRedirectTarget(origin: string, target: string): URL {\n const url = new URL(target, origin);\n if (!/^https?:\\/\\//i.test(target) && url.origin !== new URL(origin).origin) {\n throw new Error(`resolveRedirectTarget: \"${target}\" is not a same-origin path`);\n }\n return url;\n}\n\n// ── Single-owner host primitives ──\n\n/** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */\nexport function hostOf(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n return new URL(value).hostname.toLowerCase();\n } catch {\n return null;\n }\n}\n\n/** Expand a host into its `www.`/apex pair. 3+-label and single-label hosts return `[host]`. */\nexport function expandWwwApex(host: string): string[] {\n if (host.startsWith('www.')) return [host, host.slice(4)];\n if (host.split('.').length === 2) return [host, `www.${host}`];\n return [host];\n}\n\n/** Registrable base domain (`parts.slice(-2).join('.')`), dotless; undefined for <2-label. */\nexport function toRegistrableBaseDomain(host: string): string | undefined {\n const parts = host.split('.');\n if (parts.length >= 2) return parts.slice(-2).join('.');\n return undefined;\n}\n\n/** An entry's alias hosts (single-owner reader). */\nexport function aliasHostsOf(key: string): string[] {\n return byKey(key)?.aliasHostnames ?? [];\n}\n\n/** All hosts an entry contributes to the reverse index (resolved host + optional aliases). */\nfunction hostsForEntry(entry: PlatformDomainEntry, opts: { includeAliases: boolean }): string[] {\n const resolved = hostOf(getPlatformProductionUrl(entry.key));\n const hosts = resolved ? expandWwwApex(resolved) : [];\n if (opts.includeAliases) hosts.push(...aliasHostsOf(entry.key));\n return hosts;\n}\n\n/**\n * Reverse resolver: hostname → platform key (first-wins over registry order, non-pseudo only).\n * Guarantees openframe.ai / www.openframe.ai / hub.openframe.ai → openframe in every env.\n * Replaces the hub `PLATFORM_DOMAIN_MAP`.\n */\nexport function getPlatformByHostname(hostname: string): PlatformDomainKey | null {\n const host = hostname.toLowerCase();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n if (hostsForEntry(entry, { includeAliases: true }).includes(host)) return entry.key;\n }\n return null;\n}\n\n// ── Preview detection (two distinct predicates — env-form vs host-form) ──\n\n/** Env-form preview predicate (Vercel `VERCEL_ENV`). */\nexport function isPreviewEnv(): boolean {\n return process.env.VERCEL_ENV === 'preview';\n}\n\n/** Host-form preview predicate (a `*.vercel.app` host). Dot-bounded suffix so a\n * malicious `foo.vercel.app.evil.com` is NOT treated as preview. */\nexport function isPreviewHost(hostname: string): boolean {\n return hostname.endsWith('.vercel.app');\n}\n\n/**\n * ALL unique cookie base domains (the cross-subdomain SSO mechanism).\n *\n * NON-PURE (the sole such export): reads `typeof window` + `process.env` to\n * preserve byte-identical cookie behavior. Keeps the original three branches:\n * 1. localhost / private IP → [] (host-only cookies)\n * 2. Vercel preview (env OR host) → ['.vercel.app','vercel.app']\n * 3. production → for each non-pseudo platform, registrable base of its resolved\n * host, emitted as both `.base` and bare `base`.\n *\n * Because `getPlatformProductionUrl` always yields a host (override OR default),\n * `.flamingo.so` / `.flamingo.run` / `.openmsp.ai` / `.tmcg.miami` / `.openframe.ai`\n * are ALWAYS present → cross-hub SSO is byte-identical to today.\n */\nexport function getAllPlatformBaseDomains(): string[] {\n if (typeof window === 'undefined') return [];\n\n const hostname = window.location.hostname;\n\n // Case 1: localhost / private IP — no domains\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('127.')) {\n return [];\n }\n\n // Case 2: Vercel preview — vercel.app domain\n const previewEnv =\n process.env.VERCEL_ENV === 'preview' || process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' || isPreviewHost(hostname);\n if (previewEnv) {\n return ['.vercel.app', 'vercel.app'];\n }\n\n // Case 3: production — registrable base of every non-pseudo platform's resolved host\n const baseDomains = new Set<string>();\n for (const entry of PLATFORM_DOMAINS) {\n if (entry.pseudo) continue;\n const host = hostOf(getPlatformProductionUrl(entry.key));\n if (!host) continue;\n const base = toRegistrableBaseDomain(host);\n if (base) {\n baseDomains.add(`.${base}`);\n baseDomains.add(base);\n }\n }\n return Array.from(baseDomains);\n}\n\n// ── Cookie-domain guard + match (single owner; shared by the client cookie-domain.ts +\n// server-only cookie-domain-server.ts resolvers, which previously hand-rolled both 3×) ──\n\n/**\n * Hosts that must NOT receive a `Domain=` cookie → the caller returns undefined (host-only):\n * localhost, loopback/private IPs, and any `*.vercel.app`. `vercel.app` is on the Public Suffix\n * List, so browsers SILENTLY drop `Set-Cookie: Domain=.vercel.app` — which broke the PKCE verifier\n * + session cookies on preview deploys. Host-only is sufficient there (the same preview host\n * round-trips the OAuth chain); production hosts (`.flamingo.so`/`.openmsp.ai`/…) fall through.\n */\nexport function isNonCookieableHost(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname.startsWith('127.') ||\n hostname.startsWith('192.168.') ||\n hostname.startsWith('10.') ||\n hostname.includes('.vercel.app')\n );\n}\n\n/**\n * Match a hostname against a set of registrable base domains → the dotted cookie `Domain`\n * (`.flamingo.so`), or undefined when none contains the host. Accepts bases with or without a\n * leading dot and always returns the dotted form. Single owner for the match loop both resolvers ran.\n */\nexport function matchCookieDomain(hostname: string, baseDomains: string[]): string | undefined {\n for (const domain of baseDomains) {\n const bare = domain.startsWith('.') ? domain.slice(1) : domain;\n if (hostname === bare || hostname.endsWith(`.${bare}`)) {\n return domain.startsWith('.') ? domain : `.${domain}`;\n }\n }\n return undefined;\n}\n\n// ── Module-load ordering self-check (NON-fatal — this module is imported by cn.ts → ~everything,\n// so a hard throw would be a total outage if the assertion were ever over-strict). Checks the REAL\n// invariant — table order — STRUCTURALLY (findIndex), NOT via getPlatformByHostname on a hardcoded\n// host: the latter false-positives when NEXT_PUBLIC_FLAMINGO_URL is overridden to a non-default host\n// (flamingo's resolved host changes, so `www.flamingo.run` no longer reverse-maps to it though the\n// ordering is fine). The alias checks below ARE env-immune (aliasHostnames are unique per key). The\n// authoritative guard is the reverse-map vitest. ⚠️ keep `flamingo` before `flamingo-teaser`/`universal`.\nconst _orderIdx = (k: PlatformDomainKey) => PLATFORM_DOMAINS.findIndex(e => e.key === k);\nif (\n _orderIdx('flamingo') > _orderIdx('flamingo-teaser') ||\n _orderIdx('flamingo') > _orderIdx('universal') ||\n getPlatformByHostname('flamingo.cx') !== 'flamingo-teaser' ||\n getPlatformByHostname('hub.openframe.ai') !== 'openframe'\n) {\n console.error(\n '[platform-domains] ⚠️ PLATFORM_DOMAINS ordering invariant violated — `flamingo` must precede ' +\n '`flamingo-teaser`/`universal`, and the openframe/teaser aliases must be intact. Do not reorder the table.',\n );\n}\n"]}
@@ -99,110 +99,6 @@ function ShellIcon({
99
99
  }
100
100
  ) });
101
101
  }
102
-
103
- // src/platform-domains.ts
104
- var PLATFORM_DOMAINS = [
105
- { key: "marketing-hub", defaultUrl: "https://marketing-hub.flamingo.so", envVar: "NEXT_PUBLIC_MARKETING_HUB_URL" },
106
- { key: "company-hub", defaultUrl: "https://company-hub.flamingo.so", envVar: "NEXT_PUBLIC_COMPANY_HUB_URL" },
107
- { key: "product-hub", defaultUrl: "https://product-hub.flamingo.so", envVar: "NEXT_PUBLIC_PRODUCT_HUB_URL" },
108
- { key: "revenue-hub", defaultUrl: "https://revenue-hub.flamingo.so", envVar: "NEXT_PUBLIC_REVENUE_HUB_URL" },
109
- { key: "people-hub", defaultUrl: "https://people-hub.flamingo.so", envVar: "NEXT_PUBLIC_PEOPLE_HUB_URL" },
110
- { key: "openmsp", defaultUrl: "https://www.openmsp.ai", envVar: "NEXT_PUBLIC_OPENMSP_URL" },
111
- // ORDERING INVARIANT (first-wins, load-bearing): `flamingo` MUST precede `flamingo-teaser` + `universal`.
112
- // All three resolve to www.flamingo.run; the reverse index is first-wins → flamingo claims the shared host,
113
- // teaser keeps only its unique flamingo.cx aliases, universal contributes no unique host.
114
- // ⚠️ DO NOT REORDER — enforced by the module-load self-check at the bottom of this file.
115
- { key: "flamingo", defaultUrl: "https://www.flamingo.run", envVar: "NEXT_PUBLIC_FLAMINGO_URL" },
116
- { key: "tmcg", defaultUrl: "https://www.tmcg.miami", envVar: "NEXT_PUBLIC_TMCG_URL" },
117
- { key: "mlg", defaultUrl: "https://www.mlg.soccer", envVar: "NEXT_PUBLIC_MLG_URL" },
118
- {
119
- key: "flamingo-teaser",
120
- defaultUrl: "https://www.flamingo.run",
121
- envVar: "NEXT_PUBLIC_FLAMINGO_URL",
122
- aliasHostnames: ["flamingo.cx", "www.flamingo.cx"]
123
- },
124
- {
125
- key: "openframe",
126
- defaultUrl: "https://openframe.ai",
127
- envVar: "NEXT_PUBLIC_OPENFRAME_URL",
128
- aliasHostnames: ["openframe.ai", "www.openframe.ai", "hub.openframe.ai"]
129
- },
130
- {
131
- key: "openframe-dashboard",
132
- defaultUrl: "https://openframe.ai",
133
- envVar: "NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL",
134
- pseudo: true
135
- },
136
- { key: "universal", defaultUrl: "https://www.flamingo.run", envVar: "NEXT_PUBLIC_FLAMINGO_URL" }
137
- ];
138
- var ENV_OVERRIDES = {
139
- NEXT_PUBLIC_MARKETING_HUB_URL: process.env.NEXT_PUBLIC_MARKETING_HUB_URL,
140
- NEXT_PUBLIC_COMPANY_HUB_URL: process.env.NEXT_PUBLIC_COMPANY_HUB_URL,
141
- NEXT_PUBLIC_PRODUCT_HUB_URL: process.env.NEXT_PUBLIC_PRODUCT_HUB_URL,
142
- NEXT_PUBLIC_REVENUE_HUB_URL: process.env.NEXT_PUBLIC_REVENUE_HUB_URL,
143
- NEXT_PUBLIC_PEOPLE_HUB_URL: process.env.NEXT_PUBLIC_PEOPLE_HUB_URL,
144
- NEXT_PUBLIC_OPENMSP_URL: process.env.NEXT_PUBLIC_OPENMSP_URL,
145
- NEXT_PUBLIC_FLAMINGO_URL: process.env.NEXT_PUBLIC_FLAMINGO_URL,
146
- NEXT_PUBLIC_TMCG_URL: process.env.NEXT_PUBLIC_TMCG_URL,
147
- NEXT_PUBLIC_MLG_URL: process.env.NEXT_PUBLIC_MLG_URL,
148
- NEXT_PUBLIC_OPENFRAME_URL: process.env.NEXT_PUBLIC_OPENFRAME_URL,
149
- NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL: process.env.NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL
150
- };
151
- function byKey(key) {
152
- return PLATFORM_DOMAINS.find((e) => e.key === key);
153
- }
154
- function envOverrideFor(key) {
155
- const envVar = byKey(key)?.envVar;
156
- if (!envVar) return null;
157
- return ENV_OVERRIDES[envVar] || null;
158
- }
159
- function ensureScheme(url) {
160
- const trimmed = url.trim();
161
- if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) return trimmed;
162
- return `https://${trimmed.replace(/^\/+/, "")}`;
163
- }
164
- function getPlatformProductionUrl(platform) {
165
- const resolved = envOverrideFor(platform) ?? byKey(platform)?.defaultUrl ?? envOverrideFor("flamingo") ?? "https://www.flamingo.run";
166
- return ensureScheme(resolved);
167
- }
168
- function hostOf(value) {
169
- if (!value) return null;
170
- try {
171
- return new URL(value).hostname.toLowerCase();
172
- } catch {
173
- return null;
174
- }
175
- }
176
- function expandWwwApex(host) {
177
- if (host.startsWith("www.")) return [host, host.slice(4)];
178
- if (host.split(".").length === 2) return [host, `www.${host}`];
179
- return [host];
180
- }
181
- function aliasHostsOf(key) {
182
- return byKey(key)?.aliasHostnames ?? [];
183
- }
184
- function hostsForEntry(entry, opts) {
185
- const resolved = hostOf(getPlatformProductionUrl(entry.key));
186
- const hosts = resolved ? expandWwwApex(resolved) : [];
187
- hosts.push(...aliasHostsOf(entry.key));
188
- return hosts;
189
- }
190
- function getPlatformByHostname(hostname) {
191
- const host = hostname.toLowerCase();
192
- for (const entry of PLATFORM_DOMAINS) {
193
- if (entry.pseudo) continue;
194
- if (hostsForEntry(entry).includes(host)) return entry.key;
195
- }
196
- return null;
197
- }
198
- var _orderIdx = (k) => PLATFORM_DOMAINS.findIndex((e) => e.key === k);
199
- if (_orderIdx("flamingo") > _orderIdx("flamingo-teaser") || _orderIdx("flamingo") > _orderIdx("universal") || getPlatformByHostname("flamingo.cx") !== "flamingo-teaser" || getPlatformByHostname("hub.openframe.ai") !== "openframe") {
200
- console.error(
201
- "[platform-domains] \u26A0\uFE0F PLATFORM_DOMAINS ordering invariant violated \u2014 `flamingo` must precede `flamingo-teaser`/`universal`, and the openframe/teaser aliases must be intact. Do not reorder the table."
202
- );
203
- }
204
-
205
- // src/utils/cn.ts
206
102
  tailwindMerge.extendTailwindMerge({
207
103
  extend: {
208
104
  classGroups: {