Add --compat option
Without it, the generated build is for recent versions of Chrome, Firefox, Safari and Edge. With it, the generated build is for IE11+.
This commit is contained in:
parent
8170682e54
commit
4bdc5e92ab
40
Gruntfile.js
40
Gruntfile.js
|
@ -13,6 +13,8 @@ module.exports = function(grunt) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
|
const dev = !!grunt.option('dev');
|
||||||
|
const compat = !!grunt.option('compat');
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
pkg: grunt.file.readJSON('package.json'),
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
browserify: {
|
browserify: {
|
||||||
|
@ -22,24 +24,48 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
browserifyOptions: {
|
browserifyOptions: {
|
||||||
fullPaths: grunt.option('dev'),
|
fullPaths: dev,
|
||||||
debug: grunt.option('dev'),
|
debug: dev,
|
||||||
standalone: 'openpgp'
|
standalone: 'openpgp'
|
||||||
},
|
},
|
||||||
cacheFile: 'browserify-cache.json',
|
cacheFile: 'browserify-cache' + (compat ? '-compat' : '') + '.json',
|
||||||
// Don't bundle these packages with openpgp.js
|
// Don't bundle these packages with openpgp.js
|
||||||
external: ['crypto', 'zlib', 'node-localstorage', 'node-fetch', 'asn1.js', 'stream', 'buffer'],
|
external: ['crypto', 'zlib', 'node-localstorage', 'node-fetch', 'asn1.js', 'stream', 'buffer'].concat(
|
||||||
|
compat ? [] : [
|
||||||
|
'whatwg-fetch',
|
||||||
|
'core-js/fn/array/fill',
|
||||||
|
'core-js/fn/array/find',
|
||||||
|
'core-js/fn/array/includes',
|
||||||
|
'core-js/fn/array/from',
|
||||||
|
'core-js/fn/promise',
|
||||||
|
'core-js/fn/typed/uint8-array',
|
||||||
|
'core-js/fn/string/repeat',
|
||||||
|
'core-js/fn/symbol',
|
||||||
|
'core-js/fn/object/assign',
|
||||||
|
]
|
||||||
|
),
|
||||||
transform: [
|
transform: [
|
||||||
["babelify", {
|
["babelify", {
|
||||||
global: true,
|
global: true,
|
||||||
// Only babelify web-stream-tools, asmcrypto and address-rfc2822 in node_modules
|
// Only babelify web-stream-tools, asmcrypto and address-rfc2822 in node_modules
|
||||||
only: /^(?:.*\/node_modules\/web-stream-tools\/|.*\/node_modules\/asmcrypto\.js\/|.*\/node_modules\/address-rfc2822\/|(?!.*\/node_modules\/)).*$/,
|
only: /^(?:.*\/node_modules\/web-stream-tools\/|.*\/node_modules\/asmcrypto\.js\/|.*\/node_modules\/address-rfc2822\/|(?!.*\/node_modules\/)).*$/,
|
||||||
plugins: ["transform-async-to-generator",
|
plugins: compat ? [
|
||||||
|
"transform-async-to-generator",
|
||||||
"syntax-async-functions",
|
"syntax-async-functions",
|
||||||
"transform-regenerator",
|
"transform-regenerator",
|
||||||
"transform-runtime"],
|
"transform-runtime"
|
||||||
|
] : [],
|
||||||
ignore: ['*.min.js'],
|
ignore: ['*.min.js'],
|
||||||
presets: ["env"]
|
presets: [["env", {
|
||||||
|
targets: {
|
||||||
|
browsers: compat ? ['defaults'] : [
|
||||||
|
'Last 2 Chrome versions',
|
||||||
|
'Last 2 Firefox versions',
|
||||||
|
'Last 2 Safari versions',
|
||||||
|
'Last 2 Edge versions'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}]]
|
||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
plugin: ['browserify-derequire']
|
plugin: ['browserify-derequire']
|
||||||
|
|
|
@ -11,6 +11,12 @@ import util from './util';
|
||||||
/* eslint-disable import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
|
/********************************************************************
|
||||||
|
* NOTE: This list is duplicated in Gruntfile.js, *
|
||||||
|
* so that these polyfills are only included in the compat bundle. *
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
try {
|
||||||
if (typeof window.fetch === 'undefined') {
|
if (typeof window.fetch === 'undefined') {
|
||||||
require('whatwg-fetch');
|
require('whatwg-fetch');
|
||||||
}
|
}
|
||||||
|
@ -42,6 +48,7 @@ if (typeof window !== 'undefined') {
|
||||||
if (typeof Object.assign === 'undefined') {
|
if (typeof Object.assign === 'undefined') {
|
||||||
require('core-js/fn/object/assign');
|
require('core-js/fn/object/assign');
|
||||||
}
|
}
|
||||||
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof TransformStream === 'undefined') {
|
if (typeof TransformStream === 'undefined') {
|
||||||
|
|
|
@ -150,7 +150,7 @@ describe("Packet", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sym. encrypted AEAD protected packet (draft04)', function() {
|
it('Sym. encrypted AEAD protected packet (draft04)', async function() {
|
||||||
let aead_protectVal = openpgp.config.aead_protect;
|
let aead_protectVal = openpgp.config.aead_protect;
|
||||||
let aead_protect_versionVal = openpgp.config.aead_protect_version;
|
let aead_protect_versionVal = openpgp.config.aead_protect_version;
|
||||||
openpgp.config.aead_protect = true;
|
openpgp.config.aead_protect = true;
|
||||||
|
@ -170,15 +170,15 @@ describe("Packet", function() {
|
||||||
|
|
||||||
const msg2 = new openpgp.packet.List();
|
const msg2 = new openpgp.packet.List();
|
||||||
|
|
||||||
return enc.encrypt(algo, key).then(async function() {
|
try {
|
||||||
|
await enc.encrypt(algo, key);
|
||||||
await msg2.read(msg.write());
|
await msg2.read(msg.write());
|
||||||
return msg2[0].decrypt(algo, key);
|
await msg2[0].decrypt(algo, key);
|
||||||
}).then(async function() {
|
|
||||||
expect(await openpgp.stream.readToEnd(msg2[0].packets[0].data)).to.deep.equal(literal.data);
|
expect(await openpgp.stream.readToEnd(msg2[0].packets[0].data)).to.deep.equal(literal.data);
|
||||||
}).finally(function() {
|
} finally {
|
||||||
openpgp.config.aead_protect = aead_protectVal;
|
openpgp.config.aead_protect = aead_protectVal;
|
||||||
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function cryptStub(webCrypto, method) {
|
function cryptStub(webCrypto, method) {
|
||||||
|
@ -201,7 +201,7 @@ describe("Packet", function() {
|
||||||
return cryptStub;
|
return cryptStub;
|
||||||
}
|
}
|
||||||
|
|
||||||
it('Sym. encrypted AEAD protected packet is encrypted in parallel (GCM, draft04)', function() {
|
it('Sym. encrypted AEAD protected packet is encrypted in parallel (GCM, draft04)', async function() {
|
||||||
const webCrypto = openpgp.util.getWebCrypto();
|
const webCrypto = openpgp.util.getWebCrypto();
|
||||||
if (!webCrypto) return;
|
if (!webCrypto) return;
|
||||||
const encryptStub = cryptStub(webCrypto, 'encrypt');
|
const encryptStub = cryptStub(webCrypto, 'encrypt');
|
||||||
|
@ -229,23 +229,23 @@ describe("Packet", function() {
|
||||||
|
|
||||||
const msg2 = new openpgp.packet.List();
|
const msg2 = new openpgp.packet.List();
|
||||||
|
|
||||||
return enc.encrypt(algo, key).then(async function() {
|
try {
|
||||||
|
await enc.encrypt(algo, key);
|
||||||
await msg2.read(msg.write());
|
await msg2.read(msg.write());
|
||||||
return msg2[0].decrypt(algo, key);
|
await msg2[0].decrypt(algo, key);
|
||||||
}).then(async function() {
|
|
||||||
expect(await openpgp.stream.readToEnd(msg2[0].packets[0].data)).to.deep.equal(literal.data);
|
expect(await openpgp.stream.readToEnd(msg2[0].packets[0].data)).to.deep.equal(literal.data);
|
||||||
expect(encryptStub.callCount > 1).to.be.true;
|
expect(encryptStub.callCount > 1).to.be.true;
|
||||||
expect(decryptStub.callCount > 1).to.be.true;
|
expect(decryptStub.callCount > 1).to.be.true;
|
||||||
}).finally(function() {
|
} finally {
|
||||||
openpgp.config.aead_protect = aead_protectVal;
|
openpgp.config.aead_protect = aead_protectVal;
|
||||||
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
||||||
openpgp.config.aead_chunk_size_byte = aead_chunk_size_byteVal;
|
openpgp.config.aead_chunk_size_byte = aead_chunk_size_byteVal;
|
||||||
encryptStub.restore();
|
encryptStub.restore();
|
||||||
decryptStub.restore();
|
decryptStub.restore();
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sym. encrypted AEAD protected packet test vector (draft04)', function() {
|
it('Sym. encrypted AEAD protected packet test vector (draft04)', async function() {
|
||||||
// From https://gitlab.com/openpgp-wg/rfc4880bis/commit/00b20923e6233fb6ff1666ecd5acfefceb32907d
|
// From https://gitlab.com/openpgp-wg/rfc4880bis/commit/00b20923e6233fb6ff1666ecd5acfefceb32907d
|
||||||
|
|
||||||
let packetBytes = openpgp.util.hex_to_Uint8Array(`
|
let packetBytes = openpgp.util.hex_to_Uint8Array(`
|
||||||
|
@ -281,19 +281,19 @@ describe("Packet", function() {
|
||||||
let randomBytesStub = stub(openpgp.crypto.random, 'getRandomBytes');
|
let randomBytesStub = stub(openpgp.crypto.random, 'getRandomBytes');
|
||||||
randomBytesStub.returns(resolves(iv));
|
randomBytesStub.returns(resolves(iv));
|
||||||
|
|
||||||
return enc.encrypt(algo, key).then(async function() {
|
try {
|
||||||
|
await enc.encrypt(algo, key);
|
||||||
const data = msg.write();
|
const data = msg.write();
|
||||||
expect(await openpgp.stream.readToEnd(openpgp.stream.clone(data))).to.deep.equal(packetBytes);
|
expect(await openpgp.stream.readToEnd(openpgp.stream.clone(data))).to.deep.equal(packetBytes);
|
||||||
await msg2.read(data);
|
await msg2.read(data);
|
||||||
return msg2[0].decrypt(algo, key);
|
await msg2[0].decrypt(algo, key);
|
||||||
}).then(async function() {
|
|
||||||
expect(await openpgp.stream.readToEnd(msg2[0].packets[0].data)).to.deep.equal(literal.data);
|
expect(await openpgp.stream.readToEnd(msg2[0].packets[0].data)).to.deep.equal(literal.data);
|
||||||
}).finally(function() {
|
} finally {
|
||||||
openpgp.config.aead_protect = aead_protectVal;
|
openpgp.config.aead_protect = aead_protectVal;
|
||||||
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
||||||
openpgp.config.aead_chunk_size_byte = aead_chunk_size_byteVal;
|
openpgp.config.aead_chunk_size_byte = aead_chunk_size_byteVal;
|
||||||
randomBytesStub.restore();
|
randomBytesStub.restore();
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sym encrypted session key with a compressed packet', async function() {
|
it('Sym encrypted session key with a compressed packet', async function() {
|
||||||
|
@ -826,7 +826,7 @@ kePFjAnu9cpynKXu3usf8+FuBw2zLsg1Id1n7ttxoAte416KjBN9lFBt8mcu
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Writing and encryption of a secret key packet. (draft04)', function() {
|
it('Writing and encryption of a secret key packet. (draft04)', async function() {
|
||||||
let aead_protectVal = openpgp.config.aead_protect;
|
let aead_protectVal = openpgp.config.aead_protect;
|
||||||
let aead_protect_versionVal = openpgp.config.aead_protect_version;
|
let aead_protect_versionVal = openpgp.config.aead_protect_version;
|
||||||
openpgp.config.aead_protect = true;
|
openpgp.config.aead_protect = true;
|
||||||
|
@ -838,7 +838,8 @@ kePFjAnu9cpynKXu3usf8+FuBw2zLsg1Id1n7ttxoAte416KjBN9lFBt8mcu
|
||||||
const rsa = openpgp.crypto.publicKey.rsa;
|
const rsa = openpgp.crypto.publicKey.rsa;
|
||||||
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
|
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
|
||||||
|
|
||||||
return rsa.generate(keySize, "10001").then(async function(mpiGen) {
|
try {
|
||||||
|
const mpiGen = await rsa.generate(keySize, "10001");
|
||||||
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
|
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
|
||||||
mpi = mpi.map(function(k) {
|
mpi = mpi.map(function(k) {
|
||||||
return new openpgp.MPI(k);
|
return new openpgp.MPI(k);
|
||||||
|
@ -855,10 +856,10 @@ kePFjAnu9cpynKXu3usf8+FuBw2zLsg1Id1n7ttxoAte416KjBN9lFBt8mcu
|
||||||
await key2[0].decrypt('hello');
|
await key2[0].decrypt('hello');
|
||||||
|
|
||||||
expect(key[0].params.toString()).to.equal(key2[0].params.toString());
|
expect(key[0].params.toString()).to.equal(key2[0].params.toString());
|
||||||
}).finally(function() {
|
} finally {
|
||||||
openpgp.config.aead_protect = aead_protectVal;
|
openpgp.config.aead_protect = aead_protectVal;
|
||||||
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
openpgp.config.aead_protect_version = aead_protect_versionVal;
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Writing and verification of a signature packet.', function() {
|
it('Writing and verification of a signature packet.', function() {
|
||||||
|
|
10
travis.sh
10
travis.sh
|
@ -15,13 +15,13 @@ elif [[ $OPENPGPJSTEST =~ ^end2end-.* ]]; then
|
||||||
echo "Running OpenPGP.js browser unit tests on Saucelabs."
|
echo "Running OpenPGP.js browser unit tests on Saucelabs."
|
||||||
|
|
||||||
declare -a capabilities=(
|
declare -a capabilities=(
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Firefox\", \"version\":\"34\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export COMPAT=1 SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Firefox\", \"version\":\"34\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Firefox\", \"version\":\"54\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Firefox\", \"version\":\"54\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Chrome\", \"version\":\"41\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\", \"extendedDebugging\":true}'"
|
"export COMPAT=1 SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Chrome\", \"version\":\"41\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\", \"extendedDebugging\":true}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Chrome\", \"version\":\"59\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\", \"extendedDebugging\":true}'"
|
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Chrome\", \"version\":\"59\", \"platform\":\"OS X 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\", \"extendedDebugging\":true}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Internet Explorer\", \"version\":\"11.103\", \"platform\":\"Windows 10\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export COMPAT=1 SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Internet Explorer\", \"version\":\"11.103\", \"platform\":\"Windows 10\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"MicrosoftEdge\", \"version\":\"15.15063\", \"platform\":\"Windows 10\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"MicrosoftEdge\", \"version\":\"15.15063\", \"platform\":\"Windows 10\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Safari\", \"version\":\"8\", \"platform\":\"OS X 10.10\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export COMPAT=1 SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Safari\", \"version\":\"8\", \"platform\":\"OS X 10.10\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Safari\", \"version\":\"10\", \"platform\":\"macOS 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Safari\", \"version\":\"10\", \"platform\":\"macOS 10.12\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Browser\", \"platformName\":\"Android\", \"platformVersion\": \"4.4\", \"deviceName\": \"Android Emulator\", \"deviceOrientation\": \"portrait\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Browser\", \"platformName\":\"Android\", \"platformVersion\": \"4.4\", \"deviceName\": \"Android Emulator\", \"deviceOrientation\": \"portrait\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Chrome\", \"platformName\":\"Android\", \"platformVersion\": \"6.0\", \"deviceName\": \"Android Emulator\", \"deviceOrientation\": \"portrait\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"Chrome\", \"platformName\":\"Android\", \"platformVersion\": \"6.0\", \"deviceName\": \"Android Emulator\", \"deviceOrientation\": \"portrait\", \"maxDuration\":\"7200\", \"commandTimeout\":\"600\", \"idleTimeout\":\"270\"}'"
|
||||||
|
@ -36,7 +36,7 @@ elif [[ $OPENPGPJSTEST =~ ^end2end-.* ]]; then
|
||||||
|
|
||||||
echo "Testing Configuration: ${testkey}"
|
echo "Testing Configuration: ${testkey}"
|
||||||
eval $capability
|
eval $capability
|
||||||
grunt saucelabs &
|
grunt saucelabs --compat=$COMPAT &
|
||||||
background_process_pid=$!
|
background_process_pid=$!
|
||||||
|
|
||||||
# https://github.com/travis-ci/travis-ci/issues/4190
|
# https://github.com/travis-ci/travis-ci/issues/4190
|
||||||
|
|
Loading…
Reference in New Issue
Block a user