@corti/sdk 0.7.0 → 0.8.0-rc.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.
Files changed (78) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/resources/stream/client/Client.js +1 -1
  4. package/dist/cjs/api/resources/stream/client/Socket.js +3 -1
  5. package/dist/cjs/api/resources/transcribe/client/Client.js +1 -1
  6. package/dist/cjs/api/resources/transcribe/client/Socket.js +3 -1
  7. package/dist/cjs/api/types/AgentsMcpServerAuthorizationType.d.ts +3 -2
  8. package/dist/cjs/api/types/AgentsMcpServerAuthorizationType.js +2 -1
  9. package/dist/cjs/custom/CortiAuth.d.ts +29 -6
  10. package/dist/cjs/custom/CortiAuth.js +10 -4
  11. package/dist/cjs/custom/CortiClient.d.ts +16 -2
  12. package/dist/cjs/custom/CortiClient.js +24 -21
  13. package/dist/cjs/custom/CortiWebSocketProxyClient.d.ts +14 -0
  14. package/dist/cjs/custom/CortiWebSocketProxyClient.js +22 -0
  15. package/dist/cjs/custom/CustomStream.d.ts +8 -1
  16. package/dist/cjs/custom/CustomStream.js +13 -3
  17. package/dist/cjs/custom/CustomStreamSocket.d.ts +5 -0
  18. package/dist/cjs/custom/CustomStreamSocket.js +6 -0
  19. package/dist/cjs/custom/CustomTranscribe.d.ts +8 -1
  20. package/dist/cjs/custom/CustomTranscribe.js +13 -3
  21. package/dist/cjs/custom/CustomTranscribeSocket.d.ts +5 -0
  22. package/dist/cjs/custom/CustomTranscribeSocket.js +6 -0
  23. package/dist/cjs/custom/proxy/CustomProxyStream.d.ts +24 -0
  24. package/dist/cjs/custom/proxy/CustomProxyStream.js +57 -0
  25. package/dist/cjs/custom/proxy/CustomProxyTranscribe.d.ts +24 -0
  26. package/dist/cjs/custom/proxy/CustomProxyTranscribe.js +56 -0
  27. package/dist/cjs/custom/utils/getEnvironmentFromString.d.ts +1 -1
  28. package/dist/cjs/custom/utils/getEnvironmentFromString.js +1 -1
  29. package/dist/cjs/custom/utils/resolveClientOptions.js +31 -10
  30. package/dist/cjs/custom/utils/tokenRequest.d.ts +1 -0
  31. package/dist/cjs/custom/utils/tokenRequest.js +4 -1
  32. package/dist/cjs/environments.d.ts +2 -2
  33. package/dist/cjs/environments.js +2 -2
  34. package/dist/cjs/index.d.ts +4 -0
  35. package/dist/cjs/index.js +6 -1
  36. package/dist/cjs/serialization/types/AgentsMcpServerAuthorizationType.d.ts +1 -1
  37. package/dist/cjs/serialization/types/AgentsMcpServerAuthorizationType.js +1 -1
  38. package/dist/cjs/version.d.ts +1 -1
  39. package/dist/cjs/version.js +1 -1
  40. package/dist/esm/Client.mjs +2 -2
  41. package/dist/esm/api/resources/stream/client/Client.mjs +1 -1
  42. package/dist/esm/api/resources/stream/client/Socket.mjs +3 -1
  43. package/dist/esm/api/resources/transcribe/client/Client.mjs +1 -1
  44. package/dist/esm/api/resources/transcribe/client/Socket.mjs +3 -1
  45. package/dist/esm/api/types/AgentsMcpServerAuthorizationType.d.mts +3 -2
  46. package/dist/esm/api/types/AgentsMcpServerAuthorizationType.mjs +2 -1
  47. package/dist/esm/custom/CortiAuth.d.mts +29 -6
  48. package/dist/esm/custom/CortiAuth.mjs +10 -4
  49. package/dist/esm/custom/CortiClient.d.mts +16 -2
  50. package/dist/esm/custom/CortiClient.mjs +24 -21
  51. package/dist/esm/custom/CortiWebSocketProxyClient.d.mts +14 -0
  52. package/dist/esm/custom/CortiWebSocketProxyClient.mjs +18 -0
  53. package/dist/esm/custom/CustomStream.d.mts +8 -1
  54. package/dist/esm/custom/CustomStream.mjs +13 -3
  55. package/dist/esm/custom/CustomStreamSocket.d.mts +5 -0
  56. package/dist/esm/custom/CustomStreamSocket.mjs +6 -0
  57. package/dist/esm/custom/CustomTranscribe.d.mts +8 -1
  58. package/dist/esm/custom/CustomTranscribe.mjs +13 -3
  59. package/dist/esm/custom/CustomTranscribeSocket.d.mts +5 -0
  60. package/dist/esm/custom/CustomTranscribeSocket.mjs +6 -0
  61. package/dist/esm/custom/proxy/CustomProxyStream.d.mts +24 -0
  62. package/dist/esm/custom/proxy/CustomProxyStream.mjs +20 -0
  63. package/dist/esm/custom/proxy/CustomProxyTranscribe.d.mts +24 -0
  64. package/dist/esm/custom/proxy/CustomProxyTranscribe.mjs +19 -0
  65. package/dist/esm/custom/utils/getEnvironmentFromString.d.mts +1 -1
  66. package/dist/esm/custom/utils/getEnvironmentFromString.mjs +1 -1
  67. package/dist/esm/custom/utils/resolveClientOptions.mjs +31 -10
  68. package/dist/esm/custom/utils/tokenRequest.d.mts +1 -0
  69. package/dist/esm/custom/utils/tokenRequest.mjs +4 -1
  70. package/dist/esm/environments.d.mts +2 -2
  71. package/dist/esm/environments.mjs +2 -2
  72. package/dist/esm/index.d.mts +4 -0
  73. package/dist/esm/index.mjs +4 -0
  74. package/dist/esm/serialization/types/AgentsMcpServerAuthorizationType.d.mts +1 -1
  75. package/dist/esm/serialization/types/AgentsMcpServerAuthorizationType.mjs +1 -1
  76. package/dist/esm/version.d.mts +1 -1
  77. package/dist/esm/version.mjs +1 -1
  78. package/package.json +1 -1
