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

iin-checker

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iin-checker - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

.jscsrc

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## **0.1.3**
- [**#3**](https://github.com/Shortbreaks/iinChecker/issues/3) Testing multiple, stubbed out providers
- Handled case where both providers are down it would silently error, Now error bubbles up.
## **0.1.2**

@@ -2,0 +6,0 @@ - [**#1**](https://github.com/Shortbreaks/iinChecker/issues/1) Added in param checking on the lookup function

15

Gruntfile.js

@@ -21,6 +21,9 @@ /* jslint node: true */

core: {
src: ['Gruntfile.js', 'package.json', 'lib/**/*.js', 'lib /**/*.json']
src: ['Gruntfile.js', 'lib/**/*.js']
},
test: {
src: ['test/**/*.js', 'test/**/*.json']
src: ['test/**/*.js']
},
json: {
src: ['package.json', 'lib/**/*.json', 'test/**/*.json']
}

@@ -30,5 +33,7 @@ },

options: {
config: 'shortbreaks.jscs.json'
config: '.jscsrc'
},
src: ['<%= jshint.core.src %>', '<%= jshint.test.src %>']
files: {
src: ['<%= jshint.core.src %>', '<%= jshint.test.src %>']
}
},

@@ -45,3 +50,3 @@ mochaTest: {

grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-jscs-checker' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.loadNpmTasks( 'grunt-mocha-test' );

@@ -48,0 +53,0 @@

@@ -90,2 +90,22 @@

callback( null, cardInfo );
} else {
// Error occured with binlist fall back on ribon
request( { url: 'https://bins.ribbon.co/api/v1/bins/' + iin, json: true }, function( error, response, body ) {
if ( !error && response.statusCode === 200 ) {
// Remap the reply to match our schema
var cardInfo = {
'bin': body.bin,
'brand': body.brand,
'issuer': body.issuer,
'type': ( body.type ? body.type : self.nullValue ),
'category': self.nullValue,
'country': body.country_code
};
// send the results back a-la-node
callback( null, cardInfo );
} else {
throw error;
}
} );
}

@@ -92,0 +112,0 @@ } );

{
"name": "iin-checker",
"description": "Issuer identification number checker which returns details about a credit/debit card",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/Shortbreaks/iinChecker",

@@ -25,6 +25,9 @@ "author": "Simon Wood <simon.wood@holidayextras.com> (https://github.com/Shortbreaks)",

"grunt": "~0.4.3",
"grunt-contrib-jshint": "~0.8.0",
"grunt-jscs-checker": "~0.4.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-coveralls": "^1.0.0",
"grunt-jscs": "^0.6.2",
"grunt-mocha-test": "^0.11.0",
"mocha": "^1.21.4"
"istanbul": "^0.3.0",
"mocha": "^1.21.4",
"nock": "^0.45.0"
},

