UNPKG

nylas

Version:

A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.

84 lines (83 loc) 3.52 kB
import { Resource } from './resource.js'; import { URLForAdminConsentConfig, URLForAuthenticationConfig, CodeExchangeRequest, PKCEAuthURL, TokenExchangeRequest, CodeExchangeResponse, ProviderDetectParams, ProviderDetectResponse, TokenInfoResponse } from '../models/auth.js'; import { Overrides } from '../config.js'; import { NylasResponse } from '../models/response.js'; import { CreateGrantRequest, Grant } from '../models/grants.js'; /** * @property requestBody The values to create the Grant with. */ interface CreateGrantParams { requestBody: CreateGrantRequest; } /** * A collection of authentication related API endpoints * * These endpoints allow for various functionality related to authentication. * Also contains the Grants API and collection of provider API endpoints. */ export declare class Auth extends Resource { /** * Build the URL for authenticating users to your application with OAuth 2.0 * @param config The configuration for building the URL * @return The URL for hosted authentication */ urlForOAuth2(config: URLForAuthenticationConfig): string; /** * Exchange an authorization code for an access token * @param request The request parameters for the code exchange * @return Information about the Nylas application */ exchangeCodeForToken(request: CodeExchangeRequest): Promise<CodeExchangeResponse>; /** * Refresh an access token * @param request The refresh token request * @return The response containing the new access token */ refreshAccessToken(request: TokenExchangeRequest): Promise<CodeExchangeResponse>; /** * Build the URL for authenticating users to your application with OAuth 2.0 and PKCE * IMPORTANT: YOU WILL NEED TO STORE THE 'secret' returned to use it inside the CodeExchange flow * @param config The configuration for building the URL * @return The URL for hosted authentication */ urlForOAuth2PKCE(config: URLForAuthenticationConfig): PKCEAuthURL; /** * Build the URL for admin consent authentication for Microsoft * @param config The configuration for building the URL * @return The URL for admin consent authentication */ urlForAdminConsent(config: URLForAdminConsentConfig): string; /** * Create a grant via Custom Authentication * @return The created grant */ customAuthentication({ requestBody, overrides, }: CreateGrantParams & Overrides): Promise<NylasResponse<Grant>>; /** * Revoke a token (and the grant attached to the token) * @param token The token to revoke * @return True if the token was revoked successfully */ revoke(token: string): Promise<boolean>; /** * Detect provider from email address * @param params The parameters to include in the request * @return The detected provider, if found */ detectProvider(params: ProviderDetectParams): Promise<NylasResponse<ProviderDetectResponse>>; /** * Get info about an ID token * @param idToken The ID token to query. * @return The token information */ idTokenInfo(idToken: string): Promise<NylasResponse<TokenInfoResponse>>; /** * Get info about an access token * @param accessToken The access token to query. * @return The token information */ accessTokenInfo(accessToken: string): Promise<NylasResponse<TokenInfoResponse>>; private urlAuthBuilder; private hashPKCESecret; private getTokenInfo; } export {};