@proofgate/agentkit 1.0.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/LICENSE +21 -0
- package/README.md +247 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/proofgate-action-provider.d.ts +98 -0
- package/dist/proofgate-action-provider.d.ts.map +1 -0
- package/dist/proofgate-action-provider.js +395 -0
- package/dist/proofgate-action-provider.js.map +1 -0
- package/dist/schemas.d.ts +123 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +83 -0
- package/dist/schemas.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ProofGate
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# @proofgate/agentkit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@proofgate/agentkit)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
**ProofGate Action Provider for Coinbase AgentKit** - Add transaction security validation to your AI agents.
|
|
7
|
+
|
|
8
|
+
ProofGate validates blockchain transactions in real-time, detecting and blocking:
|
|
9
|
+
- 🚫 Phishing addresses
|
|
10
|
+
- 🏴 Sanctioned wallets
|
|
11
|
+
- 💀 Known scam contracts
|
|
12
|
+
- ⚠️ Suspicious patterns
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @proofgate/agentkit @coinbase/agentkit
|
|
18
|
+
# or
|
|
19
|
+
yarn add @proofgate/agentkit @coinbase/agentkit
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @proofgate/agentkit @coinbase/agentkit
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { AgentKit } from "@coinbase/agentkit";
|
|
28
|
+
import { proofGateActionProvider } from "@proofgate/agentkit";
|
|
29
|
+
|
|
30
|
+
const agent = await AgentKit.from({
|
|
31
|
+
walletProvider,
|
|
32
|
+
actionProviders: [
|
|
33
|
+
proofGateActionProvider({
|
|
34
|
+
apiKey: process.env.PROOFGATE_API_KEY!,
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Your agent now has transaction validation superpowers! 🛡️
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
### 🔍 Transaction Validation
|
|
45
|
+
|
|
46
|
+
Validate any transaction before execution:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// The agent can use the validate_transaction action
|
|
50
|
+
const validation = await agent.execute(`
|
|
51
|
+
Validate this transaction before I send:
|
|
52
|
+
- To: 0xSuspiciousAddress...
|
|
53
|
+
- Amount: 5 ETH
|
|
54
|
+
`);
|
|
55
|
+
// Returns: SAFE, WARNING, or BLOCKED with risk details
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 🔐 Safe Transfers
|
|
59
|
+
|
|
60
|
+
Execute transfers with automatic validation:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// The agent can use the safe_transfer action
|
|
64
|
+
const result = await agent.execute(`
|
|
65
|
+
Send 100 USDC to 0xRecipient... using ProofGate validation
|
|
66
|
+
`);
|
|
67
|
+
// Transaction will be blocked if the address is malicious
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 📋 Audit Trail
|
|
71
|
+
|
|
72
|
+
Every validation returns a `proofId` for compliance:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Later, check validation status
|
|
76
|
+
const status = await agent.execute(`
|
|
77
|
+
Get validation status for proof ID: 550e8400-e29b-41d4-a716-446655440000
|
|
78
|
+
`);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const proofgate = proofGateActionProvider({
|
|
85
|
+
// Required
|
|
86
|
+
apiKey: process.env.PROOFGATE_API_KEY!,
|
|
87
|
+
|
|
88
|
+
// Optional settings
|
|
89
|
+
baseUrl: "https://www.proofgate.xyz/api/v1", // Custom API endpoint
|
|
90
|
+
blockThreshold: 70, // Block transactions with risk score >= 70
|
|
91
|
+
warnThreshold: 40, // Issue warnings for risk score >= 40
|
|
92
|
+
allowWarnings: true, // Allow transactions with WARNING status
|
|
93
|
+
timeout: 10000, // API timeout in milliseconds
|
|
94
|
+
verbose: false, // Enable debug logging
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Actions Provided
|
|
99
|
+
|
|
100
|
+
| Action | Description |
|
|
101
|
+
|--------|-------------|
|
|
102
|
+
| `proofgate_validate_transaction` | Validate transaction parameters against threat intelligence |
|
|
103
|
+
| `proofgate_safe_transfer` | Transfer with automatic ProofGate validation |
|
|
104
|
+
| `proofgate_get_validation_status` | Check status of a previous validation by proof ID |
|
|
105
|
+
|
|
106
|
+
## Validation Response
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
interface ValidationResult {
|
|
110
|
+
success: boolean;
|
|
111
|
+
proofId: string; // Unique ID for audit trail
|
|
112
|
+
status: "SAFE" | "WARNING" | "BLOCKED";
|
|
113
|
+
riskScore: number; // 0-100 risk score
|
|
114
|
+
riskFactors: string[]; // Detected risk factors
|
|
115
|
+
allowed: boolean; // Whether to proceed
|
|
116
|
+
recommendation: string; // Human-readable advice
|
|
117
|
+
metadata?: {
|
|
118
|
+
addressLabels?: Record<string, string>;
|
|
119
|
+
contractInfo?: { verified: boolean; name?: string };
|
|
120
|
+
sanctions?: boolean;
|
|
121
|
+
phishing?: boolean;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Integration Examples
|
|
127
|
+
|
|
128
|
+
### With Langchain
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { AgentKit, createLangChainTools } from "@coinbase/agentkit";
|
|
132
|
+
import { proofGateActionProvider } from "@proofgate/agentkit";
|
|
133
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
134
|
+
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
|
135
|
+
|
|
136
|
+
const agent = await AgentKit.from({
|
|
137
|
+
walletProvider,
|
|
138
|
+
actionProviders: [proofGateActionProvider({ apiKey: process.env.PROOFGATE_API_KEY! })],
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const tools = await createLangChainTools(agent);
|
|
142
|
+
const langchainAgent = createReactAgent({
|
|
143
|
+
llm: new ChatOpenAI({ model: "gpt-4" }),
|
|
144
|
+
tools,
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### With OpenAI Assistants
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { AgentKit, createOpenAITools } from "@coinbase/agentkit";
|
|
152
|
+
import { proofGateActionProvider } from "@proofgate/agentkit";
|
|
153
|
+
import OpenAI from "openai";
|
|
154
|
+
|
|
155
|
+
const agent = await AgentKit.from({
|
|
156
|
+
walletProvider,
|
|
157
|
+
actionProviders: [proofGateActionProvider({ apiKey: process.env.PROOFGATE_API_KEY! })],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const openai = new OpenAI();
|
|
161
|
+
const tools = createOpenAITools(agent);
|
|
162
|
+
|
|
163
|
+
const assistant = await openai.beta.assistants.create({
|
|
164
|
+
name: "Secure Crypto Agent",
|
|
165
|
+
instructions: "You are a crypto agent that validates all transactions with ProofGate before executing.",
|
|
166
|
+
tools,
|
|
167
|
+
model: "gpt-4-turbo",
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Wrapping Existing Transfers
|
|
172
|
+
|
|
173
|
+
For maximum security, validate before using other action providers:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { AgentKit } from "@coinbase/agentkit";
|
|
177
|
+
import { erc20ActionProvider } from "@coinbase/agentkit";
|
|
178
|
+
import { proofGateActionProvider } from "@proofgate/agentkit";
|
|
179
|
+
|
|
180
|
+
const agent = await AgentKit.from({
|
|
181
|
+
walletProvider,
|
|
182
|
+
actionProviders: [
|
|
183
|
+
proofGateActionProvider({ apiKey: process.env.PROOFGATE_API_KEY! }),
|
|
184
|
+
erc20ActionProvider(), // ProofGate validates, ERC20 executes
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Agent workflow:
|
|
189
|
+
// 1. Use proofgate_validate_transaction to check recipient
|
|
190
|
+
// 2. If SAFE/WARNING allowed, use erc20_transfer to execute
|
|
191
|
+
// 3. Log the proofId for compliance
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Network Support
|
|
195
|
+
|
|
196
|
+
ProofGate supports all EVM-compatible networks:
|
|
197
|
+
- Ethereum Mainnet
|
|
198
|
+
- Base
|
|
199
|
+
- Arbitrum
|
|
200
|
+
- Optimism
|
|
201
|
+
- Polygon
|
|
202
|
+
- And more...
|
|
203
|
+
|
|
204
|
+
## API Reference
|
|
205
|
+
|
|
206
|
+
### proofGateActionProvider(config)
|
|
207
|
+
|
|
208
|
+
Creates a new ProofGate action provider instance.
|
|
209
|
+
|
|
210
|
+
**Parameters:**
|
|
211
|
+
- `config.apiKey` (required): Your ProofGate API key
|
|
212
|
+
- `config.baseUrl` (optional): Custom API endpoint
|
|
213
|
+
- `config.blockThreshold` (optional): Risk score to block (default: 70)
|
|
214
|
+
- `config.warnThreshold` (optional): Risk score to warn (default: 40)
|
|
215
|
+
- `config.allowWarnings` (optional): Allow WARNING status (default: true)
|
|
216
|
+
- `config.timeout` (optional): Request timeout ms (default: 10000)
|
|
217
|
+
- `config.verbose` (optional): Debug logging (default: false)
|
|
218
|
+
|
|
219
|
+
## Getting an API Key
|
|
220
|
+
|
|
221
|
+
Visit [proofgate.xyz](https://proofgate.xyz) to get your API key.
|
|
222
|
+
|
|
223
|
+
## Security Best Practices
|
|
224
|
+
|
|
225
|
+
1. **Always validate before high-value transactions**
|
|
226
|
+
2. **Set appropriate thresholds** - Lower `blockThreshold` for stricter security
|
|
227
|
+
3. **Log proofIds** - Keep audit trail for compliance
|
|
228
|
+
4. **Handle failures safely** - If validation fails, don't proceed
|
|
229
|
+
5. **Use in combination** - Layer with other security measures
|
|
230
|
+
|
|
231
|
+
## Contributing
|
|
232
|
+
|
|
233
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) first.
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT - see [LICENSE](LICENSE)
|
|
238
|
+
|
|
239
|
+
## Support
|
|
240
|
+
|
|
241
|
+
- 📧 Email: support@proofgate.xyz
|
|
242
|
+
- 🐦 Twitter: [@proofgate](https://twitter.com/proofgate)
|
|
243
|
+
- 📚 Docs: [docs.proofgate.xyz](https://docs.proofgate.xyz)
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
Built with ❤️ by [ProofGate](https://proofgate.xyz)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @proofgate/agentkit
|
|
3
|
+
*
|
|
4
|
+
* ProofGate transaction validation action provider for Coinbase AgentKit.
|
|
5
|
+
* Validates blockchain transactions through ProofGate's security API to detect
|
|
6
|
+
* and block malicious, phishing, or sanctioned addresses.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export * from "./proofgate-action-provider.js";
|
|
11
|
+
export * from "./schemas.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,gCAAgC,CAAC;AAC/C,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @proofgate/agentkit
|
|
4
|
+
*
|
|
5
|
+
* ProofGate transaction validation action provider for Coinbase AgentKit.
|
|
6
|
+
* Validates blockchain transactions through ProofGate's security API to detect
|
|
7
|
+
* and block malicious, phishing, or sanctioned addresses.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("./proofgate-action-provider.js"), exports);
|
|
27
|
+
__exportStar(require("./schemas.js"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;AAEH,iEAA+C;AAC/C,+CAA6B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ActionProvider, EvmWalletProvider, Network } from "@coinbase/agentkit";
|
|
3
|
+
import { ValidateTransactionSchema, GetValidationStatusSchema, SafeTransferSchema, ProofGateConfig } from "./schemas.js";
|
|
4
|
+
/**
|
|
5
|
+
* ProofGateActionProvider provides transaction validation through ProofGate's
|
|
6
|
+
* security API. It can be used standalone or to wrap existing transaction actions
|
|
7
|
+
* with security checks.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { proofGateActionProvider } from "@proofgate/agentkit";
|
|
12
|
+
*
|
|
13
|
+
* const agent = await AgentKit.from({
|
|
14
|
+
* walletProvider,
|
|
15
|
+
* actionProviders: [
|
|
16
|
+
* proofGateActionProvider({
|
|
17
|
+
* apiKey: process.env.PROOFGATE_API_KEY!,
|
|
18
|
+
* blockThreshold: 70,
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class ProofGateActionProvider extends ActionProvider<EvmWalletProvider> {
|
|
25
|
+
private readonly apiKey;
|
|
26
|
+
private readonly baseUrl;
|
|
27
|
+
private readonly allowWarnings;
|
|
28
|
+
private readonly timeout;
|
|
29
|
+
private readonly verbose;
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a new ProofGateActionProvider.
|
|
32
|
+
*
|
|
33
|
+
* @param config - ProofGate configuration options
|
|
34
|
+
*/
|
|
35
|
+
constructor(config: ProofGateConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Internal method to call ProofGate validation API
|
|
38
|
+
*/
|
|
39
|
+
private callValidationApi;
|
|
40
|
+
/**
|
|
41
|
+
* Logs a message if verbose mode is enabled
|
|
42
|
+
*/
|
|
43
|
+
private log;
|
|
44
|
+
/**
|
|
45
|
+
* Validates a transaction through ProofGate's security API.
|
|
46
|
+
* This is the core validation action that checks transaction parameters
|
|
47
|
+
* against ProofGate's security intelligence.
|
|
48
|
+
*
|
|
49
|
+
* @param args - The transaction parameters to validate
|
|
50
|
+
* @returns Validation result as stringified JSON
|
|
51
|
+
*/
|
|
52
|
+
validateTransaction(args: z.infer<typeof ValidateTransactionSchema>): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Validates and executes a transfer with ProofGate protection.
|
|
55
|
+
* Blocks the transaction if ProofGate determines it's unsafe.
|
|
56
|
+
*
|
|
57
|
+
* @param walletProvider - The wallet provider to execute the transfer
|
|
58
|
+
* @param args - Transfer parameters including destination and amount
|
|
59
|
+
* @returns Transfer result or block message
|
|
60
|
+
*/
|
|
61
|
+
safeTransfer(walletProvider: EvmWalletProvider, args: z.infer<typeof SafeTransferSchema>): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the validation status for a previously submitted transaction.
|
|
64
|
+
*
|
|
65
|
+
* @param args - The proof ID to look up
|
|
66
|
+
* @returns Validation status as stringified JSON
|
|
67
|
+
*/
|
|
68
|
+
getValidationStatus(args: z.infer<typeof GetValidationStatusSchema>): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Generates a human-readable recommendation based on validation result
|
|
71
|
+
*/
|
|
72
|
+
private getRecommendation;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if this action provider supports the given network.
|
|
75
|
+
* ProofGate supports all EVM networks.
|
|
76
|
+
*
|
|
77
|
+
* @param network - The network to check
|
|
78
|
+
* @returns True if the network is EVM-based
|
|
79
|
+
*/
|
|
80
|
+
supportsNetwork(network: Network): boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Factory function to create a ProofGateActionProvider instance.
|
|
84
|
+
*
|
|
85
|
+
* @param config - ProofGate configuration options
|
|
86
|
+
* @returns A new ProofGateActionProvider instance
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const proofgate = proofGateActionProvider({
|
|
91
|
+
* apiKey: process.env.PROOFGATE_API_KEY!,
|
|
92
|
+
* blockThreshold: 70,
|
|
93
|
+
* verbose: true,
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare const proofGateActionProvider: (config: ProofGateConfig) => ProofGateActionProvider;
|
|
98
|
+
//# sourceMappingURL=proofgate-action-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proofgate-action-provider.d.ts","sourceRoot":"","sources":["../src/proofgate-action-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAgB,iBAAiB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9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, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.proofGateActionProvider = exports.ProofGateActionProvider = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const agentkit_1 = require("@coinbase/agentkit");
|
|
15
|
+
const schemas_js_1 = require("./schemas.js");
|
|
16
|
+
const DEFAULT_API_URL = "https://www.proofgate.xyz/api/v1";
|
|
17
|
+
const DEFAULT_TIMEOUT = 10000;
|
|
18
|
+
/**
|
|
19
|
+
* ProofGateActionProvider provides transaction validation through ProofGate's
|
|
20
|
+
* security API. It can be used standalone or to wrap existing transaction actions
|
|
21
|
+
* with security checks.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { proofGateActionProvider } from "@proofgate/agentkit";
|
|
26
|
+
*
|
|
27
|
+
* const agent = await AgentKit.from({
|
|
28
|
+
* walletProvider,
|
|
29
|
+
* actionProviders: [
|
|
30
|
+
* proofGateActionProvider({
|
|
31
|
+
* apiKey: process.env.PROOFGATE_API_KEY!,
|
|
32
|
+
* blockThreshold: 70,
|
|
33
|
+
* }),
|
|
34
|
+
* ],
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class ProofGateActionProvider extends agentkit_1.ActionProvider {
|
|
39
|
+
apiKey;
|
|
40
|
+
baseUrl;
|
|
41
|
+
allowWarnings;
|
|
42
|
+
timeout;
|
|
43
|
+
verbose;
|
|
44
|
+
/**
|
|
45
|
+
* Constructs a new ProofGateActionProvider.
|
|
46
|
+
*
|
|
47
|
+
* @param config - ProofGate configuration options
|
|
48
|
+
*/
|
|
49
|
+
constructor(config) {
|
|
50
|
+
super("proofgate", []);
|
|
51
|
+
if (!config.apiKey) {
|
|
52
|
+
throw new Error("ProofGate API key is required");
|
|
53
|
+
}
|
|
54
|
+
this.apiKey = config.apiKey;
|
|
55
|
+
this.baseUrl = config.baseUrl ?? DEFAULT_API_URL;
|
|
56
|
+
this.allowWarnings = config.allowWarnings ?? true;
|
|
57
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
58
|
+
this.verbose = config.verbose ?? false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Internal method to call ProofGate validation API
|
|
62
|
+
*/
|
|
63
|
+
async callValidationApi(params) {
|
|
64
|
+
const controller = new AbortController();
|
|
65
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
66
|
+
try {
|
|
67
|
+
const response = await fetch(`${this.baseUrl}/validate`, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
headers: {
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
72
|
+
"X-ProofGate-Client": "agentkit",
|
|
73
|
+
"X-ProofGate-Version": "1.0.0",
|
|
74
|
+
},
|
|
75
|
+
body: JSON.stringify({
|
|
76
|
+
from: params.fromAddress,
|
|
77
|
+
to: params.toAddress,
|
|
78
|
+
value: params.value ?? "0",
|
|
79
|
+
data: params.data ?? "0x",
|
|
80
|
+
chainId: params.chainId,
|
|
81
|
+
tokenAddress: params.tokenAddress,
|
|
82
|
+
tokenAmount: params.tokenAmount,
|
|
83
|
+
}),
|
|
84
|
+
signal: controller.signal,
|
|
85
|
+
});
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
const errorBody = await response.text();
|
|
88
|
+
throw new Error(`ProofGate API error (${response.status}): ${errorBody}`);
|
|
89
|
+
}
|
|
90
|
+
return await response.json();
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
clearTimeout(timeoutId);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Logs a message if verbose mode is enabled
|
|
98
|
+
*/
|
|
99
|
+
log(message, data) {
|
|
100
|
+
if (this.verbose) {
|
|
101
|
+
console.log(`[ProofGate] ${message}`, data ?? "");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Validates a transaction through ProofGate's security API.
|
|
106
|
+
* This is the core validation action that checks transaction parameters
|
|
107
|
+
* against ProofGate's security intelligence.
|
|
108
|
+
*
|
|
109
|
+
* @param args - The transaction parameters to validate
|
|
110
|
+
* @returns Validation result as stringified JSON
|
|
111
|
+
*/
|
|
112
|
+
async validateTransaction(args) {
|
|
113
|
+
try {
|
|
114
|
+
this.log("Validating transaction", args);
|
|
115
|
+
const result = await this.callValidationApi(args);
|
|
116
|
+
this.log("Validation result", result);
|
|
117
|
+
const statusEmoji = {
|
|
118
|
+
[schemas_js_1.ValidationStatus.SAFE]: "✅",
|
|
119
|
+
[schemas_js_1.ValidationStatus.WARNING]: "⚠️",
|
|
120
|
+
[schemas_js_1.ValidationStatus.BLOCKED]: "🚫",
|
|
121
|
+
[schemas_js_1.ValidationStatus.PENDING]: "⏳",
|
|
122
|
+
};
|
|
123
|
+
return JSON.stringify({
|
|
124
|
+
success: true,
|
|
125
|
+
proofId: result.proofId,
|
|
126
|
+
status: result.status,
|
|
127
|
+
statusDisplay: `${statusEmoji[result.status]} ${result.status}`,
|
|
128
|
+
riskScore: result.riskScore,
|
|
129
|
+
riskFactors: result.riskFactors,
|
|
130
|
+
allowed: result.status === schemas_js_1.ValidationStatus.SAFE ||
|
|
131
|
+
(result.status === schemas_js_1.ValidationStatus.WARNING && this.allowWarnings),
|
|
132
|
+
metadata: result.metadata,
|
|
133
|
+
recommendation: this.getRecommendation(result),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
this.log("Validation error", error);
|
|
138
|
+
return JSON.stringify({
|
|
139
|
+
success: false,
|
|
140
|
+
error: error instanceof Error ? error.message : "Unknown validation error",
|
|
141
|
+
allowed: false,
|
|
142
|
+
recommendation: "Transaction validation failed. Do not proceed.",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Validates and executes a transfer with ProofGate protection.
|
|
148
|
+
* Blocks the transaction if ProofGate determines it's unsafe.
|
|
149
|
+
*
|
|
150
|
+
* @param walletProvider - The wallet provider to execute the transfer
|
|
151
|
+
* @param args - Transfer parameters including destination and amount
|
|
152
|
+
* @returns Transfer result or block message
|
|
153
|
+
*/
|
|
154
|
+
async safeTransfer(walletProvider, args) {
|
|
155
|
+
try {
|
|
156
|
+
const network = walletProvider.getNetwork();
|
|
157
|
+
const fromAddress = walletProvider.getAddress();
|
|
158
|
+
this.log("Safe transfer requested", { from: fromAddress, ...args });
|
|
159
|
+
// Validate through ProofGate first
|
|
160
|
+
const chainId = typeof network.chainId === "number"
|
|
161
|
+
? network.chainId
|
|
162
|
+
: parseInt(String(network.chainId), 10) || 1;
|
|
163
|
+
const validationResult = await this.callValidationApi({
|
|
164
|
+
fromAddress,
|
|
165
|
+
toAddress: args.destinationAddress,
|
|
166
|
+
chainId,
|
|
167
|
+
tokenAddress: args.tokenAddress,
|
|
168
|
+
value: args.tokenAddress ? undefined : args.amount,
|
|
169
|
+
tokenAmount: args.tokenAddress ? args.amount : undefined,
|
|
170
|
+
});
|
|
171
|
+
this.log("ProofGate validation result", validationResult);
|
|
172
|
+
// Check if transaction should be blocked
|
|
173
|
+
if (validationResult.status === schemas_js_1.ValidationStatus.BLOCKED) {
|
|
174
|
+
return JSON.stringify({
|
|
175
|
+
success: false,
|
|
176
|
+
blocked: true,
|
|
177
|
+
proofId: validationResult.proofId,
|
|
178
|
+
status: schemas_js_1.ValidationStatus.BLOCKED,
|
|
179
|
+
riskScore: validationResult.riskScore,
|
|
180
|
+
riskFactors: validationResult.riskFactors,
|
|
181
|
+
message: `🚫 TRANSACTION BLOCKED by ProofGate\n\nRisk Score: ${validationResult.riskScore}/100\nReasons: ${validationResult.riskFactors.join(", ")}\n\nThis transaction was blocked for your protection. Do NOT proceed with this address.`,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// Check warnings
|
|
185
|
+
if (validationResult.status === schemas_js_1.ValidationStatus.WARNING && !this.allowWarnings) {
|
|
186
|
+
return JSON.stringify({
|
|
187
|
+
success: false,
|
|
188
|
+
blocked: true,
|
|
189
|
+
proofId: validationResult.proofId,
|
|
190
|
+
status: schemas_js_1.ValidationStatus.WARNING,
|
|
191
|
+
riskScore: validationResult.riskScore,
|
|
192
|
+
riskFactors: validationResult.riskFactors,
|
|
193
|
+
message: `⚠️ TRANSACTION BLOCKED due to warnings\n\nRisk Score: ${validationResult.riskScore}/100\nReasons: ${validationResult.riskFactors.join(", ")}\n\nThis transaction was blocked because warnings are not allowed in the current configuration.`,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// Validation passed - return validation info
|
|
197
|
+
// Note: Actual transfer execution should be done by the ERC20 or wallet action provider
|
|
198
|
+
return JSON.stringify({
|
|
199
|
+
success: true,
|
|
200
|
+
validated: true,
|
|
201
|
+
proofId: validationResult.proofId,
|
|
202
|
+
status: validationResult.status,
|
|
203
|
+
riskScore: validationResult.riskScore,
|
|
204
|
+
riskFactors: validationResult.riskFactors,
|
|
205
|
+
message: validationResult.status === schemas_js_1.ValidationStatus.SAFE
|
|
206
|
+
? `✅ Transaction validated as SAFE by ProofGate\n\nProof ID: ${validationResult.proofId}\nRisk Score: ${validationResult.riskScore}/100\n\nYou may proceed with the transfer.`
|
|
207
|
+
: `⚠️ Transaction has WARNINGS but is allowed\n\nProof ID: ${validationResult.proofId}\nRisk Score: ${validationResult.riskScore}/100\nWarnings: ${validationResult.riskFactors.join(", ")}\n\nProceed with caution.`,
|
|
208
|
+
transferParams: {
|
|
209
|
+
from: fromAddress,
|
|
210
|
+
to: args.destinationAddress,
|
|
211
|
+
amount: args.amount,
|
|
212
|
+
tokenAddress: args.tokenAddress ?? "native",
|
|
213
|
+
chainId: network.chainId,
|
|
214
|
+
networkId: network.networkId,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
this.log("Safe transfer error", error);
|
|
220
|
+
return JSON.stringify({
|
|
221
|
+
success: false,
|
|
222
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
223
|
+
blocked: true,
|
|
224
|
+
message: "❌ ProofGate validation failed. Transaction blocked for safety.",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Gets the validation status for a previously submitted transaction.
|
|
230
|
+
*
|
|
231
|
+
* @param args - The proof ID to look up
|
|
232
|
+
* @returns Validation status as stringified JSON
|
|
233
|
+
*/
|
|
234
|
+
async getValidationStatus(args) {
|
|
235
|
+
try {
|
|
236
|
+
this.log("Getting validation status", args);
|
|
237
|
+
const controller = new AbortController();
|
|
238
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
239
|
+
try {
|
|
240
|
+
const response = await fetch(`${this.baseUrl}/validate/${args.proofId}`, {
|
|
241
|
+
method: "GET",
|
|
242
|
+
headers: {
|
|
243
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
244
|
+
"X-ProofGate-Client": "agentkit",
|
|
245
|
+
"X-ProofGate-Version": "1.0.0",
|
|
246
|
+
},
|
|
247
|
+
signal: controller.signal,
|
|
248
|
+
});
|
|
249
|
+
if (!response.ok) {
|
|
250
|
+
if (response.status === 404) {
|
|
251
|
+
return JSON.stringify({
|
|
252
|
+
success: false,
|
|
253
|
+
error: `Proof ID not found: ${args.proofId}`,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
throw new Error(`ProofGate API error: ${response.status}`);
|
|
257
|
+
}
|
|
258
|
+
const result = await response.json();
|
|
259
|
+
return JSON.stringify({
|
|
260
|
+
success: true,
|
|
261
|
+
proofId: result.proofId,
|
|
262
|
+
status: result.status,
|
|
263
|
+
riskScore: result.riskScore,
|
|
264
|
+
riskFactors: result.riskFactors,
|
|
265
|
+
timestamp: result.timestamp,
|
|
266
|
+
metadata: result.metadata,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
clearTimeout(timeoutId);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
this.log("Get status error", error);
|
|
275
|
+
return JSON.stringify({
|
|
276
|
+
success: false,
|
|
277
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Generates a human-readable recommendation based on validation result
|
|
283
|
+
*/
|
|
284
|
+
getRecommendation(result) {
|
|
285
|
+
switch (result.status) {
|
|
286
|
+
case schemas_js_1.ValidationStatus.SAFE:
|
|
287
|
+
return "This transaction appears safe. You may proceed.";
|
|
288
|
+
case schemas_js_1.ValidationStatus.WARNING:
|
|
289
|
+
return this.allowWarnings
|
|
290
|
+
? `Proceed with caution. Risk factors: ${result.riskFactors.join(", ")}`
|
|
291
|
+
: "This transaction has warnings and is blocked by current settings.";
|
|
292
|
+
case schemas_js_1.ValidationStatus.BLOCKED:
|
|
293
|
+
return `DO NOT proceed with this transaction. Risk factors: ${result.riskFactors.join(", ")}`;
|
|
294
|
+
case schemas_js_1.ValidationStatus.PENDING:
|
|
295
|
+
return "Validation is still processing. Please check again shortly.";
|
|
296
|
+
default:
|
|
297
|
+
return "Unable to determine recommendation.";
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Checks if this action provider supports the given network.
|
|
302
|
+
* ProofGate supports all EVM networks.
|
|
303
|
+
*
|
|
304
|
+
* @param network - The network to check
|
|
305
|
+
* @returns True if the network is EVM-based
|
|
306
|
+
*/
|
|
307
|
+
supportsNetwork(network) {
|
|
308
|
+
return network.protocolFamily === "evm";
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.ProofGateActionProvider = ProofGateActionProvider;
|
|
312
|
+
__decorate([
|
|
313
|
+
(0, agentkit_1.CreateAction)({
|
|
314
|
+
name: "validate_transaction",
|
|
315
|
+
description: `Validate a blockchain transaction through ProofGate's security API.
|
|
316
|
+
|
|
317
|
+
This action checks transaction parameters against ProofGate's threat intelligence to detect:
|
|
318
|
+
- Malicious or phishing addresses
|
|
319
|
+
- Sanctioned wallets
|
|
320
|
+
- Suspicious contract interactions
|
|
321
|
+
- Known scam patterns
|
|
322
|
+
|
|
323
|
+
Inputs:
|
|
324
|
+
- fromAddress: The sender wallet address (your wallet)
|
|
325
|
+
- toAddress: The recipient or contract address
|
|
326
|
+
- chainId: The blockchain network ID (e.g., 1 for Ethereum, 8453 for Base)
|
|
327
|
+
- value: (Optional) Transaction value in wei
|
|
328
|
+
- data: (Optional) Transaction calldata for contract interactions
|
|
329
|
+
- tokenAddress: (Optional) ERC20 token contract address
|
|
330
|
+
- tokenAmount: (Optional) Token amount in base units
|
|
331
|
+
|
|
332
|
+
Returns validation status (SAFE, WARNING, or BLOCKED) with risk details.
|
|
333
|
+
Always use this before executing high-value or unfamiliar transactions.`,
|
|
334
|
+
schema: schemas_js_1.ValidateTransactionSchema,
|
|
335
|
+
}),
|
|
336
|
+
__metadata("design:type", Function),
|
|
337
|
+
__metadata("design:paramtypes", [void 0]),
|
|
338
|
+
__metadata("design:returntype", Promise)
|
|
339
|
+
], ProofGateActionProvider.prototype, "validateTransaction", null);
|
|
340
|
+
__decorate([
|
|
341
|
+
(0, agentkit_1.CreateAction)({
|
|
342
|
+
name: "safe_transfer",
|
|
343
|
+
description: `Execute a transfer with ProofGate security validation.
|
|
344
|
+
|
|
345
|
+
This action validates the destination address through ProofGate before executing.
|
|
346
|
+
If the address is flagged as malicious, the transfer will be BLOCKED.
|
|
347
|
+
|
|
348
|
+
Inputs:
|
|
349
|
+
- amount: Amount to transfer in whole units (e.g., "0.5" for 0.5 ETH)
|
|
350
|
+
- destinationAddress: The recipient address
|
|
351
|
+
- tokenAddress: (Optional) ERC20 token address. Omit for native ETH/token transfers.
|
|
352
|
+
|
|
353
|
+
Use this instead of regular transfer for maximum security.
|
|
354
|
+
The transaction will only execute if ProofGate validation passes.`,
|
|
355
|
+
schema: schemas_js_1.SafeTransferSchema,
|
|
356
|
+
}),
|
|
357
|
+
__metadata("design:type", Function),
|
|
358
|
+
__metadata("design:paramtypes", [agentkit_1.EvmWalletProvider, void 0]),
|
|
359
|
+
__metadata("design:returntype", Promise)
|
|
360
|
+
], ProofGateActionProvider.prototype, "safeTransfer", null);
|
|
361
|
+
__decorate([
|
|
362
|
+
(0, agentkit_1.CreateAction)({
|
|
363
|
+
name: "get_validation_status",
|
|
364
|
+
description: `Get the validation status for a previously submitted transaction.
|
|
365
|
+
|
|
366
|
+
Use this to check on the status of a transaction that was validated earlier.
|
|
367
|
+
|
|
368
|
+
Inputs:
|
|
369
|
+
- proofId: The proof ID returned from a previous validate_transaction call
|
|
370
|
+
|
|
371
|
+
Returns the current status and any updated risk information.`,
|
|
372
|
+
schema: schemas_js_1.GetValidationStatusSchema,
|
|
373
|
+
}),
|
|
374
|
+
__metadata("design:type", Function),
|
|
375
|
+
__metadata("design:paramtypes", [void 0]),
|
|
376
|
+
__metadata("design:returntype", Promise)
|
|
377
|
+
], ProofGateActionProvider.prototype, "getValidationStatus", null);
|
|
378
|
+
/**
|
|
379
|
+
* Factory function to create a ProofGateActionProvider instance.
|
|
380
|
+
*
|
|
381
|
+
* @param config - ProofGate configuration options
|
|
382
|
+
* @returns A new ProofGateActionProvider instance
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* const proofgate = proofGateActionProvider({
|
|
387
|
+
* apiKey: process.env.PROOFGATE_API_KEY!,
|
|
388
|
+
* blockThreshold: 70,
|
|
389
|
+
* verbose: true,
|
|
390
|
+
* });
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
const proofGateActionProvider = (config) => new ProofGateActionProvider(config);
|
|
394
|
+
exports.proofGateActionProvider = proofGateActionProvider;
|
|
395
|
+
//# sourceMappingURL=proofgate-action-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proofgate-action-provider.js","sourceRoot":"","sources":["../src/proofgate-action-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,iDAA8F;AAC9F,6CAOsB;AAEtB,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAC3D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,uBAAwB,SAAQ,yBAAiC;IAC3D,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,aAAa,CAAU;IACvB,OAAO,CAAS;IAChB,OAAO,CAAU;IAElC;;;;OAIG;IACH,YAAY,MAAuB;QACjC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAEvB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,IAAI,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO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C,CAAC;;;;kEAuCD;AA0BK;IAhBL,IAAA,uBAAY,EAAC;QACZ,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE;;;;;;;;;;;kEAWiD;QAC9D,MAAM,EAAE,+BAAkB;KAC3B,CAAC;;qCAEgB,4BAAiB;;2DAiFlC;AAoBK;IAZL,IAAA,uBAAY,EAAC;QACZ,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE;;;;;;;6DAO4C;QACzD,MAAM,EAAE,sCAAyB;KAClC,CAAC;;;;kEAoDD;AAkCH;;;;;;;;;;;;;;GAcG;AACI,MAAM,uBAAuB,GAAG,CAAC,MAAuB,EAAE,EAAE,CACjE,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AADzB,QAAA,uBAAuB,2BACE"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* ProofGate validation status enum
|
|
4
|
+
*/
|
|
5
|
+
export declare const ValidationStatus: {
|
|
6
|
+
readonly SAFE: "SAFE";
|
|
7
|
+
readonly BLOCKED: "BLOCKED";
|
|
8
|
+
readonly WARNING: "WARNING";
|
|
9
|
+
readonly PENDING: "PENDING";
|
|
10
|
+
};
|
|
11
|
+
export type ValidationStatus = (typeof ValidationStatus)[keyof typeof ValidationStatus];
|
|
12
|
+
/**
|
|
13
|
+
* Input schema for validating a transaction
|
|
14
|
+
*/
|
|
15
|
+
export declare const ValidateTransactionSchema: z.ZodObject<{
|
|
16
|
+
fromAddress: z.ZodString;
|
|
17
|
+
toAddress: z.ZodString;
|
|
18
|
+
value: z.ZodOptional<z.ZodString>;
|
|
19
|
+
data: z.ZodOptional<z.ZodString>;
|
|
20
|
+
chainId: z.ZodNumber;
|
|
21
|
+
tokenAddress: z.ZodOptional<z.ZodString>;
|
|
22
|
+
tokenAmount: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
fromAddress: string;
|
|
25
|
+
toAddress: string;
|
|
26
|
+
chainId: number;
|
|
27
|
+
value?: string | undefined;
|
|
28
|
+
data?: string | undefined;
|
|
29
|
+
tokenAddress?: string | undefined;
|
|
30
|
+
tokenAmount?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
fromAddress: string;
|
|
33
|
+
toAddress: string;
|
|
34
|
+
chainId: number;
|
|
35
|
+
value?: string | undefined;
|
|
36
|
+
data?: string | undefined;
|
|
37
|
+
tokenAddress?: string | undefined;
|
|
38
|
+
tokenAmount?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Input schema for getting validation status by proof ID
|
|
42
|
+
*/
|
|
43
|
+
export declare const GetValidationStatusSchema: z.ZodObject<{
|
|
44
|
+
proofId: z.ZodString;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
proofId: string;
|
|
47
|
+
}, {
|
|
48
|
+
proofId: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Input schema for wrapped transfer with validation
|
|
52
|
+
*/
|
|
53
|
+
export declare const SafeTransferSchema: z.ZodObject<{
|
|
54
|
+
amount: z.ZodString;
|
|
55
|
+
destinationAddress: z.ZodString;
|
|
56
|
+
tokenAddress: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
amount: string;
|
|
59
|
+
destinationAddress: string;
|
|
60
|
+
tokenAddress?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
amount: string;
|
|
63
|
+
destinationAddress: string;
|
|
64
|
+
tokenAddress?: string | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* ProofGate API response type
|
|
68
|
+
*/
|
|
69
|
+
export interface ProofGateValidationResponse {
|
|
70
|
+
proofId: string;
|
|
71
|
+
status: ValidationStatus;
|
|
72
|
+
riskScore: number;
|
|
73
|
+
riskFactors: string[];
|
|
74
|
+
timestamp: string;
|
|
75
|
+
metadata?: {
|
|
76
|
+
addressLabels?: Record<string, string>;
|
|
77
|
+
contractInfo?: {
|
|
78
|
+
verified: boolean;
|
|
79
|
+
name?: string;
|
|
80
|
+
};
|
|
81
|
+
sanctions?: boolean;
|
|
82
|
+
phishing?: boolean;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* ProofGate configuration options
|
|
87
|
+
*/
|
|
88
|
+
export interface ProofGateConfig {
|
|
89
|
+
/**
|
|
90
|
+
* ProofGate API key
|
|
91
|
+
*/
|
|
92
|
+
apiKey: string;
|
|
93
|
+
/**
|
|
94
|
+
* ProofGate API base URL (defaults to production)
|
|
95
|
+
*/
|
|
96
|
+
baseUrl?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Risk score threshold (0-100) above which transactions are blocked
|
|
99
|
+
* Default: 70
|
|
100
|
+
*/
|
|
101
|
+
blockThreshold?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Risk score threshold (0-100) above which warnings are issued
|
|
104
|
+
* Default: 40
|
|
105
|
+
*/
|
|
106
|
+
warnThreshold?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Whether to allow transactions in WARNING status
|
|
109
|
+
* Default: true
|
|
110
|
+
*/
|
|
111
|
+
allowWarnings?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Request timeout in milliseconds
|
|
114
|
+
* Default: 10000
|
|
115
|
+
*/
|
|
116
|
+
timeout?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Enable verbose logging
|
|
119
|
+
* Default: false
|
|
120
|
+
*/
|
|
121
|
+
verbose?: boolean;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC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strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SafeTransferSchema = exports.GetValidationStatusSchema = exports.ValidateTransactionSchema = exports.ValidationStatus = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* ProofGate validation status enum
|
|
7
|
+
*/
|
|
8
|
+
exports.ValidationStatus = {
|
|
9
|
+
SAFE: "SAFE",
|
|
10
|
+
BLOCKED: "BLOCKED",
|
|
11
|
+
WARNING: "WARNING",
|
|
12
|
+
PENDING: "PENDING",
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Input schema for validating a transaction
|
|
16
|
+
*/
|
|
17
|
+
exports.ValidateTransactionSchema = zod_1.z
|
|
18
|
+
.object({
|
|
19
|
+
fromAddress: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
22
|
+
.describe("The sender wallet address"),
|
|
23
|
+
toAddress: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
26
|
+
.describe("The recipient/contract address"),
|
|
27
|
+
value: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Transaction value in wei (optional for contract calls)"),
|
|
31
|
+
data: zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("Transaction calldata (optional)"),
|
|
35
|
+
chainId: zod_1.z
|
|
36
|
+
.number()
|
|
37
|
+
.positive()
|
|
38
|
+
.describe("The chain ID of the network"),
|
|
39
|
+
tokenAddress: zod_1.z
|
|
40
|
+
.string()
|
|
41
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Token contract address for ERC20 transfers (optional)"),
|
|
44
|
+
tokenAmount: zod_1.z
|
|
45
|
+
.string()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Token amount in base units (optional)"),
|
|
48
|
+
})
|
|
49
|
+
.strip()
|
|
50
|
+
.describe("Transaction parameters to validate through ProofGate");
|
|
51
|
+
/**
|
|
52
|
+
* Input schema for getting validation status by proof ID
|
|
53
|
+
*/
|
|
54
|
+
exports.GetValidationStatusSchema = zod_1.z
|
|
55
|
+
.object({
|
|
56
|
+
proofId: zod_1.z
|
|
57
|
+
.string()
|
|
58
|
+
.uuid()
|
|
59
|
+
.describe("The proof ID returned from a previous validation"),
|
|
60
|
+
})
|
|
61
|
+
.strip()
|
|
62
|
+
.describe("Get the status of a previously submitted validation");
|
|
63
|
+
/**
|
|
64
|
+
* Input schema for wrapped transfer with validation
|
|
65
|
+
*/
|
|
66
|
+
exports.SafeTransferSchema = zod_1.z
|
|
67
|
+
.object({
|
|
68
|
+
amount: zod_1.z
|
|
69
|
+
.string()
|
|
70
|
+
.describe("The amount to transfer in whole units (e.g. 1.5 ETH or 100 USDC)"),
|
|
71
|
+
destinationAddress: zod_1.z
|
|
72
|
+
.string()
|
|
73
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
74
|
+
.describe("The destination address to send funds to"),
|
|
75
|
+
tokenAddress: zod_1.z
|
|
76
|
+
.string()
|
|
77
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("Token contract address for ERC20 transfers (omit for native ETH)"),
|
|
80
|
+
})
|
|
81
|
+
.strip()
|
|
82
|
+
.describe("Transfer with ProofGate validation - blocks suspicious transactions");
|
|
83
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;GAEG;AACU,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM;IACZ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,MAAM,CAAC;IACN,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CAAC,kEAAkE,CAAC;IAC/E,kBAAkB,EAAE,OAAC;SAClB,MAAM,EAAE;SACR,KAAK,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;SAC/D,QAAQ,CAAC,0CAA0C,CAAC;IACvD,YAAY,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,KAAK,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;SAC/D,QAAQ,EAAE;SACV,QAAQ,CAAC,kEAAkE,CAAC;CAChF,CAAC;KACD,KAAK,EAAE;KACP,QAAQ,CAAC,qEAAqE,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proofgate/agentkit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ProofGate transaction validation action provider for Coinbase AgentKit",
|
|
5
|
+
"author": "ProofGate <hello@proofgate.xyz>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/proofgate/agentkit.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://proofgate.xyz",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/proofgate/agentkit/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"proofgate",
|
|
19
|
+
"agentkit",
|
|
20
|
+
"coinbase",
|
|
21
|
+
"transaction-validation",
|
|
22
|
+
"security",
|
|
23
|
+
"ai-agent",
|
|
24
|
+
"blockchain",
|
|
25
|
+
"web3"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch",
|
|
34
|
+
"clean": "rm -rf dist/*",
|
|
35
|
+
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
|
|
36
|
+
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
|
|
37
|
+
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,json,md}\"",
|
|
38
|
+
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,json,md}\"",
|
|
39
|
+
"test": "jest --no-cache --testMatch='**/*.test.ts'",
|
|
40
|
+
"prepack": "npm run build"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@coinbase/agentkit": ">=0.10.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"zod": "^3.23.8"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@coinbase/agentkit": "^0.10.4",
|
|
50
|
+
"@types/jest": "^29.5.14",
|
|
51
|
+
"@types/node": "^20.11.0",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
53
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
54
|
+
"eslint": "^8.57.0",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"prettier": "^3.2.0",
|
|
57
|
+
"reflect-metadata": "^0.2.2",
|
|
58
|
+
"ts-jest": "^29.2.5",
|
|
59
|
+
"typescript": "^5.7.2"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18.0.0"
|
|
63
|
+
},
|
|
64
|
+
"exports": {
|
|
65
|
+
".": {
|
|
66
|
+
"types": "./dist/index.d.ts",
|
|
67
|
+
"default": "./dist/index.js"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|