Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EThree

Hierarchy

  • AbstractEThree
    • EThree

Index

Properties

accessTokenProvider

accessTokenProvider: IAccessTokenProvider

Instance of IAccessTokenProvider implementation. Using [[getToken]] to receive JWT.

cardManager

cardManager: CardManager

Instance of CardManager. Used to create cards with user public keys.

identity

identity: string

Unique identifier of current user. Received from JWT token.

Protected inProcess

inProcess: boolean

keyEntryStorage

keyEntryStorage: IKeyEntryStorage

Instance of IKeyEntryStorage implementation. Used for storing private keys.

Protected keyLoader

keyLoader: PrivateKeyLoader

Optional keyPairType

keyPairType: any

virgilCrypto

virgilCrypto: ICrypto

Instance of implementation of ICrypto interface.

Methods

authDecrypt

  • authDecrypt(message: Data): Promise<NodeBuffer | string>
  • authDecrypt(message: Data, publicKey: IPublicKey): Promise<NodeBuffer | string>
  • authDecrypt(message: Data, card: ICard, encryptedAt?: Date): Promise<NodeBuffer | string>
  • Parameters

    Returns Promise<NodeBuffer | string>

  • Parameters

    • message: Data
    • publicKey: IPublicKey

    Returns Promise<NodeBuffer | string>

  • Parameters

    • message: Data
    • card: ICard
    • Optional encryptedAt: Date

    Returns Promise<NodeBuffer | string>

authDecryptFile

  • authDecryptFile(file: File | Blob, senderCardOrPublicKey?: ICard | IPublicKey, options?: AuthDecryptFileOptions): Promise<File | Blob>
  • Decrypts and verifies integrity of File or Blob for recipient public key. If there is no recipient and the message is encrypted for the current user, omit the public key parameter. You can define chunk size and a callback, that will be invoked on each chunk.

    The file will be read twice during this method execution:

    1. To decrypt encrypted file.
    2. To verify the validity of the signature over the decrypted file for the public key.

    Parameters

    • file: File | Blob
    • Optional senderCardOrPublicKey: ICard | IPublicKey
    • Default value options: AuthDecryptFileOptions = {}

    Returns Promise<File | Blob>

authEncrypt

authEncryptFile

backupPrivateKey

  • backupPrivateKey(pwd: string, keyName?: string): Promise<void>
  • Uploads current user private key to Virgil Keyknox Storage.

    Parameters

    • pwd: string

      User password for access to Virgil Keyknox Storage

    • Optional keyName: string

      Is a name that would be used to store backup in the cloud.

    Returns Promise<void>

changePassword

  • changePassword(oldPwd: string, newPwd: string, keyName?: string): Promise<void>
  • Changes password for access to current user private key backup.

    Parameters

    • oldPwd: string

      users old password

    • newPwd: string

      users new password

    • Optional keyName: string

    Returns Promise<void>

cleanup

  • cleanup(): Promise<void>
  • Deletes local private key from key storage. Make sure backupPrivateKey method was called first.

    Returns Promise<void>

createGroup

  • createGroup(groupId: Data): Promise<Group>
  • createGroup(groupId: Data, participant: ICard): Promise<Group>
  • createGroup(groupId: Data, participants: FindUsersResult): Promise<Group>
  • Parameters

    Returns Promise<Group>

  • Parameters

    • groupId: Data
    • participant: ICard

    Returns Promise<Group>

  • Parameters

    Returns Promise<Group>

