@liveblocks/core 1.2.2-comments5 → 1.2.2-comments6

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.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.2.2-comments5";
9
+ var PKG_VERSION = "1.2.2-comments6";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1331,27 +1331,25 @@ function createAuthManager(authOptions) {
1331
1331
  }
1332
1332
  if (authentication.type === "custom") {
1333
1333
  const response = await authentication.callback(roomId);
1334
- if (!response || typeof response !== "object") {
1335
- throw new Error(
1336
- 'We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }'
1337
- );
1338
- }
1339
- if (typeof response.token === "string") {
1340
- return parseAuthToken(response.token);
1341
- } else if (typeof response.error === "string") {
1342
- const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
1343
- if (response.error === "forbidden") {
1344
- throw new StopRetrying(reason);
1345
- } else {
1346
- throw new Error(reason);
1334
+ if (response && typeof response === "object") {
1335
+ if (typeof response.token === "string") {
1336
+ return parseAuthToken(response.token);
1337
+ } else if (typeof response.error === "string") {
1338
+ const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
1339
+ if (response.error === "forbidden") {
1340
+ throw new StopRetrying(reason);
1341
+ } else {
1342
+ throw new Error(reason);
1343
+ }
1347
1344
  }
1348
- } else {
1349
- throw new Error(
1350
- 'We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }'
1351
- );
1352
1345
  }
1346
+ throw new Error(
1347
+ 'Your authentication callback function should return a token, but it did not. Hint: the return value should look like: { token: "..." }'
1348
+ );
1353
1349
  }
1354
- throw new Error("Invalid Liveblocks client options");
1350
+ throw new Error(
1351
+ "Unexpected authentication type. Must be private or custom."
1352
+ );
1355
1353
  }
1356
1354
  async function getAuthValue(requestedScope, roomId) {
1357
1355
  if (authentication.type === "public") {
@@ -1385,13 +1383,13 @@ function prepareAuthentication(authOptions) {
1385
1383
  const { publicApiKey, authEndpoint } = authOptions;
1386
1384
  if (authEndpoint !== void 0 && publicApiKey !== void 0) {
1387
1385
  throw new Error(
1388
- "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"
1386
+ "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"
1389
1387
  );
1390
1388
  }
1391
1389
  if (typeof publicApiKey === "string") {
1392
1390
  if (publicApiKey.startsWith("sk_")) {
1393
1391
  throw new Error(
1394
- "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"
1392
+ "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"
1395
1393
  );
1396
1394
  } else if (!publicApiKey.startsWith("pk_")) {
1397
1395
  throw new Error(
@@ -1415,11 +1413,11 @@ function prepareAuthentication(authOptions) {
1415
1413
  };
1416
1414
  } else if (authEndpoint !== void 0) {
1417
1415
  throw new Error(
1418
- "authEndpoint must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"
1416
+ "The `authEndpoint` option must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"
1419
1417
  );
1420
1418
  }
1421
1419
  throw new Error(
1422
- "Invalid Liveblocks client options. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient"
1420
+ "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"
1423
1421
  );
1424
1422
  }
1425
1423
  async function fetchAuthEndpoint(fetch2, endpoint, body) {