UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

34 lines (33 loc) 1.34 kB
import { makeScrypt, Password } from "@withstudiocms/auth-kit"; import { PasswordModOptions } from "@withstudiocms/auth-kit/config"; import { CheckIfUnsafe } from "@withstudiocms/auth-kit/utils/unsafeCheck"; import chalk from "chalk"; import dotenv from "dotenv"; import { Effect, runEffect } from "../../effect.js"; dotenv.config({ quiet: true }); let { CMS_ENCRYPTION_KEY } = process.env; if (!CMS_ENCRYPTION_KEY) { console.warn( `${chalk.yellow.bold("Warning:")} ${chalk.yellow( "CMS_ENCRYPTION_KEY is not set... " )}${chalk.gray("Some commands may be disabled.")}` ); CMS_ENCRYPTION_KEY = "+URKVIiIM1kmG6g9Znb10g=="; } const { hashPassword, verifyPasswordStrength } = await runEffect( Effect.gen(function* () { const config = yield* PasswordModOptions; const Scrypt = yield* makeScrypt(config); const { hashPassword: hashPassword2, verifyPasswordStrength: verifyPasswordStrength2 } = yield* Password(Scrypt); return { hashPassword: hashPassword2, verifyPasswordStrength: verifyPasswordStrength2 }; }).pipe(Effect.provide(PasswordModOptions.Live({ CMS_ENCRYPTION_KEY }))) ); const getCheckers = Effect.gen(function* () { const { _tag, ...mod } = yield* CheckIfUnsafe; return mod; }).pipe(Effect.provide(CheckIfUnsafe.Default)); export { getCheckers, hashPassword, verifyPasswordStrength };