diff --git a/packages/common/package.json b/packages/common/package.json index 9a13f5a..26cad39 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -28,6 +28,7 @@ "@react-native-async-storage/async-storage": "^2.1.2", "axios": "^1.7.0", "react": "^19.0.0", + "react-native": "^0.85.0", "zod": "^3.23.0" } } diff --git a/packages/common/src/configCrypto.ts b/packages/common/src/configCrypto.ts index 07b96be..3e9c394 100644 --- a/packages/common/src/configCrypto.ts +++ b/packages/common/src/configCrypto.ts @@ -28,10 +28,15 @@ export interface DecryptedConfig { expiresAt?: string } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function getSubtle(): any { +interface SubtleCryptoLike { + importKey(format: string, keyData: BufferSource, algorithm: string | Record, extractable: boolean, keyUsages: string[]): Promise + deriveKey(algorithm: string | Record, baseKey: CryptoKey, derivedKeyAlgorithm: string | Record, extractable: boolean, keyUsages: string[]): Promise + decrypt(algorithm: string | Record, key: CryptoKey, data: BufferSource): Promise +} + +function getSubtle(): SubtleCryptoLike { // eslint-disable-next-line @typescript-eslint/no-require-imports - const qc = require('react-native-quick-crypto') as any + const qc = require('react-native-quick-crypto') as { subtle?: SubtleCryptoLike; default?: { subtle?: SubtleCryptoLike } } const subtle = qc.subtle ?? qc.default?.subtle if (!subtle) throw new Error('[XuqmSDK] react-native-quick-crypto not available') return subtle @@ -43,8 +48,7 @@ function base64UrlDecode(s: string): Uint8Array { return Uint8Array.from({ length: binary.length }, (_, i) => binary.charCodeAt(i)) } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -async function deriveKey(salt: Uint8Array, passphrase: string): Promise { +async function deriveKey(salt: Uint8Array, passphrase: string): Promise { const subtle = getSubtle() const passphraseKey = await subtle.importKey( 'raw', @@ -54,8 +58,7 @@ async function deriveKey(salt: Uint8Array, passphrase: string): Promise { ['deriveKey'], ) return subtle.deriveKey( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - { name: 'PBKDF2', salt: salt as any, iterations: PBKDF2_ITERATIONS, hash: 'SHA-256' }, + { name: 'PBKDF2', salt: salt as unknown as BufferSource, iterations: PBKDF2_ITERATIONS, hash: 'SHA-256' }, passphraseKey, { name: 'AES-GCM', length: 256 }, false, @@ -76,8 +79,7 @@ export async function decryptConfigFile(content: string): Promise {canGoBack ? ( - + - + ) : null} - + - + ) } @@ -144,20 +144,20 @@ function MenuButton({ if (config.clickMenu) { const { clickMenu } = config return ( - {clickMenu.view ?? } - + ) } return ( - + - + ) } @@ -526,7 +526,7 @@ export function XWebViewScreen() { 页面加载失败 {loadError} - { setLoadError(null) @@ -534,7 +534,7 @@ export function XWebViewScreen() { }} > 重试 - + ) : ( 页面加载失败 {loadError} - { - setLoadError(null) - webViewRef.current?.reload() - }} + webViewRef.current?.reload()} + style={({ pressed }) => [styles.retryBtn, pressed && { opacity: 0.7 }]} > - 重试 - + 点击重试 + ) : (