From d24c5d8b2b8f74da12b70707b78d7a98ded79af9 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 8 May 2025 14:38:18 +0100
Subject: [PATCH] Update to Node 22 LTS (#4832)

Switch typescript lib to es2024 and make necessary type changes

Fixes https://github.com/matrix-org/matrix-js-sdk/issues/4796

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
 package.json                           | 2 +-
 spec/integ/crypto/verification.spec.ts | 4 ++--
 src/matrixrtc/EncryptionManager.ts     | 2 +-
 src/matrixrtc/MatrixRTCSession.ts      | 2 +-
 tsconfig.json                          | 3 ++-
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/package.json b/package.json
index 44a198e52..0171ddd2e 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
     "version": "37.5.0",
     "description": "Matrix Client-Server SDK for Javascript",
     "engines": {
-        "node": ">=20.0.0"
+        "node": ">=22.0.0"
     },
     "scripts": {
         "prepack": "yarn build",
diff --git a/spec/integ/crypto/verification.spec.ts b/spec/integ/crypto/verification.spec.ts
index a2e5c946a..53e49e1d0 100644
--- a/spec/integ/crypto/verification.spec.ts
+++ b/spec/integ/crypto/verification.spec.ts
@@ -1604,7 +1604,7 @@ function sha256(commitmentStr: string): string {
     return encodeUnpaddedBase64(createHash("sha256").update(commitmentStr, "utf8").digest());
 }
 
-function encodeUnpaddedBase64(uint8Array: ArrayBuffer | Uint8Array): string {
+function encodeUnpaddedBase64(uint8Array: ArrayLike<number>): string {
     return Buffer.from(uint8Array).toString("base64").replace(/=+$/g, "");
 }
 
@@ -1638,7 +1638,7 @@ function buildReadyMessage(
 }
 
 /** build an m.key.verification.start to-device message suitable for the m.reciprocate.v1 flow, originating from the dummy device */
-function buildReciprocateStartMessage(transactionId: string, sharedSecret: ArrayBuffer) {
+function buildReciprocateStartMessage(transactionId: string, sharedSecret: ArrayLike<number>) {
     return {
         type: "m.key.verification.start",
         content: {
diff --git a/src/matrixrtc/EncryptionManager.ts b/src/matrixrtc/EncryptionManager.ts
index 0b0fe9cb9..ccfb1e7a3 100644
--- a/src/matrixrtc/EncryptionManager.ts
+++ b/src/matrixrtc/EncryptionManager.ts
@@ -89,7 +89,7 @@ export class EncryptionManager implements IEncryptionManager {
         private transport: IKeyTransport,
         private statistics: Statistics,
         private onEncryptionKeysChanged: (
-            keyBin: Uint8Array<ArrayBufferLike>,
+            keyBin: Uint8Array,
             encryptionKeyIndex: number,
             participantId: string,
         ) => void,
diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts
index d20773d2d..d4ad66254 100644
--- a/src/matrixrtc/MatrixRTCSession.ts
+++ b/src/matrixrtc/MatrixRTCSession.ts
@@ -417,7 +417,7 @@ export class MatrixRTCSession extends TypedEventEmitter<
                 () => this.memberships,
                 transport,
                 this.statistics,
-                (keyBin: Uint8Array<ArrayBufferLike>, encryptionKeyIndex: number, participantId: string) => {
+                (keyBin: Uint8Array, encryptionKeyIndex: number, participantId: string) => {
                     this.emit(MatrixRTCSessionEvent.EncryptionKeyChanged, keyBin, encryptionKeyIndex, participantId);
                 },
                 this.logger,
diff --git a/tsconfig.json b/tsconfig.json
index 6b99f40fa..72aed9a34 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,7 +9,8 @@
         "noEmit": true,
         "declaration": true,
         "strict": true,
-        "allowImportingTsExtensions": true
+        "allowImportingTsExtensions": true,
+        "lib": ["es2024"]
     },
     "include": ["./src/**/*.ts", "./spec/**/*.ts"]
 }
-- 
GitLab