@liveblocks/node 0.3.0 → 0.17.0

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/README.md ADDED
@@ -0,0 +1,51 @@
1
+ <p align="center">
2
+ <a href="https://liveblocks.io">
3
+ <img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header.svg" alt="Liveblocks" />
4
+ </a>
5
+ </p>
6
+
7
+ # `@liveblocks/node`
8
+
9
+ <p>
10
+ <a href="https://npmjs.org/package/@liveblocks/node">
11
+ <img src="https://img.shields.io/npm/v/@liveblocks/node?style=flat&label=npm&color=c33" alt="NPM" />
12
+ </a>
13
+ <a href="https://bundlephobia.com/package/@liveblocks/node">
14
+ <img src="https://img.shields.io/bundlephobia/minzip/@liveblocks/node?style=flat&label=size&color=09f" alt="Size" />
15
+ </a>
16
+ <a href="https://github.com/liveblocks/liveblocks/blob/main/LICENSE">
17
+ <img src="https://img.shields.io/github/license/liveblocks/liveblocks?style=flat&label=license&color=f80" alt="License" />
18
+ </a>
19
+ </p>
20
+
21
+ A server-side utility that lets you set up a [Liveblocks](https://liveblocks.io) authentication endpoint.
22
+
23
+ ## Installation
24
+
25
+ ```
26
+ npm install @liveblocks/node
27
+ ```
28
+
29
+ ## Examples
30
+
31
+ - Browse our gallery of collaborative UI patterns. [View examples gallery](https://liveblocks.io/examples)
32
+ - Explore and clone any of our open-source examples. [View code examples](https://github.com/liveblocks/liveblocks/tree/main/examples)
33
+
34
+ ## Documentation
35
+
36
+ [Read the documentation](https://liveblocks.io/docs) to start using Liveblocks.
37
+
38
+ ## Releases
39
+
40
+ For changelog, visit [https://github.com/liveblocks/liveblocks/releases](https://github.com/liveblocks/liveblocks/releases).
41
+
42
+ ## Community
43
+
44
+ - [Discord](https://discord.gg/X4YWJuH9VY) - To get involved with the Liveblocks community, ask questions and share tips.
45
+ - [Twitter](https://twitter.com/liveblocks) - To receive updates, announcements, blog posts, and general Liveblocks tips.
46
+
47
+ ## License
48
+
49
+ Licensed under the Apache License 2.0, Copyright © 2021-present [Liveblocks](https://liveblocks.io).
50
+
51
+ See [LICENSE](../../LICENSE) for more information.
package/package.json CHANGED
@@ -1,31 +1,59 @@
1
1
  {
2
2
  "name": "@liveblocks/node",
3
- "version": "0.3.0",
4
- "description": "",
3
+ "version": "0.17.0",
4
+ "description": "A server-side utility that lets you set up a Liveblocks authentication endpoint.",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
7
7
  "files": [
8
8
  "lib/"
9
9
  ],
10
+ "keywords": [
11
+ "node",
12
+ "liveblocks",
13
+ "multiplayer",
14
+ "live-cursors",
15
+ "collaborative"
16
+ ],
17
+ "bugs": {
18
+ "url": "https://github.com/liveblocks/liveblocks/issues"
19
+ },
10
20
  "scripts": {
11
- "build-and-pack": "npm run build && npm pack",
12
- "build": "npm run build:esm && npm run build:cjs",
13
- "build:esm": "tsc -p tsconfig.json",
14
- "build:cjs": "tsc -p tsconfig-cjs.json",
15
- "test": "jest --watch"
21
+ "build": "rollup -c && cp ./package.json ./README.md ./lib",
22
+ "format": "eslint --fix src/ && prettier --write src/",
23
+ "lint": "eslint src/",
24
+ "test": "jest --watch --silent --verbose",
25
+ "test-ci": "jest --silent --verbose --passWithNoTests"
16
26
  },
17
- "license": "MIT",
27
+ "license": "Apache-2.0",
18
28
  "devDependencies": {
19
- "@babel/core": "^7.12.16",
20
- "@babel/preset-env": "^7.12.16",
21
- "@babel/preset-typescript": "^7.12.16",
29
+ "@babel/core": "^7.17.10",
30
+ "@babel/preset-env": "^7.17.10",
31
+ "@babel/preset-typescript": "^7.16.7",
32
+ "@rollup/plugin-babel": "^5.3.1",
33
+ "@rollup/plugin-node-resolve": "^13.3.0",
34
+ "@rollup/plugin-replace": "^4.0.0",
35
+ "@rollup/plugin-typescript": "^8.3.3",
22
36
  "@types/jest": "^26.0.21",
23
37
  "@types/node-fetch": "^2.5.8",
24
- "babel-jest": "^26.6.3",
38
+ "@typescript-eslint/eslint-plugin": "^5.18.0",
39
+ "@typescript-eslint/parser": "^5.18.0",
40
+ "eslint": "^8.12.0",
41
+ "eslint-plugin-import": "^2.26.0",
42
+ "eslint-plugin-simple-import-sort": "^7.0.0",
25
43
  "jest": "^26.6.3",
44
+ "rollup": "^2.75.7",
45
+ "rollup-plugin-command": "^1.1.3",
46
+ "rollup-plugin-dts": "^4.2.2",
47
+ "rollup-plugin-prettier": "^2.2.2",
48
+ "rollup-plugin-terser": "^7.0.2",
26
49
  "typescript": "^4.1.5"
27
50
  },
28
51
  "dependencies": {
29
52
  "node-fetch": "^2.6.1"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/liveblocks/liveblocks.git",
57
+ "directory": "packages/liveblocks-node"
30
58
  }
31
59
  }
@@ -1,25 +0,0 @@
1
- declare type AuthorizeOptions = {
2
- /**
3
- * The secret api provided at https://liveblocks.io/dashboard/apikeys
4
- */
5
- secret: string;
6
- /**
7
- * The room provided in the authorization request body
8
- */
9
- room: string;
10
- /**
11
- * 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).
12
- */
13
- userId?: string;
14
- /**
15
- * 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
16
- */
17
- userInfo?: any;
18
- };
19
- declare type AuthorizeResponse = {
20
- status: number;
21
- body: string;
22
- error?: Error;
23
- };
24
- export declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
25
- export {};
package/lib/cjs/index.js DELETED
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.authorize = void 0;
16
- const node_fetch_1 = __importDefault(require("node-fetch"));
17
- function authorize(options) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- try {
20
- const result = yield node_fetch_1.default(options.liveblocksAuthorizeEndpoint ||
21
- "https://liveblocks.io/api/authorize", {
22
- method: "POST",
23
- headers: {
24
- Authorization: `Bearer: ${options.secret}`,
25
- "Content-Type": "application/json",
26
- },
27
- body: JSON.stringify({
28
- room: options.room,
29
- userId: options.userId,
30
- userInfo: options.userInfo,
31
- }),
32
- });
33
- if (!result.ok) {
34
- return {
35
- status: 403,
36
- body: yield result.text(),
37
- };
38
- }
39
- return {
40
- status: 200,
41
- body: yield result.text(),
42
- };
43
- }
44
- catch (er) {
45
- return {
46
- status: 403,
47
- body: `Call to "https://liveblocks.io/api/authorize" failed. See "error" for more information.`,
48
- error: er,
49
- };
50
- }
51
- });
52
- }
53
- exports.authorize = authorize;
@@ -1,25 +0,0 @@
1
- declare type AuthorizeOptions = {
2
- /**
3
- * The secret api provided at https://liveblocks.io/dashboard/apikeys
4
- */
5
- secret: string;
6
- /**
7
- * The room provided in the authorization request body
8
- */
9
- room: string;
10
- /**
11
- * 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).
12
- */
13
- userId?: string;
14
- /**
15
- * 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
16
- */
17
- userInfo?: any;
18
- };
19
- declare type AuthorizeResponse = {
20
- status: number;
21
- body: string;
22
- error?: Error;
23
- };
24
- export declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
25
- export {};
package/lib/esm/index.js DELETED
@@ -1,46 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import fetch from "node-fetch";
11
- export function authorize(options) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- try {
14
- const result = yield fetch(options.liveblocksAuthorizeEndpoint ||
15
- "https://liveblocks.io/api/authorize", {
16
- method: "POST",
17
- headers: {
18
- Authorization: `Bearer: ${options.secret}`,
19
- "Content-Type": "application/json",
20
- },
21
- body: JSON.stringify({
22
- room: options.room,
23
- userId: options.userId,
24
- userInfo: options.userInfo,
25
- }),
26
- });
27
- if (!result.ok) {
28
- return {
29
- status: 403,
30
- body: yield result.text(),
31
- };
32
- }
33
- return {
34
- status: 200,
35
- body: yield result.text(),
36
- };
37
- }
38
- catch (er) {
39
- return {
40
- status: 403,
41
- body: `Call to "https://liveblocks.io/api/authorize" failed. See "error" for more information.`,
42
- error: er,
43
- };
44
- }
45
- });
46
- }