micro-stacks
Version:
Tiny libraries for building Stacks apps.
22 lines (18 loc) • 1.2 kB
TypeScript
import * as crypto from 'crypto';
declare function isSubtleCryptoAvailable(): boolean;
declare function isNodeCryptoAvailable<T>(withFeature: (nodeCrypto: typeof crypto) => boolean | T): false | T;
declare const NO_CRYPTO_LIB = "Crypto lib not found. Either the WebCrypto \"crypto.subtle\" or Node.js \"crypto\" module must be available.";
interface WebCryptoLib {
lib: Crypto;
name: 'webCrypto';
}
interface NodeCryptoLib {
lib: typeof crypto;
name: 'nodeCrypto';
}
declare function getCryptoLib(): Promise<WebCryptoLib | NodeCryptoLib>;
declare function aes256CbcEncrypt(iv: Uint8Array, key: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
declare function aes256CbcDecrypt(iv: Uint8Array, key: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>;
declare function aes128CbcEncrypt(iv: Uint8Array, key: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
declare function aes128CbcDecrypt(iv: Uint8Array, key: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>;
export { NO_CRYPTO_LIB, NodeCryptoLib, WebCryptoLib, aes128CbcDecrypt, aes128CbcEncrypt, aes256CbcDecrypt, aes256CbcEncrypt, getCryptoLib, isNodeCryptoAvailable, isSubtleCryptoAvailable };