@deepgram/sdk 5.0.0 → 5.1.0
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.
- package/dist/browser/index.global.js +1172 -199
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +15 -0
- package/dist/cjs/Client.js +79 -0
- package/dist/cjs/api/resources/agent/resources/v1/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/agent/resources/v1/client/Client.js +5 -5
- package/dist/cjs/api/resources/agent/resources/v1/client/Socket.d.ts +6 -6
- package/dist/cjs/api/resources/agent/resources/v1/client/Socket.js +6 -6
- package/dist/cjs/api/resources/agent/resources/v1/exports.d.ts +1 -0
- package/dist/cjs/api/resources/agent/resources/v1/exports.js +3 -1
- package/dist/cjs/api/resources/agent/resources/v1/resources/settings/resources/think/resources/models/client/Client.js +1 -1
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1FunctionCallRequest.d.ts +2 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1History.d.ts +24 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1History.js +3 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1Settings.d.ts +2 -1
- package/dist/cjs/api/resources/agent/resources/v1/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/index.js +1 -0
- package/dist/cjs/api/resources/auth/resources/v1/resources/tokens/client/Client.js +1 -1
- package/dist/cjs/api/resources/index.d.ts +1 -0
- package/dist/cjs/api/resources/index.js +2 -1
- package/dist/cjs/api/resources/listen/resources/v1/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/listen/resources/v1/client/Client.js +5 -5
- package/dist/cjs/api/resources/listen/resources/v1/client/Socket.d.ts +3 -3
- package/dist/cjs/api/resources/listen/resources/v1/client/Socket.js +2 -2
- package/dist/cjs/api/resources/listen/resources/v1/exports.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v1/exports.js +3 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/Client.js +11 -2
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v2/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/listen/resources/v2/client/Client.js +5 -5
- package/dist/cjs/api/resources/listen/resources/v2/client/Socket.d.ts +4 -4
- package/dist/cjs/api/resources/listen/resources/v2/client/Socket.js +3 -3
- package/dist/cjs/api/resources/listen/resources/v2/exports.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v2/exports.js +3 -1
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2Configure.d.ts +6 -0
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.ts +11 -0
- package/dist/cjs/api/resources/manage/resources/v1/resources/models/client/Client.js +6 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/client/Client.js +9 -5
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/balances/client/Client.js +2 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.d.ts +2 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.js +7 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/requests/BreakdownListRequest.d.ts +2 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/fields/client/Client.js +5 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/purchases/client/Client.js +5 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.js +8 -4
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/members/client/Client.js +2 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/members/resources/invites/client/Client.js +3 -3
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/members/resources/scopes/client/Client.js +2 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/models/client/Client.js +6 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.js +6 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/client/Client.js +5 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/client/Client.js +5 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/fields/client/Client.js +5 -1
- package/dist/cjs/api/resources/read/resources/v1/resources/text/client/Client.js +5 -1
- package/dist/cjs/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.js +9 -4
- package/dist/cjs/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/requests/CreateProjectDistributionCredentialsV1Request.d.ts +1 -0
- package/dist/cjs/api/resources/speak/resources/v1/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/speak/resources/v1/client/Client.js +6 -5
- package/dist/cjs/api/resources/speak/resources/v1/client/Socket.d.ts +2 -2
- package/dist/cjs/api/resources/speak/resources/v1/client/Socket.js +2 -2
- package/dist/cjs/api/resources/speak/resources/v1/exports.d.ts +1 -0
- package/dist/cjs/api/resources/speak/resources/v1/exports.js +3 -1
- package/dist/cjs/api/resources/speak/resources/v1/resources/audio/client/Client.js +7 -2
- package/dist/cjs/api/resources/speak/resources/v1/resources/audio/client/requests/SpeakV1Request.d.ts +2 -0
- package/dist/cjs/api/resources/speak/resources/v1/types/SpeakV1Metadata.d.ts +2 -4
- package/dist/cjs/api/resources/voiceAgent/client/Client.d.ts +15 -0
- package/dist/cjs/api/resources/voiceAgent/client/Client.js +21 -0
- package/dist/cjs/api/resources/voiceAgent/exports.d.ts +3 -0
- package/dist/cjs/api/resources/voiceAgent/exports.js +22 -0
- package/dist/cjs/api/resources/voiceAgent/index.d.ts +2 -0
- package/dist/cjs/api/resources/voiceAgent/index.js +18 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/Client.d.ts +89 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/Client.js +325 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/index.js +17 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.d.ts +14 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.js +3 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.d.ts +12 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.js +3 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/exports.d.ts +2 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/exports.js +21 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/index.d.ts +1 -0
- package/dist/cjs/api/resources/voiceAgent/resources/configurations/index.js +17 -0
- package/dist/cjs/api/resources/voiceAgent/resources/index.d.ts +4 -0
- package/dist/cjs/api/resources/voiceAgent/resources/index.js +43 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/Client.d.ts +92 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/Client.js +325 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/index.js +17 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.d.ts +16 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.js +3 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.d.ts +11 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.js +3 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/exports.d.ts +2 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/exports.js +21 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/index.d.ts +1 -0
- package/dist/cjs/api/resources/voiceAgent/resources/variables/index.js +17 -0
- package/dist/cjs/api/types/AgentConfigurationV1.d.ts +15 -0
- package/dist/cjs/api/types/AgentConfigurationV1.js +3 -0
- package/dist/cjs/api/types/AgentVariableV1.d.ts +14 -0
- package/dist/cjs/api/types/AgentVariableV1.js +3 -0
- package/dist/cjs/api/types/Cartesia.d.ts +2 -0
- package/dist/cjs/api/types/CreateAgentConfigurationV1Response.d.ts +8 -0
- package/dist/cjs/api/types/CreateAgentConfigurationV1Response.js +3 -0
- package/dist/cjs/api/types/Deepgram.d.ts +2 -0
- package/dist/cjs/api/types/DeleteAgentConfigurationV1Response.d.ts +4 -0
- package/dist/cjs/api/types/DeleteAgentConfigurationV1Response.js +3 -0
- package/dist/cjs/api/types/DeleteAgentVariableV1Response.d.ts +4 -0
- package/dist/cjs/api/types/DeleteAgentVariableV1Response.js +3 -0
- package/dist/cjs/api/types/ListAgentConfigurationsV1Response.d.ts +5 -0
- package/dist/cjs/api/types/ListAgentConfigurationsV1Response.js +3 -0
- package/dist/cjs/api/types/ListAgentVariablesV1Response.d.ts +5 -0
- package/dist/cjs/api/types/ListAgentVariablesV1Response.js +3 -0
- package/dist/cjs/api/types/ListenV1Callback.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Channels.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Endpointing.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Extra.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Keyterm.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Keywords.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Language.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1MipOptOut.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Replace.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1SampleRate.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Search.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Tag.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1UtteranceEndMs.d.ts +3 -0
- package/dist/cjs/api/types/ListenV1Version.d.ts +3 -0
- package/dist/cjs/api/types/ListenV2EagerEotThreshold.d.ts +5 -0
- package/dist/cjs/api/types/ListenV2EotThreshold.d.ts +4 -0
- package/dist/cjs/api/types/ListenV2EotTimeoutMs.d.ts +4 -0
- package/dist/cjs/api/types/ListenV2MipOptOut.d.ts +5 -0
- package/dist/cjs/api/types/ListenV2Model.d.ts +6 -4
- package/dist/cjs/api/types/ListenV2Model.js +6 -0
- package/dist/cjs/api/types/ListenV2SampleRate.d.ts +3 -0
- package/dist/cjs/api/types/ListenV2Tag.d.ts +4 -0
- package/dist/cjs/api/types/SpeakV1MipOptOut.d.ts +3 -0
- package/dist/cjs/api/types/SpeakV1Speed.d.ts +4 -0
- package/dist/cjs/api/types/SpeakV1Speed.js +3 -0
- package/dist/cjs/api/types/UsageBreakdownV1Response.d.ts +3 -4
- package/dist/cjs/api/types/index.d.ts +8 -0
- package/dist/cjs/api/types/index.js +8 -0
- package/dist/cjs/core/auth/BasicAuth.d.ts +2 -2
- package/dist/cjs/core/auth/BasicAuth.js +7 -1
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/Fetcher.d.ts +8 -0
- package/dist/cjs/core/fetcher/Fetcher.js +13 -8
- package/dist/cjs/core/fetcher/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/index.js +3 -1
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
- package/dist/cjs/core/file/file.js +3 -2
- package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
- package/dist/cjs/core/url/index.d.ts +1 -0
- package/dist/cjs/core/url/index.js +3 -1
- package/dist/cjs/core/url/qs.d.ts +2 -1
- package/dist/cjs/core/url/qs.js +24 -12
- package/dist/cjs/core/websocket/ws.d.ts +10 -1
- package/dist/cjs/core/websocket/ws.js +19 -5
- package/dist/cjs/errors/DeepgramError.d.ts +3 -1
- package/dist/cjs/errors/DeepgramError.js +4 -1
- package/dist/cjs/errors/DeepgramTimeoutError.d.ts +4 -1
- package/dist/cjs/errors/DeepgramTimeoutError.js +4 -1
- package/dist/cjs/errors/handleNonStatusCodeError.js +4 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +15 -0
- package/dist/esm/Client.mjs +46 -0
- package/dist/esm/api/resources/agent/resources/v1/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/agent/resources/v1/client/Client.mjs +5 -5
- package/dist/esm/api/resources/agent/resources/v1/client/Socket.d.mts +6 -6
- package/dist/esm/api/resources/agent/resources/v1/client/Socket.mjs +6 -6
- package/dist/esm/api/resources/agent/resources/v1/exports.d.mts +1 -0
- package/dist/esm/api/resources/agent/resources/v1/exports.mjs +1 -0
- package/dist/esm/api/resources/agent/resources/v1/resources/settings/resources/think/resources/models/client/Client.mjs +1 -1
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1FunctionCallRequest.d.mts +2 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1History.d.mts +24 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1History.mjs +2 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1Settings.d.mts +2 -1
- package/dist/esm/api/resources/agent/resources/v1/types/index.d.mts +1 -0
- package/dist/esm/api/resources/agent/resources/v1/types/index.mjs +1 -0
- package/dist/esm/api/resources/auth/resources/v1/resources/tokens/client/Client.mjs +1 -1
- package/dist/esm/api/resources/index.d.mts +1 -0
- package/dist/esm/api/resources/index.mjs +1 -0
- package/dist/esm/api/resources/listen/resources/v1/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/listen/resources/v1/client/Client.mjs +5 -5
- package/dist/esm/api/resources/listen/resources/v1/client/Socket.d.mts +3 -3
- package/dist/esm/api/resources/listen/resources/v1/client/Socket.mjs +2 -2
- package/dist/esm/api/resources/listen/resources/v1/exports.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v1/exports.mjs +1 -0
- package/dist/esm/api/resources/listen/resources/v1/resources/media/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v1/resources/media/client/Client.mjs +11 -2
- package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v2/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/listen/resources/v2/client/Client.mjs +5 -5
- package/dist/esm/api/resources/listen/resources/v2/client/Socket.d.mts +4 -4
- package/dist/esm/api/resources/listen/resources/v2/client/Socket.mjs +3 -3
- package/dist/esm/api/resources/listen/resources/v2/exports.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v2/exports.mjs +1 -0
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2Configure.d.mts +6 -0
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.mts +11 -0
- package/dist/esm/api/resources/manage/resources/v1/resources/models/client/Client.mjs +6 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/client/Client.mjs +9 -5
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/balances/client/Client.mjs +2 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.d.mts +2 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.mjs +7 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/requests/BreakdownListRequest.d.mts +2 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/fields/client/Client.mjs +5 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/purchases/client/Client.mjs +5 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.mjs +8 -4
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/members/client/Client.mjs +2 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/members/resources/invites/client/Client.mjs +3 -3
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/members/resources/scopes/client/Client.mjs +2 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/models/client/Client.mjs +6 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.mjs +6 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/client/Client.mjs +5 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/client/Client.mjs +5 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/fields/client/Client.mjs +5 -1
- package/dist/esm/api/resources/read/resources/v1/resources/text/client/Client.mjs +5 -1
- package/dist/esm/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.mjs +9 -4
- package/dist/esm/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/requests/CreateProjectDistributionCredentialsV1Request.d.mts +1 -0
- package/dist/esm/api/resources/speak/resources/v1/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/speak/resources/v1/client/Client.mjs +6 -5
- package/dist/esm/api/resources/speak/resources/v1/client/Socket.d.mts +2 -2
- package/dist/esm/api/resources/speak/resources/v1/client/Socket.mjs +2 -2
- package/dist/esm/api/resources/speak/resources/v1/exports.d.mts +1 -0
- package/dist/esm/api/resources/speak/resources/v1/exports.mjs +1 -0
- package/dist/esm/api/resources/speak/resources/v1/resources/audio/client/Client.mjs +7 -2
- package/dist/esm/api/resources/speak/resources/v1/resources/audio/client/requests/SpeakV1Request.d.mts +2 -0
- package/dist/esm/api/resources/speak/resources/v1/types/SpeakV1Metadata.d.mts +2 -4
- package/dist/esm/api/resources/voiceAgent/client/Client.d.mts +15 -0
- package/dist/esm/api/resources/voiceAgent/client/Client.mjs +17 -0
- package/dist/esm/api/resources/voiceAgent/client/index.d.mts +1 -0
- package/dist/esm/api/resources/voiceAgent/client/index.mjs +1 -0
- package/dist/esm/api/resources/voiceAgent/exports.d.mts +3 -0
- package/dist/esm/api/resources/voiceAgent/exports.mjs +4 -0
- package/dist/esm/api/resources/voiceAgent/index.d.mts +2 -0
- package/dist/esm/api/resources/voiceAgent/index.mjs +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/Client.d.mts +89 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/Client.mjs +288 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/index.d.mts +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/index.mjs +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.d.mts +14 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.mjs +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.d.mts +12 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.mjs +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/exports.d.mts +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/exports.mjs +3 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/index.d.mts +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/configurations/index.mjs +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/index.d.mts +4 -0
- package/dist/esm/api/resources/voiceAgent/resources/index.mjs +4 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/Client.d.mts +92 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/Client.mjs +288 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/index.d.mts +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/index.mjs +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.d.mts +16 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.mjs +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.d.mts +11 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.mjs +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/exports.d.mts +2 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/exports.mjs +3 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/index.d.mts +1 -0
- package/dist/esm/api/resources/voiceAgent/resources/variables/index.mjs +1 -0
- package/dist/esm/api/types/AgentConfigurationV1.d.mts +15 -0
- package/dist/esm/api/types/AgentConfigurationV1.mjs +2 -0
- package/dist/esm/api/types/AgentVariableV1.d.mts +14 -0
- package/dist/esm/api/types/AgentVariableV1.mjs +2 -0
- package/dist/esm/api/types/Cartesia.d.mts +2 -0
- package/dist/esm/api/types/CreateAgentConfigurationV1Response.d.mts +8 -0
- package/dist/esm/api/types/CreateAgentConfigurationV1Response.mjs +2 -0
- package/dist/esm/api/types/Deepgram.d.mts +2 -0
- package/dist/esm/api/types/DeleteAgentConfigurationV1Response.d.mts +4 -0
- package/dist/esm/api/types/DeleteAgentConfigurationV1Response.mjs +2 -0
- package/dist/esm/api/types/DeleteAgentVariableV1Response.d.mts +4 -0
- package/dist/esm/api/types/DeleteAgentVariableV1Response.mjs +2 -0
- package/dist/esm/api/types/ListAgentConfigurationsV1Response.d.mts +5 -0
- package/dist/esm/api/types/ListAgentConfigurationsV1Response.mjs +2 -0
- package/dist/esm/api/types/ListAgentVariablesV1Response.d.mts +5 -0
- package/dist/esm/api/types/ListAgentVariablesV1Response.mjs +2 -0
- package/dist/esm/api/types/ListenV1Callback.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Channels.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Endpointing.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Extra.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Keyterm.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Keywords.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Language.d.mts +3 -0
- package/dist/esm/api/types/ListenV1MipOptOut.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Replace.d.mts +3 -0
- package/dist/esm/api/types/ListenV1SampleRate.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Search.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Tag.d.mts +3 -0
- package/dist/esm/api/types/ListenV1UtteranceEndMs.d.mts +3 -0
- package/dist/esm/api/types/ListenV1Version.d.mts +3 -0
- package/dist/esm/api/types/ListenV2EagerEotThreshold.d.mts +5 -0
- package/dist/esm/api/types/ListenV2EotThreshold.d.mts +4 -0
- package/dist/esm/api/types/ListenV2EotTimeoutMs.d.mts +4 -0
- package/dist/esm/api/types/ListenV2MipOptOut.d.mts +5 -0
- package/dist/esm/api/types/ListenV2Model.d.mts +6 -4
- package/dist/esm/api/types/ListenV2Model.mjs +5 -1
- package/dist/esm/api/types/ListenV2SampleRate.d.mts +3 -0
- package/dist/esm/api/types/ListenV2Tag.d.mts +4 -0
- package/dist/esm/api/types/SpeakV1MipOptOut.d.mts +3 -0
- package/dist/esm/api/types/SpeakV1Speed.d.mts +4 -0
- package/dist/esm/api/types/SpeakV1Speed.mjs +2 -0
- package/dist/esm/api/types/UsageBreakdownV1Response.d.mts +3 -4
- package/dist/esm/api/types/index.d.mts +8 -0
- package/dist/esm/api/types/index.mjs +8 -0
- package/dist/esm/core/auth/BasicAuth.d.mts +2 -2
- package/dist/esm/core/auth/BasicAuth.mjs +7 -1
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/Fetcher.d.mts +8 -0
- package/dist/esm/core/fetcher/Fetcher.mjs +13 -8
- package/dist/esm/core/fetcher/index.d.mts +2 -0
- package/dist/esm/core/fetcher/index.mjs +1 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
- package/dist/esm/core/file/file.mjs +3 -2
- package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
- package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
- package/dist/esm/core/url/index.d.mts +1 -0
- package/dist/esm/core/url/index.mjs +1 -0
- package/dist/esm/core/url/qs.d.mts +2 -1
- package/dist/esm/core/url/qs.mjs +24 -12
- package/dist/esm/core/websocket/ws.d.mts +10 -1
- package/dist/esm/core/websocket/ws.mjs +19 -5
- package/dist/esm/errors/DeepgramError.d.mts +3 -1
- package/dist/esm/errors/DeepgramError.mjs +4 -1
- package/dist/esm/errors/DeepgramTimeoutError.d.mts +4 -1
- package/dist/esm/errors/DeepgramTimeoutError.mjs +4 -1
- package/dist/esm/errors/handleNonStatusCodeError.mjs +4 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +540 -500
- package/reference.md +731 -1
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.d.ts +0 -201
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.js +0 -139
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.d.ts +0 -201
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.js +0 -139
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.d.ts +0 -115
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.js +0 -57
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.d.ts +0 -201
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.js +0 -139
- package/dist/cjs/api/types/OpenAi.d.ts +0 -27
- package/dist/cjs/api/types/OpenAi.js +0 -21
- package/dist/cjs/middleware/adapters/express.d.ts +0 -103
- package/dist/cjs/middleware/adapters/express.js +0 -141
- package/dist/cjs/middleware/adapters/fastify.d.ts +0 -32
- package/dist/cjs/middleware/adapters/fastify.js +0 -194
- package/dist/cjs/middleware/adapters/http.d.ts +0 -153
- package/dist/cjs/middleware/adapters/http.js +0 -192
- package/dist/cjs/middleware/core/ProxyHandler.d.ts +0 -35
- package/dist/cjs/middleware/core/ProxyHandler.js +0 -225
- package/dist/cjs/middleware/core/TokenManager.d.ts +0 -29
- package/dist/cjs/middleware/core/TokenManager.js +0 -110
- package/dist/cjs/middleware/core/WebSocketProxy.d.ts +0 -32
- package/dist/cjs/middleware/core/WebSocketProxy.js +0 -169
- package/dist/cjs/middleware/core/jwt.d.ts +0 -71
- package/dist/cjs/middleware/core/jwt.js +0 -136
- package/dist/cjs/middleware/core/types.d.ts +0 -37
- package/dist/cjs/middleware/index.d.ts +0 -55
- package/dist/cjs/middleware/index.js +0 -75
- package/dist/cjs/tests/manual/test-custom-baseurl.js +0 -124
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.d.mts +0 -201
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.mjs +0 -136
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.d.mts +0 -201
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.mjs +0 -136
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.d.mts +0 -115
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.mjs +0 -54
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.d.mts +0 -201
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.mjs +0 -136
- package/dist/esm/api/types/OpenAi.d.mts +0 -27
- package/dist/esm/api/types/OpenAi.mjs +0 -18
- package/dist/esm/middleware/adapters/express.d.mts +0 -103
- package/dist/esm/middleware/adapters/express.mjs +0 -136
- package/dist/esm/middleware/adapters/fastify.d.mts +0 -32
- package/dist/esm/middleware/adapters/fastify.mjs +0 -157
- package/dist/esm/middleware/adapters/http.d.mts +0 -153
- package/dist/esm/middleware/adapters/http.mjs +0 -187
- package/dist/esm/middleware/core/ProxyHandler.d.mts +0 -35
- package/dist/esm/middleware/core/ProxyHandler.mjs +0 -218
- package/dist/esm/middleware/core/TokenManager.d.mts +0 -29
- package/dist/esm/middleware/core/TokenManager.mjs +0 -106
- package/dist/esm/middleware/core/WebSocketProxy.d.mts +0 -32
- package/dist/esm/middleware/core/WebSocketProxy.mjs +0 -162
- package/dist/esm/middleware/core/jwt.d.mts +0 -71
- package/dist/esm/middleware/core/jwt.mjs +0 -99
- package/dist/esm/middleware/core/types.d.mts +0 -37
- package/dist/esm/middleware/index.d.mts +0 -55
- package/dist/esm/middleware/index.mjs +0 -59
- /package/dist/{esm/middleware/core/types.mjs → cjs/api/resources/voiceAgent/client/index.d.ts} +0 -0
- /package/dist/cjs/{middleware/core/types.js → api/resources/voiceAgent/client/index.js} +0 -0
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Raw Node.js HTTP/HTTPS server adapter for proxying Deepgram API requests.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*
|
|
7
|
-
* **No Dependencies Required** - Uses only built-in Node.js modules
|
|
8
|
-
*
|
|
9
|
-
* This module provides a request handler for raw Node.js `http` and `https` servers,
|
|
10
|
-
* allowing proxy integration without any framework dependencies.
|
|
11
|
-
*/
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.createHttpHandler = createHttpHandler;
|
|
23
|
-
exports.createUpgradeHandler = createUpgradeHandler;
|
|
24
|
-
exports.createDeepgramHttpServer = createDeepgramHttpServer;
|
|
25
|
-
const ProxyHandler_js_1 = require("../core/ProxyHandler.js");
|
|
26
|
-
const TokenManager_js_1 = require("../core/TokenManager.js");
|
|
27
|
-
const WebSocketProxy_js_1 = require("../core/WebSocketProxy.js");
|
|
28
|
-
/**
|
|
29
|
-
* Create a request handler for raw Node.js HTTP/HTTPS servers
|
|
30
|
-
*
|
|
31
|
-
* This handler can be used directly with `http.createServer()` or `https.createServer()`.
|
|
32
|
-
*
|
|
33
|
-
* @param options - Middleware configuration options
|
|
34
|
-
* @returns HTTP request handler function
|
|
35
|
-
*
|
|
36
|
-
* @example Basic HTTP server
|
|
37
|
-
* ```typescript
|
|
38
|
-
* import http from 'node:http';
|
|
39
|
-
* import { createHttpHandler, createUpgradeHandler } from '@deepgram/sdk';
|
|
40
|
-
*
|
|
41
|
-
* const options = {
|
|
42
|
-
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
43
|
-
* enableTokenAuth: true
|
|
44
|
-
* };
|
|
45
|
-
*
|
|
46
|
-
* // Create request handler
|
|
47
|
-
* const handler = createHttpHandler(options);
|
|
48
|
-
*
|
|
49
|
-
* // Create server
|
|
50
|
-
* const server = http.createServer(handler);
|
|
51
|
-
*
|
|
52
|
-
* // Register WebSocket upgrade handler
|
|
53
|
-
* server.on('upgrade', createUpgradeHandler(options));
|
|
54
|
-
*
|
|
55
|
-
* server.listen(3000);
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @example HTTPS server
|
|
59
|
-
* ```typescript
|
|
60
|
-
* import https from 'node:https';
|
|
61
|
-
* import fs from 'node:fs';
|
|
62
|
-
* import { createHttpHandler, createUpgradeHandler } from '@deepgram/sdk';
|
|
63
|
-
*
|
|
64
|
-
* const options = {
|
|
65
|
-
* apiKey: process.env.DEEPGRAM_API_KEY!
|
|
66
|
-
* };
|
|
67
|
-
*
|
|
68
|
-
* const server = https.createServer({
|
|
69
|
-
* key: fs.readFileSync('server.key'),
|
|
70
|
-
* cert: fs.readFileSync('server.cert')
|
|
71
|
-
* }, createHttpHandler(options));
|
|
72
|
-
*
|
|
73
|
-
* server.on('upgrade', createUpgradeHandler(options));
|
|
74
|
-
* server.listen(443);
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @example With routing
|
|
78
|
-
* ```typescript
|
|
79
|
-
* import http from 'node:http';
|
|
80
|
-
* import { createHttpHandler } from '@deepgram/sdk';
|
|
81
|
-
*
|
|
82
|
-
* const deepgramHandler = createHttpHandler({
|
|
83
|
-
* apiKey: process.env.DEEPGRAM_API_KEY!
|
|
84
|
-
* });
|
|
85
|
-
*
|
|
86
|
-
* const server = http.createServer((req, res) => {
|
|
87
|
-
* // Route /api/deepgram/* to Deepgram proxy
|
|
88
|
-
* if (req.url?.startsWith('/api/deepgram')) {
|
|
89
|
-
* // Strip prefix before proxying
|
|
90
|
-
* req.url = req.url.slice('/api/deepgram'.length);
|
|
91
|
-
* return deepgramHandler(req, res);
|
|
92
|
-
* }
|
|
93
|
-
*
|
|
94
|
-
* // Handle other routes
|
|
95
|
-
* res.writeHead(404);
|
|
96
|
-
* res.end('Not Found');
|
|
97
|
-
* });
|
|
98
|
-
*
|
|
99
|
-
* server.listen(3000);
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
function createHttpHandler(options) {
|
|
103
|
-
const proxyHandler = new ProxyHandler_js_1.ProxyHandler(options);
|
|
104
|
-
const tokenManager = options.enableTokenAuth ? new TokenManager_js_1.TokenManager(options) : null;
|
|
105
|
-
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
try {
|
|
107
|
-
// Handle token generation requests
|
|
108
|
-
if (options.enableTokenAuth && req.url === "/token" && req.method === "GET") {
|
|
109
|
-
yield tokenManager.handleTokenRequest(req, res);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
// Handle all other requests (proxy to Deepgram)
|
|
113
|
-
yield proxyHandler.handleRequest(req, res);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
// Set error response
|
|
117
|
-
res.statusCode = 500;
|
|
118
|
-
res.setHeader("Content-Type", "application/json");
|
|
119
|
-
res.end(JSON.stringify({
|
|
120
|
-
error: error instanceof Error ? error.message : String(error),
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Create WebSocket upgrade handler for raw Node.js HTTP/HTTPS servers
|
|
127
|
-
*
|
|
128
|
-
* This must be registered on the server using `server.on('upgrade', handler)`.
|
|
129
|
-
*
|
|
130
|
-
* @param options - Middleware configuration options
|
|
131
|
-
* @returns Upgrade handler function
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* import http from 'node:http';
|
|
136
|
-
* import { createHttpHandler, createUpgradeHandler } from '@deepgram/sdk';
|
|
137
|
-
*
|
|
138
|
-
* const options = {
|
|
139
|
-
* apiKey: process.env.DEEPGRAM_API_KEY!
|
|
140
|
-
* };
|
|
141
|
-
*
|
|
142
|
-
* const server = http.createServer(createHttpHandler(options));
|
|
143
|
-
*
|
|
144
|
-
* // Register WebSocket handler
|
|
145
|
-
* server.on('upgrade', createUpgradeHandler(options));
|
|
146
|
-
*
|
|
147
|
-
* server.listen(3000);
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
function createUpgradeHandler(options) {
|
|
151
|
-
const wsProxy = new WebSocketProxy_js_1.WebSocketProxy(options);
|
|
152
|
-
return (req, socket, head) => {
|
|
153
|
-
wsProxy.handleUpgrade(req, socket, head);
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Combined helper that returns both HTTP handler and upgrade handler
|
|
158
|
-
*
|
|
159
|
-
* Convenience function for setting up both REST and WebSocket proxying.
|
|
160
|
-
*
|
|
161
|
-
* @param options - Middleware configuration options
|
|
162
|
-
* @returns Object with HTTP handler and upgrade handler
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* import http from 'node:http';
|
|
167
|
-
* import { createDeepgramHttpServer } from '@deepgram/sdk';
|
|
168
|
-
*
|
|
169
|
-
* const { handler, upgradeHandler } = createDeepgramHttpServer({
|
|
170
|
-
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
171
|
-
* enableTokenAuth: true
|
|
172
|
-
* });
|
|
173
|
-
*
|
|
174
|
-
* const server = http.createServer(handler);
|
|
175
|
-
* server.on('upgrade', upgradeHandler);
|
|
176
|
-
*
|
|
177
|
-
* server.listen(3000, () => {
|
|
178
|
-
* console.log('Deepgram proxy running on port 3000');
|
|
179
|
-
* });
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
function createDeepgramHttpServer(options) {
|
|
183
|
-
const handler = createHttpHandler(options);
|
|
184
|
-
const upgradeHandler = createUpgradeHandler(options);
|
|
185
|
-
return {
|
|
186
|
-
handler,
|
|
187
|
-
upgradeHandler,
|
|
188
|
-
server: (httpServer) => {
|
|
189
|
-
httpServer.on("upgrade", upgradeHandler);
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import type { MiddlewareOptions } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Handles HTTP/REST request proxying to Deepgram API
|
|
5
|
-
*/
|
|
6
|
-
export declare class ProxyHandler {
|
|
7
|
-
private readonly apiKey;
|
|
8
|
-
private readonly baseUrl;
|
|
9
|
-
private readonly tokenMode;
|
|
10
|
-
constructor(options: MiddlewareOptions);
|
|
11
|
-
/**
|
|
12
|
-
* Handle incoming HTTP request and proxy to Deepgram
|
|
13
|
-
*/
|
|
14
|
-
handleRequest(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Forward request to Deepgram API
|
|
17
|
-
*/
|
|
18
|
-
private forwardToDeepgram;
|
|
19
|
-
/**
|
|
20
|
-
* Prepare headers for Deepgram request
|
|
21
|
-
*/
|
|
22
|
-
private prepareHeaders;
|
|
23
|
-
/**
|
|
24
|
-
* Add CORS headers to response
|
|
25
|
-
*/
|
|
26
|
-
private addCorsHeaders;
|
|
27
|
-
/**
|
|
28
|
-
* Handle CORS preflight requests
|
|
29
|
-
*/
|
|
30
|
-
private handleCorsPreflightRequest;
|
|
31
|
-
/**
|
|
32
|
-
* Handle errors and send appropriate response
|
|
33
|
-
*/
|
|
34
|
-
private handleError;
|
|
35
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ProxyHandler = void 0;
|
|
16
|
-
const node_https_1 = __importDefault(require("node:https"));
|
|
17
|
-
const node_url_1 = require("node:url");
|
|
18
|
-
const jwt_js_1 = require("./jwt.js");
|
|
19
|
-
/**
|
|
20
|
-
* Handles HTTP/REST request proxying to Deepgram API
|
|
21
|
-
*/
|
|
22
|
-
class ProxyHandler {
|
|
23
|
-
constructor(options) {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
this.apiKey = options.apiKey;
|
|
26
|
-
this.baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : "https://api.deepgram.com";
|
|
27
|
-
this.tokenMode = (_b = options.tokenMode) !== null && _b !== void 0 ? _b : "deepgram";
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Handle incoming HTTP request and proxy to Deepgram
|
|
31
|
-
*/
|
|
32
|
-
handleRequest(req, res) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
try {
|
|
35
|
-
// Handle CORS preflight
|
|
36
|
-
if (req.method === "OPTIONS") {
|
|
37
|
-
this.handleCorsPreflightRequest(req, res);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
// Forward request to Deepgram
|
|
41
|
-
yield this.forwardToDeepgram(req, res);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
this.handleError(error, res);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Forward request to Deepgram API
|
|
50
|
-
*/
|
|
51
|
-
forwardToDeepgram(req, res) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
var _a;
|
|
54
|
-
console.log(`[ProxyHandler] Starting forward to Deepgram`);
|
|
55
|
-
console.log(`[ProxyHandler] Original URL: ${req.url}`);
|
|
56
|
-
// Strip /api/deepgram prefix if present
|
|
57
|
-
const cleanUrl = ((_a = req.url) !== null && _a !== void 0 ? _a : "/").replace(/^\/api\/deepgram/, "");
|
|
58
|
-
console.log(`[ProxyHandler] Clean URL: ${cleanUrl}`);
|
|
59
|
-
// Build Deepgram URL
|
|
60
|
-
const targetUrl = new node_url_1.URL(cleanUrl, this.baseUrl);
|
|
61
|
-
console.log(`[ProxyHandler] Target URL: ${targetUrl.toString()}`);
|
|
62
|
-
// Prepare headers (may verify JWT)
|
|
63
|
-
const headers = yield this.prepareHeaders(req);
|
|
64
|
-
console.log(`[ProxyHandler] Request headers prepared`);
|
|
65
|
-
// Create request to Deepgram
|
|
66
|
-
const options = {
|
|
67
|
-
method: req.method,
|
|
68
|
-
headers,
|
|
69
|
-
};
|
|
70
|
-
console.log(`[ProxyHandler] Creating ${req.method} request to Deepgram...`);
|
|
71
|
-
console.log(`[ProxyHandler] Headers being SENT to Deepgram:`, JSON.stringify(headers, null, 2));
|
|
72
|
-
const deepgramReq = node_https_1.default.request(targetUrl, options, (deepgramRes) => {
|
|
73
|
-
var _a;
|
|
74
|
-
console.log(`[ProxyHandler] Received response from Deepgram: ${deepgramRes.statusCode}`);
|
|
75
|
-
console.log(`[ProxyHandler] Response headers from Deepgram:`, JSON.stringify(deepgramRes.headers, null, 2));
|
|
76
|
-
// Don't set headers if they were already sent
|
|
77
|
-
if (res.headersSent) {
|
|
78
|
-
console.log(`[ProxyHandler] Headers already sent, skipping`);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Build response headers with CORS
|
|
82
|
-
const responseHeaders = Object.assign(Object.assign({}, deepgramRes.headers), { "access-control-allow-origin": "*", "access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS", "access-control-allow-headers": "Authorization, Content-Type, x-fern-language, x-fern-sdk-name, x-fern-sdk-version, x-deepgram-session-id", "access-control-max-age": "3600" });
|
|
83
|
-
// Forward status and headers
|
|
84
|
-
console.log(`[ProxyHandler] Writing response headers`);
|
|
85
|
-
res.writeHead((_a = deepgramRes.statusCode) !== null && _a !== void 0 ? _a : 200, responseHeaders);
|
|
86
|
-
// Stream response body
|
|
87
|
-
console.log(`[ProxyHandler] Piping response body to client`);
|
|
88
|
-
deepgramRes.pipe(res);
|
|
89
|
-
deepgramRes.on('end', () => {
|
|
90
|
-
console.log(`[ProxyHandler] Response stream ended`);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
// Handle request errors
|
|
94
|
-
deepgramReq.on("error", (error) => {
|
|
95
|
-
console.error(`[ProxyHandler] Request error:`, error);
|
|
96
|
-
this.handleError(error, res);
|
|
97
|
-
});
|
|
98
|
-
// Check if request stream is readable
|
|
99
|
-
console.log(`[ProxyHandler] Request stream readable: ${req.readable}`);
|
|
100
|
-
console.log(`[ProxyHandler] Request stream readableEnded: ${req.readableEnded}`);
|
|
101
|
-
console.log(`[ProxyHandler] Request method: ${req.method}`);
|
|
102
|
-
// For POST/PUT requests, manually read and forward the body
|
|
103
|
-
if (req.method === 'POST' || req.method === 'PUT' || req.method === 'PATCH') {
|
|
104
|
-
console.log(`[ProxyHandler] Reading request body for ${req.method} request...`);
|
|
105
|
-
const chunks = [];
|
|
106
|
-
req.on('data', (chunk) => {
|
|
107
|
-
console.log(`[ProxyHandler] Received request chunk: ${chunk.length} bytes`);
|
|
108
|
-
chunks.push(chunk);
|
|
109
|
-
});
|
|
110
|
-
req.on('end', () => {
|
|
111
|
-
const body = Buffer.concat(chunks);
|
|
112
|
-
console.log(`[ProxyHandler] Request body complete: ${body.length} bytes total`);
|
|
113
|
-
console.log(`[ProxyHandler] Request body content: ${body.toString()}`);
|
|
114
|
-
deepgramReq.write(body);
|
|
115
|
-
deepgramReq.end();
|
|
116
|
-
console.log(`[ProxyHandler] Request sent to Deepgram`);
|
|
117
|
-
});
|
|
118
|
-
req.on('error', (err) => {
|
|
119
|
-
console.error(`[ProxyHandler] Request stream error:`, err);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// For GET requests, just end immediately
|
|
124
|
-
console.log(`[ProxyHandler] No body expected for ${req.method} request`);
|
|
125
|
-
deepgramReq.end();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Prepare headers for Deepgram request
|
|
131
|
-
*/
|
|
132
|
-
prepareHeaders(req) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
const headers = {};
|
|
135
|
-
// Copy relevant headers
|
|
136
|
-
const allowedHeaders = [
|
|
137
|
-
"content-type",
|
|
138
|
-
"content-length",
|
|
139
|
-
"accept",
|
|
140
|
-
"user-agent",
|
|
141
|
-
"x-fern-language",
|
|
142
|
-
"x-fern-sdk-name",
|
|
143
|
-
"x-fern-sdk-version",
|
|
144
|
-
"x-fern-runtime",
|
|
145
|
-
"x-fern-runtime-version",
|
|
146
|
-
"x-deepgram-session-id",
|
|
147
|
-
];
|
|
148
|
-
for (const header of allowedHeaders) {
|
|
149
|
-
const value = req.headers[header];
|
|
150
|
-
if (value) {
|
|
151
|
-
headers[header] = Array.isArray(value) ? value[0] : value;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
// Authentication logic:
|
|
155
|
-
// 1. If client sends dummy key "Token Dummy key for SDK proxying" -> use server API key
|
|
156
|
-
// 2. If tokenMode is "jwt" and client sends Bearer token -> verify JWT and use server API key
|
|
157
|
-
// 3. If tokenMode is "deepgram" and client sends Token -> forward it (Deepgram temp token)
|
|
158
|
-
// 4. If client sends no auth header -> use server API key
|
|
159
|
-
const clientAuth = req.headers.authorization;
|
|
160
|
-
const isDummyKey = clientAuth === "Token Dummy key for SDK proxying";
|
|
161
|
-
if (clientAuth && !isDummyKey) {
|
|
162
|
-
// Check if it's a JWT Bearer token
|
|
163
|
-
if (this.tokenMode === "jwt" && clientAuth.startsWith("Bearer ")) {
|
|
164
|
-
const token = clientAuth.replace("Bearer ", "");
|
|
165
|
-
console.log(`[ProxyHandler] Client provided JWT token, verifying...`);
|
|
166
|
-
try {
|
|
167
|
-
yield (0, jwt_js_1.verifyProxyToken)(token, this.apiKey);
|
|
168
|
-
console.log(`[ProxyHandler] JWT verified successfully, using server API key`);
|
|
169
|
-
headers.authorization = `Token ${this.apiKey}`;
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
console.error(`[ProxyHandler] JWT verification failed:`, error);
|
|
173
|
-
throw new Error("Invalid or expired token");
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
console.log(`[ProxyHandler] Client provided authorization header, forwarding to Deepgram`);
|
|
178
|
-
headers.authorization = clientAuth;
|
|
179
|
-
console.log(`[ProxyHandler] Authorization header: ${headers.authorization.substring(0, 30)}...`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
if (isDummyKey) {
|
|
184
|
-
console.log(`[ProxyHandler] Client sent dummy key, using server API key`);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
console.log(`[ProxyHandler] No client auth, using server API key`);
|
|
188
|
-
}
|
|
189
|
-
headers.authorization = `Token ${this.apiKey}`;
|
|
190
|
-
console.log(`[ProxyHandler] Authorization header: ${headers.authorization.substring(0, 30)}...`);
|
|
191
|
-
}
|
|
192
|
-
return headers;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Add CORS headers to response
|
|
197
|
-
*/
|
|
198
|
-
addCorsHeaders(res) {
|
|
199
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
200
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
201
|
-
res.setHeader("Access-Control-Allow-Headers", "Authorization, Content-Type, x-fern-language, x-fern-sdk-name, x-fern-sdk-version, x-fern-runtime, x-fern-runtime-version, x-deepgram-session-id");
|
|
202
|
-
res.setHeader("Access-Control-Max-Age", "3600");
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Handle CORS preflight requests
|
|
206
|
-
*/
|
|
207
|
-
handleCorsPreflightRequest(req, res) {
|
|
208
|
-
this.addCorsHeaders(res);
|
|
209
|
-
res.writeHead(204);
|
|
210
|
-
res.end();
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Handle errors and send appropriate response
|
|
214
|
-
*/
|
|
215
|
-
handleError(error, res) {
|
|
216
|
-
console.error("ProxyHandler error:", error);
|
|
217
|
-
const message = error instanceof Error ? error.message : "Internal server error";
|
|
218
|
-
this.addCorsHeaders(res);
|
|
219
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
220
|
-
res.end(JSON.stringify({
|
|
221
|
-
error: message,
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
exports.ProxyHandler = ProxyHandler;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import type { MiddlewareOptions } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Manages temporary token generation for client authentication
|
|
5
|
-
*/
|
|
6
|
-
export declare class TokenManager {
|
|
7
|
-
private readonly client;
|
|
8
|
-
private readonly apiKey;
|
|
9
|
-
private readonly tokenMode;
|
|
10
|
-
private readonly defaultExpiration;
|
|
11
|
-
constructor(options: MiddlewareOptions);
|
|
12
|
-
/**
|
|
13
|
-
* Generate a temporary access token
|
|
14
|
-
* Uses either Deepgram's native token API or JWT signing based on tokenMode
|
|
15
|
-
*/
|
|
16
|
-
generateToken(ttlSeconds: number): Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Handle token generation request from client
|
|
19
|
-
*/
|
|
20
|
-
handleTokenRequest(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Parse JSON request body
|
|
23
|
-
*/
|
|
24
|
-
private parseBody;
|
|
25
|
-
/**
|
|
26
|
-
* Handle errors and send appropriate response
|
|
27
|
-
*/
|
|
28
|
-
private handleError;
|
|
29
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TokenManager = void 0;
|
|
13
|
-
const CustomClient_js_1 = require("../../CustomClient.js");
|
|
14
|
-
const jwt_js_1 = require("./jwt.js");
|
|
15
|
-
/**
|
|
16
|
-
* Manages temporary token generation for client authentication
|
|
17
|
-
*/
|
|
18
|
-
class TokenManager {
|
|
19
|
-
constructor(options) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
this.client = new CustomClient_js_1.CustomDeepgramClient({ apiKey: options.apiKey });
|
|
22
|
-
this.apiKey = options.apiKey;
|
|
23
|
-
this.tokenMode = (_a = options.tokenMode) !== null && _a !== void 0 ? _a : "deepgram";
|
|
24
|
-
this.defaultExpiration = (_b = options.defaultTokenExpiration) !== null && _b !== void 0 ? _b : 3600;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Generate a temporary access token
|
|
28
|
-
* Uses either Deepgram's native token API or JWT signing based on tokenMode
|
|
29
|
-
*/
|
|
30
|
-
generateToken(ttlSeconds) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
if (this.tokenMode === "jwt") {
|
|
33
|
-
return (0, jwt_js_1.createProxyToken)(this.apiKey, { ttl: ttlSeconds });
|
|
34
|
-
}
|
|
35
|
-
const response = yield this.client.auth.v1.tokens.grant({
|
|
36
|
-
ttl_seconds: ttlSeconds,
|
|
37
|
-
});
|
|
38
|
-
return response.access_token;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Handle token generation request from client
|
|
43
|
-
*/
|
|
44
|
-
handleTokenRequest(req, res) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
var _a;
|
|
47
|
-
try {
|
|
48
|
-
// Parse request body
|
|
49
|
-
const body = yield this.parseBody(req);
|
|
50
|
-
const tokenRequest = body;
|
|
51
|
-
// Generate token with requested or default TTL
|
|
52
|
-
const ttlSeconds = (_a = tokenRequest.ttlSeconds) !== null && _a !== void 0 ? _a : this.defaultExpiration;
|
|
53
|
-
const token = yield this.generateToken(ttlSeconds);
|
|
54
|
-
// Send response
|
|
55
|
-
const response = {
|
|
56
|
-
token,
|
|
57
|
-
expiresIn: ttlSeconds,
|
|
58
|
-
};
|
|
59
|
-
res.writeHead(200, {
|
|
60
|
-
"Content-Type": "application/json",
|
|
61
|
-
"Access-Control-Allow-Origin": "*",
|
|
62
|
-
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
63
|
-
"Access-Control-Allow-Headers": "Content-Type",
|
|
64
|
-
});
|
|
65
|
-
res.end(JSON.stringify(response));
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
this.handleError(error, res);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Parse JSON request body
|
|
74
|
-
*/
|
|
75
|
-
parseBody(req) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
let body = "";
|
|
79
|
-
req.on("data", (chunk) => {
|
|
80
|
-
body += chunk.toString();
|
|
81
|
-
});
|
|
82
|
-
req.on("end", () => {
|
|
83
|
-
try {
|
|
84
|
-
resolve(body ? JSON.parse(body) : {});
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
reject(new Error("Invalid JSON in request body"));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
req.on("error", reject);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Handle errors and send appropriate response
|
|
96
|
-
*/
|
|
97
|
-
handleError(error, res) {
|
|
98
|
-
console.error("TokenManager error:", error);
|
|
99
|
-
const message = error instanceof Error ? error.message : "Internal server error";
|
|
100
|
-
const statusCode = message.includes("Invalid JSON") ? 400 : 500;
|
|
101
|
-
res.writeHead(statusCode, {
|
|
102
|
-
"Content-Type": "application/json",
|
|
103
|
-
"Access-Control-Allow-Origin": "*",
|
|
104
|
-
});
|
|
105
|
-
res.end(JSON.stringify({
|
|
106
|
-
error: message,
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.TokenManager = TokenManager;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import type { Duplex } from "node:stream";
|
|
3
|
-
import type { MiddlewareOptions } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Handles WebSocket proxying to Deepgram API
|
|
6
|
-
*/
|
|
7
|
-
export declare class WebSocketProxy {
|
|
8
|
-
private readonly apiKey;
|
|
9
|
-
private readonly baseUrl;
|
|
10
|
-
private readonly tokenMode;
|
|
11
|
-
constructor(options: MiddlewareOptions);
|
|
12
|
-
/**
|
|
13
|
-
* Handle WebSocket upgrade request
|
|
14
|
-
*/
|
|
15
|
-
handleUpgrade(req: IncomingMessage, socket: Duplex, head: Buffer): void;
|
|
16
|
-
/**
|
|
17
|
-
* Async version of handleUpgrade to support JWT verification
|
|
18
|
-
*/
|
|
19
|
-
private handleUpgradeAsync;
|
|
20
|
-
/**
|
|
21
|
-
* Build WebSocket URL for Deepgram
|
|
22
|
-
*/
|
|
23
|
-
private buildWebSocketUrl;
|
|
24
|
-
/**
|
|
25
|
-
* Prepare headers for Deepgram WebSocket connection
|
|
26
|
-
*/
|
|
27
|
-
private prepareHeaders;
|
|
28
|
-
/**
|
|
29
|
-
* Forward WebSocket messages bidirectionally
|
|
30
|
-
*/
|
|
31
|
-
private forwardMessages;
|
|
32
|
-
}
|