@vellumai/vellum-gateway 0.6.0 → 0.6.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.
@@ -103,6 +103,16 @@ export class SlackSocketModeClient {
103
103
  if (data.team) {
104
104
  this.config.teamName = data.team;
105
105
  }
106
+ // Warn if the bot token is missing scopes needed for file downloads.
107
+ const scopes = resp.headers.get("x-oauth-scopes") ?? "";
108
+ if (!scopes.split(",").some((s) => s.trim() === "files:read")) {
109
+ log.warn(
110
+ "Slack bot token is missing the 'files:read' scope — file/image " +
111
+ "attachments will not be downloaded. Add 'files:read' to your " +
112
+ "Slack app's Bot Token Scopes and reinstall the app.",
113
+ );
114
+ }
115
+
106
116
  log.info(
107
117
  {
108
118
  botUserId: data.user_id,
@@ -2,6 +2,7 @@ import { fileTypeFromBuffer } from "file-type";
2
2
  import type { ConfigFileCache } from "../config-file-cache.js";
3
3
  import type { CredentialCache } from "../credential-cache.js";
4
4
  import { credentialKey } from "../credential-key.js";
5
+ import { validateDownloadedContent } from "../download-validation.js";
5
6
  import { fetchImpl } from "../fetch.js";
6
7
  import { callTelegramApi } from "./api.js";
7
8
 
@@ -72,6 +73,8 @@ export async function downloadTelegramFile(
72
73
  response.headers.get("Content-Type")?.split(";")[0].trim() ||
73
74
  "application/octet-stream";
74
75
 
76
+ await validateDownloadedContent(new Uint8Array(buffer), mimeType, fileId);
77
+
75
78
  const data = Buffer.from(buffer).toString("base64");
76
79
 
77
80
  return { filename, mimeType, data };
package/src/types.ts CHANGED
@@ -5,4 +5,5 @@ export type {
5
5
  TelegramInboundEvent,
6
6
  WhatsAppInboundEvent,
7
7
  SlackInboundEvent,
8
+ EmailInboundEvent,
8
9
  } from "./channels/inbound-event.js";
@@ -1,5 +1,6 @@
1
1
  import { fileTypeFromBuffer } from "file-type";
2
2
  import type { GatewayConfig } from "../config.js";
3
+ import { validateDownloadedContent } from "../download-validation.js";
3
4
  import {
4
5
  getWhatsAppMediaMetadata,
5
6
  downloadWhatsAppMediaBytes,
@@ -79,6 +80,8 @@ export async function downloadWhatsAppFile(
79
80
  response.headers.get("Content-Type")?.split(";")[0].trim() ||
80
81
  "application/octet-stream";
81
82
 
83
+ await validateDownloadedContent(new Uint8Array(buffer), mimeType, mediaId);
84
+
82
85
  const filename = hint?.fileName || inferFilename(mediaId, mimeType);
83
86
  const data = Buffer.from(buffer).toString("base64");
84
87