@miguelmorales13/nestkit 0.31.3 → 0.32.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.
Files changed (59) hide show
  1. package/README.md +236 -0
  2. package/dist/chunk-2RQINZCR.cjs +17 -0
  3. package/dist/{chunk-LU3HO7B3.js → chunk-3WISEIHK.js} +4 -15
  4. package/dist/chunk-HMHUOXGB.cjs +63 -0
  5. package/dist/chunk-L2QK2HN5.js +17 -0
  6. package/dist/chunk-PBAPT3L5.js +63 -0
  7. package/dist/chunk-QVLTEABJ.cjs +248 -0
  8. package/dist/chunk-XKI3DJVA.js +248 -0
  9. package/dist/{chunk-33KFVAUZ.cjs → chunk-ZBOQKXGZ.cjs} +7 -18
  10. package/dist/index.cjs +2 -2
  11. package/dist/index.js +1 -1
  12. package/dist/payments/connect/terminal-connections.d.ts +7 -0
  13. package/dist/payments/index.cjs +36 -7
  14. package/dist/payments/index.js +31 -2
  15. package/dist/resilience/index.cjs +48 -262
  16. package/dist/resilience/index.js +19 -233
  17. package/dist/security/index.cjs +4 -2
  18. package/dist/security/index.js +5 -3
  19. package/dist/telephony/adapters/meta-whatsapp.telephony.d.ts +21 -0
  20. package/dist/telephony/adapters/simulated.telephony.d.ts +49 -0
  21. package/dist/telephony/adapters/twilio.telephony.d.ts +54 -0
  22. package/dist/telephony/index.cjs +2269 -0
  23. package/dist/telephony/index.d.ts +20 -0
  24. package/dist/telephony/index.js +2269 -0
  25. package/dist/telephony/provider-http.d.ts +35 -0
  26. package/dist/telephony/relay/access.d.ts +72 -0
  27. package/dist/telephony/relay/backend.d.ts +81 -0
  28. package/dist/telephony/relay/index.cjs +483 -0
  29. package/dist/telephony/relay/index.d.ts +9 -0
  30. package/dist/telephony/relay/index.js +483 -0
  31. package/dist/telephony/relay/server.d.ts +89 -0
  32. package/dist/telephony/relay/session.d.ts +100 -0
  33. package/dist/telephony/rules/call-limits.d.ts +48 -0
  34. package/dist/telephony/rules/call-token.d.ts +30 -0
  35. package/dist/telephony/rules/destination-policy.d.ts +21 -0
  36. package/dist/telephony/rules/dial-destination.d.ts +21 -0
  37. package/dist/telephony/rules/event-deduper.d.ts +15 -0
  38. package/dist/telephony/rules/handoff.d.ts +7 -0
  39. package/dist/telephony/rules/index.d.ts +20 -0
  40. package/dist/telephony/rules/opt-out.d.ts +32 -0
  41. package/dist/telephony/rules/phone.d.ts +9 -0
  42. package/dist/telephony/rules/provider-gate.d.ts +31 -0
  43. package/dist/telephony/rules/redact.d.ts +11 -0
  44. package/dist/telephony/rules/sanitize.d.ts +10 -0
  45. package/dist/telephony/rules/sliding-window.d.ts +10 -0
  46. package/dist/telephony/rules/ttl-cache.d.ts +14 -0
  47. package/dist/telephony/rules/usage-counter.d.ts +16 -0
  48. package/dist/telephony/telephony.errors.d.ts +46 -0
  49. package/dist/telephony/telephony.facade.d.ts +71 -0
  50. package/dist/telephony/telephony.module.d.ts +38 -0
  51. package/dist/telephony/telephony.options.d.ts +187 -0
  52. package/dist/telephony/telephony.port.d.ts +421 -0
  53. package/dist/telephony/telephony.registry.d.ts +24 -0
  54. package/dist/telephony/telephony.webhook.controller.d.ts +22 -0
  55. package/dist/telephony/telephony.webhooks.d.ts +53 -0
  56. package/dist/whatsapp/index.cjs +28 -0
  57. package/dist/whatsapp/index.js +28 -0
  58. package/dist/whatsapp/whatsapp-client.d.ts +5 -0
  59. package/package.json +12 -2
