(options)
| 14 | const prepareCA = dependencies.prepareCA; |
| 15 | |
| 16 | function config(options) { |
| 17 | let config = { |
| 18 | token: null, |
| 19 | cert: "cert.pem", |
| 20 | key: "key.pem", |
| 21 | ca: null, |
| 22 | pfx: null, |
| 23 | passphrase: null, |
| 24 | production: (process.env.NODE_ENV === "production"), |
| 25 | address: null, |
| 26 | port: 443, |
| 27 | proxy: null, |
| 28 | rejectUnauthorized: true, |
| 29 | connectionRetryLimit: 10, |
| 30 | heartBeat: 60000, |
| 31 | }; |
| 32 | |
| 33 | validateOptions(options); |
| 34 | |
| 35 | extend(config, options); |
| 36 | configureAddress(config); |
| 37 | |
| 38 | if (config.token) { |
| 39 | delete config.cert; |
| 40 | delete config.key; |
| 41 | delete config.pfx; |
| 42 | |
| 43 | extend(config, { token: prepareToken(config.token) }); |
| 44 | } else { |
| 45 | if (config.pfx || config.pfxData) { |
| 46 | config.cert = options.cert; |
| 47 | config.key = options.key; |
| 48 | } |
| 49 | extend(config, prepareCertificate(config)); |
| 50 | } |
| 51 | |
| 52 | extend(config, prepareCA(config)); |
| 53 | |
| 54 | return config; |
| 55 | } |
| 56 | |
| 57 | function validateOptions(options) { |
| 58 | for (var key in options) { |
no test coverage detected
searching dependent graphs…