@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
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsageResource = void 0;
4
+ /**
5
+ * Resource for API usage and quota management
6
+ *
7
+ * Provides access to API usage statistics, current quota,
8
+ * and available plans.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const current = await client.usage.getCurrent();
13
+ * console.log(`Used: ${current.calls_used}/${current.calls_limit}`);
14
+ * ```
15
+ */
16
+ class UsageResource {
17
+ httpClient;
18
+ constructor(httpClient) {
19
+ this.httpClient = httpClient;
20
+ }
21
+ /**
22
+ * Get historical usage data
23
+ *
24
+ * Returns API usage statistics for a time period.
25
+ *
26
+ * @param options - Request options with date range
27
+ * @returns Historical usage data
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const usage = await client.usage.getUsage({
32
+ * start_date: '2024-01-01',
33
+ * end_date: '2024-01-31',
34
+ * });
35
+ *
36
+ * console.log(`Total calls: ${usage.total_calls}`);
37
+ * console.log(`Period calls: ${usage.period_calls}`);
38
+ *
39
+ * // Usage by endpoint
40
+ * if (usage.by_endpoint) {
41
+ * for (const [endpoint, count] of Object.entries(usage.by_endpoint)) {
42
+ * console.log(`${endpoint}: ${count} calls`);
43
+ * }
44
+ * }
45
+ * ```
46
+ */
47
+ async getUsage(options) {
48
+ const queryParams = new URLSearchParams();
49
+ if (options?.start_date) {
50
+ queryParams.append('start_date', options.start_date);
51
+ }
52
+ if (options?.end_date) {
53
+ queryParams.append('end_date', options.end_date);
54
+ }
55
+ const queryString = queryParams.toString();
56
+ const path = queryString ? `/usage?${queryString}` : '/usage';
57
+ const response = await this.httpClient.get(path, {
58
+ timeout: options?.timeout,
59
+ signal: options?.signal,
60
+ });
61
+ return response.data;
62
+ }
63
+ /**
64
+ * Get current usage status
65
+ *
66
+ * Returns current period usage and remaining quota.
67
+ *
68
+ * @param options - Request options
69
+ * @returns Current usage status
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const current = await client.usage.getCurrent();
74
+ *
75
+ * console.log(`Plan: ${current.plan}`);
76
+ * console.log(`Used: ${current.calls_used}/${current.calls_limit}`);
77
+ * console.log(`Remaining: ${current.calls_remaining}`);
78
+ * console.log(`Usage: ${current.usage_percentage}%`);
79
+ * console.log(`Resets: ${current.reset_date}`);
80
+ *
81
+ * if (current.usage_percentage > 80) {
82
+ * console.warn('Approaching usage limit!');
83
+ * }
84
+ * ```
85
+ */
86
+ async getCurrent(options) {
87
+ const response = await this.httpClient.get('/usage/current', {
88
+ timeout: options?.timeout,
89
+ signal: options?.signal,
90
+ });
91
+ return response.data;
92
+ }
93
+ /**
94
+ * Get available usage plans
95
+ *
96
+ * Returns list of available plans and their features.
97
+ *
98
+ * @param options - Request options
99
+ * @returns Available plans
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const plans = await client.usage.getPlans();
104
+ *
105
+ * console.log(`Current plan: ${plans.current_plan}`);
106
+ *
107
+ * for (const plan of plans.plans) {
108
+ * console.log(`${plan.name}:`);
109
+ * console.log(` Monthly limit: ${plan.monthly_limit}`);
110
+ * console.log(` Rate limit: ${plan.rate_limit}/sec`);
111
+ * console.log(` Features: ${plan.features.join(', ')}`);
112
+ * }
113
+ * ```
114
+ */
115
+ async getPlans(options) {
116
+ const response = await this.httpClient.get('/usage/usagePlans', {
117
+ timeout: options?.timeout,
118
+ signal: options?.signal,
119
+ });
120
+ return response.data;
121
+ }
122
+ }
123
+ exports.UsageResource = UsageResource;
124
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/resources/usage.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;GAWG;AACH,MAAa,aAAa;IACK;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAsB;QACnC,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;QAE1C,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,UAAU,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QAE9D,MAAM,QAAQ,GAA4B,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE;YACxE,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,UAAU,CAAC,OAGhB;QACC,MAAM,QAAQ,GAAuC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAC5E,gBAAgB,EAChB;YACE,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,QAAQ,CAAC,OAGd;QACC,MAAM,QAAQ,GAAqC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAC1E,mBAAmB,EACnB;YACE,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AA5HD,sCA4HC"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletsResource = void 0;
4
+ const sdk_core_1 = require("@rlajous/sdk-core");
5
+ /**
6
+ * Resource for wallet transaction and approval analysis
7
+ *
8
+ * Provides security analysis for wallet activity including:
9
+ * - Transaction risk analysis
10
+ * - Token approval monitoring
11
+ * - Counterparty risk assessment
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Get transaction risks
16
+ * const txs = await client.wallets.getTransactions('0x...', { chain: Chain.ETH });
17
+ *
18
+ * // Get token approvals
19
+ * const approvals = await client.wallets.getApprovals('0x...', { chain: Chain.ETH });
20
+ *
21
+ * // With default chain configured, chain can be omitted
22
+ * const client = new ThreatClient({ apiKey: '...', defaultChain: Chain.ETH });
23
+ * const txs = await client.wallets.getTransactions('0x...'); // Uses ETH
24
+ * ```
25
+ */
26
+ class WalletsResource {
27
+ httpClient;
28
+ defaultChain;
29
+ constructor(httpClient, defaultChain) {
30
+ this.httpClient = httpClient;
31
+ this.defaultChain = defaultChain;
32
+ }
33
+ /**
34
+ * Resolve the chain to use for a request
35
+ * @throws ValidationError if no chain is specified and no default is set
36
+ */
37
+ resolveChain(options) {
38
+ const chain = options?.chain ?? this.defaultChain;
39
+ if (!chain) {
40
+ throw new sdk_core_1.ValidationError('Chain is required. Either specify chain in options or set defaultChain in client configuration.');
41
+ }
42
+ return chain;
43
+ }
44
+ /**
45
+ * Validate wallet address format
46
+ * @throws ValidationError if address format is invalid for the chain
47
+ */
48
+ validateAddress(address, chain) {
49
+ if (!(0, sdk_core_1.isValidAddress)(address, chain)) {
50
+ const chainName = sdk_core_1.CHAIN_NAMES[chain] || chain;
51
+ throw new sdk_core_1.ValidationError(`Invalid ${chainName} wallet address: "${address}". Please provide a valid address format for the ${chainName} blockchain.`);
52
+ }
53
+ }
54
+ /**
55
+ * Get wallet transaction risk analysis
56
+ *
57
+ * Analyzes recent transactions for security risks including:
58
+ * - Interactions with risky addresses
59
+ * - Sanctioned counterparties
60
+ * - Suspicious patterns
61
+ *
62
+ * @param address - Wallet address
63
+ * @param options - Request options (chain is optional if defaultChain is set)
64
+ * @returns Transaction risk analysis
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const result = await client.wallets.getTransactions('0x...', {
69
+ * chain: Chain.ETH,
70
+ * limit: 50,
71
+ * });
72
+ *
73
+ * // With default chain configured
74
+ * const result = await client.wallets.getTransactions('0x...');
75
+ *
76
+ * console.log(`Total issues: ${result.count}`);
77
+ * console.log(`High risk: ${result.high}`);
78
+ * console.log(`Overall risk: ${result.overallRisk}`);
79
+ *
80
+ * for (const issue of result.issues) {
81
+ * if (issue.transaction.sanctioned_address) {
82
+ * console.error('Transaction with sanctioned address!');
83
+ * }
84
+ * }
85
+ * ```
86
+ */
87
+ async getTransactions(address, options = {}) {
88
+ const chain = this.resolveChain(options);
89
+ this.validateAddress(address, chain);
90
+ const queryParams = new URLSearchParams();
91
+ queryParams.append('chain', chain);
92
+ if (options.limit !== undefined) {
93
+ queryParams.append('limit', String(options.limit));
94
+ }
95
+ if (options.offset !== undefined) {
96
+ queryParams.append('offset', String(options.offset));
97
+ }
98
+ const response = await this.httpClient.get(`/wallets/${encodeURIComponent(address)}/transactions?${queryParams.toString()}`, {
99
+ timeout: options.timeout,
100
+ signal: options.signal,
101
+ });
102
+ return response.data;
103
+ }
104
+ /**
105
+ * Get wallet token approvals
106
+ *
107
+ * Lists all active token approvals for a wallet,
108
+ * with risk assessment for each spender.
109
+ *
110
+ * @param address - Wallet address
111
+ * @param options - Request options (chain is optional if defaultChain is set)
112
+ * @returns Token approvals with risk data
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const result = await client.wallets.getApprovals('0x...', {
117
+ * chain: Chain.ETH,
118
+ * });
119
+ *
120
+ * // With default chain configured
121
+ * const result = await client.wallets.getApprovals('0x...');
122
+ *
123
+ * console.log(`Total approvals: ${result.count}`);
124
+ * console.log(`High risk approvals: ${result.high_risk_count}`);
125
+ *
126
+ * for (const approval of result.approvals) {
127
+ * if (approval.is_unlimited) {
128
+ * console.warn(`Unlimited approval to ${approval.spender}`);
129
+ * }
130
+ * if (approval.spender_risk && approval.spender_risk > 50) {
131
+ * console.error(`High risk spender: ${approval.spender}`);
132
+ * }
133
+ * }
134
+ * ```
135
+ */
136
+ async getApprovals(address, options = {}) {
137
+ const chain = this.resolveChain(options);
138
+ this.validateAddress(address, chain);
139
+ const queryParams = new URLSearchParams();
140
+ queryParams.append('chain', chain);
141
+ const response = await this.httpClient.get(`/wallets/${encodeURIComponent(address)}/approvals?${queryParams.toString()}`, {
142
+ timeout: options.timeout,
143
+ signal: options.signal,
144
+ });
145
+ return response.data;
146
+ }
147
+ }
148
+ exports.WalletsResource = WalletsResource;
149
+ //# sourceMappingURL=wallets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallets.js","sourceRoot":"","sources":["../../../src/resources/wallets.ts"],"names":[],"mappings":";;;AAAA,gDAO2B;AAQ3B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,eAAe;IAEP;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;;;OAGG;IACK,eAAe,CAAC,OAAe,EAAE,KAAY;QACnD,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,qBAAqB,OAAO,oDAAoD,SAAS,cAAc,CAC5H,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,KA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AAQ,GAA0C,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAC/E,YAAY,kBAAkB,CAAC,OAAO,CAAC,cAAc,WAAW,CAAC,QAAQ,EAAE,EAAE,EAC7E;YACE,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAlJD,0CAkJC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=account-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-trace.js","sourceRoot":"","sources":["../../../src/types/account-trace.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/types/address.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/types/contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/types/url.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/types/usage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/types/wallet.ts"],"names":[],"mappings":""}
@@ -0,0 +1,161 @@
1
+ import { BaseClient, } from '@rlajous/sdk-core';
2
+ import { AddressesResource } from './resources/addresses';
3
+ import { ContractsResource } from './resources/contracts';
4
+ import { UrlResource } from './resources/url';
5
+ import { WalletsResource } from './resources/wallets';
6
+ import { LedgerResource } from './resources/ledger';
7
+ import { AccountTraceResource } from './resources/account-trace';
8
+ import { UsageResource } from './resources/usage';
9
+ /**
10
+ * Webacy Threat SDK Client
11
+ *
12
+ * Provides access to threat and risk analysis including address risk,
13
+ * sanctions screening, contract security, URL safety, and more.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { ThreatClient, Chain, RiskModule } from '@rlajous/sdk-threat';
18
+ *
19
+ * const client = new ThreatClient({
20
+ * apiKey: process.env.WEBACY_API_KEY!,
21
+ * });
22
+ *
23
+ * // Address risk analysis
24
+ * const risk = await client.addresses.analyze('0x...', { chain: 'eth' });
25
+ *
26
+ * // Sanctions screening
27
+ * const sanctioned = await client.addresses.checkSanctioned('0x...', { chain: 'eth' });
28
+ *
29
+ * // URL safety check
30
+ * const urlRisk = await client.url.check('https://suspicious-site.com');
31
+ * ```
32
+ */
33
+ export class ThreatClient extends BaseClient {
34
+ /**
35
+ * Addresses resource
36
+ *
37
+ * Comprehensive security analysis for blockchain addresses including
38
+ * risk scoring, sanctions screening, and address poisoning detection.
39
+ */
40
+ addresses;
41
+ /**
42
+ * Contracts resource
43
+ *
44
+ * Smart contract security analysis including vulnerability detection,
45
+ * source code analysis, and tax detection.
46
+ */
47
+ contracts;
48
+ /**
49
+ * URL resource
50
+ *
51
+ * URL safety analysis to identify phishing sites and malicious domains.
52
+ */
53
+ url;
54
+ /**
55
+ * Wallets resource
56
+ *
57
+ * Wallet activity analysis including transaction risks and token approvals.
58
+ */
59
+ wallets;
60
+ /**
61
+ * Ledger resource
62
+ *
63
+ * Hardware wallet transaction scanning for secure signing.
64
+ */
65
+ ledger;
66
+ /**
67
+ * Account trace resource
68
+ *
69
+ * Fund flow tracing to identify connections to risky entities.
70
+ */
71
+ accountTrace;
72
+ /**
73
+ * Usage resource
74
+ *
75
+ * API usage statistics and quota management.
76
+ */
77
+ usage;
78
+ /**
79
+ * Create a new ThreatClient instance
80
+ *
81
+ * @param config - Client configuration
82
+ * @throws AuthenticationError if API key is not provided
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * // Basic setup
87
+ * const client = new ThreatClient({
88
+ * apiKey: 'your-api-key',
89
+ * });
90
+ *
91
+ * // With default chain (omit chain in API calls)
92
+ * const client = new ThreatClient({
93
+ * apiKey: 'your-api-key',
94
+ * defaultChain: Chain.ETH,
95
+ * });
96
+ *
97
+ * // With custom configuration
98
+ * const client = new ThreatClient({
99
+ * apiKey: 'your-api-key',
100
+ * timeout: 60000,
101
+ * retry: {
102
+ * maxRetries: 5,
103
+ * },
104
+ * });
105
+ * ```
106
+ */
107
+ constructor(config) {
108
+ super(config);
109
+ // Initialize resources with the HTTP client and default chain
110
+ this.addresses = new AddressesResource(this.httpClient, this.defaultChain);
111
+ this.contracts = new ContractsResource(this.httpClient, this.defaultChain);
112
+ this.url = new UrlResource(this.httpClient);
113
+ this.wallets = new WalletsResource(this.httpClient, this.defaultChain);
114
+ this.ledger = new LedgerResource(this.httpClient);
115
+ this.accountTrace = new AccountTraceResource(this.httpClient, this.defaultChain);
116
+ this.usage = new UsageResource(this.httpClient);
117
+ }
118
+ /**
119
+ * Add a request interceptor
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * client.addRequestInterceptor((url, config) => {
124
+ * console.log(`Making request to ${url}`);
125
+ * return config;
126
+ * });
127
+ * ```
128
+ */
129
+ addRequestInterceptor(interceptor) {
130
+ super.addRequestInterceptor(interceptor);
131
+ }
132
+ /**
133
+ * Add a response interceptor
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * client.addResponseInterceptor((response) => {
138
+ * console.log(`Received ${response.status} response`);
139
+ * return response;
140
+ * });
141
+ * ```
142
+ */
143
+ addResponseInterceptor(interceptor) {
144
+ super.addResponseInterceptor(interceptor);
145
+ }
146
+ /**
147
+ * Add an error interceptor
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * client.addErrorInterceptor((error) => {
152
+ * console.error(`Request failed: ${error.message}`);
153
+ * return error;
154
+ * });
155
+ * ```
156
+ */
157
+ addErrorInterceptor(interceptor) {
158
+ super.addErrorInterceptor(interceptor);
159
+ }
160
+ }
161
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAKX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MA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C;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"}
@@ -0,0 +1,7 @@
1
+ // Client
2
+ export { ThreatClient } from './client';
3
+ // Resources
4
+ export { AddressesResource, ContractsResource, UrlResource, WalletsResource, LedgerResource, AccountTraceResource, UsageResource, } from './resources';
5
+ // Re-export commonly used types from core
6
+ export { Chain, ChainCompatibility, isEvmChain, CHAIN_NAMES, RiskModule, RiskScore, RiskLevel, TypeOfAddress, TokenStandard, WebacyError, AuthenticationError, RateLimitError, ValidationError, NotFoundError, NetworkError, } from '@rlajous/sdk-core';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,YAAY;AACZ,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,aAAa,GACd,MAAM,aAAa,CAAC;AAiErB,0CAA0C;AAC1C,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,GAMb,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,92 @@
1
+ import { ValidationError, isValidAddress, CHAIN_NAMES, } from '@rlajous/sdk-core';
2
+ /**
3
+ * Resource for account fund flow tracing
4
+ *
5
+ * Traces fund flows to and from addresses to identify
6
+ * connections to risky entities.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const trace = await client.accountTrace.trace('0x...', { chain: Chain.ETH });
11
+ * console.log(`Sanctioned connections: ${trace.summary.sanctioned_connections}`);
12
+ *
13
+ * // With default chain configured, chain can be omitted
14
+ * const client = new ThreatClient({ apiKey: '...', defaultChain: Chain.ETH });
15
+ * const trace = await client.accountTrace.trace('0x...'); // Uses ETH
16
+ * ```
17
+ */
18
+ export class AccountTraceResource {
19
+ httpClient;
20
+ defaultChain;
21
+ constructor(httpClient, defaultChain) {
22
+ this.httpClient = httpClient;
23
+ this.defaultChain = defaultChain;
24
+ }
25
+ /**
26
+ * Resolve the chain to use for a request
27
+ * @throws ValidationError if no chain is specified and no default is set
28
+ */
29
+ resolveChain(options) {
30
+ const chain = options?.chain ?? this.defaultChain;
31
+ if (!chain) {
32
+ throw new ValidationError('Chain is required. Either specify chain in options or set defaultChain in client configuration.');
33
+ }
34
+ return chain;
35
+ }
36
+ /**
37
+ * Trace account fund flows
38
+ *
39
+ * Analyzes connections to identify:
40
+ * - Direct counterparties
41
+ * - Sanctioned address connections
42
+ * - Mixer usage
43
+ * - High-risk entities
44
+ *
45
+ * @param address - Address to trace
46
+ * @param options - Trace options (chain is optional if defaultChain is set)
47
+ * @returns Fund flow trace result
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const trace = await client.accountTrace.trace('0x...', {
52
+ * chain: Chain.ETH,
53
+ * depth: 2, // Trace 2 hops
54
+ * });
55
+ *
56
+ * // With default chain configured
57
+ * const trace = await client.accountTrace.trace('0x...');
58
+ *
59
+ * console.log(`Total connections: ${trace.summary.total_connections}`);
60
+ * console.log(`High risk: ${trace.summary.high_risk_connections}`);
61
+ * console.log(`Sanctioned: ${trace.summary.sanctioned_connections}`);
62
+ * console.log(`Mixers: ${trace.summary.mixer_connections}`);
63
+ *
64
+ * // Check individual connections
65
+ * for (const conn of trace.connections) {
66
+ * if (conn.risk_flags?.length) {
67
+ * console.warn(`Risky connection: ${conn.address}`);
68
+ * console.warn(`Flags: ${conn.risk_flags.join(', ')}`);
69
+ * }
70
+ * }
71
+ * ```
72
+ */
73
+ async trace(address, options = {}) {
74
+ const chain = this.resolveChain(options);
75
+ // Validate address format before making API call
76
+ if (!isValidAddress(address, chain)) {
77
+ const chainName = CHAIN_NAMES[chain] || chain;
78
+ throw new ValidationError(`Invalid ${chainName} address: "${address}". Please provide a valid address format for the ${chainName} blockchain.`);
79
+ }
80
+ const queryParams = new URLSearchParams();
81
+ queryParams.append('chain', chain);
82
+ if (options.depth !== undefined) {
83
+ queryParams.append('depth', String(options.depth));
84
+ }
85
+ const response = await this.httpClient.get(`/account-trace/${encodeURIComponent(address)}?${queryParams.toString()}`, {
86
+ timeout: options.timeout,
87
+ signal: options.signal,
88
+ });
89
+ return response.data;
90
+ }
91
+ }
92
+ //# 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,OAAO,EAGL,eAAe,EACf,cAAc,EACd,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,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,eAAe,CACvB,iGAAiG,CAClG,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,KAAK,CAAC,KAAK,CAAC,OAAe,EA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