diff --git a/packages/backend/src/entity/Deployer.ts b/packages/backend/src/entity/Deployer.ts index e6c2a904..fb217e69 100644 --- a/packages/backend/src/entity/Deployer.ts +++ b/packages/backend/src/entity/Deployer.ts @@ -15,8 +15,8 @@ export class Deployer { @Column('varchar') baseDomain!: string; - @Column('varchar') - publicKey!: string; + @Column('varchar', { nullable: true}) + publicKey!: string | null; @Column('varchar', { nullable: true }) minimumPayment!: string | null; diff --git a/packages/backend/src/entity/Deployment.ts b/packages/backend/src/entity/Deployment.ts index 5c772b32..88cd0df1 100644 --- a/packages/backend/src/entity/Deployment.ts +++ b/packages/backend/src/entity/Deployment.ts @@ -36,7 +36,9 @@ export interface ApplicationDeploymentRequest { application: string; lrn?: string; auction?: string; - config: string; + config: { + ref: string; + }; meta: string; payment?: string; } diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 689a5cac..2c0516ad 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -272,13 +272,24 @@ export class Registry { "config": { "env": data.environmentVariables }, } - const serialized = yaml.dump(config) + const binaryKey = Buffer.from(data.publicKey, 'base64'); - const publicKey = await openpgp.readKey({ armoredKey: data.publicKey }); + // Convert binary to ASCII-armored format + const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----\n\n` + + binaryKey.toString('base64').match(/.{1,64}/g)?.join('\n') + + `\n\n-----END PGP PUBLIC KEY BLOCK-----`; + // Read the public key + const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored }); + + // Serialize the config (convert to YAML) + const serialized = JSON.stringify(config, null, 2); // Use YAML if needed + + // Encrypt the config const encrypted = await openpgp.encrypt({ message: await openpgp.createMessage({ text: serialized }), - encryptionKeys: publicKey + encryptionKeys: publicKey, + format: 'binary' // Equivalent to armor=False }); // To get the hash after uploading encrypted env diff --git a/packages/backend/test/publish-deploy-records.ts b/packages/backend/test/publish-deploy-records.ts index 26e0823a..8f78a806 100644 --- a/packages/backend/test/publish-deploy-records.ts +++ b/packages/backend/test/publish-deploy-records.ts @@ -10,7 +10,7 @@ import { Deployment, DeploymentStatus, Environment } from '../src/entity/Deploym const log = debug('snowball:publish-deploy-records'); async function main() { - const { registryConfig, database, misc } = await getConfig(); + const { registryConfig, database } = await getConfig(); const registry = new Registry( registryConfig.gqlEndpoint,