buffer.ts
This file
Path
src/utils/buffer.ts
35 lines · 674 bytes · TypeScript
Last changed by
feat: basic auth middleware supports overriding `hashFunction` (#128)Yusuke Wadabefore adoption7a31de5
History of this fileTake it
refactor: create `utils/crypto.ts` (#118)Yusuke Wadabefore adoptionbea8aef
lines 1–2why, one step back1import { sha256 } from './crypto'2refactor(utils): better management for utils modules to avoid kitchen sink issue (#59)Minghebefore adoptionc522636
lines 3–21why, one step back3export const equal = (a: ArrayBuffer, b: ArrayBuffer) => {4 if (a === b) {5 return true6 }7 if (a.byteLength !== b.byteLength) {8 return false9 }1011 const va = new DataView(a)12 const vb = new DataView(b)1314 let i = va.byteLength15 while (i--) {16 if (va.getUint8(i) !== vb.getUint8(i)) {17 return false18 }19 }2021 return truefeat: Basic-auth with polyfill (#86)Yusuke Wadabefore adoptiond5280a1
lines 22–23why, one step back22}23chore: set up prettier (#106)Yusuke Wadabefore adoption9c397fb
lines 24–25why, one step back24export const timingSafeEqual = async (25 a: string | object | boolean,feat: basic auth middleware supports overriding `hashFunction` (#128)Yusuke Wadabefore adoption7a31de5
lines 26–27why, one step back26 b: string | object | boolean,27 hashFunction?: Functionchore: set up prettier (#106)Yusuke Wadabefore adoption9c397fb
line 28why, one step back28) => {feat: basic auth middleware supports overriding `hashFunction` (#128)Yusuke Wadabefore adoption7a31de5
lines 29–33why, one step back29 if (!hashFunction) {30 hashFunction = sha25631 }32 const sa = await hashFunction(a)33 const sb = await hashFunction(b)feat: Basic-auth with polyfill (#86)Yusuke Wadabefore adoptiond5280a1
line 34why, one step back34 return sa === sb && a === brefactor(utils): better management for utils modules to avoid kitchen sink issue (#59)Minghebefore adoptionc522636
line 35why, one step back35}