Add standalone support
This commit is contained in:
parent
acb537bea3
commit
4cabe075d5
46
Gruntfile.js
46
Gruntfile.js
|
@ -23,6 +23,25 @@ module.exports = function(grunt) {
|
||||||
external: [ 'crypto', 'node-localstorage' ]
|
external: [ 'crypto', 'node-localstorage' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
openpgp_sa_nodebug: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp-sa_nodebug.js': [ './src/index.js' ]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
standalone: 'openpgp',
|
||||||
|
external: [ 'crypto', 'node-localstorage' ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openpgp_sa: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp-sa.js': [ './src/index.js' ]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
debug: true,
|
||||||
|
standalone: 'openpgp',
|
||||||
|
external: [ 'crypto', 'node-localstorage' ]
|
||||||
|
}
|
||||||
|
},
|
||||||
unittests: {
|
unittests: {
|
||||||
files: {
|
files: {
|
||||||
'test/lib/unittests-bundle.js': []
|
'test/lib/unittests-bundle.js': []
|
||||||
|
@ -35,7 +54,7 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replace: {
|
replace: {
|
||||||
openpgpjs: {
|
openpgp: {
|
||||||
src: ['dist/openpgp.js'],
|
src: ['dist/openpgp.js'],
|
||||||
dest: ['dist/openpgp.js'],
|
dest: ['dist/openpgp.js'],
|
||||||
replacements: [{
|
replacements: [{
|
||||||
|
@ -43,21 +62,42 @@ module.exports = function(grunt) {
|
||||||
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
|
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
openpgpjs_nodebug: {
|
openpgp_nodebug: {
|
||||||
src: ['dist/openpgp_nodebug.js'],
|
src: ['dist/openpgp_nodebug.js'],
|
||||||
dest: ['dist/openpgp_nodebug.js'],
|
dest: ['dist/openpgp_nodebug.js'],
|
||||||
replacements: [{
|
replacements: [{
|
||||||
from: /OpenPGP.js VERSION/g,
|
from: /OpenPGP.js VERSION/g,
|
||||||
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
|
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
|
||||||
}]
|
}]
|
||||||
|
},
|
||||||
|
openpgp_sa: {
|
||||||
|
src: ['dist/openpgp-sa.js'],
|
||||||
|
dest: ['dist/openpgp-sa.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: /OpenPGP.js VERSION/g,
|
||||||
|
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
openpgp_sa_nodebug: {
|
||||||
|
src: ['dist/openpgp-sa_nodebug.js'],
|
||||||
|
dest: ['dist/openpgp-sa_nodebug.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: /OpenPGP.js VERSION/g,
|
||||||
|
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
uglify: {
|
uglify: {
|
||||||
openpgpjs: {
|
openpgp: {
|
||||||
files: {
|
files: {
|
||||||
'dist/openpgp.min.js' : [ 'dist/openpgp_nodebug.js' ]
|
'dist/openpgp.min.js' : [ 'dist/openpgp_nodebug.js' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
openpgp_sa: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp-sa.min.js' : [ 'dist/openpgp-sa_nodebug.js' ]
|
||||||
|
}
|
||||||
|
},
|
||||||
options: {
|
options: {
|
||||||
banner: '/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v<%= pkg.version %> - ' +
|
banner: '/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v<%= pkg.version %> - ' +
|
||||||
'<%= grunt.template.today("yyyy-mm-dd") %> */'
|
'<%= grunt.template.today("yyyy-mm-dd") %> */'
|
||||||
|
|
|
@ -25,10 +25,8 @@
|
||||||
var type_mpi = require('../type/mpi.js');
|
var type_mpi = require('../type/mpi.js');
|
||||||
var nodeCrypto = null;
|
var nodeCrypto = null;
|
||||||
|
|
||||||
if (typeof window === undefined) {}
|
if (typeof window === 'undefined') {
|
||||||
try {
|
|
||||||
nodeCrypto = require('crypto');
|
nodeCrypto = require('crypto');
|
||||||
} catch (e) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -81,9 +79,9 @@ module.exports = {
|
||||||
* @param {Uint32Array} buf
|
* @param {Uint32Array} buf
|
||||||
*/
|
*/
|
||||||
getRandomValues: function(buf) {
|
getRandomValues: function(buf) {
|
||||||
try {
|
if (nodeCrypto === null) {
|
||||||
window.crypto.getRandomValues(buf);
|
window.crypto.getRandomValues(buf);
|
||||||
} catch (e) {
|
} else {
|
||||||
var bytes = nodeCrypto.randomBytes(4);
|
var bytes = nodeCrypto.randomBytes(4);
|
||||||
buf[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
|
buf[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
BFencrypt = openpgp.crypto.cipher.blowfish,
|
BFencrypt = openpgp.crypto.cipher.blowfish,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
chai = require('chai'),
|
|
||||||
|
var chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
describe('API functional testing', function() {
|
describe('API functional testing', function() {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
MD5 = openpgp.crypto.hash.md5,
|
MD5 = openpgp.crypto.hash.md5,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
RMDstring = openpgp.crypto.hash.ripemd,
|
RMDstring = openpgp.crypto.hash.ripemd,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
util = openpgp.util,
|
|
||||||
|
var util = openpgp.util,
|
||||||
hash = openpgp.crypto.hash,
|
hash = openpgp.crypto.hash,
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
chai = require('chai'),
|
|
||||||
|
var chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
describe('Basic', function() {
|
describe('Basic', function() {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
chai = require('chai'),
|
|
||||||
|
var chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
describe('Key', function() {
|
describe('Key', function() {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
keyring = new openpgp.Keyring(),
|
|
||||||
|
var keyring = new openpgp.Keyring(),
|
||||||
chai = require('chai'),
|
chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
chai = require('chai'),
|
|
||||||
|
var chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
describe("Packet", function() {
|
describe("Packet", function() {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var openpgp = require('openpgp'),
|
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('openpgp');
|
||||||
chai = require('chai'),
|
|
||||||
|
var chai = require('chai'),
|
||||||
expect = chai.expect;
|
expect = chai.expect;
|
||||||
|
|
||||||
describe("Signature", function() {
|
describe("Signature", function() {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div id="mocha"></div>
|
<div id="mocha"></div>
|
||||||
|
|
||||||
<!--<script src="lib/jquery.min.js"></script>-->
|
<!--<script src="lib/jquery.min.js"></script>-->
|
||||||
<script src="../dist/openpgp.js"></script>
|
<script src="../dist/openpgp-sa.js"></script>
|
||||||
<script src="lib/chai.js"></script>
|
<script src="lib/chai.js"></script>
|
||||||
<script src="lib/mocha.js"></script>
|
<script src="lib/mocha.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user