Browse Source

Update server dependencies

pull/3334/head
Chocobozzz 1 week ago
parent
commit
fce7fe04ee
No known key found for this signature in database GPG Key ID: 583A612D890159BE
6 changed files with 769 additions and 515 deletions
  1. +18
    -20
      package.json
  2. +1
    -2
      server/lib/peertube-socket.ts
  3. +4
    -4
      server/middlewares/oauth.ts
  4. +6
    -8
      server/tests/api/check-params/user-notifications.ts
  5. +1
    -1
      shared/extra-utils/socket/socket-io.ts
  6. +739
    -480
      yarn.lock

+ 18
- 20
package.json View File

@@ -83,7 +83,7 @@
},
"resolutions": {
"oauth2-server": "3.1.0-beta.1",
"http-signature": "1.3.4"
"http-signature": "1.3.5"
},
"dependencies": {
"apicache": "^1.4.0",
@@ -111,18 +111,18 @@
"fluent-ffmpeg": "^2.1.0",
"fs-extra": "^9.0.0",
"helmet": "^4.1.0",
"http-signature": "1.3.4",
"http-signature": "1.3.5",
"ip-anonymize": "^0.1.0",
"ipaddr.js": "2.0.0",
"is-cidr": "^4.0.0",
"iso-639-3": "^2.0.0",
"jimp": "^0.16.0",
"js-yaml": "^3.5.4",
"jsonld": "~3.1.1",
"jsonld": "~3.2.0",
"lodash": "^4.17.10",
"lru-cache": "^6.0.0",
"magnet-uri": "^5.1.4",
"markdown-it": "11.x",
"magnet-uri": "^6.1.0",
"markdown-it": "12.0.2",
"markdown-it-emoji": "^2.0.0",
"memoizee": "^0.4.14",
"morgan": "^1.5.3",
@@ -130,7 +130,7 @@
"node-media-server": "^2.1.4",
"nodemailer": "^6.0.0",
"oauth2-server": "3.1.0-beta.1",
"parse-torrent": "^7.0.0",
"parse-torrent": "^9.1.0",
"password-generator": "^2.0.2",
"pem": "^1.12.3",
"pfeed": "1.1.11",
@@ -145,7 +145,7 @@
"sequelize": "5.21.13",
"sequelize-typescript": "^1.0.0-beta.4",
"sitemap": "^6.1.0",
"socket.io": "^2.2.0",
"socket.io": "^3.0.2",
"srt-to-vtt": "^1.1.2",
"tsconfig-paths": "^3.9.0",
"tslib": "^2.0.0",
@@ -153,20 +153,20 @@
"uuid": "^8.1.0",
"validator": "^13.0.0",
"webfinger.js": "^2.6.6",
"webtorrent": "^0.108.6",
"webtorrent": "^0.111.0",
"winston": "3.3.3",
"ws": "^7.0.0",
"youtube-dl": "^3.0.2"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "^1.0.15-4.3.1",
"@openapitools/openapi-generator-cli": "^2.1.4",
"@types/apicache": "^1.2.0",
"@types/async": "^3.0.0",
"@types/async-lock": "^1.1.0",
"@types/bcrypt": "^3.0.0",
"@types/bluebird": "3.5.32",
"@types/bluebird": "3.5.33",
"@types/body-parser": "^1.16.3",
"@types/bull": "3.14.2",
"@types/bull": "3.14.4",
"@types/bytes": "^3.0.0",
"@types/chai": "^4.0.4",
"@types/chai-json-schema": "^1.4.3",
@@ -192,19 +192,17 @@
"@types/pem": "^1.9.3",
"@types/redis": "^2.8.5",
"@types/request": "^2.0.3",
"@types/socket.io": "^2.1.2",
"@types/socket.io-client": "^1.4.34",
"@types/supertest": "^2.0.3",
"@types/validator": "^13.0.0",
"@types/webtorrent": "^0.107.0",
"@types/webtorrent": "^0.109.0",
"@types/ws": "^7.2.1",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"chai": "^4.1.1",
"chai-json-schema": "^1.5.0",
"chai-xml": "^0.3.2",
"chai-xml": "^0.4.0",
"concurrently": "^5.0.0",
"eslint": "^7.2.0",
"eslint-config-standard-with-typescript": "^18.0.2",
"eslint-config-standard-with-typescript": "^19.0.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
@@ -215,12 +213,12 @@
"marked-man": "^0.7.0",
"mocha": "^8.0.1",
"nodemon": "^2.0.1",
"socket.io-client": "^2.3.1",
"socket.io-client": "^3.0.2",
"source-map-support": "^0.5.0",
"supertest": "^4.0.2",
"supertest": "^6.0.1",
"swagger-cli": "^4.0.2",
"ts-node": "9.0.0",
"typescript": "^3.7.2"
"typescript": "^4.0.5"
},
"scripty": {
"silent": true


+ 1
- 2
server/lib/peertube-socket.ts View File

@@ -1,4 +1,3 @@
import { Socket } from 'dgram'
import { Server } from 'http'
import * as SocketIO from 'socket.io'
import { MVideo } from '@server/types/models'
@@ -18,7 +17,7 @@ class PeerTubeSocket {
private constructor () {}

init (server: Server) {
const io = SocketIO(server)
const io = new SocketIO.Server(server)

io.of('/user-notifications')
.use(authenticateSocket)


+ 4
- 4
server/middlewares/oauth.ts View File

@@ -1,8 +1,8 @@
import * as express from 'express'
import { logger } from '../helpers/logger'
import { Socket } from 'socket.io'
import { getAccessToken } from '../lib/oauth-model'
import { oAuthServer } from '@server/lib/auth'
import { logger } from '../helpers/logger'
import { getAccessToken } from '../lib/oauth-model'

function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) {
const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {}
@@ -24,7 +24,7 @@ function authenticate (req: express.Request, res: express.Response, next: expres
}

function authenticateSocket (socket: Socket, next: (err?: any) => void) {
const accessToken = socket.handshake.query.accessToken
const accessToken = socket.handshake.query['accessToken']

logger.debug('Checking socket access token %s.', accessToken)

@@ -38,7 +38,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) {
return next(new Error('Invalid access token.'))
}

socket.handshake.query.user = tokenDB.User
socket.handshake.query['user'] = tokenDB.User

return next()
})


+ 6
- 8
server/tests/api/check-params/user-notifications.ts View File

@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import 'mocha'
import * as io from 'socket.io-client'
import { io } from 'socket.io-client'

import {
cleanupTests,
@@ -235,11 +235,11 @@ describe('Test user notifications API validators', function () {
})

describe('When connecting to my notification socket', function () {

it('Should fail with no token', function (next) {
const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false })

socket.on('error', function () {
socket.removeListener('error', this)
socket.once('connect_error', function () {
socket.disconnect()
next()
})
@@ -256,8 +256,7 @@ describe('Test user notifications API validators', function () {
reconnection: false
})

socket.on('error', function () {
socket.removeListener('error', this)
socket.once('connect_error', function () {
socket.disconnect()
next()
})
@@ -278,10 +277,9 @@ describe('Test user notifications API validators', function () {
next(new Error('Error in connection: ' + err))
}

socket.on('error', errorListener)
socket.on('connect_error', errorListener)

socket.on('connect', async () => {
socket.removeListener('error', errorListener)
socket.once('connect', async () => {
socket.disconnect()

await wait(500)


+ 1
- 1
shared/extra-utils/socket/socket-io.ts View File

@@ -1,4 +1,4 @@
import * as io from 'socket.io-client'
import { io } from 'socket.io-client'

function getUserNotificationSocket (serverUrl: string, accessToken: string) {
return io(serverUrl + '/user-notifications', {


+ 739
- 480
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save