WIP on shimming streams in firefox
This commit is contained in:
parent
23c347175a
commit
f4f8332f96
10
app/ece.js
10
app/ece.js
|
@ -1,4 +1,12 @@
|
||||||
require('buffer');
|
import 'buffer';
|
||||||
|
import TransformStream from './transformStream';
|
||||||
|
import { ReadableStream as ReadableStreamPony } from 'web-streams-ponyfill';
|
||||||
|
try {
|
||||||
|
new ReadableStream().pipeThrough(new TransformStream());
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-global-assign
|
||||||
|
ReadableStream = ReadableStreamPony;
|
||||||
|
}
|
||||||
|
|
||||||
const NONCE_LENGTH = 12;
|
const NONCE_LENGTH = 12;
|
||||||
const TAG_LENGTH = 16;
|
const TAG_LENGTH = 16;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Keychain from './keychain';
|
import Keychain from './keychain';
|
||||||
import { downloadStream } from './api';
|
import { downloadStream } from './api';
|
||||||
|
import TransformStream from './transformStream';
|
||||||
|
|
||||||
let noSave = false;
|
let noSave = false;
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
@ -37,8 +38,8 @@ async function decryptStream(request) {
|
||||||
'Content-Type': file.type,
|
'Content-Type': file.type,
|
||||||
'Content-Length': file.size
|
'Content-Length': file.size
|
||||||
};
|
};
|
||||||
|
const body = decrypted.local ? decrypted.nativeReadable : decrypted;
|
||||||
return new Response(decrypted, { headers });
|
return new Response(body, { headers });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (noSave) {
|
if (noSave) {
|
||||||
return new Response(null, { status: e.message });
|
return new Response(null, { status: e.message });
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* global TransformStream */
|
||||||
|
import { createReadableStreamWrapper } from '@mattiasbuelens/web-streams-adapter';
|
||||||
|
import { TransformStream as TransformStreamPony } from 'web-streams-ponyfill';
|
||||||
|
|
||||||
|
const toNative = createReadableStreamWrapper(ReadableStream);
|
||||||
|
|
||||||
|
class TransformStreamLocal {
|
||||||
|
constructor(transformer) {
|
||||||
|
this.stream = new TransformStreamPony(transformer);
|
||||||
|
this.local = true;
|
||||||
|
}
|
||||||
|
get nativeReadable() {
|
||||||
|
return toNative(this.stream.readable);
|
||||||
|
}
|
||||||
|
get readable() {
|
||||||
|
return this.stream.readable;
|
||||||
|
}
|
||||||
|
get writable() {
|
||||||
|
return this.stream.writable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (typeof TransformStream === 'function'
|
||||||
|
? TransformStream
|
||||||
|
: TransformStreamLocal);
|
|
@ -91,7 +91,8 @@
|
||||||
"@mattiasbuelens/web-streams-adapter": {
|
"@mattiasbuelens/web-streams-adapter": {
|
||||||
"version": "0.1.0-alpha.1",
|
"version": "0.1.0-alpha.1",
|
||||||
"resolved": "https://registry.npmjs.org/@mattiasbuelens/web-streams-adapter/-/web-streams-adapter-0.1.0-alpha.1.tgz",
|
"resolved": "https://registry.npmjs.org/@mattiasbuelens/web-streams-adapter/-/web-streams-adapter-0.1.0-alpha.1.tgz",
|
||||||
"integrity": "sha512-8YK2ZY6CAgrzFGfW2uPyNDMYvh7OmWjrlbdP+GeHiMJhzPF3XwrQaHyLQ4IZqGTj8NW879ttfbcqbLqQxWvtsw=="
|
"integrity": "sha512-8YK2ZY6CAgrzFGfW2uPyNDMYvh7OmWjrlbdP+GeHiMJhzPF3XwrQaHyLQ4IZqGTj8NW879ttfbcqbLqQxWvtsw==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"@mrmlnc/readdir-enhanced": {
|
"@mrmlnc/readdir-enhanced": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
|
@ -16276,10 +16277,10 @@
|
||||||
"minimalistic-assert": "1.0.1"
|
"minimalistic-assert": "1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"web-streams-polyfill": {
|
"web-streams-ponyfill": {
|
||||||
"version": "1.3.2",
|
"version": "1.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-1.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/web-streams-ponyfill/-/web-streams-ponyfill-1.4.2.tgz",
|
||||||
"integrity": "sha1-NxkkXpCSgtk5Z4JfRLzVUOnAOZU=",
|
"integrity": "sha512-LCHW+fE2UBJ2vjhqJujqmoxh1ytEDEr0dPO3CabMdMDJPKmsaxzS90V1Ar6LtNE5VHLqxR4YMEj1i4lzMAccIA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"webpack": {
|
"webpack": {
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dannycoates/webpack-dev-server": "^3.1.4",
|
"@dannycoates/webpack-dev-server": "^3.1.4",
|
||||||
|
"@mattiasbuelens/web-streams-adapter": "0.1.0-alpha.1",
|
||||||
"asmcrypto.js": "^0.22.0",
|
"asmcrypto.js": "^0.22.0",
|
||||||
"babel-core": "^6.26.3",
|
"babel-core": "^6.26.3",
|
||||||
"babel-loader": "^7.1.4",
|
"babel-loader": "^7.1.4",
|
||||||
|
@ -112,7 +113,7 @@
|
||||||
"svgo-loader": "^2.1.0",
|
"svgo-loader": "^2.1.0",
|
||||||
"testpilot-ga": "^0.3.0",
|
"testpilot-ga": "^0.3.0",
|
||||||
"val-loader": "^1.1.1",
|
"val-loader": "^1.1.1",
|
||||||
"web-streams-polyfill": "^1.3.2",
|
"web-streams-ponyfill": "^1.4.2",
|
||||||
"webpack": "^4.15.1",
|
"webpack": "^4.15.1",
|
||||||
"webpack-cli": "^3.0.8",
|
"webpack-cli": "^3.0.8",
|
||||||
"webpack-dev-middleware": "^3.1.3",
|
"webpack-dev-middleware": "^3.1.3",
|
||||||
|
@ -120,7 +121,6 @@
|
||||||
"webpack-unassert-loader": "^1.2.0"
|
"webpack-unassert-loader": "^1.2.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mattiasbuelens/web-streams-adapter": "0.1.0-alpha.1",
|
|
||||||
"aws-sdk": "^2.266.1",
|
"aws-sdk": "^2.266.1",
|
||||||
"babel-polyfill": "^6.26.0",
|
"babel-polyfill": "^6.26.0",
|
||||||
"choo": "^6.12.1",
|
"choo": "^6.12.1",
|
||||||
|
|
Loading…
Reference in New Issue