@droponair/sdk-js 0.34.0 → 0.34.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **A file was deleted before the last recipient could download it.** With
|
|
8
|
+
`deleteWhenEveryoneHasIt`, the platform counted a recipient as having the file the
|
|
9
|
+
moment it issued their download link, so the final recipient got a link to a file
|
|
10
|
+
already gone. The SDK now confirms receipt only after the download and decrypt
|
|
11
|
+
succeed, and the platform deletes only on those confirmations. Nothing to change
|
|
12
|
+
in an app: it happens inside `downloadAttachment`.
|
|
13
|
+
|
|
3
14
|
## 0.34.0
|
|
4
15
|
|
|
5
16
|
### Added
|
|
@@ -63,6 +63,8 @@ export declare class AttachmentClient {
|
|
|
63
63
|
* current device, unwraps it, then decrypts the stored bytes.
|
|
64
64
|
*/
|
|
65
65
|
downloadAttachment(ref: AttachmentRef): Promise<DownloadedAttachment>;
|
|
66
|
+
/** Best effort: a missed confirmation only means the copy waits for its own expiry. */
|
|
67
|
+
private confirmReceived;
|
|
66
68
|
/** Convert public AttachmentRef into the wire-format type for proto encoding. */
|
|
67
69
|
toWire(ref: AttachmentRef): WireAttachmentRef;
|
|
68
70
|
/** Convert a wire AttachmentRef (from a received message) into the public type. */
|
|
@@ -198,6 +198,7 @@ class AttachmentClient {
|
|
|
198
198
|
const arrayBuf = await resp.arrayBuffer();
|
|
199
199
|
let stored = new Uint8Array(arrayBuf);
|
|
200
200
|
if (ref.encryptionType === 'CLEARTEXT') {
|
|
201
|
+
await this.confirmReceived(ref.attachmentId);
|
|
201
202
|
return { attachmentId: ref.attachmentId, mimeType: info.mimeType, sizeBytes: info.sizeBytes, sha256: info.sha256, bytes: stored };
|
|
202
203
|
}
|
|
203
204
|
const myDeviceId = await this.deps.getCurrentDeviceId();
|
|
@@ -214,6 +215,10 @@ class AttachmentClient {
|
|
|
214
215
|
const ciphertext = stored.slice(12);
|
|
215
216
|
const aesKey = await crypto.subtle.importKey('raw', asBufferSource(fileKey), { name: 'AES-GCM' }, false, ['decrypt']);
|
|
216
217
|
const plain = await crypto.subtle.decrypt({ name: 'AES-GCM', iv: asBufferSource(fileNonce), tagLength: 128 }, aesKey, asBufferSource(ciphertext));
|
|
218
|
+
// Only now, with the bytes downloaded and readable, does this device say it has
|
|
219
|
+
// the file. A download link is not a file, so the platform deletes the stored
|
|
220
|
+
// copy on this confirmation, never on the link.
|
|
221
|
+
await this.confirmReceived(ref.attachmentId);
|
|
217
222
|
return {
|
|
218
223
|
attachmentId: ref.attachmentId,
|
|
219
224
|
mimeType: info.mimeType,
|
|
@@ -222,6 +227,20 @@ class AttachmentClient {
|
|
|
222
227
|
bytes: new Uint8Array(plain),
|
|
223
228
|
};
|
|
224
229
|
}
|
|
230
|
+
/** Best effort: a missed confirmation only means the copy waits for its own expiry. */
|
|
231
|
+
async confirmReceived(attachmentId) {
|
|
232
|
+
try {
|
|
233
|
+
const jwt = await this.deps.getValidDropOnAirJwt();
|
|
234
|
+
await this.deps.fetchFn(`${this.deps.httpUrl}/v1/attachments/${encodeURIComponent(attachmentId)}/received`, {
|
|
235
|
+
method: 'POST',
|
|
236
|
+
headers: { Authorization: `Bearer ${jwt}`, 'Content-Type': 'application/json' },
|
|
237
|
+
body: '{}',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
// The download itself succeeded; nothing to surface.
|
|
242
|
+
}
|
|
243
|
+
}
|
|
225
244
|
/** Convert public AttachmentRef into the wire-format type for proto encoding. */
|
|
226
245
|
toWire(ref) {
|
|
227
246
|
return {
|
package/dist/version.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* MINOR, additive feature (e.g. multi-device payloads, new call event type)
|
|
8
8
|
* PATCH, bug-fix / perf improvement with no wire or API change
|
|
9
9
|
*/
|
|
10
|
-
export declare const SDK_VERSION = "0.34.
|
|
10
|
+
export declare const SDK_VERSION = "0.34.1";
|
|
11
11
|
/**
|
|
12
12
|
* Binary encrypted-payload format version.
|
|
13
13
|
* Included as the first byte of every encrypted payload so receivers can
|
package/dist/version.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.PROTOCOL_VERSION = exports.PAYLOAD_FORMAT_VERSION = exports.SDK_VERSION
|
|
|
10
10
|
* MINOR, additive feature (e.g. multi-device payloads, new call event type)
|
|
11
11
|
* PATCH, bug-fix / perf improvement with no wire or API change
|
|
12
12
|
*/
|
|
13
|
-
exports.SDK_VERSION = '0.34.
|
|
13
|
+
exports.SDK_VERSION = '0.34.1';
|
|
14
14
|
/**
|
|
15
15
|
* Binary encrypted-payload format version.
|
|
16
16
|
* Included as the first byte of every encrypted payload so receivers can
|
package/package.json
CHANGED