@unavatar/core 3.48.8 → 3.49.1

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/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.48.8",
5
+ "version": "3.49.1",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -126,7 +126,6 @@
126
126
  "@keyvhq/offline": "~2.2.0",
127
127
  "@keyvhq/redis": "~2.2.3",
128
128
  "@metascraper/helpers": "~5.56.2",
129
- "@microlink/mql": "~0.19.0",
130
129
  "@microlink/ping-url": "~1.5.0",
131
130
  "bimi-url": "~1.0.0",
132
131
  "browserless": "~13.9.2",
@@ -141,6 +140,7 @@
141
140
  "is-antibot": "~2.5.0",
142
141
  "is-email-like": "~1.0.0",
143
142
  "lodash": "~4.18.1",
143
+ "microlink.io": "~0.10.4",
144
144
  "ms": "~2.1.3",
145
145
  "p-any": "~3.0.0",
146
146
  "p-timeout": "~4.1.0",
@@ -56,6 +56,7 @@ const providerTiers = {
56
56
  'stackoverflow',
57
57
  'steam',
58
58
  'strava',
59
+ 'stripe',
59
60
  'substack',
60
61
  'telegram',
61
62
  'thingiverse',
@@ -146,6 +147,7 @@ module.exports = ctx => {
146
147
  stackoverflow: require('./stackoverflow')(ctx),
147
148
  steam: require('./steam')(ctx),
148
149
  strava: require('./strava')(ctx),
150
+ stripe: require('./stripe')(ctx),
149
151
  substack: require('./substack')(ctx),
150
152
  telegram: require('./telegram')(ctx),
151
153
  thingiverse: require('./thingiverse')(ctx),
@@ -1,15 +1,17 @@
1
1
  'use strict'
2
2
 
3
- const mql = require('@microlink/mql')
4
- const { get } = require('lodash')
3
+ const createClient = require('microlink.io')
5
4
 
6
- module.exports = ({ constants }) =>
7
- async function microlink (input, context) {
5
+ module.exports = ({ constants }) => {
6
+ const client = createClient()
7
+
8
+ return async function microlink (input, context) {
8
9
  const req = context?.req
9
- const { data } = await mql(`https://${input}`, {
10
+ const logo = await client.logo(`https://${input}`, {
10
11
  apiKey: req?.isPro
11
12
  ? constants.MICROLINK_API_KEY
12
13
  : req?.headers?.['x-api-key']
13
14
  })
14
- return get(data, 'logo.url')
15
+ return logo?.url
15
16
  }
17
+ }
@@ -0,0 +1,34 @@
1
+ 'use strict'
2
+
3
+ const API_URL = 'https://api.stripe.com/v2/xauth_/network/business_profiles'
4
+
5
+ const normalizeHandle = input =>
6
+ String(input || '')
7
+ .trim()
8
+ .replace(/^@/, '')
9
+
10
+ const getAvatarUrl = input =>
11
+ `${API_URL}/${encodeURIComponent(normalizeHandle(input))}`
12
+
13
+ const getAvatar = body => {
14
+ const pic = body?.branding?.icon?.original
15
+ return typeof pic === 'string' && pic ? pic : undefined
16
+ }
17
+
18
+ module.exports = ({ got }) =>
19
+ async function stripe (input) {
20
+ if (!normalizeHandle(input)) return
21
+
22
+ const { body, statusCode } = await got(getAvatarUrl(input), {
23
+ responseType: 'json',
24
+ throwHttpErrors: false,
25
+ headers: { 'Stripe-Version': 'unsafe-development' }
26
+ })
27
+
28
+ if (statusCode >= 400) return
29
+
30
+ return getAvatar(body)
31
+ }
32
+
33
+ module.exports.getAvatarUrl = getAvatarUrl
34
+ module.exports.getAvatar = getAvatar