2022-10-29 22:21:24 +02:00
|
|
|
import { createHash } from 'node:crypto'
|
|
|
|
import dotenv from 'dotenv'
|
|
|
|
dotenv.config()
|
|
|
|
|
2022-10-31 17:54:49 +01:00
|
|
|
/*
|
|
|
|
* Cleans a string (typically email) for hashing
|
|
|
|
*/
|
|
|
|
export const clean = (string) => {
|
|
|
|
if (typeof string !== 'string') throw 'clean() only takes a string as input'
|
2022-10-29 22:21:24 +02:00
|
|
|
|
2022-10-31 17:54:49 +01:00
|
|
|
return string.toLowerCase().trim()
|
|
|
|
}
|
2022-10-29 22:21:24 +02:00
|
|
|
|
2022-10-31 17:54:49 +01:00
|
|
|
/*
|
|
|
|
* I find JSON.stringify to long to type, and prone to errors
|
|
|
|
* So I make an alias here: asJson
|
|
|
|
*/
|
|
|
|
export const asJson = JSON.stringify
|