Skip to content

Commit

Permalink
refactor(api): Replace for loop with array indexing while decrypting …
Browse files Browse the repository at this point in the history
…secrets during bulk fetch #265 (#266)
  • Loading branch information
anudeeps352 authored Jun 10, 2024
1 parent fd36abd commit 62a1731
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions apps/api/src/secret/service/secret.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,14 @@ export class SecretService {
} = {}

for (const secret of secrets) {
// Decrypt the secret value
for (let i = 0; i < secret.versions.length; i++) {
const version = secret.versions[i]
// Optionally decrypt secret value if decryptValue is true
if (decryptValue) {
const decryptedValue = await decrypt(
project.privateKey,
version.value
)
version.value = decryptedValue
}
// Optionally decrypt secret value if decryptValue is true
if (decryptValue) {
const latestSecretVersion = secret.versions[0]
const decryptedValue = await decrypt(
project.privateKey,
latestSecretVersion.value
)
latestSecretVersion.value = decryptedValue
}

const { id, name } = secret.environment
Expand Down

0 comments on commit 62a1731

Please sign in to comment.