
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
AUTH-VK is a powerful Node.js a module that allows you to easily log in to Vkontakte 🚀
📖 Documentation | 🤖 Author |
---|
Node.js 12.0.0 or newer is required
npm i auth-vk --save
npm i passport --save
// Example of using the library:
new auth(
{
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: process.env.CALLBACK_URL,
scope: process.env.SCOPE,
profileFields: process.env.PROFILE_FIELDS,
},
async function verify(accessToken, refreshToken, params, profile, done) {
process.nextTick(function () {
done(null, profile);
});
}
);
ID приложения
Защищённый ключ
clientID: 7624701,
clientSecret: 'xZUHQ8vgnMk4okBAKn1e',
callbackURL: "https://dev-up.ru/auth/vk/callback",
Then you need to specify the application rights and display the rights:
You can get a list of rights here 📖 Application Rights.
In the example, we will specify the rights to: Access at any time, Groups, Email, Friends List.
scope: ["offline", "groups", "email", "friends"],
profileFields: ["offline", "groups", "email", "friends"],
That's it!
Sample code:
const auth = require("auth-vk").Zeuvs;
const express = require("express");
const passport = require("passport");
const expressSession = require("express-session");
const app = express();
require("http").Server(app).listen(80);
app.set("views", __dirname + "/scr");
app.set("view engine", "ejs");
app.use(
expressSession({
secret: process.env.SECRET,
key: process.env.KEY,
resave: true,
saveUninitialized: true,
cookie: {
secure: true,
httpOnly: true,
sameSite: true,
},
})
);
passport.serializeUser(function (user, done) {
done(null, user);
});
passport.deserializeUser(function (obj, done) {
done(null, obj);
});
passport.use(
new auth(
{
clientID: process.env.CLIENTID,
clientSecret: process.env.CLIENTSECRET,
callbackURL: process.env.CALLBACKURL,
scope: process.env.SCOPE,
profileFields: process.env.PROFILEFIELDS,
},
async function verify(accessToken, refreshToken, params, profile, done) {
process.nextTick(function () {
done(null, profile);
});
}
)
);
app.get("/", auth, function (req, res) {
res.json({
user: {
id: req.user.id,
fullname: req.user.displayName,
pname: req.user.name,
sex: req.user.gender,
url: req.user.url,
},
});
/*
RESULT:
user.id: 449532928
user.fullname: Mihail Bezmolenko
user.pname: { "givenName": "Mihail", "familyName": "Bezmolenko" }
user.sex: Мужской
user.url: "http://vk.com/zeuvs"
*/
});
app.get("/logout", function (req, res) {
req.logout();
res.redirect("/");
});
app.get("/auth/vk", passport.authenticate("vkontakte"), function (req, res) {
req.session.returnTo = req.originalUrl;
});
app.get(
"/auth/vk/callback",
passport.authenticate("vkontakte", {
failureRedirect: "/",
session: true,
}),
async function (req, res) {
res.redirect(req.session.returnTo || "/");
delete req.session.returnTo;
}
);
async function auth(req, res, next) {
if (!req.user) {
req.session.returnTo = req.originalUrl;
return res.redirect("/auth/vk/");
}
return next();
}
FAQs
Authorization for websites via Vkontakte
The npm package auth-vk receives a total of 9 weekly downloads. As such, auth-vk popularity was classified as not popular.
We found that auth-vk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.