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>

authEncrypt

  • authEncrypt(message: Data): Promise<NodeBuffer | string>
  • authEncrypt(message: Data, publicKey: IPublicKey): Promise<NodeBuffer | string>
  • authEncrypt(message: Data, card: ICard): Promise<NodeBuffer | string>
  • authEncrypt(message: Data, users: FindUsersResult): Promise<NodeBuffer | string>
  • Parameters

    Returns Promise<NodeBuffer | string>

  • Parameters

    • message: Data
    • publicKey: IPublicKey

    Returns Promise<NodeBuffer | string>

  • Parameters

    • message: Data
    • card: ICard

    Returns Promise<NodeBuffer | string>

  • Parameters

    • message: Data
    • users: FindUsersResult

    Returns Promise<NodeBuffer | string>

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

    • groupId: Data
    • participants: FindUsersResult

    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.

deleteGroup

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

    Returns Promise<void>

encrypt

  • encrypt(message: Data): Promise<NodeBuffer | string>
  • encrypt(message: Data, card: ICard): Promise<NodeBuffer | string>
  • encrypt(message: Data, users: FindUsersResult): Promise<NodeBuffer | string>
  • encrypt(message: Data, publicKey: IPublicKey): Promise<NodeBuffer | string>
  • encrypt(message: Data, publicKeys: LookupResult): Promise<NodeBuffer | string>
  • 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

    • message: Data

      Message to sign and encrypt.

    • publicKeys: LookupResult

    Returns Promise<NodeBuffer | string>

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

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