2013-06-10 11:57:33 -04:00
|
|
|
/**
|
|
|
|
* Node.js module for Forge.
|
|
|
|
*
|
|
|
|
* @author Dave Longley
|
|
|
|
*
|
|
|
|
* Copyright 2011-2013 Digital Bazaar, Inc.
|
|
|
|
*/
|
|
|
|
(function() {
|
2013-08-05 10:45:02 -04:00
|
|
|
var name = 'forge';
|
|
|
|
if(typeof define !== 'function') {
|
|
|
|
// NodeJS -> AMD
|
|
|
|
if(typeof module === 'object' && module.exports) {
|
|
|
|
var nodeJS = true;
|
|
|
|
define = function(ids, factory) {
|
|
|
|
factory(require, module);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// <script>
|
|
|
|
else {
|
|
|
|
if(typeof forge === 'undefined') {
|
|
|
|
// set to true to disable native code if even it's available
|
|
|
|
forge = {disableNativeCode: false};
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// AMD
|
|
|
|
var deps;
|
|
|
|
var defineFunc = function(require, module) {
|
|
|
|
module.exports = function(forge) {
|
|
|
|
var mods = deps.map(function(dep) {
|
|
|
|
return require(dep);
|
|
|
|
});
|
|
|
|
// handle circular dependencies
|
|
|
|
forge = forge || {};
|
|
|
|
forge.defined = forge.defined || {};
|
|
|
|
if(forge.defined[name]) {
|
|
|
|
return forge[name];
|
|
|
|
}
|
|
|
|
forge.defined[name] = true;
|
|
|
|
for(var i = 0; i < mods.length; ++i) {
|
|
|
|
mods[i](forge);
|
|
|
|
}
|
|
|
|
return forge;
|
|
|
|
};
|
|
|
|
// set to true to disable native code if even it's available
|
|
|
|
module.exports.disableNativeCode = false;
|
|
|
|
module.exports(module.exports);
|
|
|
|
};
|
|
|
|
var tmpDefine = define;
|
|
|
|
define = function(ids, factory) {
|
|
|
|
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
|
|
if(nodeJS) {
|
|
|
|
delete define;
|
|
|
|
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
|
|
}
|
|
|
|
define = tmpDefine;
|
|
|
|
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
|
|
};
|
|
|
|
define([
|
|
|
|
'require',
|
|
|
|
'module',
|
2013-06-10 11:57:33 -04:00
|
|
|
'./aes',
|
2013-08-05 10:45:02 -04:00
|
|
|
'./aesCipherSuites',
|
2013-06-10 11:57:33 -04:00
|
|
|
'./asn1',
|
|
|
|
'./debug',
|
|
|
|
'./des',
|
|
|
|
'./hmac',
|
|
|
|
'./log',
|
|
|
|
'./pbkdf2',
|
2013-08-05 10:45:02 -04:00
|
|
|
'./pem',
|
2013-06-10 11:57:33 -04:00
|
|
|
'./pkcs7',
|
2013-08-05 10:45:02 -04:00
|
|
|
'./pkcs1',
|
2013-06-10 11:57:33 -04:00
|
|
|
'./pkcs12',
|
|
|
|
'./pki',
|
|
|
|
'./prng',
|
|
|
|
'./pss',
|
|
|
|
'./random',
|
|
|
|
'./rc2',
|
|
|
|
'./task',
|
|
|
|
'./tls',
|
|
|
|
'./util',
|
|
|
|
'./md',
|
|
|
|
'./mgf1'
|
2013-08-05 10:45:02 -04:00
|
|
|
], function() {
|
|
|
|
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
|
|
});
|
2013-06-10 11:57:33 -04:00
|
|
|
})();
|