@liveblocks/node 0.17.11-debug2 → 0.17.11

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.
Files changed (2) hide show
  1. package/index.mjs +3 -76
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1,77 +1,4 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
1
+ import mod from "./index.js";
21
2
 
22
- // src/index.ts
23
- import fetch from "node-fetch";
24
- function authorize(options) {
25
- return __async(this, null, function* () {
26
- try {
27
- const { room, secret, userId, userInfo, groupIds } = options;
28
- if (!(typeof room === "string" && room.length > 0)) {
29
- throw new Error(
30
- "Invalid room. Please provide a non-empty string as the room. For more information: https://liveblocks.io/docs/api-reference/liveblocks-node#authorize"
31
- );
32
- }
33
- const result = yield fetch(
34
- buildLiveblocksAuthorizeEndpoint(options, room),
35
- {
36
- method: "POST",
37
- headers: {
38
- Authorization: `Bearer ${secret}`,
39
- "Content-Type": "application/json"
40
- },
41
- body: JSON.stringify({
42
- userId,
43
- userInfo,
44
- groupIds
45
- })
46
- }
47
- );
48
- if (!result.ok) {
49
- return {
50
- status: 403,
51
- body: yield result.text()
52
- };
53
- }
54
- return {
55
- status: 200,
56
- body: yield result.text()
57
- };
58
- } catch (er) {
59
- return {
60
- status: 403,
61
- body: 'Call to "https://api.liveblocks.io/v2/rooms/:roomId/authorize" failed. See "error" for more information.',
62
- error: er
63
- };
64
- }
65
- });
66
- }
67
- function buildLiveblocksAuthorizeEndpoint(options, roomId) {
68
- if (options.liveblocksAuthorizeEndpoint) {
69
- return options.liveblocksAuthorizeEndpoint.replace("{roomId}", roomId);
70
- }
71
- return `https://api.liveblocks.io/v2/rooms/${encodeURIComponent(
72
- roomId
73
- )}/authorize`;
74
- }
75
- export {
76
- authorize
77
- };
3
+ export default mod;
4
+ export const authorize = mod.authorize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/node",
3
- "version": "0.17.11-debug2",
3
+ "version": "0.17.11",
4
4
  "description": "A server-side utility that lets you set up a Liveblocks authentication endpoint.",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",