@trustpayments/ts-iin-lookup 2.0.635 → 2.0.636

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.
@@ -0,0 +1,6 @@
1
+ import { BrandDetailsType, CardTreeType } from './types';
2
+ declare const CARD_TREE: CardTreeType;
3
+ declare const BRAND_MAPPING: {
4
+ [key: string]: BrandDetailsType;
5
+ };
6
+ export { CARD_TREE, BRAND_MAPPING };
@@ -1,69 +1,60 @@
1
- export declare type BrandDetailsType = {
2
- type: string;
3
- luhn?: boolean;
4
- length?: number[];
5
- cvcLength?: number[];
6
- format?: string;
7
- };
8
-
9
- export declare interface IBinLookupConfigType {
10
- defaultCardType: string;
11
- minMatch: number;
12
- maxMatch: number;
13
- supported: string[];
14
- }
15
-
16
- export declare class IinLookup {
17
- readonly minMatch: number;
18
- readonly maxMatch: number;
19
- readonly supported: string[];
20
- readonly default: BrandDetailsType | null;
21
- constructor(config?: IBinLookupConfigType);
22
- /**
23
- * Lookup the type of a card
24
- * @param number Card number to lookup
25
- * @return BrandDetails for the brand identified
26
- */
27
- lookup(number: string): BrandDetailsType;
28
- /**
29
- * ForEachBreak helper function that only runs over supported brands
30
- * @param callback Callback to run over the supported brands
31
- * @return first truthy result of the callback or null
32
- */
33
- private forEachBreakBrands;
34
- /**
35
- * All text brand names the wywtem knows about
36
- * @return array of all text brand names
37
- */
38
- private getAllBrands;
39
- /**
40
- * Test if a brand is supported with the current configuration
41
- * @param brand the brand to lookup
42
- * @return Whether this brand is supported
43
- */
44
- private isSupported;
45
- /**
46
- * Look up a brand given it's text name (rather than the internal ID)
47
- * @param type The name of the brand to get the details for
48
- * @return The details about the named brand
49
- */
50
- private getCard;
51
- /**
52
- * Tree key searching function
53
- * @param number Card number to check against this key
54
- * @param key Search key to test against
55
- * @return whether the card number matches this key
56
- */
57
- private matchKey;
58
- /**
59
- * Recursive lookup helper function
60
- * @param number Card number to lookup
61
- * @param tree Recursively searched tree branch
62
- * @return The succesfully found brand for this card number or null
63
- */
64
- private recursiveLookup;
65
- }
66
-
67
- export declare const iinLookup: IinLookup;
68
-
69
- export { }
1
+ import { BrandDetailsType } from './types';
2
+ export type { BrandDetailsType };
3
+ export interface IBinLookupConfigType {
4
+ defaultCardType: string;
5
+ minMatch: number;
6
+ maxMatch: number;
7
+ supported: string[];
8
+ }
9
+ declare class IinLookup {
10
+ readonly minMatch: number;
11
+ readonly maxMatch: number;
12
+ readonly supported: string[];
13
+ readonly default: BrandDetailsType | null;
14
+ constructor(config?: IBinLookupConfigType);
15
+ /**
16
+ * Lookup the type of a card
17
+ * @param number Card number to lookup
18
+ * @return BrandDetails for the brand identified
19
+ */
20
+ lookup(number: string): BrandDetailsType;
21
+ /**
22
+ * ForEachBreak helper function that only runs over supported brands
23
+ * @param callback Callback to run over the supported brands
24
+ * @return first truthy result of the callback or null
25
+ */
26
+ private forEachBreakBrands;
27
+ /**
28
+ * All text brand names the wywtem knows about
29
+ * @return array of all text brand names
30
+ */
31
+ private getAllBrands;
32
+ /**
33
+ * Test if a brand is supported with the current configuration
34
+ * @param brand the brand to lookup
35
+ * @return Whether this brand is supported
36
+ */
37
+ private isSupported;
38
+ /**
39
+ * Look up a brand given it's text name (rather than the internal ID)
40
+ * @param type The name of the brand to get the details for
41
+ * @return The details about the named brand
42
+ */
43
+ private getCard;
44
+ /**
45
+ * Tree key searching function
46
+ * @param number Card number to check against this key
47
+ * @param key Search key to test against
48
+ * @return whether the card number matches this key
49
+ */
50
+ private matchKey;
51
+ /**
52
+ * Recursive lookup helper function
53
+ * @param number Card number to lookup
54
+ * @param tree Recursively searched tree branch
55
+ * @return The succesfully found brand for this card number or null
56
+ */
57
+ private recursiveLookup;
58
+ }
59
+ declare const iinLookup: IinLookup;
60
+ export { iinLookup, IinLookup };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ type Brand = number;
2
+ type CardTreeNode = CardTreeType | Brand;
3
+ type CardTreeType = {
4
+ D?: Brand;
5
+ [key: string]: CardTreeNode;
6
+ };
7
+ type BrandDetailsType = {
8
+ type: string;
9
+ luhn?: boolean;
10
+ length?: number[];
11
+ cvcLength?: number[];
12
+ format?: string;
13
+ };
14
+ export { Brand, CardTreeNode, CardTreeType, BrandDetailsType };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Utils method class
3
+ */
4
+ export default class Utils {
5
+ /**
6
+ * Test if item is in array
7
+ * @param array An array of items
8
+ * @param item the item to test for
9
+ * @return boolean Whether the item is i the array
10
+ */
11
+ static inArray<T>(array: ArrayLike<T>, item: T): boolean;
12
+ /**
13
+ * This is a custom implementation of Array.some which returns the first
14
+ * truthy response rather than boolean
15
+ * @param iterable The iterable to iterate over
16
+ * @param callback A callback function to find the result
17
+ * @return returnType The first non-falsy return value of the callback function or null
18
+ */
19
+ static forEachBreak<TInputType, TReturnType>(iterable: ArrayLike<TInputType>, callback: (item: TInputType) => TReturnType): TReturnType | null;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustpayments/ts-iin-lookup",
3
- "version": "2.0.635",
3
+ "version": "2.0.636",
4
4
  "description": "Perform an IIN lookup to determine the credit card type",
5
5
  "author": "Trust Payments <support@trustpayments.com>",
6
6
  "homepage": "https://docs.trustpayments.com",
@@ -38,5 +38,5 @@
38
38
  "test": "vitest run",
39
39
  "type-check": "tsc --noEmit"
40
40
  },
41
- "gitHead": "9b07b760b1bee74cdf18aacbbb1c2480aa0ba733"
41
+ "gitHead": "d0b16a436a2f83cfab9553ff3043a0b86c84d7c8"
42
42
  }