@alleyboss/micropay-solana-x402-paywall 3.1.4 → 3.2.0
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/agent/index.cjs +12 -5
- package/dist/agent/index.js +8 -5
- package/dist/client/index.cjs +1605 -0
- package/dist/client/index.d.cts +94 -1
- package/dist/client/index.d.ts +94 -1
- package/dist/client/index.js +1604 -1
- package/dist/index.cjs +1615 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1611 -8
- package/package.json +5 -1
package/dist/agent/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var web3_js = require('@solana/web3.js');
|
|
4
|
+
var bs58 = require('bs58');
|
|
4
5
|
var jose = require('jose');
|
|
5
6
|
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
10
|
+
|
|
6
11
|
// src/agent/agentPayment.ts
|
|
7
12
|
var DEFAULT_COMPUTE_UNITS = 2e5;
|
|
8
13
|
var DEFAULT_MICRO_LAMPORTS = 1e3;
|
|
@@ -51,8 +56,6 @@ async function buildVersionedTransaction(config) {
|
|
|
51
56
|
lastValidBlockHeight
|
|
52
57
|
};
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
// src/agent/agentPayment.ts
|
|
56
59
|
var WALLET_REGEX = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
57
60
|
function isValidWalletAddress(address) {
|
|
58
61
|
if (!address || typeof address !== "string") return false;
|
|
@@ -153,15 +156,19 @@ async function hasAgentSufficientBalance(connection, agentKeypair, requiredLampo
|
|
|
153
156
|
};
|
|
154
157
|
}
|
|
155
158
|
function keypairFromBase58(base58Secret) {
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
try {
|
|
160
|
+
const bytes = bs58__default.default.decode(base58Secret);
|
|
161
|
+
if (bytes.length !== 64) {
|
|
162
|
+
throw new Error("Invalid secret key length. Expected 64 bytes.");
|
|
163
|
+
}
|
|
164
|
+
return web3_js.Keypair.fromSecretKey(bytes);
|
|
165
|
+
} catch (error) {
|
|
158
166
|
const parts = base58Secret.split(",").map((n) => parseInt(n.trim(), 10));
|
|
159
167
|
if (parts.length === 64) {
|
|
160
168
|
return web3_js.Keypair.fromSecretKey(Uint8Array.from(parts));
|
|
161
169
|
}
|
|
162
170
|
throw new Error("Invalid secret key format. Expected base58 string or comma-separated bytes.");
|
|
163
171
|
}
|
|
164
|
-
return web3_js.Keypair.fromSecretKey(bytes);
|
|
165
172
|
}
|
|
166
173
|
function generateAgentKeypair() {
|
|
167
174
|
const keypair = web3_js.Keypair.generate();
|
package/dist/agent/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PublicKey, SystemProgram, LAMPORTS_PER_SOL, Keypair, TransactionMessage, VersionedTransaction, ComputeBudgetProgram } from '@solana/web3.js';
|
|
2
|
+
import bs58 from 'bs58';
|
|
2
3
|
import { SignJWT, jwtVerify } from 'jose';
|
|
3
4
|
|
|
4
5
|
// src/agent/agentPayment.ts
|
|
@@ -49,8 +50,6 @@ async function buildVersionedTransaction(config) {
|
|
|
49
50
|
lastValidBlockHeight
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
// src/agent/agentPayment.ts
|
|
54
53
|
var WALLET_REGEX = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
55
54
|
function isValidWalletAddress(address) {
|
|
56
55
|
if (!address || typeof address !== "string") return false;
|
|
@@ -151,15 +150,19 @@ async function hasAgentSufficientBalance(connection, agentKeypair, requiredLampo
|
|
|
151
150
|
};
|
|
152
151
|
}
|
|
153
152
|
function keypairFromBase58(base58Secret) {
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
try {
|
|
154
|
+
const bytes = bs58.decode(base58Secret);
|
|
155
|
+
if (bytes.length !== 64) {
|
|
156
|
+
throw new Error("Invalid secret key length. Expected 64 bytes.");
|
|
157
|
+
}
|
|
158
|
+
return Keypair.fromSecretKey(bytes);
|
|
159
|
+
} catch (error) {
|
|
156
160
|
const parts = base58Secret.split(",").map((n) => parseInt(n.trim(), 10));
|
|
157
161
|
if (parts.length === 64) {
|
|
158
162
|
return Keypair.fromSecretKey(Uint8Array.from(parts));
|
|
159
163
|
}
|
|
160
164
|
throw new Error("Invalid secret key format. Expected base58 string or comma-separated bytes.");
|
|
161
165
|
}
|
|
162
|
-
return Keypair.fromSecretKey(bytes);
|
|
163
166
|
}
|
|
164
167
|
function generateAgentKeypair() {
|
|
165
168
|
const keypair = Keypair.generate();
|