grist-widget-sdk 0.6.0 → 0.6.1

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.
@@ -2,12 +2,12 @@ import {
2
2
  GristWidgetApp,
3
3
  entryProps,
4
4
  isGristWidgetEntry
5
- } from "../chunk-TUPCTWE5.js";
5
+ } from "../chunk-KHOPLBCJ.js";
6
6
  import {
7
7
  encodeGristCell,
8
8
  isGristWidget,
9
9
  resetGristForTests
10
- } from "../chunk-DKCRFNAW.js";
10
+ } from "../chunk-JJ23G6RR.js";
11
11
  import {
12
12
  createGristEmulator,
13
13
  presets
package/dist/index.cjs CHANGED
@@ -612,8 +612,12 @@ async function getAttachmentDownloadUrl(docApi, attachmentId, options) {
612
612
  if (!getAccessToken) {
613
613
  throw new Error("getAccessToken is not available on docApi");
614
614
  }
615
+ const id = String(attachmentId).trim();
616
+ if (!/^[1-9]\d*$/.test(id)) {
617
+ throw new Error(`getAttachmentDownloadUrl: "${attachmentId}" is not an attachment id (a positive integer).`);
618
+ }
615
619
  const { token, baseUrl } = await getAccessToken({ readOnly: options?.readOnly ?? false });
616
- return `${baseUrl}/attachments/${attachmentId}/download?auth=${token}`;
620
+ return `${baseUrl}/attachments/${id}/download?auth=${encodeURIComponent(token)}`;
617
621
  }
618
622
  async function fetchBytesFromSignedAttachmentUrl(url) {
619
623
  const response = await fetch(url);