Feature/api (#82)

* my test changes for branch protection

* feat(api): introduced 'deploy as an API' button and updated workflows db to include status of deployment

* feat(api): added 'trigger' column for logs table to indicate source of workflow run, persist logs from API executions, removed session validation in favor of API key

* fix(bug): cleanup old reference to JSX element in favor of ReactElement

* feat(api): added persistent notification for one-click deployment with copy boxes for url, keys, & ex curl

* fix(ui/notifications): cleaned up deploy with one-click button ui
This commit is contained in:
waleedlatif1
2025-02-23 13:46:50 -08:00
committed by GitHub
parent 48b6095d53
commit f52de5d1d6
27 changed files with 2184 additions and 1480 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
import { type ClassValue, clsx } from 'clsx'
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto'
import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'crypto'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
@@ -117,3 +117,17 @@ export function convertScheduleOptionsToCron(
throw new Error('Unsupported schedule type')
}
}
export async function generateApiKey(): Promise<string> {
const buffer = randomBytes(32)
const hash = createHash('sha256').update(buffer).digest('hex')
return `wf_${hash}`
}
export async function validateApiKey(
apiKey: string | null,
storedApiKey: string | null
): Promise<boolean> {
if (!apiKey || !storedApiKey) return false
return apiKey === storedApiKey
}