Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blink-data

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blink-data

Interact with blink camera servers in javascript

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Interact with blink camera servers in javascript

This will allow you to interact with blink cameras. You can use it in node, electron, or a browser (with CORS security disabled.)

install

npm i blink-data

usage

basics

import { Blink } from 'blink-data'

async function run () {
  const blink = new Blink()
  await blink.login('me@demo.com', 'mypassword')

  // get current user-info
  const user = await blink.user()
  console.log(user)

  // get list of current user's networks
  const networks = await blink.networks()
  console.log(networks)

  // get details about a network
  const network = await blink.network(networks[0].id)
  console.log(network)

  // get a list of videos
  const videos = await blink.videos()
  console.log(videos)

  // get details about a camera
  const camera = await blink.camera(networks[0].network_id, networks[0].cameras[0].id)
  console.log(camera)
}

run()

I haven't setup API-docs yet, but you can see usage examples iun the unit-test.

browser

You will need to disable CORS security for this to work directly from blink servers, in a browser:

Close all instances of Chrome browser (open taskmanager and kill any resilient Chrome process). Execute

Windows

C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --disable-web-security --user-data-dir=<path to viewer>. 

MacOS

open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir=<path to viewer>

You can also do this in your own electron app:

const win = new BrowserWindow({
  webPreferences: { webSecurity: false }
})

Alternatively, if you want to do it all in IPC-space, you can:

const Blink = require('electron').remote.require('blink-data')

And CORS-security should be disabled for just blink.

rehydrate

If you are using this on a webserver, or just want to login via a token (instead of email/password), you can rehydrate them to work with their session:

const blink = new Blink()
blink.hydrate (token, account, region)
blink.user().then(console.log)

You can get token, account, and region from the output of blink.login(), so store this, and send it via a cookie/session/header.

Here is a client-side example using localStorage:

// at login time
const blink = new Blink()
const { authtoken, account, region } = await blink.login(email, password)
localStorage.user = JSON.stringify({ token: authtoken.authtoken, id: account.id, region: Object.keys(region)[0] })

// later
const blink = new Blink()
const { token, id, region } = JSON.parse(localStorage.user)
blink.hydrate(token, id, region)
blink.user().then(console.log)

TODO

  • Still need to do support programs
  • There are a lot of other API endpoints to wrap
  • need to use commandPolling to check for things finishing, maybe make a nice fancy event-pipe
  • need to work out video proxy for rtsps://. this should help.
  • Here is my desktop-client, using electron.

credit

Big shout-out to MattTW's BlinkMonitorProtocol. This is totally generated from that. bling-viewer is also great, and helped work out some parts.

Keywords

FAQs

Package last updated on 08 Dec 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc