@absolutejs/voice 0.0.22-beta.651 → 0.0.22-beta.652
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/core/plugin.d.ts +3 -0
- package/dist/index.js +16 -13
- package/package.json +1 -1
package/dist/core/plugin.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Elysia } from "elysia";
|
|
2
2
|
import type { VoicePluginConfig, VoiceSessionRecord } from "./types";
|
|
3
|
+
export declare const resolveSocketHeaders: (ws: {
|
|
4
|
+
data?: unknown;
|
|
5
|
+
}) => Headers;
|
|
3
6
|
export declare const voice: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(config: VoicePluginConfig<TContext, TSession, TResult>) => Elysia<"", {
|
|
4
7
|
decorator: {};
|
|
5
8
|
store: {};
|
package/dist/index.js
CHANGED
|
@@ -39957,24 +39957,27 @@ var resolveSessionId3 = (runtime, ws) => {
|
|
|
39957
39957
|
return resolved;
|
|
39958
39958
|
};
|
|
39959
39959
|
var resolveSocketQuery = (ws) => ws.data && typeof ws.data === "object" && ("query" in ws.data) ? ws.data.query ?? {} : {};
|
|
39960
|
+
var normalizeSocketHeaders = (value) => {
|
|
39961
|
+
if (!value || typeof value !== "object")
|
|
39962
|
+
return null;
|
|
39963
|
+
try {
|
|
39964
|
+
return new Headers(value);
|
|
39965
|
+
} catch {
|
|
39966
|
+
return null;
|
|
39967
|
+
}
|
|
39968
|
+
};
|
|
39960
39969
|
var resolveSocketHeaders = (ws) => {
|
|
39961
39970
|
if (!ws.data || typeof ws.data !== "object")
|
|
39962
39971
|
return new Headers;
|
|
39963
|
-
if ("request" in ws.data && ws.data.request
|
|
39964
|
-
|
|
39972
|
+
if ("request" in ws.data && ws.data.request && typeof ws.data.request === "object" && "headers" in ws.data.request) {
|
|
39973
|
+
const requestHeaders = normalizeSocketHeaders(ws.data.request.headers);
|
|
39974
|
+
if (requestHeaders)
|
|
39975
|
+
return requestHeaders;
|
|
39965
39976
|
}
|
|
39966
39977
|
if ("headers" in ws.data) {
|
|
39967
|
-
const
|
|
39968
|
-
if (
|
|
39969
|
-
return
|
|
39970
|
-
if (headers && typeof headers === "object") {
|
|
39971
|
-
const resolved = new Headers;
|
|
39972
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
39973
|
-
if (typeof value === "string")
|
|
39974
|
-
resolved.set(key, value);
|
|
39975
|
-
}
|
|
39976
|
-
return resolved;
|
|
39977
|
-
}
|
|
39978
|
+
const directHeaders = normalizeSocketHeaders(ws.data.headers);
|
|
39979
|
+
if (directHeaders)
|
|
39980
|
+
return directHeaders;
|
|
39978
39981
|
}
|
|
39979
39982
|
return new Headers;
|
|
39980
39983
|
};
|