balena-register-device
Advanced tools
Comparing version 6.0.1 to 6.1.0-optional-user-id-9fbce4bec49a406c2d42a07bb870fa275e6f4f34
@@ -66,3 +66,3 @@ // Generated by CoffeeScript 1.12.7 | ||
* @param {Object} options - options | ||
* @param {Number} options.userId - user id | ||
* @param {Number} [options.userId] - user id | ||
* @param {Number} options.applicationId - application id | ||
@@ -91,3 +91,3 @@ * @param {String} options.uuid - device uuid | ||
var i, len, opt, ref; | ||
ref = ['userId', 'applicationId', 'uuid', 'deviceType', 'provisioningApiKey', 'apiEndpoint']; | ||
ref = ['applicationId', 'uuid', 'deviceType', 'provisioningApiKey', 'apiEndpoint']; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
@@ -94,0 +94,0 @@ opt = ref[i]; |
@@ -8,4 +8,9 @@ # Change Log | ||
## 6.0.1 - 2020-02-07 | ||
# v6.1.0 | ||
## (2020-04-17) | ||
* Make user id optional [Pagan Gazzard] | ||
## 6.0.1 - 2020-02-04 | ||
* GenerateUniqueKey: Reduce generated UUID size to 16 bytes. [James Harton] | ||
@@ -12,0 +17,0 @@ |
{ | ||
"name": "balena-register-device", | ||
"version": "6.0.1", | ||
"version": "6.1.0-optional-user-id-9fbce4bec49a406c2d42a07bb870fa275e6f4f34", | ||
"description": "Balena device registration utilities", | ||
@@ -25,3 +25,3 @@ "main": "build/register.js", | ||
"build": "gulp build", | ||
"lint": "resin-lint lib tests gulpfile.coffee", | ||
"lint": "balena-lint lib tests gulpfile.coffee", | ||
"test-node": "gulp test", | ||
@@ -35,2 +35,3 @@ "test-browser": "mockttp -c karma start", | ||
"devDependencies": { | ||
"@balena/lint": "^5.0.2", | ||
"balena-config-karma": "^2.3.1", | ||
@@ -41,3 +42,3 @@ "balena-request": "^10.0.0", | ||
"coffeescript": "~1.12.2", | ||
"gulp": "^3.8.10", | ||
"gulp": "^4.0.2", | ||
"gulp-coffee": "^2.3.0", | ||
@@ -50,7 +51,6 @@ "gulp-mocha": "^3.0.0", | ||
"mockttp": "^0.8.0", | ||
"resin-lint": "^2.0.0", | ||
"sinon": "^1.17.6" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.0.0", | ||
"bluebird": "^3.7.2", | ||
"randomstring": "^1.1.5" | ||
@@ -57,0 +57,0 @@ }, |
213
README.md
@@ -1,106 +0,107 @@ | ||
balena-register-device | ||
===================== | ||
> Balena device registration utilities. | ||
[](http://badge.fury.io/js/balena-register-device) | ||
[](https://david-dm.org/balena-io-modules/balena-register-device.svg) | ||
[](https://travis-ci.org/balena-io-modules/balena-register-device) | ||
[](https://ci.appveyor.com/project/resin-io/balena-register-device/branch/master) | ||
Installation | ||
------------ | ||
Install `balena-register-device` by running: | ||
```sh | ||
$ 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`](https://github.com/balena-io-modules/balena-request) instance. | ||
Example: | ||
```coffee | ||
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: | ||
```coffee | ||
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: | ||
```coffee | ||
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: | ||
```sh | ||
$ npm test | ||
``` | ||
Contribute | ||
---------- | ||
- Issue Tracker: [github.com/balena-io-modules/balena-register-device/issues](https://github.com/balena-io-modules/balena-register-device/issues) | ||
- Source Code: [github.com/balena-io-modules/balena-register-device](https://github.com/balena-io-modules/balena-register-device) | ||
Before submitting a PR, please make sure that you include tests, and that [coffeelint](http://www.coffeelint.org/) runs without any warning: | ||
```sh | ||
$ npm run lint | ||
``` | ||
Support | ||
------- | ||
If you're having any problem, please [raise an issue](https://github.com/balena-io-modules/balena-register-device/issues/new) on GitHub. | ||
License | ||
------- | ||
The project is licensed under the Apache 2.0 license. | ||
��b a l e n a - r e g i s t e r - d e v i c e | ||