Update server dependencies
This commit is contained in:
parent
4ddcb7c3ba
commit
fce7fe04ee
38
package.json
38
package.json
|
@ -83,7 +83,7 @@
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"oauth2-server": "3.1.0-beta.1",
|
"oauth2-server": "3.1.0-beta.1",
|
||||||
"http-signature": "1.3.4"
|
"http-signature": "1.3.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"apicache": "^1.4.0",
|
"apicache": "^1.4.0",
|
||||||
|
@ -111,18 +111,18 @@
|
||||||
"fluent-ffmpeg": "^2.1.0",
|
"fluent-ffmpeg": "^2.1.0",
|
||||||
"fs-extra": "^9.0.0",
|
"fs-extra": "^9.0.0",
|
||||||
"helmet": "^4.1.0",
|
"helmet": "^4.1.0",
|
||||||
"http-signature": "1.3.4",
|
"http-signature": "1.3.5",
|
||||||
"ip-anonymize": "^0.1.0",
|
"ip-anonymize": "^0.1.0",
|
||||||
"ipaddr.js": "2.0.0",
|
"ipaddr.js": "2.0.0",
|
||||||
"is-cidr": "^4.0.0",
|
"is-cidr": "^4.0.0",
|
||||||
"iso-639-3": "^2.0.0",
|
"iso-639-3": "^2.0.0",
|
||||||
"jimp": "^0.16.0",
|
"jimp": "^0.16.0",
|
||||||
"js-yaml": "^3.5.4",
|
"js-yaml": "^3.5.4",
|
||||||
"jsonld": "~3.1.1",
|
"jsonld": "~3.2.0",
|
||||||
"lodash": "^4.17.10",
|
"lodash": "^4.17.10",
|
||||||
"lru-cache": "^6.0.0",
|
"lru-cache": "^6.0.0",
|
||||||
"magnet-uri": "^5.1.4",
|
"magnet-uri": "^6.1.0",
|
||||||
"markdown-it": "11.x",
|
"markdown-it": "12.0.2",
|
||||||
"markdown-it-emoji": "^2.0.0",
|
"markdown-it-emoji": "^2.0.0",
|
||||||
"memoizee": "^0.4.14",
|
"memoizee": "^0.4.14",
|
||||||
"morgan": "^1.5.3",
|
"morgan": "^1.5.3",
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
"node-media-server": "^2.1.4",
|
"node-media-server": "^2.1.4",
|
||||||
"nodemailer": "^6.0.0",
|
"nodemailer": "^6.0.0",
|
||||||
"oauth2-server": "3.1.0-beta.1",
|
"oauth2-server": "3.1.0-beta.1",
|
||||||
"parse-torrent": "^7.0.0",
|
"parse-torrent": "^9.1.0",
|
||||||
"password-generator": "^2.0.2",
|
"password-generator": "^2.0.2",
|
||||||
"pem": "^1.12.3",
|
"pem": "^1.12.3",
|
||||||
"pfeed": "1.1.11",
|
"pfeed": "1.1.11",
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
"sequelize": "5.21.13",
|
"sequelize": "5.21.13",
|
||||||
"sequelize-typescript": "^1.0.0-beta.4",
|
"sequelize-typescript": "^1.0.0-beta.4",
|
||||||
"sitemap": "^6.1.0",
|
"sitemap": "^6.1.0",
|
||||||
"socket.io": "^2.2.0",
|
"socket.io": "^3.0.2",
|
||||||
"srt-to-vtt": "^1.1.2",
|
"srt-to-vtt": "^1.1.2",
|
||||||
"tsconfig-paths": "^3.9.0",
|
"tsconfig-paths": "^3.9.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
|
@ -153,20 +153,20 @@
|
||||||
"uuid": "^8.1.0",
|
"uuid": "^8.1.0",
|
||||||
"validator": "^13.0.0",
|
"validator": "^13.0.0",
|
||||||
"webfinger.js": "^2.6.6",
|
"webfinger.js": "^2.6.6",
|
||||||
"webtorrent": "^0.108.6",
|
"webtorrent": "^0.111.0",
|
||||||
"winston": "3.3.3",
|
"winston": "3.3.3",
|
||||||
"ws": "^7.0.0",
|
"ws": "^7.0.0",
|
||||||
"youtube-dl": "^3.0.2"
|
"youtube-dl": "^3.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@openapitools/openapi-generator-cli": "^1.0.15-4.3.1",
|
"@openapitools/openapi-generator-cli": "^2.1.4",
|
||||||
"@types/apicache": "^1.2.0",
|
"@types/apicache": "^1.2.0",
|
||||||
"@types/async": "^3.0.0",
|
"@types/async": "^3.0.0",
|
||||||
"@types/async-lock": "^1.1.0",
|
"@types/async-lock": "^1.1.0",
|
||||||
"@types/bcrypt": "^3.0.0",
|
"@types/bcrypt": "^3.0.0",
|
||||||
"@types/bluebird": "3.5.32",
|
"@types/bluebird": "3.5.33",
|
||||||
"@types/body-parser": "^1.16.3",
|
"@types/body-parser": "^1.16.3",
|
||||||
"@types/bull": "3.14.2",
|
"@types/bull": "3.14.4",
|
||||||
"@types/bytes": "^3.0.0",
|
"@types/bytes": "^3.0.0",
|
||||||
"@types/chai": "^4.0.4",
|
"@types/chai": "^4.0.4",
|
||||||
"@types/chai-json-schema": "^1.4.3",
|
"@types/chai-json-schema": "^1.4.3",
|
||||||
|
@ -192,19 +192,17 @@
|
||||||
"@types/pem": "^1.9.3",
|
"@types/pem": "^1.9.3",
|
||||||
"@types/redis": "^2.8.5",
|
"@types/redis": "^2.8.5",
|
||||||
"@types/request": "^2.0.3",
|
"@types/request": "^2.0.3",
|
||||||
"@types/socket.io": "^2.1.2",
|
|
||||||
"@types/socket.io-client": "^1.4.34",
|
|
||||||
"@types/supertest": "^2.0.3",
|
"@types/supertest": "^2.0.3",
|
||||||
"@types/validator": "^13.0.0",
|
"@types/validator": "^13.0.0",
|
||||||
"@types/webtorrent": "^0.107.0",
|
"@types/webtorrent": "^0.109.0",
|
||||||
"@types/ws": "^7.2.1",
|
"@types/ws": "^7.2.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.3.0",
|
"@typescript-eslint/eslint-plugin": "^4.8.1",
|
||||||
"chai": "^4.1.1",
|
"chai": "^4.1.1",
|
||||||
"chai-json-schema": "^1.5.0",
|
"chai-json-schema": "^1.5.0",
|
||||||
"chai-xml": "^0.3.2",
|
"chai-xml": "^0.4.0",
|
||||||
"concurrently": "^5.0.0",
|
"concurrently": "^5.0.0",
|
||||||
"eslint": "^7.2.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-import": "^2.20.1",
|
||||||
"eslint-plugin-node": "^11.0.0",
|
"eslint-plugin-node": "^11.0.0",
|
||||||
"eslint-plugin-promise": "^4.2.1",
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
|
@ -215,12 +213,12 @@
|
||||||
"marked-man": "^0.7.0",
|
"marked-man": "^0.7.0",
|
||||||
"mocha": "^8.0.1",
|
"mocha": "^8.0.1",
|
||||||
"nodemon": "^2.0.1",
|
"nodemon": "^2.0.1",
|
||||||
"socket.io-client": "^2.3.1",
|
"socket.io-client": "^3.0.2",
|
||||||
"source-map-support": "^0.5.0",
|
"source-map-support": "^0.5.0",
|
||||||
"supertest": "^4.0.2",
|
"supertest": "^6.0.1",
|
||||||
"swagger-cli": "^4.0.2",
|
"swagger-cli": "^4.0.2",
|
||||||
"ts-node": "9.0.0",
|
"ts-node": "9.0.0",
|
||||||
"typescript": "^3.7.2"
|
"typescript": "^4.0.5"
|
||||||
},
|
},
|
||||||
"scripty": {
|
"scripty": {
|
||||||
"silent": true
|
"silent": true
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { Socket } from 'dgram'
|
|
||||||
import { Server } from 'http'
|
import { Server } from 'http'
|
||||||
import * as SocketIO from 'socket.io'
|
import * as SocketIO from 'socket.io'
|
||||||
import { MVideo } from '@server/types/models'
|
import { MVideo } from '@server/types/models'
|
||||||
|
@ -18,7 +17,7 @@ class PeerTubeSocket {
|
||||||
private constructor () {}
|
private constructor () {}
|
||||||
|
|
||||||
init (server: Server) {
|
init (server: Server) {
|
||||||
const io = SocketIO(server)
|
const io = new SocketIO.Server(server)
|
||||||
|
|
||||||
io.of('/user-notifications')
|
io.of('/user-notifications')
|
||||||
.use(authenticateSocket)
|
.use(authenticateSocket)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import { logger } from '../helpers/logger'
|
|
||||||
import { Socket } from 'socket.io'
|
import { Socket } from 'socket.io'
|
||||||
import { getAccessToken } from '../lib/oauth-model'
|
|
||||||
import { oAuthServer } from '@server/lib/auth'
|
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) {
|
function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) {
|
||||||
const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {}
|
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) {
|
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)
|
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.'))
|
return next(new Error('Invalid access token.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.handshake.query.user = tokenDB.User
|
socket.handshake.query['user'] = tokenDB.User
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as io from 'socket.io-client'
|
import { io } from 'socket.io-client'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -235,11 +235,11 @@ describe('Test user notifications API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When connecting to my notification socket', function () {
|
describe('When connecting to my notification socket', function () {
|
||||||
|
|
||||||
it('Should fail with no token', function (next) {
|
it('Should fail with no token', function (next) {
|
||||||
const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false })
|
const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false })
|
||||||
|
|
||||||
socket.on('error', function () {
|
socket.once('connect_error', function () {
|
||||||
socket.removeListener('error', this)
|
|
||||||
socket.disconnect()
|
socket.disconnect()
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
@ -256,8 +256,7 @@ describe('Test user notifications API validators', function () {
|
||||||
reconnection: false
|
reconnection: false
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('error', function () {
|
socket.once('connect_error', function () {
|
||||||
socket.removeListener('error', this)
|
|
||||||
socket.disconnect()
|
socket.disconnect()
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
@ -278,10 +277,9 @@ describe('Test user notifications API validators', function () {
|
||||||
next(new Error('Error in connection: ' + err))
|
next(new Error('Error in connection: ' + err))
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('error', errorListener)
|
socket.on('connect_error', errorListener)
|
||||||
|
|
||||||
socket.on('connect', async () => {
|
socket.once('connect', async () => {
|
||||||
socket.removeListener('error', errorListener)
|
|
||||||
socket.disconnect()
|
socket.disconnect()
|
||||||
|
|
||||||
await wait(500)
|
await wait(500)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as io from 'socket.io-client'
|
import { io } from 'socket.io-client'
|
||||||
|
|
||||||
function getUserNotificationSocket (serverUrl: string, accessToken: string) {
|
function getUserNotificationSocket (serverUrl: string, accessToken: string) {
|
||||||
return io(serverUrl + '/user-notifications', {
|
return io(serverUrl + '/user-notifications', {
|
||||||
|
|
Loading…
Reference in New Issue