(body: ICredentialReqBody)
| 1743 | * @returns {Credential} |
| 1744 | */ |
| 1745 | export const transformToCredentialEntity = async (body: ICredentialReqBody): Promise<Credential> => { |
| 1746 | const credentialBody: ICommonObject = { |
| 1747 | name: body.name, |
| 1748 | credentialName: body.credentialName |
| 1749 | } |
| 1750 | |
| 1751 | if (body.plainDataObj) { |
| 1752 | const encryptedData = await encryptCredentialData(body.plainDataObj) |
| 1753 | credentialBody.encryptedData = encryptedData |
| 1754 | } |
| 1755 | |
| 1756 | const newCredential = new Credential() |
| 1757 | Object.assign(newCredential, credentialBody) |
| 1758 | |
| 1759 | if (body.workspaceId) { |
| 1760 | newCredential.workspaceId = body.workspaceId |
| 1761 | } |
| 1762 | |
| 1763 | return newCredential |
| 1764 | } |
| 1765 | |
| 1766 | /** |
| 1767 | * Redact values that are of password type to avoid sending back to client |
no test coverage detected