added git submodule deps in npm

This commit is contained in:
Tankred Hase 2013-05-16 16:54:56 +02:00
parent d731ae32d8
commit 4a080eed26
4 changed files with 31 additions and 6 deletions

View File

@ -4,7 +4,11 @@
"engines": {
"node": ">=0.8"
},
"scripts": {
"postinstall": "./res/copy-deps.sh"
},
"dependencies": {
"express": "latest"
"express": "latest",
"crypto-lib": "git://github.com/whiteout-io/crypto-lib.git#master"
}
}

9
res/copy-deps.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
echo "--> copying dependencies to src\n"
# go to root
cd `dirname $0`
cd ..
cp ./node_modules/crypto-lib/src/*.js ./src/js/crypto/

View File

@ -1,7 +1,7 @@
/**
* A Wrapper for Forge's AES-CBC encryption
*/
app.crypto.AesCBC = function(forge) {
var AesCBC = function(forge) {
'use strict';
var utl = forge.util;
@ -42,4 +42,10 @@ app.crypto.AesCBC = function(forge) {
return utl.decodeUtf8(cipher.output.getBytes());
};
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = AesCBC;
} else {
app.crypto.AesCBC = AesCBC;
}

View File

@ -1,7 +1,7 @@
/**
* A Wrapper for Forge's RSA encryption
*/
app.crypto.RSA = function(forge, util) {
var RSA = function(forge, util) {
'use strict';
var utl = forge.util;
@ -29,7 +29,7 @@ app.crypto.RSA = function(forge, util) {
this.generateKeypair = function(keySize, callback) {
forge.rsa.generateKeyPair({
bits: keySize,
workerScript: app.config.workerPath + '/../../lib/forge/prime.worker.js'
workerScript: (typeof app !== 'undefined') ? (app.config.workerPath + '/../../lib/forge/prime.worker.js') : undefined
}, function(err, newKeypair) {
if (err || !newKeypair || !newKeypair.publicKey || !newKeypair.privateKey) {
callback({
@ -117,4 +117,10 @@ app.crypto.RSA = function(forge, util) {
return keypair.publicKey.verify(sha.digest().getBytes(), sigUtf8);
};
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = RSA;
} else {
app.crypto.RSA = RSA;
}