/**
 * Minimal browser shim for the node `crypto` module.
 *
 * Replaces `crypto-browserify`, which pulls in `elliptic` (via
 * `browserify-sign` and `create-ecdh`) - a package with open low-severity
 * advisories and no fixed release.  None of the signing/ECDH functionality
 * is needed here: `@sheet/crypto` (see tsconfig `paths` mapping for
 * "crypto") only uses hashing, HMAC, AES ciphers and random bytes.
 */
import createHash from 'create-hash'
import createHmac from 'create-hmac'
import { createCipheriv, createDecipheriv } from 'browserify-cipher'
import randomBytes from 'randombytes'

const HASHES = [
  'md4',
  'md5',
  'ripemd160',
  'sha1',
  'sha224',
  'sha256',
  'sha384',
  'sha512'
]

export function getHashes(): string[] {
  return [...HASHES]
}

export { createHash, createHmac, createCipheriv, createDecipheriv, randomBytes }
