UNPKG

@integromat/proto

Version:
99 lines 3.83 kB
import { Readable } from 'stream'; import { CommonData, ModuleData } from './base'; import { DoneCallback } from './types'; export type Scope = string[]; export type DoneWithUrlCallback = (err?: Error | null, url?: string) => void; /** * Base class for all Accounts. * * @property common - Collection of common parameters. Read only. * @property data - Collection of config parameters. */ export declare class IMTAccount { common: CommonData | null; data: ModuleData | null; constructor(); /** * Initializes the account. Function that overrides should always call super. * * @callback done Callback to call when account is initialized. * @param {Error} err - Error on error, otherwise null. */ initialize(done: DoneCallback): void; /** * Finalizes the account. Function that overrides should always call super. * * @callback done Callback to call when account is finalized. * @param {Error} err Error on error, otherwise null. */ finalize(done: DoneCallback): void; /** * Test account connection. * * @callback done Callback to call when test is complete. * @param {Error} err Error on error, otherwise null. * @param {Boolean} valid True if account is valid. */ test(done: DoneCallback): void; /** * Test account validity. * * @callback done Callback to call when validation is complete. * @param {Error} err Error on error, otherwise null. * @param {Boolean} changed True if validation made changes in account's data. */ validate(done: DoneCallback): void; } export declare class IMTOAuthAccount extends IMTAccount { private id?; /** * Sets account ID by received data. * * @param {stream.Readdable} req HTTP request stream. * @callback done Callback to call when account was resolved from request. * @param {Error} err Error on error, otherwise null. */ accountFromCallbackRequest(req: Readable, done: DoneCallback): void; /** * Create authorization request and redirect user to OAuth provider. * * @param {Array} scope Array of permission to request. * @callback done Callback to call when authorization request is complete. * @param {Error} err Error on error, otherwise null. * @param {String} url URL to redirect user to. */ authorize(scope: Scope, done: DoneWithUrlCallback): void; /** * Callback from OAuth provider. * * @param {stream.Readdable} req HTTP request stream. * @callback done Callback to call when authorization request is complete. * @param {Error} err Error on error, otherwise null. */ callback(req: Readable, done: DoneCallback): void; /** * Create scope extension request and redirect user to OAuth provider. * * @param {Array} scope Array of permission to request. * @callback done Callback to call when authorization request is complete. * @param {Error} err Error on error, otherwise null. * @param {String} url URL to redirect user to. */ extendScope(scope: Scope, done: DoneWithUrlCallback): void; /** * Create reauthorization request and redirect user to OAuth provider. * * @callback done Callback to call when authorization request is complete. * @param {Error} err Error on error, otherwise null. * @param {String} url URL to redirect user to. */ reauthorize(done: DoneWithUrlCallback): void; /** * Invalidate current access token. * * @callback done Callback to call when invalidation request is complete. * @param {Error} err Error on error, otherwise null. */ invalidate(done: DoneCallback): void; } //# sourceMappingURL=account.d.ts.map