@liveblocks/core 1.3.1 → 1.3.2

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.d.mts CHANGED
@@ -1103,7 +1103,8 @@ declare type YDocUpdate = {
1103
1103
  declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
1104
1104
  readonly type: ServerMsgCode.BROADCASTED_EVENT;
1105
1105
  /**
1106
- * The User who broadcasted the Event.
1106
+ * The User who broadcast the Event. Absent when this event is broadcast from
1107
+ * the REST API in the backend.
1107
1108
  */
1108
1109
  readonly actor: number;
1109
1110
  /**
@@ -1223,6 +1224,11 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
1223
1224
  };
1224
1225
 
1225
1226
  declare type CustomEvent<TRoomEvent extends Json> = {
1227
+ /**
1228
+ * The connection ID of the client that sent the event.
1229
+ * If this message was broadcast from the server (via the REST API), then
1230
+ * this value will be -1.
1231
+ */
1226
1232
  connectionId: number;
1227
1233
  event: TRoomEvent;
1228
1234
  };
package/dist/index.d.ts CHANGED
@@ -1103,7 +1103,8 @@ declare type YDocUpdate = {
1103
1103
  declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
1104
1104
  readonly type: ServerMsgCode.BROADCASTED_EVENT;
1105
1105
  /**
1106
- * The User who broadcasted the Event.
1106
+ * The User who broadcast the Event. Absent when this event is broadcast from
1107
+ * the REST API in the backend.
1107
1108
  */
1108
1109
  readonly actor: number;
1109
1110
  /**
@@ -1223,6 +1224,11 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
1223
1224
  };
1224
1225
 
1225
1226
  declare type CustomEvent<TRoomEvent extends Json> = {
1227
+ /**
1228
+ * The connection ID of the client that sent the event.
1229
+ * If this message was broadcast from the server (via the REST API), then
1230
+ * this value will be -1.
1231
+ */
1226
1232
  connectionId: number;
1227
1233
  event: TRoomEvent;
1228
1234
  };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "1.3.1";
9
+ var PKG_VERSION = "1.3.2";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1281,6 +1281,7 @@ function parseAuthToken(rawTokenString) {
1281
1281
  // src/auth-manager.ts
1282
1282
  function createAuthManager(authOptions) {
1283
1283
  const authentication = prepareAuthentication(authOptions);
1284
+ const seenTokens = /* @__PURE__ */ new Set();
1284
1285
  const tokens = [];
1285
1286
  const expiryTimes = [];
1286
1287
  const requestPromises = /* @__PURE__ */ new Map();
@@ -1304,8 +1305,6 @@ function createAuthManager(authOptions) {
1304
1305
  }
1305
1306
  if (token.parsed.k === "id" /* ID_TOKEN */) {
1306
1307
  return token;
1307
- } else if (token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
1308
- return void 0;
1309
1308
  } else if (token.parsed.k === "acc" /* ACCESS_TOKEN */) {
1310
1309
  for (const [resource, scopes] of Object.entries(token.parsed.perms)) {
1311
1310
  if (resource.includes("*") && roomId.startsWith(resource.replace("*", "")) || roomId === resource && hasCorrespondingScopes(requestedScope, scopes)) {
@@ -1327,7 +1326,13 @@ function createAuthManager(authOptions) {
1327
1326
  const response = await fetchAuthEndpoint(fetcher, authentication.url, {
1328
1327
  room: roomId
1329
1328
  });
1330
- return parseAuthToken(response.token);
1329
+ const parsed = parseAuthToken(response.token);
1330
+ if (seenTokens.has(parsed.raw)) {
1331
+ throw new StopRetrying(
1332
+ "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
1333
+ );
1334
+ }
1335
+ return parsed;
1331
1336
  }
1332
1337
  if (authentication.type === "custom") {
1333
1338
  const response = await authentication.callback(roomId);
@@ -1368,8 +1373,11 @@ function createAuthManager(authOptions) {
1368
1373
  const token = await currentPromise;
1369
1374
  const BUFFER = 30;
1370
1375
  const expiresAt = Math.floor(Date.now() / 1e3) + (token.parsed.exp - token.parsed.iat) - BUFFER;
1371
- tokens.push(token);
1372
- expiryTimes.push(expiresAt);
1376
+ seenTokens.add(token.raw);
1377
+ if (token.parsed.k !== "sec-legacy" /* SECRET_LEGACY */) {
1378
+ tokens.push(token);
1379
+ expiryTimes.push(expiresAt);
1380
+ }
1373
1381
  return { type: "secret", token };
1374
1382
  } finally {
1375
1383
  requestPromises.delete(roomId);