@laplace.live/event-bridge-server 0.2.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/.env +1 -0
- package/.env.example +8 -0
- package/CHANGELOG.md +13 -0
- package/README.md +118 -0
- package/package.json +23 -0
package/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# LAPLACE_EVENT_BRIDGE_AUTH=laplace
|
package/.env.example
ADDED
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# LAPLACE Event Bridge Server
|
|
2
|
+
|
|
3
|
+
A specialized WebSocket bridge server that connects LAPLACE Chat to clients.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Acts as a bridge between LAPLACE Chat and clients
|
|
8
|
+
- Server-to-clients message broadcasting
|
|
9
|
+
- Role-based connection system
|
|
10
|
+
- Token-based authentication
|
|
11
|
+
|
|
12
|
+
## Use Cases
|
|
13
|
+
|
|
14
|
+
The event bridge enables various use cases:
|
|
15
|
+
|
|
16
|
+
- Integrate user message events directly with Discord
|
|
17
|
+
- Create custom chat layouts in your favorite frontend languages to display chat messages
|
|
18
|
+
- Create custom interactions with chat messages in VTube Studio
|
|
19
|
+
- Connect to streamer.bot, SAMMI, or other 3rd party services for advanced automation and integrations
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- [Bun](https://bun.sh/) v1.0.0 or higher
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### From Source
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Clone the repository
|
|
31
|
+
git clone https://github.com/laplace-live/event-bridge
|
|
32
|
+
cd event-bridge
|
|
33
|
+
|
|
34
|
+
# Install dependencies
|
|
35
|
+
bun install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
### Authentication
|
|
41
|
+
|
|
42
|
+
You can set authentication in order of precedence:
|
|
43
|
+
|
|
44
|
+
1. Environment variable: `LEB_AUTH="your-secure-token"`
|
|
45
|
+
2. Command line: `--auth "your-secure-token"`
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Example using environment variable
|
|
49
|
+
export LEB_AUTH="your-secure-token"
|
|
50
|
+
|
|
51
|
+
# Example using CLI
|
|
52
|
+
bun run start --auth "your-secure-token"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If the authentication token is set, all connections including the clients must provide it to connect.
|
|
56
|
+
|
|
57
|
+
### Debug Mode
|
|
58
|
+
|
|
59
|
+
Enable detailed debug logging using:
|
|
60
|
+
|
|
61
|
+
1. Environment variable: `DEBUG=1` or `DEBUG=true`
|
|
62
|
+
2. Command line: `--debug`
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Enable debug mode using environment variable
|
|
66
|
+
export DEBUG=1
|
|
67
|
+
|
|
68
|
+
# Enable debug mode using CLI
|
|
69
|
+
bun run start --debug
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
### Start the Bridge Server
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Start the server
|
|
78
|
+
bun run start
|
|
79
|
+
|
|
80
|
+
# Start with CLI options
|
|
81
|
+
bun run start --debug --auth "your-secure-token"
|
|
82
|
+
|
|
83
|
+
# Or with hot reloading during development
|
|
84
|
+
bun run dev
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The WebSocket bridge server runs on `http://localhost:9696`.
|
|
88
|
+
|
|
89
|
+
### Connection Types
|
|
90
|
+
|
|
91
|
+
The bridge supports two types of connections:
|
|
92
|
+
|
|
93
|
+
1. **LAPLACE Chat** - Connects with the special protocol `laplace-event-bridge-role-server` and broadcasts messages to all clients
|
|
94
|
+
2. **Clients** - Regular connections that receive broadcasts from the server
|
|
95
|
+
|
|
96
|
+
### Authentication
|
|
97
|
+
|
|
98
|
+
When authentication is enabled, clients must provide the auth token in the WebSocket protocol:
|
|
99
|
+
|
|
100
|
+
- For clients: `['laplace-event-bridge-role-client', 'your-auth-token']`
|
|
101
|
+
|
|
102
|
+
### Message Flow
|
|
103
|
+
|
|
104
|
+
- Messages from the LAPLACE Chat are broadcast to all connected clients
|
|
105
|
+
- Messages from clients are acknowledged but not relayed to other clients or the server
|
|
106
|
+
|
|
107
|
+
## Client Demo
|
|
108
|
+
|
|
109
|
+
A simple HTML client demo is included for testing (`client-demo.html`):
|
|
110
|
+
|
|
111
|
+
1. Open the file in your web browser
|
|
112
|
+
2. Configure connection settings (URL, authentication)
|
|
113
|
+
3. Connect to the bridge
|
|
114
|
+
4. Receive broadcasts from the LAPLACE Chat
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
AGPL
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@laplace.live/event-bridge-server",
|
|
3
|
+
"description": "LAPLACE Event Bridge Server",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"license": "AGPL-3.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "index.ts",
|
|
8
|
+
"main": "index.ts",
|
|
9
|
+
"types": "index.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "bun run index.ts",
|
|
12
|
+
"dev": "bun --hot run index.ts",
|
|
13
|
+
"build": "bun build ./index.ts --outdir ./dist --target node --minify --sourcemap",
|
|
14
|
+
"prepublishOnly": "bun run build"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@laplace.live/event-types": "^2.0.4"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"bun-types": "latest",
|
|
21
|
+
"typescript": "^5.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|