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'

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'

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.

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.

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

Contributors

dependabot[bot] avatar ryansonshine avatar smguggen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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

Deprecated dependencies warnings (move to Smithy)

Not a bug neither a feature request.

Current Behavior

$ npm install aws-sdk-v3-proxy

npm WARN deprecated @aws-sdk/[email protected]: This package has moved to @smithy/node-http-handler
npm WARN deprecated @aws-sdk/[email protected]: This package has moved to @smithy/protocol-http

Expected Behavior

No warnings about deprecated packages.

Steps to Reproduce the Problem

  1. npm install aws-sdk-v3-proxy
  2. Observe the warnings.

Environment

  • Version: 2.1.2
  • Platform: Linux
  • Node.js Version: v20.12.2

Either httpAgent or httpsAgent are set, but not both

Current Behavior

According to the code, either httpAgent or httpsAgent are set, but never both.
However, aws-sdk v3 documentation clearly states:
"httpAgent is not the same as httpsAgent, and since most calls from the client will be to https, both should be set."
https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-proxies.html

Expected Behavior

If both http and https are provided, both should be passed on to the client.

Steps to Reproduce the Problem

Try use this package with AmazonConnect, which requires both.

Environment

  • Version: 0.0.0-development
  • Platform: Linux
  • Node.js Version: 18

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Client network socket disconnected before secure TLS connection was established

Current Behavior

Setting https proxy to https://172.20.7.148:9090
recoverIdToken error: TimeoutError: Client network socket disconnected before secure TLS connection was established

Works without "addProxyToClient".

Expected Behavior

Traffic is proxied through Proxyman.

Steps to Reproduce the Problem

import { addProxyToClient } from 'aws-sdk-v3-proxy';

...

const cognitoIdpCient: CognitoIdentityProviderClient = addProxyToClient(
  new CognitoIdentityProviderClient({
    region: REGION,
  }),
  {
    debug: true,
  }
);

...

const forgotPasswordCommand: ForgotPasswordCommand = new ForgotPasswordCommand({
      ClientId: CLIENT_ID,
      Username: PHONE,
});
forgotPasswordResponse = await cognitoIdpCient.send(forgotPasswordCommand);

Environment

  • Version: 2.0.14
  • Platform: Mac/Linux
  • Node.js Version: v18.16.0

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.