@openclaw/sms 2026.10.5-beta.4 → 2026.10.10-beta.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as getSmsRuntime } from "./runtime-BBlPgBIF.mjs";
|
|
2
|
-
import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-
|
|
2
|
+
import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-BvmfwtSb.mjs";
|
|
3
3
|
import { collectErrorGraphCandidates } from "openclaw/plugin-sdk/error-runtime";
|
|
4
4
|
import { resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
@@ -7,7 +7,7 @@ import { SsrFBlockedError, safeEqualSecret } from "openclaw/plugin-sdk/security-
|
|
|
7
7
|
import { formatInboundMediaUnavailableText, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
8
8
|
import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
|
|
9
9
|
import { MediaFetchError, unlinkIfExists } from "openclaw/plugin-sdk/media-runtime";
|
|
10
|
-
import { createHostedOutboundMediaStore } from "openclaw/plugin-sdk/outbound-media";
|
|
10
|
+
import { createHostedOutboundMediaStore, resolveHostedOutboundMediaRequest, resolveOutboundMediaAccess } from "openclaw/plugin-sdk/outbound-media";
|
|
11
11
|
import { isTransientNetworkError } from "openclaw/plugin-sdk/retry-runtime";
|
|
12
12
|
//#region extensions/sms/src/media.ts
|
|
13
13
|
const TWILIO_API_HOSTNAME = "api.twilio.com";
|
|
@@ -142,19 +142,6 @@ function getHostedSmsMediaStore(accountId) {
|
|
|
142
142
|
hostedSmsMediaStores.set(accountId, created);
|
|
143
143
|
return created;
|
|
144
144
|
}
|
|
145
|
-
function createHostedSmsMediaCleanup(store, id) {
|
|
146
|
-
let cleanup;
|
|
147
|
-
return async () => {
|
|
148
|
-
const activeCleanup = cleanup ?? store.delete(id);
|
|
149
|
-
cleanup = activeCleanup;
|
|
150
|
-
try {
|
|
151
|
-
await activeCleanup;
|
|
152
|
-
} catch (error) {
|
|
153
|
-
if (cleanup === activeCleanup) cleanup = void 0;
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
145
|
async function prepareHostedSmsMedia(params) {
|
|
159
146
|
const route = resolveSmsHostedMediaRoute({
|
|
160
147
|
webhookPath: params.account.webhookPath,
|
|
@@ -165,28 +152,17 @@ async function prepareHostedSmsMedia(params) {
|
|
|
165
152
|
if (!Number.isSafeInteger(captionByteLength) || captionByteLength < 0) throw new Error("MMS caption byte length must be a non-negative integer.");
|
|
166
153
|
const aggregateMediaBudget = TWILIO_MMS_IMAGE_MAX_BYTES - captionByteLength - 1;
|
|
167
154
|
if (aggregateMediaBudget < 1) throw new Error("Twilio MMS caption leaves no room for an attachment below 5,000,000 bytes.");
|
|
168
|
-
const mediaAccess = (() => {
|
|
169
|
-
const localRoots = params.mediaAccess?.localRoots ?? params.mediaLocalRoots;
|
|
170
|
-
const readFile = params.mediaAccess?.readFile ?? params.mediaReadFile;
|
|
171
|
-
const workspaceDir = params.mediaAccess?.workspaceDir;
|
|
172
|
-
if (!localRoots && !readFile && !workspaceDir) return;
|
|
173
|
-
return {
|
|
174
|
-
...localRoots ? { localRoots } : {},
|
|
175
|
-
...readFile ? { readFile } : {},
|
|
176
|
-
...workspaceDir ? { workspaceDir } : {}
|
|
177
|
-
};
|
|
178
|
-
})();
|
|
179
155
|
const stagedUrl = new URL(await store.prepareUrl({
|
|
180
156
|
mediaUrl: params.mediaUrl,
|
|
181
157
|
routePath: route.localRoutePath,
|
|
182
158
|
publicBaseUrl: route.publicBaseUrl,
|
|
183
159
|
maxBytes: Math.min(params.account.mediaMaxBytes ?? aggregateMediaBudget, aggregateMediaBudget),
|
|
184
|
-
mediaAccess
|
|
160
|
+
mediaAccess: resolveOutboundMediaAccess(params)
|
|
185
161
|
}));
|
|
186
162
|
const id = stagedUrl.pathname.split("/").at(-1) ?? "";
|
|
187
163
|
const token = stagedUrl.searchParams.get("token");
|
|
188
164
|
if (!SMS_OUTBOUND_MEDIA_ID_RE.test(id) || !token) throw new Error("Hosted MMS media URL could not be prepared.");
|
|
189
|
-
const cleanup =
|
|
165
|
+
const cleanup = () => store.delete(id);
|
|
190
166
|
const entry = await store.read(id);
|
|
191
167
|
if (!entry) throw new Error("Hosted MMS media expired before it could be sent.");
|
|
192
168
|
const contentType = entry.metadata.contentType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
@@ -347,33 +323,11 @@ function hostedSmsMediaFileName(id, contentType) {
|
|
|
347
323
|
return extension ? `mms-${id.slice(0, 10)}${extension}` : void 0;
|
|
348
324
|
}
|
|
349
325
|
async function tryHandleHostedSmsMediaRequest(req, res, accountId = "default") {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
} catch {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
const tokenCandidates = [...url.searchParams.entries()].filter(([key]) => key.startsWith(`${SMS_OUTBOUND_MEDIA_TOKEN_PARAM_PREFIX}_`)).map(([key, token]) => ({
|
|
357
|
-
id: key.slice(21),
|
|
358
|
-
token
|
|
359
|
-
})).filter((candidate) => SMS_OUTBOUND_MEDIA_ID_RE.test(candidate.id));
|
|
360
|
-
if (tokenCandidates.length === 0) return false;
|
|
361
|
-
if (tokenCandidates.length !== 1) {
|
|
362
|
-
res.statusCode = 400;
|
|
363
|
-
res.end("Bad Request");
|
|
364
|
-
return true;
|
|
365
|
-
}
|
|
366
|
-
const method = req.method ?? "GET";
|
|
367
|
-
if (method !== "GET" && method !== "HEAD") {
|
|
368
|
-
res.statusCode = 405;
|
|
369
|
-
res.setHeader("Allow", "GET, HEAD");
|
|
370
|
-
res.end("Method Not Allowed");
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
326
|
+
const candidate = resolveHostedOutboundMediaRequest(req, res, SMS_OUTBOUND_MEDIA_TOKEN_PARAM_PREFIX);
|
|
327
|
+
if (typeof candidate === "boolean") return candidate;
|
|
328
|
+
const { url, method } = candidate;
|
|
373
329
|
const routePath = toHostedStoreRoutePath(url.pathname);
|
|
374
330
|
const store = getHostedSmsMediaStore(accountId);
|
|
375
|
-
const candidate = tokenCandidates[0];
|
|
376
|
-
if (!candidate) return false;
|
|
377
331
|
const metadata = await store.readMetadata(candidate.id);
|
|
378
332
|
if (!metadata || metadata.routePath !== routePath) {
|
|
379
333
|
res.statusCode = 404;
|
|
@@ -95,7 +95,7 @@ function resolveTwilioStatusCallbackUrl(publicWebhookUrl) {
|
|
|
95
95
|
const retryCount = Number.isInteger(configuredRetryCount) && configuredRetryCount >= 1 && configuredRetryCount <= 5 ? configuredRetryCount : 1;
|
|
96
96
|
overrides.set("rc", String(retryCount));
|
|
97
97
|
const callbackUrl = `${baseUrl}#${overrides.toString().replaceAll("%2C", ",")}`;
|
|
98
|
-
if (callbackUrl.length > SMS_STATUS_CALLBACK_MAX_LENGTH
|
|
98
|
+
if (callbackUrl.length > SMS_STATUS_CALLBACK_MAX_LENGTH) return "";
|
|
99
99
|
return callbackUrl;
|
|
100
100
|
}
|
|
101
101
|
//#endregion
|
package/dist/api.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { getSmsRuntime, setSmsRuntime };
|
|
1
|
+
export { t as getSmsRuntime, n as setSmsRuntime } from "./.setup/runtime-BBlPgBIF.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as getSmsRuntime } from "./.setup/runtime-BBlPgBIF.mjs";
|
|
2
|
-
import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./.setup/twilio-
|
|
2
|
+
import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./.setup/twilio-BvmfwtSb.mjs";
|
|
3
3
|
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-B2P_lFGm.mjs";
|
|
4
4
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
5
5
|
import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
@@ -446,7 +446,7 @@ async function prepareSmsMediaAttempt(params) {
|
|
|
446
446
|
});
|
|
447
447
|
let hostedMedia;
|
|
448
448
|
try {
|
|
449
|
-
const { prepareHostedSmsMedia } = await import("./.setup/media-
|
|
449
|
+
const { prepareHostedSmsMedia } = await import("./.setup/media-CJXLLK4_.mjs");
|
|
450
450
|
assertSmsCredentialOwnerAvailable(params.account);
|
|
451
451
|
const prepared = await prepareHostedSmsMedia({
|
|
452
452
|
account: params.account,
|
|
@@ -557,7 +557,7 @@ async function dispatchSmsInboundEvent(params) {
|
|
|
557
557
|
params.log?.warn?.(`SMS sender ${from} is not authorized`);
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
560
|
-
const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./.setup/media-
|
|
560
|
+
const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./.setup/media-CJXLLK4_.mjs")).materializeSmsInboundMedia({
|
|
561
561
|
account: params.account,
|
|
562
562
|
msg: params.msg,
|
|
563
563
|
mediaRuntime: params.channelRuntime,
|
|
@@ -1060,7 +1060,7 @@ async function registerSmsWebhookRoute(params) {
|
|
|
1060
1060
|
throwOnFailure: true,
|
|
1061
1061
|
log: (msg) => params.log?.info?.(msg),
|
|
1062
1062
|
handler: async (req, res) => {
|
|
1063
|
-
const { tryHandleHostedSmsMediaRequest } = await import("./.setup/media-
|
|
1063
|
+
const { tryHandleHostedSmsMediaRequest } = await import("./.setup/media-CJXLLK4_.mjs");
|
|
1064
1064
|
if (await tryHandleHostedSmsMediaRequest(req, res, params.account.accountId)) return true;
|
|
1065
1065
|
return await webhookHandler(req, res);
|
|
1066
1066
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { channelSecrets, collectRuntimeConfigAssignments, secretTargetRegistryEntries };
|
|
1
|
+
export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-B2P_lFGm.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/sms",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.10-beta.2",
|
|
4
4
|
"description": "OpenClaw SMS/MMS channel plugin for Twilio messages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -123,10 +123,10 @@
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
"compat": {
|
|
126
|
-
"pluginApi": ">=2026.10.
|
|
126
|
+
"pluginApi": ">=2026.10.10-beta.2"
|
|
127
127
|
},
|
|
128
128
|
"build": {
|
|
129
|
-
"openclawVersion": "2026.10.
|
|
129
|
+
"openclawVersion": "2026.10.10-beta.2",
|
|
130
130
|
"bundledDist": false
|
|
131
131
|
},
|
|
132
132
|
"install": {
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"assets/activity.svg"
|
|
153
153
|
],
|
|
154
154
|
"peerDependencies": {
|
|
155
|
-
"openclaw": ">=2026.10.
|
|
155
|
+
"openclaw": ">=2026.10.10-beta.2"
|
|
156
156
|
},
|
|
157
157
|
"peerDependenciesMeta": {
|
|
158
158
|
"openclaw": {
|