MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / getCredentialById

Function getCredentialById

packages/server/src/services/credentials/index.ts:127–167  ·  view source on GitHub ↗
(credentialId: string, workspaceId: string)

Source from the content-addressed store, hash-verified

125}
126
127const getCredentialById = async (credentialId: string, workspaceId: string): Promise<any> => {
128 try {
129 const appServer = getRunningExpressApp()
130 const credential = await appServer.AppDataSource.getRepository(Credential).findOneBy({
131 id: credentialId,
132 workspaceId: workspaceId
133 })
134 if (!credential) {
135 throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Credential ${credentialId} not found`)
136 }
137 // Decrpyt credentialData
138 const decryptedCredentialData = await decryptCredentialData(
139 credential.encryptedData,
140 credential.credentialName,
141 appServer.nodesPool.componentCredentials
142 )
143 const returnCredential: ICredentialReturnResponse = {
144 ...credential,
145 plainDataObj: decryptedCredentialData
146 }
147 const dbResponse: any = omit(returnCredential, ['encryptedData'])
148 if (workspaceId) {
149 const shared = await appServer.AppDataSource.getRepository(WorkspaceShared).count({
150 where: {
151 workspaceId: workspaceId,
152 sharedItemId: credentialId,
153 itemType: 'credential'
154 }
155 })
156 if (shared > 0) {
157 dbResponse.shared = true
158 }
159 }
160 return dbResponse
161 } catch (error) {
162 throw new InternalFlowiseError(
163 StatusCodes.INTERNAL_SERVER_ERROR,
164 `Error: credentialsService.createCredential - ${getErrorMessage(error)}`
165 )
166 }
167}
168
169const updateCredential = async (credentialId: string, requestBody: any, workspaceId: string): Promise<any> => {
170 try {

Callers

nothing calls this directly

Calls 3

getRunningExpressAppFunction · 0.90
decryptCredentialDataFunction · 0.90
getErrorMessageFunction · 0.90

Tested by

no test coverage detected