Skip to content

Commit 7736945

Browse files
Merge pull request #3 from phaxio/enforce-tls1.2
Set default of TLSv1.2
2 parents 7107d7f + aff8bc5 commit 7736945

18 files changed

Lines changed: 324 additions & 300 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Change Log
2+
3+
## v1.2 (2019-03-21)
4+
Adds optional argument to set the minimum TLS version to be used. Defaults to `TLSv1.2`.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,27 @@ phaxio.faxes.listFaxes({ direction: 'sent' })
7474
Phaxio methods are categorized according to the Phaxio API route that they target.
7575
See the [Phaxio Docs]('https://www.phaxio.com/docs/api/v2.1/') for more information about the raw API.
7676
77+
### Initialization
78+
Initializing the `Phaxio` class takes two required arguments, the Key and Secret you retreived from Phaxio, and
79+
allows for one optional argument, the minimum TLS version to use. By default, the minimum TLS version is set to
80+
`TLSv1.2`. See the [TLS documentation](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options) for
81+
other possible options to `minVersion` if you require something other than `TLSv1.2`. **Modifying the minimum TLS
82+
version is not recommended.**
83+
84+
Arguments:
85+
86+
| Key | Value Type | Required? | Description |
87+
| --- | ---------- | --------- | ----------- |
88+
| `phaxio api key` | String | True | Your Phaxio API Key |
89+
| `phaxio api secret` | String | True | Your Phaxio API Secret |
90+
| `minimum TLS Version` | String | False | Default: `TLSv1.2`, other possible options are the same as `minVersion` in the [TLS documentation](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options). |
91+
92+
```javascript
93+
const Phaxio = require('phaxio-official');
94+
95+
const phaxio = new Phaxio(<phaxio api key>, <phaxio api secret>, [optional: <minimum TLS version>]);
96+
```
97+
7798
**All Phaxio methods take one argument:** either a single argument such as an ID, or an Object containing
7899
`key: value` parameters.
79100
See the documentation below for specifics.

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ const PhaxCode = require('./src/phax-code');
55
const PhoneNumber = require('./src/phone-number');
66

77
module.exports = class {
8-
constructor(apiKey, apiSecret) {
8+
constructor(apiKey, apiSecret, minTLSVersion) {
99
this.apiKey = apiKey;
1010
this.apiSecret = apiSecret;
1111

1212
this.url = 'https://api.phaxio.com/v2.1';
13+
this.agentOptions = { minVersion: minTLSVersion || 'TLSv1.2' };
1314

14-
this.public = new Public(this.url);
15-
this.faxes = new Faxes(this.apiKey, this.apiSecret, this.url);
16-
this.account = new Account(this.apiKey, this.apiSecret, this.url);
17-
this.phaxCode = new PhaxCode(this.apiKey, this.apiSecret, this.url);
18-
this.phoneNumber = new PhoneNumber(this.apiKey, this.apiSecret, this.url);
15+
this.public = new Public(this.url, this.agentOptions);
16+
this.faxes = new Faxes(this.apiKey, this.apiSecret, this.url, this.agentOptions);
17+
this.account = new Account(this.apiKey, this.apiSecret, this.url, this.agentOptions);
18+
this.phaxCode = new PhaxCode(this.apiKey, this.apiSecret, this.url, this.agentOptions);
19+
this.phoneNumber = new PhoneNumber(this.apiKey, this.apiSecret, this.url, this.agentOptions);
1920
}
2021
};

0 commit comments

Comments
 (0)