-
Notifications
You must be signed in to change notification settings - Fork 2
chore(POCP-1226): support 8-digit IINs in card event #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
25cf56a
a1bf701
1f3179d
7b3e367
51e82b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -455,10 +455,55 @@ module ProcessOut { | |
| public static getIIN(number: string): string { | ||
| number = Card.parseNumber(number); // Remove potential spaces | ||
|
|
||
| var l = number.length; | ||
| if (l > 6) | ||
| l = 6; | ||
| return number.substring(0, l); | ||
| if (number.length < 6) | ||
| return number; | ||
|
|
||
| // Only expose an 8-digit IIN when PCI rules allow it: the scheme | ||
| // must permit it and the full PAN must be exactly 16 digits. | ||
| // Everything else caps at 6 to avoid over-exposing the BIN. | ||
| // Mirrors binder's TruncateNumber / api (controllers/card_inn.go). | ||
| if (Card.canExpose8DigitIIN(number)) | ||
| return number.substring(0, 8); | ||
|
|
||
| return number.substring(0, 6); | ||
| } | ||
|
|
||
| /** | ||
| * Schemes permitted to surface an 8-digit IIN, mirroring the backend | ||
| * allow-list in api (controllers/card_inn.go). Every other scheme - | ||
| * notably American Express - is capped at 6 digits. Note the JS | ||
| * scheme key "union-pay" maps to the backend's "china union pay". | ||
| */ | ||
| private static iin8DigitSchemes: Array<string> = [ | ||
| "visa", "mastercard", "discover", "jcb", "union-pay", "carte bancaire" | ||
| ]; | ||
|
|
||
| /** | ||
| * canExpose8DigitIIN reports whether an 8-digit IIN may be surfaced | ||
| * for the given card number. Mirrors binder's TruncateNumber: the PAN | ||
| * must be exactly 16 digits and every detected scheme must be in the | ||
| * allow-list. Conservative on co-badged or ambiguous prefixes (and | ||
| * unknown schemes), which fall back to 6 digits. | ||
| * @param {string} number | ||
| * @return {boolean} | ||
| */ | ||
| public static canExpose8DigitIIN(number: string): boolean { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Binder also does one extra check which I don't think API does: https://github.com/processout/binder/blob/master/services/binder/iindb/transformer.go#L42 It double checks the length https://www.pcisecuritystandards.org/faqs/1091/
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| number = Card.parseNumber(number); // Remove potential spaces | ||
|
|
||
| // PCI: 8-digit BINs are only defined for 16-digit PANs. | ||
| if (number.length != 16) | ||
| return false; | ||
|
|
||
| var schemes = Card.getPossibleSchemes(number); | ||
| if (schemes.length == 0) | ||
| return false; | ||
|
|
||
| for (var i = 0; i < schemes.length; i++) { | ||
| if (Card.iin8DigitSchemes.indexOf(schemes[i]) === -1) | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.