laravel-echo-api-gateway 0.5.4 → 0.5.8

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.
@@ -3,6 +3,15 @@ name: Publish new release
3
3
  on:
4
4
  release:
5
5
  types: [ published ]
6
+ workflow_dispatch:
7
+ inputs:
8
+ version:
9
+ description: Version to publish (e.g. 0.5.8)
10
+ required: true
11
+
12
+ permissions:
13
+ id-token: write # npm trusted publishing (OIDC)
14
+ contents: write # push the version bump
6
15
 
7
16
  jobs:
8
17
  release:
@@ -13,22 +22,20 @@ jobs:
13
22
  - uses: actions/checkout@v4
14
23
  with:
15
24
  ref: ${{ github.event.release.target_commitish }}
16
- - name: Use Node.js 12
25
+ - name: Use Node.js 24
17
26
  uses: actions/setup-node@v4
18
27
  with:
19
- node-version: 18
28
+ node-version: 24
20
29
  registry-url: https://registry.npmjs.org/
21
30
  - run: npm ci --verbose
22
31
  - run: git config --global user.name "GitHub CD bot"
23
32
  - run: git config --global user.email "github-cd-bot@github.com"
24
- - run: npm --no-git-tag-version version ${{ github.event.release.tag_name }}
33
+ - run: npm --no-git-tag-version version "$VERSION"
34
+ env:
35
+ VERSION: ${{ github.event.release.tag_name || inputs.version }}
25
36
  # - run: npm run build
26
37
  # - run: npm run test
27
38
  - run: npm publish --verbose --access public --tag latest
28
- env:
29
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30
- - run: git add package.json
39
+ - run: git add package.json package-lock.json
31
40
  - run: git commit -m 'Bump version'
32
41
  - run: git push
