UNPKG

shifro

Version:

A lightweight, dependency-free MP4 decrypter

40 lines (37 loc) 1.38 kB
//#region lib/process.d.ts type EncryptionScheme = 'cenc' | 'cbcs'; type TransformSampleParams = { encryptionScheme?: EncryptionScheme; data: Uint8Array; iv: Uint8Array; timestamp: number; }; type TransformSampleFn = (params: TransformSampleParams) => Promise<Uint8Array | null>; //#endregion //#region lib/stream.d.ts interface ProcessStreamOptions { transformSample: TransformSampleFn; onProgress?: (bytesProcessed: number) => void; preventClose?: boolean; } //#endregion //#region shifro.d.ts declare const decryptWithKey: (key: Uint8Array, params: TransformSampleParams) => Promise<Uint8Array<ArrayBuffer>>; type DecryptWithKey = { key: string; keyId?: string; encryptionScheme?: EncryptionScheme; }; type DecryptWithCallback = { keyId?: string; transformSample: (params: TransformSampleParams) => Promise<Uint8Array | null>; }; type DecryptParams = DecryptWithKey | DecryptWithCallback; declare const decryptSegment: (segment: Uint8Array, params: DecryptParams) => Promise<Uint8Array<ArrayBufferLike>>; declare const decryptStream: (readable: ReadableStream, writable: WritableStream, { preventClose, onProgress, ...params }: DecryptParams & Omit<ProcessStreamOptions, "transformSample">) => Promise<void>; //#endregion export { DecryptParams, ProcessStreamOptions, TransformSampleParams, decryptSegment, decryptStream, decryptWithKey };