@ixblix/sdk-js 0.4.0 → 0.4.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/dist/client.d.ts +20 -6
- package/dist/client.js +33 -5
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +77 -2
- package/dist/webhooks.js +1 -0
- package/dist/webhooks.js.map +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActivateCompanyResult, CompanyBalance, CompanyCustomization, CompanyCustomizationInput, CompanyEncryptionKey, CompanyProfile, ContactInput, ConversationKeys, CreateConversationResult, CreditPurchase, Media, Message, MessageEnvelope, OperatorInput, OriginalChannelMessageInput, PaymentProvidersResult, Plan, PurchaseCreditsResult, RegisterCompanyEncryptionKeyInput, RegisterCompanyInput, RegisterCompanyResult, UpdateOperatorResult } from "./types.js";
|
|
1
|
+
import type { ActivateCompanyResult, CompanyBalance, CompanyCustomization, CompanyCustomizationInput, CompanyEncryptionKey, CompanyProfile, ContactInput, ConversationKeys, CreateConversationResult, CreditPurchase, Media, Message, MessageEnvelope, MessageReactionResult, OperatorInput, OriginalChannelMessageInput, PaymentProvidersResult, Plan, PurchaseCreditsResult, RegisterCompanyEncryptionKeyInput, RegisterCompanyInput, RegisterCompanyResult, UpdateOperatorResult } from "./types.js";
|
|
2
2
|
/** Options for constructing an {@link IxblixClient}. */
|
|
3
3
|
export interface IxblixClientOptions {
|
|
4
4
|
/** Base URL of the ixblix API, e.g. `https://api.ixblix.app`. */
|
|
@@ -146,11 +146,24 @@ export declare class IxblixClient {
|
|
|
146
146
|
/**
|
|
147
147
|
* Send an encrypted message from the company to the contact. The message must
|
|
148
148
|
* already be encrypted to the customer's public key (see the crypto helpers).
|
|
149
|
-
* Optionally pass the operator uuid so it is attributed to the message
|
|
149
|
+
* Optionally pass the operator uuid so it is attributed to the message, and
|
|
150
|
+
* `replyToId` to send it as a reply to another message.
|
|
151
|
+
*/
|
|
152
|
+
sendCompanyMessage(conversationId: string, envelope: MessageEnvelope, contentType?: string, operatorUuid?: string, replyToId?: string | null): Promise<Message>;
|
|
153
|
+
/**
|
|
154
|
+
* List all messages of a conversation (content is always ciphertext).
|
|
155
|
+
* Each message includes its replied-to message (one level deep) and its
|
|
156
|
+
* emoji reactions.
|
|
150
157
|
*/
|
|
151
|
-
sendCompanyMessage(conversationId: string, envelope: MessageEnvelope, contentType?: string, operatorUuid?: string): Promise<Message>;
|
|
152
|
-
/** List all messages of a conversation (content is always ciphertext). */
|
|
153
158
|
listMessages(conversationId: string): Promise<Message[]>;
|
|
159
|
+
/**
|
|
160
|
+
* Add, replace or remove an emoji reaction on a message as the operator.
|
|
161
|
+
* A reactor holds at most one reaction per message; pass an empty `emoji` to
|
|
162
|
+
* remove the operator's existing reaction. Emits a `message_reaction`
|
|
163
|
+
* Socket.io event to the customer's chat app and a `MESSAGE_REACTION`
|
|
164
|
+
* webhook to the operator.
|
|
165
|
+
*/
|
|
166
|
+
reactToMessage(conversationId: string, messageId: string, emoji: string, operatorUuid?: string): Promise<MessageReactionResult>;
|
|
154
167
|
/**
|
|
155
168
|
* Mark a contact-sent message as read by the operator. Emits a
|
|
156
169
|
* `message_read` Socket.io event to the customer's chat app so the customer
|
|
@@ -175,9 +188,10 @@ export declare class IxblixClient {
|
|
|
175
188
|
/**
|
|
176
189
|
* Upload an encrypted media file from the company. `file.data` must be the
|
|
177
190
|
* ciphertext bytes produced by the media encryption helper. Optionally pass
|
|
178
|
-
* the operator uuid so the media message is attributed to the operator
|
|
191
|
+
* the operator uuid so the media message is attributed to the operator, and
|
|
192
|
+
* `replyToId` to send it as a reply to another message.
|
|
179
193
|
*/
|
|
180
|
-
sendCompanyMedia(conversationId: string, file: MediaUpload, envelope: MessageEnvelope, operatorUuid?: string): Promise<Message>;
|
|
194
|
+
sendCompanyMedia(conversationId: string, file: MediaUpload, envelope: MessageEnvelope, operatorUuid?: string, replyToId?: string | null): Promise<Message>;
|
|
181
195
|
/** Fetch the metadata (envelope + file info) of a media file. */
|
|
182
196
|
getMedia(mediaId: string): Promise<Media>;
|
|
183
197
|
/**
|
package/dist/client.js
CHANGED
|
@@ -225,9 +225,10 @@ export class IxblixClient {
|
|
|
225
225
|
/**
|
|
226
226
|
* Send an encrypted message from the company to the contact. The message must
|
|
227
227
|
* already be encrypted to the customer's public key (see the crypto helpers).
|
|
228
|
-
* Optionally pass the operator uuid so it is attributed to the message
|
|
228
|
+
* Optionally pass the operator uuid so it is attributed to the message, and
|
|
229
|
+
* `replyToId` to send it as a reply to another message.
|
|
229
230
|
*/
|
|
230
|
-
sendCompanyMessage(conversationId, envelope, contentType = "text", operatorUuid) {
|
|
231
|
+
sendCompanyMessage(conversationId, envelope, contentType = "text", operatorUuid, replyToId) {
|
|
231
232
|
return this.request("/api/messages/company", {
|
|
232
233
|
method: "POST",
|
|
233
234
|
body: JSON.stringify({
|
|
@@ -240,13 +241,36 @@ export class IxblixClient {
|
|
|
240
241
|
selfEncryptedKey: envelope.selfEncryptedKey,
|
|
241
242
|
keyId: envelope.keyId,
|
|
242
243
|
operatorUuid,
|
|
244
|
+
replyToId: replyToId ?? undefined,
|
|
243
245
|
}),
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* List all messages of a conversation (content is always ciphertext).
|
|
250
|
+
* Each message includes its replied-to message (one level deep) and its
|
|
251
|
+
* emoji reactions.
|
|
252
|
+
*/
|
|
247
253
|
listMessages(conversationId) {
|
|
248
254
|
return this.request(`/api/messages/${conversationId}`);
|
|
249
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Add, replace or remove an emoji reaction on a message as the operator.
|
|
258
|
+
* A reactor holds at most one reaction per message; pass an empty `emoji` to
|
|
259
|
+
* remove the operator's existing reaction. Emits a `message_reaction`
|
|
260
|
+
* Socket.io event to the customer's chat app and a `MESSAGE_REACTION`
|
|
261
|
+
* webhook to the operator.
|
|
262
|
+
*/
|
|
263
|
+
reactToMessage(conversationId, messageId, emoji, operatorUuid) {
|
|
264
|
+
return this.request("/api/messages/company/react", {
|
|
265
|
+
method: "POST",
|
|
266
|
+
body: JSON.stringify({
|
|
267
|
+
conversationId,
|
|
268
|
+
messageId,
|
|
269
|
+
emoji,
|
|
270
|
+
operatorUuid,
|
|
271
|
+
}),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
250
274
|
/**
|
|
251
275
|
* Mark a contact-sent message as read by the operator. Emits a
|
|
252
276
|
* `message_read` Socket.io event to the customer's chat app so the customer
|
|
@@ -284,9 +308,10 @@ export class IxblixClient {
|
|
|
284
308
|
/**
|
|
285
309
|
* Upload an encrypted media file from the company. `file.data` must be the
|
|
286
310
|
* ciphertext bytes produced by the media encryption helper. Optionally pass
|
|
287
|
-
* the operator uuid so the media message is attributed to the operator
|
|
311
|
+
* the operator uuid so the media message is attributed to the operator, and
|
|
312
|
+
* `replyToId` to send it as a reply to another message.
|
|
288
313
|
*/
|
|
289
|
-
async sendCompanyMedia(conversationId, file, envelope, operatorUuid) {
|
|
314
|
+
async sendCompanyMedia(conversationId, file, envelope, operatorUuid, replyToId) {
|
|
290
315
|
const form = new FormData();
|
|
291
316
|
form.append("conversationId", conversationId);
|
|
292
317
|
form.append("file", new Blob([file.data], { type: file.mimeType }), file.fileName);
|
|
@@ -298,6 +323,9 @@ export class IxblixClient {
|
|
|
298
323
|
if (operatorUuid) {
|
|
299
324
|
form.append("operatorUuid", operatorUuid);
|
|
300
325
|
}
|
|
326
|
+
if (replyToId) {
|
|
327
|
+
form.append("replyToId", replyToId);
|
|
328
|
+
}
|
|
301
329
|
const headers = {};
|
|
302
330
|
if (this.apiKey) {
|
|
303
331
|
headers["X-API-Key"] = this.apiKey;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;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M,EAAE,QAAQ,CAAC,MAAM;aACxB,CACF,CAAC;QACJ,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;QACjD,OAAO,EAAE,IAAI,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC;IACtD,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,4 +22,4 @@ export { loadOrCreateOperatorKey } from "./keypair.js";
|
|
|
22
22
|
export { parseWebhook, verifyWebhook } from "./webhooks.js";
|
|
23
23
|
export type { ParsedWebhook } from "./webhooks.js";
|
|
24
24
|
export { WEBHOOK_SIGNATURE_HEADER, WEBHOOK_ID_HEADER, WEBHOOK_EVENT_HEADER, } from "./webhooks.js";
|
|
25
|
-
export type { SenderType, ConversationKeyStatus, ConversationStatus, ConsentStatus, Contact, ContactInput, Conversation, CompanyCustomization, CompanyCustomizationInput, CompanyEncryptionKey, RegisterCompanyEncryptionKeyInput, CompanySummary, CompanyProfile, CreateConversationResult, ConversationKeys, RegisterCustomerKeyResult, EraseConversationResult, Operator, OperatorInput, UpdateOperatorResult, MessageEnvelope, Message, Media, Plan, RegisterCompanyInput, PaymentInstructions, RegisterCompanyResult, ActivateCompanyResult, CompanyBalance, CreditPurchase, PurchaseCreditsResult, PaymentProvidersResult, OriginalChannelMessageInput, WebhookEvent, CompanyActivatedEvent, MessageReceivedEvent, MessageReadEvent, CustomerJoinedEvent, ConversationClosedEvent, PresenceEvent, BalanceLowEvent, IxblixErrorBody, } from "./types.js";
|
|
25
|
+
export type { SenderType, ConversationKeyStatus, ConversationStatus, ConsentStatus, Contact, ContactInput, Conversation, CompanyCustomization, CompanyCustomizationInput, CompanyEncryptionKey, RegisterCompanyEncryptionKeyInput, CompanySummary, CompanyProfile, CreateConversationResult, ConversationKeys, RegisterCustomerKeyResult, EraseConversationResult, Operator, OperatorInput, UpdateOperatorResult, MessageEnvelope, Message, MessageReaction, MessageReactionResult, Media, Plan, RegisterCompanyInput, PaymentInstructions, RegisterCompanyResult, ActivateCompanyResult, CompanyBalance, CreditPurchase, PurchaseCreditsResult, PaymentProvidersResult, OriginalChannelMessageInput, WebhookEvent, CompanyActivatedEvent, MessageReceivedEvent, MessageReadEvent, MessageReactionEvent, CustomerJoinedEvent, ConversationClosedEvent, PresenceEvent, BalanceLowEvent, IxblixErrorBody, } from "./types.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -19,8 +19,17 @@ export interface Contact {
|
|
|
19
19
|
externalId: string;
|
|
20
20
|
name?: string;
|
|
21
21
|
metadata?: Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* LGPD consent status. Consent is memorized per company: once `GRANTED`, it
|
|
24
|
+
* is reused by every conversation with the same company and the customer is
|
|
25
|
+
* not asked again.
|
|
26
|
+
*/
|
|
22
27
|
consentStatus: ConsentStatus;
|
|
23
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Timestamp of the first time the customer granted consent for this company.
|
|
30
|
+
* Absent/null when consent was never granted.
|
|
31
|
+
*/
|
|
32
|
+
consentedAt?: string | null;
|
|
24
33
|
}
|
|
25
34
|
/** Payload used to create a conversation for a contact. */
|
|
26
35
|
export interface ContactInput {
|
|
@@ -186,10 +195,57 @@ export interface Message {
|
|
|
186
195
|
/** Present when the message carries an attached media file. */
|
|
187
196
|
mediaId?: string;
|
|
188
197
|
media?: Media;
|
|
198
|
+
/**
|
|
199
|
+
* Client-generated idempotency key, echoed back for contact-sent messages.
|
|
200
|
+
*
|
|
201
|
+
* The customer app renders an optimistic balloon before the request is
|
|
202
|
+
* answered and uses this id to reconcile it with the server-assigned message.
|
|
203
|
+
* Sending the same id twice returns the message created by the first attempt
|
|
204
|
+
* instead of creating a duplicate, which makes retries safe.
|
|
205
|
+
*/
|
|
206
|
+
clientMessageId?: string | null;
|
|
189
207
|
/** Identifier of the operator that sent this message (COMPANY-sent only). */
|
|
190
208
|
operatorUuid?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Identifier of the message this one replies to, when it is a reply.
|
|
211
|
+
* Absent/null when the message is not a reply.
|
|
212
|
+
*/
|
|
213
|
+
replyToId?: string | null;
|
|
214
|
+
/**
|
|
215
|
+
* The replied-to message (one level deep), so the quote can be rendered
|
|
216
|
+
* without an extra request. Null when the message is not a reply or the
|
|
217
|
+
* original message was deleted.
|
|
218
|
+
*/
|
|
219
|
+
replyTo?: Message | null;
|
|
220
|
+
/** Emoji reactions attached to this message. */
|
|
221
|
+
reactions?: MessageReaction[];
|
|
191
222
|
sentAt: string;
|
|
192
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* An emoji reaction attached to a message.
|
|
226
|
+
*
|
|
227
|
+
* A reactor holds at most one reaction per message, so changing the emoji
|
|
228
|
+
* replaces the previous one. The reactor is the customer (`CONTACT`) or an
|
|
229
|
+
* operator (`COMPANY`).
|
|
230
|
+
*/
|
|
231
|
+
export interface MessageReaction {
|
|
232
|
+
id: string;
|
|
233
|
+
messageId: string;
|
|
234
|
+
emoji: string;
|
|
235
|
+
senderType: SenderType;
|
|
236
|
+
/** Identifier of the operator that reacted (COMPANY reactions only). */
|
|
237
|
+
operatorUuid?: string | null;
|
|
238
|
+
createdAt: string;
|
|
239
|
+
}
|
|
240
|
+
/** Result of adding, replacing or removing a message reaction. */
|
|
241
|
+
export interface MessageReactionResult {
|
|
242
|
+
id: string;
|
|
243
|
+
messageId: string;
|
|
244
|
+
emoji: string | null;
|
|
245
|
+
senderType: SenderType;
|
|
246
|
+
operatorUuid?: string | null;
|
|
247
|
+
createdAt: string;
|
|
248
|
+
}
|
|
193
249
|
/** Metadata of a media file attached to a message. */
|
|
194
250
|
export interface Media {
|
|
195
251
|
id: string;
|
|
@@ -303,7 +359,7 @@ export interface OriginalChannelMessageInput {
|
|
|
303
359
|
metadata?: Record<string, unknown>;
|
|
304
360
|
}
|
|
305
361
|
/** Webhook event payloads ixblix may deliver to a company. */
|
|
306
|
-
export type WebhookEvent = CompanyActivatedEvent | MessageReceivedEvent | MessageReadEvent | CustomerJoinedEvent | ConversationClosedEvent | PresenceEvent | BalanceLowEvent;
|
|
362
|
+
export type WebhookEvent = CompanyActivatedEvent | MessageReceivedEvent | MessageReadEvent | MessageReactionEvent | CustomerJoinedEvent | ConversationClosedEvent | PresenceEvent | BalanceLowEvent;
|
|
307
363
|
/** Delivered when a company is activated after payment confirmation. */
|
|
308
364
|
export interface CompanyActivatedEvent {
|
|
309
365
|
event: "COMPANY_ACTIVATED";
|
|
@@ -317,6 +373,8 @@ export interface MessageReceivedEvent {
|
|
|
317
373
|
companyId: string;
|
|
318
374
|
conversationId: string;
|
|
319
375
|
messageId: string;
|
|
376
|
+
/** Identifier of the message this one replies to, when it is a reply. */
|
|
377
|
+
replyToId?: string | null;
|
|
320
378
|
sentAt: string;
|
|
321
379
|
}
|
|
322
380
|
/** Delivered when the customer reads a company-sent message. */
|
|
@@ -327,6 +385,23 @@ export interface MessageReadEvent {
|
|
|
327
385
|
messageId: string;
|
|
328
386
|
readAt: string;
|
|
329
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Delivered when a message reaction is added, replaced or removed.
|
|
390
|
+
*
|
|
391
|
+
* `emoji` is null when the reaction was removed. `senderType` identifies who
|
|
392
|
+
* reacted: `CONTACT` for the customer, `COMPANY` for an operator.
|
|
393
|
+
*/
|
|
394
|
+
export interface MessageReactionEvent {
|
|
395
|
+
event: "MESSAGE_REACTION";
|
|
396
|
+
companyId: string;
|
|
397
|
+
conversationId: string;
|
|
398
|
+
messageId: string;
|
|
399
|
+
emoji: string | null;
|
|
400
|
+
action: "added" | "removed";
|
|
401
|
+
senderType: SenderType;
|
|
402
|
+
operatorUuid?: string | null;
|
|
403
|
+
reactedAt: string;
|
|
404
|
+
}
|
|
330
405
|
/** Delivered when the customer joins the secure conversation and registers its public key. */
|
|
331
406
|
export interface CustomerJoinedEvent {
|
|
332
407
|
event: "CUSTOMER_JOINED";
|
package/dist/webhooks.js
CHANGED
package/dist/webhooks.js.map
CHANGED
|
@@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AAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAClD,IACE,WAAW,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM;QACzC,CAAC,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,EAC1C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixblix/sdk-js",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Official ixblix SDK for desk/CRM integrations. Create overflow conversations, exchange end-to-end encrypted messages and media, and manage company onboarding.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|