@droponair/sdk-js 0.12.0 → 0.13.0
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 +15 -0
- package/README.md +4 -0
- package/dist/attachment/attachment-client.d.ts +7 -0
- package/dist/attachment/attachment-client.js +31 -0
- package/dist/attachment/attachment-types.d.ts +15 -0
- package/dist/core/messaging-client.d.ts +10 -0
- package/dist/core/messaging-client.js +20 -0
- package/dist/core/types.d.ts +25 -0
- package/dist/transport/protobuf-codec.d.ts +2 -0
- package/dist/transport/protobuf-codec.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,21 @@ This project follows [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [0.13.0], 2026-05-21
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **Group read receipts.** When a group has `readReceiptsVisibleToGroup` enabled, a member's `markRead(messageId, groupId)` is fanned to every other member, not just the reader's own devices. The inbound `ReadReceiptEvent` now carries `fromUserId` so you know which member read the message. New `client.updateGroup(groupId, { name?, readReceiptsVisibleToGroup? })` controls the per-group flag (it is a group-level choice; off by default). Broadcasts stay own-device only by design.
|
|
14
|
+
- **Attachment revoke.** New `client.revokeAttachment(attachmentId)` — the platform stops issuing download URLs for it and recipients with a live connection get an `ATTACHMENT_REVOKED` event via `onEvent` (metadata = attachmentId). Bytes already downloaded cannot be recalled.
|
|
15
|
+
- **Attachment preview thumbnails.** `prepareAttachmentAndUpload` accepts an optional `thumbnail` (and `thumbnailMimeType`). Entirely optional — if provided, the SDK uploads it as a separate attachment encrypted the same way and links it via `AttachmentRef.thumbnailAttachmentId`; download it like any attachment. If omitted, there is simply no thumbnail.
|
|
16
|
+
|
|
17
|
+
### Notes
|
|
18
|
+
|
|
19
|
+
- Download authorization for GROUP attachments is now checked against *current* group membership: a user removed from a group can no longer download its attachments even if they were a recipient at upload time.
|
|
20
|
+
- No PROTOCOL_VERSION change — additive proto fields (`SyncFrame.fromUserId`, `AttachmentRef.thumbnailAttachmentId`) and an additive event type.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
9
24
|
## [0.12.0], 2026-05-20
|
|
10
25
|
|
|
11
26
|
### Added
|
package/README.md
CHANGED
|
@@ -231,8 +231,12 @@ client.onMessage(async (msg) => {
|
|
|
231
231
|
| `createUploadSession(options)` | `Promise<UploadSession>` | Low-level: presigned PUT URL only |
|
|
232
232
|
| `finalizeAttachment(attachmentId, sha256)` | `Promise<void>` | Low-level: commit integrity hash |
|
|
233
233
|
| `downloadAttachment(ref)` | `Promise<DownloadedAttachment>` | Get presigned URL + download + decrypt |
|
|
234
|
+
| `revokeAttachment(attachmentId)` | `Promise<void>` | Revoke an attachment you sent; recipients get `ATTACHMENT_REVOKED` |
|
|
234
235
|
| `sendMessage(toUserId, text, { attachments })` | `Promise<{ messageId }>` | Send with attachments |
|
|
235
236
|
|
|
237
|
+
- **Preview thumbnails (optional).** Pass `thumbnail` (bytes) in `prepareAttachmentAndUpload` options and the SDK uploads it as a separate encrypted attachment, linked via `AttachmentRef.thumbnailAttachmentId`. Purely the developer's choice; omit it and there is no thumbnail. Download the thumbnail like any attachment.
|
|
238
|
+
- **Revoke.** `revokeAttachment()` stops the platform issuing new download URLs and notifies recipients. Bytes a recipient already downloaded cannot be recalled. For GROUP attachments, download is authorized against *current* group membership, so a removed member loses access.
|
|
239
|
+
|
|
236
240
|
- E2EE: a random AES-256-GCM file key encrypts the bytes; the file key is wrapped per recipient device using X25519 + HKDF (same model as message payloads). Server never sees the unwrapped file key.
|
|
237
241
|
- Availability and per-file / per-month limits depend on your plan and are enforced server-side before the presigned URL is issued. See the [pricing page](https://www.droponair.com/pricing) and your dashboard Subscription page for what's enabled on your app.
|
|
238
242
|
- Upload URL TTL = 15 min. Download URL TTL = 5 min. Download authorization checks that the requester is the original sender or in the captured recipient list.
|
|
@@ -43,6 +43,13 @@ export declare class AttachmentClient {
|
|
|
43
43
|
* finalizes, and returns a fully-formed AttachmentRef for sendMessage.
|
|
44
44
|
*/
|
|
45
45
|
prepareAttachmentAndUpload(input: Uint8Array, opts: PrepareAttachmentOptions): Promise<AttachmentRef>;
|
|
46
|
+
/**
|
|
47
|
+
* Revoke an attachment you sent (Phase 2f). After revoke the platform
|
|
48
|
+
* refuses to issue further download URLs and recipients with a live
|
|
49
|
+
* connection get an ATTACHMENT_REVOKED event. Bytes a recipient already
|
|
50
|
+
* downloaded cannot be recalled.
|
|
51
|
+
*/
|
|
52
|
+
revokeAttachment(attachmentId: string): Promise<void>;
|
|
46
53
|
getDownloadUrl(attachmentId: string): Promise<{
|
|
47
54
|
url: string;
|
|
48
55
|
method: string;
|
|
@@ -78,6 +78,20 @@ class AttachmentClient {
|
|
|
78
78
|
if (!input || input.length === 0) {
|
|
79
79
|
throw new Error('attachment bytes are empty');
|
|
80
80
|
}
|
|
81
|
+
// Optional preview thumbnail: the developer's choice. If supplied, upload
|
|
82
|
+
// it as an independent attachment (same conversation + recipients +
|
|
83
|
+
// encryption) and link it from the main ref. The recursive call passes
|
|
84
|
+
// thumbnail: undefined so it terminates.
|
|
85
|
+
let thumbnailAttachmentId;
|
|
86
|
+
if (opts.thumbnail && opts.thumbnail.length > 0) {
|
|
87
|
+
const thumbRef = await this.prepareAttachmentAndUpload(opts.thumbnail, {
|
|
88
|
+
...opts,
|
|
89
|
+
thumbnail: undefined,
|
|
90
|
+
mimeType: opts.thumbnailMimeType ?? 'image/jpeg',
|
|
91
|
+
onUploadProgress: undefined,
|
|
92
|
+
});
|
|
93
|
+
thumbnailAttachmentId = thumbRef.attachmentId;
|
|
94
|
+
}
|
|
81
95
|
const encryptionType = opts.encryptionType ?? 'E2EE';
|
|
82
96
|
const conversationType = opts.groupId ? 'GROUP' : 'ONE_TO_ONE';
|
|
83
97
|
if (conversationType === 'ONE_TO_ONE' && !opts.toUserId) {
|
|
@@ -129,8 +143,23 @@ class AttachmentClient {
|
|
|
129
143
|
sha256,
|
|
130
144
|
encryptionType,
|
|
131
145
|
wrappedKeys,
|
|
146
|
+
thumbnailAttachmentId,
|
|
132
147
|
};
|
|
133
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Revoke an attachment you sent (Phase 2f). After revoke the platform
|
|
151
|
+
* refuses to issue further download URLs and recipients with a live
|
|
152
|
+
* connection get an ATTACHMENT_REVOKED event. Bytes a recipient already
|
|
153
|
+
* downloaded cannot be recalled.
|
|
154
|
+
*/
|
|
155
|
+
async revokeAttachment(attachmentId) {
|
|
156
|
+
const jwt = await this.deps.getValidDropOnAirJwt();
|
|
157
|
+
const resp = await this.deps.fetchFn(`${this.deps.httpUrl}/v1/attachments/${encodeURIComponent(attachmentId)}/revoke`, { method: 'POST', headers: { Authorization: `Bearer ${jwt}` } });
|
|
158
|
+
if (!resp.ok) {
|
|
159
|
+
const text = await resp.text().catch(() => '');
|
|
160
|
+
throw new Error(`Failed to revoke attachment (HTTP ${resp.status}): ${text}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
134
163
|
async getDownloadUrl(attachmentId) {
|
|
135
164
|
const jwt = await this.deps.getValidDropOnAirJwt();
|
|
136
165
|
const resp = await this.deps.fetchFn(`${this.deps.httpUrl}/v1/attachments/${encodeURIComponent(attachmentId)}/download-url`, {
|
|
@@ -204,6 +233,7 @@ class AttachmentClient {
|
|
|
204
233
|
senderPublicKey: wk.senderPublicKey,
|
|
205
234
|
nonce: wk.nonce,
|
|
206
235
|
})),
|
|
236
|
+
thumbnailAttachmentId: ref.thumbnailAttachmentId ?? '',
|
|
207
237
|
};
|
|
208
238
|
}
|
|
209
239
|
/** Convert a wire AttachmentRef (from a received message) into the public type. */
|
|
@@ -214,6 +244,7 @@ class AttachmentClient {
|
|
|
214
244
|
mimeType: wire.mimeType,
|
|
215
245
|
sizeBytes: Number(wire.sizeBytes),
|
|
216
246
|
sha256: wire.sha256,
|
|
247
|
+
thumbnailAttachmentId: wire.thumbnailAttachmentId ? wire.thumbnailAttachmentId : undefined,
|
|
217
248
|
encryptionType: wire.encryptionType === 1 ? 'CLEARTEXT' : 'E2EE',
|
|
218
249
|
wrappedKeys: (wire.wrappedKeys ?? []).map((wk) => ({
|
|
219
250
|
deviceId: wk.deviceId,
|
|
@@ -27,6 +27,12 @@ export interface AttachmentRef {
|
|
|
27
27
|
encryptionType: AttachmentEncryptionType;
|
|
28
28
|
/** Empty for CLEARTEXT. One entry per recipient device for E2EE. */
|
|
29
29
|
wrappedKeys: DeviceWrappedKey[];
|
|
30
|
+
/**
|
|
31
|
+
* Optional. The attachmentId of a separate attachment holding a preview
|
|
32
|
+
* thumbnail. Present only when the sender chose to attach one. Download it
|
|
33
|
+
* like any attachment via {@link DropOnAirClient.downloadAttachment}.
|
|
34
|
+
*/
|
|
35
|
+
thumbnailAttachmentId?: string;
|
|
30
36
|
}
|
|
31
37
|
/** Optional metadata for {@link DropOnAirClient.createUploadSession}. */
|
|
32
38
|
export interface CreateUploadSessionOptions {
|
|
@@ -66,6 +72,15 @@ export interface PrepareAttachmentOptions {
|
|
|
66
72
|
mimeType?: string;
|
|
67
73
|
/** Progress callback called with bytes uploaded so far. */
|
|
68
74
|
onUploadProgress?: (bytesUploaded: number, totalBytes: number) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Optional preview thumbnail bytes. Entirely the developer's choice - if
|
|
77
|
+
* provided, the SDK uploads it as a separate attachment (encrypted with the
|
|
78
|
+
* same scheme as the main file) and links it via thumbnailAttachmentId. If
|
|
79
|
+
* omitted, the AttachmentRef simply has no thumbnail.
|
|
80
|
+
*/
|
|
81
|
+
thumbnail?: Uint8Array;
|
|
82
|
+
/** Mime type of the thumbnail bytes (defaults to 'image/jpeg'). */
|
|
83
|
+
thumbnailMimeType?: string;
|
|
69
84
|
}
|
|
70
85
|
/** Bytes payload returned by downloadAttachment. */
|
|
71
86
|
export interface DownloadedAttachment {
|
|
@@ -93,6 +93,7 @@ export declare class MessagingClient implements DropOnAirClient {
|
|
|
93
93
|
createUploadSession(options: CreateUploadSessionOptions): Promise<UploadSession>;
|
|
94
94
|
finalizeAttachment(attachmentId: string, sha256: string): Promise<void>;
|
|
95
95
|
downloadAttachment(ref: AttachmentRef): Promise<DownloadedAttachment>;
|
|
96
|
+
revokeAttachment(attachmentId: string): Promise<void>;
|
|
96
97
|
connect(): Promise<void>;
|
|
97
98
|
disconnect(): void;
|
|
98
99
|
sendMessage(toUserId: string, plaintextMessage: string, options?: {
|
|
@@ -213,6 +214,15 @@ export declare class MessagingClient implements DropOnAirClient {
|
|
|
213
214
|
createGroup(name: string, memberUserIds?: string[]): Promise<GroupInfo>;
|
|
214
215
|
listGroups(): Promise<GroupInfo[]>;
|
|
215
216
|
getGroup(groupId: string): Promise<GroupInfo>;
|
|
217
|
+
/**
|
|
218
|
+
* Update a group. Any omitted field is left unchanged. `readReceiptsVisibleToGroup`
|
|
219
|
+
* (Phase 2e) controls whether members' group read receipts are visible to
|
|
220
|
+
* the whole group or stay own-device only.
|
|
221
|
+
*/
|
|
222
|
+
updateGroup(groupId: string, update: {
|
|
223
|
+
name?: string;
|
|
224
|
+
readReceiptsVisibleToGroup?: boolean;
|
|
225
|
+
}): Promise<GroupInfo>;
|
|
216
226
|
addGroupMembers(groupId: string, userIds: string[]): Promise<GroupInfo>;
|
|
217
227
|
removeGroupMember(groupId: string, userId: string): Promise<GroupInfo>;
|
|
218
228
|
deleteGroup(groupId: string): Promise<void>;
|
|
@@ -270,6 +270,9 @@ class MessagingClient {
|
|
|
270
270
|
async downloadAttachment(ref) {
|
|
271
271
|
return this.attachmentClient.downloadAttachment(ref);
|
|
272
272
|
}
|
|
273
|
+
async revokeAttachment(attachmentId) {
|
|
274
|
+
return this.attachmentClient.revokeAttachment(attachmentId);
|
|
275
|
+
}
|
|
273
276
|
async connect() {
|
|
274
277
|
this.log('connect_start');
|
|
275
278
|
this.shouldReconnect = true;
|
|
@@ -723,6 +726,7 @@ class MessagingClient {
|
|
|
723
726
|
messageId: frame.messageId,
|
|
724
727
|
conversationId: frame.conversationId || undefined,
|
|
725
728
|
timestamp: frame.timestamp,
|
|
729
|
+
fromUserId: frame.fromUserId || undefined,
|
|
726
730
|
};
|
|
727
731
|
for (const listener of this.readReceiptListeners) {
|
|
728
732
|
try {
|
|
@@ -878,6 +882,22 @@ class MessagingClient {
|
|
|
878
882
|
throw new Error(`getGroup failed (HTTP ${res.status})`);
|
|
879
883
|
return res.json();
|
|
880
884
|
}
|
|
885
|
+
/**
|
|
886
|
+
* Update a group. Any omitted field is left unchanged. `readReceiptsVisibleToGroup`
|
|
887
|
+
* (Phase 2e) controls whether members' group read receipts are visible to
|
|
888
|
+
* the whole group or stay own-device only.
|
|
889
|
+
*/
|
|
890
|
+
async updateGroup(groupId, update) {
|
|
891
|
+
const jwt = await this.getValidDropOnAirJwt(false);
|
|
892
|
+
const res = await this.fetchFn(`${this.httpUrl}/api/groups/${encodeURIComponent(groupId)}`, {
|
|
893
|
+
method: 'PUT',
|
|
894
|
+
headers: { Authorization: `Bearer ${jwt}`, 'Content-Type': 'application/json' },
|
|
895
|
+
body: JSON.stringify(update),
|
|
896
|
+
});
|
|
897
|
+
if (!res.ok)
|
|
898
|
+
throw new Error(`updateGroup failed (HTTP ${res.status})`);
|
|
899
|
+
return res.json();
|
|
900
|
+
}
|
|
881
901
|
async addGroupMembers(groupId, userIds) {
|
|
882
902
|
const jwt = await this.getValidDropOnAirJwt(false);
|
|
883
903
|
const res = await this.fetchFn(`${this.httpUrl}/api/groups/${encodeURIComponent(groupId)}/members`, {
|
package/dist/core/types.d.ts
CHANGED
|
@@ -58,6 +58,12 @@ export interface ReadReceiptEvent {
|
|
|
58
58
|
/** Optional peer userId / group id, echoed from markRead() for bucketing. */
|
|
59
59
|
conversationId?: string;
|
|
60
60
|
timestamp: number;
|
|
61
|
+
/**
|
|
62
|
+
* The user who read the message. Set when a group read receipt is fanned
|
|
63
|
+
* to other members (so you know WHICH member read it). Undefined / your own
|
|
64
|
+
* userId for plain own-device sync.
|
|
65
|
+
*/
|
|
66
|
+
fromUserId?: string;
|
|
61
67
|
}
|
|
62
68
|
export type ReadReceiptCallback = (event: ReadReceiptEvent) => void;
|
|
63
69
|
/**
|
|
@@ -110,6 +116,11 @@ export interface GroupInfo {
|
|
|
110
116
|
createdBy: string;
|
|
111
117
|
members: GroupMemberInfo[];
|
|
112
118
|
createdAt: number;
|
|
119
|
+
/**
|
|
120
|
+
* Phase 2e. When true, a member's group read receipt is fanned to all other
|
|
121
|
+
* members; when false it stays own-device only. Controlled via updateGroup().
|
|
122
|
+
*/
|
|
123
|
+
readReceiptsVisibleToGroup?: boolean;
|
|
113
124
|
}
|
|
114
125
|
export interface GroupMemberInfo {
|
|
115
126
|
userId: string;
|
|
@@ -274,6 +285,12 @@ export interface DropOnAirClient {
|
|
|
274
285
|
finalizeAttachment(attachmentId: string, sha256: string): Promise<void>;
|
|
275
286
|
/** Download (and for E2EE decrypt) an attachment referenced inside a received message. */
|
|
276
287
|
downloadAttachment(ref: import('../attachment/attachment-types').AttachmentRef): Promise<import('../attachment/attachment-types').DownloadedAttachment>;
|
|
288
|
+
/**
|
|
289
|
+
* Revoke an attachment you sent (Phase 2f). The platform stops issuing
|
|
290
|
+
* download URLs for it and notifies recipients. Bytes already downloaded
|
|
291
|
+
* cannot be recalled.
|
|
292
|
+
*/
|
|
293
|
+
revokeAttachment(attachmentId: string): Promise<void>;
|
|
277
294
|
/** Send a cleartext message to a user (no encryption). */
|
|
278
295
|
sendCleartextMessage(toUserId: string, plaintext: string): Promise<{
|
|
279
296
|
messageId: string;
|
|
@@ -324,6 +341,14 @@ export interface DropOnAirClient {
|
|
|
324
341
|
listGroups(): Promise<GroupInfo[]>;
|
|
325
342
|
/** Get details of a specific group. */
|
|
326
343
|
getGroup(groupId: string): Promise<GroupInfo>;
|
|
344
|
+
/**
|
|
345
|
+
* Update a group (requires OWNER/ADMIN role). Omitted fields are unchanged.
|
|
346
|
+
* `readReceiptsVisibleToGroup` toggles group-wide read-receipt visibility.
|
|
347
|
+
*/
|
|
348
|
+
updateGroup(groupId: string, update: {
|
|
349
|
+
name?: string;
|
|
350
|
+
readReceiptsVisibleToGroup?: boolean;
|
|
351
|
+
}): Promise<GroupInfo>;
|
|
327
352
|
/** Add members to a group (requires OWNER/ADMIN role). */
|
|
328
353
|
addGroupMembers(groupId: string, userIds: string[]): Promise<GroupInfo>;
|
|
329
354
|
/** Remove a member from a group (OWNER/ADMIN can remove others; anyone can leave). */
|
|
@@ -20,6 +20,7 @@ export interface WireAttachmentRef {
|
|
|
20
20
|
sha256: string;
|
|
21
21
|
encryptionType: number;
|
|
22
22
|
wrappedKeys?: WireDeviceWrappedKey[];
|
|
23
|
+
thumbnailAttachmentId?: string;
|
|
23
24
|
}
|
|
24
25
|
export interface WireEnvelope {
|
|
25
26
|
messageId: string;
|
|
@@ -158,6 +159,7 @@ export interface WireSyncFrame {
|
|
|
158
159
|
conversationId?: string;
|
|
159
160
|
timestamp: number;
|
|
160
161
|
payload?: string;
|
|
162
|
+
fromUserId?: string;
|
|
161
163
|
}
|
|
162
164
|
/** Tombstone frame, scope FOR_EVERYONE or FOR_ME. */
|
|
163
165
|
export interface WireMessageDeleteFrame {
|
|
@@ -59,7 +59,8 @@ const AttachmentRefType = new protobuf.Type('AttachmentRef')
|
|
|
59
59
|
.add(new protobuf.Field('sizeBytes', 4, 'int64'))
|
|
60
60
|
.add(new protobuf.Field('sha256', 5, 'string'))
|
|
61
61
|
.add(new protobuf.Field('encryptionType', 6, 'EncryptionType'))
|
|
62
|
-
.add(new protobuf.Field('wrappedKeys', 7, 'DeviceWrappedKey', 'repeated'))
|
|
62
|
+
.add(new protobuf.Field('wrappedKeys', 7, 'DeviceWrappedKey', 'repeated'))
|
|
63
|
+
.add(new protobuf.Field('thumbnailAttachmentId', 8, 'string'));
|
|
63
64
|
const EnvelopeType = new protobuf.Type('Envelope')
|
|
64
65
|
.add(EncryptionTypeEnum)
|
|
65
66
|
.add(DeviceEncryptedPayloadType) // nested type must be added first
|
|
@@ -225,7 +226,8 @@ const SyncFrameType = new protobuf.Type('SyncFrame')
|
|
|
225
226
|
.add(new protobuf.Field('messageId', 2, 'string'))
|
|
226
227
|
.add(new protobuf.Field('conversationId', 3, 'string'))
|
|
227
228
|
.add(new protobuf.Field('timestamp', 4, 'int64'))
|
|
228
|
-
.add(new protobuf.Field('payload', 5, 'string'))
|
|
229
|
+
.add(new protobuf.Field('payload', 5, 'string'))
|
|
230
|
+
.add(new protobuf.Field('fromUserId', 6, 'string'));
|
|
229
231
|
class ProtobufCodec {
|
|
230
232
|
encodeEnvelope(value) {
|
|
231
233
|
return EnvelopeType.encode(value).finish();
|
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.
|
|
10
|
+
export declare const SDK_VERSION = "0.13.0";
|
|
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.
|
|
13
|
+
exports.SDK_VERSION = '0.13.0';
|
|
14
14
|
/**
|
|
15
15
|
* Binary encrypted-payload format version.
|
|
16
16
|
* Included as the first byte of every encrypted payload so receivers can
|