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

ibankit

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ibankit - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

1

lib/bbanStructure.d.ts

@@ -12,2 +12,3 @@ import { BbanStructurePart, PartType } from "./structurePart";

extractValue(bban: string, partType: PartType): string | null;
extractValueMust(bban: string, partType: PartType): string;
static forCountry(countryCode: CountryCode | string | undefined): BbanStructure | null;

@@ -14,0 +15,0 @@ static getEntries(): BbanStructure[];

@@ -40,1 +40,3 @@ export declare enum FormatViolation {

}
export declare class RequiredPartTypeMissing extends Error {
}

5

lib/exceptions.js

@@ -52,2 +52,5 @@ "use strict";

exports.InvalidCheckDigitException = InvalidCheckDigitException;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhjZXB0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9leGNlcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBWSxlQWdDWDtBQWhDRCxXQUFZLGVBQWU7SUFDekIsMkRBQU8sQ0FBQTtJQUVQLDZEQUFRLENBQUE7SUFDUiwrREFBUyxDQUFBO0lBQ1QsaUZBQWtCLENBQUE7SUFDbEIsbUdBQTJCLENBQUE7SUFHM0IsaUhBQWtDLENBQUE7SUFDbEMscUhBQW9DLENBQUE7SUFDcEMseUZBQXNCLENBQUE7SUFFdEIsNkZBQXdCLENBQUE7SUFDeEIscUhBQW9DLENBQUE7SUFDcEMsb0ZBQW1CLENBQUE7SUFFbkIsc0ZBQW9CLENBQUE7SUFHcEIsMEZBQXNCLENBQUE7SUFDdEIsNEZBQXVCLENBQUE7SUFDdkIsb0VBQVcsQ0FBQTtJQUNYLHNHQUE0QixDQUFBO0lBQ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BQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO0lBQ3ZCLENBQUM7Q0FDRjtBQWpCRCwwQ0FpQkM7QUFFRCxNQUFhLDJCQUE0QixTQUFRLEtBQUs7SUFHcEQsWUFBWSxHQUFXLEVBQUUsTUFBZTtRQUN0QyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDWCxJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztJQUN2QixDQUFDO0NBQ0Y7QUFQRCxrRUFPQztBQUVELE1BQWEsMEJBQTJCLFNBQVEsS0FBSztJQUluRCxZQUFZLEdBQVcsRUFBRSxRQUFpQixFQUFFLE1BQWU7UUFDekQsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBRVgsSUFBSSxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUM7UUFDekIsSUFBSSxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUM7SUFDdkIsQ0FBQztDQUNGO0FBVkQsZ0VBVUM7QUFFRCxNQUFhLHVCQUF3QixTQUFRLEtBQUs7Q0FBRztBQUFyRCwwREFBcUQifQ==
{
"name": "ibankit",
"version": "1.1.1",
"version": "1.1.2",
"description": "IBAN and BIC utilities",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

import { CharacterType, BbanStructurePart, PartType } from "./structurePart";
import { CountryCode } from "./country";
import { FormatException, FormatViolation } from "./exceptions";
import {
FormatException,
FormatViolation,
RequiredPartTypeMissing,
} from "./exceptions";

@@ -10,26 +14,11 @@ /**

return (
11 -
(value
.split("")
.reverse()
.reduce((acc, s, idx) => acc + parseInt(s, 10) * weights[idx], 0) %
11)
(11 -
(value
.split("")
.reduce((acc, s, idx) => acc + parseInt(s, 10) * weights[idx], 0) %
11)) %
11
);
}
/*
** Return a function that is a MOD11 national check digit checker
*/
function nationalFactory(weights: number[]) {
return (bban: string, structure: BbanStructure) => {
const accountNumber = structure.extractValue(bban, PartType.ACCOUNT_NUMBER);
if (accountNumber === null) {
throw new FormatException(FormatViolation.NOT_EMPTY, "account number");
}
return String(mod11(accountNumber, weights));
};
}
/**

@@ -529,3 +518,9 @@ * Class which represents bban structure

CharacterType.n,
nationalFactory([5, 4, 3, 2, 7, 6, 5, 4, 3, 2]),
(bban: string, structure: BbanStructure) => {
const value = [PartType.BANK_CODE, PartType.ACCOUNT_NUMBER]
.map(p => structure.extractValueMust(bban, p))
.join("");
return String(mod11(value, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]));
},
),

@@ -715,2 +710,17 @@ ),

/**
* Return part type or fail
*/
extractValueMust(bban: string, partType: PartType): string {
const value = this.extractValue(bban, partType);
if (value === null) {
throw new RequiredPartTypeMissing(
`Required part type [${partType}] missing`,
);
}
return value;
}
/**
* @param countryCode the country code.

@@ -717,0 +727,0 @@ * @return BbanStructure for specified country or null if country is not supported.

@@ -74,1 +74,3 @@ export enum FormatViolation {

}
export class RequiredPartTypeMissing extends Error {}

Sorry, the diff of this file is too big to display

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