change(player): manual decompression for encrypted files
This commit is contained in:
parent
66d0b298c4
commit
4ac476f9e1
4 changed files with 26 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { gunzipSync } from 'fflate'
|
||||
|
||||
const u8aFromHex = (hexString:string) =>
|
||||
Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)))
|
||||
|
|
@ -18,7 +19,22 @@ export function decryptSessionBytes(cypher: Uint8Array, keyString: string): Prom
|
|||
|
||||
return crypto.subtle.importKey("raw", byteKey, { name: "AES-CBC" }, false, ["decrypt"])
|
||||
.then(key => crypto.subtle.decrypt({ name: "AES-CBC", iv: iv}, key, cypher))
|
||||
.then((bArray: ArrayBuffer) => new Uint8Array(bArray)) //?? TS doesn not catch the `decrypt`` returning type
|
||||
.then((bArray: ArrayBuffer) => new Uint8Array(bArray))
|
||||
.then(async (u8Array: Uint8Array) => {
|
||||
const now = performance.now()
|
||||
const data = gunzipSync(u8Array)
|
||||
console.debug(
|
||||
"Decompression time",
|
||||
performance.now() - now,
|
||||
'size',
|
||||
Math.floor(u8Array.byteLength/1024),
|
||||
'->',
|
||||
Math.floor(data.byteLength/1024),
|
||||
'kb'
|
||||
)
|
||||
return data
|
||||
})
|
||||
//?? TS doesn not catch the `decrypt`` returning type
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"classnames": "^2.3.1",
|
||||
"copy-to-clipboard": "^3.3.1",
|
||||
"deep-diff": "^1.0.2",
|
||||
"fflate": "^0.7.4",
|
||||
"html-to-image": "^1.9.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"immutable": "^4.0.0-rc.12",
|
||||
|
|
|
|||
|
|
@ -11047,6 +11047,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"fflate@npm:^0.7.4":
|
||||
version: 0.7.4
|
||||
resolution: "fflate@npm:0.7.4"
|
||||
checksum: 5e749eb3a6ed61a0f6c55756abf9f4258f06f60505db689e22d18503dd252ca5af656d32668e4b7b20714adf8b313febf695d23863a8352f23e325baee0f672d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"figgy-pudding@npm:^3.4.1, figgy-pudding@npm:^3.5.1, figgy-pudding@npm:^3.5.2":
|
||||
version: 3.5.2
|
||||
resolution: "figgy-pudding@npm:3.5.2"
|
||||
|
|
@ -17215,6 +17222,7 @@ __metadata:
|
|||
eslint-plugin-react: ^7.29.4
|
||||
eslint-plugin-react-hooks: ^4.5.0
|
||||
faker: ^5.5.3
|
||||
fflate: ^0.7.4
|
||||
file-loader: ^6.2.0
|
||||
flow-bin: ^0.115.0
|
||||
html-to-image: ^1.9.0
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@ import type {
|
|||
FromWorkerData,
|
||||
} from '../../common/interaction.js'
|
||||
|
||||
// @ts-ignore
|
||||
window.gzip = gzip
|
||||
|
||||
interface TypedWorker extends Omit<Worker, 'postMessage'> {
|
||||
postMessage(data: ToWorkerData): void
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue