@alleyboss/micropay-solana-x402-paywall 3.3.1 → 3.3.3
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 +10 -2
- package/dist/client/index.js +10 -2
- package/dist/index.cjs +10 -2
- package/dist/index.js +10 -2
- package/package.json +2 -2
package/dist/client/index.cjs
CHANGED
|
@@ -178,22 +178,30 @@ function usePaywallResource({
|
|
|
178
178
|
}
|
|
179
179
|
const res = await fetch(url, { headers });
|
|
180
180
|
if (res.status === 402) {
|
|
181
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
181
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
182
|
+
console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
|
|
182
183
|
if (wwwAuth) {
|
|
183
184
|
setPaymentHeader(wwwAuth);
|
|
184
185
|
try {
|
|
185
186
|
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
186
187
|
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
187
188
|
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
189
|
+
console.log("[usePaywallResource] Decoded header:", decoded);
|
|
188
190
|
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
191
|
+
console.log("[usePaywallResource] Accepts:", accepts);
|
|
189
192
|
if (accepts) {
|
|
190
|
-
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
193
|
+
const amountStr = accepts.amount || accepts.price || accepts.maxAmountRequired || "0";
|
|
191
194
|
setPrice(BigInt(amountStr));
|
|
192
195
|
setRecipient(accepts.payTo);
|
|
196
|
+
console.log("[usePaywallResource] Set price:", amountStr, "recipient:", accepts.payTo);
|
|
197
|
+
} else {
|
|
198
|
+
console.warn("[usePaywallResource] No accepts found in header");
|
|
193
199
|
}
|
|
194
200
|
} catch (e) {
|
|
195
201
|
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
196
202
|
}
|
|
203
|
+
} else {
|
|
204
|
+
console.warn("[usePaywallResource] 402 response missing WWW-Authenticate header");
|
|
197
205
|
}
|
|
198
206
|
setIsLocked(true);
|
|
199
207
|
setData(null);
|
package/dist/client/index.js
CHANGED
|
@@ -176,22 +176,30 @@ function usePaywallResource({
|
|
|
176
176
|
}
|
|
177
177
|
const res = await fetch(url, { headers });
|
|
178
178
|
if (res.status === 402) {
|
|
179
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
179
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
180
|
+
console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
|
|
180
181
|
if (wwwAuth) {
|
|
181
182
|
setPaymentHeader(wwwAuth);
|
|
182
183
|
try {
|
|
183
184
|
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
184
185
|
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
185
186
|
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
187
|
+
console.log("[usePaywallResource] Decoded header:", decoded);
|
|
186
188
|
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
189
|
+
console.log("[usePaywallResource] Accepts:", accepts);
|
|
187
190
|
if (accepts) {
|
|
188
|
-
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
191
|
+
const amountStr = accepts.amount || accepts.price || accepts.maxAmountRequired || "0";
|
|
189
192
|
setPrice(BigInt(amountStr));
|
|
190
193
|
setRecipient(accepts.payTo);
|
|
194
|
+
console.log("[usePaywallResource] Set price:", amountStr, "recipient:", accepts.payTo);
|
|
195
|
+
} else {
|
|
196
|
+
console.warn("[usePaywallResource] No accepts found in header");
|
|
191
197
|
}
|
|
192
198
|
} catch (e) {
|
|
193
199
|
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
194
200
|
}
|
|
201
|
+
} else {
|
|
202
|
+
console.warn("[usePaywallResource] 402 response missing WWW-Authenticate header");
|
|
195
203
|
}
|
|
196
204
|
setIsLocked(true);
|
|
197
205
|
setData(null);
|
package/dist/index.cjs
CHANGED
|
@@ -190,22 +190,30 @@ function usePaywallResource({
|
|
|
190
190
|
}
|
|
191
191
|
const res = await fetch(url, { headers });
|
|
192
192
|
if (res.status === 402) {
|
|
193
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
193
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
194
|
+
console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
|
|
194
195
|
if (wwwAuth) {
|
|
195
196
|
setPaymentHeader(wwwAuth);
|
|
196
197
|
try {
|
|
197
198
|
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
198
199
|
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
199
200
|
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
201
|
+
console.log("[usePaywallResource] Decoded header:", decoded);
|
|
200
202
|
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
203
|
+
console.log("[usePaywallResource] Accepts:", accepts);
|
|
201
204
|
if (accepts) {
|
|
202
|
-
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
205
|
+
const amountStr = accepts.amount || accepts.price || accepts.maxAmountRequired || "0";
|
|
203
206
|
setPrice(BigInt(amountStr));
|
|
204
207
|
setRecipient(accepts.payTo);
|
|
208
|
+
console.log("[usePaywallResource] Set price:", amountStr, "recipient:", accepts.payTo);
|
|
209
|
+
} else {
|
|
210
|
+
console.warn("[usePaywallResource] No accepts found in header");
|
|
205
211
|
}
|
|
206
212
|
} catch (e) {
|
|
207
213
|
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
208
214
|
}
|
|
215
|
+
} else {
|
|
216
|
+
console.warn("[usePaywallResource] 402 response missing WWW-Authenticate header");
|
|
209
217
|
}
|
|
210
218
|
setIsLocked(true);
|
|
211
219
|
setData(null);
|
package/dist/index.js
CHANGED
|
@@ -184,22 +184,30 @@ function usePaywallResource({
|
|
|
184
184
|
}
|
|
185
185
|
const res = await fetch(url, { headers });
|
|
186
186
|
if (res.status === 402) {
|
|
187
|
-
const wwwAuth = res.headers.get("WWW-Authenticate");
|
|
187
|
+
const wwwAuth = res.headers.get("WWW-Authenticate") || res.headers.get("Payment-Required");
|
|
188
|
+
console.log("[usePaywallResource] 402 Response. Header:", wwwAuth);
|
|
188
189
|
if (wwwAuth) {
|
|
189
190
|
setPaymentHeader(wwwAuth);
|
|
190
191
|
try {
|
|
191
192
|
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
192
193
|
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
193
194
|
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
195
|
+
console.log("[usePaywallResource] Decoded header:", decoded);
|
|
194
196
|
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
197
|
+
console.log("[usePaywallResource] Accepts:", accepts);
|
|
195
198
|
if (accepts) {
|
|
196
|
-
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
199
|
+
const amountStr = accepts.amount || accepts.price || accepts.maxAmountRequired || "0";
|
|
197
200
|
setPrice(BigInt(amountStr));
|
|
198
201
|
setRecipient(accepts.payTo);
|
|
202
|
+
console.log("[usePaywallResource] Set price:", amountStr, "recipient:", accepts.payTo);
|
|
203
|
+
} else {
|
|
204
|
+
console.warn("[usePaywallResource] No accepts found in header");
|
|
199
205
|
}
|
|
200
206
|
} catch (e) {
|
|
201
207
|
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
202
208
|
}
|
|
209
|
+
} else {
|
|
210
|
+
console.warn("[usePaywallResource] 402 response missing WWW-Authenticate header");
|
|
203
211
|
}
|
|
204
212
|
setIsLocked(true);
|
|
205
213
|
setData(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alleyboss/micropay-solana-x402-paywall",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "Production-ready Solana micropayments library wrapper for official x402 SDK",
|
|
5
5
|
"author": "AlleyBoss",
|
|
6
6
|
"license": "MIT",
|
|
@@ -135,4 +135,4 @@
|
|
|
135
135
|
"engines": {
|
|
136
136
|
"node": ">=18"
|
|
137
137
|
}
|
|
138
|
-
}
|
|
138
|
+
}
|