/** * Copyright (c) "Neo4j" * Neo4j Sweden AB [https://neo4j.com] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import Integer from '../integer'; import { EncapsulatedKey, EncapsulatedKeyRecord, EncapsulatedKeyRecordRepository } from './encapsulated-key'; import { KeyEncapsulationService } from './key-encapsulation-service'; /** * An interface for encryption profiles used for Neo4j Property Encryption. * * @since 6.3.0 * @experimental Part of the Client-Side Encrytion preview feature */ export interface EncryptionProfile { name: string; encapsulationService: KeyEncapsulationService; keyRepository: EncapsulatedKeyRecordRepository; type: string; version: Integer; /** * @private */ findKey: (options: string | { alias?: string; id?: string; }) => Promise; /** * @private */ saveKey: (alias: string, encapsulation: Int8Array, metadata: Record) => Promise; } /** * An encryption profile that enables Envelope Encryption for Neo4j Property Encryption. * * @since 6.3.0 * @experimental Part of the Client-Side Encrytion preview feature */ export declare class EnvelopeEncryptionProfile implements EncryptionProfile { name: string; encapsulationService: KeyEncapsulationService; keyRepository: EncapsulatedKeyRecordRepository; type: string; version: Integer; private readonly _keyCacheTTL; private readonly _keyCacheMaxSize; private readonly _keyAliasIndexTTL; private readonly _keyAliasIndexMaxSize; private readonly _keyCache; private readonly _aliasIndex; /** * * @param {Object} config - Configurations * @param {string} config.name - Name of the profile, must be the same on all drivers used to access the encrypted data. * @param {KeyEncapsulationService} config.encapsulationService - Encapsulation service used to encapsulate and dencapsulate keys. The driver ships with {@link LocalKeyEncapsulationService}, other implementations can be found as separate packages. * @param {EncapsulatedKeyRecordRepository} config.keyRepository - Implementation of the {@link EncapsulatedKeyRecordRepository} interface, must be implemented so that the driver can access your key repository. * @param {number} config.keyCacheTTL - How How long in milliseconds to keep a retrieved encapsulated keys cached by Id - defaults to 15 minutes * @param {number} config.keyCacheMaxSize - How many items to keep in the key cache before pruning the oldest, setting to 0 will disable the cache - defaults to 100 * @param {number} config.keyAliasIndexTTL - How How long in milliseconds to keep the mapping of alias to key cached - defaults to 15 seconds * @param {number} config.keyAliasIndexMaxSize - How many items to keep in the alias cache before pruning the oldest, setting to 0 will disable the index - defaults to 100 */ constructor(config: { name: string; encapsulationService: KeyEncapsulationService; keyRepository: EncapsulatedKeyRecordRepository; keyCacheTTL?: number; keyCacheMaxSize?: number; keyAliasIndexTTL?: number; keyAliasIndexMaxSize?: number; }); /** * @private */ findKey(options: string | { alias?: string; id?: string; }): Promise; /** * @private */ saveKey(alias: string, encapsulation: Int8Array, metadata: Record): Promise; /** * @private */ _findById(id: string): Promise; /** * @private */ _findByAlias(alias: string): Promise; /** * @private */ private _pruneCache; /** * @private */ removeFromKeyCache(id: string): void; setAliasIndexEntry(id: string, alias: string | undefined): void; }