@trustpayments/ts-iin-lookup 2.0.621 → 2.0.622

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.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={2:{21:{2184415:1},22:{225:{2250:{225062108:2,225062109:2}},226:{2260:{226002088:2,226002089:2},2265:{226500:2,226508:2}},227:{227001097:{"2270010975-2270010979":2},227001098:2,227001099:2,"227001090-227001094":{"2270010900-2270010944":2},"227001094-227001095":{"2270010945-2270010959":2},"227001096-227001097":{"2270010960-2270010974":2}},228:{228002157:{"2280021575-2280021579":2},228002158:2,228002159:2,"228002150-228002154":{"2280021500-2280021544":2},"228002154-228002155":{"2280021545-2280021559":2},"228002156-228002157":{"2280021560-2280021574":2}},229:{2290:{229001058:2,229001059:2}}},23:{230:{2300:{230026:2},2304:{230491:2},2305:{230540:2}},231:{23100:{231009:2},23101:{231013:2,231014:2,231019:2},23102:{231021:2,231022:2,231023:2,231024:2},23103:{231032:2,231038:2},23104:{231041018:2,231041019:2}},232:{2321:{23212030:2},2322:{232200:2}},234:{2340:{23400:2}},235:{23500:{235001:2,235002:2,235003:2,235004:2},23501:{235015:2},23502:{235020058:2,235020059:2}},236:{236e3:2,236001:2,236002:2,236003:{236003e3:2},236004:{23600400:2},236006:{2360060:2,2360061:2},236007:{23600701:2},236008:{236008288:2,236008289:2}},237:{237e3:{237e4:2,2370001:2},237003:{237003078:2,237003079:2}},238:{238e3:2,238006:{2380060:2,2380061:2,2380062:2,2380063:2},238007:{238007388:2,238007389:2}},239:{239000097:{"2390000975-2390000979":2},239000098:2,239000099:2,"239000090-239000094":{"2390000900-2390000944":2},"239000094-239000095":{"2390000945-2390000959":2},"239000096-239000097":{"2390000960-2390000974":2}}},24:{240:{240010:2,240011:2,240013:{240013048:2,240013049:2}},241:{241e3:2,241001:{241001448:2,241001449:2}},242:{242000027:{"2420000275-2420000279":2},242000028:2,242000029:2,"242000020-242000024":{"2420000200-2420000244":2},"242000024-242000025":{"2420000245-2420000259":2},"242000026-242000027":{"2420000260-2420000274":2}},243:{243002097:{"2430020975-2430020979":2},243002098:2,243002099:2,"243002090-243002094":{"2430020900-2430020944":2},"243002094-243002095":{"2430020945-2430020959":2},"243002096-243002097":{"2430020960-2430020974":2}},244:{24400:{244006:2,244009:2},24401:{244014:2,244015:2}},245:{245001077:{"2450010775-2450010779":2},245001078:2,245001079:2,"245001070-245001074":{"2450010700-2450010744":2},"245001074-245001075":{"2450010745-2450010759":2},"245001076-245001077":{"2450010760-2450010774":2}},246:{246002:{246002038:2,246002039:2}}},25:{250:{25e3:{250006:2},25001:{250013:2},25002:{250023:2,250029:2},25003:{250030:2,250031:2,250033:2,250034:2},25004:{250042:2,250043:2,250044:2,250048:2,250049:2},25005:{250051:2,250052:2,250053:2,250054:2,250058:2},25006:{250060:2,250061:2,250062:2,250063:2,250064:2,250065:2,250068:2},25007:{250072:2,250074:2},25008:{250083:2,250084:2,250085:2}},252:{25250:{252500:2,252502:2,252503:2},25252:{252525:2}},256:{"256000010-256000012":{"2560000100-2560000125":2},"256000012-256000014":{"2560000126-2560000140":2},"256000014-256000015":{"2560000141-2560000155":2},"256000015-256000017":{"2560000156-2560000170":2},"256000017-256000018":{"2560000171-2560000185":2},"256000018-256000019":{"2560000186-2560000199":2}}},26:{260:{26e3:{26e4:2,260001:2,260002:2,260004:2,260008:2},26001:{260014:2}},262:{2626e5:2},265:{26500501:2,26500502:2,26500503:2,26500504:2,26500505:2,26500506:2},266:{266e5:2},267:{2672e4:2}},27:{270:{2708:{270833:2}},271:{2710:{27100200:2},2716:{271679:2},2718:{271832:2}},272:{2720980:{27209800:2,27209801:2,27209802:2,27209803:2,27209807:2},2720981:{27209813:2,27209819:2},2720982:{27209821:2},2720983:{27209831:2,27209836:2},2720986:{27209863:2,27209866:2,27209867:2},2720987:{27209875:2,27209878:2},2720988:{27209880:2,27209881:2}}},"22-27":{"2221-2720":2}},3:{30:{308:{308950:3},309:{3095:4},"300-305":4,"308-309":{"3088-3094":5}},31:{315:{"3158-3159":5},"311-312":{"3112-3120":5}},33:{"3337-3349":5},34:6,35:{357:{357266:5},"352-358":{"3528-3589":5}},36:{360:{3607:{"360765-360766":7},3609:{360966:7}},361:{3613:{36135:7},3619:{361911:7}},364:{3643:{"364304-364305":7},3649:{"364940-364942":7}},365:{365539:7},367:{36712:{367123:7,"367126-367127":7},36713:{"367132-367133":7},"36713-36714":{"367139-367140":7}},368:{368357:7},369:{369620:7},D:4},37:{D:6},"30-31":{"3096-3102":5},"38-39":4},4:{40:{400:{4004:{40045:8}}},42:{420:{4205:{42051:8,42053:8}},423:{4234:{42340:8,42341:8}},425:{4256:{42563:8,42564:8}}},43:{431:{4319:{"43193-43197":8}},435:{4352:{43528:8}},437:{4372:{437295:8}},438:{4380:{43800:8,43801:8,43802:8,43803:8}}},44:{443:{4430:{44304:8,44306:8}},446:{4462:{D:8}}},45:{450:{4503:{45033:8},4505:{45055:8}},451:{4515:{451502:8,451503:8,451504:8,451505:8,451506:8}},452:{4526:{45260214:8}},453:{4534:{45340:8,45343:8,45345:8,45346:8,45347:8,45348:8,45349:8},4537:{45370:8},4538:{45385:8}},457:{4576:{45767:8},4579:{45795:8}},459:{"4596-4597":8}},46:{461:{4618:{461805:8,461806:8,461807:8,461808:8}},463:{4632:{46327:8,46328:8},4635:{46354:8,46358:8}},464:{4640:{46407:8},4648:{46488:8}},465:{4650:{46503:8,46506:8,46508:8},4658:{"46583-46587":8}},466:{4668:{466800:8,466803:8,466804:8}},468:{4683:{468300:8}},469:{4691:{46911:8,46912:8}}},47:{470:{4708:{47080:8,47081:8}},471:{4711:{471100:8}},474:{4744:{47448:8}},475:{4751:{"47511-47515":8},4753:{475394:8},4757:{"47571-47575":8}},476:{4762:{"47622-47626":8},4763:{"47634-47638":8}}},48:{480:{4805:{480500010:8}},482:{4827:{482751:8}},485:{4858:{485802:8,485804:8}},487:{4878:{48782:8}}},49:{490:{4909:{"49096-49097":8}},492:{4922:{49222:8,49226:8},4923:{"49238-49239":8}},493:{4935:{49351:8},4937:{49379:8}},498:{4986:{49860:8}},499:{4992:{499200:8},4996:{"4996840-4996844":8},4998:{49986:8}}},D:8},5:{50:{500:{5e3:{500033:1},5001:{"5001385000":1},5004:{500443:1},5005:{500539:1},5006:{"5006300-5006306":1}},501:{5010:{50102:1}},502:{5023:{502312:1},5025:{502502:1},5026:{502697:1},5028:{502820:1}},503:{5031:{503140:1,503141:1,503144:1},5032:{503223:1},5034:{503444:1},5035:{503563:1,503565:1},5038:{503871:1}},504:{5040:{50405:1,50406:1},5041:{504152:1,504155:1,504157:1}},505:{5057:{50573:1},5058:{505826:1}},508:{5082:{508226:1}},D:1},51:{514:{5144:{D:2}},516:{"5167-5169":{"51673-51697":2}},517:{5170:{"51700-51704":2}},518:{5183:{51838:2}}},52:{520:{5208:{52080:2,52086:2}},521:{5210:{52100:2},5214:{52145:2,52146:2},5219:{52190:2,52191:2,52192:2,52193:2}},525:{5251:{52514:2,52518:2,52519:2},5252:{52525:2},5257:{52570:2},5258:{52589:2}},527:{5279:{52794:2,52796:2}},529:{5296:{52965:2,52968:2}}},53:{530:{5301:{53016:2},5308:{53089:2}},532:{5321:{53217:2}},534:{5348:{53486:2,53487:2}},535:{"5351-5353":{"53511-53530":2},"5354-5358":{"53542-53581":2}},538:{5382:{53820001:2},5383:{538399:2},5385:{53853500:2,53853501:2,53853502:2,53853503:2,53853504:2,53853505:2,53853506:2,53853507:2},5386:{53868:2}}},54:{544:{5441:{54410:2}},546:{5469:{54690:2,54694:2,54698:2}}},55:{557:{5578:{55785:2},"5573-5574":{"557347-557496":2},"5574-5575":{"557498-557547":2}},559:{5591:{D:2},5594:{D:2}}},56:{560:{5600:{560054:1}},561:{5614:{561448:1}},562:{562534:1},563:{5635600:1,5635601:1},564:{5642:{564222:1},5644:{56441100:1}},565:{565151:1},566:{5664:{566458:1},5666:{566607:1},5669:{566973:1}},567:{5670:{567062:1},5673:{567327:1},5677:{567730:1,567731:1,567733:1,567734:1},5678:{567811:1}},568:{5680:{568096:1},5682:{568217:1},5685:{568532:1},5686:{568616:1}}},57:{570:{5704:{570402:1},5705:{570586:1}},571:{571760:1},572:{5720:{572034:1,572038:1},5721:{572197:1},5726:{572622:1}},573:{5730:{573087:1},5732:{573271:1}},574:{574933:1},575:{5753:{575308:1},5755:{5755322:1}},577:{5770:{577069:1},5772:{577251:1},5774:{577464:1},5777:{577765:1},5778:{5778762:1}},579:{5791:{579164:1}}},58:{580:{5800:{580051:1,580059:1},5801:{580122:1},5809:{580919:1}},581:{5815:{581508:1}},582:{5820:{582090:1,582093:1},5822:{582234:1,582238:1},5823:{582304:1},5824:{582411:2},5827:{582718:1},5828:{"58281601-58281699":1}},583:{5835:{583592:1},5838:{5838776:1}},584:{5843:{584320:1},5844:{584414:1}},585:{5850:{585014:1},5851:{585176:1},5859:{585948:1}},586:{5860:{586085:1},5865:{586555:1}},587:{5870:{5870939:1},5872:{587256:1},5874:{58746:1},5875:{587588:1},5879:{587993:1}},588:{5880:{588060:1,588067:1},5881:{588165:1,588166:1,588167:1},5882:{588267:1},5883:{588325:1},5889:{588969:1}},589:{5890:{589004:1}}},59:{594774:2},"51-55":2},6:{60:{600:{6002:{600296:1},6007:{"6007938004":1}},601:{6011:{60110:7,"60112-60114":7},6012:{601287:1,601288:1}},603:{6035:{603555:1}},604:{6047:{604779:1}},605:{6051:{605141:1},6056:{605661:1},6058:{605839:1}},606:{6061:{606144:1}},608:{6086:{608699:1},6087:{608710:1}}},61:{612:{6128895:1},616:{616788:1}},62:{621:{6218:{62183:1,62186:1,62188:1}},622:{6220:{622092:1},"6221-6229":{"622126-622925":7}},627:{6272:{627252:1,627254:1},6278:{627801:1,627802:1}},"624-626":7},63:{633:{633857:1},636:{6360:{636093:1,636095:1},6365:{636548:1},6367:{636708:1}},637:{6375:{637529:1}},639:{6394:{639489:1},6396:{"6396440002":1,"6396440003":1},6397:{639781:1}}},64:{640:{6400:{640005:1},6404:{640475:1},6406:{640614:1}},641:{641377:1},642:{6420:{642097:1,642098:1}}},65:{652:{6524:{"65240-65241":7},"6522-6523":{"652299-652300":7},"6528-6529":{"652897-652904":7}},658:{6587:{"65878700-65878701":7}}},67:{670:{6700:1,6701:1,6702:1,6703:{67033:1}},671:{6710:{67102:1}},672:{6720:1,6722:{67220:1,67222:1,67224:1,67226:1,67228:1},6723:1,6724:1,6726:{67260:1,67261:1,67263:1,67264:1,67265:1,67266:1,67267:1,67268:1,67269:1},6729:{67290:1,67291:1,67292:1,67293:1,67294:1,67295:1,67296:1,67297:1,67298:1}},673:{6733:{673333:1,673334:1,673336:1,673337:1,673338:1},6734:{673400:1,673401:1},6736:{673675:1}},674:{6744:{67447:1}},675:{6757:{675753:1},6759:{"67594100-67594108":1}},676:{6760:{676067:1}},678:{6782:{6782950:1,6782951:1,6782952:1},6784:{678424:1},6787:{678702:1}}},69:{6900:{"6900460456":1}},"64-65":{"644-659":7}},7:{706159:2},9:{91:{918:{918838:2}},98:{988:{98832:{988328:2,988329:2},98833:{988330:2},98838:{988388:2}}}},"5-6":{"56-69":1}},t={1:{type:`MAESTRO`,format:`(\\d{1,4})(\\d{1,4})?(\\d{1,4})?(\\d+)?`,length:[13,14,15,16,17,18,19],cvcLength:[3],luhn:!1},2:{type:`MASTERCARD`,format:`(\\d{1,4})(\\d{1,4})?(\\d{1,4})?(\\d+)?`,length:[16],cvcLength:[3],luhn:!0},3:{type:`PIBA`,format:`(\\d{1,4})(\\d{1,4})?(\\d{1,4})?(\\d+)?`,length:[19],cvcLength:[0],luhn:!0},4:{type:`DINERS`,format:`(\\d{1,4})(\\d{1,6})?(\\d+)?`,length:[14,15,16,17,18,19],cvcLength:[3],luhn:!0},5:{type:`JCB`,format:`(\\d{1,4})(\\d{1,4})?(\\d{1,4})?(\\d+)?`,length:[15,16,19],cvcLength:[3],luhn:!0},6:{type:`AMEX`,format:`(\\d{1,4})(\\d{1,6})?(\\d+)?`,length:[15],cvcLength:[4],luhn:!0},7:{type:`DISCOVER`,format:`(\\d{1,4})(\\d{1,4})?(\\d{1,4})?(\\d+)?`,length:[14,15,16,17,18,19],cvcLength:[3],luhn:!0},8:{type:`VISA`,format:`(\\d{1,4})(\\d{1,4})?(\\d{1,4})?(\\d+)?`,length:[13,16,19],cvcLength:[3],luhn:!0}},n=class{static inArray(e,t){return Array.from(e).indexOf(t)>=0}static forEachBreak(e,t){let n=null,r=e.length;for(let i=0;i<r;i++)if(i in e){let r=t(e[i]);if(r){n=r;break}}return n}},r=class{constructor(e){let t={defaultCardType:``,minMatch:0,maxMatch:6,supported:[]};if(e=e||t,this.minMatch=Object.prototype.hasOwnProperty.call(e,`minMatch`)?e.minMatch:t.minMatch,this.maxMatch=Object.prototype.hasOwnProperty.call(e,`maxMatch`)?e.maxMatch:t.maxMatch,this.supported=this.getAllBrands(),e?.supported?.length){let{supported:t}=e;t.forEach(e=>{if(!this.isSupported(e))throw Error(`unsupported CARD_TREE ${e}`)}),this.supported=t}this.default=`defaultCardType`in e?this.getCard(e.defaultCardType):null}lookup(n){let r={type:``};if(n.length>=this.minMatch){let i=t[this.recursiveLookup(n,e)];this.isSupported(i)&&(r=i)}return!r.type&&this.default&&n.length<=this.maxMatch&&(r=this.default),r}forEachBreakBrands(e){return n.forEachBreak(Object.values(t),t=>{if(this.isSupported(t))return e(t)})}getAllBrands(){return Object.values(t).map(e=>e.type).sort()}isSupported(e){return e instanceof Object&&(e=e.type),n.inArray(this.supported,e)}getCard(e){return this.forEachBreakBrands(t=>{if(t.type===e)return t})}matchKey(e,t){let r=e.substring(0,t.length)===t;if(!r&&n.inArray(t,`-`)){let n=t.split(`-`),i=parseInt(e.substring(0,n[1].length),10);parseInt(n[0],10)<=i&&i<=parseInt(n[1],10)&&(r=!0)}return r}recursiveLookup(e,t){if(!(t instanceof Object))return t;let r=Object.keys(t).filter(t=>this.matchKey(e,t)).sort((e,t)=>e.length-t.length);return n.forEachBreak(r,n=>this.recursiveLookup(e,t[n]))||t.D||null}},i=new r;exports.IinLookup=r,exports.iinLookup=i;
@@ -1,59 +1,69 @@
1
- import { BrandDetailsType } from "./types";
2
- export interface IBinLookupConfigType {
3
- defaultCardType: string;
4
- minMatch: number;
5
- maxMatch: number;
6
- supported: string[];
7
- }
8
- declare class IinLookup {
9
- readonly minMatch: number;
10
- readonly maxMatch: number;
11
- readonly supported: string[];
12
- readonly default: BrandDetailsType | null;
13
- constructor(config?: IBinLookupConfigType);
14
- /**
15
- * Lookup the type of a card
16
- * @param number Card number to lookup
17
- * @return BrandDetails for the brand identified
18
- */
19
- lookup(number: string): BrandDetailsType;
20
- /**
21
- * ForEachBreak helper function that only runs over supported brands
22
- * @param callback Callback to run over the supported brands
23
- * @return first truthy result of the callback or null
24
- */
25
- private forEachBreakBrands;
26
- /**
27
- * All text brand names the wywtem knows about
28
- * @return array of all text brand names
29
- */
30
- private getAllBrands;
31
- /**
32
- * Test if a brand is supported with the current configuration
33
- * @param brand the brand to lookup
34
- * @return Whether this brand is supported
35
- */
36
- private isSupported;
37
- /**
38
- * Look up a brand given it's text name (rather than the internal ID)
39
- * @param type The name of the brand to get the details for
40
- * @return The details about the named brand
41
- */
42
- private getCard;
43
- /**
44
- * Tree key searching function
45
- * @param number Card number to check against this key
46
- * @param key Search key to test against
47
- * @return whether the card number matches this key
48
- */
49
- private matchKey;
50
- /**
51
- * Recursive lookup helper function
52
- * @param number Card number to lookup
53
- * @param tree Recursively searched tree branch
54
- * @return The succesfully found brand for this card number or null
55
- */
56
- private recursiveLookup;
57
- }
58
- declare const iinLookup: IinLookup;
59
- export { iinLookup, IinLookup };
1
+ 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 { }