@rlajous/sdk-threat 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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +288 -0
  3. package/dist/cjs/client.js +165 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/index.js +33 -0
  6. package/dist/cjs/index.js.map +1 -0
  7. package/dist/cjs/package.json +1 -0
  8. package/dist/cjs/resources/account-trace.js +96 -0
  9. package/dist/cjs/resources/account-trace.js.map +1 -0
  10. package/dist/cjs/resources/addresses.js +189 -0
  11. package/dist/cjs/resources/addresses.js.map +1 -0
  12. package/dist/cjs/resources/contracts.js +216 -0
  13. package/dist/cjs/resources/contracts.js.map +1 -0
  14. package/dist/cjs/resources/index.js +18 -0
  15. package/dist/cjs/resources/index.js.map +1 -0
  16. package/dist/cjs/resources/ledger.js +123 -0
  17. package/dist/cjs/resources/ledger.js.map +1 -0
  18. package/dist/cjs/resources/url.js +85 -0
  19. package/dist/cjs/resources/url.js.map +1 -0
  20. package/dist/cjs/resources/usage.js +124 -0
  21. package/dist/cjs/resources/usage.js.map +1 -0
  22. package/dist/cjs/resources/wallets.js +149 -0
  23. package/dist/cjs/resources/wallets.js.map +1 -0
  24. package/dist/cjs/types/account-trace.js +3 -0
  25. package/dist/cjs/types/account-trace.js.map +1 -0
  26. package/dist/cjs/types/address.js +3 -0
  27. package/dist/cjs/types/address.js.map +1 -0
  28. package/dist/cjs/types/contract.js +3 -0
  29. package/dist/cjs/types/contract.js.map +1 -0
  30. package/dist/cjs/types/index.js +3 -0
  31. package/dist/cjs/types/index.js.map +1 -0
  32. package/dist/cjs/types/ledger.js +3 -0
  33. package/dist/cjs/types/ledger.js.map +1 -0
  34. package/dist/cjs/types/url.js +3 -0
  35. package/dist/cjs/types/url.js.map +1 -0
  36. package/dist/cjs/types/usage.js +3 -0
  37. package/dist/cjs/types/usage.js.map +1 -0
  38. package/dist/cjs/types/wallet.js +3 -0
  39. package/dist/cjs/types/wallet.js.map +1 -0
  40. package/dist/esm/client.js +161 -0
  41. package/dist/esm/client.js.map +1 -0
  42. package/dist/esm/index.js +7 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/package.json +1 -0
  45. package/dist/esm/resources/account-trace.js +92 -0
  46. package/dist/esm/resources/account-trace.js.map +1 -0
  47. package/dist/esm/resources/addresses.js +185 -0
  48. package/dist/esm/resources/addresses.js.map +1 -0
  49. package/dist/esm/resources/contracts.js +212 -0
  50. package/dist/esm/resources/contracts.js.map +1 -0
  51. package/dist/esm/resources/index.js +8 -0
  52. package/dist/esm/resources/index.js.map +1 -0
  53. package/dist/esm/resources/ledger.js +119 -0
  54. package/dist/esm/resources/ledger.js.map +1 -0
  55. package/dist/esm/resources/url.js +81 -0
  56. package/dist/esm/resources/url.js.map +1 -0
  57. package/dist/esm/resources/usage.js +120 -0
  58. package/dist/esm/resources/usage.js.map +1 -0
  59. package/dist/esm/resources/wallets.js +145 -0
  60. package/dist/esm/resources/wallets.js.map +1 -0
  61. package/dist/esm/types/account-trace.js +2 -0
  62. package/dist/esm/types/account-trace.js.map +1 -0
  63. package/dist/esm/types/address.js +2 -0
  64. package/dist/esm/types/address.js.map +1 -0
  65. package/dist/esm/types/contract.js +2 -0
  66. package/dist/esm/types/contract.js.map +1 -0
  67. package/dist/esm/types/index.js +2 -0
  68. package/dist/esm/types/index.js.map +1 -0
  69. package/dist/esm/types/ledger.js +2 -0
  70. package/dist/esm/types/ledger.js.map +1 -0
  71. package/dist/esm/types/url.js +2 -0
  72. package/dist/esm/types/url.js.map +1 -0
  73. package/dist/esm/types/usage.js +2 -0
  74. package/dist/esm/types/usage.js.map +1 -0
  75. package/dist/esm/types/wallet.js +2 -0
  76. package/dist/esm/types/wallet.js.map +1 -0
  77. package/dist/types/client.d.ts +145 -0
  78. package/dist/types/client.d.ts.map +1 -0
  79. package/dist/types/index.d.ts +5 -0
  80. package/dist/types/index.d.ts.map +1 -0
  81. package/dist/types/resources/account-trace.d.ts +67 -0
  82. package/dist/types/resources/account-trace.d.ts.map +1 -0
  83. package/dist/types/resources/addresses.d.ts +131 -0
  84. package/dist/types/resources/addresses.d.ts.map +1 -0
  85. package/dist/types/resources/contracts.d.ts +156 -0
  86. package/dist/types/resources/contracts.d.ts.map +1 -0
  87. package/dist/types/resources/index.d.ts +8 -0
  88. package/dist/types/resources/index.d.ts.map +1 -0
  89. package/dist/types/resources/ledger.d.ts +107 -0
  90. package/dist/types/resources/ledger.d.ts.map +1 -0
  91. package/dist/types/resources/url.d.ts +69 -0
  92. package/dist/types/resources/url.d.ts.map +1 -0
  93. package/dist/types/resources/usage.d.ts +99 -0
  94. package/dist/types/resources/usage.d.ts.map +1 -0
  95. package/dist/types/resources/wallets.d.ts +106 -0
  96. package/dist/types/resources/wallets.d.ts.map +1 -0
  97. package/dist/types/types/account-trace.d.ts +68 -0
  98. package/dist/types/types/account-trace.d.ts.map +1 -0
  99. package/dist/types/types/address.d.ts +266 -0
  100. package/dist/types/types/address.d.ts.map +1 -0
  101. package/dist/types/types/contract.d.ts +169 -0
  102. package/dist/types/types/contract.d.ts.map +1 -0
  103. package/dist/types/types/index.d.ts +8 -0
  104. package/dist/types/types/index.d.ts.map +1 -0
  105. package/dist/types/types/ledger.d.ts +106 -0
  106. package/dist/types/types/ledger.d.ts.map +1 -0
  107. package/dist/types/types/url.d.ts +39 -0
  108. package/dist/types/types/url.d.ts.map +1 -0
  109. package/dist/types/types/usage.d.ts +74 -0
  110. package/dist/types/types/usage.d.ts.map +1 -0
  111. package/dist/types/types/wallet.d.ts +129 -0
  112. package/dist/types/types/wallet.d.ts.map +1 -0
  113. package/package.json +74 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Webacy
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,288 @@
1
+ # @rlajous/sdk-threat
2
+
3
+ Threat and risk analysis SDK for the Webacy Risk Score API. Analyze addresses, contracts, and URLs for security risks.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @rlajous/sdk-threat
9
+ ```
10
+
11
+ Or install the full SDK:
12
+
13
+ ```bash
14
+ npm install @rlajous/sdk
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { ThreatClient, RiskModule } from '@rlajous/sdk-threat';
21
+
22
+ const client = new ThreatClient({
23
+ apiKey: process.env.WEBACY_API_KEY!,
24
+ });
25
+
26
+ // Analyze address risk
27
+ const risk = await client.addresses.analyze('0x742d35Cc...', {
28
+ chain: 'eth',
29
+ });
30
+
31
+ console.log(`Risk Score: ${risk.overallRisk}/100`);
32
+ console.log(`High severity issues: ${risk.high}`);
33
+ ```
34
+
35
+ ## Features
36
+
37
+ ### Address Risk Analysis
38
+
39
+ Comprehensive security analysis for blockchain addresses.
40
+
41
+ ```typescript
42
+ const risk = await client.addresses.analyze('0x742d35Cc...', {
43
+ chain: 'eth',
44
+ modules: [RiskModule.FUND_FLOW_SCREENING, RiskModule.SANCTIONS_COMPLIANCE],
45
+ detailed: true,
46
+ });
47
+
48
+ console.log(`Overall Risk: ${risk.overallRisk}/100`);
49
+ console.log(`Is Contract: ${risk.isContract}`);
50
+ console.log(`Address Type: ${risk.addressType}`);
51
+ console.log(`High Issues: ${risk.high}`);
52
+ console.log(`Medium Issues: ${risk.medium}`);
53
+
54
+ // Detailed fund flow analysis
55
+ if (risk.details?.fund_flows?.risk) {
56
+ const flowRisk = risk.details.fund_flows.risk;
57
+ if (flowRisk.ofac) console.log('Connected to OFAC addresses');
58
+ if (flowRisk.tornado) console.log('Used Tornado Cash');
59
+ if (flowRisk.mixers) console.log('Used mixing services');
60
+ }
61
+ ```
62
+
63
+ ### Sanctions Screening
64
+
65
+ Screen addresses against OFAC and other sanctions lists.
66
+
67
+ ```typescript
68
+ const result = await client.addresses.checkSanctioned('0x...', {
69
+ chain: 'eth',
70
+ });
71
+
72
+ if (result.is_sanctioned) {
73
+ console.log('Address is sanctioned!');
74
+ console.log(`Source: ${result.sanction_details?.source}`);
75
+ console.log(`List: ${result.sanction_details?.list_name}`);
76
+ }
77
+ ```
78
+
79
+ ### Address Poisoning Detection
80
+
81
+ Detect dust attack and address poisoning attempts.
82
+
83
+ ```typescript
84
+ const result = await client.addresses.checkPoisoning('0x...', {
85
+ chain: 'eth',
86
+ });
87
+
88
+ if (result.is_poisoned) {
89
+ console.log('Poisoning detected!');
90
+ console.log(`Similar addresses: ${result.poisoning_details?.similar_addresses?.length}`);
91
+ console.log(`Dust transactions: ${result.poisoning_details?.dust_tx_count}`);
92
+ }
93
+ ```
94
+
95
+ ### Contract Analysis
96
+
97
+ Analyze smart contracts for vulnerabilities.
98
+
99
+ ```typescript
100
+ const contract = await client.contracts.analyze('0xContract...', {
101
+ chain: 'eth',
102
+ });
103
+
104
+ console.log(`Risk Score: ${contract.overallRisk}/100`);
105
+ console.log(`Verified: ${contract.is_verified}`);
106
+
107
+ // Vulnerabilities
108
+ for (const vuln of contract.vulnerabilities || []) {
109
+ console.log(`${vuln.severity}: ${vuln.name}`);
110
+ }
111
+
112
+ // Get source code
113
+ const source = await client.contracts.getSourceCode('0xContract...', {
114
+ chain: 'eth',
115
+ });
116
+
117
+ // Get buy/sell taxes
118
+ const taxes = await client.contracts.getTaxes('0xToken...', {
119
+ chain: 'eth',
120
+ });
121
+ console.log(`Buy Tax: ${taxes.buy_tax}%`);
122
+ console.log(`Sell Tax: ${taxes.sell_tax}%`);
123
+ ```
124
+
125
+ ### URL Safety
126
+
127
+ Check URLs for phishing and malware.
128
+
129
+ ```typescript
130
+ const result = await client.url.check('https://suspicious-site.com');
131
+
132
+ if (result.is_malicious) {
133
+ console.log(`Risk Score: ${result.risk_score}/100`);
134
+ console.log(`Threats: ${result.threat_types?.join(', ')}`);
135
+ }
136
+
137
+ // Report a malicious URL
138
+ await client.url.add('https://phishing-site.xyz');
139
+ ```
140
+
141
+ ### Wallet Analysis
142
+
143
+ Analyze wallet transactions and token approvals.
144
+
145
+ ```typescript
146
+ // Get recent transactions
147
+ const txs = await client.wallets.getTransactions('0x...', {
148
+ chain: 'eth',
149
+ limit: 10,
150
+ });
151
+
152
+ // Get token approvals
153
+ const approvals = await client.wallets.getApprovals('0x...', {
154
+ chain: 'eth',
155
+ });
156
+
157
+ for (const approval of approvals.approvals || []) {
158
+ console.log(`${approval.token_symbol}: ${approval.amount}`);
159
+ if (approval.risk_score > 70) {
160
+ console.log(' ⚠️ High risk approval!');
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Ledger Scan
166
+
167
+ Scan hardware wallet transactions for security.
168
+
169
+ ```typescript
170
+ const scan = await client.ledger.scanTransaction('ethereum', {
171
+ tx: {
172
+ from: '0x...',
173
+ to: '0x...',
174
+ data: '0x...',
175
+ },
176
+ chain: 1,
177
+ });
178
+
179
+ console.log(`Risk Level: ${scan.risk_level}`);
180
+ for (const warning of scan.warnings || []) {
181
+ console.log(`Warning: ${warning}`);
182
+ }
183
+ ```
184
+
185
+ ### Account Trace
186
+
187
+ Trace fund flows for an address.
188
+
189
+ ```typescript
190
+ const trace = await client.accountTrace.trace('0x...', {
191
+ chain: 'eth',
192
+ });
193
+
194
+ console.log(`Traced transactions: ${trace.transactions?.length}`);
195
+ ```
196
+
197
+ ### API Usage
198
+
199
+ Monitor your API usage and quota.
200
+
201
+ ```typescript
202
+ const usage = await client.usage.getCurrent();
203
+ console.log(`Requests used: ${usage.requests_used}`);
204
+ console.log(`Requests limit: ${usage.requests_limit}`);
205
+ ```
206
+
207
+ ## API Reference
208
+
209
+ ### ThreatClient
210
+
211
+ ```typescript
212
+ const client = new ThreatClient({
213
+ apiKey: string; // Required: Your Webacy API key
214
+ baseUrl?: string; // Optional: Custom API URL
215
+ timeout?: number; // Optional: Request timeout (ms)
216
+ retry?: RetryConfig; // Optional: Retry configuration
217
+ });
218
+ ```
219
+
220
+ ### Resources
221
+
222
+ | Resource | Method | Description |
223
+ |----------|--------|-------------|
224
+ | `addresses` | `analyze(address, options)` | Analyze address risk |
225
+ | `addresses` | `checkSanctioned(address, options)` | Check sanctions status |
226
+ | `addresses` | `checkPoisoning(address, options)` | Check for poisoning |
227
+ | `contracts` | `analyze(address, options)` | Analyze contract risk |
228
+ | `contracts` | `getSourceCode(address, options)` | Get contract source |
229
+ | `contracts` | `getTaxes(address, options)` | Get token taxes |
230
+ | `contracts` | `analyzeSolidity(body)` | Analyze Solidity code |
231
+ | `url` | `check(url)` | Check URL safety |
232
+ | `url` | `add(url)` | Report malicious URL |
233
+ | `wallets` | `getTransactions(address, options)` | Get wallet transactions |
234
+ | `wallets` | `getApprovals(address, options)` | Get token approvals |
235
+ | `ledger` | `scanTransaction(family, body)` | Scan Ledger transaction |
236
+ | `ledger` | `scanEip712(family, body)` | Scan EIP-712 message |
237
+ | `accountTrace` | `trace(address, options)` | Trace fund flows |
238
+ | `usage` | `getUsage(options)` | Get usage history |
239
+ | `usage` | `getCurrent()` | Get current usage |
240
+ | `usage` | `getPlans()` | Get available plans |
241
+
242
+ ## Risk Modules
243
+
244
+ ```typescript
245
+ import { RiskModule } from '@rlajous/sdk-threat';
246
+
247
+ const modules = [
248
+ RiskModule.FUND_FLOW_SCREENING,
249
+ RiskModule.SANCTIONS_COMPLIANCE,
250
+ RiskModule.CONTRACT_ANALYSIS,
251
+ RiskModule.TOKEN_SECURITY,
252
+ // ... and more
253
+ ];
254
+ ```
255
+
256
+ ## Supported Chains
257
+
258
+ - Ethereum (`eth`)
259
+ - Base (`base`)
260
+ - BSC (`bsc`)
261
+ - Polygon (`pol`)
262
+ - Arbitrum (`arb`)
263
+ - Optimism (`opt`)
264
+ - Solana (`sol`)
265
+ - TON (`ton`)
266
+ - Sui (`sui`)
267
+ - Stellar (`stellar`)
268
+ - Bitcoin (`btc`)
269
+
270
+ ## Error Handling
271
+
272
+ ```typescript
273
+ import { ThreatClient, RateLimitError, AuthenticationError } from '@rlajous/sdk-threat';
274
+
275
+ try {
276
+ const risk = await client.addresses.analyze('0x...', { chain: 'eth' });
277
+ } catch (error) {
278
+ if (error instanceof AuthenticationError) {
279
+ console.log('Invalid API key');
280
+ } else if (error instanceof RateLimitError) {
281
+ console.log(`Rate limited. Retry after ${error.retryAfter}s`);
282
+ }
283
+ }
284
+ ```
285
+
286
+ ## License
287
+
288
+ MIT
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreatClient = void 0;
4
+ const sdk_core_1 = require("@rlajous/sdk-core");
5
+ const addresses_1 = require("./resources/addresses");
6
+ const contracts_1 = require("./resources/contracts");
7
+ const url_1 = require("./resources/url");
8
+ const wallets_1 = require("./resources/wallets");
9
+ const ledger_1 = require("./resources/ledger");
10
+ const account_trace_1 = require("./resources/account-trace");
11
+ const usage_1 = require("./resources/usage");
12
+ /**
13
+ * Webacy Threat SDK Client
14
+ *
15
+ * Provides access to threat and risk analysis including address risk,
16
+ * sanctions screening, contract security, URL safety, and more.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { ThreatClient, Chain, RiskModule } from '@rlajous/sdk-threat';
21
+ *
22
+ * const client = new ThreatClient({
23
+ * apiKey: process.env.WEBACY_API_KEY!,
24
+ * });
25
+ *
26
+ * // Address risk analysis
27
+ * const risk = await client.addresses.analyze('0x...', { chain: 'eth' });
28
+ *
29
+ * // Sanctions screening
30
+ * const sanctioned = await client.addresses.checkSanctioned('0x...', { chain: 'eth' });
31
+ *
32
+ * // URL safety check
33
+ * const urlRisk = await client.url.check('https://suspicious-site.com');
34
+ * ```
35
+ */
36
+ class ThreatClient extends sdk_core_1.BaseClient {
37
+ /**
38
+ * Addresses resource
39
+ *
40
+ * Comprehensive security analysis for blockchain addresses including
41
+ * risk scoring, sanctions screening, and address poisoning detection.
42
+ */
43
+ addresses;
44
+ /**
45
+ * Contracts resource
46
+ *
47
+ * Smart contract security analysis including vulnerability detection,
48
+ * source code analysis, and tax detection.
49
+ */
50
+ contracts;
51
+ /**
52
+ * URL resource
53
+ *
54
+ * URL safety analysis to identify phishing sites and malicious domains.
55
+ */
56
+ url;
57
+ /**
58
+ * Wallets resource
59
+ *
60
+ * Wallet activity analysis including transaction risks and token approvals.
61
+ */
62
+ wallets;
63
+ /**
64
+ * Ledger resource
65
+ *
66
+ * Hardware wallet transaction scanning for secure signing.
67
+ */
68
+ ledger;
69
+ /**
70
+ * Account trace resource
71
+ *
72
+ * Fund flow tracing to identify connections to risky entities.
73
+ */
74
+ accountTrace;
75
+ /**
76
+ * Usage resource
77
+ *
78
+ * API usage statistics and quota management.
79
+ */
80
+ usage;
81
+ /**
82
+ * Create a new ThreatClient instance
83
+ *
84
+ * @param config - Client configuration
85
+ * @throws AuthenticationError if API key is not provided
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Basic setup
90
+ * const client = new ThreatClient({
91
+ * apiKey: 'your-api-key',
92
+ * });
93
+ *
94
+ * // With default chain (omit chain in API calls)
95
+ * const client = new ThreatClient({
96
+ * apiKey: 'your-api-key',
97
+ * defaultChain: Chain.ETH,
98
+ * });
99
+ *
100
+ * // With custom configuration
101
+ * const client = new ThreatClient({
102
+ * apiKey: 'your-api-key',
103
+ * timeout: 60000,
104
+ * retry: {
105
+ * maxRetries: 5,
106
+ * },
107
+ * });
108
+ * ```
109
+ */
110
+ constructor(config) {
111
+ super(config);
112
+ // Initialize resources with the HTTP client and default chain
113
+ this.addresses = new addresses_1.AddressesResource(this.httpClient, this.defaultChain);
114
+ this.contracts = new contracts_1.ContractsResource(this.httpClient, this.defaultChain);
115
+ this.url = new url_1.UrlResource(this.httpClient);
116
+ this.wallets = new wallets_1.WalletsResource(this.httpClient, this.defaultChain);
117
+ this.ledger = new ledger_1.LedgerResource(this.httpClient);
118
+ this.accountTrace = new account_trace_1.AccountTraceResource(this.httpClient, this.defaultChain);
119
+ this.usage = new usage_1.UsageResource(this.httpClient);
120
+ }
121
+ /**
122
+ * Add a request interceptor
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * client.addRequestInterceptor((url, config) => {
127
+ * console.log(`Making request to ${url}`);
128
+ * return config;
129
+ * });
130
+ * ```
131
+ */
132
+ addRequestInterceptor(interceptor) {
133
+ super.addRequestInterceptor(interceptor);
134
+ }
135
+ /**
136
+ * Add a response interceptor
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * client.addResponseInterceptor((response) => {
141
+ * console.log(`Received ${response.status} response`);
142
+ * return response;
143
+ * });
144
+ * ```
145
+ */
146
+ addResponseInterceptor(interceptor) {
147
+ super.addResponseInterceptor(interceptor);
148
+ }
149
+ /**
150
+ * Add an error interceptor
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * client.addErrorInterceptor((error) => {
155
+ * console.error(`Request failed: ${error.message}`);
156
+ * return error;
157
+ * });
158
+ * ```
159
+ */
160
+ addErrorInterceptor(interceptor) {
161
+ super.addErrorInterceptor(interceptor);
162
+ }
163
+ }
164
+ exports.ThreatClient = ThreatClient;
165
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,gDAM2B;AAC3B,qDAA0D;AAC1D,qDAA0D;AAC1D,yCAA8C;AAC9C,iDAAsD;AACtD,+CAAoD;AACpD,6DAAiE;AACjE,6CAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,YAAa,SAAQ,qBAAU;IAC1C;;;;;OAKG;IACa,SAAS,CAAoB;IAE7C;;;;;OAKG;IACa,SAAS,CAAoB;IAE7C;;;;OAIG;IACa,GAAG,CAAc;IAEjC;;;;OAIG;IACa,OAAO,CAAkB;IAEzC;;;;OAIG;IACa,MAAM,CAAiB;IAEvC;;;;OAIG;IACa,YAAY,CAAuB;IAEnD;;;;OAIG;IACa,KAAK,CAAgB;IAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,8DAA8D;QAC9D,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3E,IAAI,CAAC,GAAG,GAAG,IAAI,iBAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,GAAG,IAAI,oCAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;;OAUG;IACM,qBAAqB,CAAC,WAA+B;QAC5D,KAAK,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;OAUG;IACM,sBAAsB,CAAC,WAAgC;QAC9D,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;OAUG;IACM,mBAAmB,CAAC,WAA6B;QACxD,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;CACF;AA1ID,oCA0IC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NetworkError = exports.NotFoundError = exports.ValidationError = exports.RateLimitError = exports.AuthenticationError = exports.WebacyError = exports.TokenStandard = exports.TypeOfAddress = exports.RiskLevel = exports.RiskScore = exports.RiskModule = exports.CHAIN_NAMES = exports.isEvmChain = exports.ChainCompatibility = exports.Chain = exports.UsageResource = exports.AccountTraceResource = exports.LedgerResource = exports.WalletsResource = exports.UrlResource = exports.ContractsResource = exports.AddressesResource = exports.ThreatClient = void 0;
4
+ // Client
5
+ var client_1 = require("./client");
6
+ Object.defineProperty(exports, "ThreatClient", { enumerable: true, get: function () { return client_1.ThreatClient; } });
7
+ // Resources
8
+ var resources_1 = require("./resources");
9
+ Object.defineProperty(exports, "AddressesResource", { enumerable: true, get: function () { return resources_1.AddressesResource; } });
10
+ Object.defineProperty(exports, "ContractsResource", { enumerable: true, get: function () { return resources_1.ContractsResource; } });
11
+ Object.defineProperty(exports, "UrlResource", { enumerable: true, get: function () { return resources_1.UrlResource; } });
12
+ Object.defineProperty(exports, "WalletsResource", { enumerable: true, get: function () { return resources_1.WalletsResource; } });
13
+ Object.defineProperty(exports, "LedgerResource", { enumerable: true, get: function () { return resources_1.LedgerResource; } });
14
+ Object.defineProperty(exports, "AccountTraceResource", { enumerable: true, get: function () { return resources_1.AccountTraceResource; } });
15
+ Object.defineProperty(exports, "UsageResource", { enumerable: true, get: function () { return resources_1.UsageResource; } });
16
+ // Re-export commonly used types from core
17
+ var sdk_core_1 = require("@rlajous/sdk-core");
18
+ Object.defineProperty(exports, "Chain", { enumerable: true, get: function () { return sdk_core_1.Chain; } });
19
+ Object.defineProperty(exports, "ChainCompatibility", { enumerable: true, get: function () { return sdk_core_1.ChainCompatibility; } });
20
+ Object.defineProperty(exports, "isEvmChain", { enumerable: true, get: function () { return sdk_core_1.isEvmChain; } });
21
+ Object.defineProperty(exports, "CHAIN_NAMES", { enumerable: true, get: function () { return sdk_core_1.CHAIN_NAMES; } });
22
+ Object.defineProperty(exports, "RiskModule", { enumerable: true, get: function () { return sdk_core_1.RiskModule; } });
23
+ Object.defineProperty(exports, "RiskScore", { enumerable: true, get: function () { return sdk_core_1.RiskScore; } });
24
+ Object.defineProperty(exports, "RiskLevel", { enumerable: true, get: function () { return sdk_core_1.RiskLevel; } });
25
+ Object.defineProperty(exports, "TypeOfAddress", { enumerable: true, get: function () { return sdk_core_1.TypeOfAddress; } });
26
+ Object.defineProperty(exports, "TokenStandard", { enumerable: true, get: function () { return sdk_core_1.TokenStandard; } });
27
+ Object.defineProperty(exports, "WebacyError", { enumerable: true, get: function () { return sdk_core_1.WebacyError; } });
28
+ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return sdk_core_1.AuthenticationError; } });
29
+ Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return sdk_core_1.RateLimitError; } });
30
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return sdk_core_1.ValidationError; } });
31
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return sdk_core_1.NotFoundError; } });
32
+ Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return sdk_core_1.NetworkError; } });
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAS;AACT,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAErB,YAAY;AACZ,yCAQqB;AAPnB,8GAAA,iBAAiB,OAAA;AACjB,8GAAA,iBAAiB,OAAA;AACjB,wGAAA,WAAW,OAAA;AACX,4GAAA,eAAe,OAAA;AACf,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,0GAAA,aAAa,OAAA;AAkEf,0CAA0C;AAC1C,8CAqB2B;AApBzB,iGAAA,KAAK,OAAA;AACL,8GAAA,kBAAkB,OAAA;AAClB,sGAAA,UAAU,OAAA;AACV,uGAAA,WAAW,OAAA;AACX,sGAAA,UAAU,OAAA;AACV,qGAAA,SAAS,OAAA;AACT,qGAAA,SAAS,OAAA;AACT,yGAAA,aAAa,OAAA;AACb,yGAAA,aAAa,OAAA;AACb,uGAAA,WAAW,OAAA;AACX,+GAAA,mBAAmB,OAAA;AACnB,0GAAA,cAAc,OAAA;AACd,2GAAA,eAAe,OAAA;AACf,yGAAA,aAAa,OAAA;AACb,wGAAA,YAAY,OAAA"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountTraceResource = void 0;
4
+ const sdk_core_1 = require("@rlajous/sdk-core");
5
+ /**
6
+ * Resource for account fund flow tracing
7
+ *
8
+ * Traces fund flows to and from addresses to identify
9
+ * connections to risky entities.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const trace = await client.accountTrace.trace('0x...', { chain: Chain.ETH });
14
+ * console.log(`Sanctioned connections: ${trace.summary.sanctioned_connections}`);
15
+ *
16
+ * // With default chain configured, chain can be omitted
17
+ * const client = new ThreatClient({ apiKey: '...', defaultChain: Chain.ETH });
18
+ * const trace = await client.accountTrace.trace('0x...'); // Uses ETH
19
+ * ```
20
+ */
21
+ class AccountTraceResource {
22
+ httpClient;
23
+ defaultChain;
24
+ constructor(httpClient, defaultChain) {
25
+ this.httpClient = httpClient;
26
+ this.defaultChain = defaultChain;
27
+ }
28
+ /**
29
+ * Resolve the chain to use for a request
30
+ * @throws ValidationError if no chain is specified and no default is set
31
+ */
32
+ resolveChain(options) {
33
+ const chain = options?.chain ?? this.defaultChain;
34
+ if (!chain) {
35
+ throw new sdk_core_1.ValidationError('Chain is required. Either specify chain in options or set defaultChain in client configuration.');
36
+ }
37
+ return chain;
38
+ }
39
+ /**
40
+ * Trace account fund flows
41
+ *
42
+ * Analyzes connections to identify:
43
+ * - Direct counterparties
44
+ * - Sanctioned address connections
45
+ * - Mixer usage
46
+ * - High-risk entities
47
+ *
48
+ * @param address - Address to trace
49
+ * @param options - Trace options (chain is optional if defaultChain is set)
50
+ * @returns Fund flow trace result
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const trace = await client.accountTrace.trace('0x...', {
55
+ * chain: Chain.ETH,
56
+ * depth: 2, // Trace 2 hops
57
+ * });
58
+ *
59
+ * // With default chain configured
60
+ * const trace = await client.accountTrace.trace('0x...');
61
+ *
62
+ * console.log(`Total connections: ${trace.summary.total_connections}`);
63
+ * console.log(`High risk: ${trace.summary.high_risk_connections}`);
64
+ * console.log(`Sanctioned: ${trace.summary.sanctioned_connections}`);
65
+ * console.log(`Mixers: ${trace.summary.mixer_connections}`);
66
+ *
67
+ * // Check individual connections
68
+ * for (const conn of trace.connections) {
69
+ * if (conn.risk_flags?.length) {
70
+ * console.warn(`Risky connection: ${conn.address}`);
71
+ * console.warn(`Flags: ${conn.risk_flags.join(', ')}`);
72
+ * }
73
+ * }
74
+ * ```
75
+ */
76
+ async trace(address, options = {}) {
77
+ const chain = this.resolveChain(options);
78
+ // Validate address format before making API call
79
+ if (!(0, sdk_core_1.isValidAddress)(address, chain)) {
80
+ const chainName = sdk_core_1.CHAIN_NAMES[chain] || chain;
81
+ throw new sdk_core_1.ValidationError(`Invalid ${chainName} address: "${address}". Please provide a valid address format for the ${chainName} blockchain.`);
82
+ }
83
+ const queryParams = new URLSearchParams();
84
+ queryParams.append('chain', chain);
85
+ if (options.depth !== undefined) {
86
+ queryParams.append('depth', String(options.depth));
87
+ }
88
+ const response = await this.httpClient.get(`/account-trace/${encodeURIComponent(address)}?${queryParams.toString()}`, {
89
+ timeout: options.timeout,
90
+ signal: options.signal,
91
+ });
92
+ return response.data;
93
+ }
94
+ }
95
+ exports.AccountTraceResource = AccountTraceResource;
96
+ //# sourceMappingURL=account-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-trace.js","sourceRoot":"","sources":["../../../src/resources/account-trace.ts"],"names":[],"mappings":";;;AAAA,gDAO2B;AAG3B;;;;;;;;;;;;;;;GAeG;AACH,MAAa,oBAAoB;IAEZ;IACA;IAFnB,YACmB,UAAsB,EACtB,YAAoB;QADpB,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAQ;IACpC,CAAC;IAEJ;;;OAGG;IACK,YAAY,CAAC,OAA2B;QAC9C,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,0BAAe,CACvB,iGAAiG,CAClG,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,KAAK,CAAC,KAAK,CAAC,OAAe,EAAE,UAA+B,EAAE;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEzC,iDAAiD;QACjD,IAAI,CAAC,IAAA,yBAAc,EAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,sBAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;YAC9C,MAAM,IAAI,0BAAe,CACvB,WAAW,SAAS,cAAc,OAAO,oDAAoD,SAAS,cAAc,CACrH,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;QAC1C,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEnC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,QAAQ,GAAuC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAC5E,kBAAkB,kBAAkB,CAAC,OAAO,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,EACzE;YACE,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AArFD,oDAqFC"}