Comparing version 0.42.0 to 0.42.2-alpha.0
@@ -84,2 +84,3 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var auth_1 = __importDefault(require("@aws-amplify/auth")); | ||
var defaults = { | ||
@@ -913,16 +914,42 @@ apiURL: 'https://api.remot3.it/apv/v27', | ||
return __awaiter(this, void 0, void 0, function () { | ||
var currentSession, token, error_1; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, r3.axios | ||
.request({ | ||
url: url, | ||
method: method, | ||
data: data, | ||
headers: __assign({}, extraHeaders, utils_1.pickBy({ | ||
accessKey: r3.accessKey, | ||
apiKey: r3.apiKey, | ||
developerKey: r3.developerKey, | ||
token: r3.token, | ||
})), | ||
}) | ||
.then(r3.processData, r3.processError)]; | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, auth_1.default.currentSession()]; | ||
case 1: | ||
currentSession = _a.sent(); | ||
token = 'Bearer ' + currentSession.getAccessToken().getJwtToken(); | ||
return [2 /*return*/, r3.axios | ||
.request({ | ||
url: url, | ||
method: method, | ||
data: data, | ||
headers: __assign({}, extraHeaders, utils_1.pickBy({ | ||
Authorization: token, | ||
developerKey: r3.developerKey, | ||
})), | ||
}) | ||
.then(r3.processData, r3.processError)]; | ||
case 2: | ||
error_1 = _a.sent(); | ||
//console.error(error) | ||
//alert('ERROR: ' + error.message) | ||
//No AWS Auth, use legacy | ||
return [2 /*return*/, r3.axios | ||
.request({ | ||
url: url, | ||
method: method, | ||
data: data, | ||
headers: __assign({}, extraHeaders, utils_1.pickBy({ | ||
accessKey: r3.accessKey, | ||
apiKey: r3.apiKey, | ||
developerKey: r3.developerKey, | ||
token: r3.token, | ||
})), | ||
}) | ||
.then(r3.processData, r3.processError)]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -929,0 +956,0 @@ }); |
{ | ||
"name": "remote.it", | ||
"version": "0.42.0", | ||
"version": "0.42.2-alpha.0", | ||
"description": "remote.it JavaScript/node client library", | ||
@@ -21,3 +21,3 @@ "main": "lib/remote.it.js", | ||
"test": "jest", | ||
"watch-compile": "tsc -w", | ||
"watch-compile": "tsc -w --preserveWatchOutput", | ||
"watch-tests": "jest --watch" | ||
@@ -42,3 +42,3 @@ }, | ||
"path": "lib/*.js", | ||
"limit": "30 kB" | ||
"limit": "130 kB" | ||
} | ||
@@ -48,2 +48,3 @@ ], | ||
"dependencies": { | ||
"@aws-amplify/auth": "1.3.3", | ||
"axios": "0.18.0", | ||
@@ -53,3 +54,5 @@ "luxon": "1.13.2" | ||
"devDependencies": { | ||
"@types/jest": "24.0.18", | ||
"@types/jsdom": "12.2.4", | ||
"@types/luxon": "1.15.2", | ||
"eslint": "5.5.0", | ||
@@ -81,3 +84,4 @@ "eslint-config-standard": "12.0.0", | ||
}, | ||
"homepage": "https://github.com/remoteit/remote.it.js#readme" | ||
"homepage": "https://github.com/remoteit/remote.it.js#readme", | ||
"gitHead": "b9d89f622bdda332c8ec931c699f21377c4d49da" | ||
} |
import axios, { AxiosError, AxiosResponse } from 'axios' | ||
import { groupBy, parseLegacyDate, pickBy, toNumber } from './utils' | ||
import Auth from '@aws-amplify/auth' | ||
@@ -695,18 +696,42 @@ const defaults = { | ||
async request(method: string, url: string, data = {}, extraHeaders = {}) { | ||
return r3.axios | ||
.request({ | ||
url, | ||
method, | ||
data, | ||
headers: { | ||
...extraHeaders, | ||
...pickBy({ | ||
accessKey: r3.accessKey, | ||
apiKey: r3.apiKey, | ||
developerKey: r3.developerKey, | ||
token: r3.token, | ||
}), | ||
}, | ||
}) | ||
.then(r3.processData, r3.processError) | ||
try { | ||
let currentSession = await Auth.currentSession() | ||
let token = 'Bearer ' + currentSession.getAccessToken().getJwtToken() | ||
return r3.axios | ||
.request({ | ||
url, | ||
method, | ||
data, | ||
headers: { | ||
...extraHeaders, | ||
...pickBy({ | ||
Authorization: token, | ||
developerKey: r3.developerKey, | ||
}), | ||
}, | ||
}) | ||
.then(r3.processData, r3.processError) | ||
} catch (error) { | ||
//console.error(error) | ||
//alert('ERROR: ' + error.message) | ||
//No AWS Auth, use legacy | ||
return r3.axios | ||
.request({ | ||
url, | ||
method, | ||
data, | ||
headers: { | ||
...extraHeaders, | ||
...pickBy({ | ||
accessKey: r3.accessKey, | ||
apiKey: r3.apiKey, | ||
developerKey: r3.developerKey, | ||
token: r3.token, | ||
}), | ||
}, | ||
}) | ||
.then(r3.processData, r3.processError) | ||
} | ||
}, | ||
@@ -713,0 +738,0 @@ async get(url: string, data = {}) { |
Sorry, the diff of this file is not supported yet
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
206562
4159
3
21
+ Added@aws-amplify/auth@1.3.3
+ Added@aws-amplify/auth@1.3.3(transitive)
+ Added@aws-amplify/cache@1.2.3(transitive)
+ Added@aws-amplify/core@1.3.3(transitive)
+ Addedamazon-cognito-identity-js@3.3.3(transitive)
+ Addedaws-sdk@2.518.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@4.9.1(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcrypto-js@3.3.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedevents@1.1.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedieee754@1.1.8(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjmespath@0.15.0(transitive)
+ Addedjs-cookie@2.2.1(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedpunycode@1.3.21.4.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedquerystring@0.2.0(transitive)
+ Addedsax@1.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedurl@0.10.30.11.4(transitive)
+ Addeduuid@3.3.2(transitive)
+ Addedxml2js@0.4.19(transitive)
+ Addedxmlbuilder@9.0.7(transitive)