Skip to content

Conversation

@lukeocodes
Copy link
Contributor

@lukeocodes lukeocodes commented Jun 13, 2025

Description

This PR adds utility functions to the generated TS SDK, improving WebSocket support in different runtimes (specifically the browser).

TODOs:

  • Generates the utils whether web sockets are required or not
  • probably more ...

New Utility Functions Added:

🔌 WebSocket Support

  • createWebSocket(url, options) - Creates WebSocket connections with runtime-specific handling:
    • Browser/Web Worker/Deno/Bun: Uses native WebSocket with auth protocols
    • Node.js: Dynamically imports ws library with proper headers
    • Unsupported runtimes: Throws descriptive error messages

🔐 Authentication Utilities

  • getAuthHeaders(apiKey) - Generates authorization headers with token format
  • getAuthProtocols(apiKey) - Creates WebSocket auth protocols array

📋 SDK Headers Management

  • getHeaders() - Provides standardized SDK headers with runtime detection:
    • User-Agent, X-Fern-Language, X-Fern-SDK-Name/Version
    • X-Fern-Runtime and X-Fern-Runtime-Version
    • CORS-aware: Returns empty object for CORS-sensitive runtimes

Testing

  • Unit tests added/updated
  • Manual testing completed

@lukeocodes lukeocodes changed the title feat(websockets): [DRAFT] creating websocket util files feat(typescript): [DRAFT] creating websocket util files Jun 13, 2025
}

if (this.generatedWebsocketImplementation != null) {
// we need to import the factory for the client
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain this is how to import this from here.

@lukeocodes lukeocodes marked this pull request as ready for review June 17, 2025 12:50
@lukeocodes lukeocodes requested a review from dsinghvi as a code owner June 17, 2025 12:50
@lukeocodes lukeocodes changed the title feat(typescript): [DRAFT] creating websocket util files feat(typescript): creating websocket util files Jun 25, 2025
@lukeocodes
Copy link
Contributor Author

@fern-support I believe Deepgram is going to need this or something similar pretty soon

@github-actions
Copy link
Contributor

This PR is stale because it has been open 25 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale This PR hasn't has any commits or comments in 25 days or more. label Jul 21, 2025
@github-actions
Copy link
Contributor

This PR was closed because it has been inactive for 5 days after being marked stale.

@github-actions github-actions bot closed this Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale This PR hasn't has any commits or comments in 25 days or more.

Development

Successfully merging this pull request may close these issues.

1 participant