Pluggable X3DH implementation, using Web Crypto API.

Constructors

Properties

identityKeyManager: IdentityKeyManagerInterface
sessionKeyManager: SessionKeyManagerInterface

Methods

  • Decrypt the next message received by the sender.

    Parameters

    • sender: string
    • encrypted: string

    Returns Promise<string | Uint8Array<ArrayBufferLike>>

  • Encrypt the next message to send to the recipient.

    Parameters

    • recipient: string
    • message: string | Uint8Array<ArrayBufferLike>

    Returns Promise<string>

  • Generates and signs a bundle of one-time keys.

    Useful for pushing more OTKs to the server.

    Parameters

    • signingKey: CryptoKey
    • numKeys: number = 100

    Returns Promise<SignedBundle>

  • Initialize keys for receiving an initial message. Returns the initial plaintext message on success. Throws on failure.

    Parameters

    Returns Promise<(string | Uint8Array<ArrayBufferLike>)[]>

  • Get the shared key when receiving an initial message.

    Parameters

    Returns Promise<{ IK: CryptoKey; Sender: string; SK: any }>

  • Get the shared key when sending an initial message.

    Parameters

    • res: InitServerInfo
    • _senderIdentity: string

      not needed for key operations, ust for context

    Returns Promise<RecipientInitWithSK>

  • Sets the identity string for the current user.

    Parameters

    • id: string

    Returns Promise<void>

  • Sign a pre-key with the identity key. This is what should be used for signed pre-keys in X3DH.

    Parameters

    • signingKey: CryptoKey
    • preKey: CryptoKey

    Returns Promise<string>