@ixblix/sdk-js 0.4.1 → 0.4.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/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 +75 -11
- 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,17 +19,8 @@ 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
|
-
*/
|
|
27
22
|
consentStatus: ConsentStatus;
|
|
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;
|
|
23
|
+
consentedAt?: string;
|
|
33
24
|
}
|
|
34
25
|
/** Payload used to create a conversation for a contact. */
|
|
35
26
|
export interface ContactInput {
|
|
@@ -206,8 +197,53 @@ export interface Message {
|
|
|
206
197
|
clientMessageId?: string | null;
|
|
207
198
|
/** Identifier of the operator that sent this message (COMPANY-sent only). */
|
|
208
199
|
operatorUuid?: string;
|
|
200
|
+
/** Identity of the operator that sent this message (COMPANY-sent only). */
|
|
201
|
+
operator?: Operator;
|
|
202
|
+
/**
|
|
203
|
+
* Identifier of the message this one replies to, when it is a reply.
|
|
204
|
+
* Absent/null when the message is not a reply.
|
|
205
|
+
*/
|
|
206
|
+
replyToId?: string | null;
|
|
207
|
+
/**
|
|
208
|
+
* The replied-to message (one level deep), so the quote can be rendered
|
|
209
|
+
* without an extra request. Null when the message is not a reply or the
|
|
210
|
+
* original message was deleted.
|
|
211
|
+
*/
|
|
212
|
+
replyTo?: Message | null;
|
|
213
|
+
/** Emoji reactions attached to this message. */
|
|
214
|
+
reactions?: MessageReaction[];
|
|
209
215
|
sentAt: string;
|
|
210
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* An emoji reaction attached to a message.
|
|
219
|
+
*
|
|
220
|
+
* A reactor holds at most one reaction per message, so changing the emoji
|
|
221
|
+
* replaces the previous one. The reactor is the customer (`CONTACT`) or an
|
|
222
|
+
* operator (`COMPANY`).
|
|
223
|
+
*/
|
|
224
|
+
export interface MessageReaction {
|
|
225
|
+
id: string;
|
|
226
|
+
messageId: string;
|
|
227
|
+
emoji: string;
|
|
228
|
+
senderType: SenderType;
|
|
229
|
+
/** Identifier of the operator that reacted (COMPANY reactions only). */
|
|
230
|
+
operatorUuid?: string | null;
|
|
231
|
+
createdAt: string;
|
|
232
|
+
}
|
|
233
|
+
/** Result of adding, replacing or removing an emoji reaction. */
|
|
234
|
+
export interface MessageReactionResult {
|
|
235
|
+
conversationId: string;
|
|
236
|
+
messageId: string;
|
|
237
|
+
/** The message's reactions after the change. */
|
|
238
|
+
reactions: MessageReaction[];
|
|
239
|
+
/** `added` when a reaction was set or replaced, `removed` when cleared. */
|
|
240
|
+
action: "added" | "removed";
|
|
241
|
+
/** The emoji that was set, or null when removed. */
|
|
242
|
+
emoji: string | null;
|
|
243
|
+
senderType: SenderType;
|
|
244
|
+
operatorUuid?: string | null;
|
|
245
|
+
reactedAt: string;
|
|
246
|
+
}
|
|
211
247
|
/** Metadata of a media file attached to a message. */
|
|
212
248
|
export interface Media {
|
|
213
249
|
id: string;
|
|
@@ -246,6 +282,10 @@ export interface RegisterCompanyInput {
|
|
|
246
282
|
planId?: string;
|
|
247
283
|
paymentProvider?: string;
|
|
248
284
|
confirmationWebhookUrl?: string;
|
|
285
|
+
/** Contact e-mail forwarded to the gateway as the checkout customer e-mail. */
|
|
286
|
+
email?: string;
|
|
287
|
+
/** Tax id (CPF/CNPJ) required by some gateways such as Asaas. */
|
|
288
|
+
taxId?: string;
|
|
249
289
|
}
|
|
250
290
|
/** Payment instructions returned when registering a company. */
|
|
251
291
|
export interface PaymentInstructions {
|
|
@@ -255,6 +295,11 @@ export interface PaymentInstructions {
|
|
|
255
295
|
currency: string;
|
|
256
296
|
confirmationUrl: string;
|
|
257
297
|
status: string;
|
|
298
|
+
/**
|
|
299
|
+
* Hosted checkout URL the customer must be redirected to. Absent for free
|
|
300
|
+
* plans and for providers that settle the charge inline.
|
|
301
|
+
*/
|
|
302
|
+
checkoutUrl?: string;
|
|
258
303
|
}
|
|
259
304
|
/** Result of registering a company. */
|
|
260
305
|
export interface RegisterCompanyResult {
|
|
@@ -321,7 +366,7 @@ export interface OriginalChannelMessageInput {
|
|
|
321
366
|
metadata?: Record<string, unknown>;
|
|
322
367
|
}
|
|
323
368
|
/** Webhook event payloads ixblix may deliver to a company. */
|
|
324
|
-
export type WebhookEvent = CompanyActivatedEvent | MessageReceivedEvent | MessageReadEvent | CustomerJoinedEvent | ConversationClosedEvent | PresenceEvent | BalanceLowEvent;
|
|
369
|
+
export type WebhookEvent = CompanyActivatedEvent | MessageReceivedEvent | MessageReadEvent | MessageReactionEvent | CustomerJoinedEvent | ConversationClosedEvent | PresenceEvent | BalanceLowEvent;
|
|
325
370
|
/** Delivered when a company is activated after payment confirmation. */
|
|
326
371
|
export interface CompanyActivatedEvent {
|
|
327
372
|
event: "COMPANY_ACTIVATED";
|
|
@@ -335,6 +380,8 @@ export interface MessageReceivedEvent {
|
|
|
335
380
|
companyId: string;
|
|
336
381
|
conversationId: string;
|
|
337
382
|
messageId: string;
|
|
383
|
+
/** Identifier of the message this one replies to, when it is a reply. */
|
|
384
|
+
replyToId?: string | null;
|
|
338
385
|
sentAt: string;
|
|
339
386
|
}
|
|
340
387
|
/** Delivered when the customer reads a company-sent message. */
|
|
@@ -345,6 +392,23 @@ export interface MessageReadEvent {
|
|
|
345
392
|
messageId: string;
|
|
346
393
|
readAt: string;
|
|
347
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Delivered when a message reaction is added, replaced or removed.
|
|
397
|
+
*
|
|
398
|
+
* `emoji` is null when the reaction was removed. `senderType` identifies who
|
|
399
|
+
* reacted: `CONTACT` for the customer, `COMPANY` for an operator.
|
|
400
|
+
*/
|
|
401
|
+
export interface MessageReactionEvent {
|
|
402
|
+
event: "MESSAGE_REACTION";
|
|
403
|
+
companyId: string;
|
|
404
|
+
conversationId: string;
|
|
405
|
+
messageId: string;
|
|
406
|
+
emoji: string | null;
|
|
407
|
+
action: "added" | "removed";
|
|
408
|
+
senderType: SenderType;
|
|
409
|
+
operatorUuid?: string | null;
|
|
410
|
+
reactedAt: string;
|
|
411
|
+
}
|
|
348
412
|
/** Delivered when the customer joins the secure conversation and registers its public key. */
|
|
349
413
|
export interface CustomerJoinedEvent {
|
|
350
414
|
event: "CUSTOMER_JOINED";
|
package/dist/webhooks.js
CHANGED
package/dist/webhooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG1D,iEAAiE;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAC7D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,sCAAsC;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAUrD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B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,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QACpD;YACE,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAa,EACb,MAAc,EACd,SAAkB;IAElB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC;SAC1C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC5B,MAAM,CAAC,KAAK,CAAC,CAAC;IACjB,MAAM,WAAW,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.3",
|
|
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",
|