Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
lelylan-node
Advanced tools
Node.js client library for Lelylan API.
Lelylan makes it easy for developers to monitor and control all devices in your house providing a simple, self descriptive and consistent representation of them. Lelylan maps every device in your house to a unique URI which will provide a simple access over it.
With Lelylan developers can build secure applications and services that use real-time data coming from the real world to create the future connected house.
Node client library is tested against Node ~0.8.x
Install the client library using npm:
$ npm install lelylan-node
$ npm install simple-oauth2
Install the client library using git:
$ git clone git://github.com/lelylan/lelylan-node.git
$ cd lelylan-node
$ npm install
Before calling Lelylan APIs you need to set the access token using Simple OAuth2. If not used to OAuth2 concepts, check out the dev center documentation.
// Set the client credentials and the OAuth2 server
var credentials = {
clientID: '<client-id>',
clientSecret: '<client-secret>',
site: 'http://people.lelylan.com'
};
// Initialize the OAuth2 Library
var OAuth2 = require('simple-oauth2')(credentials);
// Authorization OAuth2 URI
// See available scopes here http://localhost:4000/api/oauth#scopes
var authorization_uri = OAuth2.AuthCode.authorizeURL({
redirect_uri: '<redirect-uri>',
scope: '<scopes>',
state: '<state>'
});
console.log('Auhtorization URI', authorization_uri);
// => http://people.lelylan.com/oauth/authorize?
// redirect_uri=<redirect-uri>&
// scope=<scopes>&response_type=code&client_id=<client-id>
// Redirect example using Express (see http://expressjs.com/api.html#res.redirect)
res.redirect(authorization_uri);
// Get the access token object (authorization code is given from the previous step)
var token;
OAuth2.AuthCode.getToken({
code: '<code>',
redirect_uri: '<client-id>'
}, function(error, result) {
// Save the access token
if (error) console.log('Access Token Error', error.message);
token = OAuth2.AccessToken.create(result);
console.log('Access Token', token);
});
Once you have the access token you can access to the Lelylan API. The following example shows how to print in the console a list of owned devices.
// Initialize Lelylan Node library
var Lelylan = require('lelylan-node')({ token: token });
// Get all devices
Lelylan.Device.all({}, function(error, response) {
if (error) console.log('Lelylan Error', error.message);
console.log(response);
console.log(response.uri);
console.log(response.properties[0].value);
});
Using a Simple OAuth2 AccessToken, the access token is automatically refreshed when it expires.
When using the subscription services (realtime) you don't need an access token. In this case you need to set the client credentials.
// Setup credentials
credentials = { clientID: '<client-id>', clientSecret: '<client-secret>' };
Lelylan = require('lelylan-node')(credentials);
// Get all subscriptions
Lelylan.Subscriptions.all(function(error, response) {
if (error) console.log('Lelylan Error', error.message);
console.log(response)
})
Learn how to use Lelylan and AngulasJS in deep.
Exceptions are raised when a 4xx or 5xx status code is returned.
HTTPError
Through the error message attribute you can access the JSON representation
made by the HTTP status
and an error message
.
Lelylan.Device.all({}, function(error, response) {
if (error) console.log('Lelylan Error', error.message.message);
})
The error.message
object contains the status
and the message
properties.
401, 403, 404, 422 responses has also a valid response
object.
Learn more about errors on Lelylan.
Lelylan Configuration accepts an object with the following valid params.
token
- A Simple OAuth2 AccessToken object.clientID
- A string that represents the registered Client ID.clientSecret
- A string that represents the registered Client secret.endpoint
- A string that represents the API endpoint (api.lelylan.com
by deafault).Here a simple example where we change the API endpoint.
options = { 'endpoint' : 'http://localhost:8000' }
Lelylan = require('lelylan')(options);
To directly access to the config object use the #config
method.
var rawToken = Lelylan.config.token.token
Fork the repo on github and send a pull requests with topic branches. Do not forget to provide specs to your contribution.
npm install
for dependencies.npm test
to execute all specs.make test-watch
to auto execute all specs when a file change.$ git clone https://github.com/lelylan/lelylan-node
$ cd lelylan-node
$ node
$ > var lelylan = require('./lib/lelylan-node.js')();
Follow github guidelines.
Use the issue tracker for bugs. Mail or Tweet us for any idea that can improve the project.
Special thanks to the following people for submitting patches.
See CHANGELOG
FAQs
Node.js client for the Lelylan API
The npm package lelylan-node receives a total of 0 weekly downloads. As such, lelylan-node popularity was classified as not popular.
We found that lelylan-node 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.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.