UNPKG

nylas

Version:

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

187 lines (186 loc) 4.86 kB
import { Provider } from './auth.js'; /** * Interface representing a Nylas Grant object. */ export interface Grant { /** * Globally unique object identifier. */ id: string; /** * OAuth provider that the user authenticated with. */ provider: string; /** * Scopes specified for the grant. */ scope: string[]; /** * Unix timestamp when the grant was created. */ createdAt: number; /** * Status of the grant, if it is still valid or if the user needs to re-authenticate. */ grantStatus?: string; /** * Email address associated with the grant. */ email?: string; /** * Name associated with the grant. */ name?: string; /** * End user's client user agent. */ userAgent?: string; /** * End user's client IP address. */ ip?: string; /** * Initial state that was sent as part of the OAuth request. */ state?: string; /** * Unix timestamp when the grant was updated. */ updatedAt?: number; /** * Provider's ID for the user this grant is associated with. */ providerUserId?: string; /** * Settings required by the provider that were sent as part of the OAuth request. */ settings?: Record<string, unknown>; /** * The credential ID that was used to create this grant. * This links the grant to a specific set of provider credentials. */ credentialId?: string; } /** * Interface representing a request to create a grant. */ export interface CreateCustomAuthenticationGrantRequest { /** * OAuth provider */ provider: Exclude<Provider, 'nylas'>; /** * Settings required by provider. * Can include 'credentialId' to specify which credential to use for authentication. * If not specified, the connector's default credential will be used. */ settings: Record<string, unknown> & { /** * Optional credential ID to use for this authentication. * Allows selecting a specific set of provider credentials when multiple are configured. */ credentialId?: string; }; /** * Optional state value to return to developer's website after authentication flow is completed. */ state?: string; /** * Optional list of scopes to request. If not specified it will use the integration default scopes. */ scope?: string[]; } /** * Interface representing settings to create a Nylas Agent Account grant. */ export interface CreateAgentAccountSettings { /** * The Agent Account email address. */ email: string; /** * A policy to apply to this grant. */ policyId?: string; /** * Password for IMAP and SMTP-submission access. */ appPassword?: string; } /** * Interface representing a request to create a Nylas Agent Account grant. */ export interface CreateAgentAccountRequest { /** * The Nylas provider provisions an Agent Account. */ provider: 'nylas'; /** * Settings required to provision the Agent Account. */ settings: CreateAgentAccountSettings; /** * Optional state value to return to developer's website after authentication flow is completed. */ state?: string; } export type CreateGrantRequest = CreateCustomAuthenticationGrantRequest | CreateAgentAccountRequest; /** * Interface representing a request to update a grant. */ export interface UpdateGrantRequest { /** * Settings required by provider. */ settings?: Record<string, unknown>; /** * List of integration scopes for the grant. */ scope?: string[]; } /** * Interface representing the query parameters for listing grants. */ export interface ListGrantsQueryParams { /** * The maximum number of objects to return. * This field defaults to 10. The maximum allowed value is 200. */ limit?: number; /** * Offset grant results by this number. */ offset?: number; /** * Sort entries by field name */ sortBy?: 'created_at' | 'updated_at'; /** * Specify ascending or descending order. */ orderBy?: 'asc' | 'desc'; /** * Scope grants from a specific point in time by Unix timestamp. */ since?: number; /** * Scope grants to a specific point in time by Unix timestamp. */ before?: number; /** * Filtering your query based on grant email address (if applicable) */ email?: string; /** * Filtering your query based on grant email status (if applicable) */ grantStatus?: string; /** * Filtering your query based on grant IP address */ ip?: string; /** * Filtering your query based on OAuth provider */ provider?: Provider; }