(selectedCredentialId: string, options: ICommonObject)
| 649 | * @returns {Promise<ICommonObject>} |
| 650 | */ |
| 651 | export const getCredentialData = async (selectedCredentialId: string, options: ICommonObject): Promise<ICommonObject> => { |
| 652 | const appDataSource = options.appDataSource as DataSource |
| 653 | const databaseEntities = options.databaseEntities as IDatabaseEntity |
| 654 | |
| 655 | try { |
| 656 | if (!selectedCredentialId) { |
| 657 | return {} |
| 658 | } |
| 659 | |
| 660 | const credential = await appDataSource.getRepository(databaseEntities['Credential']).findOneBy({ |
| 661 | id: selectedCredentialId |
| 662 | }) |
| 663 | |
| 664 | if (!credential) return {} |
| 665 | |
| 666 | // Decrypt credentialData |
| 667 | const decryptedCredentialData = await decryptCredentialData(credential.encryptedData) |
| 668 | |
| 669 | return decryptedCredentialData |
| 670 | } catch (e) { |
| 671 | throw new Error(e) |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * Get first non falsy value |
no test coverage detected