lumisjs 1.0.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/LICENSE +21 -0
- package/README.md +274 -0
- package/SECURITY.md +160 -0
- package/index.js +90 -0
- package/package.json +68 -0
- package/src/cache/CacheManager.js +393 -0
- package/src/cache/MemoryAdapter.js +259 -0
- package/src/cache/MultiLevelCache.js +362 -0
- package/src/cache/RedisAdapter.js +329 -0
- package/src/cache/SQLiteAdapter.js +280 -0
- package/src/cache/index.js +15 -0
- package/src/client/Client.js +554 -0
- package/src/client/ShardingManager.js +274 -0
- package/src/config/ConfigValidator.js +172 -0
- package/src/config/index.js +7 -0
- package/src/dashboard/DashboardManager.js +362 -0
- package/src/datagen/DataGenerator.js +47 -0
- package/src/datagen/apis/GraphqlMocker.js +16 -0
- package/src/datagen/apis/OpenApiMocker.js +18 -0
- package/src/datagen/cli.js +130 -0
- package/src/datagen/formatters/csv.js +45 -0
- package/src/datagen/formatters/index.js +15 -0
- package/src/datagen/formatters/json.js +33 -0
- package/src/datagen/formatters/mongo.js +22 -0
- package/src/datagen/formatters/sql.js +32 -0
- package/src/datagen/index.js +17 -0
- package/src/datagen/plugin/PluginManager.js +43 -0
- package/src/datagen/plugins/example-plugin.js +21 -0
- package/src/datagen/schema/SchemaGenerator.js +172 -0
- package/src/datagen/schema/loadSchema.js +14 -0
- package/src/datagen/utils/seed.js +26 -0
- package/src/di/ServiceContainer.js +229 -0
- package/src/errors/ErrorCodes.js +110 -0
- package/src/errors/LumisError.js +85 -0
- package/src/game/EconomyManager.js +161 -0
- package/src/game/GameSessionManager.js +76 -0
- package/src/game/GuildManager.js +197 -0
- package/src/game/InventoryManager.js +140 -0
- package/src/game/LevelingSystem.js +194 -0
- package/src/game/MusicManager.js +587 -0
- package/src/health/HealthChecker.js +170 -0
- package/src/health/index.js +7 -0
- package/src/performance/PerformanceMonitor.js +244 -0
- package/src/performance/index.js +7 -0
- package/src/security/InputSanitizer.js +185 -0
- package/src/security/SecurityMiddleware.js +231 -0
- package/src/security/index.js +9 -0
- package/src/shutdown/GracefulShutdown.js +159 -0
- package/src/shutdown/index.js +7 -0
- package/src/utils/StructuredLogger.js +118 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Lumis
|
|
2
|
+
|
|
3
|
+
A powerful, feature-rich Discord bot framework with advanced capabilities including game systems, data generation, dependency injection, and more.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Advanced Client Architecture**: Built on top of Discord's API with WebSocket support
|
|
8
|
+
- **Game Systems**: Built-in economy, inventory, leveling, guild management, and music systems
|
|
9
|
+
- **Data Generation**: Powerful mock data generation with support for OpenAPI and GraphQL schemas
|
|
10
|
+
- **Dependency Injection**: Service container for managing and injecting dependencies
|
|
11
|
+
- **Advanced Caching**: Multi-level caching (Memory, Redis, SQLite) with automatic promotion/demotion
|
|
12
|
+
- **Security**: Input sanitization, security middleware, rate limiting, and protection against common attacks
|
|
13
|
+
- **Performance Monitoring**: Real-time CPU, memory, and event loop monitoring with alerts
|
|
14
|
+
- **Health Checks**: Built-in health checker with periodic monitoring and alerts
|
|
15
|
+
- **Graceful Shutdown**: Proper cleanup on shutdown with timeout handling
|
|
16
|
+
- **Configuration Validation**: Schema-based configuration validation
|
|
17
|
+
- **Structured Logging**: Winston-based structured logging with multiple transports
|
|
18
|
+
- **Plugin System**: Extensible plugin architecture
|
|
19
|
+
- **Command System**: Slash command support with interaction handling
|
|
20
|
+
- **Dashboard**: Web dashboard for bot management with security headers and CSP
|
|
21
|
+
- **Hot Reload**: Automatic command reloading during development
|
|
22
|
+
- **Middleware & Interceptors**: Event processing pipeline
|
|
23
|
+
- **Sharding**: Built-in sharding support for large bots with safe IPC communication
|
|
24
|
+
- **Internationalization**: i18n support for multiple languages
|
|
25
|
+
- **Error Handling**: Comprehensive error handling with custom error types
|
|
26
|
+
- **Testing**: Comprehensive test suite with Jest
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install lumis
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const { Client, Intents } = require('lumis');
|
|
38
|
+
|
|
39
|
+
const client = new Client({
|
|
40
|
+
intents: [
|
|
41
|
+
Intents.FLAGS.GUILDS,
|
|
42
|
+
Intents.FLAGS.GUILD_MESSAGES,
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
client.on('ready', () => {
|
|
47
|
+
console.log(`Logged in as ${client.user.tag}`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
client.login('YOUR_BOT_TOKEN');
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Documentation
|
|
54
|
+
|
|
55
|
+
### Core Client
|
|
56
|
+
|
|
57
|
+
The `Client` class is the main entry point for your bot.
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
const { Client } = require('lumis');
|
|
61
|
+
|
|
62
|
+
const client = new Client({
|
|
63
|
+
intents: ['GUILDS', 'GUILD_MESSAGES'],
|
|
64
|
+
logLevel: 'debug',
|
|
65
|
+
cache: { adapter: 'memory' },
|
|
66
|
+
economy: { enabled: true },
|
|
67
|
+
music: { enabled: false },
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Game Systems
|
|
72
|
+
|
|
73
|
+
Lumis includes several game systems out of the box:
|
|
74
|
+
|
|
75
|
+
#### Economy System
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
client.economy.addBalance(userId, 100);
|
|
79
|
+
client.economy.removeBalance(userId, 50);
|
|
80
|
+
const balance = client.economy.getBalance(userId);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Inventory System
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
client.inventory.addItem(userId, 'sword', { damage: 10 });
|
|
87
|
+
client.inventory.removeItem(userId, 'sword');
|
|
88
|
+
const items = client.inventory.getItems(userId);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Leveling System
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
client.leveling.addXP(userId, 50);
|
|
95
|
+
const level = client.leveling.getLevel(userId);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Data Generation
|
|
99
|
+
|
|
100
|
+
Generate mock data from schemas:
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
const { DataGenerator, loadSchema } = require('lumis');
|
|
104
|
+
|
|
105
|
+
const schema = loadSchema('./schema.json');
|
|
106
|
+
const generator = new DataGenerator(schema);
|
|
107
|
+
|
|
108
|
+
const data = generator.generate(10); // Generate 10 records
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Dependency Injection
|
|
112
|
+
|
|
113
|
+
Register and inject services:
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// Register a service
|
|
117
|
+
client.services.register('database', new Database());
|
|
118
|
+
|
|
119
|
+
// Inject into a command
|
|
120
|
+
class MyCommand extends Command {
|
|
121
|
+
inject = ['database'];
|
|
122
|
+
|
|
123
|
+
async execute(interaction) {
|
|
124
|
+
const data = await this.database.query('SELECT * FROM users');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Caching
|
|
130
|
+
|
|
131
|
+
Configure different cache adapters:
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
const client = new Client({
|
|
135
|
+
cache: {
|
|
136
|
+
adapter: 'redis', // or 'memory', 'sqlite'
|
|
137
|
+
options: {
|
|
138
|
+
host: 'localhost',
|
|
139
|
+
port: 6379,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Plugin System
|
|
146
|
+
|
|
147
|
+
Create and load plugins:
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// Load a plugin
|
|
151
|
+
client.plugins.load('./plugins/my-plugin');
|
|
152
|
+
|
|
153
|
+
// Plugin structure
|
|
154
|
+
module.exports = {
|
|
155
|
+
name: 'my-plugin',
|
|
156
|
+
version: '1.0.0',
|
|
157
|
+
load(client) {
|
|
158
|
+
// Initialize plugin
|
|
159
|
+
},
|
|
160
|
+
unload(client) {
|
|
161
|
+
// Cleanup
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## API Reference
|
|
167
|
+
|
|
168
|
+
### Classes
|
|
169
|
+
|
|
170
|
+
- **Client**: Main bot client
|
|
171
|
+
- **ServiceContainer**: Dependency injection container
|
|
172
|
+
- **CacheManager**: Unified cache management with metrics
|
|
173
|
+
- **MultiLevelCache**: Advanced tiered caching with auto promotion/demotion
|
|
174
|
+
- **MemoryAdapter**: In-memory cache with LRU eviction
|
|
175
|
+
- **RedisAdapter**: Redis cache with pub/sub for distributed invalidation
|
|
176
|
+
- **SQLiteAdapter**: Persistent SQLite cache with transactions
|
|
177
|
+
- **InputSanitizer**: Input validation and sanitization
|
|
178
|
+
- **SecurityMiddleware**: Rate limiting, IP blocking, and request validation
|
|
179
|
+
- **PerformanceMonitor**: Real-time performance metrics and alerts
|
|
180
|
+
- **HealthChecker**: Health monitoring with periodic checks
|
|
181
|
+
- **GracefulShutdown**: Graceful shutdown handler with cleanup
|
|
182
|
+
- **ConfigValidator**: Schema-based configuration validation
|
|
183
|
+
- **StructuredLogger**: Winston-based structured logging
|
|
184
|
+
- **PluginManager**: Plugin system
|
|
185
|
+
- **CommandManager**: Command handling
|
|
186
|
+
- **DataGenerator**: Mock data generation
|
|
187
|
+
- **EconomyManager**: Economy system
|
|
188
|
+
- **InventoryManager**: Inventory system
|
|
189
|
+
- **LevelingSystem**: Leveling system
|
|
190
|
+
- **GameSessionManager**: Game session management
|
|
191
|
+
- **GuildManager**: Guild management
|
|
192
|
+
- **MusicManager**: Music playback
|
|
193
|
+
- **DashboardManager**: Web dashboard with security
|
|
194
|
+
|
|
195
|
+
### Errors
|
|
196
|
+
|
|
197
|
+
- **LumisError**: Base error class
|
|
198
|
+
- **APIError**: API-related errors
|
|
199
|
+
- **WebSocketError**: WebSocket connection errors
|
|
200
|
+
- **RateLimitError**: Rate limit errors
|
|
201
|
+
|
|
202
|
+
## Project Structure
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
lumis/
|
|
206
|
+
├── src/
|
|
207
|
+
│ ├── cache/ # Cache adapters
|
|
208
|
+
│ ├── client/ # Main client
|
|
209
|
+
│ ├── config/ # Configuration validation
|
|
210
|
+
│ ├── dashboard/ # Dashboard system
|
|
211
|
+
│ ├── datagen/ # Data generation
|
|
212
|
+
│ ├── di/ # Dependency injection
|
|
213
|
+
│ ├── errors/ # Error handling
|
|
214
|
+
│ ├── game/ # Game systems
|
|
215
|
+
│ ├── guards/ # Route guards
|
|
216
|
+
│ ├── health/ # Health monitoring
|
|
217
|
+
│ ├── interactions/ # Command handling
|
|
218
|
+
│ ├── interceptors/ # Event interceptors
|
|
219
|
+
│ ├── middleware/ # Middleware
|
|
220
|
+
│ ├── performance/ # Performance monitoring
|
|
221
|
+
│ ├── plugins/ # Plugin system
|
|
222
|
+
│ ├── rest/ # REST API
|
|
223
|
+
│ ├── security/ # Security middleware
|
|
224
|
+
│ ├── shutdown/ # Graceful shutdown
|
|
225
|
+
│ ├── structures/ # Data structures
|
|
226
|
+
│ ├── utils/ # Utilities
|
|
227
|
+
│ └── ws/ # WebSocket
|
|
228
|
+
├── tests/ # Test files
|
|
229
|
+
├── data/ # Data files
|
|
230
|
+
├── examples/ # Example schemas
|
|
231
|
+
└── index.js # Entry point
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Contributing
|
|
235
|
+
|
|
236
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
237
|
+
|
|
238
|
+
### Development Setup
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Install dependencies
|
|
242
|
+
npm install
|
|
243
|
+
|
|
244
|
+
# Run tests
|
|
245
|
+
npm test
|
|
246
|
+
|
|
247
|
+
# Run tests with coverage
|
|
248
|
+
npm run test:coverage
|
|
249
|
+
|
|
250
|
+
# Run tests in watch mode
|
|
251
|
+
npm run test:watch
|
|
252
|
+
|
|
253
|
+
# Run linter
|
|
254
|
+
npm run lint
|
|
255
|
+
|
|
256
|
+
# Format code
|
|
257
|
+
npm run format
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Security
|
|
261
|
+
|
|
262
|
+
Lumis takes security seriously. Key security features include:
|
|
263
|
+
|
|
264
|
+
- **Input Sanitization**: All user input is automatically sanitized to prevent XSS and injection attacks
|
|
265
|
+
- **Rate Limiting**: Built-in rate limiting to prevent abuse
|
|
266
|
+
- **Security Headers**: Dashboard includes comprehensive security headers (CSP, XSS protection, etc.)
|
|
267
|
+
- **Safe Sharding**: IPC communication uses registered handlers only, no arbitrary code execution
|
|
268
|
+
- **No Dynamic Code**: Dangerous `eval()` and `new Function()` usage has been eliminated
|
|
269
|
+
|
|
270
|
+
See [SECURITY.md](SECURITY.md) for detailed security information and best practices.
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
MIT License - see LICENSE file for details.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Lumis takes security seriously and implements multiple layers of protection to ensure safe operation.
|
|
6
|
+
|
|
7
|
+
## Security Features
|
|
8
|
+
|
|
9
|
+
### Input Sanitization
|
|
10
|
+
|
|
11
|
+
All user input is sanitized using the `InputSanitizer` class to prevent:
|
|
12
|
+
- XSS attacks
|
|
13
|
+
- SQL injection
|
|
14
|
+
- Command injection
|
|
15
|
+
- Path traversal
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
const { InputSanitizer } = require('lumis');
|
|
19
|
+
|
|
20
|
+
const sanitized = InputSanitizer.sanitize(userInput, {
|
|
21
|
+
allowHTML: false,
|
|
22
|
+
allowScript: false,
|
|
23
|
+
maxLength: 1000,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Security Middleware
|
|
28
|
+
|
|
29
|
+
The `SecurityMiddleware` class provides:
|
|
30
|
+
- Rate limiting
|
|
31
|
+
- IP blocking
|
|
32
|
+
- Request size validation
|
|
33
|
+
- Suspicious pattern detection
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
const { SecurityMiddleware } = require('lumis');
|
|
37
|
+
|
|
38
|
+
const security = new SecurityMiddleware({
|
|
39
|
+
maxRequestSize: 1024 * 1024, // 1MB
|
|
40
|
+
rateLimitWindow: 60000, // 1 minute
|
|
41
|
+
rateLimitMax: 100,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Use with Express
|
|
45
|
+
app.use(security.createMiddleware());
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Safe Sharding
|
|
49
|
+
|
|
50
|
+
**IMPORTANT**: IPC communication uses registered handlers only. Arbitrary code execution is not supported.
|
|
51
|
+
|
|
52
|
+
Use the safe `broadcastAction` method with registered handlers:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
// Register a handler
|
|
56
|
+
client.registerBroadcastHandler('getStats', () => ({
|
|
57
|
+
guilds: client.guilds.size,
|
|
58
|
+
users: client.users.size,
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
// Use safe broadcast
|
|
62
|
+
const stats = await manager.broadcastAction('getStats');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Cache Security
|
|
66
|
+
|
|
67
|
+
- No arbitrary code execution in cache operations
|
|
68
|
+
- TTL-based automatic expiration
|
|
69
|
+
- Pattern-based invalidation
|
|
70
|
+
- Backup/restore with validation
|
|
71
|
+
|
|
72
|
+
### Dashboard Security
|
|
73
|
+
|
|
74
|
+
The dashboard includes:
|
|
75
|
+
- Authentication via Bearer tokens
|
|
76
|
+
- Security headers (CSP, XSS protection, frame options)
|
|
77
|
+
- CORS configuration
|
|
78
|
+
- Rate limiting
|
|
79
|
+
|
|
80
|
+
## Security Headers
|
|
81
|
+
|
|
82
|
+
The dashboard automatically sets the following security headers:
|
|
83
|
+
|
|
84
|
+
- `X-Content-Type-Options: nosniff`
|
|
85
|
+
- `X-Frame-Options: DENY`
|
|
86
|
+
- `X-XSS-Protection: 1; mode=block`
|
|
87
|
+
- `Strict-Transport-Security: max-age=31536000; includeSubDomains`
|
|
88
|
+
- `Content-Security-Policy: default-src 'self'`
|
|
89
|
+
|
|
90
|
+
## Best Practices
|
|
91
|
+
|
|
92
|
+
### 1. Never Hardcode Tokens
|
|
93
|
+
|
|
94
|
+
Always use environment variables:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
const token = process.env.DISCORD_TOKEN;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 2. Validate All Input
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
const { InputSanitizer } = require('lumis');
|
|
104
|
+
|
|
105
|
+
function handleUserInput(input) {
|
|
106
|
+
const sanitized = InputSanitizer.sanitize(input);
|
|
107
|
+
// Process sanitized input
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. Use Rate Limiting
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
const { SecurityMiddleware } = require('lumis');
|
|
115
|
+
|
|
116
|
+
const security = new SecurityMiddleware({
|
|
117
|
+
rateLimitMax: 100,
|
|
118
|
+
rateLimitWindow: 60000,
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 4. Enable Authentication
|
|
123
|
+
|
|
124
|
+
Always enable authentication on the dashboard:
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const client = new Client({
|
|
128
|
+
dashboard: {
|
|
129
|
+
enabled: true,
|
|
130
|
+
auth: process.env.DASHBOARD_AUTH,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 5. Keep Dependencies Updated
|
|
136
|
+
|
|
137
|
+
Regularly update dependencies:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm audit
|
|
141
|
+
npm audit fix
|
|
142
|
+
npm update
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Reporting Security Issues
|
|
146
|
+
|
|
147
|
+
If you discover a security vulnerability, please:
|
|
148
|
+
|
|
149
|
+
1. Do not create a public issue
|
|
150
|
+
2. Email security details to the maintainers
|
|
151
|
+
3. Include steps to reproduce
|
|
152
|
+
4. Allow time for the issue to be fixed before disclosing
|
|
153
|
+
|
|
154
|
+
## Security Audits
|
|
155
|
+
|
|
156
|
+
This project undergoes regular security audits to identify and fix vulnerabilities.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
This security policy is part of the Lumis project and is licensed under the MIT License.
|
package/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lumis - A powerful Discord bot framework
|
|
5
|
+
*
|
|
6
|
+
* @module Lumis
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const Client = require('./src/client/Client');
|
|
10
|
+
const { LumisError, APIError, WebSocketError, RateLimitError } = require('./src/errors/LumisError');
|
|
11
|
+
const { ErrorCodes } = require('./src/errors/ErrorCodes');
|
|
12
|
+
const ServiceContainer = require('./src/di/ServiceContainer');
|
|
13
|
+
const { CacheManager, MemoryAdapter, RedisAdapter, SQLiteAdapter, MultiLevelCache } = require('./src/cache');
|
|
14
|
+
const { InputSanitizer, SecurityMiddleware } = require('./src/security');
|
|
15
|
+
const { PerformanceMonitor } = require('./src/performance');
|
|
16
|
+
|
|
17
|
+
// Data generation module
|
|
18
|
+
const {
|
|
19
|
+
DataGenerator,
|
|
20
|
+
loadSchema,
|
|
21
|
+
formatters,
|
|
22
|
+
PluginManager: DataGenPluginManager,
|
|
23
|
+
mockFromOpenApi,
|
|
24
|
+
mockFromGraphqlSchema,
|
|
25
|
+
} = require('./src/datagen');
|
|
26
|
+
|
|
27
|
+
// Game systems
|
|
28
|
+
const EconomyManager = require('./src/game/EconomyManager');
|
|
29
|
+
const InventoryManager = require('./src/game/InventoryManager');
|
|
30
|
+
const LevelingSystem = require('./src/game/LevelingSystem');
|
|
31
|
+
const GameSessionManager = require('./src/game/GameSessionManager');
|
|
32
|
+
const GuildManager = require('./src/game/GuildManager');
|
|
33
|
+
const MusicManager = require('./src/game/MusicManager');
|
|
34
|
+
|
|
35
|
+
// Dashboard
|
|
36
|
+
const DashboardManager = require('./src/dashboard/DashboardManager');
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
// Core
|
|
40
|
+
Client,
|
|
41
|
+
|
|
42
|
+
// Errors
|
|
43
|
+
LumisError,
|
|
44
|
+
APIError,
|
|
45
|
+
WebSocketError,
|
|
46
|
+
RateLimitError,
|
|
47
|
+
ErrorCodes,
|
|
48
|
+
|
|
49
|
+
// Dependency Injection
|
|
50
|
+
ServiceContainer,
|
|
51
|
+
|
|
52
|
+
// Caching
|
|
53
|
+
CacheManager,
|
|
54
|
+
MemoryAdapter,
|
|
55
|
+
RedisAdapter,
|
|
56
|
+
SQLiteAdapter,
|
|
57
|
+
MultiLevelCache,
|
|
58
|
+
|
|
59
|
+
// Security
|
|
60
|
+
InputSanitizer,
|
|
61
|
+
SecurityMiddleware,
|
|
62
|
+
|
|
63
|
+
// Performance
|
|
64
|
+
PerformanceMonitor,
|
|
65
|
+
|
|
66
|
+
// Health & Monitoring
|
|
67
|
+
HealthChecker,
|
|
68
|
+
GracefulShutdown,
|
|
69
|
+
ConfigValidator,
|
|
70
|
+
StructuredLogger,
|
|
71
|
+
|
|
72
|
+
// Data Generation
|
|
73
|
+
DataGenerator,
|
|
74
|
+
loadSchema,
|
|
75
|
+
formatters,
|
|
76
|
+
PluginManager: DataGenPluginManager,
|
|
77
|
+
mockFromOpenApi,
|
|
78
|
+
mockFromGraphqlSchema,
|
|
79
|
+
|
|
80
|
+
// Game Systems
|
|
81
|
+
EconomyManager,
|
|
82
|
+
InventoryManager,
|
|
83
|
+
LevelingSystem,
|
|
84
|
+
GameSessionManager,
|
|
85
|
+
GuildManager,
|
|
86
|
+
MusicManager,
|
|
87
|
+
|
|
88
|
+
// Dashboard
|
|
89
|
+
DashboardManager,
|
|
90
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lumisjs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A powerful, feature-rich Discord bot framework with advanced capabilities including game systems, data generation, dependency injection, security, performance monitoring, health checks, and more.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"test:coverage": "jest --coverage",
|
|
10
|
+
"test:watch": "jest --watch",
|
|
11
|
+
"lint": "eslint src/ tests/",
|
|
12
|
+
"lint:fix": "eslint src/ tests/ --fix",
|
|
13
|
+
"format": "prettier --write \"src/**/*.js\" \"tests/**/*.js\"",
|
|
14
|
+
"format:check": "prettier --check \"src/**/*.js\" \"tests/**/*.js\"",
|
|
15
|
+
"prepare": "husky install || true"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"discord",
|
|
19
|
+
"bot",
|
|
20
|
+
"framework",
|
|
21
|
+
"discord.js",
|
|
22
|
+
"gaming",
|
|
23
|
+
"economy",
|
|
24
|
+
"music",
|
|
25
|
+
"dashboard",
|
|
26
|
+
"sharding",
|
|
27
|
+
"data-generation",
|
|
28
|
+
"security",
|
|
29
|
+
"caching",
|
|
30
|
+
"performance",
|
|
31
|
+
"monitoring",
|
|
32
|
+
"health-checks",
|
|
33
|
+
"graceful-shutdown",
|
|
34
|
+
"logging",
|
|
35
|
+
"middleware"
|
|
36
|
+
],
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=16.0.0"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/username/lumis"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/username/lumis/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/username/lumis#readme",
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"ws": "^8.14.0",
|
|
52
|
+
"helmet": "^7.1.0",
|
|
53
|
+
"winston": "^3.11.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"eslint": "^8.50.0",
|
|
57
|
+
"prettier": "^3.0.0",
|
|
58
|
+
"jest": "^29.7.0",
|
|
59
|
+
"husky": "^8.0.3"
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"src/",
|
|
63
|
+
"index.js",
|
|
64
|
+
"README.md",
|
|
65
|
+
"LICENSE",
|
|
66
|
+
"SECURITY.md"
|
|
67
|
+
]
|
|
68
|
+
}
|