@agent-shield/sdk 0.4.1 → 0.5.2
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/LICENSE +191 -0
- package/README.md +10 -19
- package/dist/idl-json.d.ts +3 -3
- package/dist/idl-json.js +3 -3
- package/dist/idl-json.js.map +1 -1
- package/dist/idl.d.ts +3 -3
- package/dist/idl.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/wrapper/engine.d.ts +17 -0
- package/dist/wrapper/engine.d.ts.map +1 -0
- package/dist/wrapper/engine.js +45 -0
- package/dist/wrapper/engine.js.map +1 -0
- package/dist/wrapper/errors.d.ts +10 -0
- package/dist/wrapper/errors.d.ts.map +1 -0
- package/dist/wrapper/errors.js +20 -0
- package/dist/wrapper/errors.js.map +1 -0
- package/dist/wrapper/harden.d.ts +119 -0
- package/dist/wrapper/harden.d.ts.map +1 -0
- package/dist/wrapper/harden.js +399 -0
- package/dist/wrapper/harden.js.map +1 -0
- package/dist/wrapper/index.d.ts +17 -0
- package/dist/wrapper/index.d.ts.map +1 -0
- package/dist/wrapper/index.js +60 -0
- package/dist/wrapper/index.js.map +1 -0
- package/dist/wrapper/inspector.d.ts +22 -0
- package/dist/wrapper/inspector.d.ts.map +1 -0
- package/dist/wrapper/inspector.js +175 -0
- package/dist/wrapper/inspector.js.map +1 -0
- package/dist/wrapper/policies.d.ts +78 -0
- package/dist/wrapper/policies.d.ts.map +1 -0
- package/dist/wrapper/policies.js +108 -0
- package/dist/wrapper/policies.js.map +1 -0
- package/dist/wrapper/registry.d.ts +24 -0
- package/dist/wrapper/registry.d.ts.map +1 -0
- package/dist/wrapper/registry.js +43 -0
- package/dist/wrapper/registry.js.map +1 -0
- package/dist/wrapper/shield.d.ts +86 -0
- package/dist/wrapper/shield.d.ts.map +1 -0
- package/dist/wrapper/shield.js +236 -0
- package/dist/wrapper/shield.js.map +1 -0
- package/dist/wrapper/state.d.ts +3 -0
- package/dist/wrapper/state.d.ts.map +1 -0
- package/dist/wrapper/state.js +6 -0
- package/dist/wrapper/state.js.map +1 -0
- package/dist/wrapper/x402.d.ts +153 -0
- package/dist/wrapper/x402.d.ts.map +1 -0
- package/dist/wrapper/x402.js +342 -0
- package/dist/wrapper/x402.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.X402UnsupportedError = exports.X402PaymentError = exports.X402ParseError = void 0;
|
|
4
|
+
exports.decodePaymentRequiredHeader = decodePaymentRequiredHeader;
|
|
5
|
+
exports.encodePaymentSignatureHeader = encodePaymentSignatureHeader;
|
|
6
|
+
exports.decodePaymentResponseHeader = decodePaymentResponseHeader;
|
|
7
|
+
exports.selectPaymentOption = selectPaymentOption;
|
|
8
|
+
exports.evaluateX402Payment = evaluateX402Payment;
|
|
9
|
+
exports.buildX402TransferInstruction = buildX402TransferInstruction;
|
|
10
|
+
exports.encodeX402Payload = encodeX402Payload;
|
|
11
|
+
exports.shieldedFetch = shieldedFetch;
|
|
12
|
+
exports.createShieldedFetchForWallet = createShieldedFetchForWallet;
|
|
13
|
+
/**
|
|
14
|
+
* x402 — HTTP 402 Payment Required support for shielded wallets.
|
|
15
|
+
*
|
|
16
|
+
* Implements the x402 V2 protocol (coinbase/x402) for machine-to-machine
|
|
17
|
+
* crypto payments. The client signs a payment, retries with PAYMENT-SIGNATURE
|
|
18
|
+
* header, and the API server settles via a facilitator.
|
|
19
|
+
*
|
|
20
|
+
* @see https://x402.org
|
|
21
|
+
*/
|
|
22
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
23
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
24
|
+
const engine_1 = require("./engine");
|
|
25
|
+
const errors_1 = require("./errors");
|
|
26
|
+
const registry_1 = require("./registry");
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Errors
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
class X402ParseError extends Error {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(`x402 parse error: ${message}`);
|
|
33
|
+
this.name = "X402ParseError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.X402ParseError = X402ParseError;
|
|
37
|
+
class X402PaymentError extends Error {
|
|
38
|
+
constructor(message) {
|
|
39
|
+
super(`x402 payment error: ${message}`);
|
|
40
|
+
this.name = "X402PaymentError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.X402PaymentError = X402PaymentError;
|
|
44
|
+
class X402UnsupportedError extends Error {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super(`x402 unsupported: ${message}`);
|
|
47
|
+
this.name = "X402UnsupportedError";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.X402UnsupportedError = X402UnsupportedError;
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Header encoding / decoding
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
function base64Encode(data) {
|
|
55
|
+
if (typeof Buffer !== "undefined") {
|
|
56
|
+
return Buffer.from(data, "utf-8").toString("base64");
|
|
57
|
+
}
|
|
58
|
+
return btoa(data);
|
|
59
|
+
}
|
|
60
|
+
function base64Decode(encoded) {
|
|
61
|
+
if (typeof Buffer !== "undefined") {
|
|
62
|
+
return Buffer.from(encoded, "base64").toString("utf-8");
|
|
63
|
+
}
|
|
64
|
+
return atob(encoded);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Decode a base64-encoded PAYMENT-REQUIRED header value.
|
|
68
|
+
*/
|
|
69
|
+
function decodePaymentRequiredHeader(header) {
|
|
70
|
+
try {
|
|
71
|
+
const json = base64Decode(header);
|
|
72
|
+
const parsed = JSON.parse(json);
|
|
73
|
+
if (!parsed.accepts || !Array.isArray(parsed.accepts)) {
|
|
74
|
+
throw new Error("missing accepts array");
|
|
75
|
+
}
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw new X402ParseError(`Failed to decode PAYMENT-REQUIRED header: ${err.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Encode a PaymentPayload as a base64 string for PAYMENT-SIGNATURE header.
|
|
84
|
+
*/
|
|
85
|
+
function encodePaymentSignatureHeader(payload) {
|
|
86
|
+
return base64Encode(JSON.stringify(payload));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Decode a base64-encoded PAYMENT-RESPONSE header value.
|
|
90
|
+
*/
|
|
91
|
+
function decodePaymentResponseHeader(header) {
|
|
92
|
+
try {
|
|
93
|
+
return JSON.parse(base64Decode(header));
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
throw new X402ParseError(`Failed to decode PAYMENT-RESPONSE header: ${err.message}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// Payment option selection
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
/**
|
|
103
|
+
* Select a Solana-compatible payment option from the accepts array.
|
|
104
|
+
*
|
|
105
|
+
* @param paymentRequired The decoded PAYMENT-REQUIRED payload
|
|
106
|
+
* @param allowedTokens Optional set of token mint addresses to accept
|
|
107
|
+
* @returns The first matching PaymentRequirements, or throws
|
|
108
|
+
*/
|
|
109
|
+
function selectPaymentOption(paymentRequired, allowedTokens) {
|
|
110
|
+
for (const option of paymentRequired.accepts) {
|
|
111
|
+
// Network must start with "solana:" (CAIP-2 format)
|
|
112
|
+
if (!option.network.startsWith("solana:")) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
// If token filter provided, asset must be in the allowlist
|
|
116
|
+
if (allowedTokens && !allowedTokens.has(option.asset)) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
return option;
|
|
120
|
+
}
|
|
121
|
+
throw new X402UnsupportedError("No compatible Solana payment option found in accepts array");
|
|
122
|
+
}
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Policy evaluation (pre-check only — does NOT record spend)
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
/**
|
|
127
|
+
* Evaluate an x402 payment against shield policies without recording spend.
|
|
128
|
+
*
|
|
129
|
+
* Creates a synthetic TransactionAnalysis from the payment requirements
|
|
130
|
+
* and runs it through the existing policy engine.
|
|
131
|
+
*/
|
|
132
|
+
function evaluateX402Payment(selected, policies, state) {
|
|
133
|
+
const analysis = {
|
|
134
|
+
programIds: [spl_token_1.TOKEN_PROGRAM_ID],
|
|
135
|
+
transfers: [
|
|
136
|
+
{
|
|
137
|
+
mint: new web3_js_1.PublicKey(selected.asset),
|
|
138
|
+
amount: BigInt(selected.amount),
|
|
139
|
+
direction: "outgoing",
|
|
140
|
+
destination: new web3_js_1.PublicKey(selected.payTo),
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
estimatedValueLamports: BigInt(selected.amount),
|
|
144
|
+
};
|
|
145
|
+
return (0, engine_1.evaluatePolicy)(analysis, policies, state);
|
|
146
|
+
}
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// Transfer instruction builder
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
/**
|
|
151
|
+
* Build an SPL TransferChecked instruction for an x402 payment.
|
|
152
|
+
*/
|
|
153
|
+
function buildX402TransferInstruction(params) {
|
|
154
|
+
const sourceAta = (0, spl_token_1.getAssociatedTokenAddressSync)(params.asset, params.from);
|
|
155
|
+
const destAta = (0, spl_token_1.getAssociatedTokenAddressSync)(params.asset, params.payTo);
|
|
156
|
+
return (0, spl_token_1.createTransferCheckedInstruction)(sourceAta, params.asset, destAta, params.from, params.amount, params.decimals);
|
|
157
|
+
}
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
// Payload encoding
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
/**
|
|
162
|
+
* Encode a signed transaction into a full x402 V2 PaymentPayload.
|
|
163
|
+
*/
|
|
164
|
+
function encodeX402Payload(signedTx, resource, accepted) {
|
|
165
|
+
const txBase64 = base64Encode(String.fromCharCode(...signedTx));
|
|
166
|
+
const payload = {
|
|
167
|
+
x402Version: 2,
|
|
168
|
+
resource,
|
|
169
|
+
accepted,
|
|
170
|
+
payload: { transaction: txBase64 },
|
|
171
|
+
extensions: {},
|
|
172
|
+
};
|
|
173
|
+
return encodePaymentSignatureHeader(payload);
|
|
174
|
+
}
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// Core: shieldedFetch
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
/**
|
|
179
|
+
* Fetch a URL with automatic x402 payment support.
|
|
180
|
+
*
|
|
181
|
+
* Flow:
|
|
182
|
+
* 1. Make the initial HTTP request
|
|
183
|
+
* 2. If 402, parse PAYMENT-REQUIRED header
|
|
184
|
+
* 3. Select a Solana payment option
|
|
185
|
+
* 4. Evaluate against shield policies (fast deny)
|
|
186
|
+
* 5. Build, sign, and encode payment transaction
|
|
187
|
+
* 6. Retry with PAYMENT-SIGNATURE header
|
|
188
|
+
* 7. Return response with x402 metadata
|
|
189
|
+
*
|
|
190
|
+
* The client NEVER settles — the API server calls the facilitator.
|
|
191
|
+
*/
|
|
192
|
+
async function shieldedFetch(wallet, url, options) {
|
|
193
|
+
const init = { ...options };
|
|
194
|
+
const connection = options?.connection;
|
|
195
|
+
const dryRun = options?.dryRun ?? false;
|
|
196
|
+
// Strip our custom options from the fetch init
|
|
197
|
+
delete init.connection;
|
|
198
|
+
delete init.dryRun;
|
|
199
|
+
delete init.maxPayment;
|
|
200
|
+
// Step 1: Initial request
|
|
201
|
+
const response = await globalThis.fetch(url.toString(), init);
|
|
202
|
+
// Non-402 responses pass through unchanged
|
|
203
|
+
if (response.status !== 402) {
|
|
204
|
+
return response;
|
|
205
|
+
}
|
|
206
|
+
// Step 2: Extract PAYMENT-REQUIRED header (case-insensitive)
|
|
207
|
+
const paymentRequiredHeader = response.headers.get("payment-required") ??
|
|
208
|
+
response.headers.get("PAYMENT-REQUIRED");
|
|
209
|
+
if (!paymentRequiredHeader) {
|
|
210
|
+
// Non-x402 402 response — return as-is
|
|
211
|
+
return response;
|
|
212
|
+
}
|
|
213
|
+
// Step 3: Prevent infinite retry loops — reject if already attempted
|
|
214
|
+
const hasPaymentHeader = (() => {
|
|
215
|
+
if (!init.headers)
|
|
216
|
+
return false;
|
|
217
|
+
if (init.headers instanceof Headers) {
|
|
218
|
+
return (init.headers.has("PAYMENT-SIGNATURE") ||
|
|
219
|
+
init.headers.has("payment-signature"));
|
|
220
|
+
}
|
|
221
|
+
if (Array.isArray(init.headers)) {
|
|
222
|
+
return init.headers.some(([k]) => k.toLowerCase() === "payment-signature");
|
|
223
|
+
}
|
|
224
|
+
const rec = init.headers;
|
|
225
|
+
return "PAYMENT-SIGNATURE" in rec || "payment-signature" in rec;
|
|
226
|
+
})();
|
|
227
|
+
if (hasPaymentHeader) {
|
|
228
|
+
throw new X402PaymentError("Payment already attempted — refusing to retry to prevent infinite loops");
|
|
229
|
+
}
|
|
230
|
+
// Step 4: Decode header
|
|
231
|
+
const paymentRequired = decodePaymentRequiredHeader(paymentRequiredHeader);
|
|
232
|
+
// Step 5: Select a Solana payment option
|
|
233
|
+
const allowedTokens = wallet.resolvedPolicies.allowedTokens
|
|
234
|
+
? new Set(wallet.resolvedPolicies.allowedTokens)
|
|
235
|
+
: undefined;
|
|
236
|
+
const selected = selectPaymentOption(paymentRequired, allowedTokens);
|
|
237
|
+
// Enforce maxPayment ceiling if set
|
|
238
|
+
if (options?.maxPayment) {
|
|
239
|
+
try {
|
|
240
|
+
const maxAmount = BigInt(options.maxPayment);
|
|
241
|
+
const requestedAmount = BigInt(selected.amount);
|
|
242
|
+
if (requestedAmount > maxAmount) {
|
|
243
|
+
throw new X402PaymentError(`Server requires ${selected.amount} but maxPayment is ${options.maxPayment}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (e) {
|
|
247
|
+
if (e instanceof X402PaymentError)
|
|
248
|
+
throw e;
|
|
249
|
+
throw new X402PaymentError(`Invalid maxPayment value: "${options.maxPayment}" (must be a non-negative integer string)`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Step 5: Policy pre-check (does NOT record spend)
|
|
253
|
+
const violations = evaluateX402Payment(selected, wallet.resolvedPolicies, wallet.shieldState);
|
|
254
|
+
if (violations.length > 0) {
|
|
255
|
+
throw new errors_1.ShieldDeniedError(violations);
|
|
256
|
+
}
|
|
257
|
+
// Step 6: Dry run — return metadata without paying
|
|
258
|
+
if (dryRun) {
|
|
259
|
+
const dryResponse = new Response(null, {
|
|
260
|
+
status: 402,
|
|
261
|
+
});
|
|
262
|
+
dryResponse.x402 = {
|
|
263
|
+
paid: false,
|
|
264
|
+
amountPaid: selected.amount,
|
|
265
|
+
asset: selected.asset,
|
|
266
|
+
payTo: selected.payTo,
|
|
267
|
+
};
|
|
268
|
+
return dryResponse;
|
|
269
|
+
}
|
|
270
|
+
// Step 7: Build and sign the payment transaction
|
|
271
|
+
const assetPubkey = new web3_js_1.PublicKey(selected.asset);
|
|
272
|
+
const tokenInfo = (0, registry_1.getTokenInfo)(assetPubkey);
|
|
273
|
+
const decimals = tokenInfo?.decimals ?? 6; // USDC default
|
|
274
|
+
if (!connection) {
|
|
275
|
+
throw new X402PaymentError("Connection required for x402 payments. Pass connection in ShieldedFetchOptions.");
|
|
276
|
+
}
|
|
277
|
+
const transferIx = buildX402TransferInstruction({
|
|
278
|
+
from: wallet.publicKey,
|
|
279
|
+
payTo: new web3_js_1.PublicKey(selected.payTo),
|
|
280
|
+
asset: assetPubkey,
|
|
281
|
+
amount: BigInt(selected.amount),
|
|
282
|
+
decimals,
|
|
283
|
+
});
|
|
284
|
+
const tx = new web3_js_1.Transaction();
|
|
285
|
+
tx.add(transferIx);
|
|
286
|
+
const { blockhash } = await connection.getLatestBlockhash();
|
|
287
|
+
tx.recentBlockhash = blockhash;
|
|
288
|
+
tx.feePayer = wallet.publicKey;
|
|
289
|
+
// For client-side wallets: signTransaction runs through the shield interceptor
|
|
290
|
+
// which evaluates policies AND records the spend.
|
|
291
|
+
// For hardened wallets: the shield interceptor wraps in vault composition.
|
|
292
|
+
const signedTx = await wallet.signTransaction(tx);
|
|
293
|
+
const serialized = signedTx.serialize({
|
|
294
|
+
verifySignatures: false,
|
|
295
|
+
});
|
|
296
|
+
// Step 8: Encode the payment payload
|
|
297
|
+
const encodedPayload = encodeX402Payload(serialized, paymentRequired.resource, selected);
|
|
298
|
+
// Step 10: Retry with PAYMENT-SIGNATURE header
|
|
299
|
+
const retryHeaders = new Headers(init.headers);
|
|
300
|
+
retryHeaders.set("PAYMENT-SIGNATURE", encodedPayload);
|
|
301
|
+
const retryResponse = (await globalThis.fetch(url.toString(), {
|
|
302
|
+
...init,
|
|
303
|
+
headers: retryHeaders,
|
|
304
|
+
}));
|
|
305
|
+
// Step 10: Parse PAYMENT-RESPONSE header if present
|
|
306
|
+
const paymentResponseHeader = retryResponse.headers.get("payment-response") ??
|
|
307
|
+
retryResponse.headers.get("PAYMENT-RESPONSE");
|
|
308
|
+
let settlement;
|
|
309
|
+
if (paymentResponseHeader) {
|
|
310
|
+
try {
|
|
311
|
+
settlement = decodePaymentResponseHeader(paymentResponseHeader);
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
// Non-fatal — settlement data is optional
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Attach x402 metadata
|
|
318
|
+
retryResponse.x402 = {
|
|
319
|
+
paid: true,
|
|
320
|
+
amountPaid: selected.amount,
|
|
321
|
+
asset: selected.asset,
|
|
322
|
+
payTo: selected.payTo,
|
|
323
|
+
settlement,
|
|
324
|
+
};
|
|
325
|
+
return retryResponse;
|
|
326
|
+
}
|
|
327
|
+
// ---------------------------------------------------------------------------
|
|
328
|
+
// Factory
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
/**
|
|
331
|
+
* Create a wallet-bound fetch function with automatic x402 payment support.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* const fetch = createShieldedFetchForWallet(shieldedWallet, { connection });
|
|
336
|
+
* const res = await fetch('https://api.example.com/paid-endpoint');
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
function createShieldedFetchForWallet(wallet, defaults) {
|
|
340
|
+
return (url, init) => shieldedFetch(wallet, url, { ...defaults, ...init });
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=x402.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402.js","sourceRoot":"","sources":["../../src/wrapper/x402.ts"],"names":[],"mappings":";;;AAqJA,kEAaC;AAKD,oEAEC;AAKD,kEAQC;AAaD,kDAkBC;AAYD,kDAkBC;AASD,oEAkBC;AASD,8CAcC;AAoBD,sCAoLC;AAeD,oEAMC;AAlgBD;;;;;;;;GAQG;AACH,6CAKyB;AACzB,iDAI2B;AAG3B,qCAA6D;AAC7D,qCAA6C;AAE7C,yCAA0C;AA8E1C,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AAED,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;C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;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC;IAED,uBAAuB;IACvB,aAAa,CAAC,IAAI,GAAG;QACnB,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,QAAQ,CAAC,MAAM;QAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,UAAU;KACX,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,SAAgB,4BAA4B,CAC1C,MAAsB,EACtB,QAAwD;IAExD,OAAO,CAAC,GAAiB,EAAE,IAAkB,EAAE,EAAE,CAC/C,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-shield/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"author": "Kaleb Rupe (https://x.com/MightieMags)",
|
|
5
5
|
"homepage": "https://github.com/Kaleb-Rupe/agentshield#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
"node": ">=18.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@solana/spl-token": "^0.4.0"
|
|
23
|
+
"@solana/spl-token": "^0.4.0",
|
|
24
|
+
"@x402/core": "^2.4.0",
|
|
25
|
+
"@agent-shield/core": "0.1.5"
|
|
24
26
|
},
|
|
25
27
|
"peerDependencies": {
|
|
26
28
|
"@coral-xyz/anchor": "^0.32.1",
|
|
27
29
|
"@solana/web3.js": "^1.95.0"
|
|
28
30
|
},
|
|
29
31
|
"optionalDependencies": {
|
|
30
|
-
"flash-sdk": "^14.
|
|
32
|
+
"flash-sdk": "^14.1.1"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/bn.js": "^5.1.5",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"policy-engine",
|
|
49
51
|
"mcp"
|
|
50
52
|
],
|
|
51
|
-
"license": "
|
|
53
|
+
"license": "Apache-2.0",
|
|
52
54
|
"repository": {
|
|
53
55
|
"type": "git",
|
|
54
56
|
"url": "https://github.com/Kaleb-Rupe/agentshield",
|