Skip to content

Commit e7b2455

Browse files
committed
use buffer shims
1 parent 7e87fc7 commit e7b2455

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"timing-safe-equal": "^1.0.0"
3232
},
3333
"devDependencies": {
34+
"buffer-shims": "^1.0.0",
3435
"hash-test-vectors": "~1.3.2",
3536
"pseudorandombytes": "^2.0.0",
3637
"standard": "^5.0.2",

test/timing-safe-equal.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
var test = require('tape')
22
var timingSafeEqual = require('timing-safe-equal/browser')
3+
var bufferShims = require('buffer-shims')
34
test('timingSafeEqual', function (t) {
45
t.plan(5)
56
t.strictEqual(
6-
timingSafeEqual(Buffer.from('foo'), Buffer.from('foo')),
7+
timingSafeEqual(bufferShims.from('foo'), bufferShims.from('foo')),
78
true,
89
'should consider equal strings to be equal'
910
)
1011

1112
t.strictEqual(
12-
timingSafeEqual(Buffer.from('foo'), Buffer.from('bar')),
13+
timingSafeEqual(bufferShims.from('foo'), bufferShims.from('bar')),
1314
false,
1415
'should consider unequal strings to be unequal'
1516
)
1617

1718
t.throws(function () {
18-
timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2]))
19+
timingSafeEqual(bufferShims.from([1, 2, 3]), bufferShims.from([1, 2]))
1920
}, 'should throw when given buffers with different lengths')
2021

2122
t.throws(function () {
22-
timingSafeEqual('not a buffer', Buffer.from([1, 2]))
23+
timingSafeEqual('not a buffer', bufferShims.from([1, 2]))
2324
}, 'should throw if the first argument is not a buffer')
2425

2526
t.throws(function () {
26-
timingSafeEqual(Buffer.from([1, 2]), 'not a buffer')
27+
timingSafeEqual(bufferShims.from([1, 2]), 'not a buffer')
2728
}, 'should throw if the second argument is not a buffer')
2829
})

0 commit comments

Comments
 (0)