Skip to content

Commit

Permalink
refactor: Update CredentialManager constructor to accept worldId and …
Browse files Browse the repository at this point in the history
…agentId as parameters
  • Loading branch information
HaruHunab1320 committed Jul 19, 2024
1 parent 2642ae5 commit 774c423
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { decrypt, encrypt } from '@magickml/credentials'
import { CREDENTIALS_ENCRYPTION_KEY } from '@magickml/server-config'

export class CredentialManager implements ICredentialManager {
protected projectId: string
protected worldId: string
protected agentId: string
protected cachedCredentials: CredentialKeyValuePair[] = []

constructor(agentId: string, projectId: string) {
this.projectId = projectId
constructor({ worldId, agentId }: { worldId: string; agentId: string }) {
this.worldId = worldId
this.agentId = agentId
}

Expand All @@ -39,7 +39,7 @@ export class CredentialManager implements ICredentialManager {
where: {
agentId: this.agentId,
credentials: {
projectId: this.projectId,
worldId: this.worldId,
},
},
include: {
Expand Down Expand Up @@ -82,7 +82,7 @@ export class CredentialManager implements ICredentialManager {
agentId: this.agentId,
credentials: {
credentialType: 'custom',
projectId: this.projectId,
worldId: this.worldId,
name,
},
},
Expand All @@ -108,7 +108,7 @@ export class CredentialManager implements ICredentialManager {
where: {
name: credential.name,
serviceType: credential?.serviceType,
projectId: this.projectId,
worldId: this.worldId,
},
})

Expand All @@ -121,7 +121,8 @@ export class CredentialManager implements ICredentialManager {
name: credential.name,
value: encrypt(credential.value, CREDENTIALS_ENCRYPTION_KEY),
serviceType: credential.serviceType,
projectId: this.projectId,
worldId: this.worldId,
projectId: '',
credentialType: credential.credentialType,
description: credential.description,
},
Expand All @@ -143,7 +144,7 @@ export class CredentialManager implements ICredentialManager {
where: {
name: credential.name,
serviceType: credential?.serviceType,
projectId: this.projectId,
worldId: this.worldId,
},
})

Expand Down Expand Up @@ -172,7 +173,7 @@ export class CredentialManager implements ICredentialManager {
agentId: this.agentId,
credentials: {
name: name as string,
projectId: this.projectId,
worldId: this.worldId,
},
},
})
Expand All @@ -181,7 +182,7 @@ export class CredentialManager implements ICredentialManager {
await prismaCore.credentials.deleteMany({
where: {
name: name as string,
projectId: this.projectId,
worldId: this.worldId,
},
})

Expand Down

0 comments on commit 774c423

Please sign in to comment.