@absolutejs/voice 0.0.22-beta.269 → 0.0.22-beta.270

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/index.d.ts CHANGED
@@ -161,12 +161,12 @@ export type { StoredVoiceIntegrationEvent, StoredVoiceExternalObjectMap, StoredV
161
161
  export { createTwilioMediaStreamBridge, createTwilioVoiceRoutes, createTwilioVoiceResponse, decodeTwilioMulawBase64, encodeTwilioMulawBase64, transcodePCMToTwilioOutboundPayload, transcodeTwilioInboundPayloadToPCM16 } from './telephony/twilio';
162
162
  export { evaluateVoiceTelephonyContract } from './telephony/contract';
163
163
  export { createTelnyxMediaStreamBridge, createTelnyxVoiceResponse, createTelnyxVoiceRoutes, verifyVoiceTelnyxWebhookSignature } from './telephony/telnyx';
164
- export { createPlivoMediaStreamBridge, createPlivoVoiceResponse, createPlivoVoiceRoutes, signVoicePlivoWebhook, verifyVoicePlivoWebhookSignature } from './telephony/plivo';
164
+ export { createMemoryVoicePlivoWebhookNonceStore, createPlivoMediaStreamBridge, createPlivoVoiceResponse, createPlivoVoiceRoutes, createVoicePlivoWebhookVerifier, signVoicePlivoWebhook, verifyVoicePlivoWebhookSignature } from './telephony/plivo';
165
165
  export { createVoiceTelephonyCarrierMatrix, createVoiceTelephonyCarrierMatrixRoutes, renderVoiceTelephonyCarrierMatrixHTML } from './telephony/matrix';
166
166
  export type { TwilioInboundMessage, TwilioMediaStreamBridge, TwilioMediaStreamBridgeOptions, TwilioMediaStreamSocket, TwilioOutboundClearMessage, TwilioOutboundMarkMessage, TwilioOutboundMediaMessage, TwilioOutboundMessage, TwilioVoiceRouteParameters, TwilioVoiceResponseOptions, TwilioVoiceSmokeCheck, TwilioVoiceSmokeOptions, TwilioVoiceSmokeReport, TwilioVoiceSetupOptions, TwilioVoiceSetupStatus, TwilioVoiceRoutesOptions } from './telephony/twilio';
167
167
  export type { VoiceTelephonyContractIssue, VoiceTelephonyContractOptions, VoiceTelephonyContractReport, VoiceTelephonyContractRequirement, VoiceTelephonyProvider, VoiceTelephonySetupStatus, VoiceTelephonySmokeCheck, VoiceTelephonySmokeReport } from './telephony/contract';
168
168
  export type { TelnyxInboundMessage, TelnyxMediaPayload, TelnyxMediaStreamBridge, TelnyxMediaStreamBridgeOptions, TelnyxMediaStreamSocket, TelnyxOutboundClearMessage, TelnyxOutboundMarkMessage, TelnyxOutboundMediaMessage, TelnyxOutboundMessage, TelnyxVoiceResponseOptions, TelnyxVoiceRoutesOptions, TelnyxVoiceSetupOptions, TelnyxVoiceSetupStatus, TelnyxVoiceSmokeCheck, TelnyxVoiceSmokeOptions, TelnyxVoiceSmokeReport } from './telephony/telnyx';
169
- export type { PlivoInboundMessage, PlivoMediaStreamBridge, PlivoMediaStreamBridgeOptions, PlivoMediaStreamSocket, PlivoOutboundCheckpointMessage, PlivoOutboundClearAudioMessage, PlivoOutboundMessage, PlivoOutboundPlayAudioMessage, PlivoVoiceResponseOptions, PlivoVoiceRoutesOptions, PlivoVoiceSetupOptions, PlivoVoiceSetupStatus, PlivoVoiceSmokeCheck, PlivoVoiceSmokeOptions, PlivoVoiceSmokeReport } from './telephony/plivo';
169
+ export type { PlivoInboundMessage, PlivoMediaStreamBridge, PlivoMediaStreamBridgeOptions, PlivoMediaStreamSocket, PlivoOutboundCheckpointMessage, PlivoOutboundClearAudioMessage, PlivoOutboundMessage, PlivoOutboundPlayAudioMessage, PlivoVoiceResponseOptions, PlivoVoiceRoutesOptions, PlivoVoiceSetupOptions, PlivoVoiceSetupStatus, PlivoVoiceSmokeCheck, PlivoVoiceSmokeOptions, PlivoVoiceSmokeReport, VoicePlivoWebhookNonceStore, VoicePlivoWebhookVerifierOptions } from './telephony/plivo';
170
170
  export type { VoiceTelephonyCarrierMatrix, VoiceTelephonyCarrierMatrixEntry, VoiceTelephonyCarrierMatrixInput, VoiceTelephonyCarrierMatrixOptions, VoiceTelephonyCarrierMatrixRoutesOptions, VoiceTelephonyCarrierMatrixStatus } from './telephony/matrix';
171
171
  export { shapeTelephonyAssistantText } from './telephony/response';
172
172
  export type { TelephonyResponseShapeMode, TelephonyResponseShapeOptions } from './telephony/response';
package/dist/index.js CHANGED
@@ -19122,6 +19122,40 @@ var verifyVoicePlivoWebhookSignature = async (input) => {
19122
19122
  });
