import { KeyPair, ShaVersion } from '../crypto/RSA';
export declare function notConcurrent<T>(concurrencyMap: {
    [key: string]: PromiseLike<any>;
}, key: string, proc: () => PromiseLike<T>): PromiseLike<T>;
export declare function jwk2pkcs8(jwk: any): string;
export declare function jwk2spki(jwk: any): string;
export declare function spkiToJwk(buf: Uint8Array, shaVersion: ShaVersion): {
    kty: string;
    alg: string;
    n: string;
    e: string;
    ext: boolean;
};
export declare function pkcs8ToJwk(buf: Uint8Array | ArrayBuffer): {
    kty: string;
    n: string;
    e: string;
    d: string;
    p: string;
    q: string;
    dp: string;
    dq: string;
    qi: string;
};
/**
 * Provide a view over the given Uint8Array where any trailing null bytes at
 * the end are truncated.
 *
 * This can be used to ignore null bytes at the end of a padded UTF-8 string
 * without needing to copy that string, assuming code point U+0000 is encoded
 * in one null byte according to standards rather than in a multi-byte
 * overlong form.
 */
export declare function truncateTrailingNulls(a: Uint8Array): Uint8Array<ArrayBufferLike>;
/**
 *
 * @param buffer1 {Uint8Array}
 * @param buffer2{ Uint8Array}
 * @returns {ArrayBuffer}
 */
export declare function appendBuffer(buffer1: ArrayBuffer, buffer2: ArrayBuffer): ArrayBuffer;
export declare function after(d1: number | null | undefined, d2: number | null | undefined): boolean;
export declare function before(d1: number | null | undefined, d2: number | null | undefined): boolean;
/**
 * Configuration for the encryption of an object.
 * @param topLevelFields the fields of the object to encrypt. All the fields will be encrypted in a single encryptedSelf field which is added to the
 * object.
 * @param nestedObjectsKeys the name of fields which are expected to contain a nested object (or undefined). Allows to specify
 */
export type EncryptedFieldsManifest = {
    topLevelFields: {
        fieldName: string;
        fieldPath: string;
    }[];
    nestedObjectsKeys: {
        [objectFieldName: string]: EncryptedFieldsManifest;
    };
    mapsValuesKeys: {
        [mapFieldName: string]: EncryptedFieldsManifest;
    };
    arraysValuesKeys: {
        [arrayFieldName: string]: EncryptedFieldsManifest;
    };
};
/**
 * @internal this function is for internal use only and may be changed without notice
 *
 * Parse the encrypted fields configuration for a specific entity type.
 *
 * ## Grammar
 *
 * The grammar for each encrypted field is the following:
 * ```
 * fieldName :=
 *   regex([a-zA-Z_][a-zA-Z0-9_]+)
 * encryptedField :=
 *   fieldName
 *   | fieldName + ("." | ".*." | "[].") + encryptedField
 * ```
 *
 * This grammar allows you to specify the fields to encrypt for the object and recursively for nested objects.
 * - A string containing only a single `fieldName` will encrypt the field with the given name.
 * - A string starting with `fieldName.` allows to specify the encrypted fields of a nested object. The encrypted values of the
 *   fields in the nested object will be saved in the nested object.
 * - A string starting with `fieldName.*.` treats `fieldName` as a map/dictionary data structure and allows to specify the encrypted fields of the
 *   values of the map. Note that the values of the map must be objects as well. The encrypted content of each map value is stored in that value.
 * - A string starting with `fieldName[].` treats `fieldName` as an array and allows to specify the encrypted fields of the values of the array.
 *   Note that the values of the array must be objects as well. The encrypted content of each array element is stored in that element.
 *
 * ## Example
 *
 * Consider the following object and encryption keys:
 * ```javascript
 * const obj = {
 *   a: { x: 0, y: 1 },
 *   b: "hello",
 *   c: [ { public: "a", secret: "b" }, { public: "c", secret: "d" } ],
 *   d: "ok",
 *   e: {
 *     info: "something",
 *     private: "secret",
 *     dataMap: {
 *       "en": {
 *         a: 1,
 *         b: 2
 *       },
 *       "fr": {
 *         a: 3,
 *         b: 4
 *       }
 *     }
 *   }
 * }
 * const encryptedFields = [
 *   "a",
 *   "c[].secret",
 *   "d",
 *   "e.private",
 *   "e.datamap.*.a"
 * ]
 * ```
 * If you use them with the crypt method you will get the following result:
 * ```json
 * {
 *   b: "hello",
 *   c: [
 *     { public: "a", encryptedSelf: "...encrypted data of c[0]" },
 *     { public: "c", encryptedSelf: "...encrypted data of c[1]" }
 *   ],
 *   e: {
 *     info: "something",
 *     dataMap: {
 *       "en": { b: 2, encryptedSelf: "...encrypted data of e.dataMap['en']" },
 *       "fr": { b: 4, encryptedSelf: "...encrypted data of e.dataMap['fr']" }
 *     },
 *     encryptedSelf: "...encrypted data of e"
 *   },
 *   encryptedSelf: "...encrypted data of obj"
 * }
 * ```
 *
 * ## Shortened representation
 *
 * You can also group encrypted fields having the same prefix by concatenating to the prefix the JSON representation of an array of all the postfixes.
 * For example the following encrypted fields:
 * ```javascript
 * const encryptedFields = ["a.b.c.d.e.f1", "a.b.c.d.e.f2", "a.b.c.d.e.f3", "a.b.c.d.e.f4"]
 * ```
 * can be shortened to
 * ```javascript
 * const encryptedFields = ['a.b.c.d.e.["f1","f2","f3","f4"]'] // Note the use of single quotes to avoid escaping the double quotes
 * ```
 * If you use the shortened representation you may need to escape nested json representations. In that case the use of `JSON.stringify` is
 * recommended.
 *
 * @param encryptedFields
 * @param path
 */
