/** * OAuth 2.0 for installed applications, one Google Cloud project, N accounts. * * Uses the loopback redirect flow (RFC 8252): a throwaway HTTP server on an * ephemeral port receives the authorization code. Google allows any loopback * port for "Desktop app" clients, so nothing has to be pre-registered beyond * the client itself — which is what makes "one project, N accounts" practical. * * ⚠️ The OAuth client comes from `@googleapis/gmail`, NOT from a direct * `google-auth-library` dependency. `googleapis-common` bundles its own nested * copy, so a client built from the top-level package is a structurally * different class and `gmail({ auth })` rejects it. Taking the class from the * same package it will be handed to removes the duplication instead of casting * around it. */ import { auth } from '@googleapis/gmail'; import type { AccountId, OAuthCredentials, StoredTokens } from '../gmail/types.js'; /** The exact OAuth2 client class `@googleapis/gmail` expects. */ export type GoogleOAuthClient = InstanceType; /** * Gmail: read, drafts, send and labels. `gmail.modify` is everything except * permanent deletion — which this server deliberately cannot do. */ export declare const GMAIL_SCOPES: readonly ['https://www.googleapis.com/auth/gmail.modify']; /** * Drive: full access to the user's files. * * ⚠️ This is a RESTRICTED scope, the same tier Google applies to `gmail.modify`. * `drive.file` — access limited to files this app created or the user explicitly * picked — is not restricted and would keep verification simpler, but it cannot * see files the user already has, so `drive_search` over an existing Drive would * return nothing. Full `drive` is the deliberate choice; see the README. */ export declare const DRIVE_SCOPES: readonly ['https://www.googleapis.com/auth/drive']; /** Calendar: read and write events, and free/busy queries. */ export declare const CALENDAR_SCOPES: readonly ['https://www.googleapis.com/auth/calendar']; /** * Contacts, through the People API: read and write the user own contacts. * * Not `contacts.readonly`, because `contacts_create` and `contacts_update` write. * This does NOT cover "other contacts" — the addresses Google auto-collects from * mail — which live behind a separate scope and a separate endpoint. */ export declare const CONTACTS_SCOPES: readonly ['https://www.googleapis.com/auth/contacts']; /** Everything requested at consent time, in one list. */ export declare const SCOPES: readonly ["https://www.googleapis.com/auth/gmail.modify", "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/contacts"]; /** The space-separated `scope` string Google returns, as a set. */ export declare function grantedScopes(scope: string | null | undefined): Set; /** * Which of the scopes this build needs are absent from a stored token. * * ⚠️ A refresh will NOT fix these. A refresh token is bound to the scope set * granted when it was issued, so an account authorised before Drive and * Calendar existed here needs a full re-consent — which is why the flow always * passes `prompt: 'consent'`. */ export declare function missingScopes(scope: string | null | undefined): string[]; /** * Credentials come from the environment first and `config.json` second. * * Environment wins so a deployment can inject them without rewriting a file in * the user's home directory. */ export declare function loadCredentials(redirectUri?: string): Promise; export interface AuthorizationResult { email: AccountId; tokens: StoredTokens; } /** * Runs the interactive consent flow and returns the account's tokens. * * `onUrl` receives the authorization URL so the caller decides how to surface * it — this module never prints anything itself, because the MCP server shares * stdout with the protocol. */ export declare function runAuthorizationFlow(onUrl: (url: string) => void | Promise): Promise; /** * Builds an authenticated client for a configured account. * * Refresh is automatic: `google-auth-library` renews the access token when it * has expired, and the `tokens` listener writes the new one back to disk so the * next process start does not have to refresh again. */ export declare function getAuthenticatedClient(email: AccountId): Promise; //# sourceMappingURL=oauth.d.ts.map