pusher-js 7.0.1 → 7.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.github/stale.yml +2 -2
  2. package/.github/workflows/release.yml +112 -0
  3. package/.github/workflows/release_pr.yml +42 -0
  4. package/.github/workflows/run-tests.yml +38 -0
  5. package/CHANGELOG.md +28 -0
  6. package/Makefile +17 -12
  7. package/README.md +28 -0
  8. package/dist/node/pusher.js +85 -44
  9. package/dist/node/pusher.js.map +1 -0
  10. package/dist/react-native/pusher.js +3 -2
  11. package/dist/react-native/pusher.js.map +1 -0
  12. package/dist/web/pusher-with-encryption.js +7 -5
  13. package/dist/web/pusher-with-encryption.js.map +1 -0
  14. package/dist/web/pusher-with-encryption.min.js +3 -2
  15. package/dist/web/pusher-with-encryption.min.js.map +1 -0
  16. package/dist/web/pusher.js +7 -5
  17. package/dist/web/pusher.js.map +1 -0
  18. package/dist/web/pusher.min.js +3 -2
  19. package/dist/web/pusher.min.js.map +1 -0
  20. package/dist/worker/pusher-with-encryption.worker.js +19 -7
  21. package/dist/worker/pusher-with-encryption.worker.js.map +1 -0
  22. package/dist/worker/pusher-with-encryption.worker.min.js +3 -2
  23. package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -0
  24. package/dist/worker/pusher.worker.js +19 -7
  25. package/dist/worker/pusher.worker.js.map +1 -0
  26. package/dist/worker/pusher.worker.min.js +3 -2
  27. package/dist/worker/pusher.worker.min.js.map +1 -0
  28. package/package.json +17 -15
  29. package/react-native/index.d.ts +7 -8
  30. package/spec/config/jasmine/helpers/reporter.js +14 -0
  31. package/spec/config/jasmine/integration.json +13 -0
  32. package/spec/config/jasmine/unit.json +13 -0
  33. package/spec/config/{jasmine-node → jasmine}/webpack.integration.js +4 -4
  34. package/spec/config/{jasmine-node → jasmine}/webpack.unit.js +4 -6
  35. package/spec/config/karma/config.common.js +10 -4
  36. package/spec/config/karma/config.integration.js +4 -4
  37. package/spec/config/karma/config.unit.js +5 -7
  38. package/spec/config/karma/integration.js +3 -3
  39. package/spec/config/karma/unit.js +2 -2
  40. package/spec/javascripts/helpers/mocks.js +18 -18
  41. package/spec/javascripts/helpers/waitsFor.js +37 -0
  42. package/spec/javascripts/integration/core/cluster_config_spec.js +45 -34
  43. package/spec/javascripts/integration/core/falling_back_spec.js +124 -127
  44. package/spec/javascripts/integration/core/pusher_spec/test_builder.js +264 -284
  45. package/spec/javascripts/integration/core/timeout_configuration_spec.js +24 -22
  46. package/spec/javascripts/integration/core/transport_lists_spec.js +8 -8
  47. package/spec/javascripts/integration/web/dom/jsonp_spec.js +67 -69
  48. package/spec/javascripts/integration/web/dom/script_request_spec.js +44 -52
  49. package/spec/javascripts/unit/core/channels/channel_spec.js +11 -21
  50. package/spec/javascripts/unit/core/channels/encrypted_channel_spec.js +9 -17
  51. package/spec/javascripts/unit/core/channels/presence_channel_spec.js +8 -19
  52. package/spec/javascripts/unit/core/channels/private_channel_spec.js +9 -19
  53. package/spec/javascripts/unit/core/config_spec.js +2 -2
  54. package/spec/javascripts/unit/core/connection/connection_manager_spec.js +69 -63
  55. package/spec/javascripts/unit/core/connection/connection_spec.js +14 -13
  56. package/spec/javascripts/unit/core/connection/handshake_spec.js +14 -12
  57. package/spec/javascripts/unit/core/connection/protocol_spec.js +9 -4
  58. package/spec/javascripts/unit/core/defaults_spec.js +1 -1
  59. package/spec/javascripts/unit/core/events_dispatcher_spec.js +20 -20
  60. package/spec/javascripts/unit/core/http/http_polling_socket_spec.js +4 -4
  61. package/spec/javascripts/unit/core/http/http_request_spec.js +20 -17
  62. package/spec/javascripts/unit/core/http/http_socket_spec.js +35 -32
  63. package/spec/javascripts/unit/core/http/http_streaming_socket_spec.js +4 -4
  64. package/spec/javascripts/unit/core/http/http_xhr_request_spec.js +13 -13
  65. package/spec/javascripts/unit/core/pusher_authorizer_spec.js +11 -11
  66. package/spec/javascripts/unit/core/pusher_spec.js +31 -27
  67. package/spec/javascripts/unit/core/strategies/best_connected_ever_strategy_spec.js +5 -5
  68. package/spec/javascripts/unit/core/strategies/cached_strategy_spec.js +17 -13
  69. package/spec/javascripts/unit/core/strategies/delayed_strategy_spec.js +12 -8
  70. package/spec/javascripts/unit/core/strategies/sequential_strategy_spec.js +23 -19
  71. package/spec/javascripts/unit/core/strategies/transport_strategy_spec.js +22 -24
  72. package/spec/javascripts/unit/core/timeline/timeline_spec.js +16 -9
  73. package/spec/javascripts/unit/core/transports/assistant_to_the_transport_manager_spec.js +36 -22
  74. package/spec/javascripts/unit/core/transports/hosts_and_ports_spec.js +10 -10
  75. package/spec/javascripts/unit/core/transports/transport_connection_spec.js +81 -86
  76. package/spec/javascripts/unit/core/transports/transport_manager_spec.js +1 -1
  77. package/spec/javascripts/unit/core/utils/periodic_timer_spec.js +17 -16
  78. package/spec/javascripts/unit/core/utils/timers_spec.js +32 -26
  79. package/spec/javascripts/unit/isomorphic/transports/hosts_and_ports_spec.js +12 -8
  80. package/spec/javascripts/unit/isomorphic/transports/transports_spec.js +7 -7
  81. package/spec/javascripts/unit/node/timeline_sender_spec.js +5 -5
  82. package/spec/javascripts/unit/web/dom/dependency_loader_spec.js +30 -30
  83. package/spec/javascripts/unit/web/dom/jsonp_request_spec.js +7 -7
  84. package/spec/javascripts/unit/web/http/http_xdomain_request_spec.js +22 -22
  85. package/spec/javascripts/unit/web/pusher_authorizer_spec.js +3 -3
  86. package/spec/javascripts/unit/web/timeline/timeline_sender_spec.js +12 -12
  87. package/spec/javascripts/unit/web/transports/hosts_and_ports_spec.js +15 -12
  88. package/spec/javascripts/unit/web/transports/transports_spec.js +24 -26
  89. package/spec/javascripts/unit/worker/pusher_authorizer_spec.js +2 -2
  90. package/spec/javascripts/unit/worker/timeline_sender_spec.js +2 -2
  91. package/src/core/auth/options.ts +1 -0
  92. package/types/src/core/auth/options.d.ts +1 -0
  93. package/webpack/config.node.js +2 -2
  94. package/webpack/config.react-native.js +2 -2
  95. package/webpack/config.shared.js +9 -1
  96. package/webpack/config.web.js +2 -2
  97. package/webpack/config.worker.js +4 -3
  98. package/with-encryption/index.d.ts +0 -1
  99. package/worker/index.d.ts +15 -0
  100. package/worker/index.js +1 -0
  101. package/worker/with-encryption/index.d.ts +15 -0
  102. package/worker/with-encryption/index.js +1 -0
  103. package/.travis.build +0 -22
  104. package/.travis.yml +0 -7
  105. package/spec/config/jasmine-node/config.js +0 -10
