Home Reference Source
import EncryptionService from 'neo4j-driver-core/lib/encryption/encryption.js'
public class | since 6.3.0 | source

EncryptionService

this class is experimental. Part of the Client-Side Encrytion preview feature

Provides Neo4j Property Encryption functions.

Method Summary

Public Methods
public

decrypt(decryptRequest: Object): Promise<T|UnsupportedType>

Decrypts data encrypted with this or another Neo4j Driver's EncryptionService#encrypt function.

public

encrypt(encryptRequest: Object): Promise<Int8Array>

Encrypts data with AES-GCM 256 into a byte array ready to be saved an a property in a Neo4j database.

public

keyManager(profileName: string | undefined): EncapsulatedKeyManager

Returns the key manager for the specified profile

Public Methods

public decrypt(decryptRequest: Object): Promise<T|UnsupportedType> source

Decrypts data encrypted with this or another Neo4j Driver's EncryptionService#encrypt function.

Params:

NameTypeAttributeDescription
decryptRequest Object

Object containing encrypted ciphertext and required metadata.

decryptRequest.ciphertext Int8Array

The encrypted ciphertext

decryptRequest.aad any | undefined

The Additional Authenticated Data to verify when decrypting

decryptRequest.usePersistedAad boolean | undefined

Wether to use the persisted aad data stored with the ciphertext, mutually exclusive with decryptRequest.aad

Return:

Promise<T|UnsupportedType>

The decrypted property or an UnsupportedType if decoding the decrypted bytes failed.

public encrypt(encryptRequest: Object): Promise<Int8Array> source

Encrypts data with AES-GCM 256 into a byte array ready to be saved an a property in a Neo4j database. The byte array includes metadata required to allow another Neo4j Driver configured with the same EncapsulatedKeyRecordRepository to decrypt the data.

Params:

NameTypeAttributeDescription
encryptRequest Object

The value to encrypt and associated metadata for the encryption

encryptRequest.value any

The value to encrypt, must be a value able to be saved as a Neo4j Property.

encryptRequest.keyOptions string | Object | undefined

Used to determine the key to be used, a plain string is assumed to be the id, if omitted the encryption profile's default key reference will be used

encryptRequest.encryptionProfile string

Name of the EncryptionProfile to use, must be provided unless the driver is configured with only 1 profile.

encryptRequest.aad any | undefined

Additional Authenticated Data for the encryption.

Return:

Promise<Int8Array>

A Int8Array that can be stored as a ByteArray in a Neo4j database.

public keyManager(profileName: string | undefined): EncapsulatedKeyManager source

Returns the key manager for the specified profile

Params:

NameTypeAttributeDescription
profileName string | undefined

name of the profile to get the key manager of, can be omitted if driver is configured with only one encryption profile

Return:

EncapsulatedKeyManager

The key manager of the specified profile.