export interface NylasProps { /** * URL of the backend server configured with the Nylas middleware or Nylas routes implemented. */ serverBaseUrl: string; } export interface AuthUrlOptions { /** * URL to redirect to upon successful authentication */ successRedirectUrl: string; /** * Email address of the account to authenticate */ emailAddress?: string; /** * URL to override the endpoint for building the authentication URL */ buildAuthUrlEndpoint?: string; } export interface ExchangeCodeOptions { /** * URL to override the endpoint for exchanging the code for the access token */ exchangeCodeForTokenEndpoint?: string; } export default class Nylas { /** * URL of the backend server configured with the Nylas middleware or Nylas routes implemented. */ serverBaseUrl: string; constructor(props: NylasProps); /** * Builds the URL for authenticating users to your application via Hosted Authentication * @param opts Configuration for building the URL * @return URL for authentication * @throws If the HTTP response code is non 2xx * @throws If the server doesn't respond with a URL */ buildAuthUrl: (opts: AuthUrlOptions) => Promise; /** * Builds and redirects to the URL for authenticating users to your application via Hosted Authentication * @param opts Configuration for building the URL * @throws If window is not defined * @throws If the HTTP response code is non 2xx * @throws If the server doesn't respond with a URL */ authWithRedirect: (opts: AuthUrlOptions) => Promise; /** * Exchange the Nylas authorization code for a Nylas access token * @param authorizationCode Nylas authorization code * @param opts Configuration for the token exchange * @throws If no authorization code was provided * @throws If the HTTP response code is non 2xx * @throws If the server doesn't respond with an access token */ exchangeCodeForToken: (authorizationCode: string, opts?: ExchangeCodeOptions) => Promise; /** * Parses the URL for the Nylas authorization code for a Nylas access token * @param opts Configuration for the token exchange * @throws If window is not defined * @throws If no authorization code was provided * @throws If the HTTP response code is non 2xx * @throws If the server doesn't respond with an access token */ exchangeCodeFromUrlForToken: (opts?: ExchangeCodeOptions) => Promise; }