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

rest-client-sdk

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-client-sdk - npm Package Compare versions

Comparing version 0.9.2 to 0.10.0

28

dist/TokenGenerator/ProvidedTokenGenerator.js

@@ -9,2 +9,6 @@ 'use strict';

var _urijs = require('urijs');
var _urijs2 = _interopRequireDefault(_urijs);
var _AbstractTokenGenerator = require('./AbstractTokenGenerator');

@@ -20,4 +24,5 @@

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* global fetch */
var ProvidedTokenGenerator = function (_AbstractTokenGenerat) {

@@ -27,2 +32,4 @@ _inherits(ProvidedTokenGenerator, _AbstractTokenGenerat);

function ProvidedTokenGenerator(token) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, ProvidedTokenGenerator);

@@ -34,2 +41,3 @@

_this.canAutogenerateToken = true;
_this._params = params;
return _this;

@@ -48,2 +56,20 @@ }

value: function refreshToken() {
if (this._params && this._params.refreshTokenUrl) {
var uri = new _urijs2.default(this._params.refreshTokenUrl);
var url = uri.toString();
return fetch(url, {
method: 'POST'
}).then(function (response) {
if (response.status !== 200) {
return response.json().then(function (responseData) {
return Promise.reject(responseData);
});
}
return response.json();
});
}
return this.generateToken();

@@ -50,0 +76,0 @@ }

2

package.json
{
"name": "rest-client-sdk",
"version": "0.9.2",
"version": "0.10.0",
"description": "Rest Client SDK for API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -0,1 +1,3 @@

/* global fetch */
import URI from 'urijs';
import AbstractTokenGenerator from './AbstractTokenGenerator';

@@ -5,6 +7,7 @@

constructor(token) {
constructor(token, params = {}) {
super();
this._token = token;
this.canAutogenerateToken = true;
this._params = params;
}

@@ -19,2 +22,21 @@

refreshToken() {
if (this._params && this._params.refreshTokenUrl) {
const uri = new URI(this._params.refreshTokenUrl);
const url = uri.toString();
return fetch(url, {
method: 'POST',
})
.then((response) => {
if (response.status !== 200) {
return response.json()
.then(responseData => Promise.reject(responseData));
}
return response.json();
})
;
}
return this.generateToken();

@@ -21,0 +43,0 @@ }

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