New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

laravel-echo

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

laravel-echo - npm Package Compare versions

Comparing version 1.16.1 to 1.17.0

dist/channel/null-encrypted-private-channel.d.ts

2

.github/SECURITY.md

@@ -18,3 +18,3 @@ # Security Policy

Version: OpenPGP v2.0.8
Comment: https://sela.io/pgp/
Comment: Report Security Vulnerabilities to taylor@laravel.com

@@ -21,0 +21,0 @@ xsFNBFugFSQBEACxEKhIY9IoJzcouVTIYKJfWFGvwFgbRjQWBiH3QdHId5vCrbWo

# Release Notes
## [Unreleased](https://github.com/laravel/echo/compare/v1.16.0...master)
## [Unreleased](https://github.com/laravel/echo/compare/v1.16.1...master)
## [v1.16.1](https://github.com/laravel/echo/compare/v1.16.0...v1.16.1) - 2024-04-09
* Replaced deprecated substr function by [@SuperDJ](https://github.com/SuperDJ) in https://github.com/laravel/echo/pull/395
* Throw error on unsupported broadcaster by [@SuperDJ](https://github.com/SuperDJ) in https://github.com/laravel/echo/pull/396
## [v1.16.0](https://github.com/laravel/echo/compare/v1.15.3...v1.16.0) - 2024-02-20

@@ -6,0 +11,0 @@

@@ -12,27 +12,27 @@ /**

*/
abstract listen(event: string, callback: Function): Channel;
abstract listen(event: string, callback: Function): this;
/**
* Listen for a whisper event on the channel instance.
*/
listenForWhisper(event: string, callback: Function): Channel;
listenForWhisper(event: string, callback: Function): this;
/**
* Listen for an event on the channel instance.
*/
notification(callback: Function): Channel;
notification(callback: Function): this;
/**
* Stop listening to an event on the channel instance.
*/
abstract stopListening(event: string, callback?: Function): Channel;
abstract stopListening(event: string, callback?: Function): this;
/**
* Stop listening for a whisper event on the channel instance.
*/
stopListeningForWhisper(event: string, callback?: Function): Channel;
stopListeningForWhisper(event: string, callback?: Function): this;
/**
* Register a callback to be called anytime a subscription succeeds.
*/
abstract subscribed(callback: Function): Channel;
abstract subscribed(callback: Function): this;
/**
* Register a callback to be called anytime an error occurs.
*/
abstract error(callback: Function): Channel;
abstract error(callback: Function): this;
}

@@ -12,2 +12,3 @@ export * from './channel';

export * from './null-private-channel';
export * from './null-encrypted-private-channel';
export * from './null-presence-channel';

@@ -17,23 +17,23 @@ import { Channel } from './channel';

*/
listen(event: string, callback: Function): NullChannel;
listen(event: string, callback: Function): this;
/**
* Listen for all events on the channel instance.
*/
listenToAll(callback: Function): NullChannel;
listenToAll(callback: Function): this;
/**
* Stop listening for an event on the channel instance.
*/
stopListening(event: string, callback?: Function): NullChannel;
stopListening(event: string, callback?: Function): this;
/**
* Register a callback to be called anytime a subscription succeeds.
*/
subscribed(callback: Function): NullChannel;
subscribed(callback: Function): this;
/**
* Register a callback to be called anytime an error occurs.
*/
error(callback: Function): NullChannel;
error(callback: Function): this;
/**
* Bind a channel to an event.
*/
on(event: string, callback: Function): NullChannel;
on(event: string, callback: Function): this;
}

@@ -1,2 +0,2 @@

import { NullChannel } from './null-channel';
import { NullPrivateChannel } from './null-private-channel';
import { PresenceChannel } from './presence-channel';

@@ -6,19 +6,19 @@ /**

*/
export declare class NullPresenceChannel extends NullChannel implements PresenceChannel {
export declare class NullPresenceChannel extends NullPrivateChannel implements PresenceChannel {
/**
* Register a callback to be called anytime the member list changes.
*/
here(callback: Function): NullPresenceChannel;
here(callback: Function): this;
/**
* Listen for someone joining the channel.
*/
joining(callback: Function): NullPresenceChannel;
joining(callback: Function): this;
/**
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): NullPresenceChannel;
whisper(eventName: string, data: any): this;
/**
* Listen for someone leaving the channel.
*/
leaving(callback: Function): NullPresenceChannel;
leaving(callback: Function): this;
}

@@ -9,3 +9,3 @@ import { NullChannel } from './null-channel';

*/
whisper(eventName: string, data: any): NullPrivateChannel;
whisper(eventName: string, data: any): this;
}

@@ -9,15 +9,15 @@ import { Channel } from './channel';

*/
here(callback: Function): PresenceChannel;
here(callback: Function): this;
/**
* Listen for someone joining the channel.
*/
joining(callback: Function): PresenceChannel;
joining(callback: Function): this;
/**
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): PresenceChannel;
whisper(eventName: string, data: any): this;
/**
* Listen for someone leaving the channel.
*/
leaving(callback: Function): PresenceChannel;
leaving(callback: Function): this;
}

@@ -42,27 +42,27 @@ import { EventFormatter } from '../util';

