@telecrypt-io/storage 0.2.6 → 0.2.8

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.
@@ -363,13 +363,20 @@ export class TeleCryptIOStorage {
363
363
  return event_id;
364
364
  }
365
365
  async downloadFile(branch) {
366
- const { info } = await branch.getFileInfo();
367
- // If the underlying room event couldn't be decrypted (e.g. this device
368
- // never received/recovered the megolm session for it), matrix-js-sdk
369
- // hands back a placeholder with no usable `info` rather than throwing —
370
- // so without this check, callers would hit an opaque
371
- // "Cannot read properties of undefined" a few lines down instead of a
372
- // clear, actionable error.
366
+ let info;
367
+ try {
368
+ ({ info } = await branch.getFileInfo());
369
+ }
370
+ catch {
371
+ // matrix-js-sdk's MSC3089Branch.getFileInfo() reads `file["url"]` off
372
+ // the raw event content; when the event is undecryptable on this
373
+ // device it hands back a placeholder with no `file` block, so that
374
+ // read throws an opaque "Cannot read properties of undefined" instead
375
+ // of a useful error. Surface the real cause.
376
+ throw new Error(`downloadFile: could not read file info from the event — it is likely undecryptable on this device (missing megolm session; try restoring from a Recovery Key)`);
377
+ }
378
+ // Belt-and-braces: if a future matrix-js-sdk version returns a
379
+ // placeholder without throwing, still fail with the clear message.
373
380
  if (!info || typeof info.url !== "string") {
374
381
  throw new Error("downloadFile: could not read file info from the event — it is likely undecryptable on this device (missing megolm session; try restoring from a Recovery Key)");
375
382
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telecrypt-io/storage",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",