@agent-cards/sdk 0.23.12 → 0.23.14
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 +38 -1
- package/LICENSE +38 -0
- package/PREFLIGHT.md +1 -1
- package/README.md +53 -14
- package/dist/adyen-merchant-hosted.generated.js +2 -2
- package/dist/builtin-registry.generated.js +1 -1
- package/dist/card-fields.generated.js +843 -3
- package/dist/cdp.js +101 -13
- package/dist/client.d.ts +91 -2
- package/dist/client.js +205 -13
- package/dist/creditguard.generated.d.ts +100 -2
- package/dist/creditguard.generated.js +333 -3
- package/dist/datatrans.generated.d.ts +19 -4
- package/dist/datatrans.generated.js +15 -3
- package/dist/ebanx.d.ts +107 -0
- package/dist/ebanx.generated.d.ts +78 -0
- package/dist/ebanx.generated.js +577 -0
- package/dist/ebanx.js +159 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/lifecycle.d.ts +35 -3
- package/dist/lifecycle.js +38 -3
- package/dist/paddle-tokenex.d.ts +56 -0
- package/dist/paddle-tokenex.generated.d.ts +67 -0
- package/dist/paddle-tokenex.generated.js +951 -0
- package/dist/paddle-tokenex.js +95 -0
- package/dist/paddle-vgs-pay.d.ts +55 -0
- package/dist/paddle-vgs-pay.js +115 -0
- package/dist/paddle-vgs.generated.d.ts +29 -1
- package/dist/paddle-vgs.generated.js +124 -5
- package/dist/paysafe.generated.d.ts +5 -7
- package/dist/paysafe.generated.js +50 -18
- package/dist/pre-claim.d.ts +46 -1
- package/dist/pre-claim.js +338 -17
- package/dist/preparation.d.ts +13 -0
- package/dist/preparation.js +22 -0
- package/dist/prepared-processor.js +6 -2
- package/dist/primer.generated.js +878 -38
- package/dist/redsys.d.ts +42 -0
- package/dist/redsys.js +68 -0
- package/dist/stripe-checkout.generated.js +479 -11
- package/package.json +9 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Generated from @agent-cards/payment-core. Do not edit.
|
|
3
|
-
// artifact-sha256:
|
|
3
|
+
// artifact-sha256: 0fd8db3c00fa0c1aea085fd184efe4b3ebc67c57673b69d2daec5a912991e181
|
|
4
4
|
// src/card-number-key.js
|
|
5
5
|
var CARD_NUMBER_KEY = /^(number|card_number|cardnumber|cardNum|card_num|pan)$/i;
|
|
6
6
|
// src/json-path.js
|
|
@@ -101,8 +101,8 @@ function parseConvergeBody(body) {
|
|
|
101
101
|
return parsed;
|
|
102
102
|
}
|
|
103
103
|
function convergeAmountCents(value) {
|
|
104
|
-
const
|
|
105
|
-
const m = typeof
|
|
104
|
+
const text2 = typeof value === "number" && Number.isFinite(value) ? String(value) : value;
|
|
105
|
+
const m = typeof text2 === "string" ? AMOUNT.exec(text2) : null;
|
|
106
106
|
if (!m)
|
|
107
107
|
return null;
|
|
108
108
|
const cents = Number(m[1]) * 100 + Number(((m[2] ?? "") + "00").slice(0, 2));
|
|
@@ -406,13 +406,853 @@ var pin2 = (fields) => Object.freeze({
|
|
|
406
406
|
var PADDLE_VGS_MERCHANT_PINS = /* @__PURE__ */ Object.freeze([
|
|
407
407
|
pin2({ id: "rectangle_pro", merchant: "Rectangle Pro", origins: ["https://rectangleapp.com"], sellerClaim: null })
|
|
408
408
|
]);
|
|
409
|
+
var FACT_KEYS = /* @__PURE__ */ Object.freeze(["card_first_six", "card_last_four", "expiry_month", "expiry_year", "card_brand"]);
|
|
410
|
+
var METADATA_KEYS = /* @__PURE__ */ Object.freeze(["cardholder_name", ...FACT_KEYS]);
|
|
411
|
+
// src/payfast.js
|
|
412
|
+
var PAYFAST_PSP = "payfast";
|
|
413
|
+
var PAYFAST_PAY_HOSTS = /* @__PURE__ */ Object.freeze({
|
|
414
|
+
production: Object.freeze(["payment.payfast.io", "www.payfast.co.za"]),
|
|
415
|
+
sandbox: Object.freeze(["sandbox.payfast.co.za"])
|
|
416
|
+
});
|
|
417
|
+
var PAYFAST_BODY_KEYS = /* @__PURE__ */ Object.freeze([
|
|
418
|
+
"card_number",
|
|
419
|
+
"cardholder_name",
|
|
420
|
+
"consent_check",
|
|
421
|
+
"cvv",
|
|
422
|
+
"expiry_month",
|
|
423
|
+
"expiry_year",
|
|
424
|
+
"g-recaptcha-response",
|
|
425
|
+
"captcha_version",
|
|
426
|
+
"captcha_action"
|
|
427
|
+
]);
|
|
428
|
+
var BODY_LIMIT3 = 8192;
|
|
429
|
+
var URL_LIMIT = 256;
|
|
430
|
+
var PAY_PATH = /^\/eng\/method\/CreditCard\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/pay$/;
|
|
431
|
+
var VISA = /^4[0-9]{15}$/;
|
|
432
|
+
var MASTERCARD = /^(?:5[1-5][0-9]{14}|2(?:2(?:2[1-9]|[3-9][0-9])|[3-6][0-9]{2}|7(?:[01][0-9]|20))[0-9]{12})$/;
|
|
433
|
+
var AMEX = /^3[47][0-9]{13}$/;
|
|
434
|
+
var SECURITY_CODE3 = /^[0-9]{3,4}$/;
|
|
435
|
+
var MONTH = /^(?:0?[1-9]|1[0-2])$/;
|
|
436
|
+
var YEAR = /^[0-9]{2}$/;
|
|
437
|
+
var HOLDER = /^(?!(?:[^0-9]*[0-9]){3})[a-zA-Z0-9 -]+\.?[a-zA-Z0-9 -]+$/;
|
|
438
|
+
var HOLDER_LIMIT = 256;
|
|
439
|
+
var CAPTCHA_VERSIONS = /* @__PURE__ */ Object.freeze(["v0", "v1", "v2"]);
|
|
440
|
+
var SOLVED_CAPTCHA2 = /^[A-Za-z0-9_-]{1,4096}$/;
|
|
441
|
+
var refuse5 = (code) => Object.freeze({ verdict: "refuse", code });
|
|
442
|
+
var CARD5 = /* @__PURE__ */ Object.freeze({ verdict: "card" });
|
|
443
|
+
var formEncode = (value) => encodeURIComponent(value).replace(/%20/g, "+");
|
|
444
|
+
function payfastEnvironment(url) {
|
|
445
|
+
if (typeof url !== "string" || url.length > URL_LIMIT || url.includes("?") || url.includes("#"))
|
|
446
|
+
return null;
|
|
447
|
+
let parsed;
|
|
448
|
+
try {
|
|
449
|
+
parsed = new URL(url);
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
if (parsed.href !== url || parsed.protocol !== "https:" || parsed.port || parsed.username || parsed.password || !PAY_PATH.test(parsed.pathname))
|
|
455
|
+
return null;
|
|
456
|
+
if (PAYFAST_PAY_HOSTS.production.includes(parsed.hostname))
|
|
457
|
+
return "production";
|
|
458
|
+
if (PAYFAST_PAY_HOSTS.sandbox.includes(parsed.hostname))
|
|
459
|
+
return "sandbox";
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
function isPayfastPayUrl(url) {
|
|
463
|
+
return payfastEnvironment(url) !== null;
|
|
464
|
+
}
|
|
465
|
+
function readForm(body) {
|
|
466
|
+
if (typeof body !== "string" || body === "" || body.length > BODY_LIMIT3)
|
|
467
|
+
return null;
|
|
468
|
+
try {
|
|
469
|
+
const pairs = body.split("&").map((chunk) => {
|
|
470
|
+
const eq = chunk.indexOf("=");
|
|
471
|
+
if (eq <= 0)
|
|
472
|
+
throw new URIError("not a form pair");
|
|
473
|
+
return [decodeURIComponent(chunk.slice(0, eq).replace(/\+/g, " ")), decodeURIComponent(chunk.slice(eq + 1).replace(/\+/g, " "))];
|
|
474
|
+
});
|
|
475
|
+
return pairs.map(([key, value]) => `${formEncode(key)}=${formEncode(value)}`).join("&") === body ? pairs : null;
|
|
476
|
+
}
|
|
477
|
+
catch {
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function cardNetwork(number) {
|
|
482
|
+
if (typeof number !== "string")
|
|
483
|
+
return null;
|
|
484
|
+
if (VISA.test(number))
|
|
485
|
+
return "visa";
|
|
486
|
+
if (MASTERCARD.test(number))
|
|
487
|
+
return "mastercard";
|
|
488
|
+
return AMEX.test(number) ? "amex" : null;
|
|
489
|
+
}
|
|
490
|
+
function judgeBody(body) {
|
|
491
|
+
const pairs = readForm(body);
|
|
492
|
+
if (pairs === null)
|
|
493
|
+
return { code: "payfast_body_unsupported", pairs: null };
|
|
494
|
+
if (pairs.some(([key]) => key === "cc_key"))
|
|
495
|
+
return { code: "payfast_saved_card", pairs: null };
|
|
496
|
+
if (pairs.length !== PAYFAST_BODY_KEYS.length || !pairs.every(([key], at) => key === PAYFAST_BODY_KEYS[at])) {
|
|
497
|
+
return { code: "payfast_body_unsupported", pairs: null };
|
|
498
|
+
}
|
|
499
|
+
const value = Object.fromEntries(pairs);
|
|
500
|
+
const answer = value["g-recaptcha-response"];
|
|
501
|
+
if (cardNetwork(value.card_number) === null || !SECURITY_CODE3.test(value.cvv) || !MONTH.test(value.expiry_month) || !YEAR.test(value.expiry_year) || value.cardholder_name.length > HOLDER_LIMIT || !HOLDER.test(value.cardholder_name) || !(answer === "" || SOLVED_CAPTCHA2.test(answer)) || !CAPTCHA_VERSIONS.includes(value.captcha_version) || value.captcha_action !== "checkout") {
|
|
502
|
+
return { code: "payfast_body_unsupported", pairs: null };
|
|
503
|
+
}
|
|
504
|
+
if (value.consent_check === "1")
|
|
505
|
+
return { code: "payfast_keep_on_file", pairs: null };
|
|
506
|
+
return value.consent_check === "" ? { code: null, pairs } : { code: "payfast_body_unsupported", pairs: null };
|
|
507
|
+
}
|
|
508
|
+
function payfastBodyVerdict(body) {
|
|
509
|
+
const { code } = judgeBody(body);
|
|
510
|
+
return code === null ? CARD5 : refuse5(code);
|
|
511
|
+
}
|
|
512
|
+
// src/sha256.js
|
|
513
|
+
var K = /* @__PURE__ */ new Uint32Array([
|
|
514
|
+
1116352408,
|
|
515
|
+
1899447441,
|
|
516
|
+
3049323471,
|
|
517
|
+
3921009573,
|
|
518
|
+
961987163,
|
|
519
|
+
1508970993,
|
|
520
|
+
2453635748,
|
|
521
|
+
2870763221,
|
|
522
|
+
3624381080,
|
|
523
|
+
310598401,
|
|
524
|
+
607225278,
|
|
525
|
+
1426881987,
|
|
526
|
+
1925078388,
|
|
527
|
+
2162078206,
|
|
528
|
+
2614888103,
|
|
529
|
+
3248222580,
|
|
530
|
+
3835390401,
|
|
531
|
+
4022224774,
|
|
532
|
+
264347078,
|
|
533
|
+
604807628,
|
|
534
|
+
770255983,
|
|
535
|
+
1249150122,
|
|
536
|
+
1555081692,
|
|
537
|
+
1996064986,
|
|
538
|
+
2554220882,
|
|
539
|
+
2821834349,
|
|
540
|
+
2952996808,
|
|
541
|
+
3210313671,
|
|
542
|
+
3336571891,
|
|
543
|
+
3584528711,
|
|
544
|
+
113926993,
|
|
545
|
+
338241895,
|
|
546
|
+
666307205,
|
|
547
|
+
773529912,
|
|
548
|
+
1294757372,
|
|
549
|
+
1396182291,
|
|
550
|
+
1695183700,
|
|
551
|
+
1986661051,
|
|
552
|
+
2177026350,
|
|
553
|
+
2456956037,
|
|
554
|
+
2730485921,
|
|
555
|
+
2820302411,
|
|
556
|
+
3259730800,
|
|
557
|
+
3345764771,
|
|
558
|
+
3516065817,
|
|
559
|
+
3600352804,
|
|
560
|
+
4094571909,
|
|
561
|
+
275423344,
|
|
562
|
+
430227734,
|
|
563
|
+
506948616,
|
|
564
|
+
659060556,
|
|
565
|
+
883997877,
|
|
566
|
+
958139571,
|
|
567
|
+
1322822218,
|
|
568
|
+
1537002063,
|
|
569
|
+
1747873779,
|
|
570
|
+
1955562222,
|
|
571
|
+
2024104815,
|
|
572
|
+
2227730452,
|
|
573
|
+
2361852424,
|
|
574
|
+
2428436474,
|
|
575
|
+
2756734187,
|
|
576
|
+
3204031479,
|
|
577
|
+
3329325298
|
|
578
|
+
]);
|
|
579
|
+
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
580
|
+
function utf8(text2) {
|
|
581
|
+
const out = [];
|
|
582
|
+
for (const char of text2) {
|
|
583
|
+
let cp = char.codePointAt(0);
|
|
584
|
+
if (cp >= 55296 && cp <= 57343)
|
|
585
|
+
cp = 65533;
|
|
586
|
+
if (cp < 128)
|
|
587
|
+
out.push(cp);
|
|
588
|
+
else if (cp < 2048)
|
|
589
|
+
out.push(192 | cp >> 6, 128 | cp & 63);
|
|
590
|
+
else if (cp < 65536)
|
|
591
|
+
out.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
592
|
+
else
|
|
593
|
+
out.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
|
|
594
|
+
}
|
|
595
|
+
return Uint8Array.from(out);
|
|
596
|
+
}
|
|
597
|
+
function sha256Hex(input) {
|
|
598
|
+
const isBytes = Object.prototype.toString.call(input) === "[object Uint8Array]";
|
|
599
|
+
if (typeof input !== "string" && !isBytes)
|
|
600
|
+
throw new TypeError("sha256Hex takes a string or a Uint8Array.");
|
|
601
|
+
const bytes = typeof input === "string" ? utf8(input) : input;
|
|
602
|
+
const length = bytes.length;
|
|
603
|
+
const padded = new Uint8Array((length + 8 >> 6) + 1 << 6);
|
|
604
|
+
padded.set(bytes);
|
|
605
|
+
padded[length] = 128;
|
|
606
|
+
const view = new DataView(padded.buffer);
|
|
607
|
+
view.setUint32(padded.length - 8, Math.floor(length / 536870912));
|
|
608
|
+
view.setUint32(padded.length - 4, length << 3 >>> 0);
|
|
609
|
+
const H = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
|
|
610
|
+
const W = new Uint32Array(64);
|
|
611
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
612
|
+
for (let t = 0; t < 16; t++)
|
|
613
|
+
W[t] = view.getUint32(offset + t * 4);
|
|
614
|
+
for (let t = 16; t < 64; t++) {
|
|
615
|
+
const s0 = rotr(W[t - 15], 7) ^ rotr(W[t - 15], 18) ^ W[t - 15] >>> 3;
|
|
616
|
+
const s1 = rotr(W[t - 2], 17) ^ rotr(W[t - 2], 19) ^ W[t - 2] >>> 10;
|
|
617
|
+
W[t] = W[t - 16] + s0 + W[t - 7] + s1 >>> 0;
|
|
618
|
+
}
|
|
619
|
+
let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];
|
|
620
|
+
for (let t = 0; t < 64; t++) {
|
|
621
|
+
const t1 = h + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + (e & f ^ ~e & g) + K[t] + W[t] >>> 0;
|
|
622
|
+
const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
623
|
+
h = g;
|
|
624
|
+
g = f;
|
|
625
|
+
f = e;
|
|
626
|
+
e = d + t1 >>> 0;
|
|
627
|
+
d = c;
|
|
628
|
+
c = b;
|
|
629
|
+
b = a;
|
|
630
|
+
a = t1 + t2 >>> 0;
|
|
631
|
+
}
|
|
632
|
+
H[0] += a;
|
|
633
|
+
H[1] += b;
|
|
634
|
+
H[2] += c;
|
|
635
|
+
H[3] += d;
|
|
636
|
+
H[4] += e;
|
|
637
|
+
H[5] += f;
|
|
638
|
+
H[6] += g;
|
|
639
|
+
H[7] += h;
|
|
640
|
+
}
|
|
641
|
+
return Array.from(H, (word) => word.toString(16).padStart(8, "0")).join("");
|
|
642
|
+
}
|
|
643
|
+
// src/rsa-pkcs1v15.js
|
|
644
|
+
var RsaPkcs1v15Error = class extends Error {
|
|
645
|
+
constructor(reason) {
|
|
646
|
+
super("RSA PKCS#1 v1.5 encryption refused.");
|
|
647
|
+
this.name = "RsaPkcs1v15Error";
|
|
648
|
+
this.code = "rsa_pkcs1v15_refused";
|
|
649
|
+
this.reason = reason;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
var refuse6 = (reason) => new RsaPkcs1v15Error(reason);
|
|
653
|
+
var BASE64 = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
654
|
+
var SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
655
|
+
var RSA_ALGORITHM = [48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0];
|
|
656
|
+
var MODULUS_BYTES = [128, 256, 384, 512];
|
|
657
|
+
var TYPED_ARRAY = Object.getPrototypeOf(Uint8Array.prototype);
|
|
658
|
+
var typedArrayName = Object.getOwnPropertyDescriptor(TYPED_ARRAY, Symbol.toStringTag).get;
|
|
659
|
+
function parseRsaPublicKey(key) {
|
|
660
|
+
const spki = key && typeof key === "object" ? key.spki : void 0;
|
|
661
|
+
const pin3 = key && typeof key === "object" ? key.sha256 : void 0;
|
|
662
|
+
if (typeof spki !== "string" || spki.length > 1024 || spki.length % 4 !== 0 || !BASE64.test(spki))
|
|
663
|
+
throw refuse6("key");
|
|
664
|
+
if (typeof pin3 !== "string" || !SHA256_HEX.test(pin3))
|
|
665
|
+
throw refuse6("key");
|
|
666
|
+
let binary;
|
|
667
|
+
try {
|
|
668
|
+
binary = atob(spki);
|
|
669
|
+
}
|
|
670
|
+
catch {
|
|
671
|
+
throw refuse6("key");
|
|
672
|
+
}
|
|
673
|
+
if (btoa(binary) !== spki)
|
|
674
|
+
throw refuse6("key");
|
|
675
|
+
const der = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
676
|
+
if (sha256Hex(der) !== pin3)
|
|
677
|
+
throw refuse6("key");
|
|
678
|
+
const outer = readElement(der, 0, 48);
|
|
679
|
+
if (outer.end !== der.length || outer.start + RSA_ALGORITHM.length > der.length)
|
|
680
|
+
throw refuse6("key");
|
|
681
|
+
if (!RSA_ALGORITHM.every((byte, i) => der[outer.start + i] === byte))
|
|
682
|
+
throw refuse6("key");
|
|
683
|
+
const bits = readElement(der, outer.start + RSA_ALGORITHM.length, 3);
|
|
684
|
+
if (bits.end !== outer.end || bits.start === bits.end || der[bits.start] !== 0)
|
|
685
|
+
throw refuse6("key");
|
|
686
|
+
const rsa = readElement(der, bits.start + 1, 48);
|
|
687
|
+
if (rsa.end !== bits.end)
|
|
688
|
+
throw refuse6("key");
|
|
689
|
+
const modulus = readPositiveInteger(der, rsa.start);
|
|
690
|
+
const exponent = readPositiveInteger(der, modulus.end);
|
|
691
|
+
if (exponent.end !== rsa.end)
|
|
692
|
+
throw refuse6("key");
|
|
693
|
+
const n = modulus.bytes;
|
|
694
|
+
if (!MODULUS_BYTES.includes(n.length) || !(n[0] & 128) || !(n[n.length - 1] & 1))
|
|
695
|
+
throw refuse6("key");
|
|
696
|
+
const e = exponent.bytes;
|
|
697
|
+
if (e.length !== 3 || e[0] !== 1 || e[1] !== 0 || e[2] !== 1)
|
|
698
|
+
throw refuse6("key");
|
|
699
|
+
return Object.freeze({ n: toBigInt(n), e: 65537n, size: n.length });
|
|
700
|
+
}
|
|
701
|
+
function readElement(der, at, tag) {
|
|
702
|
+
if (at + 2 > der.length || der[at] !== tag)
|
|
703
|
+
throw refuse6("key");
|
|
704
|
+
let length = der[at + 1];
|
|
705
|
+
let start = at + 2;
|
|
706
|
+
if (length & 128) {
|
|
707
|
+
const count = length & 127;
|
|
708
|
+
if (count === 0 || count > 2 || start + count > der.length || der[start] === 0)
|
|
709
|
+
throw refuse6("key");
|
|
710
|
+
length = count === 1 ? der[start] : der[start] * 256 + der[start + 1];
|
|
711
|
+
if (length < 128)
|
|
712
|
+
throw refuse6("key");
|
|
713
|
+
start += count;
|
|
714
|
+
}
|
|
715
|
+
if (start + length > der.length)
|
|
716
|
+
throw refuse6("key");
|
|
717
|
+
return { start, end: start + length };
|
|
718
|
+
}
|
|
719
|
+
function readPositiveInteger(der, at) {
|
|
720
|
+
const { start, end } = readElement(der, at, 2);
|
|
721
|
+
if (end === start || der[start] & 128)
|
|
722
|
+
throw refuse6("key");
|
|
723
|
+
if (der[start] === 0 && (end - start === 1 || !(der[start + 1] & 128)))
|
|
724
|
+
throw refuse6("key");
|
|
725
|
+
return { bytes: der.subarray(der[start] === 0 ? start + 1 : start, end), end };
|
|
726
|
+
}
|
|
727
|
+
function toBigInt(bytes) {
|
|
728
|
+
let hex = "";
|
|
729
|
+
for (let i = 0; i < bytes.length; i++)
|
|
730
|
+
hex += (bytes[i] < 16 ? "0" : "") + bytes[i].toString(16);
|
|
731
|
+
return BigInt(`0x${hex}`);
|
|
732
|
+
}
|
|
733
|
+
// src/paddle-keys.js
|
|
734
|
+
var PADDLE_TOKENEX_KEYS = /* @__PURE__ */ Object.freeze({
|
|
735
|
+
sandbox: Object.freeze({
|
|
736
|
+
spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvWpIQFjQQCPpaIlJKpegirp5kLkzLB1AxHmnLk73D3TJbAGqr1QmlsWDBtMPMRpdzzUM7ZwX3kzhIuATV4Pe7RKp3nZlVmcrT0YCQXBrTwqZNh775z58GP2kZs+gVfNqBampJPzSB/hB62KkByhECn6grrRjiAVwJyZVEvs/2vrxaEpO+aE16emtX12RgI5JdzdOiNyZEQteU6zRBRJEocPWVxExaOpVVVJ5+UnW0LcalzA+lRGRTrQJ5JguAPiAOzRPTK/lYFFpCAl/F8wtoAVG1c8zO2NcQ0Pko+fmeidRFxJ/did2btV+9Mkze3mBphwFmvnxa35LF+Cs/XJHDwIDAQAB",
|
|
737
|
+
sha256: "877d29a008ed9998d6035032870c63dcc4cbf37ca22cb50b0cc9fe2250a9e3dc"
|
|
738
|
+
}),
|
|
739
|
+
production: Object.freeze({
|
|
740
|
+
spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8gGPMwBRPuVyJReZGIkWH/+Bf5pnpDN1bSR2cLYLXVT8CaSnTw74qeboSnktgYCi1D9R3Bj2fYzTIwGGZb8KinLdxwbqZmHwrE9cFhCaHbG/E0PbqQGhXP2vbniZTT4M0i0Cbi7ES3Bw5zqNbIZZnX041QEpxLvIyWPKZCX+fBogNMhWfCF779aclChjHkwZMsufThVWE9xklWGxXiytx5aL4I5JPxq0I7cAkZGGs4aF/GxWwPaq7R3wPikJQ0YHnCMfcURzl2Hnw/inqyMy+JB6djTq2/BdzMAhWTh3cDWq9Xu+gEkb/QCd0n1yYIdKuDISlk/AfHdWe34IvzhVyQIDAQAB",
|
|
741
|
+
sha256: "92529bd289bb24d52a1bdcc42edc9ac0bb1dacbb58f7568573d44771e1287762"
|
|
742
|
+
})
|
|
743
|
+
});
|
|
744
|
+
function paddleTokenexKey(environment) {
|
|
745
|
+
if (environment !== "sandbox" && environment !== "production")
|
|
746
|
+
return null;
|
|
747
|
+
return PADDLE_TOKENEX_KEYS[environment] ?? null;
|
|
748
|
+
}
|
|
749
|
+
function paddleTokenexKeyBytes(environment) {
|
|
750
|
+
const key = paddleTokenexKey(environment);
|
|
751
|
+
if (!key)
|
|
752
|
+
return null;
|
|
753
|
+
try {
|
|
754
|
+
return parseRsaPublicKey(key).size;
|
|
755
|
+
}
|
|
756
|
+
catch {
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
// src/paddle-tokenex.js
|
|
761
|
+
var PADDLE_TOKENEX_PSP = "paddle_tokenex";
|
|
762
|
+
var PADDLE_TOKENEX_FACT_KEYS = /* @__PURE__ */ Object.freeze(["card_first_six", "card_last_four", "expiry_month", "expiry_year", "card_brand"]);
|
|
763
|
+
var record4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
764
|
+
var sameKeys2 = (value, keys) => {
|
|
765
|
+
const own = Object.keys(value);
|
|
766
|
+
return own.length === keys.length && own.every((key, at) => key === keys[at]);
|
|
767
|
+
};
|
|
768
|
+
var refuse7 = (code) => Object.freeze({ verdict: "refuse", code });
|
|
769
|
+
var CARD6 = /* @__PURE__ */ Object.freeze({ verdict: "card" });
|
|
770
|
+
var CONTINUE2 = /* @__PURE__ */ Object.freeze({ verdict: "continue" });
|
|
771
|
+
var PAY_URL = /^https:\/\/(sandbox-)?checkout-service\.paddle\.com\/(checkout|transaction-checkout)\/[A-Za-z0-9_-]{1,64}\/pay$/;
|
|
772
|
+
function paddleTokenexPayTarget(url) {
|
|
773
|
+
const match = typeof url === "string" ? PAY_URL.exec(url) : null;
|
|
774
|
+
return match ? Object.freeze({ environment: match[1] ? "sandbox" : "production", line: match[2] === "checkout" ? "classic" : "billing" }) : null;
|
|
775
|
+
}
|
|
776
|
+
function paddleTokenexPayCarriesCard(body) {
|
|
777
|
+
if (typeof body !== "string")
|
|
778
|
+
return true;
|
|
779
|
+
try {
|
|
780
|
+
return JSON.stringify(JSON.parse(body)).includes('"tokenex_card"');
|
|
781
|
+
}
|
|
782
|
+
catch {
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
var FRAME_BRANDS = /* @__PURE__ */ Object.freeze(["visa", "master", "american_express", "discover", "diners_club", "jcb", "maestro", "dankort", "unionpay", "unknown"]);
|
|
787
|
+
var NAME_LIMIT2 = 256;
|
|
788
|
+
var CONTROL2 = /[\u0000-\u001f\u007f]/;
|
|
789
|
+
var FIRST_SIX = /^[0-9]{6}$/;
|
|
790
|
+
var LAST_FOUR = /^[0-9]{4}$/;
|
|
791
|
+
var BASE642 = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
792
|
+
var cardLikeName2 = (name) => (name.match(/[0-9]/g) ?? []).length >= 12;
|
|
793
|
+
var expiryMonth = (month) => Number.isInteger(month) && month >= 1 && month <= 12;
|
|
794
|
+
var expiryYear = (year) => Number.isInteger(year) && year >= 2e3 && year <= 2099;
|
|
795
|
+
var PAY_BODY_LIMIT = 16384;
|
|
796
|
+
var PAY_DATA_KEYS = /* @__PURE__ */ Object.freeze(["payment_method_type", "payment_method_data"]);
|
|
797
|
+
var PAY_CARD_KEYS = /* @__PURE__ */ Object.freeze(["metadata", "three_d_s", "tokenex_card"]);
|
|
798
|
+
var METADATA_KEYS2 = /* @__PURE__ */ Object.freeze(["cardholder_name", ...PADDLE_TOKENEX_FACT_KEYS]);
|
|
799
|
+
var CARD_KEYS3 = /* @__PURE__ */ Object.freeze(["encrypted_card_number", "encrypted_cvv"]);
|
|
800
|
+
var BROWSER_INFO = /^[A-Za-z0-9+/]{1,4096}={0,2}$/;
|
|
801
|
+
var RADAR_TOKEN = /^[\x21-\x7e]{1,512}$/;
|
|
802
|
+
var COUNTRY_CODE = /^[A-Za-z]{2}$/;
|
|
803
|
+
var FRONTEND_HOST = /^https:\/\/[\x21-\x7e]{1,1024}$/;
|
|
804
|
+
var radarKeys = (value) => sameKeys2(value, ["token", "country_code"]) || sameKeys2(value, ["country_code", "token"]);
|
|
805
|
+
function isBase64OfBytes(value, bytes) {
|
|
806
|
+
if (typeof value !== "string" || value.length !== Math.ceil(bytes / 3) * 4 || !BASE642.test(value))
|
|
807
|
+
return false;
|
|
808
|
+
const pad = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
809
|
+
return value.length / 4 * 3 - pad === bytes && btoa(atob(value)) === value;
|
|
810
|
+
}
|
|
811
|
+
function isPaddleTokenexCiphertext(value, environment) {
|
|
812
|
+
const bytes = paddleTokenexKeyBytes(environment);
|
|
813
|
+
return bytes !== null && isBase64OfBytes(value, bytes);
|
|
814
|
+
}
|
|
815
|
+
function readPay(body, line, environment) {
|
|
816
|
+
if (typeof body !== "string" || body === "" || body.length > PAY_BODY_LIMIT)
|
|
817
|
+
return null;
|
|
818
|
+
let value;
|
|
819
|
+
try {
|
|
820
|
+
value = JSON.parse(body);
|
|
821
|
+
if (!record4(value) || JSON.stringify(value) !== body)
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
catch {
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
const data = value.data;
|
|
828
|
+
if (!sameKeys2(value, ["data"]) || !record4(data) || !(sameKeys2(data, PAY_DATA_KEYS) || sameKeys2(data, [...PAY_DATA_KEYS, "checkout"])) || data.payment_method_type !== (line === "classic" ? "CARD" : "card"))
|
|
829
|
+
return null;
|
|
830
|
+
if (data.checkout !== void 0 && !(record4(data.checkout) && sameKeys2(data.checkout, ["frontend_host"]) && typeof data.checkout.frontend_host === "string" && FRONTEND_HOST.test(data.checkout.frontend_host)))
|
|
831
|
+
return null;
|
|
832
|
+
const method = data.payment_method_data;
|
|
833
|
+
const card = record4(method) && sameKeys2(method, ["card"]) ? method.card : null;
|
|
834
|
+
if (!record4(card) || !(sameKeys2(card, PAY_CARD_KEYS) || sameKeys2(card, [...PAY_CARD_KEYS, "session_tracking"])))
|
|
835
|
+
return null;
|
|
836
|
+
const metadata = card.metadata;
|
|
837
|
+
if (!record4(metadata) || !sameKeys2(metadata, METADATA_KEYS2) || typeof metadata.cardholder_name !== "string" || metadata.cardholder_name.length > NAME_LIMIT2 || CONTROL2.test(metadata.cardholder_name) || cardLikeName2(metadata.cardholder_name) || typeof metadata.card_first_six !== "string" || !FIRST_SIX.test(metadata.card_first_six) || typeof metadata.card_last_four !== "string" || !LAST_FOUR.test(metadata.card_last_four) || !expiryMonth(metadata.expiry_month) || !expiryYear(metadata.expiry_year) || !FRAME_BRANDS.includes(metadata.card_brand))
|
|
838
|
+
return null;
|
|
839
|
+
const details = card.three_d_s;
|
|
840
|
+
if (!record4(details) || !sameKeys2(details, ["browser_info"]) || typeof details.browser_info !== "string" || !BROWSER_INFO.test(details.browser_info))
|
|
841
|
+
return null;
|
|
842
|
+
const tokenex = card.tokenex_card;
|
|
843
|
+
if (!record4(tokenex) || !sameKeys2(tokenex, CARD_KEYS3))
|
|
844
|
+
return null;
|
|
845
|
+
for (const name of CARD_KEYS3) {
|
|
846
|
+
const blob = tokenex[name];
|
|
847
|
+
if (environment === void 0) {
|
|
848
|
+
if (typeof blob !== "string" || !BASE642.test(blob) || blob.length < 4 || blob.length > 4096)
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
else if (!isPaddleTokenexCiphertext(blob, environment))
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
if (tokenex.encrypted_card_number === tokenex.encrypted_cvv)
|
|
855
|
+
return null;
|
|
856
|
+
if (card.session_tracking !== void 0) {
|
|
857
|
+
const tracking = card.session_tracking;
|
|
858
|
+
const radar = record4(tracking) && sameKeys2(tracking, ["stripe_radar"]) ? tracking.stripe_radar : null;
|
|
859
|
+
if (!record4(radar) || !radarKeys(radar) || typeof radar.token !== "string" || !RADAR_TOKEN.test(radar.token) || typeof radar.country_code !== "string" || !COUNTRY_CODE.test(radar.country_code))
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
return value;
|
|
863
|
+
}
|
|
864
|
+
function paddleTokenexBodyVerdict(body, line) {
|
|
865
|
+
if (!paddleTokenexPayCarriesCard(body))
|
|
866
|
+
return CONTINUE2;
|
|
867
|
+
for (const candidate of line === "classic" || line === "billing" ? [line] : ["classic", "billing"]) {
|
|
868
|
+
if (readPay(body, candidate) !== null)
|
|
869
|
+
return CARD6;
|
|
870
|
+
}
|
|
871
|
+
return refuse7("paddle_tokenex_pay_unsupported");
|
|
872
|
+
}
|
|
873
|
+
var CARD_PATH = /* @__PURE__ */ Object.freeze(["data", "payment_method_data", "card"]);
|
|
874
|
+
var TOKENEX_PATH = /* @__PURE__ */ Object.freeze([...CARD_PATH, "tokenex_card"]);
|
|
875
|
+
// src/lyra.js
|
|
876
|
+
var LYRA_PSP = "lyra";
|
|
877
|
+
var LYRA_PROCESS_PATH = "/api-payment/V4/Charge/Public/ProcessPayment/2";
|
|
878
|
+
var LYRA_HOSTS = /* @__PURE__ */ Object.freeze({
|
|
879
|
+
"api.payzen.eu": Object.freeze({ staticOrigin: "https://static.payzen.eu", prefixes: Object.freeze(["01", "02"]) }),
|
|
880
|
+
"api.systempay.fr": Object.freeze({ staticOrigin: "https://static.systempay.fr", prefixes: Object.freeze(["24", "25"]) }),
|
|
881
|
+
"api-sogecommerce.societegenerale.eu": Object.freeze({ staticOrigin: "https://static-sogecommerce.societegenerale.eu", prefixes: Object.freeze(["06", "07"]) }),
|
|
882
|
+
"api.lyra.com": Object.freeze({ staticOrigin: "https://static.lyra.com", prefixes: Object.freeze(["10", "11"]) })
|
|
883
|
+
});
|
|
884
|
+
var BODY_LIMIT4 = 32768;
|
|
885
|
+
var TOKEN = /^([0-9a-z]{2})[0-9A-Za-z]([A-Za-z0-9_-]{64,16384})$/;
|
|
886
|
+
var SESSION = /^[A-Za-z0-9._-]{1,128}$/;
|
|
887
|
+
var PUBLIC_KEY = /^([0-9]{4,12}):(testpublickey|publickey)_[A-Za-z0-9]{1,128}$/;
|
|
888
|
+
var REMOTE_ID = /^[0-9a-f]{32}$/;
|
|
889
|
+
var CARD_NUMBER5 = /^[0-9]{12,19}$/;
|
|
890
|
+
var SECURITY_CODE4 = /^[0-9]{3,4}$/;
|
|
891
|
+
var MONTH2 = /^(?:0[1-9]|1[0-2])$/;
|
|
892
|
+
var YEAR2 = /^20[0-9]{2}$/;
|
|
893
|
+
var BRAND = /^[A-Z][A-Z0-9_-]{1,31}$/;
|
|
894
|
+
var CONTROL3 = /[\u0000-\u001f\u007f]/;
|
|
895
|
+
var PAN_LIKE2 = /(?:[0-9][ _.:-]*){12,}/;
|
|
896
|
+
var CARD_KEYS4 = /* @__PURE__ */ Object.freeze([
|
|
897
|
+
"formToken",
|
|
898
|
+
"clientVersion",
|
|
899
|
+
"kryptonCallbackUrl",
|
|
900
|
+
"language",
|
|
901
|
+
"paymentForm",
|
|
902
|
+
"postUrl",
|
|
903
|
+
"publicKey",
|
|
904
|
+
"remoteId",
|
|
905
|
+
"wsUser",
|
|
906
|
+
"refererUrl",
|
|
907
|
+
"challengePreference",
|
|
908
|
+
"device",
|
|
909
|
+
"partialPaymentsAllowed",
|
|
910
|
+
"paymentMethodCloseButton",
|
|
911
|
+
"skipPaymentTicket"
|
|
912
|
+
]);
|
|
913
|
+
var CARD_REQUIRED = /* @__PURE__ */ Object.freeze(["formToken", "paymentForm", "publicKey", "remoteId"]);
|
|
914
|
+
var PAYMENT_FORM_KEYS = /* @__PURE__ */ Object.freeze(["pan", "securityCode", "cardHolderName", "expiryMonth", "expiryYear", "brand"]);
|
|
915
|
+
var FOLLOW_UP_KEYS = /* @__PURE__ */ Object.freeze([
|
|
916
|
+
"formToken",
|
|
917
|
+
"publicKey",
|
|
918
|
+
"instructionResult",
|
|
919
|
+
"remoteId",
|
|
920
|
+
"clientVersion",
|
|
921
|
+
"device",
|
|
922
|
+
"wsUser",
|
|
923
|
+
"partialPaymentsAllowed",
|
|
924
|
+
"paymentMethodCloseButton",
|
|
925
|
+
"skipPaymentTicket"
|
|
926
|
+
]);
|
|
927
|
+
var FOLLOW_UP_REQUIRED = /* @__PURE__ */ Object.freeze(["formToken", "publicKey", "instructionResult", "remoteId"]);
|
|
928
|
+
var INSTRUCTION_RESULT_KEYS = /* @__PURE__ */ Object.freeze(["name", "value", "protocol"]);
|
|
929
|
+
var DEVICE_KEYS = /* @__PURE__ */ Object.freeze([
|
|
930
|
+
"deviceType",
|
|
931
|
+
"acceptHeader",
|
|
932
|
+
"userAgent",
|
|
933
|
+
"javaEnabled",
|
|
934
|
+
"language",
|
|
935
|
+
"colorDepth",
|
|
936
|
+
"screenHeight",
|
|
937
|
+
"screenWidth",
|
|
938
|
+
"timeZoneOffset"
|
|
939
|
+
]);
|
|
940
|
+
var TEXT_MEMBERS = /* @__PURE__ */ Object.freeze({
|
|
941
|
+
clientVersion: 64,
|
|
942
|
+
language: 16,
|
|
943
|
+
postUrl: 2048,
|
|
944
|
+
wsUser: 32,
|
|
945
|
+
refererUrl: 2048,
|
|
946
|
+
challengePreference: 64,
|
|
947
|
+
paymentMethodCloseButton: 32
|
|
948
|
+
});
|
|
949
|
+
var BOOLEAN_MEMBERS = /* @__PURE__ */ Object.freeze(["partialPaymentsAllowed", "skipPaymentTicket"]);
|
|
950
|
+
var CALLBACK_PATH = "/static/js/krypton-client/V4.0/done/done.html";
|
|
951
|
+
var record5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
952
|
+
var owns4 = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
953
|
+
var keysWithin = (value, allowed) => record5(value) && Object.keys(value).every((key) => allowed.includes(key));
|
|
954
|
+
var text = (value, max) => typeof value === "string" && value.length <= max && !CONTROL3.test(value);
|
|
955
|
+
var refuse8 = (code) => Object.freeze({ verdict: "refuse", code });
|
|
956
|
+
var CARD7 = /* @__PURE__ */ Object.freeze({ verdict: "card" });
|
|
957
|
+
var CONTINUE3 = /* @__PURE__ */ Object.freeze({ verdict: "continue" });
|
|
958
|
+
function lyraProcessPaymentUrl(url) {
|
|
959
|
+
if (typeof url !== "string" || url.length > 512 || url.includes("?") || url.includes("#"))
|
|
960
|
+
return null;
|
|
961
|
+
let parsed;
|
|
962
|
+
try {
|
|
963
|
+
parsed = new URL(url);
|
|
964
|
+
}
|
|
965
|
+
catch {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
if (parsed.href !== url || parsed.protocol !== "https:" || parsed.port || parsed.username || parsed.password || !owns4(LYRA_HOSTS, parsed.hostname))
|
|
969
|
+
return null;
|
|
970
|
+
const path = parsed.pathname;
|
|
971
|
+
if (path === LYRA_PROCESS_PATH)
|
|
972
|
+
return Object.freeze({ host: parsed.hostname, session: null });
|
|
973
|
+
const marker = `${LYRA_PROCESS_PATH};jsessionid=`;
|
|
974
|
+
if (!path.startsWith(marker))
|
|
975
|
+
return null;
|
|
976
|
+
const session = path.slice(marker.length);
|
|
977
|
+
return SESSION.test(session) ? Object.freeze({ host: parsed.hostname, session }) : null;
|
|
978
|
+
}
|
|
979
|
+
function base64UrlBytes(input) {
|
|
980
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
981
|
+
const bytes = [];
|
|
982
|
+
let bits = 0;
|
|
983
|
+
let value = 0;
|
|
984
|
+
for (const character of input) {
|
|
985
|
+
const sextet = alphabet.indexOf(character);
|
|
986
|
+
if (sextet < 0)
|
|
987
|
+
return null;
|
|
988
|
+
value = value << 6 | sextet;
|
|
989
|
+
bits += 6;
|
|
990
|
+
if (bits >= 8) {
|
|
991
|
+
bits -= 8;
|
|
992
|
+
bytes.push(value >> bits & 255);
|
|
993
|
+
value &= (1 << bits) - 1;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return bytes;
|
|
997
|
+
}
|
|
998
|
+
function jsonObjectText(bytes, start) {
|
|
999
|
+
let depth = 0;
|
|
1000
|
+
let inString = false;
|
|
1001
|
+
let escaped = false;
|
|
1002
|
+
for (let at = start; at < bytes.length; at += 1) {
|
|
1003
|
+
const byte = bytes[at];
|
|
1004
|
+
if (inString) {
|
|
1005
|
+
if (escaped)
|
|
1006
|
+
escaped = false;
|
|
1007
|
+
else if (byte === 92)
|
|
1008
|
+
escaped = true;
|
|
1009
|
+
else if (byte === 34)
|
|
1010
|
+
inString = false;
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
if (byte === 34)
|
|
1014
|
+
inString = true;
|
|
1015
|
+
else if (byte === 123)
|
|
1016
|
+
depth += 1;
|
|
1017
|
+
else if (byte === 125) {
|
|
1018
|
+
depth -= 1;
|
|
1019
|
+
if (depth === 0) {
|
|
1020
|
+
try {
|
|
1021
|
+
return decodeURIComponent(bytes.slice(start, at + 1).map((b) => "%" + b.toString(16).padStart(2, "0")).join(""));
|
|
1022
|
+
}
|
|
1023
|
+
catch {
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return null;
|
|
1030
|
+
}
|
|
1031
|
+
function lyraFormTokenFacts(token) {
|
|
1032
|
+
const match = typeof token === "string" ? TOKEN.exec(token) : null;
|
|
1033
|
+
const bytes = match ? base64UrlBytes(match[2]) : null;
|
|
1034
|
+
if (!bytes || bytes.length < 20 || bytes[18] !== 123)
|
|
1035
|
+
return null;
|
|
1036
|
+
const json = jsonObjectText(bytes, 18);
|
|
1037
|
+
let dna;
|
|
1038
|
+
try {
|
|
1039
|
+
dna = json === null ? null : JSON.parse(json);
|
|
1040
|
+
}
|
|
1041
|
+
catch {
|
|
1042
|
+
return null;
|
|
1043
|
+
}
|
|
1044
|
+
if (!record5(dna) || !Number.isSafeInteger(dna.amount) || dna.amount < 0 || typeof dna.currency !== "string" || !/^[A-Z]{3}$/.test(dna.currency) || dna.mode !== "TEST" && dna.mode !== "PRODUCTION" || typeof dna.formAction !== "string" || !/^[A-Z_]{1,32}$/.test(dna.formAction) || owns4(dna, "jSessionId") && (typeof dna.jSessionId !== "string" || !SESSION.test(dna.jSessionId)))
|
|
1045
|
+
return null;
|
|
1046
|
+
return Object.freeze({
|
|
1047
|
+
prefix: match[1],
|
|
1048
|
+
amount: dna.amount,
|
|
1049
|
+
currency: dna.currency,
|
|
1050
|
+
mode: dna.mode,
|
|
1051
|
+
formAction: dna.formAction,
|
|
1052
|
+
session: owns4(dna, "jSessionId") ? dna.jSessionId : null
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
function readJson(body) {
|
|
1056
|
+
if (typeof body !== "string" || body === "" || body.length > BODY_LIMIT4)
|
|
1057
|
+
return null;
|
|
1058
|
+
let at = 0;
|
|
1059
|
+
let nodes = 0;
|
|
1060
|
+
const fail = () => {
|
|
1061
|
+
throw new Error("invalid_lyra_json");
|
|
1062
|
+
};
|
|
1063
|
+
const space = () => {
|
|
1064
|
+
while (" \r\n".includes(body[at] ?? "\0"))
|
|
1065
|
+
at += 1;
|
|
1066
|
+
};
|
|
1067
|
+
const string = () => {
|
|
1068
|
+
space();
|
|
1069
|
+
const start = at;
|
|
1070
|
+
if (body[at++] !== '"')
|
|
1071
|
+
fail();
|
|
1072
|
+
while (at < body.length) {
|
|
1073
|
+
const character = body[at++];
|
|
1074
|
+
if (character === "\\") {
|
|
1075
|
+
at += 1;
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
if (character === '"')
|
|
1079
|
+
return JSON.parse(body.slice(start, at));
|
|
1080
|
+
}
|
|
1081
|
+
return fail();
|
|
1082
|
+
};
|
|
1083
|
+
const value = (depth) => {
|
|
1084
|
+
if (depth > 6 || ++nodes > 256)
|
|
1085
|
+
fail();
|
|
1086
|
+
space();
|
|
1087
|
+
const character = body[at];
|
|
1088
|
+
if (character === '"')
|
|
1089
|
+
return string();
|
|
1090
|
+
if (character === "{") {
|
|
1091
|
+
at += 1;
|
|
1092
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
1093
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1094
|
+
space();
|
|
1095
|
+
if (body[at] === "}") {
|
|
1096
|
+
at += 1;
|
|
1097
|
+
return result;
|
|
1098
|
+
}
|
|
1099
|
+
for (;;) {
|
|
1100
|
+
const key = string();
|
|
1101
|
+
if (seen.has(key) || ["__proto__", "prototype", "constructor"].includes(key))
|
|
1102
|
+
fail();
|
|
1103
|
+
seen.add(key);
|
|
1104
|
+
space();
|
|
1105
|
+
if (body[at++] !== ":")
|
|
1106
|
+
fail();
|
|
1107
|
+
result[key] = value(depth + 1);
|
|
1108
|
+
space();
|
|
1109
|
+
const next = body[at++];
|
|
1110
|
+
if (next === "}")
|
|
1111
|
+
return result;
|
|
1112
|
+
if (next !== ",")
|
|
1113
|
+
fail();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
if (character === "[") {
|
|
1117
|
+
at += 1;
|
|
1118
|
+
const result = [];
|
|
1119
|
+
space();
|
|
1120
|
+
if (body[at] === "]") {
|
|
1121
|
+
at += 1;
|
|
1122
|
+
return result;
|
|
1123
|
+
}
|
|
1124
|
+
for (;;) {
|
|
1125
|
+
result.push(value(depth + 1));
|
|
1126
|
+
space();
|
|
1127
|
+
const next = body[at++];
|
|
1128
|
+
if (next === "]")
|
|
1129
|
+
return result;
|
|
1130
|
+
if (next !== ",")
|
|
1131
|
+
fail();
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
for (const literal of ["true", "false", "null"]) {
|
|
1135
|
+
if (body.startsWith(literal, at)) {
|
|
1136
|
+
at += literal.length;
|
|
1137
|
+
return JSON.parse(literal);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
const number = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(body.slice(at, at + 32));
|
|
1141
|
+
if (!number)
|
|
1142
|
+
fail();
|
|
1143
|
+
at += number[0].length;
|
|
1144
|
+
const parsed = Number(number[0]);
|
|
1145
|
+
if (!Number.isFinite(parsed))
|
|
1146
|
+
fail();
|
|
1147
|
+
return parsed;
|
|
1148
|
+
};
|
|
1149
|
+
try {
|
|
1150
|
+
const parsed = value(0);
|
|
1151
|
+
space();
|
|
1152
|
+
return at === body.length && record5(parsed) ? parsed : null;
|
|
1153
|
+
}
|
|
1154
|
+
catch {
|
|
1155
|
+
return null;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
function namesCard(root) {
|
|
1159
|
+
const pending = [root];
|
|
1160
|
+
while (pending.length > 0) {
|
|
1161
|
+
const node = pending.pop();
|
|
1162
|
+
for (const key of Object.keys(node)) {
|
|
1163
|
+
if (!Array.isArray(node) && /^(?:pan|cardnumber|card_number|number|securitycode|cvv|cvc|paymentform|paymentmethodtoken)$/i.test(key))
|
|
1164
|
+
return true;
|
|
1165
|
+
const child = node[key];
|
|
1166
|
+
if (child !== null && typeof child === "object")
|
|
1167
|
+
pending.push(child);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return false;
|
|
1171
|
+
}
|
|
1172
|
+
function sharedMembersReadable(value) {
|
|
1173
|
+
for (const [key, max] of Object.entries(TEXT_MEMBERS))
|
|
1174
|
+
if (owns4(value, key) && value[key] !== null && !text(value[key], max))
|
|
1175
|
+
return false;
|
|
1176
|
+
for (const key of BOOLEAN_MEMBERS)
|
|
1177
|
+
if (owns4(value, key) && value[key] !== null && typeof value[key] !== "boolean")
|
|
1178
|
+
return false;
|
|
1179
|
+
if (owns4(value, "device")) {
|
|
1180
|
+
const device = value.device;
|
|
1181
|
+
if (!keysWithin(device, DEVICE_KEYS))
|
|
1182
|
+
return false;
|
|
1183
|
+
for (const member of Object.values(device)) {
|
|
1184
|
+
if (!(member === null || text(member, 512) || typeof member === "boolean" || Number.isSafeInteger(member) && member >= 0 && member <= 1e5))
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
return true;
|
|
1189
|
+
}
|
|
1190
|
+
function followUpReadable(value) {
|
|
1191
|
+
const result = value.instructionResult;
|
|
1192
|
+
return keysWithin(value, FOLLOW_UP_KEYS) && FOLLOW_UP_REQUIRED.every((key) => owns4(value, key)) && text(value.formToken, 16384) && value.formToken !== "" && text(value.publicKey, 160) && value.publicKey !== "" && typeof value.remoteId === "string" && REMOTE_ID.test(value.remoteId) && sharedMembersReadable(value) && keysWithin(result, INSTRUCTION_RESULT_KEYS) && typeof result.name === "string" && /^[A-Z_]{1,32}$/.test(result.name) && (!owns4(result, "value") || result.value === null || text(result.value, 16384)) && (!owns4(result, "protocol") || result.protocol === null || record5(result.protocol)) && !namesCard(value);
|
|
1193
|
+
}
|
|
1194
|
+
function bindingHolds(facts, publicKey, target) {
|
|
1195
|
+
const key = PUBLIC_KEY.exec(publicKey);
|
|
1196
|
+
if (!key || facts.mode === "TEST" !== (key[2] === "testpublickey"))
|
|
1197
|
+
return false;
|
|
1198
|
+
if (target === void 0)
|
|
1199
|
+
return true;
|
|
1200
|
+
return LYRA_HOSTS[target.host].prefixes.includes(facts.prefix) && facts.session === target.session;
|
|
1201
|
+
}
|
|
1202
|
+
function lyraBodyVerdict(body, url) {
|
|
1203
|
+
let target;
|
|
1204
|
+
if (url !== void 0) {
|
|
1205
|
+
target = lyraProcessPaymentUrl(url);
|
|
1206
|
+
if (target === null)
|
|
1207
|
+
return refuse8("lyra_url_refused");
|
|
1208
|
+
}
|
|
1209
|
+
const value = readJson(body);
|
|
1210
|
+
if (value === null)
|
|
1211
|
+
return refuse8("lyra_body_unsupported");
|
|
1212
|
+
if (!owns4(value, "paymentForm"))
|
|
1213
|
+
return followUpReadable(value) ? CONTINUE3 : refuse8("lyra_body_unsupported");
|
|
1214
|
+
const form = value.paymentForm;
|
|
1215
|
+
if (!keysWithin(value, CARD_KEYS4) || !CARD_REQUIRED.every((key) => owns4(value, key)) || !sharedMembersReadable(value) || !keysWithin(form, PAYMENT_FORM_KEYS) || typeof form.pan !== "string" || !CARD_NUMBER5.test(form.pan) || typeof form.expiryMonth !== "string" || !MONTH2.test(form.expiryMonth) || typeof form.expiryYear !== "string" || !YEAR2.test(form.expiryYear) || owns4(form, "securityCode") && (typeof form.securityCode !== "string" || !SECURITY_CODE4.test(form.securityCode)) || owns4(form, "cardHolderName") && (!text(form.cardHolderName, 256) || PAN_LIKE2.test(form.cardHolderName)) || owns4(form, "brand") && (typeof form.brand !== "string" || !BRAND.test(form.brand)) || typeof value.remoteId !== "string" || !REMOTE_ID.test(value.remoteId) || typeof value.publicKey !== "string" || owns4(value, "kryptonCallbackUrl") && !Object.values(LYRA_HOSTS).some((entry) => value.kryptonCallbackUrl === `${entry.staticOrigin}${CALLBACK_PATH}`)) {
|
|
1216
|
+
return refuse8("lyra_body_unsupported");
|
|
1217
|
+
}
|
|
1218
|
+
const facts = lyraFormTokenFacts(value.formToken);
|
|
1219
|
+
if (facts === null)
|
|
1220
|
+
return refuse8("lyra_body_unsupported");
|
|
1221
|
+
if (facts.formAction !== "PAYMENT")
|
|
1222
|
+
return refuse8("lyra_keeps_card");
|
|
1223
|
+
if (!bindingHolds(facts, value.publicKey, target))
|
|
1224
|
+
return refuse8("lyra_session_mismatch");
|
|
1225
|
+
return CARD7;
|
|
1226
|
+
}
|
|
1227
|
+
var LYRA_MERCHANT_PINS = /* @__PURE__ */ Object.freeze([
|
|
1228
|
+
Object.freeze({
|
|
1229
|
+
id: "le_mas_lyon",
|
|
1230
|
+
merchant: "Association Le MAS",
|
|
1231
|
+
origins: Object.freeze(["https://www.mas-asso.fr"]),
|
|
1232
|
+
shopIds: Object.freeze(["95120524"]),
|
|
1233
|
+
hosts: Object.freeze(["api.systempay.fr"])
|
|
1234
|
+
})
|
|
1235
|
+
]);
|
|
409
1236
|
// src/card-fields.js
|
|
410
1237
|
function processorGate(recognizer, url, body) {
|
|
1238
|
+
if (recognizer && recognizer.psp === LYRA_PSP)
|
|
1239
|
+
return lyraBodyVerdict(body, url);
|
|
411
1240
|
if (recognizer && recognizer.psp === PADDLE_VGS_PSP) {
|
|
412
1241
|
if (url !== void 0 && !isPaddleVgsCardsUrl(url))
|
|
413
1242
|
return { verdict: "refuse", code: "paddle_vgs_url_refused" };
|
|
414
1243
|
return paddleVgsBodyVerdict(body);
|
|
415
1244
|
}
|
|
1245
|
+
if (recognizer && recognizer.psp === PAYFAST_PSP) {
|
|
1246
|
+
if (url !== void 0 && !isPayfastPayUrl(url))
|
|
1247
|
+
return { verdict: "refuse", code: "payfast_url_refused" };
|
|
1248
|
+
return payfastBodyVerdict(body);
|
|
1249
|
+
}
|
|
1250
|
+
if (recognizer && recognizer.psp === PADDLE_TOKENEX_PSP) {
|
|
1251
|
+
const target = url !== void 0 ? paddleTokenexPayTarget(url) : null;
|
|
1252
|
+
if (url !== void 0 && target === null)
|
|
1253
|
+
return { verdict: "refuse", code: "paddle_tokenex_pay_unsupported" };
|
|
1254
|
+
return paddleTokenexBodyVerdict(body, target ? target.line : void 0);
|
|
1255
|
+
}
|
|
416
1256
|
if (recognizer && recognizer.psp === GRAVY_PSP)
|
|
417
1257
|
return gravyBodyVerdict(body);
|
|
418
1258
|
if (recognizer && recognizer.psp === MONERIS_PSP) {
|