33
- env:
34
- github-token: ${{ secrets.GITHUB_TOKEN }}
package/README.md CHANGED
@@ -13,15 +13,12 @@ messages. We also configure Laravel to use this connection as a broadcast driver
13
13
  This package currently only works with either [Bref](https://bref.sh) or [Laravel Vapor](https://vapor.laravel.com),
14
14
  though the latter one involves some manual set-up.
15
15
 
16
- As soon as version 1.0 will be released, this package will be suitable for production workloads. Until then, it is
17
- advised to only use this package for non-critical / non-production projects.
18
-
19
16
  ## Requirements
20
17
 
21
18
  In order to use this package, your project needs to meet the following criteria:
22
19
 
23
- - PHP 7.4 or 8.x
24
- - Laravel 6 to 11
20
+ - PHP 8.x
21
+ - Laravel 6 to 12
25
22
  - Uses either [bref](https://bref.sh) or [Laravel Vapor](https://vapor.laravel.com) to deploy to AWS
26
23
  - Has a working queue
27
24
  - Uses Laravel Mix or any other tool to bundle your assets
@@ -2,12 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var axios = require('axios');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
-
11
5
  function _classCallCheck(instance, Constructor) {
12
6
  if (!(instance instanceof Constructor)) {
13
7
  throw new TypeError("Cannot call a class as a function");
@@ -453,19 +447,29 @@ var Websocket = /*#__PURE__*/function () {
453
447
  this.options.auth.headers['Authorization'] = 'Bearer ' + this.options.bearerToken;
454
448
  }
455
449
 
456
- axios__default['default'].post(this.options.authEndpoint, {
457
- socket_id: this.getSocketId(),
458
- channel_name: channel.name
459
- }, {
460
- headers: this.options.auth.headers || {}
450
+ fetch(this.options.authEndpoint, {
451
+ method: 'POST',
452
+ headers: _extends({
453
+ 'Content-Type': 'application/json'
454
+ }, this.options.auth.headers),
455
+ body: JSON.stringify({
456
+ socket_id: this.getSocketId(),
457
+ channel_name: channel.name
458
+ })
461
459
  }).then(function (response) {
460
+ if (!response.ok) {
461
+ throw new Error("Auth request failed: ".concat(response.status));
462
+ }
463
+
464
+ return response.json();
465
+ }).then(function (data) {
462
466
  _this2.options.debug && console.log("".concat(LOG_PREFIX, " Subscribing to private channel ").concat(channel.name));
463
467
 
464
468
  _this2.send({
465
469
  event: 'subscribe',
466
470
  data: _extends({
467
471
  channel: channel.name
468
- }, response.data)
472
+ }, data)
469
473
  });
470
474
  })["catch"](function (error) {
471
475
  _this2.options.debug && console.log("".concat(LOG_PREFIX, " Auth request for channel ").concat(channel.name, " failed"));
@@ -1,10 +1,6 @@
1
- var LaravelEchoApiGateway = (function (exports, axios) {
1
+ var LaravelEchoApiGateway = (function (exports) {
2
2
  'use strict';
3
3
 
4
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
5
-
6
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
7
-
8
4
  function _classCallCheck(instance, Constructor) {
9
5
  if (!(instance instanceof Constructor)) {
10
6
  throw new TypeError("Cannot call a class as a function");
@@ -450,19 +446,29 @@ var LaravelEchoApiGateway = (function (exports, axios) {
450
446
  this.options.auth.headers['Authorization'] = 'Bearer ' + this.options.bearerToken;
451
447
  }
452
448
 
453
- axios__default['default'].post(this.options.authEndpoint, {
454
- socket_id: this.getSocketId(),
455
- channel_name: channel.name
456
- }, {
457
- headers: this.options.auth.headers || {}
449
+ fetch(this.options.authEndpoint, {
450
+ method: 'POST',
451
+ headers: _extends({
452
+ 'Content-Type': 'application/json'
453
+ }, this.options.auth.headers),
454
+ body: JSON.stringify({
455
+ socket_id: this.getSocketId(),
456
+ channel_name: channel.name
457
+ })
458
458
  }).then(function (response) {
459
+ if (!response.ok) {
460
+ throw new Error("Auth request failed: ".concat(response.status));
461
+ }
462
+
463
+ return response.json();
464
+ }).then(function (data) {
459
465
  _this2.options.debug && console.log("".concat(LOG_PREFIX, " Subscribing to private channel ").concat(channel.name));
460
466
 
461
467
  _this2.send({
462
468
  event: 'subscribe',
463
469
  data: _extends({
464
470
  channel: channel.name
465
- }, response.data)
471
+ }, data)
466
472
  });
467
473
  })["catch"](function (error) {
468
474
  _this2.options.debug && console.log("".concat(LOG_PREFIX, " Auth request for channel ").concat(channel.name, " failed"));
@@ -871,4 +877,4 @@ var LaravelEchoApiGateway = (function (exports, axios) {
871
877
 
872
878
  return exports;
873
879
 
874
- }({}, axios));
880
+ }({}));
@@ -1,5 +1,3 @@
1
- import axios from 'axios';
2
-
3
1
  function _classCallCheck(instance, Constructor) {
4
2
  if (!(instance instanceof Constructor)) {
5
3
  throw new TypeError("Cannot call a class as a function");
@@ -445,19 +443,29 @@ var Websocket = /*#__PURE__*/function () {
445
443
  this.options.auth.headers['Authorization'] = 'Bearer ' + this.options.bearerToken;
446
444
  }
447
445
 
448
- axios.post(this.options.authEndpoint, {
449
- socket_id: this.getSocketId(),
450
- channel_name: channel.name
451
- }, {
452
- headers: this.options.auth.headers || {}
446
+ fetch(this.options.authEndpoint, {
447
+ method: 'POST',
448
+ headers: _extends({
449
+ 'Content-Type': 'application/json'
450
+ }, this.options.auth.headers),
451
+ body: JSON.stringify({
452
+ socket_id: this.getSocketId(),
453
+ channel_name: channel.name
454
+ })
453
455
  }).then(function (response) {
456
+ if (!response.ok) {
457
+ throw new Error("Auth request failed: ".concat(response.status));
458
+ }
459
+
460
+ return response.json();
461
+ }).then(function (data) {
454
462
  _this2.options.debug && console.log("".concat(LOG_PREFIX, " Subscribing to private channel ").concat(channel.name));
455
463
 
456
464
  _this2.send({
457
465
  event: 'subscribe',
458
466
  data: _extends({
459
467
  channel: channel.name
460
- }, response.data)
468
+ }, data)
461
469
  });
462
470
  })["catch"](function (error) {
463
471
  _this2.options.debug && console.log("".concat(LOG_PREFIX, " Auth request for channel ").concat(channel.name, " failed"));
@@ -1,6 +1,4 @@
1
- import { AxiosResponse } from "axios";
2
1
  import { Channel } from "./Channel";
3
- import axios from 'axios';
4
2
 
5
3
  export type Options = { authEndpoint: string, host: string, bearerToken: string, auth: any, debug: boolean };
6
4
 
@@ -199,19 +197,30 @@ export class Websocket {
199
197
  this.options.auth.headers['Authorization'] = 'Bearer ' + this.options.bearerToken;
200
198
  }
201
199
 
202
- axios.post(this.options.authEndpoint, {
203
- socket_id: this.getSocketId(),
204
- channel_name: channel.name,
205
- }, {
206
- headers: this.options.auth.headers || {}
207
- }).then((response: AxiosResponse) => {
200
+ fetch(this.options.authEndpoint, {
201
+ method: 'POST',
202
+ headers: {
203
+ 'Content-Type': 'application/json',
204
+ ...this.options.auth.headers,
205
+ },
206
+ body: JSON.stringify({
207
+ socket_id: this.getSocketId(),
208
+ channel_name: channel.name,
209
+ }),
210
+ }).then((response) => {
211
+ if (!response.ok) {
212
+ throw new Error(`Auth request failed: ${response.status}`);
213
+ }
214
+
215
+ return response.json();
216
+ }).then((data) => {
208
217
  this.options.debug && console.log(`${LOG_PREFIX} Subscribing to private channel ${channel.name}`);
209
218
 
210
219
  this.send({
211
220
  event: 'subscribe',
212
221
  data: {
213
222
  channel: channel.name,
214
- ...response.data
223
+ ...data,
215
224
  },
216
225
  });
217
226
  }).catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laravel-echo-api-gateway",
3
- "version": "0.5.4",
3
+ "version": "0.5.8",
4
4
  "description": "Use Laravel Echo with API Gateway Websockets",
5
5
  "keywords": [
6
6
  "laravel",
@@ -45,7 +45,6 @@
45
45
  "@types/node": "^12.7.5",
46
46
  "@typescript-eslint/eslint-plugin": "^3.7.0",
47
47
  "@typescript-eslint/parser": "^3.7.0",
48
- "axios": "^0.21.1",
49
48
  "eslint": "^7.5.0",
50
49
  "jest": "^24.9.0",
51
50
  "jest-websocket-mock": "^2.2.0",
@@ -1,4 +1,4 @@
1
- declare const axios: import('axios').AxiosStatic;
1
+ declare const axios: any;
2
2
  declare const Pusher: any;
3
3
  declare const io: any;
4
4
  declare const Vue: any;