Skip to content
Myr

buffer.ts

This file

Path

src/utils/buffer.ts

43 lines · 872 bytes · TypeScript

Last changed by

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

History of this file

Take it

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

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

line 1why, one step back
1import { sha256 } from './crypto'

refactor: create `utils/crypto.ts` (#118)Yusuke Wadabefore adoptionbea8aef

line 2why, one step back
2

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 3–25why, one step back
3export 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 true22}2324export const timingSafeEqual = async (25 a: string | object | boolean,

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

lines 26–27why, one step back
26 b: string | object | boolean,
27 hashFunction?: Function

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

line 28why, one step back
28) => {

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

lines 29–33why, one step back
29 if (!hashFunction) {
30 hashFunction = sha25631 }32 const sa = await hashFunction(a)33 const sb = await hashFunction(b)

Bump up to v0.4.2Yusuke Wadabefore adoptionbe40084

lines 34–35why, one step back
34 return sa === sb && a === b
35}

refactor: refine code (#167)Yusuke Wadabefore adoptionb41b1eb

lines 36–43why, one step back
36
37export const bufferToString = (buffer: ArrayBuffer): string => {38 if (buffer instanceof ArrayBuffer) {39 const enc = new TextDecoder('utf-8')40 return enc.decode(buffer)41 }42 return buffer43}