mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2025-07-02 18:22:12 +08:00
26 lines
904 B
TypeScript
26 lines
904 B
TypeScript
import { transformBlob } from '~/decrypt-worker/util/transformBlob';
|
|
import type { CryptoBase } from '../CryptoBase';
|
|
import { DecryptCommandOptions } from '~/decrypt-worker/types';
|
|
|
|
export class QingTingFM$Device implements CryptoBase {
|
|
cryptoName = 'QingTing FM/Device ID';
|
|
checkByDecryptHeader = false;
|
|
|
|
async checkBySignature(_buffer: ArrayBuffer, options: DecryptCommandOptions) {
|
|
return Boolean(/^\.p~?!.*\.qta$/.test(options.fileName) && options.qingTingAndroidKey);
|
|
}
|
|
|
|
async decrypt(buffer: ArrayBuffer, options: DecryptCommandOptions): Promise<Blob> {
|
|
const { fileName: name, qingTingAndroidKey } = options;
|
|
if (!qingTingAndroidKey) {
|
|
throw new Error('QingTingFM Android Device Key was not provided');
|
|
}
|
|
|
|
return transformBlob(buffer, (p) => p.make.QingTingFM(name, qingTingAndroidKey));
|
|
}
|
|
|
|
public static make() {
|
|
return new QingTingFM$Device();
|
|
}
|
|
}
|