Skip to content

Commit

Permalink
added agent as a top level option to pass in
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengill committed Jul 9, 2020
1 parent c379711 commit 0250bdf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/interactive-messages/src/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable import-name */
import http, { RequestListener } from 'http';
import http, { RequestListener, Agent } from 'http';
import axios, { AxiosInstance } from 'axios';
import isString from 'lodash.isstring';
import isRegExp from 'lodash.isregexp';
Expand Down Expand Up @@ -137,6 +137,7 @@ export class SlackMessageAdapter {
constructor(signingSecret: string, {
syncResponseTimeout = 2500,
lateResponseFallbackEnabled = true,
agent = undefined,
}: MessageAdapterOptions = {}) {
if (!isString(signingSecret)) {
throw new TypeError('SlackMessageAdapter needs a signing secret');
Expand All @@ -154,6 +155,13 @@ export class SlackMessageAdapter {
headers: {
'User-Agent': packageIdentifier(),
},
httpAgent: agent,
httpsAgent: agent,
// disabling axios' automatic proxy support:
// axios would read from envvars to configure a proxy automatically, but it doesn't support TLS destinations.
// for compatibility with https://api.slack.com, and for a larger set of possible proxies (SOCKS or other
// protocols), users of this package should use the `agent` option to configure a proxy.
proxy: false,
});

debug('instantiated');
Expand Down Expand Up @@ -654,6 +662,7 @@ interface DispatchResult {
export interface MessageAdapterOptions {
syncResponseTimeout?: number;
lateResponseFallbackEnabled?: boolean;
agent?: Agent;
}

/**
Expand Down

0 comments on commit 0250bdf

Please sign in to comment.