@telecrypt-io/storage 0.9.0 → 0.9.3

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/LICENSE CHANGED
@@ -2,7 +2,7 @@ Business Source License 1.1
2
2
 
3
3
  Parameters
4
4
 
5
- Licensor: TeleCrypt.io
5
+ Licensor: Alexander Potemkin
6
6
  Licensed Work: TeleCrypt.io Storage
7
7
  The Licensed Work is (c) 2026 TeleCrypt.io
8
8
  Additional Use Grant: You may use, copy, modify, and create derivative
package/README.md CHANGED
@@ -12,6 +12,9 @@ unmerged Matrix proposal.
12
12
  npm install @telecrypt-io/storage
13
13
  ```
14
14
 
15
+ The SDK supports Node.js `24.21.0` as its exact engine version. Its release tooling uses the
16
+ bundled npm `11.19.0`.
17
+
15
18
  ## Browser quick start
16
19
 
17
20
  The example below starts with an authenticated OIDC session. Obtain `userId`, `accessToken`, and
@@ -83,6 +86,18 @@ and a per-file key distributed through the room's Megolm session). The server st
83
86
  media and Matrix events, but encryption does not hide all room, event, or other metadata from the
84
87
  server or users who can read the room.
85
88
 
89
+ If an upload is rejected after media was accepted, the SDK removes that media and any acknowledged
90
+ attachment. A transport failure leaves accepted work intact. An upload `MutationPartialError`
91
+ retains `treeId` and `completedIds` in the order `[mediaId, attachmentEventId?]`. Keep those IDs;
92
+ do not repeat the upload blindly. To discard the partial upload, call
93
+ `core.cleanupFileUpload(storage, error.treeId, error.completedIds[0], error.completedIds[1])`.
94
+ Retry cleanup with the same IDs if it fails. A known attachment ID can also be passed to ordinary
95
+ `core.deleteFile` even when its listing was never committed. An initial media response lost before
96
+ the server returns any identifier still has an unknown outcome and cannot provide cleanup IDs.
97
+ Upload cancellation stops before the next write and waits for the current request's bounded
98
+ settlement so returned media/event IDs are retained. Keep observing the upload promise after
99
+ cancelling a UI wait or closing a view; persist any partial receipt for the originating account.
100
+
86
101
  The Decryption Key Safe is mandatory before the public core storage operations. Inspect
87
102
  `storage.keySafe.getStatus(signal?)`. For `setup-required`, call `setup(signal?)`, offer the returned
88
103
  `recoveryKey` for copying/saving, explain that losing both this key and local decryption keys can
@@ -93,6 +108,12 @@ room keys and signs the current login using the existing account keys. Normal us
93
108
  Setup and restore never replace an existing safe or account signing identity. Resetting the account
94
109
  password cannot recover encrypted files.
95
110
 
111
+ Short-lived clients should call `storage.waitForKeyBackup(treeId, fileId?, options?)` after creating
112
+ or renaming encrypted metadata and before closing. Omit `fileId` for a vault or folder. This checks
113
+ the exact encryption session in the active server backup, including reused keys that produce no
114
+ new backup-progress event. If verification fails, retain the local profile and retry backup;
115
+ the metadata mutation has already committed.
116
+
96
117
  Pending setup state is kept beside the login's IndexedDB crypto data. A platform that snapshots
97
118
  IndexedDB to disk, such as the CLI, must supply `onKeySafeStateChanged` at creation and durably flush
98
119
  its snapshot before resolving that callback. Key Safe methods accept an optional `AbortSignal`.
@@ -105,6 +126,17 @@ the SDK checks native recipient-device eligibility afterward and reports partial
105
126
  keys could not be shared. An upload restriction can reject the encrypted history bundle upload;
106
127
  the error is preserved, including when retrying an existing invitation.
107
128
 
129
+ `joinVault` accepts the vault and its linked folder invitations, including their history keys.
130
+ New folders inherit the parent's joined and invited readers; browsing accepts their folder
131
+ invitations. If reader access fails after folder creation, the partial-completion error retains
132
+ the created folder ID. Retry sharing the parent vault to complete access to that folder.
133
+
134
+ Storage spaces are private and only their creator changes room state. Loading owned trees or
135
+ refreshing their state repairs the permissive defaults emitted by older SDKs and restores
136
+ invite-only joining. The repair preserves membership, unrelated power settings and encryption
137
+ keys; readers do not write it. Owners must use an updated client for their existing trees to be
138
+ repaired. Disabled Storage markers and deleted trees are not restored automatically.
139
+
108
140
  Deletion has strict ordering. Delete files before their folders or vaults because folders and
109
141
  vaults must be empty. File deletion removes the encrypted media object before redacting its Matrix
110
142
  event and requires TeleCrypt's Synapse storage extension; stock Synapse cannot provide that
@@ -21,7 +21,7 @@ export interface TreeSpace {
21
21
  setPermissions(userId: string, role: string): Promise<void>;
22
22
  getFile(fileEventId: string): FileBranch | null;
23
23
  listFiles(): FileBranch[];
24
- createFile(name: string, encryptedContents: ArrayBuffer | Uint8Array, info: Record<string, unknown>, additionalContent?: Record<string, unknown>): Promise<{
24
+ createFile(name: string, encryptedContents: ArrayBuffer | Uint8Array, info: Record<string, unknown>, additionalContent?: Record<string, unknown>, signal?: AbortSignal): Promise<{
25
25
  event_id: string;
26
26
  }>;
27
27
  }
@@ -170,10 +170,18 @@ export declare class TeleCryptIOStorage {
170
170
  private getStateEvent;
171
171
  private getTreeOwnerId;
172
172
  private sendEncryptedMetadataMessage;
173
+ private requireEncryptedStorageRoom;
173
174
  private readEncryptedMetadataMessage;
174
175
  private writeTreeName;
176
+ private getTreeMetadataEvent;
175
177
  /** Resolves an encrypted vault/folder name through its pointer state event. */
176
178
  getTreeName(roomId: string, options?: MatrixRequestOptions): Promise<string>;
179
+ /**
180
+ * Waits for the current encrypted vault/folder name, or file metadata, to
181
+ * have its session in the active native key backup. Checks the exact session
182
+ * even when encryption reuses a key and the backup engine emits no new event.
183
+ */
184
+ waitForKeyBackup(treeId: string, fileId?: string, options?: MatrixRequestOptions): Promise<void>;
177
185
  private writeFileName;
178
186
  /** Resolves an encrypted file name from the MSC3089 index pointer. */
179
187
  getFileName(treeId: string, fileId: string, options?: MatrixRequestOptions & {
@@ -186,6 +194,12 @@ export declare class TeleCryptIOStorage {
186
194
  /** Fetches the original encrypted file message directly by event ID. */
187
195
  getOriginalFileEvent(treeId: string, fileId: string, allowRedacted?: boolean): Promise<MatrixEvent>;
188
196
  private createEncryptedFile;
197
+ /**
198
+ * Discards a partial upload using its MutationPartialError.completedIds:
199
+ * [mediaId, fileId?]. Explicit cleanup also covers an unacknowledged listing.
200
+ * Keep the same IDs after failure and retry this operation, not the upload.
201
+ */
202
+ cleanupFileUpload(treeId: string, mediaId: string, fileId?: string, options?: MatrixRequestOptions): Promise<void>;
189
203
  /**
190
204
  * Refreshes a room's current state from the homeserver. The background sync
191
205
  * loop is intentionally asynchronous, so a short-lived CLI process can
@@ -193,6 +207,7 @@ export declare class TeleCryptIOStorage {
193
207
  * changed a file name or branch.
194
208
  */
195
209
  refreshRoomState(roomId: string, options?: MatrixRequestOptions): Promise<void>;
210
+ private repairOwnedTreePermissions;
196
211
  /**
197
212
  * Recommended entry point: builds the MatrixClient with a persistent crypto
198
213
  * store and the secret-storage callback wiring `keys.*` needs, starts the