@take2identity/verosint 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/postinstall.js +16 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@take2identity/verosint",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Official CLI to interact with Verosint API",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,8 +27,8 @@
27
27
  ],
28
28
  "homepage": "https://gitlab.com/443id/public/verosint#readme",
29
29
  "dependencies": {
30
+ "axios": "^1.3.4",
30
31
  "mkdirp": "^2.1.5",
31
- "request": "^2.88.2",
32
32
  "tar": "^6.1.13",
33
33
  "unzipper": "0.10.11"
34
34
  }
package/postinstall.js CHANGED
@@ -8,7 +8,7 @@ const { join } = require('path');
8
8
  const { exec } = require('child_process');
9
9
  const { existsSync, chmodSync, copyFileSync, unlinkSync, createWriteStream, readFileSync } = require('fs');
10
10
  const mkdirp = require('mkdirp');
11
- const request = require('request');
11
+ const axios = require('axios')
12
12
  const tar = require('tar');
13
13
  const zlib = require('zlib');
14
14
  const unzipper = require('unzipper');
@@ -210,28 +210,27 @@ function getStrategy({ url }) {
210
210
  */
211
211
 
212
212
  function install(callback) {
213
-
214
213
  const opts = parsePackageJson();
215
214
  if (!opts) return callback('Invalid inputs');
216
-
217
215
  mkdirp.sync(opts.binPath);
218
-
219
216
  console.log('Downloading from URL: ' + opts.url);
220
217
 
221
- const req = request({ uri: opts.url });
222
- req.on('error', () => callback('Error downloading from URL: ' + opts.url));
223
- req.on('response', (res) => {
224
- if (res.statusCode !== 200) return callback('Error downloading binary. HTTP Status Code: ' + res.statusCode);
225
-
226
- const strategy = getStrategy(opts);
227
-
228
- strategy({
229
- opts,
230
- req,
231
- onSuccess: () => verifyAndPlaceBinary(opts.binName, callback),
232
- onError: callback
218
+ axios.get( opts.url, {
219
+ responseType: 'stream'
220
+ } )
221
+ .then(response => {
222
+ if (response.status !== 200) return callback('Error downloading binary. HTTP Status Code: ' + response.status);
223
+ const strategy = getStrategy(opts);
224
+ strategy({
225
+ opts,
226
+ req: response.data,
227
+ onSuccess: () => verifyAndPlaceBinary(opts.binName, callback),
228
+ onError: callback
229
+ });
230
+ })
231
+ .catch(function( err ) {
232
+ callback(`Error downloading binary from ${opts.url} error: ${err}`);
233
233
  });
234
- });
235
234
  }
236
235
 
237
236