diff --git a/package-lock.json b/package-lock.json index 3524b36a6..0b77d42d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3236,6 +3236,23 @@ "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", "dev": true }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, "debuglog": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz", @@ -4849,23 +4866,6 @@ "requires": { "agent-base": "4", "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } } }, "http-signature": { @@ -4887,17 +4887,6 @@ "requires": { "agent-base": "^4.3.0", "debug": "^3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } } }, "humanize-ms": { @@ -5525,12 +5514,6 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -8237,6 +8220,12 @@ "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, "quick-lru": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", @@ -8550,20 +8539,6 @@ "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" - }, - "dependencies": { - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", - "dev": true - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - } } }, "require-directory": { @@ -9320,12 +9295,6 @@ "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true } } }, @@ -9827,6 +9796,12 @@ "object.getownpropertydescriptors": "^2.0.3" } }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/packages/authentication-client/test/integration/socketio.test.ts b/packages/authentication-client/test/integration/socketio.test.ts index 2e7594cf7..d99959267 100644 --- a/packages/authentication-client/test/integration/socketio.test.ts +++ b/packages/authentication-client/test/integration/socketio.test.ts @@ -1,4 +1,4 @@ -import io from 'socket.io-client'; +import { io } from 'socket.io-client'; import assert from 'assert'; import feathers, { Application } from '@feathersjs/feathers'; import socketio from '@feathersjs/socketio'; diff --git a/packages/client/package.json b/packages/client/package.json index c5e117cf9..fcae711d9 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -70,7 +70,8 @@ "mocha-puppeteer": "^0.14.0", "node-fetch": "^2.6.1", "parallel-webpack": "^2.6.0", - "socket.io-client": "^2.3.1", + "shx": "^0.3.3", + "socket.io-client": "^3.0.3", "superagent": "^6.1.0", "uglifyjs-webpack-plugin": "^2.2.0", "webpack": "^5.10.0", diff --git a/packages/socketio-client/package.json b/packages/socketio-client/package.json index a5a9b3505..6f620af11 100644 --- a/packages/socketio-client/package.json +++ b/packages/socketio-client/package.json @@ -50,8 +50,7 @@ "access": "public" }, "dependencies": { - "@feathersjs/transport-commons": "^5.0.0-pre.0", - "@types/socket.io-client": "^1.4.34" + "@feathersjs/transport-commons": "^5.0.0-pre.0" }, "devDependencies": { "@feathersjs/commons": "^5.0.0-pre.0", @@ -59,7 +58,7 @@ "@feathersjs/socketio": "^5.0.0-pre.0", "@feathersjs/tests": "^5.0.0-pre.0", "@feathersjs/transport-commons": "^4.5.11", - "socket.io-client": "^2.3.1", + "socket.io-client": "^3.0.3", "@types/mocha": "^8.0.4", "@types/node": "^14.14.10", "mocha": "^8.2.1", diff --git a/packages/socketio-client/src/index.ts b/packages/socketio-client/src/index.ts index 5748bd55c..9f323c841 100644 --- a/packages/socketio-client/src/index.ts +++ b/packages/socketio-client/src/index.ts @@ -1,10 +1,11 @@ import { Service } from '@feathersjs/transport-commons/lib/client'; +import { Socket } from 'socket.io-client'; export interface SocketIOClientOptions { timeout?: number; } -export default function socketioClient (connection: SocketIOClient.Socket, options?: SocketIOClientOptions) { +export default function socketioClient (connection: Socket, options?: SocketIOClientOptions) { if (!connection) { throw new Error('Socket.io connection needs to be provided'); } diff --git a/packages/socketio-client/test/index.test.ts b/packages/socketio-client/test/index.test.ts index 1883d4820..1dfc05438 100644 --- a/packages/socketio-client/test/index.test.ts +++ b/packages/socketio-client/test/index.test.ts @@ -1,7 +1,7 @@ import { strict as assert } from 'assert'; import { Server } from 'http'; import feathers from '@feathersjs/feathers'; -import io from 'socket.io-client'; +import { io, Socket } from 'socket.io-client'; import { setupTests } from '@feathersjs/tests/lib/client'; import { createServer } from './server'; @@ -10,7 +10,7 @@ import socketio from '../src'; describe('@feathersjs/socketio-client', () => { const app = feathers(); - let socket: SocketIOClient.Socket; + let socket: Socket; let server: Server; before(done => { diff --git a/packages/socketio/package.json b/packages/socketio/package.json index 7e4c7e662..f5a79a6d2 100644 --- a/packages/socketio/package.json +++ b/packages/socketio/package.json @@ -51,9 +51,8 @@ }, "dependencies": { "@feathersjs/transport-commons": "^5.0.0-pre.0", - "@types/socket.io": "^2.1.11", "debug": "^4.3.1", - "socket.io": "^2.3.0", + "socket.io": "^3.0.3", "uberproto": "^2.0.6" }, "devDependencies": { @@ -67,7 +66,7 @@ "lodash": "^4.17.20", "mocha": "^8.2.1", "shx": "^0.3.3", - "socket.io-client": "^2.3.1", + "socket.io-client": "^3.0.3", "typescript": "^4.1.2" }, "gitHead": "e6b82b809c21da298501a12b82e72e166468994b" diff --git a/packages/socketio/src/index.ts b/packages/socketio/src/index.ts index 7ee6a23d1..bd08e87f9 100644 --- a/packages/socketio/src/index.ts +++ b/packages/socketio/src/index.ts @@ -1,7 +1,7 @@ -import Debug from 'debug'; -import socketio, { Server, ServerOptions } from 'socket.io'; // @ts-ignore import Proto from 'uberproto'; +import Debug from 'debug'; +import { Server, ServerOptions } from 'socket.io'; import http from 'http'; import { Application } from '@feathersjs/feathers'; import { socket } from '@feathersjs/transport-commons'; @@ -11,8 +11,8 @@ import { disconnect, params, authentication, FeathersSocket } from './middleware const debug = Debug('@feathersjs/socketio'); function configureSocketio (callback?: (io: Server) => void): (app: Application) => void; -function configureSocketio (options: number | ServerOptions, callback?: (io: Server) => void): (app: Application) => void; -function configureSocketio (port: number, options?: ServerOptions, callback?: (io: Server) => void): (app: Application) => void; +function configureSocketio (options: number | Partial, callback?: (io: Server) => void): (app: Application) => void; +function configureSocketio (port: number, options?: Partial, callback?: (io: Server) => void): (app: Application) => void; function configureSocketio (port?: any, options?: any, config?: any) { if (typeof port !== 'number') { config = options; @@ -55,7 +55,7 @@ function configureSocketio (port?: any, options?: any, config?: any) { setup (server: http.Server) { if (!this.io) { - const io = this.io = socketio.listen(port || server, options); + const io = this.io = new Server(port || server, options); io.use(disconnect(app, getParams)); io.use(params(app, socketMap)); diff --git a/packages/socketio/test/events.ts b/packages/socketio/test/events.ts index 8ff9a9811..0cbeb97e8 100644 --- a/packages/socketio/test/events.ts +++ b/packages/socketio/test/events.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import io from 'socket.io-client'; +import { io, Socket } from 'socket.io-client'; import { verify } from '@feathersjs/tests/lib/fixture'; import { RealTimeConnection } from '@feathersjs/transport-commons/lib/channels/channel/base'; @@ -27,7 +27,7 @@ export default (name: string, options: any) => { }; describe('Basic service events', () => { - let socket: SocketIOClient.Socket; + let socket: Socket; let connection: RealTimeConnection; before(done => { diff --git a/packages/socketio/test/index.test.ts b/packages/socketio/test/index.test.ts index 03a37b191..3436fefad 100644 --- a/packages/socketio/test/index.test.ts +++ b/packages/socketio/test/index.test.ts @@ -2,10 +2,11 @@ import { strict as assert } from 'assert'; import feathers, { Application, HookContext, NullableId, Params } from '@feathersjs/feathers'; import express from '@feathersjs/express'; import { omit, extend } from 'lodash'; -import io from 'socket.io-client'; +import { io } from 'socket.io-client'; import axios from 'axios'; import { Server } from 'http'; import { Service } from '@feathersjs/tests/lib/fixture'; +import { Socket } from 'socket.io-client'; import methodTests from './methods'; import eventTests from './events'; @@ -15,7 +16,7 @@ import { FeathersSocket, NextFunction } from '../src/middleware.js'; describe('@feathersjs/socketio', () => { let app: Application; let server: Server; - let socket: SocketIOClient.Socket; + let socket: Socket; const socketParams: any = { user: { name: 'David' }, @@ -44,7 +45,7 @@ describe('@feathersjs/socketio', () => { socket.feathers.user = { name: 'David' }; socketParams.headers = socket.feathers.headers; - const { channel } = socket.handshake.query; + const { channel } = socket.handshake.query as any; if (channel) { socket.feathers.channel = channel;