Comparing version 2.1.0 to 2.2.0
@@ -11,3 +11,3 @@ /*! | ||
* @see module:ibantools | ||
* @version 2.1.0 | ||
* @version 2.2.0 | ||
* @license MPL-2.0 | ||
@@ -31,2 +31,3 @@ */ | ||
if (iban !== undefined && iban !== null) { | ||
var reg = new RegExp("^[0-9]{2}$", ""); | ||
var spec = countrySpecs[iban.slice(0, 2)]; | ||
@@ -36,4 +37,5 @@ if (spec !== undefined && | ||
spec.chars === iban.length && | ||
reg.test(iban.slice(2, 4)) && | ||
checkFormatBBAN(iban.slice(4), spec.bban_regexp) && | ||
mod9710(iban) === 1) { | ||
isValidIBANChecksum(iban)) { | ||
return true; | ||
@@ -171,2 +173,27 @@ } | ||
/** | ||
* Calculate checksum of IBAN and compares it with checksum provided in IBANregistry | ||
* @param {string} IBAN | ||
* @return {boolean} | ||
*/ | ||
function isValidIBANChecksum(iban) { | ||
var providedChecksum = parseInt(iban.slice(2, 4), 10); | ||
var temp = iban.slice(3) + iban.slice(0, 2) + '00'; | ||
var validationString = ""; | ||
for (var n = 1; n < temp.length; n++) { | ||
var c = temp.charCodeAt(n); | ||
if (c >= 65) { | ||
validationString += (c - 55).toString(); | ||
} | ||
else { | ||
validationString += temp[n]; | ||
} | ||
} | ||
while (validationString.length > 2) { | ||
var part = validationString.slice(0, 6); | ||
validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length); | ||
} | ||
var rest = parseInt(validationString, 10) % 97; | ||
return (98 - rest) === providedChecksum; | ||
} | ||
/** | ||
* MOD-97-10 | ||
@@ -173,0 +200,0 @@ * @param {string} |
@@ -11,3 +11,3 @@ /*! | ||
* @see module:ibantools | ||
* @version 2.1.0 | ||
* @version 2.2.0 | ||
* @license MPL-2.0 | ||
@@ -30,2 +30,3 @@ */ | ||
if (iban !== undefined && iban !== null) { | ||
var reg = new RegExp("^[0-9]{2}$", ""); | ||
var spec = countrySpecs[iban.slice(0, 2)]; | ||
@@ -35,4 +36,5 @@ if (spec !== undefined && | ||
spec.chars === iban.length && | ||
reg.test(iban.slice(2, 4)) && | ||
checkFormatBBAN(iban.slice(4), spec.bban_regexp) && | ||
mod9710(iban) === 1) { | ||
isValidIBANChecksum(iban)) { | ||
return true; | ||
@@ -164,2 +166,27 @@ } | ||
/** | ||
* Calculate checksum of IBAN and compares it with checksum provided in IBANregistry | ||
* @param {string} IBAN | ||
* @return {boolean} | ||
*/ | ||
function isValidIBANChecksum(iban) { | ||
var providedChecksum = parseInt(iban.slice(2, 4), 10); | ||
var temp = iban.slice(3) + iban.slice(0, 2) + '00'; | ||
var validationString = ""; | ||
for (var n = 1; n < temp.length; n++) { | ||
var c = temp.charCodeAt(n); | ||
if (c >= 65) { | ||
validationString += (c - 55).toString(); | ||
} | ||
else { | ||
validationString += temp[n]; | ||
} | ||
} | ||
while (validationString.length > 2) { | ||
var part = validationString.slice(0, 6); | ||
validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length); | ||
} | ||
var rest = parseInt(validationString, 10) % 97; | ||
return (98 - rest) === providedChecksum; | ||
} | ||
/** | ||
* MOD-97-10 | ||
@@ -166,0 +193,0 @@ * @param {string} |
{ | ||
"name": "ibantools", | ||
"version": "2.1.0", | ||
"version": "2.2.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", | ||
@@ -51,12 +51,12 @@ "keywords": [ | ||
"@types/chai": "^4.1.2", | ||
"@types/mocha": "^2.2.48", | ||
"@types/mocha": "^5.2", | ||
"chai": "^4.1.2", | ||
"cheerio": "^0.22", | ||
"coveralls": "^3.0.3", | ||
"docdash": "^0.4.0", | ||
"docdash": "^1.1", | ||
"gulp": "^4.0.1", | ||
"gulp-mocha": "^5.0", | ||
"gulp-mocha": "^6.0", | ||
"gulp-rename": "^1.2", | ||
"gulp-shell": "^0.7.0", | ||
"gulp-typescript": "^4.0", | ||
"gulp-typescript": "^5.0", | ||
"istanbul": "^0.4", | ||
@@ -67,12 +67,17 @@ "jasmine-core": "^3.1", | ||
"karma-chrome-launcher": "^2.2", | ||
"karma-jasmine": "^1.1.1", | ||
"karma-jasmine": "^2.0", | ||
"karma-requirejs": "^1.1", | ||
"merge2": "^1.2.1", | ||
"mocha": "^5.0", | ||
"mocha": "^6.1", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"request": "^2.88.0", | ||
"requirejs": "^2.3", | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.7" | ||
"typescript": "^3.4", | ||
"extend": ">=3.0.2", | ||
"sshpk": ">=1.13.2" | ||
}, | ||
"//": { | ||
"extend": "deep dependency of karma - security issue", | ||
"sshpk": "deep dependency of coverals - security issue" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # IBANTools | ||
For more information about IBAN/BBAN see [wikipedia page](https://en.wikipedia.org/wiki/International_Bank_Account_Number) and | ||
[IBAN registry](https://www.swift.com/sites/default/files/resources/iban_registry.pdf). | ||
[IBAN registry](https://www.swift.com/resource/iban-registry-pdf). | ||
@@ -21,0 +21,0 @@ For more information about BIC/SWIFT see [this wikipedia page](https://en.wikipedia.org/wiki/ISO_9362). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97801
1263
26