ActivityPub-federated video streaming platform using P2P directly in your web browser
Reapply "Upgrade webfinger lib to 2.8.1"
Chocobozzza5c087d3d46c
diff --git a/package.json b/package.jsonindex 0422102a8d..9b44c8afbc 100644--- a/package.json+++ b/package.json@@ -192,7 +192,7 @@"tslib": "^2.0.0","uuid": "^11.0.5","validator": "^13.0.0",- "webfinger.js": "2.7.1",+ "webfinger.js": "2.8.2","winston": "3.17.0","ws": "^8.0.0","yauzl": "^3.1.0"diff --git a/server/core/lib/activitypub/actors/webfinger.ts b/server/core/lib/activitypub/actors/webfinger.tsindex 6fcc269dbb..61abca9c6d 100644--- a/server/core/lib/activitypub/actors/webfinger.ts+++ b/server/core/lib/activitypub/actors/webfinger.ts@@ -1,19 +1,20 @@-import WebFinger from 'webfinger.js'-import { WebFingerData } from '@peertube/peertube-models'import { isProdInstance } from '@peertube/peertube-node-utils'import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc.js'+import { CONFIG } from '@server/initializers/config.js'import { REQUEST_TIMEOUTS, WEBSERVER } from '@server/initializers/constants.js'import { ActorModel } from '@server/models/actor/actor.js'import { MActorFull } from '@server/types/models/index.js'+import WebFinger from 'webfinger.js'+// eslint-disable-next-line new-capconst webfinger = new WebFinger({- webfist_fallback: false,tls_only: isProdInstance(),uri_fallback: false,- request_timeout: REQUEST_TIMEOUTS.DEFAULT+ request_timeout: REQUEST_TIMEOUTS.DEFAULT,+ allow_private_addresses: CONFIG.FEDERATION.PREVENT_SSRF === false})-async function loadActorUrlOrGetFromWebfinger (uriArg: string) {+export async function loadActorUrlOrGetFromWebfinger (uriArg: string) {// Handle strings like @[email protected]const uri = uriArg.startsWith('@') ? uriArg.slice(1) : uriArg@@ -31,37 +32,15 @@ async function loadActorUrlOrGetFromWebfinger (uriArg: string) {return getUrlFromWebfinger(uri)}-async function getUrlFromWebfinger (uri: string) {- const webfingerData: WebFingerData = await webfingerLookup(uri)- return getLinkOrThrow(webfingerData)-}--// -----------------------------------------------------------------------------export {- getUrlFromWebfinger,- loadActorUrlOrGetFromWebfinger-}--// ---------------------------------------------------------------------------+export async function getUrlFromWebfinger (uri: string) {+ const { object } = await webfinger.lookup(uri)-function getLinkOrThrow (webfingerData: WebFingerData) {- if (Array.isArray(webfingerData.links) === false) throw new Error('WebFinger links is not an array.')+ if (Array.isArray(object.links) === false) throw new Error('WebFinger links is not an array.')- const selfLink = webfingerData.links.find(l => l.rel === 'self')- if (selfLink === undefined || isActivityPubUrlValid(selfLink.href) === false) {+ const selfLink = object.links.find(l => l.rel === 'self')+ if (selfLink === undefined || isActivityPubUrlValid(selfLink.href as string) === false) {throw new Error('Cannot find self link or href is not a valid URL.')}- return selfLink.href-}--function webfingerLookup (handle: string) {- return new Promise<WebFingerData>((res, rej) => {- webfinger.lookup(handle, (err, p) => {- if (err) return rej(err)-- return res(p.object)- })- })+ return selfLink.href as string}diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.mdindex 3084d6e7a9..4cd7ac4a9e 100644--- a/support/doc/plugins/guide.md+++ b/support/doc/plugins/guide.md@@ -378,7 +378,7 @@ function register (...) {// Will be displayed in a button next to the login formauthDisplayName: () => 'Auth method'- // If the user click on the auth button, PeerTube will forward the request in this function+ // If the user click on the auth button, PeerTube will forward the request to this functiononAuthRequest: (req, res) => {res.redirect('https://external-auth.example.com/auth')},diff --git a/yarn.lock b/yarn.lockindex 9ab3400e66..6de8a781f6 100644--- a/yarn.lock+++ b/yarn.lock@@ -11830,12 +11830,10 @@ web-streams-polyfill@^3.0.3:resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz#2073b91a2fdb1fbfbd401e7de0ac9f8214cecb4b"integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==- version "2.7.1"- resolved "https://registry.yarnpkg.com/webfinger.js/-/webfinger.js-2.7.1.tgz#6a96ce1c4c36222f3664fe81b2641ceef771c4ea"- integrity sha512-H4RokaE4RC39N3uiRTcjKMmy6yYg06lUPORQHvv8DjowZ6I5SalxUeoqHbtTN3EVBmYP/XHQ8Ow6BLEIpe2DtA==- dependencies:- xhr2 "0.2.1"+ version "2.8.2"+ resolved "https://registry.yarnpkg.com/webfinger.js/-/webfinger.js-2.8.2.tgz#84c88fb131fb5cd1e262f7665a2a6fa2f76fcb33"+ integrity sha512-Zqn9KXkGrD1tVEm029bVUIfmzef2KXs3G7OZrdqehDHtgv9YSxX1oy4RoPoMk2PHWIifwWCA0xwKZOAZqXMpfg==webidl-conversions@^3.0.0:version "3.0.1"@@ -12145,11 +12143,6 @@ ws@~8.17.1:resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==- version "0.2.1"- resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.2.1.tgz#4e73adc4f9cfec9cbd2157f73efdce3a5f108a93"- integrity sha512-sID0rrVCqkVNUn8t6xuv9+6FViXjUVXq8H5rWOH2rz9fDNQEd4g0EA2XlcEdJXRz5BMEn4O1pJFdT+z4YHhoWw==-xhr@^2.0.1:version "2.6.0"resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.6.0.tgz#b69d4395e792b4173d6b7df077f0fc5e4e2b249d"