import * as grpcWeb from 'grpc-web'; import AitmedResponse from '../common/Response'; export { generalCallback, encryptSecretKeyWithPassword, encryptSecretKeyWithParentSK, generatePasswordWithParentSK, normalizeStringTo32BitArray, objectToBase64, storeCredentialsInLocalStorage, removeCredentialsFromLocalStorage, generateAKey, aKeyCheck, aKeyEncrypt, aKeyEncrypt_str, aKeyDecrypt, aKeyDecrypt_str, generateSKey, sKeyEncrypt, sKeyDecrypt, uint8ArrayToBase64, base64ToUint8Array, uTF8ToUint8Array, uint8ArrayToUTF8, base64ToBlob, blobToBase64, uTF8ToBase64, base64ToUTF8, blobToUint8Array, uint8ArrayToBlob, signature, generateSignatureKeyPair, verifySignature, jsonEscape, base58ToUint8Array, uint8ArrayToBase58, serverDownhandle }; export declare function isBrowser(): boolean; export declare function delay(ms?: number): Promise; /** * * @param _response the response * @param _error an error response * * used as a general callback to pass to methods */ declare function generalCallback(_response: any, _error: grpcWeb.Error | null): AitmedResponse; /** * * @param param0 * * helper method to encrypt the secretKey with the user's password */ declare function encryptSecretKeyWithPassword({ secretKey, password }: any): Uint8Array; declare function encryptSecretKeyWithParentSK({ secretKey, password }: any): Uint8Array; declare function generatePasswordWithParentSK({ password }: any): string; /** * * @param string * * helper method used to normalize any size string to a 32bit array * used to pass in data to encrypt since encrypt/decrypt methods * only handle 32bit array data */ declare function normalizeStringTo32BitArray(string: string): Uint8Array; /** * * @param obj * * converts object to base64 to be able to decrease the data size of the JSONObject */ declare function objectToBase64(obj: Record | null): string; /** * * @param string * * converts utf8 string to base64 */ declare function uTF8ToBase64(string: string): string; /** * * @param string * * converts base64 string to utf8 */ declare function base64ToUTF8(string: string): string; /** * * @param param0 * * helper function to store user credentials in localstorage */ declare function storeCredentialsInLocalStorage({ pkSign, eskSign, secretKey, publicKey, encryptedSecretKey, vcjwt, jwt, user_vid, uid, }: { pkSign?: Uint8Array | string; eskSign?: Uint8Array | string; secretKey?: Uint8Array | string; publicKey?: Uint8Array | string; encryptedSecretKey?: Uint8Array | string; jwt?: string; vcjwt?: string; user_vid?: string; uid?: string; }): void; /** * returns a public, and secret key pair for asymmetric encrypting */ declare function generateAKey(): import("tweetnacl").BoxKeyPair; declare function aKeyCheck(publicKey: Uint8Array, secretKey: Uint8Array): boolean; /** * * @param secretKey * @param data * * assymetrically encrypts data using the sender's secretKey * and receiver's publicKey * extraKey provide extra protection which needs to be exchanged separatedly */ declare function aKeyEncrypt(recvPublicKey: Uint8Array, sendSecretKey: Uint8Array, data: Uint8Array, extraKey?: Uint8Array): Uint8Array; declare function aKeyEncrypt_str(recvPublicKey: Uint8Array, sendSecretKey: Uint8Array, data: string, extraKey?: string): string; /** * * @param publicKey * @param eData * * decrypts assymetrically encrypted data using the sender's publicKey * and receiver's secretKey * extraKey:may needed */ declare function aKeyDecrypt(sendPublicKey: Uint8Array, recvSecretKey: Uint8Array, eData: Uint8Array, extraKey?: Uint8Array): Uint8Array | null; declare function aKeyDecrypt_str(sendPublicKey: Uint8Array, recvSecretKey: Uint8Array, eData: string, // any string extraKey?: string): string | null; /** * returns a secretKey for symmetric encrypting */ declare function generateSKey(): Uint8Array; /** * * @param secretKey * @param data * * encrypts data symmetrically using teh provided secretKey */ declare function sKeyEncrypt(secretKey: Uint8Array, data: Uint8Array): Uint8Array; /** * * @param secretKey * @param eData * * decrypt data symmetrically using the secretKey provided */ declare function sKeyDecrypt(secretKey: Uint8Array, eData: Uint8Array): Uint8Array | null; /** * * @param data * * encodes Uint8Array data to base64 string */ declare function uint8ArrayToBase64(data: Uint8Array): string; /** * * @param data * * decodes string data to Uint8Array */ declare function base64ToUint8Array(data: string): Uint8Array; /** * * @param data * * converts Blob to base64 */ declare function blobToBase64(data: Blob): Promise; /** * * @param data * @param type optional * * converts string data to Blob */ declare function base64ToBlob(data: string, type?: string): Blob; /** * * @param data * * decodes string and returns Uint8Array */ declare function uTF8ToUint8Array(data: string): Uint8Array; /** * * @param data * * encodes Uint8Array or Array of bytes into string */ declare function uint8ArrayToUTF8(data: Uint8Array): string; /** * * @param data * * converts data from Blob to Uint8Array */ declare function blobToUint8Array(data: Blob): Promise; /** * * @param data * @param type * * converts data from Uint8Array to Blob */ declare function uint8ArrayToBlob(data: Uint8Array, type?: string): Blob; declare function removeCredentialsFromLocalStorage(): void; /** * * @param */ declare function generateSignatureKeyPair(): { pkSign: Uint8Array; skSign: Uint8Array; }; /** * * @param message * @throws {LOGIN_REQUIRED} If the user is not logged in. */ declare function signature({ sk, message, eskSign }: { sk: any; message: any; eskSign: any; }): string; /** * * @param signature * @param pkSign */ declare function verifySignature(signature: string | Uint8Array, pkSign: string | Uint8Array): boolean; declare const jsonEscape: (str: string) => string; /** * @description base58 to uint8Array * @param data base58 * @returns uint8Array */ declare function base58ToUint8Array(data: string): Uint8Array; /** * @description uint8Array to base58 * @param data uint8Array * @returns base58 */ declare function uint8ArrayToBase58(data: Uint8Array): string; declare function serverDownhandle(): void;