@liveblocks/node 1.2.0-internal4 → 1.2.0-internal5
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.mts +339 -0
- package/dist/index.d.ts +139 -1
- package/dist/index.js +298 -69
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +418 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +14 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { IncomingHttpHeaders } from 'http';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
5
|
+
*/
|
|
6
|
+
declare type AuthorizeOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The secret API key for your Liveblocks account. You can find it on
|
|
9
|
+
* https://liveblocks.io/dashboard/apikeys
|
|
10
|
+
*/
|
|
11
|
+
secret: string;
|
|
12
|
+
/**
|
|
13
|
+
* The room ID for which to authorize the user. This will authorize the user
|
|
14
|
+
* to enter the Liveblocks room.
|
|
15
|
+
*/
|
|
16
|
+
room: string;
|
|
17
|
+
/**
|
|
18
|
+
* Associates a user ID to the session that is being authorized. The user ID
|
|
19
|
+
* is typically set to the user ID from your own database.
|
|
20
|
+
*
|
|
21
|
+
* It can also be used to generate a token that gives access to a private
|
|
22
|
+
* room where the userId is configured in the room accesses.
|
|
23
|
+
*
|
|
24
|
+
* This user ID will be used as the unique identifier to compute your
|
|
25
|
+
* Liveblocks account's Monthly Active Users.
|
|
26
|
+
*/
|
|
27
|
+
userId: string;
|
|
28
|
+
/**
|
|
29
|
+
* Arbitrary metadata associated to this user session.
|
|
30
|
+
*
|
|
31
|
+
* You can use it to store a small amount of static metadata for a user
|
|
32
|
+
* session. It is public information, that will be visible to other users in
|
|
33
|
+
* the same room, like name, avatar URL, etc.
|
|
34
|
+
*
|
|
35
|
+
* It's only suitable for static info that won't change during a session. If
|
|
36
|
+
* you want to store dynamic metadata on a user session, don't keep that in
|
|
37
|
+
* the session token, but use Presence instead.
|
|
38
|
+
*
|
|
39
|
+
* Can't exceed 1KB when serialized as JSON.
|
|
40
|
+
*/
|
|
41
|
+
userInfo?: unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Tell Liveblocks which group IDs this user belongs to. This will authorize
|
|
44
|
+
* the user session to access private rooms that have at least one of these
|
|
45
|
+
* group IDs listed in their room access configuration.
|
|
46
|
+
*
|
|
47
|
+
* See https://liveblocks.io/docs/guides/managing-rooms-users-permissions#permissions
|
|
48
|
+
* for how to configure your room's permissions to use this feature.
|
|
49
|
+
*/
|
|
50
|
+
groupIds?: string[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
54
|
+
*/
|
|
55
|
+
declare type AuthorizeResponse = {
|
|
56
|
+
status: number;
|
|
57
|
+
body: string;
|
|
58
|
+
error?: Error;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
62
|
+
*
|
|
63
|
+
* Tells Liveblocks that a user should be allowed access to a room, which user
|
|
64
|
+
* this session is for, and what metadata to associate with the user (like
|
|
65
|
+
* name, avatar, etc.)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* export default async function auth(req, res) {
|
|
69
|
+
*
|
|
70
|
+
* // Implement your own security here.
|
|
71
|
+
*
|
|
72
|
+
* const room = req.body.room;
|
|
73
|
+
* const response = await authorize({
|
|
74
|
+
* room,
|
|
75
|
+
* secret,
|
|
76
|
+
* userId: "123",
|
|
77
|
+
* userInfo: { // Optional
|
|
78
|
+
* name: "Ada Lovelace"
|
|
79
|
+
* },
|
|
80
|
+
* groupIds: ["group1"] // Optional
|
|
81
|
+
* });
|
|
82
|
+
* return res.status(response.status).end(response.body);
|
|
83
|
+
* }
|
|
84
|
+
*/
|
|
85
|
+
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
86
|
+
|
|
87
|
+
declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read"];
|
|
88
|
+
declare type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
89
|
+
/**
|
|
90
|
+
* Class to help you construct the exact permission set to grant a user, used
|
|
91
|
+
* when making `.authorizeUser()` calls.
|
|
92
|
+
*
|
|
93
|
+
* Usage:
|
|
94
|
+
*
|
|
95
|
+
* const session = liveblocks.prepareSession();
|
|
96
|
+
* session.allow(roomId, permissions) // or...
|
|
97
|
+
*
|
|
98
|
+
* For the `permissions` argument, you can pass a list of specific permissions,
|
|
99
|
+
* or use one of our presets:
|
|
100
|
+
*
|
|
101
|
+
* session.allow('my-room', session.FULL_ACCESS) // Read + write access to room storage and comments
|
|
102
|
+
* session.allow('my-room', session.READ_ACCESS) // Read-only access to room storage and comments
|
|
103
|
+
*
|
|
104
|
+
* Rooms can be specified with a prefix match, if the name ends in an asterisk.
|
|
105
|
+
* In that case, access is granted to *all* rooms that start with that prefix:
|
|
106
|
+
*
|
|
107
|
+
* // Read + write access to *all* rooms that start with "abc:"
|
|
108
|
+
* session.allow('abc:*', session.FULL_ACCESS)
|
|
109
|
+
*
|
|
110
|
+
* You can define at most 10 room IDs (or patterns) in a single token,
|
|
111
|
+
* otherwise the token would become too large and unwieldy.
|
|
112
|
+
*
|
|
113
|
+
* All permissions granted are additive. You cannot "remove" permissions once
|
|
114
|
+
* you grant them. For example:
|
|
115
|
+
*
|
|
116
|
+
* session
|
|
117
|
+
* .allow('abc:*', session.FULL_ACCESS)
|
|
118
|
+
* .allow('abc:123', session.READ_ACCESS)
|
|
119
|
+
*
|
|
120
|
+
* Here, room `abc:123` would have full access. The second .allow() call only
|
|
121
|
+
* _adds_ read permissions, but that has no effect since full access
|
|
122
|
+
* permissions were already added to the set.
|
|
123
|
+
*/
|
|
124
|
+
declare class Session {
|
|
125
|
+
readonly FULL_ACCESS: readonly ["room:write", "comments:write"];
|
|
126
|
+
readonly READ_ACCESS: readonly ["room:read", "room:presence:write", "comments:read"];
|
|
127
|
+
allow(roomIdOrPattern: string, newPerms: readonly Permission[]): this;
|
|
128
|
+
/**
|
|
129
|
+
* Call this to authorize the session to access Liveblocks. Note that this
|
|
130
|
+
* will return a Liveblocks "access token". Anyone that obtains such access
|
|
131
|
+
* token will have access to the allowed resources.
|
|
132
|
+
*/
|
|
133
|
+
authorize(): Promise<AuthResponse>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare type LiveblocksOptions = {
|
|
137
|
+
/**
|
|
138
|
+
* The Liveblocks secret key. Must start with "sk_".
|
|
139
|
+
* Get it from https://liveblocks.io/dashboard/apikeys
|
|
140
|
+
*/
|
|
141
|
+
secret: string;
|
|
142
|
+
};
|
|
143
|
+
declare type CreateSessionOptions = {
|
|
144
|
+
userInfo: unknown;
|
|
145
|
+
};
|
|
146
|
+
declare type AuthResponse = {
|
|
147
|
+
status: number;
|
|
148
|
+
body: string;
|
|
149
|
+
error?: Error;
|
|
150
|
+
};
|
|
151
|
+
declare type Identity = {
|
|
152
|
+
userId: string;
|
|
153
|
+
groupIds: string[];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Interact with the Liveblocks API from your Node.js backend.
|
|
157
|
+
*/
|
|
158
|
+
declare class Liveblocks {
|
|
159
|
+
/**
|
|
160
|
+
* Interact with the Liveblocks API from your Node.js backend.
|
|
161
|
+
*/
|
|
162
|
+
constructor(options: LiveblocksOptions);
|
|
163
|
+
/**
|
|
164
|
+
* Prepares a new session to authorize a user to access Liveblocks.
|
|
165
|
+
*
|
|
166
|
+
* IMPORTANT:
|
|
167
|
+
* Always make sure that you trust the user making the request to your
|
|
168
|
+
* backend before calling .prepareSession()!
|
|
169
|
+
*
|
|
170
|
+
* @param userId Tell Liveblocks the user ID of the user to authorize. Must
|
|
171
|
+
* uniquely identify the user account in your system. The uniqueness of this
|
|
172
|
+
* value will determine how many MAUs will be counted/billed.
|
|
173
|
+
*
|
|
174
|
+
* @param options.userInfo Custom metadata to attach to this user. Data you
|
|
175
|
+
* add here will be visible to all other clients in the room, through the
|
|
176
|
+
* `other.info` property.
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
prepareSession(userId: string, options?: CreateSessionOptions): Session;
|
|
180
|
+
/**
|
|
181
|
+
* Call this to authenticate the user as an actor you want to allow to use
|
|
182
|
+
* Liveblocks.
|
|
183
|
+
*
|
|
184
|
+
* You should use this method only if you want to manage your permissions
|
|
185
|
+
* through the Liveblocks Permissions API. This method is more complicated to
|
|
186
|
+
* set up, but allows for finer-grained specification of permissions.
|
|
187
|
+
*
|
|
188
|
+
* Calling `.identifyUser()` only lets you securely identify a user (and what
|
|
189
|
+
* groups they belong to). What permissions this user will end up having is
|
|
190
|
+
* determined by whatever permissions you assign the user/group in your
|
|
191
|
+
* Liveblocks account, through the Permissions API:
|
|
192
|
+
* https://liveblocks.io/docs/rooms/permissions
|
|
193
|
+
*
|
|
194
|
+
* IMPORTANT:
|
|
195
|
+
* Always verify that you trust the user making the request before calling
|
|
196
|
+
* .identifyUser()!
|
|
197
|
+
*
|
|
198
|
+
* @param identity Tell Liveblocks the user ID of the user to authenticate.
|
|
199
|
+
* Must uniquely identify the user account in your system. The uniqueness of
|
|
200
|
+
* this value will determine how many MAUs will be counted/billed.
|
|
201
|
+
*
|
|
202
|
+
* If you also want to assign which groups this user belongs to, use the
|
|
203
|
+
* object form and specify the `groupIds` property. Those `groupIds` should
|
|
204
|
+
* match the groupIds you assigned permissions to via the Liveblocks
|
|
205
|
+
* Permissions API, see
|
|
206
|
+
* https://liveblocks.io/docs/rooms/permissions#permissions-levels-groups-accesses-example
|
|
207
|
+
*
|
|
208
|
+
* @param options.userInfo Custom metadata to attach to this user. Data you
|
|
209
|
+
* add here will be visible to all other clients in the room, through the
|
|
210
|
+
* `other.info` property.
|
|
211
|
+
*/
|
|
212
|
+
identifyUser(identity: string | Identity, options?: {
|
|
213
|
+
userInfo: unknown;
|
|
214
|
+
}): Promise<AuthResponse>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
declare class WebhookHandler {
|
|
218
|
+
private secretBuffer;
|
|
219
|
+
private static secretPrefix;
|
|
220
|
+
constructor(
|
|
221
|
+
/**
|
|
222
|
+
* The signing secret provided on the dashboard's webhooks page
|
|
223
|
+
* @example "whsec_wPbvQ+u3VtN2e2tRPDKchQ1tBZ3svaHLm"
|
|
224
|
+
*/
|
|
225
|
+
secret: string);
|
|
226
|
+
/**
|
|
227
|
+
* Verifies a webhook request and returns the event
|
|
228
|
+
*/
|
|
229
|
+
verifyRequest(request: WebhookRequest): WebhookEvent;
|
|
230
|
+
/**
|
|
231
|
+
* Verifies the headers and returns the webhookId, timestamp and rawSignatures
|
|
232
|
+
*/
|
|
233
|
+
private verifyHeaders;
|
|
234
|
+
/**
|
|
235
|
+
* Signs the content with the secret
|
|
236
|
+
* @param content
|
|
237
|
+
* @returns `string`
|
|
238
|
+
*/
|
|
239
|
+
private sign;
|
|
240
|
+
/**
|
|
241
|
+
* Verifies that the timestamp is not too old or in the future
|
|
242
|
+
*/
|
|
243
|
+
private verifyTimestamp;
|
|
244
|
+
/**
|
|
245
|
+
* Ensures that the event is a known event type
|
|
246
|
+
* or throws and prompts the user to upgrade to a higher version of @liveblocks/node
|
|
247
|
+
*/
|
|
248
|
+
private verifyWebhookEventType;
|
|
249
|
+
}
|
|
250
|
+
declare type WebhookRequest = {
|
|
251
|
+
/**
|
|
252
|
+
* Headers of the request
|
|
253
|
+
* @example
|
|
254
|
+
* {
|
|
255
|
+
* "webhook-id": "123",
|
|
256
|
+
* "webhook-timestamp": "1614588800000",
|
|
257
|
+
* "webhook-signature": "v1,bm9ldHUjKzFob2VudXRob2VodWUzMjRvdWVvdW9ldQo= v2,MzJsNDk4MzI0K2VvdSMjMTEjQEBAQDEyMzMzMzEyMwo="
|
|
258
|
+
* }
|
|
259
|
+
*/
|
|
260
|
+
headers: IncomingHttpHeaders;
|
|
261
|
+
/**
|
|
262
|
+
* Raw body of the request, do not parse it
|
|
263
|
+
* @example '{"type":"storageUpdated","data":{"roomId":"my-room-id","appId":"my-app-id","updatedAt":"2021-03-01T12:00:00.000Z"}}'
|
|
264
|
+
*/
|
|
265
|
+
rawBody: string;
|
|
266
|
+
};
|
|
267
|
+
declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent;
|
|
268
|
+
declare type StorageUpdatedEvent = {
|
|
269
|
+
type: "storageUpdated";
|
|
270
|
+
data: {
|
|
271
|
+
roomId: string;
|
|
272
|
+
appId: string;
|
|
273
|
+
/**
|
|
274
|
+
* ISO 8601 datestring
|
|
275
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
276
|
+
*/
|
|
277
|
+
updatedAt: string;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
declare type UserEnteredEvent = {
|
|
281
|
+
type: "userEntered";
|
|
282
|
+
data: {
|
|
283
|
+
appId: string;
|
|
284
|
+
roomId: string;
|
|
285
|
+
connectionId: number;
|
|
286
|
+
userId: string | null;
|
|
287
|
+
userInfo: Record<string, unknown> | null;
|
|
288
|
+
/**
|
|
289
|
+
* ISO 8601 datestring
|
|
290
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
291
|
+
* @description The time when the user entered the room.
|
|
292
|
+
*/
|
|
293
|
+
enteredAt: string;
|
|
294
|
+
numActiveUsers: number;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
declare type UserLeftEvent = {
|
|
298
|
+
type: "userLeft";
|
|
299
|
+
data: {
|
|
300
|
+
appId: string;
|
|
301
|
+
roomId: string;
|
|
302
|
+
connectionId: number;
|
|
303
|
+
userId: string | null;
|
|
304
|
+
userInfo: Record<string, unknown> | null;
|
|
305
|
+
/**
|
|
306
|
+
* ISO 8601 datestring
|
|
307
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
308
|
+
* @description The time when the user left the room.
|
|
309
|
+
*/
|
|
310
|
+
leftAt: string;
|
|
311
|
+
numActiveUsers: number;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
declare type RoomCreatedEvent = {
|
|
315
|
+
type: "roomCreated";
|
|
316
|
+
data: {
|
|
317
|
+
appId: string;
|
|
318
|
+
roomId: string;
|
|
319
|
+
/**
|
|
320
|
+
* ISO 8601 datestring
|
|
321
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
322
|
+
*/
|
|
323
|
+
createdAt: string;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
declare type RoomDeletedEvent = {
|
|
327
|
+
type: "roomDeleted";
|
|
328
|
+
data: {
|
|
329
|
+
appId: string;
|
|
330
|
+
roomId: string;
|
|
331
|
+
/**
|
|
332
|
+
* ISO 8601 datestring
|
|
333
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
334
|
+
*/
|
|
335
|
+
deletedAt: string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export { Liveblocks, LiveblocksOptions, StorageUpdatedEvent, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { IncomingHttpHeaders } from 'http';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
5
|
+
*/
|
|
3
6
|
declare type AuthorizeOptions = {
|
|
4
7
|
/**
|
|
5
8
|
* The secret API key for your Liveblocks account. You can find it on
|
|
@@ -46,12 +49,17 @@ declare type AuthorizeOptions = {
|
|
|
46
49
|
*/
|
|
47
50
|
groupIds?: string[];
|
|
48
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
54
|
+
*/
|
|
49
55
|
declare type AuthorizeResponse = {
|
|
50
56
|
status: number;
|
|
51
57
|
body: string;
|
|
52
58
|
error?: Error;
|
|
53
59
|
};
|
|
54
60
|
/**
|
|
61
|
+
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
62
|
+
*
|
|
55
63
|
* Tells Liveblocks that a user should be allowed access to a room, which user
|
|
56
64
|
* this session is for, and what metadata to associate with the user (like
|
|
57
65
|
* name, avatar, etc.)
|
|
@@ -76,6 +84,136 @@ declare type AuthorizeResponse = {
|
|
|
76
84
|
*/
|
|
77
85
|
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
78
86
|
|
|
87
|
+
declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read"];
|
|
88
|
+
declare type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
89
|
+
/**
|
|
90
|
+
* Class to help you construct the exact permission set to grant a user, used
|
|
91
|
+
* when making `.authorizeUser()` calls.
|
|
92
|
+
*
|
|
93
|
+
* Usage:
|
|
94
|
+
*
|
|
95
|
+
* const session = liveblocks.prepareSession();
|
|
96
|
+
* session.allow(roomId, permissions) // or...
|
|
97
|
+
*
|
|
98
|
+
* For the `permissions` argument, you can pass a list of specific permissions,
|
|
99
|
+
* or use one of our presets:
|
|
100
|
+
*
|
|
101
|
+
* session.allow('my-room', session.FULL_ACCESS) // Read + write access to room storage and comments
|
|
102
|
+
* session.allow('my-room', session.READ_ACCESS) // Read-only access to room storage and comments
|
|
103
|
+
*
|
|
104
|
+
* Rooms can be specified with a prefix match, if the name ends in an asterisk.
|
|
105
|
+
* In that case, access is granted to *all* rooms that start with that prefix:
|
|
106
|
+
*
|
|
107
|
+
* // Read + write access to *all* rooms that start with "abc:"
|
|
108
|
+
* session.allow('abc:*', session.FULL_ACCESS)
|
|
109
|
+
*
|
|
110
|
+
* You can define at most 10 room IDs (or patterns) in a single token,
|
|
111
|
+
* otherwise the token would become too large and unwieldy.
|
|
112
|
+
*
|
|
113
|
+
* All permissions granted are additive. You cannot "remove" permissions once
|
|
114
|
+
* you grant them. For example:
|
|
115
|
+
*
|
|
116
|
+
* session
|
|
117
|
+
* .allow('abc:*', session.FULL_ACCESS)
|
|
118
|
+
* .allow('abc:123', session.READ_ACCESS)
|
|
119
|
+
*
|
|
120
|
+
* Here, room `abc:123` would have full access. The second .allow() call only
|
|
121
|
+
* _adds_ read permissions, but that has no effect since full access
|
|
122
|
+
* permissions were already added to the set.
|
|
123
|
+
*/
|
|
124
|
+
declare class Session {
|
|
125
|
+
readonly FULL_ACCESS: readonly ["room:write", "comments:write"];
|
|
126
|
+
readonly READ_ACCESS: readonly ["room:read", "room:presence:write", "comments:read"];
|
|
127
|
+
allow(roomIdOrPattern: string, newPerms: readonly Permission[]): this;
|
|
128
|
+
/**
|
|
129
|
+
* Call this to authorize the session to access Liveblocks. Note that this
|
|
130
|
+
* will return a Liveblocks "access token". Anyone that obtains such access
|
|
131
|
+
* token will have access to the allowed resources.
|
|
132
|
+
*/
|
|
133
|
+
authorize(): Promise<AuthResponse>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare type LiveblocksOptions = {
|
|
137
|
+
/**
|
|
138
|
+
* The Liveblocks secret key. Must start with "sk_".
|
|
139
|
+
* Get it from https://liveblocks.io/dashboard/apikeys
|
|
140
|
+
*/
|
|
141
|
+
secret: string;
|
|
142
|
+
};
|
|
143
|
+
declare type CreateSessionOptions = {
|
|
144
|
+
userInfo: unknown;
|
|
145
|
+
};
|
|
146
|
+
declare type AuthResponse = {
|
|
147
|
+
status: number;
|
|
148
|
+
body: string;
|
|
149
|
+
error?: Error;
|
|
150
|
+
};
|
|
151
|
+
declare type Identity = {
|
|
152
|
+
userId: string;
|
|
153
|
+
groupIds: string[];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Interact with the Liveblocks API from your Node.js backend.
|
|
157
|
+
*/
|
|
158
|
+
declare class Liveblocks {
|
|
159
|
+
/**
|
|
160
|
+
* Interact with the Liveblocks API from your Node.js backend.
|
|
161
|
+
*/
|
|
162
|
+
constructor(options: LiveblocksOptions);
|
|
163
|
+
/**
|
|
164
|
+
* Prepares a new session to authorize a user to access Liveblocks.
|
|
165
|
+
*
|
|
166
|
+
* IMPORTANT:
|
|
167
|
+
* Always make sure that you trust the user making the request to your
|
|
168
|
+
* backend before calling .prepareSession()!
|
|
169
|
+
*
|
|
170
|
+
* @param userId Tell Liveblocks the user ID of the user to authorize. Must
|
|
171
|
+
* uniquely identify the user account in your system. The uniqueness of this
|
|
172
|
+
* value will determine how many MAUs will be counted/billed.
|
|
173
|
+
*
|
|
174
|
+
* @param options.userInfo Custom metadata to attach to this user. Data you
|
|
175
|
+
* add here will be visible to all other clients in the room, through the
|
|
176
|
+
* `other.info` property.
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
prepareSession(userId: string, options?: CreateSessionOptions): Session;
|
|
180
|
+
/**
|
|
181
|
+
* Call this to authenticate the user as an actor you want to allow to use
|
|
182
|
+
* Liveblocks.
|
|
183
|
+
*
|
|
184
|
+
* You should use this method only if you want to manage your permissions
|
|
185
|
+
* through the Liveblocks Permissions API. This method is more complicated to
|
|
186
|
+
* set up, but allows for finer-grained specification of permissions.
|
|
187
|
+
*
|
|
188
|
+
* Calling `.identifyUser()` only lets you securely identify a user (and what
|
|
189
|
+
* groups they belong to). What permissions this user will end up having is
|
|
190
|
+
* determined by whatever permissions you assign the user/group in your
|
|
191
|
+
* Liveblocks account, through the Permissions API:
|
|
192
|
+
* https://liveblocks.io/docs/rooms/permissions
|
|
193
|
+
*
|
|
194
|
+
* IMPORTANT:
|
|
195
|
+
* Always verify that you trust the user making the request before calling
|
|
196
|
+
* .identifyUser()!
|
|
197
|
+
*
|
|
198
|
+
* @param identity Tell Liveblocks the user ID of the user to authenticate.
|
|
199
|
+
* Must uniquely identify the user account in your system. The uniqueness of
|
|
200
|
+
* this value will determine how many MAUs will be counted/billed.
|
|
201
|
+
*
|
|
202
|
+
* If you also want to assign which groups this user belongs to, use the
|
|
203
|
+
* object form and specify the `groupIds` property. Those `groupIds` should
|
|
204
|
+
* match the groupIds you assigned permissions to via the Liveblocks
|
|
205
|
+
* Permissions API, see
|
|
206
|
+
* https://liveblocks.io/docs/rooms/permissions#permissions-levels-groups-accesses-example
|
|
207
|
+
*
|
|
208
|
+
* @param options.userInfo Custom metadata to attach to this user. Data you
|
|
209
|
+
* add here will be visible to all other clients in the room, through the
|
|
210
|
+
* `other.info` property.
|
|
211
|
+
*/
|
|
212
|
+
identifyUser(identity: string | Identity, options?: {
|
|
213
|
+
userInfo: unknown;
|
|
214
|
+
}): Promise<AuthResponse>;
|
|
215
|
+
}
|
|
216
|
+
|
|
79
217
|
declare class WebhookHandler {
|
|
80
218
|
private secretBuffer;
|
|
81
219
|
private static secretPrefix;
|
|
@@ -198,4 +336,4 @@ declare type RoomDeletedEvent = {
|
|
|
198
336
|
};
|
|
199
337
|
};
|
|
200
338
|
|
|
201
|
-
export { StorageUpdatedEvent, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize };
|
|
339
|
+
export { Liveblocks, LiveblocksOptions, StorageUpdatedEvent, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize };
|