@@ -31,0 +34,0 @@ "dependencies": {

# IIN Checker for payment cards
[![Build Status](https://travis-ci.org/Shortbreaks/iinChecker.png)](https://travis-ci.org/Shortbreaks/iinChecker)
[![Coverage Status](https://coveralls.io/repos/Shortbreaks/iinChecker/badge.png?branch=master)](https://coveralls.io/r/Shortbreaks/iinChecker?branch=master)
[![Dependency status](https://david-dm.org/Shortbreaks/iinChecker/status.png)](https://david-dm.org/Shortbreaks/iinChecker#info=dependencies&view=table)
[![Dev Dependency Status](https://david-dm.org/Shortbreaks/iinChecker/dev-status.png)](https://david-dm.org/Shortbreaks/iinChecker#info=devDependencies&view=table)
[![NPM](https://nodei.co/npm/iin-checker.png)](https://nodei.co/npm/iin-checker/)
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
## About

@@ -53,4 +56,4 @@

## Todo (REMOVE BEFORE FINAL COMMIT)
- Change heading of this file. See [this](https://github.com/mikeal/request)
- Get working with providers and none provider RegEx alternative
- Get mock working with ribon provider
- Get non-provider RegEx alternative
- Allow preference of providers to be passed into options

@@ -57,0 +60,0 @@ - Support caching

@@ -7,78 +7,105 @@ /* jshint -W098 */

var iin = new IinChecker( {} );
var nock = require('nock');
describe( '#lookup a card', function() {
var testGenCard;
it( 'should lookup a card without error', function( done ) {
iin.lookup( '411111', function( err, result ) {
if ( err ) {
throw( err );
} else {
testGenCard = result;
done();
}
// Load all of our providers into an array that we can loop over. This needs to match those available
var providers = require( '../configs/providers.json' );
// Lets read our providers in from the config and loop over them
providers.forEach( function( provider ) {
var stubRequest = function( iin ) {
// Make sure our string comparisons don't get caught out by case issues by converting to uppercase
nock( provider.domain ).get( provider.path + iin ).reply( 200, require( './fixtures/' + provider.name + '/' + iin ) );
};
// This will stop all further calls to this provider from functioning...Please make sure you call this on the last line of your last test function
var breakProvider = function() {
nock( provider.domain ).persist().get( '*' ).reply( 500 );
};
describe( '#lookup a card using ' + provider.name, function() {
var testGenCard;
it( 'should lookup a card without error', function( done ) {
var iinToLookup = '411111';
stubRequest( iinToLookup );
iin.lookup( iinToLookup, function( err, result ) {
if ( err ) {
throw( err );
} else {
testGenCard = result;
done();
}
} );
} );
} );
it( 'iin lookup returns card as an object', function( done ) {
testGenCard.should.be.a( 'object' );
done();
} );
it( 'iin lookup returns card as an object', function( done ) {
testGenCard.should.be.a( 'object' );
done();
} );
it( 'card object returned contains the correct properties', function( done ) {
testGenCard.should.have.property( 'bin' );
testGenCard.should.have.property( 'brand' );
testGenCard.should.have.property( 'issuer' );
testGenCard.should.have.property( 'type' );
testGenCard.should.have.property( 'category' );
testGenCard.should.have.property( 'country' );
done();
it( 'card object returned contains the correct properties', function( done ) {
testGenCard.should.have.property( 'bin' );
testGenCard.should.have.property( 'brand' );
testGenCard.should.have.property( 'issuer' );
testGenCard.should.have.property( 'type' );
testGenCard.should.have.property( 'category' );
testGenCard.should.have.property( 'country' );
done();
} );
} );
} );
describe( '#lookup visa debit', function() {
var testVisaDebitCard;
it( 'should lookup a card without error', function( done ) {
iin.lookup( '431940', function( err, result ) {
if ( err ) {
throw( err );
} else {
testVisaDebitCard = result;
done();
}
describe( '#lookup visa debit using ' + provider.name, function() {
var testVisaDebitCard;
it( 'should lookup a card without error', function( done ) {
var iinToLookup = '431940';
stubRequest( iinToLookup );
iin.lookup( iinToLookup, function( err, result ) {
if ( err ) {
throw( err );
} else {
testVisaDebitCard = result;
done();
}
} );
} );
} );
it( 'card is of type debit', function( done ) {
testVisaDebitCard.type.should.equal( iin.types.DEBIT );
done();
} );
it( 'card is of type debit', function( done ) {
testVisaDebitCard.type.should.equal( iin.types.DEBIT );
done();
} );
it( 'card is of brand visa', function( done ) {
testVisaDebitCard.brand.should.equal( iin.brands.VISA );
done();
it( 'card is of brand visa', function( done ) {
testVisaDebitCard.brand.should.equal( iin.brands.VISA );
done();
} );
} );
} );
describe( '#lookup mastercard credit', function() {
var testMasterCreditCard;
it( 'should lookup a card without error', function( done ) {
iin.lookup( '518791', function( err, result ) {
if ( err ) {
throw( err );
} else {
testMasterCreditCard = result;
done();
}
describe( '#lookup mastercard credit using ' + provider.name, function() {
var testMasterCreditCard;
it( 'should lookup a card without error', function( done ) {
var iinToLookup = '518791';
stubRequest( iinToLookup );
iin.lookup( iinToLookup, function( err, result ) {
if ( err ) {
throw( err );
} else {
testMasterCreditCard = result;
done();
}
} );
} );
} );
it( 'card is of type credit', function( done ) {
testMasterCreditCard.type.should.equal( iin.types.CREDIT );
done();
} );
it( 'card is of type credit', function( done ) {
testMasterCreditCard.type.should.equal( iin.types.CREDIT );
done();
} );
it( 'card is of brand mastercard', function( done ) {
testMasterCreditCard.brand.should.equal( iin.brands.MASTERCARD );
done();
it( 'card is of brand mastercard', function( done ) {
testMasterCreditCard.brand.should.equal( iin.brands.MASTERCARD );
// This is the final test...we are all done with the provider, so let's mock them being broken, so that fallback will work for the subsequent provider
breakProvider();
done();
} );
} );
} );

Sorry, the diff of this file is not supported yet

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