From 30b40c3c7afc80f7de2f61fc097ca84139d419d4 Mon Sep 17 00:00:00 2001 From: Jonathan Baldie Date: Fri, 1 May 2026 20:09:57 +0100 Subject: [PATCH] Fix buffer-equal-constant-time for Node.js v25+ compatibility --- server/libs/jwa/buffer-equal-constant-time/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/libs/jwa/buffer-equal-constant-time/index.js b/server/libs/jwa/buffer-equal-constant-time/index.js index 07c14266..56a7252c 100644 --- a/server/libs/jwa/buffer-equal-constant-time/index.js +++ b/server/libs/jwa/buffer-equal-constant-time/index.js @@ -28,14 +28,19 @@ function bufferEq(a, b) { } bufferEq.install = function () { - Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) { + Buffer.prototype.equal = function equal(that) { return bufferEq(this, that); }; + if (SlowBuffer && SlowBuffer.prototype) { + SlowBuffer.prototype.equal = Buffer.prototype.equal; + } }; var origBufEqual = Buffer.prototype.equal; -var origSlowBufEqual = SlowBuffer.prototype.equal; +var origSlowBufEqual = SlowBuffer && SlowBuffer.prototype ? SlowBuffer.prototype.equal : undefined; bufferEq.restore = function () { Buffer.prototype.equal = origBufEqual; - SlowBuffer.prototype.equal = origSlowBufEqual; + if (SlowBuffer && SlowBuffer.prototype) { + SlowBuffer.prototype.equal = origSlowBufEqual; + } };