*/
listen(event: string, callback: Function): PusherChannel;
listen(event: string, callback: Function): this;
/**
* Listen for all events on the channel instance.
*/
listenToAll(callback: Function): PusherChannel;
listenToAll(callback: Function): this;
/**
* Stop listening for an event on the channel instance.
*/
stopListening(event: string, callback?: Function): PusherChannel;
stopListening(event: string, callback?: Function): this;
/**
* Stop listening for all events on the channel instance.
*/
stopListeningToAll(callback?: Function): PusherChannel;
stopListeningToAll(callback?: Function): this;
/**
* Register a callback to be called anytime a subscription succeeds.
*/
subscribed(callback: Function): PusherChannel;
subscribed(callback: Function): this;
/**
* Register a callback to be called anytime a subscription error occurs.
*/
error(callback: Function): PusherChannel;
error(callback: Function): this;
/**
* Bind a channel to an event.
*/
on(event: string, callback: Function): PusherChannel;
on(event: string, callback: Function): this;
}

@@ -9,3 +9,3 @@ import { PusherChannel } from './pusher-channel';

*/
whisper(eventName: string, data: any): PusherEncryptedPrivateChannel;
whisper(eventName: string, data: any): this;
}

@@ -1,23 +0,23 @@

import { PusherChannel } from './pusher-channel';
import { PresenceChannel } from './presence-channel';
import { PusherPrivateChannel } from './pusher-private-channel';
/**
* This class represents a Pusher presence channel.
*/
export declare class PusherPresenceChannel extends PusherChannel implements PresenceChannel {
export declare class PusherPresenceChannel extends PusherPrivateChannel implements PresenceChannel {
/**
* Register a callback to be called anytime the member list changes.
*/
here(callback: Function): PusherPresenceChannel;
here(callback: Function): this;
/**
* Listen for someone joining the channel.
*/
joining(callback: Function): PusherPresenceChannel;
joining(callback: Function): this;
/**
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): PusherPresenceChannel;
whisper(eventName: string, data: any): this;
/**
* Listen for someone leaving the channel.
*/
leaving(callback: Function): PusherPresenceChannel;
leaving(callback: Function): this;
}

@@ -9,3 +9,3 @@ import { PusherChannel } from './pusher-channel';

*/
whisper(eventName: string, data: any): PusherPrivateChannel;
whisper(eventName: string, data: any): this;
}

@@ -46,19 +46,19 @@ import { EventFormatter } from '../util';

*/
listen(event: string, callback: Function): SocketIoChannel;
listen(event: string, callback: Function): this;
/**
* Stop listening for an event on the channel instance.
*/
stopListening(event: string, callback?: Function): SocketIoChannel;
stopListening(event: string, callback?: Function): this;
/**
* Register a callback to be called anytime a subscription succeeds.
*/
subscribed(callback: Function): SocketIoChannel;
subscribed(callback: Function): this;
/**
* Register a callback to be called anytime an error occurs.
*/
error(callback: Function): SocketIoChannel;
error(callback: Function): this;
/**
* Bind the channel's socket to an event and store the callback.
*/
on(event: string, callback: Function): SocketIoChannel;
on(event: string, callback: Function): this;
/**

@@ -65,0 +65,0 @@ * Unbind the channel's socket from all stored event callbacks.

@@ -10,15 +10,15 @@ import { PresenceChannel } from './presence-channel';

*/
here(callback: Function): SocketIoPresenceChannel;
here(callback: Function): this;
/**
* Listen for someone joining the channel.
*/
joining(callback: Function): SocketIoPresenceChannel;
joining(callback: Function): this;
/**
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): SocketIoPresenceChannel;
whisper(eventName: string, data: any): this;
/**
* Listen for someone leaving the channel.
*/
leaving(callback: Function): SocketIoPresenceChannel;
leaving(callback: Function): this;
}

@@ -9,3 +9,3 @@ import { SocketIoChannel } from './socketio-channel';

*/
whisper(eventName: string, data: any): SocketIoChannel;
whisper(eventName: string, data: any): this;
}

@@ -1,3 +0,3 @@

