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