Skip to content
Myr

buffer.test.ts

This file

Path

src/utils/buffer.test.ts

55 lines · 2.1 KiB · TypeScript

Last changed by

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

History of this file

Take it

The walk stopped after 200 commits: lines older than be40084 point at it.

feat: basic auth middleware supports overriding `hashFunction` (#128)Yusuke Wadabefore adoption7a31de5

line 1why, one step back
1import { SHA256 as sha256CryptoJS } from 'crypto-js'

chore: absolute import to relative import (#228)Yusuke Wadabefore adoption6ddba47

line 2why, one step back
2import { timingSafeEqual, bufferToString } from './buffer'

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 3–13why, one step back
3
4describe('buffer', () => {5 it('positive', async () => {6 expect(7 await timingSafeEqual(8 '127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935',9 '127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935'10 )11 ).toBe(true)12 expect(await timingSafeEqual('a', 'a')).toBe(true)13 expect(await timingSafeEqual('', '')).toBe(true)

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

lines 14–15why, one step back
14 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15 // @ts-ignore

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 16–18why, one step back
16 expect(await timingSafeEqual(undefined, undefined)).toBe(true)
17 expect(await timingSafeEqual(true, true)).toBe(true)18 expect(await timingSafeEqual(false, false)).toBe(true)

feat: basic auth middleware supports overriding `hashFunction` (#128)Yusuke Wadabefore adoption7a31de5

line 19why, one step back
19 expect(await timingSafeEqual(true, true, (d: string) => sha256CryptoJS(d).toString()))

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 20–31why, one step back
20 })
2122 it('negative', async () => {23 expect(await timingSafeEqual('a', 'b')).toBe(false)24 expect(25 await timingSafeEqual('a', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')26 ).toBe(false)27 expect(28 await timingSafeEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'a')29 ).toBe(false)30 expect(await timingSafeEqual('alpha', 'beta')).toBe(false)31 expect(await timingSafeEqual(false, true)).toBe(false)

refactor(TypeScript): enable strict null check (#280)Yusuke Wadabefore adoptionb55eb2e

lines 32–33why, one step back
32 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33 // @ts-ignore

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 34–45why, one step back
34 expect(await timingSafeEqual(false, undefined)).toBe(false)
35 expect(36 await timingSafeEqual(37 () => {},38 () => {}39 )40 ).toBe(false)41 expect(await timingSafeEqual({}, {})).toBe(false)42 expect(await timingSafeEqual({ a: 1 }, { a: 1 })).toBe(false)43 expect(await timingSafeEqual({ a: 1 }, { a: 2 })).toBe(false)44 expect(await timingSafeEqual([1, 2], [1, 2])).toBe(false)45 expect(await timingSafeEqual([1, 2], [1, 2, 3])).toBe(false)

refactor: refine code (#167)Yusuke Wadabefore adoptionb41b1eb

lines 46–53why, one step back
46 })
47})4849describe('bufferToString', () => {50 it('Should return あいうえお', () => {51 const bytes = [227, 129, 130, 227, 129, 132, 227, 129, 134, 227, 129, 136, 227, 129, 138]52 const buffer = Uint8Array.from(bytes).buffer53 expect(bufferToString(buffer)).toBe('あいうえお')

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 54–55why, one step back
54 })
55})