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

peerjs

Package Overview
Dependencies
Maintainers
3
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peerjs - npm Package Compare versions

Comparing version 1.5.0-rc.1 to 1.5.0

68

dist/types.d.ts

@@ -168,2 +168,10 @@ import * as BinaryPack from "peerjs-js-binarypack";

}
export enum BaseConnectionErrorType {
NegotiationFailed = "negotiation-failed",
ConnectionClosed = "connection-closed"
}
export enum DataConnectionErrorType {
NotOpenYet = "not-open-yet",
MessageToBig = "message-too-big"
}
export enum SerializationType {

@@ -209,4 +217,26 @@ Binary = "binary",

}
type BaseConnectionEvents = {
interface EventsWithError<ErrorType extends string> {
error: (error: PeerError<`${ErrorType}`>) => void;
}
declare class EventEmitterWithError<ErrorType extends string, Events extends EventsWithError<ErrorType>> extends EventEmitter<Events, never> {
/**
* Emits a typed error message.
*
* @internal
*/
emitError(type: ErrorType, err: string | Error): void;
}
/**
* A PeerError is emitted whenever an error occurs.
* It always has a `.type`, which can be used to identify the error.
*/
export class PeerError<T extends string> extends Error {
/**
* @internal
*/
constructor(type: T, err: Error | string);
type: T;
}
interface BaseConnectionEvents<ErrorType extends string = BaseConnectionErrorType> extends EventsWithError<ErrorType> {
/**
* Emitted when either you or the remote peer closes the connection.

@@ -224,6 +254,6 @@ *

*/
error: (error: Error) => void;
error: (error: PeerError<`${ErrorType}`>) => void;
iceStateChanged: (state: RTCIceConnectionState) => void;
};
declare abstract class BaseConnection<T extends ValidEventTypes> extends EventEmitter<T & BaseConnectionEvents> {
}
declare abstract class BaseConnection<SubClassEvents extends ValidEventTypes, ErrorType extends string = never> extends EventEmitterWithError<ErrorType | BaseConnectionErrorType, SubClassEvents & BaseConnectionEvents<BaseConnectionErrorType | ErrorType>> {
/**

@@ -270,3 +300,3 @@ * The ID of the peer on the other end of this connection.

}
type DataConnectionEvents = {
interface DataConnectionEvents extends EventsWithError<DataConnectionErrorType | BaseConnectionErrorType>, BaseConnectionEvents<DataConnectionErrorType | BaseConnectionErrorType> {
/**

@@ -280,7 +310,7 @@ * Emitted when data is received from the remote peer.

open: () => void;
};
}
/**
* Wraps a DataChannel between two Peers.
*/
export abstract class DataConnection extends BaseConnection<DataConnectionEvents> implements DataConnection {
export abstract class DataConnection extends BaseConnection<DataConnectionEvents, DataConnectionErrorType> {
protected static readonly ID_PREFIX = "dc_";

@@ -354,3 +384,3 @@ protected static readonly MAX_BUFFERED_AMOUNT: number;

}
type MediaConnectionEvents = {
interface MediaConnectionEvents extends BaseConnectionEvents<never> {
/**

@@ -370,3 +400,3 @@ * Emitted when a connection to the PeerServer is established.

willCloseOnRemote: () => void;
};
}
/**

@@ -464,10 +494,6 @@ * Wraps WebRTC's media streams.

}
export class PeerError extends Error {
constructor(type: PeerErrorType, err: Error | string);
type: PeerErrorType;
export interface SerializerMapping {
[key: string]: new (peerId: string, provider: Peer, options: any) => DataConnection;
}
export type SerializerMapping = {
[key: string]: new (peerId: string, provider: Peer, options: any) => DataConnection;
};
export type PeerEvents = {
export interface PeerEvents {
/**

@@ -500,8 +526,8 @@ * Emitted when a connection to the PeerServer is established.

*/
error: (error: PeerError) => void;
};
error: (error: PeerError<`${PeerErrorType}`>) => void;
}
/**
* A peer who can initiate connections with other peers.
*/
export class Peer extends EventEmitter<PeerEvents> {
export class Peer extends EventEmitterWithError<PeerErrorType, PeerEvents> {
protected readonly _serializers: SerializerMapping;

@@ -562,3 +588,3 @@ /**

*/
connect(peer: string, options: PeerConnectOption): DataConnection;
connect(peer: string, options?: PeerConnectOption): DataConnection;
/**

@@ -574,4 +600,2 @@ * Calls the remote peer specified by id and returns a media connection.

getConnection(peerId: string, connectionId: string): null | DataConnection | MediaConnection;
/** Emits a typed error message. */
emitError(type: PeerErrorType, err: string | Error): void;
/**

@@ -578,0 +602,0 @@ * Destroys the Peer: closes all active connections as well as the connection

{
"name": "peerjs",
"version": "1.5.0-rc.1",
"version": "1.5.0",
"keywords": [

@@ -212,3 +212,3 @@ "peerjs",

"prettier": "^3.0.0",
"semantic-release": "^20.0.0",
"semantic-release": "^21.0.0",
"ts-node": "^10.9.1",

@@ -215,0 +215,0 @@ "typescript": "^5.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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