(user: LoggedInUser, id: string, keyName: string, permissions: string[])
| 192 | |
| 193 | // Update api key |
| 194 | const updateApiKey = async (user: LoggedInUser, id: string, keyName: string, permissions: string[]) => { |
| 195 | // Validate permissions before updating the key |
| 196 | validatePermissions(user, permissions, 'update') |
| 197 | |
| 198 | const appServer = getRunningExpressApp() |
| 199 | const currentKey = await appServer.AppDataSource.getRepository(ApiKey).findOneBy({ |
| 200 | id: id, |
| 201 | workspaceId: user.activeWorkspaceId |
| 202 | }) |
| 203 | if (!currentKey) { |
| 204 | throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `ApiKey ${currentKey} not found`) |
| 205 | } |
| 206 | currentKey.keyName = keyName |
| 207 | currentKey.permissions = permissions |
| 208 | await appServer.AppDataSource.getRepository(ApiKey).save(currentKey) |
| 209 | return await getAllApiKeys(user) |
| 210 | } |
| 211 | |
| 212 | const deleteApiKey = async (id: string, workspaceId: string) => { |
| 213 | try { |
nothing calls this directly
no test coverage detected