@liveblocks/core 0.18.3 → 0.18.4

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.
@@ -367,6 +367,10 @@ declare type BaseUserMeta = {
367
367
  * Additional user information that has been set in the authentication endpoint.
368
368
  */
369
369
  info?: Json;
370
+ /**
371
+ * Permissions that the user has in the room.
372
+ */
373
+ scopes: string[];
370
374
  };
371
375
 
372
376
  declare enum OpCode {
@@ -639,6 +643,10 @@ declare type UserJoinServerMsg<TUserMeta extends BaseUserMeta> = {
639
643
  * endpoint.
640
644
  */
641
645
  info: TUserMeta["info"];
646
+ /**
647
+ * Permissions that the user has in the Room.
648
+ */
649
+ scopes: string[];
642
650
  };
643
651
  /**
644
652
  * Sent by the WebSocket server and broadcasted to all clients to announce that
@@ -858,6 +866,10 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
858
866
  * The user presence.
859
867
  */
860
868
  readonly presence: TPresence;
869
+ /**
870
+ * False if the user can modify the room storage, true otherwise.
871
+ */
872
+ readonly isReadOnly: boolean;
861
873
  };
862
874
  declare type AuthEndpointCallback = (room: string) => Promise<{
863
875
  token: string;
@@ -899,11 +911,13 @@ declare type Connection = {
899
911
  id: number;
900
912
  userId?: string;
901
913
  userInfo?: Json;
914
+ isReadOnly: boolean;
902
915
  } | {
903
916
  state: "open";
904
917
  id: number;
905
918
  userId?: string;
906
919
  userInfo?: Json;
920
+ isReadOnly: boolean;
907
921
  } | {
908
922
  state: "unavailable";
909
923
  } | {
@@ -1255,6 +1269,33 @@ declare function isAppOnlyAuthToken(data: JsonObject): data is AppOnlyAuthToken;
1255
1269
  declare function isRoomAuthToken(data: JsonObject): data is RoomAuthToken;
1256
1270
  declare function isAuthToken(data: JsonObject): data is AuthToken;
1257
1271
 
1272
+ /**
1273
+ * Create a client that will be responsible to communicate with liveblocks servers.
1274
+ *
1275
+ * @example
1276
+ * const client = createClient({
1277
+ * authEndpoint: "/api/auth"
1278
+ * });
1279
+ *
1280
+ * // It's also possible to use a function to call your authentication endpoint.
1281
+ * // Useful to add additional headers or use an API wrapper (like Firebase functions)
1282
+ * const client = createClient({
1283
+ * authEndpoint: async (room) => {
1284
+ * const response = await fetch("/api/auth", {
1285
+ * method: "POST",
1286
+ * headers: {
1287
+ * Authentication: "token",
1288
+ * "Content-Type": "application/json"
1289
+ * },
1290
+ * body: JSON.stringify({ room })
1291
+ * });
1292
+ *
1293
+ * return await response.json(); // should be: { token: "..." }
1294
+ * }
1295
+ * });
1296
+ */
1297
+ declare function createClient(options: ClientOptions): Client;
1298
+
1258
1299
  /**
1259
1300
  * Displays a deprecation warning in the dev console. Only in dev mode, and
1260
1301
  * only once per message/key. In production, this is a no-op.
@@ -1288,6 +1329,17 @@ declare function legacy_patchImmutableObject<S extends JsonObject>(state: S, upd
1288
1329
  declare function makePosition(before?: string, after?: string): string;
1289
1330
  declare function comparePosition(posA: string, posB: string): number;
1290
1331
 
1332
+ /**
1333
+ * Shallowly compares two given values.
1334
+ *
1335
+ * - Two simple values are considered equal if they're strictly equal
1336
+ * - Two arrays are considered equal if their members are strictly equal
1337
+ * - Two objects are considered equal if their values are strictly equal
1338
+ *
1339
+ * Testing goes one level deep.
1340
+ */
1341
+ declare function shallow(a: unknown, b: unknown): boolean;
1342
+
1291
1343
  /**
1292
1344
  * Freezes the given argument, but only in development builds. In production
1293
1345
  * builds, this is a no-op for performance reasons.
@@ -1306,44 +1358,6 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
1306
1358
  */
1307
1359
  declare function b64decode(b64value: string): string;
1308
1360
 
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
1361
  /**
1348
1362
  * PRIVATE / INTERNAL APIS
1349
1363
  * -----------------------