Skip to content

Commit

Permalink
Release 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pgom committed Feb 21, 2020
1 parent 84f10f3 commit 1d01c81
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [v2.4.0](https://github.com/uphold/uphold-sdk-javascript/releases/tag/v2.4.0) (2020-02-21)
- Add scope and otp header to storage [\#30](https://github.com/uphold/uphold-sdk-javascript/pull/30) ([asoraiamartins](https://github.com/asoraiamartins))
- Update favicon and logo on `README` [\#27](https://github.com/uphold/uphold-sdk-javascript/pull/27) ([7patricia](https://github.com/7patricia))
- Fixing dependency vulnerabilities [\#26](https://github.com/uphold/uphold-sdk-javascript/pull/26) ([ryanml](https://github.com/ryanml))
- Update `babel-plugin-istanbul` to version 5.1.4 [\#24](https://github.com/uphold/uphold-sdk-javascript/pull/24) ([SandroMachado](https://github.com/SandroMachado))
- bump lodash.merge [\#25](https://github.com/uphold/uphold-sdk-javascript/pull/25) ([evq](https://github.com/evq))
- Update ESLint to version 6.0.1 [\#23](https://github.com/uphold/uphold-sdk-javascript/pull/23) ([SandroMachado](https://github.com/SandroMachado))
- Bump `Request` to version 2.88.0 [\#21](https://github.com/uphold/uphold-sdk-javascript/pull/21) ([SandroMachado](https://github.com/SandroMachado))
- Update travis node versions [\#22](https://github.com/uphold/uphold-sdk-javascript/pull/22) ([SandroMachado](https://github.com/SandroMachado))

## [v2.3.0](https://github.com/uphold/uphold-sdk-javascript/releases/tag/v2.3.0) (2018-05-22)
- Add origin to create card transaction [\#17](https://github.com/uphold/uphold-sdk-javascript/pull/17) ([pgom](https://github.com/pgom))

Expand Down
2 changes: 1 addition & 1 deletion dist/browser/uphold-sdk-javascript.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/core/errors/otp-required.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ exports.OTPRequiredError = undefined;

var _base = require('./base');

var _lodash = require('lodash');

class OTPRequiredError extends _base.BaseError {
static hasError() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
Expand All @@ -17,7 +19,7 @@ class OTPRequiredError extends _base.BaseError {
return false;
}

return headers['otp-token'].toUpperCase() === 'REQUIRED';
return (0, _lodash.includes)(['OPTIONAL', 'REQUIRED'], headers['otp-token'].toUpperCase());
}

constructor() {
Expand Down
16 changes: 13 additions & 3 deletions dist/core/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _services = require('./services');

var _utils = require('./utils');

var _lodash = require('lodash');

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

class SDK {
Expand All @@ -36,7 +38,9 @@ class SDK {
accessTokenKey: 'uphold.access_token',
baseUrl: 'https://api.uphold.com',
itemsPerPage: 10,
otpTokenStatus: 'uphold.otp_token_status',
refreshTokenKey: 'uphold.refresh_token',
scope: 'uphold.scope',
version: 'v0'
};

Expand Down Expand Up @@ -142,9 +146,14 @@ class SDK {
}

setToken(token) {
let headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

return this.storage.setItem(this.options.accessTokenKey, token.access_token).then(() => {
this.storage.setItem(this.options.scope, (0, _lodash.get)(token, 'scope', ''));
this.storage.setItem(this.options.otpTokenStatus, (0, _lodash.get)(headers, 'otp-token', ''));

if (token.refresh_token) {
return this.storage.setItem(this.options.refreshTokenKey, token.refresh_token);
this.storage.setItem(this.options.refreshTokenKey, token.refresh_token);
}
}).then(() => token);
}
Expand All @@ -155,8 +164,9 @@ class SDK {
url = _ref.url;

return this.client.request(url, 'post', body, headers).then((_ref2) => {
let body = _ref2.body;
return this.setToken(body);
let body = _ref2.body,
headers = _ref2.headers;
return this.setToken(body, headers);
});
}

Expand Down
2 changes: 1 addition & 1 deletion dist/core/utils/request-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function normalizeURI(uri) {

function buildUrl(uri, baseUrl, version, queryParams) {
// Check if the `uri` is actually an url.
if (new RegExp(/^http(s?)\:\/\//).test(uri)) {
if (new RegExp(/^http(s?):\/\//).test(uri)) {
return uri;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uphold/uphold-sdk-javascript",
"version": "2.3.0",
"version": "2.4.0",
"description": "Uphold SDK for JavasScript",
"keywords": [
"api",
Expand Down

0 comments on commit 1d01c81

Please sign in to comment.