Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
yodata-client-js
Advanced tools
A JavaScript SDK to provide API access the Yodata.io platform, within a browser based application.
Use this JavaScript library to access the Yodata.io API with your brower or node.js based applications. All API calls accept and return JSON objects.
At the moment, the only requirement to use this library is jQuery (tested with v1.11.1).
yodata.client.js
file to your website file structure.yodata.client.ui.js
file from the yodata-client-ui-js project and follow the instructions to configure the login button.YDClient
object can be accessed through the client UI library's api
property.npm i yodata-client-js
, or add the "yodata-client-js": "*"
to the dependencies
node your package.json file and run npm install
.//Make sure you have your login button configured in your HTML with the necessary app client ID and scopes.
var ydClientUi = null;
$(document).ready(function() {
ydClientUi = new YDClientUi();
ydClientUi.onAuthStateChanged(function() {
if(ydClientUi.isAuthenticated()) {
//logged in state, make API calls to populate UI.
ydClientUi.api.userProfile(function(err, results) {
if (err || !results) {
ydClientUi.logout();
} else {
$('#welcomeMessage').html('Welcome <strong>' + results.profile.name + '</strong>');
reloadTasks();
}
});
} else {
//logged out state. Hide UI elements that require login
}
});
}
function reloadTasks() {
var options = {
limit: 100,
sort: {createdAt: -1}
}
ydClientUi.api.find('yodata.task', options , function(err, results) {
if (err) {
//an error occurred
} else {
//Render the task list in the UI
}
});
}
var YDClient = require('yodata-client-js');
.
.
.
//load the auth token from your database, memory, cookies or query string and pass it to the constructor.
var client = new YDClient({ authToken: 'an auth token that was returned by the client side ui library.'});
var options = {
limit: 100,
sort: {createdAt: -1}
}
client.find('yodata.task', options , function(err, results) {
if (err) {
//an error occurred
} else {
//do something with the array of tasks
}
});
The callback functions for each of the following methods should accept both an error and a result object:
function(err, results) {
if (err) {
//handle the error
} else {
//do something with your results
}
}
Saves a new document for the currently logged in user. The results for this call will be the complete, inserted document with the new objectId, createdAt and modifiedAt dates.
Updates an existing document for the currently logged in user. You must load the entire document from either a find
or findById
call first, update the poperties you'd like to change, then pass the entire document back to the update
method. The results for this call will be the complete, updated document.
Deletes exactly one document, with the given objectId, for the current user. If no error is returned, the command completed successfully.
Returns exactly one document, with the given objectId, for the current user. The results will be a single object, if found. An error will be returned if the objectId could not be located for the current user.
Returns an array of documents. The following options are available.
option | description | default |
---|---|---|
criteria | Using the mongoDB syntax to perform a find | none |
limit | The maximum number of records to return | 10 |
offset | The number of records to skip. | 0 |
sort | The sort order for your results. Use the mongoDb syntax for sorting | { createdAt: -1 } |
fields | A comma separated list of fields to return in the results. 'firstName,lastName' | |
Here's an example of how to sort by a lastName field, in reverse alphabetical order, returning the second set of 100 documents. |
var options = {
sort: { lastName: -1 },
limit: 100,
skip: 100
}
YDClient.find('yodata.task', options, function(err, results) {
if (err) {
//handle the error
} else {
//do something with your results
}
}
Accepts the same options as the find
function, but returns unique values in the result set. For example, if you use the fields
option with a value of lastName
the result set would be a list of unique last names.
Pass the criteria
option to return the count of records that match the criteria.
Use the pipeline
option to pass an array of mongoDB aggregation stages. The following is an example of how you could query the yodata.tasks
collection to return a sorted list of tags and their count:
var options = {
pipeline: [{$unwind: '$tags'}, { $group: { _id: '$tags', count: { $sum: 1 } }}, { $sort: {_id: 1}}]
}
ydClientUi.api.aggregate('yodata.task', options, function(err, tagList) {
//display the list of tags and their counts...
});
Returns the user profile of the user associated with the current authentication token.
Allows you to upload a binary file using a multi-part form data post. The result in the callback function is a special file
object, which you can use to reference the file in collections.
Public files have a publicFileUrl
property, which would allow you to access the file directly using an img
tag (if it's an image) or a link. For private files a two step process is used to generate a download token, which can be used to download the file from the download URL. For security reasons the URL that's returned by this function is only valid for 10 minutes.
FAQs
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
We found that yodata-client-js 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.