@liveblocks/core 1.2.2 → 1.2.3

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
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var PKG_NAME = "@liveblocks/core";
3
- var PKG_VERSION = "1.2.2";
3
+ var PKG_VERSION = "1.2.3";
4
4
  var PKG_FORMAT = "esm";
5
5
 
6
6
  // src/dupe-detection.ts
@@ -1310,27 +1310,25 @@ function createAuthManager(authOptions) {
1310
1310
  }
1311
1311
  if (authentication.type === "custom") {
1312
1312
  const response = await authentication.callback(roomId);
1313
- if (!response || typeof response !== "object") {
1314
- throw new Error(
1315
- 'We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }'
1316
- );
1317
- }
1318
- if (typeof response.token === "string") {
1319
- return parseAuthToken(response.token);
1320
- } else if (typeof response.error === "string") {
1321
- const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
1322
- if (response.error === "forbidden") {
1323
- throw new StopRetrying(reason);
1324
- } else {
1325
- throw new Error(reason);
1313
+ if (response && typeof response === "object") {
1314
+ if (typeof response.token === "string") {
1315
+ return parseAuthToken(response.token);
1316
+ } else if (typeof response.error === "string") {
1317
+ const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
1318
+ if (response.error === "forbidden") {
1319
+ throw new StopRetrying(reason);
1320
+ } else {
1321
+ throw new Error(reason);
1322
+ }
1326
1323
  }
1327
- } else {
1328
- throw new Error(
1329
- 'We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }'
1330
- );
1331
1324
  }
1325
+ throw new Error(
1326
+ 'Your authentication callback function should return a token, but it did not. Hint: the return value should look like: { token: "..." }'
1327
+ );
1332
1328
  }
1333
- throw new Error("Invalid Liveblocks client options");
1329
+ throw new Error(
1330
+ "Unexpected authentication type. Must be private or custom."
1331
+ );
1334
1332
  }
1335
1333
  async function getAuthValue(requestedScope, roomId) {
1336
1334
  if (authentication.type === "public") {
@@ -1364,13 +1362,13 @@ function prepareAuthentication(authOptions) {
1364
1362
  const { publicApiKey, authEndpoint } = authOptions;
1365
1363
  if (authEndpoint !== void 0 && publicApiKey !== void 0) {
1366
1364
  throw new Error(
1367
- "You cannot use both publicApiKey and authEndpoint. Please use either publicApiKey or authEndpoint, but not both. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient"
1365
+ "You cannot simultaneously use `publicApiKey` and `authEndpoint` options. Please pick one and leave the other option unspecified. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient"
1368
1366
  );
1369
1367
  }
1370
1368
  if (typeof publicApiKey === "string") {
1371
1369
  if (publicApiKey.startsWith("sk_")) {
1372
1370
  throw new Error(
1373
- "Invalid publicApiKey. You are using the secret key which is not supported. Please use the public key instead. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey"
1371
+ "Invalid `publicApiKey` option. The value you passed is a secret key, which should not be used from the client. Please only ever pass a public key here. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey"
1374
1372
  );
1375
1373
  } else if (!publicApiKey.startsWith("pk_")) {
1376
1374
  throw new Error(
@@ -1394,11 +1392,11 @@ function prepareAuthentication(authOptions) {
1394
1392
  };
1395
1393
  } else if (authEndpoint !== void 0) {
1396
1394
  throw new Error(
1397
- "authEndpoint must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"
1395
+ "The `authEndpoint` option must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"
1398
1396
  );
1399
1397
  }
1400
1398
  throw new Error(
1401
- "Invalid Liveblocks client options. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient"
1399
+ "Invalid Liveblocks client options. Please provide either a `publicApiKey` or `authEndpoint` option. They cannot both be empty. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient"
1402
1400
  );
1403
1401
  }
1404
1402
  async function fetchAuthEndpoint(fetch2, endpoint, body) {
@@ -4708,11 +4706,13 @@ function createRoom(options, config) {
4708
4706
  } else {
4709
4707
  context.root = LiveObject._fromItems(message.items, pool);
4710
4708
  }
4709
+ const stackSizeBefore = context.undoStack.length;
4711
4710
  for (const key in context.initialStorage) {
4712
4711
  if (context.root.get(key) === void 0) {
4713
4712
  context.root.set(key, context.initialStorage[key]);
4714
4713
  }
4715
4714
  }
4715
+ context.undoStack.length = stackSizeBefore;
4716
4716
  }
4717
4717
  function updateRoot(items, batchedUpdatesWrapper) {
4718
4718
  if (context.root === void 0) {