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

credit-card-type

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

credit-card-type - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

CHANGELOG.md

2

bower.json
{
"name": "credit-card-type",
"main": "index.js",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/braintree/credit-card-type",

@@ -6,0 +6,0 @@ "authors": [

@@ -8,5 +8,5 @@ var isString = require('lodash.isstring');

type: 'visa',
pattern: '^4[0-9][\\s\\d]*$',
pattern: '^4\\d*$',
gaps: [4, 8, 12],
length: 16,
lengths: [16],
code: {

@@ -20,5 +20,5 @@ name: 'CVV',

type: 'master-card',
pattern: '^5[1-5][\\s\\d]*$',
pattern: '^5[1-5]\\d*$',
gaps: [4, 8, 12],
length: 16,
lengths: [16],
code: {

@@ -32,6 +32,6 @@ name: 'CVC',

type: 'american-express',
pattern: '^3[47][\\s\\d]*$',
pattern: '^3[47]\\d*$',
isAmex: true,
gaps: [4, 10],
length: 15,
lengths: [15],
code: {

@@ -45,5 +45,5 @@ name: 'CID',

type: 'diners-club',
pattern: '^3(?:0[0-5]|[68][0-9])[\\s\\d]*$',
pattern: '^3(0[0-5]|[689])\\d*$',
gaps: [4, 10],
length: 14,
lengths: [14],
code: {

@@ -57,5 +57,5 @@ name: 'CVV',

type: 'discover',
pattern: '^6(?:011|5[0-9]{2})[\\s\\d]*$',
pattern: '^6(011|5|4[4-9])\\d*$',
gaps: [4, 8, 12],
length: 16,
lengths: [16],
code: {

@@ -69,5 +69,5 @@ name: 'CID',

type: 'jcb',
pattern: '^(?:2131|1800|35)[\\s\\d]*$',
pattern: '^(2131|1800|35)\\d*$',
gaps: [4, 8, 12],
length: 16,
lengths: [16],
code: {

@@ -77,3 +77,26 @@ name: 'CVV',

}
}];
},
{
niceType: 'UnionPay',
type: 'unionpay',
pattern: '^62\\d*$',
gaps: [4, 8, 12],
lengths: [16, 17, 18, 19],
code: {
name: 'CVN',
size: 3
}
},
{
niceType: 'Maestro',
type: 'maestro',
pattern: '^(50|5[6-9]|6)\\d*$',
gaps: [4, 8, 12],
lengths: [12, 13, 14, 15, 16, 17, 18, 19],
code: {
name: 'CVC',
size: 3
}
}
];

@@ -80,0 +103,0 @@ module.exports = function getCardType(cardNumber) {

{
"name": "credit-card-type",
"version": "1.0.0",
"version": "2.0.0",
"description": "A library for determining credit card type",

@@ -10,2 +10,7 @@ "main": "index.js",

},
"repository": {
"type": "git",
"url": "git@github.com:braintree/credit-card-type"
},
"homepage": "https://github.com/braintree/credit-card-type",
"author": "",

@@ -12,0 +17,0 @@ "license": "MIT",

@@ -24,9 +24,9 @@ Credit Card Type [![Build Status](https://travis-ci.org/braintree/credit-card-type.svg)](https://travis-ci.org/braintree/credit-card-type) [![npm version](https://badge.fury.io/js/credit-card-type.svg)](http://badge.fury.io/js/credit-card-type)

| Key | Value | Description |
| --- | ----- | ----------- |
| `niceType` | `String` | A pretty printed represention of the card brand.<br/>- `Visa`<br />- `MasterCard`<br />- `American Express`<br />- `DinersClub`<br />- `Discover`<br />- `JCB` |
| Key | Type | Description |
| --- | ---- | ----------- |
| `niceType` | `String` | A pretty printed representation of the card brand.<br/>- `Visa`<br />- `MasterCard`<br />- `American Express`<br />- `DinersClub`<br />- `Discover`<br />- `JCB`<br />- `UnionPay`<br />- `Maestro` |
| `type` | `String` | A code-friendly presentation of the card brand (useful to class names in CSS).<br/>- `visa`<br />- `master-card`<br />- `american-express`<br />- `diners-club`<br />- `discover`<br />- `jcb` |
| `pattern` | `RegExp` | The regular expression used to determine the card type. |
| `gaps` | `Array` | The expected indeces of gaps in a string representation of the card number. For example, in a Visa card, `4111 1111 1111 1111`, there are expected spaces in the 4th, 8th, and 12th positions. This is useful in setting your own formatting rules. |
| `length` | `Integer` | The expected length of the card number string (excluding spaces and `/` characters). |
| `lengths` | `Array` | The expected lengths of the card number as an array of strings (excluding spaces and `/` characters). |
| `code` | `Object` | The information regarding the security code for the determined card. Learn more about the [code object](#code) below. |

@@ -46,2 +46,4 @@

| `JCB` | `CVV` | 3 |
| `UnionPay` | `CVN` | 3 |
| `Maestro` | `CVC` | 3 |

@@ -56,3 +58,3 @@ A full response for a `Visa` card will look like this:

gaps: [ 4, 8, 12 ],
length: 16,
lengths: [16],
code: { name: 'CVV', size: 3 }

@@ -59,0 +61,0 @@ }

@@ -40,2 +40,7 @@ var expect = require('chai').expect;

['6221558812340000', 'unionpay'],
['6269992058134322', 'unionpay'],
['6304000000000000', 'maestro'],
['3530111333300000', 'jcb'],

@@ -79,7 +84,33 @@ ['3566002020360505', 'jcb']

it('DinersClub', function () {
expect(getCardType('3530111333300000').code.size).to.equal(3);
expect(getCardType('3530111333300000').code.name).to.equal('CVV');
expect(getCardType('30569309025904').code.size).to.equal(3);
expect(getCardType('30569309025904').code.name).to.equal('CVV');
});
it('UnionPay', function () {
expect(getCardType('6221558812340000').code.size).to.equal(3);
expect(getCardType('6221558812340000').code.name).to.equal('CVN');
});
it('Maestro', function () {
expect(getCardType('6304000000000000').code.size).to.equal(3);
expect(getCardType('6304000000000000').code.name).to.equal('CVC');
});
});
describe('returns lengths for', function () {
it('maestro', function () {
expect(getCardType('63').lengths).to.deep.equal([12,13,14,15,16,17,18,19]);
});
it('diners club', function () {
expect(getCardType('305').lengths).to.deep.equal([14]);
});
it('discover', function () {
expect(getCardType('6011').lengths).to.deep.equal([16]);
});
it('visa', function () {
expect(getCardType('4').lengths).to.deep.equal([16]);
});
it('mastercard', function () {
expect(getCardType('54').lengths).to.deep.equal([16]);
});
});
describe('returns empty for', function () {

@@ -86,0 +117,0 @@ it('bad card', function () {

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