Standardized encryption adapter parameters. Fixes issue96

This commit is contained in:
Petr Bouianov 2014-04-18 13:53:46 -04:00
parent 073fe45223
commit e5779df03a
3 changed files with 5 additions and 5 deletions

View File

@ -170,7 +170,7 @@ adapters can be used together in order to compose complex functionality on top o
There are currently 2 adapters available: There are currently 2 adapters available:
* `FileSystem.adapters.Compression(provider)` - a compression adapter that uses [Zlib](https://github.com/imaya/zlib.js) * `FileSystem.adapters.Compression(provider)` - a compression adapter that uses [Zlib](https://github.com/imaya/zlib.js)
* `FileSystem.adapters.Encryption(passphrase, provider)` - an encryption adapter that uses [AES encryption](http://code.google.com/p/crypto-js/#AES) * `FileSystem.adapters.Encryption(provider, passphrase)` - an encryption adapter that uses [AES encryption](http://code.google.com/p/crypto-js/#AES)
```javascript ```javascript
var FileSystem = Filer.FileSystem; var FileSystem = Filer.FileSystem;
@ -180,7 +180,7 @@ var adapters = FileSystem.adapters;
// Create a WebSQL-based, Encrypted, Compressed File System by // Create a WebSQL-based, Encrypted, Compressed File System by
// composing a provider and adatpers. // composing a provider and adatpers.
var webSQLProvider = new providers.WebSQL(); var webSQLProvider = new providers.WebSQL();
var encryptionAdatper = new adapters.Encryption('super-secret-passphrase', webSQLProvider); var encryptionAdatper = new adapters.Encryption(webSQLProvider, 'super-secret-passphrase');
var compressionAdatper = new adatpers.Compression(encryptionAdapter); var compressionAdatper = new adatpers.Compression(encryptionAdapter);
var fs = new FileSystem({ provider: compressionAdapter }); var fs = new FileSystem({ provider: compressionAdapter });
``` ```

View File

@ -70,7 +70,7 @@ define(function(require) {
// It is up to the app using this wrapper how the passphrase is acquired, probably by // It is up to the app using this wrapper how the passphrase is acquired, probably by
// prompting the user to enter it when the file system is being opened. // prompting the user to enter it when the file system is being opened.
function CryptoAdapter(passphrase, provider) { function CryptoAdapter(provider, passphrase) {
this.provider = provider; this.provider = provider;
// Cache cipher algorithm we'll use in encrypt/decrypt // Cache cipher algorithm we'll use in encrypt/decrypt

View File

@ -156,7 +156,7 @@ define(["Filer", "util"], function(Filer, util) {
// Encryption // Encryption
buildTestsFor('Encryption', function buildAdapter(provider) { buildTestsFor('Encryption', function buildAdapter(provider) {
var passphrase = '' + Date.now(); var passphrase = '' + Date.now();
return new Filer.FileSystem.adapters.Encryption(passphrase, provider); return new Filer.FileSystem.adapters.Encryption(provider, passphrase);
}); });
// Compression // Compression
@ -168,7 +168,7 @@ define(["Filer", "util"], function(Filer, util) {
buildTestsFor('Encryption+Compression', function buildAdapter(provider) { buildTestsFor('Encryption+Compression', function buildAdapter(provider) {
var passphrase = '' + Date.now(); var passphrase = '' + Date.now();
var compression = new Filer.FileSystem.adapters.Compression(provider); var compression = new Filer.FileSystem.adapters.Compression(provider);
var encryptionWithCompression = new Filer.FileSystem.adapters.Encryption(passphrase, compression); var encryptionWithCompression = new Filer.FileSystem.adapters.Encryption(compression, passphrase);
return encryptionWithCompression; return encryptionWithCompression;
}); });