ludicord 4.1.1 → 4.1.2
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/config/types.d.ts +5 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/activity-rooms.md +1 -1
- package/dist/docs/ai-agents.md +1 -1
- package/dist/docs/api-reference.md +1 -1
- package/dist/docs/api-routes.md +1 -1
- package/dist/docs/build.md +1 -1
- package/dist/docs/cli.md +1 -1
- package/dist/docs/configuration.md +15 -2
- package/dist/docs/deployment.md +1 -1
- package/dist/docs/development.md +1 -1
- package/dist/docs/discord-developer-portal.md +1 -1
- package/dist/docs/discord-sdk.md +1 -1
- package/dist/docs/distribution.md +1 -1
- package/dist/docs/embeds.md +1 -1
- package/dist/docs/environment-variables.md +1 -1
- package/dist/docs/getting-started.md +1 -1
- package/dist/docs/installation.md +2 -2
- package/dist/docs/login.md +1 -1
- package/dist/docs/migration.md +5 -5
- package/dist/docs/mobile-layout.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/pages.md +1 -1
- package/dist/docs/participants.md +1 -1
- package/dist/docs/prefix-router.md +1 -1
- package/dist/docs/project-structure.md +1 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/security.md +2 -2
- package/dist/docs/start.md +1 -1
- package/dist/docs/state-and-effects.md +1 -1
- package/dist/docs/troubleshooting.md +1 -1
- package/dist/docs/voice-events.md +1 -1
- package/dist/docs/websockets.md +1 -1
- package/dist/runtime/server/dev-server.js +2 -2
- package/dist/server/request-security.d.ts +2 -0
- package/dist/server/request-security.js +17 -6
- package/dist/skills/ludicord/SKILL.md +2 -2
- package/dist/skills/ludicord/manifest.yaml +1 -1
- package/dist/skills/ludicord/references/config-deploy.md +5 -1
- package/dist/version.js +1 -1
- package/dist/ws/server.d.ts +1 -1
- package/dist/ws/server.js +3 -2
- package/package.json +1 -1
package/dist/config/types.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ export interface LudicordServerLimits {
|
|
|
35
35
|
export interface LudicordServerConfig {
|
|
36
36
|
port?: number;
|
|
37
37
|
host?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Hostnames allowed by HTTP, WebSocket and development asset routes.
|
|
40
|
+
* Restricted lists also include the configured application's exact
|
|
41
|
+
* `<clientId>.discordsays.com` hostname. `true` accepts every host.
|
|
42
|
+
*/
|
|
38
43
|
allowedHosts?: true | readonly string[];
|
|
39
44
|
/**
|
|
40
45
|
* Browser origins allowed to call framework routes. `discord-activity`
|
package/dist/docs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Ludicord documentation
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Learn Ludicord
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Activity Rooms
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Every authenticated WebSocket client can join the Activity Instance room:
|
package/dist/docs/ai-agents.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AI coding agents
|
|
2
2
|
|
|
3
|
-
Ludicord 4.1.
|
|
3
|
+
Ludicord 4.1.2 ships documentation and agent skills with the npm package. They
|
|
4
4
|
are available offline and change together with the installed framework:
|
|
5
5
|
|
|
6
6
|
```text
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Public API reference
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
This page describes supported import paths and their purpose. The package includes TypeScript declarations for exact signatures and data shapes; use editor completion against the version you actually installed.
|
|
6
6
|
|
package/dist/docs/api-routes.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API Routes
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Create a `route.ts` anywhere under `app/`. For example, `app/api/hello/route.ts` serves `/api/hello`; `app/health/route.ts` serves `/health`. The `api/` directory is optional. Do not place another route file in the same directory.
|
package/dist/docs/build.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Build
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
```bash
|
package/dist/docs/cli.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CLI reference
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Run commands through your generated package scripts or the locally installed `ludicord` executable.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Configuration reference
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Create `ludicord.config.mjs` in the application root:
|
|
6
6
|
|
|
@@ -83,7 +83,20 @@ Targets must be `.` or remain inside the project through a `./` path. Absolute p
|
|
|
83
83
|
|
|
84
84
|
The `"discord-activity"` policy derives `https://<clientId>.discordsays.com` from `discord.clientId` or `LUDICORD_DISCORD_CLIENT_ID`. It also permits normal same-origin requests and never trusts a wildcard for every Activity. Use `"same-origin"` for a host-only policy. When an array adds another trusted browser origin, include both built-in policies explicitly: `["same-origin", "discord-activity", "https://admin.example.com"]`.
|
|
85
85
|
|
|
86
|
-
Use an explicit host list when appropriate.
|
|
86
|
+
Use an explicit host list when appropriate. Ludicord automatically adds the
|
|
87
|
+
configured application's exact `<clientId>.discordsays.com` hostname to that list
|
|
88
|
+
for HTTP requests, WebSocket upgrades and development assets. Other Activities'
|
|
89
|
+
proxy hostnames are not added. The effective Client ID comes from configuration
|
|
90
|
+
in development and uses the supported runtime environment override in production.
|
|
91
|
+
Your deployed server or tunnel hostname must still be listed explicitly because
|
|
92
|
+
Discord URL mappings can target it. A hostname allowance does not replace user
|
|
93
|
+
authentication or the separate Origin policy.
|
|
94
|
+
|
|
95
|
+
For example, `server: { allowedHosts: ["play.example.com"] }` also recognizes
|
|
96
|
+
`123456789.discordsays.com` when the effective application ID is `123456789`.
|
|
97
|
+
No Discord hostname is added when the application ID is missing or malformed.
|
|
98
|
+
|
|
99
|
+
CLI host/port flags override environment values; `HOST` and `PORT` override configured defaults.
|
|
87
100
|
|
|
88
101
|
## WebSockets
|
|
89
102
|
|
package/dist/docs/deployment.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deployment
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Deploy Ludicord to a Node.js 20.19+ environment that supports long-lived HTTP upgrades for WebSockets.
|
package/dist/docs/development.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Development runtime
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
`ludicord dev` owns the HTTP server, API routes, WebSockets, React hot updates, and diagnostics. It binds and announces the local URL before the initial compilation, then reports a clear `listening` → `compiling` → `ready` lifecycle. Requests wait for that first compilation instead of racing an incomplete server:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Discord Developer Portal Setup
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
1. Create a Discord application and enable Activities.
|
package/dist/docs/discord-sdk.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Discord SDK
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord uses the official `@discord/embedded-app-sdk` package and initializes one SDK instance per Activity. `LudicordActivity` waits for SDK readiness before authentication and reuses shared subscriptions rather than registering one listener per component.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Package distribution and automated releases
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Ludicord uses a two-stage release pipeline so its public package links and npm provenance are correct without publishing the original TypeScript implementation.
|
|
6
6
|
|
package/dist/docs/embeds.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Embeds
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
An embed is an internal Activity screen owned by its nearest ancestor page. Create `app/home/embed.tsx` for the root page:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Environment Variables
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
```env
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Getting Started
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Create an Activity and start the development server:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Installation
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Node.js 20.19 or newer is required. A new project is the simplest installation:
|
|
7
7
|
|
|
8
|
-
The commands below install the latest **published** release. Confirm the registry reports 4.1.
|
|
8
|
+
The commands below install the latest **published** release. Confirm the registry reports 4.1.2 before upgrading a production deployment.
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
11
|
npx create-ludicord-app my-activity
|
package/dist/docs/login.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Login and sessions
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord authentication follows the Embedded App SDK authorization-code flow:
|
package/dist/docs/migration.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# Upgrading to Ludicord 4.1.
|
|
1
|
+
# Upgrading to Ludicord 4.1.2
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
|
-
Check that both 4.1.
|
|
5
|
+
Check that both 4.1.2 packages are available before upgrading:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm view ludicord version
|
|
9
9
|
npm view create-ludicord-app version
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Update an existing application's framework dependency with `npm install ludicord@4.1.
|
|
12
|
+
Update an existing application's framework dependency with `npm install ludicord@4.1.2` (or your package-manager equivalent), update its lockfile, and create a fresh production build. The generator is for new projects; do not run it over an existing non-empty application. Existing V3 trees remain supported through legacy compatibility mode; follow [the routing migration](migration-v4.md) before switching file conventions.
|
|
13
13
|
|
|
14
14
|
## Review your application
|
|
15
15
|
|
|
@@ -42,4 +42,4 @@ Update an existing application's framework dependency with `npm install ludicord
|
|
|
42
42
|
- Every expected prefix pathname and default embed URL returns the correct shell.
|
|
43
43
|
- Unknown production prefixes return 404 instead of falling through to an unrelated scope.
|
|
44
44
|
|
|
45
|
-
Back up your current lockfile and keep the last deployable build for rollback. Review the detailed [V4 migration guide](migration-v4.md), [plugins and WebAssembly](plugins.md), [4.1.
|
|
45
|
+
Back up your current lockfile and keep the last deployable build for rollback. Review the detailed [V4 migration guide](migration-v4.md), [plugins and WebAssembly](plugins.md), [4.1.2 release notes](https://github.com/mrcholer/ludicord/blob/main/releases/v4/4.1.2.md), [security](security.md), and [deployment](deployment.md).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mobile and Layout
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord installs four CSS custom properties:
|
package/dist/docs/navigation.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Navigation and generated route types
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Inside one prefix scope, use the Ludicord embed router. The current local embed is synchronized through the hash (`#/profile/user-one`) for deep links and browser back/forward, and hashes are validated against that prefix's generated registry:
|
package/dist/docs/pages.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Pages: page.tsx
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
A default-exported React component in `app/page.tsx` renders at `/`. Nested `page.tsx` files render at their directory paths. A page can render plain UI without any embed:
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Participants
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
```tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Page scopes and optional prefix navigation
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
## Choose the simplest structure
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Project structure
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
The `app/` tree is the router. These four files define routes:
|
|
6
6
|
|
package/dist/docs/recipes.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Usage recipes
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
These small application examples illustrate the public API. They are not framework implementation or complete production applications.
|
|
6
6
|
|
package/dist/docs/security.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Security
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord encrypts and authenticates session cookies with AES-256-GCM, validates OAuth state, keeps server secrets out of React stores, requires sessions for API and WebSocket routes by default, and scans production client output for actual secret values.
|
|
7
7
|
|
|
8
|
-
HTTP requests and WebSocket upgrades share the same boundary checks. `server.allowedOrigins` defaults to `"discord-activity"`, which accepts same-origin requests and the configured application's exact `https://<clientId>.discordsays.com` proxy origin. Ludicord derives the hostname from `discord.clientId` or `LUDICORD_DISCORD_CLIENT_ID` and never trusts a wildcard for other applications. The initial Discord iframe navigation is a safe `GET` request and browsers may omit its `Origin` header, so Ludicord permits origin-less `GET` and `HEAD` navigation. Cross-site mutation requests without an allowed `Origin` remain blocked. Use `"same-origin"` for a host-only policy. An origin array must include `"same-origin"` and `"discord-activity"` explicitly when both built-in policies should remain active alongside additional trusted HTTPS origins. `server.allowedHosts` can restrict the `Host` header to production and tunnel hostnames; `true` accepts every host and produces a production warning.
|
|
8
|
+
HTTP requests and WebSocket upgrades share the same boundary checks. `server.allowedOrigins` defaults to `"discord-activity"`, which accepts same-origin requests and the configured application's exact `https://<clientId>.discordsays.com` proxy origin. Ludicord derives the hostname from `discord.clientId` or `LUDICORD_DISCORD_CLIENT_ID` and never trusts a wildcard for other applications. The initial Discord iframe navigation is a safe `GET` request and browsers may omit its `Origin` header, so Ludicord permits origin-less `GET` and `HEAD` navigation. Cross-site mutation requests without an allowed `Origin` remain blocked. Use `"same-origin"` for a host-only policy. An origin array must include `"same-origin"` and `"discord-activity"` explicitly when both built-in policies should remain active alongside additional trusted HTTPS origins. `server.allowedHosts` can restrict the `Host` header to production and tunnel hostnames; `true` accepts every host and produces a production warning. Restricted host lists automatically include only the effective application’s exact `<clientId>.discordsays.com` hostname across HTTP, WebSockets and development assets. Other application IDs and lookalike domains are not automatically trusted. Keep the production or tunnel target hostname in the explicit list; host recognition does not authenticate a player or grant Activity membership.
|
|
9
9
|
|
|
10
10
|
In production, `LUDICORD_DISCORD_CLIENT_ID` may be supplied when the server starts. That effective runtime ID is injected into the served Activity document and reused by HTTP, authentication, and WebSocket origin checks. This keeps promoted build artifacts consistent with the Discord application that runs them.
|
|
11
11
|
|
package/dist/docs/start.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Start
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Build once, then run the existing output:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# React state and effects
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Ludicord is React, so ordinary React state is the first choice for ordinary interface state. Framework hooks add Activity-aware lifecycles; they do not replace `useState`, `useReducer`, or correct effect cleanup.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Run the checks relevant to the failure:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Voice Events
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Request the `rpc.voice.read` scope, then use:
|
package/dist/docs/websockets.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# WebSockets
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.1.
|
|
3
|
+
> Documentation for Ludicord 4.1.2. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Create `app/ws/presence/socket.ts` for `/ws/presence`, or `app/live/socket.ts` for `/live`. The `ws/` folder is optional. A directory may contain only one route file. Use the full discovered URL in `useWS()`; no `/ws` prefix is added automatically.
|
|
@@ -21,7 +21,7 @@ import { loadProjectEnvironment } from "../../config/environment.js";
|
|
|
21
21
|
import { LUDICORD_VERSION } from "../../version.js";
|
|
22
22
|
import { diagnostic, sourceFrame, watchProjectTypes } from "./diagnostics.js";
|
|
23
23
|
import { createProxyMiddleware } from "../../server/proxy.js";
|
|
24
|
-
import { createLudicordRequestSecurity } from "../../server/request-security.js";
|
|
24
|
+
import { createLudicordRequestSecurity, resolveLudicordAllowedHosts } from "../../server/request-security.js";
|
|
25
25
|
import { formatPrefixTable, formatRouteTable, matchPageRoute, normalizeActivityPrefix } from "../../router/prefix.js";
|
|
26
26
|
import { vitePluginAdapters } from "../../compiler/plugin-runtime.js";
|
|
27
27
|
const ENTRY = "virtual:ludicord-activity-entry";
|
|
@@ -387,7 +387,7 @@ export async function createLudicordDevServer(options) {
|
|
|
387
387
|
cacheDir: path.join(projectRoot, ".ludicord", "cache", "client"),
|
|
388
388
|
customLogger: ludicordLogger((error) => report(error, undefined, "compile")),
|
|
389
389
|
server: {
|
|
390
|
-
middlewareMode: true, allowedHosts: config.server.allowedHosts
|
|
390
|
+
middlewareMode: true, allowedHosts: resolveLudicordAllowedHosts(config.server.allowedHosts, config.discord.clientId),
|
|
391
391
|
// Compile modules when the browser requests them. Vite's speculative
|
|
392
392
|
// pre-transform can still be running when a middleware-mode server is
|
|
393
393
|
// closed, which produces a false esbuild "build was canceled" error.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { RequestHandler } from "express";
|
|
2
2
|
export type LudicordAllowedOrigins = true | "same-origin" | "discord-activity" | readonly string[];
|
|
3
|
+
/** Add only this application's Discord proxy hostname to restricted host lists. */
|
|
4
|
+
export declare function resolveLudicordAllowedHosts(allowedHosts: true | readonly string[], discordClientId?: string): true | string[];
|
|
3
5
|
export declare function isLudicordHostAllowed(hostHeader: string | undefined, allowedHosts: true | readonly string[]): boolean;
|
|
4
6
|
export declare function isLudicordOriginAllowed(originHeader: string | undefined, hostHeader: string | undefined, allowedOrigins: LudicordAllowedOrigins, discordClientId?: string): boolean;
|
|
5
7
|
export declare function createLudicordRequestSecurity(allowedHosts: true | readonly string[], allowedOrigins: LudicordAllowedOrigins, discordClientId?: string): RequestHandler;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
const DISCORD_ACTIVITY_PROXY_DOMAIN = "discordsays.com";
|
|
2
|
+
function discordActivityHostname(discordClientId) {
|
|
3
|
+
const clientId = discordClientId?.trim();
|
|
4
|
+
return clientId !== undefined && /^\d{1,32}$/.test(clientId)
|
|
5
|
+
? `${clientId}.${DISCORD_ACTIVITY_PROXY_DOMAIN}` : undefined;
|
|
6
|
+
}
|
|
7
|
+
/** Add only this application's Discord proxy hostname to restricted host lists. */
|
|
8
|
+
export function resolveLudicordAllowedHosts(allowedHosts, discordClientId) {
|
|
9
|
+
if (allowedHosts === true)
|
|
10
|
+
return true;
|
|
11
|
+
const activityHost = discordActivityHostname(discordClientId);
|
|
12
|
+
return activityHost === undefined ? [...allowedHosts] : [...new Set([...allowedHosts, activityHost])];
|
|
13
|
+
}
|
|
2
14
|
function hostname(value) {
|
|
3
|
-
if (value === undefined || value.trim() === "")
|
|
15
|
+
if (value === undefined || value.trim() === "" || /[\/\\?#@\s]/.test(value.trim()))
|
|
4
16
|
return undefined;
|
|
5
17
|
try {
|
|
6
18
|
return new URL(`http://${value.trim()}`).hostname.toLowerCase();
|
|
@@ -54,10 +66,8 @@ export function isLudicordOriginAllowed(originHeader, hostHeader, allowedOrigins
|
|
|
54
66
|
}
|
|
55
67
|
const sameOrigin = () => origin.host.toLowerCase() === hostAuthority(hostHeader);
|
|
56
68
|
const discordActivity = () => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
return false;
|
|
60
|
-
return origin.protocol === "https:" && origin.port === "" && origin.hostname.toLowerCase() === `${clientId}.${DISCORD_ACTIVITY_PROXY_DOMAIN}`;
|
|
69
|
+
const activityHost = discordActivityHostname(discordClientId);
|
|
70
|
+
return activityHost !== undefined && origin.protocol === "https:" && origin.port === "" && origin.hostname.toLowerCase() === activityHost;
|
|
61
71
|
};
|
|
62
72
|
if (allowedOrigins === "same-origin")
|
|
63
73
|
return sameOrigin();
|
|
@@ -77,8 +87,9 @@ export function isLudicordOriginAllowed(originHeader, hostHeader, allowedOrigins
|
|
|
77
87
|
});
|
|
78
88
|
}
|
|
79
89
|
export function createLudicordRequestSecurity(allowedHosts, allowedOrigins, discordClientId) {
|
|
90
|
+
const effectiveHosts = resolveLudicordAllowedHosts(allowedHosts, discordClientId);
|
|
80
91
|
return (request, response, next) => {
|
|
81
|
-
if (!isLudicordHostAllowed(request.headers.host,
|
|
92
|
+
if (!isLudicordHostAllowed(request.headers.host, effectiveHosts)) {
|
|
82
93
|
response.status(403).json({ error: "LUDICORD_HOST_NOT_ALLOWED", message: "The request Host is not allowed by server.allowedHosts." });
|
|
83
94
|
return;
|
|
84
95
|
}
|
|
@@ -3,7 +3,7 @@ name: ludicord
|
|
|
3
3
|
description: "Build, modify, debug, review, or document Ludicord Discord Activities. Use for Activity roots, embeds, typed navigation, React state and effects, API or WebSocket routes, shared Activity state, Discord SDK data, participants, voice, authentication, security, configuration, compiler plugins, WebAssembly, development diagnostics, deployment, migration, and release compatibility."
|
|
4
4
|
metadata:
|
|
5
5
|
author: ludicord
|
|
6
|
-
version: "4.1.
|
|
6
|
+
version: "4.1.2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# Ludicord
|
|
@@ -287,7 +287,7 @@ npx create-ludicord-app@latest my-activity --tailwind # scripted styling choice
|
|
|
287
287
|
npx create-ludicord-app@latest my-activity --no-tailwind
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
Generated 4.1.
|
|
290
|
+
Generated 4.1.2 projects intentionally include only `dev`, `build`, and
|
|
291
291
|
`start` scripts. Run advanced commands with the project's package runner.
|
|
292
292
|
|
|
293
293
|
## Routed Intelligence References
|
|
@@ -45,7 +45,7 @@ Key settings:
|
|
|
45
45
|
| `activity.defaultEmbed` | `"home"` | Initial registered embed |
|
|
46
46
|
| `activity.outsideDiscord` | `"error"` | `error`, `allow`, or `mock` outside Discord |
|
|
47
47
|
| `server.port` / `server.host` | `3000` / `"0.0.0.0"` | Listening port/interface |
|
|
48
|
-
| `server.allowedHosts` | `true` | All hosts or
|
|
48
|
+
| `server.allowedHosts` | `true` | All hosts, or a list that also recognizes this application’s exact Discord proxy hostname |
|
|
49
49
|
| `server.allowedOrigins` | `"discord-activity"` | Same-origin plus this application's exact Discord proxy origin |
|
|
50
50
|
| `server.limits.body` | `"2mb"` | HTTP request body limit |
|
|
51
51
|
| `websocket.maxPayload` | `262144` | Per-message byte limit |
|
|
@@ -58,6 +58,10 @@ development/testing, never a substitute for production authentication.
|
|
|
58
58
|
Invalid configuration values produce diagnostics. Restart development after
|
|
59
59
|
configuration changes; renew authorization after OAuth scope changes.
|
|
60
60
|
|
|
61
|
+
Restricted host lists automatically include `<clientId>.discordsays.com` for the
|
|
62
|
+
effective configured application in HTTP, WebSocket and development asset checks.
|
|
63
|
+
Keep your deployment/tunnel hostname explicit; other Activities are not added.
|
|
64
|
+
|
|
61
65
|
The default derives `https://<clientId>.discordsays.com` from the configured
|
|
62
66
|
Discord Application ID and never allows a wildcard for other Activities. A
|
|
63
67
|
runtime `LUDICORD_DISCORD_CLIENT_ID` takes precedence over build metadata and
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LUDICORD_VERSION = "4.1.
|
|
1
|
+
export const LUDICORD_VERSION = "4.1.2";
|
package/dist/ws/server.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export interface WebSocketRuntimeOptions {
|
|
|
88
88
|
readonly requireVerifiedActivitySessions?: boolean;
|
|
89
89
|
readonly allowedHosts?: true | readonly string[];
|
|
90
90
|
readonly allowedOrigins?: LudicordAllowedOrigins;
|
|
91
|
-
/** Discord application ID used to recognize this Activity's exact proxy origin. */
|
|
91
|
+
/** Discord application ID used to recognize this Activity's exact proxy hostname and origin. */
|
|
92
92
|
readonly discordClientId?: string;
|
|
93
93
|
readonly adapter?: LudicordWebSocketAdapter;
|
|
94
94
|
readonly enabled?: boolean;
|
package/dist/ws/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { WebSocket, WebSocketServer } from "ws";
|
|
|
5
5
|
import { compareRouteSpecificity, matchRoutePattern } from "../router/match.js";
|
|
6
6
|
import { parseSessionCookie } from "../sessions/cookies.js";
|
|
7
7
|
import { LUDICORD_LAUNCH_QUERY, normalizeLudicordLaunchId } from "../sessions/launch.js";
|
|
8
|
-
import { isLudicordHostAllowed, isLudicordOriginAllowed } from "../server/request-security.js";
|
|
8
|
+
import { isLudicordHostAllowed, isLudicordOriginAllowed, resolveLudicordAllowedHosts } from "../server/request-security.js";
|
|
9
9
|
const INTERNAL_EVENT_PREFIX = "$ludicord:";
|
|
10
10
|
function isReservedEvent(event) {
|
|
11
11
|
return (event.startsWith(INTERNAL_EVENT_PREFIX) ||
|
|
@@ -292,6 +292,7 @@ export function attachWebSocketRuntime(httpServer, options) {
|
|
|
292
292
|
const clients = new Set();
|
|
293
293
|
const clientsByRoute = new Map();
|
|
294
294
|
const loadModule = options.loadModule ?? defaultLoader;
|
|
295
|
+
const allowedHosts = resolveLudicordAllowedHosts(options.allowedHosts ?? true, options.discordClientId);
|
|
295
296
|
const heartbeatInterval = options.heartbeatInterval ?? 30_000;
|
|
296
297
|
const maxPayload = options.maxPayload ?? 262_144;
|
|
297
298
|
const backpressureLimit = options.backpressureLimit ?? 524_288;
|
|
@@ -390,7 +391,7 @@ export function attachWebSocketRuntime(httpServer, options) {
|
|
|
390
391
|
const protocols = String(request.headers["sec-websocket-protocol"] ?? "").split(/,\s*/);
|
|
391
392
|
if (protocols.includes("vite-hmr") || protocols.includes("vite-ping"))
|
|
392
393
|
return;
|
|
393
|
-
if (!isLudicordHostAllowed(request.headers.host,
|
|
394
|
+
if (!isLudicordHostAllowed(request.headers.host, allowedHosts)) {
|
|
394
395
|
rejectUpgrade(socket, 403, "Host Not Allowed");
|
|
395
396
|
return;
|
|
396
397
|
}
|