@@ -1,9 +1,23 @@
1
+ import {
2
+ ALERT_STORE,
3
+ DEFAULT_ERROR_CODE,
4
+ MemoryAlertStore,
5
+ ProviderUnavailableException,
6
+ RESILIENCE_OPTIONS,
7
+ configureRuntime,
8
+ fetchResiliente,
9
+ getRuntime,
10
+ registerAlerts,
11
+ resetRuntime,
12
+ resolveOptions,
13
+ retryDelay,
14
+ stripQuery,
15
+ withRetries
16
+ } from "../chunk-XKI3DJVA.js";
1
17
  import {
2
18
  ValidationAppException
3
19
  } from "../chunk-ZFIDAX7K.js";
4
- import {
5
- AppException
6
- } from "../chunk-M3GQDRWR.js";
20
+ import "../chunk-M3GQDRWR.js";
7
21
  import "../chunk-VVMRZEIW.js";
8
22
  import {
9
23
  __decorateClass,
@@ -21,119 +35,6 @@ import {
21
35
  } from "@nestjs/common";
22
36
  import { catchError, throwError } from "rxjs";
23
37
 
24
- // src/resilience/memory-alert-store.ts
25
- import { randomUUID } from "crypto";
26
- var MemoryAlertStore = class {
27
- constructor() {
28
- this.records = [];
29
- }
30
- async findOpen(key) {
31
- return this.records.find(
32
- (r) => r.resolvedAt === null && r.provider === key.provider && r.type === key.type && r.tenantId === (key.tenantId ?? null)
33
- ) ?? null;
34
- }
35
- async create(input) {
36
- const record = {
37
- id: randomUUID(),
38
- provider: input.provider,
39
- type: input.type,
40
- scope: input.scope,
41
- tenantId: input.tenantId,
42
- message: input.message,
43
- details: input.details,
44
- times: 1,
45
- firstAt: input.at,
46
- lastAt: input.at,
47
- notifiedAt: null,
48
- resolvedAt: null
49
- };
50
- this.records.push(record);
51
- return record;
52
- }
53
- async touch(id, patch) {
54
- const r = this.records.find((x) => x.id === id);
55
- if (!r) throw new Error(`Alerta ${id} no existe`);
56
- r.times += 1;
57
- r.lastAt = patch.at;
58
- r.message = patch.message;
59
- r.details = { ...r.details, ...patch.details ?? {} };
60
- return r;
61
- }
62
- async markNotified(id, at) {
63
- const r = this.records.find((x) => x.id === id);
64
- if (r) r.notifiedAt = at;
65
- }
66
- async listOpen(filter = {}) {
67
- return this.records.filter(
68
- (r) => r.resolvedAt === null && (!filter.provider || r.provider === filter.provider) && (!filter.tenantId || r.tenantId === filter.tenantId)
69
- ).sort((a, b) => b.lastAt.getTime() - a.lastAt.getTime());
70
- }
71
- async resolve(ids, at) {
72
- for (const r of this.records) if (ids.includes(r.id) && r.resolvedAt === null) r.resolvedAt = at;
73
- }
74
- async list(opts) {
75
- const limit = Math.min(opts.limit ?? 30, 100);
76
- const cursor = opts.cursor ? new Date(opts.cursor).getTime() : Infinity;
77
- const rows = this.records.filter((r) => (!opts.onlyOpen || r.resolvedAt === null) && r.lastAt.getTime() < cursor).sort((a, b) => b.lastAt.getTime() - a.lastAt.getTime());
78
- const items = rows.slice(0, limit);
79
- return { items, next: rows.length > limit ? items.at(-1).lastAt.toISOString() : null };
80
- }
81
- };
82
-
83
- // src/resilience/resilience.options.ts
84
- var RESILIENCE_OPTIONS = /* @__PURE__ */ Symbol("RESILIENCE_OPTIONS");
85
- var ALERT_STORE = /* @__PURE__ */ Symbol("ALERT_STORE");
86
- var DEFAULT_RETRYABLE_STATUS = [408, 425, 429, 500, 502, 503, 504];
87
- var DEFAULT_ERROR_CODE = "PROVIDER_UNAVAILABLE";
88
- var DEFAULT_BACKOFF = {
89
- baseMs: 400,
90
- factor: 2,
91
- maxMs: 3e4,
92
- jitterMs: 100
93
- };
94
- function defaultMessage(_provider, name, info) {
95
- const why = info.reason === "timeout" ? "tiempo agotado" : info.reason === "http" ? `HTTP ${info.status}` : "sin conexi\xF3n";
96
- return `${name} no responde (${why}). Intenta de nuevo en un momento.`;
97
- }
98
- function resolveOptions(options = {}) {
99
- const d = options.porDefecto ?? {};
100
- const a = options.alertas ?? {};
101
- return {
102
- proveedores: options.proveedores ?? {},
103
- porDefecto: {
104
- ...d,
105
- timeoutMs: d.timeoutMs ?? 15e3,
106
- reintentos: d.reintentos ?? 2,
107
- backoff: { ...DEFAULT_BACKOFF, ...d.backoff ?? {} }
108
- },
109
- alertas: {
110
- almacen: a.almacen ?? new MemoryAlertStore(),
111
- canales: a.canales ?? [],
112
- ventanaDedupeMs: a.ventanaDedupeMs ?? 30 * 6e4,
113
- topePorMinuto: a.topePorMinuto ?? 15,
114
- origen: a.origen ?? `api \xB7 ${process.env["NODE_ENV"] ?? "development"}`,
115
- interceptorGlobal: a.interceptorGlobal ?? false
116
- },
117
- rutaSalud: options.rutaSalud,
118
- salud: options.salud ?? {},
119
- codigoErrorProveedor: options.codigoErrorProveedor ?? DEFAULT_ERROR_CODE,
120
- mensajeProveedor: options.mensajeProveedor ?? defaultMessage
121
- };
122
- }
123
-
124
- // src/resilience/runtime.ts
125
- var current = { options: resolveOptions(), sink: null, notifier: null };
126
- var getRuntime = () => current;
127
- function configureRuntime(options) {
128
- current = { ...current, options };
129
- }
130
- function registerAlerts(sink, notifier) {
131
- current = { ...current, sink, notifier };
132
- }
133
- function resetRuntime() {
134
- current = { options: resolveOptions(), sink: null, notifier: null };
135
- }
136
-
137
38
  // src/resilience/alert-on-failure.decorator.ts
138
39
  function errorInfo(e) {
139
40
  if (e instanceof Error) return { name: e.name, message: e.message, stack: e.stack?.slice(0, 2500) };
@@ -385,7 +286,7 @@ import { timingSafeEqual } from "crypto";
385
286
  import {
386
287
  Controller,
387
288
  Get,
388
- Headers as Headers2,
289
+ Headers,
389
290
  Inject as Inject2,
390
291
  NotFoundException,
391
292
  Res,
@@ -454,7 +355,7 @@ function createProviderHealthController(path) {
454
355
  };
455
356
  __decorateClass([
456
357
  Get(),
457
- __decorateParam(0, Headers2()),
358
+ __decorateParam(0, Headers()),
458
359
  __decorateParam(1, Res({ passthrough: true }))
459
360
  ], ProviderHealthController.prototype, "health", 1);
460
361
  ProviderHealthController = __decorateClass([
@@ -528,121 +429,6 @@ ResilienceModule = __decorateClass([
528
429
  Module({})
529
430
  ], ResilienceModule);
530
431
 
531
- // src/resilience/provider-unavailable.exception.ts
532
- import { HttpStatus, Logger as Logger2 } from "@nestjs/common";
533
- var log = new Logger2("ProviderUnavailable");
534
- var ProviderUnavailableException = class extends AppException {
535
- constructor(provider, info) {
536
- const cfg = getRuntime().options;
537
- const name = cfg.proveedores[provider]?.nombre ?? provider;
538
- log.warn(
539
- `${provider} no disponible: ${info.reason} status=${info.status ?? "-"} url=${info.url} intentos=${info.attempts}${info.detail ? ` detalle=${info.detail}` : ""}`
540
- );
541
- super(
542
- cfg.codigoErrorProveedor,
543
- cfg.mensajeProveedor(provider, name, info),
544
- HttpStatus.BAD_GATEWAY,
545
- { provider, reason: info.reason, status: info.status, attempts: info.attempts }
546
- );
547
- this.provider = provider;
548
- }
549
- };
550
-
551
- // src/resilience/resilient-fetch.ts
552
- var SIDE_EFFECT_FREE = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
553
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
554
- function retryDelay(n, backoff, retryAfter) {
555
- const asked = retryAfter ? Number(retryAfter) * 1e3 : NaN;
556
- if (Number.isFinite(asked) && asked > 0) return Math.min(asked, backoff.maxMs);
557
- const wait = backoff.baseMs * backoff.factor ** n + Math.floor(Math.random() * (backoff.jitterMs + 1));
558
- return Math.min(wait, backoff.maxMs);
559
- }
560
- function hasIdempotencyHeader(headers) {
561
- if (!headers) return false;
562
- for (const k of new Headers(headers).keys()) if (/idempotency/i.test(k)) return true;
563
- return false;
564
- }
565
- function stripQuery(url) {
566
- try {
567
- const u = new URL(url);
568
- return `${u.origin}${u.pathname}`;
569
- } catch {
570
- return url.split("?")[0] ?? url;
571
- }
572
- }
573
- function fetchResiliente(o) {
574
- const resilient = async (input, init) => {
575
- const { options } = getRuntime();
576
- const cfg = options.proveedores[o.proveedor] ?? {};
577
- const def = options.porDefecto;
578
- const timeoutMs = o.timeoutMs ?? cfg.timeoutMs ?? def.timeoutMs;
579
- const retries = o.reintentos ?? cfg.reintentos ?? def.reintentos;
580
- const backoff = { ...def.backoff, ...cfg.backoff ?? {}, ...o.backoff ?? {} };
581
- const retryable = new Set(o.statusReintentables ?? cfg.statusReintentables ?? def.statusReintentables ?? DEFAULT_RETRYABLE_STATUS);
582
- const idempotent = o.idempotente ?? cfg.idempotente ?? def.idempotente ?? false;
583
- const doFetch = o.fetchImpl ?? fetch;
584
- const wait = o.sleep ?? sleep;
585
- const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
586
- const method = (init?.method ?? "GET").toUpperCase();
587
- const safe = SIDE_EFFECT_FREE.has(method) || idempotent || hasIdempotencyHeader(init?.headers);
588
- const sink = getRuntime().sink;
589
- for (let attempt = 0; ; attempt++) {
590
- const signal = init?.signal ? AbortSignal.any([init.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
591
- let res;
592
- try {
593
- res = await doFetch(input, { ...init, signal });
594
- } catch (e) {
595
- const err = e;
596
- if (init?.signal?.aborted) throw e;
597
- const reason = err.name === "TimeoutError" || err.name === "AbortError" ? "timeout" : "network";
598
- const info2 = {
599
- reason,
600
- attempts: attempt + 1,
601
- url: stripQuery(url),
602
- tenantId: o.tenantId,
603
- detail: err.message
604
- };
605
- if (safe && attempt < retries) {
606
- await wait(retryDelay(attempt, backoff));
607
- continue;
608
- }
609
- sink?.failure(o.proveedor, { ...info2, tenantId: void 0 });
610
- throw new ProviderUnavailableException(o.proveedor, info2);
611
- }
612
- if (retryable.has(res.status) && safe && attempt < retries) {
613
- await res.body?.cancel().catch(() => void 0);
614
- await wait(retryDelay(attempt, backoff, res.headers.get("retry-after")));
615
- continue;
616
- }
617
- const info = {
618
- reason: "http",
619
- status: res.status,
620
- attempts: attempt + 1,
621
- url: stripQuery(url),
622
- tenantId: o.tenantId
623
- };
624
- if (res.status >= 500 || res.status === 429) sink?.failure(o.proveedor, { ...info, tenantId: void 0 });
625
- else if (res.status === 401 || res.status === 403) sink?.credentials(o.proveedor, info);
626
- else sink?.success(o.proveedor);
627
- return res;
628
- }
629
- };
630
- return resilient;
631
- }
632
- async function withRetries(fn, isTransient, opts = {}) {
633
- const retries = opts.reintentos ?? getRuntime().options.porDefecto.reintentos;
634
- const backoff = { ...getRuntime().options.porDefecto.backoff, ...opts.backoff ?? {} };
635
- const wait = opts.sleep ?? sleep;
636
- for (let attempt = 0; ; attempt++) {
637
- try {
638
- return await fn();
639
- } catch (e) {
640
- if (!isTransient(e) || attempt >= retries) throw e;
641
- await wait(retryDelay(attempt, backoff));
642
- }
643
- }
644
- }
645
-
646
432
  // src/resilience/alert-channels.ts
647
433
  var WebhookAlertChannel = class {
648
434
  constructor(config) {
@@ -8,9 +8,11 @@
8
8
 
9
9
 
10
10
 
11
+ var _chunkZBOQKXGZcjs = require('../chunk-ZBOQKXGZ.cjs');
11
12
 
12
13
 
13
- var _chunk33KFVAUZcjs = require('../chunk-33KFVAUZ.cjs');
14
+
15
+ var _chunk2RQINZCRcjs = require('../chunk-2RQINZCR.cjs');
14
16
  require('../chunk-LRX7AMSS.cjs');
15
17
 
16
18
 
@@ -24,4 +26,4 @@ require('../chunk-LRX7AMSS.cjs');
24
26
 
25
27
 
26
28
 
27
- exports.constantTimeEqual = _chunk33KFVAUZcjs.constantTimeEqual; exports.hashSha256 = _chunk33KFVAUZcjs.hashSha256; exports.maskEmail = _chunk33KFVAUZcjs.maskEmail; exports.maskFields = _chunk33KFVAUZcjs.maskFields; exports.maskPhone = _chunk33KFVAUZcjs.maskPhone; exports.maskToken = _chunk33KFVAUZcjs.maskToken; exports.readState = _chunk33KFVAUZcjs.readState; exports.shapeOf = _chunk33KFVAUZcjs.shapeOf; exports.signGrant = _chunk33KFVAUZcjs.signGrant; exports.signState = _chunk33KFVAUZcjs.signState; exports.verifyGrant = _chunk33KFVAUZcjs.verifyGrant;
29
+ exports.constantTimeEqual = _chunk2RQINZCRcjs.constantTimeEqual; exports.hashSha256 = _chunk2RQINZCRcjs.hashSha256; exports.maskEmail = _chunkZBOQKXGZcjs.maskEmail; exports.maskFields = _chunkZBOQKXGZcjs.maskFields; exports.maskPhone = _chunkZBOQKXGZcjs.maskPhone; exports.maskToken = _chunkZBOQKXGZcjs.maskToken; exports.readState = _chunkZBOQKXGZcjs.readState; exports.shapeOf = _chunkZBOQKXGZcjs.shapeOf; exports.signGrant = _chunkZBOQKXGZcjs.signGrant; exports.signState = _chunkZBOQKXGZcjs.signState; exports.verifyGrant = _chunkZBOQKXGZcjs.verifyGrant;
@@ -1,6 +1,4 @@
1
1
  import {
2
- constantTimeEqual,
3
- hashSha256,
4
2
  maskEmail,
5
3
  maskFields,
6
4
  maskPhone,
@@ -10,7 +8,11 @@ import {
10
8
  signGrant,
11
9
  signState,
12
10
  verifyGrant
13
- } from "../chunk-LU3HO7B3.js";
11
+ } from "../chunk-3WISEIHK.js";
12
+ import {
13
+ constantTimeEqual,
14
+ hashSha256
15
+ } from "../chunk-L2QK2HN5.js";
14
16
  import "../chunk-D3DDJWUD.js";
15
17
  export {
16
18
  constantTimeEqual,
@@ -0,0 +1,21 @@
1
+ import type { MetaWhatsAppOptions } from '../telephony.options.js';
2
+ import { type TelephonyAdapter, type WebhooksPort, type WhatsAppPort } from '../telephony.port.js';
3
+ /**
4
+ * WhatsApp directo con la Cloud API de Meta, como **canal** del puerto de telefonía. Reutiliza el
5
+ * `WhatsAppClient` de `@miguelmorales13/nestkit/whatsapp` (no duplica el envío) y suma lo que le faltaba al puerto:
6
+ * firma `X-Hub-Signature-256`, reto de verificación y eventos normalizados (`whatsapp.recibido`, `whatsapp.estado`).
7
+ *
8
+ * Solo declara `whatsapp` (+ webhooks): úsalo con `channels: { whatsapp: 'meta-whatsapp' }` junto a otro proveedor de voz.
9
+ */
10
+ export declare class MetaWhatsAppTelephony implements TelephonyAdapter {
11
+ private readonly o;
12
+ readonly provider = "meta-whatsapp";
13
+ readonly portVersion = 1;
14
+ readonly whatsapp: WhatsAppPort;
15
+ readonly webhooks: WebhooksPort;
16
+ constructor(o: MetaWhatsAppOptions);
17
+ private info;
18
+ private buildWhatsApp;
19
+ private header;
20
+ private buildWebhooks;
21
+ }
@@ -0,0 +1,49 @@
1
+ import type { SimulatedTelephonyOptions } from '../telephony.options.js';
2
+ import { type CallInfo, type MessageInfo, type NumbersPort, type SmsPort, type TelephonyAdapter, type UsagePort, type VoicePort, type WebhookRequest, type WebhooksPort, type WhatsAppPort } from '../telephony.port.js';
3
+ /** Firma de un webhook simulado: HMAC-SHA256 hex de `url + "\n" + cuerpo`. */
4
+ export declare function simulatedSignature(url: string, rawBody: string, secret: string): string;
5
+ /**
6
+ * Proveedor en memoria para desarrollo y pruebas: cubre **todas** las capacidades, sin red. Pasa el mismo contrato que
7
+ * cualquier proveedor real, así que el código del consumidor se prueba contra él y se cambia a Twilio sin tocarlo.
8
+ *
9
+ * Además de implementar el puerto expone ayudas de prueba: `webhookFor(eventos)` arma una petición firmada,
10
+ * `completeCall` cierra una llamada con duración y `sentMessages`/`calls` dejan inspeccionar lo ocurrido.
11
+ */
12
+ export declare class SimulatedTelephony implements TelephonyAdapter {
13
+ private readonly o;
14
+ readonly provider: string;
15
+ readonly portVersion = 1;
16
+ readonly webhooks: WebhooksPort;
17
+ readonly numbers?: NumbersPort;
18
+ readonly voice?: VoicePort;
19
+ readonly sms?: SmsPort;
20
+ readonly whatsapp?: WhatsAppPort;
21
+ readonly usage?: UsagePort;
22
+ private readonly secret;
23
+ private readonly owned;
24
+ private readonly byKey;
25
+ private readonly callStore;
26
+ private readonly messageStore;
27
+ private inventory;
28
+ private seq;
29
+ private counter;
30
+ constructor(o?: SimulatedTelephonyOptions);
31
+ get calls(): CallInfo[];
32
+ get sentMessages(): MessageInfo[];
33
+ /** Cierra una llamada con duración, como lo haría el proveedor. */
34
+ completeCall(id: string, durationSeconds: number, status?: CallInfo['status']): CallInfo;
35
+ /** Una petición de webhook correctamente firmada con eventos normalizados (sin `provider`/`receivedAt`). */
36
+ webhookFor(events: Array<Record<string, unknown> & {
37
+ type: string;
38
+ id: string;
39
+ }>, url?: string): WebhookRequest;
40
+ private nextNumber;
41
+ private available;
42
+ private buildNumbers;
43
+ private buildVoice;
44
+ private message;
45
+ private buildSms;
46
+ private buildWhatsApp;
47
+ private buildUsage;
48
+ private buildWebhooks;
49
+ }
@@ -0,0 +1,54 @@
1
+ import { type TwilioOptions } from '../telephony.options.js';
2
+ import { type NumbersPort, type SmsPort, type TelephonyAdapter, type UsagePort, type VoicePort, type WebhooksPort, type WhatsAppPort } from '../telephony.port.js';
3
+ /**
4
+ * `X-Twilio-Signature`: HMAC-SHA1 en base64 de la URL completa a la que Twilio llamó, seguida de cada parámetro del
5
+ * formulario (nombre y valor pegados) en orden alfabético de nombre, con el Auth Token como llave.
6
+ */
7
+ export declare function twilioSignature(url: string, params: Record<string, string>, authToken: string): string;
8
+ export declare const escapeXml: (s: string) => string;
9
+ export declare const DIAL_CODES: Record<string, string>;
10
+ /**
11
+ * Twilio detrás del puerto de telefonía, por su API REST con `fetch` (sin SDK), con tiempo límite, reintentos,
12
+ * concurrencia y cortacircuito (`resilience` de nestkit). Soporta las cinco capacidades: números, voz, SMS, WhatsApp
13
+ * y uso.
14
+ *
15
+ * Los números de México exigen un *Regulatory Bundle* aprobado y una dirección: `bundleSid` y `addressSid`.
16
+ * Nada del proveedor se filtra: los errores salen como `TelephonyProviderException` con motivo estable.
17
+ */
18
+ export declare class TwilioTelephony implements TelephonyAdapter {
19
+ private readonly o;
20
+ readonly provider = "twilio";
21
+ readonly portVersion = 1;
22
+ readonly numbers: NumbersPort;
23
+ readonly voice: VoicePort;
24
+ readonly sms: SmsPort;
25
+ readonly whatsapp: WhatsAppPort;
26
+ readonly usage: UsagePort;
27
+ readonly webhooks: WebhooksPort;
28
+ private readonly http;
29
+ private readonly accountUrl;
30
+ private readonly cache;
31
+ private readonly priceCache;
32
+ constructor(o: TwilioOptions);
33
+ private auth;
34
+ private get;
35
+ private post;
36
+ private ok;
37
+ private acct;
38
+ /** `cursor` opaco = el `next_page_uri` de Twilio; solo se acepta si es de ESTA cuenta (no se puede apuntar a otra). */
39
+ private encodeCursor;
40
+ private decodeCursor;
41
+ private toPhoneNumber;
42
+ private buildNumbers;
43
+ private toCall;
44
+ private answer;
45
+ private buildVoice;
46
+ private toMessage;
47
+ private sendMessage;
48
+ private buildSms;
49
+ private buildWhatsApp;
50
+ private buildUsage;
51
+ private paramsOf;
52
+ private header;
53
+ private buildWebhooks;
54
+ }