@xmtp/xmtp-js
Advanced tools
Comparing version 11.0.0-beta.10 to 11.0.0-beta.11
@@ -490,5 +490,5 @@ import { signature, publicKey, ciphertext, privateKey, authn, keystore, invitation, messageApi, content, message } from '@xmtp/proto'; | ||
*/ | ||
declare class Stream<T> { | ||
declare class Stream<T, ClientType = any> { | ||
topics: string[]; | ||
client: Client; | ||
client: Client<ClientType>; | ||
messages: T[]; | ||
@@ -499,6 +499,6 @@ resolvers: ((value: IteratorResult<T>) => void)[]; | ||
onConnectionLost?: OnConnectionLostCallback; | ||
constructor(client: Client, topics: string[], decoder: MessageDecoder<T>, contentTopicUpdater?: ContentTopicUpdater<T>, onConnectionLost?: OnConnectionLostCallback); | ||
constructor(client: Client<ClientType>, topics: string[], decoder: MessageDecoder<T>, contentTopicUpdater?: ContentTopicUpdater<T>, onConnectionLost?: OnConnectionLostCallback); | ||
private newMessageCallback; | ||
private start; | ||
static create<T>(client: Client, topics: string[], decoder: MessageDecoder<T>, contentTopicUpdater?: ContentTopicUpdater<T>, onConnectionLost?: OnConnectionLostCallback): Promise<Stream<T>>; | ||
static create<T, ClientType = string>(client: Client<ClientType>, topics: string[], decoder: MessageDecoder<T>, contentTopicUpdater?: ContentTopicUpdater<T>, onConnectionLost?: OnConnectionLostCallback): Promise<Stream<T, ClientType>>; | ||
[Symbol.asyncIterator](): AsyncIterableIterator<T>; | ||
@@ -513,11 +513,11 @@ return(): Promise<IteratorResult<T>>; | ||
*/ | ||
declare class Conversations { | ||
declare class Conversations<ContentTypes = any> { | ||
private client; | ||
private v1JobRunner; | ||
private v2JobRunner; | ||
constructor(client: Client); | ||
constructor(client: Client<ContentTypes>); | ||
/** | ||
* List all conversations with the current wallet found in the network. | ||
*/ | ||
list(): Promise<Conversation[]>; | ||
list(): Promise<Conversation<ContentTypes>[]>; | ||
/** | ||
@@ -527,3 +527,3 @@ * List all conversations stored in the client cache, which may not include | ||
*/ | ||
listFromCache(): Promise<Conversation[]>; | ||
listFromCache(): Promise<Conversation<ContentTypes>[]>; | ||
private listV1Conversations; | ||
@@ -536,3 +536,3 @@ /** | ||
private getV1ConversationsFromKeystore; | ||
updateV2Conversations(startTime?: Date): Promise<ConversationV2[]>; | ||
updateV2Conversations(startTime?: Date): Promise<ConversationV2<ContentTypes>[]>; | ||
private decodeInvites; | ||
@@ -547,3 +547,3 @@ private saveInviteResponseToConversation; | ||
*/ | ||
stream(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<Conversation>>; | ||
stream(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<Conversation<ContentTypes>, ContentTypes>>; | ||
/** | ||
@@ -556,3 +556,3 @@ * Streams messages from all conversations. | ||
*/ | ||
streamAllMessages(onConnectionLost?: OnConnectionLostCallback): Promise<AsyncGenerator<DecodedMessage>>; | ||
streamAllMessages(onConnectionLost?: OnConnectionLostCallback): Promise<AsyncGenerator<DecodedMessage<ContentTypes>>>; | ||
private getIntroductionPeers; | ||
@@ -562,3 +562,3 @@ /** | ||
*/ | ||
newConversation(peerAddress: string, context?: InvitationContext): Promise<Conversation>; | ||
newConversation(peerAddress: string, context?: InvitationContext): Promise<Conversation<ContentTypes>>; | ||
private createV2Convo; | ||
@@ -596,2 +596,10 @@ private getPeerAddress; | ||
declare const ContentTypeText: ContentTypeId; | ||
declare class TextCodec implements ContentCodec<string> { | ||
get contentType(): ContentTypeId; | ||
encode(content: string): EncodedContent; | ||
decode(content: EncodedContent): string; | ||
fallback(content: string): string | undefined; | ||
} | ||
/** | ||
@@ -665,2 +673,5 @@ * Where message backups should be stored | ||
declare type GetMessageContentTypeFromClient<C> = C extends Client<infer T> ? T : never; | ||
declare type ExtractDecodedType<C> = C extends ContentCodec<infer T> ? T : never; | ||
declare const Compression: typeof content.Compression; | ||
@@ -802,3 +813,3 @@ declare type ListMessagesOptions = { | ||
*/ | ||
declare class Client { | ||
declare class Client<ContentTypes = any> { | ||
address: string; | ||
@@ -818,3 +829,3 @@ keystore: Keystore; | ||
*/ | ||
get conversations(): Conversations; | ||
get conversations(): Conversations<ContentTypes>; | ||
get backupType(): BackupType; | ||
@@ -828,3 +839,5 @@ get signedPublicKeyBundle(): SignedPublicKeyBundle; | ||
*/ | ||
static create(wallet: Signer | null, opts?: Partial<ClientOptions>): Promise<Client>; | ||
static create<ContentCodecs extends ContentCodec<any>[] = []>(wallet: Signer | null, opts?: Partial<ClientOptions> & { | ||
codecs?: ContentCodecs; | ||
}): Promise<Client<ExtractDecodedType<[...ContentCodecs, TextCodec][number]> | undefined>>; | ||
/** | ||
@@ -840,3 +853,5 @@ * Export the XMTP PrivateKeyBundle from the SDK as a `Uint8Array`. | ||
*/ | ||
static getKeys(wallet: Signer | null, opts?: Partial<ClientOptions>): Promise<Uint8Array>; | ||
static getKeys<U>(wallet: Signer | null, opts?: Partial<ClientOptions> & { | ||
codecs?: U; | ||
}): Promise<Uint8Array>; | ||
/** | ||
@@ -887,3 +902,3 @@ * Tells the caller whether `getKeys` will work for them or throw | ||
*/ | ||
registerCodec(codec: ContentCodec<any>): void; | ||
registerCodec<Codec extends ContentCodec<any>>(codec: Codec): Client<ContentTypes | ExtractDecodedType<Codec>>; | ||
/** | ||
@@ -898,3 +913,9 @@ * Find a matching codec for a given `ContentTypeId` from the | ||
*/ | ||
encodeContent(content: any, options?: SendOptions): Promise<Uint8Array>; | ||
encodeContent(content: ContentTypes, options?: SendOptions): Promise<Uint8Array>; | ||
decodeContent(contentBytes: Uint8Array): Promise<{ | ||
content: ContentTypes; | ||
contentType: ContentTypeId; | ||
error?: Error; | ||
contentFallback?: string; | ||
}>; | ||
listInvitations(opts?: ListMessagesOptions): Promise<messageApi.Envelope[]>; | ||
@@ -1035,3 +1056,3 @@ /** | ||
*/ | ||
interface Conversation { | ||
interface Conversation<ContentTypes = any> { | ||
conversationVersion: 'v1' | 'v2'; | ||
@@ -1076,7 +1097,7 @@ /** | ||
*/ | ||
messages(opts?: ListMessagesOptions): Promise<DecodedMessage[]>; | ||
messages(opts?: ListMessagesOptions): Promise<DecodedMessage<ContentTypes>[]>; | ||
/** | ||
* @deprecated | ||
*/ | ||
messagesPaginated(opts?: ListMessagesPaginatedOptions): AsyncGenerator<DecodedMessage[]>; | ||
messagesPaginated(opts?: ListMessagesPaginatedOptions): AsyncGenerator<DecodedMessage<ContentTypes>[]>; | ||
/** | ||
@@ -1086,3 +1107,3 @@ * Takes a XMTP envelope as input and will decrypt and decode it | ||
*/ | ||
decodeMessage(env: messageApi.Envelope): Promise<DecodedMessage>; | ||
decodeMessage(env: messageApi.Envelope): Promise<DecodedMessage<ContentTypes>>; | ||
/** | ||
@@ -1100,3 +1121,3 @@ * Return a `Stream` of new messages in this conversation. | ||
*/ | ||
streamMessages(): Promise<Stream<DecodedMessage>>; | ||
streamMessages(): Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>; | ||
/** | ||
@@ -1110,4 +1131,3 @@ * Send a message into the conversation | ||
*/ | ||
send(content: any, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
options?: SendOptions): Promise<DecodedMessage>; | ||
send(content: Exclude<ContentTypes, undefined>, options?: SendOptions): Promise<DecodedMessage<ContentTypes>>; | ||
/** | ||
@@ -1132,3 +1152,3 @@ * Return a `PreparedMessage` that has contains the message ID | ||
*/ | ||
streamEphemeral(): Promise<Stream<DecodedMessage>>; | ||
streamEphemeral(): Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>; | ||
} | ||
@@ -1138,3 +1158,3 @@ /** | ||
*/ | ||
declare class ConversationV1 implements Conversation { | ||
declare class ConversationV1<ContentTypes> implements Conversation<ContentTypes> { | ||
conversationVersion: "v1"; | ||
@@ -1145,3 +1165,3 @@ peerAddress: string; | ||
private client; | ||
constructor(client: Client, address: string, createdAt: Date); | ||
constructor(client: Client<ContentTypes>, address: string, createdAt: Date); | ||
get clientAddress(): string; | ||
@@ -1153,5 +1173,5 @@ get topic(): string; | ||
*/ | ||
messages(opts?: ListMessagesOptions): Promise<DecodedMessage[]>; | ||
messagesPaginated(opts?: ListMessagesPaginatedOptions): AsyncGenerator<DecodedMessage[]>; | ||
decodeMessage(env: messageApi.Envelope): Promise<DecodedMessage>; | ||
messages(opts?: ListMessagesOptions): Promise<DecodedMessage<ContentTypes>[]>; | ||
messagesPaginated(opts?: ListMessagesPaginatedOptions): AsyncGenerator<DecodedMessage<ContentTypes>[]>; | ||
decodeMessage(env: messageApi.Envelope): Promise<DecodedMessage<ContentTypes>>; | ||
prepareMessage(content: any, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
@@ -1162,11 +1182,10 @@ options?: SendOptions): Promise<PreparedMessage>; | ||
*/ | ||
streamMessages(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage>>; | ||
streamMessages(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>; | ||
processEnvelope({ message, contentTopic, }: messageApi.Envelope): Promise<MessageV1>; | ||
streamEphemeral(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage>>; | ||
streamEphemeral(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>; | ||
/** | ||
* Send a message into the conversation. | ||
*/ | ||
send(content: any, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
options?: SendOptions): Promise<DecodedMessage>; | ||
decryptBatch(messages: MessageV1[], topic: string, throwOnError?: boolean): Promise<DecodedMessage[]>; | ||
send(content: Exclude<ContentTypes, undefined>, options?: SendOptions): Promise<DecodedMessage<ContentTypes>>; | ||
decryptBatch(messages: MessageV1[], topic: string, throwOnError?: boolean): Promise<DecodedMessage<ContentTypes>[]>; | ||
private buildDecodedMessage; | ||
@@ -1178,5 +1197,5 @@ createMessage(payload: Uint8Array, recipient: PublicKeyBundle, timestamp?: Date): Promise<MessageV1>; | ||
*/ | ||
declare class ConversationV2 implements Conversation { | ||
declare class ConversationV2<ContentTypes> implements Conversation<ContentTypes> { | ||
conversationVersion: "v2"; | ||
client: Client; | ||
client: Client<ContentTypes>; | ||
topic: string; | ||
@@ -1186,3 +1205,3 @@ peerAddress: string; | ||
context?: InvitationContext; | ||
constructor(client: Client, topic: string, peerAddress: string, createdAt: Date, context: InvitationContext | undefined); | ||
constructor(client: Client<ContentTypes>, topic: string, peerAddress: string, createdAt: Date, context: InvitationContext | undefined); | ||
get clientAddress(): string; | ||
@@ -1192,15 +1211,14 @@ /** | ||
*/ | ||
messages(opts?: ListMessagesOptions): Promise<DecodedMessage[]>; | ||
messagesPaginated(opts?: ListMessagesPaginatedOptions): AsyncGenerator<DecodedMessage[]>; | ||
messages(opts?: ListMessagesOptions): Promise<DecodedMessage<ContentTypes>[]>; | ||
messagesPaginated(opts?: ListMessagesPaginatedOptions): AsyncGenerator<DecodedMessage<ContentTypes>[]>; | ||
get ephemeralTopic(): string; | ||
streamEphemeral(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage>>; | ||
streamEphemeral(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>; | ||
/** | ||
* Returns a Stream of any new messages to/from the peerAddress | ||
*/ | ||
streamMessages(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage>>; | ||
streamMessages(onConnectionLost?: OnConnectionLostCallback): Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>; | ||
/** | ||
* Send a message into the conversation | ||
*/ | ||
send(content: any, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
options?: SendOptions): Promise<DecodedMessage>; | ||
send(content: Exclude<ContentTypes, undefined>, options?: SendOptions): Promise<DecodedMessage<ContentTypes>>; | ||
createMessage(payload: Uint8Array, timestamp?: Date): Promise<MessageV2>; | ||
@@ -1214,3 +1232,3 @@ private decryptBatch; | ||
processEnvelope(env: messageApi.Envelope): Promise<MessageV2>; | ||
decodeMessage(env: messageApi.Envelope): Promise<DecodedMessage>; | ||
decodeMessage(env: messageApi.Envelope): Promise<DecodedMessage<ContentTypes>>; | ||
} | ||
@@ -1253,3 +1271,3 @@ | ||
declare type Message = MessageV1 | MessageV2; | ||
declare class DecodedMessage { | ||
declare class DecodedMessage<ContentTypes = any> { | ||
id: string; | ||
@@ -1261,31 +1279,21 @@ messageVersion: 'v1' | 'v2'; | ||
contentTopic: string; | ||
conversation: Conversation; | ||
conversation: Conversation<ContentTypes>; | ||
contentType: ContentTypeId; | ||
content: any; | ||
content: ContentTypes; | ||
error?: Error; | ||
contentBytes: Uint8Array; | ||
contentFallback?: string; | ||
constructor({ id, messageVersion, senderAddress, recipientAddress, conversation, contentBytes, contentType, contentTopic, content, sent, error, contentFallback, }: Omit<DecodedMessage, 'toBytes'>); | ||
constructor({ id, messageVersion, senderAddress, recipientAddress, conversation, contentBytes, contentType, contentTopic, content, sent, error, contentFallback, }: Omit<DecodedMessage<ContentTypes>, 'toBytes'>); | ||
toBytes(): Uint8Array; | ||
static fromBytes(data: Uint8Array, client: Client): Promise<DecodedMessage>; | ||
static fromV1Message(message: MessageV1, content: any, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
contentType: ContentTypeId, contentBytes: Uint8Array, contentTopic: string, conversation: Conversation, error?: Error, contentFallback?: string): DecodedMessage; | ||
static fromV2Message(message: MessageV2, content: any, // eslint-disable-line @typescript-eslint/no-explicit-any | ||
contentType: ContentTypeId, contentTopic: string, contentBytes: Uint8Array, conversation: Conversation, senderAddress: string, error?: Error, contentFallback?: string): DecodedMessage; | ||
static fromBytes<ContentTypes>(data: Uint8Array, client: Client<ContentTypes>): Promise<DecodedMessage<ContentTypes>>; | ||
static fromV1Message<ContentTypes>(message: MessageV1, content: ContentTypes, contentType: ContentTypeId, contentBytes: Uint8Array, contentTopic: string, conversation: Conversation<ContentTypes>, error?: Error, contentFallback?: string): DecodedMessage<ContentTypes>; | ||
static fromV2Message<ContentTypes>(message: MessageV2, content: ContentTypes, contentType: ContentTypeId, contentTopic: string, contentBytes: Uint8Array, conversation: Conversation<ContentTypes>, senderAddress: string, error?: Error, contentFallback?: string): DecodedMessage<ContentTypes>; | ||
} | ||
declare function decodeContent(contentBytes: Uint8Array, client: Client): Promise<{ | ||
content: any; | ||
declare function decodeContent<ContentTypes>(contentBytes: Uint8Array, client: Client<ContentTypes>): Promise<{ | ||
content: ContentTypes; | ||
contentType: ContentTypeId; | ||
error: Error | undefined; | ||
contentFallback: string | undefined; | ||
error?: Error | undefined; | ||
contentFallback?: string | undefined; | ||
}>; | ||
declare const ContentTypeText: ContentTypeId; | ||
declare class TextCodec implements ContentCodec<string> { | ||
get contentType(): ContentTypeId; | ||
encode(content: string): EncodedContent; | ||
decode(content: EncodedContent): string; | ||
fallback(content: string): string | undefined; | ||
} | ||
declare const ContentTypeComposite: ContentTypeId; | ||
@@ -1309,2 +1317,2 @@ declare type Composite = { | ||
export { ApiClient, ApiUrls, AuthCache, Authenticator, BrowserStoragePersistence, Ciphertext, Client, ClientOptions, CodecRegistry, Composite, CompositeCodec, Compression, ContentCodec, ContentOptions, ContentTypeComposite, ContentTypeFallback, ContentTypeId, ContentTypeText, Conversation, ConversationV1, ConversationV2, Conversations, DecodedMessage, EncodedContent, EncryptedPersistence, HttpApiClient, InMemoryKeystore, InMemoryPersistence, InvitationContext, KeyGeneratorKeystoreProvider, KeyStoreOptions, Keystore, KeystoreProvider, LegacyOptions, ListMessagesOptions, ListMessagesPaginatedOptions, LocalAuthenticator, Message, MessageV1, MessageV2, NetworkKeystoreProvider, NetworkOptions, OnConnectionLostCallback, Persistence, PrefixedPersistence, PrivateKey, PrivateKeyBundle, PrivateKeyBundleV1, PrivateKeyBundleV2, PublicKey, PublicKeyBundle, PublishParams, Query, QueryAllOptions, QueryParams, QueryStreamOptions, SealedInvitation, SendOptions, Signature, SignedPublicKey, SignedPublicKeyBundle, Signer, SnapKeystoreProvider as SnapProvider, SortDirection, StaticKeystoreProvider, Stream, SubscribeCallback, SubscribeParams, SubscriptionManager, TextCodec, TopicData, UnsubscribeFn, XmtpEnv, buildContentTopic, buildDirectMessageTopic, buildDirectMessageTopicV2, buildUserContactTopic, buildUserIntroTopic, buildUserInviteTopic, buildUserPrivateStoreTopic, dateToNs, decodeContactBundle, decodeContent, decrypt, defaultKeystoreProviders, encrypt, fromNanoString, apiDefs as keystoreApiDefs, mapPaginatedStream, nsToDate, retry, toNanoString }; | ||
export { ApiClient, ApiUrls, AuthCache, Authenticator, BrowserStoragePersistence, Ciphertext, Client, ClientOptions, CodecRegistry, Composite, CompositeCodec, Compression, ContentCodec, ContentOptions, ContentTypeComposite, ContentTypeFallback, ContentTypeId, ContentTypeText, Conversation, ConversationV1, ConversationV2, Conversations, DecodedMessage, EncodedContent, EncryptedPersistence, ExtractDecodedType, GetMessageContentTypeFromClient, HttpApiClient, InMemoryKeystore, InMemoryPersistence, InvitationContext, KeyGeneratorKeystoreProvider, KeyStoreOptions, Keystore, KeystoreProvider, LegacyOptions, ListMessagesOptions, ListMessagesPaginatedOptions, LocalAuthenticator, Message, MessageV1, MessageV2, NetworkKeystoreProvider, NetworkOptions, OnConnectionLostCallback, Persistence, PrefixedPersistence, PrivateKey, PrivateKeyBundle, PrivateKeyBundleV1, PrivateKeyBundleV2, PublicKey, PublicKeyBundle, PublishParams, Query, QueryAllOptions, QueryParams, QueryStreamOptions, SealedInvitation, SendOptions, Signature, SignedPublicKey, SignedPublicKeyBundle, Signer, SnapKeystoreProvider as SnapProvider, SortDirection, StaticKeystoreProvider, Stream, SubscribeCallback, SubscribeParams, SubscriptionManager, TextCodec, TopicData, UnsubscribeFn, XmtpEnv, buildContentTopic, buildDirectMessageTopic, buildDirectMessageTopicV2, buildUserContactTopic, buildUserIntroTopic, buildUserInviteTopic, buildUserPrivateStoreTopic, dateToNs, decodeContactBundle, decodeContent, decrypt, defaultKeystoreProviders, encrypt, fromNanoString, apiDefs as keystoreApiDefs, mapPaginatedStream, nsToDate, retry, toNanoString }; |
{ | ||
"name": "@xmtp/xmtp-js", | ||
"version": "11.0.0-beta.10", | ||
"version": "11.0.0-beta.11", | ||
"description": "XMTP client SDK for interacting with XMTP networks.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1801333
13897