Socket
Socket
Sign inDemoInstall

@feathersjs/transport-commons

Package Overview
Dependencies
Maintainers
3
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feathersjs/transport-commons - npm Package Compare versions

Comparing version 4.5.17 to 4.5.18

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [4.5.18](https://github.com/feathersjs/feathers/compare/v4.5.17...v4.5.18) (2023-07-19)
### Bug Fixes
* **transport-commons:** Handle invalid service paths on socket lookups ([#3242](https://github.com/feathersjs/feathers/issues/3242)) ([0b9a6b1](https://github.com/feathersjs/feathers/commit/0b9a6b19b12ad05934e4c8bd9917448ed39d1ed8))
## [4.5.17](https://github.com/feathersjs/feathers/compare/v4.5.16...v4.5.17) (2023-07-17)

@@ -8,0 +19,0 @@

13

lib/socket/index.js

@@ -31,10 +31,9 @@ "use strict";

// `connection` event
done.then(provider => provider.on('connection', (connection) => app.emit('connection', getParams(connection))));
done.then((provider) => provider.on('connection', (connection) => app.emit('connection', getParams(connection))));
// `socket.emit('methodName', 'serviceName', ...args)` handlers
done.then(provider => provider.on('connection', (connection) => {
done.then((provider) => provider.on('connection', (connection) => {
for (const method of app.methods) {
connection.on(method, (...args) => {
const path = args.shift();
debug(`Got '${method}' call for service '${path}'`);
(0, utils_1.runMethod)(app, getParams(connection), path, method, args);
const [path, ...rest] = args;
(0, utils_1.runMethod)(app, getParams(connection), path, method, rest);
});

@@ -56,5 +55,5 @@ }

// Legacy `socket.emit('serviceName::methodName', ...args)` handlers
app.mixins.push((service, path) => done.then(provider => {
app.mixins.push((service, path) => done.then((provider) => {
provider.on('connection', (socket) => {
const methods = app.methods.filter(current =>
const methods = app.methods.filter((current) =>
// @ts-ignore

@@ -61,0 +60,0 @@ typeof service[current] === 'function');

@@ -9,2 +9,2 @@ import { HookContext, Application } from '@feathersjs/feathers';

export declare function getDispatcher(emit: string, socketMap: WeakMap<RealTimeConnection, any>, socketKey?: any): (event: string, channel: CombinedChannel, context: HookContext, data?: any) => void;
export declare function runMethod(app: Application, connection: RealTimeConnection, path: string, method: string, args: any[]): void;
export declare function runMethod(app: Application, connection: RealTimeConnection, _path: string, _method: string, args: any[]): void;

@@ -55,3 +55,5 @@ "use strict";

exports.getDispatcher = getDispatcher;
function runMethod(app, connection, path, method, args) {
function runMethod(app, connection, _path, _method, args) {
const path = typeof _path === 'string' ? _path : null;
const method = typeof _method === 'string' ? _method : null;
const trace = `method '${method}' on service '${path}'`;

@@ -72,3 +74,3 @@ const methodArgs = args.slice(0);

if (lookup === null) {
return Promise.reject(new errors_1.default.NotFound(`Service '${path}' not found`));
return Promise.reject(new errors_1.default.NotFound(path === null ? 'Invalid service path' : `Service '${path}' not found`));
}

@@ -75,0 +77,0 @@ const { service, params: route = {} } = lookup;

{
"name": "@feathersjs/transport-commons",
"description": "Shared functionality for websocket providers",
"version": "4.5.17",
"version": "4.5.18",
"homepage": "https://feathersjs.com",

@@ -62,3 +62,3 @@ "main": "lib/",

},
"gitHead": "022a407dab1e813d23b283d145dfff9a870541ee"
"gitHead": "2d3671d2e3ff88034181bccf2bfda04de856aa4f"
}

@@ -18,3 +18,9 @@ import { Application, Params } from '@feathersjs/feathers';

export function socket ({ done, emit, socketMap, socketKey, getParams }: SocketOptions) {
export function socket ({
done,
emit,
socketMap,
socketKey,
getParams
}: SocketOptions) {
return (app: Application) => {

@@ -43,51 +49,69 @@ const leaveChannels = (connection: RealTimeConnection) => {

// `connection` event
done.then(provider => provider.on('connection', (connection: any) =>
app.emit('connection', getParams(connection)))
done.then((provider) =>
provider.on('connection', (connection: any) =>
app.emit('connection', getParams(connection))
)
);
// `socket.emit('methodName', 'serviceName', ...args)` handlers
done.then(provider => provider.on('connection', (connection: any) => {
for (const method of app.methods) {
connection.on(method, (...args: any[]) => {
const path = args.shift();
done.then((provider) =>
provider.on('connection', (connection: any) => {
for (const method of app.methods) {
connection.on(method, (...args: any[]) => {
const [path, ...rest] = args;
debug(`Got '${method}' call for service '${path}'`);
runMethod(app, getParams(connection), path, method, args);
runMethod(app, getParams(connection), path, method, rest);
});
}
connection.on('authenticate', (...args: any[]) => {
if (app.get('defaultAuthentication')) {
debug('Got legacy authenticate event');
runMethod(
app,
getParams(connection),
app.get('defaultAuthentication'),
'create',
args
);
}
});
}
connection.on('authenticate', (...args: any[]) => {
if (app.get('defaultAuthentication')) {
debug('Got legacy authenticate event');
runMethod(app, getParams(connection), app.get('defaultAuthentication'), 'create', args);
}
});
connection.on('logout', (callback: any) => {
if (app.get('defaultAuthentication')) {
debug('Got legacy authenticate event');
runMethod(
app,
getParams(connection),
app.get('defaultAuthentication'),
'remove',
[null, {}, callback]
);
}
});
})
);
connection.on('logout', (callback: any) => {
if (app.get('defaultAuthentication')) {
debug('Got legacy authenticate event');
runMethod(app, getParams(connection), app.get('defaultAuthentication'), 'remove', [ null, {}, callback ]);
}
});
}));
// Legacy `socket.emit('serviceName::methodName', ...args)` handlers
app.mixins.push((service, path) => done.then(provider => {
provider.on('connection', (socket: any) => {
const methods = app.methods.filter(current =>
// @ts-ignore
typeof service[current] === 'function'
);
app.mixins.push((service, path) =>
done.then((provider) => {
provider.on('connection', (socket: any) => {
const methods = app.methods.filter(
(current) =>
// @ts-ignore
typeof service[current] === 'function'
);
for (const method of methods) {
const eventName = `${path}::${method}`;
for (const method of methods) {
const eventName = `${path}::${method}`;
socket.on(eventName, (...args: any[]) => {
debug(`Got legacy method call '${eventName}'`);
runMethod(app, getParams(socket), path, method, args);
});
}
});
}));
socket.on(eventName, (...args: any[]) => {
debug(`Got legacy method call '${eventName}'`);
runMethod(app, getParams(socket), path, method, args);
});
}
});
})
);
};
}

@@ -65,3 +65,5 @@ import Debug from 'debug';

export function runMethod (app: Application, connection: RealTimeConnection, path: string, method: string, args: any[]) {
export function runMethod (app: Application, connection: RealTimeConnection, _path: string, _method: string, args: any[]) {
const path = typeof _path === 'string' ? _path : null
const method = typeof _method === 'string' ? _method : null
const trace = `method '${method}' on service '${path}'`;

@@ -85,3 +87,3 @@ const methodArgs = args.slice(0);

if (lookup === null) {
return Promise.reject(new errors.NotFound(`Service '${path}' not found`));
return Promise.reject(new errors.NotFound(path === null ? 'Invalid service path' : `Service '${path}' not found`));
}

@@ -88,0 +90,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc