test-this-package-today
Version:
Event Inc is a fully managed event bus lets you send and receive data across mission-critical cloud apps, databases and warehouses.
44 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OauthConnection = void 0;
var OauthConnectionTypes;
(function (OauthConnectionTypes) {
OauthConnectionTypes["Xero"] = "xero";
})(OauthConnectionTypes || (OauthConnectionTypes = {}));
const endpoints = {
xero: 'https://identity.xero.com/connect/token',
};
class OauthConnection {
constructor({ OAUTH_APP_CLIENT_ID, OAUTH_APP_CLIENT_SECRET, type, }) {
this.getOauthDetails = () => {
switch (this.type) {
case OauthConnectionTypes.Xero:
return {
endpoint: endpoints[this.type],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: `Basic ${Buffer.from(`${this.OAUTH_APP_CLIENT_ID}:${this.OAUTH_APP_CLIENT_SECRET}`).toString('base64')}`,
},
sourceIntegrationDefinitionId: 'conn_def_src_MTY4ODc2MzM3ODY2OQ::OWE2NDdmYjAtZjFlMy00MWEyLTgwMTctMzVhODMxYTBkOWNi',
destinationIntegrationDefinitionId: 'conn_def_dst_MTY4NjA3MDUyOTk1OA::MTgwM2E1NGItMTYxMC00NjE4LTk1NTItNjBjY2I1NmY1ZmQx',
};
}
};
this.getOauthFormData = ({ accessToken, refreshToken, }) => {
switch (this.type) {
case OauthConnectionTypes.Xero:
return {
XERO_REFRESH_TOKEN: refreshToken,
XERO_ACCESS_TOKEN: accessToken,
XERO_CLIENT_ID: this.OAUTH_APP_CLIENT_ID,
XERO_CLIENT_SECRET: this.OAUTH_APP_CLIENT_SECRET,
};
}
};
this.OAUTH_APP_CLIENT_ID = OAUTH_APP_CLIENT_ID;
this.OAUTH_APP_CLIENT_SECRET = OAUTH_APP_CLIENT_SECRET;
this.type = type;
}
}
exports.OauthConnection = OauthConnection;
//# sourceMappingURL=index.js.map