@nrfcloud/api-client-javascript
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -25,3 +25,3 @@ "use strict"; | ||
*/ | ||
constructor(token, endpoint = "https://hnmr2uba55.execute-api.us-east-1.amazonaws.com/prod") { | ||
constructor(token, endpoint = "https://hnmr2uba55.execute-api.us-east-1.amazonaws.com/dev") { | ||
this.token = token; | ||
@@ -28,0 +28,0 @@ this.endpoint = endpoint; |
{ | ||
"name": "@nrfcloud/api-client-javascript", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "JavaScript API client for the nRFCloud.com REST API", | ||
@@ -8,8 +8,9 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"pretest": "make dist", | ||
"test": "jest", | ||
"test:coverage": "npm run test -- --coverage && codeclimate-test-reporter < ./coverage/lcov.info", | ||
"commitmsg": "commitlint -e", | ||
"semantic-release": "semantic-release", | ||
"lint": "tslint --project ./tsconfig.json -e generated/**/*", | ||
"travis-deploy-once": "travis-deploy-once" | ||
"travis-deploy-once": "travis-deploy-once", | ||
"semantic-release": "semantic-release" | ||
}, | ||
@@ -32,17 +33,16 @@ "repository": { | ||
"devDependencies": { | ||
"@commitlint/cli": "^6.0.2", | ||
"@commitlint/config-angular": "^6.0.2", | ||
"@nrfcloud/api": "git+https://github.com/nRFCloud/api.git#v1.0.0-preview.1", | ||
"@nrfcloud/models": "^2.1.2", | ||
"@commitlint/cli": "^6.1.3", | ||
"@commitlint/config-angular": "^6.1.3", | ||
"@nrfcloud/models": "^2.1.3", | ||
"@nrfcloud/tslint-config": "^1.2.1", | ||
"@types/jest": "^22.1.0", | ||
"@types/jest": "^22.2.0", | ||
"codeclimate-test-reporter": "^0.5.0", | ||
"husky": "^0.14.3", | ||
"jest": "^22.1.4", | ||
"json-schema-to-typescript": "^5.3.2", | ||
"semantic-release": "^12.2.4", | ||
"travis-deploy-once": "^4.3.2", | ||
"ts-jest": "^22.0.1", | ||
"jest": "^22.4.2", | ||
"json-schema-to-typescript": "^5.3.3", | ||
"semantic-release": "^15.0.2", | ||
"travis-deploy-once": "^4.4.0", | ||
"ts-jest": "^22.4.1", | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.6.2" | ||
"typescript": "^2.7.2" | ||
}, | ||
@@ -62,3 +62,5 @@ "peerDependencies": { | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"@nrfcloud/api": "^1.0.0" | ||
}, | ||
"jest": { | ||
@@ -78,5 +80,7 @@ "moduleFileExtensions": [ | ||
"lcov" | ||
], | ||
"mapCoverage": true | ||
] | ||
}, | ||
"release": { | ||
"branch": "preview" | ||
} | ||
} |
# nRF Cloud JavaScript API Client | ||
[![npm preview version](https://img.shields.io/npm/v/@nrfcloud/api-client-javascript/preview.svg)](https://www.npmjs.com/package/@nrfcloud/api-client-javascript) | ||
[![Build Status](https://travis-ci.org/nRFCloud/api-client-javascript.svg?branch=master)](https://travis-ci.org/nRFCloud/api-client-javascript) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/7d5bd4bef1a93572dd3f/test_coverage)](https://codeclimate.com/github/nRFCloud/api-client-javascript/test_coverage) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/nrfcloud/api-client-javascript.svg)](https://greenkeeper.io/) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
[![Build Status](https://travis-ci.org/nRFCloud/api-client-javascript.svg?branch=master)](https://travis-ci.org/nRFCloud/api-client-javascript) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/nRFCloud/api-client-javascript.svg)](https://greenkeeper.io/) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
[![DeepScan Grade](https://deepscan.io/api/projects/1710/branches/7383/badge/grade.svg)](https://deepscan.io/dashboard/#view=project&pid=1710&bid=7383) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/nrfcloud/api-client-javascript/badge.svg)](https://snyk.io/test/github/nrfcloud/api-client-javascript) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/7d5bd4bef1a93572dd3f/maintainability)](https://codeclimate.com/github/nRFCloud/api-client-javascript/maintainability) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/7d5bd4bef1a93572dd3f/test_coverage)](https://codeclimate.com/github/nRFCloud/api-client-javascript/test_coverage) | ||
@@ -22,4 +21,8 @@ Provides the JavaScript API client for the [nRFCloud.com REST API](https://github.com/nRFCloud/api). | ||
npm i @nrfcloud/api-client-javascript | ||
npm i @nrfcloud/api-client-javascript@preview | ||
You also need to install the [updated models](https://github.com/nRFCloud/models). | ||
npm i @nrfcloud/models@next | ||
### Browser | ||
@@ -43,4 +46,4 @@ | ||
```javascript | ||
require('es6-promise').polyfill(); | ||
require('isomorphic-fetch'); | ||
require('es6-promise').polyfill() | ||
require('isomorphic-fetch') | ||
@@ -51,1 +54,43 @@ const {Client} = require('@nrfcloud/api-client-javascript') | ||
``` | ||
## Testing with the API client | ||
A testing API Gateway can provide an `/token` endpoint which returns a | ||
Cognito User Pool Identity Token so it is not required to use the AWS | ||
Cognito SDK. | ||
Example: | ||
npm i @nrfcloud/api-client-javascript@preview @nrfcloud/models@next isomorphic-fetch es6-promise | ||
```javascript | ||
require('es6-promise').polyfill(); | ||
require('isomorphic-fetch'); | ||
const { Client } = require('@nrfcloud/api-client-javascript'); | ||
const endpoint = 'https://1ewo2b2jmj.execute-api.us-east-1.amazonaws.com/dev'; | ||
const username = 'changeme'; // nrfcloud.com email | ||
const password = 'changeme'; | ||
(async () => { | ||
// This is an undocumented endpoint, which will only be on dev / test stages | ||
const res = await fetch(`${endpoint}/token`, { | ||
method: 'POST', | ||
body: JSON.stringify({ username, password }) | ||
}); | ||
const { token } = await res.json(); | ||
// Construct a client | ||
const client = new Client(token, endpoint); | ||
client | ||
.listTenants('true') | ||
.then(([{ id }]) => client.registerGateway(id)) | ||
.then(res => { | ||
console.log(res) | ||
}) | ||
.catch(err => { | ||
console.error(err) | ||
}) | ||
})(); | ||
``` |
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
25283
14
17
94
4
+ Added@nrfcloud/api@^1.0.0
+ Added@nrfcloud/api@1.0.0(transitive)