import { type Settings } from "@opengeni/config"; import { type McpServerConnectionRef } from "@opengeni/contracts"; import { type DnsLookup, type FetchLike } from "@opengeni/network"; import { type Database } from "./database.js"; import { type OrganizationIdentityIssuerKey } from "./mcp-auto-connect.js"; /** The organization's issuer URL: what an app is told to trust. */ export declare function organizationIdentityIssuerUrl(publicBaseUrl: string, accountId: string): string; /** The issuer's public key set URL. */ export declare function organizationIdentityJwksUrl(publicBaseUrl: string, accountId: string): string; /** A new RS256 signing key, its private half encrypted under the environments key. */ export declare function generateOrganizationIdentityKey(settings: Settings): Pick; export declare class AutoConnectUnavailableError extends Error { readonly name = "AutoConnectUnavailableError"; } export type IdJagRequest = { accountId: string; subjectId: string; /** The app's authorization server issuer. */ audience: string; /** Opengeni's client ID at that authorization server. */ clientId: string; resource: string | null; scopes: readonly string[]; }; /** * Signs an ID-JAG for one member. The person is named by their Opengeni * subject and their verified email, which is how most apps match accounts. */ export declare function mintOrganizationIdJag(db: Database, settings: Settings, request: IdJagRequest, now?: Date): Promise; export type IdJagTokenResponse = { accessToken: string; tokenType: string; expiresAt: Date; scope: string | null; }; /** The app refused the ID-JAG. `message` is plain words for the admin. */ export declare class IdJagExchangeError extends Error { readonly httpStatus: number; readonly oauthErrorCode: string | null; readonly name = "IdJagExchangeError"; constructor(httpStatus: number, oauthErrorCode: string | null, message: string); } export type IdJagTransportOptions = { fetchImpl?: FetchLike; dnsLookup?: DnsLookup; /** Tests only: answers for any host, without the public-address pinning. */ testFetch?: typeof fetch; }; /** Redeems an ID-JAG at the app's token endpoint (RFC 7523 JWT bearer grant). */ export declare function exchangeIdJag(settings: Settings, input: { tokenEndpoint: string; assertion: string; clientId: string; resource: string | null; scopes: readonly string[]; }, transport?: IdJagTransportOptions): Promise; /** What the stored credential of an auto-connected login holds besides its token. */ export type IdJagCredentialBinding = { grant: "id_jag"; /** The organization connector it was made through; renewal checks it is still there. */ connector_id: string; token_endpoint: string; client_id: string; audience: string; resource?: string; mcp_url?: string; scopes?: string[]; }; /** An auto-connected login's credential bundle. No refresh token, by design. */ export declare function idJagCredentialBundle(binding: Omit, token: IdJagTokenResponse): Record; export declare function isIdJagCredential(credential: Record): boolean; /** * "Refreshes" an auto-connected login: signs a new ID-JAG for its owner and * redeems it. Called by the connection token resolver in place of a refresh * token grant. */ export declare function refreshIdJagConnectionCredential(db: Database, settings: Settings, cred: { accountId: string; workspaceId: string; subjectId: string | null; credential: Record; }, ref: Pick, transport?: IdJagTransportOptions): Promise<{ credential: Record; expiresAt: Date; grantedScopes?: string[]; }>; /** Plain words for why an app refused, never its own response text. */ export declare function idJagRefusalMessage(httpStatus: number, code: string | null): string;