@sinch/functions-runtime 0.7.2 → 0.7.4

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/README.md CHANGED
@@ -462,6 +462,8 @@ export const voiceWebhook = onCall({
462
462
 
463
463
  `ctx.recording?.storageKey` is available in `onEnd` for the stream recording. For a plain voice
464
464
  function, `recordToFunctions()` on the builder does the same as `sinch`.
465
+ To record with your own `startRecording`, `await context.storage.recordingUrl(callId, 'mp3')` returns the
466
+ same presigned PUT URL (`recordings/<callId>.<format>`, `mp3` by default or `wav`) for `destinationUrl`.
465
467
 
466
468
  ### Talking to an LLM over Voice Relay
467
469
 
@@ -687,19 +689,19 @@ export function setup(runtime: SinchRuntime) {
687
689
 
688
690
  Every handler receives a `FunctionContext`.
689
691
 
690
- | Member | What it is |
691
- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
692
- | `context.config` | `projectId`, `functionName`, `environment`, `variables`, and `getVariable`/`requireVariable`/`getSecret`/`requireSecret`/`hasVariable`… |
693
- | `context.env` | Environment variables, including secrets |
694
- | `context.cache` | Key-value store with TTLs: `get`, `set`, `has`, `delete`, `extend`, `keys`, `getMany`. In memory locally, shared in production |
695
- | `context.storage` | Durable files: `write`, `read`, `list`, `exists`, `delete`, `getRecordingDestination`. Local filesystem in dev, object storage in production |
696
- | `context.database` | Path to a per-function SQLite file, replicated in production. Open it with `node:sqlite` or any SQLite driver |
697
- | `context.assets(name)` | Reads a file from the function's `assets/` directory |
698
- | `context.voice` | Voice API v2 client: `call`, `callWithStream`, `bridge`, `transfer`, `patch`, `onCall`. Always present |
699
- | `context.voice.v1` | Voice API v1 client, when `VOICE_APPLICATION_KEY` and `VOICE_APPLICATION_SECRET` are set |
700
- | `context.conversation` | Conversation API client, when `CONVERSATION_APP_ID` is set |
701
- | `context.sms` | SMS API client, when `SMS_SERVICE_PLAN_ID` is set |
702
- | `context.numbers` | Numbers API client, when `ENABLE_NUMBERS_API=true` |
692
+ | Member | What it is |
693
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
694
+ | `context.config` | `projectId`, `functionName`, `environment`, `variables`, and `getVariable`/`requireVariable`/`getSecret`/`requireSecret`/`hasVariable`… |
695
+ | `context.env` | Environment variables, including secrets |
696
+ | `context.cache` | Key-value store with TTLs: `get`, `set`, `has`, `delete`, `extend`, `keys`, `getMany`. In memory locally, shared in production |
697
+ | `context.storage` | Durable files: `write`, `read`, `list`, `exists`, `delete`, `recordingUrl`. Local filesystem in dev, object storage in production |
698
+ | `context.database` | Path to a per-function SQLite file, replicated in production. Open it with `node:sqlite` or any SQLite driver |
699
+ | `context.assets(name)` | Reads a file from the function's `assets/` directory |
700
+ | `context.voice` | Voice API v2 client: `call`, `callWithStream`, `bridge`, `transfer`, `patch`, `onCall`. Always present |
701
+ | `context.voice.v1` | Voice API v1 client, when `VOICE_APPLICATION_KEY` and `VOICE_APPLICATION_SECRET` are set |
702
+ | `context.conversation` | Conversation API client, when `CONVERSATION_APP_ID` is set |
703
+ | `context.sms` | SMS API client, when `SMS_SERVICE_PLAN_ID` is set |
704
+ | `context.numbers` | Numbers API client, when `ENABLE_NUMBERS_API=true` |
703
705
 
704
706
  The API clients also need `PROJECT_ID`, `PROJECT_ID_API_KEY` and `PROJECT_ID_API_SECRET`, which `sinch auth login` provides. A client whose variables are missing is `undefined` — except `context.voice`, which is always there and reports missing credentials when a request is actually sent. Full list: [SDK environment variables](https://developers.sinch.com/docs/functions/reference/sdk-env-vars).
705
707
 
@@ -22,7 +22,7 @@ import {
22
22
  require_express,
23
23
  secretsLoader,
24
24
  setupRequestHandler
25
- } from "../chunk-KGCIUPCT.js";
25
+ } from "../chunk-ZM72YQUN.js";
26
26
 
27
27
  // ../../node_modules/dotenv/package.json
28
28
  var require_package = __commonJS({
@@ -31261,8 +31261,8 @@ ${canonicalizedResource}`;
31261
31261
  }
31262
31262
  return true;
31263
31263
  };
31264
- var getHeader = (headerValue) => {
31265
- return Array.isArray(headerValue) ? headerValue[0] : headerValue;
31264
+ var getHeader = (headerValue2) => {
31265
+ return Array.isArray(headerValue2) ? headerValue2[0] : headerValue2;
31266
31266
  };
31267
31267
  }
31268
31268
  });
@@ -57144,7 +57144,7 @@ var require_websocket = __commonJS({
57144
57144
  var http3 = __require("http");
57145
57145
  var net = __require("net");
57146
57146
  var tls = __require("tls");
57147
- var { randomBytes: randomBytes2, createHash: createHash2 } = __require("crypto");
57147
+ var { randomBytes, createHash: createHash2 } = __require("crypto");
57148
57148
  var { Duplex, Readable: Readable3 } = __require("stream");
57149
57149
  var { URL: URL3 } = __require("url");
57150
57150
  var PerMessageDeflate = require_permessage_deflate();
@@ -57671,7 +57671,7 @@ var require_websocket = __commonJS({
57671
57671
  }
57672
57672
  }
57673
57673
  const defaultPort = isSecure ? 443 : 80;
57674
- const key = randomBytes2(16).toString("base64");
57674
+ const key = randomBytes(16).toString("base64");
57675
57675
  const request = isSecure ? https3.request : http3.request;
57676
57676
  const protocolSet = /* @__PURE__ */ new Set();
57677
57677
  let perMessageDeflate;
@@ -59783,6 +59783,12 @@ var MenuTemplates = {
59783
59783
 
59784
59784
  // ../runtime-shared/dist/storage/recording.js
59785
59785
  var RECORDING_RECEIVER_PATH = "/_sinch/recording/";
59786
+ function normalizeRecordingFormat(format) {
59787
+ const f = format.toLowerCase();
59788
+ if (f !== "mp3" && f !== "wav")
59789
+ throw new Error(`Unsupported recording format "${format}"`);
59790
+ return f;
59791
+ }
59786
59792
  function recordingKey(callId, format) {
59787
59793
  return `recordings/${callId.replace(/[^\w-]/g, "_")}.${format}`;
59788
59794
  }
@@ -63034,7 +63040,6 @@ function installStdioRedaction() {
63034
63040
  // ../runtime-shared/dist/security/voice-signature.js
63035
63041
  import { createHash, createHmac as createHmac2, timingSafeEqual as timingSafeEqual3 } from "crypto";
63036
63042
  var VOICE_TIMESTAMP_SKEW_MS = 5 * 60 * 1e3;
63037
- var VOICE_MISSING_SECRET_WARNING = "Voice v2 webhook not verified: VOICE_SERVICE_SECRET is not set. Deploying sets it from the voice service; redeploy to turn verification on";
63038
63043
  var AUTHORIZATION_PATTERN = /^service\s+([^:\s]+):(\S+)$/i;
63039
63044
  function fail(reason) {
63040
63045
  return { valid: false, reason };
@@ -63084,10 +63089,6 @@ function validateVoiceSignature(request, options) {
63084
63089
  }
63085
63090
  return { valid: true };
63086
63091
  }
63087
- var warnedMissingSecret = false;
63088
- function resetVoiceSignatureWarning() {
63089
- warnedMissingSecret = false;
63090
- }
63091
63092
  function verifyVoiceWebhook(request, options) {
63092
63093
  if (!shouldValidateWebhook(options.mode, options.isDevelopment)) {
63093
63094
  return { valid: true };
@@ -63095,11 +63096,7 @@ function verifyVoiceWebhook(request, options) {
63095
63096
  const env = options.env ?? process.env;
63096
63097
  const serviceSecret = env.VOICE_SERVICE_SECRET;
63097
63098
  if (!serviceSecret) {
63098
- if (!warnedMissingSecret) {
63099
- warnedMissingSecret = true;
63100
- console.warn(`[SECURITY] ${VOICE_MISSING_SECRET_WARNING}`);
63101
- }
63102
- return { valid: true };
63099
+ return fail("VOICE_SERVICE_SECRET is not set");
63103
63100
  }
63104
63101
  return validateVoiceSignature(request, {
63105
63102
  serviceSecret,
@@ -63108,6 +63105,50 @@ function verifyVoiceWebhook(request, options) {
63108
63105
  });
63109
63106
  }
63110
63107
 
63108
+ // ../runtime-shared/dist/security/conversation-signature.js
63109
+ import { createHmac as createHmac3, timingSafeEqual as timingSafeEqual4 } from "crypto";
63110
+ var SIGNATURE_HEADER = "x-sinch-webhook-signature";
63111
+ var NONCE_HEADER = "x-sinch-webhook-signature-nonce";
63112
+ var TIMESTAMP_HEADER = "x-sinch-webhook-signature-timestamp";
63113
+ function fail2(reason) {
63114
+ return { valid: false, reason };
63115
+ }
63116
+ function headerValue(headers, name) {
63117
+ const value = headers[name];
63118
+ return Array.isArray(value) ? value[0] : value;
63119
+ }
63120
+ function verifyConversationWebhook(request, options) {
63121
+ if (!shouldValidateWebhook(options.mode, options.isDevelopment)) {
63122
+ return { valid: true };
63123
+ }
63124
+ const env = options.env ?? process.env;
63125
+ const secret = env.CONVERSATION_WEBHOOK_SECRET;
63126
+ if (!secret) {
63127
+ return fail2("CONVERSATION_WEBHOOK_SECRET is not set");
63128
+ }
63129
+ const signature = headerValue(request.headers, SIGNATURE_HEADER);
63130
+ if (!signature) {
63131
+ return fail2(`${SIGNATURE_HEADER} header is missing`);
63132
+ }
63133
+ const nonce = headerValue(request.headers, NONCE_HEADER);
63134
+ if (!nonce) {
63135
+ return fail2(`${NONCE_HEADER} header is missing`);
63136
+ }
63137
+ const timestamp = headerValue(request.headers, TIMESTAMP_HEADER);
63138
+ if (!timestamp) {
63139
+ return fail2(`${TIMESTAMP_HEADER} header is missing`);
63140
+ }
63141
+ if (request.rawBody === void 0) {
63142
+ return fail2("raw body unavailable");
63143
+ }
63144
+ const expected = createHmac3("sha256", secret).update(`${request.rawBody}.${nonce}.${timestamp}`, "utf8").digest();
63145
+ const received = Buffer.from(signature, "base64");
63146
+ if (received.length !== expected.length || !timingSafeEqual4(received, expected)) {
63147
+ return fail2("signature mismatch");
63148
+ }
63149
+ return { valid: true };
63150
+ }
63151
+
63111
63152
  // ../runtime-shared/dist/sinch/index.js
63112
63153
  var import_sdk_core = __toESM(require_dist11(), 1);
63113
63154
  function createSinchClients() {
@@ -63319,6 +63360,7 @@ function getFaviconSvg() {
63319
63360
  var VOICE_V1_CALLBACKS = ["ice", "ace", "pie", "dice", "notify"];
63320
63361
  var NOTIFICATION_EVENTS = ["dice", "notify"];
63321
63362
  var VOICE_WEBHOOK_HANDLER = "voiceWebhook";
63363
+ var CONVERSATION_WEBHOOK_HANDLER = "conversationWebhook";
63322
63364
  var VOICE_EVENT_PREFIX = "call.";
63323
63365
  function isVoiceV1Callback(functionName) {
63324
63366
  return VOICE_V1_CALLBACKS.includes(functionName);
@@ -63332,10 +63374,12 @@ function isVoiceEvent(event) {
63332
63374
  function isVoiceWebhook(body) {
63333
63375
  return isVoiceEvent(body?.event);
63334
63376
  }
63377
+ var TUNNEL_VOICE_SIGNED_PATH_ENV = "SINCH_TUNNEL_VOICE_SIGNED_PATH";
63335
63378
  function buildVoiceSignedRequest(req) {
63379
+ const registered = process.env.SINCH_TUNNEL === "true" ? process.env[TUNNEL_VOICE_SIGNED_PATH_ENV] : void 0;
63336
63380
  return {
63337
63381
  method: req.method,
63338
- path: req.originalUrl.split("?")[0] || "/",
63382
+ path: registered || req.originalUrl.split("?")[0] || "/",
63339
63383
  contentType: req.headers["content-type"],
63340
63384
  timestamp: req.headers["x-timestamp"],
63341
63385
  authorization: req.headers.authorization,
@@ -63555,7 +63599,7 @@ async function handleVoiceWebhook(userFunction, context, event, request, logger)
63555
63599
  }
63556
63600
  async function rewriteRecordingSentinels(body, callId, storage) {
63557
63601
  const resolve = async (options) => {
63558
- if (!callId || !storage?.getRecordingDestination) {
63602
+ if (!callId || !(storage?.recordingUrl ?? storage?.getRecordingDestination)) {
63559
63603
  console.warn(`[recording] Dropping the recording command: ${callId ? "this storage cannot presign a recording destination" : "the event has no callId"}.`);
63560
63604
  return false;
63561
63605
  }
@@ -63565,7 +63609,7 @@ async function rewriteRecordingSentinels(body, callId, storage) {
63565
63609
  return false;
63566
63610
  }
63567
63611
  try {
63568
- options["destinationUrl"] = await storage.getRecordingDestination(callId, format);
63612
+ options["destinationUrl"] = await (storage.recordingUrl ? storage.recordingUrl(callId, format) : storage.getRecordingDestination(callId, format));
63569
63613
  return true;
63570
63614
  } catch (err) {
63571
63615
  console.warn("[recording] Dropping the recording command, presigning failed:", err);
@@ -63765,14 +63809,6 @@ function setupRequestHandler(app, options = {}) {
63765
63809
  return;
63766
63810
  }
63767
63811
  }
63768
- if (functionName === "conversationWebhook" && sinchClients.validateConversationWebhook) {
63769
- const isValid = sinchClients.validateConversationWebhook(req.headers, req.body);
63770
- if (!isValid) {
63771
- logger("[SECURITY] Conversation webhook signature validation failed");
63772
- res.status(401).json({ error: "Invalid webhook signature" });
63773
- return;
63774
- }
63775
- }
63776
63812
  }
63777
63813
  if (functionName === VOICE_WEBHOOK_HANDLER && isVoiceWebhook(req.body)) {
63778
63814
  const verdict = verifyVoiceWebhook(buildVoiceSignedRequest(req), {
@@ -63785,6 +63821,14 @@ function setupRequestHandler(app, options = {}) {
63785
63821
  return;
63786
63822
  }
63787
63823
  }
63824
+ if (functionName === CONVERSATION_WEBHOOK_HANDLER) {
63825
+ const verdict = verifyConversationWebhook({ headers: req.headers, rawBody: req.rawBody }, { mode: protectionMode, isDevelopment: isDev });
63826
+ if (!verdict.valid) {
63827
+ logger(`[SECURITY] Conversation webhook signature validation failed: ${verdict.reason}`);
63828
+ res.status(401).json({ error: "Invalid webhook signature" });
63829
+ return;
63830
+ }
63831
+ }
63788
63832
  onRequestStart({ functionName, req });
63789
63833
  const context = buildContext(req);
63790
63834
  const request = {
@@ -65629,7 +65673,7 @@ function createOpenAiAdapter(webSocketClient) {
65629
65673
  break;
65630
65674
  }
65631
65675
  case "session.delegation.created": {
65632
- const delegationId = msg["delegation_id"];
65676
+ const delegationId = msg["delegation"]?.id ?? msg["delegation_id"];
65633
65677
  if (delegationId)
65634
65678
  session.delegationCreatedAtMs.set(delegationId, Date.now());
65635
65679
  break;
@@ -67383,7 +67427,7 @@ function createResponsesWsSession(apiKey, baseUrl, factory2 = (key, url2) => new
67383
67427
  cleanup();
67384
67428
  resolve(result2);
67385
67429
  };
67386
- const fail2 = (err) => {
67430
+ const fail3 = (err) => {
67387
67431
  cleanup();
67388
67432
  reject(err instanceof Error ? err : new Error(String(err)));
67389
67433
  };
@@ -67392,14 +67436,14 @@ function createResponsesWsSession(apiKey, baseUrl, factory2 = (key, url2) => new
67392
67436
  clearTimeout(activeTimeout);
67393
67437
  activeTimeout = setTimeout(() => {
67394
67438
  failed = true;
67395
- fail2(new Error(`realtimeAgent: voice-relay provider WS ${label}`));
67439
+ fail3(new Error(`realtimeAgent: voice-relay provider WS ${label}`));
67396
67440
  ws.close();
67397
67441
  }, ms);
67398
67442
  };
67399
67443
  let producing = false;
67400
67444
  activeOnEvent = (event) => {
67401
67445
  if (event["type"] === "error") {
67402
- fail2(new Error(`realtimeAgent: voice-relay provider WS reported an error: ${JSON.stringify(event["error"] ?? event)}`));
67446
+ fail3(new Error(`realtimeAgent: voice-relay provider WS reported an error: ${JSON.stringify(event["error"] ?? event)}`));
67403
67447
  return;
67404
67448
  }
67405
67449
  if (!producing && (event["type"] === "response.output_text.delta" || event["type"] === "response.output_item.added")) {
@@ -67411,7 +67455,7 @@ function createResponsesWsSession(apiKey, baseUrl, factory2 = (key, url2) => new
67411
67455
  if (result2)
67412
67456
  done(result2);
67413
67457
  } catch (err) {
67414
- fail2(err);
67458
+ fail3(err);
67415
67459
  }
67416
67460
  };
67417
67461
  armTimeout(FIRST_OUTPUT_TIMEOUT_MS, "no output started");
@@ -68065,6 +68109,8 @@ function realtimeAgent(options) {
68065
68109
  const callConnectedAtMs = Date.now();
68066
68110
  let lastUserTurnAt;
68067
68111
  let firstAudioAtMs;
68112
+ let earlyRunStartAt;
68113
+ let lastAudioAt;
68068
68114
  const playout = createPlayoutTracker(PLAYOUT_GAP_MS);
68069
68115
  const untimedAgentEntries = [];
68070
68116
  let bytesPerMs = 8e3 * 2 / 1e3;
@@ -68208,6 +68254,10 @@ function realtimeAgent(options) {
68208
68254
  onAudioOut(pcm) {
68209
68255
  if (firstAudioAtMs === void 0 && lastUserTurnAt !== void 0)
68210
68256
  firstAudioAtMs = Date.now();
68257
+ const frameAt = Date.now();
68258
+ if (lastUserTurnAt === void 0 && (lastAudioAt === void 0 || frameAt - lastAudioAt > PLAYOUT_GAP_MS))
68259
+ earlyRunStartAt = frameAt;
68260
+ lastAudioAt = frameAt;
68211
68261
  const nowMs = Date.now();
68212
68262
  const speech = isSpeechFrame(pcm);
68213
68263
  if (speech)
@@ -68239,13 +68289,15 @@ function realtimeAgent(options) {
68239
68289
  flushPendingStreamLog();
68240
68290
  timeUntimedAgentEntries();
68241
68291
  lastUserTurnAt = Date.now();
68242
- firstAudioAtMs = void 0;
68292
+ firstAudioAtMs = earlyRunStartAt !== void 0 && lastAudioAt !== void 0 && Date.now() - lastAudioAt <= PLAYOUT_GAP_MS ? earlyRunStartAt : void 0;
68293
+ earlyRunStartAt = void 0;
68243
68294
  entry.speechStartAt = pendingSpeechStartAt;
68244
68295
  entry.speechEndAt = pendingSpeechEndAt;
68245
68296
  pendingSpeechStartAt = void 0;
68246
68297
  pendingSpeechEndAt = void 0;
68247
68298
  speechEndFromProvider = false;
68248
68299
  } else if (turn.role === "agent" && lastUserTurnAt !== void 0) {
68300
+ earlyRunStartAt = void 0;
68249
68301
  entry.totalMs = Date.now() - lastUserTurnAt;
68250
68302
  lastUserTurnAt = void 0;
68251
68303
  entry.delegationMs = turn.delegationMs;
@@ -68263,8 +68315,10 @@ function realtimeAgent(options) {
68263
68315
  currentAgentEntry = entry;
68264
68316
  pendingStreamLog = { entry, totalMs: entry.totalMs, firstAudioAtMs };
68265
68317
  }
68266
- } else if (turn.role === "agent")
68318
+ } else if (turn.role === "agent") {
68319
+ earlyRunStartAt = void 0;
68267
68320
  untimedAgentEntries.push(entry);
68321
+ }
68268
68322
  appendTranscript(entry);
68269
68323
  },
68270
68324
  onSpeechStart() {
@@ -71634,6 +71688,10 @@ var LocalStorage = class {
71634
71688
  }
71635
71689
  return url2;
71636
71690
  }
71691
+ /** The URL `recordToFunctions()` records to; see {@link IFunctionStorage.recordingUrl}. */
71692
+ async recordingUrl(callId, format = "mp3") {
71693
+ return this.getRecordingDestination(callId, normalizeRecordingFormat(format));
71694
+ }
71637
71695
  async write(key, data) {
71638
71696
  const filePath = this.resolvePath(key);
71639
71697
  await fs3.mkdir(path4.dirname(filePath), { recursive: true });
@@ -72438,8 +72496,8 @@ utils_default.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
72438
72496
  let mapped = key[0].toUpperCase() + key.slice(1);
72439
72497
  return {
72440
72498
  get: () => value,
72441
- set(headerValue) {
72442
- this[mapped] = headerValue;
72499
+ set(headerValue2) {
72500
+ this[mapped] = headerValue2;
72443
72501
  }
72444
72502
  };
72445
72503
  });
@@ -76121,7 +76179,6 @@ var {
76121
76179
 
76122
76180
  // src/tunnel/webhook-config.ts
76123
76181
  var import_sdk_core2 = __toESM(require_dist11(), 1);
76124
- import { randomBytes } from "crypto";
76125
76182
  import fs4 from "fs";
76126
76183
  import path5 from "path";
76127
76184
  var SINCH_FN_URL_PATTERN = /\.fn(-\w+)?\.sinch\.(?:com|io)/;
@@ -76185,20 +76242,15 @@ async function configureConversationWebhooks(webhookUrl, config) {
76185
76242
  config.conversationWebhookId = deployedWebhook.id;
76186
76243
  config.originalTarget = deployedWebhook.target;
76187
76244
  }
76188
- const hmacSecret = randomBytes(32).toString("hex");
76189
- process.env.CONVERSATION_WEBHOOK_SECRET = hmacSecret;
76190
- resetSinchClients();
76191
- configureSecretRedaction(process.env);
76192
76245
  await sinchClient.conversation.webhooks.update({
76193
76246
  webhook_id: deployedWebhook.id,
76194
76247
  webhookUpdateRequestBody: {
76195
- target: webhookUrl,
76196
- secret: hmacSecret
76248
+ target: webhookUrl
76197
76249
  },
76198
- update_mask: ["target", "secret"]
76250
+ update_mask: ["target"]
76199
76251
  });
76200
76252
  console.log(`\u2705 Updated Conversation webhook to tunnel: ${webhookUrl}`);
76201
- console.log("\u{1F512} HMAC secret configured for webhook signature validation");
76253
+ console.log("\u{1F512} Conversation webhook secret left as deployed");
76202
76254
  console.log("\u{1F4AC} Send a message to your Conversation app to test!");
76203
76255
  } catch (error) {
76204
76256
  console.log(
@@ -76241,8 +76293,6 @@ async function cleanupConversationWebhook(config) {
76241
76293
  console.log(`\u{1F504} Restored webhook target to: ${restoreTarget}`);
76242
76294
  config.conversationWebhookId = void 0;
76243
76295
  config.originalTarget = void 0;
76244
- delete process.env.CONVERSATION_WEBHOOK_SECRET;
76245
- resetSinchClients();
76246
76296
  } catch (error) {
76247
76297
  console.log(
76248
76298
  "\u26A0\uFE0F Could not restore Conversation webhook:",
@@ -76693,14 +76743,14 @@ var TunnelClient = class {
76693
76743
  timestampPart = ENCODING[t % 32] + timestampPart;
76694
76744
  t = Math.floor(t / 32);
76695
76745
  }
76696
- const randomBytes2 = new Uint8Array(10);
76697
- crypto.getRandomValues(randomBytes2);
76746
+ const randomBytes = new Uint8Array(10);
76747
+ crypto.getRandomValues(randomBytes);
76698
76748
  let randomPart = "";
76699
76749
  for (let i = 0; i < 10; i++) {
76700
- const byte = randomBytes2[i];
76750
+ const byte = randomBytes[i];
76701
76751
  randomPart += ENCODING[byte >> 3];
76702
76752
  if (randomPart.length < 16) {
76703
- randomPart += ENCODING[(byte & 7) << 2 | (i + 1 < 10 ? randomBytes2[i + 1] >> 6 : 0)];
76753
+ randomPart += ENCODING[(byte & 7) << 2 | (i + 1 < 10 ? randomBytes[i + 1] >> 6 : 0)];
76704
76754
  }
76705
76755
  }
76706
76756
  randomPart = randomPart.substring(0, 16);
@@ -76928,8 +76978,10 @@ var TunnelClient = class {
76928
76978
  ]);
76929
76979
  }
76930
76980
  async configureVoiceWebhooks() {
76981
+ const voiceWebhookUrl = this.buildTunnelUrl();
76982
+ process.env[TUNNEL_VOICE_SIGNED_PATH_ENV] = new URL(voiceWebhookUrl).pathname;
76931
76983
  await configureVoiceServiceWebhook(
76932
- this.buildTunnelUrl(),
76984
+ voiceWebhookUrl,
76933
76985
  process.env,
76934
76986
  globalThis.fetch,
76935
76987
  this.webhookConfig
@@ -77016,6 +77068,7 @@ var TunnelClient = class {
77016
77068
  async disconnect() {
77017
77069
  this.shuttingDown = true;
77018
77070
  delete process.env[TUNNEL_PUBLIC_URL_ENV];
77071
+ delete process.env[TUNNEL_VOICE_SIGNED_PATH_ENV];
77019
77072
  this.stopHeartbeat();
77020
77073
  this.streams.closeAll("Tunnel client shutting down");
77021
77074
  if (this.ws) {
@@ -77577,6 +77630,7 @@ export {
77577
77630
  createSimpleMenu,
77578
77631
  MenuTemplates,
77579
77632
  RECORDING_RECEIVER_PATH,
77633
+ normalizeRecordingFormat,
77580
77634
  recordingKey,
77581
77635
  UniversalConfig,
77582
77636
  createConfig,
@@ -77659,10 +77713,9 @@ export {
77659
77713
  safeCut,
77660
77714
  installStdioRedaction,
77661
77715
  VOICE_TIMESTAMP_SKEW_MS,
77662
- VOICE_MISSING_SECRET_WARNING,
77663
77716
  validateVoiceSignature,
77664
- resetVoiceSignatureWarning,
77665
77717
  verifyVoiceWebhook,
77718
+ verifyConversationWebhook,
77666
77719
  getSinchClients,
77667
77720
  resetSinchClients,
77668
77721
  getLandingPageHtml,
@@ -77670,9 +77723,11 @@ export {
77670
77723
  VOICE_V1_CALLBACKS,
77671
77724
  NOTIFICATION_EVENTS,
77672
77725
  VOICE_WEBHOOK_HANDLER,
77726
+ CONVERSATION_WEBHOOK_HANDLER,
77673
77727
  isVoiceV1Callback,
77674
77728
  isNotificationEvent,
77675
77729
  isVoiceWebhook,
77730
+ TUNNEL_VOICE_SIGNED_PATH_ENV,
77676
77731
  buildVoiceSignedRequest,
77677
77732
  extractFunctionName,
77678
77733
  generateRequestId,
@@ -78030,4 +78085,4 @@ serve-static/index.js:
78030
78085
  * MIT Licensed
78031
78086
  *)
78032
78087
  */
78033
- //# sourceMappingURL=chunk-KGCIUPCT.js.map
78088
+ //# sourceMappingURL=chunk-ZM72YQUN.js.map