@fluxy-chat/sdk 0.2.0 → 0.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/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export { useRooms } from "./use-rooms";
12
12
  import { FluxyChatRoomConnection } from "./room-connection";
13
13
  import { clampHistoryLimit, sortMessagesChronological } from "./message-history";
14
14
  import { normalizeRoomMembers } from "./room-rest";
15
+ import { trimTrailingSlashes } from "./url-utils";
15
16
  const AUDIO_FILE_SUFFIXES = [".webm", ".m4a", ".mp3", ".wav", ".ogg"];
16
17
  function fileNameLooksLikeAudio(fileName) {
17
18
  const lower = fileName.toLowerCase();
@@ -31,12 +32,6 @@ function inferAttachmentKind(contentType, fileName) {
31
32
  return "audio";
32
33
  return "file";
33
34
  }
34
- function trimTrailingSlashes(url) {
35
- let out = url;
36
- while (out.endsWith("/"))
37
- out = out.slice(0, -1);
38
- return out;
39
- }
40
35
  function httpUrlToWebSocketBase(url) {
41
36
  if (url.startsWith("https://"))
42
37
  return `wss://${url.slice("https://".length)}`;
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
4
  import { FluxyChatClient } from "./index";
5
5
  import { decodeFluxyJwtPayload, jwtRefreshDelayMs } from "./jwt-utils";
6
+ import { trimTrailingSlashes } from "./url-utils";
6
7
  import { FluxyRealtimeContext } from "./use-fluxy-chat";
7
8
  async function resolveAuthToken(provider) {
8
9
  if (typeof provider === "string") {
@@ -113,7 +114,7 @@ export function FluxyRealtimeProvider({ children, workerUrl, authTokenProvider,
113
114
  if (!token?.trim() || !userId.trim())
114
115
  return null;
115
116
  return new FluxyChatClient({
116
- baseUrl: workerUrl.replace(/\/+$/, ""),
117
+ baseUrl: trimTrailingSlashes(workerUrl),
117
118
  userId,
118
119
  token,
119
120
  });
@@ -0,0 +1,2 @@
1
+ /** Strip trailing slashes without regex (avoids ReDoS on hostile URLs). */
2
+ export declare function trimTrailingSlashes(url: string): string;
@@ -0,0 +1,7 @@
1
+ /** Strip trailing slashes without regex (avoids ReDoS on hostile URLs). */
2
+ export function trimTrailingSlashes(url) {
3
+ let out = url;
4
+ while (out.endsWith("/"))
5
+ out = out.slice(0, -1);
6
+ return out;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxy-chat/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Fluxychat JavaScript/TypeScript SDK — WebSocket rooms, REST messages, FluxyRealtimeProvider, useChat with loadMore",
5
5
  "license": "MIT",
6
6
  "author": "Fluxychat",
@@ -48,6 +48,8 @@
48
48
  "dist/room-rest.d.ts",
49
49
  "dist/agent-outbound.js",
50
50
  "dist/agent-outbound.d.ts",
51
+ "dist/url-utils.js",
52
+ "dist/url-utils.d.ts",
51
53
  "LICENSE",
52
54
  "README.md"
53
55
  ],