@getpaseo/client 0.3.0-beta.1 → 0.3.0-beta.3

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.
@@ -3,6 +3,10 @@ export declare function defaultWebSocketFactory(url: string, options?: {
3
3
  headers?: Record<string, string>;
4
4
  protocols?: string[];
5
5
  }): WebSocketLike;
6
+ export declare function nativeWebSocketFactory(url: string, options?: {
7
+ headers?: Record<string, string>;
8
+ protocols?: string[];
9
+ }): WebSocketLike;
6
10
  export declare function createWebSocketTransportFactory(factory: WebSocketFactory): DaemonTransportFactory;
7
11
  export declare function bindWsHandler(ws: WebSocketLike, event: "open" | "close" | "error" | "message", handler: (...args: unknown[]) => void): () => void;
8
12
  //# sourceMappingURL=daemon-client-websocket-transport.d.ts.map
@@ -1,10 +1,22 @@
1
1
  import { extractRelayMessage } from "./daemon-client-transport-utils.js";
2
- export function defaultWebSocketFactory(url, options) {
2
+ function getGlobalWebSocket() {
3
3
  const globalWs = globalThis.WebSocket;
4
4
  if (!globalWs) {
5
5
  throw new Error("WebSocket is not available in this runtime");
6
6
  }
7
- return new globalWs(url, options?.protocols);
7
+ return globalWs;
8
+ }
9
+ export function defaultWebSocketFactory(url, options) {
10
+ const globalWs = getGlobalWebSocket();
11
+ if (options?.protocols === undefined) {
12
+ return new globalWs(url);
13
+ }
14
+ return new globalWs(url, options.protocols);
15
+ }
16
+ // React Native and Node-compatible WebSocket implementations accept this extra options object.
17
+ // Keep it out of the standard browser factory above.
18
+ export function nativeWebSocketFactory(url, options) {
19
+ return new (getGlobalWebSocket())(url, options?.protocols, { headers: options?.headers });
8
20
  }
9
21
  export function createWebSocketTransportFactory(factory) {
10
22
  return ({ url, headers, protocols }) => {
@@ -108,6 +108,7 @@ export interface DaemonClientConfig {
108
108
  runtimeGeneration?: number | null;
109
109
  password?: string;
110
110
  authHeader?: string;
111
+ headers?: Record<string, string>;
111
112
  suppressSendErrors?: boolean;
112
113
  transportFactory?: DaemonTransportFactory;
113
114
  webSocketFactory?: WebSocketFactory;
@@ -331,7 +331,7 @@ export class DaemonClient {
331
331
  if (this.connectionState.status === "connecting") {
332
332
  return;
333
333
  }
334
- const headers = {};
334
+ const headers = { ...this.config.headers };
335
335
  const password = normalizePassword(this.config.password);
336
336
  if (password) {
337
337
  headers.Authorization = `Bearer ${password}`;
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface PaseoClientConfig {
29
29
  runtimeGeneration?: number | null;
30
30
  password?: string;
31
31
  authHeader?: string;
32
+ headers?: Record<string, string>;
32
33
  suppressSendErrors?: boolean;
33
34
  logger?: PaseoLogger;
34
35
  connectTimeoutMs?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/client",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.3",
4
4
  "description": "Paseo client SDK package",
5
5
  "files": [
6
6
  "dist",
@@ -20,6 +20,10 @@
20
20
  "./internal/daemon-client-transport-types": {
21
21
  "types": "./dist/daemon-client-transport-types.d.ts",
22
22
  "default": "./dist/daemon-client-transport-types.js"
23
+ },
24
+ "./internal/daemon-client-websocket-transport": {
25
+ "types": "./dist/daemon-client-websocket-transport.d.ts",
26
+ "default": "./dist/daemon-client-websocket-transport.js"
23
27
  }
24
28
  },
25
29
  "publishConfig": {
@@ -35,8 +39,8 @@
35
39
  "test": "vitest run"
36
40
  },
37
41
  "dependencies": {
38
- "@getpaseo/protocol": "0.3.0-beta.1",
39
- "@getpaseo/relay": "0.3.0-beta.1",
42
+ "@getpaseo/protocol": "0.3.0-beta.3",
43
+ "@getpaseo/relay": "0.3.0-beta.3",
40
44
  "zod": "^4.4.3"
41
45
  },
42
46
  "devDependencies": {