@liveblocks/node 1.0.0-beta0 → 1.0.0-beta2

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.d.ts CHANGED
@@ -50,7 +50,7 @@ declare type WebhookRequest = {
50
50
  */
51
51
  rawBody: string;
52
52
  };
53
- declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent;
53
+ declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent;
54
54
  declare type StorageUpdatedEvent = {
55
55
  type: "storageUpdated";
56
56
  data: {
@@ -97,6 +97,30 @@ declare type UserLeftEvent = {
97
97
  numActiveUsers: number;
98
98
  };
99
99
  };
100
+ declare type RoomCreatedEvent = {
101
+ type: "roomCreated";
102
+ data: {
103
+ appId: string;
104
+ roomId: string;
105
+ /**
106
+ * ISO 8601 datestring
107
+ * @example "2021-03-01T12:00:00.000Z"
108
+ */
109
+ createdAt: string;
110
+ };
111
+ };
112
+ declare type RoomDeletedEvent = {
113
+ type: "roomDeleted";
114
+ data: {
115
+ appId: string;
116
+ roomId: string;
117
+ /**
118
+ * ISO 8601 datestring
119
+ * @example "2021-03-01T12:00:00.000Z"
120
+ */
121
+ deletedAt: string;
122
+ };
123
+ };
100
124
 
101
125
  declare type AuthorizeOptions = {
102
126
  /**
@@ -108,10 +132,11 @@ declare type AuthorizeOptions = {
108
132
  */
109
133
  room: string;
110
134
  /**
111
- * The id of the user that try to connect. It should be used to get information about the connected users in the room (name, avatar, etc).
112
- * It can also be used to generate a token that gives access to a private room where the userId is configured in the room accesses
135
+ * The id of the user that try to connect. It can be used to get information about the connected users in the room (name, avatar, etc).
136
+ * It can also be used to generate a token that gives access to a private room where the userId is configured in the room accesses.
137
+ * Liveblocks uses the userId to calculate your account's Monthly Active Users.
113
138
  */
114
- userId?: string;
139
+ userId: string;
115
140
  /**
116
141
  * The info associated to the user. Can be used to store the name or the profile picture to implement avatar for example. Can't exceed 1KB when serialized as JSON
117
142
  */
@@ -136,7 +161,7 @@ declare type AuthorizeResponse = {
136
161
  * const response = await authorize({
137
162
  * room,
138
163
  * secret,
139
- * userId: "123", // Optional
164
+ * userId: "123",
140
165
  * userInfo: { // Optional
141
166
  * name: "Ada Lovelace"
142
167
  * },
package/dist/index.js CHANGED
@@ -86,7 +86,13 @@ var _WebhookHandler = class {
86
86
  }
87
87
  }
88
88
  verifyWebhookEventType(event) {
89
- if (event && event.type && (event.type === "storageUpdated" || event.type === "userEntered" || event.type === "userLeft"))
89
+ if (event && event.type && [
90
+ "storageUpdated",
91
+ "userEntered",
92
+ "userLeft",
93
+ "roomCreated",
94
+ "roomDeleted"
95
+ ].includes(event.type))
90
96
  return;
91
97
  throw new Error(
92
98
  "Unknown event type, please upgrade to a higher version of @liveblocks/node"
@@ -108,6 +114,11 @@ function authorize(options) {
108
114
  "Invalid room. Please provide a non-empty string as the room. For more information: https://liveblocks.io/docs/api-reference/liveblocks-node#authorize"
109
115
  );
110
116
  }
117
+ if (!(typeof userId === "string" && userId.length > 0)) {
118
+ throw new Error(
119
+ "Invalid userId. Please provide a non-empty string as the userId. For more information: https://liveblocks.io/docs/api-reference/liveblocks-node#authorize"
120
+ );
121
+ }
111
122
  const result = yield _nodefetch2.default.call(void 0,
112
123
  buildLiveblocksAuthorizeEndpoint(options, room),
113
124
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/node",
3
- "version": "1.0.0-beta0",
3
+ "version": "1.0.0-beta2",
4
4
  "description": "A server-side utility that lets you set up a Liveblocks authentication endpoint. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",