mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-27 23:56:59 +00:00
- Updated import paths for Kugou and Kuwo instructions to reflect new directory structure. - Introduced new key management functionalities for Kugou, including key import and selection logic. - Added comprehensive instructions for both Kugou and Kuwo key handling across various platforms. - Implemented Redux selectors for managing staging and production keys for Kugou and Kuwo. - Enhanced documentation and tests for new features and key management processes.
22 lines
930 B
TypeScript
22 lines
930 B
TypeScript
import { DatabaseKeyExtractor } from '~/util/DatabaseKeyExtractor';
|
|
import { parseAndroidQmEKey } from '~/util/mmkv/qm';
|
|
import { getFileName } from '~/util/pathHelper';
|
|
import type { StagingQMCv2Key } from './types';
|
|
|
|
/** Parse a QMCv2 key database / MMKV dump into staging key rows (without `id`). */
|
|
export async function importQMCv2KeysFromFile(file: File): Promise<null | Omit<StagingQMCv2Key, 'id'>[]> {
|
|
const fileBuffer = await file.arrayBuffer();
|
|
|
|
if (/(player_process[_.]db|music_audio_play)(\.db)?$/i.test(file.name)) {
|
|
const extractor = await DatabaseKeyExtractor.getInstance();
|
|
return extractor.extractQmcV2KeysFromSqliteDb(fileBuffer);
|
|
}
|
|
|
|
if (/MMKVStreamEncryptId|filenameEkeyMap|qmpc-mmkv-v1|(\.mmkv$)/i.test(file.name)) {
|
|
const map = parseAndroidQmEKey(new DataView(fileBuffer));
|
|
return Array.from(map.entries(), ([name, ekey]) => ({ name: getFileName(name), ekey }));
|
|
}
|
|
|
|
return null;
|
|
}
|