@unavatar/core 0.0.8 → 3.7.49

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2018 Kiko Beats <josefrancisco.verdu@gmail.com> (kikobeats.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -55,7 +55,7 @@ It's proudly powered by [microlink.io](https://microlink.io), the headless brows
55
55
 
56
56
  The service is exposed in **unavatar.io** via provider endpoints:
57
57
 
58
- - an **email**: [unavatar.io/gravatar/sindresorhus@gmail.com](https://unavatar.io/gravatar/sindresorhus@gmail.com)
58
+ - an **email**: [unavatar.io/gravatar/hello@microlink.io](https://unavatar.io/gravatar/hello@microlink.io)
59
59
  - an **username**: [unavatar.io/github/kikobeats](https://unavatar.io/github/kikobeats)
60
60
  - a **domain**: [unavatar.io/google/reddit.com](https://unavatar.io/google/reddit.com)
61
61
 
@@ -215,7 +215,7 @@ e.g., [unavatar.io/google/netflix.com](https://unavatar.io/google/netflix.com)
215
215
 
216
216
  It resolves user avatar against **gravatar.com**.
217
217
 
218
- e.g., [unavatar.io/gravatar/sindresorhus@gmail.com](https://unavatar.io/gravatar/sindresorhus@gmail.com)
218
+ e.g., [unavatar.io/gravatar/hello@microlink.io](https://unavatar.io/gravatar/hello@microlink.io)
219
219
 
220
220
  ### Instagram
221
221
 
package/bin/index.js CHANGED
@@ -15,7 +15,7 @@ module.exports = ({ baseUrl }) => {
15
15
  if (!input) {
16
16
  console.error('Usage: unavatar <input> | unavatar <provider>/<key> | unavatar ping')
17
17
  console.error(
18
- 'Examples: unavatar reddit.com | unavatar sindresorhus@gmail.com | unavatar x/kikobeats | unavatar ping'
18
+ 'Examples: unavatar reddit.com | unavatar hello@microlink.io | unavatar x/kikobeats | unavatar ping'
19
19
  )
20
20
  process.exit(1)
21
21
  }
@@ -44,7 +44,7 @@ module.exports = ({ baseUrl }) => {
44
44
  if (!provider || !key) {
45
45
  console.error('Invalid input format. Expected: <input>, <provider>/<key>, or "ping"')
46
46
  console.error(
47
- 'Examples: unavatar reddit.com | unavatar sindresorhus@gmail.com | unavatar x/kikobeats | unavatar ping'
47
+ 'Examples: unavatar reddit.com | unavatar hello@microlink.io | unavatar x/kikobeats | unavatar ping'
48
48
  )
49
49
  process.exit(1)
50
50
  }
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": "0.0.8",
5
+ "version": "3.7.49",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -66,6 +66,10 @@
66
66
  "name": "Jahir Fiquitiva",
67
67
  "email": "jahir.fiquitiva@gmail.com"
68
68
  },
69
+ {
70
+ "name": "Joseba Legarreta",
71
+ "email": "josebalega@gmail.com"
72
+ },
69
73
  {
70
74
  "name": "Mads Hougesen",
71
75
  "email": "mads@mhouge.dk"
@@ -103,18 +107,16 @@
103
107
  "youtube"
104
108
  ],
105
109
  "dependencies": {
106
- "@keyvhq/compress": "~2.1.15",
110
+ "@keyvhq/compress": "~2.2.0",
107
111
  "@keyvhq/core": "~2.1.15",
108
112
  "@keyvhq/memoize": "~2.1.16",
109
113
  "@keyvhq/multi": "~2.1.15",
110
114
  "@keyvhq/redis": "~2.1.15",
111
- "@kikobeats/got-scraping": "~4.2.0",
112
115
  "@metascraper/helpers": "~5.49.24",
113
116
  "@microlink/mql": "~0.14.2",
114
117
  "@microlink/ping-url": "~1.4.16",
115
- "browserless": "~10.10.0",
118
+ "browserless": "~10.12.0",
116
119
  "cacheable-lookup": "~6.1.0",
117
- "cheerio": "~1.2.0",
118
120
  "data-uri-regex": "~0.1.4",
119
121
  "debug-logfmt": "~1.4.7",
120
122
  "got": "~11.8.6",
@@ -128,33 +130,36 @@
128
130
  "p-cancelable": "2.1.1",
129
131
  "p-timeout": "~4.1.0",
130
132
  "puppeteer": "~24.37.5",
133
+ "re2": "~1.23.3",
131
134
  "srcset": "~4.0.0",
135
+ "stable-regex": "~1.0.0",
132
136
  "tangerine": "~2.0.2",
133
137
  "top-crawler-agents": "~1.0.34",
134
138
  "top-user-agents": "~2.1.95",
135
139
  "ua-hints": "~1.0.1",
136
140
  "unique-random-array": "~2.0.0",
137
- "url-regex": "~5.0.0"
141
+ "url-regex-safe": "~4.0.0"
138
142
  },
139
143
  "devDependencies": {
140
- "mri": "latest",
141
- "term-img": "latest",
142
144
  "@commitlint/cli": "latest",
143
145
  "@commitlint/config-conventional": "latest",
144
146
  "@ksmithut/prettier-standard": "latest",
145
147
  "ava": "latest",
146
148
  "c8": "latest",
149
+ "cheerio": "latest",
147
150
  "ci-publish": "latest",
148
151
  "conventional-changelog-cli": "latest",
149
152
  "finepack": "latest",
150
153
  "git-authors-cli": "latest",
151
154
  "github-generate-release": "latest",
155
+ "mri": "latest",
152
156
  "nano-staged": "latest",
153
157
  "proxyquire": "latest",
154
158
  "simple-git-hooks": "latest",
155
159
  "sinon": "latest",
156
160
  "standard": "latest",
157
- "standard-version": "latest"
161
+ "standard-version": "latest",
162
+ "term-img": "latest"
158
163
  },
159
164
  "engines": {
160
165
  "node": "24"
@@ -163,6 +168,18 @@
163
168
  "bin",
164
169
  "src"
165
170
  ],
171
+ "scripts": {
172
+ "contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
173
+ "postrelease": "pnpm release:tags && pnpm release:github && (ci-publish || pnpm publish --access=public)",
174
+ "release": "pnpm release:version && pnpm release:changelog && pnpm release:commit && pnpm release:tag",
175
+ "release:changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s",
176
+ "release:commit": "git add package.json CHANGELOG.md && git commit -m \"chore(release): $(node -p \"require('./package.json').version\")\"",
177
+ "release:github": "github-generate-release",
178
+ "release:tag": "git tag -a v$(node -p \"require('./package.json').version\") -m \"v$(node -p \"require('./package.json').version\")\"",
179
+ "release:tags": "git push origin HEAD:master --follow-tags",
180
+ "release:version": "standard-version --skip.changelog --skip.commit --skip.tag",
181
+ "test": "c8 ava"
182
+ },
166
183
  "license": "MIT",
167
184
  "commitlint": {
168
185
  "extends": [
@@ -183,20 +200,11 @@
183
200
  "finepack"
184
201
  ]
185
202
  },
203
+ "pnpm": {
204
+ "neverBuiltDependencies": []
205
+ },
186
206
  "simple-git-hooks": {
187
207
  "commit-msg": "npx commitlint --edit",
188
208
  "pre-commit": "npx nano-staged"
189
- },
190
- "scripts": {
191
- "contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
192
- "postrelease": "pnpm release:tags && pnpm release:github && (ci-publish || pnpm publish --access=public)",
193
- "release": "pnpm release:version && pnpm release:changelog && pnpm release:commit && pnpm release:tag",
194
- "release:changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s",
195
- "release:commit": "git add package.json CHANGELOG.md && git commit -m \"chore(release): $(node -p \"require('./package.json').version\")\"",
196
- "release:github": "github-generate-release",
197
- "release:tag": "git tag -a v$(node -p \"require('./package.json').version\") -m \"v$(node -p \"require('./package.json').version\")\"",
198
- "release:tags": "git push origin HEAD:master --follow-tags",
199
- "release:version": "standard-version --skip.changelog --skip.commit --skip.tag",
200
- "test": "c8 ava"
201
209
  }
202
- }
210
+ }
@@ -2,18 +2,22 @@
2
2
 
3
3
  const isAbsoluteUrl = require('is-absolute-url')
4
4
  const dataUriRegex = require('data-uri-regex')
5
+ const stableRegex = require('stable-regex')
6
+ const urlRegex = require('url-regex-safe')
5
7
  const isEmail = require('is-email-like')
6
8
  const pTimeout = require('p-timeout')
7
- const urlRegex = require('url-regex')
8
9
  const pAny = require('p-any')
9
10
 
10
11
  const httpStatus = require('../util/http-status')
11
12
  const isIterable = require('../util/is-iterable')
12
13
  const ExtendableError = require('../util/error')
13
14
 
15
+ const DATA_URI_REGEX = dataUriRegex()
16
+ const DOMAIN_REGEX = urlRegex({ strict: false })
17
+
14
18
  const getInputType = input => {
15
19
  if (isEmail(input)) return 'email'
16
- if (urlRegex({ strict: false }).test(input)) return 'domain'
20
+ if (stableRegex(DOMAIN_REGEX, input)) return 'domain'
17
21
  return 'username'
18
22
  }
19
23
 
@@ -22,12 +26,16 @@ const factory = ({ constants, providers, providersBy, reachableUrl }) => {
22
26
 
23
27
  const getAvatarContent = provider => async output => {
24
28
  if (typeof output !== 'string' || output === '') {
25
- const message = output === undefined ? 'not found' : `\`${output}\` is invalid`
26
- const statusCode = output === undefined ? httpStatus.NOT_FOUND : httpStatus.UNPROCESSABLE_ENTITY
29
+ const message =
30
+ output === undefined ? 'not found' : `\`${output}\` is invalid`
31
+ const statusCode =
32
+ output === undefined
33
+ ? httpStatus.NOT_FOUND
34
+ : httpStatus.UNPROCESSABLE_ENTITY
27
35
  throw new ExtendableError({ provider, message, statusCode })
28
36
  }
29
37
 
30
- if (dataUriRegex().test(output)) {
38
+ if (stableRegex(DATA_URI_REGEX, output)) {
31
39
  return { type: 'buffer', data: output }
32
40
  }
33
41
 
package/src/constant.js CHANGED
@@ -7,8 +7,9 @@ const DEFAULTS = {
7
7
  AVATAR_SIZE: 400,
8
8
  REQUEST_TIMEOUT: 25000,
9
9
  TTL_DEFAULT: ms('28d'),
10
+ DNS_SERVERS: ['1.1.1.1', '8.8.8.8'],
10
11
  TMP_FOLDER: existsSync('/dev/shm') ? '/dev/shm' : '/tmp',
11
- DEBUG_HTML_TO_FILE: false,
12
+ DEBUG_HTML_TO_FILE: false
12
13
  }
13
14
 
14
15
  DEFAULTS.PROXY_TIMEOUT = Math.floor(DEFAULTS.REQUEST_TIMEOUT * (1 / 3))
@@ -3,7 +3,7 @@
3
3
  const CacheableLookup = require('cacheable-lookup')
4
4
  const Tangerine = require('tangerine')
5
5
 
6
- module.exports = ({ TTL_DEFAULT, DNS_TIMEOUT, createMemoryCache }) =>
6
+ module.exports = ({ TTL_DEFAULT, DNS_TIMEOUT, DNS_SERVERS, createMemoryCache }) =>
7
7
  new CacheableLookup({
8
8
  maxTtl: TTL_DEFAULT,
9
9
  cache: createMemoryCache({ namespace: 'dns' }),
@@ -11,7 +11,7 @@ module.exports = ({ TTL_DEFAULT, DNS_TIMEOUT, createMemoryCache }) =>
11
11
  {
12
12
  cache: false,
13
13
  timeout: DNS_TIMEOUT,
14
- servers: ['1.1.1.1', '8.8.8.8']
14
+ servers: DNS_SERVERS
15
15
  },
16
16
  require('got').extend({
17
17
  responseType: 'buffer',