web3bio-profile-kit 0.1.32 → 0.1.34

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.
@@ -73,6 +73,7 @@ exports.Platform = void 0;
73
73
  Platform["nextid"] = "nextid";
74
74
  Platform["nostr"] = "nostr";
75
75
  Platform["opensea"] = "opensea";
76
+ Platform["opinion"] = "opinion";
76
77
  Platform["paragraph"] = "paragraph";
77
78
  Platform["philand"] = "philand";
78
79
  Platform["poap"] = "poap";
@@ -70,6 +70,7 @@ export declare enum Platform {
70
70
  nextid = "nextid",
71
71
  nostr = "nostr",
72
72
  opensea = "opensea",
73
+ opinion = "opinion",
73
74
  paragraph = "paragraph",
74
75
  philand = "philand",
75
76
  poap = "poap",
@@ -71,6 +71,7 @@ var Platform;
71
71
  Platform["nextid"] = "nextid";
72
72
  Platform["nostr"] = "nostr";
73
73
  Platform["opensea"] = "opensea";
74
+ Platform["opinion"] = "opinion";
74
75
  Platform["paragraph"] = "paragraph";
75
76
  Platform["philand"] = "philand";
76
77
  Platform["poap"] = "poap";
@@ -6,9 +6,23 @@ require('../types/hook.cjs');
6
6
  require('../types/source.cjs');
7
7
  require('../types/cointype.cjs');
8
8
  require('../types/credential.cjs');
9
+ var platform$1 = require('./platform.cjs');
9
10
  var regex = require('./regex.cjs');
10
11
 
11
12
  const PROD_API_ENDPOINT = "https://api.web3.bio";
13
+ const WEB2_SUFFIXES = [
14
+ platform.Platform.twitter,
15
+ platform.Platform.nextid,
16
+ platform.Platform.keybase,
17
+ platform.Platform.instagram,
18
+ platform.Platform.github,
19
+ platform.Platform.discord,
20
+ platform.Platform.reddit,
21
+ platform.Platform.linkedin,
22
+ platform.Platform.nostr,
23
+ platform.Platform.bluesky,
24
+ platform.Platform.telegram,
25
+ ];
12
26
  /**
13
27
  * Resolves an identity string to a platform and identifier
14
28
  * @param input The identity to resolve
@@ -47,10 +61,6 @@ const resolveIdentity = (input) => {
47
61
  const prettify = (input) => {
48
62
  if (!input)
49
63
  return "";
50
- if (input.endsWith(".twitter"))
51
- return input.replace(".twitter", "");
52
- if (input.endsWith(".nextid"))
53
- return input.replace(".nextid", "");
54
64
  if (input.startsWith("farcaster,#"))
55
65
  return input.replace(/^(farcaster),/, "");
56
66
  if (input.endsWith(".farcaster") ||
@@ -61,6 +71,11 @@ const prettify = (input) => {
61
71
  if (input.endsWith(".base") || input.endsWith(".linea")) {
62
72
  return input.split(".")[0] + "." + input.split(".").pop() + ".eth";
63
73
  }
74
+ // for all web2 platform prettify format as "identity.platform"
75
+ const suffix = input.split(".")[input.split(".").length - 1];
76
+ if (WEB2_SUFFIXES.includes(suffix)) {
77
+ return input.replace(`.${suffix}`, "");
78
+ }
64
79
  return input;
65
80
  };
66
81
  /**
@@ -109,8 +124,15 @@ const isSupportedPlatform = (platform$1) => {
109
124
  platform.Platform.lens,
110
125
  platform.Platform.twitter,
111
126
  platform.Platform.github,
112
- platform.Platform.linkedin,
113
127
  platform.Platform.discord,
128
+ platform.Platform.linkedin,
129
+ platform.Platform.instagram,
130
+ platform.Platform.reddit,
131
+ platform.Platform.facebook,
132
+ platform.Platform.telegram,
133
+ platform.Platform.keybase,
134
+ platform.Platform.nostr,
135
+ platform.Platform.bluesky,
114
136
  platform.Platform.unstoppableDomains,
115
137
  platform.Platform.nextid,
116
138
  platform.Platform.dotbit,
@@ -141,6 +163,10 @@ const platformMap = new Map([
141
163
  * Detect platform from identity string based on regex patterns
142
164
  */
143
165
  const detectPlatform = (term) => {
166
+ // support all web2 platform as identity.platform format
167
+ const suffix = term.split(".")[term.split(".").length - 1];
168
+ if (platform$1.PLATFORM_DATA.has(suffix))
169
+ return suffix;
144
170
  if (/\.(farcaster\.eth|farcaster|fcast\.id)$/.test(term))
145
171
  return platform.Platform.farcaster;
146
172
  for (const [regex, Platform] of platformMap) {
@@ -4,9 +4,23 @@ import '../types/hook.js';
4
4
  import '../types/source.js';
5
5
  import '../types/cointype.js';
6
6
  import '../types/credential.js';
7
+ import { PLATFORM_DATA } from './platform.js';
7
8
  import { REGEX } from './regex.js';
8
9
 
9
10
  const PROD_API_ENDPOINT = "https://api.web3.bio";
11
+ const WEB2_SUFFIXES = [
12
+ Platform.twitter,
13
+ Platform.nextid,
14
+ Platform.keybase,
15
+ Platform.instagram,
16
+ Platform.github,
17
+ Platform.discord,
18
+ Platform.reddit,
19
+ Platform.linkedin,
20
+ Platform.nostr,
21
+ Platform.bluesky,
22
+ Platform.telegram,
23
+ ];
10
24
  /**
11
25
  * Resolves an identity string to a platform and identifier
12
26
  * @param input The identity to resolve
@@ -45,10 +59,6 @@ const resolveIdentity = (input) => {
45
59
  const prettify = (input) => {
46
60
  if (!input)
47
61
  return "";
48
- if (input.endsWith(".twitter"))
49
- return input.replace(".twitter", "");
50
- if (input.endsWith(".nextid"))
51
- return input.replace(".nextid", "");
52
62
  if (input.startsWith("farcaster,#"))
53
63
  return input.replace(/^(farcaster),/, "");
54
64
  if (input.endsWith(".farcaster") ||
@@ -59,6 +69,11 @@ const prettify = (input) => {
59
69
  if (input.endsWith(".base") || input.endsWith(".linea")) {
60
70
  return input.split(".")[0] + "." + input.split(".").pop() + ".eth";
61
71
  }
72
+ // for all web2 platform prettify format as "identity.platform"
73
+ const suffix = input.split(".")[input.split(".").length - 1];
74
+ if (WEB2_SUFFIXES.includes(suffix)) {
75
+ return input.replace(`.${suffix}`, "");
76
+ }
62
77
  return input;
63
78
  };
64
79
  /**
@@ -107,8 +122,15 @@ const isSupportedPlatform = (platform) => {
107
122
  Platform.lens,
108
123
  Platform.twitter,
109
124
  Platform.github,
110
- Platform.linkedin,
111
125
  Platform.discord,
126
+ Platform.linkedin,
127
+ Platform.instagram,
128
+ Platform.reddit,
129
+ Platform.facebook,
130
+ Platform.telegram,
131
+ Platform.keybase,
132
+ Platform.nostr,
133
+ Platform.bluesky,
112
134
  Platform.unstoppableDomains,
113
135
  Platform.nextid,
114
136
  Platform.dotbit,
@@ -139,6 +161,10 @@ const platformMap = new Map([
139
161
  * Detect platform from identity string based on regex patterns
140
162
  */
141
163
  const detectPlatform = (term) => {
164
+ // support all web2 platform as identity.platform format
165
+ const suffix = term.split(".")[term.split(".").length - 1];
166
+ if (PLATFORM_DATA.has(suffix))
167
+ return suffix;
142
168
  if (/\.(farcaster\.eth|farcaster|fcast\.id)$/.test(term))
143
169
  return Platform.farcaster;
144
170
  for (const [regex, Platform] of platformMap) {
@@ -649,6 +649,15 @@ const PLATFORM_DATA = new Map([
649
649
  urlPrefix: "https://opensea.io/",
650
650
  },
651
651
  ],
652
+ [
653
+ platform.Platform.opinion,
654
+ {
655
+ color: "#ed6432",
656
+ icon: "icons/icon-opinion.svg",
657
+ label: "Opinion",
658
+ urlPrefix: "https://app.opinion.trade/",
659
+ },
660
+ ],
652
661
  [
653
662
  platform.Platform.paragraph,
654
663
  {
@@ -647,6 +647,15 @@ const PLATFORM_DATA = new Map([
647
647
  urlPrefix: "https://opensea.io/",
648
648
  },
649
649
  ],
650
+ [
651
+ Platform.opinion,
652
+ {
653
+ color: "#ed6432",
654
+ icon: "icons/icon-opinion.svg",
655
+ label: "Opinion",
656
+ urlPrefix: "https://app.opinion.trade/",
657
+ },
658
+ ],
650
659
  [
651
660
  Platform.paragraph,
652
661
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web3bio-profile-kit",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "React hooks for querying ENS, Farcaster, Lens and Web3 universal profiles",
5
5
  "author": "web3bio",
6
6
  "license": "MIT",