import { type AccountRef, type AuthAccount, type AuthProvider, type CredentialStore, type KeyringTokenStore } from '@doist/cli-core/auth'; import { type AuthMode } from './config.js'; export declare const READ_ONLY_SCOPES: string[]; export declare const READ_WRITE_SCOPES: string[]; export declare const FULL_ACCESS_SCOPES: string[]; /** * Single source of truth shared by `attachCommsLoginCommand`'s `resolveScopes` * (what we request at authorize) and the provider's token-response fallback * (what we record on the account), so the two can't drift. */ export declare function getScopes({ readOnly, fullAccess, }: { readOnly: boolean; fullAccess?: boolean; }): string[]; /** * Narrow account shape: only fields that round-trip through the local token * store. `id` is the stringified numeric Comms user id (so cli-core's * `AuthAccount.id` string contract holds), `label` is the user's display * name. Richer session-user details are fetched on demand via the API * rather than threaded through the auth flow. */ export type CommsAccount = AuthAccount & { id: string; label: string; authMode: AuthMode; authScope: string; oauthClientId?: string; authBaseUrl?: string; authResource?: string; }; export type CommsTokenStore = KeyringTokenStore; export type CommsCredentialStore = CredentialStore; export declare const CREDENTIAL_STORES: readonly ["fallback", "system", "plaintext"]; export declare function parseCredentialStore(value: string): CommsCredentialStore; /** * Sentinel for the `{ id: '', label: '' }` snapshot that `tdc auth token` * persists when the user passes a raw token with no identity attached. The * empty-id/empty-label pair is the contract between `loginWithToken` (writer) * and `account current` / `account list` (readers); centralise it here so * each call site agrees on the shape. */ export declare const MANUAL_TOKEN_ACCOUNT: CommsAccount; /** True when `account` is the identity-less snapshot produced by `tdc auth token`. */ export declare function isManualTokenAccount(account: Pick): boolean; export type CommsOAuthConfig = { authBaseUrl: string; authorizationUrl: string; tokenUrl: string; resource: string; }; /** * Todoist is the OAuth authorization server; Comms is the protected resource. * The CLI signs in as a public client (PKCE, no client secret) identified by * its client ID metadata document (`OAUTH_CLIENT_ID`), so there is no * registration step, and pins tokens to the Comms resource via the RFC 8707 * `resource` indicator. The authorize / token-exchange / refresh mechanics * live in cli-core's `createPkceProvider`; the Comms-specific behaviour is: * * - endpoint + resource resolution from `COMMS_BASE_URL` / `COMMS_AS_URL` * (see `getCommsOAuthResource` / `getTodoistAuthBaseUrl`), * - choosing the `client_id` (see `resolveClientId`), * - recording the server-granted scope on the account (the `exchangeCode` * wrapper stashes it on the handshake for `validate`; `refreshToken` * refreshes it), and * - `validate`: probe `getSessionUser`, derive `authMode` from the granted * scope, and build the `CommsAccount`. */ export declare function createCommsAuthProvider(fetchImpl?: typeof fetch): AuthProvider; /** * The handshake `refreshAccessToken` forwards to the provider's * `refreshToken`. cli-core doesn't persist the login handshake, so we * reconstruct it from the stored account: `clientId` (the client the token was * issued to, read by `resolveClientId`), the resource / auth base URL (read by * the endpoint resolvers), and the identity fields (read by * `buildRefreshAccount`). */ export declare function getCommsOAuthRefreshHandshake(account: CommsAccount): Record; /** * Accepts `42`, `id:42`, and case-insensitive labels — `parseRef` normalises * the numeric forms. Broader than cli-core's default strict-equality matcher. */ export declare function matchCommsAccount(account: CommsAccount, ref: AccountRef): boolean; /** * Resolve a `ref` against the local store, returning the canonical account. * Throws `ACCOUNT_NOT_FOUND` on a miss. Shared between the `tdc account ...` * commands and `withUserRefAware` so the same hint reaches every caller. */ export declare function findAccountInStore(store: CommsTokenStore, ref: AccountRef): Promise; /** * `COMMS_API_TOKEN` short-circuits `active()` only when no explicit ref is * supplied — cli-core's `KeyringTokenStore` doesn't know about the env var, * and an explicit ref means the caller targets a specific stored account. */ export declare function createCommsTokenStore(options?: { credentialStore?: CommsCredentialStore | (() => CommsCredentialStore); }): CommsTokenStore; /** * Where the currently-active token lives. Returns `'config-file'` whenever * a plaintext token is on disk so doctor/config-view reports the * security-relevant state accurately. */ export declare function getActiveTokenSource(): Promise<'env' | 'secure-store' | 'config-file'>; //# sourceMappingURL=auth-provider.d.ts.map