@superdurable/connector-twilio-messaging 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/dex-connector.json +82 -0
- package/dist/chunk-RO6VVVPT.js +145 -0
- package/dist/connection-DU3WOoJL.d.ts +140 -0
- package/dist/index.d.ts +155 -0
- package/dist/index.js +548 -0
- package/dist/mock.d.ts +60 -0
- package/dist/mock.js +137 -0
- package/package.json +60 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
GetMessageBranch,
|
|
5
|
+
GetMessageDefinition,
|
|
6
|
+
GetMessageInputSchema,
|
|
7
|
+
MessageSchema,
|
|
8
|
+
SendMessageBranch,
|
|
9
|
+
SendMessageDefinition,
|
|
10
|
+
SendMessageInputSchema,
|
|
11
|
+
decodeCredentials,
|
|
12
|
+
newConnection,
|
|
13
|
+
newConnectionWithOperations
|
|
14
|
+
} from "./chunk-RO6VVVPT.js";
|
|
15
|
+
|
|
16
|
+
// src/client.ts
|
|
17
|
+
import { AddressRefusal, BodyTooLargeError, MaxErrorBodyBytes, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, readErrorTokens, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
18
|
+
import { SecretString, resolveCredentialAfterRejection } from "@superdurable/connectors-sdk";
|
|
19
|
+
|
|
20
|
+
// src/operations.ts
|
|
21
|
+
import { newMutationBranch, newMutationRetry, newMutationUncertain, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
22
|
+
import { CheckpointError, Fence, InsufficientTimeError } from "@superdurable/connectors-sdk/singledispatch";
|
|
23
|
+
var messagePattern = /^(SM|MM)[0-9a-f]{32}$/;
|
|
24
|
+
function requestedMessage(client, to, sender) {
|
|
25
|
+
return {
|
|
26
|
+
accountSid: client.accountSid,
|
|
27
|
+
to,
|
|
28
|
+
createdAt: zeroMessage.createdAt,
|
|
29
|
+
sentAt: zeroMessage.sentAt,
|
|
30
|
+
updatedAt: zeroMessage.updatedAt,
|
|
31
|
+
...sender?.fromAddress ? { from: sender.fromAddress } : {},
|
|
32
|
+
...sender?.messagingServiceSid ? { messagingServiceSid: sender.messagingServiceSid } : {}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function rejection(operation, subject, status, code) {
|
|
36
|
+
const kind = status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : status === 404 ? "NOT_FOUND" : status === 409 ? "CONFLICT" : "PROVIDER_REJECTION";
|
|
37
|
+
return twilioFailure(operation, kind, `Twilio rejected the ${subject}${code > 0 ? ` with error ${code}` : ""}`);
|
|
38
|
+
}
|
|
39
|
+
var SendMessageOperation = class {
|
|
40
|
+
/** Bind one client. */
|
|
41
|
+
constructor(client) {
|
|
42
|
+
this.client = client;
|
|
43
|
+
}
|
|
44
|
+
client;
|
|
45
|
+
/** Stable manifest definition. */
|
|
46
|
+
definition() {
|
|
47
|
+
return SendMessageDefinition;
|
|
48
|
+
}
|
|
49
|
+
/** Receipt identity only; Twilio does not accept an idempotency header. */
|
|
50
|
+
idempotencyKey(callId) {
|
|
51
|
+
return callId;
|
|
52
|
+
}
|
|
53
|
+
/** Classify one fenced provider attempt. */
|
|
54
|
+
async invoke(call, input) {
|
|
55
|
+
let fence;
|
|
56
|
+
try {
|
|
57
|
+
fence = new Fence(call, SendMessageDefinition.stepDefaults.executeMethodTimeoutMs ?? 3e4);
|
|
58
|
+
} catch {
|
|
59
|
+
return newMutationBranch("defect", zeroMessage, {}, twilioFailure("sendMessage", "LOCAL_DEFECT", "Twilio dispatch fence could not be initialized"));
|
|
60
|
+
}
|
|
61
|
+
const decision = fence.decide();
|
|
62
|
+
let requested = requestedMessage(this.client, input.to?.trim() ?? "");
|
|
63
|
+
if (decision.kind === "failClosed") return newMutationUncertain(requested, twilioFailure("sendMessage", "TRANSPORT", "Twilio send checkpoint cannot confirm its outcome"), this.client.receipt(call));
|
|
64
|
+
if (decision.kind === "readBackRequired") {
|
|
65
|
+
const providerId = decision.marker?.providerId ?? "";
|
|
66
|
+
if (decision.marker?.callId !== call.id || !messagePattern.test(providerId)) return newMutationUncertain(requested, twilioFailure("sendMessage", "TRANSPORT", "Twilio send outcome cannot be confirmed"), this.client.receipt(call));
|
|
67
|
+
const auth2 = await this.client.authorization(call, "sendMessage");
|
|
68
|
+
if ("failure" in auth2) {
|
|
69
|
+
if (auth2.isTransient) return newMutationRetry(auth2.failure);
|
|
70
|
+
return newMutationUncertain(requested, twilioFailure("sendMessage", "AUTHENTICATION", "Twilio accepted message cannot be read; reconnect the connection"), this.client.receipt(call, void 0, providerId));
|
|
71
|
+
}
|
|
72
|
+
const exchange2 = await this.client.exchange(call, auth2.authorization, "GET", `${this.client.messagesURL}/${providerId}.json`);
|
|
73
|
+
if ("error" in exchange2 || exchange2.isBodyReadFailed || exchange2.response.status === 408 || exchange2.response.status === 429 || exchange2.response.status >= 500) return newMutationRetry(twilioFailure("sendMessage", "AVAILABILITY", "Twilio accepted message read-back is temporarily unavailable"));
|
|
74
|
+
if (exchange2.response.status !== 200 || exchange2.isTooLarge) return newMutationUncertain(requested, twilioFailure("sendMessage", "PROTOCOL", "Twilio accepted message could not be confirmed"), this.client.receipt(call, exchange2.response, providerId));
|
|
75
|
+
try {
|
|
76
|
+
const message = this.client.decodeMessage(exchange2.response.body, auth2.authorization);
|
|
77
|
+
if (message.sid !== providerId || message.to !== requested.to) throw new TypeError("read-back mismatch");
|
|
78
|
+
return newMutationBranch("accepted", message, this.client.receipt(call, exchange2.response, providerId));
|
|
79
|
+
} catch {
|
|
80
|
+
return newMutationUncertain(requested, twilioFailure("sendMessage", "PROTOCOL", "Twilio accepted message could not be confirmed"), this.client.receipt(call, exchange2.response, providerId));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let sendRequest;
|
|
84
|
+
try {
|
|
85
|
+
sendRequest = buildSendRequest(input, this.client.defaultSender);
|
|
86
|
+
} catch (cause) {
|
|
87
|
+
return newMutationBranch("defect", zeroMessage, {}, twilioFailure("sendMessage", "VALIDATION", cause instanceof Error ? cause.message : "invalid message"));
|
|
88
|
+
}
|
|
89
|
+
requested = requestedMessage(this.client, sendRequest.recipient, sendRequest.sender);
|
|
90
|
+
const auth = await this.client.authorization(call, "sendMessage");
|
|
91
|
+
if ("failure" in auth) {
|
|
92
|
+
try {
|
|
93
|
+
await fence.recordNotSent();
|
|
94
|
+
} catch {
|
|
95
|
+
return newMutationRetry(auth.failure);
|
|
96
|
+
}
|
|
97
|
+
return auth.isTransient ? newMutationRetry(auth.failure) : newMutationBranch("defect", zeroMessage, {}, auth.failure);
|
|
98
|
+
}
|
|
99
|
+
let exchange;
|
|
100
|
+
try {
|
|
101
|
+
exchange = await fence.dispatch((signal) => this.client.exchange(call, auth.authorization, "POST", `${this.client.messagesURL}.json`, sendRequest.form, signal));
|
|
102
|
+
} catch (cause) {
|
|
103
|
+
if (cause instanceof CheckpointError || cause instanceof InsufficientTimeError || cause instanceof AggregateError) return newMutationRetry(twilioFailure("sendMessage", "TRANSPORT", "Twilio dispatch checkpoint or attempt time is unavailable"));
|
|
104
|
+
return newMutationUncertain(requested, twilioFailure("sendMessage", "TRANSPORT", "Twilio message outcome is unknown"), this.client.receipt(call));
|
|
105
|
+
}
|
|
106
|
+
if ("error" in exchange) {
|
|
107
|
+
if (exchange.isProvablyNotSent) {
|
|
108
|
+
try {
|
|
109
|
+
await fence.recordCanResend();
|
|
110
|
+
} catch {
|
|
111
|
+
return newMutationRetry(twilioFailure("sendMessage", "TRANSPORT", "Twilio could not be reached and its dispatch checkpoint is unavailable"));
|
|
112
|
+
}
|
|
113
|
+
return newMutationRetry(twilioFailure("sendMessage", "TRANSPORT", "Twilio could not be reached, so no message was sent"));
|
|
114
|
+
}
|
|
115
|
+
return newMutationUncertain(requested, twilioFailure("sendMessage", "TRANSPORT", "Twilio message outcome is unknown"), this.client.receipt(call));
|
|
116
|
+
}
|
|
117
|
+
const response = exchange.response;
|
|
118
|
+
if (response.status >= 200 && response.status < 300) {
|
|
119
|
+
if (exchange.isTooLarge) return newMutationUncertain(requested, twilioFailure("sendMessage", "RESPONSE_TOO_LARGE", "Twilio accepted the request but its response exceeds the configured size limit"), this.client.receipt(call, response));
|
|
120
|
+
if (exchange.isBodyReadFailed) return newMutationUncertain(requested, twilioFailure("sendMessage", "TRANSPORT", "Twilio accepted the request but its response was interrupted"), this.client.receipt(call, response));
|
|
121
|
+
try {
|
|
122
|
+
const message = this.client.decodeMessage(response.body, auth.authorization);
|
|
123
|
+
try {
|
|
124
|
+
await fence.recordProviderId(message.sid ?? "");
|
|
125
|
+
} catch {
|
|
126
|
+
}
|
|
127
|
+
return newMutationBranch("accepted", message, this.client.receipt(call, response, message.sid));
|
|
128
|
+
} catch {
|
|
129
|
+
return newMutationUncertain(requested, twilioFailure("sendMessage", "PROTOCOL", "Twilio accepted the request but returned an unusable message"), this.client.receipt(call, response));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (response.status === 429 || response.status === 503) {
|
|
133
|
+
let checkpointFailed = false;
|
|
134
|
+
try {
|
|
135
|
+
await fence.recordCanResend();
|
|
136
|
+
} catch {
|
|
137
|
+
checkpointFailed = true;
|
|
138
|
+
}
|
|
139
|
+
const message = response.status === 429 ? `Twilio rate limited the message before creating it${checkpointFailed ? "; retry checkpoint is unavailable" : ""}` : checkpointFailed ? "Twilio service and retry checkpoint are temporarily unavailable" : "Twilio service is temporarily unavailable";
|
|
140
|
+
return newMutationRetry(twilioFailure("sendMessage", response.status === 429 ? "RATE_LIMIT" : "AVAILABILITY", message), retryAfter(response, this.client.currentTime()));
|
|
141
|
+
}
|
|
142
|
+
if (response.status === 401) {
|
|
143
|
+
const refreshed = await this.client.authorizationAfterRejection(call);
|
|
144
|
+
if ("authorization" in refreshed && (refreshed.authorization.username !== auth.authorization.username || refreshed.authorization.password !== auth.authorization.password)) {
|
|
145
|
+
try {
|
|
146
|
+
await fence.recordCanResend();
|
|
147
|
+
} catch {
|
|
148
|
+
return newMutationRetry(twilioFailure("sendMessage", "AUTHENTICATION", "Twilio credential changed but retry checkpoint is unavailable"));
|
|
149
|
+
}
|
|
150
|
+
return newMutationRetry(twilioFailure("sendMessage", "AUTHENTICATION", "Twilio credential changed after its rejection"));
|
|
151
|
+
}
|
|
152
|
+
const code = errorCode(response.body);
|
|
153
|
+
requested = { ...requested, ...code ? { errorCode: code } : {} };
|
|
154
|
+
return newMutationBranch("providerRejected", requested, this.client.receipt(call, response, "", code), twilioFailure("sendMessage", "AUTHENTICATION", "failure" in refreshed ? refreshed.failure.message : "Twilio rejected the message credentials; update the connection"));
|
|
155
|
+
}
|
|
156
|
+
if (response.status >= 400 && response.status < 500 && response.status !== 408 && response.status !== 409) {
|
|
157
|
+
const code = errorCode(response.body);
|
|
158
|
+
requested = { ...requested, ...code ? { errorCode: code } : {} };
|
|
159
|
+
return newMutationBranch("providerRejected", requested, this.client.receipt(call, response, "", code), rejection("sendMessage", "message", response.status, code));
|
|
160
|
+
}
|
|
161
|
+
return newMutationUncertain(requested, twilioFailure("sendMessage", "AVAILABILITY", "Twilio message outcome is unknown"), this.client.receipt(call, response));
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var GetMessageOperation = class {
|
|
165
|
+
/** Bind one client. */
|
|
166
|
+
constructor(client) {
|
|
167
|
+
this.client = client;
|
|
168
|
+
}
|
|
169
|
+
client;
|
|
170
|
+
/** Stable manifest definition. */
|
|
171
|
+
definition() {
|
|
172
|
+
return GetMessageDefinition;
|
|
173
|
+
}
|
|
174
|
+
/** Classify one provider read. */
|
|
175
|
+
async invoke(call, input) {
|
|
176
|
+
const sid = input.messageSid?.trim() ?? "";
|
|
177
|
+
if (!messagePattern.test(sid)) return newQueryBranch("defect", zeroMessage, {}, twilioFailure("getMessage", "VALIDATION", "message SID must be SM or MM followed by 32 lowercase hexadecimal characters"));
|
|
178
|
+
const auth = await this.client.authorization(call, "getMessage");
|
|
179
|
+
if ("failure" in auth) return auth.isTransient ? newQueryRetry(auth.failure) : newQueryBranch("defect", zeroMessage, {}, auth.failure);
|
|
180
|
+
const exchange = await this.client.exchange(call, auth.authorization, "GET", `${this.client.messagesURL}/${sid}.json`);
|
|
181
|
+
if ("error" in exchange) return newQueryRetry(twilioFailure("getMessage", "TRANSPORT", "Twilio message status is temporarily unavailable"));
|
|
182
|
+
const response = exchange.response;
|
|
183
|
+
if (response.status >= 200 && response.status < 300) {
|
|
184
|
+
if (exchange.isBodyReadFailed) return newQueryRetry(twilioFailure("getMessage", "TRANSPORT", "Twilio message response was interrupted"));
|
|
185
|
+
if (exchange.isTooLarge) return newQueryBranch("invalidResponse", zeroMessage, this.client.receipt(call, response, sid), twilioFailure("getMessage", "RESPONSE_TOO_LARGE", "Twilio message response exceeds the configured size limit"));
|
|
186
|
+
try {
|
|
187
|
+
const message = this.client.decodeMessage(response.body, auth.authorization);
|
|
188
|
+
if (message.sid !== sid) throw new TypeError("message SID mismatch");
|
|
189
|
+
return newQueryBranch("found", message, this.client.receipt(call, response, sid));
|
|
190
|
+
} catch {
|
|
191
|
+
return newQueryBranch("invalidResponse", zeroMessage, this.client.receipt(call, response, sid), twilioFailure("getMessage", "PROTOCOL", "Twilio returned an invalid message"));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (response.status === 404) return newQueryBranch("notFound", zeroMessage, this.client.receipt(call, response, sid, errorCode(response.body)), twilioFailure("getMessage", "NOT_FOUND", "Twilio has no message with that SID"));
|
|
195
|
+
if (response.status === 429) return newQueryRetry(twilioFailure("getMessage", "RATE_LIMIT", "Twilio rate limited the message query"), retryAfter(response, this.client.currentTime()));
|
|
196
|
+
if (response.status === 408 || response.status >= 500) return newQueryRetry(twilioFailure("getMessage", "AVAILABILITY", "Twilio message status is temporarily unavailable"));
|
|
197
|
+
if (response.status >= 400 && response.status < 500) {
|
|
198
|
+
const code = errorCode(response.body);
|
|
199
|
+
return newQueryBranch("providerRejected", zeroMessage, this.client.receipt(call, response, sid, code), rejection("getMessage", "message query", response.status, code));
|
|
200
|
+
}
|
|
201
|
+
return newQueryBranch("invalidResponse", zeroMessage, this.client.receipt(call, response, sid), twilioFailure("getMessage", "PROTOCOL", "Twilio returned an unexpected HTTP status"));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/client.ts
|
|
206
|
+
var accountPattern = /^AC[0-9a-f]{32}$/;
|
|
207
|
+
var keyPattern = /^SK[0-9a-f]{32}$/;
|
|
208
|
+
var messagePattern2 = /^(SM|MM)[0-9a-f]{32}$/;
|
|
209
|
+
var servicePattern = /^MG[0-9a-f]{32}$/;
|
|
210
|
+
var phonePattern = /^\+[1-9][0-9]{6,14}$/;
|
|
211
|
+
var zeroTime = "0001-01-01T00:00:00Z";
|
|
212
|
+
var defaultEndpoint = "https://api.twilio.com/2010-04-01";
|
|
213
|
+
var defaultMaxResponseBytes = 1048576;
|
|
214
|
+
var requestTimeoutMs = 2e4;
|
|
215
|
+
var staticCredentialRefresh = {
|
|
216
|
+
refreshRequired: () => false,
|
|
217
|
+
refresh: async () => {
|
|
218
|
+
throw new Error("Twilio credentials require manual rotation");
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
var TwilioClient = class {
|
|
222
|
+
/** Account SID used in the Messages path. */
|
|
223
|
+
accountSid;
|
|
224
|
+
/** Fully qualified Messages collection URL. */
|
|
225
|
+
messagesURL;
|
|
226
|
+
/** Optional default sender. */
|
|
227
|
+
defaultSender;
|
|
228
|
+
/** Maximum successful response size. */
|
|
229
|
+
maxResponseBytes;
|
|
230
|
+
credentials;
|
|
231
|
+
send;
|
|
232
|
+
now;
|
|
233
|
+
addressPolicy;
|
|
234
|
+
/** Validate config and retain provider dependencies. */
|
|
235
|
+
constructor(config, credentials, options = {}) {
|
|
236
|
+
const accountSid = config.accountSid?.trim();
|
|
237
|
+
if (!accountPattern.test(accountSid)) throw new TypeError("Twilio accountSid must be AC followed by 32 lowercase hexadecimal characters");
|
|
238
|
+
this.accountSid = accountSid;
|
|
239
|
+
const endpoint = validateBaseURL(config.endpoint || defaultEndpoint);
|
|
240
|
+
this.messagesURL = `${endpoint}/Accounts/${accountSid}/Messages`;
|
|
241
|
+
this.addressPolicy = "privateNetworkHTTP";
|
|
242
|
+
this.maxResponseBytes = config.maxResponseBytes || defaultMaxResponseBytes;
|
|
243
|
+
if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0) throw new TypeError("Twilio maxResponseBytes must be positive");
|
|
244
|
+
this.defaultSender = config.defaultSender?.trim() ? parseSender(config.defaultSender) : { fromAddress: "", messagingServiceSid: "" };
|
|
245
|
+
if (!credentials) throw new TypeError("credential provider is required");
|
|
246
|
+
this.credentials = credentials;
|
|
247
|
+
this.send = options.send ?? sendProviderRequest;
|
|
248
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
249
|
+
}
|
|
250
|
+
/** Bind the non-idempotent send mutation. */
|
|
251
|
+
sendMessage() {
|
|
252
|
+
return new SendMessageOperation(this);
|
|
253
|
+
}
|
|
254
|
+
/** Bind the message status query. */
|
|
255
|
+
getMessage() {
|
|
256
|
+
return new GetMessageOperation(this);
|
|
257
|
+
}
|
|
258
|
+
/** Resolve current credentials without leaking lookup errors. */
|
|
259
|
+
async authorization(call, operation) {
|
|
260
|
+
let credentials;
|
|
261
|
+
try {
|
|
262
|
+
credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
if (error instanceof Error && (error.name === "ReauthorizationRequiredError" || error.message.includes("reauthorization required"))) return { failure: twilioFailure(operation, "AUTHENTICATION", "Twilio connection credentials require reauthorization; reconnect the connection"), isTransient: false };
|
|
265
|
+
return { failure: twilioFailure(operation, "AVAILABILITY", "Twilio credential lookup is temporarily unavailable"), isTransient: true };
|
|
266
|
+
}
|
|
267
|
+
return this.validateAuthorization(credentials, operation);
|
|
268
|
+
}
|
|
269
|
+
/** Ask the credential host for a newer credential after a rejected send. */
|
|
270
|
+
async authorizationAfterRejection(call) {
|
|
271
|
+
let credentials;
|
|
272
|
+
try {
|
|
273
|
+
credentials = await resolveCredentialAfterRejection(this.credentials, call, staticCredentialRefresh, call.context.cancellationSignal);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
if (error instanceof TypeError && error.message.includes("does not support refresh")) return { failure: twilioFailure("sendMessage", "AUTHENTICATION", "Twilio credential cannot be refreshed after rejection"), isTransient: false };
|
|
276
|
+
if (error instanceof Error && error.name === "ReauthorizationRequiredError") return { failure: twilioFailure("sendMessage", "AUTHENTICATION", "Twilio connection credentials require reauthorization; reconnect the connection"), isTransient: false };
|
|
277
|
+
if (error instanceof Error && error.name === "RejectedCredentialNotRefreshedError") return { failure: twilioFailure("sendMessage", "AUTHENTICATION", "Twilio rejected the message credentials; update the connection"), isTransient: false };
|
|
278
|
+
return { failure: twilioFailure("sendMessage", "AVAILABILITY", "Twilio credential refresh is temporarily unavailable"), isTransient: true };
|
|
279
|
+
}
|
|
280
|
+
return this.validateAuthorization(credentials, "sendMessage");
|
|
281
|
+
}
|
|
282
|
+
validateAuthorization(credentials, operation) {
|
|
283
|
+
let username = "";
|
|
284
|
+
let password = "";
|
|
285
|
+
if (credentials.authMethodId === "auth-token" && credentials.authToken instanceof SecretString) {
|
|
286
|
+
username = this.accountSid;
|
|
287
|
+
password = credentials.authToken.reveal();
|
|
288
|
+
} else if (credentials.authMethodId === "api-key" && credentials.apiKeySecret instanceof SecretString) {
|
|
289
|
+
username = credentials.apiKeySid?.trim() ?? "";
|
|
290
|
+
password = credentials.apiKeySecret.reveal();
|
|
291
|
+
if (!keyPattern.test(username)) return { failure: twilioFailure(operation, "AUTHENTICATION", "Twilio api_key_sid must be SK followed by 32 lowercase hexadecimal characters"), isTransient: false };
|
|
292
|
+
} else return { failure: twilioFailure(operation, "AUTHENTICATION", "Twilio connection credentials are incomplete; update or reconnect the connection"), isTransient: false };
|
|
293
|
+
if (!isHeaderSafeCredential(password)) return { failure: twilioFailure(operation, "AUTHENTICATION", "Twilio credential secret is malformed"), isTransient: false };
|
|
294
|
+
return { authorization: { username, password } };
|
|
295
|
+
}
|
|
296
|
+
/** Send one request; only successful responses use the configured body limit. */
|
|
297
|
+
async exchange(call, authorization, method, url, form, signal) {
|
|
298
|
+
const body = form ? Buffer.from(encodeGoForm(form), "utf8") : void 0;
|
|
299
|
+
const request = {
|
|
300
|
+
url,
|
|
301
|
+
method,
|
|
302
|
+
headers: { Authorization: `Basic ${Buffer.from(`${authorization.username}:${authorization.password}`).toString("base64")}`, Accept: "application/json", ...body ? { "Content-Type": "application/x-www-form-urlencoded" } : {} },
|
|
303
|
+
...body ? { body } : {},
|
|
304
|
+
maxResponseBytes: Math.max(this.maxResponseBytes, MaxErrorBodyBytes),
|
|
305
|
+
addressPolicy: this.addressPolicy,
|
|
306
|
+
timeoutMs: requestTimeoutMs,
|
|
307
|
+
signal: signal ?? call.context.cancellationSignal
|
|
308
|
+
};
|
|
309
|
+
try {
|
|
310
|
+
const response = await this.send(request);
|
|
311
|
+
return { response, isTooLarge: response.status >= 200 && response.status < 300 && response.body.length > this.maxResponseBytes, isBodyReadFailed: false };
|
|
312
|
+
} catch (error) {
|
|
313
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0 && error.headers) {
|
|
314
|
+
if (error.status < 200 || error.status >= 300) return { response: { status: error.status, headers: error.headers, body: Buffer.alloc(0) }, isTooLarge: false, isBodyReadFailed: false };
|
|
315
|
+
return { response: { status: error.status, headers: error.headers, body: Buffer.alloc(0) }, isTooLarge: true, isBodyReadFailed: false };
|
|
316
|
+
}
|
|
317
|
+
const safe = error instanceof Error ? error : new Error("Twilio transport failed");
|
|
318
|
+
return { error: safe, isProvablyNotSent: error instanceof AddressRefusal || error instanceof ProviderTransportError && error.isProvablyNotSent };
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/** Decode a safe Twilio Message subset. */
|
|
322
|
+
decodeMessage(body, authorization) {
|
|
323
|
+
let resource;
|
|
324
|
+
const rawIntegerTokens = /* @__PURE__ */ new WeakMap();
|
|
325
|
+
const parseWithSource = JSON.parse;
|
|
326
|
+
try {
|
|
327
|
+
resource = parseWithSource(Buffer.from(body).toString("utf8"), function(key, value, context) {
|
|
328
|
+
if (key === "error_code" || key === "num_segments" || key === "num_media") {
|
|
329
|
+
let tokens = rawIntegerTokens.get(this);
|
|
330
|
+
if (!tokens) {
|
|
331
|
+
tokens = /* @__PURE__ */ new Map();
|
|
332
|
+
rawIntegerTokens.set(this, tokens);
|
|
333
|
+
}
|
|
334
|
+
tokens.set(key, context.source ?? "");
|
|
335
|
+
}
|
|
336
|
+
return value;
|
|
337
|
+
});
|
|
338
|
+
} catch {
|
|
339
|
+
throw new TypeError("Twilio returned an invalid message");
|
|
340
|
+
}
|
|
341
|
+
if (!resource || typeof resource !== "object" || Array.isArray(resource)) throw new TypeError("Twilio returned an invalid message");
|
|
342
|
+
const required = (key) => {
|
|
343
|
+
const value = resource[key];
|
|
344
|
+
if (typeof value !== "string") throw new TypeError("Twilio returned an invalid message");
|
|
345
|
+
return value;
|
|
346
|
+
};
|
|
347
|
+
const optional = (key) => {
|
|
348
|
+
const value = resource[key];
|
|
349
|
+
if (value == null) return "";
|
|
350
|
+
if (typeof value !== "string") throw new TypeError("Twilio returned an invalid message");
|
|
351
|
+
return value;
|
|
352
|
+
};
|
|
353
|
+
const sid = required("sid");
|
|
354
|
+
const accountSid = required("account_sid");
|
|
355
|
+
const to = required("to");
|
|
356
|
+
const status = required("status");
|
|
357
|
+
if (!messagePattern2.test(sid) || accountSid !== this.accountSid || !/^[a-z_]{1,32}$/.test(status) || !safeAddress(to)) throw new TypeError("Twilio returned an invalid message");
|
|
358
|
+
const service = optional("messaging_service_sid");
|
|
359
|
+
const from = optional("from");
|
|
360
|
+
const direction = optional("direction");
|
|
361
|
+
const price = optional("price");
|
|
362
|
+
const priceUnit = optional("price_unit");
|
|
363
|
+
if (service && !servicePattern.test(service) || from && !safeAddress(from)) throw new TypeError("Twilio returned an invalid message");
|
|
364
|
+
const message = {
|
|
365
|
+
sid,
|
|
366
|
+
accountSid,
|
|
367
|
+
to,
|
|
368
|
+
status,
|
|
369
|
+
createdAt: twilioTime(optional("date_created")),
|
|
370
|
+
sentAt: twilioTime(optional("date_sent")),
|
|
371
|
+
updatedAt: twilioTime(optional("date_updated")),
|
|
372
|
+
...service ? { messagingServiceSid: service } : {},
|
|
373
|
+
...from ? { from } : {},
|
|
374
|
+
.../^[a-z-]{1,32}$/.test(direction) ? { direction } : {},
|
|
375
|
+
.../^-?[0-9]{1,12}(\.[0-9]{1,12})?$/.test(price) ? { price } : {},
|
|
376
|
+
.../^[A-Z]{3}$/.test(priceUnit) ? { priceUnit } : {}
|
|
377
|
+
};
|
|
378
|
+
for (const [key, target] of [["error_code", "errorCode"], ["num_segments", "segmentCount"], ["num_media", "mediaCount"]]) {
|
|
379
|
+
const value = resource[key];
|
|
380
|
+
if (value !== null && value !== void 0) {
|
|
381
|
+
const decimalText = typeof value === "number" ? rawIntegerTokens.get(resource)?.get(key) : value;
|
|
382
|
+
if (typeof value !== "string" && typeof value !== "number" || value !== "" && !/^[0-9]{1,9}$/.test(String(decimalText))) throw new TypeError("Twilio returned an invalid message");
|
|
383
|
+
const count = Number(value);
|
|
384
|
+
if (count !== 0) message[target] = count;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if ([message.sid, message.accountSid, message.messagingServiceSid, message.from, message.to, message.status, message.direction, message.price, message.priceUnit].some((value) => value !== void 0 && value.includes(authorization.password))) throw new TypeError("Twilio returned an invalid message");
|
|
388
|
+
return message;
|
|
389
|
+
}
|
|
390
|
+
/** Make a safe receipt with exact provider IDs. */
|
|
391
|
+
receipt(call, response, objectId = "", errorCode2 = 0) {
|
|
392
|
+
const raw = response?.headers["twilio-request-id"];
|
|
393
|
+
const requestId = Array.isArray(raw) ? raw[0] : raw;
|
|
394
|
+
return {
|
|
395
|
+
callId: call.id,
|
|
396
|
+
idempotencyKey: call.idempotencyKey ?? "",
|
|
397
|
+
provider: "twilio",
|
|
398
|
+
observedAt: this.now().toISOString(),
|
|
399
|
+
...objectId ? { providerObjectId: objectId } : {},
|
|
400
|
+
...requestId && safeAddress(requestId) ? { providerRequestId: requestId } : {},
|
|
401
|
+
...errorCode2 > 0 ? { metadata: { twilioErrorCode: String(errorCode2) } } : {}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
/** Current receipt time for Retry-After. */
|
|
405
|
+
currentTime() {
|
|
406
|
+
return this.now();
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
function twilioFailure(operation, kind, message) {
|
|
410
|
+
return { kind, provider: "twilio", operation, message };
|
|
411
|
+
}
|
|
412
|
+
function parseSender(value) {
|
|
413
|
+
const sender = value.trim();
|
|
414
|
+
if (servicePattern.test(sender)) return { fromAddress: "", messagingServiceSid: sender };
|
|
415
|
+
if (phonePattern.test(sender) || isWhatsApp(sender)) return { fromAddress: sender, messagingServiceSid: "" };
|
|
416
|
+
throw new TypeError("sender must be an E.164 phone number, a whatsapp:+E.164 address, or an MG Messaging Service SID");
|
|
417
|
+
}
|
|
418
|
+
function isWhatsApp(value) {
|
|
419
|
+
return value.startsWith("whatsapp:") && phonePattern.test(value.slice(9));
|
|
420
|
+
}
|
|
421
|
+
function buildSendRequest(input, defaultSender) {
|
|
422
|
+
const recipient = input.to.trim();
|
|
423
|
+
const isWhatsAppRecipient = isWhatsApp(recipient);
|
|
424
|
+
if (!phonePattern.test(recipient) && !isWhatsAppRecipient) throw new TypeError("recipient must be an E.164 phone number or a whatsapp:+E.164 address");
|
|
425
|
+
const sender = input.sender?.trim() ? parseSender(input.sender) : defaultSender;
|
|
426
|
+
if (!sender.fromAddress && !sender.messagingServiceSid) throw new TypeError("sender is required: set defaultSender on the connection or sender on the input");
|
|
427
|
+
if (sender.fromAddress && isWhatsApp(sender.fromAddress) !== isWhatsAppRecipient) throw new TypeError("sender and recipient must both be whatsapp: addresses or both be phone numbers");
|
|
428
|
+
const body = input.body ?? "";
|
|
429
|
+
const media = input.mediaUrls ?? [];
|
|
430
|
+
if ([...body].length > 1600) throw new TypeError("body cannot exceed 1600 characters");
|
|
431
|
+
if (!body.trim() && media.length === 0) throw new TypeError("body or at least one media URL is required");
|
|
432
|
+
if (media.length > 10) throw new TypeError("at most 10 media URLs are allowed");
|
|
433
|
+
const form = new URLSearchParams();
|
|
434
|
+
if (body) form.append("Body", body);
|
|
435
|
+
if (sender.fromAddress) form.append("From", sender.fromAddress);
|
|
436
|
+
else form.append("MessagingServiceSid", sender.messagingServiceSid);
|
|
437
|
+
for (const value of media) {
|
|
438
|
+
validateMediaURL(value);
|
|
439
|
+
form.append("MediaUrl", value);
|
|
440
|
+
}
|
|
441
|
+
form.append("To", recipient);
|
|
442
|
+
form.sort();
|
|
443
|
+
return { recipient, sender, form };
|
|
444
|
+
}
|
|
445
|
+
function encodeGoForm(form) {
|
|
446
|
+
const queryEscape = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g, "+");
|
|
447
|
+
return [...form].map(([key, value]) => `${queryEscape(key)}=${queryEscape(value)}`).join("&");
|
|
448
|
+
}
|
|
449
|
+
function validateMediaURL(value) {
|
|
450
|
+
if (Buffer.byteLength(value) > 2048 || !/^[!-~]+$/.test(value)) throw new TypeError("media URLs must be printable ASCII without spaces and at most 2048 bytes");
|
|
451
|
+
if (!/^https:\/\/[^/?#@\\]+(?:[/?#]|$)/.test(value)) throw new TypeError("media URLs must be absolute HTTPS URLs without credentials");
|
|
452
|
+
let parsed;
|
|
453
|
+
try {
|
|
454
|
+
parsed = new URL(value);
|
|
455
|
+
} catch {
|
|
456
|
+
throw new TypeError("media URLs must be absolute HTTPS URLs without credentials");
|
|
457
|
+
}
|
|
458
|
+
if (parsed.protocol !== "https:" || !parsed.hostname || parsed.username || parsed.password) throw new TypeError("media URLs must be absolute HTTPS URLs without credentials");
|
|
459
|
+
}
|
|
460
|
+
function safeAddress(value) {
|
|
461
|
+
return Buffer.byteLength(value) > 0 && Buffer.byteLength(value) <= 64 && /^[\x20-\x7e]+$/.test(value);
|
|
462
|
+
}
|
|
463
|
+
function twilioTime(value) {
|
|
464
|
+
const parts = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) ([+-])(\d{2})(\d{2})$/.exec(value);
|
|
465
|
+
if (!parts) return zeroTime;
|
|
466
|
+
const [, dayText, monthText, yearText, hourText, minuteText, secondText, sign, offsetHourText, offsetMinuteText] = parts;
|
|
467
|
+
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
468
|
+
const year = Number(yearText), month = months.indexOf(monthText ?? ""), day = Number(dayText), hour = Number(hourText), minute = Number(minuteText), second = Number(secondText);
|
|
469
|
+
const offsetHours = Number(offsetHourText), offsetMinutes = Number(offsetMinuteText);
|
|
470
|
+
const monthEnd = /* @__PURE__ */ new Date(0);
|
|
471
|
+
monthEnd.setUTCFullYear(year, month + 1, 0);
|
|
472
|
+
const daysInMonth = monthEnd.getUTCDate();
|
|
473
|
+
if (day < 1 || day > daysInMonth || hour > 23 || minute > 59 || second > 59 || offsetMinutes > 59) return zeroTime;
|
|
474
|
+
const instant = /* @__PURE__ */ new Date(0);
|
|
475
|
+
instant.setUTCFullYear(year, month, day);
|
|
476
|
+
instant.setUTCHours(hour, minute, second, 0);
|
|
477
|
+
const offset = (offsetHours * 60 + offsetMinutes) * 6e4;
|
|
478
|
+
const adjusted = new Date(instant.getTime() + (sign === "+" ? -offset : offset));
|
|
479
|
+
return adjusted.toISOString().replace(".000Z", "Z");
|
|
480
|
+
}
|
|
481
|
+
function errorCode(body) {
|
|
482
|
+
const value = readErrorTokens(body, ["/code"])[0];
|
|
483
|
+
return value && /^[0-9]{1,9}$/.test(value) ? Number(value) : 0;
|
|
484
|
+
}
|
|
485
|
+
function retryAfter(response, now) {
|
|
486
|
+
const raw = response.headers["retry-after"];
|
|
487
|
+
return parseRetryAfter(Array.isArray(raw) ? raw[0] ?? "" : raw ?? "", now);
|
|
488
|
+
}
|
|
489
|
+
var zeroMessage = { accountSid: "", to: "", createdAt: zeroTime, sentAt: zeroTime, updatedAt: zeroTime };
|
|
490
|
+
|
|
491
|
+
// src/project.ts
|
|
492
|
+
import { newCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
|
|
493
|
+
import { z } from "zod";
|
|
494
|
+
function newConnection2(client, name) {
|
|
495
|
+
return newConnection(client, { provider: "twilio", name });
|
|
496
|
+
}
|
|
497
|
+
function newProjectConnection(project, connectionName, options = {}) {
|
|
498
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === "twilio-messaging" && entry.connectionName === connectionName);
|
|
499
|
+
if (!selected || selected.provider !== "twilio") throw new TypeError("Twilio project connection is not configured");
|
|
500
|
+
const settings = z.object({ accountSid: z.string(), defaultSender: z.string().optional(), endpoint: z.string().optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
501
|
+
const config = ConfigSchema.parse(settings);
|
|
502
|
+
const credentialProvider = newCredentialProvider(project.connections, { connectorId: "twilio-messaging", connectionName }, decodeCredentials);
|
|
503
|
+
return newConnection2(new TwilioClient(config, credentialProvider, options), connectionName);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/generated/steps.ts
|
|
507
|
+
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
508
|
+
function newSendMessageStep(configuration) {
|
|
509
|
+
const { connection, connectionName, accepted, providerRejected, uncertain, defect, ...stepConfiguration } = configuration;
|
|
510
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
511
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.sendMessage(), connection: connection.reference, branches: [
|
|
512
|
+
goToBranch("accepted", accepted),
|
|
513
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
514
|
+
...uncertain ? [goToBranch("uncertain", uncertain)] : [],
|
|
515
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
516
|
+
] });
|
|
517
|
+
}
|
|
518
|
+
function newGetMessageStep(configuration) {
|
|
519
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
520
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
521
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getMessage(), connection: connection.reference, branches: [
|
|
522
|
+
goToBranch("found", found),
|
|
523
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
524
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
525
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
526
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
527
|
+
] });
|
|
528
|
+
}
|
|
529
|
+
export {
|
|
530
|
+
ConfigSchema,
|
|
531
|
+
Connection,
|
|
532
|
+
GetMessageBranch,
|
|
533
|
+
GetMessageDefinition,
|
|
534
|
+
GetMessageInputSchema,
|
|
535
|
+
GetMessageOperation,
|
|
536
|
+
MessageSchema,
|
|
537
|
+
SendMessageBranch,
|
|
538
|
+
SendMessageDefinition,
|
|
539
|
+
SendMessageInputSchema,
|
|
540
|
+
SendMessageOperation,
|
|
541
|
+
TwilioClient,
|
|
542
|
+
decodeCredentials,
|
|
543
|
+
newConnection2 as newConnection,
|
|
544
|
+
newConnectionWithOperations,
|
|
545
|
+
newGetMessageStep,
|
|
546
|
+
newProjectConnection,
|
|
547
|
+
newSendMessageStep
|
|
548
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MockMutation, MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, b as Connection, S as SendMessageInput, M as Message, G as GetMessageInput } from './connection-DU3WOoJL.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for SendMessageInput in scripted cases. */
|
|
7
|
+
declare const emptySendMessageInput: SendMessageInput;
|
|
8
|
+
/** Go zero value for Message in scripted cases. */
|
|
9
|
+
declare const emptyMessage: Message;
|
|
10
|
+
/** Go zero value for GetMessageInput in scripted cases. */
|
|
11
|
+
declare const emptyGetMessageInput: GetMessageInput;
|
|
12
|
+
/** Script the accepted branch. */
|
|
13
|
+
declare function sendMessageAccepted(value: Message, failure?: Failure): Case<Message>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function sendMessageProviderRejected(value: Message, failure?: Failure): Case<Message>;
|
|
16
|
+
/** Script the defect branch. */
|
|
17
|
+
declare function sendMessageDefect(value: Message, failure?: Failure): Case<Message>;
|
|
18
|
+
/** Script a safe retry of sendMessage. */
|
|
19
|
+
declare function sendMessageRetry(failure: Failure, retryAfterMs?: number): Case<Message>;
|
|
20
|
+
/** Script an uncertain sendMessage attempt. */
|
|
21
|
+
declare function sendMessageUncertain(value: Message, failure: Failure): Case<Message>;
|
|
22
|
+
/** Manifest scenario queuedText for sendMessage. */
|
|
23
|
+
declare function sendMessageQueuedText(): Case<Message>;
|
|
24
|
+
/** Default sendMessage scenario. */
|
|
25
|
+
declare function sendMessageDefault(): Case<Message>;
|
|
26
|
+
/** Manifest scenario trialRecipientRejected for sendMessage. */
|
|
27
|
+
declare function sendMessageTrialRecipientRejected(): Case<Message>;
|
|
28
|
+
/** Script the found branch. */
|
|
29
|
+
declare function getMessageFound(value: Message, failure?: Failure): Case<Message>;
|
|
30
|
+
/** Script the notFound branch. */
|
|
31
|
+
declare function getMessageNotFound(value: Message, failure?: Failure): Case<Message>;
|
|
32
|
+
/** Script the providerRejected branch. */
|
|
33
|
+
declare function getMessageProviderRejected(value: Message, failure?: Failure): Case<Message>;
|
|
34
|
+
/** Script the invalidResponse branch. */
|
|
35
|
+
declare function getMessageInvalidResponse(value: Message, failure?: Failure): Case<Message>;
|
|
36
|
+
/** Script the defect branch. */
|
|
37
|
+
declare function getMessageDefect(value: Message, failure?: Failure): Case<Message>;
|
|
38
|
+
/** Script a safe retry of getMessage. */
|
|
39
|
+
declare function getMessageRetry(failure: Failure, retryAfterMs?: number): Case<Message>;
|
|
40
|
+
/** Manifest scenario deliveredText for getMessage. */
|
|
41
|
+
declare function getMessageDeliveredText(): Case<Message>;
|
|
42
|
+
/** Default getMessage scenario. */
|
|
43
|
+
declare function getMessageDefault(): Case<Message>;
|
|
44
|
+
/** Manifest scenario messageMissing for getMessage. */
|
|
45
|
+
declare function getMessageMessageMissing(): Case<Message>;
|
|
46
|
+
/** Manifest scenario messageReadRejected for getMessage. */
|
|
47
|
+
declare function getMessageMessageReadRejected(): Case<Message>;
|
|
48
|
+
/** Manifest scenario invalidMessageResponse for getMessage. */
|
|
49
|
+
declare function getMessageInvalidMessageResponse(): Case<Message>;
|
|
50
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
51
|
+
declare class GeneratedMock implements Operations {
|
|
52
|
+
#private;
|
|
53
|
+
constructor(connectionName: string);
|
|
54
|
+
connection(): Connection;
|
|
55
|
+
sendMessage(): MockMutation<SendMessageInput, Message>;
|
|
56
|
+
getMessage(): MockQuery<GetMessageInput, Message>;
|
|
57
|
+
assertNoFailures(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { GeneratedMock, emptyGetMessageInput, emptyMessage, emptySendMessageInput, getMessageDefault, getMessageDefect, getMessageDeliveredText, getMessageFound, getMessageInvalidMessageResponse, getMessageInvalidResponse, getMessageMessageMissing, getMessageMessageReadRejected, getMessageNotFound, getMessageProviderRejected, getMessageRetry, sendMessageAccepted, sendMessageDefault, sendMessageDefect, sendMessageProviderRejected, sendMessageQueuedText, sendMessageRetry, sendMessageTrialRecipientRejected, sendMessageUncertain };
|