Comparing version 5.1.1 to 6.0.0
# Changelog | ||
## 6.0.0 (2020-04-27) | ||
[CHANGED] The default builds for web and worker no longer support encrypted | ||
channels. To use encrypted channels in web/worker you must import | ||
`pusher-js/with-encryption` or use the | ||
`pusher-with-encryption.js`/`pusher-with-encryption.min.js` bundles | ||
[CHANGED] `forceTLS` now defaults to `true` | ||
[REMOVED] the `encrypted` option - this was deprecated in `4.3.0`. The library | ||
defaults to TLS anyway. Setting `encrypted` to `false` will **NOT** change | ||
behaviour | ||
[FIXED] `activityTimeout` and `pongTimeout` options now work as described in | ||
the docs. | ||
[NEW] Typescript declarations for react-native | ||
[NEW] Support for encrypted-channels in react-native and workers | ||
## 5.1.1 (2020-02-12) | ||
@@ -4,0 +24,0 @@ |
{ | ||
"name": "pusher-js", | ||
"version": "5.1.1", | ||
"version": "6.0.0", | ||
"description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers", | ||
@@ -34,2 +34,5 @@ "main": "dist/node/pusher.js", | ||
"@react-native-community/netinfo": "^4.1.1", | ||
"@stablelib/base64": "^1.0.0", | ||
"@stablelib/utf8": "^1.0.0", | ||
"buffer": "^5.6.0", | ||
"faye-websocket": "^0.9.4", | ||
@@ -54,4 +57,3 @@ "fetch-mock": "git+https://git@github.com/jpatel531/fetch-mock.git", | ||
"ts-loader": "^6.0.4", | ||
"tweetnacl": "^1.0.2", | ||
"tweetnacl-util": "^0.15.1", | ||
"tweetnacl": "^1.0.3", | ||
"typescript": "^3.4.5", | ||
@@ -58,0 +60,0 @@ "uglify-js": "^2.6.2", |
@@ -58,2 +58,13 @@ # Pusher Channels Javascript Client | ||
#### Encrypted Channel Support | ||
The encryption primitives required to power [encrypted | ||
channels](https://github.com/pusher/pusher-js#encrypted-channels) increase the | ||
bundle size quite significantly. In order to keep bundle sizes down, the | ||
default web and worker builds of pusher-js no longer support [encrypted | ||
channels](https://github.com/pusher/pusher-js#encrypted-channels). | ||
If you'd like to make use of encrypted-channels, you need to import the | ||
`with-encryption` builds as described below. | ||
#### Yarn (or NPM) | ||
@@ -73,2 +84,8 @@ | ||
If you'd like to use encrypted channels: | ||
```javascript | ||
import Pusher from 'pusher-js/with-encryption'; | ||
``` | ||
Or, if you're not using ES6 modules: | ||
@@ -80,8 +97,20 @@ | ||
If you'd like to use encrypted channels: | ||
```javascript | ||
const Pusher = require('pusher-js/with-encryption'); | ||
``` | ||
#### CDN | ||
```html | ||
<script src="https://js.pusher.com/5.1/pusher.min.js"></script> | ||
<script src="https://js.pusher.com/6.0/pusher.min.js"></script> | ||
``` | ||
If you'd like to use encrypted channels: | ||
```html | ||
<script src="https://js.pusher.com/6.0/pusher-with-encryption.min.js"></script> | ||
``` | ||
You can also use [cdnjs.com](https://cdnjs.com/libraries/pusher) if you prefer | ||
@@ -149,5 +178,11 @@ or as a fallback. | ||
```javascript | ||
importScripts('https://js.pusher.com/5.1/pusher.worker.min.js'); | ||
importScripts('https://js.pusher.com/6.0/pusher.worker.min.js'); | ||
``` | ||
If you'd like to use encrypted channels: | ||
```javascript | ||
importScripts('https://js.pusher.com/6.0/pusher-with-encryption.worker.min.js'); | ||
``` | ||
### Node.js | ||
@@ -183,4 +218,3 @@ | ||
cluster: APP_CLUSTER, | ||
authEndpoint: 'http://example.com/pusher/auth', | ||
forceTLS: true | ||
authEndpoint: 'http://example.com/pusher/auth' | ||
}); | ||
@@ -193,3 +227,3 @@ ``` | ||
Forces the connection to use TLS. | ||
Forces the connection to use TLS. When set to `false` the library will attempt non-TLS connections first. Defaults to `true`. | ||
@@ -575,13 +609,13 @@ #### `authEndpoint` (String) | ||
First, make sure you expose all files from the `dist` directory. They need to be in a directory with named after the version number. For example, if you're hosting version 5.1.0 under `http://example.com/pusher-js` (and https for SSL), files should be accessible under following URL's: | ||
First, make sure you expose all files from the `dist` directory. They need to be in a directory with named after the version number. For example, if you're hosting version 6.0.0 under `http://example.com/pusher-js` (and https for SSL), files should be accessible under following URL's: | ||
http://example.com/pusher-js/5.1.0/pusher.js | ||
http://example.com/pusher-js/5.1.0/json2.js | ||
http://example.com/pusher-js/5.1.0/sockjs.js | ||
http://example.com/pusher-js/6.0.0/pusher.js | ||
http://example.com/pusher-js/6.0.0/json2.js | ||
http://example.com/pusher-js/6.0.0/sockjs.js | ||
Minified files should have `.min` in their names, as in the `dist/web` directory: | ||
http://example.com/pusher-js/5.1.0/pusher.min.js | ||
http://example.com/pusher-js/5.1.0/json2.min.js | ||
http://example.com/pusher-js/5.1.0/sockjs.min.js | ||
http://example.com/pusher-js/6.0.0/pusher.min.js | ||
http://example.com/pusher-js/6.0.0/json2.min.js | ||
http://example.com/pusher-js/6.0.0/sockjs.min.js | ||
@@ -588,0 +622,0 @@ ## SockJS compatibility |
@@ -24,3 +24,3 @@ var objectAssign = require('object-assign-deep'); | ||
alias: { | ||
pusher_integration: 'core/index', | ||
pusher_integration: 'core/pusher.js', | ||
integration: 'node/integration', | ||
@@ -27,0 +27,0 @@ 'dom/dependencies': 'node/mock-dom-dependencies', |
@@ -13,3 +13,3 @@ var objectAssign = require('object-assign-deep'); | ||
config.webpack.resolve.alias = { | ||
pusher_integration: 'core', | ||
pusher_integration: 'core/pusher', | ||
integration: 'node/integration' | ||
@@ -16,0 +16,0 @@ } |
@@ -104,4 +104,4 @@ var TestEnv = require('testenv'); | ||
var _VERSION; | ||
var _channel_auth_transport; | ||
var _channel_auth_endpoint; | ||
var _authTransport; | ||
var _authEndpoint; | ||
var _Dependencies; | ||
@@ -112,9 +112,9 @@ | ||
_VERSION = Defaults.VERSION; | ||
_channel_auth_transport = Defaults.channel_auth_transport; | ||
_channel_auth_endpoint = Defaults.channel_auth_endpoint; | ||
_authTransport = Defaults.authTransport; | ||
_authEndpoint = Defaults.authEndpoint; | ||
_Dependencies = Dependencies; | ||
Defaults.VERSION = "8.8.8"; | ||
Defaults.channel_auth_transport = ""; | ||
Defaults.channel_auth_endpoint = ""; | ||
Defaults.authTransport = ""; | ||
Defaults.authEndpoint = ""; | ||
@@ -121,0 +121,0 @@ if (TestEnv === "web") { |
@@ -29,4 +29,4 @@ var Pusher = require('pusher_integration'); | ||
var _VERSION; | ||
var _channel_auth_transport; | ||
var _channel_auth_endpoint; | ||
var _authTransport; | ||
var _authEndpoint; | ||
var _Dependencies; | ||
@@ -37,9 +37,9 @@ | ||
_VERSION = Defaults.VERSION; | ||
_channel_auth_transport = Defaults.channel_auth_transport; | ||
_channel_auth_endpoint = Defaults.channel_auth_endpoint; | ||
_authTransport = Defaults.authTransport; | ||
_authEndpoint = Defaults.authEndpoint; | ||
_Dependencies = Dependencies; | ||
Defaults.VERSION = "8.8.8"; | ||
Defaults.channel_auth_transport = (TestEnv === 'web') ? 'jsonp' : 'ajax'; | ||
Defaults.channel_auth_endpoint = Integration.API_URL + "/auth"; | ||
Defaults.authTransport = (TestEnv === 'web') ? 'jsonp' : 'ajax'; | ||
Defaults.authEndpoint = Integration.API_URL + "/auth"; | ||
@@ -64,4 +64,4 @@ if (TestEnv === "web") { | ||
Dependencies = _Dependencies; | ||
Defaults.channel_auth_endpoint = _channel_auth_endpoint; | ||
Defaults.channel_auth_transport = _channel_auth_transport; | ||
Defaults.authEndpoint = _authEndpoint; | ||
Defaults.authTransport = _authTransport; | ||
Defaults.VERSION = _VERSION; | ||
@@ -68,0 +68,0 @@ }); |
@@ -52,3 +52,3 @@ var Pusher = require('pusher_integration'); | ||
jasmine.Clock.tick(Defaults.unavailable_timeout - 1); | ||
jasmine.Clock.tick(Defaults.unavailableTimeout - 1); | ||
expect(onUnavailable).not.toHaveBeenCalled(); | ||
@@ -62,3 +62,3 @@ jasmine.Clock.tick(1); | ||
pusher = new Pusher("foobar", { unavailable_timeout: 2345 }); | ||
pusher = new Pusher("foobar", { unavailableTimeout: 2345 }); | ||
pusher.connect(); | ||
@@ -99,3 +99,3 @@ pusher.connection.bind("unavailable", onUnavailable); | ||
jasmine.Clock.tick(Defaults.pong_timeout - 1); | ||
jasmine.Clock.tick(Defaults.pongTimeout - 1); | ||
expect(firstTransport.close).not.toHaveBeenCalled(); | ||
@@ -108,4 +108,4 @@ jasmine.Clock.tick(1); | ||
pusher = new Pusher("foobar", { | ||
activity_timeout: 16000, | ||
pong_timeout: 2222 | ||
activityTimeout: 16000, | ||
pongTimeout: 2222 | ||
}); | ||
@@ -139,4 +139,4 @@ pusher.connect(); | ||
pusher = new Pusher("foobar", { | ||
activity_timeout: 15555, | ||
pong_timeout: 2222 | ||
activityTimeout: 15555, | ||
pongTimeout: 2222 | ||
}); | ||
@@ -170,3 +170,3 @@ pusher.connect(); | ||
pusher = new Pusher("foobar", { | ||
pong_timeout: 2222 | ||
pongTimeout: 2222 | ||
}); | ||
@@ -173,0 +173,0 @@ pusher.connect(); |
@@ -5,2 +5,3 @@ var Channels = require('core/channels/channels').default; | ||
var PresenceChannel = require('core/channels/presence_channel').default; | ||
var EncryptedChannel = require('core/channels/encrypted_channel').default; | ||
var Factory = require('core/utils/factory').default; | ||
@@ -31,12 +32,24 @@ var Mocks = require("mocks"); | ||
it("should create a regular channel when name doesn't have known prefix", function() { | ||
expect(channels.add("test")).toEqual(jasmine.any(Channel)); | ||
expect(channels.add("test", {})).toEqual(jasmine.any(Channel)); | ||
}); | ||
it("should create a private channel when name starts with 'private-'", function() { | ||
expect(channels.add("private-test")).toEqual(jasmine.any(PrivateChannel)); | ||
expect(channels.add("private-test", {})).toEqual(jasmine.any(PrivateChannel)); | ||
}); | ||
it("should create a presence channel when name starts with 'presence-'", function() { | ||
expect(channels.add("presence-test")).toEqual(jasmine.any(PresenceChannel)); | ||
expect(channels.add("presence-test", {})).toEqual(jasmine.any(PresenceChannel)); | ||
}); | ||
describe("Subscribing to channel with name starting 'private-encrypted-'", function() { | ||
it("should create an encrypted channel when nacl is available", function() { | ||
var pusher = Mocks.getPusher({ nacl: {} }) | ||
expect(channels.add("private-encrypted-test", pusher)) | ||
.toEqual(jasmine.any(EncryptedChannel)); | ||
}); | ||
it("should throw an error if nacl is not available", function() { | ||
var pusher = Mocks.getPusher({}) | ||
var fn = () => channels.add("private-encrypted-test", pusher) | ||
expect(fn).toThrow(); | ||
}); | ||
}) | ||
}); | ||
@@ -43,0 +56,0 @@ |
@@ -6,4 +6,5 @@ const Errors = require("core/errors"); | ||
const Mocks = require("mocks"); | ||
const tweetNacl = require("tweetnacl"); | ||
const tweetNaclUtil = require("tweetnacl-util"); | ||
const nacl = require("tweetnacl"); | ||
const utf8 = require("@stablelib/utf8"); | ||
const base64 = require("@stablelib/base64"); | ||
@@ -16,11 +17,11 @@ describe("EncryptedChannel", function() { | ||
const secretUTF8 = "It Must Be Thirty Two Characters"; | ||
const secretBytes = tweetNaclUtil.decodeUTF8(secretUTF8); | ||
const secretBase64 = tweetNaclUtil.encodeBase64(secretBytes); | ||
const secretBytes = utf8.encode(secretUTF8); | ||
const secretBase64 = base64.encode(secretBytes); | ||
const nonceUTF8 = "aaaaaaaaaaaaaaaaaaaaaaaa"; | ||
const nonceBytes = tweetNaclUtil.decodeUTF8(nonceUTF8); | ||
const nonceBase64 = tweetNaclUtil.encodeBase64(nonceBytes); | ||
const nonceBytes = utf8.encode(nonceUTF8); | ||
const nonceBase64 = base64.encode(nonceBytes); | ||
const testEncrypt = function(payload) { | ||
let payloadBytes = tweetNaclUtil.decodeUTF8(JSON.stringify(payload)); | ||
let bytes = tweetNacl.secretbox(payloadBytes, nonceBytes, secretBytes); | ||
return tweetNaclUtil.encodeBase64(bytes); | ||
let payloadBytes = utf8.encode(JSON.stringify(payload)); | ||
let bytes = nacl.secretbox(payloadBytes, nonceBytes, secretBytes); | ||
return base64.encode(bytes); | ||
}; | ||
@@ -30,3 +31,3 @@ | ||
pusher = Mocks.getPusher({ foo: "bar" }); | ||
channel = new EncryptedChannel("private-encrypted-test", pusher); | ||
channel = new EncryptedChannel("private-encrypted-test", pusher, nacl); | ||
authorizer = Mocks.getAuthorizer(); | ||
@@ -89,3 +90,3 @@ factorySpy = spyOn(Factory, "createAuthorizer").andReturn(authorizer); | ||
}); | ||
channel = new EncryptedChannel("private-test-custom-auth", pusher); | ||
channel = new EncryptedChannel("private-test-custom-auth", pusher, nacl); | ||
factorySpy.andCallThrough(); | ||
@@ -257,8 +258,8 @@ }); | ||
const newSecretUTF8 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | ||
const newSecretBytes = tweetNaclUtil.decodeUTF8(newSecretUTF8); | ||
const newSecretBase64 = tweetNaclUtil.encodeBase64(newSecretBytes); | ||
const newSecretBytes = utf8.encode(newSecretUTF8); | ||
const newSecretBase64 = base64.encode(newSecretBytes); | ||
const newTestEncrypt = function(payload) { | ||
let payloadBytes = tweetNaclUtil.decodeUTF8(JSON.stringify(payload)); | ||
let bytes = tweetNacl.secretbox(payloadBytes, nonceBytes, newSecretBytes); | ||
return tweetNaclUtil.encodeBase64(bytes); | ||
let payloadBytes = utf8.encode(JSON.stringify(payload)); | ||
let bytes = nacl.secretbox(payloadBytes, nonceBytes, newSecretBytes); | ||
return base64.encode(bytes); | ||
}; | ||
@@ -294,3 +295,3 @@ | ||
nonce: nonceBase64, | ||
ciphertext: tweetNaclUtil.encodeBase64('garbage-ciphertext') | ||
ciphertext: base64.encode('garbage-ciphertext') | ||
}; | ||
@@ -297,0 +298,0 @@ spyOn(Logger, "error"); |
@@ -24,3 +24,4 @@ var ConnectionManager = require('core/connection/connection_manager').default; | ||
pongTimeout: 2345, | ||
unavailableTimeout: 1234 | ||
unavailableTimeout: 1234, | ||
useTLS: false, | ||
}; | ||
@@ -51,3 +52,3 @@ manager = new ConnectionManager("foo", managerOptions); | ||
unavailableTimeout: 1234 | ||
}); | ||
}, {}); | ||
expect(getStrategy).toHaveBeenCalled(); | ||
@@ -68,3 +69,4 @@ }); | ||
var manager = new ConnectionManager( | ||
"foo", Collections.extend(managerOptions, { useTLS: true }) | ||
"foo", | ||
Object.assign({}, managerOptions, { useTLS: true }) | ||
); | ||
@@ -71,0 +73,0 @@ expect(manager.isUsingTLS()).toEqual(true); |
var WSTransport = require('runtime').default.Transports.ws; | ||
var StrategyBuilder = require('core/strategies/strategy_builder'); | ||
var Runtime = require('runtime').default; | ||
var DefaultConfig = require('core/config'); | ||
var Config = require('core/config'); | ||
@@ -13,3 +13,7 @@ describe("Default", function() { | ||
} | ||
var strategy = Runtime.getDefaultStrategy(DefaultConfig.getGlobalConfig(), StrategyBuilder.defineTransport); | ||
var strategy = Runtime.getDefaultStrategy( | ||
Config.getConfig({}), | ||
{}, | ||
StrategyBuilder.defineTransport, | ||
); | ||
expect(strategy.isSupported()).toBe(true); | ||
@@ -16,0 +20,0 @@ }); |
@@ -35,12 +35,11 @@ var TestEnv = require('testenv'); | ||
spyOn(Runtime, "getDefaultStrategy").andCallFake(function(options) { | ||
var strategy = Mocks.getStrategy(true); | ||
strategy.options = options; | ||
return strategy; | ||
spyOn(Runtime, "getDefaultStrategy").andCallFake(function() { | ||
return Mocks.getStrategy(true); | ||
}); | ||
spyOn(Factory, "createConnectionManager").andCallFake(function(key, options) { | ||
spyOn(Factory, "createConnectionManager").andCallFake(function(key, options, config) { | ||
var manager = Mocks.getConnectionManager(); | ||
manager.key = key; | ||
manager.options = options; | ||
manager.config = config; | ||
return manager; | ||
@@ -114,3 +113,3 @@ }); | ||
var pusher = new Pusher("foo"); | ||
expect(pusher.timeline.options.cluster).toBe(undefined); | ||
expect(pusher.timeline.options.cluster).toBe(Defaults.cluster); | ||
@@ -150,8 +149,8 @@ pusher = new Pusher("foo", { cluster: "spec" }); | ||
it("should be off by default", function() { | ||
expect(pusher.shouldUseTLS()).toBe(false); | ||
expect(pusher.shouldUseTLS()).toBe(true); | ||
}); | ||
it("should be on when 'forceTLS' parameter is passed", function() { | ||
var pusher = new Pusher("foo", { forceTLS: true }); | ||
expect(pusher.shouldUseTLS()).toBe(true); | ||
it("should be off when 'forceTLS' parameter is passed", function() { | ||
var pusher = new Pusher("foo", { forceTLS: false }); | ||
expect(pusher.shouldUseTLS()).toBe(false); | ||
}); | ||
@@ -166,2 +165,3 @@ | ||
}); | ||
var pusher = new Pusher("foo", { forceTLS: false }); | ||
expect(pusher.shouldUseTLS()).toBe(true); | ||
@@ -179,25 +179,14 @@ }); | ||
it("should pass per-connection strategy options", function() { | ||
pusher = new Pusher("foo", { forceTLS: true }); | ||
it("should pass config and options to the strategy builder", function() { | ||
var config = DefaultConfig.getConfig({}); | ||
var options = { useTLS: true } | ||
var expectedConfig = Collections.extend( | ||
DefaultConfig.getGlobalConfig(), | ||
{ forceTLS: true } | ||
); | ||
var getStrategy = pusher.connection.options.getStrategy; | ||
expect(getStrategy().options).toEqual(expectedConfig); | ||
getStrategy(options) | ||
expect(Runtime.getDefaultStrategy).toHaveBeenCalledWith( | ||
pusher.config, | ||
options, | ||
jasmine.any(Function), | ||
) | ||
}); | ||
it("should pass options to the strategy builder", function() { | ||
var expectedConfig = Collections.extend( | ||
DefaultConfig.getGlobalConfig(), | ||
{ useTLS: true } | ||
); | ||
var getStrategy = pusher.connection.options.getStrategy; | ||
expect(getStrategy({ useTLS: true }).options).toEqual( | ||
expectedConfig | ||
); | ||
}); | ||
}); | ||
@@ -215,5 +204,5 @@ | ||
expect(options.activityTimeout).toEqual(Defaults.activity_timeout); | ||
expect(options.pongTimeout).toEqual(Defaults.pong_timeout); | ||
expect(options.unavailableTimeout).toEqual(Defaults.unavailable_timeout); | ||
expect(options.activityTimeout).toEqual(Defaults.activityTimeout); | ||
expect(options.pongTimeout).toEqual(Defaults.pongTimeout); | ||
expect(options.unavailableTimeout).toEqual(Defaults.unavailableTimeout); | ||
}); | ||
@@ -233,24 +222,2 @@ | ||
}); | ||
it("should not use TLS by default", function() { | ||
var pusher = new Pusher("foo"); | ||
expect(pusher.connection.options.useTLS).toBe(false); | ||
}); | ||
it("should use TLS when specified in Pusher constructor", function() { | ||
var pusher = new Pusher("foo", { forceTLS: true }); | ||
expect(pusher.connection.options.useTLS).toBe(true); | ||
}); | ||
if (TestEnv === "web") { | ||
it("should use TLS when using HTTPS", function() { | ||
Runtime.getDocument.andReturn({ | ||
location: { | ||
protocol: "https:" | ||
} | ||
}); | ||
var pusher = new Pusher("foo", { forceTLS: true }); | ||
expect(pusher.connection.options.useTLS).toBe(true); | ||
}); | ||
} | ||
}); | ||
@@ -257,0 +224,0 @@ }); |
@@ -49,3 +49,3 @@ var TestEnv = require('testenv'); | ||
it("should connect to ws://ws.pusherapp.com:80 by default", function() { | ||
it("should connect to wss://ws-mt1.pusher.com:443 by default", function() { | ||
pusher = new Pusher("foobar"); | ||
@@ -55,30 +55,30 @@ pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"ws://ws.pusherapp.com:80/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"wss://ws-mt1.pusher.com:443/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
}); | ||
it("should connect to wss://ws.pusherapp.com:443 by default when forcing TLS", function() { | ||
pusher = new Pusher("foobar", { forceTLS: true }); | ||
it("should connect to ws://ws-mt1.pusher.com:80 by default when forceTLS disabled", function() { | ||
pusher = new Pusher("foobar", { forceTLS: false }); | ||
pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"wss://ws.pusherapp.com:443/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"ws://ws-mt1.pusher.com:80/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
}); | ||
it("should connect using wsHost and wsPort when specified in options", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.com", wsPort: 1999 }); | ||
it("should connect using wsHost and wssPort when specified in options", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.com", wssPort: 1999 }); | ||
pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"ws://example.com:1999/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"wss://example.com:1999/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
}); | ||
it("should connect using wsHost and wssPort when specified in options and forcing TLS", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.org", wssPort: 4444, forceTLS: true }); | ||
it("should connect using wsHost and wsPort when specified in options and forceTLS disabled", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.org", wsPort: 4444, forceTLS: false }); | ||
pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"wss://example.org:4444/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"ws://example.org:4444/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
@@ -85,0 +85,0 @@ }); |
@@ -7,4 +7,2 @@ var TestEnv = require('testenv'); | ||
var version = Defaults.VERSION; | ||
var cdn_http = Defaults.cdn_http; | ||
var cdn_https = Defaults.cdn_https; | ||
var dependency_suffix = Defaults.dependency_suffix; | ||
@@ -45,3 +43,3 @@ var Runtime = require('runtime').default; | ||
it("should connect to ws://ws.pusherapp.com:80 by default", function() { | ||
it("should connect to wss://ws-mt1.pusher.com:443 by default", function() { | ||
pusher = new Pusher("foobar"); | ||
@@ -51,30 +49,30 @@ pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"ws://ws.pusherapp.com:80/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"wss://ws-mt1.pusher.com:443/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
}); | ||
it("should connect to wss://ws.pusherapp.com:443 by default when forcing TLS", function() { | ||
pusher = new Pusher("foobar", { forceTLS: true }); | ||
it("should connect to ws://ws-mt1.pusher.com:80 by default when forceTLS disabled", function() { | ||
pusher = new Pusher("foobar", { forceTLS: false }); | ||
pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"wss://ws.pusherapp.com:443/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"ws://ws-mt1.pusher.com:80/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
}); | ||
it("should connect using wsHost and wsPort when specified in options", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.com", wsPort: 1999 }); | ||
it("should connect using wsHost and wssPort when specified in options", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.com", wssPort: 1999 }); | ||
pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"ws://example.com:1999/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"wss://example.com:1999/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
}); | ||
it("should connect using wsHost and wssPort when specified in options and forcing TLS", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.org", wssPort: 4444, forceTLS: true }); | ||
it("should connect using wsHost and wsPort when specified in options and forceTLS disabled", function() { | ||
pusher = new Pusher("foobar", { wsHost: "example.org", wsPort: 4444, forceTLS: false }); | ||
pusher.connect(); | ||
expect(Runtime.createWebSocket).toHaveBeenCalledWith( | ||
"wss://example.org:4444/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
"ws://example.org:4444/app/foobar?protocol=7&client=js&version="+version+"&flash=false" | ||
); | ||
@@ -81,0 +79,0 @@ }); |
@@ -58,3 +58,3 @@ var Runtime = require('runtime').default; | ||
it("should connect to http://sockjs.pusher.com:80 by default", function() { | ||
it("should connect to https://sockjs.pusher.com:443 by default", function() { | ||
pusher = new Pusher("foobar"); | ||
@@ -64,5 +64,5 @@ pusher.connect(); | ||
expect(window.SockJS).toHaveBeenCalledWith( | ||
"http://sockjs.pusher.com:80/pusher", | ||
"https://sockjs.pusher.com:443/pusher", | ||
null, | ||
{ js_path: cdn_http + '/' + version + '/sockjs'+dependency_suffix+'.js', | ||
{ js_path: cdn_https + '/' + version + '/sockjs'+dependency_suffix+'.js', | ||
ignore_null_origin: undefined | ||
@@ -73,10 +73,10 @@ } | ||
it("should connect to https://sockjs.pusher.com:443 by default when forcing TLS", function() { | ||
pusher = new Pusher("foobar", { forceTLS: true }); | ||
it("should connect to http://sockjs.pusher.com:80 by default when forceTLS disabled", function() { | ||
pusher = new Pusher("foobar", { forceTLS: false }); | ||
pusher.connect(); | ||
expect(window.SockJS).toHaveBeenCalledWith( | ||
"https://sockjs.pusher.com:443/pusher", | ||
"http://sockjs.pusher.com:80/pusher", | ||
null, | ||
{ js_path: cdn_https+'/'+version +'/sockjs'+dependency_suffix+'.js', | ||
{ js_path: cdn_http+'/'+version +'/sockjs'+dependency_suffix+'.js', | ||
ignore_null_origin: undefined | ||
@@ -87,10 +87,10 @@ } | ||
it("should connect using httpHost and httpPort when specified in options", function() { | ||
pusher = new Pusher("foobar", { httpHost: "example.com", httpPort: 1999 }); | ||
it("should connect using httpHost and httpsPort when specified in options", function() { | ||
pusher = new Pusher("foobar", { httpHost: "example.com", httpsPort: 1999 }); | ||
pusher.connect(); | ||
expect(window.SockJS).toHaveBeenCalledWith( | ||
"http://example.com:1999/pusher", | ||
"https://example.com:1999/pusher", | ||
null, | ||
{ js_path: cdn_http + '/' + version + '/sockjs'+dependency_suffix+'.js', | ||
{ js_path: cdn_https + '/' + version + '/sockjs'+dependency_suffix+'.js', | ||
ignore_null_origin: undefined | ||
@@ -101,10 +101,10 @@ } | ||
it("should connect using httpHost and httpsPort when specified in options and forcing TLS", function() { | ||
pusher = new Pusher("foobar", { httpHost: "example.org", httpsPort: 4444, forceTLS: true }); | ||
it("should connect using httpHost and httpPort when specified in options and forceTLS disabled", function() { | ||
pusher = new Pusher("foobar", { httpHost: "example.org", httpPort: 4444, forceTLS: false }); | ||
pusher.connect(); | ||
expect(window.SockJS).toHaveBeenCalledWith( | ||
"https://example.org:4444/pusher", | ||
"http://example.org:4444/pusher", | ||
null, | ||
{ js_path: cdn_https+'/'+version +'/sockjs'+dependency_suffix+'.js', | ||
{ js_path: cdn_http+'/'+version +'/sockjs'+dependency_suffix+'.js', | ||
ignore_null_origin: undefined | ||
@@ -120,5 +120,5 @@ } | ||
expect(window.SockJS).toHaveBeenCalledWith( | ||
"http://sockjs.pusher.com:80/test", | ||
"https://sockjs.pusher.com:443/test", | ||
null, | ||
{ js_path: cdn_http + '/' + version + '/sockjs'+dependency_suffix+'.js', | ||
{ js_path: cdn_https + '/' + version + '/sockjs'+dependency_suffix+'.js', | ||
ignore_null_origin: undefined | ||
@@ -125,0 +125,0 @@ } |
import Channel from '../channels/channel'; | ||
export interface AuthOptions { | ||
params: any; | ||
headers: any; | ||
params?: any; | ||
headers?: any; | ||
} | ||
@@ -27,4 +27,4 @@ | ||
authTransport: 'ajax' | 'jsonp'; | ||
auth: AuthOptions; | ||
authorizer: AuthorizerGenerator; | ||
auth?: AuthOptions; | ||
authorizer?: AuthorizerGenerator; | ||
} |
@@ -32,3 +32,3 @@ import Logger from '../logger'; | ||
this.options = options; | ||
this.authOptions = (options || <any>{}).auth || {}; | ||
this.authOptions = options.auth || {}; | ||
} | ||
@@ -35,0 +35,0 @@ |
@@ -8,2 +8,4 @@ import Channel from './channel'; | ||
import * as Errors from '../errors'; | ||
import urlStore from '../utils/url_store'; | ||
/** Handles a channel map. */ | ||
@@ -67,9 +69,9 @@ export default class Channels { | ||
if (name.indexOf('private-encrypted-') === 0) { | ||
// We don't currently support e2e on React Native due to missing functionality. | ||
// This prevents any weirdness by just returning a private channel instead. | ||
if (RUNTIME === 'react-native') { | ||
let errorMsg = `Encrypted channels are not yet supported when using React Native builds.`; | ||
throw new Errors.UnsupportedFeature(errorMsg); | ||
if (pusher.config.nacl) { | ||
return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl); | ||
} | ||
return Factory.createEncryptedChannel(name, pusher); | ||
let errMsg = | ||
'Tried to subscribe to a private-encrypted- channel but no nacl implementation available'; | ||
let suffix = urlStore.buildLogSuffix('encryptedChannelSupport'); | ||
throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`); | ||
} else if (name.indexOf('private-') === 0) { | ||
@@ -76,0 +78,0 @@ return Factory.createPrivateChannel(name, pusher); |
import PrivateChannel from './private_channel'; | ||
import * as Errors from '../errors'; | ||
import Logger from '../logger'; | ||
import { secretbox } from 'tweetnacl'; | ||
import { encodeUTF8, decodeBase64 } from 'tweetnacl-util'; | ||
import Pusher from '../pusher'; | ||
import { decode as encodeUTF8 } from '@stablelib/utf8'; | ||
import { decode as decodeBase64 } from '@stablelib/base64'; | ||
import Dispatcher from '../events/dispatcher'; | ||
import { PusherEvent } from '../connection/protocol/message-types'; | ||
import { AuthorizerCallback } from '../auth/options'; | ||
import * as nacl from 'tweetnacl'; | ||
@@ -17,3 +19,9 @@ /** Extends private channels to provide encrypted channel interface. | ||
key: Uint8Array = null; | ||
nacl: nacl; | ||
constructor(name: string, pusher: Pusher, nacl: nacl) { | ||
super(name, pusher); | ||
this.nacl = nacl; | ||
} | ||
/** Authorizes the connection to use the channel. | ||
@@ -80,5 +88,5 @@ * | ||
let cipherText = decodeBase64(data.ciphertext); | ||
if (cipherText.length < secretbox.overheadLength) { | ||
if (cipherText.length < this.nacl.secretbox.overheadLength) { | ||
Logger.error( | ||
`Expected encrypted event ciphertext length to be ${secretbox.overheadLength}, got: ${cipherText.length}` | ||
`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}` | ||
); | ||
@@ -88,5 +96,5 @@ return; | ||
let nonce = decodeBase64(data.nonce); | ||
if (nonce.length < secretbox.nonceLength) { | ||
if (nonce.length < this.nacl.secretbox.nonceLength) { | ||
Logger.error( | ||
`Expected encrypted event nonce length to be ${secretbox.nonceLength}, got: ${nonce.length}` | ||
`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}` | ||
); | ||
@@ -96,3 +104,3 @@ return; | ||
let bytes = secretbox.open(cipherText, nonce, this.key); | ||
let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key); | ||
if (bytes === null) { | ||
@@ -111,3 +119,3 @@ Logger.debug( | ||
} | ||
bytes = secretbox.open(cipherText, nonce, this.key); | ||
bytes = this.nacl.secretbox.open(cipherText, nonce, this.key); | ||
if (bytes === null) { | ||
@@ -114,0 +122,0 @@ Logger.error( |
@@ -0,28 +1,131 @@ | ||
import { Options } from './options'; | ||
import Defaults from './defaults'; | ||
import { AuthOptions, AuthorizerGenerator } from './auth/options'; | ||
import Runtime from 'runtime'; | ||
import * as nacl from 'tweetnacl'; | ||
import Logger from './logger'; | ||
export var getGlobalConfig = function() { | ||
return { | ||
wsHost: Defaults.host, | ||
wsPort: Defaults.ws_port, | ||
wssPort: Defaults.wss_port, | ||
wsPath: Defaults.ws_path, | ||
httpHost: Defaults.sockjs_host, | ||
httpPort: Defaults.sockjs_http_port, | ||
httpsPort: Defaults.sockjs_https_port, | ||
httpPath: Defaults.sockjs_path, | ||
statsHost: Defaults.stats_host, | ||
authEndpoint: Defaults.channel_auth_endpoint, | ||
authTransport: Defaults.channel_auth_transport, | ||
// TODO make this consistent with other options in next major version | ||
activity_timeout: Defaults.activity_timeout, | ||
pong_timeout: Defaults.pong_timeout, | ||
unavailable_timeout: Defaults.unavailable_timeout | ||
export type AuthTransport = 'ajax' | 'jsonp'; | ||
export type Transport = | ||
| 'ws' | ||
| 'wss' | ||
| 'xhr_streaming' | ||
| 'xhr_polling' | ||
| 'sockjs'; | ||
export interface Config { | ||
// these are all 'required' config parameters, it's not necessary for the user | ||
// to set them, but they have configured defaults. | ||
activityTimeout: number; | ||
authEndpoint: string; | ||
authTransport: AuthTransport; | ||
enableStats: boolean; | ||
httpHost: string; | ||
httpPath: string; | ||
httpPort: number; | ||
httpsPort: number; | ||
pongTimeout: number; | ||
statsHost: string; | ||
unavailableTimeout: number; | ||
useTLS: boolean; | ||
wsHost: string; | ||
wsPath: string; | ||
wsPort: number; | ||
wssPort: number; | ||
// these are all optional parameters or overrrides. The customer can set these | ||
// but it's not strictly necessary | ||
forceTLS?: boolean; | ||
auth?: AuthOptions; | ||
authorizer?: AuthorizerGenerator; | ||
cluster?: string; | ||
disabledTransports?: Transport[]; | ||
enabledTransports?: Transport[]; | ||
ignoreNullOrigin?: boolean; | ||
nacl?: nacl; | ||
timelineParams?: any; | ||
} | ||
export function getConfig(opts: Options): Config { | ||
let config: Config = { | ||
activityTimeout: opts.activityTimeout || Defaults.activityTimeout, | ||
authEndpoint: opts.authEndpoint || Defaults.authEndpoint, | ||
authTransport: opts.authTransport || Defaults.authTransport, | ||
cluster: opts.cluster || Defaults.cluster, | ||
httpPath: opts.httpPath || Defaults.httpPath, | ||
httpPort: opts.httpPort || Defaults.httpPort, | ||
httpsPort: opts.httpsPort || Defaults.httpsPort, | ||
pongTimeout: opts.pongTimeout || Defaults.pongTimeout, | ||
statsHost: opts.statsHost || Defaults.stats_host, | ||
unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout, | ||
wsPath: opts.wsPath || Defaults.wsPath, | ||
wsPort: opts.wsPort || Defaults.wsPort, | ||
wssPort: opts.wssPort || Defaults.wssPort, | ||
enableStats: getEnableStatsConfig(opts), | ||
httpHost: getHttpHost(opts), | ||
useTLS: shouldUseTLS(opts), | ||
wsHost: getWebsocketHost(opts) | ||
}; | ||
}; | ||
export var getClusterConfig = function(clusterName) { | ||
return { | ||
wsHost: 'ws-' + clusterName + '.pusher.com', | ||
httpHost: 'sockjs-' + clusterName + '.pusher.com' | ||
}; | ||
}; | ||
if ('auth' in opts) config.auth = opts.auth; | ||
if ('authorizer' in opts) config.authorizer = opts.authorizer; | ||
if ('disabledTransports' in opts) | ||
config.disabledTransports = opts.disabledTransports; | ||
if ('enabledTransports' in opts) | ||
config.enabledTransports = opts.enabledTransports; | ||
if ('ignoreNullOrigin' in opts) | ||
config.ignoreNullOrigin = opts.ignoreNullOrigin; | ||
if ('timelineParams' in opts) config.timelineParams = opts.timelineParams; | ||
if ('nacl' in opts) { | ||
config.nacl = opts.nacl; | ||
} | ||
return config; | ||
} | ||
function getHttpHost(opts: Options): string { | ||
if (opts.httpHost) { | ||
return opts.httpHost; | ||
} | ||
if (opts.cluster) { | ||
return `sockjs-${opts.cluster}.pusher.com`; | ||
} | ||
return Defaults.httpHost; | ||
} | ||
function getWebsocketHost(opts: Options): string { | ||
if (opts.wsHost) { | ||
return opts.wsHost; | ||
} | ||
if (opts.cluster) { | ||
return getWebsocketHostFromCluster(opts.cluster); | ||
} | ||
return getWebsocketHostFromCluster(Defaults.cluster); | ||
} | ||
function getWebsocketHostFromCluster(cluster: string): string { | ||
return `ws-${cluster}.pusher.com`; | ||
} | ||
function shouldUseTLS(opts: Options): boolean { | ||
if (Runtime.getProtocol() === 'https:') { | ||
return true; | ||
} else if (opts.forceTLS === false) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
// if enableStats is set take the value | ||
// if disableStats is set take the inverse | ||
// otherwise default to false | ||
function getEnableStatsConfig(opts: Options): boolean { | ||
if ('enableStats' in opts) { | ||
return opts.enableStats; | ||
} | ||
if ('disableStats' in opts) { | ||
return !opts.disableStats; | ||
} | ||
return false; | ||
} |
@@ -11,4 +11,5 @@ import Timeline from '../timeline/timeline'; | ||
activityTimeout: number; | ||
useTLS: boolean; | ||
} | ||
export default ConnectionManagerOptions; |
import { default as EventsDispatcher } from '../events/dispatcher'; | ||
import { OneOffTimer as Timer } from '../utils/timers'; | ||
import { Config } from '../config'; | ||
import Logger from '../logger'; | ||
@@ -12,2 +13,3 @@ import HandshakePayload from './handshake/handshake_payload'; | ||
import Runtime from 'runtime'; | ||
import { | ||
@@ -64,10 +66,11 @@ ErrorCallbacks, | ||
constructor(key: string, options: any) { | ||
constructor(key: string, options: ConnectionManagerOptions) { | ||
super(); | ||
this.key = key; | ||
this.options = options || {}; | ||
this.state = 'initialized'; | ||
this.connection = null; | ||
this.usingTLS = !!options.useTLS; | ||
this.key = key; | ||
this.options = options; | ||
this.timeline = this.options.timeline; | ||
this.usingTLS = this.options.useTLS; | ||
@@ -74,0 +77,0 @@ this.errorCallbacks = this.buildErrorCallbacks(); |
@@ -0,18 +1,20 @@ | ||
import { AuthTransport } from './config'; | ||
export interface DefaultConfig { | ||
VERSION: string; | ||
PROTOCOL: number; | ||
host: string; | ||
ws_port: number; | ||
wss_port: number; | ||
ws_path: string; | ||
sockjs_host: string; | ||
sockjs_http_port: number; | ||
sockjs_https_port: number; | ||
sockjs_path: string; | ||
wsPort: number; | ||
wssPort: number; | ||
wsPath: string; | ||
httpHost: string; | ||
httpPort: number; | ||
httpsPort: number; | ||
httpPath: string; | ||
stats_host: string; | ||
channel_auth_endpoint: string; | ||
channel_auth_transport: string; | ||
activity_timeout: number; | ||
pong_timeout: number; | ||
unavailable_timeout: number; | ||
authEndpoint: string; | ||
authTransport: AuthTransport; | ||
activityTimeout: number; | ||
pongTimeout: number; | ||
unavailableTimeout: number; | ||
cluster: string; | ||
@@ -28,20 +30,19 @@ cdn_http?: string; | ||
// DEPRECATED: WS connection parameters | ||
host: 'ws.pusherapp.com', | ||
ws_port: 80, | ||
wss_port: 443, | ||
ws_path: '', | ||
wsPort: 80, | ||
wssPort: 443, | ||
wsPath: '', | ||
// DEPRECATED: SockJS fallback parameters | ||
sockjs_host: 'sockjs.pusher.com', | ||
sockjs_http_port: 80, | ||
sockjs_https_port: 443, | ||
sockjs_path: '/pusher', | ||
httpHost: 'sockjs.pusher.com', | ||
httpPort: 80, | ||
httpsPort: 443, | ||
httpPath: '/pusher', | ||
// DEPRECATED: Stats | ||
stats_host: 'stats.pusher.com', | ||
// DEPRECATED: Other settings | ||
channel_auth_endpoint: '/pusher/auth', | ||
channel_auth_transport: 'ajax', | ||
activity_timeout: 120000, | ||
pong_timeout: 30000, | ||
unavailable_timeout: 10000, | ||
authEndpoint: '/pusher/auth', | ||
authTransport: 'ajax', | ||
activityTimeout: 120000, | ||
pongTimeout: 30000, | ||
unavailableTimeout: 10000, | ||
cluster: 'mt1', | ||
@@ -48,0 +49,0 @@ // CDN configuration |
import ConnectionManager from './connection/connection_manager'; | ||
import { AuthOptions, AuthorizerGenerator } from './auth/options'; | ||
import { AuthTransport, Transport } from './config'; | ||
import * as nacl from 'tweetnacl'; | ||
export interface PusherOptions { | ||
cluster: string; | ||
disableStats: boolean; | ||
enableStats: boolean; | ||
statsHost: string; | ||
activity_timeout: number; | ||
pong_timeout: number; | ||
unavailable_timeout: number; | ||
forceTLS: boolean; | ||
encrypted: boolean; | ||
timelineParams: any; | ||
authTransport: 'ajax' | 'jsonp'; | ||
auth: AuthOptions; | ||
authorizer: AuthorizerGenerator; | ||
} | ||
type Transport = 'ws' | 'wss' | 'xhr_streaming' | 'xhr_polling' | 'sockjs'; | ||
type AuthTransport = 'ajax' | 'jsonp'; | ||
export interface Options { | ||
activityTimeout?: number; | ||
enableStats?: boolean; | ||
disableStats?: boolean; // deprecated | ||
auth?: AuthOptions; | ||
authEndpoint?: string; | ||
auth?: AuthOptions; | ||
authTransport?: AuthTransport; | ||
authorizer?: AuthorizerGenerator; | ||
cluster?: string; | ||
enableStats?: boolean; | ||
disableStats?: boolean; | ||
disabledTransports?: Transport[]; | ||
enabledTransports?: Transport[]; | ||
encrypted?: boolean; | ||
forceTLS?: boolean; | ||
httpHost?: string; | ||
httpPath?: string; | ||
httpPort?: number; | ||
httpsPort?: number; | ||
ignoreNullOrigin?: boolean; | ||
nacl?: nacl; | ||
pongTimeout?: number; | ||
statsHost?: string; | ||
timelineParams?: any; | ||
unavailable_timeout?: number; | ||
cluster?: string; | ||
unavailableTimeout?: number; | ||
wsHost?: string; | ||
httpHost?: string; | ||
wsPath?: string; | ||
wsPort?: number; | ||
wssPort?: number; | ||
httpPort?: number; | ||
httpsPort?: number; | ||
} |
@@ -19,4 +19,6 @@ import AbstractRuntime from '../runtimes/interface'; | ||
import Factory from './utils/factory'; | ||
import { PusherOptions, Options } from './options'; | ||
import UrlStore from 'core/utils/url_store'; | ||
import { Options } from './options'; | ||
import { Config, getConfig } from './config'; | ||
import StrategyOptions from './strategies/strategy_options'; | ||
@@ -54,3 +56,3 @@ export default class Pusher { | ||
key: string; | ||
config: PusherOptions; | ||
config: Config; | ||
channels: Channels; | ||
@@ -77,13 +79,6 @@ global_emitter: EventsDispatcher; | ||
); | ||
if (!('enableStats' in options)) { | ||
options.enableStats = !options.disableStats; | ||
} | ||
} | ||
this.key = app_key; | ||
this.config = Collections.extend<PusherOptions>( | ||
DefaultConfig.getGlobalConfig(), | ||
options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, | ||
options | ||
); | ||
this.config = getConfig(options); | ||
@@ -109,21 +104,14 @@ this.channels = Factory.createChannels(); | ||
var getStrategy = options => { | ||
var config = Collections.extend({}, this.config, options); | ||
return Runtime.getDefaultStrategy(config, defineTransport); | ||
var getStrategy = (options: StrategyOptions) => { | ||
return Runtime.getDefaultStrategy(this.config, options, defineTransport); | ||
}; | ||
this.connection = Factory.createConnectionManager( | ||
this.key, | ||
Collections.extend<ConnectionManagerOptions>( | ||
{ | ||
getStrategy: getStrategy, | ||
timeline: this.timeline, | ||
activityTimeout: this.config.activity_timeout, | ||
pongTimeout: this.config.pong_timeout, | ||
unavailableTimeout: this.config.unavailable_timeout | ||
}, | ||
this.config, | ||
{ useTLS: this.shouldUseTLS() } | ||
) | ||
); | ||
this.connection = Factory.createConnectionManager(this.key, { | ||
getStrategy: getStrategy, | ||
timeline: this.timeline, | ||
activityTimeout: this.config.activityTimeout, | ||
pongTimeout: this.config.pongTimeout, | ||
unavailableTimeout: this.config.unavailableTimeout, | ||
useTLS: Boolean(this.config.useTLS) | ||
}); | ||
@@ -136,2 +124,3 @@ this.connection.bind('connected', () => { | ||
}); | ||
this.connection.bind('message', event => { | ||
@@ -264,10 +253,3 @@ var eventName = event.event; | ||
shouldUseTLS(): boolean { | ||
if (Runtime.getProtocol() === 'https:') { | ||
return true; | ||
} else if (this.config.forceTLS === true) { | ||
return true; | ||
} else { | ||
// `encrypted` deprecated in favor of `forceTLS` | ||
return Boolean(this.config.encrypted); | ||
} | ||
return this.config.useTLS; | ||
} | ||
@@ -274,0 +256,0 @@ } |
@@ -7,2 +7,4 @@ import * as Collections from '../utils/collections'; | ||
import TransportStrategy from './transport_strategy'; | ||
import StrategyOptions from '../strategies/strategy_options'; | ||
import { Config } from '../config'; | ||
import Runtime from 'runtime'; | ||
@@ -13,7 +15,7 @@ | ||
export var defineTransport = function( | ||
config: any, | ||
config: Config, | ||
name: string, | ||
type: string, | ||
priority: number, | ||
options, | ||
options: StrategyOptions, | ||
manager?: TransportManager | ||
@@ -34,2 +36,7 @@ ): Strategy { | ||
if (enabled) { | ||
options = Object.assign( | ||
{ ignoreNullOrigin: config.ignoreNullOrigin }, | ||
options | ||
); | ||
transport = new TransportStrategy( | ||
@@ -39,11 +46,3 @@ name, | ||
manager ? manager.getAssistant(transportClass) : transportClass, | ||
Collections.extend( | ||
{ | ||
key: config.key, | ||
useTLS: config.useTLS, | ||
timeline: config.timeline, | ||
ignoreNullOrigin: config.ignoreNullOrigin | ||
}, | ||
options | ||
) | ||
options | ||
); | ||
@@ -50,0 +49,0 @@ } else { |
@@ -0,13 +1,18 @@ | ||
import Timeline from '../timeline/timeline'; | ||
interface StrategyOptions { | ||
ttl?: number; | ||
timeline?: any; | ||
useTLS?: boolean; | ||
failFast?: boolean; | ||
hostNonTLS?: string; | ||
hostTLS?: string; | ||
httpPath?: string; | ||
ignoreNullOrigin?: boolean; | ||
key?: string; | ||
loop?: boolean; | ||
failFast?: boolean; | ||
timeline?: Timeline; | ||
timeout?: number; | ||
timeoutLimit?: number; | ||
key?: string; | ||
ttl?: number; | ||
useTLS?: boolean; | ||
} | ||
export default StrategyOptions; |
@@ -58,3 +58,2 @@ import Factory from '../utils/factory'; | ||
var connected = false; | ||
var transport = this.transport.createConnection( | ||
@@ -61,0 +60,0 @@ this.name, |
import Factory from '../utils/factory'; | ||
import TransportHooks from './transport_hooks'; | ||
import TransportConnection from './transport_connection'; | ||
import TransportConnectionOptions from './transport_connection_options'; | ||
@@ -5,0 +6,0 @@ /** Provides interface for transport connection instantiation. |
@@ -25,2 +25,4 @@ import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager'; | ||
import Pusher from '../pusher'; | ||
import { Config } from '../config'; | ||
import * as nacl from 'tweetnacl'; | ||
@@ -51,4 +53,8 @@ var Factory = { | ||
createEncryptedChannel(name: string, pusher: Pusher): EncryptedChannel { | ||
return new EncryptedChannel(name, pusher); | ||
createEncryptedChannel( | ||
name: string, | ||
pusher: Pusher, | ||
nacl: nacl | ||
): EncryptedChannel { | ||
return new EncryptedChannel(name, pusher, nacl); | ||
}, | ||
@@ -55,0 +61,0 @@ |
@@ -16,2 +16,6 @@ /** | ||
path: '/docs/client_api_guide/client_events#trigger-events' | ||
}, | ||
encryptedChannelSupport: { | ||
fullUrl: | ||
'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support' | ||
} | ||
@@ -18,0 +22,0 @@ } |
@@ -13,2 +13,4 @@ import { AuthTransports } from '../core/auth/auth_transports'; | ||
import Strategy from '../core/strategies/strategy'; | ||
import { Config } from '../core/config'; | ||
import StrategyOptions from '../core/strategies/strategy_options'; | ||
@@ -34,3 +36,7 @@ /* | ||
getNetwork(): Reachability; | ||
getDefaultStrategy(config: any, defineTransport: Function): Strategy; | ||
getDefaultStrategy( | ||
config: Config, | ||
options: StrategyOptions, | ||
defineTransport: Function | ||
): Strategy; | ||
Transports: TransportsTable; | ||
@@ -37,0 +43,0 @@ getWebSocketAPI(): new (url: string) => Socket; |
@@ -12,2 +12,4 @@ import * as Collections from 'core/utils/collections'; | ||
import FirstConnectedStrategy from 'core/strategies/first_connected_strategy'; | ||
import { Config } from 'core/config'; | ||
import StrategyOptions from 'core/strategies/strategy_options'; | ||
@@ -21,3 +23,4 @@ function testSupportsStrategy(strategy: Strategy) { | ||
var getDefaultStrategy = function( | ||
config: any, | ||
config: Config, | ||
baseOptions: StrategyOptions, | ||
defineTransport: Function | ||
@@ -31,3 +34,3 @@ ): Strategy { | ||
priority: number, | ||
options, | ||
options: StrategyOptions, | ||
manager?: TransportManager | ||
@@ -49,15 +52,15 @@ ) { | ||
var ws_options = { | ||
var ws_options: StrategyOptions = Object.assign({}, baseOptions, { | ||
hostNonTLS: config.wsHost + ':' + config.wsPort, | ||
hostTLS: config.wsHost + ':' + config.wssPort, | ||
httpPath: config.wsPath | ||
}; | ||
var wss_options = Collections.extend({}, ws_options, { | ||
}); | ||
var wss_options: StrategyOptions = Collections.extend({}, ws_options, { | ||
useTLS: true | ||
}); | ||
var http_options = { | ||
var http_options: StrategyOptions = Object.assign({}, baseOptions, { | ||
hostNonTLS: config.httpHost + ':' + config.httpPort, | ||
hostTLS: config.httpHost + ':' + config.httpsPort, | ||
httpPath: config.httpPath | ||
}; | ||
}); | ||
var timeouts = { | ||
@@ -72,3 +75,3 @@ loop: true, | ||
minPingDelay: 10000, | ||
maxPingDelay: config.activity_timeout | ||
maxPingDelay: config.activityTimeout | ||
}); | ||
@@ -78,3 +81,3 @@ var streaming_manager = new TransportManager({ | ||
minPingDelay: 10000, | ||
maxPingDelay: config.activity_timeout | ||
maxPingDelay: config.activityTimeout | ||
}); | ||
@@ -133,3 +136,3 @@ | ||
var wsStrategy; | ||
if (config.useTLS) { | ||
if (baseOptions.useTLS) { | ||
wsStrategy = new BestConnectedEverStrategy([ | ||
@@ -154,4 +157,4 @@ ws_loop, | ||
ttl: 1800000, | ||
timeline: config.timeline, | ||
useTLS: config.useTLS | ||
timeline: baseOptions.timeline, | ||
useTLS: baseOptions.useTLS | ||
} | ||
@@ -158,0 +161,0 @@ ); |
import * as Collections from 'core/utils/collections'; | ||
import TransportManager from 'core/transports/transport_manager'; | ||
import Strategy from 'core/strategies/strategy'; | ||
import StrategyOptions from 'core/strategies/strategy_options'; | ||
import SequentialStrategy from 'core/strategies/sequential_strategy'; | ||
@@ -12,2 +13,3 @@ import BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy'; | ||
import FirstConnectedStrategy from 'core/strategies/first_connected_strategy'; | ||
import { Config } from 'core/config'; | ||
@@ -21,3 +23,4 @@ function testSupportsStrategy(strategy: Strategy) { | ||
var getDefaultStrategy = function( | ||
config: any, | ||
config: Config, | ||
baseOptions: StrategyOptions, | ||
defineTransport: Function | ||
@@ -31,3 +34,3 @@ ): Strategy { | ||
priority: number, | ||
options, | ||
options: StrategyOptions, | ||
manager?: TransportManager | ||
@@ -49,15 +52,16 @@ ) { | ||
var ws_options = { | ||
var ws_options: StrategyOptions = Object.assign({}, baseOptions, { | ||
hostNonTLS: config.wsHost + ':' + config.wsPort, | ||
hostTLS: config.wsHost + ':' + config.wssPort, | ||
httpPath: config.wsPath | ||
}; | ||
var wss_options = Collections.extend({}, ws_options, { | ||
}); | ||
var wss_options: StrategyOptions = Object.assign({}, ws_options, { | ||
useTLS: true | ||
}); | ||
var sockjs_options = { | ||
var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, { | ||
hostNonTLS: config.httpHost + ':' + config.httpPort, | ||
hostTLS: config.httpHost + ':' + config.httpsPort, | ||
httpPath: config.httpPath | ||
}; | ||
}); | ||
var timeouts = { | ||
@@ -72,3 +76,3 @@ loop: true, | ||
minPingDelay: 10000, | ||
maxPingDelay: config.activity_timeout | ||
maxPingDelay: config.activityTimeout | ||
}); | ||
@@ -78,3 +82,3 @@ var streaming_manager = new TransportManager({ | ||
minPingDelay: 10000, | ||
maxPingDelay: config.activity_timeout | ||
maxPingDelay: config.activityTimeout | ||
}); | ||
@@ -174,3 +178,3 @@ | ||
var wsStrategy; | ||
if (config.useTLS) { | ||
if (baseOptions.useTLS) { | ||
wsStrategy = new BestConnectedEverStrategy([ | ||
@@ -199,4 +203,4 @@ ws_loop, | ||
ttl: 1800000, | ||
timeline: config.timeline, | ||
useTLS: config.useTLS | ||
timeline: baseOptions.timeline, | ||
useTLS: baseOptions.useTLS | ||
} | ||
@@ -203,0 +207,0 @@ ); |
import Channel from '../channels/channel'; | ||
export interface AuthOptions { | ||
params: any; | ||
headers: any; | ||
params?: any; | ||
headers?: any; | ||
} | ||
@@ -20,4 +20,4 @@ export interface AuthData { | ||
authTransport: 'ajax' | 'jsonp'; | ||
auth: AuthOptions; | ||
authorizer: AuthorizerGenerator; | ||
auth?: AuthOptions; | ||
authorizer?: AuthorizerGenerator; | ||
} |
import PrivateChannel from './private_channel'; | ||
import Pusher from '../pusher'; | ||
import Dispatcher from '../events/dispatcher'; | ||
import { PusherEvent } from '../connection/protocol/message-types'; | ||
import { AuthorizerCallback } from '../auth/options'; | ||
import * as nacl from 'tweetnacl'; | ||
export default class EncryptedChannel extends PrivateChannel { | ||
key: Uint8Array; | ||
nacl: nacl; | ||
constructor(name: string, pusher: Pusher, nacl: nacl); | ||
authorize(socketId: string, callback: AuthorizerCallback): void; | ||
@@ -8,0 +12,0 @@ trigger(event: string, data: any): boolean; |
@@ -1,20 +0,33 @@ | ||
export declare var getGlobalConfig: () => { | ||
wsHost: string; | ||
wsPort: number; | ||
wssPort: number; | ||
wsPath: string; | ||
import { Options } from './options'; | ||
import { AuthOptions, AuthorizerGenerator } from './auth/options'; | ||
import * as nacl from 'tweetnacl'; | ||
export declare type AuthTransport = 'ajax' | 'jsonp'; | ||
export declare type Transport = 'ws' | 'wss' | 'xhr_streaming' | 'xhr_polling' | 'sockjs'; | ||
export interface Config { | ||
activityTimeout: number; | ||
authEndpoint: string; | ||
authTransport: AuthTransport; | ||
enableStats: boolean; | ||
httpHost: string; | ||
httpPath: string; | ||
httpPort: number; | ||
httpsPort: number; | ||
httpPath: string; | ||
pongTimeout: number; | ||
statsHost: string; | ||
authEndpoint: string; | ||
authTransport: string; | ||
activity_timeout: number; | ||
pong_timeout: number; | ||
unavailable_timeout: number; | ||
}; | ||
export declare var getClusterConfig: (clusterName: any) => { | ||
unavailableTimeout: number; | ||
useTLS: boolean; | ||
wsHost: string; | ||
httpHost: string; | ||
}; | ||
wsPath: string; | ||
wsPort: number; | ||
wssPort: number; | ||
forceTLS?: boolean; | ||
auth?: AuthOptions; | ||
authorizer?: AuthorizerGenerator; | ||
cluster?: string; | ||
disabledTransports?: Transport[]; | ||
enabledTransports?: Transport[]; | ||
ignoreNullOrigin?: boolean; | ||
nacl?: nacl; | ||
timelineParams?: any; | ||
} | ||
export declare function getConfig(opts: Options): Config; |
@@ -9,3 +9,4 @@ import Timeline from '../timeline/timeline'; | ||
activityTimeout: number; | ||
useTLS: boolean; | ||
} | ||
export default ConnectionManagerOptions; |
@@ -26,3 +26,3 @@ import { default as EventsDispatcher } from '../events/dispatcher'; | ||
connectionCallbacks: ConnectionCallbacks; | ||
constructor(key: string, options: any); | ||
constructor(key: string, options: ConnectionManagerOptions); | ||
connect(): void; | ||
@@ -29,0 +29,0 @@ send(data: any): boolean; |
@@ -0,18 +1,19 @@ | ||
import { AuthTransport } from './config'; | ||
export interface DefaultConfig { | ||
VERSION: string; | ||
PROTOCOL: number; | ||
host: string; | ||
ws_port: number; | ||
wss_port: number; | ||
ws_path: string; | ||
sockjs_host: string; | ||
sockjs_http_port: number; | ||
sockjs_https_port: number; | ||
sockjs_path: string; | ||
wsPort: number; | ||
wssPort: number; | ||
wsPath: string; | ||
httpHost: string; | ||
httpPort: number; | ||
httpsPort: number; | ||
httpPath: string; | ||
stats_host: string; | ||
channel_auth_endpoint: string; | ||
channel_auth_transport: string; | ||
activity_timeout: number; | ||
pong_timeout: number; | ||
unavailable_timeout: number; | ||
authEndpoint: string; | ||
authTransport: AuthTransport; | ||
activityTimeout: number; | ||
pongTimeout: number; | ||
unavailableTimeout: number; | ||
cluster: string; | ||
cdn_http?: string; | ||
@@ -19,0 +20,0 @@ cdn_https?: string; |
import { AuthOptions, AuthorizerGenerator } from './auth/options'; | ||
export interface PusherOptions { | ||
cluster: string; | ||
disableStats: boolean; | ||
enableStats: boolean; | ||
statsHost: string; | ||
activity_timeout: number; | ||
pong_timeout: number; | ||
unavailable_timeout: number; | ||
forceTLS: boolean; | ||
encrypted: boolean; | ||
timelineParams: any; | ||
authTransport: 'ajax' | 'jsonp'; | ||
auth: AuthOptions; | ||
authorizer: AuthorizerGenerator; | ||
} | ||
declare type Transport = 'ws' | 'wss' | 'xhr_streaming' | 'xhr_polling' | 'sockjs'; | ||
declare type AuthTransport = 'ajax' | 'jsonp'; | ||
import { AuthTransport, Transport } from './config'; | ||
import * as nacl from 'tweetnacl'; | ||
export interface Options { | ||
activityTimeout?: number; | ||
enableStats?: boolean; | ||
disableStats?: boolean; | ||
auth?: AuthOptions; | ||
authEndpoint?: string; | ||
auth?: AuthOptions; | ||
authTransport?: AuthTransport; | ||
authorizer?: AuthorizerGenerator; | ||
cluster?: string; | ||
enableStats?: boolean; | ||
disableStats?: boolean; | ||
disabledTransports?: Transport[]; | ||
enabledTransports?: Transport[]; | ||
encrypted?: boolean; | ||
forceTLS?: boolean; | ||
httpHost?: string; | ||
httpPath?: string; | ||
httpPort?: number; | ||
httpsPort?: number; | ||
ignoreNullOrigin?: boolean; | ||
nacl?: nacl; | ||
pongTimeout?: number; | ||
statsHost?: string; | ||
timelineParams?: any; | ||
unavailable_timeout?: number; | ||
cluster?: string; | ||
unavailableTimeout?: number; | ||
wsHost?: string; | ||
httpHost?: string; | ||
wsPath?: string; | ||
wsPort?: number; | ||
wssPort?: number; | ||
httpPort?: number; | ||
httpsPort?: number; | ||
} | ||
export {}; |
@@ -9,3 +9,4 @@ import AbstractRuntime from '../runtimes/interface'; | ||
import { PeriodicTimer } from './utils/timers'; | ||
import { PusherOptions, Options } from './options'; | ||
import { Options } from './options'; | ||
import { Config } from './config'; | ||
export default class Pusher { | ||
@@ -23,3 +24,3 @@ static instances: Pusher[]; | ||
key: string; | ||
config: PusherOptions; | ||
config: Config; | ||
channels: Channels; | ||
@@ -26,0 +27,0 @@ global_emitter: EventsDispatcher; |
import TransportManager from '../transports/transport_manager'; | ||
import Strategy from './strategy'; | ||
export declare var defineTransport: (config: any, name: string, type: string, priority: number, options: any, manager?: TransportManager) => Strategy; | ||
import StrategyOptions from '../strategies/strategy_options'; | ||
import { Config } from '../config'; | ||
export declare var defineTransport: (config: Config, name: string, type: string, priority: number, options: StrategyOptions, manager?: TransportManager) => Strategy; |
@@ -0,12 +1,16 @@ | ||
import Timeline from '../timeline/timeline'; | ||
interface StrategyOptions { | ||
ttl?: number; | ||
timeline?: any; | ||
useTLS?: boolean; | ||
failFast?: boolean; | ||
hostNonTLS?: string; | ||
hostTLS?: string; | ||
httpPath?: string; | ||
ignoreNullOrigin?: boolean; | ||
key?: string; | ||
loop?: boolean; | ||
failFast?: boolean; | ||
timeline?: Timeline; | ||
timeout?: number; | ||
timeoutLimit?: number; | ||
key?: string; | ||
ttl?: number; | ||
useTLS?: boolean; | ||
} | ||
export default StrategyOptions; |
@@ -18,2 +18,3 @@ import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager'; | ||
import Pusher from '../pusher'; | ||
import * as nacl from 'tweetnacl'; | ||
declare var Factory: { | ||
@@ -25,3 +26,3 @@ createChannels(): Channels; | ||
createPresenceChannel(name: string, pusher: Pusher): PresenceChannel; | ||
createEncryptedChannel(name: string, pusher: Pusher): EncryptedChannel; | ||
createEncryptedChannel(name: string, pusher: Pusher, nacl: nacl): EncryptedChannel; | ||
createTimelineSender(timeline: Timeline, options: TimelineSenderOptions): TimelineSender; | ||
@@ -28,0 +29,0 @@ createAuthorizer(channel: Channel, options: AuthorizerOptions): Authorizer; |
@@ -12,2 +12,4 @@ import { AuthTransports } from '../core/auth/auth_transports'; | ||
import Strategy from '../core/strategies/strategy'; | ||
import { Config } from '../core/config'; | ||
import StrategyOptions from '../core/strategies/strategy_options'; | ||
interface Runtime { | ||
@@ -25,3 +27,3 @@ setup(PusherClass: { | ||
getNetwork(): Reachability; | ||
getDefaultStrategy(config: any, defineTransport: Function): Strategy; | ||
getDefaultStrategy(config: Config, options: StrategyOptions, defineTransport: Function): Strategy; | ||
Transports: TransportsTable; | ||
@@ -28,0 +30,0 @@ getWebSocketAPI(): new (url: string) => Socket; |
import Strategy from 'core/strategies/strategy'; | ||
declare var getDefaultStrategy: (config: any, defineTransport: Function) => Strategy; | ||
import { Config } from 'core/config'; | ||
import StrategyOptions from 'core/strategies/strategy_options'; | ||
declare var getDefaultStrategy: (config: Config, baseOptions: StrategyOptions, defineTransport: Function) => Strategy; | ||
export default getDefaultStrategy; |
import Strategy from 'core/strategies/strategy'; | ||
declare var getDefaultStrategy: (config: any, defineTransport: Function) => Strategy; | ||
import StrategyOptions from 'core/strategies/strategy_options'; | ||
import { Config } from 'core/config'; | ||
declare var getDefaultStrategy: (config: Config, baseOptions: StrategyOptions, defineTransport: Function) => Strategy; | ||
export default getDefaultStrategy; |
@@ -7,2 +7,5 @@ var path = require('path'); | ||
module.exports = objectAssign({}, configShared, { | ||
entry: { | ||
pusher: './src/core/pusher-with-encryption.js' | ||
}, | ||
output: { | ||
@@ -9,0 +12,0 @@ library: 'Pusher', |
@@ -8,4 +8,8 @@ var path = require('path'); | ||
var webpack = require('webpack'); | ||
var buffer = require('buffer'); | ||
module.exports = objectAssign({}, configShared, { | ||
entry: { | ||
pusher: './src/core/pusher-with-encryption.js' | ||
}, | ||
output: { | ||
@@ -17,3 +21,2 @@ library: 'Pusher', | ||
}, | ||
target: 'node', | ||
externals: { | ||
@@ -24,19 +27,3 @@ // our Reachability implementation needs to reference @react-native-community/netinfo. | ||
resolve: { | ||
modules: ['src/runtimes/react-native'], | ||
// at the moment, react-native doesn't contain the requisite crypto APIs to | ||
// use tweetnacl/tweetnacl-utils. | ||
// | ||
// As a result encrypted channels cannot be supported in react native at | ||
// this time. In order for the build to work, we need to replace the | ||
// tweetnacl-utils with 'mocks' | ||
alias: { | ||
tweetnacl: path.resolve( | ||
__dirname, | ||
'../src/runtimes/react-native/tweetnacl-dummy.ts' | ||
), | ||
'tweetnacl-util': path.resolve( | ||
__dirname, | ||
'../src/runtimes/react-native/tweetnacl-util-dummy.ts' | ||
) | ||
} | ||
modules: ['src/runtimes/react-native'] | ||
}, | ||
@@ -46,4 +33,7 @@ plugins: [ | ||
RUNTIME: JSON.stringify('react-native') | ||
}), | ||
new webpack.ProvidePlugin({ | ||
buffer: 'buffer' | ||
}) | ||
] | ||
}); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
entry: { | ||
pusher: './src/core/index' | ||
pusher: './src/core/pusher.js' | ||
}, | ||
@@ -20,0 +20,0 @@ resolve: { |
@@ -11,3 +11,12 @@ var path = require('path'); | ||
var entry = './src/core/pusher.js'; | ||
if (process.env.INCLUDE_TWEETNACL === 'true') { | ||
entry = './src/core/pusher-with-encryption.js'; | ||
filename = filename.replace('pusher', 'pusher-with-encryption'); | ||
} | ||
module.exports = objectAssign({}, configShared, { | ||
entry: { | ||
pusher: entry | ||
}, | ||
output: { | ||
@@ -14,0 +23,0 @@ library: 'Pusher', |
@@ -13,3 +13,12 @@ var path = require('path'); | ||
var entry = './src/core/pusher.js'; | ||
if (process.env.INCLUDE_TWEETNACL === 'true') { | ||
entry = './src/core/pusher-with-encryption.js'; | ||
filename = filename.replace('pusher', 'pusher-with-encryption'); | ||
} | ||
var config = objectAssign(configShared, { | ||
entry: { | ||
pusher: entry | ||
}, | ||
output: { | ||
@@ -32,7 +41,2 @@ library: 'Pusher', | ||
// the file should be pusher.worker.js not pusher.js | ||
config.entry = { | ||
'pusher.worker': './src/core/index' | ||
}; | ||
module.exports = config; |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2379813
362
55816
715
30
20
23