@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.
@@ -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 instanceof Request) {
39964
- return ws.data.request.headers;
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 { headers } = ws.data;
39968
- if (headers instanceof Headers)
39969
- return headers;
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.651",
3
+ "version": "0.0.22-beta.653",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",