package/README.md CHANGED
@@ -19,6 +19,8 @@ npm i -s @corti/sdk
19
19
 
20
20
  For detailed authentication instructions, see the [Authentication Guide](./AUTHENTICATION.md).
21
21
 
22
+ For information about proxying and securing frontend implementations, see the [Proxying Guide](./PROXYING.md).
23
+
22
24
  ## Usage
23
25
 
24
26
  Instantiate and use the client with the following:
@@ -64,8 +64,8 @@ class CortiClient {
64
64
  "Tenant-Name": _options === null || _options === void 0 ? void 0 : _options.tenantName,
65
65
  "X-Fern-Language": "JavaScript",
66
66
  "X-Fern-SDK-Name": "@corti/sdk",
67
- "X-Fern-SDK-Version": "0.7.0",
68
- "User-Agent": "@corti/sdk/0.7.0",
67
+ "X-Fern-SDK-Version": "0.8.0-rc.1",
68
+ "User-Agent": "@corti/sdk/0.8.0-rc.1",
69
69
  "X-Fern-Runtime": core.RUNTIME.type,
70
70
  "X-Fern-Runtime-Version": core.RUNTIME.version,
71
71
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -61,7 +61,7 @@ class Stream {
61
61
  _queryParams["token"] = token;
62
62
  let _headers = Object.assign({}, headers);
63
63
  const socket = new core.ReconnectingWebSocket({
64
- url: core.url.join((_a = (yield core.Supplier.get(this._options["baseUrl"]))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options["environment"])).wss, `/audio-bridge/v2/interactions/${encodeURIComponent(id)}/streams`),
64
+ url: core.url.join((_a = (yield core.Supplier.get(this._options["baseUrl"]))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options["environment"])).wss, `/interactions/${encodeURIComponent(id)}/streams`),
65
65
  protocols: [],
66
66
  queryParameters: _queryParams,
67
67
  headers: _headers,
@@ -121,7 +121,9 @@ class StreamSocket {
121
121
  }
122
122
  sendAudio(message) {
123
123
  this.assertSocketIsOpen();
124
- const jsonPayload = core.serialization.string().jsonOrThrow(message, {
124
+ const jsonPayload = core.serialization
125
+ .string()
126
+ .jsonOrThrow(message, {
125
127
  unrecognizedObjectKeys: "passthrough",
126
128
  allowUnrecognizedUnionMembers: true,
127
129
  allowUnrecognizedEnumValues: true,
@@ -61,7 +61,7 @@ class Transcribe {
61
61
  _queryParams["token"] = token;
62
62
  let _headers = Object.assign({}, headers);
63
63
  const socket = new core.ReconnectingWebSocket({
64
- url: core.url.join((_a = (yield core.Supplier.get(this._options["baseUrl"]))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options["environment"])).wss, "/audio-bridge/v2/transcribe"),
64
+ url: core.url.join((_a = (yield core.Supplier.get(this._options["baseUrl"]))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options["environment"])).wss, "/transcribe"),
65
65
  protocols: [],
66
66
  queryParameters: _queryParams,
67
67
  headers: _headers,
@@ -121,7 +121,9 @@ class TranscribeSocket {
121
121
  }
122
122
  sendAudio(message) {
123
123
  this.assertSocketIsOpen();
124
- const jsonPayload = core.serialization.string().jsonOrThrow(message, {
124
+ const jsonPayload = core.serialization
125
+ .string()
126
+ .jsonOrThrow(message, {
125
127
  unrecognizedObjectKeys: "passthrough",
126
128
  allowUnrecognizedUnionMembers: true,
127
129
  allowUnrecognizedEnumValues: true,
@@ -4,9 +4,10 @@
4
4
  /**
5
5
  * Type of authorization used by the MCP server.
6
6
  */
7
- export type AgentsMcpServerAuthorizationType = "none" | "oauth2.0" | "oauth2.1";
7
+ export type AgentsMcpServerAuthorizationType = "none" | "bearer" | "inherit" | "oauth2.0";
8
8
  export declare const AgentsMcpServerAuthorizationType: {
9
9
  readonly None: "none";
10
+ readonly Bearer: "bearer";
11
+ readonly Inherit: "inherit";
10
12
  readonly Oauth20: "oauth2.0";
11
- readonly Oauth21: "oauth2.1";
12
13
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AgentsMcpServerAuthorizationType = void 0;
7
7
  exports.AgentsMcpServerAuthorizationType = {
8
8
  None: "none",
9
+ Bearer: "bearer",
10
+ Inherit: "inherit",
9
11
  Oauth20: "oauth2.0",
10
- Oauth21: "oauth2.1",
11
12
  };
@@ -14,7 +14,7 @@
14
14
  import { Auth as FernAuth } from "../api/resources/auth/client/Client.js";
15
15
  import * as core from "../core/index.js";
16
16
  import * as Corti from "../api/index.js";
17
- import * as environments from "../environments.js";
17
+ import { Environment, CortiInternalEnvironment } from "./utils/getEnvironmentFromString.js";
18
18
  /**
19
19
  * Patch: added codeChallenge to the AuthorizationCodeClient interface to support PKCE flow
20
20
  */
@@ -22,6 +22,7 @@ interface AuthorizationCodeClient {
22
22
  clientId: string;
23
23
  redirectUri: string;
24
24
  codeChallenge?: string;
25
+ scopes?: string[];
25
26
  }
26
27
  /**
27
28
  * Patch: renamed AuthorizationCodeClient to AuthorizationCode as it can be used for both(server and client) flows
@@ -31,6 +32,7 @@ interface AuthorizationCode {
31
32
  clientSecret: string;
32
33
  redirectUri: string;
33
34
  code: string;
35
+ scopes?: string[];
34
36
  }
35
37
  /**
36
38
  * Patch: added type for AuthorizationPkce request
@@ -40,6 +42,7 @@ interface AuthorizationPkce {
40
42
  redirectUri: string;
41
43
  code: string;
42
44
  codeVerifier?: string;
45
+ scopes?: string[];
43
46
  }
44
47
  /**
45
48
  * Patch: added type for AuthorizationRopc request
@@ -48,6 +51,7 @@ interface AuthorizationRopcServer {
48
51
  clientId: string;
49
52
  username: string;
50
53
  password: string;
54
+ scopes?: string[];
51
55
  }
52
56
  interface AuthorizationRefreshServer {
53
57
  clientId: string;
@@ -56,34 +60,53 @@ interface AuthorizationRefreshServer {
56
60
  */
57
61
  clientSecret?: string;
58
62
  refreshToken: string;
63
+ scopes?: string[];
59
64
  }
60
65
  interface Options {
61
66
  skipRedirect?: boolean;
62
67
  }
63
- type AuthOptions = Omit<FernAuth.Options, "environment"> & {
64
- environment: core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls> | string;
68
+ type AuthOptionsBase = Omit<FernAuth.Options, "environment" | "tenantName" | "baseUrl">;
69
+ type AuthOptionsWithBaseUrl = AuthOptionsBase & {
70
+ baseUrl: core.Supplier<string>;
71
+ environment?: Environment;
72
+ tenantName?: core.Supplier<string>;
65
73
  };
74
+ type AuthOptionsWithObjectEnvironment = AuthOptionsBase & {
75
+ baseUrl?: core.Supplier<string>;
76
+ environment: CortiInternalEnvironment;
77
+ tenantName?: core.Supplier<string>;
78
+ };
79
+ type AuthOptionsWithStringEnvironment = AuthOptionsBase & {
80
+ baseUrl?: core.Supplier<string>;
81
+ environment: string;
82
+ tenantName: core.Supplier<string>;
83
+ };
84
+ type AuthOptions = AuthOptionsWithBaseUrl | AuthOptionsWithObjectEnvironment | AuthOptionsWithStringEnvironment;
66
85
  export declare class Auth extends FernAuth {
67
86
  /**
68
87
  * Patch: use custom AuthOptions type to support string-based environment
88
+ * When baseUrl is provided, environment and tenantName become optional
69
89
  */
70
90
  constructor(_options: AuthOptions);
71
91
  /**
72
92
  * Patch: Generate PKCE authorization URL with automatic code verifier generation
73
93
  */
74
- authorizePkceUrl({ clientId, redirectUri }: AuthorizationCodeClient, options?: Options): Promise<string>;
94
+ authorizePkceUrl({ clientId, redirectUri, scopes }: AuthorizationCodeClient, options?: Options): Promise<string>;
75
95
  /**
76
96
  * Patch: Get the stored PKCE code verifier
77
97
  */
78
98
  getCodeVerifier(): string | null;
79
99
  /**
80
100
  * Patch: called custom implementation this.__getToken_custom instead of this.__getToken
101
+ * Extended to support additional scopes
81
102
  */
82
- getToken(request: Corti.AuthGetTokenRequest, requestOptions?: FernAuth.RequestOptions): core.HttpResponsePromise<Corti.GetTokenResponse>;
103
+ getToken(request: Corti.AuthGetTokenRequest & {
104
+ scopes?: string[];
105
+ }, requestOptions?: FernAuth.RequestOptions): core.HttpResponsePromise<Corti.GetTokenResponse>;
83
106
  /**
84
107
  * Patch: added method to get Authorization URL for Authorization code flow and PKCE flow
85
108
  */
86
- authorizeURL({ clientId, redirectUri, codeChallenge }: AuthorizationCodeClient, options?: Options): Promise<string>;
109
+ authorizeURL({ clientId, redirectUri, codeChallenge, scopes }: AuthorizationCodeClient, options?: Options): Promise<string>;
87
110
  /**
88
111
  * Patch: calls __getToken_custom with additional fields to support Authorization code flow
89
112
  */
@@ -70,15 +70,16 @@ const CODE_VERIFIER_KEY = "corti_js_sdk_code_verifier";
70
70
  class Auth extends Client_js_1.Auth {
71
71
  /**
72
72
  * Patch: use custom AuthOptions type to support string-based environment
73
+ * When baseUrl is provided, environment and tenantName become optional
73
74
  */
74
75
  constructor(_options) {
75
- super(Object.assign(Object.assign({}, _options), { environment: (0, getEnvironmentFromString_js_1.getEnvironment)(_options.environment) }));
76
+ super(Object.assign(Object.assign({}, _options), { tenantName: _options.tenantName || "", environment: (0, getEnvironmentFromString_js_1.getEnvironment)(_options.environment) }));
76
77
  }
77
78
  /**
78
79
  * Patch: Generate PKCE authorization URL with automatic code verifier generation
79
80
  */
80
81
  authorizePkceUrl(_a, options_1) {
81
- return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri }, options) {
82
+ return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, scopes }, options) {
82
83
  const codeVerifier = (0, pkce_js_1.generateCodeVerifier)();
83
84
  (0, localStorage_js_1.setLocalStorageItem)(CODE_VERIFIER_KEY, codeVerifier);
84
85
  const codeChallenge = yield (0, pkce_js_1.generateCodeChallenge)(codeVerifier);
@@ -86,6 +87,7 @@ class Auth extends Client_js_1.Auth {
86
87
  clientId,
87
88
  redirectUri,
88
89
  codeChallenge,
90
+ scopes,
89
91
  }, options);
90
92
  });
91
93
  }
@@ -97,6 +99,7 @@ class Auth extends Client_js_1.Auth {
97
99
  }
98
100
  /**
99
101
  * Patch: called custom implementation this.__getToken_custom instead of this.__getToken
102
+ * Extended to support additional scopes
100
103
  */
101
104
  getToken(request, requestOptions) {
102
105
  return core.HttpResponsePromise.fromPromise(this.__getToken_custom(request, requestOptions));
@@ -105,11 +108,14 @@ class Auth extends Client_js_1.Auth {
105
108
  * Patch: added method to get Authorization URL for Authorization code flow and PKCE flow
106
109
  */
107
110
  authorizeURL(_a, options_1) {
108
- return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, codeChallenge }, options) {
111
+ return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, codeChallenge, scopes }, options) {
109
112
  var _b;
110
113
  const authUrl = new URL(core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)).login, yield core.Supplier.get(this._options.tenantName), "protocol/openid-connect/auth"));
111
114
  authUrl.searchParams.set("response_type", "code");
112
- authUrl.searchParams.set("scope", "openid profile");
115
+ // Build scope string: always include "openid profile", add any additional scopes
116
+ const allScopes = ["openid", "profile", ...(scopes || [])];
117
+ const scopeString = [...new Set(allScopes)].join(" ");
118
+ authUrl.searchParams.set("scope", scopeString);
113
119
  if (clientId !== undefined) {
114
120
  authUrl.searchParams.set("client_id", clientId);
115
121
  }
@@ -40,6 +40,8 @@ export declare namespace CortiClient {
40
40
  interface BaseOptions {
41
41
  /** Additional headers to include in requests. */
42
42
  headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
43
+ /** Specify a custom URL to connect the client to. */
44
+ baseUrl?: core.Supplier<string>;
43
45
  }
44
46
  interface OptionsWithClientCredentials extends BaseOptions {
45
47
  /**
@@ -59,7 +61,18 @@ export declare namespace CortiClient {
59
61
  tenantName?: core.Supplier<string>;
60
62
  auth: BearerOptions;
61
63
  }
62
- type Options = OptionsWithClientCredentials | OptionsWithBearerToken;
64
+ interface OptionsWithBaseUrl extends BaseOptions {
65
+ baseUrl: core.Supplier<string>;
66
+ environment?: Environment;
67
+ tenantName?: core.Supplier<string>;
68
+ auth?: ClientCredentials | BearerOptions;
69
+ }
70
+ interface OptionsWithObjectEnvironment extends BaseOptions {
71
+ environment: CortiInternalEnvironment;
72
+ tenantName?: core.Supplier<string>;
73
+ auth?: ClientCredentials | BearerOptions;
74
+ }
75
+ type Options = OptionsWithClientCredentials | OptionsWithBearerToken | OptionsWithBaseUrl | OptionsWithObjectEnvironment;
63
76
  /**
64
77
  * Patch:
65
78
  * - renamed `Options` to `InternalOptions`
@@ -99,8 +112,9 @@ export declare class CortiClient {
99
112
  protected readonly _options: CortiClient.InternalOptions;
100
113
  /**
101
114
  * Patch: extended `_oauthTokenProvider` to support both `RefreshBearerProvider` and `OAuthTokenProvider` options
115
+ * Optional - not created when auth is not provided (proxying scenarios)
102
116
  */
103
- private readonly _oauthTokenProvider;
117
+ private readonly _oauthTokenProvider?;
104
118
  protected _interactions: Interactions | undefined;
105
119
  protected _recordings: Recordings | undefined;
106
120
  protected _transcripts: Transcripts | undefined;
@@ -104,57 +104,60 @@ class CortiClient {
104
104
  "User-Agent": `@corti/sdk/${version_js_1.SDK_VERSION}`,
105
105
  "X-Fern-Runtime": core.RUNTIME.type,
106
106
  "X-Fern-Runtime-Version": core.RUNTIME.version,
107
- }, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: "clientId" in _options.auth ? _options.auth.clientId : undefined, clientSecret: "clientSecret" in _options.auth ? _options.auth.clientSecret : undefined, token: "accessToken" in _options.auth ? _options.auth.accessToken : undefined, tenantName, environment: (0, getEnvironmentFromString_js_1.getEnvironment)(environment) });
107
+ }, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: _options.auth && "clientId" in _options.auth ? _options.auth.clientId : undefined, clientSecret: _options.auth && "clientSecret" in _options.auth ? _options.auth.clientSecret : undefined, token: _options.auth && "accessToken" in _options.auth ? _options.auth.accessToken : undefined, tenantName, environment: (0, getEnvironmentFromString_js_1.getEnvironment)(environment) });
108
108
  /**
109
109
  * Patch: if `clientId` is provided, use OAuthTokenProvider, otherwise use BearerProvider
110
+ * Only create token provider when auth is provided
110
111
  */
111
- this._oauthTokenProvider =
112
- "clientId" in _options.auth
113
- ? new core.OAuthTokenProvider({
114
- clientId: _options.auth.clientId,
115
- clientSecret: _options.auth.clientSecret,
116
- /**
117
- * Patch: provide whole `options` object to the Auth client, since it depends on both tenantName and environment
118
- */
119
- authClient: new CortiAuth_js_1.Auth(this._options),
120
- })
121
- : new RefreshBearerProvider_js_1.RefreshBearerProvider(Object.assign(Object.assign({}, _options.auth), { initialTokenResponse }));
112
+ if (_options.auth) {
113
+ this._oauthTokenProvider =
114
+ "clientId" in _options.auth
115
+ ? new core.OAuthTokenProvider({
116
+ clientId: _options.auth.clientId,
117
+ clientSecret: _options.auth.clientSecret,
118
+ /**
119
+ * Patch: provide whole `options` object to the Auth client, since it depends on both tenantName and environment
120
+ */
121
+ authClient: new CortiAuth_js_1.Auth(this._options),
122
+ })
123
+ : new RefreshBearerProvider_js_1.RefreshBearerProvider(Object.assign(Object.assign({}, _options.auth), { initialTokenResponse }));
124
+ }
122
125
  }
123
126
  get interactions() {
124
127
  var _a;
125
- return ((_a = this._interactions) !== null && _a !== void 0 ? _a : (this._interactions = new Client_js_1.Interactions(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
128
+ return ((_a = this._interactions) !== null && _a !== void 0 ? _a : (this._interactions = new Client_js_1.Interactions(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
126
129
  }
127
130
  get recordings() {
128
131
  var _a;
129
- return ((_a = this._recordings) !== null && _a !== void 0 ? _a : (this._recordings = new Client_js_2.Recordings(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
132
+ return ((_a = this._recordings) !== null && _a !== void 0 ? _a : (this._recordings = new Client_js_2.Recordings(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
130
133
  }
131
134
  get transcripts() {
132
135
  var _a;
133
- return ((_a = this._transcripts) !== null && _a !== void 0 ? _a : (this._transcripts = new Client_js_3.Transcripts(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
136
+ return ((_a = this._transcripts) !== null && _a !== void 0 ? _a : (this._transcripts = new Client_js_3.Transcripts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
134
137
  }
135
138
  get facts() {
136
139
  var _a;
137
- return ((_a = this._facts) !== null && _a !== void 0 ? _a : (this._facts = new Client_js_4.Facts(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
140
+ return ((_a = this._facts) !== null && _a !== void 0 ? _a : (this._facts = new Client_js_4.Facts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
138
141
  }
139
142
  get documents() {
140
143
  var _a;
141
- return ((_a = this._documents) !== null && _a !== void 0 ? _a : (this._documents = new Client_js_5.Documents(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
144
+ return ((_a = this._documents) !== null && _a !== void 0 ? _a : (this._documents = new Client_js_5.Documents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
142
145
  }
143
146
  get templates() {
144
147
  var _a;
145
- return ((_a = this._templates) !== null && _a !== void 0 ? _a : (this._templates = new Client_js_6.Templates(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
148
+ return ((_a = this._templates) !== null && _a !== void 0 ? _a : (this._templates = new Client_js_6.Templates(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
146
149
  }
147
150
  get agents() {
148
151
  var _a;
149
- return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Client_js_7.Agents(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
152
+ return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Client_js_7.Agents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
150
153
  }
151
154
  get stream() {
152
155
  var _a;
153
- return ((_a = this._stream) !== null && _a !== void 0 ? _a : (this._stream = new CustomStream_js_1.Stream(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
156
+ return ((_a = this._stream) !== null && _a !== void 0 ? _a : (this._stream = new CustomStream_js_1.Stream(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
154
157
  }
155
158
  get transcribe() {
156
159
  var _a;
157
- return ((_a = this._transcribe) !== null && _a !== void 0 ? _a : (this._transcribe = new CustomTranscribe_js_1.Transcribe(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
160
+ return ((_a = this._transcribe) !== null && _a !== void 0 ? _a : (this._transcribe = new CustomTranscribe_js_1.Transcribe(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
158
161
  }
159
162
  }
160
163
  exports.CortiClient = CortiClient;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Patch: Lightweight proxy client with only WebSocket resources (stream and transcribe).
3
+ * Use this when you need direct WebSocket connections through your own proxy backend.
4
+ *
5
+ * No environment or tenantName required - proxy is required in connect().
6
+ */
7
+ import { CustomProxyStream } from "./proxy/CustomProxyStream.js";
8
+ import { CustomProxyTranscribe } from "./proxy/CustomProxyTranscribe.js";
9
+ export declare class CortiWebSocketProxyClient {
10
+ private static _stream;
11
+ private static _transcribe;
12
+ static get stream(): CustomProxyStream;
13
+ static get transcribe(): CustomProxyTranscribe;
14
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Patch: Lightweight proxy client with only WebSocket resources (stream and transcribe).
4
+ * Use this when you need direct WebSocket connections through your own proxy backend.
5
+ *
6
+ * No environment or tenantName required - proxy is required in connect().
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CortiWebSocketProxyClient = void 0;
10
+ const CustomProxyStream_js_1 = require("./proxy/CustomProxyStream.js");
11
+ const CustomProxyTranscribe_js_1 = require("./proxy/CustomProxyTranscribe.js");
12
+ class CortiWebSocketProxyClient {
13
+ static get stream() {
14
+ var _a;
15
+ return ((_a = this._stream) !== null && _a !== void 0 ? _a : (this._stream = new CustomProxyStream_js_1.CustomProxyStream()));
16
+ }
17
+ static get transcribe() {
18
+ var _a;
19
+ return ((_a = this._transcribe) !== null && _a !== void 0 ? _a : (this._transcribe = new CustomProxyTranscribe_js_1.CustomProxyTranscribe()));
20
+ }
21
+ }
22
+ exports.CortiWebSocketProxyClient = CortiWebSocketProxyClient;
@@ -13,8 +13,15 @@ import { StreamSocket } from "./CustomStreamSocket.js";
13
13
  export declare class Stream extends FernStream {
14
14
  /**
15
15
  * Patch: use custom connect method to support passing _options parameters
16
+ * Added optional `proxy` parameter for direct WebSocket connection (proxy scenarios)
16
17
  */
17
- connect({ configuration, ...args }: Omit<FernStream.ConnectArgs, "token" | "tenantName"> & {
18
+ connect({ configuration, proxy, ...args }: Omit<FernStream.ConnectArgs, "token" | "tenantName"> & {
18
19
  configuration?: api.StreamConfig;
20
+ /** Patch: Proxy connection options - bypasses normal URL construction */
21
+ proxy?: {
22
+ url: string;
23
+ protocols?: string[];
24
+ queryParameters?: Record<string, string>;
25
+ };
19
26
  }): Promise<StreamSocket>;
20
27
  }
@@ -69,15 +69,25 @@ const CustomStreamSocket_js_1 = require("./CustomStreamSocket.js");
69
69
  class Stream extends Client_js_1.Stream {
70
70
  /**
71
71
  * Patch: use custom connect method to support passing _options parameters
72
+ * Added optional `proxy` parameter for direct WebSocket connection (proxy scenarios)
72
73
  */
73
74
  connect(_a) {
74
75
  const _super = Object.create(null, {
75
76
  connect: { get: () => super.connect }
76
77
  });
77
78
  return __awaiter(this, void 0, void 0, function* () {
78
- var { configuration } = _a, args = __rest(_a, ["configuration"]);
79
- const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield core.Supplier.get(this._options.tenantName) }));
80
- const ws = new CustomStreamSocket_js_1.StreamSocket({ socket: fernWs.socket });
79
+ var _b, _c;
80
+ var { configuration, proxy } = _a, args = __rest(_a, ["configuration", "proxy"]);
81
+ const socket = proxy
82
+ ? new core.ReconnectingWebSocket({
83
+ url: proxy.url,
84
+ protocols: proxy.protocols || [],
85
+ queryParameters: proxy.queryParameters || {},
86
+ headers: args.headers || {},
87
+ options: { debug: (_b = args.debug) !== null && _b !== void 0 ? _b : false, maxRetries: (_c = args.reconnectAttempts) !== null && _c !== void 0 ? _c : 30 },
88
+ })
89
+ : (yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield core.Supplier.get(this._options.tenantName) }))).socket;
90
+ const ws = new CustomStreamSocket_js_1.StreamSocket({ socket });
81
91
  if (!configuration) {
82
92
  return ws;
83
93
  }
@@ -2,6 +2,7 @@
2
2
  * Patch: file patches disability of auto-generating binary data methods for sending data to the socket
3
3
  */
4
4
  import { StreamSocket as FernStreamSocket } from "../api/resources/stream/client/Socket.js";
5
+ import { ReconnectingWebSocket } from "../core/index.js";
5
6
  export declare class StreamSocket extends FernStreamSocket {
6
7
  sendAudio(message: ArrayBufferLike | Blob | ArrayBufferView | string): void;
7
8
  /**
@@ -12,4 +13,8 @@ export declare class StreamSocket extends FernStreamSocket {
12
13
  * Patch: added ability to remove event handlers
13
14
  */
14
15
  off<T extends keyof FernStreamSocket.EventHandlers>(event: T, callback?: FernStreamSocket.EventHandlers[T]): void;
16
+ /**
17
+ * Patch: expose underlying socket send method for direct access
18
+ */
19
+ send(data: ReconnectingWebSocket.Message): void;
15
20
  }
@@ -66,5 +66,11 @@ class StreamSocket extends Socket_js_1.StreamSocket {
66
66
  delete this.eventHandlers[event];
67
67
  }
68
68
  }
69
+ /**
70
+ * Patch: expose underlying socket send method for direct access
71
+ */
72
+ send(data) {
73
+ this.socket.send(data);
74
+ }
69
75
  }
70
76
  exports.StreamSocket = StreamSocket;
@@ -13,8 +13,15 @@ import { TranscribeSocket } from "./CustomTranscribeSocket.js";
13
13
  export declare class Transcribe extends FernTranscribe {
14
14
  /**
15
15
  * Patch: use custom connect method to support passing _options parameters
16
+ * Added optional `proxy` parameter for direct WebSocket connection (proxy scenarios)
16
17
  */
17
- connect({ configuration, ...args }?: Omit<FernTranscribe.ConnectArgs, "token" | "tenantName"> & {
18
+ connect({ configuration, proxy, ...args }?: Omit<FernTranscribe.ConnectArgs, "token" | "tenantName"> & {
18
19
  configuration?: api.TranscribeConfig;
20
+ /** Patch: Proxy connection options - bypasses normal URL construction */
21
+ proxy?: {
22
+ url: string;
23
+ protocols?: string[];
24
+ queryParameters?: Record<string, string>;
25
+ };
19
26
  }): Promise<TranscribeSocket>;
20
27
  }
@@ -69,15 +69,25 @@ const CustomTranscribeSocket_js_1 = require("./CustomTranscribeSocket.js");
69
69
  class Transcribe extends Client_js_1.Transcribe {
70
70
  /**
71
71
  * Patch: use custom connect method to support passing _options parameters
72
+ * Added optional `proxy` parameter for direct WebSocket connection (proxy scenarios)
72
73
  */
73
74
  connect() {
74
75
  const _super = Object.create(null, {
75
76
  connect: { get: () => super.connect }
76
77
  });
77
78
  return __awaiter(this, arguments, void 0, function* (_a = {}) {
78
- var { configuration } = _a, args = __rest(_a, ["configuration"]);
79
- const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield core.Supplier.get(this._options.tenantName) }));
80
- const ws = new CustomTranscribeSocket_js_1.TranscribeSocket({ socket: fernWs.socket });
79
+ var _b, _c;
80
+ var { configuration, proxy } = _a, args = __rest(_a, ["configuration", "proxy"]);
81
+ const socket = proxy
82
+ ? new core.ReconnectingWebSocket({
83
+ url: proxy.url,
84
+ protocols: proxy.protocols || [],
85
+ queryParameters: proxy.queryParameters || {},
86
+ headers: args.headers || {},
87
+ options: { debug: (_b = args.debug) !== null && _b !== void 0 ? _b : false, maxRetries: (_c = args.reconnectAttempts) !== null && _c !== void 0 ? _c : 30 },
88
+ })
89
+ : (yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield core.Supplier.get(this._options.tenantName) }))).socket;
90
+ const ws = new CustomTranscribeSocket_js_1.TranscribeSocket({ socket });
81
91
  if (!configuration) {
82
92
  return ws;
83
93
  }
@@ -2,6 +2,7 @@
2
2
  * Patch: file patches disability of auto-generating binary data methods for sending data to the socket
3
3
  */
4
4
  import { TranscribeSocket as FernTranscribeSocket } from "../api/resources/transcribe/client/Socket.js";
5
+ import { ReconnectingWebSocket } from "../core/index.js";
5
6
  export declare class TranscribeSocket extends FernTranscribeSocket {
6
7
  sendAudio(message: ArrayBufferLike | Blob | ArrayBufferView | string): void;
7
8
  /**
@@ -12,4 +13,8 @@ export declare class TranscribeSocket extends FernTranscribeSocket {
12
13
  * Patch: added ability to remove event handlers
13
14
  */
14
15
  off<T extends keyof FernTranscribeSocket.EventHandlers>(event: T, callback?: FernTranscribeSocket.EventHandlers[T]): void;
16
+ /**
17
+ * Patch: expose underlying socket send method for direct access
18
+ */
19
+ send(data: ReconnectingWebSocket.Message): void;
15
20
  }
@@ -66,5 +66,11 @@ class TranscribeSocket extends Socket_js_1.TranscribeSocket {
66
66
  delete this.eventHandlers[event];
67
67
  }
68
68
  }
69
+ /**
70
+ * Patch: expose underlying socket send method for direct access
71
+ */
72
+ send(data) {
73
+ this.socket.send(data);
74
+ }
69
75
  }
70
76
  exports.TranscribeSocket = TranscribeSocket;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Patch: Proxy-specific Stream wrapper that enforces `proxy` as required.
3
+ *
4
+ * Reuses the underlying CustomStream class to preserve the logic we added on top
5
+ * of generated sockets (e.g., sending configuration messages, handling responses).
6
+ */
7
+ import * as api from "../../api/index.js";
8
+ import { StreamSocket } from "../CustomStreamSocket.js";
9
+ export type ProxyOptions = {
10
+ url: string;
11
+ protocols?: string[];
12
+ queryParameters?: Record<string, string>;
13
+ };
14
+ export declare class CustomProxyStream {
15
+ private _stream;
16
+ constructor();
17
+ connect(args: {
18
+ proxy: ProxyOptions;
19
+ configuration?: api.StreamConfig;
20
+ headers?: Record<string, string>;
21
+ debug?: boolean;
22
+ reconnectAttempts?: number;
23
+ }): Promise<StreamSocket>;
24
+ }