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

balena-register-device

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-register-device

Balena device registration utilities

  • 6.0.0-36-rename-to-balena-dfbfe2c2b12bd2a54543d10c177c354acdf66fe6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.3K
increased by14.03%
Maintainers
1
Weekly downloads
 
Created
Source

balena-register-device

Balena device registration utilities.

npm version dependencies Build Status Build status

Installation

Install balena-register-device by running:

$ npm install --save balena-register-device

Documentation

Balena-Register-Device exports a factory function, which must be called with a dependencies object, containing a configured balena-request instance.

Example:

deviceRegister = require('balena-register-device')({
	request: request # An instantiated balena-request instance
})

deviceRegister.generateUniqueKey()

Generate a random key, useful for both uuid and api key.

Example:

randomKey = deviceRegister.generateUniqueKey()
# randomKey is a randomly generated key that can be used as either a uuid or an api key
console.log(randomKey)

deviceRegister.register(Object options, Function callback)

Register a device with Balena.

Notice: You can use this function as a promise if you omit the callback argument.

The options object requires the following properties:

  • Number userId: The user id.
  • Number applicationId: The application id.
  • String uuid: The device's UUID.
  • String deviceType: The device type slug.
  • String deviceApiKey: The API key to create for the newly registered device.
  • String provisioningApiKey: The provisioning API Key.
  • String apiEndpoint: The API endpoint.

The callback gets called with two arguments: (error, deviceInfo), where deviceInfo is an object containing one property: the id for the device that was just registered.

Example:

deviceRegister.register
		userId: 199
		applicationId: 10350
		uuid: '...'
		deviceType: 'raspberry-pi'
		deviceApiKey: '...'
		provisioningApiKey: '...'
		apiEndpoint: 'https://api.balena-cloud.com'
	, (error, deviceInfo) ->
		throw error if error?
		console.log(deviceInfo) # { id }

Tests

Run the test suite by doing:

$ npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ npm run lint

Support

If you're having any problem, please raise an issue on GitHub.

License

The project is licensed under the Apache 2.0 license.

Keywords

FAQs

Package last updated on 11 Apr 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