@alleyboss/micropay-solana-x402-paywall 3.3.3 → 3.3.4

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.
@@ -176,10 +176,19 @@ function usePaywallResource({
176
176
  if (authHeader) {
177
177
  headers["Authorization"] = authHeader;
178
178
  }
179
- const res = await fetch(url, { headers });
179
+ const res = await fetch(url, {
180
+ headers,
181
+ credentials: "include"
182
+ // Ensure cookies are sent/received
183
+ });
180
184
  if (res.status === 402) {
181
185
  const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
182
- console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
186
+ const errorReason = res.headers.get("X-Payment-Error");
187
+ console.log("[usePaywallResource] 402 Response. Header:", wwwAuth, "Error:", errorReason);
188
+ if (authHeader && errorReason) {
189
+ console.error("[usePaywallResource] Verification Failed:", errorReason);
190
+ setError(`Verification Failed: ${errorReason}`);
191
+ }
183
192
  if (wwwAuth) {
184
193
  setPaymentHeader(wwwAuth);
185
194
  try {
@@ -174,10 +174,19 @@ function usePaywallResource({
174
174
  if (authHeader) {
175
175
  headers["Authorization"] = authHeader;
176
176
  }
177
- const res = await fetch(url, { headers });
177
+ const res = await fetch(url, {
178
+ headers,
179
+ credentials: "include"
180
+ // Ensure cookies are sent/received
181
+ });
178
182
  if (res.status === 402) {
179
183
  const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
180
- console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
184
+ const errorReason = res.headers.get("X-Payment-Error");
185
+ console.log("[usePaywallResource] 402 Response. Header:", wwwAuth, "Error:", errorReason);
186
+ if (authHeader && errorReason) {
187
+ console.error("[usePaywallResource] Verification Failed:", errorReason);
188
+ setError(`Verification Failed: ${errorReason}`);
189
+ }
181
190
  if (wwwAuth) {
182
191
  setPaymentHeader(wwwAuth);
183
192
  try {
package/dist/index.cjs CHANGED
@@ -188,10 +188,19 @@ function usePaywallResource({
188
188
  if (authHeader) {
189
189
  headers["Authorization"] = authHeader;
190
190
  }
191
- const res = await fetch(url, { headers });
191
+ const res = await fetch(url, {
192
+ headers,
193
+ credentials: "include"
194
+ // Ensure cookies are sent/received
195
+ });
192
196
  if (res.status === 402) {
193
197
  const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
194
- console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
198
+ const errorReason = res.headers.get("X-Payment-Error");
199
+ console.log("[usePaywallResource] 402 Response. Header:", wwwAuth, "Error:", errorReason);
200
+ if (authHeader && errorReason) {
201
+ console.error("[usePaywallResource] Verification Failed:", errorReason);
202
+ setError(`Verification Failed: ${errorReason}`);
203
+ }
195
204
  if (wwwAuth) {
196
205
  setPaymentHeader(wwwAuth);
197
206
  try {
package/dist/index.js CHANGED
@@ -182,10 +182,19 @@ function usePaywallResource({
182
182
  if (authHeader) {
183
183
  headers["Authorization"] = authHeader;
184
184
  }
185
- const res = await fetch(url, { headers });
185
+ const res = await fetch(url, {
186
+ headers,
187
+ credentials: "include"
188
+ // Ensure cookies are sent/received
189
+ });
186
190
  if (res.status === 402) {
187
191
  const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
188
- console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
192
+ const errorReason = res.headers.get("X-Payment-Error");
193
+ console.log("[usePaywallResource] 402 Response. Header:", wwwAuth, "Error:", errorReason);
194
+ if (authHeader && errorReason) {
195
+ console.error("[usePaywallResource] Verification Failed:", errorReason);
196
+ setError(`Verification Failed: ${errorReason}`);
197
+ }
189
198
  if (wwwAuth) {
190
199
  setPaymentHeader(wwwAuth);
191
200
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alleyboss/micropay-solana-x402-paywall",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Production-ready Solana micropayments library wrapper for official x402 SDK",
5
5
  "author": "AlleyBoss",
6
6
  "license": "MIT",