@absolutejs/voice 0.0.22-beta.651 → 0.0.22-beta.653
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 +19 -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,30 @@ 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
|
+
if ("get" in value && typeof value.get === "function" && "entries" in value && typeof value.entries === "function") {
|
|
39964
|
+
return value;
|
|
39965
|
+
}
|
|
39966
|
+
try {
|
|
39967
|
+
return new Headers(value);
|
|
39968
|
+
} catch {
|
|
39969
|
+
return null;
|
|
39970
|
+
}
|
|
39971
|
+
};
|
|
39960
39972
|
var resolveSocketHeaders = (ws) => {
|
|
39961
39973
|
if (!ws.data || typeof ws.data !== "object")
|
|
39962
39974
|
return new Headers;
|
|
39963
|
-
if ("request" in ws.data && ws.data.request
|
|
39964
|
-
|
|
39975
|
+
if ("request" in ws.data && ws.data.request && typeof ws.data.request === "object" && "headers" in ws.data.request) {
|
|
39976
|
+
const requestHeaders = normalizeSocketHeaders(ws.data.request.headers);
|
|
39977
|
+
if (requestHeaders)
|
|
39978
|
+
return requestHeaders;
|
|
39965
39979
|
}
|
|
39966
39980
|
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
|
-
}
|
|
39981
|
+
const directHeaders = normalizeSocketHeaders(ws.data.headers);
|
|
39982
|
+
if (directHeaders)
|
|
39983
|
+
return directHeaders;
|
|
39978
39984
|
}
|
|
39979
39985
|
return new Headers;
|
|
39980
39986
|
};
|