decrypt

  • decrypt(message: Data): Promise<NodeBuffer | string>
  • decrypt(message: Data, senderCard: ICard): Promise<NodeBuffer | string>
  • decrypt(message: Data, senderCard: ICard, encryptedAt: Date): Promise<NodeBuffer | string>
  • decrypt(message: Data, senderPublicKey: IPublicKey): Promise<NodeBuffer | string>
  • Decrypts and verifies the data encrypted by the current user for the current user.

    Parameters

    • message: Data

      Message to decrypt

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

  • Decrypts and verifies the data encrypted by the user identified by senderCard for the current user.

    Parameters

    • message: Data

      Message to decrypt

    • senderCard: ICard

      Virgil Card of the user who encrypted and signed the message.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

  • Decrypts and verifies the data encrypted by the user identified by senderCard for the current user. If the sender had ever rotated their keys (e.g. by using the EThree.rotatePrivateKey method), then the encryptedAt date is used to find the public key that was current at the time of encryption.

    Parameters

    • message: Data

      Message to decrypt

    • senderCard: ICard

      Virgil Card of the user who encrypted and signed the message.

    • encryptedAt: Date

      The date the message was encrypted on.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

  • Decrypts and verifies the data encrypted by the user identified by senderPublicKey for the current user.

    deprecated

    and will be removed in next major release.

    Use the overload that accepts Virgil Card object instead.

    Parameters

    • message: Data

      Message to decrypt

    • senderPublicKey: IPublicKey

      Public key of the user who encrypted and signed the message.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

decryptFile

  • decryptFile(file: File | Blob, senderCardOrPublicKey?: ICard | IPublicKey, options?: DecryptFileOptions): Promise<File | Blob>
  • deprecated

    and will be removed in next major release. Decrypts and verifies integrity of File or Blob for recipient public key. If there is no recipient and the message is encrypted for the current user, omit the public key parameter. You can define chunk size and a callback, that will be invoked on each chunk.

    The file will be read twice during this method execution:

    1. To decrypt encrypted file.
    2. To verify the validity of the signature over the decrypted file for the public key.

    Parameters

    • file: File | Blob
    • Optional senderCardOrPublicKey: ICard | IPublicKey
    • Default value options: DecryptFileOptions = {}

    Returns Promise<File | Blob>

decryptSharedFile

  • decryptSharedFile(file: File | Blob, fileKey: Data, senderCardOrPublicKey?: ICard | IPublicKey, options?: DecryptSharedFileOptions): Promise<File | Blob>
  • Decrypts File or Blob with fileKey and verifies integrity with senderCardOrPublicKey. If there is no recipient and the message is encrypted for the current user, omit the senderCardOrPublicKey parameter. You can define chunk size and a callback, that will be invoked on each chunk.

    Parameters

    Returns Promise<File | Blob>

deleteGroup

  • deleteGroup(groupId: Data): Promise<void>
  • Parameters

    Returns Promise<void>

encrypt

  • Encrypts and signs the message for the current user.

    Parameters

    • message: Data

      Message to sign and encrypt.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise

  • Encrypts and signs the message for the current user and a single recipient user.

    Parameters

    • message: Data

      Message to sign and encrypt.

    • card: ICard

      Virgil Card of the encrypted message recipient.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

  • Encrypts and signs the message for the current user and multiple recipient users.

    Parameters

    • message: Data

      Message to sign and encrypt.

    • users: FindUsersResult

      Result of the {@link AbstractEThree.findUsers} method. Specifies multiple recipients.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

  • Encrypts and signs the message for the current user and a single recipient user.

    Use the overload that accepts ICard object instead.

    Parameters

    • message: Data

      Message to sign and encrypt.

    • publicKey: IPublicKey

      Public key of the encrypted message recipient.

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

  • Encrypts and signs the message for the current user and multiple recipient users.

    deprecated

    and will be removed in next major release.

    Use the overload that accepts FindUsersResult object instead.

    Parameters

    Returns Promise<NodeBuffer | string>

    Promise that is that resolves to a string if message was a string and Buffer otherwise.

encryptFile

encryptSharedFile

findUsers

  • findUsers(identity: string): Promise<ICard>
  • findUsers(identities: string[]): Promise<FindUsersResult>
  • Finds Virgil Card for user identity registered on Virgil Cloud.

    throws

    {UsersNotFoundError} in case the Virgil Card wasn't found for the given identity.

    throws

    {UsersFoundWithMultipleCardsError} in case the given user has more than one Virgil Card, which is not allowed with E3kit.

    Parameters

    • identity: string

    Returns Promise<ICard>

    • Promise that resolves to the Virgil Card object.
  • Finds Virgil Cards for user identities registered on Virgil Cloud.

    throws

    {UsersNotFoundError} in case the Virgil Card wasn't found for any one of the given identities.

    throws

    {UsersFoundWithMultipleCardsError} in case any one of the given users have more than one Virgil Card, which is not allowed with E3kit.

    Parameters

    • identities: string[]

    Returns Promise<FindUsersResult>

    • Promise that resolves to a hash with identities as keys and Virgil Card objects as values.

