import type { KeysToCamelCase } from '@silverhand/essentials'; import type { Requester } from '../types/index.js'; export type FetchTokenByAuthorizationCodeParameters = { clientId: string; tokenEndpoint: string; redirectUri: string; codeVerifier: string; code: string; resource?: string; }; export type FetchTokenByRefreshTokenParameters = { /** The client ID of the application. */ clientId: string; /** The token endpoint of the authorization server. */ tokenEndpoint: string; /** The refresh token to be used to fetch the organization access token. */ refreshToken: string; /** The API resource to be fetch the access token for. */ resource?: string; /** The ID of the organization to be fetch the access token for. */ organizationId?: string; /** * The scopes to request for the access token. If not provided, the authorization server * will use all the scopes that the client is authorized for. */ scopes?: string[]; }; type SnakeCaseCodeTokenResponse = { access_token: string; refresh_token?: string; id_token: string; scope: string; expires_in: number; }; export type CodeTokenResponse = KeysToCamelCase; type SnakeCaseRefreshTokenTokenResponse = { access_token: string; refresh_token?: string; id_token?: string; scope: string; expires_in: number; }; export type RefreshTokenTokenResponse = KeysToCamelCase; export declare const fetchTokenByAuthorizationCode: ({ clientId, tokenEndpoint, redirectUri, codeVerifier, code, resource, }: FetchTokenByAuthorizationCodeParameters, requester: Requester) => Promise; /** * Fetch access token by refresh token using the token endpoint and `refresh_token` grant type. * @param params The parameters for fetching access token. * @param requester The requester for sending HTTP request. * @returns A Promise that resolves to the access token response. */ export declare const fetchTokenByRefreshToken: (params: FetchTokenByRefreshTokenParameters, requester: Requester) => Promise; export {};