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.
loop54-js-connector
Advanced tools
Javascript Wrapper for Loop54 JSON V3 API
<script>
tagloop54-js-connector.js
(for development) from
https://static.loop54.com/lib/js/loop54-js-connector.js or
loop54-js-connector.min.js
(for production) from
https://static.loop54.com/lib/js/loop54-js-connector.min.js<script>
tag with an src
attribute that points to your hosted fileLoop54
.npm install --save loop54-js-connector
require('loop54-js-connector');
or with define(["loop54-js-connector"], function(getClient) { /* ... */ })
npm install --save loop54-js-connector
const getClient = require('loop54-js-connector');
or import getClient from 'loop54-js-connector';
If you're using NPM to include the connector in your build pipeline, (for instance using Rollup or Webpack), note that the module is exported as a pure ES6 module, and it is not bundled with dependencies, transpiled or otherwise prepared for live environment. You will need to make those preparations as part of your own pipeline.
When creating a client, you will need to set the endpoint to match the one you will get from Loop54.
If you included loop54-js-connector.js
(or loop54-js-connector.min.js
) in a script tag,
you can get a configured client from the global Loop54 object:
Get client from global Loop54 object
var client = Loop54.getClient('URL_TO_YOUR_ENDPOINT');
If you imported the connector as an ECMAScript module (with require('loop54-js-connector') or equivalent), you can call the getClient function directly:
Get client from imported function
var client = getClient('URL_TO_YOUR_ENDPOINT');
Search example with promise
var options = {skip:0,take:20}; //this will take the first 20 results
client.search("R2 droids", options)
.then(function(response){
if(response.data.error) {
console.log(response.data.error.title);
} else {
console.log("found " + response.data.results.count + " results");
}
});
Search example with callback
var options = {skip:0,take:20}; //this will take the first 20 results
var callback = function(response){
if(response.data.error) {
console.log(response.data.error.title);
} else {
console.log("found " + response.data.results.count + " results");
}
}
client.search("R2 droids", options, callback);
The options
and callback
parameters are optional. As seen above,
client.search
will return a Promise.
All API operations work the same way with regards to options
and callback
.
Cancelling a request
All requests can be cancelled, which is useful when the user types fast.
Using promise:
const request = client.search("R2 droids", {}); //create request
request.then(response => if(!response.cancelled) console.log('done')); //attach continuation
request.cancel(); // cancel the request
Using callback:
var callback = function(response) { if(!response.cancelled) console.log('done'); } //create callback
const request = client.search("R2 droids", {}, callback); //create request
request.cancel(); // cancel the request
Create events example
var entity = {type:"Product",id:"1234"};
var callback = function(response){
if(response.data.error) {
console.log(response.data.error.title);
} else {
console.log("success");
}
}
client.createEvent("click",entity,null,null,null,callback);
See http://docs.loop54.com for more code samples.
If you for some reason want to handle user ID:s yourself instead of letting the Connector do it using cookies, you can set the user ID when retrieving a client like this:
Configuration example with custom user ID
var client = Loop54.getClient('URL_TO_YOUR_ENDPOINT','YOUR_USER_ID');
The connector supports the following API operations:
It also aids in developing a Loop54 integration by:
A Linux or MacOS environment is required. Windows is not supported and the npm commands below will fail on it.
npm install
to install all dependenciesnpm run dev
to start the webserver, open up
http://localhost:3001/#search and try out the basic featuresBefore creating a pull request:
package.json
npm run sync-version
package.json
, package-lock.json
and core.js
.1.14
.Committing version related changes separately from implementation makes it easier to cherry-pick specific changes. Also, spotting version increments in the git history is much quicker.
run npm run bundle
to build the source code into /lib folder
npm run test
to do check if the tests passes
All tests are located in the test
folder
Thanks to Doru Moisa for PR #1
FAQs
JS Wrapper for Loop54 JSON API
The npm package loop54-js-connector receives a total of 142 weekly downloads. As such, loop54-js-connector popularity was classified as not popular.
We found that loop54-js-connector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.