getGroup

  • getGroup(groupId: Data): Promise<Group | null>
  • Parameters

    Returns Promise<Group | null>

hasLocalPrivateKey

  • hasLocalPrivateKey(): Promise<boolean>
  • Checks if current user has private key saved locally.

    Returns Promise<boolean>

loadGroup

  • loadGroup(groupId: Data, initiatorCard: ICard): Promise<Group>
  • Parameters

    • groupId: Data
    • initiatorCard: ICard

    Returns Promise<Group>

lookupPublicKeys

  • lookupPublicKeys(identity: string): Promise<IPublicKey>
  • lookupPublicKeys(identities: string[]): Promise<LookupResult>
  • Finds public key for user identity registered on Virgil Cloud.

    deprecated

    and will be removed in next major release.

    Use the EThree.findUsers instead, which returns Virgil Cards instead of just the public keys. You can get a public key out of the Virgil Card object via the publicKey property.

    Parameters

    • identity: string

    Returns Promise<IPublicKey>

    • Promise that resolves to a public key object.
  • Finds public keys for user identities registered on Virgil Cloud.

    deprecated

    and will be removed in next major release.

    Use the EThree.findUsers instead, which returns Virgil Cards instead of just the public keys. You can get a public key out of the Virgil Card object via the publicKey property.

    Parameters

    • identities: string[]

    Returns Promise<LookupResult>

    • Promise that resolves to a hash with identities as keys and public key objects as values.

register

  • register(keyPair?: IKeyPair): Promise<void>
  • Registers current user in Virgil Cloud. Saves private key locally and uploads public key to the cloud.

    Parameters

    • Optional keyPair: IKeyPair

    Returns Promise<void>

resetPrivateKeyBackup

  • resetPrivateKeyBackup(): Promise<void>
  • resetPrivateKeyBackup(pwd: string): Promise<void>
  • Delete private key saved in Virgil Keyknox Storage.

    Returns Promise<void>

    • Promise that is resolved if everything went fine.
  • Delete private key saved in Virgil Keyknox Storage.

    deprecated

    and will be removed in next major release.

    Parameters

    • pwd: string

      User password for access to Virgil Keyknox Storage.

    Returns Promise<void>

    • Promise that is resolved if everything went fine.

resetPrivateKeyBackupWithKeyName

  • resetPrivateKeyBackupWithKeyName(keyName: string): Promise<void>
  • Delete private key saved in Virgil Keyknox Storage.

    Parameters

    • keyName: string

    Returns Promise<void>

    • Promise that is resolved if everything went fine.

restorePrivateKey

  • restorePrivateKey(pwd: string, keyName?: string): Promise<void>
  • Downloads private key from Virgil Cloud. Use backupPrivateKey to upload the key first.

    Parameters

    • pwd: string

      User password for access to Virgil Keyknox Storage.

    • Optional keyName: string

      Is a name for the key backup in the cloud.

    Returns Promise<void>

rotatePrivateKey

  • rotatePrivateKey(): Promise<void>
  • Generates a new private key and saves locally. Replaces old public key with new one in Cloud. Used in case if old private key is lost.

    Returns Promise<void>

unregister

  • unregister(): Promise<void>
  • Unregister current user. Revokes public key in Virgil Cloud and deletes local private key.

    throws

    {RegisterRequiredError} If current user is not registered (i.e. there is no Virgil Card for this identity)

    throws

    {MultipleCardsError} If there is more than one Virgil Card for this identity

    Returns Promise<void>

Static derivePasswords

Static initialize

  • Initialize a new instance of EThree which tied to specific user.

    Parameters

    • getToken: () => Promise<string>

      Function that receive JWT.

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

    • Default value options: EThreeInitializeOptions = {}

    Returns Promise<EThree>

Generated using TypeDoc