@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.
@@ -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 instanceof Request) {
39964
- return ws.data.request.headers;
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 { 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
- }
39978
+ const directHeaders = normalizeSocketHeaders(ws.data.headers);
39979
+ if (directHeaders)
39980
+ return directHeaders;
39978
39981
  }
39979
39982
  return new Headers;
39980
39983
  };
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.652",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",