mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
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:
+15
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user