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

keymetrics-api

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keymetrics-api - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

.travis.yml

15

lib/Authenticate.js

@@ -48,3 +48,3 @@ 'use strict';

cb = token;
token = this.refresh_token || '';
token = this.token || '';
}

@@ -80,6 +80,6 @@

// if the user did input a refresh token
if (opts.token_type === 'refresh_token')
this.refresh(opts.refresh_token, function (err, data) {
if (opts.token)
this.refresh(opts.token, function (err, data) {
if (err) {
self.bus.emit('error:auth', { msg: 'Refeshing token failed, maybe invalid/revoked refresh_token ?', err: err });
self.bus.emit('error:auth', { msg: 'Refeshing token failed, maybe invalid/revoked token ?', err: err });
return cb(err);

@@ -93,4 +93,4 @@ }

// if the user did input an access_token
else if (opts.token_type === 'access_token') {
var data = { access_token: opts.access_token, refresh_token: '', token_type: opts.token_type }
else if (opts.access_token) {
var data = { access_token: opts.access_token, token: '', token_type: 'access_token' }
self.bus.emit('auth:ready', data);

@@ -119,3 +119,2 @@ return cb(null, data)

.post(this.root_url + '/oauth/revoke')
.send('access_token=' + this.access_token + '&refresh_token=' + this.refresh_token + '&client_id=' + this.client_id)
.set("Content-Type", "application/x-www-form-urlencoded")

@@ -126,3 +125,3 @@ .end(function (err, res) {

self.bus.emit("user:logged_out");
self.refresh_token = null;
self.token = null;
self.access_token = null;

@@ -129,0 +128,0 @@ self.type = null;

@@ -48,7 +48,2 @@ 'use strict';

this.bus.on('bucket:active', function (id) {
self._id = id;
self.URL = self.root_url + '/bucket/' + id;
});
this.bus.on('auth:ready', function (data) {

@@ -104,3 +99,3 @@ // update Authorization header

self._id = self.current_raw._id;
self.URL = self.root_url + '/bucket/' + self.current_raw._id;
self.URL = self.current_raw.node_cache.endpoints.web + '/api/bucket/' + self.current_raw._id;
return cb(null, self.current_raw);

@@ -124,3 +119,3 @@ }

if (err) return self.bus.emit('error:bucket', err);
self.bus.emit("bucket:active", self.current_raw._id);
self.bus.emit("bucket:active", { id: self.current_raw._id, endpoint: self.current_raw.node_cache.endpoints.web });
});

@@ -145,3 +140,3 @@ },

self._id = self.current_raw._id;
self.URL = self.root_url + '/bucket/' + self.current_raw._id;
self.URL = self.current_raw.node_cache.endpoints.web + '/api/bucket/' + self.current_raw._id;
return cb(null, res.body);

@@ -161,3 +156,3 @@ });

self.bus.emit("bucket:active", bucket._id);
self.bus.emit("bucket:active", { id: self.current_raw._id, endpoint: self.current_raw.node_cache.endpoints.web });
});

@@ -164,0 +159,0 @@ },

@@ -59,3 +59,2 @@ 'use strict';

/**

@@ -68,6 +67,10 @@ * Start the Keymetrics connection

Keymetrics.prototype.init = function (cb) {
Keymetrics.prototype.init = function (public_key, cb) {
var self = this;
var cb = cb || function(){};
if (typeof (public_key) === 'function') {
cb = public_key;
public_key = this.options.public_key || '';
}
this.auth.init(this.options, function(err, res) {

@@ -77,7 +80,7 @@ if (err) return cb(err);

//If public key already setup
if (self.options.public_key) {
self.bucket.retrieve(self.options.public_key, function(err, res) {
if (public_key) {
self.bucket.retrieve(public_key, function(err, res) {
if (err) return cb(err);
self.bus.emit("bucket:active", res._id);
self.bus.emit("bucket:active", { id: res._id, endpoint: res.node_cache.endpoints.web });
//If realtime is to be launched at start

@@ -84,0 +87,0 @@ if (self.options.realtime)

@@ -20,5 +20,6 @@ 'use strict';

this.bus.on('bucket:active', function(id) {
self._id = id;
self.URL = self.root_url + '/bucket/' + id;
this.bus.on('bucket:active', function(data) {
self._id = data.id;
self.root_url = data.endpoint + '/api';
self.URL = self.root_url + '/bucket/' + data.id;
});

@@ -25,0 +26,0 @@ this.bus.on('auth:ready', function(data) {

@@ -20,5 +20,6 @@ 'use strict';

this.bus.on('bucket:active', function(id) {
self._id = id;
self.URL = self.root_url + '/bucket/' + id;
this.bus.on('bucket:active', function(data) {
self._id = data.id;
self.root_url = data.endpoint + '/api';
self.URL = self.root_url + '/bucket/' + data.id;
});

@@ -25,0 +26,0 @@ this.bus.on('auth:ready', function(data) {

@@ -20,5 +20,6 @@ 'use strict';

this.bus.on('bucket:active', function(id) {
self._id = id;
self.URL = self.root_url + '/bucket/' + id;
this.bus.on('bucket:active', function(data) {
self._id = data.id;
self.root_url = data.endpoint + '/api';
self.URL = self.root_url + '/bucket/' + data.id;
});

@@ -25,0 +26,0 @@ this.bus.on('auth:ready', function(data) {

@@ -21,5 +21,6 @@ 'use strict';

this.bus.on('bucket:active', function(id) {
self._id = id;
self.URL = self.root_url + '/bucket/' + id;
this.bus.on('bucket:active', function(data) {
self._id = data.id;
self.root_url = data.endpoint + '/api';
self.URL = self.root_url + '/bucket/' + data.id;
});

@@ -26,0 +27,0 @@ this.bus.on('auth:ready', function(data) {

@@ -26,4 +26,4 @@ 'use strict';

this.bus.on('bucket:active', function (id) {
self.bucket_id = id;
this.bus.on('bucket:active', function (data) {
self.bucket_id = data.id;
});

@@ -30,0 +30,0 @@

{
"name": "keymetrics-api",
"version": "1.1.0",
"version": "1.1.1",
"description": "Keymetrics API Wrapper",
"main": "lib/keymetrics.js",
"main": "index.js",
"scripts": {

@@ -7,0 +7,0 @@ "test": "mocha test/keymetrics.mocha.js"

# Keymetrics API Wrapper
<a href="https://travis-ci.org/keymetrics/keymetrics-api">
<img src="https://travis-ci.org/keymetrics/keymetrics-api.svg?branch=master" alt="Build Status"/>
</a>
This module lets you implement a fully customizable Keymetrics client, receiving live data from the Keymetrics API.

@@ -11,6 +15,20 @@

## Basic use - callbacks
## Install
With NPM:
```bash
$ npm install keymetrics-api --save
```
With YARN:
```bash
$ yarn add keymetrics-api
```
## Usage example
```javascript
var Keymetrics = require('../lib/keymetrics');
var Keymetrics = require('keymetrics-api');

@@ -124,1 +142,5 @@ var km = new Keymetrics({

`DEBUG=*` allows verbose mode for received realtime data.
## License
Apache 2.0

Sorry, the diff of this file is not supported yet

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