Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | import { CornerDownLeft } from 'lucide-react'; |
| 2 | |
| 3 | const NODES: { |
| 4 | label: string; |
| 5 | sub: string; |
| 6 | edge?: string; |
| 7 | accent?: boolean; |
| 8 | }[] = [ |
| 9 | { label: 'Your app', sub: 'user starts here' }, |
| 10 | { |
| 11 | label: 'OAuth toolkit', |
| 12 | sub: 'Google, GitHub, …', |
| 13 | edge: 'user connects', |
| 14 | }, |
| 15 | { |
| 16 | label: 'yourdomain.com', |
| 17 | sub: 'receives code and state', |
| 18 | edge: 'redirects user', |
| 19 | accent: true, |
| 20 | }, |
| 21 | { |
| 22 | label: 'backend.composio.dev', |
| 23 | sub: 'exchanges code for tokens', |
| 24 | edge: 'browser follows 302', |
| 25 | }, |
| 26 | ]; |
| 27 | |
| 28 | /** |
| 29 | * Browser hops for a GET-query OAuth2 callback forwarded through your domain. |
| 30 | * Your endpoint receives the authorization code and state, then redirects the |
| 31 | * browser to Composio for token exchange. It must not log the callback query. |
| 32 | */ |
| 33 | export function WhiteLabelFlow() { |
| 34 | return ( |
| 35 | <div className="not-prose my-6 overflow-hidden rounded-sm border border-fd-border bg-fd-background"> |
| 36 | {/* header strip */} |
| 37 | <div className="flex items-center justify-between border-b border-fd-border px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.06em] text-fd-foreground/45"> |
| 38 | <span>oauth.redirect</span> |
| 39 | <span className="text-fd-foreground/55">browser hops only</span> |
| 40 | </div> |
| 41 | |
| 42 | {/* the hops */} |
| 43 | <div className="grid items-stretch gap-px bg-fd-border md:grid-cols-4"> |
| 44 | {NODES.map((node, i) => { |
| 45 | const last = i === NODES.length - 1; |
| 46 | return ( |
| 47 | <div |
| 48 | key={node.label} |
| 49 | className="relative flex flex-col gap-2 bg-fd-background p-3" |
| 50 | > |
| 51 | {/* edge label sits above the node it points into */} |
| 52 | <span className="font-mono text-[9px] uppercase tracking-[0.06em] text-fd-foreground/40"> |
| 53 | {node.edge ? `→ ${node.edge}` : ' '} |
| 54 | </span> |
| 55 | <div className="flex flex-1 items-center"> |
| 56 | <div |
| 57 | className={ |
| 58 | 'relative w-full border p-3 ' + |
| 59 | (node.accent |
| 60 | ? 'border-[var(--composio-brand)]/30 bg-[var(--composio-brand)]/[0.04]' |
| 61 | : 'border-fd-border bg-fd-card') |
| 62 | } |
| 63 | > |
| 64 | {node.accent && ( |
| 65 | <span |
| 66 | aria-hidden="true" |
| 67 | className="pointer-events-none absolute inset-y-0 left-0 w-[2px] bg-[var(--composio-brand)]" |
| 68 | /> |
| 69 | )} |
| 70 | <code |
| 71 | className={ |
| 72 | 'block truncate font-mono text-[12px] font-medium ' + |
| 73 | (node.accent |
| 74 | ? 'text-[var(--composio-brand)]' |
| 75 | : 'text-fd-foreground') |
| 76 | } |
| 77 | > |
| 78 | {node.label} |
| 79 | </code> |
| 80 | <span className="mt-1 block truncate font-mono text-[10px] text-fd-foreground/45"> |
| 81 | {node.sub} |
| 82 | </span> |
| 83 | </div> |
| 84 | </div> |
| 85 | {!last && <Connector />} |
| 86 | </div> |
| 87 | ); |
| 88 | })} |
| 89 | </div> |
| 90 | |
| 91 | {/* the return hop */} |
| 92 | <div className="flex items-center justify-center gap-1.5 border-t border-fd-border px-3 py-2 font-mono text-[10px] text-fd-foreground/50"> |
| 93 | <CornerDownLeft |
| 94 | aria-hidden="true" |
| 95 | className="size-3 text-[var(--composio-brand)]" |
| 96 | /> |
| 97 | The browser still visits Composio before returning to{' '} |
| 98 | <code className="text-fd-foreground/70">your app</code>. Your endpoint |
| 99 | receives code and state; do not log them. |
| 100 | </div> |
| 101 | </div> |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | function Connector() { |
| 106 | return ( |
| 107 | <div |
| 108 | aria-hidden="true" |
| 109 | className="pointer-events-none absolute z-10 hidden md:block" |
| 110 | style={{ right: '-7px', top: '50%' }} |
| 111 | > |
| 112 | <div className="flex items-center"> |
| 113 | <span className="h-px w-3 bg-fd-border" /> |
| 114 | <span className="size-0 border-y-[3px] border-l-[5px] border-y-transparent border-l-fd-border" /> |
| 115 | </div> |
| 116 | </div> |
| 117 | ); |
| 118 | } |