From 2ec7d6f6c530d38103139c315c8d5c53539dc61f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 16:34:16 +0000 Subject: [PATCH 1/2] chore(deps): update dependency typescript to v5.9.3 --- package.json | 2 +- pnpm-lock.yaml | 108 ++++++++++++++++++++++++------------------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index e67f1abbba..68196baf25 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "size-limit": "^11.2.0", "typedoc": "0.28.10", "typedoc-plugin-no-inherit": "1.6.1", - "typescript": "5.8.3", + "typescript": "5.9.3", "vite": "7.1.2", "vitest": "^3.0.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49b9c4e561..c602414ec8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -92,10 +92,10 @@ importers: version: 0.7.39 '@typescript-eslint/eslint-plugin': specifier: 7.18.0 - version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3) + version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) '@typescript-eslint/parser': specifier: 7.18.0 - version: 7.18.0(eslint@8.57.1)(typescript@5.8.3) + version: 7.18.0(eslint@8.57.1)(typescript@5.9.3) downlevel-dts: specifier: ^0.11.0 version: 0.11.0 @@ -104,7 +104,7 @@ importers: version: 8.57.1 eslint-config-airbnb-typescript: specifier: 18.0.0 - version: 18.0.0(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1))(eslint@8.57.1) + version: 18.0.0(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1))(eslint@8.57.1) eslint-config-prettier: specifier: 10.1.8 version: 10.1.8(eslint@8.57.1) @@ -113,7 +113,7 @@ importers: version: 3.2.1(eslint@8.57.1) eslint-plugin-import: specifier: 2.32.0 - version: 2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1) + version: 2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1) gh-pages: specifier: 6.3.0 version: 6.3.0 @@ -134,19 +134,19 @@ importers: version: 2.2.0(rollup@4.46.2) rollup-plugin-typescript2: specifier: 0.36.0 - version: 0.36.0(rollup@4.46.2)(typescript@5.8.3) + version: 0.36.0(rollup@4.46.2)(typescript@5.9.3) size-limit: specifier: ^11.2.0 version: 11.2.0 typedoc: specifier: 0.28.10 - version: 0.28.10(typescript@5.8.3) + version: 0.28.10(typescript@5.9.3) typedoc-plugin-no-inherit: specifier: 1.6.1 - version: 1.6.1(typedoc@0.28.10(typescript@5.8.3)) + version: 1.6.1(typedoc@0.28.10(typescript@5.9.3)) typescript: - specifier: 5.8.3 - version: 5.8.3 + specifier: 5.9.3 + version: 5.9.3 vite: specifier: 7.1.2 version: 7.1.2(jiti@2.4.2)(terser@5.39.2)(yaml@2.8.0) @@ -3448,13 +3448,13 @@ packages: engines: {node: '>=4.2.0'} hasBin: true - typescript@5.8.3: - resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} hasBin: true - typescript@6.0.0-dev.20250923: - resolution: {integrity: sha512-Aiy0yklpKnRJkElhXO/bB2DhosYfL+j4RiUinq6C58ncyDOjuKn5wk6O5rds4n4AOobAqMjLU55H5q7bEyDcMQ==} + typescript@6.0.0-dev.20251001: + resolution: {integrity: sha512-FwticMnSAyRGVO2htUy3PKk7Q80NwX+bdysyyxzbx9Bs90efZ/UrXSJp+jdQqzFcrx/0Pf3lQV3IGz+Aoz1xMw==} engines: {node: '>=14.17'} hasBin: true @@ -5072,34 +5072,34 @@ snapshots: '@types/unist@3.0.3': {} - '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.8.3) + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.9.3) '@typescript-eslint/scope-manager': 7.18.0 - '@typescript-eslint/type-utils': 7.18.0(eslint@8.57.1)(typescript@5.8.3) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.8.3) + '@typescript-eslint/type-utils': 7.18.0(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 7.18.0 eslint: 8.57.1 graphemer: 1.4.0 ignore: 5.3.1 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.8.3) + ts-api-utils: 1.3.0(typescript@5.9.3) optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3)': + '@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.9.3) '@typescript-eslint/visitor-keys': 7.18.0 debug: 4.3.6 eslint: 8.57.1 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -5108,21 +5108,21 @@ snapshots: '@typescript-eslint/types': 7.18.0 '@typescript-eslint/visitor-keys': 7.18.0 - '@typescript-eslint/type-utils@7.18.0(eslint@8.57.1)(typescript@5.8.3)': + '@typescript-eslint/type-utils@7.18.0(eslint@8.57.1)(typescript@5.9.3)': dependencies: - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.8.3) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.9.3) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.9.3) debug: 4.4.1 eslint: 8.57.1 - ts-api-utils: 1.3.0(typescript@5.8.3) + ts-api-utils: 1.3.0(typescript@5.9.3) optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color '@typescript-eslint/types@7.18.0': {} - '@typescript-eslint/typescript-estree@7.18.0(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@7.18.0(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 7.18.0 '@typescript-eslint/visitor-keys': 7.18.0 @@ -5131,18 +5131,18 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.0 - ts-api-utils: 1.3.0(typescript@5.8.3) + ts-api-utils: 1.3.0(typescript@5.9.3) optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@7.18.0(eslint@8.57.1)(typescript@5.8.3)': + '@typescript-eslint/utils@7.18.0(eslint@8.57.1)(typescript@5.9.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.1) '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.9.3) eslint: 8.57.1 transitivePeerDependencies: - supports-color @@ -5687,7 +5687,7 @@ snapshots: dependencies: semver: 7.6.0 shelljs: 0.8.5 - typescript: 6.0.0-dev.20250923 + typescript: 6.0.0-dev.20251001 dunder-proto@1.0.1: dependencies: @@ -5917,21 +5917,21 @@ snapshots: eslint: 8.57.1 semver: 7.6.0 - eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1))(eslint@8.57.1): + eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1))(eslint@8.57.1): dependencies: confusing-browser-globals: 1.0.11 eslint: 8.57.1 - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1) object.assign: 4.1.5 object.entries: 1.1.7 semver: 6.3.1 - eslint-config-airbnb-typescript@18.0.0(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1))(eslint@8.57.1): + eslint-config-airbnb-typescript@18.0.0(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1))(eslint@8.57.1): dependencies: - '@typescript-eslint/eslint-plugin': 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3) - '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.8.3) + '@typescript-eslint/eslint-plugin': 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.9.3) eslint: 8.57.1 - eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1))(eslint@8.57.1) + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1))(eslint@8.57.1) transitivePeerDependencies: - eslint-plugin-import @@ -5947,11 +5947,11 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1): + eslint-module-utils@2.12.1(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1): dependencies: debug: 3.2.7 optionalDependencies: - '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.8.3) + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.9.3) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: @@ -5972,7 +5972,7 @@ snapshots: eslint: 8.57.1 eslint-compat-utils: 0.5.0(eslint@8.57.1) - eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 @@ -5983,7 +5983,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.1(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1) + eslint-module-utils: 2.12.1(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 @@ -5995,7 +5995,7 @@ snapshots: string.prototype.trimend: 1.0.9 tsconfig-paths: 3.15.0 optionalDependencies: - '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.8.3) + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.9.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack @@ -7059,7 +7059,7 @@ snapshots: del: 6.1.1 rollup: 4.46.2 - rollup-plugin-typescript2@0.36.0(rollup@4.46.2)(typescript@5.8.3): + rollup-plugin-typescript2@0.36.0(rollup@4.46.2)(typescript@5.9.3): dependencies: '@rollup/pluginutils': 4.2.1 find-cache-dir: 3.3.2 @@ -7067,7 +7067,7 @@ snapshots: rollup: 4.46.2 semver: 7.6.0 tslib: 2.8.1 - typescript: 5.8.3 + typescript: 5.9.3 rollup@4.46.2: dependencies: @@ -7423,9 +7423,9 @@ snapshots: dependencies: escape-string-regexp: 1.0.5 - ts-api-utils@1.3.0(typescript@5.8.3): + ts-api-utils@1.3.0(typescript@5.9.3): dependencies: - typescript: 5.8.3 + typescript: 5.9.3 ts-debounce@4.0.0: {} @@ -7513,24 +7513,24 @@ snapshots: optionalDependencies: rxjs: 7.8.1 - typedoc-plugin-no-inherit@1.6.1(typedoc@0.28.10(typescript@5.8.3)): + typedoc-plugin-no-inherit@1.6.1(typedoc@0.28.10(typescript@5.9.3)): dependencies: - typedoc: 0.28.10(typescript@5.8.3) + typedoc: 0.28.10(typescript@5.9.3) - typedoc@0.28.10(typescript@5.8.3): + typedoc@0.28.10(typescript@5.9.3): dependencies: '@gerrit0/mini-shiki': 3.9.2 lunr: 2.3.9 markdown-it: 14.1.0 minimatch: 9.0.5 - typescript: 5.8.3 + typescript: 5.9.3 yaml: 2.8.0 typescript@4.5.2: {} - typescript@5.8.3: {} + typescript@5.9.3: {} - typescript@6.0.0-dev.20250923: {} + typescript@6.0.0-dev.20251001: {} uc.micro@2.1.0: {} From 5d7d9f787208fa7ba07a76cf4b9c63e501d839c3 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Thu, 2 Oct 2025 12:40:52 +0200 Subject: [PATCH 2/2] update to non shared types --- src/e2ee/E2eeManager.ts | 18 ++++++++-------- src/e2ee/types.ts | 14 ++++++------- src/e2ee/utils.ts | 10 ++++----- src/e2ee/worker/DataCryptor.ts | 12 +++++------ src/e2ee/worker/FrameCryptor.test.ts | 4 ++-- src/e2ee/worker/FrameCryptor.ts | 21 ++++++++++++------- src/e2ee/worker/ParticipantKeyHandler.test.ts | 8 +++---- src/e2ee/worker/e2ee.worker.ts | 4 ++-- src/e2ee/worker/naluUtils.ts | 8 +++---- src/e2ee/worker/sifPayload.ts | 18 +++++++++------- src/room/RTCEngine.ts | 10 +++++---- src/room/Room.ts | 13 ++++++++---- src/room/events.ts | 4 ++-- src/room/participant/LocalParticipant.ts | 2 +- src/room/participant/Participant.ts | 2 +- src/room/track/Track.ts | 2 +- src/room/track/record.ts | 2 +- src/room/utils.ts | 4 ++-- .../non-shared-typed-arrays.d.ts | 1 + src/utils/dataPacketBuffer.ts | 2 +- 20 files changed, 88 insertions(+), 71 deletions(-) create mode 100644 src/type-polyfills/non-shared-typed-arrays.d.ts diff --git a/src/e2ee/E2eeManager.ts b/src/e2ee/E2eeManager.ts index a9efa4b729..082f94d829 100644 --- a/src/e2ee/E2eeManager.ts +++ b/src/e2ee/E2eeManager.ts @@ -42,11 +42,11 @@ export interface BaseE2EEManager { isEnabled: boolean; isDataChannelEncryptionEnabled: boolean; setParticipantCryptorEnabled(enabled: boolean, participantIdentity: string): void; - setSifTrailer(trailer: Uint8Array): void; - encryptData(data: Uint8Array): Promise; + setSifTrailer(trailer: NonSharedUint8Array): void; + encryptData(data: NonSharedUint8Array): Promise; handleEncryptedData( - payload: Uint8Array, - iv: Uint8Array, + payload: NonSharedUint8Array, + iv: NonSharedUint8Array, participantIdentity: string, keyIndex: number, ): Promise; @@ -131,7 +131,7 @@ export class E2EEManager /** * @internal */ - setSifTrailer(trailer: Uint8Array) { + setSifTrailer(trailer: NonSharedUint8Array) { if (!trailer || trailer.length === 0) { log.warn("ignoring server sent trailer as it's empty"); } else { @@ -291,7 +291,7 @@ export class E2EEManager ); } - async encryptData(data: Uint8Array): Promise { + async encryptData(data: NonSharedUint8Array): Promise { if (!this.worker) { throw Error('could not encrypt data, worker is missing'); } @@ -314,8 +314,8 @@ export class E2EEManager } handleEncryptedData( - payload: Uint8Array, - iv: Uint8Array, + payload: NonSharedUint8Array, + iv: NonSharedUint8Array, participantIdentity: string, keyIndex: number, ) { @@ -404,7 +404,7 @@ export class E2EEManager this.worker.postMessage(msg); } - private postSifTrailer(trailer: Uint8Array) { + private postSifTrailer(trailer: NonSharedUint8Array) { if (!this.worker) { throw Error('could not post SIF trailer, worker is missing'); } diff --git a/src/e2ee/types.ts b/src/e2ee/types.ts index 915a8178ae..372e84d49e 100644 --- a/src/e2ee/types.ts +++ b/src/e2ee/types.ts @@ -37,7 +37,7 @@ export interface RTPVideoMapMessage extends BaseMessage { export interface SifTrailerMessage extends BaseMessage { kind: 'setSifTrailer'; data: { - trailer: Uint8Array; + trailer: NonSharedUint8Array; }; } @@ -113,8 +113,8 @@ export interface DecryptDataRequestMessage extends BaseMessage { kind: 'decryptDataRequest'; data: { uuid: string; - payload: Uint8Array; - iv: Uint8Array; + payload: NonSharedUint8Array; + iv: NonSharedUint8Array; participantIdentity: string; keyIndex: number; }; @@ -124,7 +124,7 @@ export interface DecryptDataResponseMessage extends BaseMessage { kind: 'decryptDataResponse'; data: { uuid: string; - payload: Uint8Array; + payload: NonSharedUint8Array; }; } @@ -132,7 +132,7 @@ export interface EncryptDataRequestMessage extends BaseMessage { kind: 'encryptDataRequest'; data: { uuid: string; - payload: Uint8Array; + payload: NonSharedUint8Array; participantIdentity: string; }; } @@ -141,8 +141,8 @@ export interface EncryptDataResponseMessage extends BaseMessage { kind: 'encryptDataResponse'; data: { uuid: string; - payload: Uint8Array; - iv: Uint8Array; + payload: NonSharedUint8Array; + iv: NonSharedUint8Array; keyIndex: number; }; } diff --git a/src/e2ee/utils.ts b/src/e2ee/utils.ts index a75f78a351..0ccc13a952 100644 --- a/src/e2ee/utils.ts +++ b/src/e2ee/utils.ts @@ -25,7 +25,7 @@ export function isVideoFrame( } export async function importKey( - keyBytes: Uint8Array | ArrayBuffer, + keyBytes: NonSharedUint8Array | ArrayBuffer, algorithm: string | { name: string } = { name: ENCRYPTION_ALGORITHM }, usage: 'derive' | 'encrypt' = 'encrypt', ) { @@ -111,7 +111,7 @@ export async function deriveKeys(material: CryptoKey, salt: string) { return { material, encryptionKey }; } -export function createE2EEKey(): Uint8Array { +export function createE2EEKey(): NonSharedUint8Array { return window.crypto.getRandomValues(new Uint8Array(32)); } @@ -126,14 +126,14 @@ export async function ratchet(material: CryptoKey, salt: string): Promise { const iv = DataCryptor.makeIV(performance.now()); @@ -51,14 +51,14 @@ export class DataCryptor { } static async decrypt( - data: Uint8Array, - iv: Uint8Array, + data: NonSharedUint8Array, + iv: NonSharedUint8Array, keys: ParticipantKeyHandler, keyIndex: number = 0, initialMaterial?: KeySet, ratchetOpts: DecodeRatchetOptions = { ratchetCount: 0 }, ): Promise<{ - payload: Uint8Array; + payload: NonSharedUint8Array; }> { const keySet = await keys.getKeySet(keyIndex); if (!keySet) { diff --git a/src/e2ee/worker/FrameCryptor.test.ts b/src/e2ee/worker/FrameCryptor.test.ts index 42dd2f12a2..80d2191cae 100644 --- a/src/e2ee/worker/FrameCryptor.test.ts +++ b/src/e2ee/worker/FrameCryptor.test.ts @@ -13,7 +13,7 @@ function mockEncryptedRTCEncodedVideoFrame(keyIndex: number): RTCEncodedVideoFra return mockRTCEncodedVideoFrame(data); } -function mockRTCEncodedVideoFrame(data: Uint8Array): RTCEncodedVideoFrame { +function mockRTCEncodedVideoFrame(data: NonSharedUint8Array): RTCEncodedVideoFrame { return { data: data.buffer, timestamp: vitest.getMockedSystemTime()?.getTime() ?? 0, @@ -24,7 +24,7 @@ function mockRTCEncodedVideoFrame(data: Uint8Array): RTCEncodedVideoFrame { }; } -function mockFrameTrailer(keyIndex: number): Uint8Array { +function mockFrameTrailer(keyIndex: number): NonSharedUint8Array { const frameTrailer = new Uint8Array(2); frameTrailer[0] = IV_LENGTH; diff --git a/src/e2ee/worker/FrameCryptor.ts b/src/e2ee/worker/FrameCryptor.ts index 379e604eb1..239d20d9a2 100644 --- a/src/e2ee/worker/FrameCryptor.ts +++ b/src/e2ee/worker/FrameCryptor.ts @@ -64,7 +64,7 @@ export class FrameCryptor extends BaseFrameCryptor { /** * used for detecting server injected unencrypted frames */ - private sifTrailer: Uint8Array; + private sifTrailer: NonSharedUint8Array; private detectedCodec?: VideoCodec; @@ -74,7 +74,7 @@ export class FrameCryptor extends BaseFrameCryptor { keys: ParticipantKeyHandler; participantIdentity: string; keyProviderOptions: KeyProviderOptions; - sifTrailer?: Uint8Array; + sifTrailer?: NonSharedUint8Array; }) { super(); this.sendCounts = new Map(); @@ -205,7 +205,7 @@ export class FrameCryptor extends BaseFrameCryptor { this.trackId = trackId; } - setSifTrailer(trailer: Uint8Array) { + setSifTrailer(trailer: NonSharedUint8Array) { workerLogger.debug('setting SIF trailer', { ...this.logContext, trailer }); this.sifTrailer = trailer; } @@ -294,7 +294,7 @@ export class FrameCryptor extends BaseFrameCryptor { new Uint8Array(encodedFrame.data, frameInfo.unencryptedBytes), ); - let newDataWithoutHeader = new Uint8Array( + let newDataWithoutHeader: NonSharedUint8Array = new Uint8Array( cipherText.byteLength + iv.byteLength + frameTrailer.byteLength, ); newDataWithoutHeader.set(new Uint8Array(cipherText)); // add ciphertext. @@ -426,8 +426,12 @@ export class FrameCryptor extends BaseFrameCryptor { // ---------+-------------------------+-+---------+---- try { - const frameHeader = new Uint8Array(encodedFrame.data, 0, frameInfo.unencryptedBytes); - var encryptedData = new Uint8Array( + const frameHeader: NonSharedUint8Array = new Uint8Array( + encodedFrame.data, + 0, + frameInfo.unencryptedBytes, + ); + var encryptedData: NonSharedUint8Array = new Uint8Array( encodedFrame.data, frameHeader.length, encodedFrame.data.byteLength - frameHeader.length, @@ -647,7 +651,10 @@ export class FrameCryptor extends BaseFrameCryptor { * by the livekit server and thus to be treated as unencrypted * @internal */ -export function isFrameServerInjected(frameData: ArrayBuffer, trailerBytes: Uint8Array): boolean { +export function isFrameServerInjected( + frameData: ArrayBuffer, + trailerBytes: NonSharedUint8Array, +): boolean { if (trailerBytes.byteLength === 0) { return false; } diff --git a/src/e2ee/worker/ParticipantKeyHandler.test.ts b/src/e2ee/worker/ParticipantKeyHandler.test.ts index a18faa429c..8ebfe24ebf 100644 --- a/src/e2ee/worker/ParticipantKeyHandler.test.ts +++ b/src/e2ee/worker/ParticipantKeyHandler.test.ts @@ -261,7 +261,7 @@ describe('ParticipantKeyHandler', () => { await keyHandler.setKey(originalMaterial); - const ciphertexts: Uint8Array[] = []; + const ciphertexts: NonSharedUint8Array[] = []; const plaintext = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); @@ -354,8 +354,8 @@ describe('ParticipantKeyHandler', () => { async function encrypt( participantKeyHandler: ParticipantKeyHandler, keyIndex: number, - iv: Uint8Array, - data: Uint8Array, + iv: NonSharedUint8Array, + data: NonSharedUint8Array, ): Promise { return crypto.subtle.encrypt( { @@ -370,7 +370,7 @@ describe('ParticipantKeyHandler', () => { async function decrypt( participantKeyHandler: ParticipantKeyHandler, keyIndex: number, - iv: Uint8Array, + iv: NonSharedUint8Array, cipherText: ArrayBuffer, ): Promise { return crypto.subtle.decrypt( diff --git a/src/e2ee/worker/e2ee.worker.ts b/src/e2ee/worker/e2ee.worker.ts index 9be87107d8..08c45e521a 100644 --- a/src/e2ee/worker/e2ee.worker.ts +++ b/src/e2ee/worker/e2ee.worker.ts @@ -29,7 +29,7 @@ let isEncryptionEnabled: boolean = false; let useSharedKey: boolean = false; -let sifTrailer: Uint8Array | undefined; +let sifTrailer: NonSharedUint8Array | undefined; let keyProviderOptions: KeyProviderOptions = KEY_PROVIDER_DEFAULTS; @@ -301,7 +301,7 @@ function emitRatchetedKeys( postMessage(msg); } -function handleSifTrailer(trailer: Uint8Array) { +function handleSifTrailer(trailer: NonSharedUint8Array) { sifTrailer = trailer; participantCryptors.forEach((c) => { c.setSifTrailer(trailer); diff --git a/src/e2ee/worker/naluUtils.ts b/src/e2ee/worker/naluUtils.ts index 475a10418e..5a4076c84d 100644 --- a/src/e2ee/worker/naluUtils.ts +++ b/src/e2ee/worker/naluUtils.ts @@ -200,7 +200,7 @@ export interface NALUProcessingResult { * @param naluIndices Indices where NALUs start * @returns Detected codec type */ -function detectCodecFromNALUs(data: Uint8Array, naluIndices: number[]): DetectedCodec { +function detectCodecFromNALUs(data: NonSharedUint8Array, naluIndices: number[]): DetectedCodec { for (const naluIndex of naluIndices) { if (isH264SliceNALU(parseH264NALUType(data[naluIndex]))) return 'h264'; if (isH265SliceNALU(parseH265NALUType(data[naluIndex]))) return 'h265'; @@ -216,7 +216,7 @@ function detectCodecFromNALUs(data: Uint8Array, naluIndices: number[]): Detected * @returns Number of unencrypted bytes (index + 2) or null if no slice found */ function findSliceNALUUnencryptedBytes( - data: Uint8Array, + data: NonSharedUint8Array, naluIndices: number[], codec: 'h264' | 'h265', ): number | null { @@ -246,7 +246,7 @@ function findSliceNALUUnencryptedBytes( * @param stream Byte stream containing NALUs * @returns Array of indices where NALUs start (after the start code) */ -function findNALUIndices(stream: Uint8Array): number[] { +function findNALUIndices(stream: NonSharedUint8Array): number[] { const result: number[] = []; let start = 0, pos = 0, @@ -309,7 +309,7 @@ function findNALUIndices(stream: Uint8Array): number[] { * @returns NALU processing result */ export function processNALUsForEncryption( - data: Uint8Array, + data: NonSharedUint8Array, knownCodec?: 'h264' | 'h265', ): NALUProcessingResult { const naluIndices = findNALUIndices(data); diff --git a/src/e2ee/worker/sifPayload.ts b/src/e2ee/worker/sifPayload.ts index 09f0baf41f..c2dc62804a 100644 --- a/src/e2ee/worker/sifPayload.ts +++ b/src/e2ee/worker/sifPayload.ts @@ -2,29 +2,31 @@ import type { VideoCodec } from '../..'; // Payload definitions taken from https://github.com/livekit/livekit/blob/master/pkg/sfu/downtrack.go#L104 -export const VP8KeyFrame8x8: Uint8Array = new Uint8Array([ +export const VP8KeyFrame8x8: NonSharedUint8Array = new Uint8Array([ 0x10, 0x02, 0x00, 0x9d, 0x01, 0x2a, 0x08, 0x00, 0x08, 0x00, 0x00, 0x47, 0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x02, 0x02, 0x00, 0x0c, 0x0d, 0x60, 0x00, 0xfe, 0xff, 0xab, 0x50, 0x80, ]); -export const H264KeyFrame2x2SPS: Uint8Array = new Uint8Array([ +export const H264KeyFrame2x2SPS: NonSharedUint8Array = new Uint8Array([ 0x67, 0x42, 0xc0, 0x1f, 0x0f, 0xd9, 0x1f, 0x88, 0x88, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xc8, 0x3c, 0x60, 0xc9, 0x20, ]); -export const H264KeyFrame2x2PPS: Uint8Array = new Uint8Array([0x68, 0x87, 0xcb, 0x83, 0xcb, 0x20]); +export const H264KeyFrame2x2PPS: NonSharedUint8Array = new Uint8Array([ + 0x68, 0x87, 0xcb, 0x83, 0xcb, 0x20, +]); -export const H264KeyFrame2x2IDR: Uint8Array = new Uint8Array([ +export const H264KeyFrame2x2IDR: NonSharedUint8Array = new Uint8Array([ 0x65, 0x88, 0x84, 0x0a, 0xf2, 0x62, 0x80, 0x00, 0xa7, 0xbe, ]); -export const H264KeyFrame2x2: Uint8Array[] = [ +export const H264KeyFrame2x2: NonSharedUint8Array[] = [ H264KeyFrame2x2SPS, H264KeyFrame2x2PPS, H264KeyFrame2x2IDR, ]; -export const OpusSilenceFrame: Uint8Array = new Uint8Array([ +export const OpusSilenceFrame: NonSharedUint8Array = new Uint8Array([ 0xf8, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -35,7 +37,7 @@ export const OpusSilenceFrame: Uint8Array = new Uint8Array([ /** * Create a crypto hash using Web Crypto API for secure comparison operations */ -async function cryptoHash(data: Uint8Array | ArrayBuffer): Promise { +async function cryptoHash(data: NonSharedUint8Array | ArrayBuffer): Promise { const hashBuffer = await crypto.subtle.digest('SHA-256', data); const hashArray = new Uint8Array(hashBuffer); return Array.from(hashArray) @@ -58,7 +60,7 @@ export const CryptoHashes = { * Check if a byte array matches any of the known SIF payload frame types using secure crypto hashes */ export async function identifySifPayload( - data: Uint8Array | ArrayBuffer, + data: NonSharedUint8Array | ArrayBuffer, ): Promise { const hash = await cryptoHash(data); diff --git a/src/room/RTCEngine.ts b/src/room/RTCEngine.ts index 8af239ad51..dc9e767337 100644 --- a/src/room/RTCEngine.ts +++ b/src/room/RTCEngine.ts @@ -724,8 +724,8 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit return; } const decryptedData = await this.e2eeManager?.handleEncryptedData( - dp.value.value.encryptedValue, - dp.value.value.iv, + dp.value.value.encryptedValue as NonSharedUint8Array, + dp.value.value.iv as NonSharedUint8Array, dp.participantIdentity, dp.value.value.keyIndex, ); @@ -1222,7 +1222,9 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit if (this.e2eeManager && this.e2eeManager.isDataChannelEncryptionEnabled) { const encryptablePacket = asEncryptablePacket(packet); if (encryptablePacket) { - const encryptedData = await this.e2eeManager.encryptData(encryptablePacket.toBinary()); + const encryptedData = await this.e2eeManager.encryptData( + encryptablePacket.toBinary() as NonSharedUint8Array, + ); packet.value = { case: 'encryptedPacket', value: new EncryptedPacket({ @@ -1239,7 +1241,7 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit this.reliableDataSequence += 1; } - const msg = packet.toBinary(); + const msg = packet.toBinary() as Uint8Array; const dc = this.dataChannelForKind(kind); if (dc) { diff --git a/src/room/Room.ts b/src/room/Room.ts index ceea07f2d6..331be77364 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -804,7 +804,7 @@ class Room extends (EventEmitter as new () => TypedEmitter) if (this.e2eeManager) { try { - this.e2eeManager.setSifTrailer(joinResponse.sifTrailer); + this.e2eeManager.setSifTrailer(joinResponse.sifTrailer as NonSharedUint8Array); } catch (e: any) { this.log.error(e instanceof Error ? e.message : 'Could not set SifTrailer', { ...this.logContext, @@ -1764,7 +1764,7 @@ class Room extends (EventEmitter as new () => TypedEmitter) ) => { this.emit( RoomEvent.DataReceived, - userPacket.payload, + userPacket.payload as NonSharedUint8Array, participant, kind, userPacket.topic, @@ -1772,7 +1772,12 @@ class Room extends (EventEmitter as new () => TypedEmitter) ); // also emit on the participant - participant?.emit(ParticipantEvent.DataReceived, userPacket.payload, kind, encryptionType); + participant?.emit( + ParticipantEvent.DataReceived, + userPacket.payload as NonSharedUint8Array, + kind, + encryptionType, + ); }; private handleSipDtmf = (participant: RemoteParticipant | undefined, dtmf: SipDTMF) => { @@ -2613,7 +2618,7 @@ export type RoomEventCallbacks = { activeSpeakersChanged: (speakers: Array) => void; roomMetadataChanged: (metadata: string) => void; dataReceived: ( - payload: Uint8Array, + payload: NonSharedUint8Array, participant?: RemoteParticipant, kind?: DataPacket_Kind, topic?: string, diff --git a/src/room/events.ts b/src/room/events.ts index 26248686e6..64035a1b38 100644 --- a/src/room/events.ts +++ b/src/room/events.ts @@ -225,7 +225,7 @@ export enum RoomEvent { * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads. * All participants in the room will receive the messages sent to the room. * - * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]], topic?: string) + * args: (payload: NonSharedUint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]], topic?: string) */ DataReceived = 'dataReceived', @@ -469,7 +469,7 @@ export enum ParticipantEvent { * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads. * All participants in the room will receive the messages sent to the room. * - * args: (payload: Uint8Array, kind: [[DataPacket_Kind]]) + * args: (payload: NonSharedUint8Array, kind: [[DataPacket_Kind]]) */ DataReceived = 'dataReceived', diff --git a/src/room/participant/LocalParticipant.ts b/src/room/participant/LocalParticipant.ts index bd4b937900..50b37f19ca 100644 --- a/src/room/participant/LocalParticipant.ts +++ b/src/room/participant/LocalParticipant.ts @@ -1629,7 +1629,7 @@ export default class LocalParticipant extends Participant { * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode * @param options optionally specify a `reliable`, `topic` and `destination` */ - async publishData(data: Uint8Array, options: DataPublishOptions = {}): Promise { + async publishData(data: NonSharedUint8Array, options: DataPublishOptions = {}): Promise { const kind = options.reliable ? DataPacket_Kind.RELIABLE : DataPacket_Kind.LOSSY; const destinationIdentities = options.destinationIdentities; const topic = options.topic; diff --git a/src/room/participant/Participant.ts b/src/room/participant/Participant.ts index 5cc2f72202..032bcb85c2 100644 --- a/src/room/participant/Participant.ts +++ b/src/room/participant/Participant.ts @@ -410,7 +410,7 @@ export type ParticipantEventCallbacks = { participantMetadataChanged: (prevMetadata: string | undefined, participant?: any) => void; participantNameChanged: (name: string) => void; dataReceived: ( - payload: Uint8Array, + payload: NonSharedUint8Array, kind: DataPacket_Kind, encryptionType?: Encryption_Type, ) => void; diff --git a/src/room/track/Track.ts b/src/room/track/Track.ts index 94e4d915b6..cb32ffd8ca 100644 --- a/src/room/track/Track.ts +++ b/src/room/track/Track.ts @@ -537,6 +537,6 @@ export type TrackEventCallbacks = { trackProcessorUpdate: (processor?: TrackProcessor) => void; audioTrackFeatureUpdate: (track: any, feature: AudioTrackFeature, enabled: boolean) => void; timeSyncUpdate: (update: { timestamp: number; rtpTimestamp: number }) => void; - preConnectBufferFlushed: (buffer: Uint8Array[]) => void; + preConnectBufferFlushed: (buffer: NonSharedUint8Array[]) => void; cpuConstrained: () => void; }; diff --git a/src/room/track/record.ts b/src/room/track/record.ts index 249b06df1e..d2afc3421c 100644 --- a/src/room/track/record.ts +++ b/src/room/track/record.ts @@ -51,7 +51,7 @@ export class LocalTrackRecorder extends RecorderBase { start: (controller) => { streamController = controller; dataListener = async (event: BlobEvent) => { - let data: Uint8Array; + let data: NonSharedUint8Array; if (event.data.arrayBuffer) { const arrayBuffer = await event.data.arrayBuffer(); diff --git a/src/room/utils.ts b/src/room/utils.ts index 75f2383dcd..94949f51f8 100644 --- a/src/room/utils.ts +++ b/src/room/utils.ts @@ -696,12 +696,12 @@ export function isRemoteParticipant(p: Participant): p is RemoteParticipant { return !p.isLocal; } -export function splitUtf8(s: string, n: number): Uint8Array[] { +export function splitUtf8(s: string, n: number): NonSharedUint8Array[] { if (n < 4) { throw new Error('n must be at least 4 due to utf8 encoding rules'); } // adapted from https://stackoverflow.com/a/6043797 - const result: Uint8Array[] = []; + const result: NonSharedUint8Array[] = []; let encoded = new TextEncoder().encode(s); while (encoded.length > n) { let k = n; diff --git a/src/type-polyfills/non-shared-typed-arrays.d.ts b/src/type-polyfills/non-shared-typed-arrays.d.ts new file mode 100644 index 0000000000..98abe32fe1 --- /dev/null +++ b/src/type-polyfills/non-shared-typed-arrays.d.ts @@ -0,0 +1 @@ +type NonSharedUint8Array = ReturnType; diff --git a/src/utils/dataPacketBuffer.ts b/src/utils/dataPacketBuffer.ts index 9d41877d66..2a310e94ff 100644 --- a/src/utils/dataPacketBuffer.ts +++ b/src/utils/dataPacketBuffer.ts @@ -1,5 +1,5 @@ export interface DataPacketItem { - data: Uint8Array; + data: NonSharedUint8Array; sequence: number; }