@eleven-am/pondsocket-client 0.0.31 → 0.0.34

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.
package/browser/client.js CHANGED
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _PondClient_instances, _PondClient_channels, _PondClient_clearTimeouts, _PondClient_createPublisher, _PondClient_handleAcknowledge, _PondClient_init;
13
+ var _PondClient_instances, _PondClient_channels, _PondClient_clearTimeouts, _PondClient_createPublisher, _PondClient_handleAcknowledge, _PondClient_handleUnauthorized, _PondClient_init;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.PondClient = void 0;
16
16
  const pondsocket_common_1 = require("@eleven-am/pondsocket-common");
@@ -30,6 +30,7 @@ class PondClient {
30
30
  catch (e) {
31
31
  address = new URL(window.location.toString());
32
32
  address.pathname = endpoint;
33
+ address.hash = '';
33
34
  }
34
35
  this._disconnecting = false;
35
36
  this._reconnectAttempts = 0;
@@ -173,11 +174,20 @@ _PondClient_channels = new WeakMap(), _PondClient_instances = new WeakSet(), _Po
173
174
  const channel = (_a = __classPrivateFieldGet(this, _PondClient_channels, "f").get(message.channelName)) !== null && _a !== void 0 ? _a : new channel_1.Channel(__classPrivateFieldGet(this, _PondClient_instances, "m", _PondClient_createPublisher).call(this), this._connectionState, message.channelName, {});
174
175
  __classPrivateFieldGet(this, _PondClient_channels, "f").set(message.channelName, channel);
175
176
  channel.acknowledge(this._broadcaster);
177
+ }, _PondClient_handleUnauthorized = function _PondClient_handleUnauthorized(message) {
178
+ const channel = __classPrivateFieldGet(this, _PondClient_channels, "f").get(message.channelName);
179
+ if (channel) {
180
+ const payload = message.payload;
181
+ channel.decline(payload);
182
+ }
176
183
  }, _PondClient_init = function _PondClient_init() {
177
184
  this._broadcaster.subscribe((message) => {
178
185
  if (message.event === pondsocket_common_1.Events.ACKNOWLEDGE) {
179
186
  __classPrivateFieldGet(this, _PondClient_instances, "m", _PondClient_handleAcknowledge).call(this, message);
180
187
  }
188
+ else if (message.event === pondsocket_common_1.Events.UNAUTHORIZED) {
189
+ __classPrivateFieldGet(this, _PondClient_instances, "m", _PondClient_handleUnauthorized).call(this, message);
190
+ }
181
191
  else if (message.event === pondsocket_common_1.Events.CONNECTION && message.action === pondsocket_common_1.ServerActions.CONNECT) {
182
192
  this._connectionState.publish(types_1.ConnectionState.CONNECTED);
183
193
  }
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _SSEClient_instances, _SSEClient_channels, _SSEClient_handleMessage, _SSEClient_clearTimeout, _SSEClient_createPublisher, _SSEClient_handleAcknowledge, _SSEClient_init;
13
+ var _SSEClient_instances, _SSEClient_channels, _SSEClient_handleMessage, _SSEClient_clearTimeout, _SSEClient_createPublisher, _SSEClient_handleAcknowledge, _SSEClient_handleUnauthorized, _SSEClient_init;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.SSEClient = void 0;
16
16
  const pondsocket_common_1 = require("@eleven-am/pondsocket-common");
@@ -178,11 +178,20 @@ _SSEClient_channels = new WeakMap(), _SSEClient_instances = new WeakSet(), _SSEC
178
178
  const channel = (_a = __classPrivateFieldGet(this, _SSEClient_channels, "f").get(message.channelName)) !== null && _a !== void 0 ? _a : new channel_1.Channel(__classPrivateFieldGet(this, _SSEClient_instances, "m", _SSEClient_createPublisher).call(this), this._connectionState, message.channelName, {});
179
179
  __classPrivateFieldGet(this, _SSEClient_channels, "f").set(message.channelName, channel);
180
180
  channel.acknowledge(this._broadcaster);
181
+ }, _SSEClient_handleUnauthorized = function _SSEClient_handleUnauthorized(message) {
182
+ const channel = __classPrivateFieldGet(this, _SSEClient_channels, "f").get(message.channelName);
183
+ if (channel) {
184
+ const payload = message.payload;
185
+ channel.decline(payload);
186
+ }
181
187
  }, _SSEClient_init = function _SSEClient_init() {
182
188
  this._broadcaster.subscribe((message) => {
183
189
  if (message.event === pondsocket_common_1.Events.ACKNOWLEDGE) {
184
190
  __classPrivateFieldGet(this, _SSEClient_instances, "m", _SSEClient_handleAcknowledge).call(this, message);
185
191
  }
192
+ else if (message.event === pondsocket_common_1.Events.UNAUTHORIZED) {
193
+ __classPrivateFieldGet(this, _SSEClient_instances, "m", _SSEClient_handleUnauthorized).call(this, message);
194
+ }
186
195
  else if (message.event === pondsocket_common_1.Events.CONNECTION && message.action === pondsocket_common_1.ServerActions.CONNECT) {
187
196
  this._connectionState.publish(types_1.ConnectionState.CONNECTED);
188
197
  }
package/core/channel.js CHANGED
@@ -60,6 +60,14 @@ class Channel {
60
60
  __classPrivateFieldGet(this, _Channel_instances, "m", _Channel_init).call(this, receiver);
61
61
  __classPrivateFieldGet(this, _Channel_instances, "m", _Channel_emptyQueue).call(this);
62
62
  }
63
+ /**
64
+ * @desc Marks the channel join as declined by the server.
65
+ * @param payload - The decline payload containing status code and message.
66
+ */
67
+ decline(payload) {
68
+ __classPrivateFieldGet(this, _Channel_joinState, "f").publish(pondsocket_common_1.ChannelState.DECLINED);
69
+ __classPrivateFieldSet(this, _Channel_queue, [], "f");
70
+ }
63
71
  /**
64
72
  * @desc Connects to the channel.
65
73
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket-client",
3
- "version": "0.0.31",
3
+ "version": "0.0.34",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -30,19 +30,19 @@
30
30
  "pipeline": "npm run test && npm run build && npm run push"
31
31
  },
32
32
  "dependencies": {
33
- "@eleven-am/pondsocket-common": "^0.0.32",
33
+ "@eleven-am/pondsocket-common": "^0.0.34",
34
34
  "websocket": "^1.0.35"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/jest": "^30.0.0",
38
38
  "@types/websocket": "^1.0.10",
39
- "@typescript-eslint/eslint-plugin": "^8.46.1",
39
+ "@typescript-eslint/eslint-plugin": "^8.49.0",
40
40
  "eslint-plugin-file-progress": "^3.0.2",
41
41
  "eslint-plugin-import": "^2.32.0",
42
42
  "jest": "^30.2.0",
43
- "prettier": "^3.6.2",
43
+ "prettier": "^3.7.4",
44
44
  "supertest": "^7.1.4",
45
- "ts-jest": "^29.4.5",
45
+ "ts-jest": "^29.4.6",
46
46
  "ts-loader": "^9.5.4",
47
47
  "ts-node": "^10.9.2",
48
48
  "typescript": "^5.9.3"