mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 03:23:02 +00:00
30 lines
935 B
TypeScript
30 lines
935 B
TypeScript
import { transformBlob } from '~/decrypt-worker/util/transformBlob';
|
|
import type { CryptoBase } from '../CryptoBase.js';
|
|
import { XimalayaAndroidKey, XimalayaX2MKey, XimalayaX3MKey } from './xmly_android.key.js';
|
|
|
|
export class XimalayaAndroidCrypto implements CryptoBase {
|
|
cryptoName = 'Ximalaya/Android';
|
|
checkByDecryptHeader = true;
|
|
constructor(private key: XimalayaAndroidKey) {}
|
|
|
|
async decrypt(buffer: ArrayBuffer): Promise<Blob> {
|
|
const { contentKey, init, step } = this.key;
|
|
return transformBlob(buffer, (p) => {
|
|
const transformer = p.make.XimalayaAndroid(init, step, contentKey);
|
|
if (!transformer) {
|
|
throw new Error('could not make xmly transformer, is key invalid?');
|
|
}
|
|
|
|
return transformer;
|
|
});
|
|
}
|
|
|
|
public static makeX2M() {
|
|
return new XimalayaAndroidCrypto(XimalayaX2MKey);
|
|
}
|
|
|
|
public static makeX3M() {
|
|
return new XimalayaAndroidCrypto(XimalayaX3MKey);
|
|
}
|
|
}
|