Skip to content

Commit

Permalink
chore: package update
Browse files Browse the repository at this point in the history
  • Loading branch information
XVincentX committed Sep 7, 2019
1 parent 6a64c3b commit 452dccc
Show file tree
Hide file tree
Showing 30 changed files with 1,038 additions and 531 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"always"
],
"no-console": "warn",
"no-prototype-builtins": "off",
"prefer-const": "error",
"node/no-deprecated-api": [
"error",
Expand Down
4 changes: 2 additions & 2 deletions bin/generators/credentials/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module.exports = class extends eg.Generator {
yargs
.usage(`Usage: $0 ${process.argv[2]} create [options]`)
.example(`$0 ${process.argv[2]} create -c jdoe -t key-auth`)
.example(`echo '{"consumer":"jdoe", "type": "key-auth"}'` +
.example('echo \'{"consumer":"jdoe", "type": "key-auth"}\'' +
`| $0 ${process.argv[2]} create --stdin`)
.example(`echo '{"consumer":"jdoe", "type": "key-auth", "scopes":["existingScope"]}'` +
.example('echo \'{"consumer":"jdoe", "type": "key-auth", "scopes":["existingScope"]}\'' +
`| $0 ${process.argv[2]} create --stdin`)
.example(`cat all_apps.json | $0 ${process.argv[2]} create --stdin`)
.example(`$0 ${process.argv[2]} create -u jdoe -p 'scopes=existingScope'`)
Expand Down
1 change: 1 addition & 0 deletions bin/generators/users/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = class extends eg.Generator {
.example(`$0 ${process.argv[2]} list`)
});
}

prompting () {
return this.admin.users.list({ all: this.argv.a })
.then(data => {
Expand Down
2 changes: 1 addition & 1 deletion lib/conditions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function register({ type = 'condition', name, handler, schema }) {
}

logger.error(`Condition ${chalk.default.red.bold(name)} config validation failed: ${validationResult.error}`);
throw new Error(`CONDITION_PARAMS_VALIDATION_FAILED`);
throw new Error('CONDITION_PARAMS_VALIDATION_FAILED');
};
}

Expand Down
3 changes: 2 additions & 1 deletion lib/plugin-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class PluginInstaller {
updateConfigurationFiles ({
pluginOptions,
enablePlugin,
addPoliciesToWhitelist }) {
addPoliciesToWhitelist
}) {
// WARNING (kevinswiber): Updating YAML while maintaining presentation
// style is not easy. We're using the YAWN library here, which has
// a decent approach given the current state of available YAML parsers,
Expand Down
2 changes: 1 addition & 1 deletion lib/policies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const register = (policyOptions) => {
}

logger.error(`Policy ${chalk.default.red.bold(name)} params validation failed: ${validationResult.error}`);
throw new Error(`POLICY_PARAMS_VALIDATION_FAILED`);
throw new Error('POLICY_PARAMS_VALIDATION_FAILED');
};

policies[name] = policyOptions;
Expand Down
8 changes: 4 additions & 4 deletions lib/policies/jwt/extractors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const passportJWT = require('passport-jwt');

module.exports = {
'header': passportJWT.ExtractJwt.fromHeader,
'query': passportJWT.ExtractJwt.fromUrlQueryParameter,
'authScheme': passportJWT.ExtractJwt.fromAuthHeaderWithScheme,
'authBearer': passportJWT.ExtractJwt.fromAuthHeaderAsBearerToken
header: passportJWT.ExtractJwt.fromHeader,
query: passportJWT.ExtractJwt.fromUrlQueryParameter,
authScheme: passportJWT.ExtractJwt.fromAuthHeaderWithScheme,
authBearer: passportJWT.ExtractJwt.fromAuthHeaderAsBearerToken
};
2 changes: 1 addition & 1 deletion lib/policies/oauth2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
{
type: 'object',
properties: {
jwt: { '$ref': 'jwt.json' }
jwt: { $ref: 'jwt.json' }
}
}]
}
Expand Down
2 changes: 1 addition & 1 deletion lib/policies/oauth2/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function authenticateLocal(req, clientId, clientSecret, done) {
return done(null, false);
}

delete req.headers['authorization'];
delete req.headers.authorization;
return done(null, consumer);
});
})
Expand Down
4 changes: 2 additions & 2 deletions lib/policies/request-transformer/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module.exports = {
}
},
properties: {
headers: { '$ref': '#/definitions/addRemove' },
body: { '$ref': '#/definitions/addRemove' }
headers: { $ref: '#/definitions/addRemove' },
body: { $ref: '#/definitions/addRemove' }
},
anyOf: [{ required: ['headers'] }, { required: ['body'] }]
};
4 changes: 2 additions & 2 deletions lib/services/consumers/application.dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ dao.getAllAppIdsByUser = function (userId) {
};

dao.activate = function (id) {
return db.hmset(appHashKey(id), { 'isActive': 'true', 'updatedAt': String(new Date()) });
return db.hmset(appHashKey(id), { isActive: 'true', updatedAt: String(new Date()) });
};

dao.deactivate = function (id) {
return db.hmset(appHashKey(id), { 'isActive': 'false', 'updatedAt': String(new Date()) });
return db.hmset(appHashKey(id), { isActive: 'false', updatedAt: String(new Date()) });
};

dao.deactivateAll = function (userId) {
Expand Down
4 changes: 2 additions & 2 deletions lib/services/credentials/credential.dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ dao.getCredential = function (id, type) {
};

dao.activateCredential = function (id, type) {
return db.hmset(buildIdKey(type, id), { 'isActive': 'true', 'updatedAt': String(new Date()) });
return db.hmset(buildIdKey(type, id), { isActive: 'true', updatedAt: String(new Date()) });
};

dao.deactivateCredential = function (id, type) {
return db.hmset(buildIdKey(type, id), { 'isActive': 'false', 'updatedAt': String(new Date()) });
return db.hmset(buildIdKey(type, id), { isActive: 'false', updatedAt: String(new Date()) });
};

dao.removeCredential = function (id, type) {
Expand Down
12 changes: 6 additions & 6 deletions lib/services/credentials/credential.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ s.insertCredential = function (id, type, credentialDetails) {
])
.then(([scopes, { hash, password }, credentialProps]) => {
if (scopes) {
newCredential['scopes'] = JSON.stringify(scopes);
newCredential.scopes = JSON.stringify(scopes);
}
newCredential[credentialConfig.properties.passwordKey.default] = hash;
delete credentialProps[credentialConfig.properties.passwordKey.default];
Expand Down Expand Up @@ -287,20 +287,20 @@ function validateAndHashPassword (credentialConfig, credentialDetails) {
}

function validateNewCredentialScopes (credentialConfig, credentialDetails) {
if (!credentialConfig.properties || !credentialConfig.properties['scopes']) {
if (!credentialConfig.properties || !credentialConfig.properties.scopes) {
return Promise.resolve(null);
}

if (credentialDetails['scopes']) {
return validateExistingScopes(credentialDetails['scopes']);
if (credentialDetails.scopes) {
return validateExistingScopes(credentialDetails.scopes);
}

if (credentialConfig.required && credentialConfig.required.includes('scopes')) {
throw new Error('scopes are required'); // TODO: replace with validation error
}

if (credentialConfig.properties['scopes'].default) {
return Promise.resolve(credentialConfig.properties['scopes'].default);
if (credentialConfig.properties.scopes.default) {
return Promise.resolve(credentialConfig.properties.scopes.default);
}

return Promise.resolve(null);
Expand Down
Loading

0 comments on commit 452dccc

Please sign in to comment.