@p2pdotme/sdk 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/country.cjs +123 -2
- package/dist/country.cjs.map +1 -1
- package/dist/country.d.cts +21 -1
- package/dist/country.d.ts +21 -1
- package/dist/country.mjs +120 -2
- package/dist/country.mjs.map +1 -1
- package/dist/fraud-engine.cjs +3 -1
- package/dist/fraud-engine.cjs.map +1 -1
- package/dist/fraud-engine.mjs +3 -1
- package/dist/fraud-engine.mjs.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/orders.cjs +3 -1
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +4 -0
- package/dist/orders.d.ts +4 -0
- package/dist/orders.mjs +3 -1
- package/dist/orders.mjs.map +1 -1
- package/dist/prices.cjs +3 -1
- package/dist/prices.cjs.map +1 -1
- package/dist/prices.d.cts +2 -0
- package/dist/prices.d.ts +2 -0
- package/dist/prices.mjs +3 -1
- package/dist/prices.mjs.map +1 -1
- package/dist/profile.cjs +3 -1
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.d.cts +4 -0
- package/dist/profile.d.ts +4 -0
- package/dist/profile.mjs +3 -1
- package/dist/profile.mjs.map +1 -1
- package/dist/qr-parsers.cjs +127 -1
- package/dist/qr-parsers.cjs.map +1 -1
- package/dist/qr-parsers.d.cts +4 -2
- package/dist/qr-parsers.d.ts +4 -2
- package/dist/qr-parsers.mjs +127 -1
- package/dist/qr-parsers.mjs.map +1 -1
- package/dist/react.cjs +3 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +12 -0
- package/dist/react.d.ts +12 -0
- package/dist/react.mjs +3 -1
- package/dist/react.mjs.map +1 -1
- package/dist/stake.cjs +3 -1
- package/dist/stake.cjs.map +1 -1
- package/dist/stake.d.cts +2 -0
- package/dist/stake.d.ts +2 -0
- package/dist/stake.mjs +3 -1
- package/dist/stake.mjs.map +1 -1
- package/dist/zkkyc.cjs +3 -1
- package/dist/zkkyc.cjs.map +1 -1
- package/dist/zkkyc.mjs +3 -1
- package/dist/zkkyc.mjs.map +1 -1
- package/package.json +1 -1
package/dist/qr-parsers.d.cts
CHANGED
|
@@ -30,8 +30,10 @@ declare const CURRENCY: {
|
|
|
30
30
|
readonly NGN: "NGN";
|
|
31
31
|
readonly USD: "USD";
|
|
32
32
|
readonly COP: "COP";
|
|
33
|
+
readonly CUP: "CUP";
|
|
33
34
|
readonly ECU: "ECU";
|
|
34
35
|
readonly PEN: "PEN";
|
|
36
|
+
readonly PHP: "PHP";
|
|
35
37
|
};
|
|
36
38
|
/** Union of supported currency codes. */
|
|
37
39
|
type CurrencyCode = (typeof CURRENCY)[keyof typeof CURRENCY];
|
|
@@ -66,8 +68,8 @@ type ParseResult = Result<ParsedQR, QRParserError>;
|
|
|
66
68
|
* behind a location URL pointing at the issuing bank's PIX endpoint. The SDK
|
|
67
69
|
* resolves that URL via a CORS-bypassing proxy (see `proxyUrl`), which returns
|
|
68
70
|
* a signed JWT whose `valor.original` field holds the amount. All other parsers
|
|
69
|
-
* (UPI, QRIS, MercadoPago, PagoMovil) and static PIX are synchronous and
|
|
70
|
-
* immediately.
|
|
71
|
+
* (UPI, QRIS, QR Ph, MercadoPago, PagoMovil, Transfermóvil) and static PIX are synchronous and
|
|
72
|
+
* resolve immediately.
|
|
71
73
|
*/
|
|
72
74
|
declare function parseQR(params: ParseQRParams): Promise<ParseResult>;
|
|
73
75
|
|
package/dist/qr-parsers.d.ts
CHANGED
|
@@ -30,8 +30,10 @@ declare const CURRENCY: {
|
|
|
30
30
|
readonly NGN: "NGN";
|
|
31
31
|
readonly USD: "USD";
|
|
32
32
|
readonly COP: "COP";
|
|
33
|
+
readonly CUP: "CUP";
|
|
33
34
|
readonly ECU: "ECU";
|
|
34
35
|
readonly PEN: "PEN";
|
|
36
|
+
readonly PHP: "PHP";
|
|
35
37
|
};
|
|
36
38
|
/** Union of supported currency codes. */
|
|
37
39
|
type CurrencyCode = (typeof CURRENCY)[keyof typeof CURRENCY];
|
|
@@ -66,8 +68,8 @@ type ParseResult = Result<ParsedQR, QRParserError>;
|
|
|
66
68
|
* behind a location URL pointing at the issuing bank's PIX endpoint. The SDK
|
|
67
69
|
* resolves that URL via a CORS-bypassing proxy (see `proxyUrl`), which returns
|
|
68
70
|
* a signed JWT whose `valor.original` field holds the amount. All other parsers
|
|
69
|
-
* (UPI, QRIS, MercadoPago, PagoMovil) and static PIX are synchronous and
|
|
70
|
-
* immediately.
|
|
71
|
+
* (UPI, QRIS, QR Ph, MercadoPago, PagoMovil, Transfermóvil) and static PIX are synchronous and
|
|
72
|
+
* resolve immediately.
|
|
71
73
|
*/
|
|
72
74
|
declare function parseQR(params: ParseQRParams): Promise<ParseResult>;
|
|
73
75
|
|
package/dist/qr-parsers.mjs
CHANGED
|
@@ -24,8 +24,10 @@ var CURRENCY = {
|
|
|
24
24
|
NGN: "NGN",
|
|
25
25
|
USD: "USD",
|
|
26
26
|
COP: "COP",
|
|
27
|
+
CUP: "CUP",
|
|
27
28
|
ECU: "ECU",
|
|
28
|
-
PEN: "PEN"
|
|
29
|
+
PEN: "PEN",
|
|
30
|
+
PHP: "PHP"
|
|
29
31
|
};
|
|
30
32
|
var CURRENCY_CODES = Object.values(CURRENCY);
|
|
31
33
|
|
|
@@ -95,6 +97,28 @@ var COP_COUNTRY_OPTION = {
|
|
|
95
97
|
disabledPaymentTypes: []
|
|
96
98
|
};
|
|
97
99
|
|
|
100
|
+
// src/country/currencies/cup.ts
|
|
101
|
+
var CUP_COUNTRY_OPTION = {
|
|
102
|
+
country: "Cuba",
|
|
103
|
+
currency: CURRENCY.CUP,
|
|
104
|
+
symbolNative: "$",
|
|
105
|
+
locale: "es-CU",
|
|
106
|
+
paymentMethod: "TRANSFERMOVIL",
|
|
107
|
+
paymentAddressName: "TRANSFERMOVIL_DETAILS",
|
|
108
|
+
timezone: "America/Havana",
|
|
109
|
+
timezone_name: "CST",
|
|
110
|
+
flag: "\u{1F1E8}\u{1F1FA}",
|
|
111
|
+
flagUrl: "https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f1e8-1f1fa.png",
|
|
112
|
+
phoneCode: "+53",
|
|
113
|
+
telegramSupportChannel: "https://t.me/p2pdotmecuba",
|
|
114
|
+
twitterUsername: "P2Pdotmecuba",
|
|
115
|
+
smsCountryCodes: ["CU"],
|
|
116
|
+
precision: 2,
|
|
117
|
+
isAlpha: true,
|
|
118
|
+
disabled: false,
|
|
119
|
+
disabledPaymentTypes: []
|
|
120
|
+
};
|
|
121
|
+
|
|
98
122
|
// src/country/currencies/ecu.ts
|
|
99
123
|
var ECU_COUNTRY_OPTION = {
|
|
100
124
|
country: "Ecuador",
|
|
@@ -251,6 +275,28 @@ var PEN_COUNTRY_OPTION = {
|
|
|
251
275
|
disabledPaymentTypes: []
|
|
252
276
|
};
|
|
253
277
|
|
|
278
|
+
// src/country/currencies/php.ts
|
|
279
|
+
var PHP_COUNTRY_OPTION = {
|
|
280
|
+
country: "Philippines",
|
|
281
|
+
currency: CURRENCY.PHP,
|
|
282
|
+
symbolNative: "\u20B1",
|
|
283
|
+
locale: "en-PH",
|
|
284
|
+
paymentMethod: "INSTAPAY",
|
|
285
|
+
paymentAddressName: "PHONE_NUMBER",
|
|
286
|
+
timezone: "Asia/Manila",
|
|
287
|
+
timezone_name: "PST",
|
|
288
|
+
flag: "\u{1F1F5}\u{1F1ED}",
|
|
289
|
+
flagUrl: "https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f1f5-1f1ed.png",
|
|
290
|
+
phoneCode: "+63",
|
|
291
|
+
telegramSupportChannel: "https://t.me/p2pdotmeph",
|
|
292
|
+
twitterUsername: "p2pdotmeph",
|
|
293
|
+
smsCountryCodes: ["PH"],
|
|
294
|
+
precision: 2,
|
|
295
|
+
isAlpha: true,
|
|
296
|
+
disabled: false,
|
|
297
|
+
disabledPaymentTypes: []
|
|
298
|
+
};
|
|
299
|
+
|
|
254
300
|
// src/country/currencies/usd.ts
|
|
255
301
|
var USD_COUNTRY_OPTION = {
|
|
256
302
|
country: "Revolut USD",
|
|
@@ -306,8 +352,10 @@ var COUNTRY_OPTIONS = [
|
|
|
306
352
|
VEN_COUNTRY_OPTION,
|
|
307
353
|
NGN_COUNTRY_OPTION,
|
|
308
354
|
COP_COUNTRY_OPTION,
|
|
355
|
+
CUP_COUNTRY_OPTION,
|
|
309
356
|
ECU_COUNTRY_OPTION,
|
|
310
357
|
PEN_COUNTRY_OPTION,
|
|
358
|
+
PHP_COUNTRY_OPTION,
|
|
311
359
|
EUR_COUNTRY_OPTION,
|
|
312
360
|
USD_COUNTRY_OPTION
|
|
313
361
|
];
|
|
@@ -590,6 +638,53 @@ function parseCOP(qrData, sellPrice) {
|
|
|
590
638
|
return failure("INVALID_QR", "Not a recognized Colombian QR code");
|
|
591
639
|
}
|
|
592
640
|
|
|
641
|
+
// src/qr-parsers/parsers/cup.ts
|
|
642
|
+
var TRANSFERMOVIL_PREFIX = "TRANSFERMOVIL_ETECSA";
|
|
643
|
+
var CARD_INDEX = 2;
|
|
644
|
+
var PHONE_INDEX = 3;
|
|
645
|
+
var AMOUNT_INDEX = 4;
|
|
646
|
+
function normalizePhone(phone) {
|
|
647
|
+
const cleaned = phone.replace(/\D/g, "");
|
|
648
|
+
if (/^\d{8}$/.test(cleaned)) return cleaned;
|
|
649
|
+
if (/^53\d{8}$/.test(cleaned)) return cleaned.slice(2);
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
function normalizeCard(card) {
|
|
653
|
+
const cleaned = card.replace(/[\s-]/g, "");
|
|
654
|
+
return /^\d{16}$/.test(cleaned) ? cleaned : null;
|
|
655
|
+
}
|
|
656
|
+
function parseTransfermovil(qrData, sellPrice) {
|
|
657
|
+
if (!qrData || typeof qrData !== "string" || qrData.trim().length === 0) {
|
|
658
|
+
return failure("INVALID_QR", "QR data is empty or invalid");
|
|
659
|
+
}
|
|
660
|
+
const trimmed = qrData.trim();
|
|
661
|
+
const parts = trimmed.split(",").map((p) => p.trim());
|
|
662
|
+
if (parts[0]?.toUpperCase() !== TRANSFERMOVIL_PREFIX) {
|
|
663
|
+
return failure("INVALID_QR", "Not a valid Cuban (Transferm\xF3vil) QR code");
|
|
664
|
+
}
|
|
665
|
+
if (parts.length <= PHONE_INDEX) {
|
|
666
|
+
return failure("INVALID_QR", "Transferm\xF3vil QR is missing card or phone fields");
|
|
667
|
+
}
|
|
668
|
+
const card = normalizeCard(parts[CARD_INDEX] ?? "");
|
|
669
|
+
if (!card) {
|
|
670
|
+
return failure("INVALID_QR", "Transferm\xF3vil QR has an invalid card number");
|
|
671
|
+
}
|
|
672
|
+
const phone = normalizePhone(parts[PHONE_INDEX] ?? "");
|
|
673
|
+
if (!phone) {
|
|
674
|
+
return failure("INVALID_QR", "Transferm\xF3vil QR has an invalid phone number");
|
|
675
|
+
}
|
|
676
|
+
const result = { paymentAddress: `${phone}|${card}` };
|
|
677
|
+
const amountStr = parts[AMOUNT_INDEX];
|
|
678
|
+
if (amountStr) {
|
|
679
|
+
const amount = parseAmount(amountStr, sellPrice);
|
|
680
|
+
if (!amount) {
|
|
681
|
+
return failure("INVALID_AMOUNT", "Invalid amount in QR");
|
|
682
|
+
}
|
|
683
|
+
result.amount = amount;
|
|
684
|
+
}
|
|
685
|
+
return success(result);
|
|
686
|
+
}
|
|
687
|
+
|
|
593
688
|
// src/qr-parsers/parsers/ecu.ts
|
|
594
689
|
var DEUNA_HOST = "pagar.deuna.app";
|
|
595
690
|
function parseDeUna(qrData, _sellPrice) {
|
|
@@ -773,6 +868,33 @@ function parsePeru(qrData, sellPrice) {
|
|
|
773
868
|
return success(result);
|
|
774
869
|
}
|
|
775
870
|
|
|
871
|
+
// src/qr-parsers/parsers/php.ts
|
|
872
|
+
var PHP_TAGS = { AMOUNT: "54", CURRENCY: "53", COUNTRY: "58" };
|
|
873
|
+
function parseQRPh(qrData, sellPrice) {
|
|
874
|
+
if (!qrData || typeof qrData !== "string" || qrData.trim().length === 0) {
|
|
875
|
+
return failure("INVALID_QR", "QR data is empty or invalid");
|
|
876
|
+
}
|
|
877
|
+
const trimmed = qrData.trim();
|
|
878
|
+
const tags = extractTags(trimmed, [PHP_TAGS.AMOUNT, PHP_TAGS.CURRENCY, PHP_TAGS.COUNTRY]);
|
|
879
|
+
if (tags[PHP_TAGS.COUNTRY] !== "PH" || tags[PHP_TAGS.CURRENCY] !== "608") {
|
|
880
|
+
return failure("INVALID_QR", "Not a valid QR Ph code");
|
|
881
|
+
}
|
|
882
|
+
const crc = verifyCRC16(trimmed);
|
|
883
|
+
if (!crc.valid) {
|
|
884
|
+
return failure("INVALID_QR", crc.error ?? "Invalid QR Ph checksum");
|
|
885
|
+
}
|
|
886
|
+
const result = { paymentAddress: trimmed };
|
|
887
|
+
const amountStr = tags[PHP_TAGS.AMOUNT];
|
|
888
|
+
if (amountStr) {
|
|
889
|
+
const amount = parseAmount(amountStr, sellPrice);
|
|
890
|
+
if (!amount) {
|
|
891
|
+
return failure("INVALID_AMOUNT", "Invalid amount in QR");
|
|
892
|
+
}
|
|
893
|
+
result.amount = amount;
|
|
894
|
+
}
|
|
895
|
+
return success(result);
|
|
896
|
+
}
|
|
897
|
+
|
|
776
898
|
// src/qr-parsers/parsers/ven.ts
|
|
777
899
|
function parsePagoMovil(qrData, _sellPrice) {
|
|
778
900
|
if (!qrData || typeof qrData !== "string" || qrData.trim().length === 0) {
|
|
@@ -811,10 +933,14 @@ async function parseQR(params) {
|
|
|
811
933
|
return parseNGN(qrData, sellPrice);
|
|
812
934
|
case CURRENCY.COP:
|
|
813
935
|
return parseCOP(qrData, sellPrice);
|
|
936
|
+
case CURRENCY.CUP:
|
|
937
|
+
return parseTransfermovil(qrData, sellPrice);
|
|
814
938
|
case CURRENCY.ECU:
|
|
815
939
|
return parseDeUna(qrData, sellPrice);
|
|
816
940
|
case CURRENCY.PEN:
|
|
817
941
|
return parsePeru(qrData, sellPrice);
|
|
942
|
+
case CURRENCY.PHP:
|
|
943
|
+
return parseQRPh(qrData, sellPrice);
|
|
818
944
|
default:
|
|
819
945
|
return failure("INVALID_CURRENCY", `Currency "${currency}" is not supported`);
|
|
820
946
|
}
|