@openfacilitator/sdk 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -599,6 +599,7 @@ function createPaymentMiddleware(config) {
|
|
|
599
599
|
};
|
|
600
600
|
});
|
|
601
601
|
res.status(402).json({
|
|
602
|
+
x402Version: 2,
|
|
602
603
|
error: "Payment Required",
|
|
603
604
|
accepts
|
|
604
605
|
});
|
|
@@ -607,7 +608,8 @@ function createPaymentMiddleware(config) {
|
|
|
607
608
|
}
|
|
608
609
|
let paymentPayload;
|
|
609
610
|
try {
|
|
610
|
-
|
|
611
|
+
const decoded = Buffer.from(paymentString, "base64").toString("utf-8");
|
|
612
|
+
paymentPayload = JSON.parse(decoded);
|
|
611
613
|
if (!isPaymentPayload(paymentPayload)) {
|
|
612
614
|
throw new Error("Invalid payment payload structure");
|
|
613
615
|
}
|
|
@@ -704,13 +706,15 @@ function honoPaymentMiddleware(config) {
|
|
|
704
706
|
};
|
|
705
707
|
});
|
|
706
708
|
return c.json({
|
|
709
|
+
x402Version: 2,
|
|
707
710
|
error: "Payment Required",
|
|
708
711
|
accepts
|
|
709
712
|
}, 402);
|
|
710
713
|
}
|
|
711
714
|
let paymentPayload;
|
|
712
715
|
try {
|
|
713
|
-
|
|
716
|
+
const decoded = atob(paymentString);
|
|
717
|
+
paymentPayload = JSON.parse(decoded);
|
|
714
718
|
if (!isPaymentPayload(paymentPayload)) {
|
|
715
719
|
throw new Error("Invalid payment payload structure");
|
|
716
720
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -548,6 +548,7 @@ function createPaymentMiddleware(config) {
|
|
|
548
548
|
};
|
|
549
549
|
});
|
|
550
550
|
res.status(402).json({
|
|
551
|
+
x402Version: 2,
|
|
551
552
|
error: "Payment Required",
|
|
552
553
|
accepts
|
|
553
554
|
});
|
|
@@ -556,7 +557,8 @@ function createPaymentMiddleware(config) {
|
|
|
556
557
|
}
|
|
557
558
|
let paymentPayload;
|
|
558
559
|
try {
|
|
559
|
-
|
|
560
|
+
const decoded = Buffer.from(paymentString, "base64").toString("utf-8");
|
|
561
|
+
paymentPayload = JSON.parse(decoded);
|
|
560
562
|
if (!isPaymentPayload(paymentPayload)) {
|
|
561
563
|
throw new Error("Invalid payment payload structure");
|
|
562
564
|
}
|
|
@@ -653,13 +655,15 @@ function honoPaymentMiddleware(config) {
|
|
|
653
655
|
};
|
|
654
656
|
});
|
|
655
657
|
return c.json({
|
|
658
|
+
x402Version: 2,
|
|
656
659
|
error: "Payment Required",
|
|
657
660
|
accepts
|
|
658
661
|
}, 402);
|
|
659
662
|
}
|
|
660
663
|
let paymentPayload;
|
|
661
664
|
try {
|
|
662
|
-
|
|
665
|
+
const decoded = atob(paymentString);
|
|
666
|
+
paymentPayload = JSON.parse(decoded);
|
|
663
667
|
if (!isPaymentPayload(paymentPayload)) {
|
|
664
668
|
throw new Error("Invalid payment payload structure");
|
|
665
669
|
}
|