Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
use new common, remove logs to avoid exposing sensitive data
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Jan 22, 2021
1 parent 25bcaca commit c0cbcc1
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 107 deletions.
22 changes: 8 additions & 14 deletions lib/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var _Client = require("./Client");

var _Utils = require("./Utils");

var _languageCommon = require("language-common");
var _languageCommon = require("@openfn/language-common");

var _cheerio = _interopRequireDefault(require("cheerio"));

Expand All @@ -81,14 +81,15 @@ var _fs = _interopRequireDefault(require("fs"));

var _csvParse = _interopRequireDefault(require("csv-parse"));

var _http = require("language-common/lib/http");

var _toughCookie = _interopRequireDefault(require("tough-cookie"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/** @module Adaptor */

const {
axios
} = _languageCommon.http;
exports.axios = axios;
/**
* Execute a sequence of operations.
* Wraps `language-common/execute`, and prepends initial state for http.
Expand All @@ -101,6 +102,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
* @param {Operations} operations - Operations to be performed.
* @returns {Operation}
*/

function execute(...operations) {
const initialState = {
references: [],
Expand All @@ -116,15 +118,13 @@ function execute(...operations) {

var Cookie = _toughCookie.default.Cookie;
var cookiejar = new _toughCookie.default.CookieJar();

_http.__axios.interceptors.request.use(function (config) {
axios.interceptors.request.use(function (config) {
cookiejar === null || cookiejar === void 0 ? void 0 : cookiejar.getCookies(config.url, function (err, cookies) {
config.headers.cookie = cookies === null || cookies === void 0 ? void 0 : cookies.join('; ');
});
return config;
});

_http.__axios.interceptors.response.use(function (response) {
axios.interceptors.response.use(function (response) {
let cookies;
let keepCookies = [];
response = { ...response,
Expand Down Expand Up @@ -175,14 +175,12 @@ _http.__axios.interceptors.response.use(function (response) {
* @returns {Operation}
*/


function get(path, params, callback) {
return state => {
var _params$authenticatio, _params, _params2;

path = (0, _languageCommon.expandReferences)(path)(state);
params = (0, _languageCommon.expandReferences)(params)(state);
console.log('params', params);
const url = (0, _Utils.setUrl)(state.configuration, path);
const auth = (0, _Utils.setAuth)(state.configuration, (_params$authenticatio = (_params = params) === null || _params === void 0 ? void 0 : _params.authentication) !== null && _params$authenticatio !== void 0 ? _params$authenticatio : (_params2 = params) === null || _params2 === void 0 ? void 0 : _params2.auth);
const config = (0, _Utils.mapToAxiosConfig)({ ...params,
Expand Down Expand Up @@ -223,7 +221,6 @@ function post(path, params, callback) {

path = (0, _languageCommon.expandReferences)(path)(state);
params = (0, _languageCommon.expandReferences)(params)(state);
console.log('params', params);
const url = (0, _Utils.setUrl)(state.configuration, path);
const auth = (0, _Utils.setAuth)(state.configuration, (_params$authenticatio2 = (_params3 = params) === null || _params3 === void 0 ? void 0 : _params3.authentication) !== null && _params$authenticatio2 !== void 0 ? _params$authenticatio2 : (_params4 = params) === null || _params4 === void 0 ? void 0 : _params4.auth);
const config = (0, _Utils.mapToAxiosConfig)({ ...params,
Expand Down Expand Up @@ -264,7 +261,6 @@ function put(path, params, callback) {

path = (0, _languageCommon.expandReferences)(path)(state);
params = (0, _languageCommon.expandReferences)(params)(state);
console.log('params', params);
const url = (0, _Utils.setUrl)(state.configuration, path);
const auth = (0, _Utils.setAuth)(state.configuration, (_params$authenticatio3 = (_params5 = params) === null || _params5 === void 0 ? void 0 : _params5.authentication) !== null && _params$authenticatio3 !== void 0 ? _params$authenticatio3 : (_params6 = params) === null || _params6 === void 0 ? void 0 : _params6.auth);
const config = (0, _Utils.mapToAxiosConfig)({ ...params,
Expand Down Expand Up @@ -305,7 +301,6 @@ function patch(path, params, callback) {

path = (0, _languageCommon.expandReferences)(path)(state);
params = (0, _languageCommon.expandReferences)(params)(state);
console.log('params', params);
const url = (0, _Utils.setUrl)(state.configuration, path);
const auth = (0, _Utils.setAuth)(state.configuration, (_params$authenticatio4 = (_params7 = params) === null || _params7 === void 0 ? void 0 : _params7.authentication) !== null && _params$authenticatio4 !== void 0 ? _params$authenticatio4 : (_params8 = params) === null || _params8 === void 0 ? void 0 : _params8.auth);
const config = (0, _Utils.mapToAxiosConfig)({ ...params,
Expand Down Expand Up @@ -346,7 +341,6 @@ function del(path, params, callback) {

path = (0, _languageCommon.expandReferences)(path)(state);
params = (0, _languageCommon.expandReferences)(params)(state);
console.log('params', params);
const url = (0, _Utils.setUrl)(state.configuration, path);
const auth = (0, _Utils.setAuth)(state.configuration, (_params$authenticatio5 = (_params9 = params) === null || _params9 === void 0 ? void 0 : _params9.authentication) !== null && _params$authenticatio5 !== void 0 ? _params$authenticatio5 : (_params10 = params) === null || _params10 === void 0 ? void 0 : _params10.auth);
const config = (0, _Utils.mapToAxiosConfig)({ ...params,
Expand Down
2 changes: 0 additions & 2 deletions lib/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ exports.tryJson = tryJson;
exports.mapToAxiosConfig = mapToAxiosConfig;
exports.recursivelyExpandReferences = recursivelyExpandReferences;

var _http = require("language-common/lib/http");

var _formData = _interopRequireDefault(require("form-data"));

var _fp = require("lodash/fp");
Expand Down
Loading

0 comments on commit c0cbcc1

Please sign in to comment.