@alleyboss/micropay-solana-x402-paywall 3.3.0 → 3.3.1
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 +15 -0
- package/dist/client/index.cjs +9 -5
- package/dist/client/index.js +9 -5
- package/dist/index.cjs +9 -5
- package/dist/index.js +9 -5
- package/dist/next/index.cjs +33 -5
- package/dist/next/index.js +33 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -186,6 +186,7 @@ function PaywallBanner({ priceInLamports }) {
|
|
|
186
186
|
|
|
187
187
|
We're actively working on these exciting features:
|
|
188
188
|
|
|
189
|
+
### Core Features
|
|
189
190
|
| Feature | Status | Description |
|
|
190
191
|
|---------|--------|-------------|
|
|
191
192
|
| ⚡ **Jupiter Swap-on-Pay** | 🔜 Coming Soon | Pay with any token, auto-swap to SOL/USDC |
|
|
@@ -194,6 +195,20 @@ We're actively working on these exciting features:
|
|
|
194
195
|
| 🌳 **Compressed NFTs** | 🔜 Planned | Scalable access tokens via cNFTs |
|
|
195
196
|
| 🔄 **Payment Streaming** | 🔜 Planned | Pay-as-you-consume for APIs |
|
|
196
197
|
|
|
198
|
+
### For Solana Power Users
|
|
199
|
+
| Feature | Status | Description |
|
|
200
|
+
|---------|--------|-------------|
|
|
201
|
+
| 🚀 **Jito Bundle Support** | 🔜 Planned | Guaranteed transaction inclusion via MEV |
|
|
202
|
+
| 📡 **WebSocket Confirmations** | 🔜 Planned | Real-time confirmation, no polling |
|
|
203
|
+
| 📋 **Lookup Tables** | 🔜 Planned | Batch payments efficiency for agents |
|
|
204
|
+
|
|
205
|
+
### For x402 Protocol Ecosystem
|
|
206
|
+
| Feature | Status | Description |
|
|
207
|
+
|---------|--------|-------------|
|
|
208
|
+
| 💳 **Coinbase Commerce** | 🔜 Planned | Accept payments via Coinbase Pay |
|
|
209
|
+
| 🤖 **CDP Agent Wallets** | 🔜 Planned | Coinbase Developer Platform integration |
|
|
210
|
+
| 🔷 **Base Network Support** | 🔜 Planned | EVM x402 payments on Base L2 |
|
|
211
|
+
|
|
197
212
|
Want to contribute or sponsor a feature? Open an issue on [GitHub](https://github.com/AlleyBo55/micropay-solana-x402-paywall)!
|
|
198
213
|
|
|
199
214
|
## 📚 Documentation
|
package/dist/client/index.cjs
CHANGED
|
@@ -182,13 +182,17 @@ function usePaywallResource({
|
|
|
182
182
|
if (wwwAuth) {
|
|
183
183
|
setPaymentHeader(wwwAuth);
|
|
184
184
|
try {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
186
|
+
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
187
|
+
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
188
|
+
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
189
|
+
if (accepts) {
|
|
190
|
+
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
191
|
+
setPrice(BigInt(amountStr));
|
|
192
|
+
setRecipient(accepts.payTo);
|
|
189
193
|
}
|
|
190
194
|
} catch (e) {
|
|
191
|
-
console.warn("Failed to parse
|
|
195
|
+
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
198
|
setIsLocked(true);
|
package/dist/client/index.js
CHANGED
|
@@ -180,13 +180,17 @@ function usePaywallResource({
|
|
|
180
180
|
if (wwwAuth) {
|
|
181
181
|
setPaymentHeader(wwwAuth);
|
|
182
182
|
try {
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
184
|
+
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
185
|
+
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
186
|
+
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
187
|
+
if (accepts) {
|
|
188
|
+
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
189
|
+
setPrice(BigInt(amountStr));
|
|
190
|
+
setRecipient(accepts.payTo);
|
|
187
191
|
}
|
|
188
192
|
} catch (e) {
|
|
189
|
-
console.warn("Failed to parse
|
|
193
|
+
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
setIsLocked(true);
|
package/dist/index.cjs
CHANGED
|
@@ -194,13 +194,17 @@ function usePaywallResource({
|
|
|
194
194
|
if (wwwAuth) {
|
|
195
195
|
setPaymentHeader(wwwAuth);
|
|
196
196
|
try {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
198
|
+
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
199
|
+
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
200
|
+
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
201
|
+
if (accepts) {
|
|
202
|
+
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
203
|
+
setPrice(BigInt(amountStr));
|
|
204
|
+
setRecipient(accepts.payTo);
|
|
201
205
|
}
|
|
202
206
|
} catch (e) {
|
|
203
|
-
console.warn("Failed to parse
|
|
207
|
+
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
setIsLocked(true);
|
package/dist/index.js
CHANGED
|
@@ -188,13 +188,17 @@ function usePaywallResource({
|
|
|
188
188
|
if (wwwAuth) {
|
|
189
189
|
setPaymentHeader(wwwAuth);
|
|
190
190
|
try {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
const { decodePaymentRequiredHeader: decodePaymentRequiredHeader2 } = await import('@x402/core/http');
|
|
192
|
+
const cleanHeader = wwwAuth.replace(/^[Xx]402\s+/, "");
|
|
193
|
+
const decoded = decodePaymentRequiredHeader2(cleanHeader);
|
|
194
|
+
const accepts = Array.isArray(decoded.accepts) ? decoded.accepts[0] : decoded.accepts;
|
|
195
|
+
if (accepts) {
|
|
196
|
+
const amountStr = accepts.amount || accepts.maxAmountRequired || "0";
|
|
197
|
+
setPrice(BigInt(amountStr));
|
|
198
|
+
setRecipient(accepts.payTo);
|
|
195
199
|
}
|
|
196
200
|
} catch (e) {
|
|
197
|
-
console.warn("Failed to parse
|
|
201
|
+
console.warn("[usePaywallResource] Failed to parse x402 header:", e);
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
setIsLocked(true);
|
package/dist/next/index.cjs
CHANGED
|
@@ -20,20 +20,48 @@ var LocalSvmFacilitator = class {
|
|
|
20
20
|
* Get supported payment kinds
|
|
21
21
|
* Mocking the response of the /supported endpoint
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Network Constants - CAIP-2 format for x402 v2
|
|
25
|
+
* These match the official Solana chain IDs used by x402 protocol
|
|
26
|
+
*/
|
|
24
27
|
NETWORKS = {
|
|
25
28
|
DEVNET: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
|
|
26
29
|
MAINNET: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
/**
|
|
32
|
+
* DUMMY_FEE_PAYER Explanation (for auditors):
|
|
33
|
+
*
|
|
34
|
+
* In a HOSTED facilitator (like x402.org), the `feePayer` field in the
|
|
35
|
+
* SupportedResponse.extra specifies which address will pay transaction fees
|
|
36
|
+
* when the facilitator submits transactions on behalf of users.
|
|
37
|
+
*
|
|
38
|
+
* In LOCAL/SELF-SOVEREIGN mode (this implementation):
|
|
39
|
+
* - The USER pays their own transaction fees directly
|
|
40
|
+
* - The facilitator NEVER submits transactions - it only VERIFIES them
|
|
41
|
+
* - Therefore, no fee payer address is actually used
|
|
42
|
+
*
|
|
43
|
+
* However, the x402 protocol REQUIRES this field in the response schema.
|
|
44
|
+
* We use the System Program address (all 1s) as a placeholder because:
|
|
45
|
+
* 1. It's clearly not a real wallet (obvious placeholder)
|
|
46
|
+
* 2. It cannot receive funds or sign transactions
|
|
47
|
+
* 3. It signals to developers that fee paying is handled differently
|
|
48
|
+
*
|
|
49
|
+
* SECURITY NOTE: This is NOT a security risk because:
|
|
50
|
+
* - The fee payer is never used in verify() or settle() methods
|
|
51
|
+
* - Users sign and pay for their own transactions
|
|
52
|
+
* - The address is just a protocol-required placeholder
|
|
53
|
+
*
|
|
54
|
+
* @see https://docs.x402.org for protocol specification
|
|
55
|
+
*/
|
|
30
56
|
DUMMY_FEE_PAYER = "11111111111111111111111111111111";
|
|
31
57
|
/**
|
|
32
58
|
* Get supported payment kinds
|
|
33
59
|
* Returns x402 v2 compatible response with CAIP-2 network identifiers
|
|
60
|
+
*
|
|
61
|
+
* NOTE: The feePayer in extra.feePayer is a placeholder only.
|
|
62
|
+
* In self-sovereign mode, users pay their own transaction fees.
|
|
34
63
|
*/
|
|
35
64
|
async getSupported(_extensionKeys = []) {
|
|
36
|
-
console.log("[LocalSvmFacilitator] getSupported called");
|
|
37
65
|
const supported = {
|
|
38
66
|
kinds: [
|
|
39
67
|
{
|
|
@@ -51,10 +79,10 @@ var LocalSvmFacilitator = class {
|
|
|
51
79
|
],
|
|
52
80
|
extensions: [],
|
|
53
81
|
signers: {
|
|
82
|
+
// Placeholder - in self-sovereign mode, users are their own signers
|
|
54
83
|
"solana:*": [this.DUMMY_FEE_PAYER]
|
|
55
84
|
}
|
|
56
85
|
};
|
|
57
|
-
console.log("[LocalSvmFacilitator] Returning supported:", JSON.stringify(supported));
|
|
58
86
|
return supported;
|
|
59
87
|
}
|
|
60
88
|
/**
|
package/dist/next/index.js
CHANGED
|
@@ -19,20 +19,48 @@ var LocalSvmFacilitator = class {
|
|
|
19
19
|
* Get supported payment kinds
|
|
20
20
|
* Mocking the response of the /supported endpoint
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Network Constants - CAIP-2 format for x402 v2
|
|
24
|
+
* These match the official Solana chain IDs used by x402 protocol
|
|
25
|
+
*/
|
|
23
26
|
NETWORKS = {
|
|
24
27
|
DEVNET: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
|
|
25
28
|
MAINNET: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
|
|
26
29
|
};
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* DUMMY_FEE_PAYER Explanation (for auditors):
|
|
32
|
+
*
|
|
33
|
+
* In a HOSTED facilitator (like x402.org), the `feePayer` field in the
|
|
34
|
+
* SupportedResponse.extra specifies which address will pay transaction fees
|
|
35
|
+
* when the facilitator submits transactions on behalf of users.
|
|
36
|
+
*
|
|
37
|
+
* In LOCAL/SELF-SOVEREIGN mode (this implementation):
|
|
38
|
+
* - The USER pays their own transaction fees directly
|
|
39
|
+
* - The facilitator NEVER submits transactions - it only VERIFIES them
|
|
40
|
+
* - Therefore, no fee payer address is actually used
|
|
41
|
+
*
|
|
42
|
+
* However, the x402 protocol REQUIRES this field in the response schema.
|
|
43
|
+
* We use the System Program address (all 1s) as a placeholder because:
|
|
44
|
+
* 1. It's clearly not a real wallet (obvious placeholder)
|
|
45
|
+
* 2. It cannot receive funds or sign transactions
|
|
46
|
+
* 3. It signals to developers that fee paying is handled differently
|
|
47
|
+
*
|
|
48
|
+
* SECURITY NOTE: This is NOT a security risk because:
|
|
49
|
+
* - The fee payer is never used in verify() or settle() methods
|
|
50
|
+
* - Users sign and pay for their own transactions
|
|
51
|
+
* - The address is just a protocol-required placeholder
|
|
52
|
+
*
|
|
53
|
+
* @see https://docs.x402.org for protocol specification
|
|
54
|
+
*/
|
|
29
55
|
DUMMY_FEE_PAYER = "11111111111111111111111111111111";
|
|
30
56
|
/**
|
|
31
57
|
* Get supported payment kinds
|
|
32
58
|
* Returns x402 v2 compatible response with CAIP-2 network identifiers
|
|
59
|
+
*
|
|
60
|
+
* NOTE: The feePayer in extra.feePayer is a placeholder only.
|
|
61
|
+
* In self-sovereign mode, users pay their own transaction fees.
|
|
33
62
|
*/
|
|
34
63
|
async getSupported(_extensionKeys = []) {
|
|
35
|
-
console.log("[LocalSvmFacilitator] getSupported called");
|
|
36
64
|
const supported = {
|
|
37
65
|
kinds: [
|
|
38
66
|
{
|
|
@@ -50,10 +78,10 @@ var LocalSvmFacilitator = class {
|
|
|
50
78
|
],
|
|
51
79
|
extensions: [],
|
|
52
80
|
signers: {
|
|
81
|
+
// Placeholder - in self-sovereign mode, users are their own signers
|
|
53
82
|
"solana:*": [this.DUMMY_FEE_PAYER]
|
|
54
83
|
}
|
|
55
84
|
};
|
|
56
|
-
console.log("[LocalSvmFacilitator] Returning supported:", JSON.stringify(supported));
|
|
57
85
|
return supported;
|
|
58
86
|
}
|
|
59
87
|
/**
|
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.1",
|
|
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
|
+
}
|