skydiver / ewelink-api

eWeLink API for JavaScript
https://www.npmjs.com/package/ewelink-api
MIT License
265 stars 109 forks source link

Connection through proxy not implemented #107

Open belichuk opened 3 years ago

belichuk commented 3 years ago

I used proxy in my local network for security reasons. But ewelink-api doesn't support proxy.

What was checked: src/mixins/getCredentials.js

const request = await fetch(`${this.getApiUrl()}/user/login`, {
  method: 'post',
  headers: { Authorization: `Sign ${makeAuthorizationSign(body)}` },
  body: JSON.stringify(body),
});

src/mixins/makeRequest.js

const payload = {
  method,
  headers: {
    Authorization: `Bearer ${this.at}`,
    'Content-Type': 'application/json',
  },
};
...
const request = await fetch(requestUrl, payload);

};

This could be solved in several ways, but most simple is to add package https-proxy-agent (see node-https-proxy-agent). @skydiver Let me know if you interesting to implement or approve PR to support proxy functionality.

skydiver commented 3 years ago

@belichuk sorry for the delay on the response 😳

today version 3.1 was merged and released, you're welcome to open that PR (if still interested)