web3bio-profile-kit 0.1.0 → 0.1.2
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/README.md +12 -12
- package/dist/index.d.ts +60 -29
- package/dist/index.esm.js +120 -49
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +120 -49
- package/dist/index.js.map +1 -1
- package/dist/{hooks → types/hooks}/index.d.ts +3 -1
- package/dist/types/hooks/useBaseQuery.d.ts +6 -0
- package/dist/types/hooks/useBatchNS.d.ts +13 -0
- package/dist/types/hooks/useBatchProfile.d.ts +13 -0
- package/dist/{hooks → types/hooks}/useDomain.d.ts +3 -3
- package/dist/{hooks → types/hooks}/useNS.d.ts +3 -3
- package/dist/{hooks → types/hooks}/useProfile.d.ts +3 -3
- package/dist/{hooks → types/hooks}/useUniversalNS.d.ts +3 -3
- package/dist/{hooks → types/hooks}/useUniversalProfile.d.ts +3 -3
- package/dist/types/index.d.ts +3 -0
- package/dist/{utils → types/utils}/types.d.ts +9 -4
- package/package.json +12 -6
- package/dist/hooks/useBaseQuery.d.ts +0 -6
- /package/dist/{setupTests.d.ts → types/setupTests.d.ts} +0 -0
- /package/dist/{utils → types/utils}/constants.d.ts +0 -0
- /package/dist/{utils → types/utils}/helpers.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Web3.bio Profile Kit
|
|
2
2
|
|
|
3
|
-
A lightweight React hooks library for easily integrating Web3
|
|
3
|
+
A lightweight React hooks library for easily integrating Web3 profile data from Ethereum / ENS, Basenames, Farcaster, Lens, Linea Name Service, Solana / SNS, and more into your apps.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Web3.bio Profile Kit provides React hooks for querying the [Web3.bio Profile API](https://api.web3.bio/), which offers unified profile data across multiple Web3 platforms. This library makes it easy to fetch user profiles, name service information, and domain data.
|
|
8
|
+
|
|
9
|
+
More information about the Web3.bio Profile API can be found in the [document](https://api.web3.bio/).
|
|
4
10
|
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
@@ -12,12 +18,6 @@ yarn add web3bio-profile-kit
|
|
|
12
18
|
pnpm add web3bio-profile-kit
|
|
13
19
|
```
|
|
14
20
|
|
|
15
|
-
## Overview
|
|
16
|
-
|
|
17
|
-
Web3.bio Profile Kit provides React hooks for querying the [Web3.bio Profile API](https://api.web3.bio/), which offers unified profile data across multiple Web3 platforms. This library makes it easy to fetch user profiles, name service information, and domain data.
|
|
18
|
-
|
|
19
|
-
More information about the Web3.bio Profile API can be found in the [document](https://api.web3.bio/).
|
|
20
|
-
|
|
21
21
|
## API Key
|
|
22
22
|
|
|
23
23
|
The Profile API is free, but usage without API keys includes rate limiting mechanisms to ensure fair usage and prevent abuse. If you need an API Key, you can obtain one by contacting Web3.bio via [Twitter (X)](https://x.com/web3bio) or [Telegram group](https://t.me/web3dotbio).
|
|
@@ -156,18 +156,18 @@ function DomainComponent() {
|
|
|
156
156
|
### Batch Profile Query
|
|
157
157
|
|
|
158
158
|
```jsx
|
|
159
|
-
import {
|
|
159
|
+
import { useBatchProfile } from 'web3bio-profile-kit';
|
|
160
160
|
|
|
161
161
|
function BatchProfileComponent() {
|
|
162
|
-
const { data, isLoading } =
|
|
162
|
+
const { data, isLoading } = useBatchProfile([
|
|
163
163
|
"vitalik.eth",
|
|
164
|
-
"lens
|
|
164
|
+
"stani.lens"
|
|
165
165
|
]);
|
|
166
166
|
|
|
167
167
|
// You can also use useNS for batch queries
|
|
168
|
-
// const { data, isLoading } =
|
|
168
|
+
// const { data, isLoading } = useBatchNS([
|
|
169
169
|
// "vitalik.eth",
|
|
170
|
-
// "lens
|
|
170
|
+
// "stani.lens"
|
|
171
171
|
// ]);
|
|
172
172
|
|
|
173
173
|
if (isLoading) return <div>Loading...</div>;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ interface ProfileResponse {
|
|
|
49
49
|
status: string | null;
|
|
50
50
|
error?: string;
|
|
51
51
|
links: SocialLinks;
|
|
52
|
+
aliases?: string[];
|
|
52
53
|
social: {
|
|
53
54
|
uid: number | null;
|
|
54
55
|
follower: number;
|
|
@@ -62,6 +63,7 @@ interface NSResponse {
|
|
|
62
63
|
description: string | null;
|
|
63
64
|
platform: string;
|
|
64
65
|
displayName: string | null;
|
|
66
|
+
aliases?: string[];
|
|
65
67
|
}
|
|
66
68
|
interface DomainResponse {
|
|
67
69
|
identity: string;
|
|
@@ -86,20 +88,23 @@ type QueryOptions = {
|
|
|
86
88
|
enabled?: boolean;
|
|
87
89
|
};
|
|
88
90
|
type IdentityString = string | `${PlatformType},${string}`;
|
|
89
|
-
type Identity = IdentityString | IdentityString[];
|
|
90
91
|
type QueryResult<T> = {
|
|
91
92
|
data: T | null;
|
|
92
93
|
isLoading: boolean;
|
|
93
94
|
error: Error | null;
|
|
94
95
|
};
|
|
95
|
-
type
|
|
96
|
-
type
|
|
97
|
-
type
|
|
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>;
|
|
98
103
|
|
|
99
104
|
/**
|
|
100
105
|
* Hook to query Web3.bio profile data by identity
|
|
101
106
|
*
|
|
102
|
-
* @param identity - Identity string
|
|
107
|
+
* @param identity - Identity string
|
|
103
108
|
* @param options - Optional configuration options
|
|
104
109
|
* @returns Object containing profile data, loading state, and any errors
|
|
105
110
|
*
|
|
@@ -110,12 +115,12 @@ type DomainQueryResult = QueryResult<DomainResponse>;
|
|
|
110
115
|
* // Query with platform specification
|
|
111
116
|
* const { data } = useProfile("farcaster,dwr");
|
|
112
117
|
*/
|
|
113
|
-
declare function useProfile(identity:
|
|
118
|
+
declare function useProfile(identity: IdentityString, options?: QueryOptions): ProfileResult;
|
|
114
119
|
|
|
115
120
|
/**
|
|
116
121
|
* Hook to query Web3.bio name service (NS) data by identity
|
|
117
122
|
*
|
|
118
|
-
* @param identity - Identity string
|
|
123
|
+
* @param identity - Identity string
|
|
119
124
|
* @param options - Optional configuration options
|
|
120
125
|
* @returns Object containing NS data, loading state, and any errors
|
|
121
126
|
*
|
|
@@ -126,28 +131,12 @@ declare function useProfile(identity: Identity, options?: QueryOptions): Profile
|
|
|
126
131
|
* // Query by Ethereum address
|
|
127
132
|
* const { data } = useNS("0x123...");
|
|
128
133
|
*/
|
|
129
|
-
declare function useNS(identity:
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Hook to query Web3.bio domain data by identity
|
|
133
|
-
*
|
|
134
|
-
* @param identity - Identity string or array of identities to query
|
|
135
|
-
* @param options - Optional configuration options
|
|
136
|
-
* @returns Object containing domain data, loading state, and any errors
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* // Query by ENS name
|
|
140
|
-
* const { data, isLoading, error } = useDomain("vitalik.eth");
|
|
141
|
-
*
|
|
142
|
-
* // Query by domain name with platform
|
|
143
|
-
* const { data } = useDomain("ens,vitalik.eth");
|
|
144
|
-
*/
|
|
145
|
-
declare function useDomain(identity: Identity, options?: QueryOptions): DomainQueryResult;
|
|
134
|
+
declare function useNS(identity: IdentityString, options?: QueryOptions): NSResult;
|
|
146
135
|
|
|
147
136
|
/**
|
|
148
137
|
* Hook to query Web3.bio profile data using universal identity lookup
|
|
149
138
|
*
|
|
150
|
-
* @param identity - Identity string
|
|
139
|
+
* @param identity - Identity string
|
|
151
140
|
* @param options - Optional configuration options
|
|
152
141
|
* @returns Object containing profile data, loading state, and any errors
|
|
153
142
|
*
|
|
@@ -158,12 +147,12 @@ declare function useDomain(identity: Identity, options?: QueryOptions): DomainQu
|
|
|
158
147
|
* // Query by any identity type with universal lookup
|
|
159
148
|
* const { data } = useUniversalProfile("dwr.farcaster");
|
|
160
149
|
*/
|
|
161
|
-
declare function useUniversalProfile(identity:
|
|
150
|
+
declare function useUniversalProfile(identity: IdentityString, options?: QueryOptions): ProfileUniversalResult;
|
|
162
151
|
|
|
163
152
|
/**
|
|
164
153
|
* Hook to query Web3.bio name service (NS) data using universal identity lookup
|
|
165
154
|
*
|
|
166
|
-
* @param identity - Identity string
|
|
155
|
+
* @param identity - Identity string
|
|
167
156
|
* @param options - Optional configuration options
|
|
168
157
|
* @returns Object containing NS data, loading state, and any errors
|
|
169
158
|
*
|
|
@@ -174,7 +163,49 @@ declare function useUniversalProfile(identity: Identity, options?: QueryOptions)
|
|
|
174
163
|
* // Query by any identity type with universal lookup
|
|
175
164
|
* const { data } = useUniversalNS("dwr.farcaster");
|
|
176
165
|
*/
|
|
177
|
-
declare function useUniversalNS(identity:
|
|
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;
|
|
178
209
|
|
|
179
210
|
declare const API_ENDPOINT = "https://api.web3.bio";
|
|
180
211
|
declare enum ErrorMessages {
|
|
@@ -213,4 +244,4 @@ declare const REGEX: {
|
|
|
213
244
|
NEXT_ID: RegExp;
|
|
214
245
|
};
|
|
215
246
|
|
|
216
|
-
export { API_ENDPOINT,
|
|
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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
const API_ENDPOINT = "https://api.web3.bio";
|
|
4
4
|
var ErrorMessages;
|
|
@@ -180,36 +180,78 @@ const getApiKey = (userProvidedKey) => {
|
|
|
180
180
|
* Constructs the API URL based on query parameters
|
|
181
181
|
*/
|
|
182
182
|
const buildApiUrl = (identity, endpoint, universal) => {
|
|
183
|
-
// Handle batch
|
|
183
|
+
// Handle batch requests
|
|
184
184
|
if (Array.isArray(identity)) {
|
|
185
|
-
return `${API_ENDPOINT}/${endpoint}/batch/${JSON.stringify(identity)}`;
|
|
185
|
+
return `${API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;
|
|
186
186
|
}
|
|
187
|
-
// Handle
|
|
187
|
+
// Handle universal queries
|
|
188
188
|
if (universal) {
|
|
189
189
|
return `${API_ENDPOINT}/${endpoint}/${identity}`;
|
|
190
190
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
// Handle platform-specific queries
|
|
192
|
+
const resolvedId = resolveIdentity(identity);
|
|
193
|
+
if (!resolvedId)
|
|
194
|
+
return null;
|
|
195
|
+
// Domain endpoint uses resolved ID directly
|
|
196
|
+
if (endpoint === QueryEndpoint.DOMAIN) {
|
|
197
|
+
return `${API_ENDPOINT}/${endpoint}/${resolvedId}`;
|
|
197
198
|
}
|
|
199
|
+
// Other endpoints need platform/handle split
|
|
200
|
+
const [platform, handle] = resolvedId.split(",");
|
|
201
|
+
return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;
|
|
202
|
+
};
|
|
203
|
+
// Generate a stable cache key for this request
|
|
204
|
+
const getCacheKey = (identity, endpoint, universal) => {
|
|
205
|
+
return JSON.stringify({
|
|
206
|
+
identity,
|
|
207
|
+
endpoint,
|
|
208
|
+
universal,
|
|
209
|
+
});
|
|
198
210
|
};
|
|
211
|
+
// Create a cache to store results across component instances and re-renders
|
|
212
|
+
const globalRequestCache = new Map();
|
|
199
213
|
/**
|
|
200
214
|
* Core hook for querying Web3.bio Profile API
|
|
201
215
|
*/
|
|
202
216
|
function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
203
217
|
const { apiKey: userApiKey, enabled = true } = options;
|
|
204
218
|
const apiKey = getApiKey(userApiKey);
|
|
205
|
-
const [data, setData] = useState(
|
|
219
|
+
const [data, setData] = useState(() => {
|
|
220
|
+
// Initialize state from cache if available
|
|
221
|
+
const cacheKey = getCacheKey(identity, endpoint, universal);
|
|
222
|
+
return globalRequestCache.get(cacheKey) || null;
|
|
223
|
+
});
|
|
206
224
|
const [isLoading, setIsLoading] = useState(false);
|
|
207
225
|
const [error, setError] = useState(null);
|
|
226
|
+
// Use ref to track in-flight requests and prevent race conditions
|
|
227
|
+
const requestIdRef = useRef(0);
|
|
228
|
+
const prevParamsRef = useRef("");
|
|
229
|
+
// Current request parameters as a string for comparison
|
|
230
|
+
const currentParams = JSON.stringify({
|
|
231
|
+
identity,
|
|
232
|
+
endpoint,
|
|
233
|
+
universal,
|
|
234
|
+
});
|
|
208
235
|
useEffect(() => {
|
|
209
236
|
// Don't run the query if disabled or no identity
|
|
210
237
|
if (!enabled || !identity)
|
|
211
238
|
return;
|
|
212
|
-
|
|
239
|
+
// Skip if parameters haven't changed
|
|
240
|
+
if (currentParams === prevParamsRef.current && data !== null) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// Update previous parameters
|
|
244
|
+
prevParamsRef.current = currentParams;
|
|
245
|
+
// Generate cache key
|
|
246
|
+
const cacheKey = getCacheKey(identity, endpoint, universal);
|
|
247
|
+
// Check if we already have cached data
|
|
248
|
+
const cachedData = globalRequestCache.get(cacheKey);
|
|
249
|
+
if (cachedData) {
|
|
250
|
+
setData(cachedData);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
// Increment request ID to track the latest request
|
|
254
|
+
const requestId = ++requestIdRef.current;
|
|
213
255
|
setIsLoading(true);
|
|
214
256
|
setError(null);
|
|
215
257
|
const fetchData = async () => {
|
|
@@ -219,11 +261,11 @@ function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
|
219
261
|
throw new Error(ErrorMessages.INVALID_IDENTITY);
|
|
220
262
|
}
|
|
221
263
|
const headers = apiKey ? { "x-api-key": apiKey } : {};
|
|
222
|
-
const
|
|
264
|
+
const fetchOptions = {
|
|
223
265
|
method: "GET",
|
|
224
266
|
headers,
|
|
225
|
-
|
|
226
|
-
|
|
267
|
+
};
|
|
268
|
+
const response = await fetch(url, fetchOptions);
|
|
227
269
|
if (!response.ok) {
|
|
228
270
|
throw new Error(`API error: ${response.status}`);
|
|
229
271
|
}
|
|
@@ -231,29 +273,28 @@ function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
|
231
273
|
if (responseData === null || responseData === void 0 ? void 0 : responseData.error) {
|
|
232
274
|
throw new Error(responseData.error);
|
|
233
275
|
}
|
|
234
|
-
|
|
276
|
+
if (requestId === requestIdRef.current) {
|
|
277
|
+
globalRequestCache.set(cacheKey, responseData);
|
|
278
|
+
setData(responseData);
|
|
279
|
+
setIsLoading(false);
|
|
280
|
+
}
|
|
235
281
|
}
|
|
236
282
|
catch (err) {
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
finally {
|
|
242
|
-
setIsLoading(false);
|
|
283
|
+
if (requestId === requestIdRef.current) {
|
|
284
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
285
|
+
setIsLoading(false);
|
|
286
|
+
}
|
|
243
287
|
}
|
|
244
288
|
};
|
|
245
289
|
fetchData();
|
|
246
|
-
|
|
247
|
-
controller.abort();
|
|
248
|
-
};
|
|
249
|
-
}, [identity, apiKey, enabled, endpoint, universal]);
|
|
290
|
+
}, [currentParams, enabled]);
|
|
250
291
|
return { data, isLoading, error };
|
|
251
292
|
}
|
|
252
293
|
|
|
253
294
|
/**
|
|
254
295
|
* Hook to query Web3.bio profile data by identity
|
|
255
296
|
*
|
|
256
|
-
* @param identity - Identity string
|
|
297
|
+
* @param identity - Identity string
|
|
257
298
|
* @param options - Optional configuration options
|
|
258
299
|
* @returns Object containing profile data, loading state, and any errors
|
|
259
300
|
*
|
|
@@ -271,7 +312,7 @@ function useProfile(identity, options = {}) {
|
|
|
271
312
|
/**
|
|
272
313
|
* Hook to query Web3.bio name service (NS) data by identity
|
|
273
314
|
*
|
|
274
|
-
* @param identity - Identity string
|
|
315
|
+
* @param identity - Identity string
|
|
275
316
|
* @param options - Optional configuration options
|
|
276
317
|
* @returns Object containing NS data, loading state, and any errors
|
|
277
318
|
*
|
|
@@ -286,28 +327,10 @@ function useNS(identity, options = {}) {
|
|
|
286
327
|
return useBaseQuery(identity, QueryEndpoint.NS, false, options);
|
|
287
328
|
}
|
|
288
329
|
|
|
289
|
-
/**
|
|
290
|
-
* Hook to query Web3.bio domain data by identity
|
|
291
|
-
*
|
|
292
|
-
* @param identity - Identity string or array of identities to query
|
|
293
|
-
* @param options - Optional configuration options
|
|
294
|
-
* @returns Object containing domain data, loading state, and any errors
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* // Query by ENS name
|
|
298
|
-
* const { data, isLoading, error } = useDomain("vitalik.eth");
|
|
299
|
-
*
|
|
300
|
-
* // Query by domain name with platform
|
|
301
|
-
* const { data } = useDomain("ens,vitalik.eth");
|
|
302
|
-
*/
|
|
303
|
-
function useDomain(identity, options = {}) {
|
|
304
|
-
return useBaseQuery(identity, QueryEndpoint.DOMAIN, false, options);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
330
|
/**
|
|
308
331
|
* Hook to query Web3.bio profile data using universal identity lookup
|
|
309
332
|
*
|
|
310
|
-
* @param identity - Identity string
|
|
333
|
+
* @param identity - Identity string
|
|
311
334
|
* @param options - Optional configuration options
|
|
312
335
|
* @returns Object containing profile data, loading state, and any errors
|
|
313
336
|
*
|
|
@@ -325,7 +348,7 @@ function useUniversalProfile(identity, options = {}) {
|
|
|
325
348
|
/**
|
|
326
349
|
* Hook to query Web3.bio name service (NS) data using universal identity lookup
|
|
327
350
|
*
|
|
328
|
-
* @param identity - Identity string
|
|
351
|
+
* @param identity - Identity string
|
|
329
352
|
* @param options - Optional configuration options
|
|
330
353
|
* @returns Object containing NS data, loading state, and any errors
|
|
331
354
|
*
|
|
@@ -340,5 +363,53 @@ function useUniversalNS(identity, options = {}) {
|
|
|
340
363
|
return useBaseQuery(identity, QueryEndpoint.NS, true, options);
|
|
341
364
|
}
|
|
342
365
|
|
|
343
|
-
|
|
366
|
+
/**
|
|
367
|
+
* Hook to query Web3.bio profile data using batch identity lookup
|
|
368
|
+
*
|
|
369
|
+
* @param identity - array of Identity string
|
|
370
|
+
* @param options - Optional configuration options
|
|
371
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* // Query by any identity type with batch lookup
|
|
375
|
+
* const { data } = useBatchProfile(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
376
|
+
*/
|
|
377
|
+
function useBatchProfile(identity, options = {}) {
|
|
378
|
+
return useBaseQuery(identity, QueryEndpoint.PROFILE, false, options);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Hook to query Web3.bio profile data using batch(NS) identity lookup
|
|
383
|
+
*
|
|
384
|
+
* @param identity - array of Identity string
|
|
385
|
+
* @param options - Optional configuration options
|
|
386
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* // Query by any identity type with batch lookup
|
|
390
|
+
* const { data } = useBatchNS(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
391
|
+
*/
|
|
392
|
+
function useBatchNS(identity, options = {}) {
|
|
393
|
+
return useBaseQuery(identity, QueryEndpoint.NS, false, options);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Hook to query Web3.bio domain data by identity
|
|
398
|
+
*
|
|
399
|
+
* @param identity - Identity string
|
|
400
|
+
* @param options - Optional configuration options
|
|
401
|
+
* @returns Object containing domain data, loading state, and any errors
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* // Query by ENS name
|
|
405
|
+
* const { data, isLoading, error } = useDomain("vitalik.eth");
|
|
406
|
+
*
|
|
407
|
+
* // Query by domain name with platform
|
|
408
|
+
* const { data } = useDomain("ens,vitalik.eth");
|
|
409
|
+
*/
|
|
410
|
+
function useDomain(identity, options = {}) {
|
|
411
|
+
return useBaseQuery(identity, QueryEndpoint.DOMAIN, false, options);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export { API_ENDPOINT, ErrorMessages, PlatformType, QueryEndpoint, REGEX, SourceType, useBatchNS, useBatchProfile, useDomain, useNS, useProfile, useUniversalNS, useUniversalProfile };
|
|
344
415
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/utils/constants.ts","../src/utils/types.ts","../src/utils/helpers.ts","../src/hooks/useBaseQuery.ts","../src/hooks/useProfile.ts","../src/hooks/useNS.ts","../src/hooks/useDomain.ts","../src/hooks/useUniversalProfile.ts","../src/hooks/useUniversalNS.ts"],"sourcesContent":["export const API_ENDPOINT = \"https://api.web3.bio\";\n\nexport enum ErrorMessages {\n NOT_FOUND = \"Not Found\",\n INVALID_RESOLVER = \"Invalid Resolver Address\",\n INVALID_RESOLVED = \"Invalid Resolved Address\",\n NOT_EXIST = \"Does Not Exist\",\n INVALID_IDENTITY = \"Invalid Identity or Domain\",\n INVALID_ADDRESS = \"Invalid Address\",\n UNKNOWN_ERROR = \"Unknown Error Occurred\",\n NETWORK_ERROR = \"Network Error\",\n}\n\nexport enum QueryEndpoint {\n NS = \"ns\",\n PROFILE = \"profile\",\n DOMAIN = \"domain\",\n}\n\n// Regular expressions for identity detection\nexport const REGEX = {\n ENS: /^.+\\.(eth|xyz|bio|app|luxe|kred|art|ceo|club|box)$/i,\n BASENAMES: /^.+\\.base(\\.eth)?$/i,\n LINEA: /^.+\\.linea(\\.eth)?$/i,\n FARCASTER: /^(?:[A-Za-z0-9_-]{1,61}(?:(?:\\.eth)?(?:\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)?)?|farcaster,#\\d+)$/i,\n LENS: /^(?:.+\\.lens)$/i,\n CLUSTER: /^[\\w-]+\\/[\\w-]+$/,\n SPACE_ID: /^.+\\.(bnb|arb)$/i,\n GENOME: /^.+\\.gno$/i,\n UNSTOPPABLE_DOMAINS: /^.+\\.(crypto|888|nft|blockchain|bitcoin|dao|x|klever|hi|zil|kresus|polygon|wallet|binanceus|anime|go|manga|eth)$/i,\n CROSSBELL: /^.+\\.csb$/i,\n DOTBIT: /^.+\\.bit$/i,\n SNS: /^.+\\.sol$/i,\n ETH_ADDRESS: /^0x[a-fA-F0-9]{40}$/i,\n BTC_ADDRESS: /\\b([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qp][a-z0-9]{11,71})\\b/,\n SOLANA_ADDRESS: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/,\n 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/,\n TWITTER: /^[A-Za-z0-9_]{1,15}(?:\\.twitter)?$/i,\n NEXT_ID: /^0x[a-f0-9]{66}(?:\\.nextid)?$/i,\n};","export enum PlatformType {\n ens = \"ens\",\n farcaster = \"farcaster\",\n lens = \"lens\",\n ethereum = \"ethereum\",\n twitter = \"twitter\",\n github = \"github\",\n bitcoin = \"bitcoin\",\n unstoppableDomains = \"unstoppabledomains\",\n basenames = \"basenames\",\n linea = \"linea\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n}\n\nexport enum SourceType {\n ethereum = \"ethereum\",\n ens = \"ens\",\n twitter = \"twitter\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n unstoppabledomains = \"unstoppabledomains\",\n lens = \"lens\",\n farcaster = \"farcaster\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n}\n\nexport type SocialLinksItem = {\n link: string | null;\n handle: string | null;\n sources: SourceType[];\n};\n\nexport type SocialLinks = Record<string, SocialLinksItem>;\n\nexport interface ProfileResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n email: string | null;\n contenthash: string | null;\n header: string | null;\n location: string | null;\n createdAt: string | null;\n status: string | null;\n error?: string;\n links: SocialLinks;\n social:\n | {\n uid: number | null;\n follower: number;\n following: number;\n }\n | {};\n}\n\nexport interface NSResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n}\n\nexport interface DomainResponse {\n identity: string;\n platform: PlatformType;\n resolvedAddress: string | null;\n ownerAddress: string | null;\n managerAddress: string | null;\n displayName: string | null;\n isPrimary: boolean;\n status: string;\n createdAt: string | null;\n updatedAt: string | null;\n expiredAt: string | null;\n contenthash: string | null;\n texts: Record<string, string>;\n addresses: Record<string, string>;\n}\n\nexport type QueryOptions = {\n /** API Key for authentication */\n apiKey?: string;\n /** Whether the query should execute */\n enabled?: boolean;\n};\n\nexport type IdentityString = string | `${PlatformType},${string}`;\nexport type Identity = IdentityString | IdentityString[];\n\nexport type QueryResult<T> = {\n data: T | null;\n isLoading: boolean;\n error: Error | null;\n};\n\n// Query-specific result types for better type safety\nexport type ProfileQueryResult = QueryResult<ProfileResponse>;\nexport type NSQueryResult = QueryResult<NSResponse>;\nexport type DomainQueryResult = QueryResult<DomainResponse>;\n","import { REGEX } from \"./constants\";\nimport { PlatformType, Identity } from \"./types\";\n\n/**\n * Resolves an identity string to a platform and identifier\n * @param input The identity to resolve\n * @returns A formatted identity string or null if invalid\n */\nexport const resolveIdentity = (input: string): string | null => {\n if (!input) return null;\n\n const parts = input.split(\",\");\n\n let platform: PlatformType;\n let identity: string;\n\n if (parts.length === 2) {\n // Format is already \"platform,identity\"\n platform = parts[0] as PlatformType;\n identity = prettify(parts[1]);\n } else if (parts.length === 1) {\n // Auto-detect platform from the identity string\n platform = detectPlatform(input);\n identity = prettify(input);\n } else {\n return null;\n }\n\n if (!isSupportedPlatform(platform) || !identity) return null;\n\n // Normalize case except for case-sensitive identities\n const normalizedIdentity = REGEX.LOWERCASE_EXEMPT.test(identity)\n ? identity\n : identity.toLowerCase();\n\n return `${platform},${normalizedIdentity}`;\n};\n\n/**\n * Clean up and standardize identity format\n */\nexport const prettify = (input: string): string => {\n if (!input) return \"\";\n if (input.endsWith(\".twitter\")) return input.replace(\".twitter\", \"\");\n if (input.endsWith(\".nextid\")) return input.replace(\".nextid\", \"\");\n if (input.startsWith(\"farcaster,#\"))\n return input.replace(/^(farcaster),/, \"\");\n if (\n input.endsWith(\".farcaster\") ||\n input.endsWith(\".fcast.id\") ||\n input.endsWith(\".farcaster.eth\")\n ) {\n return input.replace(/(\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)$/, \"\");\n }\n if (input.endsWith(\".base\") || input.endsWith(\".linea\")) {\n return input.split(\".\")[0] + \".\" + input.split(\".\").pop() + \".eth\";\n }\n return input;\n};\n\n/**\n * Check if the platform is supported for API queries\n */\nexport const isSupportedPlatform = (\n platform?: PlatformType | null,\n): boolean => {\n if (!platform) return false;\n return Object.values(PlatformType).includes(platform as PlatformType);\n};\n\n/**\n * Detect platform from identity string based on regex patterns\n */\nexport const detectPlatform = (term: string): PlatformType => {\n if (term.endsWith(\".farcaster.eth\")) return PlatformType.farcaster;\n\n const platformMap: [RegExp, PlatformType][] = [\n [REGEX.BASENAMES, PlatformType.basenames],\n [REGEX.LINEA, PlatformType.linea],\n [REGEX.ENS, PlatformType.ens],\n [REGEX.ETH_ADDRESS, PlatformType.ethereum],\n [REGEX.LENS, PlatformType.lens],\n [REGEX.UNSTOPPABLE_DOMAINS, PlatformType.unstoppableDomains],\n [REGEX.SPACE_ID, PlatformType.space_id],\n [REGEX.DOTBIT, PlatformType.dotbit],\n [REGEX.SNS, PlatformType.sns],\n [REGEX.BTC_ADDRESS, PlatformType.bitcoin],\n [REGEX.SOLANA_ADDRESS, PlatformType.solana],\n [REGEX.FARCASTER, PlatformType.farcaster],\n [REGEX.TWITTER, PlatformType.twitter],\n [REGEX.NEXT_ID, PlatformType.nextid],\n ];\n\n for (const [regex, platformType] of platformMap) {\n if (regex.test(term)) {\n return platformType;\n }\n }\n\n // Default fallback\n return term.includes(\".\") ? PlatformType.ens : PlatformType.farcaster;\n};\n\n/**\n * Get API key from various environment sources or user provided value\n */\nexport const getApiKey = (userProvidedKey?: string): string | undefined => {\n return (\n userProvidedKey ||\n process.env.WEB3BIO_API_KEY ||\n process.env.REACT_APP_WEB3BIO_API_KEY ||\n process.env.NEXT_PUBLIC_WEB3BIO_API_KEY ||\n process.env.VITE_WEB3BIO_API_KEY\n );\n};\n","import { useState, useEffect } from \"react\";\nimport { API_ENDPOINT, ErrorMessages, QueryEndpoint } from \"../utils/constants\";\nimport { getApiKey, resolveIdentity } from \"../utils/helpers\";\nimport { Identity, QueryOptions, QueryResult } from \"../utils/types\";\n\n/**\n * Constructs the API URL based on query parameters\n */\nconst buildApiUrl = (\n identity: Identity,\n endpoint: QueryEndpoint,\n universal: boolean,\n): string | null => {\n // Handle batch queries (array of identities)\n if (Array.isArray(identity)) {\n return `${API_ENDPOINT}/${endpoint}/batch/${JSON.stringify(identity)}`;\n }\n\n // Handle single identity query\n if (universal) {\n return `${API_ENDPOINT}/${endpoint}/${identity}`;\n } else {\n const resolvedId = resolveIdentity(identity);\n if (!resolvedId) return null;\n\n const [platform, handle] = resolvedId.split(\",\");\n return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;\n }\n};\n\n/**\n * Core hook for querying Web3.bio Profile API\n */\nexport function useBaseQuery<T>(\n identity: Identity,\n endpoint: QueryEndpoint,\n universal: boolean = false,\n options: QueryOptions = {},\n): QueryResult<T> {\n const { apiKey: userApiKey, enabled = true } = options;\n const apiKey = getApiKey(userApiKey);\n\n const [data, setData] = useState<T | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n // Don't run the query if disabled or no identity\n if (!enabled || !identity) return;\n\n const controller = new AbortController();\n setIsLoading(true);\n setError(null);\n\n const fetchData = async () => {\n try {\n const url = buildApiUrl(identity, endpoint, universal);\n\n if (!url) {\n throw new Error(ErrorMessages.INVALID_IDENTITY);\n }\n\n const headers: HeadersInit = apiKey ? { \"x-api-key\": apiKey } : {};\n\n const response = await fetch(url, {\n method: \"GET\",\n headers,\n signal: controller.signal,\n });\n\n if (!response.ok) {\n throw new Error(`API error: ${response.status}`);\n }\n\n const responseData = await response.json();\n\n if (responseData?.error) {\n throw new Error(responseData.error);\n }\n\n setData(responseData as T);\n } catch (err) {\n if (err instanceof Error && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n };\n\n fetchData();\n\n return () => {\n controller.abort();\n };\n }, [identity, apiKey, enabled, endpoint, universal]);\n\n return { data, isLoading, error };\n}\n","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, ProfileQueryResult, ProfileResponse, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data by identity\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n * \n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useProfile(\"vitalik.eth\");\n * \n * // Query with platform specification\n * const { data } = useProfile(\"farcaster,dwr\");\n */\nexport function useProfile(\n identity: Identity,\n options: QueryOptions = {}\n): ProfileQueryResult {\n return useBaseQuery<ProfileResponse>(identity, QueryEndpoint.PROFILE, false, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, NSResponse, NSQueryResult, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data by identity\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n * \n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useNS(\"vitalik.eth\");\n * \n * // Query by Ethereum address\n * const { data } = useNS(\"0x123...\");\n */\nexport function useNS(\n identity: Identity,\n options: QueryOptions = {}\n): NSQueryResult {\n return useBaseQuery<NSResponse>(identity, QueryEndpoint.NS, false, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { DomainQueryResult, DomainResponse, Identity, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio domain data by identity\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing domain data, loading state, and any errors\n * \n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useDomain(\"vitalik.eth\");\n * \n * // Query by domain name with platform\n * const { data } = useDomain(\"ens,vitalik.eth\");\n */\nexport function useDomain(\n identity: Identity,\n options: QueryOptions = {}\n): DomainQueryResult {\n return useBaseQuery<DomainResponse>(identity, QueryEndpoint.DOMAIN, false, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, ProfileQueryResult, ProfileResponse, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using universal identity lookup\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n * \n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalProfile(\"vitalik.eth\");\n * \n * // Query by any identity type with universal lookup\n * const { data } = useUniversalProfile(\"dwr.farcaster\");\n */\nexport function useUniversalProfile(\n identity: Identity,\n options: QueryOptions = {}\n): ProfileQueryResult {\n return useBaseQuery<ProfileResponse>(identity, QueryEndpoint.PROFILE, true, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, NSResponse, NSQueryResult, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data using universal identity lookup\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n * \n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalNS(\"vitalik.eth\");\n * \n * // Query by any identity type with universal lookup\n * const { data } = useUniversalNS(\"dwr.farcaster\");\n */\nexport function useUniversalNS(\n identity: Identity,\n options: QueryOptions = {}\n): NSQueryResult {\n return useBaseQuery<NSResponse>(identity, QueryEndpoint.NS, true, options);\n}"],"names":[],"mappings":";;AAAO,MAAM,YAAY,GAAG,uBAAuB;IAEvC,cASX;AATD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,WAAA,CAAA,GAAA,WAAuB,CAAA;AACvB,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,0BAA6C,CAAA;AAC7C,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,0BAA6C,CAAA;AAC7C,IAAA,aAAA,CAAA,WAAA,CAAA,GAAA,gBAA4B,CAAA;AAC5B,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,4BAA+C,CAAA;AAC/C,IAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,aAAA,CAAA,eAAA,CAAA,GAAA,wBAAwC,CAAA;AACxC,IAAA,aAAA,CAAA,eAAA,CAAA,GAAA,eAA+B,CAAA;AACjC,CAAC,EATW,aAAa,KAAb,aAAa,GASxB,EAAA,CAAA,CAAA,CAAA;IAEW,cAIX;AAJD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACT,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,I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EAClB,UAAwB,EAAE,EAAA;AAE1B,IAAA,OAAO,YAAY,CAAiB,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACtF;;ACnBA;;;;;;;;;;;;;AAaG;SACa,mBAAmB,CACjC,QAAkB,EAClB,UAAwB,EAAE,EAAA;AAE1B,IAAA,OAAO,YAAY,CAAkB,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACvF;;ACnBA;;;;;;;;;;;;;AAaG;SACa,cAAc,CAC5B,QAAkB,EAClB,UAAwB,EAAE,EAAA;AAE1B,IAAA,OAAO,YAAY,CAAa,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7E;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/utils/constants.ts","../src/utils/types.ts","../src/utils/helpers.ts","../src/hooks/useBaseQuery.ts","../src/hooks/useProfile.ts","../src/hooks/useNS.ts","../src/hooks/useUniversalProfile.ts","../src/hooks/useUniversalNS.ts","../src/hooks/useBatchProfile.ts","../src/hooks/useBatchNS.ts","../src/hooks/useDomain.ts"],"sourcesContent":["export const API_ENDPOINT = \"https://api.web3.bio\";\n\nexport enum ErrorMessages {\n NOT_FOUND = \"Not Found\",\n INVALID_RESOLVER = \"Invalid Resolver Address\",\n INVALID_RESOLVED = \"Invalid Resolved Address\",\n NOT_EXIST = \"Does Not Exist\",\n INVALID_IDENTITY = \"Invalid Identity or Domain\",\n INVALID_ADDRESS = \"Invalid Address\",\n UNKNOWN_ERROR = \"Unknown Error Occurred\",\n NETWORK_ERROR = \"Network Error\",\n}\n\nexport enum QueryEndpoint {\n NS = \"ns\",\n PROFILE = \"profile\",\n DOMAIN = \"domain\",\n}\n\n// Regular expressions for identity detection\nexport const REGEX = {\n ENS: /^.+\\.(eth|xyz|bio|app|luxe|kred|art|ceo|club|box)$/i,\n BASENAMES: /^.+\\.base(\\.eth)?$/i,\n LINEA: /^.+\\.linea(\\.eth)?$/i,\n FARCASTER:\n /^(?:[A-Za-z0-9_-]{1,61}(?:(?:\\.eth)?(?:\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)?)?|farcaster,#\\d+)$/i,\n LENS: /^(?:.+\\.lens)$/i,\n CLUSTER: /^[\\w-]+\\/[\\w-]+$/,\n SPACE_ID: /^.+\\.(bnb|arb)$/i,\n GENOME: /^.+\\.gno$/i,\n UNSTOPPABLE_DOMAINS:\n /^.+\\.(crypto|888|nft|blockchain|bitcoin|dao|x|klever|hi|zil|kresus|polygon|wallet|binanceus|anime|go|manga|eth)$/i,\n CROSSBELL: /^.+\\.csb$/i,\n DOTBIT: /^.+\\.bit$/i,\n SNS: /^.+\\.sol$/i,\n ETH_ADDRESS: /^0x[a-fA-F0-9]{40}$/i,\n BTC_ADDRESS: /\\b([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qp][a-z0-9]{11,71})\\b/,\n SOLANA_ADDRESS: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/,\n LOWERCASE_EXEMPT:\n /\\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/,\n TWITTER: /^[A-Za-z0-9_]{1,15}(?:\\.twitter)?$/i,\n NEXT_ID: /^0x[a-f0-9]{66}(?:\\.nextid)?$/i,\n};\n","export enum PlatformType {\n ens = \"ens\",\n farcaster = \"farcaster\",\n lens = \"lens\",\n ethereum = \"ethereum\",\n twitter = \"twitter\",\n github = \"github\",\n bitcoin = \"bitcoin\",\n unstoppableDomains = \"unstoppabledomains\",\n basenames = \"basenames\",\n linea = \"linea\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n}\n\nexport enum SourceType {\n ethereum = \"ethereum\",\n ens = \"ens\",\n twitter = \"twitter\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n unstoppabledomains = \"unstoppabledomains\",\n lens = \"lens\",\n farcaster = \"farcaster\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n}\n\nexport type SocialLinksItem = {\n link: string | null;\n handle: string | null;\n sources: SourceType[];\n};\n\nexport type SocialLinks = Record<string, SocialLinksItem>;\n\nexport interface ProfileResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n email: string | null;\n contenthash: string | null;\n header: string | null;\n location: string | null;\n createdAt: string | null;\n status: string | null;\n error?: string;\n links: SocialLinks;\n aliases?: string[];\n social:\n | {\n uid: number | null;\n follower: number;\n following: number;\n }\n | {};\n}\n\nexport interface NSResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n aliases?: string[];\n}\n\nexport interface DomainResponse {\n identity: string;\n platform: PlatformType;\n resolvedAddress: string | null;\n ownerAddress: string | null;\n managerAddress: string | null;\n displayName: string | null;\n isPrimary: boolean;\n status: string;\n createdAt: string | null;\n updatedAt: string | null;\n expiredAt: string | null;\n contenthash: string | null;\n texts: Record<string, string>;\n addresses: Record<string, string>;\n}\n\nexport type QueryOptions = {\n /** API Key for authentication */\n apiKey?: string;\n /** Whether the query should execute */\n enabled?: boolean;\n};\n\nexport type IdentityString = string | `${PlatformType},${string}`;\n\nexport type QueryResult<T> = {\n data: T | null;\n isLoading: boolean;\n error: Error | null;\n};\n\n// Query-specific result types for better type safety\nexport type ProfileResult = QueryResult<ProfileResponse>;\nexport type NSResult = QueryResult<NSResponse>;\nexport type ProfileBatchResult = QueryResult<ProfileResponse[]>;\nexport type NSBatchResult = QueryResult<NSResponse[]>;\nexport type ProfileUniversalResult = QueryResult<ProfileResponse[]>;\nexport type NSUniversalResult = QueryResult<NSResponse[]>;\nexport type DomainResult = QueryResult<DomainResponse>;\n","import { REGEX } from \"./constants\";\nimport { PlatformType } from \"./types\";\n\n/**\n * Resolves an identity string to a platform and identifier\n * @param input The identity to resolve\n * @returns A formatted identity string or null if invalid\n */\nexport const resolveIdentity = (input: string): string | null => {\n if (!input) return null;\n\n const parts = input.split(\",\");\n\n let platform: PlatformType;\n let identity: string;\n\n if (parts.length === 2) {\n // Format is already \"platform,identity\"\n platform = parts[0] as PlatformType;\n identity = prettify(parts[1]);\n } else if (parts.length === 1) {\n // Auto-detect platform from the identity string\n platform = detectPlatform(input);\n identity = prettify(input);\n } else {\n return null;\n }\n\n if (!isSupportedPlatform(platform) || !identity) return null;\n\n // Normalize case except for case-sensitive identities\n const normalizedIdentity = REGEX.LOWERCASE_EXEMPT.test(identity)\n ? identity\n : identity.toLowerCase();\n\n return `${platform},${normalizedIdentity}`;\n};\n\n/**\n * Clean up and standardize identity format\n */\nexport const prettify = (input: string): string => {\n if (!input) return \"\";\n if (input.endsWith(\".twitter\")) return input.replace(\".twitter\", \"\");\n if (input.endsWith(\".nextid\")) return input.replace(\".nextid\", \"\");\n if (input.startsWith(\"farcaster,#\"))\n return input.replace(/^(farcaster),/, \"\");\n if (\n input.endsWith(\".farcaster\") ||\n input.endsWith(\".fcast.id\") ||\n input.endsWith(\".farcaster.eth\")\n ) {\n return input.replace(/(\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)$/, \"\");\n }\n if (input.endsWith(\".base\") || input.endsWith(\".linea\")) {\n return input.split(\".\")[0] + \".\" + input.split(\".\").pop() + \".eth\";\n }\n return input;\n};\n\n/**\n * Check if the platform is supported for API queries\n */\nexport const isSupportedPlatform = (\n platform?: PlatformType | null,\n): boolean => {\n if (!platform) return false;\n return Object.values(PlatformType).includes(platform as PlatformType);\n};\n\n/**\n * Detect platform from identity string based on regex patterns\n */\nexport const detectPlatform = (term: string): PlatformType => {\n if (term.endsWith(\".farcaster.eth\")) return PlatformType.farcaster;\n\n const platformMap: [RegExp, PlatformType][] = [\n [REGEX.BASENAMES, PlatformType.basenames],\n [REGEX.LINEA, PlatformType.linea],\n [REGEX.ENS, PlatformType.ens],\n [REGEX.ETH_ADDRESS, PlatformType.ethereum],\n [REGEX.LENS, PlatformType.lens],\n [REGEX.UNSTOPPABLE_DOMAINS, PlatformType.unstoppableDomains],\n [REGEX.SPACE_ID, PlatformType.space_id],\n [REGEX.DOTBIT, PlatformType.dotbit],\n [REGEX.SNS, PlatformType.sns],\n [REGEX.BTC_ADDRESS, PlatformType.bitcoin],\n [REGEX.SOLANA_ADDRESS, PlatformType.solana],\n [REGEX.FARCASTER, PlatformType.farcaster],\n [REGEX.TWITTER, PlatformType.twitter],\n [REGEX.NEXT_ID, PlatformType.nextid],\n ];\n\n for (const [regex, platformType] of platformMap) {\n if (regex.test(term)) {\n return platformType;\n }\n }\n\n // Default fallback\n return term.includes(\".\") ? PlatformType.ens : PlatformType.farcaster;\n};\n\n/**\n * Get API key from various environment sources or user provided value\n */\nexport const getApiKey = (userProvidedKey?: string): string | undefined => {\n return (\n userProvidedKey ||\n process.env.WEB3BIO_API_KEY ||\n process.env.REACT_APP_WEB3BIO_API_KEY ||\n process.env.NEXT_PUBLIC_WEB3BIO_API_KEY ||\n process.env.VITE_WEB3BIO_API_KEY\n );\n};\n","import type { IdentityString, QueryOptions, QueryResult } from \"../utils/types\";\nimport { useState, useEffect, useRef } from \"react\";\nimport { API_ENDPOINT, ErrorMessages, QueryEndpoint } from \"../utils/constants\";\nimport { getApiKey, resolveIdentity } from \"../utils/helpers\";\n\n/**\n * Constructs the API URL based on query parameters\n */\nconst buildApiUrl = (\n identity: IdentityString | IdentityString[],\n endpoint: QueryEndpoint,\n universal: boolean,\n): string | null => {\n // Handle batch requests\n if (Array.isArray(identity)) {\n return `${API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;\n }\n\n // Handle universal queries\n if (universal) {\n return `${API_ENDPOINT}/${endpoint}/${identity}`;\n }\n\n // Handle platform-specific queries\n const resolvedId = resolveIdentity(identity);\n if (!resolvedId) return null;\n\n // Domain endpoint uses resolved ID directly\n if (endpoint === QueryEndpoint.DOMAIN) {\n return `${API_ENDPOINT}/${endpoint}/${resolvedId}`;\n }\n\n // Other endpoints need platform/handle split\n const [platform, handle] = resolvedId.split(\",\");\n return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;\n};\n\n// Generate a stable cache key for this request\nconst getCacheKey = (\n identity: IdentityString | IdentityString[],\n endpoint: QueryEndpoint,\n universal: boolean,\n): string => {\n return JSON.stringify({\n identity,\n endpoint,\n universal,\n });\n};\n\n// Create a cache to store results across component instances and re-renders\nconst globalRequestCache = new Map<string, any>();\n\n/**\n * Core hook for querying Web3.bio Profile API\n */\nexport function useBaseQuery<T>(\n identity: IdentityString | IdentityString[],\n endpoint: QueryEndpoint,\n universal: boolean = false,\n options: QueryOptions = {},\n): QueryResult<T> {\n const { apiKey: userApiKey, enabled = true } = options;\n const apiKey = getApiKey(userApiKey);\n\n const [data, setData] = useState<T | null>(() => {\n // Initialize state from cache if available\n const cacheKey = getCacheKey(identity, endpoint, universal);\n return (globalRequestCache.get(cacheKey) as T) || null;\n });\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n // Use ref to track in-flight requests and prevent race conditions\n const requestIdRef = useRef<number>(0);\n const prevParamsRef = useRef<string>(\"\");\n\n // Current request parameters as a string for comparison\n const currentParams = JSON.stringify({\n identity,\n endpoint,\n universal,\n });\n\n useEffect(() => {\n // Don't run the query if disabled or no identity\n if (!enabled || !identity) return;\n\n // Skip if parameters haven't changed\n if (currentParams === prevParamsRef.current && data !== null) {\n return;\n }\n\n // Update previous parameters\n prevParamsRef.current = currentParams;\n\n // Generate cache key\n const cacheKey = getCacheKey(identity, endpoint, universal);\n\n // Check if we already have cached data\n const cachedData = globalRequestCache.get(cacheKey) as T | undefined;\n if (cachedData) {\n setData(cachedData);\n return;\n }\n\n // Increment request ID to track the latest request\n const requestId = ++requestIdRef.current;\n\n setIsLoading(true);\n setError(null);\n\n const fetchData = async () => {\n try {\n const url = buildApiUrl(identity, endpoint, universal);\n\n if (!url) {\n throw new Error(ErrorMessages.INVALID_IDENTITY);\n }\n\n const headers: HeadersInit = apiKey ? { \"x-api-key\": apiKey } : {};\n\n const fetchOptions: RequestInit = {\n method: \"GET\",\n headers,\n };\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n throw new Error(`API error: ${response.status}`);\n }\n\n const responseData = await response.json();\n\n if (responseData?.error) {\n throw new Error(responseData.error);\n }\n\n if (requestId === requestIdRef.current) {\n globalRequestCache.set(cacheKey, responseData);\n setData(responseData as T);\n setIsLoading(false);\n }\n } catch (err) {\n if (requestId === requestIdRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n }\n };\n\n fetchData();\n }, [currentParams, enabled]);\n\n return { data, isLoading, error };\n}\n","import type {\n IdentityString,\n ProfileResponse,\n ProfileResult,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data by identity\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useProfile(\"vitalik.eth\");\n *\n * // Query with platform specification\n * const { data } = useProfile(\"farcaster,dwr\");\n */\nexport function useProfile(\n identity: IdentityString,\n options: QueryOptions = {},\n): ProfileResult {\n return useBaseQuery<ProfileResponse>(\n identity,\n QueryEndpoint.PROFILE,\n false,\n options,\n );\n}\n","import type {\n NSResponse,\n QueryOptions,\n IdentityString,\n NSResult,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data by identity\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n *\n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useNS(\"vitalik.eth\");\n *\n * // Query by Ethereum address\n * const { data } = useNS(\"0x123...\");\n */\nexport function useNS(\n identity: IdentityString,\n options: QueryOptions = {},\n): NSResult {\n return useBaseQuery<NSResponse>(identity, QueryEndpoint.NS, false, options);\n}\n","import type {\n IdentityString,\n ProfileResponse,\n ProfileUniversalResult,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using universal identity lookup\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalProfile(\"vitalik.eth\");\n *\n * // Query by any identity type with universal lookup\n * const { data } = useUniversalProfile(\"dwr.farcaster\");\n */\nexport function useUniversalProfile(\n identity: IdentityString,\n options: QueryOptions = {},\n): ProfileUniversalResult {\n return useBaseQuery<ProfileResponse[]>(\n identity,\n QueryEndpoint.PROFILE,\n true,\n options,\n );\n}\n","import type {\n NSResponse,\n QueryOptions,\n IdentityString,\n NSUniversalResult,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data using universal identity lookup\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n *\n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalNS(\"vitalik.eth\");\n *\n * // Query by any identity type with universal lookup\n * const { data } = useUniversalNS(\"dwr.farcaster\");\n */\nexport function useUniversalNS(\n identity: IdentityString,\n options: QueryOptions = {},\n): NSUniversalResult {\n return useBaseQuery<NSResponse[]>(identity, QueryEndpoint.NS, true, options);\n}\n","import type {\n IdentityString,\n ProfileBatchResult,\n ProfileResponse,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using batch identity lookup\n *\n * @param identity - array of Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by any identity type with batch lookup\n * const { data } = useBatchProfile([\"dwr.farcaster\",\"ens,vitalik.eth\",\"sujiyan.eth\",\"stani.lens\"]);\n */\nexport function useBatchProfile(\n identity: IdentityString[],\n options: QueryOptions = {},\n): ProfileBatchResult {\n return useBaseQuery<ProfileResponse[]>(\n identity,\n QueryEndpoint.PROFILE,\n false,\n options,\n );\n}\n","import type {\n IdentityString,\n NSBatchResult,\n NSResponse,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using batch(NS) identity lookup\n *\n * @param identity - array of Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by any identity type with batch lookup\n * const { data } = useBatchNS([\"dwr.farcaster\",\"ens,vitalik.eth\",\"sujiyan.eth\",\"stani.lens\"]);\n */\nexport function useBatchNS(\n identity: IdentityString[],\n options: QueryOptions = {},\n): NSBatchResult {\n return useBaseQuery<NSResponse[]>(identity, QueryEndpoint.NS, false, options);\n}\n","import type {\n DomainResponse,\n DomainResult,\n IdentityString,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio domain data by identity\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing domain data, loading state, and any errors\n *\n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useDomain(\"vitalik.eth\");\n *\n * // Query by domain name with platform\n * const { data } = useDomain(\"ens,vitalik.eth\");\n */\nexport function useDomain(\n identity: IdentityString,\n options: QueryOptions = {},\n): DomainResult {\n return useBaseQuery<DomainResponse>(\n identity,\n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AA;AAE1B,IAAA,OAAO,YAAY,CAAe,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAChF;;AChBA;;;;;;;;;;;;;AAaG;SACa,SAAS,CACvB,QAAwB,EACxB,UAAwB,EAAE,EAAA;AAE1B,IAAA,OAAO,YAAY,CACjB,QAAQ,EACR,aAAa,CAAC,MAAM,EACpB,KAAK,EACL,OAAO,CACR,CAAC;AACJ;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var react = require('react');
|
|
6
4
|
|
|
7
5
|
const API_ENDPOINT = "https://api.web3.bio";
|
|
@@ -184,36 +182,78 @@ const getApiKey = (userProvidedKey) => {
|
|
|
184
182
|
* Constructs the API URL based on query parameters
|
|
185
183
|
*/
|
|
186
184
|
const buildApiUrl = (identity, endpoint, universal) => {
|
|
187
|
-
// Handle batch
|
|
185
|
+
// Handle batch requests
|
|
188
186
|
if (Array.isArray(identity)) {
|
|
189
|
-
return `${API_ENDPOINT}/${endpoint}/batch/${JSON.stringify(identity)}`;
|
|
187
|
+
return `${API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;
|
|
190
188
|
}
|
|
191
|
-
// Handle
|
|
189
|
+
// Handle universal queries
|
|
192
190
|
if (universal) {
|
|
193
191
|
return `${API_ENDPOINT}/${endpoint}/${identity}`;
|
|
194
192
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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}`;
|
|
201
200
|
}
|
|
201
|
+
// Other endpoints need platform/handle split
|
|
202
|
+
const [platform, handle] = resolvedId.split(",");
|
|
203
|
+
return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;
|
|
202
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();
|
|
203
215
|
/**
|
|
204
216
|
* Core hook for querying Web3.bio Profile API
|
|
205
217
|
*/
|
|
206
218
|
function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
207
219
|
const { apiKey: userApiKey, enabled = true } = options;
|
|
208
220
|
const apiKey = getApiKey(userApiKey);
|
|
209
|
-
const [data, setData] = react.useState(
|
|
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
|
+
});
|
|
210
226
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
211
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
|
+
});
|
|
212
237
|
react.useEffect(() => {
|
|
213
238
|
// Don't run the query if disabled or no identity
|
|
214
239
|
if (!enabled || !identity)
|
|
215
240
|
return;
|
|
216
|
-
|
|
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;
|
|
217
257
|
setIsLoading(true);
|
|
218
258
|
setError(null);
|
|
219
259
|
const fetchData = async () => {
|
|
@@ -223,11 +263,11 @@ function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
|
223
263
|
throw new Error(exports.ErrorMessages.INVALID_IDENTITY);
|
|
224
264
|
}
|
|
225
265
|
const headers = apiKey ? { "x-api-key": apiKey } : {};
|
|
226
|
-
const
|
|
266
|
+
const fetchOptions = {
|
|
227
267
|
method: "GET",
|
|
228
268
|
headers,
|
|
229
|
-
|
|
230
|
-
|
|
269
|
+
};
|
|
270
|
+
const response = await fetch(url, fetchOptions);
|
|
231
271
|
if (!response.ok) {
|
|
232
272
|
throw new Error(`API error: ${response.status}`);
|
|
233
273
|
}
|
|
@@ -235,29 +275,28 @@ function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
|
235
275
|
if (responseData === null || responseData === void 0 ? void 0 : responseData.error) {
|
|
236
276
|
throw new Error(responseData.error);
|
|
237
277
|
}
|
|
238
|
-
|
|
278
|
+
if (requestId === requestIdRef.current) {
|
|
279
|
+
globalRequestCache.set(cacheKey, responseData);
|
|
280
|
+
setData(responseData);
|
|
281
|
+
setIsLoading(false);
|
|
282
|
+
}
|
|
239
283
|
}
|
|
240
284
|
catch (err) {
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
finally {
|
|
246
|
-
setIsLoading(false);
|
|
285
|
+
if (requestId === requestIdRef.current) {
|
|
286
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
287
|
+
setIsLoading(false);
|
|
288
|
+
}
|
|
247
289
|
}
|
|
248
290
|
};
|
|
249
291
|
fetchData();
|
|
250
|
-
|
|
251
|
-
controller.abort();
|
|
252
|
-
};
|
|
253
|
-
}, [identity, apiKey, enabled, endpoint, universal]);
|
|
292
|
+
}, [currentParams, enabled]);
|
|
254
293
|
return { data, isLoading, error };
|
|
255
294
|
}
|
|
256
295
|
|
|
257
296
|
/**
|
|
258
297
|
* Hook to query Web3.bio profile data by identity
|
|
259
298
|
*
|
|
260
|
-
* @param identity - Identity string
|
|
299
|
+
* @param identity - Identity string
|
|
261
300
|
* @param options - Optional configuration options
|
|
262
301
|
* @returns Object containing profile data, loading state, and any errors
|
|
263
302
|
*
|
|
@@ -275,7 +314,7 @@ function useProfile(identity, options = {}) {
|
|
|
275
314
|
/**
|
|
276
315
|
* Hook to query Web3.bio name service (NS) data by identity
|
|
277
316
|
*
|
|
278
|
-
* @param identity - Identity string
|
|
317
|
+
* @param identity - Identity string
|
|
279
318
|
* @param options - Optional configuration options
|
|
280
319
|
* @returns Object containing NS data, loading state, and any errors
|
|
281
320
|
*
|
|
@@ -290,28 +329,10 @@ function useNS(identity, options = {}) {
|
|
|
290
329
|
return useBaseQuery(identity, exports.QueryEndpoint.NS, false, options);
|
|
291
330
|
}
|
|
292
331
|
|
|
293
|
-
/**
|
|
294
|
-
* Hook to query Web3.bio domain data by identity
|
|
295
|
-
*
|
|
296
|
-
* @param identity - Identity string or array of identities to query
|
|
297
|
-
* @param options - Optional configuration options
|
|
298
|
-
* @returns Object containing domain data, loading state, and any errors
|
|
299
|
-
*
|
|
300
|
-
* @example
|
|
301
|
-
* // Query by ENS name
|
|
302
|
-
* const { data, isLoading, error } = useDomain("vitalik.eth");
|
|
303
|
-
*
|
|
304
|
-
* // Query by domain name with platform
|
|
305
|
-
* const { data } = useDomain("ens,vitalik.eth");
|
|
306
|
-
*/
|
|
307
|
-
function useDomain(identity, options = {}) {
|
|
308
|
-
return useBaseQuery(identity, exports.QueryEndpoint.DOMAIN, false, options);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
332
|
/**
|
|
312
333
|
* Hook to query Web3.bio profile data using universal identity lookup
|
|
313
334
|
*
|
|
314
|
-
* @param identity - Identity string
|
|
335
|
+
* @param identity - Identity string
|
|
315
336
|
* @param options - Optional configuration options
|
|
316
337
|
* @returns Object containing profile data, loading state, and any errors
|
|
317
338
|
*
|
|
@@ -329,7 +350,7 @@ function useUniversalProfile(identity, options = {}) {
|
|
|
329
350
|
/**
|
|
330
351
|
* Hook to query Web3.bio name service (NS) data using universal identity lookup
|
|
331
352
|
*
|
|
332
|
-
* @param identity - Identity string
|
|
353
|
+
* @param identity - Identity string
|
|
333
354
|
* @param options - Optional configuration options
|
|
334
355
|
* @returns Object containing NS data, loading state, and any errors
|
|
335
356
|
*
|
|
@@ -344,8 +365,58 @@ function useUniversalNS(identity, options = {}) {
|
|
|
344
365
|
return useBaseQuery(identity, exports.QueryEndpoint.NS, true, options);
|
|
345
366
|
}
|
|
346
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
|
+
|
|
347
416
|
exports.API_ENDPOINT = API_ENDPOINT;
|
|
348
417
|
exports.REGEX = REGEX;
|
|
418
|
+
exports.useBatchNS = useBatchNS;
|
|
419
|
+
exports.useBatchProfile = useBatchProfile;
|
|
349
420
|
exports.useDomain = useDomain;
|
|
350
421
|
exports.useNS = useNS;
|
|
351
422
|
exports.useProfile = useProfile;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/utils/constants.ts","../src/utils/types.ts","../src/utils/helpers.ts","../src/hooks/useBaseQuery.ts","../src/hooks/useProfile.ts","../src/hooks/useNS.ts","../src/hooks/useDomain.ts","../src/hooks/useUniversalProfile.ts","../src/hooks/useUniversalNS.ts"],"sourcesContent":["export const API_ENDPOINT = \"https://api.web3.bio\";\n\nexport enum ErrorMessages {\n NOT_FOUND = \"Not Found\",\n INVALID_RESOLVER = \"Invalid Resolver Address\",\n INVALID_RESOLVED = \"Invalid Resolved Address\",\n NOT_EXIST = \"Does Not Exist\",\n INVALID_IDENTITY = \"Invalid Identity or Domain\",\n INVALID_ADDRESS = \"Invalid Address\",\n UNKNOWN_ERROR = \"Unknown Error Occurred\",\n NETWORK_ERROR = \"Network Error\",\n}\n\nexport enum QueryEndpoint {\n NS = \"ns\",\n PROFILE = \"profile\",\n DOMAIN = \"domain\",\n}\n\n// Regular expressions for identity detection\nexport const REGEX = {\n ENS: /^.+\\.(eth|xyz|bio|app|luxe|kred|art|ceo|club|box)$/i,\n BASENAMES: /^.+\\.base(\\.eth)?$/i,\n LINEA: /^.+\\.linea(\\.eth)?$/i,\n FARCASTER: /^(?:[A-Za-z0-9_-]{1,61}(?:(?:\\.eth)?(?:\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)?)?|farcaster,#\\d+)$/i,\n LENS: /^(?:.+\\.lens)$/i,\n CLUSTER: /^[\\w-]+\\/[\\w-]+$/,\n SPACE_ID: /^.+\\.(bnb|arb)$/i,\n GENOME: /^.+\\.gno$/i,\n UNSTOPPABLE_DOMAINS: /^.+\\.(crypto|888|nft|blockchain|bitcoin|dao|x|klever|hi|zil|kresus|polygon|wallet|binanceus|anime|go|manga|eth)$/i,\n CROSSBELL: /^.+\\.csb$/i,\n DOTBIT: /^.+\\.bit$/i,\n SNS: /^.+\\.sol$/i,\n ETH_ADDRESS: /^0x[a-fA-F0-9]{40}$/i,\n BTC_ADDRESS: /\\b([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qp][a-z0-9]{11,71})\\b/,\n SOLANA_ADDRESS: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/,\n 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/,\n TWITTER: /^[A-Za-z0-9_]{1,15}(?:\\.twitter)?$/i,\n NEXT_ID: /^0x[a-f0-9]{66}(?:\\.nextid)?$/i,\n};","export enum PlatformType {\n ens = \"ens\",\n farcaster = \"farcaster\",\n lens = \"lens\",\n ethereum = \"ethereum\",\n twitter = \"twitter\",\n github = \"github\",\n bitcoin = \"bitcoin\",\n unstoppableDomains = \"unstoppabledomains\",\n basenames = \"basenames\",\n linea = \"linea\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n}\n\nexport enum SourceType {\n ethereum = \"ethereum\",\n ens = \"ens\",\n twitter = \"twitter\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n unstoppabledomains = \"unstoppabledomains\",\n lens = \"lens\",\n farcaster = \"farcaster\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n}\n\nexport type SocialLinksItem = {\n link: string | null;\n handle: string | null;\n sources: SourceType[];\n};\n\nexport type SocialLinks = Record<string, SocialLinksItem>;\n\nexport interface ProfileResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n email: string | null;\n contenthash: string | null;\n header: string | null;\n location: string | null;\n createdAt: string | null;\n status: string | null;\n error?: string;\n links: SocialLinks;\n social:\n | {\n uid: number | null;\n follower: number;\n following: number;\n }\n | {};\n}\n\nexport interface NSResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n}\n\nexport interface DomainResponse {\n identity: string;\n platform: PlatformType;\n resolvedAddress: string | null;\n ownerAddress: string | null;\n managerAddress: string | null;\n displayName: string | null;\n isPrimary: boolean;\n status: string;\n createdAt: string | null;\n updatedAt: string | null;\n expiredAt: string | null;\n contenthash: string | null;\n texts: Record<string, string>;\n addresses: Record<string, string>;\n}\n\nexport type QueryOptions = {\n /** API Key for authentication */\n apiKey?: string;\n /** Whether the query should execute */\n enabled?: boolean;\n};\n\nexport type IdentityString = string | `${PlatformType},${string}`;\nexport type Identity = IdentityString | IdentityString[];\n\nexport type QueryResult<T> = {\n data: T | null;\n isLoading: boolean;\n error: Error | null;\n};\n\n// Query-specific result types for better type safety\nexport type ProfileQueryResult = QueryResult<ProfileResponse>;\nexport type NSQueryResult = QueryResult<NSResponse>;\nexport type DomainQueryResult = QueryResult<DomainResponse>;\n","import { REGEX } from \"./constants\";\nimport { PlatformType, Identity } from \"./types\";\n\n/**\n * Resolves an identity string to a platform and identifier\n * @param input The identity to resolve\n * @returns A formatted identity string or null if invalid\n */\nexport const resolveIdentity = (input: string): string | null => {\n if (!input) return null;\n\n const parts = input.split(\",\");\n\n let platform: PlatformType;\n let identity: string;\n\n if (parts.length === 2) {\n // Format is already \"platform,identity\"\n platform = parts[0] as PlatformType;\n identity = prettify(parts[1]);\n } else if (parts.length === 1) {\n // Auto-detect platform from the identity string\n platform = detectPlatform(input);\n identity = prettify(input);\n } else {\n return null;\n }\n\n if (!isSupportedPlatform(platform) || !identity) return null;\n\n // Normalize case except for case-sensitive identities\n const normalizedIdentity = REGEX.LOWERCASE_EXEMPT.test(identity)\n ? identity\n : identity.toLowerCase();\n\n return `${platform},${normalizedIdentity}`;\n};\n\n/**\n * Clean up and standardize identity format\n */\nexport const prettify = (input: string): string => {\n if (!input) return \"\";\n if (input.endsWith(\".twitter\")) return input.replace(\".twitter\", \"\");\n if (input.endsWith(\".nextid\")) return input.replace(\".nextid\", \"\");\n if (input.startsWith(\"farcaster,#\"))\n return input.replace(/^(farcaster),/, \"\");\n if (\n input.endsWith(\".farcaster\") ||\n input.endsWith(\".fcast.id\") ||\n input.endsWith(\".farcaster.eth\")\n ) {\n return input.replace(/(\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)$/, \"\");\n }\n if (input.endsWith(\".base\") || input.endsWith(\".linea\")) {\n return input.split(\".\")[0] + \".\" + input.split(\".\").pop() + \".eth\";\n }\n return input;\n};\n\n/**\n * Check if the platform is supported for API queries\n */\nexport const isSupportedPlatform = (\n platform?: PlatformType | null,\n): boolean => {\n if (!platform) return false;\n return Object.values(PlatformType).includes(platform as PlatformType);\n};\n\n/**\n * Detect platform from identity string based on regex patterns\n */\nexport const detectPlatform = (term: string): PlatformType => {\n if (term.endsWith(\".farcaster.eth\")) return PlatformType.farcaster;\n\n const platformMap: [RegExp, PlatformType][] = [\n [REGEX.BASENAMES, PlatformType.basenames],\n [REGEX.LINEA, PlatformType.linea],\n [REGEX.ENS, PlatformType.ens],\n [REGEX.ETH_ADDRESS, PlatformType.ethereum],\n [REGEX.LENS, PlatformType.lens],\n [REGEX.UNSTOPPABLE_DOMAINS, PlatformType.unstoppableDomains],\n [REGEX.SPACE_ID, PlatformType.space_id],\n [REGEX.DOTBIT, PlatformType.dotbit],\n [REGEX.SNS, PlatformType.sns],\n [REGEX.BTC_ADDRESS, PlatformType.bitcoin],\n [REGEX.SOLANA_ADDRESS, PlatformType.solana],\n [REGEX.FARCASTER, PlatformType.farcaster],\n [REGEX.TWITTER, PlatformType.twitter],\n [REGEX.NEXT_ID, PlatformType.nextid],\n ];\n\n for (const [regex, platformType] of platformMap) {\n if (regex.test(term)) {\n return platformType;\n }\n }\n\n // Default fallback\n return term.includes(\".\") ? PlatformType.ens : PlatformType.farcaster;\n};\n\n/**\n * Get API key from various environment sources or user provided value\n */\nexport const getApiKey = (userProvidedKey?: string): string | undefined => {\n return (\n userProvidedKey ||\n process.env.WEB3BIO_API_KEY ||\n process.env.REACT_APP_WEB3BIO_API_KEY ||\n process.env.NEXT_PUBLIC_WEB3BIO_API_KEY ||\n process.env.VITE_WEB3BIO_API_KEY\n );\n};\n","import { useState, useEffect } from \"react\";\nimport { API_ENDPOINT, ErrorMessages, QueryEndpoint } from \"../utils/constants\";\nimport { getApiKey, resolveIdentity } from \"../utils/helpers\";\nimport { Identity, QueryOptions, QueryResult } from \"../utils/types\";\n\n/**\n * Constructs the API URL based on query parameters\n */\nconst buildApiUrl = (\n identity: Identity,\n endpoint: QueryEndpoint,\n universal: boolean,\n): string | null => {\n // Handle batch queries (array of identities)\n if (Array.isArray(identity)) {\n return `${API_ENDPOINT}/${endpoint}/batch/${JSON.stringify(identity)}`;\n }\n\n // Handle single identity query\n if (universal) {\n return `${API_ENDPOINT}/${endpoint}/${identity}`;\n } else {\n const resolvedId = resolveIdentity(identity);\n if (!resolvedId) return null;\n\n const [platform, handle] = resolvedId.split(\",\");\n return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;\n }\n};\n\n/**\n * Core hook for querying Web3.bio Profile API\n */\nexport function useBaseQuery<T>(\n identity: Identity,\n endpoint: QueryEndpoint,\n universal: boolean = false,\n options: QueryOptions = {},\n): QueryResult<T> {\n const { apiKey: userApiKey, enabled = true } = options;\n const apiKey = getApiKey(userApiKey);\n\n const [data, setData] = useState<T | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n // Don't run the query if disabled or no identity\n if (!enabled || !identity) return;\n\n const controller = new AbortController();\n setIsLoading(true);\n setError(null);\n\n const fetchData = async () => {\n try {\n const url = buildApiUrl(identity, endpoint, universal);\n\n if (!url) {\n throw new Error(ErrorMessages.INVALID_IDENTITY);\n }\n\n const headers: HeadersInit = apiKey ? { \"x-api-key\": apiKey } : {};\n\n const response = await fetch(url, {\n method: \"GET\",\n headers,\n signal: controller.signal,\n });\n\n if (!response.ok) {\n throw new Error(`API error: ${response.status}`);\n }\n\n const responseData = await response.json();\n\n if (responseData?.error) {\n throw new Error(responseData.error);\n }\n\n setData(responseData as T);\n } catch (err) {\n if (err instanceof Error && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n };\n\n fetchData();\n\n return () => {\n controller.abort();\n };\n }, [identity, apiKey, enabled, endpoint, universal]);\n\n return { data, isLoading, error };\n}\n","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, ProfileQueryResult, ProfileResponse, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data by identity\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n * \n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useProfile(\"vitalik.eth\");\n * \n * // Query with platform specification\n * const { data } = useProfile(\"farcaster,dwr\");\n */\nexport function useProfile(\n identity: Identity,\n options: QueryOptions = {}\n): ProfileQueryResult {\n return useBaseQuery<ProfileResponse>(identity, QueryEndpoint.PROFILE, false, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, NSResponse, NSQueryResult, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data by identity\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n * \n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useNS(\"vitalik.eth\");\n * \n * // Query by Ethereum address\n * const { data } = useNS(\"0x123...\");\n */\nexport function useNS(\n identity: Identity,\n options: QueryOptions = {}\n): NSQueryResult {\n return useBaseQuery<NSResponse>(identity, QueryEndpoint.NS, false, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { DomainQueryResult, DomainResponse, Identity, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio domain data by identity\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing domain data, loading state, and any errors\n * \n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useDomain(\"vitalik.eth\");\n * \n * // Query by domain name with platform\n * const { data } = useDomain(\"ens,vitalik.eth\");\n */\nexport function useDomain(\n identity: Identity,\n options: QueryOptions = {}\n): DomainQueryResult {\n return useBaseQuery<DomainResponse>(identity, QueryEndpoint.DOMAIN, false, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, ProfileQueryResult, ProfileResponse, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using universal identity lookup\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n * \n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalProfile(\"vitalik.eth\");\n * \n * // Query by any identity type with universal lookup\n * const { data } = useUniversalProfile(\"dwr.farcaster\");\n */\nexport function useUniversalProfile(\n identity: Identity,\n options: QueryOptions = {}\n): ProfileQueryResult {\n return useBaseQuery<ProfileResponse>(identity, QueryEndpoint.PROFILE, true, options);\n}","import { QueryEndpoint } from \"../utils/constants\";\nimport { Identity, NSResponse, NSQueryResult, QueryOptions } from \"../utils/types\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data using universal identity lookup\n * \n * @param identity - Identity string or array of identities to query\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n * \n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalNS(\"vitalik.eth\");\n * \n * // Query by any identity type with universal lookup\n * const { data } = useUniversalNS(\"dwr.farcaster\");\n */\nexport function useUniversalNS(\n identity: Identity,\n options: QueryOptions = {}\n): NSQueryResult {\n return useBaseQuery<NSResponse>(identity, QueryEndpoint.NS, true, options);\n}"],"names":["ErrorMessages","QueryEndpoint","PlatformType","SourceType","useState","useEffect"],"mappings":";;;;;;AAAO,MAAM,YAAY,GAAG,uBAAuB;AAEvCA,+BASX;AATD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,WAAA,CAAA,G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;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils/constants.ts","../src/utils/types.ts","../src/utils/helpers.ts","../src/hooks/useBaseQuery.ts","../src/hooks/useProfile.ts","../src/hooks/useNS.ts","../src/hooks/useUniversalProfile.ts","../src/hooks/useUniversalNS.ts","../src/hooks/useBatchProfile.ts","../src/hooks/useBatchNS.ts","../src/hooks/useDomain.ts"],"sourcesContent":["export const API_ENDPOINT = \"https://api.web3.bio\";\n\nexport enum ErrorMessages {\n NOT_FOUND = \"Not Found\",\n INVALID_RESOLVER = \"Invalid Resolver Address\",\n INVALID_RESOLVED = \"Invalid Resolved Address\",\n NOT_EXIST = \"Does Not Exist\",\n INVALID_IDENTITY = \"Invalid Identity or Domain\",\n INVALID_ADDRESS = \"Invalid Address\",\n UNKNOWN_ERROR = \"Unknown Error Occurred\",\n NETWORK_ERROR = \"Network Error\",\n}\n\nexport enum QueryEndpoint {\n NS = \"ns\",\n PROFILE = \"profile\",\n DOMAIN = \"domain\",\n}\n\n// Regular expressions for identity detection\nexport const REGEX = {\n ENS: /^.+\\.(eth|xyz|bio|app|luxe|kred|art|ceo|club|box)$/i,\n BASENAMES: /^.+\\.base(\\.eth)?$/i,\n LINEA: /^.+\\.linea(\\.eth)?$/i,\n FARCASTER:\n /^(?:[A-Za-z0-9_-]{1,61}(?:(?:\\.eth)?(?:\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)?)?|farcaster,#\\d+)$/i,\n LENS: /^(?:.+\\.lens)$/i,\n CLUSTER: /^[\\w-]+\\/[\\w-]+$/,\n SPACE_ID: /^.+\\.(bnb|arb)$/i,\n GENOME: /^.+\\.gno$/i,\n UNSTOPPABLE_DOMAINS:\n /^.+\\.(crypto|888|nft|blockchain|bitcoin|dao|x|klever|hi|zil|kresus|polygon|wallet|binanceus|anime|go|manga|eth)$/i,\n CROSSBELL: /^.+\\.csb$/i,\n DOTBIT: /^.+\\.bit$/i,\n SNS: /^.+\\.sol$/i,\n ETH_ADDRESS: /^0x[a-fA-F0-9]{40}$/i,\n BTC_ADDRESS: /\\b([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qp][a-z0-9]{11,71})\\b/,\n SOLANA_ADDRESS: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/,\n LOWERCASE_EXEMPT:\n /\\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/,\n TWITTER: /^[A-Za-z0-9_]{1,15}(?:\\.twitter)?$/i,\n NEXT_ID: /^0x[a-f0-9]{66}(?:\\.nextid)?$/i,\n};\n","export enum PlatformType {\n ens = \"ens\",\n farcaster = \"farcaster\",\n lens = \"lens\",\n ethereum = \"ethereum\",\n twitter = \"twitter\",\n github = \"github\",\n bitcoin = \"bitcoin\",\n unstoppableDomains = \"unstoppabledomains\",\n basenames = \"basenames\",\n linea = \"linea\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n}\n\nexport enum SourceType {\n ethereum = \"ethereum\",\n ens = \"ens\",\n twitter = \"twitter\",\n nextid = \"nextid\",\n dotbit = \"dotbit\",\n unstoppabledomains = \"unstoppabledomains\",\n lens = \"lens\",\n farcaster = \"farcaster\",\n space_id = \"space_id\",\n solana = \"solana\",\n sns = \"sns\",\n}\n\nexport type SocialLinksItem = {\n link: string | null;\n handle: string | null;\n sources: SourceType[];\n};\n\nexport type SocialLinks = Record<string, SocialLinksItem>;\n\nexport interface ProfileResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n email: string | null;\n contenthash: string | null;\n header: string | null;\n location: string | null;\n createdAt: string | null;\n status: string | null;\n error?: string;\n links: SocialLinks;\n aliases?: string[];\n social:\n | {\n uid: number | null;\n follower: number;\n following: number;\n }\n | {};\n}\n\nexport interface NSResponse {\n identity: string;\n address: string | null;\n avatar: string | null;\n description: string | null;\n platform: string;\n displayName: string | null;\n aliases?: string[];\n}\n\nexport interface DomainResponse {\n identity: string;\n platform: PlatformType;\n resolvedAddress: string | null;\n ownerAddress: string | null;\n managerAddress: string | null;\n displayName: string | null;\n isPrimary: boolean;\n status: string;\n createdAt: string | null;\n updatedAt: string | null;\n expiredAt: string | null;\n contenthash: string | null;\n texts: Record<string, string>;\n addresses: Record<string, string>;\n}\n\nexport type QueryOptions = {\n /** API Key for authentication */\n apiKey?: string;\n /** Whether the query should execute */\n enabled?: boolean;\n};\n\nexport type IdentityString = string | `${PlatformType},${string}`;\n\nexport type QueryResult<T> = {\n data: T | null;\n isLoading: boolean;\n error: Error | null;\n};\n\n// Query-specific result types for better type safety\nexport type ProfileResult = QueryResult<ProfileResponse>;\nexport type NSResult = QueryResult<NSResponse>;\nexport type ProfileBatchResult = QueryResult<ProfileResponse[]>;\nexport type NSBatchResult = QueryResult<NSResponse[]>;\nexport type ProfileUniversalResult = QueryResult<ProfileResponse[]>;\nexport type NSUniversalResult = QueryResult<NSResponse[]>;\nexport type DomainResult = QueryResult<DomainResponse>;\n","import { REGEX } from \"./constants\";\nimport { PlatformType } from \"./types\";\n\n/**\n * Resolves an identity string to a platform and identifier\n * @param input The identity to resolve\n * @returns A formatted identity string or null if invalid\n */\nexport const resolveIdentity = (input: string): string | null => {\n if (!input) return null;\n\n const parts = input.split(\",\");\n\n let platform: PlatformType;\n let identity: string;\n\n if (parts.length === 2) {\n // Format is already \"platform,identity\"\n platform = parts[0] as PlatformType;\n identity = prettify(parts[1]);\n } else if (parts.length === 1) {\n // Auto-detect platform from the identity string\n platform = detectPlatform(input);\n identity = prettify(input);\n } else {\n return null;\n }\n\n if (!isSupportedPlatform(platform) || !identity) return null;\n\n // Normalize case except for case-sensitive identities\n const normalizedIdentity = REGEX.LOWERCASE_EXEMPT.test(identity)\n ? identity\n : identity.toLowerCase();\n\n return `${platform},${normalizedIdentity}`;\n};\n\n/**\n * Clean up and standardize identity format\n */\nexport const prettify = (input: string): string => {\n if (!input) return \"\";\n if (input.endsWith(\".twitter\")) return input.replace(\".twitter\", \"\");\n if (input.endsWith(\".nextid\")) return input.replace(\".nextid\", \"\");\n if (input.startsWith(\"farcaster,#\"))\n return input.replace(/^(farcaster),/, \"\");\n if (\n input.endsWith(\".farcaster\") ||\n input.endsWith(\".fcast.id\") ||\n input.endsWith(\".farcaster.eth\")\n ) {\n return input.replace(/(\\.farcaster|\\.fcast\\.id|\\.farcaster\\.eth)$/, \"\");\n }\n if (input.endsWith(\".base\") || input.endsWith(\".linea\")) {\n return input.split(\".\")[0] + \".\" + input.split(\".\").pop() + \".eth\";\n }\n return input;\n};\n\n/**\n * Check if the platform is supported for API queries\n */\nexport const isSupportedPlatform = (\n platform?: PlatformType | null,\n): boolean => {\n if (!platform) return false;\n return Object.values(PlatformType).includes(platform as PlatformType);\n};\n\n/**\n * Detect platform from identity string based on regex patterns\n */\nexport const detectPlatform = (term: string): PlatformType => {\n if (term.endsWith(\".farcaster.eth\")) return PlatformType.farcaster;\n\n const platformMap: [RegExp, PlatformType][] = [\n [REGEX.BASENAMES, PlatformType.basenames],\n [REGEX.LINEA, PlatformType.linea],\n [REGEX.ENS, PlatformType.ens],\n [REGEX.ETH_ADDRESS, PlatformType.ethereum],\n [REGEX.LENS, PlatformType.lens],\n [REGEX.UNSTOPPABLE_DOMAINS, PlatformType.unstoppableDomains],\n [REGEX.SPACE_ID, PlatformType.space_id],\n [REGEX.DOTBIT, PlatformType.dotbit],\n [REGEX.SNS, PlatformType.sns],\n [REGEX.BTC_ADDRESS, PlatformType.bitcoin],\n [REGEX.SOLANA_ADDRESS, PlatformType.solana],\n [REGEX.FARCASTER, PlatformType.farcaster],\n [REGEX.TWITTER, PlatformType.twitter],\n [REGEX.NEXT_ID, PlatformType.nextid],\n ];\n\n for (const [regex, platformType] of platformMap) {\n if (regex.test(term)) {\n return platformType;\n }\n }\n\n // Default fallback\n return term.includes(\".\") ? PlatformType.ens : PlatformType.farcaster;\n};\n\n/**\n * Get API key from various environment sources or user provided value\n */\nexport const getApiKey = (userProvidedKey?: string): string | undefined => {\n return (\n userProvidedKey ||\n process.env.WEB3BIO_API_KEY ||\n process.env.REACT_APP_WEB3BIO_API_KEY ||\n process.env.NEXT_PUBLIC_WEB3BIO_API_KEY ||\n process.env.VITE_WEB3BIO_API_KEY\n );\n};\n","import type { IdentityString, QueryOptions, QueryResult } from \"../utils/types\";\nimport { useState, useEffect, useRef } from \"react\";\nimport { API_ENDPOINT, ErrorMessages, QueryEndpoint } from \"../utils/constants\";\nimport { getApiKey, resolveIdentity } from \"../utils/helpers\";\n\n/**\n * Constructs the API URL based on query parameters\n */\nconst buildApiUrl = (\n identity: IdentityString | IdentityString[],\n endpoint: QueryEndpoint,\n universal: boolean,\n): string | null => {\n // Handle batch requests\n if (Array.isArray(identity)) {\n return `${API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;\n }\n\n // Handle universal queries\n if (universal) {\n return `${API_ENDPOINT}/${endpoint}/${identity}`;\n }\n\n // Handle platform-specific queries\n const resolvedId = resolveIdentity(identity);\n if (!resolvedId) return null;\n\n // Domain endpoint uses resolved ID directly\n if (endpoint === QueryEndpoint.DOMAIN) {\n return `${API_ENDPOINT}/${endpoint}/${resolvedId}`;\n }\n\n // Other endpoints need platform/handle split\n const [platform, handle] = resolvedId.split(\",\");\n return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;\n};\n\n// Generate a stable cache key for this request\nconst getCacheKey = (\n identity: IdentityString | IdentityString[],\n endpoint: QueryEndpoint,\n universal: boolean,\n): string => {\n return JSON.stringify({\n identity,\n endpoint,\n universal,\n });\n};\n\n// Create a cache to store results across component instances and re-renders\nconst globalRequestCache = new Map<string, any>();\n\n/**\n * Core hook for querying Web3.bio Profile API\n */\nexport function useBaseQuery<T>(\n identity: IdentityString | IdentityString[],\n endpoint: QueryEndpoint,\n universal: boolean = false,\n options: QueryOptions = {},\n): QueryResult<T> {\n const { apiKey: userApiKey, enabled = true } = options;\n const apiKey = getApiKey(userApiKey);\n\n const [data, setData] = useState<T | null>(() => {\n // Initialize state from cache if available\n const cacheKey = getCacheKey(identity, endpoint, universal);\n return (globalRequestCache.get(cacheKey) as T) || null;\n });\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n // Use ref to track in-flight requests and prevent race conditions\n const requestIdRef = useRef<number>(0);\n const prevParamsRef = useRef<string>(\"\");\n\n // Current request parameters as a string for comparison\n const currentParams = JSON.stringify({\n identity,\n endpoint,\n universal,\n });\n\n useEffect(() => {\n // Don't run the query if disabled or no identity\n if (!enabled || !identity) return;\n\n // Skip if parameters haven't changed\n if (currentParams === prevParamsRef.current && data !== null) {\n return;\n }\n\n // Update previous parameters\n prevParamsRef.current = currentParams;\n\n // Generate cache key\n const cacheKey = getCacheKey(identity, endpoint, universal);\n\n // Check if we already have cached data\n const cachedData = globalRequestCache.get(cacheKey) as T | undefined;\n if (cachedData) {\n setData(cachedData);\n return;\n }\n\n // Increment request ID to track the latest request\n const requestId = ++requestIdRef.current;\n\n setIsLoading(true);\n setError(null);\n\n const fetchData = async () => {\n try {\n const url = buildApiUrl(identity, endpoint, universal);\n\n if (!url) {\n throw new Error(ErrorMessages.INVALID_IDENTITY);\n }\n\n const headers: HeadersInit = apiKey ? { \"x-api-key\": apiKey } : {};\n\n const fetchOptions: RequestInit = {\n method: \"GET\",\n headers,\n };\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n throw new Error(`API error: ${response.status}`);\n }\n\n const responseData = await response.json();\n\n if (responseData?.error) {\n throw new Error(responseData.error);\n }\n\n if (requestId === requestIdRef.current) {\n globalRequestCache.set(cacheKey, responseData);\n setData(responseData as T);\n setIsLoading(false);\n }\n } catch (err) {\n if (requestId === requestIdRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n }\n };\n\n fetchData();\n }, [currentParams, enabled]);\n\n return { data, isLoading, error };\n}\n","import type {\n IdentityString,\n ProfileResponse,\n ProfileResult,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data by identity\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useProfile(\"vitalik.eth\");\n *\n * // Query with platform specification\n * const { data } = useProfile(\"farcaster,dwr\");\n */\nexport function useProfile(\n identity: IdentityString,\n options: QueryOptions = {},\n): ProfileResult {\n return useBaseQuery<ProfileResponse>(\n identity,\n QueryEndpoint.PROFILE,\n false,\n options,\n );\n}\n","import type {\n NSResponse,\n QueryOptions,\n IdentityString,\n NSResult,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data by identity\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n *\n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useNS(\"vitalik.eth\");\n *\n * // Query by Ethereum address\n * const { data } = useNS(\"0x123...\");\n */\nexport function useNS(\n identity: IdentityString,\n options: QueryOptions = {},\n): NSResult {\n return useBaseQuery<NSResponse>(identity, QueryEndpoint.NS, false, options);\n}\n","import type {\n IdentityString,\n ProfileResponse,\n ProfileUniversalResult,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using universal identity lookup\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalProfile(\"vitalik.eth\");\n *\n * // Query by any identity type with universal lookup\n * const { data } = useUniversalProfile(\"dwr.farcaster\");\n */\nexport function useUniversalProfile(\n identity: IdentityString,\n options: QueryOptions = {},\n): ProfileUniversalResult {\n return useBaseQuery<ProfileResponse[]>(\n identity,\n QueryEndpoint.PROFILE,\n true,\n options,\n );\n}\n","import type {\n NSResponse,\n QueryOptions,\n IdentityString,\n NSUniversalResult,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio name service (NS) data using universal identity lookup\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing NS data, loading state, and any errors\n *\n * @example\n * // Query by ENS name with universal lookup\n * const { data, isLoading, error } = useUniversalNS(\"vitalik.eth\");\n *\n * // Query by any identity type with universal lookup\n * const { data } = useUniversalNS(\"dwr.farcaster\");\n */\nexport function useUniversalNS(\n identity: IdentityString,\n options: QueryOptions = {},\n): NSUniversalResult {\n return useBaseQuery<NSResponse[]>(identity, QueryEndpoint.NS, true, options);\n}\n","import type {\n IdentityString,\n ProfileBatchResult,\n ProfileResponse,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using batch identity lookup\n *\n * @param identity - array of Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by any identity type with batch lookup\n * const { data } = useBatchProfile([\"dwr.farcaster\",\"ens,vitalik.eth\",\"sujiyan.eth\",\"stani.lens\"]);\n */\nexport function useBatchProfile(\n identity: IdentityString[],\n options: QueryOptions = {},\n): ProfileBatchResult {\n return useBaseQuery<ProfileResponse[]>(\n identity,\n QueryEndpoint.PROFILE,\n false,\n options,\n );\n}\n","import type {\n IdentityString,\n NSBatchResult,\n NSResponse,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio profile data using batch(NS) identity lookup\n *\n * @param identity - array of Identity string\n * @param options - Optional configuration options\n * @returns Object containing profile data, loading state, and any errors\n *\n * @example\n * // Query by any identity type with batch lookup\n * const { data } = useBatchNS([\"dwr.farcaster\",\"ens,vitalik.eth\",\"sujiyan.eth\",\"stani.lens\"]);\n */\nexport function useBatchNS(\n identity: IdentityString[],\n options: QueryOptions = {},\n): NSBatchResult {\n return useBaseQuery<NSResponse[]>(identity, QueryEndpoint.NS, false, options);\n}\n","import type {\n DomainResponse,\n DomainResult,\n IdentityString,\n QueryOptions,\n} from \"../utils/types\";\nimport { QueryEndpoint } from \"../utils/constants\";\nimport { useBaseQuery } from \"./useBaseQuery\";\n\n/**\n * Hook to query Web3.bio domain data by identity\n *\n * @param identity - Identity string\n * @param options - Optional configuration options\n * @returns Object containing domain data, loading state, and any errors\n *\n * @example\n * // Query by ENS name\n * const { data, isLoading, error } = useDomain(\"vitalik.eth\");\n *\n * // Query by domain name with platform\n * const { data } = useDomain(\"ens,vitalik.eth\");\n */\nexport function useDomain(\n identity: IdentityString,\n options: QueryOptions = {},\n): DomainResult {\n return useBaseQuery<DomainResponse>(\n identity,\n QueryEndpoint.DOMAIN,\n false,\n options,\n );\n}\n"],"names":["ErrorMessages","QueryEndpoint","PlatformType","SourceType","useState","useRef","useEffect"],"mappings":";;;;AAAO,MAAM,YAAY,GAAG,uBAAuB;AAEvCA,+BASX;AATD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,WAAA,CAAA,GAAA,WAAuB,CAAA;AACvB,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,0BAA6C,CAAA;AAC7C,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,0BAA6C,CAAA;AAC7C,IAAA,aAAA,CAAA,WAAA,CAAA,GAAA,gBAA4B,CAAA;AAC5B,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,4BAA+C,CAAA;AAC/C,IAAA,aAAA,CAAA,iB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from "./useProfile";
|
|
2
2
|
export { useNS } from "./useNS";
|
|
3
|
-
export { useDomain } from "./useDomain";
|
|
4
3
|
export { useUniversalProfile } from "./useUniversalProfile";
|
|
5
4
|
export { useUniversalNS } from "./useUniversalNS";
|
|
5
|
+
export { useBatchProfile } from "./useBatchProfile";
|
|
6
|
+
export { useBatchNS } from "./useBatchNS";
|
|
7
|
+
export { useDomain } from "./useDomain";
|
|
6
8
|
export { useBaseQuery } from "./useBaseQuery";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IdentityString, QueryOptions, QueryResult } from "../utils/types";
|
|
2
|
+
import { QueryEndpoint } from "../utils/constants";
|
|
3
|
+
/**
|
|
4
|
+
* Core hook for querying Web3.bio Profile API
|
|
5
|
+
*/
|
|
6
|
+
export declare function useBaseQuery<T>(identity: IdentityString | IdentityString[], endpoint: QueryEndpoint, universal?: boolean, options?: QueryOptions): QueryResult<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IdentityString, NSBatchResult, QueryOptions } from "../utils/types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to query Web3.bio profile data using batch(NS) identity lookup
|
|
4
|
+
*
|
|
5
|
+
* @param identity - array of Identity string
|
|
6
|
+
* @param options - Optional configuration options
|
|
7
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Query by any identity type with batch lookup
|
|
11
|
+
* const { data } = useBatchNS(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
12
|
+
*/
|
|
13
|
+
export declare function useBatchNS(identity: IdentityString[], options?: QueryOptions): NSBatchResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IdentityString, ProfileBatchResult, QueryOptions } from "../utils/types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to query Web3.bio profile data using batch identity lookup
|
|
4
|
+
*
|
|
5
|
+
* @param identity - array of Identity string
|
|
6
|
+
* @param options - Optional configuration options
|
|
7
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Query by any identity type with batch lookup
|
|
11
|
+
* const { data } = useBatchProfile(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
12
|
+
*/
|
|
13
|
+
export declare function useBatchProfile(identity: IdentityString[], options?: QueryOptions): ProfileBatchResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DomainResult, IdentityString, QueryOptions } from "../utils/types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to query Web3.bio domain data by identity
|
|
4
4
|
*
|
|
5
|
-
* @param identity - Identity string
|
|
5
|
+
* @param identity - Identity string
|
|
6
6
|
* @param options - Optional configuration options
|
|
7
7
|
* @returns Object containing domain data, loading state, and any errors
|
|
8
8
|
*
|
|
@@ -13,4 +13,4 @@ import { DomainQueryResult, Identity, QueryOptions } from "../utils/types";
|
|
|
13
13
|
* // Query by domain name with platform
|
|
14
14
|
* const { data } = useDomain("ens,vitalik.eth");
|
|
15
15
|
*/
|
|
16
|
-
export declare function useDomain(identity:
|
|
16
|
+
export declare function useDomain(identity: IdentityString, options?: QueryOptions): DomainResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { QueryOptions, IdentityString, NSResult } from "../utils/types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to query Web3.bio name service (NS) data by identity
|
|
4
4
|
*
|
|
5
|
-
* @param identity - Identity string
|
|
5
|
+
* @param identity - Identity string
|
|
6
6
|
* @param options - Optional configuration options
|
|
7
7
|
* @returns Object containing NS data, loading state, and any errors
|
|
8
8
|
*
|
|
@@ -13,4 +13,4 @@ import { Identity, NSQueryResult, QueryOptions } from "../utils/types";
|
|
|
13
13
|
* // Query by Ethereum address
|
|
14
14
|
* const { data } = useNS("0x123...");
|
|
15
15
|
*/
|
|
16
|
-
export declare function useNS(identity:
|
|
16
|
+
export declare function useNS(identity: IdentityString, options?: QueryOptions): NSResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IdentityString, ProfileResult, QueryOptions } from "../utils/types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to query Web3.bio profile data by identity
|
|
4
4
|
*
|
|
5
|
-
* @param identity - Identity string
|
|
5
|
+
* @param identity - Identity string
|
|
6
6
|
* @param options - Optional configuration options
|
|
7
7
|
* @returns Object containing profile data, loading state, and any errors
|
|
8
8
|
*
|
|
@@ -13,4 +13,4 @@ import { Identity, ProfileQueryResult, QueryOptions } from "../utils/types";
|
|
|
13
13
|
* // Query with platform specification
|
|
14
14
|
* const { data } = useProfile("farcaster,dwr");
|
|
15
15
|
*/
|
|
16
|
-
export declare function useProfile(identity:
|
|
16
|
+
export declare function useProfile(identity: IdentityString, options?: QueryOptions): ProfileResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { QueryOptions, IdentityString, NSUniversalResult } from "../utils/types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to query Web3.bio name service (NS) data using universal identity lookup
|
|
4
4
|
*
|
|
5
|
-
* @param identity - Identity string
|
|
5
|
+
* @param identity - Identity string
|
|
6
6
|
* @param options - Optional configuration options
|
|
7
7
|
* @returns Object containing NS data, loading state, and any errors
|
|
8
8
|
*
|
|
@@ -13,4 +13,4 @@ import { Identity, NSQueryResult, QueryOptions } from "../utils/types";
|
|
|
13
13
|
* // Query by any identity type with universal lookup
|
|
14
14
|
* const { data } = useUniversalNS("dwr.farcaster");
|
|
15
15
|
*/
|
|
16
|
-
export declare function useUniversalNS(identity:
|
|
16
|
+
export declare function useUniversalNS(identity: IdentityString, options?: QueryOptions): NSUniversalResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IdentityString, ProfileUniversalResult, QueryOptions } from "../utils/types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to query Web3.bio profile data using universal identity lookup
|
|
4
4
|
*
|
|
5
|
-
* @param identity - Identity string
|
|
5
|
+
* @param identity - Identity string
|
|
6
6
|
* @param options - Optional configuration options
|
|
7
7
|
* @returns Object containing profile data, loading state, and any errors
|
|
8
8
|
*
|
|
@@ -13,4 +13,4 @@ import { Identity, ProfileQueryResult, QueryOptions } from "../utils/types";
|
|
|
13
13
|
* // Query by any identity type with universal lookup
|
|
14
14
|
* const { data } = useUniversalProfile("dwr.farcaster");
|
|
15
15
|
*/
|
|
16
|
-
export declare function useUniversalProfile(identity:
|
|
16
|
+
export declare function useUniversalProfile(identity: IdentityString, options?: QueryOptions): ProfileUniversalResult;
|
|
@@ -49,6 +49,7 @@ export interface ProfileResponse {
|
|
|
49
49
|
status: string | null;
|
|
50
50
|
error?: string;
|
|
51
51
|
links: SocialLinks;
|
|
52
|
+
aliases?: string[];
|
|
52
53
|
social: {
|
|
53
54
|
uid: number | null;
|
|
54
55
|
follower: number;
|
|
@@ -62,6 +63,7 @@ export interface NSResponse {
|
|
|
62
63
|
description: string | null;
|
|
63
64
|
platform: string;
|
|
64
65
|
displayName: string | null;
|
|
66
|
+
aliases?: string[];
|
|
65
67
|
}
|
|
66
68
|
export interface DomainResponse {
|
|
67
69
|
identity: string;
|
|
@@ -86,12 +88,15 @@ export type QueryOptions = {
|
|
|
86
88
|
enabled?: boolean;
|
|
87
89
|
};
|
|
88
90
|
export type IdentityString = string | `${PlatformType},${string}`;
|
|
89
|
-
export type Identity = IdentityString | IdentityString[];
|
|
90
91
|
export type QueryResult<T> = {
|
|
91
92
|
data: T | null;
|
|
92
93
|
isLoading: boolean;
|
|
93
94
|
error: Error | null;
|
|
94
95
|
};
|
|
95
|
-
export type
|
|
96
|
-
export type
|
|
97
|
-
export type
|
|
96
|
+
export type ProfileResult = QueryResult<ProfileResponse>;
|
|
97
|
+
export type NSResult = QueryResult<NSResponse>;
|
|
98
|
+
export type ProfileBatchResult = QueryResult<ProfileResponse[]>;
|
|
99
|
+
export type NSBatchResult = QueryResult<NSResponse[]>;
|
|
100
|
+
export type ProfileUniversalResult = QueryResult<ProfileResponse[]>;
|
|
101
|
+
export type NSUniversalResult = QueryResult<NSResponse[]>;
|
|
102
|
+
export type DomainResult = QueryResult<DomainResponse>;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web3bio-profile-kit",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "React hooks for querying Web3
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "React hooks for querying ENS, Farcaster, Lens and Web3 universal profiles",
|
|
5
5
|
"author": "web3bio",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
8
|
+
"type": "module",
|
|
8
9
|
"main": "dist/index.js",
|
|
9
10
|
"module": "dist/index.esm.js",
|
|
10
11
|
"types": "dist/index.d.ts",
|
|
@@ -32,8 +33,8 @@
|
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "rimraf dist && rollup -c",
|
|
35
|
-
"test": "react-scripts test",
|
|
36
|
-
"prepublishOnly": "
|
|
36
|
+
"test": "react-scripts test --watchAll=false",
|
|
37
|
+
"prepublishOnly": "pnpm run build"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"react": ">=16.8.0",
|
|
@@ -43,7 +44,11 @@
|
|
|
43
44
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
44
45
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
45
46
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
46
|
-
"@testing-library/
|
|
47
|
+
"@testing-library/dom": "^10.4.0",
|
|
48
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
49
|
+
"@testing-library/react": "^16.3.0",
|
|
50
|
+
"@testing-library/user-event": "^13.5.0",
|
|
51
|
+
"react-scripts": "5.0.1",
|
|
47
52
|
"@types/react": "^18.0.0",
|
|
48
53
|
"react": "^18.2.0",
|
|
49
54
|
"react-dom": "^18.2.0",
|
|
@@ -51,6 +56,7 @@
|
|
|
51
56
|
"rollup": "^3.25.0",
|
|
52
57
|
"rollup-plugin-dts": "^5.3.0",
|
|
53
58
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
54
|
-
"typescript": "^5.0.0"
|
|
59
|
+
"typescript": "^5.0.0",
|
|
60
|
+
"dotenv": "^16.5.0"
|
|
55
61
|
}
|
|
56
62
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { QueryEndpoint } from "../utils/constants";
|
|
2
|
-
import { Identity, QueryOptions, QueryResult } from "../utils/types";
|
|
3
|
-
/**
|
|
4
|
-
* Core hook for querying Web3.bio Profile API
|
|
5
|
-
*/
|
|
6
|
-
export declare function useBaseQuery<T>(identity: Identity, endpoint: QueryEndpoint, universal?: boolean, options?: QueryOptions): QueryResult<T>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|