voicecc 1.2.0 → 1.2.1
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/dashboard/routes/webrtc.ts +2 -11
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WebRTC device pairing API routes.
|
|
3
3
|
*
|
|
4
4
|
* Handles pairing code generation and device token validation:
|
|
5
|
-
* - POST /generate-code --
|
|
5
|
+
* - POST /generate-code -- create a 6-digit pairing code
|
|
6
6
|
* - POST /pair -- validate a code and issue a device token
|
|
7
7
|
* - GET /validate -- check if a device token is valid
|
|
8
8
|
*/
|
|
@@ -27,17 +27,8 @@ import {
|
|
|
27
27
|
export function webrtcRoutes(): Hono {
|
|
28
28
|
const app = new Hono();
|
|
29
29
|
|
|
30
|
-
/** Generate a pairing code
|
|
30
|
+
/** Generate a pairing code */
|
|
31
31
|
app.post("/generate-code", (c) => {
|
|
32
|
-
const remoteAddr = c.req.header("x-forwarded-for") ?? "";
|
|
33
|
-
const isLocalhost = remoteAddr === "127.0.0.1" || remoteAddr === "::1" || remoteAddr === "::ffff:127.0.0.1" || remoteAddr === "";
|
|
34
|
-
console.log(`[webrtc] generate-code from ${remoteAddr || "(empty)"}, isLocalhost=${isLocalhost}`);
|
|
35
|
-
|
|
36
|
-
if (!isLocalhost) {
|
|
37
|
-
console.log("[webrtc] generate-code REJECTED: not localhost");
|
|
38
|
-
return c.json({ error: "Pairing codes can only be generated from localhost" }, 403);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
32
|
const result = generatePairingCode();
|
|
42
33
|
console.log("[webrtc] generate-code OK, code:", result.code);
|
|
43
34
|
return c.json(result);
|
package/package.json
CHANGED