fix typecheck

This commit is contained in:
mtvpls
2025-12-10 00:46:57 +08:00
parent a5b02ea8d5
commit 0b6723cf45
5 changed files with 19 additions and 11 deletions

View File

@@ -9,7 +9,8 @@
"WebFetch(domain:www.artplayer.org)", "WebFetch(domain:www.artplayer.org)",
"WebFetch(domain:m.douban.com)", "WebFetch(domain:m.douban.com)",
"WebFetch(domain:movie.douban.com)", "WebFetch(domain:movie.douban.com)",
"Bash(cat:*)" "Bash(cat:*)",
"Bash(pnpm typecheck)"
], ],
"deny": [], "deny": [],
"ask": [] "ask": []

View File

@@ -4,9 +4,11 @@
import React, { createContext, useContext, useEffect, useState, useCallback } from 'react'; import React, { createContext, useContext, useEffect, useState, useCallback } from 'react';
import { useWatchRoom } from '@/hooks/useWatchRoom'; import { useWatchRoom } from '@/hooks/useWatchRoom';
import type { Room, Member, ChatMessage, WatchRoomConfig } from '@/types/watch-room'; import type { Room, Member, ChatMessage, WatchRoomConfig } from '@/types/watch-room';
import type { WatchRoomSocket } from '@/lib/watch-room-socket';
import Toast, { ToastProps } from '@/components/Toast'; import Toast, { ToastProps } from '@/components/Toast';
// Import type from watch-room-socket
type WatchRoomSocket = import('@/lib/watch-room-socket').WatchRoomSocket;
interface WatchRoomContextType { interface WatchRoomContextType {
socket: WatchRoomSocket | null; socket: WatchRoomSocket | null;
isConnected: boolean; isConnected: boolean;

View File

@@ -139,8 +139,8 @@ export class AESDecryptor {
const invSubMix2 = invSubMix[2]; const invSubMix2 = invSubMix[2];
const invSubMix3 = invSubMix[3]; const invSubMix3 = invSubMix[3];
let prev; let prev: number = 0;
let t; let t: number;
for (ksRow = 0; ksRow < ksRows; ksRow++) { for (ksRow = 0; ksRow < ksRows; ksRow++) {
if (ksRow < keySize) { if (ksRow < keySize) {
@@ -168,6 +168,10 @@ export class AESDecryptor {
t = keySchedule[ksRow - 4]; t = keySchedule[ksRow - 4];
} }
if (t === undefined) {
throw new Error('Invalid key schedule');
}
if (invKsRow < 4 || ksRow <= 4) { if (invKsRow < 4 || ksRow <= 4) {
invKeySchedule[invKsRow] = t; invKeySchedule[invKsRow] = t;
} else { } else {

View File

@@ -545,8 +545,10 @@ export class M3U8Downloader {
if (xhr.status >= 200 && xhr.status < 300) { if (xhr.status >= 200 && xhr.status < 300) {
task.aesConf.key = xhr.response; task.aesConf.key = xhr.response;
// 初始化 AES 解密器 // 初始化 AES 解密器
task.aesConf.decryption = new AESDecryptor(); if (task.aesConf.key) {
task.aesConf.decryption.expandKey(task.aesConf.key); task.aesConf.decryption = new AESDecryptor();
task.aesConf.decryption.expandKey(task.aesConf.key);
}
resolve(); resolve();
} else { } else {
reject(new Error('获取 AES 密钥失败')); reject(new Error('获取 AES 密钥失败'));
@@ -562,7 +564,7 @@ export class M3U8Downloader {
* AES 解密 * AES 解密
*/ */
private aesDecrypt(task: M3U8DownloadTask, data: ArrayBuffer, index: number): ArrayBuffer { private aesDecrypt(task: M3U8DownloadTask, data: ArrayBuffer, index: number): ArrayBuffer {
if (!task.aesConf.decryption) { if (!task.aesConf.decryption || !task.aesConf.key) {
return data; return data;
} }

View File

@@ -8,8 +8,8 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "Node16", "module": "esnext",
"moduleResolution": "node16", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
@@ -26,6 +26,5 @@
] ]
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"], "exclude": ["node_modules"]
"moduleResolution": ["node_modules", ".next", "node"]
} }