export declare function parseEncryptedFields(encryptedFields: string[], path: string): EncryptedFieldsManifest;
/**
 * @internal this function is for internal use only and may be changed without notice
 * Encrypt the object graph recursively. Generally return an updated SHALLOW copy, although some fields may be deep copied if they also needed to be
 * recursively encrypted.
 * @param obj the object to encrypt
 * @param cryptor takes in input an object consisting only of the fields to encrypt of obj, and returns the encrypted object.
 * @param decryptor takes in input an "encrytpedSelf" value and returns the decrypted content. Can return null or throw exception if the decryption fails.
 * @param keys the keys to encrypt for the
 * @param path path of the current object, used for error messages.
 * @return a shallow copy of the object with a new encryptedSelfField and without the encrypted fields.
 */
export declare function encryptObject(obj: {
    [key: string]: any;
}, cryptor: (obj: {
    [key: string]: any;
}) => Promise<ArrayBuffer>, decryptor: (encryptedSelf: Uint8Array<ArrayBufferLike>) => Promise<any>, keys: EncryptedFieldsManifest, path?: string): Promise<{
    [key: string]: any;
}>;
/**
 * @internal this function is for internal use only and may be changed without notice
 * Decrypt object graph recursively.
 *
 * @param obj the object to decrypt
 * @param decryptor the decryptor function (returns a promise); the decryptor returns the decrypted input or null if
 * the decryption fails
 * @return a deep copy of the object with the decrypted fields and removed encryptedSelf field, or null if the
 * decryption failed
 */
export declare function decryptObject(obj: {
    [key: string]: any;
}, decryptor: (obj: Uint8Array) => Promise<{
    [key: string]: any;
} | null>): Promise<{
    [key: string]: any;
} | null>;
/**
 * Extracts the full jwk key pair from the jwk representation of the private key.
 * @param privateKeyJwk private key in jwk representation
 * @param shaVersion the SHA algorithm version
 * @throws if the key is missing the public modulus or public exponent.
 */
export declare function keyPairFromPrivateKeyJwk(privateKeyJwk: JsonWebKey, shaVersion: ShaVersion): KeyPair<JsonWebKey>;
