diff --git a/packages/backend/src/entity/Deployer.ts b/packages/backend/src/entity/Deployer.ts index 657e0805..72f386ca 100644 --- a/packages/backend/src/entity/Deployer.ts +++ b/packages/backend/src/entity/Deployer.ts @@ -10,7 +10,7 @@ export class Deployer { deployerId!: string; @Column('varchar') - deployerApiUrl!: string; + deployerApiUrl!: string; @Column('varchar') baseDomain!: string; diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index facf5450..f8c55355 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -265,16 +265,7 @@ export class Registry { throw new Error(`No record found for ${lrn}`); } - // Config to be encrypted - const config = { - "authorized": [data.requesterAddress], - "config": { "env": data.environmentVariables }, - } - - // Serialize the config (convert to YAML) - const serialized = JSON.stringify(config, null, 2); - - const envHash = await this.generateHash(serialized, data.publicKey, data.apiUrl); + const envHash = await this.generateConfigHash(data.environmentVariables, data.requesterAddress, data.publicKey, data.apiUrl); // Create record of type ApplicationDeploymentRequest and publish const applicationDeploymentRequest = { @@ -548,14 +539,22 @@ export class Registry { return `lrn://${this.registryConfig.authority}/applications/${appName}`; } - async generateHash(message: string, pubKey: string, url: string): Promise { + async generateConfigHash(environmentVariables: { [key: string]: string }, requesterAddress: string, pubKey: string, url: string): Promise { + // Config to be encrypted + const config = { + "authorized": [requesterAddress], + "config": { "env": environmentVariables }, + } + + // Serialize the config (convert to YAML) + const serialized = JSON.stringify(config, null, 2); const armoredKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----\n\n${pubKey}\n\n-----END PGP PUBLIC KEY BLOCK-----`; const publicKey = await openpgp.readKey({ armoredKey }); // Encrypt the config const encrypted = await openpgp.encrypt({ - message: await openpgp.createMessage({ text: message }), + message: await openpgp.createMessage({ text: serialized }), encryptionKeys: publicKey, format: 'binary' });