@unavatar/core 3.66.0 → 3.68.0
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 +14 -0
- package/package.json +1 -1
- package/src/providers/index.js +4 -0
- package/src/providers/lemmy.js +32 -0
- package/src/providers/wattpad.js +34 -0
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
- [Keybase](#keybase)
|
|
63
63
|
- [Kick](#kick)
|
|
64
64
|
- [Ko-fi](#ko-fi)
|
|
65
|
+
- [Lemmy](#lemmy)
|
|
65
66
|
- [Libravatar](#libravatar)
|
|
66
67
|
- [LinkedIn](#linkedin)
|
|
67
68
|
- [Mastodon](#mastodon)
|
|
@@ -106,6 +107,7 @@
|
|
|
106
107
|
- [Twitch](#twitch)
|
|
107
108
|
- [Venmo](#venmo)
|
|
108
109
|
- [Vimeo](#vimeo)
|
|
110
|
+
- [Wattpad](#wattpad)
|
|
109
111
|
- [Weibo](#weibo)
|
|
110
112
|
- [WhatsApp](#whatsapp)
|
|
111
113
|
- [Wise](#wise)
|
|
@@ -917,6 +919,12 @@ Get any Ko-fi page's profile picture by the creator username.
|
|
|
917
919
|
|
|
918
920
|
e.g., [unavatar.io/ko-fi/geekshock](https://unavatar.io/ko-fi/geekshock)
|
|
919
921
|
|
|
922
|
+
### Lemmy
|
|
923
|
+
|
|
924
|
+
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.
|
|
925
|
+
|
|
926
|
+
e.g., [unavatar.io/lemmy/ruud@lemmy.world](https://unavatar.io/lemmy/ruud@lemmy.world)
|
|
927
|
+
|
|
920
928
|
### Libravatar
|
|
921
929
|
|
|
922
930
|
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).
|
|
@@ -1244,6 +1252,12 @@ Get any Vimeo user's profile picture by their username.
|
|
|
1244
1252
|
|
|
1245
1253
|
e.g., [unavatar.io/vimeo/ladieswithlenses](https://unavatar.io/vimeo/ladieswithlenses)
|
|
1246
1254
|
|
|
1255
|
+
### Wattpad
|
|
1256
|
+
|
|
1257
|
+
Get any Wattpad user's profile picture by their username.
|
|
1258
|
+
|
|
1259
|
+
e.g., [unavatar.io/wattpad/Wattpad](https://unavatar.io/wattpad/Wattpad)
|
|
1260
|
+
|
|
1247
1261
|
### Weibo
|
|
1248
1262
|
|
|
1249
1263
|
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.
|
|
5
|
+
"version": "3.68.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
package/src/providers/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const providerTiers = {
|
|
|
42
42
|
'keybase',
|
|
43
43
|
'kick',
|
|
44
44
|
'ko-fi',
|
|
45
|
+
'lemmy',
|
|
45
46
|
'linkedin',
|
|
46
47
|
'mastodon',
|
|
47
48
|
'medium',
|
|
@@ -85,6 +86,7 @@ const providerTiers = {
|
|
|
85
86
|
'twitch',
|
|
86
87
|
'venmo',
|
|
87
88
|
'vimeo',
|
|
89
|
+
'wattpad',
|
|
88
90
|
'weibo',
|
|
89
91
|
'whatsapp',
|
|
90
92
|
'wise',
|
|
@@ -149,6 +151,7 @@ module.exports = ctx => {
|
|
|
149
151
|
keybase: require('./keybase')(ctx),
|
|
150
152
|
kick: require('./kick')(ctx),
|
|
151
153
|
'ko-fi': require('./ko-fi')(ctx),
|
|
154
|
+
lemmy: require('./lemmy')(ctx),
|
|
152
155
|
libravatar: require('./libravatar')(ctx),
|
|
153
156
|
linkedin: require('./linkedin')(ctx),
|
|
154
157
|
mastodon: require('./mastodon')(ctx),
|
|
@@ -194,6 +197,7 @@ module.exports = ctx => {
|
|
|
194
197
|
twitch: require('./twitch')(ctx),
|
|
195
198
|
venmo: require('./venmo')(ctx),
|
|
196
199
|
vimeo: require('./vimeo')(ctx),
|
|
200
|
+
wattpad: require('./wattpad')(ctx),
|
|
197
201
|
weibo: require('./weibo')(ctx),
|
|
198
202
|
whatsapp: require('./whatsapp')(ctx),
|
|
199
203
|
wise: require('./wise')(ctx),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { parseInput } = require('./mastodon')
|
|
4
|
+
|
|
5
|
+
const getAvatarUrl = ({ username, server }) =>
|
|
6
|
+
`https://${server}/api/v3/user?username=${encodeURIComponent(username)}`
|
|
7
|
+
|
|
8
|
+
const getAvatar = body => {
|
|
9
|
+
const pic = body?.person_view?.person?.avatar
|
|
10
|
+
return typeof pic === 'string' && pic ? pic : undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = ({ got, isReservedIp }) =>
|
|
14
|
+
async function lemmy (input) {
|
|
15
|
+
const parsed = parseInput(input)
|
|
16
|
+
if (!parsed) return
|
|
17
|
+
|
|
18
|
+
if (await isReservedIp(parsed.server)) return
|
|
19
|
+
|
|
20
|
+
const { statusCode, body } = await got(getAvatarUrl(parsed), {
|
|
21
|
+
responseType: 'json',
|
|
22
|
+
throwHttpErrors: false
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
if (statusCode >= 400) return
|
|
26
|
+
|
|
27
|
+
return getAvatar(body)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports.parseInput = parseInput
|
|
31
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
32
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const API_URL = 'https://www.wattpad.com/api/v3/users'
|
|
4
|
+
|
|
5
|
+
const MAX_AVATAR_SIZE = 256
|
|
6
|
+
|
|
7
|
+
const AVATAR_SIZE_RE = /\.\d+(\.\d+\.\w+)$/
|
|
8
|
+
|
|
9
|
+
const STOCK_DEFAULT_AVATAR_RE = /\/useravatar\/[0-9a-f]\.\d+\.\w+$/
|
|
10
|
+
|
|
11
|
+
const getAvatarUrl = input =>
|
|
12
|
+
`${API_URL}/${encodeURIComponent(input.replace(/^@/, ''))}?fields=avatar`
|
|
13
|
+
|
|
14
|
+
const getAvatar = body => {
|
|
15
|
+
const avatar = body?.avatar
|
|
16
|
+
if (typeof avatar !== 'string' || !avatar) return
|
|
17
|
+
if (STOCK_DEFAULT_AVATAR_RE.test(avatar)) return
|
|
18
|
+
return avatar.replace(AVATAR_SIZE_RE, `.${MAX_AVATAR_SIZE}$1`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = ({ got }) =>
|
|
22
|
+
async function wattpad (input) {
|
|
23
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
24
|
+
responseType: 'json',
|
|
25
|
+
throwHttpErrors: false
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
if (statusCode >= 400) return
|
|
29
|
+
|
|
30
|
+
return getAvatar(body)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
34
|
+
module.exports.getAvatar = getAvatar
|