Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
vk-api-calls
Advanced tools
Yet another VK API wrapper for Node.js & io.js.
npm install --save vk-api-calls
var vk = new VK([app], [options], [session])
Type: object
Info about your app for future authentication.
Type: number
or string
Your app's ID.
Type: string
Your app's Secure Key.
Type: string
Redirect URI as specified in your app's options.
Type: string
, array
or number
List of desirable scopes for your app or calculated bit mask.
Type: string
or number
Version of VK API you want to work with.
Type: object
Custom vk-api-calls settings.
Type: number
Default: 666
Delay for API calls debouncing in milliseconds. Has to be at least 333 because of API restrictions.
Type: number
Default: 30000
Milliseconds untill ETIMEDOUT
error is thrown if there's no response from the server.
Type: object
Default: {'user-agent': 'https://github.com/dsblv/vk-api-calls'}
Headers to be sent with each request. user-agent
contains a link to this repo by default. Provide some information about your app here so VK server administration will beter know what's going on.
Type: object
Session data: user id, access token and when it expires:
{
userId: 'USER_ID',
token: 'ACCESS_TOKEN',
expires: 1440163431337
}
This will help you not to perform authentication each time user visits your page. Save this in your session storage and use until it's expired. If expires is set to 0
, token is assumed to be eternal.
Note that expires
value is not relative, but absolute
vk.setSession(data)
→ this
Saves session data.
Required
Type: object
Data returned by VK API server:
{
'user_id': 'USER_ID',
'access_token': 'ACCESS_TOKEN',
'expires_in': 3600
}
Note that this time expires_in
is relative. The module will internally convert in to absolute value.
vk.getSession()
→ object
Returns session data prepared for storing in session storage.
vk.getToken()
→ string
Returns current access token
or undefined
if it's expired or not set.
vk.hasValidToken()
→ boolean
Tells if valid token is avalible.
vk.renderAuthUrl([query])
→ string
Retutns URL to direct user to for authentication.
Type: object
Query parameters you may want to manually override.
vk.performSiteAuth(query, [callback])
→ promise/this
Alias: vk.siteAuth()
Performs Authorization Code Flow auth.
Required
Type: object
Query has only one required parameter — code
— which is returned by VK API server when user is successfully logged in.
Type: function
If callback is supplied, it will be called when server responds. Otherwise, the method returns a Promise.
vk.performServerAuth([query], [callback])
→ promise/this
Alias: vk.serverAuth()
Performs Client Credentials Flow auth.
Type: object
Query parameters you may want to manually override.
Type: function
If callback is supplied, it will be called when server responds. Otherwise, the method returns a Promise.
vk.performApiCall(method, [query], [callback])
→ promise/this
Alias: vk.apiCall()
Performs API requests.
Required
Type: string
One of VK API methods.
Type: object
Query parameters you want to pass to VK API method. Required authentication data will be attached automatically.
Type: function
If callback is supplied, it will be called when server responds. Otherwise, the method returns a Promise.
vk.collectStream(method, [query])
→ readable streamThis metod allows you to get more data than VK restrictions allow by sending multiple requests. Every API response will emit data
event with received data so you can operatively store it.
Stream emits data
, error
and end
events.
API request rate is limited to match VK API requirements.
Required
Type: string
One of VK API methods.
Type: object
Query parameters you want to pass to VK API method. Required authentication data will be attached automatically.
Example:
// your save-to-database module
var save = require('./save');
// let's get 10000 members of a group
// when maximum per request is 1000
var stream = vk.collectStream('groups.getMembers', {
group_id: 1,
count: 10000
});
stream.on('data', function (data) {
save(data.items);
});
stream.on('error', function (error) {
console.error('wild error appears');
});
vk.collect(method, [query], [callback])
→ promise/this
Wrapper around #collectStream() that collects the whole stream.
Arguments are same as in #peformApiCall()
vk-api-calls provides a way to collect several API calls and run them all at once via execute method. This approach can speed up your application, as yo're able to retreive all data you need by one shot.
vk.execution()
→ execution
This method return an Execution object instance.
execution.push(method, [query])
→ this
Add an API call to the set.
Arguments are same as in #peformApiCall() except callback
— no callbacks needed here.
execution.code()
→ string
Generates code
for execution by VK at any point of time.
execution.execute([callback])
→ promise/vk-api-calls instance
Runs the execution via #peformApiCall() with 'execute'
as first argument.
Example:
var exec = vk.execution();
exec
.push('users.get', {user_ids: 1})
.push('wall.get', {owner_id: 1})
.push('photos.get', {owner_id: 1})
.execute()
.then(function (data) {
console.log('Name: ' + data[0].response.first_name);
console.log('Wall posts: ' + data[1].response.count);
console.log('Photos posts: ' + data[2].response.count);
});
vk.hasInScope(method)
→ boolean
Tells if application scope allows you to call particular method. vk-api-calls performs this check internally before every call, so you don't need to do it yourself.
Required
Type: string
MIT © Dmitriy Sobolev
FAQs
VK API calls simplified
The npm package vk-api-calls receives a total of 3 weekly downloads. As such, vk-api-calls popularity was classified as not popular.
We found that vk-api-calls 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.