@telecrypt-io/storage 0.9.3 → 0.9.4

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,4 +1,5 @@
1
1
  import { ClientEvent, createClient, EventType, JoinRule, MatrixEvent, MatrixError, MsgType, Preset, RoomCreateTypeField, RoomType, SyncState, UNSTABLE_MSC3088_ENABLED, UNSTABLE_MSC3088_PURPOSE, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF, UNSTABLE_MSC3089_TREE_SUBTYPE, } from "matrix-js-sdk";
2
+ import { EventShieldReason, OnlySignedDevicesIsolationMode, } from "matrix-js-sdk/lib/crypto-api/index.js";
2
3
  import { Method } from "matrix-js-sdk/lib/http-api/method.js";
3
4
  import { ClientPrefix } from "matrix-js-sdk/lib/http-api/prefix.js";
4
5
  import { encryptAttachment, decryptAttachment } from "matrix-encrypt-attachment";
@@ -514,6 +515,13 @@ export class TeleCryptIOStorage {
514
515
  event.getType() !== EventType.RoomMessage) {
515
516
  throw new StorageError("encrypted storage metadata is invalid or unavailable");
516
517
  }
518
+ const crypto = this.client.getCrypto();
519
+ if (!crypto)
520
+ throw new StorageError("encryption is not initialized");
521
+ const encryptionInfo = await crypto.getEncryptionInfoForEvent(event);
522
+ if (!encryptionInfo || encryptionInfo.shieldReason === EventShieldReason.MISMATCHED_SENDER) {
523
+ throw new UndecryptableFileError();
524
+ }
517
525
  return event;
518
526
  }
519
527
  async writeTreeName(roomId, name) {
@@ -1031,6 +1039,10 @@ export class TeleCryptIOStorage {
1031
1039
  useIndexedDB: persistent,
1032
1040
  cryptoDatabasePrefix: opts.cryptoDatabasePrefix ?? `telecrypt-io-storage::${opts.userId}::${opts.deviceId}`,
1033
1041
  }), opts.initTimeoutMs ?? 60000, "crypto init", opts.signal);
1042
+ const crypto = client.getCrypto();
1043
+ if (!crypto)
1044
+ throw new StorageError("encryption is not initialized");
1045
+ crypto.setDeviceIsolationMode(new OnlySignedDevicesIsolationMode());
1034
1046
  progress("Encryption ready — opening secure store…");
1035
1047
  storage = new TeleCryptIOStorage(client, opts, opts);
1036
1048
  if (opts.startClient === false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telecrypt-io/storage",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.19.0",