Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ofac

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ofac - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

29

index.js
const fs = require('fs');
const readline = require('readline');
const fetch = require('node-fetch');
const unzip = require('unzip');
const zip = require('node-stream-zip');
const xml2js = require('xml2js');

@@ -21,5 +21,4 @@

self.db = await self.zipInfo(fn, 'path');
if (!fs.existsSync(self.db) || force)
await self.unzip(fn);
self.db = await self.zipExtract(fn);

@@ -36,18 +35,16 @@ return self;

},
zipInfo: (fn, prop) => {
zipExtract: (fn, path = './') => {
var z = new zip({file: fn});
return new Promise((resolve, reject) => {
fs.createReadStream(fn)
.pipe(unzip.Parse())
.on('error', reject)
.on('entry', entry => resolve(prop ? entry[prop] : entry));
var xfn = 'sdn.xml';
z.on('error', reject);
z.on('ready', () => {
z.extract(xfn, path, err => {
if (err) reject(err);
resolve(xfn);
z.close();
})
});
});
},
unzip: (fn, path = './') => {
return new Promise((resolve, reject) => {
fs.createReadStream(fn)
.pipe(unzip.Extract({ path }))
.on('error', reject)
.on('close', resolve)
});
},
search: (cust, fn = self.db) => {

@@ -54,0 +51,0 @@ // input data clean

{
"name": "ofac",
"version": "1.0.1",
"version": "1.0.2",
"description": "A module to facilitate OFAC searches",

@@ -25,3 +25,3 @@ "main": "index.js",

"node-fetch": "^2.3.0",
"unzip": "^0.1.11",
"node-stream-zip": "^1.8.0",
"xml2js": "^0.4.19"

@@ -28,0 +28,0 @@ },

@@ -13,14 +13,21 @@ # OFAC

## Installation
## Install
The usual way:
Fetch from from the repository
```
npm install --save ofac
```
And set up a usable instance like this:
```
// using ES6 modules
import ofaq from 'ofac';
// using CommonJS modules
const ofaq = require('ofac');
```
## API
In the CommonJs paradigm, we require the module and subsequently initialise it:
The module must be initialised:
```
const ofaq = require('ofac');
ofaq.init().then(...);

@@ -27,0 +34,0 @@ ```

@@ -0,1 +1,2 @@

var fs = require('fs');
var assert = require('assert').strict;

@@ -31,2 +32,16 @@ const ofac = require('../index.js');

describe('OFAC', () => {
describe('Archive', () => {
var zip = 'sdn_xml.zip', fn = 'sdn.xml';
before(() => {
if (fs.existsSync(fn)) fs.unlinkSync(fn);
})
it('Extraction', async () => {
assert.ok(fs.existsSync(zip), 'Archive does not exist');
assert.ok(!fs.existsSync(fn), 'Extract exists');
var actual = await ofac.zipExtract(zip);
assert.equal(actual, fn, 'Extracted a different file');
assert.ok(fs.existsSync(fn), 'Extract file does not exist');
});
});
describe('search', () => {

@@ -33,0 +48,0 @@ before(() => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc