@unavatar/core 3.59.0 → 3.61.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/bitbucket.js +27 -0
- package/src/providers/index.js +4 -0
- package/src/providers/sketchfab.js +39 -0
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- [Behance](#behance)
|
|
25
25
|
- [Bilibili](#bilibili)
|
|
26
26
|
- [BIMI](#bimi)
|
|
27
|
+
- [Bitbucket](#bitbucket)
|
|
27
28
|
- [Bluesky](#bluesky)
|
|
28
29
|
- [Buy Me a Coffee](#buy-me-a-coffee)
|
|
29
30
|
- [Cash App](#cash-app)
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
- [Reddit](#reddit)
|
|
83
84
|
- [Revolut](#revolut)
|
|
84
85
|
- [Roblox](#roblox)
|
|
86
|
+
- [Sketchfab](#sketchfab)
|
|
85
87
|
- [Snapchat](#snapchat)
|
|
86
88
|
- [SoundCloud](#soundcloud)
|
|
87
89
|
- [Spotify](#spotify)
|
|
@@ -611,6 +613,12 @@ Available inputs:
|
|
|
611
613
|
- Domain, e.g., [unavatar.io/bimi/cnn.com](https://unavatar.io/bimi/cnn.com)
|
|
612
614
|
- Email address, e.g., [unavatar.io/bimi/support@ebay.com](https://unavatar.io/bimi/support@ebay.com)
|
|
613
615
|
|
|
616
|
+
### Bitbucket
|
|
617
|
+
|
|
618
|
+
Get any Bitbucket workspace's avatar by its workspace slug. Personal accounts are covered through their personal workspace, which shares the account's username.
|
|
619
|
+
|
|
620
|
+
e.g., [unavatar.io/bitbucket/atlassian](https://unavatar.io/bitbucket/atlassian)
|
|
621
|
+
|
|
614
622
|
### Bluesky
|
|
615
623
|
|
|
616
624
|
Get any Bluesky user's profile picture by their handle. Domain-style handles are supported.
|
|
@@ -1053,6 +1061,12 @@ Available inputs:
|
|
|
1053
1061
|
- Username, e.g., [unavatar.io/roblox/builderman](https://unavatar.io/roblox/builderman)
|
|
1054
1062
|
- User ID, e.g., [unavatar.io/roblox/id:156](https://unavatar.io/roblox/id:156)
|
|
1055
1063
|
|
|
1064
|
+
### Sketchfab
|
|
1065
|
+
|
|
1066
|
+
Get any Sketchfab creator's profile picture by their username.
|
|
1067
|
+
|
|
1068
|
+
e.g., [unavatar.io/sketchfab/nasa](https://unavatar.io/sketchfab/nasa)
|
|
1069
|
+
|
|
1056
1070
|
### Snapchat
|
|
1057
1071
|
|
|
1058
1072
|
Get any Snapchat user's profile picture by their username.
|
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.61.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const WORKSPACES_URL = 'https://bitbucket.org/workspaces'
|
|
4
|
+
const DEFAULT_AVATAR_PATH = '/default_workspace_avatar/'
|
|
5
|
+
|
|
6
|
+
const getAvatarUrl = input =>
|
|
7
|
+
`${WORKSPACES_URL}/${encodeURIComponent(input)}/avatar/`
|
|
8
|
+
|
|
9
|
+
const getAvatar = location => {
|
|
10
|
+
if (!location) return
|
|
11
|
+
const url = new URL(location, WORKSPACES_URL)
|
|
12
|
+
return url.pathname.includes(DEFAULT_AVATAR_PATH) ? undefined : url.toString()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = ({ got }) =>
|
|
16
|
+
async function bitbucket (input) {
|
|
17
|
+
const { headers } = await got(getAvatarUrl(input), {
|
|
18
|
+
method: 'HEAD',
|
|
19
|
+
followRedirect: false,
|
|
20
|
+
throwHttpErrors: false
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return getAvatar(headers.location)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
27
|
+
module.exports.getAvatar = getAvatar
|
package/src/providers/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const providerTiers = {
|
|
|
9
9
|
'apple-store',
|
|
10
10
|
'behance',
|
|
11
11
|
'bilibili',
|
|
12
|
+
'bitbucket',
|
|
12
13
|
'bluesky',
|
|
13
14
|
'buymeacoffee',
|
|
14
15
|
'cashapp',
|
|
@@ -61,6 +62,7 @@ const providerTiers = {
|
|
|
61
62
|
'reddit',
|
|
62
63
|
'revolut',
|
|
63
64
|
'roblox',
|
|
65
|
+
'sketchfab',
|
|
64
66
|
'snapchat',
|
|
65
67
|
'soundcloud',
|
|
66
68
|
'spotify',
|
|
@@ -107,6 +109,7 @@ module.exports = ctx => {
|
|
|
107
109
|
behance: require('./behance')(ctx),
|
|
108
110
|
bilibili: require('./bilibili')(ctx),
|
|
109
111
|
bimi: require('./bimi')(ctx),
|
|
112
|
+
bitbucket: require('./bitbucket')(ctx),
|
|
110
113
|
bluesky: require('./bluesky')(ctx),
|
|
111
114
|
buymeacoffee: require('./buymeacoffee')(ctx),
|
|
112
115
|
cashapp: require('./cashapp')(ctx),
|
|
@@ -163,6 +166,7 @@ module.exports = ctx => {
|
|
|
163
166
|
reddit: require('./reddit')(ctx),
|
|
164
167
|
revolut: require('./revolut')(ctx),
|
|
165
168
|
roblox: require('./roblox')(ctx),
|
|
169
|
+
sketchfab: require('./sketchfab')(ctx),
|
|
166
170
|
snapchat: require('./snapchat')(ctx),
|
|
167
171
|
soundcloud: require('./soundcloud')(ctx),
|
|
168
172
|
spotify: require('./spotify')(ctx),
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const API_URL = 'https://api.sketchfab.com/v3/users'
|
|
4
|
+
|
|
5
|
+
const DEFAULT_AVATAR_UIDS = new Set([
|
|
6
|
+
'3ef1bd11d3eb4b57a0b353e8f2e5fc3e',
|
|
7
|
+
'51af6a870cce449eb75b0345feebaebb',
|
|
8
|
+
'78fa317e46024a5283765aa34df5e508'
|
|
9
|
+
])
|
|
10
|
+
|
|
11
|
+
const getAvatarUrl = input =>
|
|
12
|
+
`${API_URL}/@${encodeURIComponent(input.replace(/^@/, ''))}`
|
|
13
|
+
|
|
14
|
+
const getAvatar = body => {
|
|
15
|
+
const avatar = body?.avatar
|
|
16
|
+
if (!avatar || DEFAULT_AVATAR_UIDS.has(avatar.uid)) return
|
|
17
|
+
|
|
18
|
+
const largest = (avatar.images ?? []).reduce(
|
|
19
|
+
(best, image) => (image.width > (best?.width ?? 0) ? image : best),
|
|
20
|
+
undefined
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
return largest?.url || undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = ({ got }) =>
|
|
27
|
+
async function sketchfab (input) {
|
|
28
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
29
|
+
responseType: 'json',
|
|
30
|
+
throwHttpErrors: false
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
if (statusCode >= 400) return
|
|
34
|
+
|
|
35
|
+
return getAvatar(body)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
39
|
+
module.exports.getAvatar = getAvatar
|