-
Notifications
You must be signed in to change notification settings - Fork 2
Allow to propagate query params to sdk #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lucy-demo-branch-DONT-merge
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ export type RealTimeClientOptions = { | |
| baseUrl: string; | ||
| apiKey: string; | ||
| integration?: string; | ||
| /** Additional query parameters to append to the WebSocket connection URL */ | ||
| queryParams?: Record<string, string>; | ||
| }; | ||
|
|
||
| const realTimeClientInitialStateSchema = modelStateSchema; | ||
|
|
@@ -90,7 +92,7 @@ export type RealTimeClient = { | |
| }; | ||
|
|
||
| export const createRealTimeClient = (opts: RealTimeClientOptions) => { | ||
| const { baseUrl, apiKey, integration } = opts; | ||
| const { baseUrl, apiKey, integration, queryParams } = opts; | ||
|
|
||
| const connect = async ( | ||
| stream: MediaStream | null, | ||
|
|
@@ -141,8 +143,14 @@ export const createRealTimeClient = (opts: RealTimeClientOptions) => { | |
| : undefined; | ||
|
|
||
| const url = `${baseUrl}${options.model.urlPath}`; | ||
| // Build query string with api_key, model, and any additional query params | ||
| const urlParams = new URLSearchParams({ | ||
| api_key: apiKey, | ||
| model: options.model.name, | ||
| ...(queryParams || {}), | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Query params can override reserved URL parametersMedium Severity The |
||
| const webrtcManager = new WebRTCManager({ | ||
| webrtcUrl: `${url}?api_key=${apiKey}&model=${options.model.name}`, | ||
| webrtcUrl: `${url}?${urlParams.toString()}`, | ||
| apiKey, | ||
| sessionId, | ||
| fps: options.model.fps, | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zod schema uses
z.any()instead of typed recordMedium Severity
The Zod schema uses
z.any()forqueryParamsbut the TypeScript type declares it asRecord<string, string>. This validation gap means the schema accepts values that don't match the expected type (e.g., nested objects, numbers, arrays). When spread intoURLSearchParams, non-string values will be coerced via.toString(), causing objects to become[object Object]in the URL. The schema could usez.record(z.string(), z.string()).optional()to match the type.