MCPcopy
hub / github.com/FlowiseAI/Flowise / createApiKey

Function createApiKey

packages/server/src/services/apikey/index.ts:174–191  ·  view source on GitHub ↗
(user: LoggedInUser, keyName: string, permissions: string[])

Source from the content-addressed store, hash-verified

172}
173
174const createApiKey = async (user: LoggedInUser, keyName: string, permissions: string[]) => {
175 // Validate permissions before creating the key
176 validatePermissions(user, permissions, 'create')
177
178 const apiKey = generateAPIKey()
179 const apiSecret = generateSecretHash(apiKey)
180 const appServer = getRunningExpressApp()
181 const newKey = new ApiKey()
182 newKey.id = uuidv4()
183 newKey.apiKey = apiKey
184 newKey.apiSecret = apiSecret
185 newKey.keyName = keyName
186 newKey.permissions = permissions
187 newKey.workspaceId = user.activeWorkspaceId
188 const key = appServer.AppDataSource.getRepository(ApiKey).create(newKey)
189 await appServer.AppDataSource.getRepository(ApiKey).save(key)
190 return await getAllApiKeys(user)
191}
192
193// Update api key
194const updateApiKey = async (user: LoggedInUser, id: string, keyName: string, permissions: string[]) => {

Callers

nothing calls this directly

Calls 6

generateAPIKeyFunction · 0.90
generateSecretHashFunction · 0.90
getRunningExpressAppFunction · 0.90
validatePermissionsFunction · 0.85
getAllApiKeysFunction · 0.70
createMethod · 0.45

Tested by

no test coverage detected