import { Auth } from "@langchain/langgraph-sdk/auth"; import { type IdentityConfig, type IdentityDefinition, type RuntimeIdentity } from "../identity/index.js"; /** * Reserved transport for the trusted-backend ingress mode. User identity * travels as reserved headers (mapped into `config.configurable` by the generated * `langgraph.json` allowlist); the ingress secret is validated here and is * deliberately **not** allowlisted, so it never reaches `config.configurable`. */ /** Trusted-backend / channel-loopback identity headers (single source of truth). */ export declare const USER_HEADER = "x-mda-user-id"; export declare const INGRESS_SECRET_HEADER = "x-mda-ingress-secret"; /** * Internal channel handoff headers. Accepted only after a server API key or * legacy ingress secret validates — never part of the public HTTP identity * surface, and deliberately not allowlisted into `config.configurable`. */ export declare const SOURCE_PROVIDER_HEADER = "x-mda-source-provider"; export declare const SOURCE_THREAD_HEADER = "x-mda-source-thread-id"; /** Deployment env var carrying the shared secret the trusted backend presents. */ export declare const INGRESS_SECRET_ENV = "MDA_INGRESS_SECRET"; /** Deploy/dev-owned credential used only for internal identity handoffs. */ export declare const HANDOFF_SECRET_ENV = "MDA_HANDOFF_SECRET"; export declare const HANDOFF_SECRET_HEADER = "x-mda-handoff-secret"; /** Platform-owned LangSmith auth configuration. */ export declare const LANGSMITH_AUTH_ENDPOINT_ENV = "LANGSMITH_AUTH_ENDPOINT"; export declare const LANGSMITH_TENANT_ID_ENV = "LANGSMITH_TENANT_ID"; export declare const LANGSMITH_API_KEY_HEADER = "x-api-key"; export declare const LANGSMITH_API_KEY_ENV = "LANGSMITH_API_KEY"; export declare const LANGCHAIN_API_KEY_ENV = "LANGCHAIN_API_KEY"; /** Internal Trigger-channel principal used to start and observe Agent runs. */ export declare const CHANNEL_SERVICE_USER = "mda:channel"; /** * The user object `@auth.authenticate` returns. `identity`/`permissions` satisfy * the LangGraph base shape; the `mda_*` fields carry the identity envelope into * `config.configurable.langgraph_auth_user` for the runtime seam. */ export interface ManagedUser { identity: string; permissions: string[]; mda_user_id: string; mda_user_email?: string; /** Resolved group memberships; read-only, never an isolation key. */ mda_groups?: string[]; mda_claims?: Record; /** Trusted source provider stamped by managed ingress (never client-supplied). */ mda_source_provider?: string; /** Trusted source thread key stamped by managed channel ingress. */ mda_source_thread_id?: string; [key: string]: unknown; } /** * Build the managed LangGraph custom-auth handler from a declared identity. * * Handles trusted-backend, LangSmith API-key, and validated-token ingress. * Also registers thread and store scoping with a studio bypass. */ export declare function buildManagedAuth(identity: IdentityDefinition): Auth; /** * Resolve the caller's frozen {@link RuntimeIdentity} from a raw HTTP request, * using the same ingress logic (`trusted_backend` headers / `validated_token` * verification) as the managed auth handler. Throws an {@link HTTPException} * (401) when the caller is unauthenticated or unresolvable. * * This is the resolver that backs default-secure connector HTTP routes: a * connector route runs behind identity by default, and this is what enforces it. */ export declare function resolveRequestIdentity(cfg: IdentityConfig, request: Request): Promise; /** LangGraph Store namespace prefix for Slack ↔ user account links. */ export declare const IDENTITY_LINKS_STORE_PREFIX = "mda_identity_links"; /** * LangGraph Store namespace prefix for legacy Connect-with-X GitHub OAuth tokens. * * The Connect flow no longer writes here, but existing deployments may still * hold tokens under this prefix. Keep it reserved (service principal only) * until contents are explicitly scrubbed — do not reopen it to ordinary Store * API callers. */ export declare const GITHUB_CREDENTIALS_STORE_PREFIX = "mda_github_credentials"; /** * Trusted service principal for {@link IDENTITY_LINKS_STORE_PREFIX} Store ops. * Stamped by the managed link client together with the ingress secret. */ export declare const IDENTITY_LINKS_SERVICE_USER = "mda:identity-links"; /** * Fail-closed (403) on the managed reserved namespaces. * * `mda_identity_links` and `mda_github_credentials` are deployment-wide managed * tables — account links and (legacy) OAuth tokens for every caller — so only * the trusted identity-links service principal may touch them. This check * deliberately does not consult memory: it used to sit behind a per-caller * memory check, which left the tables open to any authenticated caller on * deployments without a user slice. * * There is no per-caller store partition to enforce beyond that, because no * declaration mounts per-caller state in this release. */ export declare function assertStoreAccess(user: ManagedUser, value: unknown): void; /** * Resolve the caller identity for `trusted_backend`: validate the shared ingress * secret, then trust the reserved user headers. Fail-closed (401) on a * missing/invalid secret or a missing user. * * Under `mda dev` (`MDA_LOCAL_DEV=1`), requests without a valid ingress secret * resolve to a synthetic local service principal so LangGraph Studio can talk * to the agent without custom headers. Deploy never sets that env var. * * Optional source-provider / source-thread headers are accepted only after the * ingress secret validates. They exist for the managed channel runner's * loopback handoff — ordinary clients without the secret cannot stamp them. */ export declare function resolveTrustedBackendUser(cfg: IdentityConfig, request: Request): ManagedUser; /** Verify a LangSmith API key without replacing MDA's authorization hooks. */ export declare function resolveLangSmithApiKeyUser(request: Request): Promise; /** * Under `mda dev`, synthetic local/Companion service principals are unscoped * for thread search + store so authors can see Studio-created Local threads. * Deploy never sets `MDA_LOCAL_DEV`, so this stays local-only. */ export declare function isLocalDevUnscopedUser(user: unknown): boolean; /** * When `MDA_LOCAL_DEV=1` and the request does not present a valid ingress * secret, return a synthetic service principal for Studio / local API use. * Returns `null` when local-dev mode is off or real ingress credentials are * present (so the normal trusted-backend path runs). */ export declare function tryLocalDevTrustedUser(_cfg: IdentityConfig, request: Request): ManagedUser | null; /** Derive the owner value `@auth.on.threads` filters on (the caller user id). */ export declare function threadOwnerKey(user: ManagedUser): string; /** True when the request targets a public channel/connector Events ingress route. */ export declare function isChannelEventsRequest(request: Request): boolean; /** Placeholder identity so middleware allows provider-signed channel Events. */ export declare function channelEventsBypassUser(): ManagedUser; //# sourceMappingURL=auth.d.ts.map