web3bio-profile-kit 0.1.2 → 0.1.4

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 (74) hide show
  1. package/README.md +14 -6
  2. package/dist/hooks/index.cjs +21 -0
  3. package/dist/hooks/index.js +8 -0
  4. package/dist/hooks/useBaseQuery.cjs +129 -0
  5. package/dist/{types/hooks → hooks}/useBaseQuery.d.ts +1 -2
  6. package/dist/hooks/useBaseQuery.js +127 -0
  7. package/dist/hooks/useBatchNS.cjs +25 -0
  8. package/dist/{types/hooks → hooks}/useBatchNS.d.ts +1 -1
  9. package/dist/hooks/useBatchNS.js +23 -0
  10. package/dist/hooks/useBatchProfile.cjs +25 -0
  11. package/dist/{types/hooks → hooks}/useBatchProfile.d.ts +1 -1
  12. package/dist/hooks/useBatchProfile.js +23 -0
  13. package/dist/hooks/useDomain.cjs +28 -0
  14. package/dist/{types/hooks → hooks}/useDomain.d.ts +1 -1
  15. package/dist/hooks/useDomain.js +26 -0
  16. package/dist/hooks/useNS.cjs +28 -0
  17. package/dist/{types/hooks → hooks}/useNS.d.ts +1 -1
  18. package/dist/hooks/useNS.js +26 -0
  19. package/dist/hooks/useProfile.cjs +28 -0
  20. package/dist/{types/hooks → hooks}/useProfile.d.ts +1 -1
  21. package/dist/hooks/useProfile.js +26 -0
  22. package/dist/hooks/useUniversalNS.cjs +28 -0
  23. package/dist/{types/hooks → hooks}/useUniversalNS.d.ts +1 -1
  24. package/dist/hooks/useUniversalNS.js +26 -0
  25. package/dist/hooks/useUniversalProfile.cjs +28 -0
  26. package/dist/{types/hooks → hooks}/useUniversalProfile.d.ts +1 -1
  27. package/dist/hooks/useUniversalProfile.js +26 -0
  28. package/dist/index.cjs +71 -0
  29. package/dist/index.d.ts +3 -247
  30. package/dist/index.js +18 -425
  31. package/dist/types/cointype.cjs +29 -0
  32. package/dist/types/cointype.d.ts +26 -0
  33. package/dist/types/cointype.js +29 -0
  34. package/dist/types/hook.cjs +38 -0
  35. package/dist/types/hook.d.ts +195 -0
  36. package/dist/types/hook.js +38 -0
  37. package/dist/types/index.cjs +38 -0
  38. package/dist/types/index.d.ts +5 -3
  39. package/dist/types/index.js +5 -0
  40. package/dist/types/network.cjs +41 -0
  41. package/dist/types/network.d.ts +55 -0
  42. package/dist/types/network.js +41 -0
  43. package/dist/types/platform.cjs +110 -0
  44. package/dist/types/platform.d.ts +122 -0
  45. package/dist/types/platform.js +110 -0
  46. package/dist/types/source.cjs +44 -0
  47. package/dist/types/source.d.ts +49 -0
  48. package/dist/types/source.js +44 -0
  49. package/dist/utils/helpers.cjs +119 -0
  50. package/dist/{types/utils → utils}/helpers.d.ts +4 -3
  51. package/dist/utils/helpers.js +112 -0
  52. package/dist/utils/index.cjs +27 -0
  53. package/dist/utils/index.d.ts +6 -0
  54. package/dist/utils/index.js +6 -0
  55. package/dist/utils/network.cjs +355 -0
  56. package/dist/utils/network.d.ts +4 -0
  57. package/dist/utils/network.js +353 -0
  58. package/dist/utils/platform.cjs +983 -0
  59. package/dist/utils/platform.d.ts +18 -0
  60. package/dist/utils/platform.js +979 -0
  61. package/dist/utils/regex.cjs +34 -0
  62. package/dist/utils/regex.d.ts +30 -0
  63. package/dist/utils/regex.js +32 -0
  64. package/dist/utils/source.cjs +144 -0
  65. package/dist/utils/source.d.ts +2 -0
  66. package/dist/utils/source.js +142 -0
  67. package/package.json +32 -12
  68. package/dist/index.esm.js +0 -415
  69. package/dist/index.esm.js.map +0 -1
  70. package/dist/index.js.map +0 -1
  71. package/dist/types/utils/constants.d.ts +0 -36
  72. package/dist/types/utils/types.d.ts +0 -102
  73. /package/dist/{types/hooks → hooks}/index.d.ts +0 -0
  74. /package/dist/{types/setupTests.d.ts → setupTests.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,425 +1,18 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
-
5
- const API_ENDPOINT = "https://api.web3.bio";
6
- exports.ErrorMessages = void 0;
7
- (function (ErrorMessages) {
8
- ErrorMessages["NOT_FOUND"] = "Not Found";
9
- ErrorMessages["INVALID_RESOLVER"] = "Invalid Resolver Address";
10
- ErrorMessages["INVALID_RESOLVED"] = "Invalid Resolved Address";
11
- ErrorMessages["NOT_EXIST"] = "Does Not Exist";
12
- ErrorMessages["INVALID_IDENTITY"] = "Invalid Identity or Domain";
13
- ErrorMessages["INVALID_ADDRESS"] = "Invalid Address";
14
- ErrorMessages["UNKNOWN_ERROR"] = "Unknown Error Occurred";
15
- ErrorMessages["NETWORK_ERROR"] = "Network Error";
16
- })(exports.ErrorMessages || (exports.ErrorMessages = {}));
17
- exports.QueryEndpoint = void 0;
18
- (function (QueryEndpoint) {
19
- QueryEndpoint["NS"] = "ns";
20
- QueryEndpoint["PROFILE"] = "profile";
21
- QueryEndpoint["DOMAIN"] = "domain";
22
- })(exports.QueryEndpoint || (exports.QueryEndpoint = {}));
23
- // Regular expressions for identity detection
24
- const REGEX = {
25
- ENS: /^.+\.(eth|xyz|bio|app|luxe|kred|art|ceo|club|box)$/i,
26
- BASENAMES: /^.+\.base(\.eth)?$/i,
27
- LINEA: /^.+\.linea(\.eth)?$/i,
28
- FARCASTER: /^(?:[A-Za-z0-9_-]{1,61}(?:(?:\.eth)?(?:\.farcaster|\.fcast\.id|\.farcaster\.eth)?)?|farcaster,#\d+)$/i,
29
- LENS: /^(?:.+\.lens)$/i,
30
- CLUSTER: /^[\w-]+\/[\w-]+$/,
31
- SPACE_ID: /^.+\.(bnb|arb)$/i,
32
- GENOME: /^.+\.gno$/i,
33
- UNSTOPPABLE_DOMAINS: /^.+\.(crypto|888|nft|blockchain|bitcoin|dao|x|klever|hi|zil|kresus|polygon|wallet|binanceus|anime|go|manga|eth)$/i,
34
- CROSSBELL: /^.+\.csb$/i,
35
- DOTBIT: /^.+\.bit$/i,
36
- SNS: /^.+\.sol$/i,
37
- ETH_ADDRESS: /^0x[a-fA-F0-9]{40}$/i,
38
- BTC_ADDRESS: /\b([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qp][a-z0-9]{11,71})\b/,
39
- SOLANA_ADDRESS: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/,
40
- LOWERCASE_EXEMPT: /\b(?:(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qp][a-z0-9]{11,71})|(?:[1-9A-HJ-NP-Za-km-z]{32,44}))\b/,
41
- TWITTER: /^[A-Za-z0-9_]{1,15}(?:\.twitter)?$/i,
42
- NEXT_ID: /^0x[a-f0-9]{66}(?:\.nextid)?$/i,
43
- };
44
-
45
- exports.PlatformType = void 0;
46
- (function (PlatformType) {
47
- PlatformType["ens"] = "ens";
48
- PlatformType["farcaster"] = "farcaster";
49
- PlatformType["lens"] = "lens";
50
- PlatformType["ethereum"] = "ethereum";
51
- PlatformType["twitter"] = "twitter";
52
- PlatformType["github"] = "github";
53
- PlatformType["bitcoin"] = "bitcoin";
54
- PlatformType["unstoppableDomains"] = "unstoppabledomains";
55
- PlatformType["basenames"] = "basenames";
56
- PlatformType["linea"] = "linea";
57
- PlatformType["space_id"] = "space_id";
58
- PlatformType["solana"] = "solana";
59
- PlatformType["sns"] = "sns";
60
- PlatformType["nextid"] = "nextid";
61
- PlatformType["dotbit"] = "dotbit";
62
- })(exports.PlatformType || (exports.PlatformType = {}));
63
- exports.SourceType = void 0;
64
- (function (SourceType) {
65
- SourceType["ethereum"] = "ethereum";
66
- SourceType["ens"] = "ens";
67
- SourceType["twitter"] = "twitter";
68
- SourceType["nextid"] = "nextid";
69
- SourceType["dotbit"] = "dotbit";
70
- SourceType["unstoppabledomains"] = "unstoppabledomains";
71
- SourceType["lens"] = "lens";
72
- SourceType["farcaster"] = "farcaster";
73
- SourceType["space_id"] = "space_id";
74
- SourceType["solana"] = "solana";
75
- SourceType["sns"] = "sns";
76
- })(exports.SourceType || (exports.SourceType = {}));
77
-
78
- /**
79
- * Resolves an identity string to a platform and identifier
80
- * @param input The identity to resolve
81
- * @returns A formatted identity string or null if invalid
82
- */
83
- const resolveIdentity = (input) => {
84
- if (!input)
85
- return null;
86
- const parts = input.split(",");
87
- let platform;
88
- let identity;
89
- if (parts.length === 2) {
90
- // Format is already "platform,identity"
91
- platform = parts[0];
92
- identity = prettify(parts[1]);
93
- }
94
- else if (parts.length === 1) {
95
- // Auto-detect platform from the identity string
96
- platform = detectPlatform(input);
97
- identity = prettify(input);
98
- }
99
- else {
100
- return null;
101
- }
102
- if (!isSupportedPlatform(platform) || !identity)
103
- return null;
104
- // Normalize case except for case-sensitive identities
105
- const normalizedIdentity = REGEX.LOWERCASE_EXEMPT.test(identity)
106
- ? identity
107
- : identity.toLowerCase();
108
- return `${platform},${normalizedIdentity}`;
109
- };
110
- /**
111
- * Clean up and standardize identity format
112
- */
113
- const prettify = (input) => {
114
- if (!input)
115
- return "";
116
- if (input.endsWith(".twitter"))
117
- return input.replace(".twitter", "");
118
- if (input.endsWith(".nextid"))
119
- return input.replace(".nextid", "");
120
- if (input.startsWith("farcaster,#"))
121
- return input.replace(/^(farcaster),/, "");
122
- if (input.endsWith(".farcaster") ||
123
- input.endsWith(".fcast.id") ||
124
- input.endsWith(".farcaster.eth")) {
125
- return input.replace(/(\.farcaster|\.fcast\.id|\.farcaster\.eth)$/, "");
126
- }
127
- if (input.endsWith(".base") || input.endsWith(".linea")) {
128
- return input.split(".")[0] + "." + input.split(".").pop() + ".eth";
129
- }
130
- return input;
131
- };
132
- /**
133
- * Check if the platform is supported for API queries
134
- */
135
- const isSupportedPlatform = (platform) => {
136
- if (!platform)
137
- return false;
138
- return Object.values(exports.PlatformType).includes(platform);
139
- };
140
- /**
141
- * Detect platform from identity string based on regex patterns
142
- */
143
- const detectPlatform = (term) => {
144
- if (term.endsWith(".farcaster.eth"))
145
- return exports.PlatformType.farcaster;
146
- const platformMap = [
147
- [REGEX.BASENAMES, exports.PlatformType.basenames],
148
- [REGEX.LINEA, exports.PlatformType.linea],
149
- [REGEX.ENS, exports.PlatformType.ens],
150
- [REGEX.ETH_ADDRESS, exports.PlatformType.ethereum],
151
- [REGEX.LENS, exports.PlatformType.lens],
152
- [REGEX.UNSTOPPABLE_DOMAINS, exports.PlatformType.unstoppableDomains],
153
- [REGEX.SPACE_ID, exports.PlatformType.space_id],
154
- [REGEX.DOTBIT, exports.PlatformType.dotbit],
155
- [REGEX.SNS, exports.PlatformType.sns],
156
- [REGEX.BTC_ADDRESS, exports.PlatformType.bitcoin],
157
- [REGEX.SOLANA_ADDRESS, exports.PlatformType.solana],
158
- [REGEX.FARCASTER, exports.PlatformType.farcaster],
159
- [REGEX.TWITTER, exports.PlatformType.twitter],
160
- [REGEX.NEXT_ID, exports.PlatformType.nextid],
161
- ];
162
- for (const [regex, platformType] of platformMap) {
163
- if (regex.test(term)) {
164
- return platformType;
165
- }
166
- }
167
- // Default fallback
168
- return term.includes(".") ? exports.PlatformType.ens : exports.PlatformType.farcaster;
169
- };
170
- /**
171
- * Get API key from various environment sources or user provided value
172
- */
173
- const getApiKey = (userProvidedKey) => {
174
- return (userProvidedKey ||
175
- process.env.WEB3BIO_API_KEY ||
176
- process.env.REACT_APP_WEB3BIO_API_KEY ||
177
- process.env.NEXT_PUBLIC_WEB3BIO_API_KEY ||
178
- process.env.VITE_WEB3BIO_API_KEY);
179
- };
180
-
181
- /**
182
- * Constructs the API URL based on query parameters
183
- */
184
- const buildApiUrl = (identity, endpoint, universal) => {
185
- // Handle batch requests
186
- if (Array.isArray(identity)) {
187
- return `${API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;
188
- }
189
- // Handle universal queries
190
- if (universal) {
191
- return `${API_ENDPOINT}/${endpoint}/${identity}`;
192
- }
193
- // Handle platform-specific queries
194
- const resolvedId = resolveIdentity(identity);
195
- if (!resolvedId)
196
- return null;
197
- // Domain endpoint uses resolved ID directly
198
- if (endpoint === exports.QueryEndpoint.DOMAIN) {
199
- return `${API_ENDPOINT}/${endpoint}/${resolvedId}`;
200
- }
201
- // Other endpoints need platform/handle split
202
- const [platform, handle] = resolvedId.split(",");
203
- return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;
204
- };
205
- // Generate a stable cache key for this request
206
- const getCacheKey = (identity, endpoint, universal) => {
207
- return JSON.stringify({
208
- identity,
209
- endpoint,
210
- universal,
211
- });
212
- };
213
- // Create a cache to store results across component instances and re-renders
214
- const globalRequestCache = new Map();
215
- /**
216
- * Core hook for querying Web3.bio Profile API
217
- */
218
- function useBaseQuery(identity, endpoint, universal = false, options = {}) {
219
- const { apiKey: userApiKey, enabled = true } = options;
220
- const apiKey = getApiKey(userApiKey);
221
- const [data, setData] = react.useState(() => {
222
- // Initialize state from cache if available
223
- const cacheKey = getCacheKey(identity, endpoint, universal);
224
- return globalRequestCache.get(cacheKey) || null;
225
- });
226
- const [isLoading, setIsLoading] = react.useState(false);
227
- const [error, setError] = react.useState(null);
228
- // Use ref to track in-flight requests and prevent race conditions
229
- const requestIdRef = react.useRef(0);
230
- const prevParamsRef = react.useRef("");
231
- // Current request parameters as a string for comparison
232
- const currentParams = JSON.stringify({
233
- identity,
234
- endpoint,
235
- universal,
236
- });
237
- react.useEffect(() => {
238
- // Don't run the query if disabled or no identity
239
- if (!enabled || !identity)
240
- return;
241
- // Skip if parameters haven't changed
242
- if (currentParams === prevParamsRef.current && data !== null) {
243
- return;
244
- }
245
- // Update previous parameters
246
- prevParamsRef.current = currentParams;
247
- // Generate cache key
248
- const cacheKey = getCacheKey(identity, endpoint, universal);
249
- // Check if we already have cached data
250
- const cachedData = globalRequestCache.get(cacheKey);
251
- if (cachedData) {
252
- setData(cachedData);
253
- return;
254
- }
255
- // Increment request ID to track the latest request
256
- const requestId = ++requestIdRef.current;
257
- setIsLoading(true);
258
- setError(null);
259
- const fetchData = async () => {
260
- try {
261
- const url = buildApiUrl(identity, endpoint, universal);
262
- if (!url) {
263
- throw new Error(exports.ErrorMessages.INVALID_IDENTITY);
264
- }
265
- const headers = apiKey ? { "x-api-key": apiKey } : {};
266
- const fetchOptions = {
267
- method: "GET",
268
- headers,
269
- };
270
- const response = await fetch(url, fetchOptions);
271
- if (!response.ok) {
272
- throw new Error(`API error: ${response.status}`);
273
- }
274
- const responseData = await response.json();
275
- if (responseData === null || responseData === void 0 ? void 0 : responseData.error) {
276
- throw new Error(responseData.error);
277
- }
278
- if (requestId === requestIdRef.current) {
279
- globalRequestCache.set(cacheKey, responseData);
280
- setData(responseData);
281
- setIsLoading(false);
282
- }
283
- }
284
- catch (err) {
285
- if (requestId === requestIdRef.current) {
286
- setError(err instanceof Error ? err : new Error(String(err)));
287
- setIsLoading(false);
288
- }
289
- }
290
- };
291
- fetchData();
292
- }, [currentParams, enabled]);
293
- return { data, isLoading, error };
294
- }
295
-
296
- /**
297
- * Hook to query Web3.bio profile data by identity
298
- *
299
- * @param identity - Identity string
300
- * @param options - Optional configuration options
301
- * @returns Object containing profile data, loading state, and any errors
302
- *
303
- * @example
304
- * // Query by ENS name
305
- * const { data, isLoading, error } = useProfile("vitalik.eth");
306
- *
307
- * // Query with platform specification
308
- * const { data } = useProfile("farcaster,dwr");
309
- */
310
- function useProfile(identity, options = {}) {
311
- return useBaseQuery(identity, exports.QueryEndpoint.PROFILE, false, options);
312
- }
313
-
314
- /**
315
- * Hook to query Web3.bio name service (NS) data by identity
316
- *
317
- * @param identity - Identity string
318
- * @param options - Optional configuration options
319
- * @returns Object containing NS data, loading state, and any errors
320
- *
321
- * @example
322
- * // Query by ENS name
323
- * const { data, isLoading, error } = useNS("vitalik.eth");
324
- *
325
- * // Query by Ethereum address
326
- * const { data } = useNS("0x123...");
327
- */
328
- function useNS(identity, options = {}) {
329
- return useBaseQuery(identity, exports.QueryEndpoint.NS, false, options);
330
- }
331
-
332
- /**
333
- * Hook to query Web3.bio profile data using universal identity lookup
334
- *
335
- * @param identity - Identity string
336
- * @param options - Optional configuration options
337
- * @returns Object containing profile data, loading state, and any errors
338
- *
339
- * @example
340
- * // Query by ENS name with universal lookup
341
- * const { data, isLoading, error } = useUniversalProfile("vitalik.eth");
342
- *
343
- * // Query by any identity type with universal lookup
344
- * const { data } = useUniversalProfile("dwr.farcaster");
345
- */
346
- function useUniversalProfile(identity, options = {}) {
347
- return useBaseQuery(identity, exports.QueryEndpoint.PROFILE, true, options);
348
- }
349
-
350
- /**
351
- * Hook to query Web3.bio name service (NS) data using universal identity lookup
352
- *
353
- * @param identity - Identity string
354
- * @param options - Optional configuration options
355
- * @returns Object containing NS data, loading state, and any errors
356
- *
357
- * @example
358
- * // Query by ENS name with universal lookup
359
- * const { data, isLoading, error } = useUniversalNS("vitalik.eth");
360
- *
361
- * // Query by any identity type with universal lookup
362
- * const { data } = useUniversalNS("dwr.farcaster");
363
- */
364
- function useUniversalNS(identity, options = {}) {
365
- return useBaseQuery(identity, exports.QueryEndpoint.NS, true, options);
366
- }
367
-
368
- /**
369
- * Hook to query Web3.bio profile data using batch identity lookup
370
- *
371
- * @param identity - array of Identity string
372
- * @param options - Optional configuration options
373
- * @returns Object containing profile data, loading state, and any errors
374
- *
375
- * @example
376
- * // Query by any identity type with batch lookup
377
- * const { data } = useBatchProfile(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
378
- */
379
- function useBatchProfile(identity, options = {}) {
380
- return useBaseQuery(identity, exports.QueryEndpoint.PROFILE, false, options);
381
- }
382
-
383
- /**
384
- * Hook to query Web3.bio profile data using batch(NS) identity lookup
385
- *
386
- * @param identity - array of Identity string
387
- * @param options - Optional configuration options
388
- * @returns Object containing profile data, loading state, and any errors
389
- *
390
- * @example
391
- * // Query by any identity type with batch lookup
392
- * const { data } = useBatchNS(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
393
- */
394
- function useBatchNS(identity, options = {}) {
395
- return useBaseQuery(identity, exports.QueryEndpoint.NS, false, options);
396
- }
397
-
398
- /**
399
- * Hook to query Web3.bio domain data by identity
400
- *
401
- * @param identity - Identity string
402
- * @param options - Optional configuration options
403
- * @returns Object containing domain data, loading state, and any errors
404
- *
405
- * @example
406
- * // Query by ENS name
407
- * const { data, isLoading, error } = useDomain("vitalik.eth");
408
- *
409
- * // Query by domain name with platform
410
- * const { data } = useDomain("ens,vitalik.eth");
411
- */
412
- function useDomain(identity, options = {}) {
413
- return useBaseQuery(identity, exports.QueryEndpoint.DOMAIN, false, options);
414
- }
415
-
416
- exports.API_ENDPOINT = API_ENDPOINT;
417
- exports.REGEX = REGEX;
418
- exports.useBatchNS = useBatchNS;
419
- exports.useBatchProfile = useBatchProfile;
420
- exports.useDomain = useDomain;
421
- exports.useNS = useNS;
422
- exports.useProfile = useProfile;
423
- exports.useUniversalNS = useUniversalNS;
424
- exports.useUniversalProfile = useUniversalProfile;
425
- //# sourceMappingURL=index.js.map
1
+ export { useProfile } from './hooks/useProfile.js';
2
+ export { useNS } from './hooks/useNS.js';
3
+ export { useUniversalProfile } from './hooks/useUniversalProfile.js';
4
+ export { useUniversalNS } from './hooks/useUniversalNS.js';
5
+ export { useBatchProfile } from './hooks/useBatchProfile.js';
6
+ export { useBatchNS } from './hooks/useBatchNS.js';
7
+ export { useDomain } from './hooks/useDomain.js';
8
+ export { useBaseQuery } from './hooks/useBaseQuery.js';
9
+ export { CoinType } from './types/cointype.js';
10
+ export { REGEX } from './utils/regex.js';
11
+ export { API_ENDPOINT, detectPlatform, getApiKey, isSupportedPlatform, prettify, resolveIdentity } from './utils/helpers.js';
12
+ export { NETWORK_DATA } from './utils/network.js';
13
+ export { DEFAULT_PLATFORM, PLATFORM_DATA, getPlatformData } from './utils/platform.js';
14
+ export { SOURCE_DATA } from './utils/source.js';
15
+ export { Platform, PlatformSystem } from './types/platform.js';
16
+ export { Network } from './types/network.js';
17
+ export { ErrorMessages, QueryEndpoint } from './types/hook.js';
18
+ export { Source } from './types/source.js';
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Coin types based on SLIP-0044 standard
5
+ * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
6
+ */
7
+ exports.CoinType = void 0;
8
+ (function (CoinType) {
9
+ CoinType[CoinType["BTC"] = 0] = "BTC";
10
+ CoinType[CoinType["LTC"] = 2] = "LTC";
11
+ CoinType[CoinType["DOGE"] = 3] = "DOGE";
12
+ CoinType[CoinType["DASH"] = 5] = "DASH";
13
+ CoinType[CoinType["MONACOIN"] = 22] = "MONACOIN";
14
+ CoinType[CoinType["ETH"] = 60] = "ETH";
15
+ CoinType[CoinType["ETC"] = 61] = "ETC";
16
+ CoinType[CoinType["XRP"] = 145] = "XRP";
17
+ CoinType[CoinType["ATOM"] = 118] = "ATOM";
18
+ CoinType[CoinType["ROOTSTOCK"] = 137] = "ROOTSTOCK";
19
+ CoinType[CoinType["RIPPLE"] = 144] = "RIPPLE";
20
+ CoinType[CoinType["BCH"] = 145] = "BCH";
21
+ CoinType[CoinType["BNB"] = 714] = "BNB";
22
+ CoinType[CoinType["XLM"] = 148] = "XLM";
23
+ CoinType[CoinType["RSK"] = 137] = "RSK";
24
+ CoinType[CoinType["EOS"] = 194] = "EOS";
25
+ CoinType[CoinType["XEM"] = 43] = "XEM";
26
+ CoinType[CoinType["TRX"] = 195] = "TRX";
27
+ CoinType[CoinType["XDAI"] = 700] = "XDAI";
28
+ CoinType[CoinType["MATIC"] = 2147483785] = "MATIC";
29
+ })(exports.CoinType || (exports.CoinType = {}));
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Coin types based on SLIP-0044 standard
3
+ * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
4
+ */
5
+ export declare enum CoinType {
6
+ BTC = 0,
7
+ LTC = 2,
8
+ DOGE = 3,
9
+ DASH = 5,
10
+ MONACOIN = 22,
11
+ ETH = 60,
12
+ ETC = 61,
13
+ XRP = 145,
14
+ ATOM = 118,
15
+ ROOTSTOCK = 137,
16
+ RIPPLE = 144,
17
+ BCH = 145,
18
+ BNB = 714,
19
+ XLM = 148,
20
+ RSK = 137,
21
+ EOS = 194,
22
+ XEM = 43,
23
+ TRX = 195,
24
+ XDAI = 700,
25
+ MATIC = 2147483785
26
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Coin types based on SLIP-0044 standard
3
+ * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
4
+ */
5
+ var CoinType;
6
+ (function (CoinType) {
7
+ CoinType[CoinType["BTC"] = 0] = "BTC";
8
+ CoinType[CoinType["LTC"] = 2] = "LTC";
9
+ CoinType[CoinType["DOGE"] = 3] = "DOGE";
10
+ CoinType[CoinType["DASH"] = 5] = "DASH";
11
+ CoinType[CoinType["MONACOIN"] = 22] = "MONACOIN";
12
+ CoinType[CoinType["ETH"] = 60] = "ETH";
13
+ CoinType[CoinType["ETC"] = 61] = "ETC";
14
+ CoinType[CoinType["XRP"] = 145] = "XRP";
15
+ CoinType[CoinType["ATOM"] = 118] = "ATOM";
16
+ CoinType[CoinType["ROOTSTOCK"] = 137] = "ROOTSTOCK";
17
+ CoinType[CoinType["RIPPLE"] = 144] = "RIPPLE";
18
+ CoinType[CoinType["BCH"] = 145] = "BCH";
19
+ CoinType[CoinType["BNB"] = 714] = "BNB";
20
+ CoinType[CoinType["XLM"] = 148] = "XLM";
21
+ CoinType[CoinType["RSK"] = 137] = "RSK";
22
+ CoinType[CoinType["EOS"] = 194] = "EOS";
23
+ CoinType[CoinType["XEM"] = 43] = "XEM";
24
+ CoinType[CoinType["TRX"] = 195] = "TRX";
25
+ CoinType[CoinType["XDAI"] = 700] = "XDAI";
26
+ CoinType[CoinType["MATIC"] = 2147483785] = "MATIC";
27
+ })(CoinType || (CoinType = {}));
28
+
29
+ export { CoinType };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Standard error messages used across the library
5
+ * @public
6
+ */
7
+ exports.ErrorMessages = void 0;
8
+ (function (ErrorMessages) {
9
+ /** Resource not found */
10
+ ErrorMessages["NOT_FOUND"] = "Not Found";
11
+ /** Resolver address is invalid */
12
+ ErrorMessages["INVALID_RESOLVER"] = "Invalid Resolver Address";
13
+ /** Resolved address is invalid */
14
+ ErrorMessages["INVALID_RESOLVED"] = "Invalid Resolved Address";
15
+ /** Resource does not exist */
16
+ ErrorMessages["NOT_EXIST"] = "Does Not Exist";
17
+ /** Provided identity or domain is invalid */
18
+ ErrorMessages["INVALID_IDENTITY"] = "Invalid Identity or Domain";
19
+ /** Provided address is invalid */
20
+ ErrorMessages["INVALID_ADDRESS"] = "Invalid Address";
21
+ /** An unknown error occurred */
22
+ ErrorMessages["UNKNOWN_ERROR"] = "Unknown Error Occurred";
23
+ /** Network-related error */
24
+ ErrorMessages["NETWORK_ERROR"] = "Network Error";
25
+ })(exports.ErrorMessages || (exports.ErrorMessages = {}));
26
+ /**
27
+ * API endpoints for different query types
28
+ * @public
29
+ */
30
+ exports.QueryEndpoint = void 0;
31
+ (function (QueryEndpoint) {
32
+ /** Name service endpoint */
33
+ QueryEndpoint["NS"] = "ns";
34
+ /** Profile data endpoint */
35
+ QueryEndpoint["PROFILE"] = "profile";
36
+ /** Domain information endpoint */
37
+ QueryEndpoint["DOMAIN"] = "domain";
38
+ })(exports.QueryEndpoint || (exports.QueryEndpoint = {}));