Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingEngine
//
// Copyright 2015 Giovanni Campagna
//
// See COPYING for details
const Tp = require('thingpedia');
module.exports = new Tp.DeviceClass({
Name: 'SportRadarDevice',
_init: function(engine, state) {
this.parent(engine, state);
this.uniqueId = 'sportradar';
this.isTransient = true;
this.name = "SportRadar";
this.description = "SportRadar is a quick source of Sport Results and info and stuff.";
},
get ownerTier() {
return Tp.Tier.GLOBAL;
},
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Sunkyu Lim
//
// See LICENSE for details
"use strict";
const Tp = require('thingpedia');
module.exports = new Tp.DeviceClass({
Name: 'InstagramAccountDevice',
UseOAuth2: Tp.Helpers.OAuth2({
kind: 'com.instagram',
client_id: 'fbd0f2d229ff4db38e58c2c3a193a710',
client_secret: '4q41qr80n1544q2po63q91461p7r2226',
scope: ['basic'],
authorize: 'https://api.instagram.com/oauth/authorize/',
get_access_token: 'https://api.instagram.com/oauth/access_token',
callback: function(engine, accessToken, refreshToken) {
return Tp.Helpers.Http.get('https://api.instagram.com/v1/users/self/?access_token=' + accessToken, {
accept: 'application/json'
})
.then(function(response) {
var parsed = JSON.parse(response);
return engine.devices.loadOneDevice({
kind: 'com.instagram',
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2015 Giovanni Campagna
//
// See LICENSE for details
const Tp = require('thingpedia');
module.exports = new Tp.DeviceClass({
Name: 'NineGagDevice',
_init: function(engine, state) {
this.parent(engine, state);
this.uniqueId = 'com.9gag';
this.name = "9Gag";
this.description = "Gets you the latest fun on 9gag";
},
});
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingEngine
//
// Copyright 2016 Giovanni Campagna
//
// See COPYING for details
"use strict";
const Tp = require('thingpedia');
module.exports = new Tp.DeviceClass({
Name: 'GraphdbDevice',
_init: function(engine, state) {
this.parent(engine, state);
this.uniqueId = 'thingengine-own-graphdb';
this.isTransient = true;
}
});
this.parent(false);
devices.forEach(function(d) {
try {
this.addOne(engine.devices.getDevice(d));
} catch(e) {
return null;
}
}, this);
// FIXME: mutation
this.freeze();
}
});
module.exports = new Tp.DeviceClass({
Name: 'GroupDevice',
_init: function(engine, state) {
this.parent(engine, state);
// let the device db pick a uniqueId for this group
// this.uniqueId = undefined;
this.name = "Group %s".format(this.state.name);
this.description = "This is a group of devices. You can share it on a chat room to give people access to it.";
},
get devices() {
return this.state.devices;
},
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Shloka Desai
// Giovanni Campagna
//
// See LICENSE for details
const Tp = require('thingpedia');
module.exports = new Tp.DeviceClass({
Name: "RSSDevice",
_init: function(engine, state) {
this.parent(engine, state);
this.uniqueId = 'org.thingpedia.rss-' + this.url;
this.name = "RSS Feed at " + this.url;
this.description = "This is a RSS Feed";
},
get url() {
return this.state.url;
}
});
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingEngine
//
// Copyright 2015 Giovanni Campagna
//
// See COPYING for details
const Tp = require('thingpedia');
module.exports = new Tp.DeviceClass({
Name: 'BluetoothGenericDevice',
UseDiscovery: function(engine, publicData, privateData) {
if (privateData.paired) {
engine.devices.loadOneDevice({ kind: 'bluetooth-generic',
uuids: publicData.uuids,
class: publicData.class,
hwAddress: privateData.address,
alias: privateData.alias }, true);
} else {
// FINISHME: ask the user to pair the device then add it
}
},
_init: function(engine, state) {
this.parent(engine, state);
function runOAuth2(engine, req) {
return Q.try(function() {
if (req === null) {
return runOAuthStep1(engine);
} else {
return runOAuthStep2(engine, req);
}
}).catch(function(e) {
console.log(e);
console.log(e.stack);
throw e;
});
}
module.exports = new Tp.DeviceClass({
Name: 'TwitterAccountDevice',
Extends: Tp.OnlineAccount,
UseOAuth2: runOAuth2,
Kinds: ['twitter'],
_init: function(engine, state) {
this.parent(engine, state);
this.uniqueId = 'twitter-account-' + this.userId;
this.name = "Twitter Account %s".format(this.screenName);
this.description = "This is your Twitter Account. You can use it to be updated on the status of your friends, and update them with your thoughts.";
},
get screenName() {
return this.state.screenName;
},
return Q.Promise(function(callback, errback) {
client.enable();
client.onSignedUp = callback;
client.auth.confirmAuth(code, key);
}).then(function() {
return engine.devices.loadOneDevice({ kind: 'omlet',
omletId: findPrimaryIdentity(client),
instance: instance,
storage: storage.serialize() }, true);
}).finally(function() {
client.disable();
});
}
module.exports = new Tp.DeviceClass({
Name: 'OmletDevice',
UseOAuth2: function(engine, req) {
if (req === null)
return runOAuth2Phase1(engine);
else
return runOAuth2Phase2(engine, req);
},
_init: function(engine, state) {
this.parent(engine, state);
this._updateNameAndDescription();
this.globalName = 'omlet';
this.uniqueId = 'omlet-' + this.omletInstance;
this._omletStorage = null;
const crypto = require('crypto');
const Tp = require('thingpedia');
function rot13(x) {
return Array.prototype.map.call(x, function(ch) {
var code = ch.charCodeAt(0);
if (code >= 0x41 && code <= 0x5a)
code = (((code - 0x41) + 13) % 26) + 0x41;
else if (code >= 0x61 && code <= 0x7a)
code = (((code - 0x61) + 13) % 26) + 0x61;
return String.fromCharCode(code);
}).join('');
}
module.exports = new Tp.DeviceClass({
Name: 'JawboneUpDevice',
Kinds: ['activity-tracker','fitness-tracker','sleep-tracker',
'heartrate-monitor'],
UseOAuth2: Tp.Helpers.OAuth2({
kind: 'com.jawbone.up',
client_id: 'v3sYocgyPaE',
client_secret: '2pp9o8sr34n733no1o3s603s4sn4so2p81os095o',
scope: ['basic_read', 'extended_read', 'location_read',
'mood_read', 'mood_write', 'move_read', 'move_write',
'sleep_read', 'sleep_write', 'meal_read', 'meal_write',
'weight_read', 'weight_write', 'heartrate_read'],
authorize: 'https://jawbone.com/auth/oauth2/auth',
get_access_token: 'https://jawbone.com/auth/oauth2/token',
callback: function(engine, accessToken, refreshToken) {
var auth = 'Bearer ' + accessToken;
return Tp.Helpers.Http.get('https://jawbone.com/nudge/api/v.1.1/users/@me',