@agent-cards/sdk 0.20.0 → 0.22.0
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/CHANGELOG.md +51 -0
- package/PREFLIGHT.md +34 -0
- package/README.md +1217 -15
- package/dist/aci.d.ts +173 -0
- package/dist/aci.generated.d.ts +87 -0
- package/dist/aci.generated.js +306 -0
- package/dist/aci.js +371 -0
- package/dist/adyen-merchant-hosted.generated.d.ts +3 -3
- package/dist/adyen-merchant-hosted.generated.js +283 -49
- package/dist/agentcard.d.ts +9 -2
- package/dist/agentcard.js +4 -2
- package/dist/amadeus-checkout.generated.d.ts +57 -0
- package/dist/amadeus-checkout.generated.js +549 -0
- package/dist/amadeus.d.ts +41 -0
- package/dist/amadeus.js +81 -0
- package/dist/builtin-registry.generated.js +1 -1
- package/dist/card-endpoint.d.ts +177 -0
- package/dist/card-endpoint.js +286 -0
- package/dist/card-fields.generated.d.ts +5 -3
- package/dist/card-fields.generated.js +284 -7
- package/dist/cdp.d.ts +6 -1
- package/dist/cdp.js +983 -147
- package/dist/client.d.ts +493 -13
- package/dist/client.js +1100 -82
- package/dist/creditguard.generated.d.ts +79 -0
- package/dist/creditguard.generated.js +662 -0
- package/dist/cse-body.js +11 -1
- package/dist/cybersource-flex.d.ts +183 -0
- package/dist/cybersource-flex.generated.d.ts +92 -0
- package/dist/cybersource-flex.generated.js +689 -0
- package/dist/cybersource-flex.js +275 -0
- package/dist/datatrans.d.ts +96 -0
- package/dist/datatrans.generated.d.ts +64 -0
- package/dist/datatrans.generated.js +426 -0
- package/dist/datatrans.js +178 -0
- package/dist/elavon-converge.d.ts +37 -0
- package/dist/elavon-converge.generated.d.ts +49 -0
- package/dist/elavon-converge.generated.js +439 -0
- package/dist/elavon-converge.js +84 -0
- package/dist/eprotect.d.ts +152 -0
- package/dist/eprotect.generated.d.ts +77 -0
- package/dist/eprotect.generated.js +498 -0
- package/dist/eprotect.js +222 -0
- package/dist/gmo.d.ts +63 -0
- package/dist/gmo.generated.d.ts +60 -0
- package/dist/gmo.generated.js +586 -0
- package/dist/gmo.js +119 -0
- package/dist/hosted-form.d.ts +3 -2
- package/dist/hosted-form.js +3 -2
- package/dist/index.d.ts +19 -3
- package/dist/index.js +6 -1
- package/dist/juspay-gate.d.ts +82 -0
- package/dist/juspay-gate.js +126 -0
- package/dist/juspay.generated.d.ts +89 -0
- package/dist/juspay.generated.js +705 -0
- package/dist/lifecycle.d.ts +62 -6
- package/dist/lifecycle.js +123 -8
- package/dist/merchant-card-endpoints.generated.d.ts +63 -0
- package/dist/merchant-card-endpoints.generated.js +1103 -0
- package/dist/merchant-hosted.d.ts +4 -1
- package/dist/merchant-hosted.js +5 -2
- package/dist/merchant-session-probe.d.ts +48 -0
- package/dist/merchant-session-probe.js +53 -0
- package/dist/merchant-session.generated.d.ts +69 -0
- package/dist/merchant-session.generated.js +919 -0
- package/dist/payrails.d.ts +133 -0
- package/dist/payrails.generated.d.ts +73 -0
- package/dist/payrails.generated.js +596 -0
- package/dist/payrails.js +305 -0
- package/dist/pelecard.d.ts +32 -0
- package/dist/pelecard.generated.d.ts +32 -0
- package/dist/pelecard.generated.js +283 -0
- package/dist/pelecard.js +42 -0
- package/dist/pre-claim.d.ts +84 -3
- package/dist/pre-claim.js +987 -9
- package/dist/preflight-catalog.json +2310 -263
- package/dist/preflight-schemas.json +187 -6
- package/dist/preflight.generated.d.ts +1 -1
- package/dist/preflight.generated.js +247 -4
- package/dist/preparation.d.ts +5 -2
- package/dist/preparation.js +36 -10
- package/dist/prepared-processor.d.ts +86 -5
- package/dist/prepared-processor.js +157 -6
- package/dist/primer.d.ts +53 -0
- package/dist/primer.generated.d.ts +38 -0
- package/dist/primer.generated.js +624 -0
- package/dist/primer.js +82 -0
- package/dist/registry.d.ts +114 -12
- package/dist/registry.js +85 -11
- package/dist/shiji-sts.d.ts +144 -0
- package/dist/shiji-sts.generated.d.ts +72 -0
- package/dist/shiji-sts.generated.js +913 -0
- package/dist/shiji-sts.js +222 -0
- package/dist/stripe-checkout.generated.d.ts +1 -1
- package/dist/stripe-checkout.generated.js +735 -10
- package/dist/stripe-setup.d.ts +16 -0
- package/dist/stripe-setup.js +61 -0
- package/dist/substitutions.generated.js +187 -29
- package/dist/verifone.d.ts +68 -0
- package/dist/verifone.generated.d.ts +51 -0
- package/dist/verifone.generated.js +1401 -0
- package/dist/verifone.js +119 -0
- package/dist/voice-types.d.ts +27 -0
- package/dist/voice.d.ts +6 -1
- package/dist/voice.js +6 -1
- package/dist/wspay.d.ts +41 -0
- package/dist/wspay.generated.d.ts +41 -0
- package/dist/wspay.generated.js +370 -0
- package/dist/wspay.js +65 -0
- package/examples/preflight/kernel-native/inventory.json +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Generated from @agent-cards/payment-core. Do not edit.
|
|
3
|
+
// artifact-sha256: a2260c2d905a5cd4ef148ab8a79e90fb2f9f6790d9efba06e95ed35f8bea2755
|
|
4
|
+
// src/cybersource-flex-rules.js
|
|
5
|
+
var CYBERSOURCE_FLEX_RULES_SOURCE = Object.freeze({ version: "2.12.1", sha256: "8429ebae83e9745cd53ad8ff0d9ba69bee0087c1435ed0695a25444bed418327" });
|
|
6
|
+
var CYBERSOURCE_FLEX_RULES = [
|
|
7
|
+
{ "name": "visa", "code": "001", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [4] },
|
|
8
|
+
{ "name": "mastercard", "code": "002", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[2221, 2720], [51, 55]] },
|
|
9
|
+
{ "name": "amex", "code": "003", "lengths": [15], "luhn": true, "securityCode": { "length": 4, "required": true }, "ranges": [34, 37] },
|
|
10
|
+
{ "name": "maestro", "code": "042", "lengths": [12, 13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [218441, 222888, 407128, 433717, 435620, 436803, [5e3, 5061], [506500, 507802], [50780351, 50780829], [5078103, 5099999], 536106, 553103, 554563, 554587, 559808, [56e7, 578097104], [578097110, 578097179], [578097186, 588771999], [588773, 601099], 60111, [601150, 601173], [601175, 601176], [601180, 601185], [601200, 603264], [60326600, 60561499], [60561600, 60976946], [60976948, 61999999], 621019, 62183, 62186, 62188, 621976, 621984, 621986, 621992, 621996, 621999, [622017, 622018], 622090, 622092, 622110, 622125, 627089, 627101, 627123, 627135, 627139, 627166, 627173, 627252, 627254, 627295, 627352, 627355, 627360, 627366, 627397, 627399, 627407, 627441, [627453, 627454], 627456, 627499, 627519, 627532, 627534, 627539, 627568, 627574, 627582, 627592, 627606, 627609, 627643, 627665, 627669, 627696, [627700, 627798], [627801, 627802], 627816, 627911, 627920, 627950, 627959, 627973, 628007, 628013, 628047, 628079, 628081, 628095, 628110, 628133, 628155, [628179, 628181], [629441, 629443], [629447, 629453], 629854, 629860, 630121, [636093, 636095], [636111, 636112], 636117, 636123, 636129, 636133, 636141, 636164, 636173, 636189, 636192, 636507, 636548, 636708, 637096, 637102, 637118, 637529, 639002, 639004, 639009, 639012, 639092, 639098, 639133, 639148, 639207, 639215, 639221, 639226, 639261, 639310, 639339, 639350, 639489, 639566, 639578, 639589, 639644, 639781, 640001, 640005, 640069, 640221, 640241, 640252, 640475, 640581, 640614, 640671, 640674, 641377, 641583, 641718, 641860, 641863, 642041, [642097, 642098], 642110, 642119, 642150, 642173, [642222, 642223], 642240, 642258, 642301, 642344, 642354, 642362, 642373, 642376, [642383, 642384], 642391, 642395, [642398, 642399], 642426, 642433, 642445, 642449, 642491, 642501, 642514, 642546, [66e4, 669008], 66900902, 66900906, [66900932, 66900936], 66900938, [66900941, 66900949], 66900958, 66900961, 66900965, [66900975, 66900978], [66900988, 66900990], 66900999, [66901001, 66901051], [66901053, 66901055], [66901058, 66901070], [66901074, 66901075], 66901077, 66901086, [66901088, 69999999], 708305, 849686] },
|
|
11
|
+
{ "name": "maestro", "code": "042", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [52e6] },
|
|
12
|
+
{ "name": "discover", "code": "004", "lengths": [16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [60110, [60112, 60114], 601174, [601177, 601179], [601186, 601199], [644e3, 653946], [653948, 659999]] },
|
|
13
|
+
{ "name": "dinersclub", "code": "005", "lengths": [14, 16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[300, 305], 3095, 36, [38, 39]] },
|
|
14
|
+
{ "name": "dinersclub", "code": "005", "lengths": [16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [6011e4] },
|
|
15
|
+
{ "name": "jcb", "code": "007", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[3088, 3094], [3096, 3102], [3112, 3120], [3158, 3159], [3337, 3349], [3528, 3589]] },
|
|
16
|
+
{ "name": "cup", "code": "062", "lengths": [12, 16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [601382, 603265, [62e4, 621018], [621020, 621985], [621987, 622017], [622019, 627243], [627245, 627294], [627296, 627396], [627398, 627534], [627536, 627699], [627799, 628180], [628182, 629999], 632062, [81e4, 817199], 900105, 900205, 90030, 90592, 9111, [94e4, 940009], [940013, 940016], [940018, 940019], [940021, 940029], [940031, 940039], [940041, 940059], [940061, 940079], [940081, 940089], [940091, 940099], 9551, [9558, 9559], 966666, 968807, [984300, 984303], [98800, 98802], 990027] },
|
|
17
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [10, 13, 16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [627244, [639014, 639022], 639024, [639026, 639028], 639031, [639034, 639044], [63907e3, 63907200], [639073, 639085], [639095, 639096], 639101, [639104, 639105], 639107, [639110, 639114], [639116, 639117], [639120, 639122], [639124, 639125], [639127, 639128], 925000208, 925000235, 925000277, 925000320, 925000364, 925000384, 925000426, 925025, 92507878] },
|
|
18
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [15], "luhn": true, "securityCode": { "length": 4, "required": true }, "ranges": [[377450, 377451]] },
|
|
19
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [510726, [513023, 513024], [513028, 513031], [5131e4, 51310100], [51310102, 51310110], [51310112, 51310113], 51310117, 51310120, [51310122, 51310125], 51310129, 51310131, 51310133, [51310135, 51310136], [51310139, 51310140], [51310144, 51310145], [51310147, 51310161], 51310164, [51310166, 51310169], [51310171, 51310172], [51310178, 51310179], [51310181, 51310183], 51310185, 51310187, 51310191, [51310194, 51310195], [51310198, 51310399], 513105, [51310700, 51310800], [51310802, 51310810], [51310812, 51310813], 51310817, 51310820, [51310822, 51310825], 51310829, 51310831, 51310833, [51310835, 51310836], [51310839, 51310840], [51310844, 51310845], [51310847, 51310861], 51310864, [51310866, 51310869], [51310871, 51310872], [51310878, 51310879], [51310881, 51310883], 51310885, 51310887, 51310891, [51310894, 51310895], [51310898, 51310899], [513110, 513114], [513116, 513117], 513120, [513122, 513125], 513127, [51312900, 51313e3], [51313002, 51313010], [51313012, 51313013], 51313017, 51313020, [51313022, 51313025], 51313029, 51313031, 51313033, [51313035, 51313036], [51313039, 51313040], [51313044, 51313045], [51313047, 51313061], 51313064, [51313066, 51313069], [51313071, 51313072], [51313078, 51313079], [51313081, 51313083], 51313085, 51313087, 51313091, [51313094, 51313095], [51313098, 51313199], [51313500, 51313800], [51313802, 51313810], [51313812, 51313813], 51313817, 51313820, [51313822, 51313825], 51313829, 51313831, 51313833, [51313835, 51313836], [51313839, 51313840], [51313844, 51313845], [51313847, 51313861], 51313864, [51313866, 51313869], [51313871, 51313872], [51313878, 51313879], [51313881, 51313883], 51313885, 51313887, 51313891, [51313894, 51313895], [51313898, 51314299], [513144, 513145], [513147, 513148], [5131501, 5131509], [5131511, 5131519], 51315400, [51315402, 51315410], [51315412, 51315413], 51315417, 51315420, [51315422, 51315425], 51315429, 51315431, 51315433, [51315435, 51315436], [51315439, 51315440], [51315444, 51315445], [51315447, 51315461], 51315464, [51315466, 51315469], [51315471, 51315472], [51315478, 51315479], [51315481, 51315483], 51315485, 51315487, 51315491, [51315494, 51315495], [51315498, 51315599], 51315900, [51315902, 51315910], [51315912, 51315913], 51315917, 51315920, [51315922, 51315925], 51315929, 51315931, 51315933, [51315935, 51315936], [51315939, 51315940], [51315944, 51315945], [51315947, 51315961], 51315964, [51315966, 51315969], [51315971, 51315972], [51315978, 51315979], [51315981, 51315983], 51315985, 51315987, 51315991, [51315994, 51315995], [51315998, 51316200], [51316202, 51316210], [51316212, 51316213], 51316217, 51316220, [51316222, 51316225], 51316229, 51316231, 51316233, [51316235, 51316236], [51316239, 51316240], [51316244, 51316245], [51316247, 51316261], 51316264, [51316266, 51316269], [51316271, 51316272], [51316278, 51316279], [51316281, 51316283], 51316285, 51316287, 51316291, [51316294, 51316295], [51316298, 51316300], [51316302, 51316310], [51316312, 51316313], 51316317, 51316320, [51316322, 51316325], 51316329, 51316331, 51316333, [51316335, 51316336], [51316339, 51316340], [51316344, 51316345], [51316347, 51316361], 51316364, [51316366, 51316369], [51316371, 51316372], [51316378, 51316379], [51316381, 51316383], 51316385, 51316387, 51316391, [51316394, 51316395], [51316398, 51316399], 51316500, [51316502, 51316510], [51316512, 51316513], 51316517, 51316520, [51316522, 51316525], 51316529, 51316531, 51316533, [51316535, 51316536], [51316539, 51316540], [51316544, 51316545], [51316547, 51316561], 51316564, [51316566, 51316569], [51316571, 51316572], [513165780, 513165810], 51316585, 51316587, 51316591, [51316594, 51316595], [51316598, 51316999], [513171, 513174], [513178, 513179], [51318100, 51318600], [51318602, 51318610], [51318612, 51318613], 51318617, 51318620, [51318622, 51318625], 51318629, 51318631, 51318633, [51318635, 51318636], [51318639, 51318640], [51318644, 51318645], [51318647, 51318661], 51318664, [51318666, 51318669], [51318671, 51318672], [51318678, 51318679], [51318681, 51318683], 51318685, 51318687, 51318691, [51318694, 51318695], [51318698, 51318799], [5131891, 5131899], 513191, [513194, 513196], [513198, 513200], 513203, 513209, [513214, 513215], [513217, 513218], 513225, [513230, 513231], [513233, 513235], [513238, 513239], 513241, [513248, 513250], 513256, [513262, 513265], [513267, 513275], 513277, 513279, [513282, 513287], 513293, [513296, 513297], 513299, 513304, [513307, 513311], 513320, [513351, 513353], 513356, [513362, 513363], 513365, [513374, 513376], [513379, 513381], [513385, 513387], 513389, [513411, 513415], 513418, 513453, 513489, [513500, 513501], [513505, 513506], 513508, 513511, [513513, 513515], [513517, 513518], [513523, 513525], [513527, 513528], 513531, 513533, [513537, 513539], [513543, 513544], 513549, [513551, 513554], 513556, [513559, 513561], [513563, 513564], [513569, 513570], [513600, 513601], [513604, 513608], [513611, 513618], 513621, [513623, 513626], [513632, 513633], [513635, 513636], [513640, 513642], [513644, 513648], 513650, 513655, 513657, 51366400, 51366411, 513666, 513668, 513677, 513690, 51369790, 51369801, 51369901, 51369940, [513705, 513706], [513711, 513714], [513720, 513722], 513724, 513730, 513732, [513734, 513738], [513740, 513743], [513745, 513746], 513748, [513750, 513754], [513757, 513759], 51377e3, [51377002, 51377010], [51377012, 51377013], 51377017, 51377020, [51377022, 51377025], 51377029, 51377031, 51377033, [51377035, 51377036], [51377039, 51377040], [51377044, 51377045], [51377047, 51377061], 51377064, [51377066, 51377069], [51377071, 51377072], [51377078, 51377079], [51377081, 51377083], 51377085, 51377087, 51377091, [51377094, 51377095], [51377098, 51377100], [51377102, 51377110], [51377112, 51377113], 51377117, 51377120, [51377122, 51377125], 51377129, 51377131, 51377133, [51377135, 51377136], [51377139, 51377140], [51377144, 51377145], [51377147, 51377161], 51377164, [51377166, 51377169], [51377171, 51377172], [51377178, 51377179], [51377181, 51377183], 51377185, 51377187, 51377191, [51377194, 51377195], [51377198, 51378e3], [51378002, 51378010], [51378012, 51378013], 51378017, 51378020, [51378022, 51378025], 51378029, 51378031, 51378033, [51378035, 51378036], [51378039, 51378040], [51378044, 51378045], [51378047, 51378061], 51378064, [51378066, 51378069], [51378071, 51378072], [51378078, 51378079], [51378081, 51378083], 51378085, 51378087, 51378091, [51378094, 51378095], [51378098, 51378100], [51378102, 51378110], [51378112, 51378113], 51378117, 51378120, [51378122, 51378125], 51378129, 51378131, 51378133, [51378135, 51378136], [51378139, 51378140], [51378144, 51378145], [51378147, 51378161], 51378164, [51378166, 51378169], [51378171, 51378172], [51378178, 51378179], [51378181, 51378183], 51378185, 51378187, 51378191, [51378194, 51378195], [51378198, 51378299], 51379901, 51379911, 513852, [513854, 513856], 513858, [513860, 513861], 513900, 513938, 515214, 516207, 516236, 517222, 517243, [517365, 517366], 517502, 517647, 51810100, 51810110, 51810120, 51810130, 51810140, 519920, 520993, 521662, 52371800, [52371802, 52371810], [52371812, 52371813], 52371817, 52371820, [52371822, 52371825], 52371829, 52371831, 52371833, [52371835, 52371836], [52371839, 52371840], [52371844, 52371845], [52371847, 52371861], 52371864, [52371866, 52371869], [52371871, 52371872], [52371878, 52371879], [52371881, 52371883], 52371885, 52371887, 52371891, [52371894, 52371895], [52371898, 52371899], 527429, 529227, [529313, 529314], 529331, 529414, 529421, 529430, 529440, 529447, [529455, 529456], [529464, 529470], 529473, 529477, [529483, 529484], 529493, 529498, 529542, 530066, 530448, 530467, 530901, 531028, 531030, 531195, [532344, 532347], 532459, 532509, 532534, 532554, 532556, 532915, 533801, 53410100, [53410102, 53410110], [53410112, 53410113], 53410117, 53410120, [53410122, 53410125], 53410129, 53410131, 53410133, [53410135, 53410136], [53410139, 53410140], [53410144, 53410145], [53410147, 53410161], 53410164, [53410166, 53410169], [53410171, 53410172], [53410178, 53410179], [53410181, 53410183], 53410185, 53410187, 53410191, [53410194, 53410195], [53410198, 53410299], [5341051, 5341059], 53410900, [53410902, 53410910], [53410912, 53410913], 53410917, 53410920, [53410922, 53410925], 53410929, 53410931, 53410933, [53410935, 53410936], [53410939, 53410940], [53410944, 53410945], [53410947, 53410961], 53410964, [53410966, 53410969], [53410971, 53410972], [53410978, 53410979], [53410981, 53410983], 53410985, 53410987, 53410991, [53410994, 53410995], [53410998, 53410999], 534111, 535029, 535066, 535324, 536107, 536115, 536395, 537106, 537112, 53801101, 542848, 545157, 54953800, [549858, 549859], 553979, 553993, 554205, 554260, 554965, 557008, 558867, 558882, 55892900, 55892910, 55892920, 55892930, [558942, 558943], 559618, [559809, 559810]] },
|
|
20
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [12, 13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [501637, 501767, 504384, 504478, 504526, 504977, [50758900, 50759411], 507595, 50759701, 50759703, 560149, [560400, 560406], 560408, [560410, 560411], 560784, [561202, 561241], [561243, 561244], [56124600, 56125600], [56125602, 56125610], [56125612, 56125613], 56125617, 56125620, [56125622, 56125625], 56125629, 56125631, 56125633, [56125635, 56125636], [56125639, 56125640], [56125644, 56125645], [56125647, 56125661], 56125664, [56125666, 56125669], [56125671, 56125672], [56125678, 56125679], [56125681, 56125683], 56125685, 56125687, 56125691, [56125694, 56125695], [56125698, 56125800], [56125802, 56125810], [56125812, 56125813], 56125817, 56125820, [56125822, 56125825], 56125829, 56125831, 56125833, [56125835, 56125836], [56125839, 56125840], [56125844, 56125845], [56125847, 56125861], 56125864, [56125866, 56125869], [56125871, 56125872], [56125878, 56125879], [56125881, 56125883], 56125885, 56125887, 56125891, [56125894, 56125895], [56125898, 56125900], [56125902, 56125910], [56125912, 56125913], 56125917, 56125920, [56125922, 56125925], 56125929, 56125931, 56125933, [56125935, 56125936], [56125939, 56125940], [56125944, 56125945], [56125947, 56125961], 56125964, [56125966, 56125969], [56125971, 56125972], [56125978, 56125979], [56125981, 56125983], 56125985, 56125987, 56125991, [56125994, 56125995], [56125998, 56127999], [561281, 561283], [561285, 561287], [561289, 561299], 581180, [581700, 581713], 581715, [581719, 581729], 581731, [581733, 581754], [581756, 581763], 581766, 581769, [581772, 581793], [581795, 581799], [585400, 585413], 585415, [585419, 585431], [585433, 585463], [585466, 585467], [585472, 585599], 588639, 588656, 589271, 639092, [670903, 670904], [6751, 6756], 677590] },
|
|
21
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[401005, 401006], 40158100, [402096, 402097], 40210100, [402102e3, 402102001], [402230, 402231], 40355099, [403579016, 403579017], 403579700, [403579719, 403579759], [40593500, 40593600], 405937, [405939, 405941], 406572, [413849e3, 413849001], [414819e3, 414819002], 415056, [415058, 415063], [415066, 415069], 415071, [41507300, 41507400], 416286, 416537, 41657900, [417174, 417175], [420110, 420113], [420116, 420118], [420120, 420124], 423460, [434721, 434722], [435048, 435052], [436e3, 436001], 43600304, 436005, [436009, 436011], 436032, 436037, 436041, 43604602, 43604610, [43604612, 43604613], 43604617, 43604620, 43604622, [43604624, 43604625], 43604629, 43604631, 43604633, [43604635, 43604636], [43604639, 43604640], [43604644, 43604645], [43604647, 43604648], [43604660, 43604661], [43604666, 43604669], [43604671, 43604672], [43604678, 43604679], [43604681, 43604683], 43604687, 43604691, [43604694, 43604695], [43604698, 43604699], 436092, 437835, [437875, 437876], 439509, 439511, 439513, 439515, 43953901, 43953960, 439598, 439603, [439618, 439620], 439622, 439672, [442448, 442452], 442457, 448412, 449951, [449954, 449955], [449957, 449959], [449961, 449962], [449964, 449965], 449967, [449969, 449971], 449973, 450519, 450544, 450560, [4526, 4528], [453300, 453302], 45330400, [45330402, 45330410], [45330412, 45330413], 45330417, 45330420, [45330422, 45330425], 45330429, 45330431, 45330433, [45330435, 45330436], [45330439, 45330440], [45330444, 45330445], [45330447, 45330461], 45330464, [45330466, 45330469], [45330471, 45330472], [45330478, 45330479], [45330481, 45330483], 45330485, 45330487, 45330491, [45330494, 45330495], [45330498, 45330599], [453307, 453308], [45331e3, 45331400], [45331402, 45331410], [45331412, 45331413], 45331417, 45331420, [45331422, 45331425], 45331429, 45331431, 45331433, [45331435, 45331436], [45331439, 45331440], [45331444, 45331445], [45331447, 45331461], 45331464, [45331466, 45331469], [45331471, 45331472], [45331478, 45331479], [45331481, 45331483], 45331485, 45331487, 45331491, [45331494, 45331495], [45331498, 45331499], 45331523, 45331623, [45331700, 45331800], [45331802, 45331810], [45331812, 45331813], 45331817, 45331820, [45331822, 45331825], 45331829, 45331831, 45331833, [45331835, 45331836], [45331839, 45331840], [45331844, 45331845], [45331847, 45331861], 45331864, [45331866, 45331869], [45331871, 45331872], [45331878, 45331879], [45331881, 45331883], 45331885, 45331887, 45331891, [45331894, 45331895], [45331898, 45332099], 45332123, [453322, 453325], 45332623, 453329, 45333090, [45333100, 45333200], [45333202, 45333210], [45333212, 45333213], 45333217, 45333220, [45333222, 45333225], 45333229, 45333231, 45333233, [45333235, 45333236], [45333239, 45333240], [45333244, 45333245], [45333247, 45333261], 45333264, [45333266, 45333269], [45333271, 45333272], [45333278, 45333279], [45333281, 45333283], 45333285, 45333287, 45333291, [45333294, 45333295], [45333298, 45333399], [45333600, 45334100], 45334250, 45334300, [453344, 453345], 45334650, [45334700, 45334900], 45334980, 45334990, 45335e3, [45335002, 45335010], [45335012, 45335013], 45335017, 45335020, [45335022, 45335025], 45335029, 45335031, 45335033, [45335035, 45335036], [45335039, 45335040], [45335044, 45335045], [45335047, 45335061], 45335064, [45335066, 45335069], [45335071, 45335072], [45335078, 45335079], [45335081, 45335083], 45335085, 45335087, 45335091, [45335094, 45335095], [45335098, 45335099], 45335200, [45335202, 45335210], [45335212, 45335213], 45335217, 45335220, [45335222, 45335225], 45335229, 45335231, 45335233, [45335235, 45335236], [45335239, 45335240], [45335244, 45335245], [45335247, 45335261], 45335264, [45335266, 45335269], [45335271, 45335272], [45335278, 45335279], [45335281, 45335283], 45335285, 45335287, 45335291, [45335294, 45335295], [45335298, 45335299], 45335400, [45335402, 45335410], [45335412, 45335413], 45335417, 45335420, [45335422, 45335425], 45335429, 45335431, 45335433, [45335435, 45335436], [45335439, 45335440], [45335444, 45335445], [45335447, 45335461], 45335464, [45335466, 45335469], [45335471, 45335472], [45335478, 45335479], [45335481, 45335483], 45335485, 45335487, 45335491, [45335494, 45335495], [45335498, 45335499], 453356, [45335800, 45335900], 45335980, 45335990, [453360, 453363], [453366, 453372], [453378, 453379], [453381, 453383], 453387, 453391, 45339300, [453394, 453395], 45339700, [453398, 453399], 455660, 45566220, 45566289, 45566298, 455664, 455670, [455672, 455673], 45567500, 455677, [455679, 455685], 455688, 455694, 4561e5, [456100026, 456100027], [45610030, 45610035], 456102, 45610700, 45610830, 45610860, [45610898, 45611099], [456111017, 456111018], 456113, 45611540, [45611542, 45611545], [456117, 456118], [456122027, 456122028], 45612230, [45612232, 45612235], 456125, 4561263, 45612643, 45612646, 45612665, 456128, [456132, 456135], 456138018, [456138028, 456138029], 456139, [45614092, 45614099], [45614193, 45614198], [45614293, 45614399], [45614493, 45614496], [45614498, 45614499], 45614597, 45614599, 456148, 4561533, 45615360, 45615363, 45615366, 45615373, 45615376, [45615500, 45615600], 456158, [45615930, 45615931], 45615934, 456160, 45616300, 45616530, 45616560, [45616598, 45616599], [45616630, 45616631], 45616637, 45616660, [45616662, 45616663], [45616665, 45616669], 456167, 45616970, 45616979, 45616989, [45617220, 45617221], 45617266, 456173, 456176, [456179, 456180], 456186, [45618895, 45618897], 45618899, 456190, 456193, [456195, 456196], 45619800, [456199, 456207], [456209, 456211], [456214, 456216], 45622006, 45622090, [456221, 456222], [456225, 456226], [456228, 456230], [456232, 456241], [456243, 456244], [456247, 456250], [456252, 456253], 456255, 45625601, [456257, 456261], 456263, [456265, 456267], 456269, [456272, 456276], [456279, 456283], 456290, 456292, [456295, 456296], 456299, 456955, 457200, [457211, 457214], 457452, 457717, 459297, 459302, 459320, [459330, 459331], 459337, 459375, [459395, 459396], 459398, 459408, [45950600, 45950641], [45950643, 45950799], [459546, 459549], 459586, [460993, 460998], [463218, 463219], 46547620, 46547629, 46547720, 46547729, 46547798, 466091, 466258, 466575, 467038, 469698, [469781, 469783], [469804, 469807], [469829, 469830], 469861, 474107, [477171, 477172], 47717397, 47717399, 47717497, 47717499, 477181, 477183, [477185, 477186], [477221, 477222], 477265, 477293, [478020, 478023], [478090, 478095], 479619, 481091, 483622, [483690, 483691], 483733, 486519, [4903e4, 49030301], [490333, 490399], 4905, 4911, [492700, 492701], [492702001, 492704449], 49270451, [4927050, 4927481], [493300, 493314], [493316, 493399], 4936, 4939, [494202, 494257], [494259, 494281], 494284, 494287, 494290, 494292, [494294, 494295], [4944, 4945], [4947, 4949], [495100, 495200], 4952070, [495300, 495762], [495764, 495999], [4961e3, 4962600], [4962610, 4962666], [4962670, 4962690], [49627, 49659], [4967, 4969], [49700104, 49700109], 49701170, 49701470, 49701570, 49701670, [497028, 497035], [49703601, 49703604], [497037, 497038], 49704, [497051, 497053], [497060, 497061], 497069, [497071, 497074], 497079, 49709070, [497100, 497101], [497107, 497109], 497111, [497115010, 497115011], [497116, 497117], [497121, 497122], [497128, 497130], 497132, [497134, 497136], [497138, 497140], [497141012, 497141013], 497144, [497146024, 497146025], 49714610, [49714612, 49714615], 497148, 497152, [497154, 497155], [49715921, 49715925], 49715990, [49715992, 49715995], [49716e3, 49716001], [497160025, 497160026], 497160029, 49716006, [49716010, 49716015], [497162, 497164], [497166, 497169], 497172, 497177, [497179, 497180], 497185, [497190, 497191], [497194, 497195], [497199, 497208], 497210, 497213, 497215, 497219, 49722006, 49722090, [497222, 497223], [49722600, 49722900], [497230, 497231], [497234, 497235], [497237, 497241], [497243, 497247], 497249, [497252, 497255], 49725601, 497257, 497260, [497266, 497267], [497269, 497270], 497272, [49727400, 49727500], 497276, 497278, 497281, 497288, 497291, 497293, [497299, 497300], [49730190, 49730198], 49730299, [49730493, 49730599], [49730693, 49730698], [49730793, 49731099], 49731194, [49731196, 49731197], 497312, [497315, 497316], [49731794, 49731797], [497318, 497319], [497321, 497322], [497326, 497328], 49732920, 49732925, 49732929, 49732935, 497330, 497337, 49733820, 49733829, 49733898, [497339, 497341], [497350, 497351], 497353, [497355, 497357], [497360, 497361], [49736400, 49736500], 49736520, 49736540, 49736550, 49736598, [497366, 497367], 497369, 49737020, 49737050, [497371, 497374], [497376, 497380], [497383, 497384], 497386, [497388, 497390], [497394, 497397], [497400, 497414], 497416, 497419, [497421, 497422], 497424, [497426, 497427], [497429, 497433], [497435, 497437], 497439, [497441, 497444], 497446, 497448, 497450, [497452, 497453], [497455, 497456], [497460, 497461], [497464, 497465], [497467, 497472], 497477, 497481, 497484, [497489, 497492], [497495, 497496], [497498, 497500], [497502, 497504], 497508, [497510, 497512], [497519, 497520], 497522, 497524, [497527, 497529], 497533, 497535, [497537, 497539], 497542, [497546, 497547], 497550, 497554, [497559, 497561], 497563, [497566, 497568], [497572, 497573], [497577, 497578], 497580, 497582, 497585, 497587, [497589, 497594], [497597, 497602], [497604, 497612], [497616, 497620], [497622, 497626], [49762800, 49762900], [497630, 497632], 497634, 497636, [497639, 497641], [497645, 497647], [497650, 497660], 497662, [497664, 497665], [497667, 497668], [497670, 497671], 497673, [497675, 497678], 49768, [497692, 497707], [497709, 497712], [497714, 497718], 497722, [497724, 497725], [497729, 497733], [497735, 497737], [497739, 497743], 497746, [497753, 497754], 497756, [497758, 497760], [497762, 497770], [497773, 497774], [497777, 497779], 497781, [497783, 497784], 497792, [497795, 497801], [497803, 497805], [497807, 497808], [497810, 497811], [497813, 497818], [497820, 497824], [497826, 497831], 497833, [497835, 497846], 497848, 497854, 497856, 497859, [497861, 497864], 497866, [497868, 497869], 497872, 497874, [497876, 497887], [497889, 497895], [497897, 497909], 497911, 497916, 497920, 497925, [497931, 497933], [497940, 497941], [497943, 497944], [497946, 497959], 497961, [497967, 497969], [497972, 497974], 497976, 497979, [497981, 497983], [497985, 497988], [497990, 497993], [497995, 497999], [4981, 4982], 498302, [498322, 498323], 498327, [49835800, 49836237], 498363, [498368, 498373], 498376, 498380, 498390, 498399, [498900, 499006], [499010, 499016], [499020, 499033], [49904, 49909], [4993, 4997]] },
|
|
22
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [4e7] },
|
|
23
|
+
{ "name": "cartesbancaires", "code": "036", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [52e6] },
|
|
24
|
+
{ "name": "carnet", "code": "058", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [286900, [5062, 5064], 588772, 627535, 636318, 636379, 639484, 639559, 653947] },
|
|
25
|
+
{ "name": "mada", "code": "060", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [636120, [968201, 968209], 968211] },
|
|
26
|
+
{ "name": "mada", "code": "060", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [403024, 405454, 406136, 406996, 407197, 407395, 407520, 409201, 410621, 410685, 410834, 412565, 417633, 419593, 420132, 421141, [422817, 422819], 428331, [428671, 428673], 431361, 432328, 434107, 439954, 440533, 440647, 440795, 442463, 445564, 446393, 446404, 446672, 454887, 455036, 455708, 457865, 457997, 458456, 462220, [468540, 468543], 474491, [483010, 483012], 484783, [486094, 486096], [489318, 489319], 490980, 492464] },
|
|
27
|
+
{ "name": "mada", "code": "060", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [223379, 224020, 242030, 513213, 515079, 516138, 520058, 521076, 521661, 524130, 524514, 524940, 529415, 529741, 530060, 531196, 535825, 535989, 536023, 537767, 539737, 543085, 543357, 549760, 554180, 555610, 558563] },
|
|
28
|
+
{ "name": "mada", "code": "060", "lengths": [12, 13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [504300, 506968, 588845, 588848, 588850, 589206, 604906] },
|
|
29
|
+
{ "name": "mada", "code": "060", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [4e7] },
|
|
30
|
+
{ "name": "mada", "code": "060", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [52e6] },
|
|
31
|
+
{ "name": "jcrew", "code": "046", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [60976947] },
|
|
32
|
+
{ "name": "jcrew", "code": "046", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [51599715] },
|
|
33
|
+
{ "name": "elo", "code": "054", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [636297, 636368] },
|
|
34
|
+
{ "name": "elo", "code": "054", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [451416] },
|
|
35
|
+
{ "name": "elo", "code": "054", "lengths": [12, 13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[506707, 506708], 506715, [506717, 506722], [506724, 506736], [506739, 506748], 506753, [506774, 506778], [509e3, 509014], [50902, 50908], [509091, 509101], [509103, 509807], [509831, 509877], [509897, 509900], [509918, 509964], [509971, 509986], [509995, 509999], 627780] },
|
|
36
|
+
{ "name": "elo", "code": "054", "lengths": [16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[650031, 650033], [650035, 650051], [650057, 650081], [650406, 650439], [650485, 650504], [650506, 650538], [650552, 650598], [650720, 650727], [650901, 650922], 650928, [650938, 650939], [650946, 650978], [651652, 651704], [65500, 65501], [655021, 655057]] },
|
|
37
|
+
{ "name": "meeza", "code": "067", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[50780300, 50780350], [5078083, 5078102]] },
|
|
38
|
+
{ "name": "meeza", "code": "067", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [52e6] },
|
|
39
|
+
{ "name": "eftpos", "code": "070", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [401795, 402608, 402979, 402993, 404137, 404340, 404342, 404887, 404940, 405221, 406587, 407220, 408967, 412978, [413302, 413303], 413306, 413309, 413312, [413322, 413326], [413328, 413330], [413333, 413335], 413337, 413339, 415436, 415700, 418243, 425135, 426011, [429317, 429318], 429762, 430330, 433687, 433696, 433770, 434402, 434968, 437381, 438875, [439239, 439242], 443084, [443401, 443402], 443405, 443408, [443410, 443418], [443420, 443421], 443425, [443427, 443428], [443431, 443432], [443436, 443438], 443441, [443445, 443453], 443455, 443458, [443460, 443461], 443463, 443467, 443469, [443474, 443478], [443480, 443482], [443485, 443486], [443488, 443489], [443495, 443496], 443499, 445010, 445012, 445014, 445088, 450606, 450949, [452479, 452480], 453030, [453150, 453151], 453224, [455701, 455703], 456004, 456075, 456403, 456409, 456436, [456441, 456443], [456461, 456469], [456471, 456472], 456475, [456479, 456480], 456482, 456489, 456495, 458524, [458594, 458595], 458858, 461953, 461955, 461957, 461961, 461967, 461973, [461976, 461977], 462239, [462481, 462482], 462949, 463925, 464579, [466168, 466169], 468229, [470564, 470565], 470568, 471514, 471572, 472134, 472245, 472248, [472678, 472679], 472690, [472694, 472697], 476330, 476339, 476357, [477360, 477361], 482883, 482885, 482887, 483740, 483805, 483820, [483822, 483824], 483867, 486040, 488903, 490292, 493191, 493414, 494005, [494052, 494053]] },
|
|
40
|
+
{ "name": "eftpos", "code": "070", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [514813, 516310, 516315, [516319, 516321], [516323, 516326], [516328, 516330], 516335, 516337, [516339, 516340], 516345, [516349, 516350], 516355, [516359, 516361], [516365, 516366], [516369, 516370], 516375, [516379, 516380], 516385, [516389, 516391], 517497, 518840, 518868, 519244, 521729, 529757, 532655, [535316, 535319], 536763, 537196, 540403, [543048, 543049], 545818, 548171, 550124, 551344, 551439, 551521, 552033, 552282, 552294, [552350, 552351], 552638, 555003, 555005, 555522, [558320, 558321], 558701, 558850, [559738, 559741]] },
|
|
41
|
+
{ "name": "eftpos", "code": "070", "lengths": [12, 13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [504897, [507729, 507732], 507734, [507737, 507740]] },
|
|
42
|
+
{ "name": "eftpos", "code": "070", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [4e7] },
|
|
43
|
+
{ "name": "eftpos", "code": "070", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [52e6] },
|
|
44
|
+
{ "name": "paypak", "code": "068", "lengths": [16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[220543, 220585], [22058800, 22059301], [22059303, 22059316], 220594, 220600] },
|
|
45
|
+
{ "name": "jaywan", "code": "081", "lengths": [16], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [[66900900, 66900901], [66900903, 66900905], [66900907, 66900931], 66900937, [66900939, 66900940], [66900950, 66900957], [66900959, 66900960], [66900962, 66900964], [66900966, 66900974], [66900979, 66900987], [66900991, 66900998], 66901e3, 66901052, [66901056, 66901057], [66901071, 66901073], 66901076, [66901078, 66901085], 66901087, 97845003] },
|
|
46
|
+
{ "name": "jaywan", "code": "081", "lengths": [13, 14, 15, 16, 17, 18, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [40490622, 40504325, 45070710, [471388, 471389], 476578, 47878e3] },
|
|
47
|
+
{ "name": "jaywan", "code": "081", "lengths": [16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [650053, 650483] },
|
|
48
|
+
{ "name": "jaywan", "code": "081", "lengths": [12, 16, 19], "luhn": true, "securityCode": { "length": 3, "required": true }, "ranges": [62245443] },
|
|
49
|
+
{ "name": "kcp", "code": "065", "lengths": [16, 17, 18, 19, 20], "luhn": true, "securityCode": false, "ranges": [605615, 834e3, 834024, 834026, 871010, 871069, 900001, 900050, 900101, [903501, 903505], [903516, 903520], [903551, 903555], 905301, 910003, [910006, 910007], [910011, 910012], [910020, 910021], 910023, 910025, 910027, [910031, 910032], [910034, 910037], 910039, 910050, 910120, 910150, 910550, [920002, 920003], [920006, 920007], 920009, [920011, 920014], 920018, [920020, 920021], 920023, 920025, 920027, [920030, 920032], [920034, 920037], 920039, [920043, 920045], [920048, 920051], 920059, 920061, [920063, 920064], 920071, 920077, [920079, 920080], 920082, [920085, 920087], [920091, 920096], 920120, 920215, 920232, 920239, 920315, 920432, 920439, 930003, 930007, 930011, 930020, 930023, 930025, [930031, 930032], 930034, 930037, 930039, [930050, 930051], [930102, 930103], 930107, [930111, 930112], 930118, 930120, 930123, 930125, [930131, 930132], 930139, 930144, 930146, 930150, 935003, 935007, [935016, 935017], 935020, 935023, [935031, 935032], 935034, 935037, 935039, 935048, 935071, 940327, 940388, [940010, 940012], 940017, 940020, 940030, 940040, 940060, 940080, 940090, [940701, 940704], [940706, 940708], [940910, 940943], 940945, [940947, 940949], [940951, 940958], [940960, 940986], 940991, [940999, 941e3], [941002, 941015], [941017, 941039], 941044, [941049, 941054], [941056, 941069], [941073, 941078], [941080, 941099], [941111, 941112], [941116, 941117], 941120, 941122, 941124, 941150, 941161, [941177, 941181], [941183, 941192], [941194, 941196], 941199, [941216, 941217], 941222, 941224, 941281, [941316, 941317], 941381, 941450, 941520, 941581, 941607, 941620, 941623, [941631, 941632], [941634, 941637], 941639, 941643, 941645, 941648, 941650, 941671, 941681, 941691, 941696, 941707, [941711, 941712], [941722, 941725], [941731, 941732], [941734, 941737], 941739, 941750, 941781, 941807, 941881, 941934, 941981, 942003, 942006, [942011, 942012], [942018, 942025], 942027, [942031, 942036], 942039, [942061, 942065], [942069, 942070], [942072, 942078], [942082, 942097], 942099, [942101, 942107], 942120, [942122, 942124], 942132, 942150, 942199, 942203, 942220, 942222, 942224, 942239, 942520, 942522, 942524, 942620, 942622, 942624, 942720, 942820, 942822, 943003, 943006, [943011, 943012], [943016, 943017], [943020, 943025], 943027, [943031, 943034], 943036, 943039, 943050, 943062, 943078, 943081, [943116, 943117], [943132, 943161], [943163, 943166], 943181, [943210, 943216], 943281, 943381, [943416, 943417], 943481, 943520, [943543, 943544], 943581, [943645, 943646], [943648, 943649], 943651, 943661, [943666, 943667], 943681, [943711, 943715], [943721, 943727], 943731, [943740, 943748], 943781, 943881, 943907, [943920, 943921], [943924, 943925], 943950, 943978, [944002, 944003], [944006, 944007], 944009, [944011, 944012], 944018, [944020, 944025], 944027, [944030, 944034], 944039, [944043, 944045], 944048, 944055, 944061, [944063, 944064], 944071, [944078, 944081], [944095, 944096], [944100, 944101], [944103, 944104], 944106, [944108, 944120], 944122, 944124, [944126, 944135], [944138, 944140], [944143, 944155], 944171, 944178, [944181, 944182], 944187, [944192, 944194], 944196, 944203, [944211, 944212], [944216, 944217], 944222, 944224, 944234, 944243, 944281, 944303, [944306, 944307], [944311, 944312], 944320, 944322, [944324, 944325], 944331, 944334, 944350, 944386, 944403, [944411, 944412], 944420, 944422, 944431, 944443, 944520, 944522, 944524, [944541, 944543], [944545, 944552], [944554, 944558], [944560, 944561], 944603, 944620, 944622, 944624, 944631, 944664, 944691, 944696, 944703, 944707, 944711, 944720, 944722, 944732, 944912, 944920, 944934, [944948, 944950], 945003, [945006, 945007], [945011, 945012], [945020, 945021], 945023, 945025, 945027, [945031, 945032], [945034, 945035], 945039, 945078, 945081, 945103, 945107, [945111, 945112], 945120, 945122, 945124, [945131, 945132], 945150, [945161, 945162], 945203, [945211, 945212], 945220, 945320, 945324, 945420, 945511, 945520, 945620, 945720, [945810, 945825], 945903, 945920, 945934, 946003, [946006, 946007], [946011, 946012], [946016, 946017], [946020, 946025], 946027, [946031, 946032], 946034, 946039, 946044, 946046, [946050, 946051], 946103, 946106, [946111, 946112], [946116, 946117], 946120, [946124, 946125], 946127, [946131, 946132], 946134, 946137, 946139, 946144, 946150, 946178, 946181, [946216, 946217], 946220, 946222, [946224, 946225], 946250, 946253, 946260, 946272, 946285, 946304, 946309, [946316, 946317], 946320, 946332, 946334, 946350, 946352, 946361, 946365, 946370, 946372, 946403, 946406, [946411, 946412], 946420, [946422, 946425], 946427, [946431, 946432], 946439, 946450, 946478, 946503, [946511, 946514], 946520, [946531, 946532], 946539, [946544, 946545], 946550, 946620, [946631, 946632], 946644, 946650, 946720, 946731, 946750, 946803, 946820, 946831, 946850, 946904, 946908, 946920, 946950, 946952, 946961, 947003, 947006, [947011, 947012], [947020, 947021], 947023, 947025, 947027, [947031, 947033], 947039, 947050, 947078, 947081, 947103, [947111, 947112], 947120, 947124, [947131, 947132], 947134, 947137, 947139, 947150, 947181, 947203, 947206, 947211, 947221, 947225, 947232, 947239, 947271, 947520, 947920, 947934, 947950, [948001, 948003], 948020, 948022, 948031, 948034, [948050, 948051], 948120, 948122, [948124, 948125], [948134, 948135], [948150, 948151], 948220, 948222, 948224, 948234, [948250, 948251], 948521, [948816, 948817], 948934, [949001, 949005], [949008, 949072], [949074, 949075], [949077, 949079], 949082, [949084, 949113], [949120, 949138], 949211, 949545, [949551, 949552], 949811, [95e4, 950012], [950018, 950020], 950022, [950061, 950062], 95009, [951001, 951002], [952001, 952002], 952061, [953001, 953005], 954034, 954039, 954049, 954334, 958001, 960161, 960167, [960171, 960172], 970003, [970031, 970032], 970039, 970045, [971e3, 971004], 971010, 972e3, 999950, 999960, 999977, 999999] },
|
|
50
|
+
{ "name": "uatp", "code": "040", "lengths": [15], "luhn": true, "securityCode": false, "ranges": [1001, 1006, 1010, 1014, 1016, 1027, 1035, 1037, [1045, 1046], 1053, 1065, 1071, 1075, 1081, 1086, 1098, 1105, 1112, 1114, 1119, 1125, 1127, 1131, 1139, 1169, 1175, 1185, 1204, 1220, 1227, 1235, 1242, 1257, 1272, 1275, [1278, 1279], 1290, 1301, 1321, 1324, 1337, 1341, [1344, 1345], 1365, 1403, 1412, 1422, 1424, 1428, 1444, 1456, 1462, 1471, 1485, 1489, 1526, 1536, 1544, 1556, 1564, [1574, 1575], 1607, 1611, 1617, 1619, 1654, 1656, 1695, 1700, 1710, 1720, 1781, 1800, 1811, 1813, 1838, 1871, 1876, 1888, 1901, 1920, 1946, 1957, 1999] },
|
|
51
|
+
{ "name": "ulta", "code": "089", "lengths": [16], "luhn": true, "securityCode": false, "ranges": [[578097105, 578097109], [578097180, 578097185]] }
|
|
52
|
+
];
|
|
53
|
+
// src/deep-freeze.js
|
|
54
|
+
function deepFreeze(value) {
|
|
55
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
56
|
+
for (const child of Object.values(value))
|
|
57
|
+
deepFreeze(child);
|
|
58
|
+
Object.freeze(value);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
// src/cybersource-flex-jose.js
|
|
63
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
64
|
+
var VALUE = new Map([...ALPHABET].map((c, i) => [c, i]));
|
|
65
|
+
var COMPACT_PART = /^[A-Za-z0-9_-]+$/;
|
|
66
|
+
var CybersourceFlexError = class extends Error {
|
|
67
|
+
/** @param {string} reason a short code from a closed list, safe to log and return */
|
|
68
|
+
constructor(reason, message) {
|
|
69
|
+
super(`Refusing to pay: ${message}`);
|
|
70
|
+
this.name = "CybersourceFlexError";
|
|
71
|
+
this.reason = reason;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var refuse = (reason, message) => {
|
|
75
|
+
throw new CybersourceFlexError(reason, message);
|
|
76
|
+
};
|
|
77
|
+
function base64UrlToBytes(text, reason = "format") {
|
|
78
|
+
if (typeof text !== "string" || !COMPACT_PART.test(text) || text.length % 4 === 1)
|
|
79
|
+
refuse(reason, "malformed base64url.");
|
|
80
|
+
const out = new Uint8Array(Math.floor(text.length * 3 / 4));
|
|
81
|
+
let bits = 0, buffer = 0, at = 0;
|
|
82
|
+
for (const c of text) {
|
|
83
|
+
buffer = (buffer << 6 | VALUE.get(c)) & 16383;
|
|
84
|
+
bits += 6;
|
|
85
|
+
if (bits >= 8) {
|
|
86
|
+
bits -= 8;
|
|
87
|
+
out[at++] = buffer >> bits & 255;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (buffer & (1 << bits) - 1)
|
|
91
|
+
refuse(reason, "non-canonical base64url.");
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
function bytesToBase64Url(bytes) {
|
|
95
|
+
let out = "", bits = 0, buffer = 0;
|
|
96
|
+
for (const byte of bytes) {
|
|
97
|
+
buffer = (buffer << 8 | byte) & 65535;
|
|
98
|
+
bits += 8;
|
|
99
|
+
while (bits >= 6) {
|
|
100
|
+
bits -= 6;
|
|
101
|
+
out += ALPHABET[buffer >> bits & 63];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (bits > 0)
|
|
105
|
+
out += ALPHABET[buffer << 6 - bits & 63];
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
function asciiBytes(text, reason = "format") {
|
|
109
|
+
if (typeof text !== "string")
|
|
110
|
+
refuse(reason, "expected text.");
|
|
111
|
+
const out = new Uint8Array(text.length);
|
|
112
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
113
|
+
const code = text.charCodeAt(i);
|
|
114
|
+
if (code > 127)
|
|
115
|
+
refuse(reason, "CyberSource Flex accepts ASCII only.");
|
|
116
|
+
out[i] = code;
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
function jsonFromBytes(bytes, reason = "format") {
|
|
121
|
+
let value;
|
|
122
|
+
try {
|
|
123
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
refuse(reason, "malformed JSON.");
|
|
127
|
+
}
|
|
128
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
129
|
+
refuse(reason, "expected a JSON object.");
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
function compactParts(value, count, maxLength, reason = "format") {
|
|
133
|
+
if (typeof value !== "string" || value.length === 0 || value.length > maxLength)
|
|
134
|
+
refuse(reason, "malformed compact serialization.");
|
|
135
|
+
const parts = value.split(".");
|
|
136
|
+
if (parts.length !== count || parts.some((part) => !COMPACT_PART.test(part) || part.length % 4 === 1)) {
|
|
137
|
+
refuse(reason, "malformed compact serialization.");
|
|
138
|
+
}
|
|
139
|
+
return parts;
|
|
140
|
+
}
|
|
141
|
+
var RSA_HASH = Object.freeze({ RS256: "SHA-256", RS512: "SHA-512" });
|
|
142
|
+
var JWS_ALGORITHMS = Object.freeze(Object.keys(RSA_HASH));
|
|
143
|
+
async function verifyCompactJws(token, key, { crypto, maxLength, allowedHeader, reason = "signature" }) {
|
|
144
|
+
if (!crypto?.subtle)
|
|
145
|
+
refuse("crypto", "WebCrypto is unavailable.");
|
|
146
|
+
const [h, p, s] = compactParts(token, 3, maxLength, "format");
|
|
147
|
+
const header2 = jsonFromBytes(base64UrlToBytes(h), "format");
|
|
148
|
+
if (Object.keys(header2).some((name) => !allowedHeader.includes(name)))
|
|
149
|
+
refuse("format", "the signature header carries a member it may not.");
|
|
150
|
+
const hash = RSA_HASH[header2.alg];
|
|
151
|
+
if (typeof header2.alg !== "string" || !hash)
|
|
152
|
+
refuse("alg", "the signature algorithm is not RS256 or RS512.");
|
|
153
|
+
const algorithm = { name: "RSASSA-PKCS1-v1_5", hash };
|
|
154
|
+
let publicKey;
|
|
155
|
+
try {
|
|
156
|
+
publicKey = key.spki ? await crypto.subtle.importKey("spki", base64ToBytes(key.spki), algorithm, false, ["verify"]) : await crypto.subtle.importKey("jwk", { kty: "RSA", n: key.jwk.n, e: key.jwk.e, ext: true }, algorithm, false, ["verify"]);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
refuse("key", "the signing key cannot be imported.");
|
|
160
|
+
}
|
|
161
|
+
let verified = false;
|
|
162
|
+
try {
|
|
163
|
+
verified = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", publicKey, base64UrlToBytes(s), asciiBytes(`${h}.${p}`));
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
verified = false;
|
|
167
|
+
}
|
|
168
|
+
if (verified !== true)
|
|
169
|
+
refuse(reason, "the signature does not verify.");
|
|
170
|
+
return { header: header2, payload: jsonFromBytes(base64UrlToBytes(p), "format") };
|
|
171
|
+
}
|
|
172
|
+
function base64ToBytes(text) {
|
|
173
|
+
return base64UrlToBytes(String(text).replace(/=+$/, "").replace(/\+/g, "-").replace(/\//g, "_"), "key");
|
|
174
|
+
}
|
|
175
|
+
function modulusBits(n) {
|
|
176
|
+
const bytes = base64UrlToBytes(n, "key");
|
|
177
|
+
let at = 0;
|
|
178
|
+
while (at < bytes.length && bytes[at] === 0)
|
|
179
|
+
at += 1;
|
|
180
|
+
if (at === bytes.length)
|
|
181
|
+
return 0;
|
|
182
|
+
return (bytes.length - at - 1) * 8 + (32 - Math.clz32(bytes[at]));
|
|
183
|
+
}
|
|
184
|
+
async function sealCompactJwe(jwk, plaintext, { crypto }) {
|
|
185
|
+
if (!crypto?.subtle || typeof crypto.getRandomValues !== "function")
|
|
186
|
+
refuse("crypto", "WebCrypto is unavailable.");
|
|
187
|
+
const protectedHeader = bytesToBase64Url(asciiBytes(JSON.stringify({ kid: jwk.kid, alg: "RSA-OAEP", enc: "A256GCM" })));
|
|
188
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
189
|
+
const contentKey = await crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, true, ["encrypt"]);
|
|
190
|
+
const sealed = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv, additionalData: asciiBytes(protectedHeader), tagLength: 128 }, contentKey, asciiBytes(plaintext)));
|
|
191
|
+
const wrappingKey = await crypto.subtle.importKey("jwk", { kty: "RSA", n: jwk.n, e: jwk.e, ext: true }, { name: "RSA-OAEP", hash: "SHA-1" }, false, ["wrapKey"]);
|
|
192
|
+
const wrapped = new Uint8Array(await crypto.subtle.wrapKey("raw", contentKey, wrappingKey, { name: "RSA-OAEP" }));
|
|
193
|
+
const tagAt = sealed.byteLength - 16;
|
|
194
|
+
return [
|
|
195
|
+
protectedHeader,
|
|
196
|
+
bytesToBase64Url(wrapped),
|
|
197
|
+
bytesToBase64Url(iv),
|
|
198
|
+
bytesToBase64Url(sealed.subarray(0, tagAt)),
|
|
199
|
+
bytesToBase64Url(sealed.subarray(tagAt))
|
|
200
|
+
].join(".");
|
|
201
|
+
}
|
|
202
|
+
// src/cybersource-flex-context.js
|
|
203
|
+
var FLEX_TOKENS_PATH = "/flex/v2/tokens";
|
|
204
|
+
var FLEX_HOSTS = Object.freeze({ production: "flex.cybersource.com", sandbox: "testflex.cybersource.com" });
|
|
205
|
+
var CAPTURE_CONTEXT_MAX_LENGTH = 16384;
|
|
206
|
+
var CLOCK_SKEW_MS = 6e4;
|
|
207
|
+
var KID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
208
|
+
var NETWORK = /^[A-Z][A-Z0-9_]{0,31}$/i;
|
|
209
|
+
var record = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
210
|
+
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
211
|
+
var VERIFIED = /* @__PURE__ */ new WeakSet();
|
|
212
|
+
function isVerifiedCaptureContext(value) {
|
|
213
|
+
return typeof value === "object" && value !== null && VERIFIED.has(value);
|
|
214
|
+
}
|
|
215
|
+
function flexHostEnvironment(hostname) {
|
|
216
|
+
const host = String(hostname ?? "").toLowerCase();
|
|
217
|
+
if (host === FLEX_HOSTS.production)
|
|
218
|
+
return "production";
|
|
219
|
+
if (host === FLEX_HOSTS.sandbox)
|
|
220
|
+
return "sandbox";
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
function networks(value) {
|
|
224
|
+
if (value === void 0)
|
|
225
|
+
return null;
|
|
226
|
+
if (!Array.isArray(value) || value.length > 32 || value.some((name) => typeof name !== "string" || !NETWORK.test(name))) {
|
|
227
|
+
refuse("format", "the capture context names card networks in an unexpected form.");
|
|
228
|
+
}
|
|
229
|
+
return Object.freeze([...value]);
|
|
230
|
+
}
|
|
231
|
+
function origins(value) {
|
|
232
|
+
if (!Array.isArray(value))
|
|
233
|
+
return Object.freeze([]);
|
|
234
|
+
return Object.freeze(value.filter((origin) => typeof origin === "string" && origin.length <= 2048).slice(0, 16));
|
|
235
|
+
}
|
|
236
|
+
async function verifyContextWithKeys(jwt, keys, { crypto, now } = {}) {
|
|
237
|
+
const [encodedHeader] = compactParts(jwt, 3, CAPTURE_CONTEXT_MAX_LENGTH, "format");
|
|
238
|
+
const peek = jsonFromBytes(base64UrlToBytes(encodedHeader), "format");
|
|
239
|
+
const kid = peek.kid;
|
|
240
|
+
if (typeof kid !== "string" || !own(keys, kid))
|
|
241
|
+
refuse("kid_unknown", "the capture context is signed by a key CyberSource does not use for Flex.");
|
|
242
|
+
const pinned = keys[kid];
|
|
243
|
+
const { payload } = await verifyCompactJws(jwt, { spki: pinned.spki }, {
|
|
244
|
+
crypto,
|
|
245
|
+
maxLength: CAPTURE_CONTEXT_MAX_LENGTH,
|
|
246
|
+
allowedHeader: ["kid", "alg", "typ"],
|
|
247
|
+
reason: "signature"
|
|
248
|
+
});
|
|
249
|
+
const environment = pinned.environment;
|
|
250
|
+
const host = FLEX_HOSTS[environment];
|
|
251
|
+
if (!host)
|
|
252
|
+
refuse("kid_unknown", "the signing key has no Flex environment.");
|
|
253
|
+
const flx = payload.flx;
|
|
254
|
+
if (!record(flx))
|
|
255
|
+
refuse("format", "the capture context has no Flex section.");
|
|
256
|
+
const origin = `https://${host}`;
|
|
257
|
+
const url = `${origin}${FLEX_TOKENS_PATH}`;
|
|
258
|
+
if (flx.origin !== origin || flx.path !== FLEX_TOKENS_PATH || own(flx, "tokensUrl") && flx.tokensUrl !== url) {
|
|
259
|
+
refuse("url_mismatch", `the capture context does not send the card to ${url}.`);
|
|
260
|
+
}
|
|
261
|
+
const jwk = flx.jwk;
|
|
262
|
+
if (!record(jwk) || jwk.kty !== "RSA" || typeof jwk.n !== "string" || typeof jwk.e !== "string" || typeof jwk.kid !== "string" || !KID.test(jwk.kid) || own(jwk, "use") && jwk.use !== "enc") {
|
|
263
|
+
refuse("key", "the capture context carries no usable CyberSource encryption key.");
|
|
264
|
+
}
|
|
265
|
+
const bits = modulusBits(jwk.n);
|
|
266
|
+
const exponent = base64UrlToBytes(jwk.e, "key");
|
|
267
|
+
if (bits < 2048 || bits > 8192 || exponent.length < 1 || exponent.length > 8)
|
|
268
|
+
refuse("key", "the CyberSource encryption key is too weak.");
|
|
269
|
+
const nowMs = typeof now === "function" ? now() : Date.now();
|
|
270
|
+
if (!Number.isFinite(payload.exp) || !Number.isFinite(nowMs) || payload.exp * 1e3 <= nowMs - CLOCK_SKEW_MS) {
|
|
271
|
+
refuse("expired", "the capture context has expired.");
|
|
272
|
+
}
|
|
273
|
+
const ctx = Array.isArray(payload.ctx) ? payload.ctx : [];
|
|
274
|
+
const index = ctx.findIndex((entry) => record(entry) && typeof entry.type === "string" && /^mf-/.test(entry.type));
|
|
275
|
+
if (index < 0)
|
|
276
|
+
refuse("microform", "the capture context is not a Microform context.");
|
|
277
|
+
const data = record(ctx[index].data) ? ctx[index].data : {};
|
|
278
|
+
const context = Object.freeze({
|
|
279
|
+
raw: jwt,
|
|
280
|
+
signingKid: kid,
|
|
281
|
+
environment,
|
|
282
|
+
origin,
|
|
283
|
+
path: FLEX_TOKENS_PATH,
|
|
284
|
+
url,
|
|
285
|
+
jwk: Object.freeze({ kty: "RSA", n: jwk.n, e: jwk.e, kid: jwk.kid }),
|
|
286
|
+
modulusBytes: Math.ceil(bits / 8),
|
|
287
|
+
index,
|
|
288
|
+
contextType: ctx[index].type,
|
|
289
|
+
allowedCardNetworks: networks(data.allowedCardNetworks),
|
|
290
|
+
targetOrigins: origins(data.targetOrigins),
|
|
291
|
+
iat: Number.isFinite(payload.iat) ? payload.iat : null,
|
|
292
|
+
exp: payload.exp
|
|
293
|
+
});
|
|
294
|
+
VERIFIED.add(context);
|
|
295
|
+
return context;
|
|
296
|
+
}
|
|
297
|
+
// src/cybersource-flex.js
|
|
298
|
+
var CYBERSOURCE_FLEX_PSP = "cybersource_flex";
|
|
299
|
+
var CYBERSOURCE_FLEX_CONTENT_TYPE = "application/jwt; charset=utf-8";
|
|
300
|
+
var CYBERSOURCE_FLEX_TOKENS_URLS = Object.freeze({
|
|
301
|
+
production: `https://${FLEX_HOSTS.production}${FLEX_TOKENS_PATH}`,
|
|
302
|
+
sandbox: `https://${FLEX_HOSTS.sandbox}${FLEX_TOKENS_PATH}`
|
|
303
|
+
});
|
|
304
|
+
var CYBERSOURCE_FLEX_CAPTURE_CONTEXT_MAX_LENGTH = CAPTURE_CONTEXT_MAX_LENGTH;
|
|
305
|
+
var CYBERSOURCE_FLEX_REVIEWED_IFRAME_VERSIONS = Object.freeze(["2.12.1"]);
|
|
306
|
+
var CYBERSOURCE_FLEX_SIGNING_KEYS = deepFreeze({
|
|
307
|
+
ln: { environment: "production", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg1Rzx+fgWZRG85rr2BGDEllGL1ktK5i9d1+5yXmP5BKm9jgXuNobr2QyBIZoii5yfkRiswpqkflARJl9kmkOCFaZ0b5p0/h530V/DZyam9SrMfGST9jiNu7W7j/9iLHIVCRTeILeeW9/wBDWGeoEZCaBNIF+73zP08gzaQfEzvu37R2hqkk7MSh4HuWj8jXubUQYQxti89S1AfNoxKRYcTNBb/xYP9AeczjowU4QZwxFVKXn6//vCL5419fGPH+YQtGaJePHE0+u/PKV0GZxBzhR07DqjuuORmD6guLxejKAt/sSbvbVdJ7owhHYxZskVep1rfEekuSdxrHpJ6dm0QIDAQAB" },
|
|
308
|
+
wf: { environment: "production", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmutlUOjmsHUaPlCyQCSrxpH1fOFwUwHTCtB3lTVVcabVPaF3Cv+RYgLY47VjxwucRoNz5w6/Eupfw4MDqC2vYOxHT5iCjyIZtm7EPWPsuJh/u2xBcRcez6lWrQuKx9h6Sf/uJFq7Xl6Edwv2/x2bHcZSRyAsSawvVNeOnFcA3JT3ax7P26psE90CHG4/1O3IdsttGttY64ynNUxKj9hNa/Iwgxu9fnaDbcObaT8v5AkfYD2l1j3J+s46g9OlMY6CZS0P8sDBkZ6C+7tIkB5NLrMo88JfbRSshUSKZmhWiYgMHcxUgwDs3cunI2aWIEegQZwgDNyiQxV2Xd2aQr2BEwIDAQAB" },
|
|
309
|
+
p1: { environment: "production", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnBfDCTWnGltC7pwVzQKUw0f5zemqFM9KJSPjPxVtd0g+No3eLiMAWQZo32Dtd6ZVPQeI/ZMj1mY/Hde6eknDXXMI+XvgY4BRpKrHQ9GbhvWnEZa9T29j3naVlkOF8rR6dPKf9QghKL3kl666IcexlOeGQaypyzfvL0C63E3V/VtyR6hEbEx+YLwMEqdsmirxvc0rlVGvHjPy+J5quH3gnnZHKUonDLRRGeMOISsPTp5r66llFOxVKy5IZ8/FvM9TLaso38h5qSb6RGc45qk12d9Nkx4u/1g+ze9Gbm9m0idVHrfDUpDCjtGMeMRvyK9zVWHbGmLsdNC7DMyRZxn93wIDAQAB" },
|
|
310
|
+
p2: { environment: "production", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAimRR2guDU42iF/Erjn9XXmgn3UgiPNusErluLKtEL3cQYE5nGL58pvaWRKVEUkxK/O6aNBAN2XY8YEKxs/Rkh38ayimL/3yyV8T9CZs7rxTif1IuVDerpUZIVwSlolWMHxXdG+wDK1EyCPsImLrDLd+CMaj9PFPLE9qaonGAxOKtOvvRmEsPBHmrHqk+nzBHQGJHYgo9J9tTb/MGdCmEZQ1i5E8tv9jVThDI2G2oiBQyFIuGodYdgdzqRweQV0o6iO9ihKvxiLlRkQpv8fne8XYxd4hGLeIr2JD2pyY2ZR0ZuRSc1AIuSY+CELhqP5SnOBUtiB6+efm9k+lFukTBewIDAQAB" },
|
|
311
|
+
"3g": { environment: "sandbox", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAir7Nl1Bj8G9rxr3co5v/JLkP3o9UxXZRX1LIZFZeckguEf7Gdt5kGFFfTsymKBesm3Pe8o1hwfkq7KmJZEZSuDbiJSZvFBZycK2pEeBjycahw9CqOweM7aKG2F/bhwVHrY4YdKsp/cSJe/ZMXFUqYmjk7D0p7clX6CmR1QgMl41Ajb7NHI23uOWL7PyfJQwP1X8HdunE6ZwKDNcavqxOW5VuW6nfsGvtygKQxjeHrI+gpyMXF0e/PeVpUIG0KVjmb5+em/Vd2SbyPNmenADGJGCmECYMgL5hEvnTuyAybwgVwuM9amyfFqIbRcrAIzclT4jQBeZFwkzZfQF7MgA6QQIDAQAB" },
|
|
312
|
+
zu: { environment: "sandbox", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAozmvkuGzWNHs9cEcC5PWwbG+dmSjPcoQFxEbqH/fBjkj/nfTTKshdiSq5ciulWEa/rrqQ2qwcSADNxtTzRR1qfud+NvsM8VltT7xDuVVqPTZoWLKa0BWXgQQ+1mCm1KdGltYWccB0R1LoF+rb3DEEZySsHvqErYzYt4M/rqjEiK5Y9y1h3k1h5Yk4zGLWchko3jiDS+pVevvWsQsN+Y3KuB19485G9P/MXLtfJWQ4wC4jlo9etdD/hgDfxX+hQy3wuwHfHifLdxvxiB8X5Is4m6DuY4/7hS5RwXAjO1QSd+zUYZNT/2yWVR56/jyiZEiOdgIm9QtLPZCTKzqsXoqZQIDAQAB" },
|
|
313
|
+
c1: { environment: "sandbox", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgk5sqfQNVvixE24DgcI6T4fKmrLNOkq+d3TKmRlpEpIPNGsYt+x6hSvkwFF/6Wm9s5SpyvFq4WmQQf35FUwlq8/X9vB2s2NYdN/qSsORVmifE2mVqZErsmI5+aKba16B1FFFojJ8KjdUPTRYFgjlnwFTY+JF0JdpXYjZb4QW/KwpF4cCYSIcR3t0GQZhdf0RqTT2iOE26NeT+T5pPX3Zvw2QvrULKsiQXrTR4dsgBblgGC4W4dljmpX85BKGhsSRwFQvVad9wsrs3YgOtQf5Oi8MilBKEusPv8hsk9COa/8pqbLTzoo+S77CLPxR53MeJq6jcwghPiyQzYqfo1WV7QIDAQAB" },
|
|
314
|
+
c2: { environment: "sandbox", spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLM8+PFEjLMqpcaLz0PLJitWblVeOQ1XOSGVnHd6Ho4AkXZt7hfv8Rsvf60G6lvrKY143ro/2dWcsVP6N8qbxoMiXLlMjdzf2SpLPar4imebKIMgRAYW6BQfE8moHSfRJaueVkZGWjruMkA37O3GemidktlOmiJVFuAqLOhERT9Yq0BCIhA+dcubbDOTYKbJcUvmvQOxGShL1bPC3iGafBF4eUjnzWHd+KjIQdW16jwejZOGP9mf2AoyJxNJeUCqu1rKb7rYPHvHTdDG4ARQ2Cx6w2ObMF/gS2X0q4BO3PBxEE2PrxUnLP7QMxr8jCcHn8hWr/H4eTR389OF4kX5LwIDAQAB" }
|
|
315
|
+
});
|
|
316
|
+
var testPans = /* @__PURE__ */ new Set([
|
|
317
|
+
"4111111111111111",
|
|
318
|
+
"4622943127013705",
|
|
319
|
+
"4622943127013713",
|
|
320
|
+
"4622943127013721",
|
|
321
|
+
"4622943127013739",
|
|
322
|
+
"4622943127013747",
|
|
323
|
+
"2222420000001113",
|
|
324
|
+
"2222630000001125",
|
|
325
|
+
"5555555555554444",
|
|
326
|
+
"378282246310005",
|
|
327
|
+
"6011111111111117",
|
|
328
|
+
"6011000990139424",
|
|
329
|
+
"3566111111111113"
|
|
330
|
+
]);
|
|
331
|
+
for (const method of ["add", "delete", "clear"])
|
|
332
|
+
testPans[method] = () => {
|
|
333
|
+
throw new TypeError("CYBERSOURCE_FLEX_TEST_PANS is immutable");
|
|
334
|
+
};
|
|
335
|
+
var CYBERSOURCE_FLEX_TEST_PANS = Object.freeze(testPans);
|
|
336
|
+
function verifyCaptureContext(jwt, { crypto, now } = {}) {
|
|
337
|
+
return verifyContextWithKeys(jwt, CYBERSOURCE_FLEX_SIGNING_KEYS, { crypto, now });
|
|
338
|
+
}
|
|
339
|
+
function cybersourceFlexEnvironment(url) {
|
|
340
|
+
if (url === CYBERSOURCE_FLEX_TOKENS_URLS.production)
|
|
341
|
+
return "production";
|
|
342
|
+
if (url === CYBERSOURCE_FLEX_TOKENS_URLS.sandbox)
|
|
343
|
+
return "sandbox";
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
var FRAGMENT_MAX_LENGTH = 16384;
|
|
347
|
+
var IFRAME_PATH = /^\/microform\/bundle\/v(\d+\.\d+\.\d+)\/iframe\.html$/;
|
|
348
|
+
var FIELD_TYPES = Object.freeze(["number", "securityCode"]);
|
|
349
|
+
function parseMicroformFragment(rawUrl) {
|
|
350
|
+
if (typeof rawUrl !== "string" || rawUrl.length > FRAGMENT_MAX_LENGTH + 2048)
|
|
351
|
+
return null;
|
|
352
|
+
let url;
|
|
353
|
+
try {
|
|
354
|
+
url = new URL(rawUrl);
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
const environment = flexHostEnvironment(url.hostname);
|
|
360
|
+
const path = IFRAME_PATH.exec(url.pathname);
|
|
361
|
+
if (url.protocol !== "https:" || url.port || url.username || url.password || !environment || !path)
|
|
362
|
+
return null;
|
|
363
|
+
const fragment = url.hash.slice(1);
|
|
364
|
+
if (!fragment || fragment.length > FRAGMENT_MAX_LENGTH)
|
|
365
|
+
return null;
|
|
366
|
+
let value;
|
|
367
|
+
try {
|
|
368
|
+
value = JSON.parse(decodeURIComponent(fragment));
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
374
|
+
return null;
|
|
375
|
+
const microformType = value.microformType === void 0 ? "card" : value.microformType;
|
|
376
|
+
const text = (item, max) => typeof item === "string" && item.length > 0 && item.length <= max;
|
|
377
|
+
if (!text(microformType, 32) || !text(value.fieldType, 32) || !text(value.jwt, CAPTURE_CONTEXT_MAX_LENGTH) || value.microformId !== void 0 && !text(value.microformId, 128))
|
|
378
|
+
return null;
|
|
379
|
+
const keyId = url.searchParams.get("keyId");
|
|
380
|
+
return Object.freeze({
|
|
381
|
+
environment,
|
|
382
|
+
version: path[1],
|
|
383
|
+
reviewed: CYBERSOURCE_FLEX_REVIEWED_IFRAME_VERSIONS.includes(path[1]),
|
|
384
|
+
microformType,
|
|
385
|
+
microformId: value.microformId ?? null,
|
|
386
|
+
fieldType: value.fieldType,
|
|
387
|
+
keyId: keyId && keyId.length <= 128 ? keyId : null,
|
|
388
|
+
captureContext: value.jwt
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
var RULES = deepFreeze(CYBERSOURCE_FLEX_RULES.map((rule) => ({ ...rule })));
|
|
392
|
+
var NETWORK_NAMES = RULES.map((rule) => rule.name.toUpperCase());
|
|
393
|
+
function rulesFor(allowedCardNetworks) {
|
|
394
|
+
if (!allowedCardNetworks)
|
|
395
|
+
return RULES;
|
|
396
|
+
const names = Array.isArray(allowedCardNetworks) ? Array.from(new Set(allowedCardNetworks)).filter((name) => typeof name === "string" && NETWORK_NAMES.includes(name)) : [];
|
|
397
|
+
if (names.length < 1)
|
|
398
|
+
return RULES;
|
|
399
|
+
return names.reduce((out, name) => {
|
|
400
|
+
out.push(...RULES.filter((rule) => rule.name === name.toLowerCase()));
|
|
401
|
+
return out;
|
|
402
|
+
}, []);
|
|
403
|
+
}
|
|
404
|
+
function inRange(range, prefix) {
|
|
405
|
+
const [low, high] = Array.isArray(range) ? [range[0], range[1]] : [range, range];
|
|
406
|
+
const value = parseInt(prefix, 10);
|
|
407
|
+
const scale = Number(`1e${prefix.length - low.toString().length}`);
|
|
408
|
+
const from = Math.floor(low * scale);
|
|
409
|
+
const to = Math.floor(high * scale) + (scale >= 1 ? scale - 1 : 0);
|
|
410
|
+
return from <= value && value <= to;
|
|
411
|
+
}
|
|
412
|
+
function luhn(number) {
|
|
413
|
+
if (!number)
|
|
414
|
+
return false;
|
|
415
|
+
let sum = 0;
|
|
416
|
+
const parity = number.length % 2;
|
|
417
|
+
for (let i = 0; i < number.length; i += 1) {
|
|
418
|
+
let digit = parseInt(number.charAt(i), 10);
|
|
419
|
+
if (i % 2 === parity)
|
|
420
|
+
digit *= 2;
|
|
421
|
+
if (digit > 9)
|
|
422
|
+
digit -= 9;
|
|
423
|
+
sum += digit;
|
|
424
|
+
}
|
|
425
|
+
return sum % 10 === 0;
|
|
426
|
+
}
|
|
427
|
+
function detectCardTypes(pan, allowedCardNetworks) {
|
|
428
|
+
const number = String(pan ?? "").replace(/\s+/g, "").slice(0, 19);
|
|
429
|
+
const prefix = number.substring(0, 9);
|
|
430
|
+
const cards = [];
|
|
431
|
+
for (const rule of rulesFor(allowedCardNetworks)) {
|
|
432
|
+
if (number.length > Math.max(...rule.lengths))
|
|
433
|
+
continue;
|
|
434
|
+
if (rule.ranges.some((range) => inRange(range, prefix)))
|
|
435
|
+
cards.push(rule);
|
|
436
|
+
}
|
|
437
|
+
const verdicts = cards.map((rule) => ({
|
|
438
|
+
code: rule.code,
|
|
439
|
+
name: rule.name,
|
|
440
|
+
valid: rule.lengths.includes(number.length) && (!rule.luhn || luhn(number))
|
|
441
|
+
}));
|
|
442
|
+
const required = cards.filter((rule) => rule.securityCode !== false && rule.securityCode.required === true);
|
|
443
|
+
return {
|
|
444
|
+
codes: verdicts.map((card) => card.code),
|
|
445
|
+
valid: verdicts.length > 0 && verdicts.every((card) => card.valid),
|
|
446
|
+
cards: verdicts,
|
|
447
|
+
securityCode: {
|
|
448
|
+
required: cards.length === 0 || required.length > 0,
|
|
449
|
+
length: required.reduce((max, rule) => Math.max(max, rule.securityCode.length), 3)
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
var JWE_MAX_LENGTH = 32768;
|
|
454
|
+
var JWE_KID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
455
|
+
var ascii = (bytes) => {
|
|
456
|
+
let out = "";
|
|
457
|
+
for (const byte of bytes)
|
|
458
|
+
out += String.fromCharCode(byte);
|
|
459
|
+
return out;
|
|
460
|
+
};
|
|
461
|
+
function cybersourceFlexTemplateKid(body) {
|
|
462
|
+
try {
|
|
463
|
+
const [h, key, iv, ciphertext, tag] = compactParts(body, 5, JWE_MAX_LENGTH, "template");
|
|
464
|
+
const headerBytes = base64UrlToBytes(h, "template");
|
|
465
|
+
const header2 = jsonFromBytes(headerBytes, "template");
|
|
466
|
+
if (typeof header2.kid !== "string" || !JWE_KID.test(header2.kid) || ascii(headerBytes) !== JSON.stringify({ kid: header2.kid, alg: "RSA-OAEP", enc: "A256GCM" }))
|
|
467
|
+
return null;
|
|
468
|
+
const wrapped = base64UrlToBytes(key, "template").length;
|
|
469
|
+
if (wrapped < 256 || wrapped > 1024 || base64UrlToBytes(iv, "template").length !== 12 || base64UrlToBytes(tag, "template").length !== 16 || base64UrlToBytes(ciphertext, "template").length < 1)
|
|
470
|
+
return null;
|
|
471
|
+
return header2.kid;
|
|
472
|
+
}
|
|
473
|
+
catch {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function isCybersourceFlexTemplateBody(body) {
|
|
478
|
+
return cybersourceFlexTemplateKid(body) !== null;
|
|
479
|
+
}
|
|
480
|
+
function isCybersourceFlexMediaType(value) {
|
|
481
|
+
return typeof value === "string" && /^application\/jwt(?:\s*;\s*charset=utf-8)?$/i.test(value.trim());
|
|
482
|
+
}
|
|
483
|
+
var header = (headers, name) => {
|
|
484
|
+
if (!headers || typeof headers !== "object" || Array.isArray(headers))
|
|
485
|
+
return void 0;
|
|
486
|
+
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name);
|
|
487
|
+
return entry ? entry[1] : void 0;
|
|
488
|
+
};
|
|
489
|
+
function isCybersourceFlexRequest(url, method, body, headers) {
|
|
490
|
+
return method === "POST" && cybersourceFlexEnvironment(url) !== void 0 && isCybersourceFlexMediaType(header(headers, "content-type")) && isCybersourceFlexTemplateBody(body);
|
|
491
|
+
}
|
|
492
|
+
function assertCybersourceFlexTemplate(body, verified) {
|
|
493
|
+
if (!isVerifiedCaptureContext(verified))
|
|
494
|
+
refuse("context", "the capture context was not verified on this device.");
|
|
495
|
+
const kid = cybersourceFlexTemplateKid(body);
|
|
496
|
+
if (kid === null)
|
|
497
|
+
refuse("template", "the paused request is not a CyberSource Flex card body.");
|
|
498
|
+
if (kid !== verified.jwk.kid || base64UrlToBytes(body.split(".")[1], "template").length !== verified.modulusBytes) {
|
|
499
|
+
refuse("capture_context_mismatch", "the paused request was sealed for a different capture context.");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function flexCard(card, nowMs) {
|
|
503
|
+
if (!card || typeof card !== "object" || Array.isArray(card))
|
|
504
|
+
refuse("card", "no card to send.");
|
|
505
|
+
const number = String(card.number ?? "").replace(/[ -]/g, "");
|
|
506
|
+
if (!/^[0-9]{12,19}$/.test(number))
|
|
507
|
+
refuse("card", "the card number is malformed.");
|
|
508
|
+
const month = String(card.month ?? "");
|
|
509
|
+
const year = String(card.year ?? "");
|
|
510
|
+
const expirationMonth = /^[0-9]{1,2}$/.test(month) ? month.padStart(2, "0") : "";
|
|
511
|
+
const expirationYear = /^[0-9]{2}$/.test(year) ? `20${year}` : year;
|
|
512
|
+
if (!/^(0[1-9]|1[0-2])$/.test(expirationMonth) || !/^(20[1-9][0-9])$/.test(expirationYear))
|
|
513
|
+
refuse("card", "the card expiry is malformed.");
|
|
514
|
+
const today = new Date(nowMs);
|
|
515
|
+
if (Number(expirationYear) * 12 + Number(expirationMonth) - 1 < today.getUTCFullYear() * 12 + today.getUTCMonth()) {
|
|
516
|
+
refuse("card_expired", "the card has expired.");
|
|
517
|
+
}
|
|
518
|
+
return { number, cvc: String(card.cvc ?? "").trim(), expirationMonth, expirationYear };
|
|
519
|
+
}
|
|
520
|
+
function fieldSet(fields, trigger) {
|
|
521
|
+
if (!Array.isArray(fields) || fields.length < 1 || fields.length > FIELD_TYPES.length || new Set(fields).size !== fields.length || fields.some((field) => !FIELD_TYPES.includes(field)) || !fields.includes("number") || !fields.includes(trigger)) {
|
|
522
|
+
refuse("fields", "the Microform fields this payment loaded are not a card number field and an optional security code field.");
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function buildCardPlaintext(verified, card, { fields, trigger = "number", now } = {}) {
|
|
526
|
+
if (!isVerifiedCaptureContext(verified))
|
|
527
|
+
refuse("context", "the capture context was not verified on this device.");
|
|
528
|
+
fieldSet(fields, trigger);
|
|
529
|
+
const normalized = flexCard(card, typeof now === "function" ? now() : Date.now());
|
|
530
|
+
const detected = detectCardTypes(normalized.number, verified.allowedCardNetworks ?? void 0);
|
|
531
|
+
if (detected.codes.length === 0)
|
|
532
|
+
refuse("card_network", "this merchant's CyberSource form does not accept this card network.");
|
|
533
|
+
if (!detected.valid)
|
|
534
|
+
refuse("card_invalid", "the card number fails its network's length or check digit.");
|
|
535
|
+
const numberData = { number: normalized.number, detectedCardTypes: detected.codes };
|
|
536
|
+
let securityData = null;
|
|
537
|
+
if (fields.includes("securityCode") && detected.securityCode.required) {
|
|
538
|
+
if (!new RegExp(`^[0-9]{${detected.securityCode.length}}$`).test(normalized.cvc)) {
|
|
539
|
+
refuse("card_security_code", "the security code has the wrong length for this card.");
|
|
540
|
+
}
|
|
541
|
+
securityData = { securityCode: normalized.cvc };
|
|
542
|
+
}
|
|
543
|
+
const CARD = {};
|
|
544
|
+
for (const part of trigger === "securityCode" && securityData ? [securityData, numberData] : [numberData, securityData]) {
|
|
545
|
+
if (part)
|
|
546
|
+
Object.assign(CARD, part);
|
|
547
|
+
}
|
|
548
|
+
CARD.expirationMonth = normalized.expirationMonth;
|
|
549
|
+
CARD.expirationYear = normalized.expirationYear;
|
|
550
|
+
const plaintext = JSON.stringify({ data: { CARD }, context: verified.raw, index: verified.index });
|
|
551
|
+
asciiBytes(plaintext, "card_ascii");
|
|
552
|
+
return plaintext;
|
|
553
|
+
}
|
|
554
|
+
async function sealForContext(verified, plaintext, { crypto } = {}) {
|
|
555
|
+
if (!isVerifiedCaptureContext(verified))
|
|
556
|
+
refuse("context", "the capture context was not verified on this device.");
|
|
557
|
+
return sealCompactJwe(verified.jwk, plaintext, { crypto });
|
|
558
|
+
}
|
|
559
|
+
var TOKEN_MAX_LENGTH = 8192;
|
|
560
|
+
var CYBERSOURCE_FLEX_REFUSAL_REASONS = Object.freeze([
|
|
561
|
+
"VALIDATION_ERROR",
|
|
562
|
+
"RESOURCE_QUOTA_EXCEEDED",
|
|
563
|
+
"TOKENIZATION_ERROR",
|
|
564
|
+
"DECRYPTION_ERROR",
|
|
565
|
+
"SIGNATURE_ERROR",
|
|
566
|
+
"PROFILE_ERROR",
|
|
567
|
+
"API_GATEWAY_ERROR",
|
|
568
|
+
"JSON_PARSER_ERROR",
|
|
569
|
+
"INTERNAL_ERROR",
|
|
570
|
+
"UNSUPPORTED_MEDIA_TYPE"
|
|
571
|
+
]);
|
|
572
|
+
function cybersourceFlexRefusalCode(text) {
|
|
573
|
+
if (typeof text !== "string" || text.length === 0 || text.length > TOKEN_MAX_LENGTH)
|
|
574
|
+
return null;
|
|
575
|
+
let body;
|
|
576
|
+
try {
|
|
577
|
+
body = JSON.parse(text);
|
|
578
|
+
}
|
|
579
|
+
catch {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
583
|
+
return null;
|
|
584
|
+
const status = body.responseStatus && typeof body.responseStatus === "object" && !Array.isArray(body.responseStatus) ? body.responseStatus : null;
|
|
585
|
+
const reason = status && status.reason !== void 0 ? status.reason : body.reason;
|
|
586
|
+
return typeof reason === "string" && CYBERSOURCE_FLEX_REFUSAL_REASONS.includes(reason) ? reason : null;
|
|
587
|
+
}
|
|
588
|
+
function isCybersourceFlexTokenShape(text) {
|
|
589
|
+
try {
|
|
590
|
+
const [h] = compactParts(text, 3, TOKEN_MAX_LENGTH, "token");
|
|
591
|
+
const tokenHeader = jsonFromBytes(base64UrlToBytes(h, "token"), "token");
|
|
592
|
+
return tokenHeader.alg === "RS256" && typeof tokenHeader.kid === "string" && tokenHeader.kid.length > 0 && tokenHeader.kid.length <= 128 && Object.keys(tokenHeader).every((name) => name === "kid" || name === "alg");
|
|
593
|
+
}
|
|
594
|
+
catch {
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
var unconfirmed = (reason) => ({ confirmed: false, reason });
|
|
599
|
+
async function signedToken(status, body, verified, crypto) {
|
|
600
|
+
if (!isVerifiedCaptureContext(verified))
|
|
601
|
+
return unconfirmed("context");
|
|
602
|
+
if (!Number.isInteger(status) || status < 200 || status > 299)
|
|
603
|
+
return unconfirmed("status");
|
|
604
|
+
if (!isCybersourceFlexTokenShape(body))
|
|
605
|
+
return unconfirmed("format");
|
|
606
|
+
let token;
|
|
607
|
+
try {
|
|
608
|
+
token = await verifyCompactJws(body, { jwk: verified.jwk }, { crypto, maxLength: TOKEN_MAX_LENGTH, allowedHeader: ["kid", "alg"] });
|
|
609
|
+
}
|
|
610
|
+
catch {
|
|
611
|
+
return unconfirmed("signature");
|
|
612
|
+
}
|
|
613
|
+
if (token.header.kid !== verified.jwk.kid)
|
|
614
|
+
return unconfirmed("kid");
|
|
615
|
+
const jti = token.payload.jti;
|
|
616
|
+
if (typeof jti !== "string" || jti.length < 1 || jti.length > 128)
|
|
617
|
+
return unconfirmed("jti");
|
|
618
|
+
return { confirmed: true, reason: null, token };
|
|
619
|
+
}
|
|
620
|
+
async function transientTokenSigned(status, body, verified, { crypto } = {}) {
|
|
621
|
+
const signed = await signedToken(status, body, verified, crypto);
|
|
622
|
+
return { confirmed: signed.confirmed, reason: signed.reason };
|
|
623
|
+
}
|
|
624
|
+
async function transientTokenFacts(status, body, verified, card, { crypto } = {}) {
|
|
625
|
+
const signed = await signedToken(status, body, verified, crypto);
|
|
626
|
+
if (!signed.confirmed)
|
|
627
|
+
return unconfirmed(signed.reason);
|
|
628
|
+
const number = String(card?.number ?? "").replace(/[ -]/g, "");
|
|
629
|
+
const tokenCard = signed.token.payload.content?.paymentInformation?.card;
|
|
630
|
+
const masked = tokenCard?.number?.maskedValue;
|
|
631
|
+
if (!/^[0-9]{12,19}$/.test(number) || typeof masked !== "string" || masked.length > 19 || !masked.endsWith(number.slice(-4))) {
|
|
632
|
+
return unconfirmed("last_four");
|
|
633
|
+
}
|
|
634
|
+
const bin = tokenCard.number.bin;
|
|
635
|
+
if (typeof bin !== "string" || !/^[0-9]{6,8}$/.test(bin) || !number.startsWith(bin))
|
|
636
|
+
return unconfirmed("bin");
|
|
637
|
+
const month = tokenCard.expirationMonth?.value;
|
|
638
|
+
const year = tokenCard.expirationYear?.value;
|
|
639
|
+
const cardMonth = String(card?.month ?? "").padStart(2, "0");
|
|
640
|
+
const cardYear = String(card?.year ?? "").length === 2 ? `20${card.year}` : String(card?.year ?? "");
|
|
641
|
+
if (typeof month !== "string" || typeof year !== "string" || month !== cardMonth || year !== cardYear)
|
|
642
|
+
return unconfirmed("expiry");
|
|
643
|
+
return { confirmed: true, reason: null };
|
|
644
|
+
}
|
|
645
|
+
function cybersourceFlexPreparationUrl(environment) {
|
|
646
|
+
if (environment !== "production" && environment !== "sandbox")
|
|
647
|
+
throw new Error("unsupported_preparation_environment");
|
|
648
|
+
return CYBERSOURCE_FLEX_TOKENS_URLS[environment];
|
|
649
|
+
}
|
|
650
|
+
var BROWSER_HEADERS = /* @__PURE__ */ new Set([
|
|
651
|
+
"accept",
|
|
652
|
+
"accept-language",
|
|
653
|
+
"accept-encoding",
|
|
654
|
+
"content-length",
|
|
655
|
+
"origin",
|
|
656
|
+
"referer",
|
|
657
|
+
"user-agent",
|
|
658
|
+
"host",
|
|
659
|
+
"connection",
|
|
660
|
+
"cache-control",
|
|
661
|
+
"pragma",
|
|
662
|
+
"priority",
|
|
663
|
+
"dnt",
|
|
664
|
+
"sec-fetch-dest",
|
|
665
|
+
"sec-fetch-mode",
|
|
666
|
+
"sec-fetch-site",
|
|
667
|
+
"sec-fetch-user",
|
|
668
|
+
"sec-fetch-storage-access",
|
|
669
|
+
"cookie"
|
|
670
|
+
]);
|
|
671
|
+
function iframeHeaders(headers) {
|
|
672
|
+
if (!headers || typeof headers !== "object" || Array.isArray(headers))
|
|
673
|
+
return false;
|
|
674
|
+
const seen = /* @__PURE__ */ new Set();
|
|
675
|
+
let bytes = 0;
|
|
676
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
677
|
+
const lower = name.toLowerCase();
|
|
678
|
+
if (seen.size >= 64 || seen.has(lower) || !/^[A-Za-z0-9-]+$/.test(name) || typeof value !== "string" || value.length > 8192 || (bytes += name.length + value.length) > 32768)
|
|
679
|
+
return false;
|
|
680
|
+
if (lower !== "content-type" && !BROWSER_HEADERS.has(lower) && !/^sec-ch-ua(?:-[a-z0-9-]+)?$/.test(lower))
|
|
681
|
+
return false;
|
|
682
|
+
seen.add(lower);
|
|
683
|
+
}
|
|
684
|
+
return isCybersourceFlexMediaType(header(headers, "content-type"));
|
|
685
|
+
}
|
|
686
|
+
function isPreparedCybersourceFlexRequest(url, method, body, environment, headers) {
|
|
687
|
+
return (environment === "production" || environment === "sandbox") && method === "POST" && cybersourceFlexEnvironment(url) === environment && iframeHeaders(headers) && isCybersourceFlexTemplateBody(body);
|
|
688
|
+
}
|
|
689
|
+
export { CYBERSOURCE_FLEX_CAPTURE_CONTEXT_MAX_LENGTH, CYBERSOURCE_FLEX_CONTENT_TYPE, CYBERSOURCE_FLEX_PSP, CYBERSOURCE_FLEX_REFUSAL_REASONS, CYBERSOURCE_FLEX_REVIEWED_IFRAME_VERSIONS, CYBERSOURCE_FLEX_RULES_SOURCE, CYBERSOURCE_FLEX_SIGNING_KEYS, CYBERSOURCE_FLEX_TEST_PANS, CYBERSOURCE_FLEX_TOKENS_URLS, CybersourceFlexError, assertCybersourceFlexTemplate, buildCardPlaintext, cybersourceFlexEnvironment, flexHostEnvironment as cybersourceFlexHostEnvironment, cybersourceFlexPreparationUrl, cybersourceFlexRefusalCode, cybersourceFlexTemplateKid, detectCardTypes, isCybersourceFlexMediaType, isCybersourceFlexRequest, isCybersourceFlexTemplateBody, isCybersourceFlexTokenShape, isPreparedCybersourceFlexRequest, isVerifiedCaptureContext, parseMicroformFragment, sealForContext, transientTokenFacts, transientTokenSigned, verifyCaptureContext };
|