Comparing version 0.0.4 to 1.0.0
const data = require('./data'); | ||
const dateFormat = require('dateformat'); | ||
const session = require('./session'); | ||
const randomstring = require('randomstring'); | ||
@@ -11,22 +10,20 @@ // https://github.com/jeffreydwalter/arlo/blob/master/Arlo.py | ||
const timeout = ms => new Promise(res => setTimeout(res, ms)) | ||
const timeout = ms => new Promise(res => setTimeout(res, ms)); | ||
const arlo = { | ||
login: async(auth) => { | ||
let d = await data.post({ path: 'login/v2', body: auth}); | ||
login: async auth => { | ||
let d = await data.post({path: 'login/v2', body: auth}); | ||
userId = d.userId; | ||
session.set(d); | ||
}, | ||
logout: async() => { | ||
await data.put({ path: 'logout'}); | ||
logout: async () => { | ||
await data.put({path: 'logout'}); | ||
session.reset(); | ||
}, | ||
modes: { | ||
set: async(mode) => { | ||
let { | ||
deviceId, xCloudId | ||
} = await arlo.basestation.get(); | ||
set: async mode => { | ||
let {deviceId, xCloudId} = await arlo.basestation.get(); | ||
let headers = { | ||
xCloudId | ||
xCloudId, | ||
}; | ||
@@ -37,58 +34,64 @@ | ||
to: deviceId, | ||
action: "set", | ||
resource: "modes", | ||
action: 'set', | ||
resource: 'modes', | ||
publishResponse: true, | ||
properties: { | ||
active: mode | ||
} | ||
} | ||
active: mode, | ||
}, | ||
}; | ||
let ret = await data.post({ path: `users/devices/notify/${deviceId}`, body, headers }); | ||
let ret = await data.post({ | ||
path: `users/devices/notify/${deviceId}`, | ||
body, | ||
headers, | ||
}); | ||
var active = await arlo.modes.active(); | ||
while(active != mode) { | ||
while (active != mode) { | ||
await timeout(50); | ||
active = await arlo.modes.active(); | ||
} | ||
return ret; | ||
}, | ||
active: async() => { | ||
let automations = await data.get({ path: 'users/devices/automation/active'}); | ||
active: async () => { | ||
let automations = await data.get({ | ||
path: 'users/devices/automation/active', | ||
}); | ||
return automations[0].activeModes[0]; | ||
} | ||
}, | ||
}, | ||
devices: { | ||
get: async() => { | ||
return await data.get({ path: 'users/devices'}); | ||
} | ||
get: async () => { | ||
return await data.get({path: 'users/devices'}); | ||
}, | ||
}, | ||
basestation: { | ||
get: async() => { | ||
get: async () => { | ||
let devices = await arlo.devices.get(); | ||
return devices.filter(({deviceType}) => deviceType == 'basestation')[0]; | ||
} | ||
}, | ||
}, | ||
cameras: { | ||
get: async() => { | ||
get: async () => { | ||
let devices = await arlo.devices.get(); | ||
return devices.filter(({deviceType}) => deviceType == 'camera'); | ||
} | ||
}, | ||
}, | ||
recordings: { | ||
get: async({ from=new Date(), to=new Date()}={}) => { | ||
get: async ({from = new Date(), to = new Date()} = {}) => { | ||
const body = { | ||
dateFrom: dateFormat(from, 'yyyymmdd'), | ||
dateTo: dateFormat(to, 'yyyymmdd'), | ||
} | ||
return await data.post({ path: 'users/library', body }); | ||
}; | ||
return await data.post({path: 'users/library', body}); | ||
}, | ||
delete: async(recordings) => { | ||
delete: async recordings => { | ||
const body = { | ||
data: [].concat(recordings || []) | ||
data: [].concat(recordings || []), | ||
}; | ||
return await r2.post({ path: 'users/library/recycle', body }); | ||
return await r2.post({path: 'users/library/recycle', body}); | ||
}, | ||
}, | ||
} | ||
module.exports = arlo | ||
}; | ||
module.exports = arlo; |
//const r2 = require('r2'); | ||
const rp = require('request-promise'); | ||
const rp = require('request-promise-native'); | ||
const session = require('./session'); | ||
const request = async({ | ||
path, body, headers | ||
}, method) => { | ||
const request = async ({path, body, headers}, method) => { | ||
let options = { | ||
uri: `https://arlo.netgear.com/hmsweb/${path}`, | ||
method, | ||
headers: {...session.get(), ...headers | ||
}, | ||
headers: {...session.get(), ...headers}, | ||
body, | ||
json: true | ||
json: true, | ||
}; | ||
@@ -19,3 +16,3 @@ | ||
return resp.data; | ||
} | ||
}; | ||
@@ -31,5 +28,5 @@ const data = { | ||
return await request(opts, 'PUT'); | ||
} | ||
} | ||
}, | ||
}; | ||
module.exports = data | ||
module.exports = data; |
var config; | ||
const set = ({ token }) => { | ||
const set = ({token}) => { | ||
config = { | ||
DNT: "1", | ||
schemaVersion: "1", | ||
Host: "arlo.netgear.com", | ||
Referer: "https://arlo.netgear.com/", | ||
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Mobile/15B202 NETGEAR/v1 (iOS Vuezone)", | ||
"Content-Type": "application/json;charset=utf-8", | ||
Authorization: token | ||
} | ||
} | ||
DNT: '1', | ||
schemaVersion: '1', | ||
Host: 'arlo.netgear.com', | ||
Referer: 'https://arlo.netgear.com/', | ||
'User-Agent': | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Mobile/15B202 NETGEAR/v1 (iOS Vuezone)', | ||
'Content-Type': 'application/json;charset=utf-8', | ||
Authorization: token, | ||
}; | ||
}; | ||
const get = () => { | ||
return config; | ||
} | ||
}; | ||
const reset = () => { | ||
set({}); | ||
} | ||
}; | ||
@@ -26,4 +27,4 @@ const session = { | ||
get, | ||
reset | ||
} | ||
reset, | ||
}; | ||
@@ -30,0 +31,0 @@ reset(); |
{ | ||
"name": "arlo", | ||
"version": "0.0.4", | ||
"version": "1.0.0", | ||
"description": "modern, promise based library for interfacing with Arlo cameras", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha --timeout 60000" | ||
"test": "jest" | ||
}, | ||
@@ -13,10 +13,3 @@ "repository": { | ||
}, | ||
"keywords": [ | ||
"arlo", | ||
"iot", | ||
"async", | ||
"await", | ||
"promise", | ||
"camera" | ||
], | ||
"keywords": ["arlo", "iot", "async", "await", "promise", "camera"], | ||
"author": "Roy Lines <roy@roylines.co.uk> (https://github.com/roylines)", | ||
@@ -30,11 +23,8 @@ "license": "MIT", | ||
"dateformat": "3.0.3", | ||
"r2": "2.0.1", | ||
"randomstring": "1.1.5", | ||
"request": "2.88.0", | ||
"request-promise": "4.2.4" | ||
"request-promise-native": "1.0.8" | ||
}, | ||
"devDependencies": { | ||
"chai": "*", | ||
"mocha": "*" | ||
"jest": "25.1.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3
1
139
0
5635
+ Addedrequest-promise-native@1.0.8
+ Addedrequest-promise-core@1.1.3(transitive)
+ Addedrequest-promise-native@1.0.8(transitive)
- Removedr2@2.0.1
- Removedrandomstring@1.1.5
- Removedrequest-promise@4.2.4
- Removedarray-uniq@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedr2@2.0.1(transitive)
- Removedrandomstring@1.1.5(transitive)
- Removedrequest-promise@4.2.4(transitive)
- Removedrequest-promise-core@1.1.2(transitive)
- Removedtr46@0.0.3(transitive)
- Removedtypedarray-to-buffer@3.1.5(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)