Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
chore(lint): upgrade eslint package to v4.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bochaco committed Jun 26, 2019
1 parent 72d68f5 commit 70b1b96
Show file tree
Hide file tree
Showing 27 changed files with 1,303 additions and 1,184 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -60,7 +60,7 @@
"devDependencies": {
"braintree-jsdoc-template": "^3.3.0",
"coveralls": "^2.13.0",
"eslint": "^3.12.2",
"eslint": "^4.18.2",
"eslint-config-airbnb-base": "^11.0.0",
"eslint-plugin-import": "^2.2.0",
"husky": "^0.14.3",
Expand Down
27 changes: 13 additions & 14 deletions src/api/auth.js
Expand Up @@ -31,11 +31,11 @@ const makeShareMDataPermissions = nativeH.makeShareMDataPermissions;
*/
const genAppUri = (str) => {
const urlSafeBase64 = (Buffer.from(str))
.toString('base64')
.replace(/\+/g, '-') // Convert '+' to '-'
.replace(/\//g, '_') // Convert '/' to '_'
.replace(/=+$/, '') // Remove ending '='
.toLowerCase();
.toString('base64')
.replace(/\+/g, '-') // Convert '+' to '-'
.replace(/\//g, '_') // Convert '/' to '_'
.replace(/=+$/, '') // Remove ending '='
.toLowerCase();
return `safe-${urlSafeBase64}`;
};

Expand Down Expand Up @@ -63,7 +63,6 @@ const removeSafeProtocol = (uri) => uri.trim().replace(/^safe-[^:]*:?[/]*/g, '')
* Contains all authentication related functionality
*/
class AuthInterface {

/**
* @hideconstructor
*/
Expand Down Expand Up @@ -163,7 +162,7 @@ class AuthInterface {
containers_len: perm.length,
containers_cap: perm.length
}).ref())
.then(addSafeAuthProtocol);
.then(addSafeAuthProtocol);
}

/**
Expand Down Expand Up @@ -203,7 +202,7 @@ class AuthInterface {
mdata: mdatasPerms,
mdata_len: mdatasPerms.length
}).ref())
.then(addSafeAuthProtocol);
.then(addSafeAuthProtocol);
}

/**
Expand Down Expand Up @@ -277,7 +276,7 @@ class AuthInterface {
containers_len: ctnrs.length,
containers_cap: ctnrs.length
}).ref())
.then(addSafeAuthProtocol);
.then(addSafeAuthProtocol);
}

/**
Expand Down Expand Up @@ -497,7 +496,7 @@ class AuthInterface {
getContainer(name) {
if (!name) {
throw makeError(errConst.MISSING_CONTAINER_STRING.code,
errConst.MISSING_CONTAINER_STRING.msg);
errConst.MISSING_CONTAINER_STRING.msg);
}
return lib.access_container_get_container_mdata_info(this.app.connection, name)
.then((data) => this.app.mutableData.wrapMdata(data));
Expand Down Expand Up @@ -541,10 +540,10 @@ class AuthInterface {
const authGranted = resp[1];
this._registered = true;
return lib.app_registered(this.app, authGranted);
// TODO: in the future: automatically refresh permissions
// .then((app) => this.refreshContainersPermissions()
// .then(() => app)
// );
// TODO: in the future: automatically refresh permissions
// .then((app) => this.refreshContainersPermissions()
// .then(() => app)
// );
}
case 'containers':
this._registered = true;
Expand Down
7 changes: 3 additions & 4 deletions src/api/cipher_opt.js
Expand Up @@ -26,7 +26,6 @@ class CipherOpt extends h.NetworkObject {
* Provides encryption methods for committing {@link ImmutableData}
*/
class CipherOptInterface {

/**
* @hideconstructor
*/
Expand All @@ -48,7 +47,7 @@ class CipherOptInterface {
*/
newPlainText() {
return lib.cipher_opt_new_plaintext(this.app.connection)
.then((c) => h.autoref(new CipherOpt(this.app, c)));
.then((c) => h.autoref(new CipherOpt(this.app, c)));
}

/**
Expand All @@ -65,7 +64,7 @@ class CipherOptInterface {
*/
newSymmetric() {
return lib.cipher_opt_new_symmetric(this.app.connection)
.then((c) => h.autoref(new CipherOpt(this.app, c)));
.then((c) => h.autoref(new CipherOpt(this.app, c)));
}
/**
* Create a new asymmetric cipher for the given public encryption key
Expand All @@ -92,7 +91,7 @@ class CipherOptInterface {
throw makeError(errConst.MISSING_PUB_ENC_KEY.code, errConst.MISSING_PUB_ENC_KEY.msg);
}
return lib.cipher_opt_new_asymmetric(this.app.connection, pubEncKey.ref)
.then((c) => h.autoref(new CipherOpt(this.app, c)));
.then((c) => h.autoref(new CipherOpt(this.app, c)));
}
}
module.exports = CipherOptInterface;
49 changes: 21 additions & 28 deletions src/api/crypto.js
Expand Up @@ -21,7 +21,6 @@ const makeError = require('../native/_error.js');
* @hideconstructor
*/
class PubEncKey extends h.NetworkObject {

/**
* Generate raw buffer of public encryption key
* @returns {Promise<Buffer>}
Expand Down Expand Up @@ -133,7 +132,6 @@ class PubEncKey extends h.NetworkObject {
* @hideconstructor
*/
class SecEncKey extends h.NetworkObject {

/**
* Generate raw buffer of secret encryption key
* @returns {Promise<Buffer>}
Expand Down Expand Up @@ -227,7 +225,6 @@ class SecEncKey extends h.NetworkObject {
* Asymmetric encryption keypair
*/
class EncKeyPair {

/**
* @hideconstructor
*/
Expand Down Expand Up @@ -293,7 +290,7 @@ class EncKeyPair {
*/
decryptSealed(cipher) {
return lib.decrypt_sealed_box(this.app.connection, cipher,
this.pubEncKey.ref, this.secEncKey.ref);
this.pubEncKey.ref, this.secEncKey.ref);
}
}

Expand All @@ -302,7 +299,6 @@ class EncKeyPair {
* @hideconstructor
*/
class PubSignKey extends h.NetworkObject {

/**
* Generate raw buffer of public sign key.
* @returns {Promise<Buffer>}
Expand Down Expand Up @@ -358,7 +354,6 @@ class PubSignKey extends h.NetworkObject {
* @hideconstructor
*/
class SecSignKey extends h.NetworkObject {

/**
* Generate raw buffer of secret sign key
* @returns {Promise<Buffer>}
Expand Down Expand Up @@ -415,7 +410,6 @@ class SecSignKey extends h.NetworkObject {
* @hideconstructor
*/
class SignKeyPair {

constructor(app, pub, secret) {
this.app = app;
this._public = pub;
Expand Down Expand Up @@ -465,7 +459,6 @@ class SignKeyPair {
* Contains all cryptographic related functionality
*/
class CryptoInterface {

/**
* @hideconstructor
*/
Expand Down Expand Up @@ -505,7 +498,7 @@ class CryptoInterface {
*/
getAppPubSignKey() {
return lib.app_pub_sign_key(this.app.connection)
.then((c) => h.autoref(new PubSignKey(this.app, c)));
.then((c) => h.autoref(new PubSignKey(this.app, c)));
}

/**
Expand All @@ -523,7 +516,7 @@ class CryptoInterface {
*/
getAppPubEncKey() {
return lib.app_pub_enc_key(this.app.connection)
.then((c) => h.autoref(new PubEncKey(this.app, c)));
.then((c) => h.autoref(new PubEncKey(this.app, c)));
}

/**
Expand All @@ -541,10 +534,10 @@ class CryptoInterface {
*/
generateEncKeyPair() {
return lib.enc_generate_key_pair(this.app.connection)
.then((r) => new EncKeyPair(this.app,
h.autoref(new PubEncKey(this.app, r[0])),
h.autoref(new SecEncKey(this.app, r[1]))
));
.then((r) => new EncKeyPair(this.app,
h.autoref(new PubEncKey(this.app, r[0])),
h.autoref(new SecEncKey(this.app, r[1]))
));
}

/**
Expand All @@ -562,10 +555,10 @@ class CryptoInterface {
*/
generateSignKeyPair() {
return lib.sign_generate_key_pair(this.app.connection)
.then((r) => new SignKeyPair(this.app,
h.autoref(new PubSignKey(this.app, r[0])),
h.autoref(new SecSignKey(this.app, r[1]))
));
.then((r) => new SignKeyPair(this.app,
h.autoref(new PubSignKey(this.app, r[0])),
h.autoref(new SecSignKey(this.app, r[1]))
));
}

/**
Expand All @@ -592,9 +585,9 @@ class CryptoInterface {
generateEncKeyPairFromRaw(rawPublicKey, rawSecretkey) {
let pubKey;
return this.pubEncKeyFromRaw(rawPublicKey)
.then((pk) => { pubKey = pk; })
.then(() => this.secEncKeyFromRaw(rawSecretkey))
.then((sk) => new EncKeyPair(this.app, pubKey, sk));
.then((pk) => { pubKey = pk; })
.then(() => this.secEncKeyFromRaw(rawSecretkey))
.then((sk) => new EncKeyPair(this.app, pubKey, sk));
}

/**
Expand All @@ -621,9 +614,9 @@ class CryptoInterface {
generateSignKeyPairFromRaw(rawPublicKey, rawSecretkey) {
let pubKey;
return this.pubSignKeyFromRaw(rawPublicKey)
.then((pk) => { pubKey = pk; })
.then(() => this.secSignKeyFromRaw(rawSecretkey))
.then((sk) => new SignKeyPair(this.app, pubKey, sk));
.then((pk) => { pubKey = pk; })
.then(() => this.secSignKeyFromRaw(rawSecretkey))
.then((sk) => new SignKeyPair(this.app, pubKey, sk));
}

/**
Expand All @@ -645,7 +638,7 @@ class CryptoInterface {
*/
pubSignKeyFromRaw(rawPubSignKey) {
return lib.sign_pub_key_new(this.app.connection, rawPubSignKey)
.then((c) => h.autoref(new PubSignKey(this.app, c)));
.then((c) => h.autoref(new PubSignKey(this.app, c)));
}

/**
Expand All @@ -667,7 +660,7 @@ class CryptoInterface {
*/
secSignKeyFromRaw(rawSecSignKey) {
return lib.sign_sec_key_new(this.app.connection, rawSecSignKey)
.then((c) => h.autoref(new SecSignKey(this.app, c)));
.then((c) => h.autoref(new SecSignKey(this.app, c)));
}

/**
Expand All @@ -689,7 +682,7 @@ class CryptoInterface {
*/
pubEncKeyFromRaw(rawPubEncKey) {
return lib.enc_pub_key_new(this.app.connection, rawPubEncKey)
.then((c) => h.autoref(new PubEncKey(this.app, c)));
.then((c) => h.autoref(new PubEncKey(this.app, c)));
}

/**
Expand All @@ -711,7 +704,7 @@ class CryptoInterface {
*/
secEncKeyFromRaw(raw) {
return lib.enc_secret_key_new(this.app.connection, raw)
.then((c) => h.autoref(new SecEncKey(this.app, c)));
.then((c) => h.autoref(new SecEncKey(this.app, c)));
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/api/emulations/nfs.js
Expand Up @@ -22,7 +22,6 @@ const makeError = require('../../native/_error.js');
* NFS-style file operations
*/
class File {

/**
* @hideconstructor
* Instantiate a new NFS File instance.
Expand Down Expand Up @@ -316,8 +315,8 @@ class NFS {
fileMeta.user_metadata_cap = userMetadataPtr.length;
}
return lib.dir_insert_file(
this.mData.app.connection, this.mData.ref, fileName, file.ref.ref()
)
this.mData.app.connection, this.mData.ref, fileName, file.ref.ref()
)
.then(() => {
const fileObj = file;
fileObj.version = 0;
Expand Down Expand Up @@ -363,7 +362,7 @@ class NFS {
}
const fileContext = file;
return lib.dir_update_file(this.mData.app.connection, this.mData.ref, fileName,
fileContext.ref.ref(), version)
fileContext.ref.ref(), version)
.then((newVersion) => {
fileContext.version = newVersion;
})
Expand Down
13 changes: 4 additions & 9 deletions src/api/immutable.js
Expand Up @@ -31,7 +31,6 @@ const genXorUrl = (xorName, mimeType) => {
* @hideconstructor
*/
class Reader extends helpers.NetworkObject {

/**
* Read the given amount of bytes from the network
* @param {Object=} options
Expand Down Expand Up @@ -65,9 +64,9 @@ class Reader extends helpers.NetworkObject {

return prms.then((end) =>
lib.idata_read_from_self_encryptor(this.app.connection,
this.ref,
opts.offset || 0,
end));
this.ref,
opts.offset || 0,
end));
}

/**
Expand Down Expand Up @@ -133,15 +132,13 @@ class Reader extends helpers.NetworkObject {
static free(app, ref) {
lib.idata_self_encryptor_reader_free(app.connection, ref);
}

}

/**
* {@link ImmutableDataInterface} writer
* @hideconstructor
*/
class Writer extends helpers.NetworkObject {

/**
* Append the given data to {@link ImmutableDataInterface}. This does not commit data to network.
*
Expand Down Expand Up @@ -197,7 +194,7 @@ class Writer extends helpers.NetworkObject {
*/
async close(cipherOpt, getXorUrl, mimeType) {
const name = await lib.idata_close_self_encryptor(this.app.connection,
this.ref, cipherOpt.ref);
this.ref, cipherOpt.ref);
if (!getXorUrl) {
return name;
}
Expand All @@ -223,11 +220,9 @@ class Writer extends helpers.NetworkObject {
static free(app, ref) {
lib.idata_self_encryptor_writer_free(app.connection, ref);
}

}

class ImmutableDataInterface {

/**
* @hideconstructor
* @param {SAFEApp} app
Expand Down

0 comments on commit 70b1b96

Please sign in to comment.