@camstack/sdk 1.2.132 → 1.2.134

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/dist/index.cjs CHANGED
@@ -701,6 +701,11 @@ var System = class {
701
701
  mirror = null;
702
702
  mirrorInit = null;
703
703
  connected = false;
704
+ /**
705
+ * The token the current socket's handshake carried (`undefined` token =
706
+ * anonymous handshake); `null` until a handshake has been attempted.
707
+ */
708
+ _wsHandshake = null;
704
709
  connectedPromise = null;
705
710
  _systemProxy;
706
711
  _connectionVersion = 0;
@@ -853,6 +858,7 @@ var System = class {
853
858
  this.resetEventSubs();
854
859
  this.connected = false;
855
860
  this.connectedPromise = null;
861
+ this._wsHandshake = null;
856
862
  this._trpcClient = this.buildTrpcClient();
857
863
  this._systemProxy = (0, _camstack_types_client.createSystemProxy)(this._trpcClient);
858
864
  }
@@ -1123,6 +1129,16 @@ var System = class {
1123
1129
  this.token = token;
1124
1130
  }
1125
1131
  /**
1132
+ * True when the live WebSocket was handshaken with a token other than the
1133
+ * current one (anonymous, or rotated since). The socket authenticates once,
1134
+ * at the handshake, so such a socket answers every protected call
1135
+ * UNAUTHORIZED until `reconnect()`. Always false for HTTP transport.
1136
+ */
1137
+ isSocketTokenStale() {
1138
+ if (!this.useWs || this._wsHandshake === null) return false;
1139
+ return this._wsHandshake.token !== this.token;
1140
+ }
1141
+ /**
1126
1142
  * Synchronous snapshot of every device matching the optional filters.
1127
1143
  * Backed by the `SystemMirror` warm-boot cache — call `init()` first
1128
1144
  * (or `awaitReady()`) before invoking. Returns an empty array if the
@@ -1368,6 +1384,7 @@ var System = class {
1368
1384
  this._wsClient = (0, _trpc_client.createWSClient)({
1369
1385
  url: wsUrl,
1370
1386
  connectionParams: () => {
1387
+ if (epoch === this._wsEpoch) this._wsHandshake = { token: this.token };
1371
1388
  const lang = this.getLanguage();
1372
1389
  return {
1373
1390
  ...this.token !== void 0 ? { token: this.token } : {},
package/dist/index.js CHANGED
@@ -700,6 +700,11 @@ var System = class {
700
700
  mirror = null;
701
701
  mirrorInit = null;
702
702
  connected = false;
703
+ /**
704
+ * The token the current socket's handshake carried (`undefined` token =
705
+ * anonymous handshake); `null` until a handshake has been attempted.
706
+ */
707
+ _wsHandshake = null;
703
708
  connectedPromise = null;
704
709
  _systemProxy;
705
710
  _connectionVersion = 0;
@@ -852,6 +857,7 @@ var System = class {
852
857
  this.resetEventSubs();
853
858
  this.connected = false;
854
859
  this.connectedPromise = null;
860
+ this._wsHandshake = null;
855
861
  this._trpcClient = this.buildTrpcClient();
856
862
  this._systemProxy = createSystemProxy(this._trpcClient);
857
863
  }
@@ -1122,6 +1128,16 @@ var System = class {
1122
1128
  this.token = token;
1123
1129
  }
1124
1130
  /**
1131
+ * True when the live WebSocket was handshaken with a token other than the
1132
+ * current one (anonymous, or rotated since). The socket authenticates once,
1133
+ * at the handshake, so such a socket answers every protected call
1134
+ * UNAUTHORIZED until `reconnect()`. Always false for HTTP transport.
1135
+ */
1136
+ isSocketTokenStale() {
1137
+ if (!this.useWs || this._wsHandshake === null) return false;
1138
+ return this._wsHandshake.token !== this.token;
1139
+ }
1140
+ /**
1125
1141
  * Synchronous snapshot of every device matching the optional filters.
1126
1142
  * Backed by the `SystemMirror` warm-boot cache — call `init()` first
1127
1143
  * (or `awaitReady()`) before invoking. Returns an empty array if the
@@ -1367,6 +1383,7 @@ var System = class {
1367
1383
  this._wsClient = createWSClient({
1368
1384
  url: wsUrl,
1369
1385
  connectionParams: () => {
1386
+ if (epoch === this._wsEpoch) this._wsHandshake = { token: this.token };
1370
1387
  const lang = this.getLanguage();
1371
1388
  return {
1372
1389
  ...this.token !== void 0 ? { token: this.token } : {},
package/dist/system.d.ts CHANGED
@@ -130,6 +130,11 @@ export declare class System {
130
130
  private mirror;
131
131
  private mirrorInit;
132
132
  private connected;
133
+ /**
134
+ * The token the current socket's handshake carried (`undefined` token =
135
+ * anonymous handshake); `null` until a handshake has been attempted.
136
+ */
137
+ private _wsHandshake;
133
138
  private connectedPromise;
134
139
  private _systemProxy;
135
140
  private _connectionVersion;
@@ -388,6 +393,13 @@ export declare class System {
388
393
  /** Update the auth token (e.g. after login or token refresh). */
389
394
  setToken(token: string): void;
390
395
  /**
396
+ * True when the live WebSocket was handshaken with a token other than the
397
+ * current one (anonymous, or rotated since). The socket authenticates once,
398
+ * at the handshake, so such a socket answers every protected call
399
+ * UNAUTHORIZED until `reconnect()`. Always false for HTTP transport.
400
+ */
401
+ isSocketTokenStale(): boolean;
402
+ /**
391
403
  * Synchronous snapshot of every device matching the optional filters.
392
404
  * Backed by the `SystemMirror` warm-boot cache — call `init()` first
393
405
  * (or `awaitReady()`) before invoking. Returns an empty array if the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/sdk",
3
- "version": "1.2.132",
3
+ "version": "1.2.134",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",