@spectrum-ts/whatsapp-business 7.0.0 → 8.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/dist/index.js +12 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedEventStream, button, buttons, createClient, list } from "@photon-ai/whatsapp-business";
|
|
2
2
|
import { UnsupportedError, cloud, definePlatform, mergeStreams, stream } from "@spectrum-ts/core";
|
|
3
|
-
import { asAttachment, asContact, asCustom, asPollOption, asReaction, asText, createLogger, errorAttrs } from "@spectrum-ts/core/authoring";
|
|
3
|
+
import { asAttachment, asContact, asCustom, asPollOption, asReaction, asText, createLogger, errorAttrs, tracedFetch } from "@spectrum-ts/core/authoring";
|
|
4
4
|
import { extension } from "mime-types";
|
|
5
5
|
import z from "zod";
|
|
6
6
|
//#region src/auth.ts
|
|
@@ -391,9 +391,19 @@ const mapContent = (client, msg) => {
|
|
|
391
391
|
default: return asCustom({ whatsapp_type: "unknown" });
|
|
392
392
|
}
|
|
393
393
|
};
|
|
394
|
+
const redactMediaUrl = (url) => {
|
|
395
|
+
try {
|
|
396
|
+
const parsed = new URL(url);
|
|
397
|
+
parsed.search = "";
|
|
398
|
+
return parsed.toString();
|
|
399
|
+
} catch {
|
|
400
|
+
return url;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
const waMediaFetch = tracedFetch("whatsapp-business", { redactUrl: redactMediaUrl });
|
|
394
404
|
const fetchMedia = async (client, mediaId) => {
|
|
395
405
|
const { url } = await client.media.getUrl(mediaId);
|
|
396
|
-
const response = await
|
|
406
|
+
const response = await waMediaFetch(url);
|
|
397
407
|
if (!response.ok) throw new Error(`Media download failed: ${response.status}`);
|
|
398
408
|
return response;
|
|
399
409
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-ts/whatsapp-business",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "WhatsApp Business provider for spectrum-ts.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"zod": "^4.2.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@spectrum-ts/core": "^
|
|
39
|
+
"@spectrum-ts/core": "^8.0.0",
|
|
40
40
|
"typescript": "^5 || ^6.0.0"
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT"
|