pusher-js
Advanced tools
Comparing version 4.3.0 to 4.3.1
# Changelog | ||
## 4.3.0 (2018-08-13) | ||
## 4.3.1 (2018-09-03) | ||
[FIXED] Honour protocol error codes received after connection succeeds | ||
## 4.3.0 (2018-08-13) | ||
[NEW] This release adds support for end to end encrypted channels, a new feature for Channels. Read more [in our docs](https://pusher.com/docs/client_api_guide/client_encrypted_channels). | ||
@@ -6,0 +10,0 @@ |
{ | ||
"name": "pusher-js", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Pusher JavaScript library for browsers, React Native, NodeJS and web workers", | ||
@@ -5,0 +5,0 @@ "main": "dist/node/pusher.js", |
@@ -456,2 +456,49 @@ var ConnectionManager = require('core/connection/connection_manager').default; | ||
}); | ||
describe("on error callback", function() { | ||
var errorHandler; | ||
beforeEach(function() { | ||
errorHandler = jasmine.createSpy(); | ||
manager.bind("error", errorHandler) | ||
}); | ||
it("should emit error and disconnect upon receipt of a refused event", function() { | ||
var error = {code: 4000}; | ||
connection.emit("refused", {error: error}); | ||
expect(manager.state).toEqual("disconnected"); | ||
expect(errorHandler).toHaveBeenCalledWith({ | ||
type: 'WebSocketError', | ||
error: error | ||
}); | ||
}); | ||
it("should emit error and reconnect upon receipt of a tls_only event", function() { | ||
var error = {code: 4000}; | ||
connection.emit("tls_only", {error: error}); | ||
jasmine.Clock.tick(1); | ||
expect(manager.state).toEqual("connecting"); | ||
expect(errorHandler).toHaveBeenCalledWith({ | ||
type: 'WebSocketError', | ||
error: error | ||
}); | ||
}); | ||
it("should emit error and reconnect with backoff upon receipt of a backoff event", function() { | ||
var error = {code: 4100}; | ||
connection.emit("backoff", {error: error}); | ||
jasmine.Clock.tick(1000); | ||
expect(manager.state).toEqual("connecting"); | ||
expect(errorHandler).toHaveBeenCalledWith({ | ||
type: 'WebSocketError', | ||
error: error | ||
}); | ||
}); | ||
it("should emit error and reconnect upon receipt of a retry event", function() { | ||
var error = {code: 4200}; | ||
connection.emit("retry", {error: error}); | ||
jasmine.Clock.tick(1); | ||
expect(manager.state).toEqual("connecting"); | ||
expect(errorHandler).toHaveBeenCalledWith({ | ||
type: 'WebSocketError', | ||
error: error | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -458,0 +505,0 @@ |
import HandshakePayload from './handshake/handshake_payload'; | ||
import Action from './protocol/action'; | ||
export interface ErrorCallbacks { | ||
tls_only: (result: HandshakePayload) => void; | ||
refused: (result: HandshakePayload) => void; | ||
backoff: (result: HandshakePayload) => void; | ||
retry: (result: HandshakePayload) => void; | ||
tls_only: (result: Action | HandshakePayload) => void; | ||
refused: (result: Action | HandshakePayload) => void; | ||
backoff: (result: Action | HandshakePayload) => void; | ||
retry: (result: Action | HandshakePayload) => void; | ||
} | ||
@@ -9,0 +10,0 @@ |
@@ -13,2 +13,3 @@ import {default as EventsDispatcher} from '../events/dispatcher'; | ||
import {ErrorCallbacks, HandshakeCallbacks, ConnectionCallbacks} from './callbacks'; | ||
import Action from './protocol/action'; | ||
@@ -68,4 +69,4 @@ /** Manages connection to Pusher. | ||
this.connectionCallbacks = this.buildConnectionCallbacks(); | ||
this.errorCallbacks = this.buildErrorCallbacks(); | ||
this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks); | ||
this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks); | ||
@@ -250,4 +251,4 @@ | ||
private buildConnectionCallbacks() : ConnectionCallbacks { | ||
return { | ||
private buildConnectionCallbacks(errorCallbacks: ErrorCallbacks) : ConnectionCallbacks { | ||
return Collections.extend<ConnectionCallbacks>({}, errorCallbacks, { | ||
message: (message)=> { | ||
@@ -274,3 +275,3 @@ // includes pong messages from server | ||
} | ||
}; | ||
}); | ||
}; | ||
@@ -296,3 +297,3 @@ | ||
let withErrorEmitted = (callback)=> { | ||
return (result)=> { | ||
return (result: Action | HandshakePayload)=> { | ||
if (result.error) { | ||
@@ -299,0 +300,0 @@ this.emit("error", { type: "WebSocketError", error: result.error }); |
@@ -154,5 +154,5 @@ import * as Collections from '../utils/collections'; | ||
if (action) { | ||
this.emit(action); | ||
this.emit(action, {action: action, error: error}); | ||
} | ||
} | ||
} |
@@ -5,10 +5,7 @@ import TransportConnection from "../../transports/transport_connection"; | ||
interface HandshakePayload { | ||
interface HandshakePayload extends Action { | ||
transport: TransportConnection; | ||
action: Action; | ||
connection?: Connection; | ||
activityTimeout?: number; | ||
error: any; | ||
} | ||
export default HandshakePayload; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1890187
47592
19