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.

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

Type declaration

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

Type declaration

  • 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(...)

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 }

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.

PrivateKeyBundle: PrivateKeyBundleV1 | PrivateKeyBundleV2
SendOptions: { compression?: proto.Compression; contentFallback?: string; contentType?: ContentTypeId; ephemeral?: boolean; timestamp?: Date }

Type declaration

  • Optional compression?: proto.Compression
  • Optional contentFallback?: string
  • Optional contentType?: ContentTypeId
  • Optional ephemeral?: boolean
  • Optional timestamp?: Date
TopicData: WithoutUndefined<keystore.TopicMap_TopicData>
TypingNotification: { isFinished: boolean; timestamp: Date; typerAddress: string }

Type declaration

  • isFinished: boolean
  • timestamp: Date
  • typerAddress: string

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 = ...
ContentTypeTypingNotification: ContentTypeId = ...
SortDirection: typeof SortDirection

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(contentBytes: Uint8Array, client: Client): Promise<{ content: any; contentFallback: undefined | string; contentType: ContentTypeId; error: undefined | Error }>
  • Parameters

    • contentBytes: Uint8Array
    • client: Client

    Returns Promise<{ content: any; contentFallback: undefined | string; contentType: ContentTypeId; error: undefined | Error }>

  • decrypt(encrypted: Ciphertext | Ciphertext, secret: Uint8Array, additionalData?: Uint8Array): Promise<Uint8Array>
  • 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
  • toNanoString(d: undefined | Date): undefined | string
  • Parameters

    • d: undefined | Date

    Returns undefined | string

Generated using TypeDoc