Options
All
  • Public
  • Public/Protected
  • All
Menu

@xmtp/xmtp-js

Index

Type aliases

ClientOptions: Flatten<NetworkOptions & KeyStoreOptions & ContentOptions & LegacyOptions & PreEventCallbackOptions>

Aggregate type for client options. Optional properties are used when the default value is calculated on invocation, and are computed as needed by each function. All other defaults are specified in defaultOptions.

Composite: { content: any; type: ContentTypeId } | { parts: Composite[] }
ContentOptions: { codecs: ContentCodec<any>[]; maxContentSize: number }

Type declaration

  • codecs: ContentCodec<any>[]

    Allow configuring codecs for additional content types

  • maxContentSize: number

    Set the maximum content size in bytes that is allowed by the Client. Currently only checked when decompressing compressed content.

ExtractDecodedType<C>: C extends ContentCodec<infer T> ? T : never

Type parameters

  • C

GetMessageContentTypeFromClient<C>: C extends Client<infer T> ? T : never

Type parameters

  • C

InvitationContext: { conversationId: string; metadata: {} }

Type declaration

  • conversationId: string
  • metadata: {}
    • [k: string]: string
KeyStoreOptions: { basePersistence: Persistence; disablePersistenceEncryption: boolean; keystoreProviders: KeystoreProvider[]; persistConversations: boolean; privateKeyOverride?: Uint8Array; useSnaps: boolean }

Type declaration

  • basePersistence: Persistence

    Override the base persistence provider. Defaults to LocalStoragePersistence, which is fine for most implementations

  • disablePersistenceEncryption: boolean

    Whether or not the persistence provider should encrypt the values. Only disable if you are using a secure datastore that already has encryption

  • keystoreProviders: KeystoreProvider[]

    Provide an array of KeystoreProviders. The client will attempt to use each one in sequence until one successfully returns a Keystore instance

  • persistConversations: boolean

    Enable the Keystore to persist conversations in the provided storage interface

  • Optional privateKeyOverride?: Uint8Array

    Provide a XMTP PrivateKeyBundle encoded as a Uint8Array. A bundle can be retried using Client.getKeys(...)

  • useSnaps: boolean

    A single option to allow Metamask Snaps to be used as a keystore provider

LegacyOptions: { publishLegacyContact?: boolean }

Type declaration

  • Optional publishLegacyContact?: boolean
ListMessagesOptions: { checkAddresses?: boolean; direction?: messageApi.SortDirection; endTime?: Date; limit?: number; startTime?: Date }

Type declaration

  • Optional checkAddresses?: boolean
  • Optional direction?: messageApi.SortDirection
  • Optional endTime?: Date
  • Optional limit?: number
  • Optional startTime?: Date
ListMessagesPaginatedOptions: { direction?: messageApi.SortDirection; endTime?: Date; pageSize?: number; startTime?: Date }

Type declaration

  • Optional direction?: messageApi.SortDirection
  • Optional endTime?: Date
  • Optional pageSize?: number
  • Optional startTime?: Date
Message: MessageV1 | MessageV2
NetworkOptions: { apiUrl: string | undefined; appVersion?: string; env: XmtpEnv; skipContactPublishing: boolean; apiClientFactory: any }

Network startup options

Type declaration

  • apiUrl: string | undefined

    apiUrl can be used to override the env flag and connect to a specific endpoint

  • Optional appVersion?: string

    identifier that's included with API requests.

    For example, you can use the following format: appVersion: APP_NAME + '/' + APP_VERSION. Setting this value provides telemetry that shows which apps are using the XMTP client SDK. This information can help XMTP developers provide app support, especially around communicating important SDK updates, including deprecations and required upgrades.

  • env: XmtpEnv

    Specify which XMTP environment to connect to. (default: dev)

  • skipContactPublishing: boolean

    Skip publishing the user's contact bundle as part of Client startup.

    This flag should be used with caution, as we rely on contact publishing to let other users know your public key and periodically run migrations on this data with new SDK versions.

    Your application should have this flag set to false at least some of the time.

    The most common use-case for setting this to true is cases where the Client instance is very short-lived. For example, spinning up a Client to decrypt a push notification.

  • apiClientFactory:function
OnConnectionLostCallback: () => void

Type declaration

    • (): void
    • Returns void

PublishParams: { contentTopic: string; message: Uint8Array; timestamp?: Date }

Type declaration

  • contentTopic: string
  • message: Uint8Array
  • Optional timestamp?: Date
QueryAllOptions: { direction?: messageApi.SortDirection; limit?: number }

