kassza 0.11.0 → 0.13.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/README.md +376 -111
- package/agents/README.md +20 -5
- package/agents/api.md +165 -2
- package/agents/pitfalls.md +16 -3
- package/agents/recipes.md +215 -45
- package/agents/skills/kassza/SKILL.md +11 -8
- package/dist/cli.cjs +552 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +552 -0
- package/dist/client-6MkeuFqD.d.ts +268 -0
- package/dist/client-B5FryKxJ.d.cts +268 -0
- package/dist/client-C-PdfL_P.cjs +1275 -0
- package/dist/client-CfaS1-Jx.js +1228 -0
- package/dist/context-BxQlIlug.d.ts +425 -0
- package/dist/context-DXNbTPwz.d.cts +425 -0
- package/dist/create-once-Cz621l8r.js +330 -0
- package/dist/create-once-DgMtKKcG.cjs +395 -0
- package/dist/crypto-Dpn4FHQ6.cjs +65 -0
- package/dist/crypto-usDg8L2K.js +36 -0
- package/dist/data-link/index.cjs +232 -0
- package/dist/data-link/index.d.cts +79 -0
- package/dist/data-link/index.d.ts +79 -0
- package/dist/data-link/index.js +224 -0
- package/dist/{dates-DtHzwNU6.d.cts → dates-9zvESP0i.d.cts} +2 -1
- package/dist/{dates-DtHzwNU6.d.ts → dates-9zvESP0i.d.ts} +2 -1
- package/dist/{dates-PPxH0n5H.cjs → dates-CPgBodkP.cjs} +44 -1
- package/dist/{dates-D2XebOIg.js → dates-CXyj7Azy.js} +39 -2
- package/dist/delegation/index.cjs +396 -0
- package/dist/delegation/index.d.cts +100 -0
- package/dist/delegation/index.d.ts +100 -0
- package/dist/delegation/index.js +378 -0
- package/dist/{errors-DapdV5DK.js → errors-DLrb0g64.js} +122 -5
- package/dist/{errors-B0QJhUW1.cjs → errors-DxeuTslP.cjs} +127 -4
- package/dist/get-Byc9T5WO.d.cts +151 -0
- package/dist/get-Byc9T5WO.d.ts +151 -0
- package/dist/get-Csm2n0rZ.cjs +445 -0
- package/dist/get-DT3JEgQ6.js +380 -0
- package/dist/index.cjs +21 -1410
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +8 -1409
- package/dist/ipn/index.cjs +1 -1
- package/dist/ipn/index.js +1 -1
- package/dist/issue-AGRohSm7.cjs +914 -0
- package/dist/issue-DtSLpVdJ.js +777 -0
- package/dist/json-4y4E2xxS.cjs +61 -0
- package/dist/json-B70TwoX1.d.cts +4 -0
- package/dist/json-B70TwoX1.d.ts +4 -0
- package/dist/json-DjnqnaJK.js +32 -0
- package/dist/mcp/index.cjs +10 -0
- package/dist/mcp/index.d.cts +71 -0
- package/dist/mcp/index.d.ts +71 -0
- package/dist/mcp/index.js +2 -0
- package/dist/money/index.cjs +12 -10
- package/dist/money/index.js +3 -1
- package/dist/{money-DkiGukAw.cjs → money-BxytJW6f.cjs} +42 -177
- package/dist/{money-C9j7nBNP.js → money-t7uy1n91.js} +29 -110
- package/dist/nav/index.cjs +1046 -0
- package/dist/nav/index.d.cts +247 -0
- package/dist/nav/index.d.ts +247 -0
- package/dist/nav/index.js +1012 -0
- package/dist/nav-BEwcX7-N.cjs +203 -0
- package/dist/nav-CK1WgYo7.js +156 -0
- package/dist/parse-BJj-aqKy.cjs +380 -0
- package/dist/parse-C608ehqM.js +291 -0
- package/dist/payments/barion.cjs +208 -0
- package/dist/payments/barion.d.cts +28 -0
- package/dist/payments/barion.d.ts +28 -0
- package/dist/payments/barion.js +199 -0
- package/dist/payments/index.cjs +16 -0
- package/dist/payments/index.d.cts +31 -0
- package/dist/payments/index.d.ts +31 -0
- package/dist/payments/index.js +3 -0
- package/dist/payments/paypal.cjs +351 -0
- package/dist/payments/paypal.d.cts +59 -0
- package/dist/payments/paypal.d.ts +59 -0
- package/dist/payments/paypal.js +337 -0
- package/dist/payments/revolut.cjs +261 -0
- package/dist/payments/revolut.d.cts +48 -0
- package/dist/payments/revolut.d.ts +48 -0
- package/dist/payments/revolut.js +249 -0
- package/dist/payments/simplepay.cjs +313 -0
- package/dist/payments/simplepay.d.cts +86 -0
- package/dist/payments/simplepay.d.ts +86 -0
- package/dist/payments/simplepay.js +299 -0
- package/dist/payments/stripe.cjs +315 -0
- package/dist/payments/stripe.d.cts +49 -0
- package/dist/payments/stripe.d.ts +49 -0
- package/dist/payments/stripe.js +303 -0
- package/dist/reports/index.cjs +103 -0
- package/dist/reports/index.d.cts +70 -0
- package/dist/reports/index.d.ts +70 -0
- package/dist/reports/index.js +94 -0
- package/dist/request-body-CH6ZGOrq.cjs +34 -0
- package/dist/request-body-uZHMRlQr.js +29 -0
- package/dist/rounding-BLyHjjI5.js +20 -0
- package/dist/rounding-TxoWy2ww.cjs +37 -0
- package/dist/serialize-BXOww1Uq.cjs +286 -0
- package/dist/serialize-DSE_o9RK.js +215 -0
- package/dist/server-C6PoNkdD.cjs +1557 -0
- package/dist/server-Cd8HB661.js +1504 -0
- package/dist/storage/fs.cjs +1 -1
- package/dist/storage/fs.js +1 -1
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +2 -2
- package/dist/tax-number-BYFkBp4A.cjs +141 -0
- package/dist/tax-number-BdqKsxNR.js +76 -0
- package/dist/testing/index.cjs +1656 -84
- package/dist/testing/index.d.cts +203 -3
- package/dist/testing/index.d.ts +203 -3
- package/dist/testing/index.js +1653 -83
- package/dist/types-BVeR7KyU.d.cts +56 -0
- package/dist/types-BVeR7KyU.d.ts +56 -0
- package/dist/types-DH8QoNZK.d.cts +135 -0
- package/dist/types-k--zHf4l.d.ts +135 -0
- package/dist/validators/index.cjs +14 -88
- package/dist/validators/index.js +1 -75
- package/dist/vat-g35srbNG.cjs +116 -0
- package/dist/vat-v_dcWCto.js +81 -0
- package/dist/webhook-81giRMdQ.cjs +223 -0
- package/dist/webhook-CpCMHhn2.d.ts +6 -0
- package/dist/webhook-CpMJuP6c.d.cts +6 -0
- package/dist/webhook-CrEGohbg.js +152 -0
- package/llms.txt +4 -4
- package/package.json +148 -2
- package/dist/client-B9kbKKBf.d.cts +0 -748
- package/dist/client-zv4enyq7.d.ts +0 -748
- package/dist/create-5YkUcJSe.js +0 -957
- package/dist/create-DZsl3Z4m.cjs +0 -1178
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//#region src/money/vat.ts
|
|
2
|
+
const NUMERIC_VAT_RATES = [
|
|
3
|
+
0,
|
|
4
|
+
1,
|
|
5
|
+
2,
|
|
6
|
+
2.1,
|
|
7
|
+
3,
|
|
8
|
+
4,
|
|
9
|
+
4.8,
|
|
10
|
+
5,
|
|
11
|
+
5.5,
|
|
12
|
+
6,
|
|
13
|
+
7,
|
|
14
|
+
7.7,
|
|
15
|
+
8,
|
|
16
|
+
8.1,
|
|
17
|
+
9,
|
|
18
|
+
9.5,
|
|
19
|
+
10,
|
|
20
|
+
11,
|
|
21
|
+
12,
|
|
22
|
+
13,
|
|
23
|
+
13.5,
|
|
24
|
+
14,
|
|
25
|
+
15,
|
|
26
|
+
16,
|
|
27
|
+
17,
|
|
28
|
+
18,
|
|
29
|
+
19,
|
|
30
|
+
20,
|
|
31
|
+
21,
|
|
32
|
+
22,
|
|
33
|
+
23,
|
|
34
|
+
24,
|
|
35
|
+
25,
|
|
36
|
+
25.5,
|
|
37
|
+
26,
|
|
38
|
+
27
|
|
39
|
+
];
|
|
40
|
+
const SPECIAL_VAT_CODES = [
|
|
41
|
+
"TAHK",
|
|
42
|
+
"TAM",
|
|
43
|
+
"AAM",
|
|
44
|
+
"EUT",
|
|
45
|
+
"EUKT",
|
|
46
|
+
"F.AFA",
|
|
47
|
+
"K.AFA",
|
|
48
|
+
"HO",
|
|
49
|
+
"EUE",
|
|
50
|
+
"EUFADE",
|
|
51
|
+
"EUFAD37",
|
|
52
|
+
"ATK",
|
|
53
|
+
"NAM",
|
|
54
|
+
"EAM",
|
|
55
|
+
"KBAUK",
|
|
56
|
+
"KBAET"
|
|
57
|
+
];
|
|
58
|
+
const numericRates = new Set(NUMERIC_VAT_RATES);
|
|
59
|
+
const specialCodes = new Set(SPECIAL_VAT_CODES);
|
|
60
|
+
function isVatRate(value) {
|
|
61
|
+
if (typeof value === "number") return numericRates.has(value);
|
|
62
|
+
return typeof value === "string" && specialCodes.has(value);
|
|
63
|
+
}
|
|
64
|
+
function vatPercentage(rate) {
|
|
65
|
+
return typeof rate === "number" ? rate : 0;
|
|
66
|
+
}
|
|
67
|
+
function formatVatRate(rate) {
|
|
68
|
+
return String(rate);
|
|
69
|
+
}
|
|
70
|
+
const HUF_CURRENCIES = /* @__PURE__ */ new Set([
|
|
71
|
+
"HUF",
|
|
72
|
+
"Ft",
|
|
73
|
+
"FT",
|
|
74
|
+
"huf",
|
|
75
|
+
"ft"
|
|
76
|
+
]);
|
|
77
|
+
function isHuf(currency) {
|
|
78
|
+
return currency === void 0 || HUF_CURRENCIES.has(currency.trim());
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
Object.defineProperty(exports, "NUMERIC_VAT_RATES", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function() {
|
|
84
|
+
return NUMERIC_VAT_RATES;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "SPECIAL_VAT_CODES", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function() {
|
|
90
|
+
return SPECIAL_VAT_CODES;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "formatVatRate", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function() {
|
|
96
|
+
return formatVatRate;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "isHuf", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function() {
|
|
102
|
+
return isHuf;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "isVatRate", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function() {
|
|
108
|
+
return isVatRate;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, "vatPercentage", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function() {
|
|
114
|
+
return vatPercentage;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region src/money/vat.ts
|
|
2
|
+
const NUMERIC_VAT_RATES = [
|
|
3
|
+
0,
|
|
4
|
+
1,
|
|
5
|
+
2,
|
|
6
|
+
2.1,
|
|
7
|
+
3,
|
|
8
|
+
4,
|
|
9
|
+
4.8,
|
|
10
|
+
5,
|
|
11
|
+
5.5,
|
|
12
|
+
6,
|
|
13
|
+
7,
|
|
14
|
+
7.7,
|
|
15
|
+
8,
|
|
16
|
+
8.1,
|
|
17
|
+
9,
|
|
18
|
+
9.5,
|
|
19
|
+
10,
|
|
20
|
+
11,
|
|
21
|
+
12,
|
|
22
|
+
13,
|
|
23
|
+
13.5,
|
|
24
|
+
14,
|
|
25
|
+
15,
|
|
26
|
+
16,
|
|
27
|
+
17,
|
|
28
|
+
18,
|
|
29
|
+
19,
|
|
30
|
+
20,
|
|
31
|
+
21,
|
|
32
|
+
22,
|
|
33
|
+
23,
|
|
34
|
+
24,
|
|
35
|
+
25,
|
|
36
|
+
25.5,
|
|
37
|
+
26,
|
|
38
|
+
27
|
|
39
|
+
];
|
|
40
|
+
const SPECIAL_VAT_CODES = [
|
|
41
|
+
"TAHK",
|
|
42
|
+
"TAM",
|
|
43
|
+
"AAM",
|
|
44
|
+
"EUT",
|
|
45
|
+
"EUKT",
|
|
46
|
+
"F.AFA",
|
|
47
|
+
"K.AFA",
|
|
48
|
+
"HO",
|
|
49
|
+
"EUE",
|
|
50
|
+
"EUFADE",
|
|
51
|
+
"EUFAD37",
|
|
52
|
+
"ATK",
|
|
53
|
+
"NAM",
|
|
54
|
+
"EAM",
|
|
55
|
+
"KBAUK",
|
|
56
|
+
"KBAET"
|
|
57
|
+
];
|
|
58
|
+
const numericRates = new Set(NUMERIC_VAT_RATES);
|
|
59
|
+
const specialCodes = new Set(SPECIAL_VAT_CODES);
|
|
60
|
+
function isVatRate(value) {
|
|
61
|
+
if (typeof value === "number") return numericRates.has(value);
|
|
62
|
+
return typeof value === "string" && specialCodes.has(value);
|
|
63
|
+
}
|
|
64
|
+
function vatPercentage(rate) {
|
|
65
|
+
return typeof rate === "number" ? rate : 0;
|
|
66
|
+
}
|
|
67
|
+
function formatVatRate(rate) {
|
|
68
|
+
return String(rate);
|
|
69
|
+
}
|
|
70
|
+
const HUF_CURRENCIES = /* @__PURE__ */ new Set([
|
|
71
|
+
"HUF",
|
|
72
|
+
"Ft",
|
|
73
|
+
"FT",
|
|
74
|
+
"huf",
|
|
75
|
+
"ft"
|
|
76
|
+
]);
|
|
77
|
+
function isHuf(currency) {
|
|
78
|
+
return currency === void 0 || HUF_CURRENCIES.has(currency.trim());
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { isVatRate as a, isHuf as i, SPECIAL_VAT_CODES as n, vatPercentage as o, formatVatRate as r, NUMERIC_VAT_RATES as t };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
const require_rounding = require("./rounding-TxoWy2ww.cjs");
|
|
2
|
+
const require_request_body = require("./request-body-CH6ZGOrq.cjs");
|
|
3
|
+
//#region src/payments/amounts.ts
|
|
4
|
+
const ISO_ZERO_DECIMAL = /* @__PURE__ */ new Set([
|
|
5
|
+
"BIF",
|
|
6
|
+
"CLP",
|
|
7
|
+
"DJF",
|
|
8
|
+
"GNF",
|
|
9
|
+
"ISK",
|
|
10
|
+
"JPY",
|
|
11
|
+
"KMF",
|
|
12
|
+
"KRW",
|
|
13
|
+
"PYG",
|
|
14
|
+
"RWF",
|
|
15
|
+
"UGX",
|
|
16
|
+
"UYI",
|
|
17
|
+
"VND",
|
|
18
|
+
"VUV",
|
|
19
|
+
"XAF",
|
|
20
|
+
"XOF",
|
|
21
|
+
"XPF"
|
|
22
|
+
]);
|
|
23
|
+
const ISO_THREE_DECIMAL = /* @__PURE__ */ new Set([
|
|
24
|
+
"BHD",
|
|
25
|
+
"IQD",
|
|
26
|
+
"JOD",
|
|
27
|
+
"KWD",
|
|
28
|
+
"LYD",
|
|
29
|
+
"OMR",
|
|
30
|
+
"TND"
|
|
31
|
+
]);
|
|
32
|
+
const ISO_FOUR_DECIMAL = /* @__PURE__ */ new Set(["CLF", "UYW"]);
|
|
33
|
+
const STRIPE_ZERO_DECIMAL = /* @__PURE__ */ new Set([
|
|
34
|
+
"BIF",
|
|
35
|
+
"CLP",
|
|
36
|
+
"DJF",
|
|
37
|
+
"GNF",
|
|
38
|
+
"JPY",
|
|
39
|
+
"KMF",
|
|
40
|
+
"KRW",
|
|
41
|
+
"MGA",
|
|
42
|
+
"PYG",
|
|
43
|
+
"RWF",
|
|
44
|
+
"VND",
|
|
45
|
+
"VUV",
|
|
46
|
+
"XAF",
|
|
47
|
+
"XOF",
|
|
48
|
+
"XPF"
|
|
49
|
+
]);
|
|
50
|
+
const STRIPE_THREE_DECIMAL = /* @__PURE__ */ new Set([
|
|
51
|
+
"BHD",
|
|
52
|
+
"JOD",
|
|
53
|
+
"KWD",
|
|
54
|
+
"OMR",
|
|
55
|
+
"TND"
|
|
56
|
+
]);
|
|
57
|
+
function currencyExponent(currency, convention) {
|
|
58
|
+
const code = currency.trim().toUpperCase();
|
|
59
|
+
if (convention === "stripe") {
|
|
60
|
+
if (STRIPE_ZERO_DECIMAL.has(code)) return 0;
|
|
61
|
+
if (STRIPE_THREE_DECIMAL.has(code)) return 3;
|
|
62
|
+
return 2;
|
|
63
|
+
}
|
|
64
|
+
if (ISO_ZERO_DECIMAL.has(code)) return 0;
|
|
65
|
+
if (ISO_THREE_DECIMAL.has(code)) return 3;
|
|
66
|
+
if (ISO_FOUR_DECIMAL.has(code)) return 4;
|
|
67
|
+
return 2;
|
|
68
|
+
}
|
|
69
|
+
function fromMinorUnits(amount, currency, convention) {
|
|
70
|
+
if (!Number.isFinite(amount)) throw new RangeError(`Érvénytelen összeg (minor unit): ${amount}`);
|
|
71
|
+
const exponent = currencyExponent(currency, convention);
|
|
72
|
+
return require_rounding.roundMoney(amount / 10 ** exponent, exponent);
|
|
73
|
+
}
|
|
74
|
+
function parseDecimalAmount(value) {
|
|
75
|
+
const trimmed = value.trim();
|
|
76
|
+
if (!/^-?(?:\d+(?:\.\d+)?|\.\d+)$/.test(trimmed)) throw new RangeError(`Érvénytelen decimális összeg: "${value}"`);
|
|
77
|
+
return Number(trimmed);
|
|
78
|
+
}
|
|
79
|
+
function normalizeCurrency(currency) {
|
|
80
|
+
return currency.trim().toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/payments/errors.ts
|
|
84
|
+
var WebhookVerificationError = class extends Error {
|
|
85
|
+
name = "WebhookVerificationError";
|
|
86
|
+
provider;
|
|
87
|
+
reason;
|
|
88
|
+
constructor(provider, reason, message) {
|
|
89
|
+
super(message);
|
|
90
|
+
this.provider = provider;
|
|
91
|
+
this.reason = reason;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var PaymentProviderError = class extends Error {
|
|
95
|
+
name = "PaymentProviderError";
|
|
96
|
+
provider;
|
|
97
|
+
status;
|
|
98
|
+
constructor(provider, message, status, cause) {
|
|
99
|
+
super(message, cause === void 0 ? void 0 : { cause });
|
|
100
|
+
this.provider = provider;
|
|
101
|
+
this.status = status;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function isWebhookVerificationError(error) {
|
|
105
|
+
return error instanceof WebhookVerificationError;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/payments/body.ts
|
|
109
|
+
const DEFAULT_MAX_WEBHOOK_BYTES = 1048576;
|
|
110
|
+
function tooLarge(provider, maxBytes) {
|
|
111
|
+
return new WebhookVerificationError(provider, "payload_too_large", `A webhook törzse nagyobb a megengedett ${maxBytes} bájtnál.`);
|
|
112
|
+
}
|
|
113
|
+
function readRawBody(request, provider, maxBytes = DEFAULT_MAX_WEBHOOK_BYTES) {
|
|
114
|
+
return require_request_body.readRequestText(request, maxBytes, () => tooLarge(provider, maxBytes));
|
|
115
|
+
}
|
|
116
|
+
function parseJsonObject(provider, payload) {
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = JSON.parse(payload);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new WebhookVerificationError(provider, "invalid_payload", `A webhook törzse nem érvényes JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
122
|
+
}
|
|
123
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new WebhookVerificationError(provider, "invalid_payload", "A webhook törzse nem JSON objektum.");
|
|
124
|
+
return parsed;
|
|
125
|
+
}
|
|
126
|
+
function plainResponse(status, body) {
|
|
127
|
+
return new Response(body, {
|
|
128
|
+
status,
|
|
129
|
+
headers: { "content-type": "text/plain; charset=utf-8" }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/payments/webhook.ts
|
|
134
|
+
function reportError(onError, error) {
|
|
135
|
+
try {
|
|
136
|
+
if (onError) onError(error);
|
|
137
|
+
else console.error("[kassza] A fizetési webhook feldolgozása nem sikerült.", error);
|
|
138
|
+
} catch {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function respondToWebhook(options, run) {
|
|
143
|
+
try {
|
|
144
|
+
return await run();
|
|
145
|
+
} catch (error) {
|
|
146
|
+
if (error instanceof WebhookVerificationError) return plainResponse(400, error.message);
|
|
147
|
+
reportError(options.onError, error);
|
|
148
|
+
return plainResponse(500, "A webhook feldolgozása nem sikerült.");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
Object.defineProperty(exports, "DEFAULT_MAX_WEBHOOK_BYTES", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function() {
|
|
155
|
+
return DEFAULT_MAX_WEBHOOK_BYTES;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(exports, "PaymentProviderError", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function() {
|
|
161
|
+
return PaymentProviderError;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, "WebhookVerificationError", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function() {
|
|
167
|
+
return WebhookVerificationError;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, "currencyExponent", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function() {
|
|
173
|
+
return currencyExponent;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, "fromMinorUnits", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function() {
|
|
179
|
+
return fromMinorUnits;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(exports, "isWebhookVerificationError", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function() {
|
|
185
|
+
return isWebhookVerificationError;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, "normalizeCurrency", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function() {
|
|
191
|
+
return normalizeCurrency;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, "parseDecimalAmount", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function() {
|
|
197
|
+
return parseDecimalAmount;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, "parseJsonObject", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function() {
|
|
203
|
+
return parseJsonObject;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, "plainResponse", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function() {
|
|
209
|
+
return plainResponse;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, "readRawBody", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function() {
|
|
215
|
+
return readRawBody;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, "respondToWebhook", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function() {
|
|
221
|
+
return respondToWebhook;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { l as PaymentWebhookBaseOptions } from "./types-BVeR7KyU.js";
|
|
2
|
+
//#region src/payments/webhook.d.ts
|
|
3
|
+
type WebhookHandler = (request: Request) => Promise<Response>;
|
|
4
|
+
declare function respondToWebhook(options: Pick<PaymentWebhookBaseOptions, "onError">, run: () => Promise<Response>): Promise<Response>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { respondToWebhook as n, WebhookHandler as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { l as PaymentWebhookBaseOptions } from "./types-BVeR7KyU.cjs";
|
|
2
|
+
//#region src/payments/webhook.d.ts
|
|
3
|
+
type WebhookHandler = (request: Request) => Promise<Response>;
|
|
4
|
+
declare function respondToWebhook(options: Pick<PaymentWebhookBaseOptions, "onError">, run: () => Promise<Response>): Promise<Response>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { respondToWebhook as n, WebhookHandler as t };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { r as roundMoney } from "./rounding-BLyHjjI5.js";
|
|
2
|
+
import { t as readRequestText } from "./request-body-uZHMRlQr.js";
|
|
3
|
+
//#region src/payments/amounts.ts
|
|
4
|
+
const ISO_ZERO_DECIMAL = /* @__PURE__ */ new Set([
|
|
5
|
+
"BIF",
|
|
6
|
+
"CLP",
|
|
7
|
+
"DJF",
|
|
8
|
+
"GNF",
|
|
9
|
+
"ISK",
|
|
10
|
+
"JPY",
|
|
11
|
+
"KMF",
|
|
12
|
+
"KRW",
|
|
13
|
+
"PYG",
|
|
14
|
+
"RWF",
|
|
15
|
+
"UGX",
|
|
16
|
+
"UYI",
|
|
17
|
+
"VND",
|
|
18
|
+
"VUV",
|
|
19
|
+
"XAF",
|
|
20
|
+
"XOF",
|
|
21
|
+
"XPF"
|
|
22
|
+
]);
|
|
23
|
+
const ISO_THREE_DECIMAL = /* @__PURE__ */ new Set([
|
|
24
|
+
"BHD",
|
|
25
|
+
"IQD",
|
|
26
|
+
"JOD",
|
|
27
|
+
"KWD",
|
|
28
|
+
"LYD",
|
|
29
|
+
"OMR",
|
|
30
|
+
"TND"
|
|
31
|
+
]);
|
|
32
|
+
const ISO_FOUR_DECIMAL = /* @__PURE__ */ new Set(["CLF", "UYW"]);
|
|
33
|
+
const STRIPE_ZERO_DECIMAL = /* @__PURE__ */ new Set([
|
|
34
|
+
"BIF",
|
|
35
|
+
"CLP",
|
|
36
|
+
"DJF",
|
|
37
|
+
"GNF",
|
|
38
|
+
"JPY",
|
|
39
|
+
"KMF",
|
|
40
|
+
"KRW",
|
|
41
|
+
"MGA",
|
|
42
|
+
"PYG",
|
|
43
|
+
"RWF",
|
|
44
|
+
"VND",
|
|
45
|
+
"VUV",
|
|
46
|
+
"XAF",
|
|
47
|
+
"XOF",
|
|
48
|
+
"XPF"
|
|
49
|
+
]);
|
|
50
|
+
const STRIPE_THREE_DECIMAL = /* @__PURE__ */ new Set([
|
|
51
|
+
"BHD",
|
|
52
|
+
"JOD",
|
|
53
|
+
"KWD",
|
|
54
|
+
"OMR",
|
|
55
|
+
"TND"
|
|
56
|
+
]);
|
|
57
|
+
function currencyExponent(currency, convention) {
|
|
58
|
+
const code = currency.trim().toUpperCase();
|
|
59
|
+
if (convention === "stripe") {
|
|
60
|
+
if (STRIPE_ZERO_DECIMAL.has(code)) return 0;
|
|
61
|
+
if (STRIPE_THREE_DECIMAL.has(code)) return 3;
|
|
62
|
+
return 2;
|
|
63
|
+
}
|
|
64
|
+
if (ISO_ZERO_DECIMAL.has(code)) return 0;
|
|
65
|
+
if (ISO_THREE_DECIMAL.has(code)) return 3;
|
|
66
|
+
if (ISO_FOUR_DECIMAL.has(code)) return 4;
|
|
67
|
+
return 2;
|
|
68
|
+
}
|
|
69
|
+
function fromMinorUnits(amount, currency, convention) {
|
|
70
|
+
if (!Number.isFinite(amount)) throw new RangeError(`Érvénytelen összeg (minor unit): ${amount}`);
|
|
71
|
+
const exponent = currencyExponent(currency, convention);
|
|
72
|
+
return roundMoney(amount / 10 ** exponent, exponent);
|
|
73
|
+
}
|
|
74
|
+
function parseDecimalAmount(value) {
|
|
75
|
+
const trimmed = value.trim();
|
|
76
|
+
if (!/^-?(?:\d+(?:\.\d+)?|\.\d+)$/.test(trimmed)) throw new RangeError(`Érvénytelen decimális összeg: "${value}"`);
|
|
77
|
+
return Number(trimmed);
|
|
78
|
+
}
|
|
79
|
+
function normalizeCurrency(currency) {
|
|
80
|
+
return currency.trim().toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/payments/errors.ts
|
|
84
|
+
var WebhookVerificationError = class extends Error {
|
|
85
|
+
name = "WebhookVerificationError";
|
|
86
|
+
provider;
|
|
87
|
+
reason;
|
|
88
|
+
constructor(provider, reason, message) {
|
|
89
|
+
super(message);
|
|
90
|
+
this.provider = provider;
|
|
91
|
+
this.reason = reason;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var PaymentProviderError = class extends Error {
|
|
95
|
+
name = "PaymentProviderError";
|
|
96
|
+
provider;
|
|
97
|
+
status;
|
|
98
|
+
constructor(provider, message, status, cause) {
|
|
99
|
+
super(message, cause === void 0 ? void 0 : { cause });
|
|
100
|
+
this.provider = provider;
|
|
101
|
+
this.status = status;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function isWebhookVerificationError(error) {
|
|
105
|
+
return error instanceof WebhookVerificationError;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/payments/body.ts
|
|
109
|
+
const DEFAULT_MAX_WEBHOOK_BYTES = 1048576;
|
|
110
|
+
function tooLarge(provider, maxBytes) {
|
|
111
|
+
return new WebhookVerificationError(provider, "payload_too_large", `A webhook törzse nagyobb a megengedett ${maxBytes} bájtnál.`);
|
|
112
|
+
}
|
|
113
|
+
function readRawBody(request, provider, maxBytes = DEFAULT_MAX_WEBHOOK_BYTES) {
|
|
114
|
+
return readRequestText(request, maxBytes, () => tooLarge(provider, maxBytes));
|
|
115
|
+
}
|
|
116
|
+
function parseJsonObject(provider, payload) {
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = JSON.parse(payload);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new WebhookVerificationError(provider, "invalid_payload", `A webhook törzse nem érvényes JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
122
|
+
}
|
|
123
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new WebhookVerificationError(provider, "invalid_payload", "A webhook törzse nem JSON objektum.");
|
|
124
|
+
return parsed;
|
|
125
|
+
}
|
|
126
|
+
function plainResponse(status, body) {
|
|
127
|
+
return new Response(body, {
|
|
128
|
+
status,
|
|
129
|
+
headers: { "content-type": "text/plain; charset=utf-8" }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/payments/webhook.ts
|
|
134
|
+
function reportError(onError, error) {
|
|
135
|
+
try {
|
|
136
|
+
if (onError) onError(error);
|
|
137
|
+
else console.error("[kassza] A fizetési webhook feldolgozása nem sikerült.", error);
|
|
138
|
+
} catch {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function respondToWebhook(options, run) {
|
|
143
|
+
try {
|
|
144
|
+
return await run();
|
|
145
|
+
} catch (error) {
|
|
146
|
+
if (error instanceof WebhookVerificationError) return plainResponse(400, error.message);
|
|
147
|
+
reportError(options.onError, error);
|
|
148
|
+
return plainResponse(500, "A webhook feldolgozása nem sikerült.");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { readRawBody as a, isWebhookVerificationError as c, normalizeCurrency as d, parseDecimalAmount as f, plainResponse as i, currencyExponent as l, DEFAULT_MAX_WEBHOOK_BYTES as n, PaymentProviderError as o, parseJsonObject as r, WebhookVerificationError as s, respondToWebhook as t, fromMinorUnits as u };
|
package/llms.txt
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# kassza
|
|
2
2
|
|
|
3
|
-
> Zero-dependency TypeScript client for the Számlázz.hu Számla Agent API (Hungarian invoicing): invoices, proformas, receipts, reversals, payments, PDFs, NAV taxpayer lookup, IPN webhooks. Unofficial.
|
|
3
|
+
> Zero-dependency TypeScript client for the Számlázz.hu Számla Agent API (Hungarian invoicing): invoices, proformas, receipts, reversals, payments, PDFs, NAV taxpayer lookup, IPN webhooks. Also: exactly-once documents from Stripe, SimplePay, Barion, Revolut and PayPal payments, NAV daily receipt reports, delegated invoicing, the Számlázz.hu data link, a fake Számla Agent for tests, a CLI and an MCP server. Unofficial.
|
|
4
4
|
|
|
5
5
|
## Docs for coding agents
|
|
6
6
|
|
|
7
7
|
- [Start here](agents/README.md): overview, the five rules, vocabulary
|
|
8
|
-
- [Pitfalls](agents/pitfalls.md): hard rules
|
|
9
|
-
- [API reference](agents/api.md): every method, input and output
|
|
10
|
-
- [Recipes](agents/recipes.md): webhooks,
|
|
8
|
+
- [Pitfalls](agents/pitfalls.md): hard rules, legal rules for receipts, error categories
|
|
9
|
+
- [API reference](agents/api.md): every method, input and output, all subpath modules
|
|
10
|
+
- [Recipes](agents/recipes.md): webhooks, exactly-once invoicing, receipts, IPN, storage, serverless, tests, payment providers, NAV reports, delegated invoicing, data link, MCP
|
|
11
11
|
- [Claude Code skill](agents/skills/kassza/SKILL.md)
|
|
12
12
|
|
|
13
13
|
## Human docs
|