import { EntityWithEncryptionMetadataTypeName } from '../crypto/entities/EntityWithEncryptionMetadataTypeName.mjs'; import { ExchangeDataInjectionDetails } from '../crypto/entities/ExchangeDataInjectionDetails.mjs'; import { RawDecryptedExchangeData } from '../crypto/entities/RawDecryptedExchangeData.mjs'; import { Pkcs8Bytes } from '../model/specializations/Pkcs8Bytes.mjs'; import { SpkiHexString } from '../model/specializations/SpkiHexString.mjs'; import { CryptoInGroupApi } from './CryptoInGroupApi.mjs'; import { ShamirKeysManagerApi } from './ShamirKeysManagerApi.mjs'; /** * * Gives access to cryptographic operations that should be managed by the user, such as the creation of recovery data for keys. */ export interface CryptoApi { shamirKeysManager: ShamirKeysManagerApi; inGroup: CryptoInGroupApi; /** * * @param entityType the type of entity to get access control keys for. * @return a List containing all the access control keys for an entity type in the current group. This method returns a non-empty list * only if the current data owner is not anonymous */ getAccessControlKeys(entityType: EntityWithEncryptionMetadataTypeName): Promise>; /** * * Clears the cache of the api and reloads the user keys and exchange keys. * In some cases this method could allow users to retrieve and decrypt data that was shared with them after the api * instantiation or last reload. */ forceReload(): Promise; /** * * Get the available keys for the data owner associated to the instance of the SDK and, if using hierarchical data * owners, also its parents. * Note that the result does not necessarily include the keys of the current user's data owner: this might be the * case if the SDK was initialized using the "parent delegator", "keyless", or "child-scoped" modes. * The result is an (unordered) map containing all the available private keys, indexed by their data owner id and * fingerprint. * @param filterTrustedKeys if true (default) only keys fully trusted by this instance of the sdk will be returned. * Otherwise, also unverified keys may be returned. * @return the available keys */ availableKeys(options?: { filterTrustedKeys?: boolean; }): Promise<{ [key: string]: { [key: string]: Pkcs8Bytes; }; }>; keylessCreateExchangeDataTo(delegate: string): Promise; /** * * Allows injecting exchange data that would not be readable or decryptable by the SDK otherwise. * IMPORTANT: the SDK will not check that the provided exchange data details are valid for the provided exchange data * id. Providing invalid details could cause permanent corruption of data. * @param details the details of the exchange data to inject. Set verified to true to allow this data to be used for * encryption of new entity. * @param reEncryptWithOwnKeys can only be true if the api wasn't initialized in keyless mode. If true the injected * data will be re-encrypted with also the current data owner key, allowing to access it in future instances without * having to re-inject it (as long as the instance has access to the current private key). */ injectExchangeData(groupId: string | undefined, details: Array, reEncryptWithOwnKeys: boolean): Promise; /** * * Make sure that a data owner that is a member of the same simple-type group as the current data owner has access * to all the exchange data of that group. * * [sharedSimpleDataOwnerGroupId] must be a simple-type data owner group, of the same data-owner-type as the current * delegator actor, and both the current delegator actor data owner and the [delegate] data owner must be directly * or indirectly through transitive links members of the [sharedSimpleDataOwnerGroupId] group; if they are not this * method fails with a [IllegalArgumentException] without applying any change to the exchange data. * * If [delegatePublicKey] is null this method will simply check that for each exchange data of the group there is * also a piece for the [delegate] data owner. If [delegatePublicKey] is not null this method will also check that * the piece for the [delegate] data owner contains entries for the provided public key. * * This method returns true if all exchange data that was found for [sharedSimpleDataOwnerGroupId] could be * successfully reshared with the [delegate] data owner, false if some data could not be shared (failed to update * it, or there is no piece that the current sdk could decrypt); this method will do its best effort to share as * much as possible (does not stop on the first failure) */ ensureHasAccessToSharedSimpleDataOwnerGroupExchangeData(delegate: string, sharedSimpleDataOwnerGroupId: string, options?: { delegatePublicKey?: SpkiHexString | undefined; }): Promise; }