@liveblocks/core 0.18.3 → 0.18.5

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.
@@ -357,6 +357,9 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
357
357
  toImmutable(): readonly ToImmutable<TItem>[];
358
358
  }
359
359
 
360
+ /**
361
+ * This type is used by clients to define the metadata for a user.
362
+ */
360
363
  declare type BaseUserMeta = {
361
364
  /**
362
365
  * The id of the user that has been set in the authentication endpoint.
@@ -639,6 +642,10 @@ declare type UserJoinServerMsg<TUserMeta extends BaseUserMeta> = {
639
642
  * endpoint.
640
643
  */
641
644
  info: TUserMeta["info"];
645
+ /**
646
+ * Permissions that the user has in the Room.
647
+ */
648
+ scopes: string[];
642
649
  };
643
650
  /**
644
651
  * Sent by the WebSocket server and broadcasted to all clients to announce that
@@ -672,7 +679,9 @@ declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
672
679
  declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
673
680
  type: ServerMsgCode.ROOM_STATE;
674
681
  users: {
675
- [actor: number]: TUserMeta;
682
+ [actor: number]: TUserMeta & {
683
+ scopes: string[];
684
+ };
676
685
  };
677
686
  };
678
687
  /**
@@ -858,6 +867,10 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
858
867
  * The user presence.
859
868
  */
860
869
  readonly presence: TPresence;
870
+ /**
871
+ * False if the user can modify the room storage, true otherwise.
872
+ */
873
+ readonly isReadOnly: boolean;
861
874
  };
862
875
  declare type AuthEndpointCallback = (room: string) => Promise<{
863
876
  token: string;
@@ -899,11 +912,13 @@ declare type Connection = {
899
912
  id: number;
900
913
  userId?: string;
901
914
  userInfo?: Json;
915
+ isReadOnly: boolean;
902
916
  } | {
903
917
  state: "open";
904
918
  id: number;
905
919
  userId?: string;
906
920
  userInfo?: Json;
921
+ isReadOnly: boolean;
907
922
  } | {
908
923
  state: "unavailable";
909
924
  } | {
@@ -1255,6 +1270,33 @@ declare function isAppOnlyAuthToken(data: JsonObject): data is AppOnlyAuthToken;
1255
1270
  declare function isRoomAuthToken(data: JsonObject): data is RoomAuthToken;
1256
1271
  declare function isAuthToken(data: JsonObject): data is AuthToken;
1257
1272
 
1273
+ /**
1274
+ * Create a client that will be responsible to communicate with liveblocks servers.
1275
+ *
1276
+ * @example
1277
+ * const client = createClient({
1278
+ * authEndpoint: "/api/auth"
1279
+ * });
1280
+ *
1281
+ * // It's also possible to use a function to call your authentication endpoint.
1282
+ * // Useful to add additional headers or use an API wrapper (like Firebase functions)
1283
+ * const client = createClient({
1284
+ * authEndpoint: async (room) => {
1285
+ * const response = await fetch("/api/auth", {
1286
+ * method: "POST",
1287
+ * headers: {
1288
+ * Authentication: "token",
1289
+ * "Content-Type": "application/json"
1290
+ * },
1291
+ * body: JSON.stringify({ room })
1292
+ * });
1293
+ *
1294
+ * return await response.json(); // should be: { token: "..." }
1295
+ * }
1296
+ * });
1297
+ */
1298
+ declare function createClient(options: ClientOptions): Client;
1299
+
1258
1300
  /**
1259
1301
  * Displays a deprecation warning in the dev console. Only in dev mode, and
1260
1302
  * only once per message/key. In production, this is a no-op.
@@ -1288,6 +1330,17 @@ declare function legacy_patchImmutableObject<S extends JsonObject>(state: S, upd
1288
1330
  declare function makePosition(before?: string, after?: string): string;
1289
1331
  declare function comparePosition(posA: string, posB: string): number;
1290
1332
 
1333
+ /**
1334
+ * Shallowly compares two given values.
1335
+ *
1336
+ * - Two simple values are considered equal if they're strictly equal
1337
+ * - Two arrays are considered equal if their members are strictly equal
1338
+ * - Two objects are considered equal if their values are strictly equal
1339
+ *
1340
+ * Testing goes one level deep.
1341
+ */
1342
+ declare function shallow(a: unknown, b: unknown): boolean;
1343
+
1291
1344
  /**
1292
1345
  * Freezes the given argument, but only in development builds. In production
1293
1346
  * builds, this is a no-op for performance reasons.
@@ -1306,44 +1359,6 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
1306
1359
  */
1307
1360
  declare function b64decode(b64value: string): string;
1308
1361
 
1309
- /**
1310
- * Create a client that will be responsible to communicate with liveblocks servers.
1311
- *
1312
- * @example
1313
- * const client = createClient({
1314
- * authEndpoint: "/api/auth"
1315
- * });
1316
- *
1317
- * // It's also possible to use a function to call your authentication endpoint.
1318
- * // Useful to add additional headers or use an API wrapper (like Firebase functions)
1319
- * const client = createClient({
1320
- * authEndpoint: async (room) => {
1321
- * const response = await fetch("/api/auth", {
1322
- * method: "POST",
1323
- * headers: {
1324
- * Authentication: "token",
1325
- * "Content-Type": "application/json"
1326
- * },
1327
- * body: JSON.stringify({ room })
1328
- * });
1329
- *
1330
- * return await response.json(); // should be: { token: "..." }
1331
- * }
1332
- * });
1333
- */
1334
- declare function createClient(options: ClientOptions): Client;
1335
-
1336
- /**
1337
- * Shallowly compares two given values.
1338
- *
1339
- * - Two simple values are considered equal if they're strictly equal
1340
- * - Two arrays are considered equal if their members are strictly equal
1341
- * - Two objects are considered equal if their values are strictly equal
1342
- *
1343
- * Testing goes one level deep.
1344
- */
1345
- declare function shallow(a: unknown, b: unknown): boolean;
1346
-
1347
1362
  /**
1348
1363
  * PRIVATE / INTERNAL APIS
1349
1364
  * -----------------------