Skip to content

Commit 4dc8bc7

Browse files
fix: avoid unsafe buffer usage (#895)
1 parent 93fcb5a commit 4dc8bc7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/utils/Vault/Vault.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export namespace Vault {
1919
}
2020

2121
export async function encrypt(text: string) {
22-
const plaintext = new Buffer(text).toString('base64')
22+
const plaintext = Buffer.from(text).toString('base64')
2323
const encrypted = await this.vault.write('transit/encrypt/frost', {
2424
plaintext,
2525
})
@@ -30,7 +30,7 @@ export namespace Vault {
3030
const decrypted = await this.vault.write('transit/decrypt/frost', {
3131
ciphertext,
3232
})
33-
return new Buffer(decrypted.data.plaintext, 'base64').toString('ascii')
33+
return Buffer.from(decrypted.data.plaintext, 'base64').toString('ascii')
3434
}
3535

3636
export async function createToken(options?: object) {

test/Integration/works/create.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('Works', function() {
109109
const { token } = user
110110
const { apiToken } = await frost.createApiToken(token, Network.LIVE)
111111

112-
const contentBuffer = new Buffer(1024 * 100)
112+
const contentBuffer = Buffer.alloc(1024 * 100)
113113
const content = contentBuffer.toString()
114114

115115
await expect(frost.createWork(apiToken, createWork({ content })))

0 commit comments

Comments
 (0)