@rlajous/sdk-core 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 +96 -0
- package/dist/cjs/client-base.js +155 -0
- package/dist/cjs/client-base.js.map +1 -0
- package/dist/cjs/config.js +30 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/errors/authentication.js +35 -0
- package/dist/cjs/errors/authentication.js.map +1 -0
- package/dist/cjs/errors/base.js +76 -0
- package/dist/cjs/errors/base.js.map +1 -0
- package/dist/cjs/errors/index.js +16 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/errors/network.js +45 -0
- package/dist/cjs/errors/network.js.map +1 -0
- package/dist/cjs/errors/not-found.js +38 -0
- package/dist/cjs/errors/not-found.js.map +1 -0
- package/dist/cjs/errors/rate-limit.js +53 -0
- package/dist/cjs/errors/rate-limit.js.map +1 -0
- package/dist/cjs/errors/validation.js +49 -0
- package/dist/cjs/errors/validation.js.map +1 -0
- package/dist/cjs/http/client.js +335 -0
- package/dist/cjs/http/client.js.map +1 -0
- package/dist/cjs/http/index.js +11 -0
- package/dist/cjs/http/index.js.map +1 -0
- package/dist/cjs/http/retry.js +43 -0
- package/dist/cjs/http/retry.js.map +1 -0
- package/dist/cjs/index.js +48 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types/chain.js +114 -0
- package/dist/cjs/types/chain.js.map +1 -0
- package/dist/cjs/types/common.js +49 -0
- package/dist/cjs/types/common.js.map +1 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/modules.js +64 -0
- package/dist/cjs/types/modules.js.map +1 -0
- package/dist/cjs/utils/address-validation.js +124 -0
- package/dist/cjs/utils/address-validation.js.map +1 -0
- package/dist/cjs/utils/index.js +14 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/client-base.js +151 -0
- package/dist/esm/client-base.js.map +1 -0
- package/dist/esm/config.js +26 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/errors/authentication.js +31 -0
- package/dist/esm/errors/authentication.js.map +1 -0
- package/dist/esm/errors/base.js +72 -0
- package/dist/esm/errors/base.js.map +1 -0
- package/dist/esm/errors/index.js +7 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/errors/network.js +41 -0
- package/dist/esm/errors/network.js.map +1 -0
- package/dist/esm/errors/not-found.js +34 -0
- package/dist/esm/errors/not-found.js.map +1 -0
- package/dist/esm/errors/rate-limit.js +49 -0
- package/dist/esm/errors/rate-limit.js.map +1 -0
- package/dist/esm/errors/validation.js +45 -0
- package/dist/esm/errors/validation.js.map +1 -0
- package/dist/esm/http/client.js +331 -0
- package/dist/esm/http/client.js.map +1 -0
- package/dist/esm/http/index.js +3 -0
- package/dist/esm/http/index.js.map +1 -0
- package/dist/esm/http/retry.js +37 -0
- package/dist/esm/http/retry.js.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types/chain.js +109 -0
- package/dist/esm/types/chain.js.map +1 -0
- package/dist/esm/types/common.js +46 -0
- package/dist/esm/types/common.js.map +1 -0
- package/dist/esm/types/index.js +4 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/modules.js +61 -0
- package/dist/esm/types/modules.js.map +1 -0
- package/dist/esm/utils/address-validation.js +113 -0
- package/dist/esm/utils/address-validation.js.map +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/client-base.d.ts +94 -0
- package/dist/types/client-base.d.ts.map +1 -0
- package/dist/types/config.d.ts +124 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/errors/authentication.d.ts +24 -0
- package/dist/types/errors/authentication.d.ts.map +1 -0
- package/dist/types/errors/base.d.ts +53 -0
- package/dist/types/errors/base.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +7 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/network.d.ts +30 -0
- package/dist/types/errors/network.d.ts.map +1 -0
- package/dist/types/errors/not-found.d.ts +27 -0
- package/dist/types/errors/not-found.d.ts.map +1 -0
- package/dist/types/errors/rate-limit.d.ts +37 -0
- package/dist/types/errors/rate-limit.d.ts.map +1 -0
- package/dist/types/errors/validation.d.ts +34 -0
- package/dist/types/errors/validation.d.ts.map +1 -0
- package/dist/types/http/client.d.ts +147 -0
- package/dist/types/http/client.d.ts.map +1 -0
- package/dist/types/http/index.d.ts +3 -0
- package/dist/types/http/index.d.ts.map +1 -0
- package/dist/types/http/retry.d.ts +32 -0
- package/dist/types/http/retry.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/chain.d.ts +60 -0
- package/dist/types/types/chain.d.ts.map +1 -0
- package/dist/types/types/common.d.ts +251 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/modules.d.ts +51 -0
- package/dist/types/types/modules.d.ts.map +1 -0
- package/dist/types/utils/address-validation.d.ts +50 -0
- package/dist/types/utils/address-validation.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Risk score classification
|
|
3
|
+
*/
|
|
4
|
+
export var RiskScore;
|
|
5
|
+
(function (RiskScore) {
|
|
6
|
+
RiskScore["HIGH"] = "High Risk";
|
|
7
|
+
RiskScore["MEDIUM"] = "Medium Risk";
|
|
8
|
+
RiskScore["LOW"] = "Low Risk";
|
|
9
|
+
RiskScore["TRUSTED"] = "Trusted";
|
|
10
|
+
RiskScore["UNKNOWN"] = "Unknown";
|
|
11
|
+
})(RiskScore || (RiskScore = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Risk level enum
|
|
14
|
+
*/
|
|
15
|
+
export var RiskLevel;
|
|
16
|
+
(function (RiskLevel) {
|
|
17
|
+
RiskLevel["Low"] = "low";
|
|
18
|
+
RiskLevel["Medium"] = "medium";
|
|
19
|
+
RiskLevel["High"] = "high";
|
|
20
|
+
RiskLevel["Suspicious"] = "suspicious";
|
|
21
|
+
})(RiskLevel || (RiskLevel = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Address type classification
|
|
24
|
+
*/
|
|
25
|
+
export var TypeOfAddress;
|
|
26
|
+
(function (TypeOfAddress) {
|
|
27
|
+
TypeOfAddress["EOA"] = "EOA";
|
|
28
|
+
TypeOfAddress["CONTRACT"] = "CONTRACT";
|
|
29
|
+
TypeOfAddress["TOKEN"] = "TOKEN";
|
|
30
|
+
TypeOfAddress["CONTRACT_WALLET"] = "CONTRACT_WALLET";
|
|
31
|
+
TypeOfAddress["MULTISIG"] = "MULTISIG";
|
|
32
|
+
})(TypeOfAddress || (TypeOfAddress = {}));
|
|
33
|
+
/**
|
|
34
|
+
* Token standard
|
|
35
|
+
*/
|
|
36
|
+
export var TokenStandard;
|
|
37
|
+
(function (TokenStandard) {
|
|
38
|
+
TokenStandard["ERC20"] = "ERC20";
|
|
39
|
+
TokenStandard["ERC721"] = "ERC721";
|
|
40
|
+
TokenStandard["ERC1155"] = "ERC1155";
|
|
41
|
+
TokenStandard["SPL"] = "SPL";
|
|
42
|
+
TokenStandard["JETTON"] = "JETTON";
|
|
43
|
+
TokenStandard["STELLAR_ASSET"] = "STELLAR_ASSET";
|
|
44
|
+
TokenStandard["SUI_COIN"] = "SUI_COIN";
|
|
45
|
+
})(TokenStandard || (TokenStandard = {}));
|
|
46
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/types/common.ts"],"names":[],"mappings":"AA8CA;;GAEG;AACH,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,+BAAkB,CAAA;IAClB,mCAAsB,CAAA;IACtB,6BAAgB,CAAA;IAChB,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;AACrB,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,8BAAiB,CAAA;IACjB,0BAAa,CAAA;IACb,sCAAyB,CAAA;AAC3B,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AA2ID;;GAEG;AACH,MAAM,CAAN,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,sCAAqB,CAAA;IACrB,gCAAe,CAAA;IACf,oDAAmC,CAAA;IACnC,sCAAqB,CAAA;AACvB,CAAC,EANW,aAAa,KAAb,aAAa,QAMxB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,4BAAW,CAAA;IACX,kCAAiB,CAAA;IACjB,gDAA+B,CAAA;IAC/B,sCAAqB,CAAA;AACvB,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAoBvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Risk analysis modules available for requests
|
|
3
|
+
*
|
|
4
|
+
* Use these to specify which analysis modules to run when making API requests.
|
|
5
|
+
* Requesting fewer modules can improve response time.
|
|
6
|
+
*/
|
|
7
|
+
export var RiskModule;
|
|
8
|
+
(function (RiskModule) {
|
|
9
|
+
// Core security analysis
|
|
10
|
+
/** Contract ownership, upgradeability, access controls */
|
|
11
|
+
RiskModule["GOVERNANCE_ANALYSIS"] = "governance_analysis";
|
|
12
|
+
/** Freezeable, mintable, blacklist, whitelist */
|
|
13
|
+
RiskModule["TOKEN_SECURITY"] = "token_security";
|
|
14
|
+
/** Static/dynamic code analysis, vulnerabilities */
|
|
15
|
+
RiskModule["CONTRACT_ANALYSIS"] = "contract_analysis";
|
|
16
|
+
/** Source code analysis, vulnerabilities */
|
|
17
|
+
RiskModule["SOURCE_CODE_ANALYSIS"] = "source_code_analysis";
|
|
18
|
+
// Financial risk analysis
|
|
19
|
+
/** Price, volatility, market cap, liquidity */
|
|
20
|
+
RiskModule["MARKET_DATA"] = "market_data";
|
|
21
|
+
/** Token distribution, concentration risks */
|
|
22
|
+
RiskModule["HOLDER_ANALYSIS"] = "holder_analysis";
|
|
23
|
+
/** Pool data, unlock schedules, LP analysis */
|
|
24
|
+
RiskModule["LIQUIDITY_ANALYSIS"] = "liquidity_analysis";
|
|
25
|
+
// Fraud and compliance
|
|
26
|
+
/** Hacker, drainer, rugpull detection */
|
|
27
|
+
RiskModule["FRAUD_DETECTION"] = "fraud_detection";
|
|
28
|
+
/** OFAC, sanctioned addresses */
|
|
29
|
+
RiskModule["SANCTIONS_COMPLIANCE"] = "sanctions_compliance";
|
|
30
|
+
/** Tornado cash, coin mixers */
|
|
31
|
+
RiskModule["MIXER_DETECTION"] = "mixer_detection";
|
|
32
|
+
// Address behavior analysis
|
|
33
|
+
/** Trading patterns, automated trading */
|
|
34
|
+
RiskModule["ADDRESS_BEHAVIOR"] = "address_behavior";
|
|
35
|
+
/** Address poisoning, wash trading */
|
|
36
|
+
RiskModule["TRANSACTION_ANALYSIS"] = "transaction_analysis";
|
|
37
|
+
/** Reported addresses, spam detection */
|
|
38
|
+
RiskModule["REPUTATION_ANALYSIS"] = "reputation_analysis";
|
|
39
|
+
// Chain-specific analysis
|
|
40
|
+
/** Solana-only risks (bundling, sniping) */
|
|
41
|
+
RiskModule["SOLANA_SPECIFIC"] = "solana_specific";
|
|
42
|
+
/** EVM-only risks (gas optimization, MEV) */
|
|
43
|
+
RiskModule["EVM_SPECIFIC"] = "evm_specific";
|
|
44
|
+
/** TON-only risks (jetton standards, etc.) */
|
|
45
|
+
RiskModule["TON_SPECIFIC"] = "ton_specific";
|
|
46
|
+
/** SUI-only risks (coin standards, object model) */
|
|
47
|
+
RiskModule["SUI_SPECIFIC"] = "sui_specific";
|
|
48
|
+
// Basic metadata (always fast)
|
|
49
|
+
/** Address type, age, balance checks */
|
|
50
|
+
RiskModule["BASIC_INFO"] = "basic_info";
|
|
51
|
+
// Ultra-fast module for core security flags
|
|
52
|
+
/** Only is_mintable, freezeable, is_metadata_immutable */
|
|
53
|
+
RiskModule["SECURITY_ESSENTIALS"] = "security_essentials";
|
|
54
|
+
// Fast fund flow screening with boolean indicators
|
|
55
|
+
/** Boolean flags for OFAC, hacker, mixer, drainer risks */
|
|
56
|
+
RiskModule["FUND_FLOW_SCREENING"] = "fund_flow_screening";
|
|
57
|
+
// Developer behavior and migration pattern analysis
|
|
58
|
+
/** Multi-platform developer behavior, token launch patterns */
|
|
59
|
+
RiskModule["DEVELOPER_MIGRATION"] = "developer_migration";
|
|
60
|
+
})(RiskModule || (RiskModule = {}));
|
|
61
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/types/modules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,UA4DX;AA5DD,WAAY,UAAU;IACpB,yBAAyB;IACzB,0DAA0D;IAC1D,yDAA2C,CAAA;IAC3C,iDAAiD;IACjD,+CAAiC,CAAA;IACjC,oDAAoD;IACpD,qDAAuC,CAAA;IACvC,4CAA4C;IAC5C,2DAA6C,CAAA;IAE7C,0BAA0B;IAC1B,+CAA+C;IAC/C,yCAA2B,CAAA;IAC3B,8CAA8C;IAC9C,iDAAmC,CAAA;IACnC,+CAA+C;IAC/C,uDAAyC,CAAA;IAEzC,uBAAuB;IACvB,yCAAyC;IACzC,iDAAmC,CAAA;IACnC,iCAAiC;IACjC,2DAA6C,CAAA;IAC7C,gCAAgC;IAChC,iDAAmC,CAAA;IAEnC,4BAA4B;IAC5B,0CAA0C;IAC1C,mDAAqC,CAAA;IACrC,sCAAsC;IACtC,2DAA6C,CAAA;IAC7C,yCAAyC;IACzC,yDAA2C,CAAA;IAE3C,0BAA0B;IAC1B,4CAA4C;IAC5C,iDAAmC,CAAA;IACnC,6CAA6C;IAC7C,2CAA6B,CAAA;IAC7B,8CAA8C;IAC9C,2CAA6B,CAAA;IAC7B,oDAAoD;IACpD,2CAA6B,CAAA;IAE7B,+BAA+B;IAC/B,wCAAwC;IACxC,uCAAyB,CAAA;IAEzB,4CAA4C;IAC5C,0DAA0D;IAC1D,yDAA2C,CAAA;IAE3C,mDAAmD;IACnD,2DAA2D;IAC3D,yDAA2C,CAAA;IAE3C,oDAAoD;IACpD,+DAA+D;IAC/D,yDAA2C,CAAA;AAC7C,CAAC,EA5DW,UAAU,KAAV,UAAU,QA4DrB"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Chain, isEvmChain } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Validate an Ethereum address format
|
|
4
|
+
*/
|
|
5
|
+
export function isValidEvmAddress(address) {
|
|
6
|
+
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Validate a Solana address format (base58)
|
|
10
|
+
*/
|
|
11
|
+
export function isValidSolanaAddress(address) {
|
|
12
|
+
// Base58 character set (no 0, O, I, l)
|
|
13
|
+
return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Validate a Bitcoin address format
|
|
17
|
+
*/
|
|
18
|
+
export function isValidBitcoinAddress(address) {
|
|
19
|
+
// P2PKH (starts with 1), P2SH (starts with 3), Bech32 (starts with bc1)
|
|
20
|
+
return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/.test(address) || /^bc1[a-z0-9]{39,59}$/.test(address);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate a TON address format
|
|
24
|
+
*/
|
|
25
|
+
export function isValidTonAddress(address) {
|
|
26
|
+
// Raw format (48 bytes hex with workchain)
|
|
27
|
+
if (/^-?\d:[a-fA-F0-9]{64}$/.test(address)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// User-friendly format (base64)
|
|
31
|
+
if (/^[A-Za-z0-9_-]{48}$/.test(address)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate a Sui address format
|
|
38
|
+
*/
|
|
39
|
+
export function isValidSuiAddress(address) {
|
|
40
|
+
return /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate a Stellar address format
|
|
44
|
+
*
|
|
45
|
+
* Supports both:
|
|
46
|
+
* - Standard account ID (G...)
|
|
47
|
+
* - Asset identifier (CODE:ISSUER)
|
|
48
|
+
*/
|
|
49
|
+
export function isValidStellarAddress(address) {
|
|
50
|
+
// Standard Stellar account ID
|
|
51
|
+
if (/^G[A-Z2-7]{55}$/.test(address)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
// Asset identifier (CODE:ISSUER)
|
|
55
|
+
if (/^[A-Za-z0-9]{1,12}:G[A-Z2-7]{55}$/.test(address)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validate an address for a specific chain
|
|
62
|
+
*
|
|
63
|
+
* @param address - The address to validate
|
|
64
|
+
* @param chain - The blockchain to validate against
|
|
65
|
+
* @returns true if the address is valid for the chain
|
|
66
|
+
*/
|
|
67
|
+
export function isValidAddress(address, chain) {
|
|
68
|
+
if (!address || typeof address !== 'string') {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (isEvmChain(chain)) {
|
|
72
|
+
return isValidEvmAddress(address);
|
|
73
|
+
}
|
|
74
|
+
switch (chain) {
|
|
75
|
+
case Chain.SOL:
|
|
76
|
+
return isValidSolanaAddress(address);
|
|
77
|
+
case Chain.BTC:
|
|
78
|
+
return isValidBitcoinAddress(address);
|
|
79
|
+
case Chain.TON:
|
|
80
|
+
return isValidTonAddress(address);
|
|
81
|
+
case Chain.SUI:
|
|
82
|
+
return isValidSuiAddress(address);
|
|
83
|
+
case Chain.STELLAR:
|
|
84
|
+
return isValidStellarAddress(address);
|
|
85
|
+
default:
|
|
86
|
+
// Unknown chain, allow any non-empty string
|
|
87
|
+
return address.length > 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Normalize an EVM address to checksum format
|
|
92
|
+
*/
|
|
93
|
+
export function normalizeEvmAddress(address) {
|
|
94
|
+
if (!isValidEvmAddress(address)) {
|
|
95
|
+
throw new Error(`Invalid EVM address: ${address}`);
|
|
96
|
+
}
|
|
97
|
+
return address.toLowerCase();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Normalize an address for a specific chain
|
|
101
|
+
*
|
|
102
|
+
* @param address - The address to normalize
|
|
103
|
+
* @param chain - The blockchain
|
|
104
|
+
* @returns The normalized address
|
|
105
|
+
*/
|
|
106
|
+
export function normalizeAddress(address, chain) {
|
|
107
|
+
if (isEvmChain(chain)) {
|
|
108
|
+
return normalizeEvmAddress(address);
|
|
109
|
+
}
|
|
110
|
+
// For non-EVM chains, return as-is
|
|
111
|
+
return address;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=address-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-validation.js","sourceRoot":"","sources":["../../../src/utils/address-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,uCAAuC;IACvC,OAAO,+BAA+B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,wEAAwE;IACxE,OAAO,mCAAmC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACnG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,2CAA2C;IAC3C,IAAI,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,gCAAgC;IAChC,IAAI,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,8BAA8B;IAC9B,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,iCAAiC;IACjC,IAAI,mCAAmC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,KAAY;IAC1D,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,KAAK,CAAC,GAAG;YACZ,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACvC,KAAK,KAAK,CAAC,GAAG;YACZ,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,KAAK,CAAC,GAAG;YACZ,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,KAAK,CAAC,GAAG;YACZ,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,KAAK,CAAC,OAAO;YAChB,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC;YACE,4CAA4C;YAC5C,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,KAAY;IAC5D,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,mCAAmC;IACnC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { WebacyClientConfig } from './config';
|
|
2
|
+
import { HttpClient, HttpResponse, RequestInterceptor, ResponseInterceptor, ErrorInterceptor } from './http';
|
|
3
|
+
import { Chain } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Base client class for Webacy SDK
|
|
6
|
+
*
|
|
7
|
+
* Provides shared functionality for all Webacy client implementations
|
|
8
|
+
* including HTTP client setup, authentication, and interceptors.
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class BaseClient {
|
|
11
|
+
protected readonly httpClient: HttpClient;
|
|
12
|
+
protected readonly config: Required<Pick<WebacyClientConfig, 'baseUrl' | 'apiVersion' | 'timeout'>> & WebacyClientConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Default chain to use when chain is not specified in API calls
|
|
15
|
+
*/
|
|
16
|
+
readonly defaultChain?: Chain;
|
|
17
|
+
constructor(config: WebacyClientConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Add a request interceptor
|
|
20
|
+
*
|
|
21
|
+
* Request interceptors are called before each request is sent.
|
|
22
|
+
* Use them to modify requests, add headers, or log requests.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* client.addRequestInterceptor((url, config) => {
|
|
27
|
+
* console.log(`Making request to ${url}`);
|
|
28
|
+
* return config;
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
addRequestInterceptor(interceptor: RequestInterceptor): void;
|
|
33
|
+
/**
|
|
34
|
+
* Add a response interceptor
|
|
35
|
+
*
|
|
36
|
+
* Response interceptors are called after each successful response.
|
|
37
|
+
* Use them to transform responses or log data.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* client.addResponseInterceptor((response) => {
|
|
42
|
+
* console.log(`Received ${response.status} response`);
|
|
43
|
+
* return response;
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
addResponseInterceptor(interceptor: ResponseInterceptor): void;
|
|
48
|
+
/**
|
|
49
|
+
* Add an error interceptor
|
|
50
|
+
*
|
|
51
|
+
* Error interceptors are called when a request fails.
|
|
52
|
+
* Use them to handle errors globally or transform error types.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* client.addErrorInterceptor((error) => {
|
|
57
|
+
* if (error instanceof RateLimitError) {
|
|
58
|
+
* console.warn('Rate limited, will retry...');
|
|
59
|
+
* }
|
|
60
|
+
* return error;
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
addErrorInterceptor(interceptor: ErrorInterceptor): void;
|
|
65
|
+
/**
|
|
66
|
+
* Make a GET request
|
|
67
|
+
*/
|
|
68
|
+
protected get<T>(path: string, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
69
|
+
/**
|
|
70
|
+
* Make a POST request
|
|
71
|
+
*/
|
|
72
|
+
protected post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
73
|
+
/**
|
|
74
|
+
* Make a PUT request
|
|
75
|
+
*/
|
|
76
|
+
protected put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
77
|
+
/**
|
|
78
|
+
* Make a DELETE request
|
|
79
|
+
*/
|
|
80
|
+
protected delete<T>(path: string, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
81
|
+
/**
|
|
82
|
+
* Build query string from parameters
|
|
83
|
+
*/
|
|
84
|
+
protected buildQueryString(params: Record<string, unknown>): string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for protected request methods
|
|
88
|
+
*/
|
|
89
|
+
interface RequestOptions {
|
|
90
|
+
timeout?: number;
|
|
91
|
+
signal?: AbortSignal;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=client-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-base.d.ts","sourceRoot":"","sources":["../../src/client-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgC,MAAM,UAAU,CAAC;AAC5E,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;GAKG;AACH,8BAAsB,UAAU;IAC9B,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CACjC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC,CAC/D,GACC,kBAAkB,CAAC;IAErB;;OAEG;IACH,SAAgB,YAAY,CAAC,EAAE,KAAK,CAAC;gBAEzB,MAAM,EAAE,kBAAkB;IA2BtC;;;;;;;;;;;;;OAaG;IACH,qBAAqB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI;IAI5D;;;;;;;;;;;;;OAaG;IACH,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,GAAG,IAAI;IAI9D;;;;;;;;;;;;;;;OAeG;IACH,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI;IAIxD;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAOlF;;OAEG;IACH,SAAS,CAAC,IAAI,CAAC,CAAC,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAO3B;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,CAAC,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAO3B;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAOrF;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;CAoBpE;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { RetryConfig } from './http/retry';
|
|
2
|
+
/**
|
|
3
|
+
* Debug mode options
|
|
4
|
+
*/
|
|
5
|
+
export type DebugMode = boolean | 'requests' | 'responses' | 'errors' | 'all';
|
|
6
|
+
/**
|
|
7
|
+
* Logger interface for custom logging implementations
|
|
8
|
+
*/
|
|
9
|
+
export interface Logger {
|
|
10
|
+
debug(message: string, data?: unknown): void;
|
|
11
|
+
info(message: string, data?: unknown): void;
|
|
12
|
+
warn(message: string, data?: unknown): void;
|
|
13
|
+
error(message: string, data?: unknown): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Default console logger implementation
|
|
17
|
+
*/
|
|
18
|
+
export declare const defaultLogger: Logger;
|
|
19
|
+
/**
|
|
20
|
+
* Webacy client configuration options
|
|
21
|
+
*/
|
|
22
|
+
export interface WebacyClientConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Your Webacy API key
|
|
25
|
+
* @required
|
|
26
|
+
*/
|
|
27
|
+
apiKey: string;
|
|
28
|
+
/**
|
|
29
|
+
* Base URL for the API
|
|
30
|
+
* @default 'https://api.webacy.com'
|
|
31
|
+
*/
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
/**
|
|
34
|
+
* API version to use
|
|
35
|
+
* @default 'v2'
|
|
36
|
+
*/
|
|
37
|
+
apiVersion?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Default request timeout in milliseconds
|
|
40
|
+
* @default 30000
|
|
41
|
+
*/
|
|
42
|
+
timeout?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Retry configuration for failed requests
|
|
45
|
+
*/
|
|
46
|
+
retry?: Partial<RetryConfig>;
|
|
47
|
+
/**
|
|
48
|
+
* Custom headers to include with all requests
|
|
49
|
+
*/
|
|
50
|
+
headers?: Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Enable debug logging
|
|
53
|
+
*
|
|
54
|
+
* - `true` or `'all'`: Log requests, responses, and errors
|
|
55
|
+
* - `'requests'`: Log only outgoing requests
|
|
56
|
+
* - `'responses'`: Log only incoming responses
|
|
57
|
+
* - `'errors'`: Log only errors
|
|
58
|
+
* - `false`: Disable logging (default)
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const client = new WebacyClient({
|
|
65
|
+
* apiKey: 'your-api-key',
|
|
66
|
+
* debug: true, // Enable full debug logging
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
debug?: DebugMode;
|
|
71
|
+
/**
|
|
72
|
+
* Custom logger instance
|
|
73
|
+
*
|
|
74
|
+
* Provide your own logger implementation (e.g., winston, pino)
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* import pino from 'pino';
|
|
79
|
+
*
|
|
80
|
+
* const client = new WebacyClient({
|
|
81
|
+
* apiKey: 'your-api-key',
|
|
82
|
+
* debug: true,
|
|
83
|
+
* logger: pino({ level: 'debug' }),
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
logger?: Logger;
|
|
88
|
+
/**
|
|
89
|
+
* Default blockchain to use when chain is not specified
|
|
90
|
+
*
|
|
91
|
+
* When set, you can omit the `chain` parameter on API calls
|
|
92
|
+
* and this chain will be used automatically.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* import { Chain } from '@rlajous/sdk';
|
|
97
|
+
*
|
|
98
|
+
* const client = new WebacyClient({
|
|
99
|
+
* apiKey: 'your-api-key',
|
|
100
|
+
* defaultChain: Chain.ETH,
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // No need to specify chain - uses ETH by default
|
|
104
|
+
* const risk = await client.threat.addresses.analyze('0x...');
|
|
105
|
+
*
|
|
106
|
+
* // Can still override for specific calls
|
|
107
|
+
* const solRisk = await client.threat.addresses.analyze('...', { chain: Chain.SOL });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
defaultChain?: import('./types').Chain;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Default API configuration
|
|
114
|
+
*/
|
|
115
|
+
export declare const DEFAULT_CONFIG: {
|
|
116
|
+
readonly baseUrl: "https://api.webacy.com";
|
|
117
|
+
readonly apiVersion: "v2";
|
|
118
|
+
readonly timeout: 30000;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Build the full base URL from configuration
|
|
122
|
+
*/
|
|
123
|
+
export declare function buildBaseUrl(config: WebacyClientConfig): string;
|
|
124
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAK3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,CAAC,EAAE,OAAO,SAAS,EAAE,KAAK,CAAC;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAI/D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WebacyError } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when API key is invalid or missing
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* try {
|
|
8
|
+
* await client.addresses.analyze(address, { chain: Chain.ETH });
|
|
9
|
+
* } catch (error) {
|
|
10
|
+
* if (error instanceof AuthenticationError) {
|
|
11
|
+
* console.error('Authentication failed:', error.message);
|
|
12
|
+
* console.error('Suggestion:', error.getRecoverySuggestion());
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class AuthenticationError extends WebacyError {
|
|
18
|
+
constructor(message?: string, options?: {
|
|
19
|
+
requestId?: string;
|
|
20
|
+
endpoint?: string;
|
|
21
|
+
});
|
|
22
|
+
getRecoverySuggestion(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=authentication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../../src/errors/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;gBAEhD,OAAO,SAA+B,EACtC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAWhD,qBAAqB,IAAI,MAAM;CAGzC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Webacy SDK errors
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* try {
|
|
7
|
+
* await client.addresses.analyze(address, { chain: Chain.ETH });
|
|
8
|
+
* } catch (error) {
|
|
9
|
+
* if (error instanceof WebacyError) {
|
|
10
|
+
* console.error(`Error: ${error.message}`);
|
|
11
|
+
* console.error(`Code: ${error.code}`);
|
|
12
|
+
* if (error.endpoint) {
|
|
13
|
+
* console.error(`Endpoint: ${error.endpoint}`);
|
|
14
|
+
* }
|
|
15
|
+
* if (error.requestId) {
|
|
16
|
+
* console.error(`Request ID: ${error.requestId} (include this when contacting support)`);
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class WebacyError extends Error {
|
|
23
|
+
/** HTTP status code if applicable */
|
|
24
|
+
readonly status?: number;
|
|
25
|
+
/** Error code for programmatic handling */
|
|
26
|
+
readonly code: string;
|
|
27
|
+
/** Original error if wrapped */
|
|
28
|
+
readonly cause?: Error;
|
|
29
|
+
/** Request ID for support inquiries */
|
|
30
|
+
readonly requestId?: string;
|
|
31
|
+
/** API endpoint that failed (for debugging) */
|
|
32
|
+
readonly endpoint?: string;
|
|
33
|
+
constructor(message: string, options: {
|
|
34
|
+
status?: number;
|
|
35
|
+
code: string;
|
|
36
|
+
cause?: Error;
|
|
37
|
+
requestId?: string;
|
|
38
|
+
endpoint?: string;
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Check if this error is retryable
|
|
42
|
+
*/
|
|
43
|
+
isRetryable(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Convert to JSON for logging
|
|
46
|
+
*/
|
|
47
|
+
toJSON(): Record<string, unknown>;
|
|
48
|
+
/**
|
|
49
|
+
* Get a user-friendly description of how to resolve this error
|
|
50
|
+
*/
|
|
51
|
+
getRecoverySuggestion(): string | undefined;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/errors/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,qCAAqC;IACrC,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhC,2CAA2C;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,gCAAgC;IAChC,SAAgB,KAAK,CAAC,EAAE,KAAK,CAAC;IAE9B,uCAAuC;IACvC,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnC,+CAA+C;IAC/C,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAgBH;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWjC;;OAEG;IACH,qBAAqB,IAAI,MAAM,GAAG,SAAS;CAG5C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { WebacyError } from './base';
|
|
2
|
+
export { AuthenticationError } from './authentication';
|
|
3
|
+
export { RateLimitError } from './rate-limit';
|
|
4
|
+
export { ValidationError } from './validation';
|
|
5
|
+
export { NotFoundError } from './not-found';
|
|
6
|
+
export { NetworkError } from './network';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WebacyError } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a network error occurs
|
|
4
|
+
*
|
|
5
|
+
* This includes timeouts, connection failures, and other transport-level errors.
|
|
6
|
+
* The SDK automatically retries network errors with exponential backoff.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* await client.addresses.analyze(address, { chain: Chain.ETH });
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* if (error instanceof NetworkError) {
|
|
14
|
+
* console.error('Network error:', error.message);
|
|
15
|
+
* if (error.cause) {
|
|
16
|
+
* console.error('Cause:', error.cause.message);
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class NetworkError extends WebacyError {
|
|
23
|
+
constructor(message?: string, options?: {
|
|
24
|
+
cause?: Error;
|
|
25
|
+
endpoint?: string;
|
|
26
|
+
});
|
|
27
|
+
isRetryable(): boolean;
|
|
28
|
+
getRecoverySuggestion(): string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/errors/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,YAAa,SAAQ,WAAW;gBAEzC,OAAO,SAA2B,EAClC,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAU3C,WAAW,IAAI,OAAO;IAItB,qBAAqB,IAAI,MAAM;CAMzC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WebacyError } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a resource is not found
|
|
4
|
+
*
|
|
5
|
+
* This typically means the address or resource doesn't exist on the specified chain,
|
|
6
|
+
* or hasn't been indexed yet.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* await client.addresses.analyze(address, { chain: Chain.ETH });
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* if (error instanceof NotFoundError) {
|
|
14
|
+
* console.error('Resource not found:', error.message);
|
|
15
|
+
* // The address may not exist or may not have any activity
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class NotFoundError extends WebacyError {
|
|
21
|
+
constructor(message?: string, options?: {
|
|
22
|
+
requestId?: string;
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
});
|
|
25
|
+
getRecoverySuggestion(): string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=not-found.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found.d.ts","sourceRoot":"","sources":["../../../src/errors/not-found.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAc,SAAQ,WAAW;gBAE1C,OAAO,SAAuB,EAC9B,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAWhD,qBAAqB,IAAI,MAAM;CAGzC"}
|