web3bio-profile-kit 0.2.7 → 0.2.8
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/dist/types/platform.cjs +0 -14
- package/dist/types/platform.d.ts +0 -14
- package/dist/types/platform.js +0 -14
- package/dist/utils/helpers.cjs +45 -45
- package/dist/utils/helpers.js +46 -46
- package/dist/utils/ipfs.cjs +19 -11
- package/dist/utils/ipfs.js +19 -11
- package/dist/utils/network.cjs +22 -20
- package/dist/utils/network.js +22 -20
- package/dist/utils/platform.cjs +3 -140
- package/dist/utils/platform.js +3 -140
- package/dist/utils/resolver.cjs +3 -2
- package/dist/utils/resolver.js +3 -2
- package/dist/utils/source.cjs +1 -1
- package/dist/utils/source.js +1 -1
- package/package.json +1 -1
package/dist/types/platform.cjs
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
exports.Platform = void 0;
|
|
9
9
|
(function (Platform) {
|
|
10
|
-
Platform["ailayer"] = "ailayer";
|
|
11
|
-
Platform["alienx"] = "alienx";
|
|
12
10
|
Platform["aptos"] = "aptos";
|
|
13
11
|
Platform["arbitrum"] = "arbitrum";
|
|
14
12
|
Platform["basenames"] = "basenames";
|
|
@@ -23,8 +21,6 @@ exports.Platform = void 0;
|
|
|
23
21
|
Platform["clusters"] = "clusters";
|
|
24
22
|
Platform["coinbase"] = "coinbase";
|
|
25
23
|
Platform["coingecko"] = "coingecko";
|
|
26
|
-
Platform["cosmos"] = "cosmos";
|
|
27
|
-
Platform["cyberconnect"] = "cyberconnect";
|
|
28
24
|
Platform["deepdao"] = "deepdao";
|
|
29
25
|
Platform["degenscore"] = "degenscore";
|
|
30
26
|
Platform["dentity"] = "dentity";
|
|
@@ -33,7 +29,6 @@ exports.Platform = void 0;
|
|
|
33
29
|
Platform["dotbit"] = "dotbit";
|
|
34
30
|
Platform["dns"] = "dns";
|
|
35
31
|
Platform["ecp"] = "ecp";
|
|
36
|
-
Platform["edgeless"] = "edgeless";
|
|
37
32
|
Platform["efp"] = "efp";
|
|
38
33
|
Platform["ens"] = "ens";
|
|
39
34
|
Platform["ethereum"] = "ethereum";
|
|
@@ -55,18 +50,13 @@ exports.Platform = void 0;
|
|
|
55
50
|
Platform["interface"] = "interface";
|
|
56
51
|
Platform["keybase"] = "keybase";
|
|
57
52
|
Platform["lens"] = "lens";
|
|
58
|
-
Platform["lightlink"] = "lightlink";
|
|
59
53
|
Platform["linkedin"] = "linkedin";
|
|
60
54
|
Platform["linea"] = "linea";
|
|
61
55
|
Platform["lobsters"] = "lobsters";
|
|
62
|
-
Platform["manta"] = "manta";
|
|
63
56
|
Platform["matters"] = "matters";
|
|
64
57
|
Platform["medium"] = "medium";
|
|
65
|
-
Platform["merlin"] = "merlin";
|
|
66
58
|
Platform["minds"] = "minds";
|
|
67
|
-
Platform["mint"] = "mint";
|
|
68
59
|
Platform["mirror"] = "mirror";
|
|
69
|
-
Platform["mode"] = "mode";
|
|
70
60
|
Platform["mstdnjp"] = "mstdnjp";
|
|
71
61
|
Platform["near"] = "near";
|
|
72
62
|
Platform["nextid"] = "nextid";
|
|
@@ -88,13 +78,11 @@ exports.Platform = void 0;
|
|
|
88
78
|
Platform["space_id"] = "space_id";
|
|
89
79
|
Platform["stacks"] = "stacks";
|
|
90
80
|
Platform["substack"] = "substack";
|
|
91
|
-
Platform["taiko"] = "taiko";
|
|
92
81
|
Platform["talent"] = "talentprotocol";
|
|
93
82
|
Platform["tally"] = "tally";
|
|
94
83
|
Platform["telegram"] = "telegram";
|
|
95
84
|
Platform["threads"] = "threads";
|
|
96
85
|
Platform["tiktok"] = "tiktok";
|
|
97
|
-
Platform["tomo"] = "tomo";
|
|
98
86
|
Platform["ton"] = "ton";
|
|
99
87
|
Platform["tron"] = "tron";
|
|
100
88
|
Platform["twitter"] = "twitter";
|
|
@@ -109,8 +97,6 @@ exports.Platform = void 0;
|
|
|
109
97
|
Platform["world_id"] = "world_id";
|
|
110
98
|
Platform["xmtp"] = "xmtp";
|
|
111
99
|
Platform["youtube"] = "youtube";
|
|
112
|
-
Platform["zeta"] = "zeta";
|
|
113
|
-
Platform["zkfair"] = "zkfair";
|
|
114
100
|
Platform["zkme"] = "zkme";
|
|
115
101
|
Platform["zora"] = "zora";
|
|
116
102
|
})(exports.Platform || (exports.Platform = {}));
|
package/dist/types/platform.d.ts
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
export declare enum Platform {
|
|
7
|
-
ailayer = "ailayer",
|
|
8
|
-
alienx = "alienx",
|
|
9
7
|
aptos = "aptos",
|
|
10
8
|
arbitrum = "arbitrum",
|
|
11
9
|
basenames = "basenames",
|
|
@@ -20,8 +18,6 @@ export declare enum Platform {
|
|
|
20
18
|
clusters = "clusters",
|
|
21
19
|
coinbase = "coinbase",
|
|
22
20
|
coingecko = "coingecko",
|
|
23
|
-
cosmos = "cosmos",
|
|
24
|
-
cyberconnect = "cyberconnect",
|
|
25
21
|
deepdao = "deepdao",
|
|
26
22
|
degenscore = "degenscore",
|
|
27
23
|
dentity = "dentity",
|
|
@@ -30,7 +26,6 @@ export declare enum Platform {
|
|
|
30
26
|
dotbit = "dotbit",
|
|
31
27
|
dns = "dns",
|
|
32
28
|
ecp = "ecp",
|
|
33
|
-
edgeless = "edgeless",
|
|
34
29
|
efp = "efp",
|
|
35
30
|
ens = "ens",
|
|
36
31
|
ethereum = "ethereum",
|
|
@@ -52,18 +47,13 @@ export declare enum Platform {
|
|
|
52
47
|
interface = "interface",
|
|
53
48
|
keybase = "keybase",
|
|
54
49
|
lens = "lens",
|
|
55
|
-
lightlink = "lightlink",
|
|
56
50
|
linkedin = "linkedin",
|
|
57
51
|
linea = "linea",
|
|
58
52
|
lobsters = "lobsters",
|
|
59
|
-
manta = "manta",
|
|
60
53
|
matters = "matters",
|
|
61
54
|
medium = "medium",
|
|
62
|
-
merlin = "merlin",
|
|
63
55
|
minds = "minds",
|
|
64
|
-
mint = "mint",
|
|
65
56
|
mirror = "mirror",
|
|
66
|
-
mode = "mode",
|
|
67
57
|
mstdnjp = "mstdnjp",
|
|
68
58
|
near = "near",
|
|
69
59
|
nextid = "nextid",
|
|
@@ -85,13 +75,11 @@ export declare enum Platform {
|
|
|
85
75
|
space_id = "space_id",
|
|
86
76
|
stacks = "stacks",
|
|
87
77
|
substack = "substack",
|
|
88
|
-
taiko = "taiko",
|
|
89
78
|
talent = "talentprotocol",
|
|
90
79
|
tally = "tally",
|
|
91
80
|
telegram = "telegram",
|
|
92
81
|
threads = "threads",
|
|
93
82
|
tiktok = "tiktok",
|
|
94
|
-
tomo = "tomo",
|
|
95
83
|
ton = "ton",
|
|
96
84
|
tron = "tron",
|
|
97
85
|
twitter = "twitter",
|
|
@@ -106,8 +94,6 @@ export declare enum Platform {
|
|
|
106
94
|
world_id = "world_id",
|
|
107
95
|
xmtp = "xmtp",
|
|
108
96
|
youtube = "youtube",
|
|
109
|
-
zeta = "zeta",
|
|
110
|
-
zkfair = "zkfair",
|
|
111
97
|
zkme = "zkme",
|
|
112
98
|
zora = "zora"
|
|
113
99
|
}
|
package/dist/types/platform.js
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
var Platform;
|
|
7
7
|
(function (Platform) {
|
|
8
|
-
Platform["ailayer"] = "ailayer";
|
|
9
|
-
Platform["alienx"] = "alienx";
|
|
10
8
|
Platform["aptos"] = "aptos";
|
|
11
9
|
Platform["arbitrum"] = "arbitrum";
|
|
12
10
|
Platform["basenames"] = "basenames";
|
|
@@ -21,8 +19,6 @@ var Platform;
|
|
|
21
19
|
Platform["clusters"] = "clusters";
|
|
22
20
|
Platform["coinbase"] = "coinbase";
|
|
23
21
|
Platform["coingecko"] = "coingecko";
|
|
24
|
-
Platform["cosmos"] = "cosmos";
|
|
25
|
-
Platform["cyberconnect"] = "cyberconnect";
|
|
26
22
|
Platform["deepdao"] = "deepdao";
|
|
27
23
|
Platform["degenscore"] = "degenscore";
|
|
28
24
|
Platform["dentity"] = "dentity";
|
|
@@ -31,7 +27,6 @@ var Platform;
|
|
|
31
27
|
Platform["dotbit"] = "dotbit";
|
|
32
28
|
Platform["dns"] = "dns";
|
|
33
29
|
Platform["ecp"] = "ecp";
|
|
34
|
-
Platform["edgeless"] = "edgeless";
|
|
35
30
|
Platform["efp"] = "efp";
|
|
36
31
|
Platform["ens"] = "ens";
|
|
37
32
|
Platform["ethereum"] = "ethereum";
|
|
@@ -53,18 +48,13 @@ var Platform;
|
|
|
53
48
|
Platform["interface"] = "interface";
|
|
54
49
|
Platform["keybase"] = "keybase";
|
|
55
50
|
Platform["lens"] = "lens";
|
|
56
|
-
Platform["lightlink"] = "lightlink";
|
|
57
51
|
Platform["linkedin"] = "linkedin";
|
|
58
52
|
Platform["linea"] = "linea";
|
|
59
53
|
Platform["lobsters"] = "lobsters";
|
|
60
|
-
Platform["manta"] = "manta";
|
|
61
54
|
Platform["matters"] = "matters";
|
|
62
55
|
Platform["medium"] = "medium";
|
|
63
|
-
Platform["merlin"] = "merlin";
|
|
64
56
|
Platform["minds"] = "minds";
|
|
65
|
-
Platform["mint"] = "mint";
|
|
66
57
|
Platform["mirror"] = "mirror";
|
|
67
|
-
Platform["mode"] = "mode";
|
|
68
58
|
Platform["mstdnjp"] = "mstdnjp";
|
|
69
59
|
Platform["near"] = "near";
|
|
70
60
|
Platform["nextid"] = "nextid";
|
|
@@ -86,13 +76,11 @@ var Platform;
|
|
|
86
76
|
Platform["space_id"] = "space_id";
|
|
87
77
|
Platform["stacks"] = "stacks";
|
|
88
78
|
Platform["substack"] = "substack";
|
|
89
|
-
Platform["taiko"] = "taiko";
|
|
90
79
|
Platform["talent"] = "talentprotocol";
|
|
91
80
|
Platform["tally"] = "tally";
|
|
92
81
|
Platform["telegram"] = "telegram";
|
|
93
82
|
Platform["threads"] = "threads";
|
|
94
83
|
Platform["tiktok"] = "tiktok";
|
|
95
|
-
Platform["tomo"] = "tomo";
|
|
96
84
|
Platform["ton"] = "ton";
|
|
97
85
|
Platform["tron"] = "tron";
|
|
98
86
|
Platform["twitter"] = "twitter";
|
|
@@ -107,8 +95,6 @@ var Platform;
|
|
|
107
95
|
Platform["world_id"] = "world_id";
|
|
108
96
|
Platform["xmtp"] = "xmtp";
|
|
109
97
|
Platform["youtube"] = "youtube";
|
|
110
|
-
Platform["zeta"] = "zeta";
|
|
111
|
-
Platform["zkfair"] = "zkfair";
|
|
112
98
|
Platform["zkme"] = "zkme";
|
|
113
99
|
Platform["zora"] = "zora";
|
|
114
100
|
})(Platform || (Platform = {}));
|
package/dist/utils/helpers.cjs
CHANGED
|
@@ -10,6 +10,29 @@ var platform$1 = require('./platform.cjs');
|
|
|
10
10
|
var regex = require('./regex.cjs');
|
|
11
11
|
|
|
12
12
|
const PROFILE_API_ENDPOINT = "https://api.web3.bio";
|
|
13
|
+
const FARCASTER_SUFFIXES = [".farcaster", ".fcast.id", ".farcaster.eth"];
|
|
14
|
+
const CHAIN_ALIASES = [".base", ".linea"];
|
|
15
|
+
const hasAnySuffix = (value, suffixes) => suffixes.some((suffix) => value.endsWith(suffix));
|
|
16
|
+
const getSuffixAfterLastDot = (value) => {
|
|
17
|
+
const lastDotIndex = value.lastIndexOf(".");
|
|
18
|
+
return lastDotIndex === -1 ? null : value.slice(lastDotIndex + 1);
|
|
19
|
+
};
|
|
20
|
+
const removeWeb2PlatformSuffix = (value) => {
|
|
21
|
+
const suffix = getSuffixAfterLastDot(value);
|
|
22
|
+
if (!suffix || !platform$1.isWeb2Platform(suffix))
|
|
23
|
+
return value;
|
|
24
|
+
return value.slice(0, -(suffix.length + 1));
|
|
25
|
+
};
|
|
26
|
+
const normalizeChainAliasToEth = (value) => {
|
|
27
|
+
const [name, ...rest] = value.split(".");
|
|
28
|
+
const chain = rest[rest.length - 1];
|
|
29
|
+
return `${name}.${chain}.eth`;
|
|
30
|
+
};
|
|
31
|
+
const withPlatformEthSuffix = (value, shortSuffix, fullSuffix) => {
|
|
32
|
+
if (value.endsWith(fullSuffix))
|
|
33
|
+
return value;
|
|
34
|
+
return value.endsWith(shortSuffix) ? `${value}.eth` : `${value}${fullSuffix}`;
|
|
35
|
+
};
|
|
13
36
|
/**
|
|
14
37
|
* Resolves an identity string to a platform and identifier
|
|
15
38
|
* @param input The identity to resolve
|
|
@@ -50,24 +73,14 @@ const prettify = (input) => {
|
|
|
50
73
|
return "";
|
|
51
74
|
if (input.startsWith("farcaster,#"))
|
|
52
75
|
return input.replace(/^(farcaster),/, "");
|
|
53
|
-
if (input
|
|
54
|
-
input.endsWith(".fcast.id") ||
|
|
55
|
-
input.endsWith(".farcaster.eth")) {
|
|
76
|
+
if (hasAnySuffix(input, FARCASTER_SUFFIXES)) {
|
|
56
77
|
return input.replace(/(\.farcaster|\.fcast\.id|\.farcaster\.eth)$/, "");
|
|
57
78
|
}
|
|
58
|
-
if (input
|
|
59
|
-
|
|
60
|
-
return `${parts[0]}.${parts[parts.length - 1]}.eth`;
|
|
61
|
-
}
|
|
62
|
-
// for all web2 platform prettify format as "identity.platform"
|
|
63
|
-
const lastDotIndex = input.lastIndexOf(".");
|
|
64
|
-
if (lastDotIndex !== -1) {
|
|
65
|
-
const suffix = input.slice(lastDotIndex + 1);
|
|
66
|
-
if (platform$1.isWeb2Platform(suffix)) {
|
|
67
|
-
return input.slice(0, lastDotIndex);
|
|
68
|
-
}
|
|
79
|
+
if (hasAnySuffix(input, CHAIN_ALIASES)) {
|
|
80
|
+
return normalizeChainAliasToEth(input);
|
|
69
81
|
}
|
|
70
|
-
|
|
82
|
+
// For all web2 platforms prettify format as "identity.platform".
|
|
83
|
+
return removeWeb2PlatformSuffix(input);
|
|
71
84
|
};
|
|
72
85
|
/**
|
|
73
86
|
* Fufill and standardize identity format
|
|
@@ -77,25 +90,15 @@ const uglify = (input, platform$1) => {
|
|
|
77
90
|
return "";
|
|
78
91
|
switch (platform$1) {
|
|
79
92
|
case platform.Platform.farcaster:
|
|
80
|
-
return input
|
|
81
|
-
input.endsWith(".fcast.id") ||
|
|
82
|
-
input.endsWith(".farcaster.eth")
|
|
93
|
+
return hasAnySuffix(input, FARCASTER_SUFFIXES)
|
|
83
94
|
? input
|
|
84
95
|
: `${input}.farcaster`;
|
|
85
96
|
case platform.Platform.lens:
|
|
86
97
|
return input.endsWith(".lens") ? input : `${input}.lens`;
|
|
87
98
|
case platform.Platform.basenames:
|
|
88
|
-
return input.
|
|
89
|
-
? input
|
|
90
|
-
: input.endsWith(".base")
|
|
91
|
-
? `${input}.eth`
|
|
92
|
-
: `${input}.base.eth`;
|
|
99
|
+
return withPlatformEthSuffix(input, ".base", ".base.eth");
|
|
93
100
|
case platform.Platform.linea:
|
|
94
|
-
return input.
|
|
95
|
-
? input
|
|
96
|
-
: input.endsWith(".linea")
|
|
97
|
-
? `${input}.eth`
|
|
98
|
-
: `${input}.linea.eth`;
|
|
101
|
+
return withPlatformEthSuffix(input, ".linea", ".linea.eth");
|
|
99
102
|
default:
|
|
100
103
|
return input;
|
|
101
104
|
}
|
|
@@ -128,9 +131,7 @@ const SUPPORTED_PLATFORMS = new Set([
|
|
|
128
131
|
* Check if the platform is supported for API queries
|
|
129
132
|
*/
|
|
130
133
|
const isSupportedPlatform = (platform) => {
|
|
131
|
-
|
|
132
|
-
return false;
|
|
133
|
-
return SUPPORTED_PLATFORMS.has(platform);
|
|
134
|
+
return !!platform && SUPPORTED_PLATFORMS.has(platform);
|
|
134
135
|
};
|
|
135
136
|
const platformMap = new Map([
|
|
136
137
|
[regex.REGEX.BASENAMES, platform.Platform.basenames],
|
|
@@ -155,19 +156,16 @@ const platformMap = new Map([
|
|
|
155
156
|
* Detect platform from identity string based on regex patterns
|
|
156
157
|
*/
|
|
157
158
|
const detectPlatform = (term) => {
|
|
158
|
-
if (
|
|
159
|
+
if (hasAnySuffix(term, FARCASTER_SUFFIXES))
|
|
159
160
|
return platform.Platform.farcaster;
|
|
160
|
-
for (const [regex,
|
|
161
|
+
for (const [regex, platform] of platformMap) {
|
|
161
162
|
if (regex.test(term)) {
|
|
162
|
-
return
|
|
163
|
+
return platform;
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
if (platform$1.PLATFORM_DATA.has(suffix))
|
|
169
|
-
return suffix;
|
|
170
|
-
}
|
|
166
|
+
const suffix = getSuffixAfterLastDot(term);
|
|
167
|
+
if (suffix && platform$1.PLATFORM_DATA.has(suffix))
|
|
168
|
+
return suffix;
|
|
171
169
|
return term.includes(".") ? platform.Platform.ens : platform.Platform.farcaster;
|
|
172
170
|
};
|
|
173
171
|
/**
|
|
@@ -189,9 +187,7 @@ const getApiKey = (userProvidedKey) => {
|
|
|
189
187
|
* @returns True if addresses match (ignoring case), false otherwise
|
|
190
188
|
*/
|
|
191
189
|
const isSameAddress = (address, otherAddress) => {
|
|
192
|
-
|
|
193
|
-
return false;
|
|
194
|
-
return address.toLowerCase() === otherAddress.toLowerCase();
|
|
190
|
+
return !!address && !!otherAddress && address.toLowerCase() === otherAddress.toLowerCase();
|
|
195
191
|
};
|
|
196
192
|
const web3AddressRegexes = [
|
|
197
193
|
regex.REGEX.ETH_ADDRESS,
|
|
@@ -234,7 +230,7 @@ const isValidEthereumAddress = (address) => {
|
|
|
234
230
|
* @returns True if the string is a valid Solana address, false otherwise
|
|
235
231
|
*/
|
|
236
232
|
const isValidSolanaAddress = (address) => {
|
|
237
|
-
return regex.REGEX.SOLANA_ADDRESS.test(address);
|
|
233
|
+
return !!address && regex.REGEX.SOLANA_ADDRESS.test(address);
|
|
238
234
|
};
|
|
239
235
|
/**
|
|
240
236
|
* Converts an identity string to a JSON object with platform and identity
|
|
@@ -250,7 +246,11 @@ const idToJson = (input) => {
|
|
|
250
246
|
const id = resolveIdentity(input);
|
|
251
247
|
if (!id)
|
|
252
248
|
return null;
|
|
253
|
-
const
|
|
249
|
+
const separatorIndex = id.indexOf(",");
|
|
250
|
+
if (separatorIndex === -1)
|
|
251
|
+
return null;
|
|
252
|
+
const _platform = id.slice(0, separatorIndex);
|
|
253
|
+
const _identity = id.slice(separatorIndex + 1);
|
|
254
254
|
return {
|
|
255
255
|
platform: _platform,
|
|
256
256
|
identity: _identity,
|
package/dist/utils/helpers.js
CHANGED
|
@@ -4,10 +4,33 @@ import '../types/hook.js';
|
|
|
4
4
|
import '../types/source.js';
|
|
5
5
|
import '../types/cointype.js';
|
|
6
6
|
import '../types/credential.js';
|
|
7
|
-
import {
|
|
7
|
+
import { PLATFORM_DATA, isWeb2Platform } from './platform.js';
|
|
8
8
|
import { REGEX } from './regex.js';
|
|
9
9
|
|
|
10
10
|
const PROFILE_API_ENDPOINT = "https://api.web3.bio";
|
|
11
|
+
const FARCASTER_SUFFIXES = [".farcaster", ".fcast.id", ".farcaster.eth"];
|
|
12
|
+
const CHAIN_ALIASES = [".base", ".linea"];
|
|
13
|
+
const hasAnySuffix = (value, suffixes) => suffixes.some((suffix) => value.endsWith(suffix));
|
|
14
|
+
const getSuffixAfterLastDot = (value) => {
|
|
15
|
+
const lastDotIndex = value.lastIndexOf(".");
|
|
16
|
+
return lastDotIndex === -1 ? null : value.slice(lastDotIndex + 1);
|
|
17
|
+
};
|
|
18
|
+
const removeWeb2PlatformSuffix = (value) => {
|
|
19
|
+
const suffix = getSuffixAfterLastDot(value);
|
|
20
|
+
if (!suffix || !isWeb2Platform(suffix))
|
|
21
|
+
return value;
|
|
22
|
+
return value.slice(0, -(suffix.length + 1));
|
|
23
|
+
};
|
|
24
|
+
const normalizeChainAliasToEth = (value) => {
|
|
25
|
+
const [name, ...rest] = value.split(".");
|
|
26
|
+
const chain = rest[rest.length - 1];
|
|
27
|
+
return `${name}.${chain}.eth`;
|
|
28
|
+
};
|
|
29
|
+
const withPlatformEthSuffix = (value, shortSuffix, fullSuffix) => {
|
|
30
|
+
if (value.endsWith(fullSuffix))
|
|
31
|
+
return value;
|
|
32
|
+
return value.endsWith(shortSuffix) ? `${value}.eth` : `${value}${fullSuffix}`;
|
|
33
|
+
};
|
|
11
34
|
/**
|
|
12
35
|
* Resolves an identity string to a platform and identifier
|
|
13
36
|
* @param input The identity to resolve
|
|
@@ -48,24 +71,14 @@ const prettify = (input) => {
|
|
|
48
71
|
return "";
|
|
49
72
|
if (input.startsWith("farcaster,#"))
|
|
50
73
|
return input.replace(/^(farcaster),/, "");
|
|
51
|
-
if (input
|
|
52
|
-
input.endsWith(".fcast.id") ||
|
|
53
|
-
input.endsWith(".farcaster.eth")) {
|
|
74
|
+
if (hasAnySuffix(input, FARCASTER_SUFFIXES)) {
|
|
54
75
|
return input.replace(/(\.farcaster|\.fcast\.id|\.farcaster\.eth)$/, "");
|
|
55
76
|
}
|
|
56
|
-
if (input
|
|
57
|
-
|
|
58
|
-
return `${parts[0]}.${parts[parts.length - 1]}.eth`;
|
|
59
|
-
}
|
|
60
|
-
// for all web2 platform prettify format as "identity.platform"
|
|
61
|
-
const lastDotIndex = input.lastIndexOf(".");
|
|
62
|
-
if (lastDotIndex !== -1) {
|
|
63
|
-
const suffix = input.slice(lastDotIndex + 1);
|
|
64
|
-
if (isWeb2Platform(suffix)) {
|
|
65
|
-
return input.slice(0, lastDotIndex);
|
|
66
|
-
}
|
|
77
|
+
if (hasAnySuffix(input, CHAIN_ALIASES)) {
|
|
78
|
+
return normalizeChainAliasToEth(input);
|
|
67
79
|
}
|
|
68
|
-
|
|
80
|
+
// For all web2 platforms prettify format as "identity.platform".
|
|
81
|
+
return removeWeb2PlatformSuffix(input);
|
|
69
82
|
};
|
|
70
83
|
/**
|
|
71
84
|
* Fufill and standardize identity format
|
|
@@ -75,25 +88,15 @@ const uglify = (input, platform) => {
|
|
|
75
88
|
return "";
|
|
76
89
|
switch (platform) {
|
|
77
90
|
case Platform.farcaster:
|
|
78
|
-
return input
|
|
79
|
-
input.endsWith(".fcast.id") ||
|
|
80
|
-
input.endsWith(".farcaster.eth")
|
|
91
|
+
return hasAnySuffix(input, FARCASTER_SUFFIXES)
|
|
81
92
|
? input
|
|
82
93
|
: `${input}.farcaster`;
|
|
83
94
|
case Platform.lens:
|
|
84
95
|
return input.endsWith(".lens") ? input : `${input}.lens`;
|
|
85
96
|
case Platform.basenames:
|
|
86
|
-
return input.
|
|
87
|
-
? input
|
|
88
|
-
: input.endsWith(".base")
|
|
89
|
-
? `${input}.eth`
|
|
90
|
-
: `${input}.base.eth`;
|
|
97
|
+
return withPlatformEthSuffix(input, ".base", ".base.eth");
|
|
91
98
|
case Platform.linea:
|
|
92
|
-
return input.
|
|
93
|
-
? input
|
|
94
|
-
: input.endsWith(".linea")
|
|
95
|
-
? `${input}.eth`
|
|
96
|
-
: `${input}.linea.eth`;
|
|
99
|
+
return withPlatformEthSuffix(input, ".linea", ".linea.eth");
|
|
97
100
|
default:
|
|
98
101
|
return input;
|
|
99
102
|
}
|
|
@@ -126,9 +129,7 @@ const SUPPORTED_PLATFORMS = new Set([
|
|
|
126
129
|
* Check if the platform is supported for API queries
|
|
127
130
|
*/
|
|
128
131
|
const isSupportedPlatform = (platform) => {
|
|
129
|
-
|
|
130
|
-
return false;
|
|
131
|
-
return SUPPORTED_PLATFORMS.has(platform);
|
|
132
|
+
return !!platform && SUPPORTED_PLATFORMS.has(platform);
|
|
132
133
|
};
|
|
133
134
|
const platformMap = new Map([
|
|
134
135
|
[REGEX.BASENAMES, Platform.basenames],
|
|
@@ -153,19 +154,16 @@ const platformMap = new Map([
|
|
|
153
154
|
* Detect platform from identity string based on regex patterns
|
|
154
155
|
*/
|
|
155
156
|
const detectPlatform = (term) => {
|
|
156
|
-
if (
|
|
157
|
+
if (hasAnySuffix(term, FARCASTER_SUFFIXES))
|
|
157
158
|
return Platform.farcaster;
|
|
158
|
-
for (const [regex,
|
|
159
|
+
for (const [regex, platform] of platformMap) {
|
|
159
160
|
if (regex.test(term)) {
|
|
160
|
-
return
|
|
161
|
+
return platform;
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
const
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
if (PLATFORM_DATA.has(suffix))
|
|
167
|
-
return suffix;
|
|
168
|
-
}
|
|
164
|
+
const suffix = getSuffixAfterLastDot(term);
|
|
165
|
+
if (suffix && PLATFORM_DATA.has(suffix))
|
|
166
|
+
return suffix;
|
|
169
167
|
return term.includes(".") ? Platform.ens : Platform.farcaster;
|
|
170
168
|
};
|
|
171
169
|
/**
|
|
@@ -187,9 +185,7 @@ const getApiKey = (userProvidedKey) => {
|
|
|
187
185
|
* @returns True if addresses match (ignoring case), false otherwise
|
|
188
186
|
*/
|
|
189
187
|
const isSameAddress = (address, otherAddress) => {
|
|
190
|
-
|
|
191
|
-
return false;
|
|
192
|
-
return address.toLowerCase() === otherAddress.toLowerCase();
|
|
188
|
+
return !!address && !!otherAddress && address.toLowerCase() === otherAddress.toLowerCase();
|
|
193
189
|
};
|
|
194
190
|
const web3AddressRegexes = [
|
|
195
191
|
REGEX.ETH_ADDRESS,
|
|
@@ -232,7 +228,7 @@ const isValidEthereumAddress = (address) => {
|
|
|
232
228
|
* @returns True if the string is a valid Solana address, false otherwise
|
|
233
229
|
*/
|
|
234
230
|
const isValidSolanaAddress = (address) => {
|
|
235
|
-
return REGEX.SOLANA_ADDRESS.test(address);
|
|
231
|
+
return !!address && REGEX.SOLANA_ADDRESS.test(address);
|
|
236
232
|
};
|
|
237
233
|
/**
|
|
238
234
|
* Converts an identity string to a JSON object with platform and identity
|
|
@@ -248,7 +244,11 @@ const idToJson = (input) => {
|
|
|
248
244
|
const id = resolveIdentity(input);
|
|
249
245
|
if (!id)
|
|
250
246
|
return null;
|
|
251
|
-
const
|
|
247
|
+
const separatorIndex = id.indexOf(",");
|
|
248
|
+
if (separatorIndex === -1)
|
|
249
|
+
return null;
|
|
250
|
+
const _platform = id.slice(0, separatorIndex);
|
|
251
|
+
const _identity = id.slice(separatorIndex + 1);
|
|
252
252
|
return {
|
|
253
253
|
platform: _platform,
|
|
254
254
|
identity: _identity,
|
package/dist/utils/ipfs.cjs
CHANGED
|
@@ -9,35 +9,43 @@ const MATCH_IPFS_CID_RE = new RegExp(IPFS_CID_PATTERN);
|
|
|
9
9
|
const MATCH_IPFS_CID_AT_STARTS_RE = new RegExp(`^https://(?:${IPFS_CID_PATTERN})`);
|
|
10
10
|
const MATCH_IPFS_CID_AND_PATHNAME_RE = new RegExp(`(?:${IPFS_CID_PATTERN})(?:/.*)?`);
|
|
11
11
|
const CORS_HOST_RE = new RegExp(`^(?:${CORS_HOST}|${CF_IPFS_HOST})\\??`);
|
|
12
|
+
const tryDecodeURIComponent = (value) => {
|
|
13
|
+
try {
|
|
14
|
+
return decodeURIComponent(value);
|
|
15
|
+
}
|
|
16
|
+
catch (_a) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
12
20
|
const resolveIPFS_CID = (str) => { var _a; return (_a = str.match(MATCH_IPFS_CID_RE)) === null || _a === void 0 ? void 0 : _a[0]; };
|
|
13
21
|
const isIPFS = (str) => MATCH_IPFS_CID_RE.test(str);
|
|
14
22
|
function resolveIPFS_URL(cidOrURL) {
|
|
15
23
|
if (!cidOrURL)
|
|
16
24
|
return cidOrURL;
|
|
17
|
-
// Normalize input by trimming and decoding
|
|
25
|
+
// Normalize input by trimming and decoding.
|
|
18
26
|
const queryIndex = cidOrURL.indexOf("?");
|
|
19
|
-
let normalizedURL =
|
|
20
|
-
// Handle CORS proxies first
|
|
27
|
+
let normalizedURL = tryDecodeURIComponent(queryIndex !== -1 ? cidOrURL.slice(0, queryIndex) : cidOrURL);
|
|
28
|
+
// Handle CORS proxies first.
|
|
21
29
|
if (normalizedURL.startsWith(CORS_HOST) ||
|
|
22
30
|
normalizedURL.startsWith(CF_IPFS_HOST)) {
|
|
23
31
|
normalizedURL = normalizedURL.replace(CORS_HOST_RE, "");
|
|
24
|
-
// Continue processing the URL without the proxy prefix
|
|
32
|
+
// Continue processing the URL without the proxy prefix.
|
|
25
33
|
}
|
|
26
|
-
// Handle ipfs.io URLs
|
|
27
|
-
if (normalizedURL.startsWith(
|
|
34
|
+
// Handle ipfs.io URLs.
|
|
35
|
+
if (normalizedURL.startsWith(IPFS_GATEWAY_HOST)) {
|
|
28
36
|
const dataMatch = normalizedURL.match(MATCH_IPFS_DATA_RE);
|
|
29
37
|
if (dataMatch === null || dataMatch === void 0 ? void 0 : dataMatch[1]) {
|
|
30
|
-
return
|
|
38
|
+
return tryDecodeURIComponent(dataMatch[1]);
|
|
31
39
|
}
|
|
32
40
|
return normalizedURL;
|
|
33
41
|
}
|
|
34
|
-
// Handle ipfs protocol and CIDs
|
|
42
|
+
// Handle ipfs protocol and CIDs.
|
|
35
43
|
if (normalizedURL.includes("ipfs:") || isIPFS(normalizedURL)) {
|
|
36
|
-
// Convert ipfs:// protocol to CID format
|
|
44
|
+
// Convert ipfs:// protocol to CID format.
|
|
37
45
|
if (normalizedURL.startsWith("ipfs://")) {
|
|
38
46
|
normalizedURL = normalizedURL.slice(7);
|
|
39
47
|
}
|
|
40
|
-
// Handle URLs that start with a CID
|
|
48
|
+
// Handle URLs that start with a CID.
|
|
41
49
|
if (MATCH_IPFS_CID_AT_STARTS_RE.test(normalizedURL)) {
|
|
42
50
|
try {
|
|
43
51
|
const url = new URL(normalizedURL);
|
|
@@ -51,7 +59,7 @@ function resolveIPFS_URL(cidOrURL) {
|
|
|
51
59
|
console.debug("Failed to parse URL with CID", { normalizedURL, error });
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
|
-
// Handle bare CIDs or CIDs with paths
|
|
62
|
+
// Handle bare CIDs or CIDs with paths.
|
|
55
63
|
const pathMatch = normalizedURL.match(MATCH_IPFS_CID_AND_PATHNAME_RE);
|
|
56
64
|
if (pathMatch === null || pathMatch === void 0 ? void 0 : pathMatch[0]) {
|
|
57
65
|
return `${IPFS_GATEWAY_HOST}/ipfs/${pathMatch[0]}`;
|
package/dist/utils/ipfs.js
CHANGED
|
@@ -7,35 +7,43 @@ const MATCH_IPFS_CID_RE = new RegExp(IPFS_CID_PATTERN);
|
|
|
7
7
|
const MATCH_IPFS_CID_AT_STARTS_RE = new RegExp(`^https://(?:${IPFS_CID_PATTERN})`);
|
|
8
8
|
const MATCH_IPFS_CID_AND_PATHNAME_RE = new RegExp(`(?:${IPFS_CID_PATTERN})(?:/.*)?`);
|
|
9
9
|
const CORS_HOST_RE = new RegExp(`^(?:${CORS_HOST}|${CF_IPFS_HOST})\\??`);
|
|
10
|
+
const tryDecodeURIComponent = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return decodeURIComponent(value);
|
|
13
|
+
}
|
|
14
|
+
catch (_a) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
10
18
|
const resolveIPFS_CID = (str) => { var _a; return (_a = str.match(MATCH_IPFS_CID_RE)) === null || _a === void 0 ? void 0 : _a[0]; };
|
|
11
19
|
const isIPFS = (str) => MATCH_IPFS_CID_RE.test(str);
|
|
12
20
|
function resolveIPFS_URL(cidOrURL) {
|
|
13
21
|
if (!cidOrURL)
|
|
14
22
|
return cidOrURL;
|
|
15
|
-
// Normalize input by trimming and decoding
|
|
23
|
+
// Normalize input by trimming and decoding.
|
|
16
24
|
const queryIndex = cidOrURL.indexOf("?");
|
|
17
|
-
let normalizedURL =
|
|
18
|
-
// Handle CORS proxies first
|
|
25
|
+
let normalizedURL = tryDecodeURIComponent(queryIndex !== -1 ? cidOrURL.slice(0, queryIndex) : cidOrURL);
|
|
26
|
+
// Handle CORS proxies first.
|
|
19
27
|
if (normalizedURL.startsWith(CORS_HOST) ||
|
|
20
28
|
normalizedURL.startsWith(CF_IPFS_HOST)) {
|
|
21
29
|
normalizedURL = normalizedURL.replace(CORS_HOST_RE, "");
|
|
22
|
-
// Continue processing the URL without the proxy prefix
|
|
30
|
+
// Continue processing the URL without the proxy prefix.
|
|
23
31
|
}
|
|
24
|
-
// Handle ipfs.io URLs
|
|
25
|
-
if (normalizedURL.startsWith(
|
|
32
|
+
// Handle ipfs.io URLs.
|
|
33
|
+
if (normalizedURL.startsWith(IPFS_GATEWAY_HOST)) {
|
|
26
34
|
const dataMatch = normalizedURL.match(MATCH_IPFS_DATA_RE);
|
|
27
35
|
if (dataMatch === null || dataMatch === void 0 ? void 0 : dataMatch[1]) {
|
|
28
|
-
return
|
|
36
|
+
return tryDecodeURIComponent(dataMatch[1]);
|
|
29
37
|
}
|
|
30
38
|
return normalizedURL;
|
|
31
39
|
}
|
|
32
|
-
// Handle ipfs protocol and CIDs
|
|
40
|
+
// Handle ipfs protocol and CIDs.
|
|
33
41
|
if (normalizedURL.includes("ipfs:") || isIPFS(normalizedURL)) {
|
|
34
|
-
// Convert ipfs:// protocol to CID format
|
|
42
|
+
// Convert ipfs:// protocol to CID format.
|
|
35
43
|
if (normalizedURL.startsWith("ipfs://")) {
|
|
36
44
|
normalizedURL = normalizedURL.slice(7);
|
|
37
45
|
}
|
|
38
|
-
// Handle URLs that start with a CID
|
|
46
|
+
// Handle URLs that start with a CID.
|
|
39
47
|
if (MATCH_IPFS_CID_AT_STARTS_RE.test(normalizedURL)) {
|
|
40
48
|
try {
|
|
41
49
|
const url = new URL(normalizedURL);
|
|
@@ -49,7 +57,7 @@ function resolveIPFS_URL(cidOrURL) {
|
|
|
49
57
|
console.debug("Failed to parse URL with CID", { normalizedURL, error });
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
|
-
// Handle bare CIDs or CIDs with paths
|
|
60
|
+
// Handle bare CIDs or CIDs with paths.
|
|
53
61
|
const pathMatch = normalizedURL.match(MATCH_IPFS_CID_AND_PATHNAME_RE);
|
|
54
62
|
if (pathMatch === null || pathMatch === void 0 ? void 0 : pathMatch[0]) {
|
|
55
63
|
return `${IPFS_GATEWAY_HOST}/ipfs/${pathMatch[0]}`;
|
package/dist/utils/network.cjs
CHANGED
|
@@ -371,6 +371,21 @@ const NETWORK_DATA = {
|
|
|
371
371
|
short: "zora",
|
|
372
372
|
},
|
|
373
373
|
};
|
|
374
|
+
const NETWORK_VALUES = Object.values(NETWORK_DATA);
|
|
375
|
+
const NETWORK_BY_CHAIN_ID = new Map(NETWORK_VALUES
|
|
376
|
+
.filter((network) => typeof network.chainId === "number")
|
|
377
|
+
.map((network) => [network.chainId, network]));
|
|
378
|
+
const NETWORK_BY_SHORT = new Map(NETWORK_VALUES
|
|
379
|
+
.filter((network) => typeof network.short === "string" && network.short.length > 0)
|
|
380
|
+
.map((network) => [network.short, network]));
|
|
381
|
+
const toFallbackNetwork = (networkIdentifier) => ({
|
|
382
|
+
key: String(networkIdentifier),
|
|
383
|
+
icon: "",
|
|
384
|
+
label: String(networkIdentifier),
|
|
385
|
+
primaryColor: "#000000",
|
|
386
|
+
bgColor: "#efefef",
|
|
387
|
+
scanPrefix: "",
|
|
388
|
+
});
|
|
374
389
|
/**
|
|
375
390
|
* Gets network metadata for a given network identifier
|
|
376
391
|
* Supports lookup by network key, network short name, or chainId
|
|
@@ -379,28 +394,15 @@ const NETWORK_DATA = {
|
|
|
379
394
|
* @returns Network metadata object
|
|
380
395
|
*/
|
|
381
396
|
const getNetwork = (networkIdentifier) => {
|
|
382
|
-
const
|
|
397
|
+
const numericIdentifier = Number(networkIdentifier);
|
|
398
|
+
const isNumberParam = !Number.isNaN(numericIdentifier);
|
|
383
399
|
if (isNumberParam) {
|
|
384
|
-
|
|
385
|
-
if (networkByChainId)
|
|
386
|
-
return networkByChainId;
|
|
400
|
+
return NETWORK_BY_CHAIN_ID.get(numericIdentifier) || toFallbackNetwork(networkIdentifier);
|
|
387
401
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
if (networkByShort) {
|
|
393
|
-
return networkByShort;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return {
|
|
397
|
-
key: String(networkIdentifier),
|
|
398
|
-
icon: "",
|
|
399
|
-
label: String(networkIdentifier),
|
|
400
|
-
primaryColor: "#000000",
|
|
401
|
-
bgColor: "#efefef",
|
|
402
|
-
scanPrefix: "",
|
|
403
|
-
};
|
|
402
|
+
const networkKey = networkIdentifier;
|
|
403
|
+
if (NETWORK_DATA[networkKey])
|
|
404
|
+
return NETWORK_DATA[networkKey];
|
|
405
|
+
return NETWORK_BY_SHORT.get(String(networkIdentifier)) || toFallbackNetwork(networkIdentifier);
|
|
404
406
|
};
|
|
405
407
|
|
|
406
408
|
exports.NETWORK_DATA = NETWORK_DATA;
|
package/dist/utils/network.js
CHANGED
|
@@ -369,6 +369,21 @@ const NETWORK_DATA = {
|
|
|
369
369
|
short: "zora",
|
|
370
370
|
},
|
|
371
371
|
};
|
|
372
|
+
const NETWORK_VALUES = Object.values(NETWORK_DATA);
|
|
373
|
+
const NETWORK_BY_CHAIN_ID = new Map(NETWORK_VALUES
|
|
374
|
+
.filter((network) => typeof network.chainId === "number")
|
|
375
|
+
.map((network) => [network.chainId, network]));
|
|
376
|
+
const NETWORK_BY_SHORT = new Map(NETWORK_VALUES
|
|
377
|
+
.filter((network) => typeof network.short === "string" && network.short.length > 0)
|
|
378
|
+
.map((network) => [network.short, network]));
|
|
379
|
+
const toFallbackNetwork = (networkIdentifier) => ({
|
|
380
|
+
key: String(networkIdentifier),
|
|
381
|
+
icon: "",
|
|
382
|
+
label: String(networkIdentifier),
|
|
383
|
+
primaryColor: "#000000",
|
|
384
|
+
bgColor: "#efefef",
|
|
385
|
+
scanPrefix: "",
|
|
386
|
+
});
|
|
372
387
|
/**
|
|
373
388
|
* Gets network metadata for a given network identifier
|
|
374
389
|
* Supports lookup by network key, network short name, or chainId
|
|
@@ -377,28 +392,15 @@ const NETWORK_DATA = {
|
|
|
377
392
|
* @returns Network metadata object
|
|
378
393
|
*/
|
|
379
394
|
const getNetwork = (networkIdentifier) => {
|
|
380
|
-
const
|
|
395
|
+
const numericIdentifier = Number(networkIdentifier);
|
|
396
|
+
const isNumberParam = !Number.isNaN(numericIdentifier);
|
|
381
397
|
if (isNumberParam) {
|
|
382
|
-
|
|
383
|
-
if (networkByChainId)
|
|
384
|
-
return networkByChainId;
|
|
398
|
+
return NETWORK_BY_CHAIN_ID.get(numericIdentifier) || toFallbackNetwork(networkIdentifier);
|
|
385
399
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (networkByShort) {
|
|
391
|
-
return networkByShort;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return {
|
|
395
|
-
key: String(networkIdentifier),
|
|
396
|
-
icon: "",
|
|
397
|
-
label: String(networkIdentifier),
|
|
398
|
-
primaryColor: "#000000",
|
|
399
|
-
bgColor: "#efefef",
|
|
400
|
-
scanPrefix: "",
|
|
401
|
-
};
|
|
400
|
+
const networkKey = networkIdentifier;
|
|
401
|
+
if (NETWORK_DATA[networkKey])
|
|
402
|
+
return NETWORK_DATA[networkKey];
|
|
403
|
+
return NETWORK_BY_SHORT.get(String(networkIdentifier)) || toFallbackNetwork(networkIdentifier);
|
|
402
404
|
};
|
|
403
405
|
|
|
404
406
|
export { NETWORK_DATA, getNetwork };
|
package/dist/utils/platform.cjs
CHANGED
|
@@ -38,9 +38,7 @@ const WEB2_PLATFORM_SET = new Set(WEB2_PLATFORMS);
|
|
|
38
38
|
* @public
|
|
39
39
|
*/
|
|
40
40
|
const isWeb2Platform = (platform) => {
|
|
41
|
-
|
|
42
|
-
return false;
|
|
43
|
-
return WEB2_PLATFORM_SET.has(platform);
|
|
41
|
+
return !!platform && WEB2_PLATFORM_SET.has(platform);
|
|
44
42
|
};
|
|
45
43
|
/**
|
|
46
44
|
* Default data
|
|
@@ -61,26 +59,6 @@ const DEFAULT_PLATFORM = {
|
|
|
61
59
|
* @public
|
|
62
60
|
*/
|
|
63
61
|
const PLATFORM_DATA = new Map([
|
|
64
|
-
[
|
|
65
|
-
platform.Platform.ailayer,
|
|
66
|
-
{
|
|
67
|
-
color: "#A283FF",
|
|
68
|
-
icon: "icons/icon-ailayer.svg",
|
|
69
|
-
label: "AILayer Name Service",
|
|
70
|
-
urlPrefix: "https://mainnet-explorer.ailayer.xyz/address/",
|
|
71
|
-
registerlink: "https://space.id/tld/19/domains?query={name}",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
[
|
|
75
|
-
platform.Platform.alienx,
|
|
76
|
-
{
|
|
77
|
-
color: "#D5F462",
|
|
78
|
-
icon: "icons/icon-alienx.svg",
|
|
79
|
-
label: "AlienX Name Service",
|
|
80
|
-
urlPrefix: "https://explorer.alienxchain.io/address/",
|
|
81
|
-
registerlink: "https://space.id/tld/17/domains?query={name}",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
62
|
[
|
|
85
63
|
platform.Platform.aptos,
|
|
86
64
|
{
|
|
@@ -212,24 +190,6 @@ const PLATFORM_DATA = new Map([
|
|
|
212
190
|
urlPrefix: "https://www.coingecko.com/en/coins/",
|
|
213
191
|
},
|
|
214
192
|
],
|
|
215
|
-
[
|
|
216
|
-
platform.Platform.cosmos,
|
|
217
|
-
{
|
|
218
|
-
color: "#000000",
|
|
219
|
-
icon: "icons/icon-cosmos.svg",
|
|
220
|
-
label: "Cosmos",
|
|
221
|
-
urlPrefix: "https://www.mintscan.io/cosmos/account/",
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
[
|
|
225
|
-
platform.Platform.cyberconnect,
|
|
226
|
-
{
|
|
227
|
-
color: "#000000",
|
|
228
|
-
icon: "icons/icon-cyberconnect.svg",
|
|
229
|
-
label: "CyberConnect",
|
|
230
|
-
urlPrefix: "https://link3.to/",
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
193
|
[
|
|
234
194
|
platform.Platform.deepdao,
|
|
235
195
|
{
|
|
@@ -302,15 +262,6 @@ const PLATFORM_DATA = new Map([
|
|
|
302
262
|
registerlink: "https://www.ethcomments.xyz/",
|
|
303
263
|
},
|
|
304
264
|
],
|
|
305
|
-
[
|
|
306
|
-
platform.Platform.edgeless,
|
|
307
|
-
{
|
|
308
|
-
color: "#a0eb67",
|
|
309
|
-
icon: "icons/icon-edgeless.svg",
|
|
310
|
-
label: "Edgeless",
|
|
311
|
-
urlPrefix: "https://explorer.edgeless.network/address/",
|
|
312
|
-
},
|
|
313
|
-
],
|
|
314
265
|
[
|
|
315
266
|
platform.Platform.efp,
|
|
316
267
|
{
|
|
@@ -516,16 +467,6 @@ const PLATFORM_DATA = new Map([
|
|
|
516
467
|
registerlink: "https://www.lens.xyz/mint?name={name}",
|
|
517
468
|
},
|
|
518
469
|
],
|
|
519
|
-
[
|
|
520
|
-
platform.Platform.lightlink,
|
|
521
|
-
{
|
|
522
|
-
color: "#00BFFF",
|
|
523
|
-
icon: "icons/icon-lightlink.svg",
|
|
524
|
-
label: "LightLink Name Service",
|
|
525
|
-
urlPrefix: "https://phoenix.lightlink.io/address/",
|
|
526
|
-
registerlink: "https://space.id/tld/9/domains?query={name}",
|
|
527
|
-
},
|
|
528
|
-
],
|
|
529
470
|
[
|
|
530
471
|
platform.Platform.linea,
|
|
531
472
|
{
|
|
@@ -557,16 +498,6 @@ const PLATFORM_DATA = new Map([
|
|
|
557
498
|
urlPrefix: "https://lobste.rs/~",
|
|
558
499
|
},
|
|
559
500
|
],
|
|
560
|
-
[
|
|
561
|
-
platform.Platform.manta,
|
|
562
|
-
{
|
|
563
|
-
color: "#0091ff",
|
|
564
|
-
icon: "icons/icon-manta.svg",
|
|
565
|
-
label: "Manta Name Service",
|
|
566
|
-
urlPrefix: "https://pacific-explorer.manta.network/address/",
|
|
567
|
-
registerlink: "https://space.id/tld/3/domains?query={name}",
|
|
568
|
-
},
|
|
569
|
-
],
|
|
570
501
|
[
|
|
571
502
|
platform.Platform.matters,
|
|
572
503
|
{
|
|
@@ -585,16 +516,6 @@ const PLATFORM_DATA = new Map([
|
|
|
585
516
|
urlPrefix: "https://medium.com/",
|
|
586
517
|
},
|
|
587
518
|
],
|
|
588
|
-
[
|
|
589
|
-
platform.Platform.merlin,
|
|
590
|
-
{
|
|
591
|
-
color: "#5A32A3",
|
|
592
|
-
icon: "icons/icon-merlin.svg",
|
|
593
|
-
label: "Merlin Name Service",
|
|
594
|
-
urlPrefix: "https://scan.merlinchain.io/address/",
|
|
595
|
-
registerlink: "https://space.id/tld/12/domains?query={name}",
|
|
596
|
-
},
|
|
597
|
-
],
|
|
598
519
|
[
|
|
599
520
|
platform.Platform.minds,
|
|
600
521
|
{
|
|
@@ -604,26 +525,6 @@ const PLATFORM_DATA = new Map([
|
|
|
604
525
|
urlPrefix: "https://www.minds.com/",
|
|
605
526
|
},
|
|
606
527
|
],
|
|
607
|
-
[
|
|
608
|
-
platform.Platform.mint,
|
|
609
|
-
{
|
|
610
|
-
color: "#00A57C",
|
|
611
|
-
icon: "icons/icon-mint.svg",
|
|
612
|
-
label: "Mint Name Service",
|
|
613
|
-
urlPrefix: "https://explorer.mintchain.io/address/",
|
|
614
|
-
registerlink: "https://space.id/tld/18/domains?query={name}",
|
|
615
|
-
},
|
|
616
|
-
],
|
|
617
|
-
[
|
|
618
|
-
platform.Platform.mode,
|
|
619
|
-
{
|
|
620
|
-
color: "#E5FD52",
|
|
621
|
-
icon: "icons/icon-mode.svg",
|
|
622
|
-
label: "Mode Name Service",
|
|
623
|
-
urlPrefix: "https://explorer.mode.network/address/",
|
|
624
|
-
registerlink: "https://space.id/tld/6/domains?query={name}",
|
|
625
|
-
},
|
|
626
|
-
],
|
|
627
528
|
[
|
|
628
529
|
platform.Platform.mstdnjp,
|
|
629
530
|
{
|
|
@@ -829,16 +730,6 @@ const PLATFORM_DATA = new Map([
|
|
|
829
730
|
urlPrefix: "https://substack.com/@",
|
|
830
731
|
},
|
|
831
732
|
],
|
|
832
|
-
[
|
|
833
|
-
platform.Platform.taiko,
|
|
834
|
-
{
|
|
835
|
-
color: "#E81899",
|
|
836
|
-
icon: "icons/icon-taiko.svg",
|
|
837
|
-
label: "DotTaiko Name Service",
|
|
838
|
-
urlPrefix: "https://taikoscan.io/address/",
|
|
839
|
-
registerlink: "https://space.id/tld/16/domains?query={name}",
|
|
840
|
-
},
|
|
841
|
-
],
|
|
842
733
|
[
|
|
843
734
|
platform.Platform.talent,
|
|
844
735
|
{
|
|
@@ -885,15 +776,6 @@ const PLATFORM_DATA = new Map([
|
|
|
885
776
|
urlPrefix: "https://www.tiktok.com/@",
|
|
886
777
|
},
|
|
887
778
|
],
|
|
888
|
-
[
|
|
889
|
-
platform.Platform.tomo,
|
|
890
|
-
{
|
|
891
|
-
color: "#DE3A7E",
|
|
892
|
-
icon: "icons/icon-tomo.svg",
|
|
893
|
-
label: "Tomo Name Service",
|
|
894
|
-
registerlink: "https://space.id/tld/10/domains?query={name}",
|
|
895
|
-
},
|
|
896
|
-
],
|
|
897
779
|
[
|
|
898
780
|
platform.Platform.ton,
|
|
899
781
|
{
|
|
@@ -1024,26 +906,6 @@ const PLATFORM_DATA = new Map([
|
|
|
1024
906
|
ensText: ["com.youtube", "youtube"],
|
|
1025
907
|
},
|
|
1026
908
|
],
|
|
1027
|
-
[
|
|
1028
|
-
platform.Platform.zeta,
|
|
1029
|
-
{
|
|
1030
|
-
color: "#005741",
|
|
1031
|
-
icon: "icons/icon-zeta.svg",
|
|
1032
|
-
label: "Zeta Name Service",
|
|
1033
|
-
urlPrefix: "https://explorer.zetachain.com/address/",
|
|
1034
|
-
registerlink: "https://space.id/tld/11/domains?query={name}",
|
|
1035
|
-
},
|
|
1036
|
-
],
|
|
1037
|
-
[
|
|
1038
|
-
platform.Platform.zkfair,
|
|
1039
|
-
{
|
|
1040
|
-
color: "#D43F36",
|
|
1041
|
-
icon: "icons/icon-zkfair.svg",
|
|
1042
|
-
label: "zkFair",
|
|
1043
|
-
urlPrefix: "https://scan.zkfair.io/address/",
|
|
1044
|
-
registerlink: "https://space.id/tld/8/domains?query={name}",
|
|
1045
|
-
},
|
|
1046
|
-
],
|
|
1047
909
|
[
|
|
1048
910
|
platform.Platform.zkme,
|
|
1049
911
|
{
|
|
@@ -1067,7 +929,8 @@ const PLATFORM_DATA = new Map([
|
|
|
1067
929
|
* @public
|
|
1068
930
|
*/
|
|
1069
931
|
const getPlatform = (platform) => {
|
|
1070
|
-
|
|
932
|
+
var _a;
|
|
933
|
+
return (_a = PLATFORM_DATA.get(platform)) !== null && _a !== void 0 ? _a : { ...DEFAULT_PLATFORM, label: platform };
|
|
1071
934
|
};
|
|
1072
935
|
|
|
1073
936
|
exports.DEFAULT_PLATFORM = DEFAULT_PLATFORM;
|
package/dist/utils/platform.js
CHANGED
|
@@ -36,9 +36,7 @@ const WEB2_PLATFORM_SET = new Set(WEB2_PLATFORMS);
|
|
|
36
36
|
* @public
|
|
37
37
|
*/
|
|
38
38
|
const isWeb2Platform = (platform) => {
|
|
39
|
-
|
|
40
|
-
return false;
|
|
41
|
-
return WEB2_PLATFORM_SET.has(platform);
|
|
39
|
+
return !!platform && WEB2_PLATFORM_SET.has(platform);
|
|
42
40
|
};
|
|
43
41
|
/**
|
|
44
42
|
* Default data
|
|
@@ -59,26 +57,6 @@ const DEFAULT_PLATFORM = {
|
|
|
59
57
|
* @public
|
|
60
58
|
*/
|
|
61
59
|
const PLATFORM_DATA = new Map([
|
|
62
|
-
[
|
|
63
|
-
Platform.ailayer,
|
|
64
|
-
{
|
|
65
|
-
color: "#A283FF",
|
|
66
|
-
icon: "icons/icon-ailayer.svg",
|
|
67
|
-
label: "AILayer Name Service",
|
|
68
|
-
urlPrefix: "https://mainnet-explorer.ailayer.xyz/address/",
|
|
69
|
-
registerlink: "https://space.id/tld/19/domains?query={name}",
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
Platform.alienx,
|
|
74
|
-
{
|
|
75
|
-
color: "#D5F462",
|
|
76
|
-
icon: "icons/icon-alienx.svg",
|
|
77
|
-
label: "AlienX Name Service",
|
|
78
|
-
urlPrefix: "https://explorer.alienxchain.io/address/",
|
|
79
|
-
registerlink: "https://space.id/tld/17/domains?query={name}",
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
60
|
[
|
|
83
61
|
Platform.aptos,
|
|
84
62
|
{
|
|
@@ -210,24 +188,6 @@ const PLATFORM_DATA = new Map([
|
|
|
210
188
|
urlPrefix: "https://www.coingecko.com/en/coins/",
|
|
211
189
|
},
|
|
212
190
|
],
|
|
213
|
-
[
|
|
214
|
-
Platform.cosmos,
|
|
215
|
-
{
|
|
216
|
-
color: "#000000",
|
|
217
|
-
icon: "icons/icon-cosmos.svg",
|
|
218
|
-
label: "Cosmos",
|
|
219
|
-
urlPrefix: "https://www.mintscan.io/cosmos/account/",
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
[
|
|
223
|
-
Platform.cyberconnect,
|
|
224
|
-
{
|
|
225
|
-
color: "#000000",
|
|
226
|
-
icon: "icons/icon-cyberconnect.svg",
|
|
227
|
-
label: "CyberConnect",
|
|
228
|
-
urlPrefix: "https://link3.to/",
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
191
|
[
|
|
232
192
|
Platform.deepdao,
|
|
233
193
|
{
|
|
@@ -300,15 +260,6 @@ const PLATFORM_DATA = new Map([
|
|
|
300
260
|
registerlink: "https://www.ethcomments.xyz/",
|
|
301
261
|
},
|
|
302
262
|
],
|
|
303
|
-
[
|
|
304
|
-
Platform.edgeless,
|
|
305
|
-
{
|
|
306
|
-
color: "#a0eb67",
|
|
307
|
-
icon: "icons/icon-edgeless.svg",
|
|
308
|
-
label: "Edgeless",
|
|
309
|
-
urlPrefix: "https://explorer.edgeless.network/address/",
|
|
310
|
-
},
|
|
311
|
-
],
|
|
312
263
|
[
|
|
313
264
|
Platform.efp,
|
|
314
265
|
{
|
|
@@ -514,16 +465,6 @@ const PLATFORM_DATA = new Map([
|
|
|
514
465
|
registerlink: "https://www.lens.xyz/mint?name={name}",
|
|
515
466
|
},
|
|
516
467
|
],
|
|
517
|
-
[
|
|
518
|
-
Platform.lightlink,
|
|
519
|
-
{
|
|
520
|
-
color: "#00BFFF",
|
|
521
|
-
icon: "icons/icon-lightlink.svg",
|
|
522
|
-
label: "LightLink Name Service",
|
|
523
|
-
urlPrefix: "https://phoenix.lightlink.io/address/",
|
|
524
|
-
registerlink: "https://space.id/tld/9/domains?query={name}",
|
|
525
|
-
},
|
|
526
|
-
],
|
|
527
468
|
[
|
|
528
469
|
Platform.linea,
|
|
529
470
|
{
|
|
@@ -555,16 +496,6 @@ const PLATFORM_DATA = new Map([
|
|
|
555
496
|
urlPrefix: "https://lobste.rs/~",
|
|
556
497
|
},
|
|
557
498
|
],
|
|
558
|
-
[
|
|
559
|
-
Platform.manta,
|
|
560
|
-
{
|
|
561
|
-
color: "#0091ff",
|
|
562
|
-
icon: "icons/icon-manta.svg",
|
|
563
|
-
label: "Manta Name Service",
|
|
564
|
-
urlPrefix: "https://pacific-explorer.manta.network/address/",
|
|
565
|
-
registerlink: "https://space.id/tld/3/domains?query={name}",
|
|
566
|
-
},
|
|
567
|
-
],
|
|
568
499
|
[
|
|
569
500
|
Platform.matters,
|
|
570
501
|
{
|
|
@@ -583,16 +514,6 @@ const PLATFORM_DATA = new Map([
|
|
|
583
514
|
urlPrefix: "https://medium.com/",
|
|
584
515
|
},
|
|
585
516
|
],
|
|
586
|
-
[
|
|
587
|
-
Platform.merlin,
|
|
588
|
-
{
|
|
589
|
-
color: "#5A32A3",
|
|
590
|
-
icon: "icons/icon-merlin.svg",
|
|
591
|
-
label: "Merlin Name Service",
|
|
592
|
-
urlPrefix: "https://scan.merlinchain.io/address/",
|
|
593
|
-
registerlink: "https://space.id/tld/12/domains?query={name}",
|
|
594
|
-
},
|
|
595
|
-
],
|
|
596
517
|
[
|
|
597
518
|
Platform.minds,
|
|
598
519
|
{
|
|
@@ -602,26 +523,6 @@ const PLATFORM_DATA = new Map([
|
|
|
602
523
|
urlPrefix: "https://www.minds.com/",
|
|
603
524
|
},
|
|
604
525
|
],
|
|
605
|
-
[
|
|
606
|
-
Platform.mint,
|
|
607
|
-
{
|
|
608
|
-
color: "#00A57C",
|
|
609
|
-
icon: "icons/icon-mint.svg",
|
|
610
|
-
label: "Mint Name Service",
|
|
611
|
-
urlPrefix: "https://explorer.mintchain.io/address/",
|
|
612
|
-
registerlink: "https://space.id/tld/18/domains?query={name}",
|
|
613
|
-
},
|
|
614
|
-
],
|
|
615
|
-
[
|
|
616
|
-
Platform.mode,
|
|
617
|
-
{
|
|
618
|
-
color: "#E5FD52",
|
|
619
|
-
icon: "icons/icon-mode.svg",
|
|
620
|
-
label: "Mode Name Service",
|
|
621
|
-
urlPrefix: "https://explorer.mode.network/address/",
|
|
622
|
-
registerlink: "https://space.id/tld/6/domains?query={name}",
|
|
623
|
-
},
|
|
624
|
-
],
|
|
625
526
|
[
|
|
626
527
|
Platform.mstdnjp,
|
|
627
528
|
{
|
|
@@ -827,16 +728,6 @@ const PLATFORM_DATA = new Map([
|
|
|
827
728
|
urlPrefix: "https://substack.com/@",
|
|
828
729
|
},
|
|
829
730
|
],
|
|
830
|
-
[
|
|
831
|
-
Platform.taiko,
|
|
832
|
-
{
|
|
833
|
-
color: "#E81899",
|
|
834
|
-
icon: "icons/icon-taiko.svg",
|
|
835
|
-
label: "DotTaiko Name Service",
|
|
836
|
-
urlPrefix: "https://taikoscan.io/address/",
|
|
837
|
-
registerlink: "https://space.id/tld/16/domains?query={name}",
|
|
838
|
-
},
|
|
839
|
-
],
|
|
840
731
|
[
|
|
841
732
|
Platform.talent,
|
|
842
733
|
{
|
|
@@ -883,15 +774,6 @@ const PLATFORM_DATA = new Map([
|
|
|
883
774
|
urlPrefix: "https://www.tiktok.com/@",
|
|
884
775
|
},
|
|
885
776
|
],
|
|
886
|
-
[
|
|
887
|
-
Platform.tomo,
|
|
888
|
-
{
|
|
889
|
-
color: "#DE3A7E",
|
|
890
|
-
icon: "icons/icon-tomo.svg",
|
|
891
|
-
label: "Tomo Name Service",
|
|
892
|
-
registerlink: "https://space.id/tld/10/domains?query={name}",
|
|
893
|
-
},
|
|
894
|
-
],
|
|
895
777
|
[
|
|
896
778
|
Platform.ton,
|
|
897
779
|
{
|
|
@@ -1022,26 +904,6 @@ const PLATFORM_DATA = new Map([
|
|
|
1022
904
|
ensText: ["com.youtube", "youtube"],
|
|
1023
905
|
},
|
|
1024
906
|
],
|
|
1025
|
-
[
|
|
1026
|
-
Platform.zeta,
|
|
1027
|
-
{
|
|
1028
|
-
color: "#005741",
|
|
1029
|
-
icon: "icons/icon-zeta.svg",
|
|
1030
|
-
label: "Zeta Name Service",
|
|
1031
|
-
urlPrefix: "https://explorer.zetachain.com/address/",
|
|
1032
|
-
registerlink: "https://space.id/tld/11/domains?query={name}",
|
|
1033
|
-
},
|
|
1034
|
-
],
|
|
1035
|
-
[
|
|
1036
|
-
Platform.zkfair,
|
|
1037
|
-
{
|
|
1038
|
-
color: "#D43F36",
|
|
1039
|
-
icon: "icons/icon-zkfair.svg",
|
|
1040
|
-
label: "zkFair",
|
|
1041
|
-
urlPrefix: "https://scan.zkfair.io/address/",
|
|
1042
|
-
registerlink: "https://space.id/tld/8/domains?query={name}",
|
|
1043
|
-
},
|
|
1044
|
-
],
|
|
1045
907
|
[
|
|
1046
908
|
Platform.zkme,
|
|
1047
909
|
{
|
|
@@ -1065,7 +927,8 @@ const PLATFORM_DATA = new Map([
|
|
|
1065
927
|
* @public
|
|
1066
928
|
*/
|
|
1067
929
|
const getPlatform = (platform) => {
|
|
1068
|
-
|
|
930
|
+
var _a;
|
|
931
|
+
return (_a = PLATFORM_DATA.get(platform)) !== null && _a !== void 0 ? _a : { ...DEFAULT_PLATFORM, label: platform };
|
|
1069
932
|
};
|
|
1070
933
|
|
|
1071
934
|
export { DEFAULT_PLATFORM, PLATFORM_DATA, WEB2_PLATFORMS, getPlatform, isWeb2Platform };
|
package/dist/utils/resolver.cjs
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var ipfs = require('./ipfs.cjs');
|
|
4
4
|
|
|
5
|
+
const DIRECT_MEDIA_PREFIXES = ["data:", "https:"];
|
|
5
6
|
const resolveMediaURL = (url) => {
|
|
6
7
|
if (!url)
|
|
7
8
|
return "";
|
|
8
|
-
// Fast path for common protocols
|
|
9
|
-
if (
|
|
9
|
+
// Fast path for common protocols.
|
|
10
|
+
if (DIRECT_MEDIA_PREFIXES.some((prefix) => url.startsWith(prefix))) {
|
|
10
11
|
return url;
|
|
11
12
|
}
|
|
12
13
|
// Handle Arweave
|
package/dist/utils/resolver.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isIPFS, resolveIPFS_URL } from './ipfs.js';
|
|
2
2
|
|
|
3
|
+
const DIRECT_MEDIA_PREFIXES = ["data:", "https:"];
|
|
3
4
|
const resolveMediaURL = (url) => {
|
|
4
5
|
if (!url)
|
|
5
6
|
return "";
|
|
6
|
-
// Fast path for common protocols
|
|
7
|
-
if (
|
|
7
|
+
// Fast path for common protocols.
|
|
8
|
+
if (DIRECT_MEDIA_PREFIXES.some((prefix) => url.startsWith(prefix))) {
|
|
8
9
|
return url;
|
|
9
10
|
}
|
|
10
11
|
// Handle Arweave
|
package/dist/utils/source.cjs
CHANGED
|
@@ -268,7 +268,7 @@ const SOURCE_DATA = {
|
|
|
268
268
|
* @returns Source metadata including name and description
|
|
269
269
|
* @public
|
|
270
270
|
*/
|
|
271
|
-
const getSource = (sourceKey) => SOURCE_DATA[sourceKey]
|
|
271
|
+
const getSource = (sourceKey) => { var _a; return (_a = SOURCE_DATA[sourceKey]) !== null && _a !== void 0 ? _a : { name: sourceKey, description: "Unknown source" }; };
|
|
272
272
|
|
|
273
273
|
exports.SOURCE_DATA = SOURCE_DATA;
|
|
274
274
|
exports.getSource = getSource;
|
package/dist/utils/source.js
CHANGED
|
@@ -266,6 +266,6 @@ const SOURCE_DATA = {
|
|
|
266
266
|
* @returns Source metadata including name and description
|
|
267
267
|
* @public
|
|
268
268
|
*/
|
|
269
|
-
const getSource = (sourceKey) => SOURCE_DATA[sourceKey]
|
|
269
|
+
const getSource = (sourceKey) => { var _a; return (_a = SOURCE_DATA[sourceKey]) !== null && _a !== void 0 ? _a : { name: sourceKey, description: "Unknown source" }; };
|
|
270
270
|
|
|
271
271
|
export { SOURCE_DATA, getSource };
|