# Interface: EncryptionSession
# Table of contents
# Properties
# Methods
- addRecipients
- decryptFile
- decryptMessage
- encryptFile
- encryptMessage
- revoke
- revokeRecipients
- serialize
- setManagingGroup
# 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
# addRecipients
▸ addRecipients(recipients
, opts?
): Promise
<AuthorizeRecipientResult
>
Add new recipients to this session. These recipients will be able to read all encrypted messages of this session.
# Parameters
Name | Type | Description |
---|---|---|
recipients | Recipients | |
opts? | Object | |
opts.allowUnregisteredUsers? | boolean | Optional. Whether or not to allow non-seald, unregistered recipients. Defaults to false . |
# Returns
Promise
<AuthorizeRecipientResult
>
# decryptFile
▸ decryptFile<T
>(encryptedFile
, progressCallback?
, fileSize?
): Promise
<{ data
: T
; filename
: string
; sessionId
: string
; size
: number
; type
: FileType
}>
Decrypts an encrypted file
# Type parameters
Name | Type |
---|---|
T | extends string | Blob | ReadableStream <any > | Readable | Buffer |
# Parameters
Name | Type | Description |
---|---|---|
encryptedFile | T | |
progressCallback? | (progress : number ) => void | Optional. Progress callback. The progress is given between 0 and 1. |
fileSize? | number | Optional. Size of the file to decrypt. Needed when using progressCallback with a ReadableStream or NodeReadable as input type. |
# Returns
Promise
<{ data
: T
; filename
: string
; sessionId
: string
; size
: number
; type
: FileType
}>
# decryptMessage
▸ decryptMessage(encryptedMessage
): Promise
<string
>
Decrypts an encrypted message string into the corresponding clear-text string.
# Parameters
Name | Type |
---|---|
encryptedMessage | string |
# Returns
Promise
<string
>
# encryptFile
▸ encryptFile<T
>(clearFile
, filename
, opts?
): Promise
<T
>
Encrypts a file
# Type parameters
Name | Type |
---|---|
T | extends string | Blob | ReadableStream <any > | Readable | Buffer |
# Parameters
Name | Type | Description |
---|---|---|
clearFile | T | |
filename | string | Name of the file. Max 256 characters long. |
opts? | Object | |
opts.fileSize? | number | Optional. Needed when using stream. |
opts.progressCallback? | (p : number ) => void | Optional. Progress callback. The progress is given between 0 and 1. |
# Returns
Promise
<T
>
# encryptMessage
▸ encryptMessage(clearString
): Promise
<string
>
Encrypts a clear-text string into an encrypted message, for the recipients of this session.
# Parameters
Name | Type |
---|---|
clearString | string |
# Returns
Promise
<string
>
# revoke
▸ revoke(): Promise
<RevokeResult
>
Entirely revoke this session. You can only do it if you are this session's administrator.
# Returns
Promise
<RevokeResult
>
# revokeRecipients
▸ revokeRecipients(recipients
, opts?
): Promise
<RevokeResult
>
Revoke recipients from this session. You can only do it if you added these recipients yourself, or if you are this session's administrator.
# Parameters
Name | Type | Description |
---|---|---|
recipients | Recipients | |
opts? | Object | |
opts.allowUnregisteredUsers? | boolean | Optional. Whether or not to allow non-seald, unregistered recipients. Defaults to false . |
# Returns
Promise
<RevokeResult
>
# serialize
▸ serialize(): string
Serialize session to a string. This is for advanced use. May be used to keep sessions in a cache. WARNING: a user could use this cache to work around being revoked. Use with caution. WARNING: if the cache is accessible to another user, they could use it to decrypt messages they are not supposed to have access to. Make sure only the current user in question can access this cache, for example by encrypting it.
# Returns
string
# setManagingGroup
▸ setManagingGroup(groupId
, user?
): Promise
<{ status
: "ok"
}>
Give the rights to manage this session with the same rights as the given user to anyone belonging to given group.
A common way to use this, and the default, is to set user = group
: this allows any member of the group to act as the owner of the group's MessageAccess
Warning : this can only be done by the user who created the session. If it is done by anyone else, the behavior is not guaranteed.
Also, this will only have the expected behavior if the group is the only direct recipient of the session, which means that, during session creation, the group was the only recipient listed, and that encryptForSelf
was set to false
.
# Parameters
Name | Type | Description |
---|---|---|
groupId | string | |
user? | Recipients | Must be one of your descendants, possibly the group itself. Defaults to the group |
# Returns
Promise
<{ status
: "ok"
}>