nacl module now checks window and document instead of importscripts

This commit is contained in:
Tankred Hase 2013-04-12 12:27:47 +02:00
parent 6a9f2c00be
commit 32a52ad6e7
2 changed files with 10 additions and 3 deletions

View File

@ -5,8 +5,8 @@
app.crypto.Crypto = function(window, util) {
'use strict';
var symmetricUserKey, // the user's secret key used to encrypt item-keys
aes = new app.crypto.AesCCM(sjcl); // use authenticated AES-CCM mode by default
var symmetricUserKey = null, // the user's secret key used to encrypt item-keys
aes = new app.crypto.AesCCM(sjcl); // use authenticated AES-CCM mode by default
/**
* Initializes the crypto modules by fetching the user's
@ -44,6 +44,13 @@ app.crypto.Crypto = function(window, util) {
});
};
/**
* Generates the user's asymmetric keypair from the user's secret key
*/
this.generateKeypair = function(naclCrypto) {
return naclCrypto.generateKeypair(symmetricUserKey);
};
/**
* Do PBKDF2 key derivation in a WebWorker thread
*/

View File

@ -10714,7 +10714,7 @@ var nacl = (function(window, document) {
nacl.random_bytes = randomBytes;
nacl.nacl_raw = nacl_raw;
return nacl;
})((typeof importScripts !== 'undefined') ? null : window, (typeof importScripts !== 'undefined') ? null : document);
})((typeof window !== 'undefined') ? window : null, (typeof document !== 'undefined') ? document : null);
// export common.js module to allow one js file for browser and node.js
if (typeof module !== 'undefined' && module.exports) {