Type declaration

  • Optional direction?: messageApi.SortDirection
  • Optional limit?: number
QueryParams: { contentTopic: string; endTime?: Date; startTime?: Date }

Type declaration

  • contentTopic: string
  • Optional endTime?: Date
  • Optional startTime?: Date
QueryStreamOptions: Flatten<Omit<QueryAllOptions, "limit"> & { pageSize?: number }>
SendOptions: { compression?: proto.Compression; contentType?: ContentTypeId; ephemeral?: boolean; timestamp?: Date }

Type declaration

  • Optional compression?: proto.Compression
  • Optional contentType?: ContentTypeId
  • Optional ephemeral?: boolean
  • Optional timestamp?: Date
SubscribeCallback: NotifyStreamEntityArrival<messageApi.Envelope>
SubscribeParams: { contentTopics: string[] }

Type declaration

  • contentTopics: string[]
SubscriptionManager: { unsubscribe: UnsubscribeFn; updateContentTopics?: UpdateContentTopics }

Type declaration

  • unsubscribe: UnsubscribeFn
  • Optional updateContentTopics?: UpdateContentTopics
TopicData: WithoutUndefined<keystore.TopicMap_TopicData>
UnsubscribeFn: () => Promise<void>

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

XmtpEnv: keyof typeof ApiUrls

Variables

ApiUrls: { dev: "https://dev.xmtp.network"; local: "http://localhost:5555"; production: "https://production.xmtp.network" } = ...

Type declaration

  • dev: "https://dev.xmtp.network"
  • local: "http://localhost:5555"
  • production: "https://production.xmtp.network"
Compression: typeof Compression
ContentTypeComposite: ContentTypeId = ...
ContentTypeFallback: ContentTypeId = ...
ContentTypeText: ContentTypeId = ...
SortDirection: typeof SortDirection
keystoreApiDefs: ApiDefs = ...

Functions

  • buildContentTopic(name: string): string
  • buildDirectMessageTopic(sender: string, recipient: string): string
  • Parameters

    • sender: string
    • recipient: string

    Returns string

  • buildDirectMessageTopicV2(randomString: string): string
  • buildUserContactTopic(walletAddr: string): string
  • buildUserIntroTopic(walletAddr: string): string
  • buildUserInviteTopic(walletAddr: string): string
  • buildUserPrivateStoreTopic(addrPrefixedKey: string): string
  • dateToNs(date: Date): Long
  • decodeContent<ContentTypes>(contentBytes: Uint8Array, client: Client<ContentTypes>): Promise<{ content: ContentTypes; contentFallback?: string; contentType: ContentTypeId; error?: Error }>
  • Type parameters

    • ContentTypes

    Parameters

    • contentBytes: Uint8Array
    • client: Client<ContentTypes>

    Returns Promise<{ content: ContentTypes; contentFallback?: string; contentType: ContentTypeId; error?: Error }>

  • decrypt(encrypted: Ciphertext | Ciphertext, secret: Uint8Array, additionalData?: Uint8Array): Promise<Uint8Array>
  • Get the default list of KeystoreProviders used in the SDK

    Particularly useful if a developer wants to add their own provider to the head of the list while falling back to the default functionality

    Returns KeystoreProvider[]

  • encrypt(plain: Uint8Array, secret: Uint8Array, additionalData?: Uint8Array): Promise<Ciphertext>
  • fromNanoString(s: undefined | string): undefined | Date
  • Parameters

    • s: undefined | string

    Returns undefined | Date

  • mapPaginatedStream<Out>(gen: AsyncGenerator<Envelope[], any, unknown>, mapper: EnvelopeMapper<Out>): AsyncGenerator<Out[]>
  • Type parameters

    • Out

    Parameters

    • gen: AsyncGenerator<Envelope[], any, unknown>
    • mapper: EnvelopeMapper<Out>

    Returns AsyncGenerator<Out[]>

  • nsToDate(ns: Long): Date
  • retry<T>(fn: T, args: Parameters<T>, maxRetries: number, sleepTime: number, isRetryableFn?: IsRetryable, retryCount?: number): Promise<Awaited<ReturnType<T>>>
  • Type parameters

    • T: (...arg0: any[]) => any

    Parameters

    • fn: T
    • args: Parameters<T>
    • maxRetries: number
    • sleepTime: number
    • isRetryableFn: IsRetryable = defaultIsRetryableFn
    • retryCount: number = 1

    Returns Promise<Awaited<ReturnType<T>>>

  • toNanoString(d: undefined | Date): undefined | string
  • Parameters

    • d: undefined | Date

    Returns undefined | string

Generated using TypeDoc