@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,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenStandard = exports.TypeOfAddress = exports.RiskLevel = exports.RiskScore = exports.RiskModule = exports.CHAIN_NAMES = exports.CHAIN_IDS = exports.isEvmChain = exports.getChainCompatibility = exports.ChainCompatibility = exports.Chain = void 0;
|
|
4
|
+
var chain_1 = require("./chain");
|
|
5
|
+
Object.defineProperty(exports, "Chain", { enumerable: true, get: function () { return chain_1.Chain; } });
|
|
6
|
+
Object.defineProperty(exports, "ChainCompatibility", { enumerable: true, get: function () { return chain_1.ChainCompatibility; } });
|
|
7
|
+
Object.defineProperty(exports, "getChainCompatibility", { enumerable: true, get: function () { return chain_1.getChainCompatibility; } });
|
|
8
|
+
Object.defineProperty(exports, "isEvmChain", { enumerable: true, get: function () { return chain_1.isEvmChain; } });
|
|
9
|
+
Object.defineProperty(exports, "CHAIN_IDS", { enumerable: true, get: function () { return chain_1.CHAIN_IDS; } });
|
|
10
|
+
Object.defineProperty(exports, "CHAIN_NAMES", { enumerable: true, get: function () { return chain_1.CHAIN_NAMES; } });
|
|
11
|
+
var modules_1 = require("./modules");
|
|
12
|
+
Object.defineProperty(exports, "RiskModule", { enumerable: true, get: function () { return modules_1.RiskModule; } });
|
|
13
|
+
var common_1 = require("./common");
|
|
14
|
+
Object.defineProperty(exports, "RiskScore", { enumerable: true, get: function () { return common_1.RiskScore; } });
|
|
15
|
+
Object.defineProperty(exports, "RiskLevel", { enumerable: true, get: function () { return common_1.RiskLevel; } });
|
|
16
|
+
Object.defineProperty(exports, "TypeOfAddress", { enumerable: true, get: function () { return common_1.TypeOfAddress; } });
|
|
17
|
+
Object.defineProperty(exports, "TokenStandard", { enumerable: true, get: function () { return common_1.TokenStandard; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,iCAOiB;AANf,8FAAA,KAAK,OAAA;AACL,2GAAA,kBAAkB,OAAA;AAClB,8GAAA,qBAAqB,OAAA;AACrB,mGAAA,UAAU,OAAA;AACV,kGAAA,SAAS,OAAA;AACT,oGAAA,WAAW,OAAA;AAGb,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAoBnB,mCAA8E;AAArE,mGAAA,SAAS,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,uGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RiskModule = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Risk analysis modules available for requests
|
|
6
|
+
*
|
|
7
|
+
* Use these to specify which analysis modules to run when making API requests.
|
|
8
|
+
* Requesting fewer modules can improve response time.
|
|
9
|
+
*/
|
|
10
|
+
var RiskModule;
|
|
11
|
+
(function (RiskModule) {
|
|
12
|
+
// Core security analysis
|
|
13
|
+
/** Contract ownership, upgradeability, access controls */
|
|
14
|
+
RiskModule["GOVERNANCE_ANALYSIS"] = "governance_analysis";
|
|
15
|
+
/** Freezeable, mintable, blacklist, whitelist */
|
|
16
|
+
RiskModule["TOKEN_SECURITY"] = "token_security";
|
|
17
|
+
/** Static/dynamic code analysis, vulnerabilities */
|
|
18
|
+
RiskModule["CONTRACT_ANALYSIS"] = "contract_analysis";
|
|
19
|
+
/** Source code analysis, vulnerabilities */
|
|
20
|
+
RiskModule["SOURCE_CODE_ANALYSIS"] = "source_code_analysis";
|
|
21
|
+
// Financial risk analysis
|
|
22
|
+
/** Price, volatility, market cap, liquidity */
|
|
23
|
+
RiskModule["MARKET_DATA"] = "market_data";
|
|
24
|
+
/** Token distribution, concentration risks */
|
|
25
|
+
RiskModule["HOLDER_ANALYSIS"] = "holder_analysis";
|
|
26
|
+
/** Pool data, unlock schedules, LP analysis */
|
|
27
|
+
RiskModule["LIQUIDITY_ANALYSIS"] = "liquidity_analysis";
|
|
28
|
+
// Fraud and compliance
|
|
29
|
+
/** Hacker, drainer, rugpull detection */
|
|
30
|
+
RiskModule["FRAUD_DETECTION"] = "fraud_detection";
|
|
31
|
+
/** OFAC, sanctioned addresses */
|
|
32
|
+
RiskModule["SANCTIONS_COMPLIANCE"] = "sanctions_compliance";
|
|
33
|
+
/** Tornado cash, coin mixers */
|
|
34
|
+
RiskModule["MIXER_DETECTION"] = "mixer_detection";
|
|
35
|
+
// Address behavior analysis
|
|
36
|
+
/** Trading patterns, automated trading */
|
|
37
|
+
RiskModule["ADDRESS_BEHAVIOR"] = "address_behavior";
|
|
38
|
+
/** Address poisoning, wash trading */
|
|
39
|
+
RiskModule["TRANSACTION_ANALYSIS"] = "transaction_analysis";
|
|
40
|
+
/** Reported addresses, spam detection */
|
|
41
|
+
RiskModule["REPUTATION_ANALYSIS"] = "reputation_analysis";
|
|
42
|
+
// Chain-specific analysis
|
|
43
|
+
/** Solana-only risks (bundling, sniping) */
|
|
44
|
+
RiskModule["SOLANA_SPECIFIC"] = "solana_specific";
|
|
45
|
+
/** EVM-only risks (gas optimization, MEV) */
|
|
46
|
+
RiskModule["EVM_SPECIFIC"] = "evm_specific";
|
|
47
|
+
/** TON-only risks (jetton standards, etc.) */
|
|
48
|
+
RiskModule["TON_SPECIFIC"] = "ton_specific";
|
|
49
|
+
/** SUI-only risks (coin standards, object model) */
|
|
50
|
+
RiskModule["SUI_SPECIFIC"] = "sui_specific";
|
|
51
|
+
// Basic metadata (always fast)
|
|
52
|
+
/** Address type, age, balance checks */
|
|
53
|
+
RiskModule["BASIC_INFO"] = "basic_info";
|
|
54
|
+
// Ultra-fast module for core security flags
|
|
55
|
+
/** Only is_mintable, freezeable, is_metadata_immutable */
|
|
56
|
+
RiskModule["SECURITY_ESSENTIALS"] = "security_essentials";
|
|
57
|
+
// Fast fund flow screening with boolean indicators
|
|
58
|
+
/** Boolean flags for OFAC, hacker, mixer, drainer risks */
|
|
59
|
+
RiskModule["FUND_FLOW_SCREENING"] = "fund_flow_screening";
|
|
60
|
+
// Developer behavior and migration pattern analysis
|
|
61
|
+
/** Multi-platform developer behavior, token launch patterns */
|
|
62
|
+
RiskModule["DEVELOPER_MIGRATION"] = "developer_migration";
|
|
63
|
+
})(RiskModule || (exports.RiskModule = RiskModule = {}));
|
|
64
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/types/modules.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,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,0BAAV,UAAU,QA4DrB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidEvmAddress = isValidEvmAddress;
|
|
4
|
+
exports.isValidSolanaAddress = isValidSolanaAddress;
|
|
5
|
+
exports.isValidBitcoinAddress = isValidBitcoinAddress;
|
|
6
|
+
exports.isValidTonAddress = isValidTonAddress;
|
|
7
|
+
exports.isValidSuiAddress = isValidSuiAddress;
|
|
8
|
+
exports.isValidStellarAddress = isValidStellarAddress;
|
|
9
|
+
exports.isValidAddress = isValidAddress;
|
|
10
|
+
exports.normalizeEvmAddress = normalizeEvmAddress;
|
|
11
|
+
exports.normalizeAddress = normalizeAddress;
|
|
12
|
+
const types_1 = require("../types");
|
|
13
|
+
/**
|
|
14
|
+
* Validate an Ethereum address format
|
|
15
|
+
*/
|
|
16
|
+
function isValidEvmAddress(address) {
|
|
17
|
+
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate a Solana address format (base58)
|
|
21
|
+
*/
|
|
22
|
+
function isValidSolanaAddress(address) {
|
|
23
|
+
// Base58 character set (no 0, O, I, l)
|
|
24
|
+
return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate a Bitcoin address format
|
|
28
|
+
*/
|
|
29
|
+
function isValidBitcoinAddress(address) {
|
|
30
|
+
// P2PKH (starts with 1), P2SH (starts with 3), Bech32 (starts with bc1)
|
|
31
|
+
return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/.test(address) || /^bc1[a-z0-9]{39,59}$/.test(address);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validate a TON address format
|
|
35
|
+
*/
|
|
36
|
+
function isValidTonAddress(address) {
|
|
37
|
+
// Raw format (48 bytes hex with workchain)
|
|
38
|
+
if (/^-?\d:[a-fA-F0-9]{64}$/.test(address)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
// User-friendly format (base64)
|
|
42
|
+
if (/^[A-Za-z0-9_-]{48}$/.test(address)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validate a Sui address format
|
|
49
|
+
*/
|
|
50
|
+
function isValidSuiAddress(address) {
|
|
51
|
+
return /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Validate a Stellar address format
|
|
55
|
+
*
|
|
56
|
+
* Supports both:
|
|
57
|
+
* - Standard account ID (G...)
|
|
58
|
+
* - Asset identifier (CODE:ISSUER)
|
|
59
|
+
*/
|
|
60
|
+
function isValidStellarAddress(address) {
|
|
61
|
+
// Standard Stellar account ID
|
|
62
|
+
if (/^G[A-Z2-7]{55}$/.test(address)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
// Asset identifier (CODE:ISSUER)
|
|
66
|
+
if (/^[A-Za-z0-9]{1,12}:G[A-Z2-7]{55}$/.test(address)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate an address for a specific chain
|
|
73
|
+
*
|
|
74
|
+
* @param address - The address to validate
|
|
75
|
+
* @param chain - The blockchain to validate against
|
|
76
|
+
* @returns true if the address is valid for the chain
|
|
77
|
+
*/
|
|
78
|
+
function isValidAddress(address, chain) {
|
|
79
|
+
if (!address || typeof address !== 'string') {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if ((0, types_1.isEvmChain)(chain)) {
|
|
83
|
+
return isValidEvmAddress(address);
|
|
84
|
+
}
|
|
85
|
+
switch (chain) {
|
|
86
|
+
case types_1.Chain.SOL:
|
|
87
|
+
return isValidSolanaAddress(address);
|
|
88
|
+
case types_1.Chain.BTC:
|
|
89
|
+
return isValidBitcoinAddress(address);
|
|
90
|
+
case types_1.Chain.TON:
|
|
91
|
+
return isValidTonAddress(address);
|
|
92
|
+
case types_1.Chain.SUI:
|
|
93
|
+
return isValidSuiAddress(address);
|
|
94
|
+
case types_1.Chain.STELLAR:
|
|
95
|
+
return isValidStellarAddress(address);
|
|
96
|
+
default:
|
|
97
|
+
// Unknown chain, allow any non-empty string
|
|
98
|
+
return address.length > 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Normalize an EVM address to checksum format
|
|
103
|
+
*/
|
|
104
|
+
function normalizeEvmAddress(address) {
|
|
105
|
+
if (!isValidEvmAddress(address)) {
|
|
106
|
+
throw new Error(`Invalid EVM address: ${address}`);
|
|
107
|
+
}
|
|
108
|
+
return address.toLowerCase();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Normalize an address for a specific chain
|
|
112
|
+
*
|
|
113
|
+
* @param address - The address to normalize
|
|
114
|
+
* @param chain - The blockchain
|
|
115
|
+
* @returns The normalized address
|
|
116
|
+
*/
|
|
117
|
+
function normalizeAddress(address, chain) {
|
|
118
|
+
if ((0, types_1.isEvmChain)(chain)) {
|
|
119
|
+
return normalizeEvmAddress(address);
|
|
120
|
+
}
|
|
121
|
+
// For non-EVM chains, return as-is
|
|
122
|
+
return address;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=address-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-validation.js","sourceRoot":"","sources":["../../../src/utils/address-validation.ts"],"names":[],"mappings":";;AAKA,8CAEC;AAKD,oDAGC;AAKD,sDAGC;AAKD,8CAUC;AAKD,8CAEC;AASD,sDAUC;AASD,wCAwBC;AAKD,kDAKC;AASD,4CAMC;AA1HD,oCAA6C;AAE7C;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,uCAAuC;IACvC,OAAO,+BAA+B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CA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AC,CAAC;QACvC,KAAK,aAAK,CAAC,GAAG;YACZ,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,aAAK,CAAC,GAAG;YACZ,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,aAAK,CAAC,GAAG;YACZ,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,aAAK,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,SAAgB,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,SAAgB,gBAAgB,CAAC,OAAe,EAAE,KAAY;IAC5D,IAAI,IAAA,kBAAU,EAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,mCAAmC;IACnC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeEvmAddress = exports.normalizeAddress = exports.isValidStellarAddress = exports.isValidSuiAddress = exports.isValidTonAddress = exports.isValidBitcoinAddress = exports.isValidSolanaAddress = exports.isValidEvmAddress = exports.isValidAddress = void 0;
|
|
4
|
+
var address_validation_1 = require("./address-validation");
|
|
5
|
+
Object.defineProperty(exports, "isValidAddress", { enumerable: true, get: function () { return address_validation_1.isValidAddress; } });
|
|
6
|
+
Object.defineProperty(exports, "isValidEvmAddress", { enumerable: true, get: function () { return address_validation_1.isValidEvmAddress; } });
|
|
7
|
+
Object.defineProperty(exports, "isValidSolanaAddress", { enumerable: true, get: function () { return address_validation_1.isValidSolanaAddress; } });
|
|
8
|
+
Object.defineProperty(exports, "isValidBitcoinAddress", { enumerable: true, get: function () { return address_validation_1.isValidBitcoinAddress; } });
|
|
9
|
+
Object.defineProperty(exports, "isValidTonAddress", { enumerable: true, get: function () { return address_validation_1.isValidTonAddress; } });
|
|
10
|
+
Object.defineProperty(exports, "isValidSuiAddress", { enumerable: true, get: function () { return address_validation_1.isValidSuiAddress; } });
|
|
11
|
+
Object.defineProperty(exports, "isValidStellarAddress", { enumerable: true, get: function () { return address_validation_1.isValidStellarAddress; } });
|
|
12
|
+
Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function () { return address_validation_1.normalizeAddress; } });
|
|
13
|
+
Object.defineProperty(exports, "normalizeEvmAddress", { enumerable: true, get: function () { return address_validation_1.normalizeEvmAddress; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2DAU8B;AAT5B,oHAAA,cAAc,OAAA;AACd,uHAAA,iBAAiB,OAAA;AACjB,0HAAA,oBAAoB,OAAA;AACpB,2HAAA,qBAAqB,OAAA;AACrB,uHAAA,iBAAiB,OAAA;AACjB,uHAAA,iBAAiB,OAAA;AACjB,2HAAA,qBAAqB,OAAA;AACrB,sHAAA,gBAAgB,OAAA;AAChB,yHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG, buildBaseUrl } from './config';
|
|
2
|
+
import { HttpClient, } from './http';
|
|
3
|
+
import { AuthenticationError } from './errors';
|
|
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 class BaseClient {
|
|
11
|
+
httpClient;
|
|
12
|
+
config;
|
|
13
|
+
/**
|
|
14
|
+
* Default chain to use when chain is not specified in API calls
|
|
15
|
+
*/
|
|
16
|
+
defaultChain;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
if (!config.apiKey) {
|
|
19
|
+
throw new AuthenticationError('API key is required');
|
|
20
|
+
}
|
|
21
|
+
this.config = {
|
|
22
|
+
...config,
|
|
23
|
+
baseUrl: config.baseUrl ?? DEFAULT_CONFIG.baseUrl,
|
|
24
|
+
apiVersion: config.apiVersion ?? DEFAULT_CONFIG.apiVersion,
|
|
25
|
+
timeout: config.timeout ?? DEFAULT_CONFIG.timeout,
|
|
26
|
+
};
|
|
27
|
+
this.defaultChain = config.defaultChain;
|
|
28
|
+
this.httpClient = new HttpClient({
|
|
29
|
+
baseUrl: buildBaseUrl(this.config),
|
|
30
|
+
timeout: this.config.timeout,
|
|
31
|
+
retry: config.retry,
|
|
32
|
+
debug: config.debug,
|
|
33
|
+
logger: config.logger,
|
|
34
|
+
headers: {
|
|
35
|
+
'x-api-key': config.apiKey,
|
|
36
|
+
...config.headers,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Add a request interceptor
|
|
42
|
+
*
|
|
43
|
+
* Request interceptors are called before each request is sent.
|
|
44
|
+
* Use them to modify requests, add headers, or log requests.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* client.addRequestInterceptor((url, config) => {
|
|
49
|
+
* console.log(`Making request to ${url}`);
|
|
50
|
+
* return config;
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
addRequestInterceptor(interceptor) {
|
|
55
|
+
this.httpClient.addRequestInterceptor(interceptor);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Add a response interceptor
|
|
59
|
+
*
|
|
60
|
+
* Response interceptors are called after each successful response.
|
|
61
|
+
* Use them to transform responses or log data.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* client.addResponseInterceptor((response) => {
|
|
66
|
+
* console.log(`Received ${response.status} response`);
|
|
67
|
+
* return response;
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
addResponseInterceptor(interceptor) {
|
|
72
|
+
this.httpClient.addResponseInterceptor(interceptor);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add an error interceptor
|
|
76
|
+
*
|
|
77
|
+
* Error interceptors are called when a request fails.
|
|
78
|
+
* Use them to handle errors globally or transform error types.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* client.addErrorInterceptor((error) => {
|
|
83
|
+
* if (error instanceof RateLimitError) {
|
|
84
|
+
* console.warn('Rate limited, will retry...');
|
|
85
|
+
* }
|
|
86
|
+
* return error;
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
addErrorInterceptor(interceptor) {
|
|
91
|
+
this.httpClient.addErrorInterceptor(interceptor);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Make a GET request
|
|
95
|
+
*/
|
|
96
|
+
get(path, options) {
|
|
97
|
+
return this.httpClient.get(path, {
|
|
98
|
+
timeout: options?.timeout,
|
|
99
|
+
signal: options?.signal,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Make a POST request
|
|
104
|
+
*/
|
|
105
|
+
post(path, body, options) {
|
|
106
|
+
return this.httpClient.post(path, body, {
|
|
107
|
+
timeout: options?.timeout,
|
|
108
|
+
signal: options?.signal,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Make a PUT request
|
|
113
|
+
*/
|
|
114
|
+
put(path, body, options) {
|
|
115
|
+
return this.httpClient.put(path, body, {
|
|
116
|
+
timeout: options?.timeout,
|
|
117
|
+
signal: options?.signal,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Make a DELETE request
|
|
122
|
+
*/
|
|
123
|
+
delete(path, options) {
|
|
124
|
+
return this.httpClient.delete(path, {
|
|
125
|
+
timeout: options?.timeout,
|
|
126
|
+
signal: options?.signal,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Build query string from parameters
|
|
131
|
+
*/
|
|
132
|
+
buildQueryString(params) {
|
|
133
|
+
const searchParams = new URLSearchParams();
|
|
134
|
+
for (const [key, value] of Object.entries(params)) {
|
|
135
|
+
if (value === undefined || value === null) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (Array.isArray(value)) {
|
|
139
|
+
for (const item of value) {
|
|
140
|
+
searchParams.append(key, String(item));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
searchParams.append(key, String(value));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const queryString = searchParams.toString();
|
|
148
|
+
return queryString ? `?${queryString}` : '';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=client-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-base.js","sourceRoot":"","sources":["../../src/client-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EACL,UAAU,GAKX,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C;;;;;GAKG;AACH,MAAM,OAAgB,UAAU;IACX,UAAU,CAAa;IACvB,MAAM,CAGJ;IAErB;;OAEG;IACa,YAAY,CAAS;IAErC,YAAY,MAA0B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AAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;QAED,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC5C,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default console logger implementation
|
|
3
|
+
*/
|
|
4
|
+
export const defaultLogger = {
|
|
5
|
+
debug: (message, data) => console.debug(`[Webacy SDK] ${message}`, data ?? ''),
|
|
6
|
+
info: (message, data) => console.info(`[Webacy SDK] ${message}`, data ?? ''),
|
|
7
|
+
warn: (message, data) => console.warn(`[Webacy SDK] ${message}`, data ?? ''),
|
|
8
|
+
error: (message, data) => console.error(`[Webacy SDK] ${message}`, data ?? ''),
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Default API configuration
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_CONFIG = {
|
|
14
|
+
baseUrl: 'https://api.webacy.com',
|
|
15
|
+
apiVersion: 'v2',
|
|
16
|
+
timeout: 30000,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Build the full base URL from configuration
|
|
20
|
+
*/
|
|
21
|
+
export function buildBaseUrl(config) {
|
|
22
|
+
const baseUrl = config.baseUrl ?? DEFAULT_CONFIG.baseUrl;
|
|
23
|
+
// API doesn't need /api/v2 prefix - endpoints are directly on base URL
|
|
24
|
+
return baseUrl.replace(/\/$/, '');
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;IAC9E,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;IAC5E,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;IAC5E,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;CAC/E,CAAC;AAwGF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,wBAAwB;IACjC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,KAAK;CACN,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC;IACzD,uEAAuE;IACvE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 class AuthenticationError extends WebacyError {
|
|
18
|
+
constructor(message = 'Invalid or missing API key', options = {}) {
|
|
19
|
+
super(message, {
|
|
20
|
+
status: 401,
|
|
21
|
+
code: 'AUTHENTICATION_ERROR',
|
|
22
|
+
requestId: options.requestId,
|
|
23
|
+
endpoint: options.endpoint,
|
|
24
|
+
});
|
|
25
|
+
this.name = 'AuthenticationError';
|
|
26
|
+
}
|
|
27
|
+
getRecoverySuggestion() {
|
|
28
|
+
return 'Verify your API key is correct and has not expired. You can get a new API key from the Webacy dashboard at https://webacy.com';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=authentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../src/errors/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAClD,YACE,OAAO,GAAG,4BAA4B,EACtC,UAAqD,EAAE;QAEvD,KAAK,CAAC,OAAO,EAAE;YACb,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,sBAAsB;YAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;IAEQ,qBAAqB;QAC5B,OAAO,+HAA+H,CAAC;IACzI,CAAC;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 class WebacyError extends Error {
|
|
23
|
+
/** HTTP status code if applicable */
|
|
24
|
+
status;
|
|
25
|
+
/** Error code for programmatic handling */
|
|
26
|
+
code;
|
|
27
|
+
/** Original error if wrapped */
|
|
28
|
+
cause;
|
|
29
|
+
/** Request ID for support inquiries */
|
|
30
|
+
requestId;
|
|
31
|
+
/** API endpoint that failed (for debugging) */
|
|
32
|
+
endpoint;
|
|
33
|
+
constructor(message, options) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = 'WebacyError';
|
|
36
|
+
this.status = options.status;
|
|
37
|
+
this.code = options.code;
|
|
38
|
+
this.cause = options.cause;
|
|
39
|
+
this.requestId = options.requestId;
|
|
40
|
+
this.endpoint = options.endpoint;
|
|
41
|
+
// Maintain proper stack trace
|
|
42
|
+
if (Error.captureStackTrace) {
|
|
43
|
+
Error.captureStackTrace(this, this.constructor);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if this error is retryable
|
|
48
|
+
*/
|
|
49
|
+
isRetryable() {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Convert to JSON for logging
|
|
54
|
+
*/
|
|
55
|
+
toJSON() {
|
|
56
|
+
return {
|
|
57
|
+
name: this.name,
|
|
58
|
+
message: this.message,
|
|
59
|
+
code: this.code,
|
|
60
|
+
status: this.status,
|
|
61
|
+
requestId: this.requestId,
|
|
62
|
+
endpoint: this.endpoint,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get a user-friendly description of how to resolve this error
|
|
67
|
+
*/
|
|
68
|
+
getRecoverySuggestion() {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/errors/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,qCAAqC;IACrB,MAAM,CAAU;IAEhC,2CAA2C;IAC3B,IAAI,CAAS;IAE7B,gCAAgC;IAChB,KAAK,CAAS;IAE9B,uCAAuC;IACvB,SAAS,CAAU;IAEnC,+CAA+C;IAC/B,QAAQ,CAAU;IAElC,YACE,OAAe,EACf,OAMC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAEjC,8BAA8B;QAC9B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,qBAAqB;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -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.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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,41 @@
|
|
|
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 class NetworkError extends WebacyError {
|
|
23
|
+
constructor(message = 'Network request failed', options = {}) {
|
|
24
|
+
super(message, {
|
|
25
|
+
code: 'NETWORK_ERROR',
|
|
26
|
+
cause: options.cause,
|
|
27
|
+
endpoint: options.endpoint,
|
|
28
|
+
});
|
|
29
|
+
this.name = 'NetworkError';
|
|
30
|
+
}
|
|
31
|
+
isRetryable() {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
getRecoverySuggestion() {
|
|
35
|
+
if (this.message.includes('timed out')) {
|
|
36
|
+
return 'The request timed out. Try increasing the timeout option or check your network connection.';
|
|
37
|
+
}
|
|
38
|
+
return 'Check your network connection and try again. If the problem persists, the Webacy API may be temporarily unavailable.';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/errors/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,YACE,OAAO,GAAG,wBAAwB,EAClC,UAAgD,EAAE;QAElD,KAAK,CAAC,OAAO,EAAE;YACb,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;IAEQ,WAAW;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,qBAAqB;QAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACvC,OAAO,4FAA4F,CAAC;QACtG,CAAC;QACD,OAAO,sHAAsH,CAAC;IAChI,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 class NotFoundError extends WebacyError {
|
|
21
|
+
constructor(message = 'Resource not found', options = {}) {
|
|
22
|
+
super(message, {
|
|
23
|
+
status: 404,
|
|
24
|
+
code: 'NOT_FOUND_ERROR',
|
|
25
|
+
requestId: options.requestId,
|
|
26
|
+
endpoint: options.endpoint,
|
|
27
|
+
});
|
|
28
|
+
this.name = 'NotFoundError';
|
|
29
|
+
}
|
|
30
|
+
getRecoverySuggestion() {
|
|
31
|
+
return 'Verify the address exists and has activity on the specified chain. For new addresses, data may take a few minutes to become available.';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=not-found.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found.js","sourceRoot":"","sources":["../../../src/errors/not-found.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,YACE,OAAO,GAAG,oBAAoB,EAC9B,UAAqD,EAAE;QAEvD,KAAK,CAAC,OAAO,EAAE;YACb,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,iBAAiB;YACvB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;IAEQ,qBAAqB;QAC5B,OAAO,wIAAwI,CAAC;IAClJ,CAAC;CACF"}
|