@yaks/telnyx 0.0.0-stage → 0.2.36

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/mod.ts ADDED
@@ -0,0 +1,561 @@
1
+ // Telnyx: what its webhooks post, a sender over its HTTP API, and the
2
+ // commands and media stream of a call. Its
3
+ // webhooks are signed under @yaks/hook's `'telnyx'` scheme. The key is an argument; nothing here reads the environment.
4
+ // https://developers.telnyx.com/docs/messaging/messages/receiving-webhooks
5
+ // https://developers.telnyx.com/docs/messaging/messages/error-codes
6
+
7
+ import { lazy } from '@yaks/fp'
8
+ import { Unsent } from '@yaks/host/senders'
9
+ import {
10
+ Blocked,
11
+ type Caller,
12
+ Denied,
13
+ type Heard,
14
+ type Line,
15
+ type Numbers,
16
+ type Offer,
17
+ othersIn,
18
+ type Receipt,
19
+ type Sender,
20
+ type Text,
21
+ type TollFree,
22
+ type Verification,
23
+ } from '@yaks/phone'
24
+
25
+ /** Telnyx as data: its API, and the error codes that mean a carrier will not carry a text, in a person's words. */
26
+ export let TELNYX = {
27
+ api: 'https://api.telnyx.com/v2',
28
+ blocked: {
29
+ '40010':
30
+ 'Carriers will not carry texts from this number until its business texting registration is approved.',
31
+ '40300':
32
+ 'This person replied STOP, so carriers will not carry texts to them until they reply START.',
33
+ } as Record<string, string>,
34
+ }
35
+
36
+ /** How a Telnyx sender is made. */
37
+ export type Telnyx = {
38
+ /** the API key */
39
+ key: string
40
+ /** the messaging profile's name: its first number sends a text with no
41
+ * `from`, and an RCS text names the profile */
42
+ profile: string
43
+ /** send from the profile's toll-free number when it has one, the number
44
+ * a toll-free verification lets text before a 10DLC campaign is approved */
45
+ tollFree?: boolean
46
+ /** the API's base URL (default {@link TELNYX}.api) */
47
+ api?: string
48
+ fetch?: typeof fetch
49
+ }
50
+
51
+ // The toll-free area codes of the North American plan.
52
+ let free = (number: string) => /^\+18(00|33|44|55|66|77|88)\d{7}$/.test(number)
53
+
54
+ type Said = {
55
+ data?: Record<string, unknown> & { id?: string }
56
+ errors?: { code?: unknown; title?: string; detail?: string }[]
57
+ }
58
+
59
+ // Telnyx's API with a key: a POST when there is a body, a GET otherwise,
60
+ // unless `method` says.
61
+ // A refusal Telnyx lists in {@link TELNYX}.blocked rejects with
62
+ // {@link Blocked}; a 401 with {@link Denied}; a connection that failed, a 429
63
+ // or a 5xx with `Unsent`, since nothing was done; anything else with an Error
64
+ // carrying Telnyx's words.
65
+ let requester = (
66
+ { key, api = TELNYX.api, fetch: given }: Pick<
67
+ Telnyx,
68
+ 'key' | 'api' | 'fetch'
69
+ >,
70
+ ) =>
71
+ async (
72
+ path: string,
73
+ body?: unknown,
74
+ method = body ? 'POST' : 'GET',
75
+ ): Promise<Said> => {
76
+ let response
77
+ try {
78
+ // The global fetch as it is at the call, not as it was when this was made.
79
+ response = await (given ?? globalThis.fetch)(api + path, {
80
+ method,
81
+ headers: {
82
+ authorization: `Bearer ${key}`,
83
+ accept: 'application/json',
84
+ ...(body ? { 'content-type': 'application/json' } : {}),
85
+ },
86
+ ...(body ? { body: JSON.stringify(body) } : {}),
87
+ })
88
+ } catch (error) {
89
+ throw new Unsent(`Telnyx could not be reached: ${error}`)
90
+ }
91
+ let said = await response.json().catch(() => ({})) as Said
92
+ if (response.ok) return said
93
+ let error = said.errors?.[0]
94
+ let code = String(error?.code ?? '')
95
+ if (TELNYX.blocked[code]) throw new Blocked(TELNYX.blocked[code], code)
96
+ let words = `Telnyx answered ${response.status} to ${path}: ${
97
+ [code, error?.title, error?.detail].filter(Boolean).join(' ') ||
98
+ 'no reason given'
99
+ }`
100
+ if (response.status == 429 || response.status >= 500) {
101
+ throw new Unsent(words, 30_000)
102
+ }
103
+ if (response.status == 401) throw new Denied(words, code)
104
+ throw new Error(words)
105
+ }
106
+
107
+ // The id of the messaging profile named `profile`.
108
+ let profileOf = async (call: ReturnType<typeof requester>, profile: string) => {
109
+ let found = await call(
110
+ `/messaging_profiles?filter[name][eq]=${encodeURIComponent(profile)}`,
111
+ )
112
+ let id = String((found.data as unknown as { id: string }[])?.[0]?.id ?? '')
113
+ if (!id) throw new Error(`Telnyx has no messaging profile "${profile}"`)
114
+ return id
115
+ }
116
+
117
+ /**
118
+ * A {@link Sender} over Telnyx's messaging API. A text with an `agent` goes
119
+ * as RCS, falling back to SMS from `from` on a phone without it. Refusals
120
+ * reject as {@link requester} says.
121
+ */
122
+ export let telnyx = (
123
+ { key, profile, tollFree, api = TELNYX.api, fetch: given }: Telnyx,
124
+ ): Sender => {
125
+ let call = requester({ key, api, fetch: given })
126
+ // The profile and its number, asked until they answer and kept as values
127
+ // (@yaks/fp `lazy`): a client may serve many requests.
128
+ let ours = lazy(async () => {
129
+ let id = await profileOf(call, profile)
130
+ let numbers = await call(`/messaging_profiles/${id}/phone_numbers`)
131
+ let all = (numbers.data as unknown as { phone_number: string }[] ?? [])
132
+ .map((n) => n.phone_number).filter(Boolean)
133
+ let number = (tollFree ? all.find(free) : undefined) ?? all[0]
134
+ if (!number) throw new Error(`"${profile}" has no number on Telnyx`)
135
+ return { id, number }
136
+ })
137
+ return {
138
+ from: async () => (await ours()).number,
139
+ send: async ({ to, text, from, agent, group }: Text): Promise<Receipt> => {
140
+ let sender = from ?? (await ours()).number
141
+ // A group text goes to everyone in it as one MMS, from a long code
142
+ // only: Telnyx carries none on a toll-free number.
143
+ let said = group?.length
144
+ ? await call('/messages/group_mms', {
145
+ from: sender,
146
+ to: [to, ...group],
147
+ text,
148
+ })
149
+ : agent
150
+ ? await call('/messages/rcs', {
151
+ agent_id: agent,
152
+ to,
153
+ messaging_profile_id: (await ours()).id,
154
+ agent_message: { content_message: { text } },
155
+ // The fallback's shape is from Telnyx's RCS guide's prose; no
156
+ // example of it was found.
157
+ sms_fallback: { from: sender, text },
158
+ })
159
+ : await call('/messages', { from: sender, to, text })
160
+ return said.data?.id ? { id: String(said.data.id) } : {}
161
+ },
162
+ }
163
+ }
164
+
165
+ type Payload = {
166
+ id?: string
167
+ call_control_id?: string
168
+ direction?: string
169
+ type?: string
170
+ text?: string
171
+ body?: { text?: string; suggestion_response?: { text?: string } }
172
+ // A text names its numbers as objects, a call as strings.
173
+ from?: { phone_number?: string } | string
174
+ to?: { phone_number?: string; agent_id?: string; status?: string }[] | string
175
+ // Everyone in a group text, as numbers or as objects naming them.
176
+ cc?: (string | { phone_number?: string })[]
177
+ media?: { url?: string; content_type?: string }[]
178
+ received_at?: string
179
+ errors?: { code?: unknown; title?: string; detail?: string }[]
180
+ // A call's STIR/SHAKEN: the originating carrier's attestation of the
181
+ // caller's number (A, B or C), and whether its signature verified.
182
+ shaken_stir_attestation?: string
183
+ shaken_stir_validated?: boolean
184
+ }
185
+
186
+ let FAILED = ['sending_failed', 'delivery_failed']
187
+
188
+ /**
189
+ * What a Telnyx webhook says, once @yaks/hook finds it signed: a text that
190
+ * arrived (SMS, MMS or RCS), what became of one that left, or neither for
191
+ * any other event.
192
+ *
193
+ * ```ts
194
+ * import { equal } from '@yaks/testing'
195
+ * import { heard } from '@yaks/telnyx'
196
+ * let { arrival } = heard({
197
+ * data: {
198
+ * event_type: 'message.received',
199
+ * payload: {
200
+ * id: 'm1',
201
+ * type: 'SMS',
202
+ * text: 'Post the agenda',
203
+ * from: { phone_number: '+12695550142' },
204
+ * to: [{ phone_number: '+12695550100' }],
205
+ * received_at: '2026-11-04T00:00:00Z',
206
+ * },
207
+ * },
208
+ * })
209
+ * equal(arrival?.text, 'Post the agenda')
210
+ * equal(arrival?.rcs, false)
211
+ * ```
212
+ */
213
+ export let heard = (event: unknown): Heard => {
214
+ let data = (event as {
215
+ data?: { event_type?: string; occurred_at?: string; payload?: Payload }
216
+ })?.data
217
+ let p = data?.payload
218
+ let call = p?.call_control_id
219
+ if (call && data!.event_type == 'call.initiated') {
220
+ // A call this account places rings here too; only one that came in is
221
+ // somebody calling.
222
+ if (p!.direction != 'incoming') return {}
223
+ return {
224
+ ring: {
225
+ id: call,
226
+ from: String(p!.from ?? ''),
227
+ to: String(p!.to ?? ''),
228
+ at: data!.occurred_at ?? new Date().toISOString(),
229
+ // Only full attestation, verified, says the caller holds the number.
230
+ // Telnyx sends it only where the connection has SHAKEN/STIR on, and
231
+ // in lower case ("a", seen live 2026-11-20).
232
+ ...p!.shaken_stir_attestation?.toUpperCase() == 'A' &&
233
+ p!.shaken_stir_validated
234
+ ? { attested: true }
235
+ : {},
236
+ },
237
+ }
238
+ }
239
+ if (call && data!.event_type == 'call.hangup') return { ended: { id: call } }
240
+ if (!p?.id) return {}
241
+ if (data!.event_type == 'message.received') {
242
+ let rcs = p.type == 'RCS'
243
+ let to = (p.to as Exclude<Payload['to'], string>)?.[0]
244
+ let from = (p.from as { phone_number?: string })?.phone_number ?? ''
245
+ let at = (rcs ? to?.agent_id : to?.phone_number) ?? ''
246
+ let group = othersIn(
247
+ { from, to: at },
248
+ (p.cc ?? []).map((n) => typeof n == 'string' ? n : n.phone_number ?? ''),
249
+ )
250
+ return {
251
+ arrival: {
252
+ id: p.id,
253
+ from,
254
+ to: at,
255
+ ...group ? { group } : {},
256
+ text: p.text ?? p.body?.text ?? p.body?.suggestion_response?.text ??
257
+ '',
258
+ at: p.received_at ?? new Date().toISOString(),
259
+ rcs,
260
+ media: (p.media ?? []).flatMap((m) =>
261
+ m.url ? [{ url: m.url, type: m.content_type ?? '' }] : []
262
+ ),
263
+ },
264
+ }
265
+ }
266
+ if (data!.event_type == 'message.finalized') {
267
+ let status = (p.to as Exclude<Payload['to'], string>)?.[0]?.status ?? ''
268
+ if (!FAILED.includes(status)) return { outcome: { id: p.id } }
269
+ let error = p.errors?.[0]
270
+ let code = String(error?.code ?? '')
271
+ return {
272
+ outcome: {
273
+ id: p.id,
274
+ failed: {
275
+ code,
276
+ reason: TELNYX.blocked[code] ??
277
+ ([code, error?.title, error?.detail].filter(Boolean).join(' ') ||
278
+ status),
279
+ blocked: code in TELNYX.blocked,
280
+ },
281
+ },
282
+ }
283
+ }
284
+ return {}
285
+ }
286
+
287
+ /**
288
+ * Telnyx's Call Control commands for a call that rang on a number whose voice
289
+ * connection is a Call Control application. Answering streams the call's
290
+ * audio both ways over a WebSocket, as μ-law at 8 kHz, the telephone's own,
291
+ * so nothing is transcoded.
292
+ * https://developers.telnyx.com/docs/voice/programmable-voice/media-streaming
293
+ */
294
+ export let caller = (
295
+ o: Pick<Telnyx, 'key' | 'api' | 'fetch'>,
296
+ ): Caller => {
297
+ let call = requester(o)
298
+ let act = (id: string, action: string, body: object = {}) =>
299
+ call(`/calls/${encodeURIComponent(id)}/actions/${action}`, body)
300
+ .then(() => {})
301
+ return {
302
+ answer: (id, stream) =>
303
+ act(id, 'answer', {
304
+ stream_url: stream,
305
+ stream_track: 'inbound_track',
306
+ stream_bidirectional_mode: 'rtp',
307
+ stream_bidirectional_codec: 'PCMU',
308
+ }),
309
+ reject: (id) => act(id, 'reject', { cause: 'CALL_REJECTED' }),
310
+ hangup: (id) => act(id, 'hangup'),
311
+ }
312
+ }
313
+
314
+ let unbase64 = (s: string) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0))
315
+ let base64 = (bytes: Uint8Array) => {
316
+ let s = ''
317
+ for (let i = 0; i < bytes.length; i += 0x8000) {
318
+ s += String.fromCharCode(...bytes.subarray(i, i + 0x8000))
319
+ }
320
+ return btoa(s)
321
+ }
322
+
323
+ /**
324
+ * Telnyx's media stream: what its frames mean, and the frames that play
325
+ * audio to the caller, stop it, and mark where it ends.
326
+ *
327
+ * ```ts
328
+ * import { equal } from '@yaks/testing'
329
+ * import { line } from '@yaks/telnyx'
330
+ * equal(
331
+ * line.frame('{"event":"media","media":{"track":"inbound","payload":"AQI="}}'),
332
+ * { audio: new Uint8Array([1, 2]) },
333
+ * )
334
+ * equal(JSON.parse(line.play(new Uint8Array([1, 2]))), {
335
+ * event: 'media',
336
+ * media: { payload: 'AQI=' },
337
+ * })
338
+ * ```
339
+ */
340
+ export let line: Line = {
341
+ format: { encoding: 'mulaw', rate: 8000 },
342
+ // Telnyx lists an inbound minute at $0.002 plus its SIP trunking fee, and
343
+ // the media stream at $0.0035 a minute (telnyx.com/pricing/call-control,
344
+ // 2026-11-05); the trunking fee for a toll-free number is unlisted there,
345
+ // so this rounds up until an invoice says otherwise.
346
+ perMinute: 0.0125,
347
+ frame: (data) => {
348
+ let f: {
349
+ event?: string
350
+ start?: { call_control_id?: string }
351
+ media?: { track?: string; payload?: string }
352
+ mark?: { name?: string }
353
+ }
354
+ try {
355
+ f = JSON.parse(data)
356
+ } catch {
357
+ return {}
358
+ }
359
+ if (f.event == 'start') {
360
+ return { start: { call: String(f.start?.call_control_id ?? '') } }
361
+ }
362
+ if (f.event == 'media' && f.media?.payload && f.media.track != 'outbound') {
363
+ return { audio: unbase64(f.media.payload) }
364
+ }
365
+ if (f.event == 'stop') return { stop: true }
366
+ if (f.event == 'mark') return { played: String(f.mark?.name ?? '') }
367
+ return {}
368
+ },
369
+ play: (audio) =>
370
+ JSON.stringify({ event: 'media', media: { payload: base64(audio) } }),
371
+ clear: () => JSON.stringify({ event: 'clear' }),
372
+ mark: (name) => JSON.stringify({ event: 'mark', mark: { name } }),
373
+ }
374
+
375
+ // What Telnyx calls a toll-free verification's state, as @yaks/phone's.
376
+ let STATUS: Record<string, Verification['status']> = {
377
+ 'Verified': 'verified',
378
+ 'Rejected': 'rejected',
379
+ 'Waiting For Customer': 'needed',
380
+ }
381
+
382
+ type Request = {
383
+ id?: string
384
+ verificationStatus?: string
385
+ reason?: string | null
386
+ phoneNumbers?: { phoneNumber?: string }[]
387
+ }
388
+
389
+ // A verification request as Telnyx answers it, whole or under `data`.
390
+ let stands = (said: Said & Request): Verification => {
391
+ let r = (said.data ?? said) as Request
392
+ let word = r.verificationStatus ?? ''
393
+ return {
394
+ id: String(r.id ?? ''),
395
+ number: r.phoneNumbers?.[0]?.phoneNumber ?? '',
396
+ status: STATUS[word] ?? 'pending',
397
+ said: word,
398
+ ...(r.reason ? { reason: r.reason } : {}),
399
+ }
400
+ }
401
+
402
+ // A toll-free verification in Telnyx's fields
403
+ // (developers.telnyx.com, `TFVerificationRequest`).
404
+ let form = (f: TollFree) => {
405
+ let b = f.business
406
+ return {
407
+ businessName: b.name,
408
+ ...(b.dba ? { doingBusinessAs: b.dba } : {}),
409
+ corporateWebsite: b.website,
410
+ businessAddr1: b.address.street,
411
+ ...(b.address.street2 ? { businessAddr2: b.address.street2 } : {}),
412
+ businessCity: b.address.city,
413
+ businessState: b.address.state,
414
+ businessZip: b.address.zip,
415
+ entityType: b.entity.toUpperCase(),
416
+ ...(b.registration
417
+ ? {
418
+ businessRegistrationNumber: b.registration.number,
419
+ businessRegistrationType: b.registration.type,
420
+ businessRegistrationCountry: b.registration.country,
421
+ }
422
+ : {}),
423
+ businessContactFirstName: f.contact.first,
424
+ businessContactLastName: f.contact.last,
425
+ businessContactEmail: f.contact.email,
426
+ businessContactPhone: f.contact.phone,
427
+ messageVolume: f.volume,
428
+ phoneNumbers: [{ phoneNumber: f.number }],
429
+ useCase: f.useCase,
430
+ useCaseSummary: f.summary,
431
+ productionMessageContent: f.sample,
432
+ optInWorkflow: f.optIn,
433
+ optInWorkflowImageURLs: f.optInImages.map((url) => ({ url })),
434
+ additionalInformation: f.more ?? '',
435
+ ...(f.confirmation ? { optInConfirmationResponse: f.confirmation } : {}),
436
+ ...(f.help ? { helpMessageResponse: f.help } : {}),
437
+ ...(f.keywords ? { optInKeywords: f.keywords } : {}),
438
+ ...(f.privacy ? { privacyPolicyURL: f.privacy } : {}),
439
+ ...(f.terms ? { termsAndConditionURL: f.terms } : {}),
440
+ ...(f.reseller ? { isvReseller: f.reseller } : {}),
441
+ }
442
+ }
443
+
444
+ type Available = {
445
+ phone_number?: string
446
+ region_information?: { region_type?: string; region_name?: string }[]
447
+ cost_information?: {
448
+ upfront_cost?: string
449
+ monthly_cost?: string
450
+ currency?: string
451
+ }
452
+ features?: { name?: string }[]
453
+ }
454
+
455
+ /**
456
+ * Telnyx's numbers: its search of what is on offer, a number order onto the
457
+ * messaging profile `profile`, deleting a number to give it back, and its
458
+ * toll-free verification requests.
459
+ * https://developers.telnyx.com/docs/numbers/phone-numbers/number-orders
460
+ */
461
+ export let numbers = (
462
+ { key, profile, api, fetch: given }: Pick<
463
+ Telnyx,
464
+ 'key' | 'profile' | 'api' | 'fetch'
465
+ >,
466
+ ): Numbers => {
467
+ let call = requester({ key, api, fetch: given })
468
+ let held = async (number: string) => {
469
+ let found = await call(
470
+ `/phone_numbers?filter[phone_number]=${encodeURIComponent(number)}`,
471
+ )
472
+ let id = (found.data as unknown as { id?: string }[])?.[0]?.id
473
+ if (!id) throw new Error(`Telnyx holds no number ${number} here`)
474
+ return id
475
+ }
476
+ return {
477
+ find: async (s) => {
478
+ let q = new URLSearchParams({
479
+ 'filter[country_code]': s.country ?? 'US',
480
+ 'filter[features][]': 'sms',
481
+ 'filter[limit]': String(s.limit ?? 5),
482
+ })
483
+ if (s.tollFree) q.set('filter[phone_number_type]', 'toll_free')
484
+ if (s.area) q.set('filter[national_destination_code]', s.area)
485
+ if (s.region) q.set('filter[administrative_area]', s.region)
486
+ if (s.city) q.set('filter[locality]', s.city)
487
+ // Telnyx matches digits within the national number, so one number
488
+ // is found by its digits after the country code (+1 here).
489
+ let digits = s.number?.replace(/^\+1?/, '') ?? s.contains
490
+ if (digits) q.set('filter[phone_number][contains]', digits)
491
+ let said = await call(`/available_phone_numbers?${q}`)
492
+ return ((said.data ?? []) as unknown as Available[]).flatMap(
493
+ (n): Offer[] => {
494
+ let number = n.phone_number
495
+ if (!number || (s.number && number != s.number)) return []
496
+ let has = (f: string) => !!n.features?.some((x) => x.name == f)
497
+ let region = (t: string) =>
498
+ n.region_information?.find((r) => r.region_type == t)?.region_name
499
+ let place = [region('rate_center'), region('state')].filter(Boolean)
500
+ .join(', ')
501
+ return [{
502
+ ...place ? { place } : {},
503
+ number,
504
+ upfront: Number(n.cost_information?.upfront_cost ?? 0),
505
+ monthly: Number(n.cost_information?.monthly_cost ?? 0),
506
+ currency: n.cost_information?.currency ?? 'USD',
507
+ sms: has('sms'),
508
+ voice: has('voice'),
509
+ }]
510
+ },
511
+ )
512
+ },
513
+ buy: async (number) => {
514
+ let said = await call('/number_orders', {
515
+ phone_numbers: [{ phone_number: number }],
516
+ messaging_profile_id: await profileOf(call, profile),
517
+ })
518
+ let order = said.data as { id?: string; status?: string } | undefined
519
+ return {
520
+ number,
521
+ order: String(order?.id ?? ''),
522
+ status: order?.status == 'success' ? 'held' : 'pending',
523
+ }
524
+ },
525
+ release: async (number) => {
526
+ await call(`/phone_numbers/${await held(number)}`, undefined, 'DELETE')
527
+ },
528
+ verify: async (f) =>
529
+ stands(await call('/messaging_tollfree/verification/requests', form(f))),
530
+ verification: async (id) =>
531
+ stands(
532
+ await call(
533
+ `/messaging_tollfree/verification/requests/${encodeURIComponent(id)}`,
534
+ ),
535
+ ),
536
+ }
537
+ }
538
+
539
+ /** The transport plugged into @yaks/phone's provider boundary. */
540
+ export let provider: import('@yaks/phone').Provider = {
541
+ needs: ['key', 'profile'],
542
+ scheme: 'telnyx',
543
+ heard,
544
+ sender: (options) => {
545
+ if (!options.key || !options.profile) {
546
+ throw new Error('a telnyx sender needs `key` and `profile`')
547
+ }
548
+ return telnyx({ ...options, key: options.key, profile: options.profile })
549
+ },
550
+ caller: (options) => {
551
+ if (!options.key) throw new Error('a telnyx caller needs `key`')
552
+ return caller({ ...options, key: options.key })
553
+ },
554
+ line,
555
+ numbers: (options) => {
556
+ if (!options.key || !options.profile) {
557
+ throw new Error('telnyx numbers need `key` and `profile`')
558
+ }
559
+ return numbers({ ...options, key: options.key, profile: options.profile })
560
+ },
561
+ }
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@yaks/telnyx",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.36",
4
+ "homepage": "https://jsr.io/@yaks/telnyx",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./_dist/mod.d.ts",
9
+ "default": "./mod.js"
10
+ },
11
+ "./graph": {
12
+ "types": "./_dist/graph.d.ts",
13
+ "default": "./graph.js"
14
+ },
15
+ "./routes": {
16
+ "types": "./_dist/routes.d.ts",
17
+ "default": "./routes.js"
18
+ }
19
+ },
20
+ "license": "Apache-2.0",
21
+ "dependencies": {
22
+ "@yaks/fp": "0.2.36",
23
+ "@yaks/host": "0.2.36",
24
+ "@yaks/phone": "0.2.36"
25
+ },
26
+ "description": "Telnyx texting, calls and verified webhook events for @yaks/phone.",
27
+ "repository": "https://github.com/yak-sh/yak.git"
28
+ }
package/routes.js ADDED
@@ -0,0 +1,7 @@
1
+ // The `@yaks/telnyx/routes` facet: `POST /telnyx/webhook`, where telnyx
2
+ // posts texts that arrived and what became of those sent, verified with the
3
+ // `door.key` the config passes this plugin.
4
+ import { routes as doors } from "@yaks/phone/plugin";
5
+ import { provider } from "./mod.js";
6
+ export let routes = doors('telnyx', provider);
7
+ //# sourceMappingURL=routes.js.map
package/routes.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sources":["./routes.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,4CAA4C;AAC5C,SAAsB,UAAU,KAAK,kCAAuC;AAC5E,SAAS,QAAQ,mBAAkB;AAEnC,OAAO,IAAI,SAAiB,MAAM,UAAU,UAAS"}
package/routes.ts ADDED
@@ -0,0 +1,7 @@
1
+ // The `@yaks/telnyx/routes` facet: `POST /telnyx/webhook`, where telnyx
2
+ // posts texts that arrived and what became of those sent, verified with the
3
+ // `door.key` the config passes this plugin.
4
+ import { type Routes, routes as doors } from '@yaks/phone/plugin'
5
+ import { provider } from './mod.js'
6
+
7
+ export let routes: Routes = doors('telnyx', provider)