diff --git a/components/gitpod-protocol/src/encryption/encryption-engine.spec.ts b/components/gitpod-protocol/src/encryption/encryption-engine.spec.ts index 41a905911191b6..548d6025ffb7c0 100644 --- a/components/gitpod-protocol/src/encryption/encryption-engine.spec.ts +++ b/components/gitpod-protocol/src/encryption/encryption-engine.spec.ts @@ -24,7 +24,7 @@ class TestEncryptionEngineImpl { @test basicSymmetry() { const plaintext = "12345678901234567890"; - const key = new Buffer(this.testkey, "base64"); + const key = Buffer.from(this.testkey, "base64"); const cut = new EncryptionEngineImpl(); const encryptedData = cut.encrypt(plaintext, key); diff --git a/components/gitpod-protocol/src/encryption/encryption-engine.ts b/components/gitpod-protocol/src/encryption/encryption-engine.ts index 7687ed2e986644..f3f90071abb399 100644 --- a/components/gitpod-protocol/src/encryption/encryption-engine.ts +++ b/components/gitpod-protocol/src/encryption/encryption-engine.ts @@ -40,7 +40,7 @@ export class EncryptionEngineImpl { encrypt(data: string, key: Buffer): EncryptedData { const iv = crypto.randomBytes(16); const cipher = crypto.createCipheriv(this.algorithm, key, iv); - const encrypted = cipher.update(new Buffer(data, "utf8")); + const encrypted = cipher.update(Buffer.from(data, "utf8")); const finalEncrypted = Buffer.concat([encrypted, cipher.final()]); return { data: finalEncrypted.toString(this.enc), @@ -51,8 +51,12 @@ export class EncryptionEngineImpl { } decrypt(encryptedData: EncryptedData, key: Buffer): string { - const decipher = crypto.createDecipheriv(this.algorithm, key, new Buffer(encryptedData.keyParams.iv, this.enc)); - let decrypted = decipher.update(new Buffer(encryptedData.data, this.enc)); + const decipher = crypto.createDecipheriv( + this.algorithm, + key, + Buffer.from(encryptedData.keyParams.iv, this.enc), + ); + let decrypted = decipher.update(Buffer.from(encryptedData.data, this.enc)); const finalDecrypted = Buffer.concat([decrypted, decipher.final()]); return finalDecrypted.toString("utf8"); } diff --git a/components/gitpod-protocol/src/encryption/key-provider.ts b/components/gitpod-protocol/src/encryption/key-provider.ts index b0a160c9bc28bd..a5c96f4bcf8802 100644 --- a/components/gitpod-protocol/src/encryption/key-provider.ts +++ b/components/gitpod-protocol/src/encryption/key-provider.ts @@ -71,7 +71,7 @@ export class KeyProviderImpl implements KeyProvider { name: config.name, version: config.version, }, - material: new Buffer(config.material, "base64"), + material: Buffer.from(config.material, "base64"), }; } } diff --git a/components/ws-manager-bridge/src/messagebus-integration.ts b/components/ws-manager-bridge/src/messagebus-integration.ts index 231642bf9e7ba7..21087c19b27900 100644 --- a/components/ws-manager-bridge/src/messagebus-integration.ts +++ b/components/ws-manager-bridge/src/messagebus-integration.ts @@ -44,7 +44,7 @@ export class MessageBusIntegration extends AbstractMessageBusIntegration { await super.publish( MessageBusHelperImpl.WORKSPACE_EXCHANGE_LOCAL, topic, - new Buffer(JSON.stringify(instance)), + Buffer.from(JSON.stringify(instance)), { trace: { span }, }, @@ -63,7 +63,7 @@ export class MessageBusIntegration extends AbstractMessageBusIntegration { } const topic = this.messageBusHelper.getWsTopicForPublishing(userId, workspaceId, "headless-log"); - const msg = new Buffer(JSON.stringify(evt)); + const msg = Buffer.from(JSON.stringify(evt)); await this.messageBusHelper.assertWorkspaceExchange(this.channel); await super.publish(MessageBusHelperImpl.WORKSPACE_EXCHANGE_LOCAL, topic, msg, { trace: ctx,