From 7b5b22b51921375b0c164dfdc71ac2fc806d0794 Mon Sep 17 00:00:00 2001 From: Moinul Moin Date: Sat, 23 Nov 2024 15:40:49 +0600 Subject: [PATCH] hotfix: update oslojs codes --- package.json | 2 +- src/actions/auth.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e9f96b7..e95b642 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chadnext", - "version": "1.6.0", + "version": "1.7.0", "private": true, "scripts": { "dev": "prisma generate && next dev", diff --git a/src/actions/auth.ts b/src/actions/auth.ts index 84548aa..368d547 100644 --- a/src/actions/auth.ts +++ b/src/actions/auth.ts @@ -2,11 +2,13 @@ import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; -import { alphabet, generateRandomString } from "oslo/crypto"; +import { generateRandomString, RandomReader } from "@oslojs/crypto/random"; import { deleteSessionTokenCookie } from "~/lib/server/cookies"; import prisma from "~/lib/server/prisma"; import { getCurrentSession, invalidateSession } from "~/lib/server/session"; +const digits = "0123456789"; + export async function logout() { const { session } = await getCurrentSession(); if (!session) { @@ -30,7 +32,12 @@ export async function generateEmailVerificationCode( userId, }, }); - const code = generateRandomString(6, alphabet("0-9")); + const random: RandomReader = { + read(bytes) { + crypto.getRandomValues(bytes); + }, + }; + const code = generateRandomString(random, digits, 6); await prisma.emailVerificationCode.create({ data: { userId,