ibantools 4.1.3 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -195,8 +195,8 @@ export interface ExtractBICResult {
195
195
  bankCode?: string;
196
196
  countryCode?: string;
197
197
  locationCode?: string;
198
- branchCode?: string;
199
- testBIC?: boolean;
198
+ branchCode: string | null;
199
+ testBIC: boolean;
200
200
  valid: boolean;
201
201
  }
202
202
  /**
@@ -8,7 +8,7 @@
8
8
  * @package Documentation
9
9
  * @author Saša Jovanić
10
10
  * @module ibantools
11
- * @version 4.1.3
11
+ * @version 4.1.6
12
12
  * @license MPL-2.0
13
13
  * @preferred
14
14
  */
@@ -27,21 +27,16 @@ exports.countrySpecs = exports.extractBIC = exports.validateBIC = exports.Valida
27
27
  * ```
28
28
  */
29
29
  function isValidIBAN(iban) {
30
- if (iban !== undefined && iban !== null) {
31
- var reg = new RegExp('^[0-9]{2}$', '');
32
- var spec = exports.countrySpecs[iban.slice(0, 2)];
33
- if (spec !== undefined &&
34
- spec.bban_regexp &&
35
- spec.bban_regexp !== null &&
36
- spec.chars &&
37
- spec.chars === iban.length &&
38
- reg.test(iban.slice(2, 4)) &&
39
- isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
40
- isValidIBANChecksum(iban)) {
41
- return true;
42
- }
43
- }
44
- return false;
30
+ if (iban === undefined || iban === null)
31
+ return false;
32
+ var reg = new RegExp('^[0-9]{2}$', '');
33
+ var spec = exports.countrySpecs[iban.slice(0, 2)];
34
+ if (spec === undefined || spec.bban_regexp === undefined || spec.bban_regexp === null || spec.chars === undefined)
35
+ return false;
36
+ return (spec.chars === iban.length &&
37
+ reg.test(iban.slice(2, 4)) &&
38
+ isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
39
+ isValidIBANChecksum(iban));
45
40
  }
46
41
  exports.isValidIBAN = isValidIBAN;
47
42
  /**
@@ -115,21 +110,21 @@ exports.validateIBAN = validateIBAN;
115
110
  * ```
116
111
  */
