@unavatar/core 3.71.0 → 3.71.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 CHANGED
@@ -24,62 +24,42 @@
24
24
  - [Behance](#behance)
25
25
  - [Bilibili](#bilibili)
26
26
  - [BIMI](#bimi)
27
- - [Bitbucket](#bitbucket)
28
27
  - [Bluesky](#bluesky)
29
28
  - [Buy Me a Coffee](#buy-me-a-coffee)
30
29
  - [Cash App](#cash-app)
31
- - [Chess.com](#chesscom)
32
- - [Codeforces](#codeforces)
33
30
  - [CodePen](#codepen)
34
31
  - [Cults3D](#cults3d)
35
32
  - [Cursor](#cursor)
36
- - [Dailymotion](#dailymotion)
37
33
  - [Deezer](#deezer)
38
- - [DEV](#dev)
39
34
  - [DeviantArt](#deviantart)
40
35
  - [Discord](#discord)
41
36
  - [Docker Hub](#docker-hub)
42
37
  - [Domain](#domain)
43
38
  - [Dribbble](#dribbble)
44
39
  - [DuckDuckGo](#duckduckgo)
45
- - [Duolingo](#duolingo)
46
40
  - [Email](#email)
47
- - [ENS](#ens)
48
41
  - [Facebook](#facebook)
49
- - [Farcaster](#farcaster)
50
42
  - [Flickr](#flickr)
51
43
  - [Gitee](#gitee)
52
44
  - [GitHub](#github)
53
45
  - [GitLab](#gitlab)
54
- - [Goodreads](#goodreads)
55
46
  - [Google](#google)
56
47
  - [Google Play](#google-play)
57
48
  - [Gravatar](#gravatar)
58
- - [Gumroad](#gumroad)
59
49
  - [Hevy](#hevy)
60
50
  - [Hugging Face](#hugging-face)
61
51
  - [Instagram](#instagram)
62
52
  - [Juejin](#juejin)
63
- - [Kaggle](#kaggle)
64
- - [Keybase](#keybase)
65
53
  - [Kick](#kick)
66
54
  - [Ko-fi](#ko-fi)
67
- - [Lemmy](#lemmy)
68
- - [Libravatar](#libravatar)
69
55
  - [LinkedIn](#linkedin)
70
56
  - [Mastodon](#mastodon)
71
- - [Matrix](#matrix)
72
57
  - [Medium](#medium)
73
58
  - [Microlink](#microlink)
74
- - [Minecraft](#minecraft)
75
- - [Mixcloud](#mixcloud)
76
59
  - [NetEase Music](#netease-music)
77
- - [note](#note)
78
60
  - [npm](#npm)
79
61
  - [OnlyFans](#onlyfans)
80
- - [Open Collective](#open-collective)
81
62
  - [OpenStreetMap](#openstreetmap)
82
- - [osu!](#osu)
83
63
  - [Patreon](#patreon)
84
64
  - [PayPal](#paypal)
85
65
  - [Pinterest](#pinterest)
@@ -91,11 +71,8 @@
91
71
  - [Raycast](#raycast)
92
72
  - [Reddit](#reddit)
93
73
  - [Revolut](#revolut)
94
- - [Roblox](#roblox)
95
- - [Sketchfab](#sketchfab)
96
74
  - [Snapchat](#snapchat)
97
75
  - [SoundCloud](#soundcloud)
98
- - [Speedrun](#speedrun)
99
76
  - [Spotify](#spotify)
100
77
  - [Stack Overflow](#stack-overflow)
101
78
  - [Steam](#steam)
@@ -111,7 +88,6 @@
111
88
  - [Twitch](#twitch)
112
89
  - [Venmo](#venmo)
113
90
  - [Vimeo](#vimeo)
114
- - [Wattpad](#wattpad)
115
91
  - [Weibo](#weibo)
116
92
  - [WhatsApp](#whatsapp)
117
93
  - [Wise](#wise)
@@ -624,12 +600,6 @@ Available inputs:
624
600
  - Domain, e.g., [unavatar.io/bimi/cnn.com](https://unavatar.io/bimi/cnn.com)
625
601
  - Email address, e.g., [unavatar.io/bimi/support@ebay.com](https://unavatar.io/bimi/support@ebay.com)
626
602
 
627
- ### Bitbucket
628
-
629
- Get any Bitbucket workspace's avatar by its workspace slug. Personal accounts are covered through their personal workspace, which shares the account's username.
630
-
631
- e.g., [unavatar.io/bitbucket/atlassian](https://unavatar.io/bitbucket/atlassian)
632
-
633
603
  ### Bluesky
634
604
 
635
605
  Get any Bluesky user's profile picture by their handle. Domain-style handles are supported.
@@ -651,18 +621,6 @@ Get any Cash App user's profile picture by their Cashtag.
651
621
 
652
622
  e.g., [unavatar.io/cashapp/ninja](https://unavatar.io/cashapp/ninja)
653
623
 
654
- ### Chess.com
655
-
656
- Get any Chess.com player's profile picture by their username.
657
-
658
- e.g., [unavatar.io/chesscom/hikaru](https://unavatar.io/chesscom/hikaru)
659
-
660
- ### Codeforces
661
-
662
- Get any Codeforces user's profile picture by their handle.
663
-
664
- e.g., [unavatar.io/codeforces/tourist](https://unavatar.io/codeforces/tourist)
665
-
666
624
  ### CodePen
667
625
 
668
626
  Get any CodePen user's profile picture by their username.
@@ -681,12 +639,6 @@ Get any Cursor user's profile picture by their username.
681
639
 
682
640
  e.g., [unavatar.io/cursor/leerob](https://unavatar.io/cursor/leerob)
683
641
 
684
- ### Dailymotion
685
-
686
- Get any Dailymotion user's profile picture by their username or user ID.
687
-
688
- e.g., [unavatar.io/dailymotion/dailymotion](https://unavatar.io/dailymotion/dailymotion)
689
-
690
642
  ### Deezer
691
643
 
692
644
  Get artwork for any Deezer artist, album, playlist, or track by ID.
@@ -702,12 +654,6 @@ Available inputs:
702
654
  - `playlist`: [unavatar.io/deezer/playlist:908622995](https://unavatar.io/deezer/playlist:908622995)
703
655
  - `track`: [unavatar.io/deezer/track:3135556](https://unavatar.io/deezer/track:3135556)
704
656
 
705
- ### DEV
706
-
707
- Get any [DEV](https://dev.to) user's profile picture by username, or an organization's logo by its slug.
708
-
709
- e.g., [unavatar.io/devto/ben](https://unavatar.io/devto/ben)
710
-
711
657
  ### DeviantArt
712
658
 
713
659
  Get any DeviantArt user's profile picture by their username.
@@ -747,21 +693,15 @@ Get the favicon or logo for any domain via DuckDuckGo's icon service. Useful as
747
693
 
748
694
  e.g., [unavatar.io/duckduckgo/microsoft.com](https://unavatar.io/duckduckgo/microsoft.com)
749
695
 
750
- ### Duolingo
751
-
752
- Get any Duolingo learner's profile picture by their username.
753
-
754
- e.g., [unavatar.io/duolingo/luis](https://unavatar.io/duolingo/luis)
755
-
756
696
  ### Email
757
697
 
758
- Resolve user avatars from an email address with a single URL. The `/email/:key` route uses the same provider chain as a bare `/user@domain` path: the service tries Gravatar and GitHub, then Libravatar, then BIMI until one returns an image. No API keys and no SDK are required.
698
+ Resolve user avatars from an email address with a single URL. The `/email/:key` route uses the same provider chain as a bare `/user@domain` path: the service tries Gravatar, GitHub, BIMI in order until one returns an image. No API keys and no SDK are required.
759
699
 
760
700
  When the path looks like an email, unavatar walks that chain until a provider succeeds. You can also skip the chain and call a named email provider directly when you know where the avatar should come from.
761
701
 
762
702
  Automatic resolution
763
703
 
764
- Pass the address as the only path segment, or prefix it with `email/`. The API auto-detects email-shaped inputs and runs the same chain (Gravatar and GitHub, then Libravatar, then BIMI).
704
+ Pass the address as the only path segment, or prefix it with `email/`. The API auto-detects email-shaped inputs and runs the same chain (Gravatar, GitHub, BIMI).
765
705
 
766
706
  - Typed route `unavatar.io/email/{email}`: [unavatar.io/email/hello@microlink.io](https://unavatar.io/email/hello@microlink.io)
767
707
  - Bare path `unavatar.io/{email}`: [unavatar.io/hello@microlink.io](https://unavatar.io/hello@microlink.io)
@@ -772,19 +712,10 @@ Target a specific provider when you know where the avatar comes from.
772
712
 
773
713
  - Gravatar (`unavatar.io/gravatar/{email-or-hash}`) — email is normalized and SHA-256 hashed; 64-hex SHA-256 or 32-hex MD5 passes through. Example: [unavatar.io/gravatar/hello@microlink.io](https://unavatar.io/gravatar/hello@microlink.io)
774
714
  - GitHub (`unavatar.io/github/{email}`) — public profile email or commit history: [unavatar.io/github/sindresorhus@gmail.com](https://unavatar.io/github/sindresorhus@gmail.com)
775
- - Libravatar (`unavatar.io/libravatar/{email-or-hash}`) — federated Gravatar alternative; follows the email domain's own avatar server when it publishes one: [unavatar.io/libravatar/francois@fmarier.org](https://unavatar.io/libravatar/francois@fmarier.org)
776
715
  - BIMI (`unavatar.io/bimi/{email}`) — official brand logo from the address domain: [unavatar.io/bimi/support@ebay.com](https://unavatar.io/bimi/support@ebay.com)
777
716
 
778
717
  e.g., [unavatar.io/email/hello@microlink.io](https://unavatar.io/email/hello@microlink.io)
779
718
 
780
- ### ENS
781
-
782
- Get the avatar set on any Ethereum Name Service (ENS) name, including subnames like `jesse.base.eth`. A bare label is treated as a `.eth` name.
783
-
784
- e.g., [unavatar.io/ens/vitalik.eth](https://unavatar.io/ens/vitalik.eth)
785
-
786
- Names ending in `.eth` are detected automatically, so [unavatar.io/vitalik.eth](https://unavatar.io/vitalik.eth) resolves through ENS too.
787
-
788
719
  ### Facebook
789
720
 
790
721
  Get any Facebook user, page, or group profile picture by their username or ID.
@@ -794,15 +725,6 @@ Available inputs:
794
725
  - Username, e.g., [unavatar.io/facebook/zuck](https://unavatar.io/facebook/zuck)
795
726
  - Page, e.g., [unavatar.io/facebook/windtodayco](https://unavatar.io/facebook/windtodayco)
796
727
 
797
- ### Farcaster
798
-
799
- Get any Farcaster user's profile picture by their username (fname). ENS-style usernames are supported.
800
-
801
- Available inputs:
802
-
803
- - Username, e.g., [unavatar.io/farcaster/dwr](https://unavatar.io/farcaster/dwr)
804
- - ENS username, e.g., [unavatar.io/farcaster/vitalik.eth](https://unavatar.io/farcaster/vitalik.eth)
805
-
806
728
  ### Flickr
807
729
 
808
730
  Get any Flickr user's buddy icon or group icon by username or group slug.
@@ -841,20 +763,6 @@ Available inputs:
841
763
  - User, e.g., [unavatar.io/gitlab/sytses](https://unavatar.io/gitlab/sytses)
842
764
  - Organization, e.g., [unavatar.io/gitlab/inkscape](https://unavatar.io/gitlab/inkscape)
843
765
 
844
- ### Goodreads
845
-
846
- Get any Goodreads user's profile picture by their vanity username or numeric user ID, or an author's photo by their author ID.
847
-
848
- The input supports a URI format `type:id`.
849
-
850
- When no type is provided, the input is treated as a user (`user`).
851
-
852
- Available inputs:
853
-
854
- - `user` (default), by username: [unavatar.io/goodreads/otis](https://unavatar.io/goodreads/otis)
855
- - `user` (default), by user ID: [unavatar.io/goodreads/1](https://unavatar.io/goodreads/1)
856
- - `author`: [unavatar.io/goodreads/author:4](https://unavatar.io/goodreads/author:4)
857
-
858
766
  ### Google
859
767
 
860
768
  Get the favicon or logo for any domain using Google's favicon service.
@@ -886,13 +794,7 @@ Available inputs:
886
794
 
887
795
  When you pass an email address directly in the URL, it is visible in plain text — both in server logs and to any intermediary that inspects the request.
888
796
 
889
- To avoid this, pass a pre-computed `MD5` or `SHA256` hash of the email instead. Unavatar detects the hash automatically and routes it to Gravatar, then Libravatar, which both natively support both hash formats.
890
-
891
- ### Gumroad
892
-
893
- Get any Gumroad creator's profile picture by their username (the subdomain of their store).
894
-
895
- e.g., [unavatar.io/gumroad/sahil](https://unavatar.io/gumroad/sahil)
797
+ To avoid this, pass a pre-computed `MD5` or `SHA256` hash of the email instead. Unavatar detects the hash automatically and routes it to Gravatar, which natively supports both hash formats.
896
798
 
897
799
  ### Hevy
898
800
 
@@ -921,18 +823,6 @@ Get any Juejin user's profile picture by their numeric user ID.
921
823
 
922
824
  e.g., [unavatar.io/juejin/1556564194374926](https://unavatar.io/juejin/1556564194374926)
923
825
 
924
- ### Kaggle
925
-
926
- Get any Kaggle user's profile picture by their username.
927
-
928
- e.g., [unavatar.io/kaggle/jhoward](https://unavatar.io/kaggle/jhoward)
929
-
930
- ### Keybase
931
-
932
- Get any Keybase user's profile picture by their username.
933
-
934
- e.g., [unavatar.io/keybase/chris](https://unavatar.io/keybase/chris)
935
-
936
826
  ### Kick
937
827
 
938
828
  Get any Kick streamer's profile picture by their username.
@@ -945,26 +835,6 @@ Get any Ko-fi page's profile picture by the creator username.
945
835
 
946
836
  e.g., [unavatar.io/ko-fi/geekshock](https://unavatar.io/ko-fi/geekshock)
947
837
 
948
- ### Lemmy
949
-
950
- Get any Lemmy user's profile picture from any instance using the public user API. Pass the handle as `user@instance` so the account resolves on the correct home instance.
951
-
952
- e.g., [unavatar.io/lemmy/ruud@lemmy.world](https://unavatar.io/lemmy/ruud@lemmy.world)
953
-
954
- ### Libravatar
955
-
956
- Resolve avatars via [Libravatar](https://www.libravatar.org), the federated, open source alternative to Gravatar, using a plain email or a precomputed hash. Emails are trimmed, lowercased, and hashed with SHA-256; 64-hex SHA-256 and 32-hex MD5 values are passed through (normalized to lowercase).
957
-
958
- Available inputs:
959
-
960
- - Email address, e.g., [unavatar.io/libravatar/francois@fmarier.org](https://unavatar.io/libravatar/francois@fmarier.org)
961
- - SHA-256 hash, e.g., [unavatar.io/libravatar/857915e8681217376523fa2c4653a499a7dc6826197b077d35fc029d7c38bda1](https://unavatar.io/libravatar/857915e8681217376523fa2c4653a499a7dc6826197b077d35fc029d7c38bda1)
962
- - MD5 hash, e.g., [unavatar.io/libravatar/7cc352a2907216992f0f16d2af50b070](https://unavatar.io/libravatar/7cc352a2907216992f0f16d2af50b070)
963
-
964
- When an email domain runs its own avatar server and publishes a `_avatars-sec._tcp` SRV record, the avatar is fetched from that server. Otherwise, and always for hashes, the central `seccdn.libravatar.org` server is used.
965
-
966
- In the email chain, Libravatar runs only after Gravatar and GitHub miss, so it never overrides or slows down a Gravatar hit.
967
-
968
838
  ### LinkedIn
969
839
 
970
840
  Get any LinkedIn user or company profile picture by username or company slug.
@@ -982,12 +852,6 @@ Get any Mastodon user's profile picture from any instance using the public accou
982
852
 
983
853
  e.g., [unavatar.io/mastodon/kpwags@hachyderm.io](https://unavatar.io/mastodon/kpwags@hachyderm.io)
984
854
 
985
- ### Matrix
986
-
987
- Get any Matrix user's profile picture from any homeserver using the public profile API. Pass the full user ID as `@user:server` (the leading `@` is optional); a bare `user` resolves on `matrix.org`. Homeservers that require authentication for profiles or media return no avatar.
988
-
989
- e.g., [unavatar.io/matrix/@matthew:matrix.org](https://unavatar.io/matrix/@matthew:matrix.org)
990
-
991
855
  ### Medium
992
856
 
993
857
  Get any Medium author's profile picture by their username.
@@ -1000,33 +864,12 @@ Extract the logo or representative image from any URL. The page is rendered and
1000
864
 
1001
865
  e.g., [unavatar.io/microlink/microlink.io](https://unavatar.io/microlink/microlink.io)
1002
866
 
1003
- ### Minecraft
1004
-
1005
- Get any Minecraft Java Edition player's face by their username or UUID. The player is resolved through Mojang first, so unknown players return no avatar, and the face is rendered by [mc-heads.net](https://mc-heads.net).
1006
-
1007
- Available inputs:
1008
-
1009
- - Username, e.g., [unavatar.io/minecraft/notch](https://unavatar.io/minecraft/notch)
1010
- - UUID, with or without dashes, e.g., [unavatar.io/minecraft/069a79f4-44e9-4726-a5be-fca90e38aaf5](https://unavatar.io/minecraft/069a79f4-44e9-4726-a5be-fca90e38aaf5)
1011
-
1012
- ### Mixcloud
1013
-
1014
- Get any Mixcloud user's profile picture by their username.
1015
-
1016
- e.g., [unavatar.io/mixcloud/spartacus](https://unavatar.io/mixcloud/spartacus)
1017
-
1018
867
  ### NetEase Music
1019
868
 
1020
869
  Get any NetEase Music user's profile picture by their numeric user ID.
1021
870
 
1022
871
  e.g., [unavatar.io/netease-music/32953014](https://unavatar.io/netease-music/32953014)
1023
872
 
1024
- ### note
1025
-
1026
- Get any note.com creator's profile picture by their username.
1027
-
1028
- e.g., [unavatar.io/note/info](https://unavatar.io/note/info)
1029
-
1030
873
  ### npm
1031
874
 
1032
875
  Get any npm user's profile picture by their username, including scoped handles.
@@ -1039,12 +882,6 @@ Get any OnlyFans creator's profile picture by their username.
1039
882
 
1040
883
  e.g., [unavatar.io/onlyfans/amandaribas](https://unavatar.io/onlyfans/amandaribas)
1041
884
 
1042
- ### Open Collective
1043
-
1044
- Get any Open Collective account's avatar by its profile slug, for collectives, organizations, and individuals.
1045
-
1046
- e.g., [unavatar.io/opencollective/webpack](https://unavatar.io/opencollective/webpack)
1047
-
1048
885
  ### OpenStreetMap
1049
886
 
1050
887
  Get any OpenStreetMap contributor's profile picture. Accepts either a numeric user ID or a username.
@@ -1054,15 +891,6 @@ Available inputs:
1054
891
  - Numeric user ID, e.g., [unavatar.io/openstreetmap/98672](https://unavatar.io/openstreetmap/98672)
1055
892
  - Username, e.g., [unavatar.io/openstreetmap/Terence%20Eden](https://unavatar.io/openstreetmap/Terence%20Eden)
1056
893
 
1057
- ### osu!
1058
-
1059
- Get any osu! player's profile picture by their username or numeric user ID.
1060
-
1061
- Available inputs:
1062
-
1063
- - Username, e.g., [unavatar.io/osu/peppy](https://unavatar.io/osu/peppy)
1064
- - Numeric user ID, e.g., [unavatar.io/osu/7562902](https://unavatar.io/osu/7562902)
1065
-
1066
894
  ### Patreon
1067
895
 
1068
896
  Get any Patreon creator's profile picture by their username.
@@ -1139,21 +967,6 @@ Get any Revolut user's profile picture by their Revolut.Me username.
1139
967
 
1140
968
  e.g., [unavatar.io/revolut/midudev](https://unavatar.io/revolut/midudev)
1141
969
 
1142
- ### Roblox
1143
-
1144
- Get any Roblox user's avatar headshot by their username or user ID.
1145
-
1146
- Available inputs:
1147
-
1148
- - Username, e.g., [unavatar.io/roblox/builderman](https://unavatar.io/roblox/builderman)
1149
- - User ID, e.g., [unavatar.io/roblox/id:156](https://unavatar.io/roblox/id:156)
1150
-
1151
- ### Sketchfab
1152
-
1153
- Get any Sketchfab creator's profile picture by their username.
1154
-
1155
- e.g., [unavatar.io/sketchfab/nasa](https://unavatar.io/sketchfab/nasa)
1156
-
1157
970
  ### Snapchat
1158
971
 
1159
972
  Get any Snapchat user's profile picture by their username.
@@ -1166,12 +979,6 @@ Get any SoundCloud artist's profile picture by their username.
1166
979
 
1167
980
  e.g., [unavatar.io/soundcloud/gorillaz](https://unavatar.io/soundcloud/gorillaz)
1168
981
 
1169
- ### Speedrun
1170
-
1171
- Get any Speedrun.com runner's profile picture by their username or user ID.
1172
-
1173
- e.g., [unavatar.io/speedrun/cheese](https://unavatar.io/speedrun/cheese)
1174
-
1175
982
  ### Spotify
1176
983
 
1177
984
  Get artwork for any Spotify entity — users, artists, albums, playlists, shows, episodes, or tracks. Look up by username or Spotify ID.
@@ -1290,12 +1097,6 @@ Get any Vimeo user's profile picture by their username.
1290
1097
 
1291
1098
  e.g., [unavatar.io/vimeo/ladieswithlenses](https://unavatar.io/vimeo/ladieswithlenses)
1292
1099
 
1293
- ### Wattpad
1294
-
1295
- Get any Wattpad user's profile picture by their username.
1296
-
1297
- e.g., [unavatar.io/wattpad/Wattpad](https://unavatar.io/wattpad/Wattpad)
1298
-
1299
1100
  ### Weibo
1300
1101
 
1301
1102
  Get any Weibo user's profile picture by numeric user ID or screen name.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@unavatar/core",
3
3
  "description": "Get unified user avatar from social networks, including Instagram, SoundCloud, Telegram, Twitter, YouTube & more.",
4
4
  "homepage": "https://unavatar.io",
5
- "version": "3.71.0",
5
+ "version": "3.71.2",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -1,5 +1,12 @@
1
1
  'use strict'
2
2
 
3
+ const uniqueRandomArray = require('unique-random-array')
4
+
5
+ // Mobile user agents get an HTML page instead of the user_json payload.
6
+ const randomDesktopUserAgent = uniqueRandomArray(
7
+ require('top-user-agents/desktop')
8
+ )
9
+
3
10
  const PORTRAIT_URL = 'https://himg.bdimg.com/sys/portrait/item'
4
11
 
5
12
  const getAvatarUrl = input =>
@@ -17,7 +24,8 @@ module.exports = ({ got }) =>
17
24
  // Unknown users respond with an empty body, which is not valid JSON.
18
25
  const { body, statusCode } = await got(getAvatarUrl(input), {
19
26
  responseType: 'text',
20
- throwHttpErrors: false
27
+ throwHttpErrors: false,
28
+ headers: { 'user-agent': randomDesktopUserAgent() }
21
29
  })
22
30
 
23
31
  if (statusCode >= 400 || !body) return
@@ -1,5 +1,12 @@
1
1
  'use strict'
2
2
 
3
+ const uniqueRandomArray = require('unique-random-array')
4
+
5
+ // Mobile user agents get a 403 from the members API.
6
+ const randomDesktopUserAgent = uniqueRandomArray(
7
+ require('top-user-agents/desktop')
8
+ )
9
+
3
10
  const API_URL = 'https://www.zhihu.com/api/v4/members'
4
11
 
5
12
  const getAvatarUrl = input =>
@@ -16,7 +23,8 @@ module.exports = ({ got }) =>
16
23
  async function zhihu (input) {
17
24
  const { body, statusCode } = await got(getAvatarUrl(input), {
18
25
  responseType: 'json',
19
- throwHttpErrors: false
26
+ throwHttpErrors: false,
27
+ headers: { 'user-agent': randomDesktopUserAgent() }
20
28
  })
21
29
 
22
30
  if (statusCode >= 400) return