addons/isl-server/proxy/proxyUtils.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import {timingSafeEqual} from 'node:crypto';
b69ab319
b69ab3110/**
b69ab3111 * Timing safe comparison of tokens coming from strings.
b69ab3112 */
b69ab3113export function areTokensEqual(a: string, b: string): boolean {
b69ab3114 const aBuf = Buffer.from(a);
b69ab3115 const bBuf = Buffer.from(b);
b69ab3116 return aBuf.length === bBuf.length && timingSafeEqual(aBuf, bBuf);
b69ab3117}