package/.github/stale.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  # Configuration for probot-stale - https://github.com/probot/stale
2
2
 
3
3
  # Number of days of inactivity before an Issue or Pull Request becomes stale
4
- daysUntilStale: 365
4
+ daysUntilStale: 90
5
5
 
6
6
  # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7
7
  # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
@@ -23,4 +23,4 @@ markComment: >
23
23
  This issue has been automatically marked as stale because it has not had
24
24
  recent activity. It will be closed if no further activity occurs. If you'd
25
25
  like this issue to stay open please leave a comment indicating how this issue
26
- is affecting you. Thankyou.
26
+ is affecting you. Thank you.
@@ -0,0 +1,112 @@
1
+ on:
2
+ push:
3
+ branches: [ master ]
4
+
5
+ jobs:
6
+ check-release-tag:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: Checkout code
10
+ uses: actions/checkout@v2
11
+ with:
12
+ fetch-depth: 0
13
+ - name: Prepare tag
14
+ id: prepare_tag
15
+ continue-on-error: true
16
+ run: |
17
+ export TAG=v$(jq -r '.version' package.json)
18
+ echo "TAG=$TAG" >> $GITHUB_ENV
19
+
20
+ export CHECK_TAG=$(git tag | grep $TAG)
21
+ if [[ $CHECK_TAG ]]; then
22
+ echo "Skipping because release tag already exists"
23
+ exit 1
24
+ fi
25
+ - name: Output
26
+ id: release_output
27
+ if: ${{ steps.prepare_tag.outcome == 'success' }}
28
+ run: |
29
+ echo "::set-output name=tag::${{ env.TAG }}"
30
+ outputs:
31
+ tag: ${{ steps.release_output.outputs.tag }}
32
+
33
+ create-github-release:
34
+ runs-on: ubuntu-latest
35
+ needs: check-release-tag
36
+ if: ${{ needs.check-release-tag.outputs.tag }}
37
+ steps:
38
+ - uses: actions/checkout@v2
39
+ - name: Prepare tag
40
+ run: |
41
+ export TAG=v$(jq -r '.version' package.json)
42
+ echo "TAG=$TAG" >> $GITHUB_ENV
43
+ - name: Setup git
44
+ run: |
45
+ git config user.email "pusher-ci@pusher.com"
46
+ git config user.name "Pusher CI"
47
+ - name: Prepare description
48
+ run: |
49
+ csplit -s CHANGELOG.md "/##/" {1}
50
+ cat xx01 > CHANGELOG.tmp
51
+ - name: Create Release
52
+ uses: actions/create-release@v1
53
+ env:
54
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
+ with:
56
+ tag_name: ${{ env.TAG }}
57
+ release_name: ${{ env.TAG }}
58
+ body_path: CHANGELOG.tmp
59
+ draft: false
60
+ prerelease: false
61
+
62
+ publish-to-npm:
63
+ runs-on: ubuntu-latest
64
+ needs: create-github-release
65
+ steps:
66
+ - uses: actions/checkout@v2
67
+ - uses: flood-io/is-published-on-npm@8478347e2650eb228d303975415458183d0a37e4
68
+ id: is-published
69
+ - run: echo "This version is already published on NPM"
70
+ if: ${{ steps.is-published.outputs.published == 'true' }}
71
+ - uses: actions/setup-node@v2
72
+ if: ${{ steps.is-published.outputs.published == 'false' }}
73
+ with:
74
+ node-version: '14'
75
+ registry-url: https://registry.npmjs.org/
76
+ - run: npm install
77
+ if: ${{ steps.is-published.outputs.published == 'false' }}
78
+ - run: npm publish --access public
79
+ if: ${{ steps.is-published.outputs.published == 'false' }}
80
+ env:
81
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
82
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83
+
84
+ upload-to-s3:
85
+ runs-on: ubuntu-latest
86
+ needs: create-github-release
87
+ steps:
88
+ - uses: actions/checkout@v2
89
+ - name: Upload to S3
90
+ run: |
91
+ VERSION=$(jq -r '.version' package.json | cut -d'.' -f1,2,3)
92
+ VERSION_MIN=$(jq -r '.version' package.json | cut -d'.' -f1,2)
93
+
94
+ egrep -o '^[0-9]+\.[0-9]+\.[0-9]+' <<< $VERSION
95
+
96
+ aws s3 sync dist/web/ s3://${BUCKET_NAME}/latest/ --acl public-read --cache-control max-age=$MAX_AGE
97
+ aws s3 sync dist/worker/ s3://${BUCKET_NAME}/latest/ --acl public-read --cache-control max-age=$MAX_AGE
98
+
99
+ aws s3 sync dist/web/ s3://${BUCKET_NAME}/${VERSION}/ --acl public-read --cache-control max-age=$MAX_AGE
100
+ aws s3 sync dist/worker/ s3://${BUCKET_NAME}/${VERSION}/ --acl public-read --cache-control max-age=$MAX_AGE
101
+
102
+ aws s3 sync dist/web/ s3://${BUCKET_NAME}/${VERSION_MIN}/ --acl public-read --cache-control max-age=$MAX_AGE
103
+ aws s3 sync dist/worker/ s3://${BUCKET_NAME}/${VERSION_MIN}/ --acl public-read --cache-control max-age=$MAX_AGE
104
+
105
+ aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_DISTRIBUTION_ID} --paths "/latest/*" "/${VERSION}/*" "/${VERSION_MIN}/*"
106
+ env:
107
+ MAX_AGE: 2592000
108
+ BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
109
+ AWS_ACCESS_KEY_ID: ${{ secrets.PUSHERINOS_AWS_ACCESS_KEY_ID }}
110
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.PUSHERINOS_AWS_SECRET_ACCESS_KEY }}
111
+ AWS_DEFAULT_REGION: eu-west-2
112
+ CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
@@ -0,0 +1,42 @@
1
+ name: release
2
+
3
+ on:
4
+ pull_request:
5
+ types: [ labeled ]
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ prepare-release:
11
+ name: Prepare release
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Get current version
16
+ shell: bash
17
+ run: |
18
+ CURRENT_VERSION=$(jq -r '.version' package.json)
19
+ echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20
+ - uses: actions/checkout@v2
21
+ with:
22
+ repository: pusher/actions
23
+ token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
24
+ path: .github/actions
25
+ - uses: ./.github/actions/prepare-version-bump
26
+ id: bump
27
+ with:
28
+ current_version: ${{ env.CURRENT_VERSION }}
29
+ - uses: actions/setup-node@v2
30
+ with:
31
+ node-version: '14'
32
+ - run: npm install
33
+ - name: Push
34
+ shell: bash
35
+ run: |
36
+ echo "$(jq '.version = "${{ steps.bump.outputs.new_version }}"' package.json)" > package.json
37
+
38
+ make build_all
39
+
40
+ git add package.json CHANGELOG.md dist/
41
+ git commit -m "Bump to version ${{ steps.bump.outputs.new_version }}"
42
+ git push
@@ -0,0 +1,38 @@
1
+ name: test
2
+ on:
3
+ push:
4
+ branches:
5
+ - '*'
6
+ pull_request:
7
+ branches:
8
+ - master
9
+ jobs:
10
+ run-web-tests:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ CI: ${{ github.event_name == 'push' && 'basic' || 'full' }}
14
+ MINIMAL_INTEGRATION_TESTS: ${{ github.event_name == 'push' && 'true' || '' }}
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: actions/setup-node@v2
18
+ with:
19
+ node-version: '14'
20
+ - run: npm install
21
+ - run: npm run check-format
22
+ - run: make web_unit
23
+ - run: make web_integration
24
+ env:
25
+ BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
26
+ BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
27
+ run-node-tests:
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - uses: actions/setup-node@v2
32
+ with:
33
+ node-version: '14'
34
+ - run: npm install
35
+ - run: npm run check-format
36
+ - run: make node_unit
37
+ - run: make node_integration
38
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.5
4
+
5
+ * [FIXED] pusher-js/worker is now built by webpack with umd libraryTarget, which
6
+ allows it to be bundled as described in the README
7
+
8
+ ## 7.0.4
9
+
10
+ * [FIXED] References to nonexistent source map #570
11
+
12
+ ## 7.0.3 (2021-01-25)
13
+
14
+ [UPDATED] Bumped version of faye-websocket (used only by the node runtime) from
15
+ 0.9.4 to 0.11.3. Thanks to @Akhawais for the PR.
16
+
17
+ [UPDATED] Bumped version of @react-native-community/netinfo (used only by the
18
+ react-native runtime) from 4.1.1 to 5.9.7. Thanks to @Yinabled for the PR.
19
+
20
+ [ADDED] We were missing a react-native key in `package.json`. Thanks to @giaset
21
+ for the PR
22
+
23
+ [ADDED] Support for importing the worker builds (solving issue #499)
24
+
25
+ ## 7.0.2 (2020-11-26)
26
+
27
+ [FIXED] Removes `AuthInfo` type from react-native and with-encryption builds.
28
+ This type was removed everywhere else in v7.0.0. See [issue
29
+ 512](https://github.com/pusher/pusher-js/issues/512)
30
+
3
31
  ## 7.0.1 (2020-11-02)
4
32
 
5
33
  [FIXED] Channels no longer get stuck in the `subscriptionPending` state
package/Makefile CHANGED
@@ -1,17 +1,14 @@
1
1
  SHELL := /bin/bash
2
2
 
3
+ .PHONY: build_all
3
4
  build_all: web react-native node worker
4
5
 
5
- # sockjs:
6
- # pushd src/runtimes/web/dom/sockjs && \
7
- # npm install && \
8
- # make build && \
9
- # popd
10
-
6
+ .PHONY: json2
11
7
  json2:
12
8
  cp src/runtimes/web/dom/json2.js dist/web
13
9
  node_modules/.bin/uglifyjs dist/web/json2.js -o dist/web/json2.min.js
14
10
 
11
+ .PHONY: web
15
12
  web:
16
13
  @echo "Browser Release:"
17
14
  MINIMIZE=false node_modules/webpack/bin/webpack.js --config=webpack/config.web.js
@@ -25,14 +22,17 @@ web:
25
22
  @echo "Minified Browser Release (with encryption)"
26
23
  INCLUDE_TWEETNACL=true node_modules/webpack/bin/webpack.js --config=webpack/config.web.js
27
24
 
25
+ .PHONY: react-native
28
26
  react-native:
29
27
  @echo "React Native Release:"
30
28
  node_modules/webpack/bin/webpack.js --config=webpack/config.react-native.js
31
29
 
30
+ .PHONY: node
32
31
  node:
33
32
  @echo "NodeJS Release":
34
33
  MINIMIZE=false node_modules/webpack/bin/webpack.js --config=webpack/config.node.js
35
34
 
35
+ .PHONY: worker
36
36
  worker:
37
37
  @echo "Web Worker Release"
38
38
  MINIMIZE=false node_modules/webpack/bin/webpack.js --config=webpack/config.worker.js
@@ -46,27 +46,32 @@ worker:
46
46
  @echo "Minified Web Worker Release (with encryption)"
47
47
  INCLUDE_TWEETNACL=true node_modules/webpack/bin/webpack.js --config=webpack/config.worker.js
48
48
 
49
+ .PHONY: web_unit
49
50
  web_unit:
50
51
  node_modules/karma/bin/karma start spec/config/karma/unit.js
51
52
 
53
+ .PHONY: web_integration
52
54
  web_integration:
53
55
  node_modules/karma/bin/karma start spec/config/karma/integration.js
54
56
 
57
+ .PHONY: worker_unit
55
58
  worker_unit:
56
59
  WORKER=true node_modules/karma/bin/karma start spec/config/karma/unit.js
57
60
 
61
+ .PHONY: worker_integration
58
62
  worker_integration:
59
63
  WORKER=true node_modules/karma/bin/karma start spec/config/karma/integration.js
60
64
 
65
+ .PHONY: node_unit
61
66
  node_unit:
62
- node_modules/webpack/bin/webpack.js --config=spec/config/jasmine-node/webpack.unit.js && \
63
- node spec/config/jasmine-node/config.js ./tmp/node_unit
67
+ node_modules/webpack/bin/webpack.js --config=spec/config/jasmine/webpack.unit.js && \
68
+ node_modules/.bin/jasmine --config=spec/config/jasmine/unit.json
64
69
 
70
+ .PHONY: node_integration
65
71
  node_integration:
66
- node_modules/webpack/bin/webpack.js --config=spec/config/jasmine-node/webpack.integration.js && \
67
- node spec/config/jasmine-node/config.js ./tmp/node_integration
72
+ node_modules/webpack/bin/webpack.js --config=spec/config/jasmine/webpack.integration.js && \
73
+ node_modules/.bin/jasmine --config=spec/config/jasmine/integration.json
68
74
 
75
+ .PHONY: serve
69
76
  serve:
70
77
  node webpack/dev.server.js
71
-
72
- .PHONY: react-native build_all
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Pusher Channels Javascript Client
2
2
 
3
+ ![test badge](https://github.com/pusher/pusher-js/workflows/test/badge.svg)
4
+
3
5
  This Pusher Channels client library supports web browsers, web workers, Node.js
4
6
  and React Native.
5
7
 
@@ -181,6 +183,18 @@ If you'd like to use encrypted channels:
181
183
  importScripts('https://js.pusher.com/7.0/pusher-with-encryption.worker.min.js');
182
184
  ```
183
185
 
186
+ If you're building your worker with a bundler, you can import the worker entrypoint
187
+
188
+ ```
189
+ import Pusher from 'pusher-js/worker'
190
+ ```
191
+
192
+ If you'd like to use encrypted channels:
193
+
194
+ ```
195
+ import Pusher from 'pusher-js/worker/with-encryption'
196
+ ```
197
+
184
198
  ### Node.js
185
199
 
186
200
  Having installed `pusher-js` via an NPM-compatible package manager, run:
@@ -598,6 +612,20 @@ channel.unbind_global();
598
612
 
599
613
  The `unbind_all` method is equivalent to calling `unbind()` and `unbind_global()` together; it removes all bindings, global and event specific.
600
614
 
615
+ ## Triggering Client Events
616
+
617
+ It's possible to trigger [client events](https://pusher.com/docs/channels/using_channels/events#triggering-client-events) using the `trigger` method on an instance of the `Channel` class.
618
+
619
+ A few gotchas to consider when using client events:
620
+ - Client events can only be triggered on private/presence channels
621
+ - Client events must be enabled in the settings page for your app: `https://dashboard.pusher.com/apps/$YOUR_APP_ID/settings`
622
+ - The event name for client events *must* start with `client-`
623
+
624
+ ```
625
+ channel.trigger('client-my-event', {message: 'Hello, world!'})
626
+ ```
627
+
628
+
601
629
  ## Batching auth requests (aka multi-auth)
602
630
 
603
631
  Currently, pusher-js itself does not support authenticating multiple channels in one HTTP request. However, thanks to @dirkbonhomme you can use the [pusher-js-auth](https://github.com/dirkbonhomme/pusher-js-auth) plugin that buffers subscription requests and sends auth requests to your endpoint in batches.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v7.0.1
2
+ * Pusher JavaScript Library v7.0.5
3
3
  * https://pusher.com/
4
4
  *
5
5
  * Copyright 2020, Pusher
@@ -369,12 +369,6 @@ module.exports = Base;
369
369
 
370
370
  /***/ }),
371
371
  /* 3 */
372
- /***/ (function(module, exports) {
373
-
374
- module.exports = require("crypto");
375
-
376
- /***/ }),
377
- /* 4 */
378
372
  /***/ (function(module, exports, __webpack_require__) {
379
373
 
380
374
  "use strict";
@@ -424,11 +418,17 @@ module.exports = Driver;
424
418
 
425
419
 
426
420
  /***/ }),
427
- /* 5 */
421
+ /* 4 */
428
422
  /***/ (function(module, exports) {
429
423
 
430
424
  module.exports = require("stream");
431
425
 
426
+ /***/ }),
427
+ /* 5 */
428
+ /***/ (function(module, exports) {
429
+
430
+ module.exports = require("crypto");
431
+
432
432
  /***/ }),
433
433
  /* 6 */
434
434
  /***/ (function(module, exports) {
@@ -437,7 +437,10 @@ module.exports = require("url");
437
437
 
438
438
  /***/ }),
439
439
  /* 7 */
440
- /***/ (function(module, exports) {
440
+ /***/ (function(module, exports, __webpack_require__) {
441
+
442
+ "use strict";
443
+
441
444
 
442
445
  var Event = function(eventType, options) {
443
446
  this.type = eventType;
@@ -747,7 +750,7 @@ exports.maxDecodedLength = function (length) {
747
750
  exports.decodedLength = function (s) {
748
751
  return stdCoder.decodedLength(s);
749
752
  };
750
- //# sourceMappingURL=base64.js.map
753
+
751
754
 
752
755
  /***/ }),
753
756
  /* 9 */
@@ -937,9 +940,12 @@ module.exports = HttpParser;
937
940
  /* 11 */
938
941
  /***/ (function(module, exports, __webpack_require__) {
939
942
 
940
- var Stream = __webpack_require__(5).Stream,
943
+ "use strict";
944
+
945
+
946
+ var Stream = __webpack_require__(4).Stream,
941
947
  util = __webpack_require__(0),
942
- driver = __webpack_require__(4),
948
+ driver = __webpack_require__(3),
943
949
  EventTarget = __webpack_require__(16),
944
950
  Event = __webpack_require__(7);
945
951
 
@@ -1002,6 +1008,8 @@ API.OPEN = 1;
1002
1008
  API.CLOSING = 2;
1003
1009
  API.CLOSED = 3;
1004
1010
 
1011
+ API.CLOSE_TIMEOUT = 30000;
1012
+
1005
1013
  var instance = {
1006
1014
  write: function(data) {
1007
1015
  return this.send(data);
@@ -1031,9 +1039,23 @@ var instance = {
1031
1039
  return this._driver.ping(message, callback);
1032
1040
  },
1033
1041
 
1034
- close: function() {
1042
+ close: function(code, reason) {
1043
+ if (code === undefined) code = 1000;
1044
+ if (reason === undefined) reason = '';
1045
+
1046
+ if (code !== 1000 && (code < 3000 || code > 4999))
1047
+ throw new Error("Failed to execute 'close' on WebSocket: " +
1048
+ "The code must be either 1000, or between 3000 and 4999. " +
1049
+ code + " is neither.");
1050
+
1035
1051
  if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;
1036
- this._driver.close();
1052
+ var self = this;
1053
+
1054
+ this._closeTimer = setTimeout(function() {
1055
+ self._beginClose('', 1006);
1056
+ }, API.CLOSE_TIMEOUT);
1057
+
1058
+ this._driver.close(reason, code);
1037
1059
  },
1038
1060
 
1039
1061
  _configureStream: function() {
@@ -1052,7 +1074,7 @@ var instance = {
1052
1074
  });
1053
1075
  },
1054
1076
 
1055
- _open: function() {
1077
+ _open: function() {
1056
1078
  if (this.readyState !== API.CONNECTING) return;
1057
1079
 
1058
1080
  this.readyState = API.OPEN;
@@ -1084,18 +1106,19 @@ var instance = {
1084
1106
  _beginClose: function(reason, code) {
1085
1107
  if (this.readyState === API.CLOSED) return;
1086
1108
  this.readyState = API.CLOSING;
1109
+ this._closeParams = [reason, code];
1087
1110
 
1088
1111
  if (this._stream) {
1089
- this._stream.end();
1112
+ this._stream.destroy();
1090
1113
  if (!this._stream.readable) this._finalizeClose();
1091
1114
  }
1092
- this._closeParams = [reason, code];
1093
1115
  },
1094
1116
 
1095
1117
  _finalizeClose: function() {
1096
1118
  if (this.readyState === API.CLOSED) return;
1097
1119
  this.readyState = API.CLOSED;
1098
1120
 
1121
+ if (this._closeTimer) clearTimeout(this._closeTimer);
1099
1122
  if (this._pingTimer) clearInterval(this._pingTimer);
1100
1123
  if (this._stream) this._stream.end();
1101
1124
 
@@ -1125,7 +1148,7 @@ module.exports = API;
1125
1148
 
1126
1149
 
1127
1150
  var Buffer = __webpack_require__(1).Buffer,
1128
- crypto = __webpack_require__(3),
1151
+ crypto = __webpack_require__(5),
1129
1152
  util = __webpack_require__(0),
1130
1153
  Extensions = __webpack_require__(29),
1131
1154
  Base = __webpack_require__(2),
@@ -1858,6 +1881,9 @@ module.exports = Draft75;
1858
1881
  /* 16 */
1859
1882
  /***/ (function(module, exports, __webpack_require__) {
1860
1883
 
1884
+ "use strict";
1885
+
1886
+
1861
1887
  var Event = __webpack_require__(7);
1862
1888
 
1863
1889
  var EventTarget = {
@@ -2041,20 +2067,23 @@ function decode(arr) {
2041
2067
  return chars.join("");
2042
2068
  }
2043
2069
  exports.decode = decode;
2044
- //# sourceMappingURL=utf8.js.map
2070
+
2045
2071
 
2046
2072
  /***/ }),
2047
2073
  /* 18 */
2048
2074
  /***/ (function(module, exports, __webpack_require__) {
2049
2075
 
2076
+ "use strict";
2050
2077
  // API references:
2051
2078
  //
2052
- // * http://dev.w3.org/html5/websockets/
2053
- // * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget
2054
- // * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-event
2079
+ // * https://html.spec.whatwg.org/multipage/comms.html#network
2080
+ // * https://dom.spec.whatwg.org/#interface-eventtarget
2081
+ // * https://dom.spec.whatwg.org/#interface-event
2082
+
2083
+
2055
2084
 
2056
2085
  var util = __webpack_require__(0),
2057
- driver = __webpack_require__(4),
2086
+ driver = __webpack_require__(3),
2058
2087
  API = __webpack_require__(11);
2059
2088
 
2060
2089
  var WebSocket = function(request, socket, body, protocols, options) {
@@ -5103,7 +5132,7 @@ nacl.setPRNG = function(fn) {
5103
5132
  });
5104
5133
  } else if (true) {
5105
5134
  // Node.js.
5106
- crypto = __webpack_require__(3);
5135
+ crypto = __webpack_require__(5);
5107
5136
  if (crypto && crypto.randomBytes) {
5108
5137
  nacl.setPRNG(function(x, n) {
5109
5138
  var i, v = crypto.randomBytes(n);
@@ -5186,7 +5215,7 @@ driver having these two methods.
5186
5215
  **/
5187
5216
 
5188
5217
 
5189
- var Stream = __webpack_require__(5).Stream,
5218
+ var Stream = __webpack_require__(4).Stream,
5190
5219
  util = __webpack_require__(0);
5191
5220
 
5192
5221
 
@@ -5373,7 +5402,7 @@ module.exports = StreamReader;
5373
5402
 
5374
5403
 
5375
5404
  var Buffer = __webpack_require__(1).Buffer,
5376
- crypto = __webpack_require__(3),
5405
+ crypto = __webpack_require__(5),
5377
5406
  url = __webpack_require__(6),
5378
5407
  util = __webpack_require__(0),
5379
5408
  HttpParser = __webpack_require__(10),
@@ -6500,7 +6529,7 @@ module.exports = Message;
6500
6529
 
6501
6530
 
6502
6531
  var Buffer = __webpack_require__(1).Buffer,
6503
- Stream = __webpack_require__(5).Stream,
6532
+ Stream = __webpack_require__(4).Stream,
6504
6533
  url = __webpack_require__(6),
6505
6534
  util = __webpack_require__(0),
6506
6535
  Base = __webpack_require__(2),
@@ -6727,7 +6756,7 @@ module.exports = Server;
6727
6756
  var Buffer = __webpack_require__(1).Buffer,
6728
6757
  Base = __webpack_require__(2),
6729
6758
  Draft75 = __webpack_require__(15),
6730
- crypto = __webpack_require__(3),
6759
+ crypto = __webpack_require__(5),
6731
6760
  util = __webpack_require__(0);
6732
6761
 
6733
6762
 
@@ -6845,12 +6874,14 @@ module.exports = Draft76;
6845
6874
  /* 39 */
6846
6875
  /***/ (function(module, exports, __webpack_require__) {
6847
6876
 
6877
+ "use strict";
6878
+
6879
+
6848
6880
  var util = __webpack_require__(0),
6849
6881
  net = __webpack_require__(40),
6850
6882
  tls = __webpack_require__(41),
6851
- crypto = __webpack_require__(3),
6852
6883
  url = __webpack_require__(6),
6853
- driver = __webpack_require__(4),
6884
+ driver = __webpack_require__(3),
6854
6885
  API = __webpack_require__(11),
6855
6886
  Event = __webpack_require__(7);
6856
6887
 
@@ -6870,20 +6901,25 @@ var Client = function(_url, protocols, options) {
6870
6901
  });
6871
6902
  }, this);
6872
6903
 
6873
- var proxy = options.proxy || {},
6874
- endpoint = url.parse(proxy.origin || this.url),
6875
- port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],
6876
- secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,
6877
- onConnect = function() { self._onConnect() },
6878
- originTLS = options.tls || {},
6879
- socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,
6880
- self = this;
6904
+ var proxy = options.proxy || {},
6905
+ endpoint = url.parse(proxy.origin || this.url),
6906
+ port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],
6907
+ secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,
6908
+ onConnect = function() { self._onConnect() },
6909
+ netOptions = options.net || {},
6910
+ originTLS = options.tls || {},
6911
+ socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,
6912
+ self = this;
6913
+
6914
+ netOptions.host = socketTLS.host = endpoint.hostname;
6915
+ netOptions.port = socketTLS.port = port;
6881
6916
 
6882
6917
  originTLS.ca = originTLS.ca || options.ca;
6918
+ socketTLS.servername = socketTLS.servername || endpoint.hostname;
6883
6919
 
6884
6920
  this._stream = secure
6885
- ? tls.connect(port, endpoint.hostname, socketTLS, onConnect)
6886
- : net.connect(port, endpoint.hostname, onConnect);
6921
+ ? tls.connect(socketTLS, onConnect)
6922
+ : net.connect(netOptions, onConnect);
6887
6923
 
6888
6924
  if (proxy.origin) this._configureProxy(proxy, originTLS);
6889
6925
 
@@ -6947,9 +6983,12 @@ module.exports = require("tls");
6947
6983
  /* 42 */
6948
6984
  /***/ (function(module, exports, __webpack_require__) {
6949
6985
 
6950
- var Stream = __webpack_require__(5).Stream,
6986
+ "use strict";
6987
+
6988
+
6989
+ var Stream = __webpack_require__(4).Stream,
6951
6990
  util = __webpack_require__(0),
6952
- driver = __webpack_require__(4),
6991
+ driver = __webpack_require__(3),
6953
6992
  Headers = __webpack_require__(9),
6954
6993
  API = __webpack_require__(11),
6955
6994
  EventTarget = __webpack_require__(16),
@@ -7109,6 +7148,7 @@ module.exports = require("https");
7109
7148
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
7110
7149
 
7111
7150
  "use strict";
7151
+ // ESM COMPAT FLAG
7112
7152
  __webpack_require__.r(__webpack_exports__);
7113
7153
 
7114
7154
  // CONCATENATED MODULE: ./src/core/base64.ts
@@ -7447,7 +7487,7 @@ function safeJSONStringify(source) {
7447
7487
 
7448
7488
  // CONCATENATED MODULE: ./src/core/defaults.ts
7449
7489
  var Defaults = {
7450
- VERSION: "7.0.1",
7490
+ VERSION: "7.0.5",
7451
7491
  PROTOCOL: 7,
7452
7492
  wsPort: 80,
7453
7493
  wssPort: 443,
@@ -10777,4 +10817,5 @@ var pusher_with_encryption_PusherWithEncryption = (function (_super) {
10777
10817
 
10778
10818
 
10779
10819
  /***/ })
10780
- /******/ ]);
10820
+ /******/ ]);
10821
+ //# sourceMappingURL=pusher.js.map