diff --git a/package.json b/package.json index 7747f32..0bc6460 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "timing-safe-equal": "^1.0.0" }, "devDependencies": { + "buffer-shims": "^1.0.0", "hash-test-vectors": "~1.3.2", "pseudorandombytes": "^2.0.0", "standard": "^5.0.2", diff --git a/test/timing-safe-equal.js b/test/timing-safe-equal.js index 7bb1fe2..2b91c41 100644 --- a/test/timing-safe-equal.js +++ b/test/timing-safe-equal.js @@ -1,28 +1,29 @@ var test = require('tape') var timingSafeEqual = require('timing-safe-equal/browser') +var bufferShims = require('buffer-shims') test('timingSafeEqual', function (t) { t.plan(5) t.strictEqual( - timingSafeEqual(Buffer.from('foo'), Buffer.from('foo')), + timingSafeEqual(bufferShims.from('foo'), bufferShims.from('foo')), true, 'should consider equal strings to be equal' ) t.strictEqual( - timingSafeEqual(Buffer.from('foo'), Buffer.from('bar')), + timingSafeEqual(bufferShims.from('foo'), bufferShims.from('bar')), false, 'should consider unequal strings to be unequal' ) t.throws(function () { - timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2])) + timingSafeEqual(bufferShims.from([1, 2, 3]), bufferShims.from([1, 2])) }, 'should throw when given buffers with different lengths') t.throws(function () { - timingSafeEqual('not a buffer', Buffer.from([1, 2])) + timingSafeEqual('not a buffer', bufferShims.from([1, 2])) }, 'should throw if the first argument is not a buffer') t.throws(function () { - timingSafeEqual(Buffer.from([1, 2]), 'not a buffer') + timingSafeEqual(bufferShims.from([1, 2]), 'not a buffer') }, 'should throw if the second argument is not a buffer') })