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
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ require('../types/platform.cjs');
4
+ require('../types/network.cjs');
5
+ var hook = require('../types/hook.cjs');
6
+ require('../types/source.cjs');
7
+ require('../types/cointype.cjs');
8
+ var useBaseQuery = require('./useBaseQuery.cjs');
9
+
10
+ /**
11
+ * Hook to query Web3.bio name service (NS) data using universal identity lookup
12
+ *
13
+ * @param identity - Identity string
14
+ * @param options - Optional configuration options
15
+ * @returns Object containing NS data, loading state, and any errors
16
+ *
17
+ * @example
18
+ * // Query by ENS name with universal lookup
19
+ * const { data, isLoading, error } = useUniversalNS("vitalik.eth");
20
+ *
21
+ * // Query by any identity type with universal lookup
22
+ * const { data } = useUniversalNS("dwr.farcaster");
23
+ */
24
+ function useUniversalNS(identity, options = {}) {
25
+ return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.NS, true, options);
26
+ }
27
+
28
+ exports.useUniversalNS = useUniversalNS;
@@ -1,4 +1,4 @@
1
- import type { QueryOptions, IdentityString, NSUniversalResult } from "../utils/types";
1
+ import { type QueryOptions, type IdentityString, type NSUniversalResult } from "../types";
2
2
  /**
3
3
  * Hook to query Web3.bio name service (NS) data using universal identity lookup
4
4
  *
@@ -0,0 +1,26 @@
1
+ import '../types/platform.js';
2
+ import '../types/network.js';
3
+ import { QueryEndpoint } from '../types/hook.js';
4
+ import '../types/source.js';
5
+ import '../types/cointype.js';
6
+ import { useBaseQuery } from './useBaseQuery.js';
7
+
8
+ /**
9
+ * Hook to query Web3.bio name service (NS) data using universal identity lookup
10
+ *
11
+ * @param identity - Identity string
12
+ * @param options - Optional configuration options
13
+ * @returns Object containing NS data, loading state, and any errors
14
+ *
15
+ * @example
16
+ * // Query by ENS name with universal lookup
17
+ * const { data, isLoading, error } = useUniversalNS("vitalik.eth");
18
+ *
19
+ * // Query by any identity type with universal lookup
20
+ * const { data } = useUniversalNS("dwr.farcaster");
21
+ */
22
+ function useUniversalNS(identity, options = {}) {
23
+ return useBaseQuery(identity, QueryEndpoint.NS, true, options);
24
+ }
25
+
26
+ export { useUniversalNS };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ require('../types/platform.cjs');
4
+ require('../types/network.cjs');
5
+ var hook = require('../types/hook.cjs');
6
+ require('../types/source.cjs');
7
+ require('../types/cointype.cjs');
8
+ var useBaseQuery = require('./useBaseQuery.cjs');
9
+
10
+ /**
11
+ * Hook to query Web3.bio profile data using universal identity lookup
12
+ *
13
+ * @param identity - Identity string
14
+ * @param options - Optional configuration options
15
+ * @returns Object containing profile data, loading state, and any errors
16
+ *
17
+ * @example
18
+ * // Query by ENS name with universal lookup
19
+ * const { data, isLoading, error } = useUniversalProfile("vitalik.eth");
20
+ *
21
+ * // Query by any identity type with universal lookup
22
+ * const { data } = useUniversalProfile("dwr.farcaster");
23
+ */
24
+ function useUniversalProfile(identity, options = {}) {
25
+ return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.PROFILE, true, options);
26
+ }
27
+
28
+ exports.useUniversalProfile = useUniversalProfile;
@@ -1,4 +1,4 @@
1
- import type { IdentityString, ProfileUniversalResult, QueryOptions } from "../utils/types";
1
+ import { type IdentityString, type ProfileUniversalResult, type QueryOptions } from "../types";
2
2
  /**
3
3
  * Hook to query Web3.bio profile data using universal identity lookup
4
4
  *
@@ -0,0 +1,26 @@
1
+ import '../types/platform.js';
2
+ import '../types/network.js';
3
+ import { QueryEndpoint } from '../types/hook.js';
4
+ import '../types/source.js';
5
+ import '../types/cointype.js';
6
+ import { useBaseQuery } from './useBaseQuery.js';
7
+
8
+ /**
9
+ * Hook to query Web3.bio profile data using universal identity lookup
10
+ *
11
+ * @param identity - Identity string
12
+ * @param options - Optional configuration options
13
+ * @returns Object containing profile data, loading state, and any errors
14
+ *
15
+ * @example
16
+ * // Query by ENS name with universal lookup
17
+ * const { data, isLoading, error } = useUniversalProfile("vitalik.eth");
18
+ *
19
+ * // Query by any identity type with universal lookup
20
+ * const { data } = useUniversalProfile("dwr.farcaster");
21
+ */
22
+ function useUniversalProfile(identity, options = {}) {
23
+ return useBaseQuery(identity, QueryEndpoint.PROFILE, true, options);
24
+ }
25
+
26
+ export { useUniversalProfile };
package/dist/index.cjs ADDED
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ var useProfile = require('./hooks/useProfile.cjs');
4
+ var useNS = require('./hooks/useNS.cjs');
5
+ var useUniversalProfile = require('./hooks/useUniversalProfile.cjs');
6
+ var useUniversalNS = require('./hooks/useUniversalNS.cjs');
7
+ var useBatchProfile = require('./hooks/useBatchProfile.cjs');
8
+ var useBatchNS = require('./hooks/useBatchNS.cjs');
9
+ var useDomain = require('./hooks/useDomain.cjs');
10
+ var useBaseQuery = require('./hooks/useBaseQuery.cjs');
11
+ var cointype = require('./types/cointype.cjs');
12
+ var regex = require('./utils/regex.cjs');
13
+ var helpers = require('./utils/helpers.cjs');
14
+ var network = require('./utils/network.cjs');
15
+ var platform = require('./utils/platform.cjs');
16
+ var source = require('./utils/source.cjs');
17
+ var platform$1 = require('./types/platform.cjs');
18
+ var network$1 = require('./types/network.cjs');
19
+ var hook = require('./types/hook.cjs');
20
+ var source$1 = require('./types/source.cjs');
21
+
22
+
23
+
24
+ exports.useProfile = useProfile.useProfile;
25
+ exports.useNS = useNS.useNS;
26
+ exports.useUniversalProfile = useUniversalProfile.useUniversalProfile;
27
+ exports.useUniversalNS = useUniversalNS.useUniversalNS;
28
+ exports.useBatchProfile = useBatchProfile.useBatchProfile;
29
+ exports.useBatchNS = useBatchNS.useBatchNS;
30
+ exports.useDomain = useDomain.useDomain;
31
+ exports.useBaseQuery = useBaseQuery.useBaseQuery;
32
+ Object.defineProperty(exports, 'CoinType', {
33
+ enumerable: true,
34
+ get: function () { return cointype.CoinType; }
35
+ });
36
+ exports.REGEX = regex.REGEX;
37
+ exports.API_ENDPOINT = helpers.API_ENDPOINT;
38
+ exports.detectPlatform = helpers.detectPlatform;
39
+ exports.getApiKey = helpers.getApiKey;
40
+ exports.isSupportedPlatform = helpers.isSupportedPlatform;
41
+ exports.prettify = helpers.prettify;
42
+ exports.resolveIdentity = helpers.resolveIdentity;
43
+ exports.NETWORK_DATA = network.NETWORK_DATA;
44
+ exports.DEFAULT_PLATFORM = platform.DEFAULT_PLATFORM;
45
+ exports.PLATFORM_DATA = platform.PLATFORM_DATA;
46
+ exports.getPlatformData = platform.getPlatformData;
47
+ exports.SOURCE_DATA = source.SOURCE_DATA;
48
+ Object.defineProperty(exports, 'Platform', {
49
+ enumerable: true,
50
+ get: function () { return platform$1.Platform; }
51
+ });
52
+ Object.defineProperty(exports, 'PlatformSystem', {
53
+ enumerable: true,
54
+ get: function () { return platform$1.PlatformSystem; }
55
+ });
56
+ Object.defineProperty(exports, 'Network', {
57
+ enumerable: true,
58
+ get: function () { return network$1.Network; }
59
+ });
60
+ Object.defineProperty(exports, 'ErrorMessages', {
61
+ enumerable: true,
62
+ get: function () { return hook.ErrorMessages; }
63
+ });
64
+ Object.defineProperty(exports, 'QueryEndpoint', {
65
+ enumerable: true,
66
+ get: function () { return hook.QueryEndpoint; }
67
+ });
68
+ Object.defineProperty(exports, 'Source', {
69
+ enumerable: true,
70
+ get: function () { return source$1.Source; }
71
+ });
package/dist/index.d.ts CHANGED
@@ -1,247 +1,3 @@
1
- declare enum PlatformType {
2
- ens = "ens",
3
- farcaster = "farcaster",
4
- lens = "lens",
5
- ethereum = "ethereum",
6
- twitter = "twitter",
7
- github = "github",
8
- bitcoin = "bitcoin",
9
- unstoppableDomains = "unstoppabledomains",
10
- basenames = "basenames",
11
- linea = "linea",
12
- space_id = "space_id",
13
- solana = "solana",
14
- sns = "sns",
15
- nextid = "nextid",
16
- dotbit = "dotbit"
17
- }
18
- declare enum SourceType {
19
- ethereum = "ethereum",
20
- ens = "ens",
21
- twitter = "twitter",
22
- nextid = "nextid",
23
- dotbit = "dotbit",
24
- unstoppabledomains = "unstoppabledomains",
25
- lens = "lens",
26
- farcaster = "farcaster",
27
- space_id = "space_id",
28
- solana = "solana",
29
- sns = "sns"
30
- }
31
- type SocialLinksItem = {
32
- link: string | null;
33
- handle: string | null;
34
- sources: SourceType[];
35
- };
36
- type SocialLinks = Record<string, SocialLinksItem>;
37
- interface ProfileResponse {
38
- identity: string;
39
- address: string | null;
40
- avatar: string | null;
41
- description: string | null;
42
- platform: string;
43
- displayName: string | null;
44
- email: string | null;
45
- contenthash: string | null;
46
- header: string | null;
47
- location: string | null;
48
- createdAt: string | null;
49
- status: string | null;
50
- error?: string;
51
- links: SocialLinks;
52
- aliases?: string[];
53
- social: {
54
- uid: number | null;
55
- follower: number;
56
- following: number;
57
- } | {};
58
- }
59
- interface NSResponse {
60
- identity: string;
61
- address: string | null;
62
- avatar: string | null;
63
- description: string | null;
64
- platform: string;
65
- displayName: string | null;
66
- aliases?: string[];
67
- }
68
- interface DomainResponse {
69
- identity: string;
70
- platform: PlatformType;
71
- resolvedAddress: string | null;
72
- ownerAddress: string | null;
73
- managerAddress: string | null;
74
- displayName: string | null;
75
- isPrimary: boolean;
76
- status: string;
77
- createdAt: string | null;
78
- updatedAt: string | null;
79
- expiredAt: string | null;
80
- contenthash: string | null;
81
- texts: Record<string, string>;
82
- addresses: Record<string, string>;
83
- }
84
- type QueryOptions = {
85
- /** API Key for authentication */
86
- apiKey?: string;
87
- /** Whether the query should execute */
88
- enabled?: boolean;
89
- };
90
- type IdentityString = string | `${PlatformType},${string}`;
91
- type QueryResult<T> = {
92
- data: T | null;
93
- isLoading: boolean;
94
- error: Error | null;
95
- };
96
- type ProfileResult = QueryResult<ProfileResponse>;
97
- type NSResult = QueryResult<NSResponse>;
98
- type ProfileBatchResult = QueryResult<ProfileResponse[]>;
99
- type NSBatchResult = QueryResult<NSResponse[]>;
100
- type ProfileUniversalResult = QueryResult<ProfileResponse[]>;
101
- type NSUniversalResult = QueryResult<NSResponse[]>;
102
- type DomainResult = QueryResult<DomainResponse>;
103
-
104
- /**
105
- * Hook to query Web3.bio profile data by identity
106
- *
107
- * @param identity - Identity string
108
- * @param options - Optional configuration options
109
- * @returns Object containing profile data, loading state, and any errors
110
- *
111
- * @example
112
- * // Query by ENS name
113
- * const { data, isLoading, error } = useProfile("vitalik.eth");
114
- *
115
- * // Query with platform specification
116
- * const { data } = useProfile("farcaster,dwr");
117
- */
118
- declare function useProfile(identity: IdentityString, options?: QueryOptions): ProfileResult;
119
-
120
- /**
121
- * Hook to query Web3.bio name service (NS) data by identity
122
- *
123
- * @param identity - Identity string
124
- * @param options - Optional configuration options
125
- * @returns Object containing NS data, loading state, and any errors
126
- *
127
- * @example
128
- * // Query by ENS name
129
- * const { data, isLoading, error } = useNS("vitalik.eth");
130
- *
131
- * // Query by Ethereum address
132
- * const { data } = useNS("0x123...");
133
- */
134
- declare function useNS(identity: IdentityString, options?: QueryOptions): NSResult;
135
-
136
- /**
137
- * Hook to query Web3.bio profile data using universal identity lookup
138
- *
139
- * @param identity - Identity string
140
- * @param options - Optional configuration options
141
- * @returns Object containing profile data, loading state, and any errors
142
- *
143
- * @example
144
- * // Query by ENS name with universal lookup
145
- * const { data, isLoading, error } = useUniversalProfile("vitalik.eth");
146
- *
147
- * // Query by any identity type with universal lookup
148
- * const { data } = useUniversalProfile("dwr.farcaster");
149
- */
150
- declare function useUniversalProfile(identity: IdentityString, options?: QueryOptions): ProfileUniversalResult;
151
-
152
- /**
153
- * Hook to query Web3.bio name service (NS) data using universal identity lookup
154
- *
155
- * @param identity - Identity string
156
- * @param options - Optional configuration options
157
- * @returns Object containing NS data, loading state, and any errors
158
- *
159
- * @example
160
- * // Query by ENS name with universal lookup
161
- * const { data, isLoading, error } = useUniversalNS("vitalik.eth");
162
- *
163
- * // Query by any identity type with universal lookup
164
- * const { data } = useUniversalNS("dwr.farcaster");
165
- */
166
- declare function useUniversalNS(identity: IdentityString, options?: QueryOptions): NSUniversalResult;
167
-
168
- /**
169
- * Hook to query Web3.bio profile data using batch identity lookup
170
- *
171
- * @param identity - array of Identity string
172
- * @param options - Optional configuration options
173
- * @returns Object containing profile data, loading state, and any errors
174
- *
175
- * @example
176
- * // Query by any identity type with batch lookup
177
- * const { data } = useBatchProfile(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
178
- */
179
- declare function useBatchProfile(identity: IdentityString[], options?: QueryOptions): ProfileBatchResult;
180
-
181
- /**
182
- * Hook to query Web3.bio profile data using batch(NS) identity lookup
183
- *
184
- * @param identity - array of Identity string
185
- * @param options - Optional configuration options
186
- * @returns Object containing profile data, loading state, and any errors
187
- *
188
- * @example
189
- * // Query by any identity type with batch lookup
190
- * const { data } = useBatchNS(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
191
- */
192
- declare function useBatchNS(identity: IdentityString[], options?: QueryOptions): NSBatchResult;
193
-
194
- /**
195
- * Hook to query Web3.bio domain data by identity
196
- *
197
- * @param identity - Identity string
198
- * @param options - Optional configuration options
199
- * @returns Object containing domain data, loading state, and any errors
200
- *
201
- * @example
202
- * // Query by ENS name
203
- * const { data, isLoading, error } = useDomain("vitalik.eth");
204
- *
205
- * // Query by domain name with platform
206
- * const { data } = useDomain("ens,vitalik.eth");
207
- */
208
- declare function useDomain(identity: IdentityString, options?: QueryOptions): DomainResult;
209
-
210
- declare const API_ENDPOINT = "https://api.web3.bio";
211
- declare enum ErrorMessages {
212
- NOT_FOUND = "Not Found",
213
- INVALID_RESOLVER = "Invalid Resolver Address",
214
- INVALID_RESOLVED = "Invalid Resolved Address",
215
- NOT_EXIST = "Does Not Exist",
216
- INVALID_IDENTITY = "Invalid Identity or Domain",
217
- INVALID_ADDRESS = "Invalid Address",
218
- UNKNOWN_ERROR = "Unknown Error Occurred",
219
- NETWORK_ERROR = "Network Error"
220
- }
221
- declare enum QueryEndpoint {
222
- NS = "ns",
223
- PROFILE = "profile",
224
- DOMAIN = "domain"
225
- }
226
- declare const REGEX: {
227
- ENS: RegExp;
228
- BASENAMES: RegExp;
229
- LINEA: RegExp;
230
- FARCASTER: RegExp;
231
- LENS: RegExp;
232
- CLUSTER: RegExp;
233
- SPACE_ID: RegExp;
234
- GENOME: RegExp;
235
- UNSTOPPABLE_DOMAINS: RegExp;
236
- CROSSBELL: RegExp;
237
- DOTBIT: RegExp;
238
- SNS: RegExp;
239
- ETH_ADDRESS: RegExp;
240
- BTC_ADDRESS: RegExp;
241
- SOLANA_ADDRESS: RegExp;
242
- LOWERCASE_EXEMPT: RegExp;
243
- TWITTER: RegExp;
244
- NEXT_ID: RegExp;
245
- };
246
-
247
- export { API_ENDPOINT, DomainResponse, DomainResult, ErrorMessages, IdentityString, NSBatchResult, NSResponse, NSResult, NSUniversalResult, PlatformType, ProfileBatchResult, ProfileResponse, ProfileResult, ProfileUniversalResult, QueryEndpoint, QueryOptions, QueryResult, REGEX, SocialLinks, SocialLinksItem, SourceType, useBatchNS, useBatchProfile, useDomain, useNS, useProfile, useUniversalNS, useUniversalProfile };
1
+ export * from "./hooks";
2
+ export * from "./utils";
3
+ export * from "./types";