@fonoster/auth
Advanced tools
Comparing version 0.2.15 to 0.2.16
@@ -65,3 +65,3 @@ "use strict"; | ||
}); | ||
const hasAccess = await (0, role_has_access_1.default)(result.data.role, pathRequest); | ||
const hasAccess = await role_has_access_1.default(result.data.role, pathRequest); | ||
if (hasAccess) { | ||
@@ -68,0 +68,0 @@ await next(); |
@@ -55,3 +55,3 @@ "use strict"; | ||
super.init(); | ||
(0, grpc_promise_1.promisifyAll)(super.getService(), { metadata: super.getMeta() }); | ||
grpc_promise_1.promisifyAll(super.getService(), { metadata: super.getMeta() }); | ||
} | ||
@@ -58,0 +58,0 @@ /** |
@@ -19,3 +19,3 @@ "use strict"; | ||
async validateToken(call, callback) { | ||
const result = await authenticator.validateToken({ accessToken: call.request.getToken() }, (0, certs_1.getSalt)()); | ||
const result = await authenticator.validateToken({ accessToken: call.request.getToken() }, certs_1.getSalt()); | ||
const validateTokenResponse = new auth_pb_1.ValidateTokenResponse(); | ||
@@ -30,3 +30,3 @@ validateTokenResponse.setValid(result.isValid); | ||
logger_1.default.verbose(`@fonoster/auth creating token [accessKeyId is ${call.request.getAccessKeyId()}]`); | ||
const result = await authenticator.createToken(call.request.getAccessKeyId(), certs_1.AUTH_ISS, call.request.getRoleName(), (0, certs_1.getSalt)(), call.request.getExpiration() || "30d"); | ||
const result = await authenticator.createToken(call.request.getAccessKeyId(), certs_1.AUTH_ISS, call.request.getRoleName(), certs_1.getSalt(), call.request.getExpiration() || "30d"); | ||
const response = new auth_pb_1.CreateTokenResponse(); | ||
@@ -41,3 +41,3 @@ response.setToken(result.accessToken); | ||
logger_1.default.verbose(`@fonoster/auth creating no access token [accessKeyId is ${call.request.getAccessKeyId()}]`); | ||
const result = await authenticator.createToken(call.request.getAccessKeyId(), certs_1.AUTH_ISS, "NO_ACCESS", (0, certs_1.getSalt)(), "1d"); | ||
const result = await authenticator.createToken(call.request.getAccessKeyId(), certs_1.AUTH_ISS, "NO_ACCESS", certs_1.getSalt(), "1d"); | ||
const response = new auth_pb_1.CreateTokenResponse(); | ||
@@ -44,0 +44,0 @@ response.setToken(result.accessToken); |
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
const express_1 = __importDefault(require("express")); | ||
const app = (0, express_1.default)(); | ||
const app = express_1.default(); | ||
const auth_utils_1 = __importDefault(require("../utils/auth_utils")); | ||
@@ -21,3 +21,3 @@ const jwt_1 = __importDefault(require("../utils/jwt")); | ||
const sessionToken = req.headers["x-session-token"]; | ||
const result = await authenticator.validateToken({ accessToken: sessionToken }, (0, certs_1.getSalt)()); | ||
const result = await authenticator.validateToken({ accessToken: sessionToken }, certs_1.getSalt()); | ||
if (!sessionToken || result.isValid === false) { | ||
@@ -44,5 +44,5 @@ res.status(401); | ||
name: "authentication", | ||
middlewareObj: new auth_middleware_1.default((0, certs_1.getSalt)(), null).middleware | ||
middlewareObj: new auth_middleware_1.default(certs_1.getSalt(), null).middleware | ||
}; | ||
(0, common_1.runServices)(services, [middleware]); | ||
common_1.runServices(services, [middleware]); | ||
}); |
@@ -39,3 +39,3 @@ "use strict"; | ||
// @ts-ignore | ||
return (0, util_1.promisify)(jsonwebtoken_1.sign)({ ...payload }, privateKey, { | ||
return util_1.promisify(jsonwebtoken_1.sign)({ ...payload }, privateKey, { | ||
expiresIn | ||
@@ -50,3 +50,3 @@ }); | ||
// @ts-ignore | ||
return (await (0, util_1.promisify)(jsonwebtoken_1.verify)(token, privateKey, { | ||
return (await util_1.promisify(jsonwebtoken_1.verify)(token, privateKey, { | ||
ignoreExpiration: false | ||
@@ -53,0 +53,0 @@ })); |
@@ -28,3 +28,3 @@ "use strict"; | ||
const common_1 = require("@fonoster/common"); | ||
const svc = new auth_grpc_pb_1.AuthClient(process.env.APISERVER_ENDPOINT || "localhost:50052", (0, common_1.getClientCredentials)()); | ||
const svc = new auth_grpc_pb_1.AuthClient(process.env.APISERVER_ENDPOINT || "localhost:50052", common_1.getClientCredentials()); | ||
async function default_1(role, service) { | ||
@@ -31,0 +31,0 @@ return new Promise((resolve, reject) => { |
{ | ||
"name": "@fonoster/auth", | ||
"version": "0.2.15", | ||
"version": "0.2.16", | ||
"description": "Authentication Module", | ||
@@ -46,6 +46,6 @@ "author": "Raul Sanchez <rsanchez@fonoster.com>", | ||
"dependencies": { | ||
"@fonoster/certs": "^0.2.15", | ||
"@fonoster/common": "^0.2.15", | ||
"@fonoster/errors": "^0.2.15", | ||
"@fonoster/logger": "^0.2.15", | ||
"@fonoster/certs": "^0.2.16", | ||
"@fonoster/common": "^0.2.16", | ||
"@fonoster/errors": "^0.2.16", | ||
"@fonoster/logger": "^0.2.16", | ||
"@grpc/grpc-js": "^1.3.6", | ||
@@ -60,3 +60,3 @@ "express": "^4.17.1", | ||
}, | ||
"gitHead": "1fdc2fff4d0c6900b1bff6a60f766492e988de41" | ||
"gitHead": "966dd4f5b459d5c6decaaa42b1bdcb485142dda5" | ||
} |
365474
Updated@fonoster/certs@^0.2.16
Updated@fonoster/common@^0.2.16
Updated@fonoster/errors@^0.2.16
Updated@fonoster/logger@^0.2.16