@liveblocks/core 1.3.0 → 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.mjs 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.0";
9
+ var PKG_VERSION = "1.3.2";
10
10
  var PKG_FORMAT = "esm";
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);
@@ -4754,7 +4762,7 @@ function createRoom(options, config) {
4754
4762
  } else {
4755
4763
  batchUpdates(() => {
4756
4764
  addToUndoStack(reverse, doNotBatchUpdates);
4757
- context.redoStack = [];
4765
+ context.redoStack.length = 0;
4758
4766
  dispatchOps(ops);
4759
4767
  notify({ storageUpdates }, doNotBatchUpdates);
4760
4768
  });
@@ -5484,6 +5492,10 @@ ${Array.from(traces).join("\n\n")}`
5484
5492
  }
5485
5493
  flushNowOrSoon();
5486
5494
  }
5495
+ function clear() {
5496
+ context.undoStack.length = 0;
5497
+ context.redoStack.length = 0;
5498
+ }
5487
5499
  function batch(callback) {
5488
5500
  if (context.activeBatch) {
5489
5501
  return callback();
@@ -5508,7 +5520,7 @@ ${Array.from(traces).join("\n\n")}`
5508
5520
  addToUndoStack(currentBatch.reverseOps, doNotBatchUpdates);
5509
5521
  }
5510
5522
  if (currentBatch.ops.length > 0) {
5511
- context.redoStack = [];
5523
+ context.redoStack.length = 0;
5512
5524
  }
5513
5525
  if (currentBatch.ops.length > 0) {
5514
5526
  dispatchOps(currentBatch.ops);
@@ -5612,6 +5624,7 @@ ${Array.from(traces).join("\n\n")}`
5612
5624
  redo,
5613
5625
  canUndo,
5614
5626
  canRedo,
5627
+ clear,
5615
5628
  pause: pauseHistory,
5616
5629
  resume: resumeHistory
5617
5630
  },