@integromat/proto
Version:
Integromat Proto-Classes
154 lines • 5.64 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.IMTOAuthAccount = exports.IMTAccount = void 0;
/**
* Base class for all Accounts.
*
* @property common - Collection of common parameters. Read only.
* @property data - Collection of config parameters.
*/
var IMTAccount = /** @class */ (function () {
function IMTAccount() {
this.common = null;
this.data = null;
}
/**
* 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.
*/
IMTAccount.prototype.initialize = function (done) {
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTAccount.prototype.finalize = function (done) {
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTAccount.prototype.test = function (done) {
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTAccount.prototype.validate = function (done) {
if ('function' === typeof done)
done();
};
return IMTAccount;
}());
exports.IMTAccount = IMTAccount;
/*
Base class for all OAuth Accounts.
*/
var IMTOAuthAccount = /** @class */ (function (_super) {
__extends(IMTOAuthAccount, _super);
function IMTOAuthAccount() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* 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.
*/
IMTOAuthAccount.prototype.accountFromCallbackRequest = function (req, done) {
this.id = null;
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTOAuthAccount.prototype.authorize = function (scope, done) {
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTOAuthAccount.prototype.callback = function (req, done) {
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTOAuthAccount.prototype.extendScope = function (scope, done) {
if ('function' === typeof done)
done();
};
/**
* 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.
*/
IMTOAuthAccount.prototype.reauthorize = function (done) {
if ('function' === typeof done)
done();
};
/**
* Invalidate current access token.
*
* @callback done Callback to call when invalidation request is complete.
* @param {Error} err Error on error, otherwise null.
*/
IMTOAuthAccount.prototype.invalidate = function (done) {
if ('function' === typeof done)
done();
};
return IMTOAuthAccount;
}(IMTAccount));
exports.IMTOAuthAccount = IMTOAuthAccount;
//# sourceMappingURL=account.js.map