import { Channel, PresenceChannel } from './../channel';
export declare abstract class Connector {
import { Channel, PresenceChannel } from '../channel';
export declare abstract class Connector<TPublic extends Channel, TPrivate extends Channel, TPresence extends PresenceChannel> {
/**

@@ -30,11 +30,11 @@ * Default connector options.

*/
abstract channel(channel: string): Channel;
abstract channel(channel: string): TPublic;
/**
* Get a private channel instance by name.
*/
abstract privateChannel(channel: string): Channel;
abstract privateChannel(channel: string): TPrivate;
/**
* Get a presence channel instance by name.
*/
abstract presenceChannel(channel: string): PresenceChannel;
abstract presenceChannel(channel: string): TPresence;
/**

@@ -41,0 +41,0 @@ * Leave the given channel, as well as its private and presence variants.

import { Connector } from './connector';
import { NullChannel, NullPrivateChannel, PresenceChannel } from './../channel';
import { NullChannel, NullPrivateChannel, NullPresenceChannel, NullEncryptedPrivateChannel } from './../channel';
/**
* This class creates a null connector.
*/
export declare class NullConnector extends Connector {
export declare class NullConnector extends Connector<NullChannel, NullPrivateChannel, NullPresenceChannel> {
/**

@@ -30,7 +30,7 @@ * All of the subscribed channel names.

*/
encryptedPrivateChannel(name: string): NullPrivateChannel;
encryptedPrivateChannel(name: string): NullEncryptedPrivateChannel;
/**
* Get a presence channel instance by name.
*/
presenceChannel(name: string): PresenceChannel;
presenceChannel(name: string): NullPresenceChannel;
/**

@@ -37,0 +37,0 @@ * Leave the given channel, as well as its private and presence variants.

import { Connector } from './connector';
import { PusherChannel, PresenceChannel } from './../channel';
import { PusherChannel, PusherPrivateChannel, PusherEncryptedPrivateChannel, PusherPresenceChannel } from './../channel';
declare type AnyPusherChannel = PusherChannel | PusherPrivateChannel | PusherEncryptedPrivateChannel | PusherPresenceChannel;
/**
* This class creates a connector to Pusher.
*/
export declare class PusherConnector extends Connector {
export declare class PusherConnector extends Connector<PusherChannel, PusherPrivateChannel, PusherPresenceChannel> {
/**

@@ -26,19 +27,19 @@ * The Pusher instance.

*/
listen(name: string, event: string, callback: Function): PusherChannel;
listen(name: string, event: string, callback: Function): AnyPusherChannel;
/**
* Get a channel instance by name.
*/
channel(name: string): PusherChannel;
channel(name: string): AnyPusherChannel;
/**
* Get a private channel instance by name.
*/
privateChannel(name: string): PusherChannel;
privateChannel(name: string): PusherPrivateChannel;
/**
* Get a private encrypted channel instance by name.
*/
encryptedPrivateChannel(name: string): PusherChannel;
encryptedPrivateChannel(name: string): PusherEncryptedPrivateChannel;
/**
* Get a presence channel instance by name.
*/
presenceChannel(name: string): PresenceChannel;
presenceChannel(name: string): PusherPresenceChannel;
/**

@@ -61,1 +62,2 @@ * Leave the given channel, as well as its private and presence variants.

}
export {};
import { Connector } from './connector';
import { SocketIoChannel, SocketIoPrivateChannel, SocketIoPresenceChannel } from './../channel';
declare type AnySocketIoChannel = SocketIoChannel | SocketIoPrivateChannel | SocketIoPresenceChannel;
/**
* This class creates a connnector to a Socket.io server.
*/
export declare class SocketIoConnector extends Connector {
export declare class SocketIoConnector extends Connector<SocketIoChannel, SocketIoPrivateChannel, SocketIoPresenceChannel> {
/**

@@ -28,7 +29,7 @@ * The Socket.io connection instance.

*/
listen(name: string, event: string, callback: Function): SocketIoChannel;
listen(name: string, event: string, callback: Function): AnySocketIoChannel;
/**
* Get a channel instance by name.
*/
channel(name: string): SocketIoChannel;
channel(name: string): AnySocketIoChannel;
/**

@@ -59,1 +60,2 @@ * Get a private channel instance by name.

}
export {};

@@ -434,4 +434,4 @@ 'use strict';

var PusherPresenceChannel = /*#__PURE__*/function (_PusherChannel) {
_inherits(PusherPresenceChannel, _PusherChannel);
var PusherPresenceChannel = /*#__PURE__*/function (_PusherPrivateChannel) {
_inherits(PusherPresenceChannel, _PusherPrivateChannel);

@@ -497,3 +497,3 @@ var _super = _createSuper(PusherPresenceChannel);

return PusherPresenceChannel;
}(PusherChannel);
}(PusherPrivateChannel);

@@ -898,7 +898,36 @@ /**

/**
* This class represents a null private channel.
*/
var NullEncryptedPrivateChannel = /*#__PURE__*/function (_NullChannel) {
_inherits(NullEncryptedPrivateChannel, _NullChannel);
var _super = _createSuper(NullEncryptedPrivateChannel);
function NullEncryptedPrivateChannel() {
_classCallCheck(this, NullEncryptedPrivateChannel);
return _super.apply(this, arguments);
}
_createClass(NullEncryptedPrivateChannel, [{
key: "whisper",
value:
/**
* Send a whisper event to other clients in the channel.
*/
function whisper(eventName, data) {
return this;
}
}]);
return NullEncryptedPrivateChannel;
}(NullChannel);
/**
* This class represents a null presence channel.
*/
var NullPresenceChannel = /*#__PURE__*/function (_NullChannel) {
_inherits(NullPresenceChannel, _NullChannel);
var NullPresenceChannel = /*#__PURE__*/function (_NullPrivateChannel) {
_inherits(NullPresenceChannel, _NullPrivateChannel);

@@ -952,3 +981,3 @@ var _super = _createSuper(NullPresenceChannel);

return NullPresenceChannel;
}(NullChannel);
}(NullPrivateChannel);

@@ -1410,3 +1439,3 @@ var Connector = /*#__PURE__*/function () {

value: function encryptedPrivateChannel(name) {
return new NullPrivateChannel();
return new NullEncryptedPrivateChannel();
}

@@ -1506,3 +1535,3 @@ /**

} else if (typeof this.options.broadcaster == 'function') {
this.connector = new this.options.broadcaster(this.options);
this.connector = this.options.broadcaster(this.options);
} else {

@@ -1584,2 +1613,6 @@ throw new Error("Broadcaster ".concat(_typeof(this.options.broadcaster), " ").concat(this.options.broadcaster, " is not supported."));

value: function encryptedPrivate(channel) {
if (this.connector instanceof SocketIoConnector) {
throw new Error("Broadcaster ".concat(_typeof(this.options.broadcaster), " ").concat(this.options.broadcaster, " does not support encrypted private channels."));
}
return this.connector.encryptedPrivateChannel(channel);

@@ -1586,0 +1619,0 @@ }

@@ -1,23 +0,23 @@

import { Channel, PresenceChannel } from './channel';
import { Connector } from './connector';
import { Channel, NullChannel, NullEncryptedPrivateChannel, NullPresenceChannel, NullPrivateChannel, PresenceChannel, PusherChannel, PusherEncryptedPrivateChannel, PusherPresenceChannel, PusherPrivateChannel, SocketIoChannel, SocketIoPresenceChannel, SocketIoPrivateChannel } from './channel';
import { Connector, PusherConnector, SocketIoConnector, NullConnector } from './connector';
/**
* This class is the primary API for interacting with broadcasting.
*/
export default class Echo {
export default class Echo<T extends keyof Broadcaster> {
/**
* The broadcasting connector.
*/
connector: any;
connector: Broadcaster[T]['connector'];
/**
* The Echo options.
*/
options: any;
options: EchoOptions<T>;
/**
* Create a new class instance.
*/
constructor(options: any);
constructor(options: EchoOptions<T>);
/**
* Get a channel instance by name.
*/
channel(channel: string): Channel;
channel(channel: string): Broadcaster[T]['public'];
/**

@@ -34,3 +34,3 @@ * Create a new connection.

*/
join(channel: string): PresenceChannel;
join(channel: string): Broadcaster[T]['presence'];
/**

@@ -51,11 +51,11 @@ * Leave the given channel, as well as its private and presence variants.

*/
listen(channel: string, event: string, callback: Function): Channel;
listen(channel: string, event: string, callback: Function): Broadcaster[T]['public'];
/**
* Get a private channel instance by name.
*/
private(channel: string): Channel;
private(channel: string): Broadcaster[T]['private'];
/**
* Get a private encrypted channel instance by name.
*/
encryptedPrivate(channel: string): Channel;
encryptedPrivate(channel: string): Broadcaster[T]['encrypted'];
/**

@@ -92,1 +92,48 @@ * Get the Socket ID for the connection.

export { EventFormatter } from './util';
/**
* Specifies the broadcaster
*/
declare type Broadcaster = {
reverb: {
connector: PusherConnector;
public: PusherChannel;
private: PusherPrivateChannel;
encrypted: PusherEncryptedPrivateChannel;
presence: PusherPresenceChannel;
};
pusher: {
connector: PusherConnector;
public: PusherChannel;
private: PusherPrivateChannel;
encrypted: PusherEncryptedPrivateChannel;
presence: PusherPresenceChannel;
};
'socket.io': {
connector: SocketIoConnector;
public: SocketIoChannel;
private: SocketIoPrivateChannel;
encrypted: never;
presence: SocketIoPresenceChannel;
};
null: {
connector: NullConnector;
public: NullChannel;
private: NullPrivateChannel;
encrypted: NullEncryptedPrivateChannel;
presence: NullPresenceChannel;
};
function: {
connector: any;
public: any;
private: any;
encrypted: any;
presence: any;
};
};
declare type EchoOptions<T extends keyof Broadcaster> = {
/**
* The broadcast connector.
*/
broadcaster: T extends 'function' ? (options: EchoOptions<T>) => any : T;
[key: string]: any;
};

@@ -433,4 +433,4 @@ var Echo = (function () {

var PusherPresenceChannel = /*#__PURE__*/function (_PusherChannel) {
_inherits(PusherPresenceChannel, _PusherChannel);
var PusherPresenceChannel = /*#__PURE__*/function (_PusherPrivateChannel) {
_inherits(PusherPresenceChannel, _PusherPrivateChannel);

@@ -496,3 +496,3 @@ var _super = _createSuper(PusherPresenceChannel);

return PusherPresenceChannel;
}(PusherChannel);
}(PusherPrivateChannel);

@@ -897,7 +897,36 @@ /**

/**
* This class represents a null private channel.
*/
var NullEncryptedPrivateChannel = /*#__PURE__*/function (_NullChannel) {
_inherits(NullEncryptedPrivateChannel, _NullChannel);
var _super = _createSuper(NullEncryptedPrivateChannel);
function NullEncryptedPrivateChannel() {
_classCallCheck(this, NullEncryptedPrivateChannel);
return _super.apply(this, arguments);
}
_createClass(NullEncryptedPrivateChannel, [{
key: "whisper",
value:
/**
* Send a whisper event to other clients in the channel.
*/
function whisper(eventName, data) {
return this;
}
}]);
return NullEncryptedPrivateChannel;
}(NullChannel);
/**
* This class represents a null presence channel.
*/
var NullPresenceChannel = /*#__PURE__*/function (_NullChannel) {
_inherits(NullPresenceChannel, _NullChannel);
var NullPresenceChannel = /*#__PURE__*/function (_NullPrivateChannel) {
_inherits(NullPresenceChannel, _NullPrivateChannel);

@@ -951,3 +980,3 @@ var _super = _createSuper(NullPresenceChannel);

return NullPresenceChannel;
}(NullChannel);
}(NullPrivateChannel);

@@ -1409,3 +1438,3 @@ var Connector = /*#__PURE__*/function () {

value: function encryptedPrivateChannel(name) {
return new NullPrivateChannel();
return new NullEncryptedPrivateChannel();
}

@@ -1505,3 +1534,3 @@ /**

} else if (typeof this.options.broadcaster == 'function') {
this.connector = new this.options.broadcaster(this.options);
this.connector = this.options.broadcaster(this.options);
} else {

@@ -1583,2 +1612,6 @@ throw new Error("Broadcaster ".concat(_typeof(this.options.broadcaster), " ").concat(this.options.broadcaster, " is not supported."));

value: function encryptedPrivate(channel) {
if (this.connector instanceof SocketIoConnector) {
throw new Error("Broadcaster ".concat(_typeof(this.options.broadcaster), " ").concat(this.options.broadcaster, " does not support encrypted private channels."));
}
return this.connector.encryptedPrivateChannel(channel);

@@ -1585,0 +1618,0 @@ }

@@ -430,4 +430,4 @@ function _typeof(obj) {

var PusherPresenceChannel = /*#__PURE__*/function (_PusherChannel) {
_inherits(PusherPresenceChannel, _PusherChannel);
var PusherPresenceChannel = /*#__PURE__*/function (_PusherPrivateChannel) {
_inherits(PusherPresenceChannel, _PusherPrivateChannel);

@@ -493,3 +493,3 @@ var _super = _createSuper(PusherPresenceChannel);

return PusherPresenceChannel;
}(PusherChannel);
}(PusherPrivateChannel);

@@ -894,7 +894,36 @@ /**

/**
* This class represents a null private channel.
*/
var NullEncryptedPrivateChannel = /*#__PURE__*/function (_NullChannel) {
_inherits(NullEncryptedPrivateChannel, _NullChannel);
var _super = _createSuper(NullEncryptedPrivateChannel);
function NullEncryptedPrivateChannel() {
_classCallCheck(this, NullEncryptedPrivateChannel);
return _super.apply(this, arguments);
}
_createClass(NullEncryptedPrivateChannel, [{
key: "whisper",
value:
/**
* Send a whisper event to other clients in the channel.
*/
function whisper(eventName, data) {
return this;
}
}]);
return NullEncryptedPrivateChannel;
}(NullChannel);
/**
* This class represents a null presence channel.
*/
var NullPresenceChannel = /*#__PURE__*/function (_NullChannel) {
_inherits(NullPresenceChannel, _NullChannel);
var NullPresenceChannel = /*#__PURE__*/function (_NullPrivateChannel) {
_inherits(NullPresenceChannel, _NullPrivateChannel);

@@ -948,3 +977,3 @@ var _super = _createSuper(NullPresenceChannel);

return NullPresenceChannel;
}(NullChannel);
}(NullPrivateChannel);

@@ -1406,3 +1435,3 @@ var Connector = /*#__PURE__*/function () {

value: function encryptedPrivateChannel(name) {
return new NullPrivateChannel();
return new NullEncryptedPrivateChannel();
}

@@ -1502,3 +1531,3 @@ /**

} else if (typeof this.options.broadcaster == 'function') {
this.connector = new this.options.broadcaster(this.options);
this.connector = this.options.broadcaster(this.options);
} else {

@@ -1580,2 +1609,6 @@ throw new Error("Broadcaster ".concat(_typeof(this.options.broadcaster), " ").concat(this.options.broadcaster, " is not supported."));

value: function encryptedPrivate(channel) {
if (this.connector instanceof SocketIoConnector) {
throw new Error("Broadcaster ".concat(_typeof(this.options.broadcaster), " ").concat(this.options.broadcaster, " does not support encrypted private channels."));
}
return this.connector.encryptedPrivateChannel(channel);

@@ -1582,0 +1615,0 @@ }

{
"name": "laravel-echo",
"version": "1.16.1",
"version": "1.17.0",
"description": "Laravel Echo library for beautiful Pusher and Socket.IO integration",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,2 +0,2 @@

<p align="center"><img src="/art/logo.svg" alt="Logo Laravel Echo"></p>
<p align="center"><img width="301" height="80" src="/art/logo.svg" alt="Logo Laravel Echo"></p>

@@ -3,0 +3,0 @@ <p align="center">

@@ -13,3 +13,3 @@ /**

*/
abstract listen(event: string, callback: Function): Channel;
abstract listen(event: string, callback: Function): this;

@@ -19,3 +19,3 @@ /**

*/
listenForWhisper(event: string, callback: Function): Channel {
listenForWhisper(event: string, callback: Function): this {
return this.listen('.client-' + event, callback);

@@ -27,3 +27,3 @@ }

*/
notification(callback: Function): Channel {
notification(callback: Function): this {
return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);

@@ -35,3 +35,3 @@ }

*/
abstract stopListening(event: string, callback?: Function): Channel;
abstract stopListening(event: string, callback?: Function): this;

@@ -41,3 +41,3 @@ /**

*/
stopListeningForWhisper(event: string, callback?: Function): Channel {
stopListeningForWhisper(event: string, callback?: Function): this {
return this.stopListening('.client-' + event, callback);

@@ -49,3 +49,3 @@ }

*/
abstract subscribed(callback: Function): Channel;
abstract subscribed(callback: Function): this;

@@ -55,3 +55,3 @@ /**

*/
abstract error(callback: Function): Channel;
abstract error(callback: Function): this;
}

@@ -12,2 +12,3 @@ export * from './channel';

export * from './null-private-channel';
export * from './null-encrypted-private-channel';
export * from './null-presence-channel';

@@ -24,3 +24,3 @@ import { Channel } from './channel';

*/
listen(event: string, callback: Function): NullChannel {
listen(event: string, callback: Function): this {
return this;

@@ -32,3 +32,3 @@ }

*/
listenToAll(callback: Function): NullChannel {
listenToAll(callback: Function): this {
return this;

@@ -40,3 +40,3 @@ }

*/
stopListening(event: string, callback?: Function): NullChannel {
stopListening(event: string, callback?: Function): this {
return this;

@@ -48,3 +48,3 @@ }

*/
subscribed(callback: Function): NullChannel {
subscribed(callback: Function): this {
return this;

@@ -56,3 +56,3 @@ }

*/
error(callback: Function): NullChannel {
error(callback: Function): this {
return this;

@@ -64,5 +64,5 @@ }

*/
on(event: string, callback: Function): NullChannel {
on(event: string, callback: Function): this {
return this;
}
}

@@ -1,2 +0,2 @@

import { NullChannel } from './null-channel';
import { NullPrivateChannel } from './null-private-channel';
import { PresenceChannel } from './presence-channel';

@@ -7,7 +7,7 @@

*/
export class NullPresenceChannel extends NullChannel implements PresenceChannel {
export class NullPresenceChannel extends NullPrivateChannel implements PresenceChannel {
/**
* Register a callback to be called anytime the member list changes.
*/
here(callback: Function): NullPresenceChannel {
here(callback: Function): this {
return this;

@@ -19,3 +19,3 @@ }

*/
joining(callback: Function): NullPresenceChannel {
joining(callback: Function): this {
return this;

@@ -27,3 +27,3 @@ }

*/
whisper(eventName: string, data: any): NullPresenceChannel {
whisper(eventName: string, data: any): this {
return this;

@@ -35,5 +35,5 @@ }

*/
leaving(callback: Function): NullPresenceChannel {
leaving(callback: Function): this {
return this;
}
}

@@ -10,5 +10,5 @@ import { NullChannel } from './null-channel';

*/
whisper(eventName: string, data: any): NullPrivateChannel {
whisper(eventName: string, data: any): this {
return this;
}
}

@@ -10,3 +10,3 @@ import { Channel } from './channel';

*/
here(callback: Function): PresenceChannel;
here(callback: Function): this;

@@ -16,3 +16,3 @@ /**

*/
joining(callback: Function): PresenceChannel;
joining(callback: Function): this;

@@ -22,3 +22,3 @@ /**

*/
whisper(eventName: string, data: any): PresenceChannel;
whisper(eventName: string, data: any): this;

@@ -28,3 +28,3 @@ /**

*/
leaving(callback: Function): PresenceChannel;
leaving(callback: Function): this;
}

@@ -64,3 +64,3 @@ import { EventFormatter } from '../util';

*/
listen(event: string, callback: Function): PusherChannel {
listen(event: string, callback: Function): this {
this.on(this.eventFormatter.format(event), callback);

@@ -74,3 +74,3 @@

*/
listenToAll(callback: Function): PusherChannel {
listenToAll(callback: Function): this {
this.subscription.bind_global((event, data) => {

@@ -94,3 +94,3 @@ if (event.startsWith('pusher:')) {

*/
stopListening(event: string, callback?: Function): PusherChannel {
stopListening(event: string, callback?: Function): this {
if (callback) {

@@ -108,3 +108,3 @@ this.subscription.unbind(this.eventFormatter.format(event), callback);

*/
stopListeningToAll(callback?: Function): PusherChannel {
stopListeningToAll(callback?: Function): this {
if (callback) {

@@ -122,3 +122,3 @@ this.subscription.unbind_global(callback);

*/
subscribed(callback: Function): PusherChannel {
subscribed(callback: Function): this {
this.on('pusher:subscription_succeeded', () => {

@@ -134,3 +134,3 @@ callback();

*/
error(callback: Function): PusherChannel {
error(callback: Function): this {
this.on('pusher:subscription_error', (status) => {

@@ -146,3 +146,3 @@ callback(status);

*/
on(event: string, callback: Function): PusherChannel {
on(event: string, callback: Function): this {
this.subscription.bind(event, callback);

@@ -149,0 +149,0 @@

@@ -10,3 +10,3 @@ import { PusherChannel } from './pusher-channel';

*/
whisper(eventName: string, data: any): PusherEncryptedPrivateChannel {
whisper(eventName: string, data: any): this {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);

@@ -13,0 +13,0 @@

@@ -1,3 +0,3 @@

import { PusherChannel } from './pusher-channel';
import { PresenceChannel } from './presence-channel';
import { PusherPrivateChannel } from './pusher-private-channel';

@@ -7,7 +7,7 @@ /**

*/
export class PusherPresenceChannel extends PusherChannel implements PresenceChannel {
export class PusherPresenceChannel extends PusherPrivateChannel implements PresenceChannel {
/**
* Register a callback to be called anytime the member list changes.
*/
here(callback: Function): PusherPresenceChannel {
here(callback: Function): this {
this.on('pusher:subscription_succeeded', (data) => {

@@ -23,3 +23,3 @@ callback(Object.keys(data.members).map((k) => data.members[k]));

*/
joining(callback: Function): PusherPresenceChannel {
joining(callback: Function): this {
this.on('pusher:member_added', (member) => {

@@ -35,3 +35,3 @@ callback(member.info);

*/
whisper(eventName: string, data: any): PusherPresenceChannel {
whisper(eventName: string, data: any): this {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);

@@ -45,3 +45,3 @@

*/
leaving(callback: Function): PusherPresenceChannel {
leaving(callback: Function): this {
this.on('pusher:member_removed', (member) => {

@@ -48,0 +48,0 @@ callback(member.info);

@@ -10,3 +10,3 @@ import { PusherChannel } from './pusher-channel';

*/
whisper(eventName: string, data: any): PusherPrivateChannel {
whisper(eventName: string, data: any): this {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);

@@ -13,0 +13,0 @@

@@ -77,3 +77,3 @@ import { EventFormatter } from '../util';

*/
listen(event: string, callback: Function): SocketIoChannel {
listen(event: string, callback: Function): this {
this.on(this.eventFormatter.format(event), callback);

@@ -87,3 +87,3 @@

*/
stopListening(event: string, callback?: Function): SocketIoChannel {
stopListening(event: string, callback?: Function): this {
this.unbindEvent(this.eventFormatter.format(event), callback);

@@ -97,3 +97,3 @@

*/
subscribed(callback: Function): SocketIoChannel {
subscribed(callback: Function): this {
this.on('connect', (socket) => {

@@ -109,3 +109,3 @@ callback(socket);

*/
error(callback: Function): SocketIoChannel {
error(callback: Function): this {
return this;

@@ -117,3 +117,3 @@ }

*/
on(event: string, callback: Function): SocketIoChannel {
on(event: string, callback: Function): this {
this.listeners[event] = this.listeners[event] || [];

@@ -120,0 +120,0 @@

@@ -11,3 +11,3 @@ import { PresenceChannel } from './presence-channel';

*/
here(callback: Function): SocketIoPresenceChannel {
here(callback: Function): this {
this.on('presence:subscribed', (members: any[]) => {

@@ -23,3 +23,3 @@ callback(members.map((m) => m.user_info));

*/
joining(callback: Function): SocketIoPresenceChannel {
joining(callback: Function): this {
this.on('presence:joining', (member) => callback(member.user_info));

@@ -33,3 +33,3 @@

*/
whisper(eventName: string, data: any): SocketIoPresenceChannel {
whisper(eventName: string, data: any): this {
this.socket.emit('client event', {

@@ -47,3 +47,3 @@ channel: this.name,

*/
leaving(callback: Function): SocketIoPresenceChannel {
leaving(callback: Function): this {
this.on('presence:leaving', (member) => callback(member.user_info));

@@ -50,0 +50,0 @@

@@ -10,3 +10,3 @@ import { SocketIoChannel } from './socketio-channel';

*/
whisper(eventName: string, data: any): SocketIoChannel {
whisper(eventName: string, data: any): this {
this.socket.emit('client event', {

@@ -13,0 +13,0 @@ channel: this.name,

@@ -1,4 +0,4 @@

import { Channel, PresenceChannel } from './../channel';
import { Channel, PresenceChannel } from '../channel';
export abstract class Connector {
export abstract class Connector<TPublic extends Channel, TPrivate extends Channel, TPresence extends PresenceChannel> {
/**

@@ -89,3 +89,3 @@ * Default connector options.

*/
abstract channel(channel: string): Channel;
abstract channel(channel: string): TPublic;

@@ -95,3 +95,3 @@ /**

*/
abstract privateChannel(channel: string): Channel;
abstract privateChannel(channel: string): TPrivate;

@@ -101,3 +101,3 @@ /**

*/
abstract presenceChannel(channel: string): PresenceChannel;
abstract presenceChannel(channel: string): TPresence;

@@ -104,0 +104,0 @@ /**

import { Connector } from './connector';
import { NullChannel, NullPrivateChannel, NullPresenceChannel, PresenceChannel } from './../channel';
import { NullChannel, NullPrivateChannel, NullPresenceChannel, NullEncryptedPrivateChannel } from './../channel';

@@ -7,3 +7,3 @@ /**

*/
export class NullConnector extends Connector {
export class NullConnector extends Connector<NullChannel, NullPrivateChannel, NullPresenceChannel> {
/**

@@ -45,4 +45,4 @@ * All of the subscribed channel names.

*/
encryptedPrivateChannel(name: string): NullPrivateChannel {
return new NullPrivateChannel();
encryptedPrivateChannel(name: string): NullEncryptedPrivateChannel {
return new NullEncryptedPrivateChannel();
}

@@ -53,3 +53,3 @@

*/
presenceChannel(name: string): PresenceChannel {
presenceChannel(name: string): NullPresenceChannel {
return new NullPresenceChannel();

@@ -56,0 +56,0 @@ }

@@ -7,9 +7,10 @@ import { Connector } from './connector';

PusherPresenceChannel,
PresenceChannel,
} from './../channel';
type AnyPusherChannel = PusherChannel | PusherPrivateChannel | PusherEncryptedPrivateChannel | PusherPresenceChannel;
/**
* This class creates a connector to Pusher.
*/
export class PusherConnector extends Connector {
export class PusherConnector extends Connector<PusherChannel, PusherPrivateChannel, PusherPresenceChannel> {
/**

@@ -48,3 +49,3 @@ * The Pusher instance.

*/
listen(name: string, event: string, callback: Function): PusherChannel {
listen(name: string, event: string, callback: Function): AnyPusherChannel {
return this.channel(name).listen(event, callback);

@@ -56,3 +57,3 @@ }

*/
channel(name: string): PusherChannel {
channel(name: string): AnyPusherChannel {
if (!this.channels[name]) {

@@ -68,3 +69,3 @@ this.channels[name] = new PusherChannel(this.pusher, name, this.options);

*/
privateChannel(name: string): PusherChannel {
privateChannel(name: string): PusherPrivateChannel {
if (!this.channels['private-' + name]) {

@@ -80,3 +81,3 @@ this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);

*/
encryptedPrivateChannel(name: string): PusherChannel {
encryptedPrivateChannel(name: string): PusherEncryptedPrivateChannel {
if (!this.channels['private-encrypted-' + name]) {

@@ -96,3 +97,3 @@ this.channels['private-encrypted-' + name] = new PusherEncryptedPrivateChannel(

*/
presenceChannel(name: string): PresenceChannel {
presenceChannel(name: string): PusherPresenceChannel {
if (!this.channels['presence-' + name]) {

@@ -99,0 +100,0 @@ this.channels['presence-' + name] = new PusherPresenceChannel(

import { Connector } from './connector';
import { SocketIoChannel, SocketIoPrivateChannel, SocketIoPresenceChannel } from './../channel';
type AnySocketIoChannel = SocketIoChannel | SocketIoPrivateChannel | SocketIoPresenceChannel;
/**
* This class creates a connnector to a Socket.io server.
*/
export class SocketIoConnector extends Connector {
export class SocketIoConnector extends Connector<SocketIoChannel, SocketIoPrivateChannel, SocketIoPresenceChannel> {
/**

@@ -53,3 +55,3 @@ * The Socket.io connection instance.

*/
listen(name: string, event: string, callback: Function): SocketIoChannel {
listen(name: string, event: string, callback: Function): AnySocketIoChannel {
return this.channel(name).listen(event, callback);

@@ -61,3 +63,3 @@ }

*/
channel(name: string): SocketIoChannel {
channel(name: string): AnySocketIoChannel {
if (!this.channels[name]) {

@@ -64,0 +66,0 @@ this.channels[name] = new SocketIoChannel(this.socket, name, this.options);

@@ -1,2 +0,16 @@

import { Channel, PresenceChannel } from './channel';
import {
Channel,
NullChannel,
NullEncryptedPrivateChannel,
NullPresenceChannel,
NullPrivateChannel,
PresenceChannel,
PusherChannel,
PusherEncryptedPrivateChannel,
PusherPresenceChannel,
PusherPrivateChannel,
SocketIoChannel,
SocketIoPresenceChannel,
SocketIoPrivateChannel,
} from './channel';
import { Connector, PusherConnector, SocketIoConnector, NullConnector } from './connector';

@@ -7,7 +21,7 @@

*/
export default class Echo {
export default class Echo<T extends keyof Broadcaster> {
/**
* The broadcasting connector.
*/
connector: any;
connector: Broadcaster[T]['connector'];

@@ -17,3 +31,3 @@ /**

*/
options: any;
options: EchoOptions<T>;

@@ -23,3 +37,3 @@ /**

*/
constructor(options: any) {
constructor(options: EchoOptions<T>) {
this.options = options;

@@ -36,3 +50,3 @@ this.connect();

*/
channel(channel: string): Channel {
channel(channel: string): Broadcaster[T]['public'] {
return this.connector.channel(channel);

@@ -54,3 +68,3 @@ }

} else if (typeof this.options.broadcaster == 'function') {
this.connector = new this.options.broadcaster(this.options);
this.connector = this.options.broadcaster(this.options as EchoOptions<'function'>);
} else {

@@ -73,3 +87,3 @@ throw new Error(

*/
join(channel: string): PresenceChannel {
join(channel: string): Broadcaster[T]['presence'] {
return this.connector.presenceChannel(channel);

@@ -104,3 +118,3 @@ }

*/
listen(channel: string, event: string, callback: Function): Channel {
listen(channel: string, event: string, callback: Function): Broadcaster[T]['public'] {
return this.connector.listen(channel, event, callback);

@@ -112,3 +126,3 @@ }

*/
private(channel: string): Channel {
private(channel: string): Broadcaster[T]['private'] {
return this.connector.privateChannel(channel);

@@ -120,3 +134,11 @@ }

*/
encryptedPrivate(channel: string): Channel {
encryptedPrivate(channel: string): Broadcaster[T]['encrypted'] {
if ((this.connector as any) instanceof SocketIoConnector) {
throw new Error(
`Broadcaster ${typeof this.options.broadcaster} ${
this.options.broadcaster
} does not support encrypted private channels.`
);
}
return this.connector.encryptedPrivateChannel(channel);

@@ -209,1 +231,51 @@ }

export { EventFormatter } from './util';
/**
* Specifies the broadcaster
*/
type Broadcaster = {
reverb: {
connector: PusherConnector;
public: PusherChannel;
private: PusherPrivateChannel;
encrypted: PusherEncryptedPrivateChannel;
presence: PusherPresenceChannel;
};
pusher: {
connector: PusherConnector;
public: PusherChannel;
private: PusherPrivateChannel;
encrypted: PusherEncryptedPrivateChannel;
presence: PusherPresenceChannel;
};
'socket.io': {
connector: SocketIoConnector;
public: SocketIoChannel;
private: SocketIoPrivateChannel;
encrypted: never;
presence: SocketIoPresenceChannel;
};
null: {
connector: NullConnector;
public: NullChannel;
private: NullPrivateChannel;
encrypted: NullEncryptedPrivateChannel;
presence: NullPresenceChannel;
};
function: {
connector: any;
public: any;
private: any;
encrypted: any;
presence: any;
};
};
type EchoOptions<T extends keyof Broadcaster> = {
/**
* The broadcast connector.
*/
broadcaster: T extends 'function' ? (options: EchoOptions<T>) => any : T;
[key: string]: any;
};

@@ -24,4 +24,6 @@ import Echo from '../src/echo';

test('it will throw error for unsupported driver', () => {
// eslint-disable-next-line
// @ts-ignore
expect(() => new Echo({ broadcaster: 'foo' })).toThrowError('Broadcaster string foo is not supported.');
});
});

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