New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ibantools

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ibantools - npm Package Compare versions

Comparing version 3.3.1 to 4.0.0

1

build/ibantools.d.ts

@@ -230,2 +230,3 @@ /*!

bban_regexp?: string;
bban_validation_func?: (bban: string) => boolean;
IBANRegistry?: boolean;

@@ -232,0 +233,0 @@ SEPA?: boolean;

@@ -8,6 +8,6 @@ /*!

* Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff
* @packageDocumentation
* @package Documentation
* @author Saša Jovanić
* @module ibantools
* @version 3.3.1
* @version 4.0.0
* @license MPL-2.0

@@ -40,3 +40,3 @@ * @preferred

reg.test(iban.slice(2, 4)) &&
checkFormatBBAN(iban.slice(4), spec.bban_regexp) &&
isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
isValidIBANChecksum(iban)) {

@@ -80,3 +80,3 @@ return true;

}
if (spec && spec.bban_regexp && !checkFormatBBAN(iban.slice(4), spec.bban_regexp)) {
if (spec && spec.bban_regexp && !isValidBBAN(iban.slice(4), iban.slice(0, 2))) {
result.valid = false;

@@ -125,2 +125,5 @@ result.errorCodes.push(ValidationErrorsIBAN.WrongBBANFormat);

checkFormatBBAN(bban, spec.bban_regexp)) {
if (spec.bban_validation_func) {
return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
}
return true;

@@ -429,2 +432,67 @@ }

/**
* Used for Norway BBAN check
*
* @ignore
*/
var checkNorwayBBAN = function (bban) {
var weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
if (bbanWithoutSpacesAndPeriods.length !== 11) {
return false;
}
else {
var controlDigit = parseInt(bbanWithoutSpacesAndPeriods.charAt(10), 10);
var bbanWithoutControlDigit = bbanWithoutSpacesAndPeriods.substring(0, 10);
var sum = 0;
for (var index = 0; index < 10; index++) {
sum += parseInt(bbanWithoutControlDigit.charAt(index), 10) * weights[index];
}
var remainder = sum % 11;
return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
}
};
/**
* Used for Poland BBAN check
*
* @ignore
*/
var checkPolandBBAN = function (bban) {
var weights = [3, 9, 7, 1, 3, 9, 7];
var controlDigit = parseInt(bban.charAt(7), 10);
var toCheck = bban.substring(0, 7);
var sum = 0;
for (var index = 0; index < 7; index++) {
sum += parseInt(toCheck.charAt(index), 10) * weights[index];
}
var remainder = sum % 10;
return controlDigit === (remainder === 0 ? 0 : 10 - remainder);
};
/**
* Spain (ES) BBAN check
*
* @ignore
*/
var checkSpainBBAN = function (bban) {
var weightsBankBranch = [4, 8, 5, 10, 9, 7, 3, 6];
var weightsAccount = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
var controlBankBranch = parseInt(bban.charAt(8), 10);
var controlAccount = parseInt(bban.charAt(9), 10);
var bankBranch = bban.substring(0, 8);
var account = bban.substring(10, 20);
var sum = 0;
for (var index = 0; index < 8; index++) {
sum += parseInt(bankBranch.charAt(index), 10) * weightsBankBranch[index];
}
var remainder = sum % 11;
if (controlBankBranch !== (remainder === 0 ? 0 : 11 - remainder)) {
return false;
}
sum = 0;
for (var index = 0; index < 10; index++) {
sum += parseInt(account.charAt(index), 10) * weightsAccount[index];
}
remainder = sum % 11;
return controlAccount === (remainder === 0 ? 0 : 11 - remainder);
};
/**
* Country specifications

@@ -497,4 +565,4 @@ */

BI: {
chars: 16,
bban_regexp: '^[0-9]{12}$',
chars: 27,
bban_regexp: '^[0-9]{23}$',
},

@@ -595,3 +663,3 @@ BJ: {

ER: {},
ES: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
ES: { chars: 24, bban_validation_func: checkSpainBBAN, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
ET: {},

@@ -871,3 +939,3 @@ FI: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true, SEPA: true },

},
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', IBANRegistry: true, SEPA: true },
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', bban_validation_func: checkNorwayBBAN, IBANRegistry: true, SEPA: true },
NP: {},

@@ -892,3 +960,3 @@ NR: {},

},
PL: { chars: 28, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
PL: { chars: 28, bban_validation_func: checkPolandBBAN, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
PM: {

@@ -959,3 +1027,3 @@ chars: 27,

chars: 28,
bban_regexp: '^[A-Z]{1}[0-9]{23}$',
bban_regexp: '^[A-Z]{2}[0-9]{22}$',
},

@@ -962,0 +1030,0 @@ SO: {},

@@ -8,6 +8,6 @@ /*!

* Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff
* @packageDocumentation
* @package Documentation
* @author Saša Jovanić
* @module ibantools
* @version 3.3.1
* @version 4.0.0
* @license MPL-2.0

@@ -38,3 +38,3 @@ * @preferred

reg.test(iban.slice(2, 4)) &&
checkFormatBBAN(iban.slice(4), spec.bban_regexp) &&
isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
isValidIBANChecksum(iban)) {

@@ -77,3 +77,3 @@ return true;

}
if (spec && spec.bban_regexp && !checkFormatBBAN(iban.slice(4), spec.bban_regexp)) {
if (spec && spec.bban_regexp && !isValidBBAN(iban.slice(4), iban.slice(0, 2))) {
result.valid = false;

@@ -121,2 +121,5 @@ result.errorCodes.push(ValidationErrorsIBAN.WrongBBANFormat);

checkFormatBBAN(bban, spec.bban_regexp)) {
if (spec.bban_validation_func) {
return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
}
return true;

@@ -415,2 +418,67 @@ }

/**
* Used for Norway BBAN check
*
* @ignore
*/
var checkNorwayBBAN = function (bban) {
var weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
if (bbanWithoutSpacesAndPeriods.length !== 11) {
return false;
}
else {
var controlDigit = parseInt(bbanWithoutSpacesAndPeriods.charAt(10), 10);
var bbanWithoutControlDigit = bbanWithoutSpacesAndPeriods.substring(0, 10);
var sum = 0;
for (var index = 0; index < 10; index++) {
sum += parseInt(bbanWithoutControlDigit.charAt(index), 10) * weights[index];
}
var remainder = sum % 11;
return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
}
};
/**
* Used for Poland BBAN check
*
* @ignore
*/
var checkPolandBBAN = function (bban) {
var weights = [3, 9, 7, 1, 3, 9, 7];
var controlDigit = parseInt(bban.charAt(7), 10);
var toCheck = bban.substring(0, 7);
var sum = 0;
for (var index = 0; index < 7; index++) {
sum += parseInt(toCheck.charAt(index), 10) * weights[index];
}
var remainder = sum % 10;
return controlDigit === (remainder === 0 ? 0 : 10 - remainder);
};
/**
* Spain (ES) BBAN check
*
* @ignore
*/
var checkSpainBBAN = function (bban) {
var weightsBankBranch = [4, 8, 5, 10, 9, 7, 3, 6];
var weightsAccount = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
var controlBankBranch = parseInt(bban.charAt(8), 10);
var controlAccount = parseInt(bban.charAt(9), 10);
var bankBranch = bban.substring(0, 8);
var account = bban.substring(10, 20);
var sum = 0;
for (var index = 0; index < 8; index++) {
sum += parseInt(bankBranch.charAt(index), 10) * weightsBankBranch[index];
}
var remainder = sum % 11;
if (controlBankBranch !== (remainder === 0 ? 0 : 11 - remainder)) {
return false;
}
sum = 0;
for (var index = 0; index < 10; index++) {
sum += parseInt(account.charAt(index), 10) * weightsAccount[index];
}
remainder = sum % 11;
return controlAccount === (remainder === 0 ? 0 : 11 - remainder);
};
/**
* Country specifications

@@ -483,4 +551,4 @@ */

BI: {
chars: 16,
bban_regexp: '^[0-9]{12}$',
chars: 27,
bban_regexp: '^[0-9]{23}$',
},

@@ -581,3 +649,3 @@ BJ: {

ER: {},
ES: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
ES: { chars: 24, bban_validation_func: checkSpainBBAN, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
ET: {},

@@ -857,3 +925,3 @@ FI: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true, SEPA: true },

},
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', IBANRegistry: true, SEPA: true },
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', bban_validation_func: checkNorwayBBAN, IBANRegistry: true, SEPA: true },
NP: {},

@@ -878,3 +946,3 @@ NR: {},

},
PL: { chars: 28, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
PL: { chars: 28, bban_validation_func: checkPolandBBAN, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
PM: {

@@ -945,3 +1013,3 @@ chars: 27,

chars: 28,
bban_regexp: '^[A-Z]{1}[0-9]{23}$',
bban_regexp: '^[A-Z]{2}[0-9]{22}$',
},

@@ -948,0 +1016,0 @@ SO: {},

2

package.json
{
"name": "ibantools",
"version": "3.3.1",
"version": "4.0.0",
"description": "Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff like ISO 3136-1 alpha 2 country list",

@@ -5,0 +5,0 @@ "keywords": [

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