changed streaming code to use new readAtLeast function, updated dependencies

This commit is contained in:
uh wot 2022-01-07 16:22:58 +01:00
parent 30a7c29192
commit 21297658fe
Signed by: uhwot
GPG Key ID: CB2454984587B781
6 changed files with 15 additions and 22 deletions

View File

@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"]
block-modes = "0.8" block-modes = "0.8"
blowfish = "0.8" blowfish = "0.8"
aes = "0.7" aes = "0.7"
md-5 = "0.9" md-5 = "0.10"
hex = "0.4" hex = "0.4"
wasm-bindgen = "0.2" wasm-bindgen = "0.2"

2
dist/worker.js vendored

File diff suppressed because one or more lines are too long

View File

@ -321,21 +321,14 @@ async function pipeDecryptedStream(writer, body, length, cipher) {
let end = false let end = false
while (!end) { while (!end) {
end = byteCount + 2048 > length end = byteCount + 2048 > length
let chunk let minBytes
if (!end) { if (!end) {
chunk = new Int8Array(2048) minBytes = 2048
} else { } else {
chunk = new Int8Array(length - byteCount) minBytes = length - byteCount
} }
// if read chunk isn't 2048 bytes, read until it is let chunk = (await reader.readAtLeast(minBytes, new Uint8Array(2048))).value
// cause of retarded readable streams not having an option to specify min bytes
let tempLength = 0
while (tempLength !== chunk.length) {
let read = (await reader.read(new Int8Array(chunk.length - tempLength))).value
chunk.set(read, tempLength)
tempLength += read.length
}
if (byteCount % 6144 === 0 && !end) { if (byteCount % 6144 === 0 && !end) {
// encrypted chunk // encrypted chunk

14
package-lock.json generated
View File

@ -10,7 +10,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"browser-id3-writer": "^4.4.0", "browser-id3-writer": "^4.4.0",
"itty-router": "^2.4.4", "itty-router": "^2.4.8",
"serverless-cloudflare-workers": "^1.2.0" "serverless-cloudflare-workers": "^1.2.0"
}, },
"devDependencies": { "devDependencies": {
@ -2401,9 +2401,9 @@
} }
}, },
"node_modules/itty-router": { "node_modules/itty-router": {
"version": "2.4.4", "version": "2.4.8",
"resolved": "https://registry.npmjs.org/itty-router/-/itty-router-2.4.4.tgz", "resolved": "https://registry.npmjs.org/itty-router/-/itty-router-2.4.8.tgz",
"integrity": "sha512-mp5i47ZotK94FHondKJTZn/0dBAFzFpZpiHWn+aCgr/sg9cIVzt1gvLCKsXMkcHgKejb9GdhqvOfh7VYJJlQoQ==" "integrity": "sha512-VpAHeAN+/ABLqT/zEnwMomNCDh8eRrs06C8HRR8OxjVwGhXtvzoJbggjUnjAeNGxqjV4w7pp87Iu8jzEpr92fg=="
}, },
"node_modules/jest-worker": { "node_modules/jest-worker": {
"version": "27.0.6", "version": "27.0.6",
@ -6813,9 +6813,9 @@
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
}, },
"itty-router": { "itty-router": {
"version": "2.4.4", "version": "2.4.8",
"resolved": "https://registry.npmjs.org/itty-router/-/itty-router-2.4.4.tgz", "resolved": "https://registry.npmjs.org/itty-router/-/itty-router-2.4.8.tgz",
"integrity": "sha512-mp5i47ZotK94FHondKJTZn/0dBAFzFpZpiHWn+aCgr/sg9cIVzt1gvLCKsXMkcHgKejb9GdhqvOfh7VYJJlQoQ==" "integrity": "sha512-VpAHeAN+/ABLqT/zEnwMomNCDh8eRrs06C8HRR8OxjVwGhXtvzoJbggjUnjAeNGxqjV4w7pp87Iu8jzEpr92fg=="
}, },
"jest-worker": { "jest-worker": {
"version": "27.0.6", "version": "27.0.6",

View File

@ -16,7 +16,7 @@
}, },
"dependencies": { "dependencies": {
"browser-id3-writer": "^4.4.0", "browser-id3-writer": "^4.4.0",
"itty-router": "^2.4.4", "itty-router": "^2.4.8",
"serverless-cloudflare-workers": "^1.2.0" "serverless-cloudflare-workers": "^1.2.0"
} }
} }

View File

@ -6,7 +6,7 @@ workers_dev = true
kv_namespaces = [ kv_namespaces = [
{ binding = "KV", id = "974c0967a84e415daa054bbbcc7f80c6", preview_id = "cfcc6491f3484cbca664913836635113" } { binding = "KV", id = "974c0967a84e415daa054bbbcc7f80c6", preview_id = "cfcc6491f3484cbca664913836635113" }
] ]
compatibility_date = "2022-01-04" compatibility_date = "2022-01-07"
# [secrets] # [secrets]
# ARL # ARL