* Constant-time comparison for the OAuth `state` parameter. Real * exploitability is very low (loopback, 256-bit entropy, narrow flow * window), but the rest of the auth path uses crypto-grade primitives * and a `!==` here would be a gratuitous deviation in security review.
(actual: string, expected: string)
| 169 | * and a `!==` here would be a gratuitous deviation in security review. |
| 170 | */ |
| 171 | function stateMatches(actual: string, expected: string): boolean { |
| 172 | const a = Buffer.from(actual, "utf8"); |
| 173 | const b = Buffer.from(expected, "utf8"); |
| 174 | if (a.length !== b.length) return false; |
| 175 | return timingSafeEqual(a, b); |
| 176 | } |
| 177 | |
| 178 | function respond(res: ServerResponse, status: number, body: string): void { |
| 179 | res |