Skip to content

Commit 6c39b90

Browse files
Stephen Smitslaphead
authored andcommitted
Updated readme and reject authorization option
1 parent 709a83a commit 6c39b90

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Please see [docs.civic.com](https://docs.civic.com) for a more details.
1414
npm install civic-sip-api --save
1515
```
1616

17-
### Usage
17+
### Basic Usage
1818
```javascript
1919
const civicSip = require('civic-sip-api');
2020

@@ -53,8 +53,35 @@ userData = {
5353
}
5454
```
5555

56+
### Proxy Usage
57+
There is basic proxy support. The server address and port is set as a url.
58+
59+
`rejectUnauthorized` Setting this to `false` is optional and can be used when testing in development and needing to use a self signed cerificate. We do *not* recommend setting this to `false` in a production environment as it will compromise security.
60+
61+
```javascript
62+
const civicSip = require('civic-sip-api');
63+
64+
const civicClient = civicSip.newClient({
65+
appId: 'ABC123',
66+
appSecret: APP_SECRET,
67+
prvKey: PRV_KEY,
68+
proxy: {
69+
url: 'http://10.0.0.6:8080',
70+
rejectUnauthorized: false, // Do not make false in production
71+
},
72+
});
73+
74+
civicClient.exchangeCode(jwtToken)
75+
.then((userData) => {
76+
// store user data and userId as appropriate
77+
console.log('userData = ', JSON.stringify(userData, null, 4));
78+
}).catch((error) => {
79+
console.log(error);
80+
});
81+
```
82+
5683
---
57-
Copyright © 2017 Civic.com
84+
Copyright © 2018 Civic.com
5885

5986
Released under the MIT License, which can be found in the repository in `LICENSE.txt`.
6087

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ sipClientFactory.newClient = (configIn) => {
167167

168168
if (config.proxy) {
169169
requestOptions.proxy = config.proxy.url;
170-
requestOptions.rejectUnauthorized = false;
170+
requestOptions.rejectUnauthorized = 'rejectUnauthorized' in config.proxy ? config.proxy.rejectUnauthorized : true;
171171
}
172172

173173
return request(requestOptions)
@@ -215,7 +215,7 @@ sipClientFactory.newClient = (configIn) => {
215215

216216
if (config.proxy) {
217217
requestOptions.proxy = config.proxy.url;
218-
requestOptions.rejectUnauthorized = false;
218+
requestOptions.rejectUnauthorized = 'rejectUnauthorized' in config.proxy ? config.proxy.rejectUnauthorized : true;
219219
}
220220

221221
return request(requestOptions)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)