fix: replace node buffers with uint8arrays (#180)

* fix: replace node buffers with uint8arrays

All usage of node buffers have been replaced with uint8arrays.

BREAKING CHANGES:

- Where node Buffers were returned, now Uint8Arrays are

* chore: remove commented code
This commit is contained in:
Alex Potsides
2020-08-07 15:23:02 +01:00
committed by GitHub
parent 8b3dc56dc2
commit a0f387aeab
35 changed files with 344 additions and 349 deletions

View File

@ -4,8 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect
const { Buffer } = require('buffer')
const uint8ArrayFromString = require('uint8arrays/from-string')
const crypto = require('../')
const webcrypto = require('../src/webcrypto')
@ -38,7 +37,7 @@ describe('Missing web crypto', () => {
})
it('should error for hmac create when web crypto is missing', () => {
return expectMissingWebCrypto(() => crypto.hmac.create('SHA256', Buffer.from('secret')))
return expectMissingWebCrypto(() => crypto.hmac.create('SHA256', uint8ArrayFromString('secret')))
})
it('should error for generate ephemeral key pair when web crypto is missing', () => {
@ -54,10 +53,10 @@ describe('Missing web crypto', () => {
})
it('should error for sign RSA private key when web crypto is missing', () => {
return expectMissingWebCrypto(() => rsaPrivateKey.sign(Buffer.from('test')))
return expectMissingWebCrypto(() => rsaPrivateKey.sign(uint8ArrayFromString('test')))
})
it('should error for verify RSA public key when web crypto is missing', () => {
return expectMissingWebCrypto(() => rsaPrivateKey.public.verify(Buffer.from('test'), Buffer.from('test')))
return expectMissingWebCrypto(() => rsaPrivateKey.public.verify(uint8ArrayFromString('test'), uint8ArrayFromString('test')))
})
})