@droponair/sdk-js 0.34.0 → 0.34.2
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,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.2
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`retentionSeconds` and `deleteWhenEveryoneHasIt` were ignored by
|
|
8
|
+
`prepareAttachmentAndUpload`.** They reached the upload session only when it was
|
|
9
|
+
called directly; the everyday path dropped them, so a file lived for the app's
|
|
10
|
+
full retention and was never deleted early. Both now pass through, thumbnail
|
|
11
|
+
included.
|
|
12
|
+
|
|
13
|
+
## 0.34.1
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **A file was deleted before the last recipient could download it.** With
|
|
18
|
+
`deleteWhenEveryoneHasIt`, the platform counted a recipient as having the file the
|
|
19
|
+
moment it issued their download link, so the final recipient got a link to a file
|
|
20
|
+
already gone. The SDK now confirms receipt only after the download and decrypt
|
|
21
|
+
succeed, and the platform deletes only on those confirmations. Nothing to change
|
|
22
|
+
in an app: it happens inside `downloadAttachment`.
|
|
23
|
+
|
|
3
24
|
## 0.34.0
|
|
4
25
|
|
|
5
26
|
### 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. */
|
|
@@ -132,6 +132,8 @@ class AttachmentClient {
|
|
|
132
132
|
conversationType,
|
|
133
133
|
conversationId: opts.groupId,
|
|
134
134
|
recipientUserIds,
|
|
135
|
+
retentionSeconds: opts.retentionSeconds,
|
|
136
|
+
deleteWhenEveryoneHasIt: opts.deleteWhenEveryoneHasIt,
|
|
135
137
|
});
|
|
136
138
|
await this.uploadBytes(session, storedBytes, opts.onUploadProgress);
|
|
137
139
|
await this.finalize(session.attachmentId, sha256);
|
|
@@ -198,6 +200,7 @@ class AttachmentClient {
|
|
|
198
200
|
const arrayBuf = await resp.arrayBuffer();
|
|
199
201
|
let stored = new Uint8Array(arrayBuf);
|
|
200
202
|
if (ref.encryptionType === 'CLEARTEXT') {
|
|
203
|
+
await this.confirmReceived(ref.attachmentId);
|
|
201
204
|
return { attachmentId: ref.attachmentId, mimeType: info.mimeType, sizeBytes: info.sizeBytes, sha256: info.sha256, bytes: stored };
|
|
202
205
|
}
|
|
203
206
|
const myDeviceId = await this.deps.getCurrentDeviceId();
|
|
@@ -214,6 +217,10 @@ class AttachmentClient {
|
|
|
214
217
|
const ciphertext = stored.slice(12);
|
|
215
218
|
const aesKey = await crypto.subtle.importKey('raw', asBufferSource(fileKey), { name: 'AES-GCM' }, false, ['decrypt']);
|
|
216
219
|
const plain = await crypto.subtle.decrypt({ name: 'AES-GCM', iv: asBufferSource(fileNonce), tagLength: 128 }, aesKey, asBufferSource(ciphertext));
|
|
220
|
+
// Only now, with the bytes downloaded and readable, does this device say it has
|
|
221
|
+
// the file. A download link is not a file, so the platform deletes the stored
|
|
222
|
+
// copy on this confirmation, never on the link.
|
|
223
|
+
await this.confirmReceived(ref.attachmentId);
|
|
217
224
|
return {
|
|
218
225
|
attachmentId: ref.attachmentId,
|
|
219
226
|
mimeType: info.mimeType,
|
|
@@ -222,6 +229,20 @@ class AttachmentClient {
|
|
|
222
229
|
bytes: new Uint8Array(plain),
|
|
223
230
|
};
|
|
224
231
|
}
|
|
232
|
+
/** Best effort: a missed confirmation only means the copy waits for its own expiry. */
|
|
233
|
+
async confirmReceived(attachmentId) {
|
|
234
|
+
try {
|
|
235
|
+
const jwt = await this.deps.getValidDropOnAirJwt();
|
|
236
|
+
await this.deps.fetchFn(`${this.deps.httpUrl}/v1/attachments/${encodeURIComponent(attachmentId)}/received`, {
|
|
237
|
+
method: 'POST',
|
|
238
|
+
headers: { Authorization: `Bearer ${jwt}`, 'Content-Type': 'application/json' },
|
|
239
|
+
body: '{}',
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
// The download itself succeeded; nothing to surface.
|
|
244
|
+
}
|
|
245
|
+
}
|
|
225
246
|
/** Convert public AttachmentRef into the wire-format type for proto encoding. */
|
|
226
247
|
toWire(ref) {
|
|
227
248
|
return {
|
|
@@ -83,6 +83,10 @@ export interface PrepareAttachmentOptions {
|
|
|
83
83
|
mimeType?: string;
|
|
84
84
|
/** Progress callback called with bytes uploaded so far. */
|
|
85
85
|
onUploadProgress?: (bytesUploaded: number, totalBytes: number) => void;
|
|
86
|
+
/** How long this one file should live, in seconds. Never granted longer than your own retention. */
|
|
87
|
+
retentionSeconds?: number;
|
|
88
|
+
/** Delete the stored bytes as soon as every recipient has confirmed they have them. */
|
|
89
|
+
deleteWhenEveryoneHasIt?: boolean;
|
|
86
90
|
/**
|
|
87
91
|
* Optional preview thumbnail bytes. Entirely the developer's choice - if
|
|
88
92
|
* provided, the SDK uploads it as a separate attachment (encrypted with the
|
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.2";
|
|
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.2';
|
|
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