AlexXanderGrib / node-qiwi-sdk

:kiwi_fruit: QIWI Bank (qiwi.com) API SDK for node JS. Fully Typed. Covers (Personal & P2P API's)
https://npmjs.com/package/qiwi-sdk
MIT License
32 stars 8 forks source link

Proxy support #10

Closed sababacash closed 2 years ago

sababacash commented 2 years ago

Идея

.env file :

QIWI-PROXY=login:passwd@192.168.0.1:5500

http.ts or other : 

const PROXY = process.env.QIWI-PROXY || null

then feed the proxy to axios
AlexXanderGrib commented 2 years ago

Any api since version 2.3 have a field called agent. You can set it to make API requests through proxy

Example

import { SocksProxyAgent } from 'socks-proxy-agent';
import { Personal } from 'qiwi-sdk';

const qiwi = new Personal(process.env.QIWI_TOKEN, process.env.QIWI_WALLET);
const agent = new SocksProxyAgent(process.env.PROXY);

qiwi.agent = agent;

// If are using custom agent, qiwi instance can not be disposed by itself. 
// So you need to set agent to undefined if you expect a safe disposal
qiwi.agent = undefined;
# .env
QIWI_TOKEN=9060***********************ac0d
QIWI_WALLET=791******31
PROXY=socks://login:passwd@192.168.0.1:5500

List of apis, that supports custom agent

import {
  // Since 2.3
  Personal,
  P2P, 

  // since 3.0
  Wallet, 
  P2p,
  Detector,
  DetectorCompat
} from "qiwi-sdk"
sababacash commented 2 years ago

Thanks!