19123
19123
  return signatures.some((signature) => timingSafeEqual2(signature, expected)) ? { ok: true } : { ok: false, reason: "invalid-signature" };
19124
19124
  };
19125
+ var createMemoryVoicePlivoWebhookNonceStore = () => {
19126
+ const nonces = new Set;
19127
+ return {
19128
+ has: (nonce) => nonces.has(nonce),
19129
+ set: (nonce) => {
19130
+ nonces.add(nonce);
19131
+ }
19132
+ };
19133
+ };
19134
+ var createVoicePlivoWebhookVerifier = (options) => async (input) => {
19135
+ const verificationUrl = options.verificationUrl;
19136
+ const verification = await verifyVoicePlivoWebhookSignature({
19137
+ authToken: options.authToken,
19138
+ body: input.body,
19139
+ headers: input.headers,
19140
+ url: typeof verificationUrl === "function" ? verificationUrl({
19141
+ query: input.query,
19142
+ request: input.request
19143
+ }) : verificationUrl ?? input.request.url
19144
+ });
19145
+ if (!verification.ok) {
19146
+ return verification;
19147
+ }
19148
+ const nonceStore = options.nonceStore;
19149
+ if (!nonceStore) {
19150
+ return verification;
19151
+ }
19152
+ const nonce = input.headers.get("x-plivo-signature-v3-nonce");
19153
+ if (!nonce || await nonceStore.has(nonce)) {
19154
+ return { ok: false, reason: "invalid-signature" };
19155
+ }
19156
+ await nonceStore.set(nonce);
19157
+ return verification;
19158
+ };
19125
19159
  var buildPlivoVoiceSetupStatus = async (options, input) => {
19126
19160
  const origin = resolveRequestOrigin2(input.request);
19127
19161
  const stream = await resolvePlivoStreamUrl(options, input);
@@ -19253,15 +19287,10 @@ var createPlivoVoiceRoutes = (options = {}) => {
19253
19287
  const smokePath = options.smoke?.path === false ? false : options.smoke?.path ?? "/api/voice/plivo/smoke";
19254
19288
  const bridges = new WeakMap;
19255
19289
  const webhookPolicy = options.webhook?.policy ?? options.outcomePolicy ?? createVoiceTelephonyOutcomePolicy();
19256
- const verificationUrl = options.webhook?.verificationUrl;
19257
- const verify = options.webhook?.verify ?? (options.webhook?.authToken ? (input) => verifyVoicePlivoWebhookSignature({
19258
- authToken: options.webhook?.authToken,
19259
- body: input.body,
19260
- headers: input.request.headers,
19261
- url: typeof verificationUrl === "function" ? verificationUrl({
19262
- query: input.query,
19263
- request: input.request
19264
- }) : verificationUrl ?? input.request.url
19290
+ const verify = options.webhook?.verify ?? (options.webhook?.authToken ? createVoicePlivoWebhookVerifier({
19291
+ authToken: options.webhook.authToken,
19292
+ nonceStore: options.webhook.nonceStore,
19293
+ verificationUrl: options.webhook.verificationUrl
19265
19294
  }) : undefined);
19266
19295
  const app = new Elysia30({
19267
19296
  name: options.name ?? "absolutejs-voice-plivo"
@@ -31678,6 +31707,7 @@ export {
31678
31707
  createVoicePostgresAuditSinkDeliveryStore,
31679
31708
  createVoicePostgresAuditEventStore,
31680
31709
  createVoicePostCallAnalysisRoutes,
31710
+ createVoicePlivoWebhookVerifier,
31681
31711
  createVoicePlivoCampaignDialer,
31682
31712
  createVoicePlatformCoverageRoutes,
31683
31713
  createVoicePhoneAgentProductionSmokeRoutes,
@@ -31820,6 +31850,7 @@ export {
31820
31850
  createOpenAIVoiceAssistantModel,
31821
31851
  createOpenAIRealtimeAdapter,
31822
31852
  createMemoryVoiceTelephonyWebhookIdempotencyStore,
31853
+ createMemoryVoicePlivoWebhookNonceStore,
31823
31854
  createJSONVoiceAssistantModel,
31824
31855
  createId,
31825
31856
  createGeminiVoiceAssistantModel,
@@ -131,6 +131,18 @@ export type PlivoVoiceSmokeOptions = {
131
131
  status?: string;
132
132
  title?: string;
133
133
  };
134
+ export type VoicePlivoWebhookNonceStore = {
135
+ has: (nonce: string) => Promise<boolean> | boolean;
136
+ set: (nonce: string) => Promise<void> | void;
137
+ };
138
+ export type VoicePlivoWebhookVerifierOptions = {
139
+ authToken?: string;
140
+ nonceStore?: VoicePlivoWebhookNonceStore;
141
+ verificationUrl?: string | ((input: {
142
+ query: Record<string, unknown>;
143
+ request: Request;
144
+ }) => string);
145
+ };
134
146
  export type PlivoVoiceRoutesOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
135
147
  answer?: {
136
148
  path?: string;
@@ -150,6 +162,7 @@ export type PlivoVoiceRoutesOptions<TContext = unknown, TSession extends VoiceSe
150
162
  streamPath?: string;
151
163
  webhook?: Omit<VoiceTelephonyWebhookRoutesOptions<TContext, TSession, TResult>, 'context' | 'path' | 'policy' | 'provider'> & {
152
164
  authToken?: string;
165
+ nonceStore?: VoicePlivoWebhookNonceStore;
153
166
  path?: string;
154
167
  policy?: VoiceTelephonyOutcomePolicy;
155
168
  verificationUrl?: string | ((input: {
@@ -172,6 +185,13 @@ export declare const verifyVoicePlivoWebhookSignature: (input: {
172
185
  headers: Headers;
173
186
  url: string;
174
187
  }) => Promise<VoiceTelephonyWebhookVerificationResult>;
188
+ export declare const createMemoryVoicePlivoWebhookNonceStore: () => VoicePlivoWebhookNonceStore;
189
+ export declare const createVoicePlivoWebhookVerifier: (options: VoicePlivoWebhookVerifierOptions) => (input: {
190
+ body: unknown;
191
+ headers: Headers;
192
+ query: Record<string, unknown>;
193
+ request: Request;
194
+ }) => Promise<VoiceTelephonyWebhookVerificationResult>;
175
195
  export declare const createPlivoVoiceRoutes: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(options?: PlivoVoiceRoutesOptions<TContext, TSession, TResult>) => Elysia<"", {
176
196
  decorator: {};
177
197
  store: {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.269",
3
+ "version": "0.0.22-beta.270",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",