Giter VIP home page Giter VIP logo

aws-sdk-v3-js-proxy's Introduction

AWS SDK v3 Proxy

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

A wrapper for adding proxy support to AWS SDK v3 clients

This wrapper adds a proxy configuration to AWS SDK clients by checking environment variables and attaching the necessary request handler. By default, an error will be thrown if no proxy is found in process.env, but also has options to not throw which can be useful when developing other node utilities using this library.

Note: http_proxy and HTTP_PROXY take precedence over https_proxy and HTTPS_PROXY. If you would like to change this behavior it can be specified in the options.

Install

npm install aws-sdk-v3-proxy

Usage

HTTP Proxy

// process.env.HTTP_PROXY = 'http://127.0.0.1'
import { S3Client } from '@aws-sdk/client-s3';
import { addProxyToClient } from 'aws-sdk-v3-proxy';

const client = addProxyToClient(new S3Client({}));
// `client` now has HTTP proxy config at 'http://127.0.0.1'

or

import { S3Client } from '@aws-sdk/client-s3';
import { addProxyToClient } from 'aws-sdk-v3-proxy';

const client = addProxyToClient(new S3Client({}), {
  httpProxy: 'http://127.0.0.1',
});
// `client` now has HTTP proxy config at 'http://127.0.0.1'

HTTPS Proxy

// process.env.HTTPS_PROXY = 'https://127.0.0.1'
import { S3Client } from '@aws-sdk/client-s3';
import { addProxyToClient } from 'aws-sdk-v3-proxy';

const client = addProxyToClient(new S3Client({}));
// `client` now has HTTPS proxy config at 'https://127.0.0.1'

or

import { S3Client } from '@aws-sdk/client-s3';
import { addProxyToClient } from 'aws-sdk-v3-proxy';

const client = addProxyToClient(new S3Client({}), {
  httpsProxy: 'https://127.0.0.1',
});
// `client` now has HTTPS proxy config at 'https://127.0.0.1'

No Proxy with exception disabled

// process.env.HTTPS_PROXY = undefined
// process.env.HTTP_PROXY = undefined
import { S3Client } from '@aws-sdk/client-s3';
import { addProxyToClient } from 'aws-sdk-v3-proxy';

const client = addProxyToClient(new S3Client({}), { throwOnNoProxy: false });
// `client` has no proxy assigned and no error thrown

Proxy with certs in header

// process.env.HTTPS_PROXY = 'https://127.0.0.1'
import { readFileSync } from 'fs';
import { S3Client } from '@aws-sdk/client-s3';
import { addProxyToClient } from 'aws-sdk-v3-proxy';

const client = addProxyToClient(new S3Client({}), {
  agentOptions: {
    ca: [readFileSync('custom-proxy-cert.pem').toString()],
  },
});

// `client` now has HTTPS proxy config at 'https://127.0.0.1' with ca `custom-proxy-cert.pem`

API

addProxyToClient(client, options?)

client

Type: Object

Any client from @aws-sdk.

options

Type: object

throwOnNoProxy

Type: boolean Default: true

Throw an error if no proxy is found in the environment.

httpsOnly

Type: boolean Default: false

Can be specified in cases where you have both http_proxy and https_proxy set, and would like to override the default behavior of the http_proxy taking precedence.

debug

Type: boolean Default: false

Toggles additional logging for debugging.

httpProxy

Type: string

The URL for the HTTP proxy server. If not specified, the value of process.env.http_proxy or process.env.HTTP_RPOXY will be used.

httpsProxy

The URL for the HTTPS proxy server. If not specified, the value of process.env.https_proxy or process.env.HTTPS_RPOXY will be used.

agentOptions

Type: HttpsProxyAgentOptions

Used to pass specific options to the proxy agent.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.