Skip to content

Split apps Core around authenticated transports#609

Draft
heyitsaamir wants to merge 2 commits into
mainfrom
core-transport-auth-boundary-on-main
Draft

Split apps Core around authenticated transports#609
heyitsaamir wants to merge 2 commits into
mainfrom
core-transport-auth-boundary-on-main

Conversation

@heyitsaamir

@heyitsaamir heyitsaamir commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

One liner: add an internal Core runtime for apps and move auth-aware transport setup behind it.

Stacking note: this is stacked on the BotBuilder HTTP adapter PR. That lower PR removes the BotBuilder plugin/server-DI pressure so this Core split can stay focused on App/Core responsibilities.

Why: App was doing runtime setup, token wiring, server setup, and typed client construction all in one place. This splits the boring plumbing out so App can stay focused on Teams behavior like activities, OAuth, ApiClient, and GraphClient.

Core's job, in principle:

  • Inbound transport: own the HTTP entrypoint for incoming Teams activities.
  • Inbound auth: validate incoming activity requests before App handles them.
  • App dispatch: call the App-provided activity handler once the inbound request is valid.
  • Outbound transport: provide HttpClient instances for outbound calls.
  • Outbound auth: attach the right bot/app Graph auth behavior to those outbound clients.
  • Host lifecycle: initialize/start/stop the local server when this runtime owns one.

App's job stays:

  • Own Teams semantics: activities, send/reply, OAuth, routing, tabs/functions, plugins, storage, events, and manifest behavior.
  • Own typed protocol clients: construct ApiClient and GraphClient using Core-provided transports.
  • Own user delegated auth/user Graph for now.
flowchart LR
  Teams[Teams/Bot Framework] -->|incoming HTTP activity| Core

  subgraph Core[Core: runtime + auth]
    Inbound[Inbound HTTP transport]
    InboundAuth[Inbound auth validation]
    Dispatch[Dispatch to App handler]
    Outbound[Authenticated HttpClient factory]
    Token[TokenManager / authorize hook]
    Inbound --> InboundAuth --> Dispatch
    Token --> Outbound
  end

  subgraph App[App: Teams semantics]
    Handler[Activity processing/routing]
    Sender[Send/reply/stream]
    OAuth[OAuth + user token flow]
    TypedClients[ApiClient / GraphClient construction]
  end

  Dispatch --> Handler
  Handler --> Sender
  Handler --> OAuth
  Handler --> TypedClients
  Sender --> TypedClients
  TypedClients -->|bot/app Graph transport| Outbound
  Outbound -->|outbound HTTP calls| Teams
  Outbound -->|outbound Graph calls| Graph[Microsoft Graph]
Loading

Interesting bits:

  • Activity sending now gets a serviceUrl-bound ApiClient from App instead of building from a shared raw HTTP client.
  • Core provides authenticated HttpClient instances; App keeps typed client construction.
  • Added an authorize hook for custom outbound bot/app Graph token resolution. The older token factory remains, but cannot be combined with authorize.

Reviewer tips:

  • Start with packages/apps/src/core/core.ts, then packages/apps/src/app.ts.
  • The key thing to check is whether the Core/App boundary feels right.

Testing:

  • npm run build --workspace @microsoft/teams.apps
  • npm run build --workspace @microsoft/teams.botbuilder

@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch from 8432a6c to 93a3924 Compare June 7, 2026 14:32
@heyitsaamir heyitsaamir changed the base branch from main to botbuilder-http-server-adapter June 7, 2026 14:32
@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch from 93a3924 to 2f46656 Compare June 7, 2026 18:33
@heyitsaamir heyitsaamir force-pushed the botbuilder-http-server-adapter branch 2 times, most recently from 55eb7de to c7f35c2 Compare June 7, 2026 21:35
@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch 3 times, most recently from bf68e5a to 84cbefd Compare June 7, 2026 22:35
@heyitsaamir heyitsaamir force-pushed the botbuilder-http-server-adapter branch from fadde96 to 66b1606 Compare June 7, 2026 22:35
@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch 2 times, most recently from 5d80aa7 to 60a64c9 Compare June 8, 2026 03:30
@heyitsaamir heyitsaamir force-pushed the botbuilder-http-server-adapter branch from 66b1606 to ffe8923 Compare June 8, 2026 03:30
@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch from 60a64c9 to fd82379 Compare June 8, 2026 05:03
@heyitsaamir heyitsaamir force-pushed the botbuilder-http-server-adapter branch 2 times, most recently from c66232a to 69bc187 Compare June 8, 2026 05:06
@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch 4 times, most recently from 3825046 to c13f455 Compare June 8, 2026 23:13
@heyitsaamir heyitsaamir force-pushed the core-transport-auth-boundary-on-main branch from c13f455 to 727f558 Compare June 8, 2026 23:17
@heyitsaamir heyitsaamir force-pushed the botbuilder-http-server-adapter branch from 69bc187 to 92f1340 Compare June 8, 2026 23:17
Base automatically changed from botbuilder-http-server-adapter to main June 15, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant