Releases: xmtp/xmtp-js
@xmtp/browser-sdk@6.0.1
Fixed reply content type exports
@xmtp/browser-sdk@6.0.0
This release introduces breaking changes and new features. If you've been building on a previous release, updating your app to use this release will require changes to your existing code.
BREAKING CHANGES
Removed features
- Removed
uploadDebugArchivemethod fromClient.DebugInformation - Removed
debugEventsEnabledclient option - Removed deprecated
Client.versionstatic property (useClient.libxmtpVersioninstead) - Removed
Conversation.sendOptimisticmethod (use dedicated send methods with theoptimisticparameter instead) - Removed
codecFor,encodeContent,decodeContent, andprepareForSendclient methods (content encoding is now handled by dedicated send methods) - Removed
Conversation.isCommitLogForkedproperty - Removed
DecodedMessage.compressionproperty - Removed
DecodedMessage.parametersproperty - Removed
MessageKindandMessageDeliveryStatustype exports (useGroupMessageKindandDeliveryStatusenums instead) - Removed most
Safe*conversion types and functions from exports (these were mostly for internal usage and are no longer necessary):- Types:
SafeContentTypeId,SafeEncodedContent,SafeMessage,SafeListMessagesOptions,SafeSendMessageOpts,SafeListConversationsOptions,SafePermissionPolicySet,SafeCreateGroupOptions,SafeCreateDmOptions,SafeInstallation,SafeInboxState,SafeConsent,SafeGroupMember,SafeHmacKey,SafeHmacKeys,SafeMessageDisappearingSettings,SafeKeyPackageStatus,SafeXMTPCursor,SafeConversationDebugInfo,SafeApiStats,SafeIdentityStats - Functions:
toContentTypeId,fromContentTypeId,toSafeContentTypeId,fromSafeContentTypeId,toEncodedContent,fromEncodedContent,toSafeEncodedContent,fromSafeEncodedContent,toSafeMessage,toSafeListMessagesOptions,fromSafeListMessagesOptions,toSafeSendMessageOpts,fromSafeSendMessageOpts,toSafeListConversationsOptions,fromSafeListConversationsOptions,toSafePermissionPolicySet,fromSafePermissionPolicySet,toSafeCreateGroupOptions,fromSafeCreateGroupOptions,toSafeCreateDmOptions,fromSafeCreateDmOptions,toSafeInstallation,toSafeInboxState,toSafeConsent,fromSafeConsent,toSafeGroupMember,fromSafeGroupMember,toSafeHmacKey,toSafeMessageDisappearingSettings,fromSafeMessageDisappearingSettings,toSafeKeyPackageStatus,toSafeConversationDebugInfo,toSafeApiStats,toSafeIdentityStats
- Types:
Updated types
Many types that were previously string literals or interfaces are now numeric enums.
The following types are now numeric enums:
ConsentEntityTypeConsentStateContentTypeConversationTypeDeliveryStatusGroupMembershipStateGroupMessageKindGroupPermissionsOptionsIdentifierKindLogLevelMetadataFieldPermissionLevelPermissionPolicyPermissionUpdateTypeSortDirection
Other type updates:
DecodedMessage.kindanddeliveryStatusfields now use enum values instead of strings- Conversation type value is now an enum in metadata
loggingLevelclient option is now usesLogLevelnumeric enum
// DecodedMessage.kind and deliveryStatus now use enums
// OLD
if (message.kind === "application") { ... }
if (message.deliveryStatus === "published") { ... }
// NEW
import { GroupMessageKind, DeliveryStatus } from "@xmtp/browser-sdk";
if (message.kind === GroupMessageKind.Application) { ... }
if (message.deliveryStatus === DeliveryStatus.Published) { ... }
// `loggingLevel` client option is now uses `LogLevel` numeric enum
import { LogLevel } from "@xmtp/browser-sdk";
// OLD
const client = await Client.create(signer, { loggingLevel: "off" });
// NEW
const client = await Client.create(signer, { loggingLevel: LogLevel.Off });
// Conversation type value is now an enum in metadata
// OLD
if (conversation.metadata.conversationType === "group") { ... }
// NEW
import { ConversationType } from "@xmtp/browser-sdk";
if (conversation.metadata.conversationType === ConversationType.Group) { ... }Refactored or renamed functions
Method names have been updated to follow a consistent naming convention across the SDK. Methods that make network requests now use fetch prefix to distinguish them from local operations. Conversation creation methods now use create prefix for clarity. Several properties that could return variable internal state have been converted to functions.
- Updated
Conversation.sendmethod signature - Renamed
Client.getKeyPackageStatusesForInstallationIdstoClient.fetchKeyPackageStatuses - Renamed
Client.getInboxIdByIdentifiertoClient.fetchInboxIdByIdentifier - Renamed static
Client.inboxStateFromInboxIdsto staticClient.fetchInboxStates - Renamed
Conversation.getHmacKeystoConversation.hmacKeys Conversation.consentStateis now a function- Renamed
Conversations.getDmByIdentifiertoConversations.fetchDmByIdentifier - Renamed
Conversations.newGroupOptimistictoConversations.createGroupOptimistic - Renamed
Conversations.newGroupWithIdentifierstoConversations.createGroupWithIdentifiers - Renamed
Conversations.newDmWithIdentifiertoConversations.createDmWithIdentifier - Renamed
Conversations.newGrouptoConversations.createGroup - Renamed
Conversations.newDmtoConversations.createDm Group.permissionsis now a functionGroup.isPendingRemovalis now a functionGroup.adminsproperty is nowGroup.listAdminsfunctionGroup.superAdminsproperty is nowGroup.listSuperAdminsfunction- Removed
Preferences.getLatestInboxState - Refactored
Preferences.inboxState - Added
Preferences.fetchInboxState - Refactored
Preferences.inboxStateFromInboxIdsintoPreferences.getInboxStatesandPreferences.fetchInboxStates - Renamed
Dm.getDuplicateDmstoDm.duplicateDms
// Conversation.send method signature changed
// OLD
await conversation.send("hello");
await conversation.send(reactionContent, ContentTypeReaction);
// NEW - use dedicated send methods for built-in content types (see below for more details)
await conversation.sendText("hello");
await conversation.sendReaction(reaction);
// NEW - use send() for custom content types with EncodedContent
await conversation.send(encodedContent, {
shouldPush: true,
optimistic: false,
});
// Properties that are now functions
// OLD
const consentState = conversation.consentState;
const permissions = group.permissions;
const isPendingRemoval = group.isPendingRemoval;
const admins = group.admins;
const superAdmins = group.superAdmins;
// NEW
const consentState = conversation.consentState();
const permissions = group.permissions();
const isPendingRemoval = group.isPendingRemoval();
const admins = group.listAdmins();
const superAdmins = group.listSuperAdmins();
// Creating conversations
// OLD
const group = await client.conversations.newGroup(inboxIds);
const dm = await client.conversations.newDm(inboxId);
const groupWithIdentifiers =
await client.conversations.newGroupWithIdentifiers(identifiers);
// NEW
const group = await client.conversations.createGroup(inboxIds);
const dm = await client.conversations.createDm(inboxId);
const groupWithIdentifiers =
await client.conversations.createGroupWithIdentifiers(identifiers);
// Preferences inbox state methods
// OLD
const inboxState = await client.preferences.inboxState();
const latestInboxState = await client.preferences.inboxState(true);
const latestInboxStateForInboxId =
await client.preferences.getLatestInboxState(inboxId); // this function removed
const inboxStates = await client.preferences.inboxStateFromInboxIds(
inboxIds,
false,
);
const latestInboxStates = await client.preferences.inboxStateFromInboxIds(
inboxIds,
true,
);
// NEW
const inboxState = await client.preferences.inboxState();
const latestInboxState = await client.preferences.fetchInboxState();
const inboxStates = await client.preferences.getInboxStates(inboxIds);
const latestInboxStates = await client.preferences.fetchInboxStates(inboxIds);NEW FEATURES
Built-in content types
Previously, sending non-text messages required installing separate content type packages and registering codecs with the client. This release simplifies messaging by including all official content types directly in the SDK. You no longer need to manage codec registration, just use the dedicated send methods for each content type.
Supported content types include: text, markdown, reactions, replies, read receipts, transaction references, wallet send calls, actions, intents, attachments, remote attachments, and multiple remote attachments.
Enriched messages
To make it easier to build rich messaging experiences, messages now include additional context. Each message includes the number of replies it has received and an array of reaction messages. This eliminates the need for separate queries to count replies or fetch reactions for a message thread.
Reply messages also include the original message being replied to, allowing you to display the parent message context without an additional lookup.
import { contentTypeReply, type Reply } from "@xmtp/browser-sdk";
import { contentTypesAreEqual } from "@xmtp/content-type-primitives";
const messages = await group.messages();
for (const message of messages) {
// number of replies to a message
console.log(`message ${message.id} has ${message.numReplies} replies`);
// message.reactions is an array of reaction messages
console.log(
`message ${message.id} has ${message.reactions.length} reactions`,
);
// reply messages include the original message
// note: contentTypeReply() is async in browser SDK
if (contentTypesAreEqual(message.contentType, await contentTypeReply())) {
const reply = message.content as Reply;
// the decoded content of the reply
console.log(...@xmtp/content-type-primitives@3.0.0
This release introduces breaking changes and new features to replace previous functionality. If you've been building on a previous release, this one will require an update to your existing code.
BREAKING CHANGES
- Updated
ContentTypeIdexport - Updated
EncodedContentexport - Updated
ContentCodecexport - Removed
CodecMapandCodecRegistryexports
New features
- Added
contentTypesAreEqualto replaceContentTypeId.sameAs - Added
contentTypeToStringto replaceContentTypeId.toString - Added
contentTypeFromStringto replaceContentTypeId.fromString
@xmtp/agent-sdk@1.2.4
Patch Changes
- 1f7e6ed: Exposed command list in CommandRouter middleware
@xmtp/agent-sdk@1.2.3
Patch Changes
- d655457: Added support for encrypted file attachments
@xmtp/node-sdk@4.6.0
This release introduces new features. If you've been building on a previous release, this one should be a drop-in replacement. Update as soon as possible to take advantage of these enhancements.
Self-removal from group chats
This feature enables a member to leave a group chat on their own. Previously, a member could be removed only by other members with appropriate permissions. This update addresses user privacy concerns and reduces the need for manual member removal by admins.
To see if a user has requested removal, check the new isPendingRemoval property.
// request removal from group
await group.requestRemoval();
console.log(group.isPendingRemoval); // trueTo learn more, see Leave a group and XIP-75: Self-removal support for XMTP/MLS groups.
New appData metadata for groups
Groups now support an appData metadata field for storing custom application-specific data. This field enables developers to attach arbitrary data to groups, such as configuration settings.
The appData field can store up to 8,192 bytes of string data.
// access app data
const appData = group.appData;
// update app data with custom JSON
await group.updateAppData(
JSON.stringify({
muted: false,
pinned: true,
}),
);
// retrieve and parse the updated data
const appData = JSON.parse(group.appData);
console.log(appData.pinned); // true@xmtp/content-type-remote-attachment@2.0.4
Patch Changes
- cf4337e: Added error handling for fetching remote attachments
@xmtp/browser-sdk@5.3.0
This release introduces new features. If you've been building on a previous release, this one should be a drop-in replacement. Update as soon as possible to take advantage of these enhancements.
Self-removal from group chats
This feature enables a member to leave a group chat on their own. Previously, a member could be removed only by other members with appropriate permissions. This update addresses user privacy concerns and reduces the need for manual member removal by admins.
To see if a user has requested removal, check the new isPendingRemoval property.
// request removal from group
await group.requestRemoval();
console.log(group.isPendingRemoval); // trueTo learn more, see Leave a group and XIP-75: Self-removal support for XMTP/MLS groups.
New appData metadata for groups
Groups now support an appData metadata field for storing custom application-specific data. This field enables developers to attach arbitrary data to groups, such as configuration settings.
The appData field can store up to 8,192 bytes of string data.
// access app data
const appData = group.appData;
// update app data with custom JSON
await group.updateAppData(
JSON.stringify({
muted: false,
pinned: true,
}),
);
// retrieve and parse the updated data
const appData = JSON.parse(group.appData);
console.log(appData.pinned); // true@xmtp/agent-sdk@1.2.2
Upgraded Node SDK to 4.6.0
@xmtp/agent-sdk@1.2.1
Patch Changes
- 1f737c5: Fixed LibXMTP version reporting