diff --git a/package.json b/package.json index 99785f2c..3da7c4b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fishjam-web-sdk", - "version": "0.28.0", + "version": "0.28.2", "license": "MIT", "private": true, "workspaces": [ diff --git a/packages/mobile-client/package.json b/packages/mobile-client/package.json index f9a6569f..e503f8c6 100644 --- a/packages/mobile-client/package.json +++ b/packages/mobile-client/package.json @@ -1,6 +1,6 @@ { "name": "@fishjam-cloud/react-native-client", - "version": "0.28.0", + "version": "0.28.2", "description": "React Native client library for Fishjam", "license": "Apache-2.0", "author": "Fishjam Team", diff --git a/packages/react-client/package.json b/packages/react-client/package.json index c08c75a7..454d5fb6 100644 --- a/packages/react-client/package.json +++ b/packages/react-client/package.json @@ -1,6 +1,6 @@ { "name": "@fishjam-cloud/react-client", - "version": "0.28.0", + "version": "0.28.2", "description": "React client library for Fishjam", "license": "Apache-2.0", "author": "Fishjam Team", diff --git a/packages/react-client/src/hooks/useSandbox.ts b/packages/react-client/src/hooks/useSandbox.ts index 9c243e27..57d54572 100644 --- a/packages/react-client/src/hooks/useSandbox.ts +++ b/packages/react-client/src/hooks/useSandbox.ts @@ -10,6 +10,16 @@ type RoomManagerResponse = { peer: BasicInfo; }; +type MoqAccessResponse = { + connection_url: string; + token: string; +}; + +export type MoqAccess = { + connectionUrl: string; + token: string; +}; + export type UseSandboxProps = { sandboxApiUrl: string; }; @@ -79,36 +89,36 @@ export const useSandbox = (props: UseSandboxProps) => { [sandboxApiUrl], ); - const fetchMoqToken = useCallback( - async (streamName: string, type: "subscriber" | "publisher") => { + const fetchMoqAccess = useCallback( + async (streamName: string, type: "subscriber" | "publisher"): Promise => { if (!sandboxApiUrl) throw new MissingSandboxApiUrlError(); const urlEncodedStreamName = encodeURIComponent(streamName); const res = await fetch(`${sandboxApiUrl}/moq/${urlEncodedStreamName}/${type}`); - if (!res.ok) throw new Error(`Failed to retrieve MoQ ${type} token for stream '${streamName}'.`); + if (!res.ok) throw new Error(`Failed to retrieve MoQ ${type} connection for stream '${streamName}'.`); - const data: { token: string } = await res.json(); - return data.token; + const data: MoqAccessResponse = await res.json(); + return { connectionUrl: data.connection_url, token: data.token }; }, [sandboxApiUrl], ); - const getSandboxMoqPublisherToken = useCallback( - async (streamName: string) => fetchMoqToken(streamName, "publisher"), - [fetchMoqToken], + const getSandboxMoqPublisherAccess = useCallback( + async (streamName: string) => fetchMoqAccess(streamName, "publisher"), + [fetchMoqAccess], ); - const getSandboxMoqSubscriberToken = useCallback( - async (streamName: string) => fetchMoqToken(streamName, "subscriber"), - [fetchMoqToken], + const getSandboxMoqSubscriberAccess = useCallback( + async (streamName: string) => fetchMoqAccess(streamName, "subscriber"), + [fetchMoqAccess], ); return { getSandboxPeerToken, getSandboxViewerToken, getSandboxLivestream, - getSandboxMoqPublisherToken, - getSandboxMoqSubscriberToken, + getSandboxMoqPublisherAccess, + getSandboxMoqSubscriberAccess, }; }; diff --git a/packages/react-client/src/index.ts b/packages/react-client/src/index.ts index a8537044..5f404ec4 100644 --- a/packages/react-client/src/index.ts +++ b/packages/react-client/src/index.ts @@ -23,7 +23,7 @@ export { type UseLivestreamViewerResult, } from "./hooks/useLivestreamViewer"; export { type PeerWithTracks, usePeers } from "./hooks/usePeers"; -export { type RoomType, useSandbox, type UseSandboxProps } from "./hooks/useSandbox"; +export { type MoqAccess, type RoomType, useSandbox, type UseSandboxProps } from "./hooks/useSandbox"; export { useScreenShare } from "./hooks/useScreenShare"; export { useUpdatePeerMetadata } from "./hooks/useUpdatePeerMetadata"; export { useVAD } from "./hooks/useVAD"; diff --git a/packages/ts-client/package.json b/packages/ts-client/package.json index 0f852cdc..77e8cc73 100644 --- a/packages/ts-client/package.json +++ b/packages/ts-client/package.json @@ -1,6 +1,6 @@ { "name": "@fishjam-cloud/ts-client", - "version": "0.28.0", + "version": "0.28.2", "description": "Typescript client library for Fishjam", "license": "Apache-2.0", "author": "Fishjam Team", diff --git a/packages/webrtc-client/package.json b/packages/webrtc-client/package.json index 2f824cd1..4b3a405f 100644 --- a/packages/webrtc-client/package.json +++ b/packages/webrtc-client/package.json @@ -1,6 +1,6 @@ { "name": "@fishjam-cloud/webrtc-client", - "version": "0.28.0", + "version": "0.28.2", "description": "Typescript client library for ExWebRTC/WebRTC endpoint in Membrane RTC Engine", "license": "Apache-2.0", "author": "Fishjam Team",