fix: mask differences in auth duration (#946)
This commit is contained in:
parent
6e16f3b30a
commit
4ca93aaf89
4 changed files with 40 additions and 14 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { generateDummyPassword } from './utils';
|
||||
|
||||
export const isProductionEnvironment = process.env.NODE_ENV === 'production';
|
||||
|
||||
export const isTestEnvironment = Boolean(
|
||||
|
|
@ -5,3 +7,5 @@ export const isTestEnvironment = Boolean(
|
|||
process.env.PLAYWRIGHT ||
|
||||
process.env.CI_PLAYWRIGHT,
|
||||
);
|
||||
|
||||
export const DUMMY_PASSWORD = generateDummyPassword();
|
||||
|
|
|
|||
26
lib/utils.ts
26
lib/utils.ts
|
|
@ -1,16 +1,15 @@
|
|||
import type {
|
||||
CoreAssistantMessage,
|
||||
CoreToolMessage,
|
||||
Message,
|
||||
TextStreamPart,
|
||||
ToolInvocation,
|
||||
ToolSet,
|
||||
UIMessage,
|
||||
import {
|
||||
generateId,
|
||||
type CoreAssistantMessage,
|
||||
type CoreToolMessage,
|
||||
type Message,
|
||||
type UIMessage,
|
||||
} from 'ai';
|
||||
import { type ClassValue, clsx } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
import type { DBMessage, Document } from '@/lib/db/schema';
|
||||
import type { Document } from '@/lib/db/schema';
|
||||
import { genSaltSync, hashSync } from 'bcrypt-ts';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
|
|
@ -163,3 +162,12 @@ export function getTrailingMessageId({
|
|||
|
||||
return trailingMessage.id;
|
||||
}
|
||||
|
||||
export function generateDummyPassword() {
|
||||
const password = generateId(12);
|
||||
|
||||
const salt = genSaltSync(10);
|
||||
const hash = hashSync(password, salt);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue