@alleyboss/micropay-solana-x402-paywall 3.3.2 → 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.
- package/dist/client/index.cjs +12 -3
- package/dist/client/index.js +12 -3
- package/dist/index.cjs +12 -3
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/dist/client/index.cjs
CHANGED
|
@@ -176,10 +176,19 @@ function usePaywallResource({
|
|
|
176
176
|
if (authHeader) {
|
|
177
177
|
headers["Authorization"] = authHeader;
|
|
178
178
|
}
|
|
179
|
-
const res = await fetch(url, {
|
|
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
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
182
|
-
|
|
185
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
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 {
|
package/dist/client/index.js
CHANGED
|
@@ -174,10 +174,19 @@ function usePaywallResource({
|
|
|
174
174
|
if (authHeader) {
|
|
175
175
|
headers["Authorization"] = authHeader;
|
|
176
176
|
}
|
|
177
|
-
const res = await fetch(url, {
|
|
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
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
180
|
-
|
|
183
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
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, {
|
|
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
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
194
|
-
|
|
197
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
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, {
|
|
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
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
188
|
-
|
|
191
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
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