Skip to content

Interface: AnonymousEncryptionSession

Properties

_sessionSymKey

_sessionSymKey: SymKey

Instance of the symKey for this EncryptionSession instance. For internal use only. Do not use directly.


sessionId

sessionId: string

The sessionId for this EncryptionSession instance.

Methods

decryptFile()

decryptFile<T>(encryptedFile: T, opts?: { fileSize: number; progressCallback: (progress: number) => void; raw: boolean; signal: AbortSignal; }): Promise<{ data: T; filename: string; sessionId: string; size: number; type: FileType; }>

Decrypts an encrypted file

sessionId, filename and size are not returned when decrypting with the raw option.

Type Parameters

T extends string | Blob | ReadableStream | Readable | Buffer

Parameters

encryptedFile

T

opts?
fileSize

number

Optional. Size of the file to decrypt. Needed when using progressCallback with a ReadableStream or NodeReadable as input type.

progressCallback

(progress: number) => void

Optional. Progress callback. The progress is given between 0 and 1. Need fileSize argument set to work with a ReadableStream or NodeReadable as input type.

raw

boolean

Optional. Whether or not the message was encrypted raw. Defaults to false.

signal

AbortSignal

Optional. An AbortSignal to cancel the decryption.

Returns

Promise<{ data: T; filename: string; sessionId: string; size: number; type: FileType; }>


decryptMessage()

decryptMessage(encryptedMessage: string, options?: { raw: boolean; }): Promise<string>

Decrypts an encrypted message string into the corresponding clear-text string.

Parameters

encryptedMessage

string

options?
raw

boolean

Optional. Whether or not the message was encrypted raw. Defaults to false.

Returns

Promise<string>


encryptFile()

encryptFile<T>(clearFile: T, opts?: { filename: string; fileSize: number; progressCallback: (progress: number) => void; raw: boolean; signal: AbortSignal; }): Promise<T>

Encrypts a file

Type Parameters

T extends string | Blob | ReadableStream | Readable | Buffer

Parameters

clearFile

T

opts?
filename

string

Needed when not encrypting raw

fileSize

number

Optional. Needed when using stream with raw option set to false.

progressCallback

(progress: number) => void

Optional. Progress callback. The progress is given between 0 and 1. Need fileSize argument set to work with a ReadableStream or NodeReadable as input type.

raw

boolean

Optional. Whether to include or not the sessionID in the encrypted string. If set to true, the encrypted string cannot be used to retrieve the encryption session. Defaults to false.

signal

AbortSignal

Optional. An AbortSignal to cancel the encryption.

Returns

Promise<T>


encryptMessage()

encryptMessage(clearString: string, options?: { raw: boolean; }): Promise<string>

Encrypts a clear-text string into an encrypted message, for the recipients of this session.

Parameters

clearString

string

options?
raw

boolean

Optional. Whether to include or not the sessionID in the encrypted string. If set to true, the encrypted string cannot be used to retrieve the encryption session. Defaults to false.

Returns

Promise<string>