117
112
  function isValidBBAN(bban, countryCode) {
118
- if (bban !== undefined && bban !== null && countryCode !== undefined && countryCode !== null) {
119
- var spec = exports.countrySpecs[countryCode];
120
- if (spec !== undefined &&
121
- spec !== null &&
122
- spec.bban_regexp &&
123
- spec.bban_regexp !== null &&
124
- spec.chars &&
125
- spec.chars !== null &&
126
- spec.chars - 4 === bban.length &&
127
- checkFormatBBAN(bban, spec.bban_regexp)) {
128
- if (spec.bban_validation_func) {
129
- return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
130
- }
131
- return true;
113
+ if (bban === undefined || bban === null || countryCode === undefined || countryCode === null)
114
+ return false;
115
+ var spec = exports.countrySpecs[countryCode];
116
+ if (spec === undefined ||
117
+ spec === null ||
118
+ spec.bban_regexp === undefined ||
119
+ spec.bban_regexp === null ||
120
+ spec.chars === undefined ||
121
+ spec.chars === null)
122
+ return false;
123
+ if (spec.chars - 4 === bban.length && checkFormatBBAN(bban, spec.bban_regexp)) {
124
+ if (spec.bban_validation_func) {
125
+ return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
132
126
  }
127
+ return true;
133
128
  }
134
129
  return false;
135
130
  }
@@ -192,10 +187,11 @@ exports.composeIBAN = composeIBAN;
192
187
  */
193
188
  function extractIBAN(iban) {
194
189
  var result = {};
195
- result.iban = iban;
196
- if (isValidIBAN(iban)) {
197
- result.bban = iban.slice(4);
198
- result.countryCode = iban.slice(0, 2);
190
+ var eFormatIBAN = electronicFormatIBAN(iban);
191
+ result.iban = eFormatIBAN || iban;
192
+ if (!!eFormatIBAN && isValidIBAN(eFormatIBAN)) {
193
+ result.bban = eFormatIBAN.slice(4);
194
+ result.countryCode = eFormatIBAN.slice(0, 2);
199
195
  result.valid = true;
200
196
  }
201
197
  else {
@@ -263,43 +259,54 @@ exports.friendlyFormatIBAN = friendlyFormatIBAN;
263
259
  * @ignore
264
260
  */
265
261
  function isValidIBANChecksum(iban) {
262
+ var countryCode = iban.slice(0, 2);
266
263
  var providedChecksum = parseInt(iban.slice(2, 4), 10);
267
- var temp = iban.slice(3) + iban.slice(0, 2) + '00';
268
- var validationString = '';
269
- for (var n = 1; n < temp.length; n++) {
270
- var c = temp.charCodeAt(n);
271
- if (c >= 65) {
272
- validationString += (c - 55).toString();
273
- }
274
- else {
275
- validationString += temp[n];
276
- }
277
- }
278
- while (validationString.length > 2) {
279
- var part = validationString.slice(0, 6);
280
- validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length);
281
- }
282
- var rest = parseInt(validationString, 10) % 97;
264
+ var bban = iban.slice(4);
265
+ // Wikipedia[validating_iban] says there are a specif way to check if a IBAN is valid but
266
+ // it. It says 'If the remainder is 1, the check digit test is passed and the
267
+ // IBAN might be valid.'. might, MIGHT!
268
+ // We don't want might but want yes or no. Since every BBAN is IBAN from the fifth
269
+ // (slice(4)) we can generate the IBAN from BBAN and country code(two first characters)
270
+ // from in the IBAN.
271
+ // To generate the (generate the iban check digits)[generating-iban-check]
272
+ // Move the country code to the end
273
+ // remove the checksum from the begging
274
+ // Add "00" to the end
275
+ // modulo 97 on the amount
276
+ // subtract remainder from 98, (98 - remainder)
277
+ // Add a leading 0 if the remainder is less then 10 (padStart(2, "0")) (we skip this
278
+ // since we compare int, not string)
279
+ //
280
+ // [validating_iban][https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN]
281
+ // [generating-iban-check][https://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits]
282
+ var validationString = replaceCharaterWithCode("".concat(bban).concat(countryCode, "00"));
283
+ var rest = mod9710(validationString);
283
284
  return 98 - rest === providedChecksum;
284
285
  }
286
+ /**
287
+ * Iban contain characters and should be converted to intereger by 55 substracted
288
+ * from there ascii value
289
+ *
290
+ * @ignore
291
+ */
292
+ function replaceCharaterWithCode(str) {
293
+ // It is slower but alot more readable
294
+ // https://jsbench.me/ttkzgsekae/1
295
+ return str
296
+ .split('')
297
+ .map(function (c) {
298
+ var code = c.charCodeAt(0);
299
+ return code >= 65 ? (code - 55).toString() : c;
300
+ })
301
+ .join('');
302
+ }
285
303
  /**
286
304
  * MOD-97-10
287
305
  *
288
306
  * @ignore
289
307
  */
290
308
  function mod9710Iban(iban) {
291
- iban = iban.slice(3) + iban.slice(0, 4);
292
- var validationString = '';
293
- for (var n = 1; n < iban.length; n++) {
294
- var c = iban.charCodeAt(n);
295
- if (c >= 65) {
296
- validationString += (c - 55).toString();
297
- }
298
- else {
299
- validationString += iban[n];
300
- }
301
- }
302
- return mod9710(validationString);
309
+ return mod9710(replaceCharaterWithCode(iban.slice(3) + iban.slice(0, 4)));
303
310
  }
304
311
  /**
305
312
  * Returns specifications for all countries, even those who are not
@@ -328,10 +335,10 @@ function getCountrySpecifications() {
328
335
  for (var countyCode in exports.countrySpecs) {
329
336
  var county = exports.countrySpecs[countyCode];
330
337
  countyMap[countyCode] = {
331
- chars: county.chars ? county.chars : null,
332
- bban_regexp: county.bban_regexp ? county.bban_regexp : null,
333
- IBANRegistry: county.IBANRegistry ? county.IBANRegistry : false,
334
- SEPA: county.SEPA ? county.SEPA : false,
338
+ chars: county.chars || null,
339
+ bban_regexp: county.bban_regexp || null,
340
+ IBANRegistry: county.IBANRegistry || false,
341
+ SEPA: county.SEPA || false,
335
342
  };
336
343
  }
337
344
  return countyMap;
@@ -417,7 +424,7 @@ function extractBIC(inputBic) {
417
424
  result.countryCode = bic.slice(4, 6);
418
425
  result.locationCode = bic.slice(6, 8);
419
426
  result.testBIC = result.locationCode[1] === '0' ? true : false;
420
- result.branchCode = bic.length > 8 ? bic.slice(8) : '619';
427
+ result.branchCode = bic.length > 8 ? bic.slice(8) : null;
421
428
  result.valid = true;
422
429
  }
423
430
  else {
@@ -443,23 +450,6 @@ var checkNorwayBBAN = function (bban) {
443
450
  var remainder = sum % 11;
444
451
  return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
445
452
  };
446
- /**
447
- * Used for Netherlands BBAN check
448
- *
449
- * @ignore
450
- */
451
- var checkDutchBBAN = function (bban) {
452
- var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
453
- var accountNumber = bbanWithoutSpacesAndPeriods.substring(4, 14);
454
- if (accountNumber.startsWith('000')) {
455
- return true; // Postbank account, no `elfproef` possible
456
- }
457
- var sum = 0;
458
- for (var index = 0; index < 10; index++) {
459
- sum += parseInt(accountNumber.charAt(index), 10) * (10 - index);
460
- }
461
- return sum % 11 === 0;
462
- };
463
453
  /**
464
454
  * Used for Belgian BBAN check
465
455
  *
@@ -479,12 +469,17 @@ var checkBelgianBBAN = function (bban) {
479
469
  */
480
470
  var mod9710 = function (validationString) {
481
471
  while (validationString.length > 2) {
472
+ // > Any computer programming language or software package that is used to compute D
473
+ // > mod 97 directly must have the ability to handle integers of more than 30 digits.
474
+ // > In practice, this can only be done by software that either supports
475
+ // > arbitrary-precision arithmetic or that can handle 219-bit (unsigned) integers
476
+ // https://en.wikipedia.org/wiki/International_Bank_Account_Number#Modulo_operation_on_IBAN
482
477
  var part = validationString.slice(0, 6);
483
- var value = parseInt(part, 10) % 97;
484
- if (isNaN(value)) {
478
+ var partInt = parseInt(part, 10);
479
+ if (isNaN(partInt)) {
485
480
  return NaN;
486
481
  }
487
- validationString = value.toString() + validationString.slice(part.length);
482
+ validationString = (partInt % 97) + validationString.slice(part.length);
488
483
  }
489
484
  return parseInt(validationString, 10) % 97;
490
485
  };
@@ -1176,7 +1171,10 @@ exports.countrySpecs = {
1176
1171
  bban_regexp: '^[A-Z0-9]{2}[0-9]{22}$',
1177
1172
  },
1178
1173
  MM: {},
1179
- MN: {},
1174
+ MN: {
1175
+ chars: 20,
1176
+ bban_regexp: '^[0-9]{16}$',
1177
+ },
1180
1178
  MO: {},
1181
1179
  MP: {},
1182
1180
  MQ: {
@@ -1228,11 +1226,16 @@ exports.countrySpecs = {
1228
1226
  NL: {
1229
1227
  chars: 18,
1230
1228
  bban_regexp: '^[A-Z]{4}[0-9]{10}$',
1231
- bban_validation_func: checkDutchBBAN,
1232
1229
  IBANRegistry: true,
1233
1230
  SEPA: true,
1234
1231
  },
1235
- NO: { chars: 15, bban_regexp: '^[0-9]{11}$', bban_validation_func: checkNorwayBBAN, IBANRegistry: true, SEPA: true },
1232
+ NO: {
1233
+ chars: 15,
1234
+ bban_regexp: '^[0-9]{11}$',
1235
+ bban_validation_func: checkNorwayBBAN,
1236
+ IBANRegistry: true,
1237
+ SEPA: true,
1238
+ },
1236
1239
  NP: {},
1237
1240
  NR: {},
1238
1241
  NU: {},
@@ -8,7 +8,7 @@
8
8
  * @package Documentation
9
9
  * @author Saša Jovanić
10
10
  * @module ibantools
11
- * @version 4.1.3
11
+ * @version 4.1.6
12
12
  * @license MPL-2.0
13
13
  * @preferred
14
14
  */
@@ -25,21 +25,16 @@
25
25
  * ```
26
26
  */
27
27
  export function isValidIBAN(iban) {
28
- if (iban !== undefined && iban !== null) {
29
- var reg = new RegExp('^[0-9]{2}$', '');
30
- var spec = countrySpecs[iban.slice(0, 2)];
31
- if (spec !== undefined &&
32
- spec.bban_regexp &&
33
- spec.bban_regexp !== null &&
34
- spec.chars &&
35
- spec.chars === iban.length &&
36
- reg.test(iban.slice(2, 4)) &&
37
- isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
38
- isValidIBANChecksum(iban)) {
39
- return true;
40
- }
41
- }
42
- return false;
28
+ if (iban === undefined || iban === null)
29
+ return false;
30
+ var reg = new RegExp('^[0-9]{2}$', '');
31
+ var spec = countrySpecs[iban.slice(0, 2)];
32
+ if (spec === undefined || spec.bban_regexp === undefined || spec.bban_regexp === null || spec.chars === undefined)
33
+ return false;
34
+ return (spec.chars === iban.length &&
35
+ reg.test(iban.slice(2, 4)) &&
36
+ isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
37
+ isValidIBANChecksum(iban));
43
38
  }
44
39
  /**
45
40
  * IBAM validation errors
@@ -111,21 +106,21 @@ export function validateIBAN(iban) {
111
106
  * ```
112
107
  */
113
108
  export function isValidBBAN(bban, countryCode) {
114
- if (bban !== undefined && bban !== null && countryCode !== undefined && countryCode !== null) {
115
- var spec = countrySpecs[countryCode];
116
- if (spec !== undefined &&
117
- spec !== null &&
118
- spec.bban_regexp &&
119
- spec.bban_regexp !== null &&
120
- spec.chars &&
121
- spec.chars !== null &&
122
- spec.chars - 4 === bban.length &&
123
- checkFormatBBAN(bban, spec.bban_regexp)) {
124
- if (spec.bban_validation_func) {
125
- return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
126
- }
127
- return true;
109
+ if (bban === undefined || bban === null || countryCode === undefined || countryCode === null)
110
+ return false;
111
+ var spec = countrySpecs[countryCode];
112
+ if (spec === undefined ||
113
+ spec === null ||
114
+ spec.bban_regexp === undefined ||
115
+ spec.bban_regexp === null ||
116
+ spec.chars === undefined ||
117
+ spec.chars === null)
118
+ return false;
119
+ if (spec.chars - 4 === bban.length && checkFormatBBAN(bban, spec.bban_regexp)) {
120
+ if (spec.bban_validation_func) {
121
+ return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
128
122
  }
123
+ return true;
129
124
  }
130
125
  return false;
131
126
  }
@@ -185,10 +180,11 @@ export function composeIBAN(params) {
185
180
  */
186
181
  export function extractIBAN(iban) {
187
182
  var result = {};
188
- result.iban = iban;
189
- if (isValidIBAN(iban)) {
190
- result.bban = iban.slice(4);
191
- result.countryCode = iban.slice(0, 2);
183
+ var eFormatIBAN = electronicFormatIBAN(iban);
184
+ result.iban = eFormatIBAN || iban;
185
+ if (!!eFormatIBAN && isValidIBAN(eFormatIBAN)) {
186
+ result.bban = eFormatIBAN.slice(4);
187
+ result.countryCode = eFormatIBAN.slice(0, 2);
192
188
  result.valid = true;
193
189
  }
194
190
  else {
@@ -253,43 +249,54 @@ export function friendlyFormatIBAN(iban, separator) {
253
249
  * @ignore
254
250
  */
255
251
  function isValidIBANChecksum(iban) {
252
+ var countryCode = iban.slice(0, 2);
256
253
  var providedChecksum = parseInt(iban.slice(2, 4), 10);
257
- var temp = iban.slice(3) + iban.slice(0, 2) + '00';
258
- var validationString = '';
259
- for (var n = 1; n < temp.length; n++) {
260
- var c = temp.charCodeAt(n);
261
- if (c >= 65) {
262
- validationString += (c - 55).toString();
263
- }
264
- else {
265
- validationString += temp[n];
266
- }
267
- }
268
- while (validationString.length > 2) {
269
- var part = validationString.slice(0, 6);
270
- validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length);
271
- }
272
- var rest = parseInt(validationString, 10) % 97;
254
+ var bban = iban.slice(4);
255
+ // Wikipedia[validating_iban] says there are a specif way to check if a IBAN is valid but
256
+ // it. It says 'If the remainder is 1, the check digit test is passed and the
257
+ // IBAN might be valid.'. might, MIGHT!
258
+ // We don't want might but want yes or no. Since every BBAN is IBAN from the fifth
259
+ // (slice(4)) we can generate the IBAN from BBAN and country code(two first characters)
260
+ // from in the IBAN.
261
+ // To generate the (generate the iban check digits)[generating-iban-check]
262
+ // Move the country code to the end
263
+ // remove the checksum from the begging
264
+ // Add "00" to the end
265
+ // modulo 97 on the amount
266
+ // subtract remainder from 98, (98 - remainder)
267
+ // Add a leading 0 if the remainder is less then 10 (padStart(2, "0")) (we skip this
268
+ // since we compare int, not string)
269
+ //
270
+ // [validating_iban][https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN]
271
+ // [generating-iban-check][https://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits]
272
+ var validationString = replaceCharaterWithCode("".concat(bban).concat(countryCode, "00"));
273
+ var rest = mod9710(validationString);
273
274
  return 98 - rest === providedChecksum;
274
275
  }
276
+ /**
277
+ * Iban contain characters and should be converted to intereger by 55 substracted
278
+ * from there ascii value
279
+ *
280
+ * @ignore
281
+ */
282
+ function replaceCharaterWithCode(str) {
283
+ // It is slower but alot more readable
284
+ // https://jsbench.me/ttkzgsekae/1
285
+ return str
286
+ .split('')
287
+ .map(function (c) {
288
+ var code = c.charCodeAt(0);
289
+ return code >= 65 ? (code - 55).toString() : c;
290
+ })
291
+ .join('');
292
+ }
275
293
  /**
276
294
  * MOD-97-10
277
295
  *
278
296
  * @ignore
279
297
  */
280
298
  function mod9710Iban(iban) {
281
- iban = iban.slice(3) + iban.slice(0, 4);
282
- var validationString = '';
283
- for (var n = 1; n < iban.length; n++) {
284
- var c = iban.charCodeAt(n);
285
- if (c >= 65) {
286
- validationString += (c - 55).toString();
287
- }
288
- else {
289
- validationString += iban[n];
290
- }
291
- }
292
- return mod9710(validationString);
299
+ return mod9710(replaceCharaterWithCode(iban.slice(3) + iban.slice(0, 4)));
293
300
  }
294
301
  /**
295
302
  * Returns specifications for all countries, even those who are not
@@ -318,10 +325,10 @@ export function getCountrySpecifications() {
318
325
  for (var countyCode in countrySpecs) {
319
326
  var county = countrySpecs[countyCode];
320
327
  countyMap[countyCode] = {
321
- chars: county.chars ? county.chars : null,
322
- bban_regexp: county.bban_regexp ? county.bban_regexp : null,
323
- IBANRegistry: county.IBANRegistry ? county.IBANRegistry : false,
324
- SEPA: county.SEPA ? county.SEPA : false,
328
+ chars: county.chars || null,
329
+ bban_regexp: county.bban_regexp || null,
330
+ IBANRegistry: county.IBANRegistry || false,
331
+ SEPA: county.SEPA || false,
325
332
  };
326
333
  }
327
334
  return countyMap;
@@ -404,7 +411,7 @@ export function extractBIC(inputBic) {
404
411
  result.countryCode = bic.slice(4, 6);
405
412
  result.locationCode = bic.slice(6, 8);
406
413
  result.testBIC = result.locationCode[1] === '0' ? true : false;
407
- result.branchCode = bic.length > 8 ? bic.slice(8) : '619';
414
+ result.branchCode = bic.length > 8 ? bic.slice(8) : null;
408
415
  result.valid = true;
409
416
  }
410
417
  else {
@@ -429,23 +436,6 @@ var checkNorwayBBAN = function (bban) {
429
436
  var remainder = sum % 11;
430
437
  return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
431
438
  };
432
- /**
433
- * Used for Netherlands BBAN check
434
- *
435
- * @ignore
436
- */
437
- var checkDutchBBAN = function (bban) {
438
- var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
439
- var accountNumber = bbanWithoutSpacesAndPeriods.substring(4, 14);
440
- if (accountNumber.startsWith('000')) {
441
- return true; // Postbank account, no `elfproef` possible
442
- }
443
- var sum = 0;
444
- for (var index = 0; index < 10; index++) {
445
- sum += parseInt(accountNumber.charAt(index), 10) * (10 - index);
446
- }
447
- return sum % 11 === 0;
448
- };
449
439
  /**
450
440
  * Used for Belgian BBAN check
451
441
  *
@@ -465,12 +455,17 @@ var checkBelgianBBAN = function (bban) {
465
455
  */
466
456
  var mod9710 = function (validationString) {
467
457
  while (validationString.length > 2) {
458
+ // > Any computer programming language or software package that is used to compute D
459
+ // > mod 97 directly must have the ability to handle integers of more than 30 digits.
460
+ // > In practice, this can only be done by software that either supports
461
+ // > arbitrary-precision arithmetic or that can handle 219-bit (unsigned) integers
462
+ // https://en.wikipedia.org/wiki/International_Bank_Account_Number#Modulo_operation_on_IBAN
468
463
  var part = validationString.slice(0, 6);
469
- var value = parseInt(part, 10) % 97;
470
- if (isNaN(value)) {
464
+ var partInt = parseInt(part, 10);
465
+ if (isNaN(partInt)) {
471
466
  return NaN;
472
467
  }
473
- validationString = value.toString() + validationString.slice(part.length);
468
+ validationString = (partInt % 97) + validationString.slice(part.length);
474
469
  }
475
470
  return parseInt(validationString, 10) % 97;
476
471
  };
@@ -1162,7 +1157,10 @@ export var countrySpecs = {
1162
1157
  bban_regexp: '^[A-Z0-9]{2}[0-9]{22}$',
1163
1158
  },
1164
1159
  MM: {},
1165
- MN: {},
1160
+ MN: {
1161
+ chars: 20,
1162
+ bban_regexp: '^[0-9]{16}$',
1163
+ },
1166
1164
  MO: {},
1167
1165
  MP: {},
1168
1166
  MQ: {
@@ -1214,11 +1212,16 @@ export var countrySpecs = {
1214
1212
  NL: {
1215
1213
  chars: 18,
1216
1214
  bban_regexp: '^[A-Z]{4}[0-9]{10}$',
1217
- bban_validation_func: checkDutchBBAN,
1218
1215
  IBANRegistry: true,
1219
1216
  SEPA: true,
1220
1217
  },
1221
- NO: { chars: 15, bban_regexp: '^[0-9]{11}$', bban_validation_func: checkNorwayBBAN, IBANRegistry: true, SEPA: true },
1218
+ NO: {
1219
+ chars: 15,
1220
+ bban_regexp: '^[0-9]{11}$',
1221
+ bban_validation_func: checkNorwayBBAN,
1222
+ IBANRegistry: true,
1223
+ SEPA: true,
1224
+ },
1222
1225
  NP: {},
1223
1226
  NR: {},
1224
1227
  NU: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibantools",
3
- "version": "4.1.3",
3
+ "version": "4.1.6",
4
4
  "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
5
  "keywords": [
6
6
  "IBAN",
@@ -53,29 +53,30 @@
53
53
  "@typescript-eslint/eslint-plugin": "^4.28.4",
54
54
  "@typescript-eslint/parser": "^4.28.4",
55
55
  "chai": "^4.3.4",
56
- "cheerio": "^0.22",
57
56
  "coveralls": "^3.1.1",
58
57
  "docdash": "^1.2.0",
59
58
  "eslint": "^7.31.0",
60
59
  "eslint-config-prettier": "^8.3.0",
61
60
  "eslint-plugin-prettier": "^4.0.0",
62
61
  "gulp": "^4.0.2",
63
- "gulp-mocha": "^8.0",
64
62
  "gulp-rename": "^2.0",
65
63
  "gulp-shell": "^0.8.0",
66
64
  "gulp-typescript": "^5.0",
67
- "jasmine-core": "^3.8.0",
65
+ "jasmine-core": "^4.0.0",
68
66
  "karma": "^6.3.4",
69
67
  "karma-chrome-launcher": "^3.1",
70
- "karma-jasmine": "^4.0",
68
+ "karma-jasmine": "^5.0",
71
69
  "karma-requirejs": "^1.1",
72
70
  "merge2": "^1.4.1",
73
- "mocha": "^9.0.2",
71
+ "mocha": "^10.0.0",
74
72
  "mocha-lcov-reporter": "^1.2.0",
75
73
  "nyc": "^15.1.0",
76
74
  "prettier": "^2.3.2",
77
75
  "requirejs": "^2.3.6",
78
- "typedoc": "^0.22.9",
76
+ "typedoc": "^0.23.1",
79
77
  "typescript": "^4.3.5"
78
+ },
79
+ "resolutions": {
80
+ "source-map": "^0.8.0-beta.0"
80
81
  }
81
82
  }
package/ChangeLog DELETED
@@ -1,270 +0,0 @@
1
- 2021-12-17 Saša Jovanić <sasa@simplify.ba>
2
- * Version 4.1.3
3
- * Fix issue #85 - Fix NaN issue when calling `validateIBAN``
4
-
5
- 2021-12-14 Saša Jovanić <sasa@simplify.ba>
6
- * Version 4.1.2
7
- * Fix issue #83 - Fix problem when country can not be found when calling `validateIBAN`
8
-
9
- 2021-12-05 Saša Jovanić <sasa@simplify.ba>
10
- * Version 4.1.1
11
- * Added Hungarian (HU) BBAN validation
12
-
13
- 2021-12-01 Saša Jovanić <sasa@simplify.ba>
14
- * Improve test coverage
15
-
16
- 2021-11-30 Saša Jovanić <sasa@simplify.ba>
17
- * Added Estonian (EE) BBAN validation
18
- * Added Finland (FI) BBAN validation
19
- * Aland Islands (AX) uses BBAN valkidation from Finland
20
- * Added French (FR) and Monaco (MC) BBAN validation
21
-
22
- 2021-11-28 Saša Jovanić <sasa@simplify.ba>
23
- * Added Czech (CZ) BBAN validation
24
-
25
- 2021-11-27 Saša Jovanić <sasa@simplify.ba>
26
- * Added Croatian (HR) BBAN validation
27
-
28
- 2021-11-25 Saša Jovanić <sasa@simplify.ba>
29
- * Version 4.1.0
30
- * Added Belgian (BE) extra BBAN validation
31
- * Added mod97/10 BBAN validation for countries that do it that way: BA, ME, MK, PT, RS and SI
32
-
33
- 2021-11-24 Saša Jovanić <sasa@simplify.ba>
34
- * Added Netherlands (NL) extra BBAN validation
35
- * Added extra error code when validating IBAN `WrongAccountBankBranchChecksum` that indicates when checksum for account number or bank or branch code is incorrect
36
-
37
- 2021-11-23 Saša Jovanić <sasa@simplify.ba>
38
- * Version 4.0.1
39
- * Fixed bug when validating Spain IBAN
40
-
41
- 2021-11-18 Saša Jovanić <sasa@simplify.ba>
42
- * Updated README with new and updated badges
43
- * Fixed documentation on GH pages
44
- * Added dependabot dependency updates and merged some created dependency pull requests
45
- * Added Node 17 to build version on GitHub actions
46
- * Added GitHub CodeQL workflow
47
-
48
- 2021-11-17 Saša Jovanić <sasa@simplify.ba>
49
- * Version 4.0.0
50
- * Fixed Senegal (SN) regular expression
51
- * Updated Burundi (BI) specification
52
- * Added Spain (ES) extra BBAN validation
53
- * Added Poland (PL) extra BBAN validation
54
- * Added test to check for extra BBAN validation function
55
-
56
- 2021-09-30 Simen Mailund Svendsen <simen.m.s@hotmail.com>
57
- * Fix invalid norwegian BBANS (failing MOD11 check) being incorrectly returned as valid
58
-
59
- 2021-07-24 Saša Jovanić <sasa@simplify.ba>
60
- * Version 3.3.1
61
- * Fixed issue not showing AD and BG as SEPA countries
62
- * Fixed issue when incorrectly showing GL and FO as SEPA countryes
63
- * Fixed incorrect documentation for `composeIBAN`
64
- * Updates list of supported Node.js versions
65
- * Update dev dependencies
66
-
67
- 2021-05-05 Daniel Friesen <d@danf.ca>
68
- * Fixed `validateIBAN`'s handling of unsupported countries like US
69
- * Added checksum validation for unsupported/unknown countries to `validateIBAN`
70
-
71
- 2021-04-03 Saša Jovanić <sasa@simplify.ba>
72
- * Coverage improved to 100%
73
-
74
- 2021-04-03 Saša Jovanić <sasa@simplify.ba>
75
- * Version 3.3.0
76
- * Error codes for IBAN and BIC validation. Added `validateIBAN` and `validateBIC` methods that will return error codes.
77
-
78
- 2021-04-03 Saša Jovanić <sasa@simplify.ba>
79
- * Version 3.2.5
80
- * (Dependabot) Bump y18n from 3.2.1 to 3.2.2
81
-
82
- 2021-03-29 Xavier Alvarez
83
- * Fix validation for Burkina Faso, Benin, Algeria and Mali
84
-
85
- 2021-03-10 Saša Jovanić <sasa@simplify.ba>
86
- * Version 3.2.4
87
- * Exported `countrySpecs` to restore a bit of compatibility broken in 3.2.3
88
- * Updated development dependencies
89
- * Documentation is now part of master branch
90
-
91
- 2021-02-07 Saša Jovanić <sasa@simplify.ba>
92
- * Version 3.2.3
93
- * Dependabot PR merged
94
-
95
- 2021-02-06 Richard Leurs
96
- * Improve bundle size
97
-
98
- 2020-11-10 Saša Jovanić <sasa@simplify.ba>
99
- * Version 3.2.2
100
- * Fixed support for Cape Verde
101
- * Dependabot PR merged
102
-
103
- 2020-11-10 Saša Jovanić <sasa@simplify.ba>
104
- * Switch from `jsdoc` to `typedoc` for documentation generation
105
- * Typo in interface name fixed, this will require mayor version release
106
-
107
- 2020-11-09 Saša Jovanić <sasa@simplify.ba>
108
- * Removed `tslint` and added `eslint` and `prettier` to be used with `gulp lint` task
109
- * Added GitHub Action for linting to workflow
110
- * Updated PR template on GitHub and modified `CONTRIBUTING.md` document
111
-
112
- 2020-11-04 Saša Jovanić <sasa@simplify.ba>
113
- * Version 3.2.1
114
- * Merged PR from @witoldsz: Fixed Azerbaijan IBAN check regexp
115
-
116
- 2020-11-04 Saša Jovanić <sasa@simplify.ba>
117
- * Removed Travis CI integration and integrated Github Action to show badge on master branch and status on pull requests
118
- * Upgraded to `typescript` 4
119
-
120
- 2020-11-03 Saša Jovanić <sasa@simplify.ba>
121
- * Version 3.2.0
122
- * Added Node 15 and removed node 13 to Travis environments
123
- * Updated various development dependencies
124
- * Test file is no longer written in TypeScript - types/chai is a problem when building for ES5
125
- * Switched from `istanbul` to `nyc` for code coverage
126
- * Added Libya as new addition to official IBAN registry
127
- * Fix crash when `isValidBIC` receives `null` or `undefined`
128
- * Added Github Build Action as preparation to move away from Travis CI
129
-
130
- 2020-06-21 Saša Jovanić <sasa@simplify.ba>
131
- * Version 3.1.0
132
- * Merged PR from @EarthlingRich (Richard Leurs) that adds `isSEPACountry` function.
133
- * Fixed RegExp for Seychelles
134
- * Added Node 14 to Travis environments
135
-
136
- 2020-04-05 Saša Jovanić <sasa@simplify.ba>
137
- * Version 3.0.0
138
-
139
- 2020-03-31 Saša Jovanić <sasa@simplify.ba>
140
- * Updated some dev dependencies
141
-
142
- 2020-03-29 Saša Jovanić <sasa@simplify.ba>
143
- * Merged #18 - Drop country names from output - PR from @eemeli (Eemeli Aro) that removes country names from functions output. Country code is still present. This will reduce total bundle size. If you still need country names, please use `countrynames` or `country-iso` packages.
144
- * Merged various dependabot pull requests.
145
- * Added prettier as dev dependency.
146
- * Upgraded dependencies based on `npm audit`.
147
- * Added node 13 and dropped node 11 on Travis.
148
- * Added Egypt as new addition to official IBAN specification.
149
- * Added countries that are not in official IBAN specification published by Swift: Algeria, Angola, Benin, Burkina Faso, Burundi, Cameroon, Cape Verde, Iran, Ivory Coast, Madagascar, Mali, Mozambique, Senegal, Comoros, Chad, Gabon, Honduras, Morocco, Nicaragua, Niger, Togo, Central African Republic, Djibouti, Equatorial Guinea and Guinea-Bissau.
150
-
151
- 2019-08-12 Saša Jovanić <sasa@simplify.ba>
152
- * Released varsion 2.2.0
153
- * Fixed Swift register PDF link on README file
154
- * Fixed problem with invalid IBAN checksum structure (GH16)
155
- * When checking if IBAN checksum is valid we will generate IBAN checksum and compare it with existing one instead of checking if result of mod97-10 is 1
156
- * Added `strict` flag to tsconfig
157
-
158
- 2019-05-05 Saša Jovanić <sasa@simplify.ba>
159
- * Updated development dependencies to latest versions
160
- * Updated deep dependencies that have security issues
161
-
162
- 2019-05-05 Saša Jovanić <sasa@simplify.ba>
163
- * Released varsion 2.1.0
164
- * Merged PR1 - Renamed `main:jsnext` to `modules` - Thanks @NeoLegends (PR1/GH9)
165
- * Upraded various packages containing security vulnerabilities using `npm audit fix`
166
- * Upgraded Gulp to version 4 and all gulp tasks
167
- * Added Vatican City State (GH13)
168
- * `friendlyFormatIBAN` and `electronicFormatIBAN` will return `null` when non-string value is provided (GH15).
169
- * Fixed issue with `extractBIC` when argument is provided in lowercase (GH12).
170
-
171
- 2018-03-11 Saša Jovanić <sasa@simplify.ba>
172
- * Released version 2.0.0
173
- * BREAKING: `isValidIBAN` does not accept IBAN with `-` and ` ` any more - IBAN must be already in electronic format
174
- * `getCountrySpecifications` now returns all countries (ISO-3166-1 alpha-2 + `XK` - temporary country code for Kosovo) with `IBANRegistry` boolean property that indicates if country is in IBAN registry or not
175
- * `extractIBAN` now requires IBAN in electronic format
176
- * `isValidBIC` now also checks if Country exists
177
- * `extractBIC` also returns property `countryCode`
178
- * Added `tslint` as development dependency
179
-
180
- 2018-02-13 Saša Jovanić <sasa@simplify.ba>
181
- * Released version 1.6.0
182
- * Fixed link to latest IBAN registry PDF document
183
- * Fixed validation for Costa Rica (it has 18 digits now, not 17)
184
- * Added Republic of Belarus
185
- * Added Iraq
186
- * Renamed `Palestinian teritories` to `State of Palestine`, as in IBAN registry
187
- * Added El Salvador
188
- * Updated develpoment dependencies
189
- * `ExtractIBANResult` now also contains `iban` that represents IBAN electronic format
190
- * `electronicFormatIBAN` now removes only spaces and dashes, not the other unicode characters
191
-
192
- 2017-11-15 Saša Jovanić <sasa@simplify.ba>
193
- * Released version 1.5.1
194
- * Fixed mistake in BIC validation regexp when brach code is present (GH-5)
195
- * Added node.js 9 to TravisCI
196
-
197
- 2017-10-10 Saša Jovanić <sasa@simplify.ba>
198
- * Released version 1.5.0
199
- * Fixed typos in source code and documentation (GH-4)
200
-
201
- 2017-10-05 Saša Jovanić <sasa@simplify.ba>
202
- * Changed documentation theme to `docdash`
203
- * Fixed links in README to avoid broken links in documentation
204
- * Updated `coverals` package
205
-
206
- 2017-10-05 Saša Jovanić <sasa@simplify.ba>
207
- * Released version 1.4.0
208
- * Added code of conduct
209
- * Updated mocha development dependency to 4.0
210
- * Added contribution guide
211
- * Updated JSDoc to latest version
212
- * Added issue and pull request template
213
-
214
- 2017-08-23 Saša Jovanić <sasa@simplify.ba>
215
- * Now using @types - typings removed
216
-
217
- 2017-08-22 Saša Jovanić <sasa@simplify.ba>
218
- * Updated development dependencies
219
- * Added node version 8 to TravisCI tests
220
-
221
- 2017-03-09 Saša Jovanić <sasa@simplify.ba>
222
- * Released version 1.3.0
223
- * Fixed `jsnext:main` file output
224
- * Fixed problem with BIC/SWIFT validation when branch code is part of BIC/SWIFT
225
- * extractBIC will return `branchCode` as '619' (primary office) if branch code in not part of BIC/SWIFT number
226
- * Fixed README file
227
- * Updated development dependencies
228
-
229
- 2017-02-04 Saša Jovanić <sasa@simplify.ba>
230
- * Released version 1.2.0
231
- * Added BIC/SWIFT validation
232
- * Added BIC/SWIFT extraction
233
- * Updated TypeScript definitions
234
-
235
- 2017-01-29 Saša Jovanić <sasa@simplify.ba>
236
- * Removed testing on Node 4 and 5 in TravisCI and added testing on 7
237
- * Updated dev dependencies
238
- * Removed TSLint deprecations
239
- * Fixed ducumentation
240
-
241
- 2016-08-30 Saša Jovanić <sasa@simplify.ba>
242
- * Removed CodeCov codes
243
- * Added Coveralls badge and integration
244
- * Added Dependency CI badge
245
-
246
- 2016-08-27 Saša Jovanić <sasa@simplify.ba>
247
- * Released version 1.1.0
248
- * Added Sao Tome And Principe (ST)
249
- * Added Saint Lucia (LC)
250
- * Added Aland Islands (AX)
251
- * Added French Guyana (GF)
252
- * Added Guadeloupe (GP)
253
- * Added Martinique (MQ)
254
- * Added Reunion (RE)
255
- * Added French Polynesia (PF)
256
- * Added French Southern Territories (TF)
257
- * Added Mayotte (YT)
258
- * Added New Caledonia (NC)
259
- * Added Saint Barthelemy (BL)
260
- * Added Saint Martin (MF)
261
- * Added Saint Pierre et Miquelon (PM)
262
- * Added Wallis and Futuna Islands (WF)
263
- * Added Seychelles (SC)
264
- * Fixed Republic of Azerbaijan and Jordan regexps
265
- * Fixed some of the country names
266
- * Added Node 6 to Travis CI
267
- * Added Codecov to Travis CI config file
268
- * Added this ChangeLog
269
- * Updated development dependencies and typings
270
- * Removed old script that used to retrive IBAN countries and codes from Wikipedia